Slimstat Analytics - Version 4.7.4.1

Version Description

  • [Update] The Browscap data file is now loaded only when needed, thus removing its inherent overhead when unnecessary.
  • [Update] The Browscap data file has been updated to the latest version available on their repository (ver 6026).
  • [Fix] Addressed a remote XSS Vulnerability responsibly disclosed by one of our customers. Thank you, riscybusiness.
  • [Fix] Reintroduced the WHOIS pin, which has been removed by mistake because of a regression bug. Thank you, brachialis.
Download this release

Release Info

Developer coolmann
Plugin Icon 128x128 Slimstat Analytics
Version 4.7.4.1
Comparing to
See all releases

Code changes from version 4.7.4 to 4.7.4.1

admin/js/amcharts/plugins/export/README.md ADDED
@@ -0,0 +1,1412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # amCharts Export
2
+
3
+ Version: 1.4.74
4
+
5
+
6
+ ## Description
7
+
8
+ This plugin adds export capabilities to all amCharts products - charts and maps.
9
+
10
+ It allows annotating and exporting chart or related data to various bitmap,
11
+ vector, document or data formats, such as PNG, JPG, PDF, SVG, JSON, XLSX and
12
+ many more.
13
+
14
+
15
+ ## Important notice
16
+
17
+ Please note that due to security measures implemented in modern browsers, some
18
+ or all export options might not work if the web page is loaded locally (via
19
+ file:///) or contain images loaded from different host than the web page itself.
20
+
21
+
22
+ ## Usage
23
+
24
+ ### 1) Include the minified version of file of this plugin as well as the
25
+ bundled CSS file. I.e.:
26
+
27
+ ```
28
+ <script src="amcharts/plugins/export/export.min.js"></script>
29
+ <link type="text/css" href="amcharts/plugins/export/export.css" rel="stylesheet">
30
+ ```
31
+
32
+ Or if you'd rather use amCharts CDN:
33
+
34
+ ```
35
+ <script src="//cdn.amcharts.com/lib/3/plugins/export/export.min.js"></script>
36
+ <link type="text/css" href="//cdn.amcharts.com/lib/3/plugins/export/export.css" rel="stylesheet">
37
+ ```
38
+
39
+ (this needs to go after all the other amCharts includes)
40
+
41
+ ### 2) Enable `export` with default options:
42
+
43
+ ```
44
+ AmCharts.makeChart( "chartdiv", {
45
+ ...,
46
+ "export": {
47
+ "enabled": true
48
+ }
49
+ } );
50
+ ```
51
+
52
+ ### ... OR set your own custom options:
53
+
54
+ ```
55
+ AmCharts.makeChart( "chartdiv", {
56
+ ...,
57
+ "export": {
58
+ "enabled": true,
59
+ "menu": [ {
60
+ "class": "export-main",
61
+ "menu": [ {
62
+ "label": "Download",
63
+ "menu": [ "PNG", "JPG", "CSV" ]
64
+ }, {
65
+ "label": "Annotate",
66
+ "action": "draw",
67
+ "menu": [ {
68
+ "class": "export-drawing",
69
+ "menu": [ "PNG", "JPG" ]
70
+ } ]
71
+ } ]
72
+ } ]
73
+ }
74
+ } );
75
+ ```
76
+
77
+
78
+ ## Loading external libraries needed for operation of this plugin
79
+
80
+ The plugin relies on a number of different libraries, to export images, draw
81
+ annotations or generate download files.
82
+
83
+ Those libraries need to be loaded for the plugin to work properly.
84
+
85
+ There are two ways to load them. Choose the one that is right:
86
+
87
+ ### 1) Automatic (preferred)
88
+
89
+ All libraries required for plugin operation are included withing plugins */libs*
90
+ subdirectory.
91
+
92
+ The plugin will automatically try to look in chart's [`path`](http://docs.amcharts.com/3/javascriptcharts/AmSerialChart#path)
93
+ property. If your plugin files are located within plugins folder under amcharts
94
+ (as is the case with the default distributions), you don't need to do anything -
95
+ the libraries will load on-demand.
96
+
97
+ If you are using relative url, note that it is relative to the web page you are
98
+ displaying your chart on, not the export.js library.
99
+
100
+ In case you've moved the libs folder you need to tell the plugin where it is
101
+ `"libs": { "path": "../libs/" }`
102
+
103
+ ### 2) Manual
104
+
105
+ You can also load all those JavaScript libraries by `<script>` tags. Since
106
+ loading of libraries is on by default you will need to turn it off by setting
107
+ `"libs": { "autoLoad": false }`
108
+
109
+ Here is a full list of the files that need to be loaded for each operation:
110
+
111
+ File | Located in | Required for
112
+ ---- | ---------- | ------------
113
+ fabric.min.js | libs/fabric.js/ | Any export operation
114
+ FileSaver.js | libs/FileSaver.js/ | Used to offer download files
115
+ pdfmake.min.js | libs/pdfmake/ | Export to PDF format
116
+ vfs_fonts.js | libs/pdfmake/ | Export to PDF format
117
+ jszip.js | libs/jszip/ | Export to XLSX format
118
+ xlsx.js | libs/xlsx/ | Export to XLSX format
119
+
120
+
121
+ ## Complete list of available export settings
122
+
123
+ Property | Default | Description
124
+ -------- | ------- | -----------
125
+ backgroundColor | #FFFFFF | RGB code of the color for the background of the exported image
126
+ enabled | true | Enables or disables export functionality
127
+ divId | | ID or a reference to div object in case you want the menu in a separate container.
128
+ fabric | {} | Overwrites the default drawing settings (fabricJS library)
129
+ fallback | {} | Holds the messages to guide the user to copy the generated output; `false` will disable the fallback feature
130
+ fileName | amCharts | A file name to use for generated export files (an extension will be appended to it based on the export format)
131
+ legend | {} | Places the legend in case it is within an external container ([skip to chapter](#adding-external-legend))
132
+ libs | | 3rd party required library settings (see the above section)
133
+ menu | [] | A list of menu or submenu items (see the next chapter for details)
134
+ pdfMake | {} | Overwrites the default settings for PDF export (pdfMake library)
135
+ position | top-right | A position of export icon. Possible values: "top-left", "top-right" (default), "bottom-left", "bottom-right"
136
+ removeImages | true | If true export checks for and removes "tainted" images that area lodead from different domains
137
+ delay | | General setting to delay the capturing of the chart ([skip to chapter](#delay-the-capturing-before-export))
138
+ exportFields | [] | If set, only fields in this array will be exported ( data export only )
139
+ exportTitles | false | Exchanges the data field names with it's dedicated title ( data export only )
140
+ columnNames | {} | An object of key/value pairs to use as column names when exporting to data formats. `exportTitles` needs to be set for this to work as well.
141
+ exportSelection | false | Exports the current data selection only ( data export only )
142
+ dataDateFormat | | Format to convert date strings to date objects, uses by default charts dataDateFormat ( data export only )
143
+ dateFormat | YYYY-MM-DD | Formats the category field in given date format ( data export only )
144
+ keyListener | false | If true it observes the pressed keys to undo/redo the annotations
145
+ fileListener | false | If true it observes the drag and drop feature and loads the dropped image file into the annotation
146
+ drawing | {} | Object which holds all possible settings for the annotation mode ([skip to chapter](#annotation-settings))
147
+ overflow | true | Flag to overwrite the css attribute 'overflow' of the chart container to avoid cropping the menu on small container
148
+ border | {} | An object of key/value pairs to define the overlaying border
149
+ processData | | A function which can be used to change the dataProvider when exporting to CSV, XLSX, or JSON
150
+ pageOrigin | true | A flag to show / hide the origin of the generated PDF ( pdf export only )
151
+ forceRemoveImages | false | If true export removes all images
152
+ debug | false | A flag which enables the plugin to write console logs (currently used by the dependency handler only).
153
+
154
+
155
+ ## Configuring export menu
156
+
157
+ Plugin includes a way to completely control what is displayed on export menu.
158
+ You can set up menus, sub-menus, down to any level. You can even add custom
159
+ items there that execute your arbitrary code on click. It's so configurable
160
+ it makes us sick with power ;)
161
+
162
+ The top-level menu is configured via `menu` property under `export`. It should
163
+ always be an array, even if you have a single item in it.
164
+
165
+ The array items could be either objects or format codes. Objects will allow you
166
+ to specify labels, action, icon, child items and even custom code to be executed
167
+ on click.
168
+
169
+ Simple format codes will assume you need an export to that format.
170
+
171
+ ### Simple menu setup
172
+
173
+ Here's a sample of the simple menu setup that allows export to PNG, JPG and CSV:
174
+
175
+ ```
176
+ "export": {
177
+ "enabled": true,
178
+ "menu": [ {
179
+ "class": "export-main",
180
+ "menu": [ "PNG", "JPG", "CSV" ]
181
+ } ]
182
+ }
183
+ ```
184
+
185
+ The above will display a menu out of three options when you hover on export
186
+ icon:
187
+
188
+ * PNG
189
+ * JPG
190
+ * CSV
191
+
192
+ When clicked the plugin will trigger export to a respective format.
193
+
194
+ If that is all you need, you're all set.
195
+
196
+ Please note that we have wrapped out menu into another menu item, so that only
197
+ the icon is displayed until we roll over the icon. This means that technically
198
+ we have a two-level hierarchical menu.
199
+
200
+ If we opmitted that first step, the chart would simply display a format list
201
+ right there on the chart.
202
+
203
+ ### Advanced menu setup
204
+
205
+ However, you can do so much more with the menu.
206
+
207
+ Let's add more formats and organize image and data formats into separate
208
+ submenus.
209
+
210
+ To add a submenu to a menu item, simply add a `menu` array as its own property:
211
+
212
+ ```
213
+ "export": {
214
+ "enabled": true,
215
+ "menu": [ {
216
+ "class": "export-main",
217
+ "menu": [ {
218
+ "label": "Download as image",
219
+ "menu": [ "PNG", "JPG", "SVG" ]
220
+ }, {
221
+ "label": "Download data",
222
+ "menu": [ "CSV", "XLSX" ]
223
+ } ]
224
+ } ]
225
+ }
226
+ ```
227
+
228
+ Now we have a hierarchical menu with the following topology:
229
+
230
+ * Download as image
231
+ * PNG
232
+ * JPG
233
+ * SVG
234
+ * Download data
235
+ * CSV
236
+ * XLSX
237
+
238
+ We can mix "string" and "object" formats the way we see fit, i.e.:
239
+
240
+ ```
241
+ "export": {
242
+ "menu": [
243
+ "PNG",
244
+ { "label": "JPEG",
245
+ "format": "JPG" },
246
+ "SVG"
247
+ ]
248
+ }
249
+ ```
250
+
251
+ The magic does not end here, though.
252
+
253
+ ### Adding custom click events to menu items
254
+
255
+ Just like we set `label` and `format` properties for menu item, we can set
256
+ `click` as well.
257
+
258
+ This needs to be a function reference. I.e.:
259
+
260
+ ```
261
+ "export": {
262
+ "menu": [
263
+ "PNG",
264
+ { "label": "JPEG",
265
+ "click": function () {
266
+ alert( "Clicked JPEG. Wow cool!" );
267
+ } },
268
+ "SVG"
269
+ ]
270
+ }
271
+ ```
272
+
273
+ ### Adding external legend
274
+
275
+ In case you have an external legend you need to define the position where it should get placed in your export.
276
+ By default it obtains the dimensions from the container but you can optionally overwrite those settings as shown below.
277
+
278
+ ```
279
+ "export": {
280
+ "legend": {
281
+ "position": "top", // or "right", "bottom" and "left" are possible
282
+ "width": 200, // optional
283
+ "height": 200 // optional
284
+ }
285
+ }
286
+ ```
287
+
288
+ ### Changing the dataProvider when exporting
289
+
290
+ If you want to change the dataProvider when exporting to CSV, XLSX, or JSON, you can use the `processData` option:
291
+
292
+ ```
293
+ "export": {
294
+ "processData": function (data, cfg) {
295
+ return data.slice(1, -1);
296
+ }
297
+ }
298
+ ```
299
+
300
+ ### Adding overlaying border
301
+
302
+ In case you need a more visible separation of your chart for further processing you can add an overlaying border.
303
+
304
+ ```
305
+ "export": {
306
+ "border": {
307
+ "stroke": "#000000", // HEX-CODE to define the border color
308
+ "strokeWidth": 1, // number which represents the width in pixel
309
+ "strokeOpacity": 1 // number which controls the opacity from 0 - 1
310
+ }
311
+ }
312
+ ```
313
+
314
+ ### Menu item reviver
315
+
316
+ By passing the `menuReviver` callback function you can modify the resulting menu
317
+ item or relative container, before it gets appended to the list (`ul`). The
318
+ function takes two arguments and it needs to return a valid DOM element.
319
+
320
+ ```
321
+ "export": {
322
+ "menuReviver": function(item,li) {
323
+ li.setAttribute("class","something special");
324
+ return li;
325
+ }
326
+ }
327
+ ```
328
+
329
+ #### Format specific options that you can override using Menu item reviver
330
+
331
+ Some formats, such as CSV, have specific parameters that are used when exporting to this format. For example, default column separator for CSV is a comma. But what if you would like to be that a tab? You could use `menuReviver` for that like this:
332
+
333
+ ```
334
+ "export": {
335
+ "enabled": true,
336
+ "menuReviver": function(cfg,li) {
337
+ if ( cfg.format == "CSV" ) {
338
+ cfg.delimiter = "\t";
339
+ }
340
+ return li;
341
+ }
342
+ }
343
+ ```
344
+
345
+ Below you will find a list of parameters that you can override for each format:
346
+
347
+ **JPG**
348
+
349
+ Property | Default | Available values | Description
350
+ --------- | ------- | ---------------- | -----------
351
+ quality |1 | 0-1 | A quality of the resulting JPG image
352
+ multiplier | 1 | number | Set this to non-1 number to resize the resulting image by
353
+
354
+ **PNG**
355
+
356
+ Property | Default | Available values | Description
357
+ --------- | ------- | ---------------- | -----------
358
+ quality | 1 | 0-1 | A quality of the resulting JPG image
359
+ multiplier | 1 | number | Set this to non-1 number to resize the resulting image by
360
+
361
+ **PDF**
362
+
363
+ Property | Default | Available values | Description
364
+ --------- | ------- | ---------------- | -----------
365
+ multiplier | 2 | number | Set this to non-1 number to resize the resulting image by
366
+
367
+ **PRINT**
368
+
369
+ Property | Default | Available values | Description
370
+ --------- | ------- | ---------------- | -----------
371
+ delay | 1 | number | Delay by number of seconds before triggering print
372
+ lossless | false | true/false | Enable or disable image optimization when printing
373
+
374
+ **CSV**
375
+
376
+ Property | Default | Available values | Description
377
+ --------- | ------- | ---------------- | -----------
378
+ delimiter | "," | string | A string to use as a column delimiter
379
+ quotes | true | true/false | Set whether to enclose strings in doublequotes
380
+ escape | true | true/false | Set whether to escape strings
381
+ withHeader | true | true/false | Add header row with column names
382
+
383
+ **XLSX**
384
+
385
+ Property | Default | Available values | Description
386
+ --------- | ------- | ---------------- | -----------
387
+ dateFormat | "dateObject" | "dateObject"\|"string" | Whether to export dates as dates recognisable by Excel or formatted as strings
388
+ withHeader | true | true/false | Add header row with column names
389
+ stringify | false | true/false | Convert all cell content to strings
390
+
391
+
392
+ ### Menu walker
393
+
394
+ In case you don't like our structure, go ahead and write your own recursive
395
+ function to create the menu by the given list configured through `menu`.
396
+
397
+ ```
398
+ "export": {
399
+ "menuWalker": function(list,container) {
400
+ // some magic to generate the nested lists using the given list
401
+ }
402
+ }
403
+ ```
404
+
405
+ ### Printing the chart
406
+
407
+ Adding menu item to print the chart or map is as easy as adding export ones. You
408
+ just use "PRINT" as `format`. I.e.:
409
+
410
+ ```
411
+ "export": {
412
+ "menu": [
413
+ "PNG",
414
+ "SVG",
415
+ "PRINT"
416
+ ]
417
+ }
418
+ ```
419
+
420
+ Or if you want to change the label:
421
+
422
+ ```
423
+ "export": {
424
+ "menu": [
425
+ "PNG",
426
+ "SVG",
427
+ {
428
+ "format": "PRINT",
429
+ "label": "Print Chart"
430
+ }
431
+ ]
432
+ }
433
+ ```
434
+
435
+ ### Annotating the chart before export
436
+
437
+ OK, this one is so cool, you'll need a class 700 insulation jacket.
438
+
439
+ By default each menu item triggers some kind of export. You can trigger an
440
+ "annotation" mode instead by including `"action": "draw"` instead.
441
+
442
+ ```
443
+ "export": {
444
+ "menu": [ {
445
+ "class": "export-main",
446
+ "menu": [ {
447
+ "label": "Download",
448
+ "menu": [ "PNG", "JPG", "CSV", "XLSX" ]
449
+ }, {
450
+ "label": "Annotate",
451
+ "action": "draw"
452
+ } ]
453
+ } ]
454
+ }
455
+ ```
456
+
457
+ Now, when you click on the "Annotate" item in the menu, the chart will turn into
458
+ an image editor which you can actual draw on and the menu gets replaced by the
459
+ default annotation menu.
460
+
461
+ If you don't like the detault annotation menu, you can define your own:
462
+
463
+ ```
464
+ "export": {
465
+ "menu": [ {
466
+ "class": "export-main",
467
+ "menu": [ {
468
+ "label": "Download",
469
+ "menu": [ "PNG", "JPG", "CSV", "XLSX" ]
470
+ }, {
471
+ "label": "Annotate",
472
+ "action": "draw",
473
+ "menu": [ {
474
+ "class": "export-drawing",
475
+ "menu": [ "JPG", "PNG", "SVG", "PDF" ]
476
+ } ]
477
+ } ]
478
+ } ]
479
+ }
480
+ ```
481
+
482
+ Now, when you turn on the annotation mode, your own submenu will display,
483
+ allowing to export the image into either PNG, JPG, SVG or PDF.
484
+
485
+ And that's not even the end of it. You can add menu items to cancel, undo, redo
486
+ and still be able to reuse the choices by using the actions `draw.modes`,
487
+ `draw.widths`, `draw.colors` or `draw.shapes`.
488
+
489
+ ```
490
+ "export": {
491
+ "menu": [ {
492
+ "class": "export-main",
493
+ "menu": [ {
494
+ "label": "Download",
495
+ "menu": [ "PNG", "JPG", "CSV", "XLSX" ]
496
+ }, {
497
+ "label": "Annotate",
498
+ "action": "draw",
499
+ "menu": [ {
500
+ "class": "export-drawing",
501
+ "menu": [ {
502
+ label: "Size ...",
503
+ action: "draw.widths",
504
+ widths: [ 5, 20, 30 ] // replaces the default choice
505
+ }, {
506
+ "label": "Edit",
507
+ "menu": [ "UNDO", "REDO", "CANCEL" ]
508
+ }, {
509
+ "label": "Save",
510
+ "format": "PNG"
511
+ } ]
512
+ } ]
513
+ } ]
514
+ } ]
515
+ }
516
+ ```
517
+
518
+ ### Annotation settings
519
+
520
+ Since 1.2.1 it's also possible to set some of the annotation options without the
521
+ need to re-define the whole menu structure. You can easily adjust the choice of
522
+ modes, colors, widths or shapes, and set the defaults when entering the
523
+ annotation mode.
524
+
525
+ Following setup shows you all available settings. If you don't have the
526
+ `drawing` property at all, it will falls back to the defaults.
527
+
528
+ ```
529
+ "export": {
530
+ "drawing": {
531
+ "enabled": true, // Flag for `action: "draw"` menu items to toggle it's visibility
532
+ "shapes": [ "test.svg" ], // Choice of shapes offered in the menu (shapes are being loaded from the shapes folder)
533
+
534
+ "width": 2, // Width of the pencil and line when entering the annotation mode
535
+ "widths": [ 2, 10, 20 ], // Choice of widths offered in the menu
536
+
537
+ "color": "#000000", // Color of the pencil, line, text and shapes when entering the annotation mode
538
+ "colors": [ "#000000", "#FF0000" ] // Choice of colors offered in the menu
539
+
540
+ "opacity": 1, // Opacity of the pencil, line, text and shapes when entering the annotation mode
541
+ "opacities": [ 1, 0.8, 0.6, 0.4, 0.2 ] // Choice of opacity offered in the menu
542
+
543
+ "menu": [ ... ], // Shown menu when entering the annotation mode
544
+
545
+ "mode": "pencil", // Drawing mode when entering the annotation mode "pencil", "line" and "arrow" are available
546
+ "modes": [ "pencil" , "line", "arrow" ], // Choice of modes offered in the menu
547
+ "arrow": "end", // position of the arrow on drawn lines; "start","middle" and "end" are available
548
+
549
+ "autoClose": true // Flag to automatically close the annotation mode after download
550
+ }
551
+ }
552
+ ```
553
+
554
+ If you need to filter the drawn elements, you can pass the `reviver` method in
555
+ your global configuration, or pass it to the `capture` method if you export
556
+ manually. For example, to hide all free labels you can simply do something like
557
+ the following:
558
+
559
+ ```
560
+ "export": {
561
+ "menu": ["PNG"],
562
+ "reviver": function(obj) {
563
+ if ( obj.className == "amcharts-label" ) {
564
+ obj.opacity = 0;
565
+ }
566
+ }
567
+ }
568
+ ```
569
+
570
+ ### Delay the capturing before export
571
+
572
+ In some cases you may want to delay the capturing of the current chart snapshot
573
+ to highlight the current value. For this you can simply define the 'delay'
574
+ property in your menu item:
575
+
576
+ ```
577
+ "export": {
578
+ "delay": 3,
579
+
580
+ // or specifically on individual menu items
581
+
582
+ "menu": [{
583
+ "label": "PNG",
584
+ "format": "PNG",
585
+ "delay": 3
586
+ }]
587
+ }
588
+ ```
589
+
590
+ ### Events
591
+
592
+ Since version 1.1.7 the plugin introduces some events you can use. For example
593
+ the `afterCapture` event allows you to add some texts or images which can't be
594
+ seen on the regular chart but only the generated export. Use it to watermark
595
+ your exported images.
596
+
597
+ ```
598
+ "export": {
599
+ "afterCapture": function(menuConfig) {
600
+ var text = new fabric.Text("This is shown on exported image only", {
601
+ top: 50,
602
+ left: 100,
603
+ family: this.setup.chart.fontFamily,
604
+ fontSize: this.setup.chart.fontSize * 2
605
+ });
606
+ this.setup.fabric.add(text);
607
+ },
608
+
609
+ // or specifically on individual menu items
610
+
611
+ "menu": [{
612
+ "label": "PNG",
613
+ "format": "PNG",
614
+ "afterCapture": function(menuConfig) {
615
+ var text = new fabric.Text("This is shown on exported image only", {
616
+ top: 50,
617
+ left: 100,
618
+ family: this.setup.chart.fontFamily,
619
+ fontSize: this.setup.chart.fontSize * 2
620
+ });
621
+ this.setup.fabric.add(text);
622
+ }
623
+ }],
624
+ ```
625
+
626
+ Since version 1.4.29 we have added the `onReady` callback to get your stuff done
627
+ right after the plugin or specific dependency is ready to use. Ensure to check the
628
+ `timedout` flag to be sure the dependency got fully loaded.
629
+
630
+ ```
631
+ "export": {
632
+ "onReady": function( type, timedout ) {
633
+
634
+ // Plugin ready for data exports
635
+ if ( type == "data" ) {
636
+ this.toCSV( {}, function( data ) {
637
+ // Exported to CSV
638
+ } );
639
+
640
+ // Plugin ready for image exports
641
+ } else if ( type == "fabric" && !timedout ) {
642
+ this.capture( {}, function() {
643
+ this.toPNG( {}, function( data ) {
644
+ // Exported to PNG
645
+ } );
646
+ } );
647
+ }
648
+ }
649
+ }
650
+ ```
651
+
652
+ ### A list of the events
653
+
654
+ Name | Arguments | Description
655
+ ---- | --------- | -----------
656
+ beforeCapture | [menu item setup](#a-list-of-menu-item-properties) | Called before the SVG element gets converted
657
+ afterCapture | [menu item setup](#a-list-of-menu-item-properties) | Called right before the passed callback of the capture method
658
+
659
+
660
+ ### A list of menu item properties
661
+
662
+ Property | Description
663
+ -------- | -----------
664
+ action | Set to "draw" if you want the item to trigger annotation mode
665
+ class | Class name applied to the tag
666
+ click | Function handler invoked upon click on menu item
667
+ format | A format to export chart/map to upon click (see below for a list of available formats)
668
+ icon | Icon file (will use chart's [path](http://docs.amcharts.com/3/javascriptcharts/AmSerialChart#path) if the URL is not full)
669
+ label | Text label to be displayed
670
+ menu | An array of submenu items
671
+ title | A title attribute of the link
672
+ backgroundColor | The background color of the canvas
673
+ fileName | A file name to use for generated export files (an extension will be appended to it based on the export format)
674
+ extension | File extension for the generated export file (uses format default if not defined)
675
+ mimeType | Internet media type to generate the export file (usses format default if not defined)
676
+ pageSize | A string or { width: number, height: number } ([details](#exporting-to-pdf))
677
+ pageOrientation | By default we use portrait, you can change it to landscape if you wish ([details](#exporting-to-pdf))
678
+ pageMargins | [left, top, right, bottom] or [horizontal, vertical] or just a number for equal margins ([details](#exporting-to-pdf))
679
+ content | Array of elements which represents the content ([details](#exporting-to-pdf))
680
+ multiplier | Scale factor for the generated image
681
+ lossless | Flag to print the actual vector graphic instead of buffered bitmap (print option only, experimental)
682
+ delay | A numeric value to delay the capturing in seconds ([details](#delay-the-capturing-before-export))
683
+ exportFields | [] | If set, only fields in this array will be exported ( data export only )
684
+ exportTitles | Exchanges the data field names with it's dedicated title ( data export only )
685
+ columnNames | An object of key/value pairs to use as column names when exporting ( data export only )
686
+ exportSelection | Exports the current data selection only ( data export only )
687
+ dataDateFormat | Format to convert date strings to date objects, uses by default charts dataDateFormat ( data export only )
688
+ dateFormat | Formats the category field in given date format ( data export only )
689
+ border | An object of key/value pairs to define the overlaying border
690
+ pageOrigin | A flag to show / hide the origin of the generated PDF ( pdf export only )
691
+ compress | A flag to compress the generated output ( svg only )
692
+
693
+ Available `format` values:
694
+
695
+ * JPG
696
+ * PNG
697
+ * SVG
698
+ * CSV
699
+ * JSON
700
+ * PDF
701
+ * XLSX
702
+ * PRINT
703
+
704
+ ### Exporting to PDF
705
+
706
+ When exporting to PDF, you can set and modify the content of the resulting
707
+ document. I.e. add additional text and/or modify image size, etc.
708
+
709
+ To do that, you can use menu item's `content` property.
710
+
711
+ Each item in `content` represents either a text line (string) or an exported
712
+ image.
713
+
714
+ To add a text line, simply use a string. It can even be a JavaScript variable or
715
+ a function that returns a string.
716
+
717
+ To include exported image, use `image: "reference"`.
718
+
719
+ Additionally, you can add `fit` property which is an array of pixel dimensions,
720
+ you want the image to be scaled to fit into.
721
+
722
+ Here's an example of such export menu item:
723
+
724
+ ```
725
+ {
726
+ "format": "PDF",
727
+ "content": [ "Saved from:", window.location.href, {
728
+ "image": "reference",
729
+ "fit": [ 523.28, 769.89 ] // fit image to A4
730
+ } ]
731
+ }
732
+ ```
733
+
734
+ Property | Description
735
+ -------- | -----------
736
+ pageSize | a string or { width: number, height: number }
737
+ pageOrientation | by default we use portrait, you can change it to landscape if you wish
738
+ pageMargins | [left, top, right, bottom] or [horizontal, vertical] or just a number for equal margins
739
+ content | array of elements which represents the content ([full description](https://github.com/bpampuch/pdfmake/))
740
+
741
+ Pagesize | Dimensions in pixel
742
+ -------- | -----------
743
+ 4A0 | [4767.87, 6740.79]
744
+ 2A0 | [3370.39, 4767.87]
745
+ A0 | [2383.94, 3370.39]
746
+ A1 | [1683.78, 2383.94]
747
+ A2 | [1190.55, 1683.78]
748
+ A3 | [841.89, 1190.55]
749
+ A4 | [595.28, 841.89]
750
+ A5 | [419.53, 595.28]
751
+ A6 | [297.64, 419.53]
752
+ A7 | [209.76, 297.64]
753
+ A8 | [147.40, 209.76]
754
+ A9 | [104.88, 147.40]
755
+ A10 | [73.70, 104.88]
756
+ B0 | [2834.65, 4008.19]
757
+ B1 | [2004.09, 2834.65]
758
+ B2 | [1417.32, 2004.09]
759
+ B3 | [1000.63, 1417.32]
760
+ B4 | [708.66, 1000.63]
761
+ B5 | [498.90, 708.66]
762
+ B6 | [354.33, 498.90]
763
+ B7 | [249.45, 354.33]
764
+ B8 | [175.75, 249.45]
765
+ B9 | [124.72, 175.75]
766
+ B10 | [87.87, 124.72]
767
+ C0 | [2599.37, 3676.54]
768
+ C1 | [1836.85, 2599.37]
769
+ C2 | [1298.27, 1836.85]
770
+ C3 | [918.43, 1298.27]
771
+ C4 | [649.13, 918.43]
772
+ C5 | [459.21, 649.13]
773
+ C6 | [323.15, 459.21]
774
+ C7 | [229.61, 323.15]
775
+ C8 | [161.57, 229.61]
776
+ C9 | [113.39, 161.57]
777
+ C10 | [79.37, 113.39]
778
+ RA0 | [2437.80, 3458.27]
779
+ RA1 | [1729.13, 2437.80]
780
+ RA2 | [1218.90, 1729.13]
781
+ RA3 | [864.57, 1218.90]
782
+ RA4 | [609.45, 864.57]
783
+ SRA0 | [2551.18, 3628.35]
784
+ SRA1 | [1814.17, 2551.18]
785
+ SRA2 | [1275.59, 1814.17]
786
+ SRA3 | [907.09, 1275.59]
787
+ SRA4 | [637.80, 907.09]
788
+ EXECUTIVE | [521.86, 756.00]
789
+ FOLIO | [612.00, 936.00]
790
+ LEGAL | [612.00, 1008.00]
791
+ LETTER | [612.00, 792.00]
792
+ TABLOID | [792.00, 1224.00]
793
+
794
+ ## Styling the export menu
795
+
796
+ The plugin comes with a default CSS file `export.css`. You just need to include
797
+ it on your page.
798
+
799
+ Feel free to override any styles defined in it, create your own version and
800
+ modify as you see fit.
801
+
802
+ If you choose to modify it, we suggest creating a copy so it does not get
803
+ overwritten when you update amCharts or plugin.
804
+
805
+
806
+ ## Plugin API
807
+
808
+ We explained how you can define custom functions to be executed on click on
809
+ export menu items.
810
+
811
+ Those functions can tap into plugin's methods to augment it with some custom
812
+ functionality.
813
+
814
+ Here's an example:
815
+
816
+ ```
817
+ "export": {
818
+ menu: [ {
819
+ label: "JPG",
820
+ click: function() {
821
+ this.capture({},function() {
822
+ this.toJPG( {}, function( data ) {
823
+ this.download( data, "image/jpg", "amCharts.jpg" );
824
+ });
825
+ });
826
+ }
827
+ } ]
828
+ }
829
+ ```
830
+
831
+ The above will use plugin's internal `capture` method to capture it's current
832
+ state and `toJPG()` method to export the chart to JPEG format.
833
+
834
+ Yes, you're right, it's the exact equivalent of just including "JPG" string. The
835
+ code is here for the explanatory purposes.
836
+
837
+ Here's a full list of API functions available for your consumption:
838
+
839
+ Function | Parameters | Description
840
+ -------- | ---------- | -----------
841
+ toJPG | (object) options, (function) callback | Prepares a JPEG representation of the chart and passes the binary data to the callback function
842
+ toPNG | (object) options, (function) callback | Prepares a PNG representation of the chart and passes the binary data to the callback function
843
+ toSVG | (object) options, (function) callback | Prepares a SVG representation of the chart and passes the binary data to the callback function
844
+ toPDF | (object) options, (function) callback | Prepares a PDF representation of the chart and passes the binary data to the callback function
845
+ toJSON | (object) options, (function) callback | Prepares a JSON and passes the plain data to the callback function
846
+ toCSV | (object) options, (function) callback | Prepares a CSV and passes the plain data to the callback function
847
+ toXLSX | (object) options, (function) callback | Prepares a XLSX representation of the chart and passes the binary data to the callback function
848
+ toBlob | (object) options, (function) callback | Prepares a BLOB and passes the instance to the callback function
849
+ toCanvas | (object) options, (function) callback | Prepares a Canvas and passes the element to the callback function
850
+ toArray | (object) options, (function) callback | Prepares an Array and passes the data to the callback function
851
+ toImage | (object) options, (function) callback | Generates an image element which holds the output in an embedded base64 data url
852
+
853
+ ## Annotation API
854
+
855
+ Since version 1.4.27 we've introduced the functionality to manage the annotations on the fly. The setter returns an array of objects, where each element represents an annotation.
856
+ On the other hand the setter processes the given annotations within options (options.data). Both methods support the reviver callback which allows you to modify the annotations if needed.
857
+
858
+ Function | Parameters | Description
859
+ -------- | ---------- | -----------
860
+ getAnnotations | (object) options, (function) callback | Returns an array of objects where each element represents an annotation.
861
+ setAnnotations | (object) options, (function) callback | Draws the given annotations (options.data).
862
+
863
+ Here's an example how to insert annotations, please ensure your chart is in annotation mode:
864
+
865
+ ```
866
+ chart.export.setAnnotations({
867
+
868
+ // Array of annotations, accepts this simple handwritten format or the detailed output of the getter
869
+ data: [{
870
+ top: 200,
871
+ left: 200,
872
+ text: "Test annotation",
873
+ type: "text"
874
+ }],
875
+
876
+ // Allows you to modify the annotation before it's being added into the canvas.
877
+ reviver: function(obj,index) {
878
+ obj.fill = "#FF00FF";
879
+ }
880
+
881
+
882
+ },function() {
883
+ // Callback when finished
884
+ });
885
+ ```
886
+
887
+ ## Fallback for IE9
888
+
889
+ Unfortunately, Internet Explorer 9 has restrictions in place that prevent the
890
+ download of locally-generated files. In this case the plugin will place the
891
+ generated image along download instructions directly over the chart area.
892
+
893
+ To avoid having a bigger payload by including senseless polyfills to your site,
894
+ you may need to add following metatag in your `<head>` of your HTML document.
895
+
896
+ ```
897
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
898
+ ```
899
+
900
+ This feature will kick in by default. If you want to disable it simply pass
901
+ `false` to the `fallback` parameter.
902
+
903
+ ```
904
+ "export": {
905
+ fallback: false
906
+ }
907
+ ```
908
+
909
+ In case you want to change our default messages you can modify it like
910
+ following.
911
+
912
+ ```
913
+ "export": {
914
+ fallback: {
915
+ text: "CTRL + C to copy the data into the clipboard.",
916
+ image: "Rightclick -> Save picture as... to save the image."
917
+ }
918
+ }
919
+ ```
920
+
921
+ ## Requirements
922
+
923
+ This plugin requires at least 3.13 version of JavaScript Charts, JavaScript
924
+ Stock Chart or JavaScript Maps.
925
+
926
+ The export will also need relatively recent browsers.
927
+
928
+ IE10 and up are supported.
929
+
930
+ Partial support for IE9; Fallback mechanism.
931
+
932
+ IE8 and older are not supported I'm afraid. Hey, it's time to upgrade!
933
+
934
+
935
+ ## Demos
936
+
937
+ They're all in subdirectory /examples.
938
+
939
+
940
+ ## Extending this plugin
941
+
942
+ You're encouraged to modify, extend and make derivative plugins out of this
943
+ plugin.
944
+
945
+ You can modify files, included in this archive or, better yet, fork this project
946
+ on GitHub:
947
+
948
+ https://github.com/amcharts/export
949
+
950
+ We're curious types. Please let us know (contact@amcharts.com) if you do create
951
+ something new out of this plugin.
952
+
953
+
954
+ ## License
955
+
956
+ This plugin is licensed under Apache License 2.0.
957
+
958
+ This basically means you're free to use or modify this plugin, even make your
959
+ own versions or completely different products out of it.
960
+
961
+ Please see attached file "license.txt" for the complete license or online here:
962
+
963
+ http://www.apache.org/licenses/LICENSE-2.0
964
+
965
+
966
+ ## Contact us
967
+
968
+ * Email:contact@amcharts.com
969
+ * Web: http://www.amcharts.com/
970
+ * Facebook: https://www.facebook.com/amcharts
971
+ * Twitter: https://twitter.com/amcharts
972
+
973
+
974
+ ## Changelog
975
+
976
+
977
+ ### 1.4.74
978
+ * Fixed: fabricJS half pixel offset
979
+
980
+ ### 1.4.73
981
+ * Fixed: Exit option in image download fallback (e.g. IE9)
982
+ * Fixed: classList method access issue (see polyfill)
983
+ * Added: `libs/classList.js` [classList polyfill](https://github.com/eligrey/classList.js/blob/master/classList.min.js) for old browser
984
+ * Added: `libs.unsupportedIE9libs` to avoid loading unused resources
985
+
986
+ ### 1.4.72
987
+ * Fixed: Memory leak within clear method, calls removeListeners on fabric instance.
988
+
989
+ ### 1.4.71
990
+ * Fixed: Added additional node existance checks before removing
991
+
992
+ ### 1.4.70
993
+ * Fixed: Safari export issue on text labels
994
+
995
+ ### 1.4.69
996
+ * Fixed: Memory leak issue on observed listeners on document
997
+
998
+ ### 1.4.68
999
+ * Fixed: PDFmake dependency version (jsZIP)
1000
+ * Fixed: XLSX export issue (caused by jsZIP dependency)
1001
+ * Fixed: Issue on given functions in given config for fabric instance creation
1002
+
1003
+ ### 1.4.67
1004
+ * Fixed: PDFmake multiplier issue on iOS devices; forced to 1
1005
+ * Updated: Libaries (ensure to replace/update the resources)
1006
+
1007
+ ### 1.4.66
1008
+ * Fixed: Menu active state on mouseleave.
1009
+
1010
+ ### 1.4.65
1011
+ * Fixed: Menu active state issue, menu kept its active when it hasn't been rerendered.
1012
+
1013
+ ### 1.4.64
1014
+ * Fixed: classList issue on IE11
1015
+
1016
+ ### 1.4.63
1017
+ * Fixed: Clip-path issue on graph lines
1018
+
1019
+ ### 1.4.62
1020
+ * Fixed: Gantt category issue
1021
+
1022
+ ### 1.4.61
1023
+ * Fixed: SmoothCustomBullet plugin support, clip-path issue on curved corners
1024
+
1025
+ ### 1.4.60
1026
+ * Fixed: Empty print output in chrome version 57
1027
+
1028
+ ### 1.4.59
1029
+ * Fixed: Issue with blurred element when closing annotation mode
1030
+
1031
+ ### 1.4.58
1032
+ * Fixed: SVG clip-path export issue; injection control; wrap elements to support fill reference
1033
+ * Fixed: Keyboard navigation disabled on touch devices
1034
+
1035
+ ### 1.4.57
1036
+ * Added: Support for keyboard navigation (tabs and arrow keys).
1037
+ * Fixed: Merged pull request [#84](https://github.com/amcharts/export/pull/54) fixing an issue when "a" is undefined within deepMerge (thanks to [RahavLussato](https://github.com/RahavLussato) )
1038
+
1039
+ ### 1.4.56
1040
+ * Added: Dependency handler on export methods, holds the actual call until the namespace shows up in current scope (uses libs.loadTimeout).
1041
+
1042
+ ### 1.4.55
1043
+ * Added: Radial gradient issue on pie caused by the vertical gradient fix (v1.4.44)
1044
+
1045
+ ### 1.4.54
1046
+ * Fixed: Default text size on width changes
1047
+
1048
+ ### 1.4.53
1049
+ * Fixed: IOS print issue, captured the whole page instead of the single page
1050
+
1051
+ ### 1.4.52
1052
+ * Fixed: Blank export issue especifically in chrome on IOS devices.
1053
+ * Updated: FileSaver.js due the chrome export issue on IOS
1054
+
1055
+ ### 1.4.51
1056
+ * Fixed: Render issue on maps due half pixel position correction; simplified the positioning.
1057
+
1058
+ ### 1.4.50
1059
+ * Fixed: Half pixel positioning issue which caused the blurriness within the canvas and exported image.
1060
+
1061
+ ### 1.4.49
1062
+ * Fixed: Custom data export issue through toXSLX and toJSON which results in an empty data sheet.
1063
+
1064
+ ### 1.4.48
1065
+ * Fixed: toXLSX issue handling objects/array in data points.
1066
+
1067
+ ### 1.4.47
1068
+ * Fixed: `afterCapture` issue which removed injected elements.
1069
+
1070
+ ### 1.4.46
1071
+ * Fixed: toSVG clipPath issue which exported multiple times the same clipPath
1072
+
1073
+ ### 1.4.45
1074
+ * Fixed: Object selection issue on charts with heavy amount of datapoints
1075
+ * Fixed: Line/Arrow drawing issue on vertical movement
1076
+ * Changed: Pressing escape while an object has been selected will deselect first instead quiting the annotation mode
1077
+
1078
+ ### 1.4.44
1079
+ * Fixed: Vertical gradient issue
1080
+
1081
+ ### 1.4.43
1082
+ * Fixed: Shown label in hidden valueAxis
1083
+
1084
+ ### 1.4.42
1085
+ * Fixed: `exportFields` issue in combination with `columnNames` or `exportTitles`
1086
+ * Added: `dataFieldsTitlesMap` into `processData` context to be able to trace back the translated keys against the data fields
1087
+
1088
+ ### 1.4.41
1089
+ * Added: quote, escape option to `toArray` method
1090
+ * Fixed: toArray method to respect `exportFields` order
1091
+ * Fixed: toCSV, toXLSX to respect `exportFields` order
1092
+
1093
+ ### 1.4.40
1094
+ * Fixed: Infinite loop in Angular2 Zones
1095
+ * Fixed: `compress` option being obtained from the global config
1096
+
1097
+ ### 1.4.39
1098
+ * Added: New menu option `compress` to compress the generated output (svg only).
1099
+ * Fixed: Strikethrough issue in SVG output.
1100
+
1101
+ ### 1.4.38
1102
+ * Fixed: Support for external stock chart legends, overlapping issue with free licensed version of amcharts
1103
+
1104
+ ### 1.4.37
1105
+ * Fixed: Gradient issue which left the chart elements hidden after the export process
1106
+ * Fixed: Typo in examples dropdown
1107
+ * Added: Support for external stock chart legends
1108
+
1109
+ ### 1.4.36
1110
+ * Fixed: exportFields order being considered
1111
+ * Fixed: Keep scroll position after printing
1112
+ * Fixed: Namespace key issue with minified resource versions
1113
+
1114
+ ### 1.4.35
1115
+ * Fixed: Menu handling issue on touch devices, uses css classname to toggle menu items (updated CSS file, on devices only where the "Touch" object is within window scope)
1116
+
1117
+ ### 1.4.34
1118
+ * Fixed: Data shifting issue in data exports with compared graphs (stock only)
1119
+ * Fixed: Shallow copy of compared graphs in data exports (stock only)
1120
+
1121
+ ### 1.4.33
1122
+ * Fixed: fill/stroke polyfilling issue on svg elements with color validation/preparation for fabric
1123
+
1124
+ ### 1.4.32
1125
+ * Fixed: Issue polyfilling the color attributes with "rgba" color codes
1126
+
1127
+ ### 1.4.31
1128
+ * Changed: Included independent IE detection to handle specific IE10, IE11 svg image in canvas issue
1129
+
1130
+ ### 1.4.30
1131
+ * Fixed: Pattern loading, positioning issue, supports x,y offset now
1132
+
1133
+ ### 1.4.29
1134
+ * Added: `libs.loadTimeout` dependency namespace timeout used within onReady handler
1135
+ * Added: `fabric.loadTimeout` loading image timeout to avoid blocking the export process
1136
+ * Added: [onReady](#events) ready callback handler to get notified when the export or specific dependency is ready to use
1137
+ * Fixed: fill/stroke issue on SVG elements which caused a crash within the export process
1138
+ * Fixed: Image loader which freezed occasionally and caused an unexpected behaviour
1139
+
1140
+ ### 1.4.28
1141
+ * Fixed: Positioning / handling issue on multiline labels (injected modifed fabricJS snippet to handle it)
1142
+ * Fixed: Cursor issue on regular exports which flashed the crosshair cursor for a moment
1143
+
1144
+ ### 1.4.27
1145
+ * Added: [Annotations API](#annotations-api) to get or set annotations within drawing mode.
1146
+
1147
+ ### 1.4.26
1148
+ * Fixed: IE10 SVG image handing issue, caused by an internal bug of IE10 (removes SVGs automatically to avoid triggering the security policy)
1149
+
1150
+ ### 1.4.25
1151
+ * Fixed: `export.config.advanced.js` sample config issue with drawing callbacks
1152
+ * Fixed: `delay` property reset issue, did not get considered after first usage
1153
+ * Fixed: `drawing.enabled` propery issue after first usage, stayed on true
1154
+ * Changed: Updated fabric.js source to `1.6.2`
1155
+ * Added: Advanced sample using the advanced config
1156
+
1157
+ ### 1.4.24
1158
+ * Fixed: Issue with external legends in maps
1159
+ * Fixed: Resource dependency issue of xlsx with jszip
1160
+ * Fixed: Issue with `forceRemoveImages` in local enviroment (includes all ":\" and "file://" sources)
1161
+ * Changed: Resource loading order according to it's priority
1162
+ * Changed: Loading minified resource versions by default to improve the payload significantly
1163
+
1164
+ ### 1.4.23
1165
+ * Fixed: Issue with `forceRemoveImages` in local enviroment
1166
+
1167
+ ### 1.4.22
1168
+ * Fixed: Local time offset issue on XLSX exports
1169
+ * Added: `forceRemoveImages` to remove images regardless if they are tainted or not
1170
+ * Added: Used config ([processData](#changing-the-dataprovider-when-exporting)) as additional given parameter.
1171
+
1172
+ ### 1.4.21
1173
+ * Fixed: Issue with file:// image origin, forced removal as it does not fit to the CORS policy and blocks the image export.
1174
+
1175
+ ### 1.4.20
1176
+ * Fixed: Issue with disappearing images in PDFs caused by exceeding boundary box for images
1177
+
1178
+ ### 1.4.19
1179
+ * Fixed: Issue with radial gradient
1180
+
1181
+ ### 1.4.18
1182
+ * Fixed: Issue with the legend positioning on the left side
1183
+
1184
+ ### 1.4.17
1185
+ * Fixed: `clip-path` issue on XY serial charts which exposed the drawn line beyond the plotarea.
1186
+
1187
+ ### 1.4.16
1188
+ * Added: ([processData](#changing-the-dataprovider-when-exporting)) config-property to change the dataProvider when exporting.
1189
+
1190
+ ### 1.4.15
1191
+ * Fixed: Menu items obtain the global `multiplier` setting to scale the output image.
1192
+
1193
+ ### 1.4.14
1194
+ * Added: ([border](#adding-overlaying-border)) config-property to add an overlaying border on the output image.
1195
+
1196
+ ### 1.4.13
1197
+ * Fixed: Issue on balloons showing it's content as HTML added "textContent" as alternative getter
1198
+
1199
+ ### 1.4.12
1200
+ * Fixed: clipPath issue on SVG export (workaround until fabricJS handles that by themselves)
1201
+
1202
+ ### 1.4.11
1203
+ * Fixed: Depth issue on value labels on columns
1204
+
1205
+ ### 1.4.10
1206
+ * Fixed: potential vulnerability with anonymous function declaration
1207
+
1208
+ ### 1.4.9
1209
+ * Added: Radial gradient support on pie charts (new feature in amCharts v3.18.0)
1210
+
1211
+ ### 1.4.8
1212
+ * Fixed: Clippath positioning issue
1213
+ * Fixed: Issue removing tainted images
1214
+ * Fixed: Hashbanged url interpretation issue in IE (related to reusable svg nodes)
1215
+
1216
+ ### 1.4.7
1217
+ * Fixed: Zeroes were being exported to data formats as empty strings rather than numbers
1218
+
1219
+ ### 1.4.6
1220
+ * Fixed: Loading issue with patterns in firefox
1221
+
1222
+ ### 1.4.5
1223
+ * Fixed: Issue with the "canvas-container" on chart revalidations
1224
+
1225
+ ### 1.4.4
1226
+ * Added: Balloon text orientation
1227
+ * Fixed: Issue with multiline label positioning
1228
+
1229
+ ### 1.4.3
1230
+ * Added: `exportFields` option which is an array of fields to export in data formats (if you want to export just some fields as opposed to all fields)
1231
+
1232
+ ### 1.4.2
1233
+ * Added: `overflow` flag to overwrite the css attribute 'overflow' of the chart container
1234
+
1235
+ ### 1.4.1
1236
+ * Fixed: cropped bullets on XY charts
1237
+
1238
+ ### 1.4.0
1239
+ * Fixed: beforeCapture issue on SVG document changes
1240
+ * Added: Namespace check within globals for required third party software
1241
+
1242
+ ### 1.3.9
1243
+ * Fixed: Base tag gradient drawing issue (includes embedded hotfix for fabricjs commit #c9745ff)
1244
+
1245
+ ### 1.3.8
1246
+ * Fixed: Base tag clip path issue which draw the lines outside the plotarea
1247
+
1248
+ ### 1.3.7
1249
+ * Added: `columnNames` property, which allows overriding column names when expoerting chart data
1250
+
1251
+ ### 1.3.6
1252
+ * Fixed: Checking parseDates for category values for date interpretation
1253
+
1254
+ ### 1.3.5
1255
+ * Fixed: Scrollbar issue hiding the unselected scrollbar background area
1256
+
1257
+ ### 1.3.4
1258
+ * Fixed: Absolute legend positioning issue.
1259
+
1260
+ ### 1.3.3
1261
+ * Added: English as default language when define language does not exist
1262
+
1263
+ ### 1.3.2
1264
+ * Added: ([drawing.autoClose](#annotation-settings)) new flag to automatically close the annotation mode after download
1265
+ * Fixed: Internal pdfMake issue which prevented to generate PDFs in IE10, uses custom build until officially fixed
1266
+
1267
+ ### 1.3.1
1268
+ * Added: Timestamp date fields get converted as dates
1269
+ * Fixed: XLSX respects given dateFormat
1270
+ * Changed: JSON exports date fields as date objects by default
1271
+
1272
+ ### 1.3.0
1273
+ * Fixed: Issue hiding drawing container on "drawing.done"
1274
+ * Fixed: Legend positioning issue with charts created in a hidden container
1275
+
1276
+ ### 1.2.9
1277
+ * Fixed: Issue with missing `export.css` which showed the canvas
1278
+ * Fixed: Issue with empty menu items; adds list only with childNodes > 1
1279
+ * Fixed: Issue with hidden bullets; caused by wrong clip-paths
1280
+ * Added: Polish language file ( thanks to piernik )
1281
+
1282
+ ### 1.2.8
1283
+ * Fixed: Issue in `gatherClassName` checking element type
1284
+
1285
+ ### 1.2.7
1286
+ * Fixed: Generates true JPG file instead PNG with JPG extension
1287
+ * Fixed: Drag&Drop feature does not activate automatically the annotation mode
1288
+
1289
+ ### 1.2.6
1290
+ * Added: Native EXCEL date cell type for date fields, forced by default
1291
+ * Fixed: Issue in `getChartData` which ignored given data array ( affected API usage only )
1292
+
1293
+ ### 1.2.5
1294
+ * Added: Illustrator support; `reviver` method to `toSVG`; converts by default RGBA to HEX colors codes and places it's dedicated opacity property
1295
+ * Fixed: Multiline text positioning / line heights
1296
+
1297
+ ### 1.2.4
1298
+ * Added: `exportSelection` exports the current data selection
1299
+ * Added: `dataDateFormat` converts the date-strings to date objects with given format
1300
+ * Added: `dateFormat` converts the date in given format
1301
+ * Added: `processData` to format date fields and translate fields
1302
+ * Changed: `gatherChartData` collects data, fields and titles only and uses `processData` to format
1303
+
1304
+ ### 1.2.3
1305
+ * Fixed: Positioning issue on multiline labels
1306
+
1307
+ ### 1.2.2
1308
+ * Fixed: Issue with object changes which overwrite undo/redo object states
1309
+ * Fixed: Issue with default fontSize
1310
+
1311
+ ### 1.2.1
1312
+ * Added: Possibility to add text, lines, shapes ([details](#annotation-settings))
1313
+ * Added: Possibility to change drawing mode, color, opacity and size
1314
+ * Added: Possibility to select,move,scale drawn items
1315
+ * Added: Possibility to define dedicated drawing menu `drawing.menu` individual menu items get prioritised
1316
+ * Added: Dropbox feature which allows to drag images into the chart `fileListener: true`
1317
+ * Added: Keylistener which allows to undo/redo/remove the drawn steps `keyListener: true`
1318
+ * Added: Isolated plugin to be able to initiate manually regardless of the chart setup
1319
+ * Fixed: Conflict with prototypeJS which caused tainted return value from `toArray`
1320
+
1321
+ ### 1.2.0
1322
+ * Fixed: Issue with deepMerge which did not allow to modfiy the pdfMake default settings
1323
+ * Fixed: Menu issue which did not allow to modify the pdfMake settings
1324
+ * Fixed: Undo issue which needed double attempts in the beginning
1325
+ * Added: Drag/Scale feature in annotation mode; toggles automatically between drawing/dragging while hovering over the elements
1326
+
1327
+ ### 1.1.9
1328
+ * Added: `exportTitles` available in general or individual setup which exchanges the data field names with it's dedicated title
1329
+ * Fix: Interpolates missing data fields across data provider
1330
+
1331
+ ### 1.1.8
1332
+ * Added: Temporary workaround to bypass FileSaver check; issue prevented to open blob urls in safari browser
1333
+
1334
+ ### 1.1.7
1335
+ * Added: beforeCapture to be able to indicate the export process in some way
1336
+ * Added: afterCapture to be able to modify the fabric instance if needed
1337
+ * Added: SVG element as second argument within the "reviver" callback
1338
+ * Added: Multiple arguments supported in "handleCallback" method
1339
+
1340
+ ### 1.1.6
1341
+ * Fix: Pattern render issue in IE;
1342
+ * Added: Multiline support (workaround until fabricJS supports tspan)
1343
+ * Added: General delay property to delay the capturing of the chart ([details](#delay-the-capturing-before-export))
1344
+
1345
+ ### 1.1.5
1346
+ * Fix: Tainted check issue which failed if location.origin wasn't available
1347
+ * Fix: Capture image check, triggers callback only if all images have been loaded
1348
+ * Added: Multi language support; embedded english by default; overtakes chart language
1349
+ * Added: Delay feature, which allows to delay the capturing ([details](#delay-the-capturing-before-export))
1350
+
1351
+ ### 1.1.4
1352
+ * Fix: Did not collect clip-path and pattern from legend
1353
+ * Fix: External legend did not respect given width when positioned on left side
1354
+ * Fix: Improved tainted image detection
1355
+
1356
+ ### 1.1.3
1357
+ * Added: Added reviver in capturing method to filter the drawn chart elements
1358
+
1359
+ ### 1.1.2
1360
+ * Added: Generalized fallback; does a lookup on the Blob constructor
1361
+ * Fix: Wait for lazy images, triggers capture callback only when all images have been fully loaded
1362
+ * Discovered: [Safari 5 issue](https://github.com/kangax/fabric.js/issues/2241) please adapt fabric.js manually to solve it
1363
+
1364
+ ### 1.1.1
1365
+ * Fix: CSV export issue on date based charts
1366
+ * Fix: Enhanced migration script to obtain more settings
1367
+
1368
+ ### 1.1.0
1369
+ * Fix: Print issue on safari which captured the actual page instead of the export
1370
+ * Added: IE9 download fallback for `text/plain` and `image/*` mime types (CSS has been modified)
1371
+ * Added: `toImage` method; returns `img` element with embedded base64 imagery
1372
+ * Added: `getBase64` option in `toSVG`
1373
+ * Added: `toImage` usage in `toPRINT` to be able to choose the image type + settings.
1374
+ * Added: `lossless` option in `toPRINT` (experimental)
1375
+
1376
+ ### 1.0.9
1377
+ * Added: IE9 base64 export
1378
+ * Added: Third party updates + minified versions
1379
+
1380
+ ### 1.0.8
1381
+ * Fix: IE8 issue which prevents the chart from initiating
1382
+
1383
+ ### 1.0.7
1384
+ * Fix: issue on toCSV handling the header (first row)
1385
+
1386
+ ### 1.0.6
1387
+ * Fix: issue on revalidation the chart/map
1388
+ * Added: [path](http://docs.amcharts.com/3/javascriptcharts/AmSerialChart#path) to load the libaries by default
1389
+
1390
+ ### 1.0.5
1391
+ * Added: divId to be able to place the menu within an external container
1392
+ * Added: menuWalker to replace the whole menu generation
1393
+ * Added: menuReviver to adapt menu items before being appended to the list
1394
+ * Added: libs.async to load dependencies asynchronous (default true)
1395
+
1396
+ ### 1.0.4
1397
+ * Considering classNamePrefix (dont't forget to adapt export.css)
1398
+ * Added: safety delay on print restore to ensure capturing the canvas
1399
+
1400
+ ### 1.0.3
1401
+ * Fix: flagged relative image paths as tainted
1402
+
1403
+ ### 1.0.2
1404
+ * Fix: compabitily on array method extension such as PrototypeJS
1405
+
1406
+ ### 1.0.1
1407
+ * Added: libs.reload: false, script tag crawling to avoid multiple insertions
1408
+ * Fix: IE10 bug on print
1409
+ * Fix: migration bug, replaces menu instead of appending
1410
+
1411
+ ### 1.0
1412
+ * Initial release
admin/js/amcharts/plugins/export/export.js ADDED
@@ -0,0 +1,4372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Plugin Name: amCharts Export
3
+ Description: Adds export capabilities to amCharts products
4
+ Author: Benjamin Maertz, amCharts
5
+ Version: 1.4.74
6
+ Author URI: http://www.amcharts.com/
7
+
8
+ Copyright 2016 amCharts
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ Please note that the above license covers only this plugin. It by all means does
23
+ not apply to any other amCharts products that are covered by different licenses.
24
+ */
25
+
26
+ /*
27
+ ** Polyfill translation
28
+ */
29
+ if ( !AmCharts.translations[ "export" ] ) {
30
+ AmCharts.translations[ "export" ] = {}
31
+ }
32
+ if ( !AmCharts.translations[ "export" ][ "en" ] ) {
33
+ AmCharts.translations[ "export" ][ "en" ] = {
34
+ "fallback.save.text": "CTRL + C to copy the data into the clipboard.",
35
+ "fallback.save.image": "Rightclick -> Save picture as... to save the image.",
36
+
37
+ "capturing.delayed.menu.label": "{{duration}}",
38
+ "capturing.delayed.menu.title": "Click to cancel",
39
+
40
+ "menu.label.print": "Print",
41
+ "menu.label.undo": "Undo",
42
+ "menu.label.redo": "Redo",
43
+ "menu.label.cancel": "Cancel",
44
+
45
+ "menu.label.save.image": "Download as ...",
46
+ "menu.label.save.data": "Save as ...",
47
+
48
+ "menu.label.draw": "Annotate ...",
49
+ "menu.label.draw.change": "Change ...",
50
+ "menu.label.draw.add": "Add ...",
51
+ "menu.label.draw.shapes": "Shape ...",
52
+ "menu.label.draw.colors": "Color ...",
53
+ "menu.label.draw.widths": "Size ...",
54
+ "menu.label.draw.opacities": "Opacity ...",
55
+ "menu.label.draw.text": "Text",
56
+
57
+ "menu.label.draw.modes": "Mode ...",
58
+ "menu.label.draw.modes.pencil": "Pencil",
59
+ "menu.label.draw.modes.line": "Line",
60
+ "menu.label.draw.modes.arrow": "Arrow",
61
+
62
+ "label.saved.from": "Saved from: "
63
+ }
64
+ }
65
+
66
+ /*
67
+ ** Polyfill export class
68
+ */
69
+ ( function() {
70
+ AmCharts[ "export" ] = function( chart, config ) {
71
+ var _timer;
72
+ var _this = {
73
+ name: "export",
74
+ version: "1.4.74",
75
+ libs: {
76
+ async: true,
77
+ autoLoad: true,
78
+ reload: false,
79
+ resources: [ "fabric.js/fabric.min.js", "FileSaver.js/FileSaver.min.js", {
80
+ "jszip/jszip.min.js": [ "xlsx/xlsx.min.js" ],
81
+ "pdfmake/pdfmake.min.js": [ "pdfmake/vfs_fonts.js" ]
82
+ } ],
83
+ namespaces: {
84
+ "pdfmake.min.js": "pdfMake",
85
+ "jszip.min.js": "JSZip",
86
+ "xlsx.min.js": "XLSX",
87
+ "fabric.min.js": "fabric",
88
+ "FileSaver.min.js": "saveAs"
89
+ },
90
+ loadTimeout: 10000,
91
+ unsupportedIE9libs: ["pdfmake.min.js", "jszip.min.js", "xlsx.min.js"]
92
+ },
93
+ config: {},
94
+ setup: {
95
+ chart: chart,
96
+ hasBlob: false,
97
+ wrapper: false,
98
+ isIE: !!window.document.documentMode,
99
+ IEversion: window.document.documentMode,
100
+ hasTouch: typeof window.Touch == "object",
101
+ focusedMenuItem: undefined,
102
+ hasClasslist: ("classList" in document.createElement("_"))
103
+ },
104
+ drawing: {
105
+ enabled: false,
106
+ undos: [],
107
+ redos: [],
108
+ buffer: {
109
+ position: {
110
+ x1: 0,
111
+ y1: 0,
112
+ x2: 0,
113
+ y2: 0,
114
+ xD: 0,
115
+ yD: 0
116
+ }
117
+ },
118
+ handler: {
119
+ undo: function( options, skipped ) {
120
+ var item = _this.drawing.undos.pop();
121
+ if ( item ) {
122
+ item.selectable = true;
123
+ _this.drawing.redos.push( item );
124
+
125
+ if ( item.action == "added" ) {
126
+ _this.setup.fabric.remove( item.target );
127
+ }
128
+
129
+ var state = JSON.parse( item.state );
130
+ item.target.set( state );
131
+
132
+ if ( item.target instanceof fabric.Group ) {
133
+ _this.drawing.handler.change( {
134
+ color: state.cfg.color,
135
+ width: state.cfg.width,
136
+ opacity: state.cfg.opacity
137
+ }, true, item.target );
138
+ }
139
+
140
+ _this.setup.fabric.renderAll();
141
+ }
142
+ },
143
+ redo: function( options, skipped ) {
144
+ var item = _this.drawing.redos.pop();
145
+ if ( item ) {
146
+ item.selectable = true;
147
+ _this.drawing.undos.push( item );
148
+
149
+ if ( item.action == "added" ) {
150
+ _this.setup.fabric.add( item.target );
151
+ }
152
+
153
+ var state = JSON.parse( item.state );
154
+ item.target.recentState = item.state;
155
+ item.target.set( state );
156
+
157
+ if ( item.target instanceof fabric.Group ) {
158
+ _this.drawing.handler.change( {
159
+ color: state.cfg.color,
160
+ width: state.cfg.width,
161
+ opacity: state.cfg.opacity
162
+ }, true, item.target );
163
+ }
164
+
165
+ _this.setup.fabric.renderAll();
166
+ }
167
+ },
168
+ done: function( options ) {
169
+ _this.drawing.enabled = false;
170
+ _this.drawing.buffer.enabled = false;
171
+ _this.drawing.undos = [];
172
+ _this.drawing.redos = [];
173
+ _this.createMenu( _this.config.menu );
174
+ _this.setup.fabric.deactivateAll();
175
+
176
+ if ( _this.isElement(_this.setup.wrapper) && _this.isElement(_this.setup.wrapper.parentNode) && _this.setup.wrapper.parentNode.removeChild ) {
177
+ _this.setup.wrapper.parentNode.removeChild( _this.setup.wrapper );
178
+ _this.setup.wrapper = false;
179
+ }
180
+ },
181
+ add: function( options ) {
182
+ var cfg = _this.deepMerge( {
183
+ top: _this.setup.fabric.height / 2,
184
+ left: _this.setup.fabric.width / 2
185
+ }, options || {} );
186
+ var method = cfg.url.indexOf( ".svg" ) != -1 ? fabric.loadSVGFromURL : fabric.Image.fromURL;
187
+
188
+ method( cfg.url, function( objects, options ) {
189
+ var group = options !== undefined ? fabric.util.groupSVGElements( objects, options ) : objects;
190
+ var ratio = false;
191
+
192
+ // RESCALE ONLY IF IT EXCEEDS THE CANVAS
193
+ if ( group.height > _this.setup.fabric.height || group.width > _this.setup.fabric.width ) {
194
+ ratio = ( _this.setup.fabric.height / 2 ) / group.height;
195
+ }
196
+
197
+ if ( cfg.top > _this.setup.fabric.height ) {
198
+ cfg.top = _this.setup.fabric.height / 2;
199
+ }
200
+
201
+ if ( cfg.left > _this.setup.fabric.width ) {
202
+ cfg.left = _this.setup.fabric.width / 2;
203
+ }
204
+
205
+ // SET DRAWING FLAG
206
+ _this.drawing.buffer.isDrawing = true;
207
+
208
+ group.set( {
209
+ originX: "center",
210
+ originY: "center",
211
+ top: cfg.top,
212
+ left: cfg.left,
213
+ width: ratio ? group.width * ratio : group.width,
214
+ height: ratio ? group.height * ratio : group.height,
215
+ fill: _this.drawing.color
216
+ } );
217
+ _this.setup.fabric.add( group );
218
+ } );
219
+ },
220
+ change: function( options, skipped, target ) {
221
+ var cfg = _this.deepMerge( {}, options || {} );
222
+ var state, i1, rgba;
223
+ var current = target || _this.drawing.buffer.target;
224
+ var objects = current ? current._objects ? current._objects : [ current ] : null;
225
+
226
+ // UPDATE DRAWING OBJECT
227
+ if ( cfg.mode ) {
228
+ _this.drawing.mode = cfg.mode;
229
+ }
230
+ if ( cfg.width ) {
231
+ _this.drawing.width = cfg.width;
232
+ _this.drawing.fontSize = cfg.fontSize = cfg.width * 3;
233
+
234
+ // BACK TO DEFAULT
235
+ if ( _this.drawing.width == 1 ) {
236
+ _this.drawing.fontSize = cfg.fontSize = _this.defaults.fabric.drawing.fontSize;
237
+ }
238
+
239
+ }
240
+ if ( cfg.fontSize ) {
241
+ _this.drawing.fontSize = cfg.fontSize;
242
+ }
243
+ if ( cfg.color ) {
244
+ _this.drawing.color = cfg.color;
245
+ }
246
+ if ( cfg.opacity ) {
247
+ _this.drawing.opacity = cfg.opacity;
248
+ }
249
+
250
+ // APPLY OPACITY ON CURRENT COLOR
251
+ rgba = _this.getRGBA( _this.drawing.color );
252
+ rgba.pop();
253
+ rgba.push( _this.drawing.opacity );
254
+ _this.drawing.color = "rgba(" + rgba.join() + ")";
255
+ _this.setup.fabric.freeDrawingBrush.color = _this.drawing.color;
256
+ _this.setup.fabric.freeDrawingBrush.width = _this.drawing.width;
257
+
258
+ // UPDATE CURRENT SELECTION
259
+ if ( current ) {
260
+ state = JSON.parse( current.recentState ).cfg;
261
+
262
+ // UPDATE GIVE OPTIONS ONLY
263
+ if ( state ) {
264
+ cfg.color = cfg.color || state.color;
265
+ cfg.width = cfg.width || state.width;
266
+ cfg.opacity = cfg.opacity || state.opacity;
267
+ cfg.fontSize = cfg.fontSize || state.fontSize;
268
+
269
+ rgba = _this.getRGBA( cfg.color );
270
+ rgba.pop();
271
+ rgba.push( cfg.opacity );
272
+ cfg.color = "rgba(" + rgba.join() + ")";
273
+ }
274
+
275
+ // UPDATE OBJECTS
276
+ for ( i1 = 0; i1 < objects.length; i1++ ) {
277
+ if (
278
+ objects[ i1 ] instanceof fabric.Text ||
279
+ objects[ i1 ] instanceof fabric.PathGroup ||
280
+ objects[ i1 ] instanceof fabric.Triangle
281
+ ) {
282
+ if ( cfg.color || cfg.opacity ) {
283
+ objects[ i1 ].set( {
284
+ fill: cfg.color
285
+ } );
286
+ }
287
+ if ( cfg.fontSize ) {
288
+ objects[ i1 ].set( {
289
+ fontSize: cfg.fontSize
290
+ } );
291
+ }
292
+ } else if (
293
+ objects[ i1 ] instanceof fabric.Path ||
294
+ objects[ i1 ] instanceof fabric.Line
295
+ ) {
296
+ if ( current instanceof fabric.Group ) {
297
+ if ( cfg.color || cfg.opacity ) {
298
+ objects[ i1 ].set( {
299
+ stroke: cfg.color
300
+ } );
301
+ }
302
+ } else {
303
+ if ( cfg.color || cfg.opacity ) {
304
+ objects[ i1 ].set( {
305
+ stroke: cfg.color
306
+ } );
307
+ }
308
+ if ( cfg.width ) {
309
+ objects[ i1 ].set( {
310
+ strokeWidth: cfg.width
311
+ } );
312
+ }
313
+ }
314
+ }
315
+ }
316
+
317
+ // ADD UNDO
318
+ if ( !skipped ) {
319
+ state = JSON.stringify( _this.deepMerge( current.saveState()._stateProperties, {
320
+ cfg: {
321
+ color: cfg.color,
322
+ width: cfg.width,
323
+ opacity: cfg.opacity
324
+ }
325
+ } ) );
326
+ current.recentState = state;
327
+ _this.drawing.redos = [];
328
+ _this.drawing.undos.push( {
329
+ action: "modified",
330
+ target: current,
331
+ state: state
332
+ } );
333
+ }
334
+
335
+ _this.setup.fabric.renderAll();
336
+ }
337
+ },
338
+ text: function( options ) {
339
+ var cfg = _this.deepMerge( {
340
+ text: _this.i18l( "menu.label.draw.text" ),
341
+ top: _this.setup.fabric.height / 2,
342
+ left: _this.setup.fabric.width / 2,
343
+ fontSize: _this.drawing.fontSize,
344
+ fontFamily: _this.setup.chart.fontFamily || "Verdana",
345
+ fill: _this.drawing.color
346
+ }, options || {} );
347
+
348
+ cfg.click = function() {};
349
+
350
+ var text = new fabric.IText( cfg.text, cfg );
351
+
352
+ // SET DRAWING FLAG
353
+ _this.drawing.buffer.isDrawing = true;
354
+
355
+ _this.setup.fabric.add( text );
356
+ _this.setup.fabric.setActiveObject( text );
357
+
358
+ text.selectAll();
359
+ text.enterEditing();
360
+
361
+ return text;
362
+ },
363
+ line: function( options ) {
364
+ var cfg = _this.deepMerge( {
365
+ x1: ( _this.setup.fabric.width / 2 ) - ( _this.setup.fabric.width / 10 ),
366
+ x2: ( _this.setup.fabric.width / 2 ) + ( _this.setup.fabric.width / 10 ),
367
+ y1: ( _this.setup.fabric.height / 2 ),
368
+ y2: ( _this.setup.fabric.height / 2 ),
369
+ angle: 90,
370
+ strokeLineCap: _this.drawing.lineCap,
371
+ arrow: _this.drawing.arrow,
372
+ color: _this.drawing.color,
373
+ width: _this.drawing.width,
374
+ group: [],
375
+ }, options || {} );
376
+ var i1, arrow, arrowTop, arrowLeft;
377
+ var line = new fabric.Line( [ cfg.x1, cfg.y1, cfg.x2, cfg.y2 ], {
378
+ stroke: cfg.color,
379
+ strokeWidth: cfg.width,
380
+ strokeLineCap: cfg.strokeLineCap
381
+ } );
382
+
383
+ cfg.group.push( line );
384
+
385
+ if ( cfg.arrow ) {
386
+ cfg.angle = cfg.angle ? cfg.angle : _this.getAngle( cfg.x1, cfg.y1, cfg.x2, cfg.y2 );
387
+
388
+ if ( cfg.arrow == "start" ) {
389
+ arrowTop = cfg.y1 + ( cfg.width / 2 );
390
+ arrowLeft = cfg.x1 + ( cfg.width / 2 );
391
+ } else if ( cfg.arrow == "middle" ) {
392
+ arrowTop = cfg.y2 + ( cfg.width / 2 ) - ( ( cfg.y2 - cfg.y1 ) / 2 );
393
+ arrowLeft = cfg.x2 + ( cfg.width / 2 ) - ( ( cfg.x2 - cfg.x1 ) / 2 );
394
+ } else { // arrow: end
395
+ arrowTop = cfg.y2 + ( cfg.width / 2 );
396
+ arrowLeft = cfg.x2 + ( cfg.width / 2 );
397
+ }
398
+
399
+ arrow = new fabric.Triangle( {
400
+ top: arrowTop,
401
+ left: arrowLeft,
402
+ fill: cfg.color,
403
+ height: cfg.width * 7,
404
+ width: cfg.width * 7,
405
+ angle: cfg.angle,
406
+ originX: "center",
407
+ originY: "bottom"
408
+ } );
409
+ cfg.group.push( arrow );
410
+ }
411
+
412
+ // SET DRAWING FLAG
413
+ _this.drawing.buffer.isDrawing = true;
414
+
415
+ if ( cfg.action != "config" ) {
416
+ if ( cfg.arrow ) {
417
+ var group = new fabric.Group( cfg.group );
418
+ group.set( {
419
+ cfg: cfg,
420
+ fill: cfg.color,
421
+ action: cfg.action,
422
+ selectable: true,
423
+ known: cfg.action == "change"
424
+ } );
425
+ if ( cfg.action == "change" ) {
426
+ _this.setup.fabric.setActiveObject( group );
427
+ }
428
+ _this.setup.fabric.add( group );
429
+ return group;
430
+ } else {
431
+ _this.setup.fabric.add( line );
432
+ return line;
433
+ }
434
+ } else {
435
+ for ( i1 = 0; i1 < cfg.group.length; i1++ ) {
436
+ cfg.group[ i1 ].ignoreUndo = true;
437
+ _this.setup.fabric.add( cfg.group[ i1 ] );
438
+ }
439
+ }
440
+ return cfg;
441
+ }
442
+ }
443
+ },
444
+ defaults: {
445
+ position: "top-right",
446
+ fileName: "amCharts",
447
+ action: "download",
448
+ overflow: true,
449
+ path: ( ( chart.path || "" ) + "plugins/export/" ),
450
+ formats: {
451
+ JPG: {
452
+ mimeType: "image/jpg",
453
+ extension: "jpg",
454
+ capture: true
455
+ },
456
+ PNG: {
457
+ mimeType: "image/png",
458
+ extension: "png",
459
+ capture: true
460
+ },
461
+ SVG: {
462
+ mimeType: "text/xml",
463
+ extension: "svg",
464
+ capture: true
465
+ },
466
+ PDF: {
467
+ mimeType: "application/pdf",
468
+ extension: "pdf",
469
+ capture: true
470
+ },
471
+ CSV: {
472
+ mimeType: "text/plain",
473
+ extension: "csv"
474
+ },
475
+ JSON: {
476
+ mimeType: "text/plain",
477
+ extension: "json"
478
+ },
479
+ XLSX: {
480
+ mimeType: "application/octet-stream",
481
+ extension: "xlsx"
482
+ }
483
+ },
484
+ fabric: {
485
+ backgroundColor: "#FFFFFF",
486
+ removeImages: true,
487
+ forceRemoveImages: false,
488
+ selection: false,
489
+ loadTimeout: 5000,
490
+ drawing: {
491
+ enabled: true,
492
+ arrow: "end",
493
+ lineCap: "butt",
494
+ mode: "pencil",
495
+ modes: [ "pencil", "line", "arrow" ],
496
+ color: "#000000",
497
+ colors: [ "#000000", "#FFFFFF", "#FF0000", "#00FF00", "#0000FF" ],
498
+ shapes: [ "11.svg", "14.svg", "16.svg", "17.svg", "20.svg", "27.svg" ],
499
+ width: 1,
500
+ fontSize: 11,
501
+ widths: [ 1, 5, 10, 15 ],
502
+ opacity: 1,
503
+ opacities: [ 1, 0.8, 0.6, 0.4, 0.2 ],
504
+ menu: undefined,
505
+ autoClose: true
506
+ },
507
+ border: {
508
+ fill: "",
509
+ fillOpacity: 0,
510
+ stroke: "#000000",
511
+ strokeWidth: 1,
512
+ strokeOpacity: 1
513
+ }
514
+ },
515
+ pdfMake: {
516
+ images: {},
517
+ pageOrientation: "portrait",
518
+ pageMargins: 40,
519
+ pageOrigin: true,
520
+ pageSize: "A4",
521
+ pageSizes: {
522
+ "4A0": [ 4767.87, 6740.79 ],
523
+ "2A0": [ 3370.39, 4767.87 ],
524
+ "A0": [ 2383.94, 3370.39 ],
525
+ "A1": [ 1683.78, 2383.94 ],
526
+ "A2": [ 1190.55, 1683.78 ],
527
+ "A3": [ 841.89, 1190.55 ],
528
+ "A4": [ 595.28, 841.89 ],
529
+ "A5": [ 419.53, 595.28 ],
530
+ "A6": [ 297.64, 419.53 ],
531
+ "A7": [ 209.76, 297.64 ],
532
+ "A8": [ 147.40, 209.76 ],
533
+ "A9": [ 104.88, 147.40 ],
534
+ "A10": [ 73.70, 104.88 ],
535
+ "B0": [ 2834.65, 4008.19 ],
536
+ "B1": [ 2004.09, 2834.65 ],
537
+ "B2": [ 1417.32, 2004.09 ],
538
+ "B3": [ 1000.63, 1417.32 ],
539
+ "B4": [ 708.66, 1000.63 ],
540
+ "B5": [ 498.90, 708.66 ],
541
+ "B6": [ 354.33, 498.90 ],
542
+ "B7": [ 249.45, 354.33 ],
543
+ "B8": [ 175.75, 249.45 ],
544
+ "B9": [ 124.72, 175.75 ],
545
+ "B10": [ 87.87, 124.72 ],
546
+ "C0": [ 2599.37, 3676.54 ],
547
+ "C1": [ 1836.85, 2599.37 ],
548
+ "C2": [ 1298.27, 1836.85 ],
549
+ "C3": [ 918.43, 1298.27 ],
550
+ "C4": [ 649.13, 918.43 ],
551
+ "C5": [ 459.21, 649.13 ],
552
+ "C6": [ 323.15, 459.21 ],
553
+ "C7": [ 229.61, 323.15 ],
554
+ "C8": [ 161.57, 229.61 ],
555
+ "C9": [ 113.39, 161.57 ],
556
+ "C10": [ 79.37, 113.39 ],
557
+ "RA0": [ 2437.80, 3458.27 ],
558
+ "RA1": [ 1729.13, 2437.80 ],
559
+ "RA2": [ 1218.90, 1729.13 ],
560
+ "RA3": [ 864.57, 1218.90 ],
561
+ "RA4": [ 609.45, 864.57 ],
562
+ "SRA0": [ 2551.18, 3628.35 ],
563
+ "SRA1": [ 1814.17, 2551.18 ],
564
+ "SRA2": [ 1275.59, 1814.17 ],
565
+ "SRA3": [ 907.09, 1275.59 ],
566
+ "SRA4": [ 637.80, 907.09 ],
567
+ "EXECUTIVE": [ 521.86, 756.00 ],
568
+ "FOLIO": [ 612.00, 936.00 ],
569
+ "LEGAL": [ 612.00, 1008.00 ],
570
+ "LETTER": [ 612.00, 792.00 ],
571
+ "TABLOID": [ 792.00, 1224.00 ]
572
+ }
573
+ },
574
+ menu: undefined,
575
+ divId: null,
576
+ menuReviver: null,
577
+ menuWalker: null,
578
+ fallback: true,
579
+ keyListener: true,
580
+ fileListener: true,
581
+ compress: true,
582
+ debug: false
583
+ },
584
+
585
+ /**
586
+ * Buffer for latter listener clearance
587
+ */
588
+ listenersToRemove: [],
589
+
590
+ /**
591
+ * Returns translated message, takes english as default
592
+ */
593
+ i18l: function( key, language ) {
594
+ var lang = language ? language : _this.setup.chart.language ? _this.setup.chart.language : "en";
595
+ var catalog = AmCharts.translations[ _this.name ][ lang ] || AmCharts.translations[ _this.name ][ "en" ];
596
+
597
+ return catalog[ key ] || key;
598
+ },
599
+
600
+ /**
601
+ * Generates download file; if unsupported offers fallback to save manually
602
+ */
603
+ download: function( data, type, filename ) {
604
+ // SAVE
605
+ if ( window.saveAs && _this.setup.hasBlob ) {
606
+ var blob = _this.toBlob( {
607
+ data: data,
608
+ type: type
609
+ }, function( data ) {
610
+ saveAs( data, filename );
611
+ } );
612
+
613
+ // FALLBACK TEXTAREA
614
+ } else if ( _this.config.fallback && type == "text/plain" ) {
615
+ var div = document.createElement( "div" );
616
+ var msg = document.createElement( "div" );
617
+ var textarea = document.createElement( "textarea" );
618
+
619
+ msg.innerHTML = _this.i18l( "fallback.save.text" );
620
+
621
+ div.appendChild( msg );
622
+ div.appendChild( textarea );
623
+ msg.setAttribute( "class", "amcharts-export-fallback-message" );
624
+ div.setAttribute( "class", "amcharts-export-fallback" );
625
+ _this.setup.chart.containerDiv.appendChild( div );
626
+
627
+ // FULFILL TEXTAREA AND PRESELECT
628
+ textarea.setAttribute( "readonly", "" );
629
+ textarea.value = data;
630
+ textarea.focus();
631
+ textarea.select();
632
+
633
+ // UPDATE MENU
634
+ _this.createMenu( [ {
635
+ "class": "export-main export-close",
636
+ label: "Done",
637
+ click: function() {
638
+ _this.createMenu( _this.config.menu );
639
+ if ( _this.isElement(_this.setup.chart.containerDiv) ) {
640
+ _this.setup.chart.containerDiv.removeChild( div );
641
+ }
642
+ }
643
+ } ] );
644
+
645
+ // FALLBACK IMAGE
646
+ } else if ( _this.config.fallback && type.split( "/" )[ 0 ] == "image" ) {
647
+ var div = document.createElement( "div" );
648
+ var msg = document.createElement( "div" );
649
+ var img = _this.toImage( {
650
+ data: data
651
+ } );
652
+
653
+ msg.innerHTML = _this.i18l( "fallback.save.image" );
654
+
655
+ // FULFILL TEXTAREA AND PRESELECT
656
+ div.appendChild( msg );
657
+ div.appendChild( img );
658
+ msg.setAttribute( "class", "amcharts-export-fallback-message" );
659
+ div.setAttribute( "class", "amcharts-export-fallback" );
660
+ _this.setup.chart.containerDiv.appendChild( div );
661
+
662
+ // UPDATE MENU
663
+ _this.createMenu( [ {
664
+ "class": "export-main export-close",
665
+ label: "Done",
666
+ click: function() {
667
+ _this.createMenu( _this.config.menu );
668
+ if ( _this.isElement(_this.setup.chart.containerDiv) ) {
669
+ _this.setup.chart.containerDiv.removeChild( div );
670
+ }
671
+ }
672
+ } ] );
673
+
674
+ // ERROR
675
+ } else {
676
+ throw new Error( "Unable to create file. Ensure saveAs (FileSaver.js) is supported." );
677
+ }
678
+ return data;
679
+ },
680
+
681
+ /**
682
+ * Generates script, links tags and places them into the document's head
683
+ * In case of reload it replaces the node to force the download
684
+ */
685
+ loadResource: function( src, addons ) {
686
+ var i1, exist, node, item, check, type;
687
+ var url = src.indexOf( "//" ) != -1 ? src : [ _this.libs.path, src ].join( "" );
688
+
689
+ function errorCallback() {
690
+ _this.handleLog( [ "amCharts[export]: Loading error on ", this.src || this.href ].join( "" ) );
691
+ }
692
+
693
+ function loadCallback() {
694
+ if ( addons ) {
695
+ for ( i1 = 0; i1 < addons.length; i1++ ) {
696
+ _this.loadResource( addons[ i1 ] );
697
+ }
698
+ }
699
+ }
700
+
701
+ if ( src.indexOf( ".js" ) != -1 ) {
702
+ node = document.createElement( "script" );
703
+ node.setAttribute( "type", "text/javascript" );
704
+ node.setAttribute( "src", url );
705
+ if ( _this.libs.async ) {
706
+ node.setAttribute( "async", "" );
707
+ }
708
+
709
+ } else if ( src.indexOf( ".css" ) != -1 ) {
710
+ node = document.createElement( "link" );
711
+ node.setAttribute( "type", "text/css" );
712
+ node.setAttribute( "rel", "stylesheet" );
713
+ node.setAttribute( "href", url );
714
+ }
715
+
716
+ // NODE CHECK
717
+ for ( i1 = 0; i1 < document.head.childNodes.length; i1++ ) {
718
+ item = document.head.childNodes[ i1 ];
719
+ check = item ? ( item.src || item.href ) : false;
720
+ type = item ? item.tagName : false;
721
+
722
+ if ( item && check && check.indexOf( src ) != -1 ) {
723
+ if ( _this.libs.reload ) {
724
+ document.head.removeChild( item );
725
+ }
726
+ exist = true;
727
+ break;
728
+ }
729
+ }
730
+
731
+ // NAMESPACE CHECK
732
+ for ( i1 in _this.libs.namespaces ) {
733
+ var namespace = _this.libs.namespaces[ i1 ];
734
+ var check = src.toLowerCase();
735
+ var item = i1.toLowerCase();
736
+
737
+ if ( check.indexOf( item ) != -1 ) {
738
+
739
+ // SKIP UNSUPPORTED IE9 LIBS
740
+ if ( _this.setup.isIE && _this.setup.IEversion <= 9 ) {
741
+ if ( _this.libs.unsupportedIE9libs && _this.libs.unsupportedIE9libs.indexOf(item) != -1 ) {
742
+ return;
743
+ }
744
+ }
745
+
746
+ // NAMESPACE EXISTS; BREAK LOOP; NEXT
747
+ if ( window[ namespace ] !== undefined ) {
748
+ exist = true;
749
+ break;
750
+ }
751
+ }
752
+ }
753
+
754
+ // EXISTS NOT NEEDED TO LOAD
755
+ if ( !exist || _this.libs.reload ) {
756
+ node.addEventListener( "load", loadCallback );
757
+ _this.addListenerToRemove( "load", node, loadCallback );
758
+ node.addEventListener( "error", errorCallback );
759
+ _this.addListenerToRemove( "error", node, errorCallback );
760
+
761
+ document.head.appendChild( node );
762
+ }
763
+ },
764
+
765
+ /**
766
+ * Adds listeners to the buffer for latter listener clearance
767
+ */
768
+ addListenerToRemove: function(event,node,method) {
769
+ _this.listenersToRemove.push( {
770
+ node: node,
771
+ method: method,
772
+ event: event
773
+ } );
774
+ },
775
+
776
+ /**
777
+ * Walker to generate the script,link tags
778
+ */
779
+ loadDependencies: function() {
780
+ var i1, i2;
781
+ if ( _this.libs.autoLoad ) {
782
+ for ( i1 = 0; i1 < _this.libs.resources.length; i1++ ) {
783
+ if ( _this.libs.resources[ i1 ] instanceof Object ) {
784
+ for ( i2 in _this.libs.resources[ i1 ] ) {
785
+ _this.loadResource( i2, _this.libs.resources[ i1 ][ i2 ] );
786
+ }
787
+ } else {
788
+ _this.loadResource( _this.libs.resources[ i1 ] );
789
+ }
790
+ }
791
+ }
792
+ },
793
+
794
+ /**
795
+ * Converts string to number
796
+ */
797
+ pxToNumber: function( attr, returnUndefined ) {
798
+ if ( !attr && returnUndefined ) {
799
+ return undefined;
800
+ }
801
+ return Number( String( attr ).replace( "px", "" ) ) || 0;
802
+ },
803
+
804
+ /**
805
+ * Converts number to string
806
+ */
807
+ numberToPx: function( attr ) {
808
+ return String( attr ) + "px";
809
+ },
810
+
811
+ /**
812
+ * Referenceless copy of object type variables
813
+ */
814
+ cloneObject: function( o ) {
815
+ var clone, v, k, isObject, isDate;
816
+ clone = Array.isArray( o ) ? [] : {};
817
+
818
+ // Walkthrough values
819
+ for ( k in o ) {
820
+ v = o[ k ];
821
+ isObject = typeof v === "object";
822
+ isDate = v instanceof Date;
823
+
824
+ // Set value; call recursivly if value is an object
825
+ clone[ k ] = isObject && !isDate ? _this.cloneObject( v ) : v;
826
+ }
827
+ return clone;
828
+ },
829
+
830
+ /**
831
+ * Recursive method to merge the given objects together
832
+ * Overwrite flag replaces the value instead to crawl through
833
+ */
834
+ deepMerge: function( a, b, overwrite ) {
835
+ var i1, v, type = b instanceof Array ? "array" : "object";
836
+
837
+ // SKIP; OBJECTS AND ARRAYS ONLY
838
+ if ( !( a instanceof Object || a instanceof Array ) ) {
839
+ return a;
840
+ }
841
+
842
+ // WALKTHOUGH SOURCE
843
+ for ( i1 in b ) {
844
+
845
+ // PREVENT METHODS
846
+ if ( type == "array" && isNaN( i1 ) ) {
847
+ continue;
848
+ }
849
+
850
+ // ASSIGN VALUE
851
+ v = b[ i1 ];
852
+
853
+ // NEW INSTANCE
854
+ if ( a && a[ i1 ] == undefined || overwrite ) {
855
+ if ( v instanceof Array ) {
856
+ a[ i1 ] = new Array();
857
+ } else if ( v instanceof Function ) {
858
+ a[ i1 ] = function() {};
859
+ } else if ( v instanceof Date ) {
860
+ a[ i1 ] = new Date();
861
+ } else if ( v instanceof Object ) {
862
+ a[ i1 ] = new Object();
863
+ } else if ( v instanceof Number ) {
864
+ a[ i1 ] = new Number();
865
+ } else if ( v instanceof String ) {
866
+ a[ i1 ] = new String();
867
+ }
868
+ }
869
+
870
+ // WALKTHROUGH RECURSIVLY
871
+ if (
872
+ ( v instanceof Object || v instanceof Array ) &&
873
+ !( v instanceof Function || v instanceof Date || _this.isElement( v ) ) &&
874
+ i1 != "chart" &&
875
+ i1 != "scope"
876
+ ) {
877
+ _this.deepMerge( a[ i1 ], v, overwrite );
878
+
879
+ // ASSIGN
880
+ } else {
881
+ if ( a instanceof Array && !overwrite ) {
882
+ a.push( v );
883
+ } else if ( a ) {
884
+ a[ i1 ] = v;
885
+ }
886
+ }
887
+ }
888
+ return a;
889
+ },
890
+
891
+ /**
892
+ * Checks if given argument is a valid node
893
+ */
894
+ isElement: function( thingy ) {
895
+ return thingy instanceof Object && thingy && thingy.nodeType === 1;
896
+ },
897
+
898
+ /**
899
+ * Checks if given argument contains a hashbang and returns it
900
+ */
901
+ isHashbanged: function( thingy ) {
902
+ var str = String( thingy ).replace( /\"/g, "" );
903
+
904
+ return str.slice( 0, 3 ) == "url" ? str.slice( str.indexOf( "#" ) + 1, str.length - 1 ) : false;
905
+ },
906
+
907
+ /**
908
+ * Checks if given event has been thrown with pressed click / touch
909
+ */
910
+ isPressed: function( event ) {
911
+ // IE EXCEPTION
912
+ if ( event.type == "mousemove" && event.which === 1 ) {
913
+ // IGNORE
914
+
915
+ // OTHERS
916
+ } else if (
917
+ event.type == "touchmove" ||
918
+ event.buttons === 1 ||
919
+ event.button === 1 ||
920
+ event.which === 1
921
+ ) {
922
+ _this.drawing.buffer.isPressed = true;
923
+ } else {
924
+ _this.drawing.buffer.isPressed = false;
925
+ }
926
+ return _this.drawing.buffer.isPressed;
927
+ },
928
+
929
+ /**
930
+ * Checks if given source needs to be removed
931
+ */
932
+ removeImage: function( source ) {
933
+ if ( source ) {
934
+
935
+ // FORCE REMOVAL
936
+ if ( _this.config.fabric.forceRemoveImages ) {
937
+ return true;
938
+
939
+ // REMOVE TAINTED
940
+ } else if ( _this.config.fabric.removeImages && _this.isTainted( source ) ) {
941
+ return true;
942
+
943
+ // IE 10 internal bug handling SVG images in canvas context
944
+ } else if ( _this.setup.isIE && ( _this.setup.IEversion == 10 || _this.setup.IEversion == 11 ) && source.toLowerCase().indexOf( ".svg" ) != -1 ) {
945
+ return true;
946
+ }
947
+ }
948
+ return false
949
+ },
950
+
951
+ /**
952
+ * Checks if given source is within the current origin
953
+ */
954
+ isTainted: function( source ) {
955
+ var origin = String( window.location.origin || window.location.protocol + "//" + window.location.hostname + ( window.location.port ? ':' + window.location.port : '' ) );
956
+
957
+ // CHECK GIVEN SOURCE
958
+ if ( source ) {
959
+ // LOCAL FILES ARE ALWAYS TAINTED
960
+ if (
961
+ origin.indexOf( ":\\" ) != -1 || source.indexOf( ":\\" ) != -1 ||
962
+ origin.indexOf( "file://" ) != -1 || source.indexOf( "file://" ) != -1
963
+ ) {
964
+ return true
965
+
966
+ // MISMATCHING ORIGIN
967
+ } else if ( source.indexOf( "//" ) != -1 && source.indexOf( origin.replace( /.*:/, "" ) ) == -1 ) {
968
+ return true;
969
+ }
970
+ }
971
+
972
+ return false;
973
+ },
974
+
975
+ /*
976
+ ** Checks several indicators for acceptance;
977
+ */
978
+ isSupported: function() {
979
+ // CHECK CONFIG
980
+ if ( !_this.config.enabled ) {
981
+ return false;
982
+ }
983
+
984
+ // CHECK IE; ATTEMPT TO ACCESS HEAD ELEMENT
985
+ if ( _this.setup.isIE && _this.setup.IEversion <= 9 ) {
986
+ if ( !Array.prototype.indexOf || !document.head || _this.config.fallback === false ) {
987
+ return false;
988
+ }
989
+ }
990
+ return true;
991
+ },
992
+
993
+
994
+ getAngle: function( x1, y1, x2, y2 ) {
995
+ var x = x2 - x1;
996
+ var y = y2 - y1;
997
+ var angle;
998
+ if ( x == 0 ) {
999
+ if ( y == 0 ) {
1000
+ angle = 0;
1001
+ } else if ( y > 0 ) {
1002
+ angle = Math.PI / 2;
1003
+ } else {
1004
+ angle = Math.PI * 3 / 2;
1005
+ }
1006
+ } else if ( y == 0 ) {
1007
+ if ( x > 0 ) {
1008
+ angle = 0;
1009
+ } else {
1010
+ angle = Math.PI;
1011
+ }
1012
+ } else {
1013
+ if ( x < 0 ) {
1014
+ angle = Math.atan( y / x ) + Math.PI;
1015
+ } else if ( y < 0 ) {
1016
+ angle = Math.atan( y / x ) + ( 2 * Math.PI );
1017
+ } else {
1018
+ angle = Math.atan( y / x );
1019
+ }
1020
+ }
1021
+ return angle * 180 / Math.PI;
1022
+ },
1023
+
1024
+ /**
1025
+ * Recursive method which crawls upwards to gather the requested attribute
1026
+ */
1027
+ gatherAttribute: function( elm, attr, limit, lvl ) {
1028
+ var value, lvl = lvl ? lvl : 0,
1029
+ limit = limit ? limit : 3;
1030
+ if ( elm ) {
1031
+ value = elm.getAttribute( attr );
1032
+
1033
+ if ( !value && lvl < limit ) {
1034
+ return _this.gatherAttribute( elm.parentNode, attr, limit, lvl + 1 );
1035
+ }
1036
+ }
1037
+ return value;
1038
+ },
1039
+
1040
+ /**
1041
+ * Recursive method which crawls upwards to gather the requested classname
1042
+ */
1043
+ gatherClassName: function( elm, className, limit, lvl ) {
1044
+ var value, lvl = lvl ? lvl : 0,
1045
+ limit = limit ? limit : 3;
1046
+
1047
+ if ( _this.isElement( elm ) ) {
1048
+ value = ( elm.getAttribute( "class" ) || "" ).split( " " ).indexOf( className ) != -1;
1049
+
1050
+ if ( !value && lvl < limit ) {
1051
+ return _this.gatherClassName( elm.parentNode, className, limit, lvl + 1 );
1052
+ } else if ( value ) {
1053
+ value = elm;
1054
+ }
1055
+ }
1056
+ return value;
1057
+ },
1058
+
1059
+ /**
1060
+ * Collects the clip-paths and patterns
1061
+ */
1062
+ gatherElements: function( group, cfg, images ) {
1063
+ var i1, i2;
1064
+ for ( i1 = 0; i1 < group.children.length; i1++ ) {
1065
+ var childNode = group.children[ i1 ];
1066
+
1067
+ // CLIPPATH
1068
+ if ( childNode.tagName == "clipPath" ) {
1069
+ var bbox = {};
1070
+ var transform = fabric.parseTransformAttribute( _this.gatherAttribute( childNode, "transform" ) );
1071
+
1072
+ // HIDE SIBLINGS; GATHER IT'S DIMENSIONS
1073
+ for ( i2 = 0; i2 < childNode.childNodes.length; i2++ ) {
1074
+ childNode.childNodes[ i2 ].setAttribute( "fill", "transparent" );
1075
+ bbox = {
1076
+ x: _this.pxToNumber( childNode.childNodes[ i2 ].getAttribute( "x" ) ),
1077
+ y: _this.pxToNumber( childNode.childNodes[ i2 ].getAttribute( "y" ) ),
1078
+ width: _this.pxToNumber( childNode.childNodes[ i2 ].getAttribute( "width" ) ),
1079
+ height: _this.pxToNumber( childNode.childNodes[ i2 ].getAttribute( "height" ) )
1080
+ }
1081
+ }
1082
+
1083
+ group.clippings[ childNode.id ] = {
1084
+ svg: childNode,
1085
+ bbox: bbox,
1086
+ transform: transform
1087
+ };
1088
+
1089
+ // PATTERN
1090
+ } else if ( childNode.tagName == "pattern" ) {
1091
+ var props = {
1092
+ node: childNode,
1093
+ source: childNode.getAttribute( "xlink:href" ),
1094
+ width: Number( childNode.getAttribute( "width" ) ),
1095
+ height: Number( childNode.getAttribute( "height" ) ),
1096
+ repeat: "repeat",
1097
+ offsetX: 0,
1098
+ offsetY: 0
1099
+ }
1100
+
1101
+ // GATHER BACKGROUND
1102
+ for ( i2 = 0; i2 < childNode.childNodes.length; i2++ ) {
1103
+ // RECT; COLOR
1104
+ if ( childNode.childNodes[ i2 ].tagName == "rect" ) {
1105
+ props.fill = childNode.childNodes[ i2 ].getAttribute( "fill" );
1106
+
1107
+ // IMAGE
1108
+ } else if ( childNode.childNodes[ i2 ].tagName == "image" ) {
1109
+ var attrs = fabric.parseAttributes( childNode.childNodes[ i2 ], fabric.SHARED_ATTRIBUTES );
1110
+
1111
+ if ( attrs.transformMatrix ) {
1112
+ props.offsetX = attrs.transformMatrix[ 4 ];
1113
+ props.offsetY = attrs.transformMatrix[ 5 ];
1114
+ }
1115
+ }
1116
+ }
1117
+
1118
+ // TAINTED
1119
+ if ( _this.removeImage( props.source ) ) {
1120
+ group.patterns[ childNode.id ] = props.fill ? props.fill : "transparent";
1121
+ } else {
1122
+ group.patterns[ props.node.id ] = props;
1123
+ }
1124
+
1125
+ // IMAGES
1126
+ } else if ( childNode.tagName == "image" ) {
1127
+ images.included++;
1128
+
1129
+ // LOAD IMAGE MANUALLY; TO RERENDER THE CANVAS
1130
+ fabric.Image.fromURL( childNode.getAttribute( "xlink:href" ), function( img ) {
1131
+ images.loaded++;
1132
+ } );
1133
+
1134
+ // FILL STROKE POLYFILL ON EVERY ELEMENT
1135
+ } else {
1136
+ var attrs = [ "fill", "stroke" ];
1137
+ for ( i2 = 0; i2 < attrs.length; i2++ ) {
1138
+ var attr = attrs[ i2 ];
1139
+ var attrVal = childNode.getAttribute( attr );
1140
+ var attrRGBA = _this.getRGBA( attrVal );
1141
+ var isHashbanged = _this.isHashbanged( attrVal );
1142
+
1143
+ // VALIDATE AND RESET UNKNOWN COLORS (avoids fabric to crash)
1144
+ if ( attrVal && !attrRGBA && !isHashbanged ) {
1145
+ childNode.setAttribute( attr, "none" );
1146
+ childNode.setAttribute( attr + "-opacity", "0" );
1147
+ }
1148
+ }
1149
+ }
1150
+ }
1151
+ return group;
1152
+ },
1153
+
1154
+ /*
1155
+ ** GET RGBA COLOR ARRAY FROM INPUT
1156
+ */
1157
+ getRGBA: function( source, returnInstance ) {
1158
+
1159
+ if ( source != "none" && source != "transparent" && !_this.isHashbanged( source ) ) {
1160
+ source = new fabric.Color( source );
1161
+
1162
+ if ( source._source ) {
1163
+ return returnInstance ? source : source.getSource();
1164
+ }
1165
+ }
1166
+
1167
+ return false;
1168
+ },
1169
+
1170
+ /*
1171
+ ** GATHER MOUSE POSITION;
1172
+ */
1173
+ gatherPosition: function( event, type ) {
1174
+ var ref = _this.drawing.buffer.position;
1175
+ var ivt = fabric.util.invertTransform( _this.setup.fabric.viewportTransform );
1176
+ var pos;
1177
+
1178
+ if ( event.type == "touchmove" ) {
1179
+ if ( "touches" in event ) {
1180
+ event = event.touches[ 0 ];
1181
+ } else if ( "changedTouches" in event ) {
1182
+ event = event.changedTouches[ 0 ];
1183
+ }
1184
+ }
1185
+
1186
+ pos = fabric.util.transformPoint( _this.setup.fabric.getPointer( event, true ), ivt );
1187
+
1188
+ if ( type == 1 ) {
1189
+ ref.x1 = pos.x;
1190
+ ref.y1 = pos.y;
1191
+ }
1192
+
1193
+ ref.x2 = pos.x;
1194
+ ref.y2 = pos.y;
1195
+ ref.xD = ( ref.x1 - ref.x2 ) < 0 ? ( ref.x1 - ref.x2 ) * -1 : ( ref.x1 - ref.x2 );
1196
+ ref.yD = ( ref.y1 - ref.y2 ) < 0 ? ( ref.y1 - ref.y2 ) * -1 : ( ref.y1 - ref.y2 );
1197
+
1198
+ return ref;
1199
+ },
1200
+
1201
+ modifyFabric: function() {
1202
+
1203
+ // ADAPTED THE WAY TO RECEIVE THE GRADIENTID
1204
+ fabric.ElementsParser.prototype.resolveGradient = function( obj, property ) {
1205
+
1206
+ var instanceFillValue = obj.get( property );
1207
+ if ( !( /^url\(/ ).test( instanceFillValue ) ) {
1208
+ return;
1209
+ }
1210
+ var gradientId = instanceFillValue.slice( instanceFillValue.indexOf( "#" ) + 1, instanceFillValue.length - 1 );
1211
+ if ( fabric.gradientDefs[ this.svgUid ][ gradientId ] ) {
1212
+ var tmp = fabric.Gradient.fromElement( fabric.gradientDefs[ this.svgUid ][ gradientId ], obj );
1213
+
1214
+ // WORKAROUND FOR VERTICAL GRADIENT ISSUE; FOR NONE PIE CHARTS
1215
+ if ( tmp.coords.y1 && _this.setup.chart.type != "pie" ) {
1216
+ tmp.coords.y2 = tmp.coords.y1 * -1;
1217
+ tmp.coords.y1 = 0;
1218
+ }
1219
+ obj.set( property, tmp );
1220
+ }
1221
+ };
1222
+
1223
+ // MULTILINE SUPPORT; TODO: BETTER POSITIONING
1224
+ fabric.Text.fromElement = function( element, options ) {
1225
+ if ( !element ) {
1226
+ return null;
1227
+ }
1228
+
1229
+ var parsedAttributes = fabric.parseAttributes( element, fabric.Text.ATTRIBUTE_NAMES );
1230
+ options = fabric.util.object.extend( ( options ? fabric.util.object.clone( options ) : {} ), parsedAttributes );
1231
+
1232
+ options.top = options.top || 0;
1233
+ options.left = options.left || 0;
1234
+ if ( 'dx' in parsedAttributes ) {
1235
+ options.left += parsedAttributes.dx;
1236
+ }
1237
+ if ( 'dy' in parsedAttributes ) {
1238
+ options.top += parsedAttributes.dy;
1239
+ }
1240
+ if ( !( 'fontSize' in options ) ) {
1241
+ options.fontSize = fabric.Text.DEFAULT_SVG_FONT_SIZE;
1242
+ }
1243
+
1244
+ if ( !options.originX ) {
1245
+ options.originX = 'left';
1246
+ }
1247
+
1248
+ var textContent = '';
1249
+ var textBuffer = [];
1250
+
1251
+ // The XML is not properly parsed in IE9 so a workaround to get
1252
+ // textContent is through firstChild.data. Another workaround would be
1253
+ // to convert XML loaded from a file to be converted using DOMParser (same way loadSVGFromString() does)
1254
+ if ( !( 'textContent' in element ) ) {
1255
+ if ( 'firstChild' in element && element.firstChild !== null ) {
1256
+ if ( 'data' in element.firstChild && element.firstChild.data !== null ) {
1257
+ textBuffer.push( element.firstChild.data );
1258
+ }
1259
+ }
1260
+ } else if ( element.childNodes ) {
1261
+ for ( var i1 = 0; i1 < element.childNodes.length; i1++ ) {
1262
+ textBuffer.push( element.childNodes[ i1 ].textContent );
1263
+ }
1264
+ } else {
1265
+ textBuffer.push( element.textContent );
1266
+ }
1267
+
1268
+ textContent = textBuffer.join( "\n" );
1269
+ //textContent = textContent.replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' ');
1270
+
1271
+ var text = new fabric.Text( textContent, options ),
1272
+ /*
1273
+ Adjust positioning:
1274
+ x/y attributes in SVG correspond to the bottom-left corner of text bounding box
1275
+ top/left properties in Fabric correspond to center point of text bounding box
1276
+ */
1277
+ offX = 0;
1278
+
1279
+ if ( text.originX === 'left' ) {
1280
+ offX = text.getWidth() / 2;
1281
+ }
1282
+ if ( text.originX === 'right' ) {
1283
+ offX = -text.getWidth() / 2;
1284
+ }
1285
+
1286
+ if ( textBuffer.length > 1 ) {
1287
+
1288
+ text.set( {
1289
+ left: text.getLeft() + offX,
1290
+ top: text.getTop() + text.fontSize * ( textBuffer.length - 1 ) * ( 0.18 + text._fontSizeFraction ),
1291
+ textAlign: options.originX,
1292
+ lineHeight: textBuffer.length > 1 ? 0.965 : 1.16,
1293
+ } );
1294
+
1295
+ } else {
1296
+ text.set( {
1297
+ left: text.getLeft() + offX,
1298
+ top: text.getTop() - text.getHeight() / 2 + text.fontSize * ( 0.18 + text._fontSizeFraction ) /* 0.3 is the old lineHeight */
1299
+ } );
1300
+ }
1301
+
1302
+ return text;
1303
+ };
1304
+ },
1305
+
1306
+ /**
1307
+ * Method to capture the current state of the chart
1308
+ */
1309
+ capture: function( options, callback ) {
1310
+ var i1;
1311
+ var cfg = _this.deepMerge( _this.deepMerge( {}, _this.config.fabric ), options || {} );
1312
+ var groups = [];
1313
+ var offset = {
1314
+ x: 0,
1315
+ y: 0,
1316
+ pX: 0,
1317
+ pY: 0,
1318
+ lX: 0,
1319
+ lY: 0,
1320
+ width: _this.setup.chart.divRealWidth,
1321
+ height: _this.setup.chart.divRealHeight
1322
+ };
1323
+ var images = {
1324
+ loaded: 0,
1325
+ included: 0
1326
+ }
1327
+ var legends = {
1328
+ items: [],
1329
+ width: 0,
1330
+ height: 0,
1331
+ maxWidth: 0,
1332
+ maxHeight: 0
1333
+ }
1334
+
1335
+ // NAMESPACE CHECK
1336
+ if ( !_this.handleNamespace( "fabric", {
1337
+ scope: this,
1338
+ cb: _this.capture,
1339
+ args: arguments
1340
+ } ) ) {
1341
+ return false;
1342
+ }
1343
+
1344
+ // MODIFY FABRIC UNTIL IT'S OFFICIALLY SUPPORTED
1345
+ _this.modifyFabric();
1346
+
1347
+ // BEFORE CAPTURING
1348
+ _this.handleCallback( cfg.beforeCapture, cfg );
1349
+
1350
+ // GATHER SVGS
1351
+ var svgs = _this.setup.chart.containerDiv.getElementsByTagName( "svg" );
1352
+ for ( i1 = 0; i1 < svgs.length; i1++ ) {
1353
+ var group = {
1354
+ svg: svgs[ i1 ],
1355
+ parent: svgs[ i1 ].parentNode,
1356
+ children: svgs[ i1 ].getElementsByTagName( "*" ),
1357
+ offset: {
1358
+ x: 0,
1359
+ y: 0
1360
+ },
1361
+ patterns: {},
1362
+ clippings: {},
1363
+ has: {
1364
+ legend: false,
1365
+ panel: false,
1366
+ scrollbar: false
1367
+ }
1368
+ }
1369
+
1370
+ // CHECK IT'S SURROUNDINGS
1371
+ group.has.legend = _this.gatherClassName( group.parent, _this.setup.chart.classNamePrefix + "-legend-div", 1 );
1372
+ group.has.panel = _this.gatherClassName( group.parent, _this.setup.chart.classNamePrefix + "-stock-panel-div" );
1373
+ group.has.scrollbar = _this.gatherClassName( group.parent, _this.setup.chart.classNamePrefix + "-scrollbar-chart-div" );
1374
+
1375
+ // GATHER ELEMENTS
1376
+ group = _this.gatherElements( group, cfg, images );
1377
+
1378
+ // APPEND GROUP
1379
+ groups.push( group );
1380
+ }
1381
+
1382
+ // GATHER EXTERNAL LEGEND
1383
+ if ( _this.config.legend ) {
1384
+
1385
+ // STOCK
1386
+ if ( _this.setup.chart.type == "stock" ) {
1387
+ for ( i1 = 0; i1 < _this.setup.chart.panels.length; i1++ ) {
1388
+ if ( _this.setup.chart.panels[ i1 ].stockLegend && _this.setup.chart.panels[ i1 ].stockLegend.divId ) {
1389
+ legends.items.push( _this.setup.chart.panels[ i1 ].stockLegend );
1390
+ }
1391
+ }
1392
+
1393
+ // NORMAL
1394
+ } else if ( _this.setup.chart.legend && _this.setup.chart.legend.divId ) {
1395
+ legends.items.push( _this.setup.chart.legend );
1396
+ }
1397
+
1398
+ // WALKTHROUGH
1399
+ for ( i1 = 0; i1 < legends.items.length; i1++ ) {
1400
+ var legend = legends.items[ i1 ];
1401
+ var group = {
1402
+ svg: legend.container.container,
1403
+ parent: legend.container.container.parentNode,
1404
+ children: legend.container.container.getElementsByTagName( "*" ),
1405
+ offset: {
1406
+ x: 0,
1407
+ y: 0
1408
+ },
1409
+ legend: {
1410
+ id: i1,
1411
+ type: [ "top", "left" ].indexOf( _this.config.legend.position ) != -1 ? "unshift" : "push",
1412
+ position: _this.config.legend.position,
1413
+ width: _this.config.legend.width ? _this.config.legend.width : legend.container.div.offsetWidth,
1414
+ height: _this.config.legend.height ? _this.config.legend.height : legend.container.div.offsetHeight
1415
+ },
1416
+ patterns: {},
1417
+ clippings: {},
1418
+ has: {
1419
+ legend: false,
1420
+ panel: false,
1421
+ scrollbar: false
1422
+ }
1423
+ }
1424
+
1425
+ // GATHER DIMENSIONS
1426
+ legends.width += group.legend.width;
1427
+ legends.height += group.legend.height;
1428
+ legends.maxWidth = group.legend.width > legends.maxWidth ? group.legend.width : legends.maxWidth;
1429
+ legends.maxHeight = group.legend.height > legends.maxHeight ? group.legend.height : legends.maxHeight;
1430
+
1431
+ // GATHER ELEMENTS
1432
+ group = _this.gatherElements( group, cfg, images );
1433
+
1434
+ // PRE/APPEND SVG
1435
+ groups[ group.legend.type ]( group );
1436
+ }
1437
+
1438
+ // ADAPT WIDTH IF NEEDED; EXPAND HEIGHT
1439
+ if ( [ "top", "bottom" ].indexOf( _this.config.legend.position ) != -1 ) {
1440
+ offset.width = legends.maxWidth > offset.width ? legends.maxWidth : offset.width;
1441
+ offset.height += legends.height;
1442
+
1443
+ // EXPAND WIDTH; ADAPT HEIGHT IF NEEDED
1444
+ } else if ( [ "left", "right" ].indexOf( _this.config.legend.position ) != -1 ) {
1445
+ offset.width += legends.maxWidth;
1446
+ offset.height = legends.height > offset.height ? legends.height : offset.height;
1447
+
1448
+ // SIMPLY EXPAND CANVAS
1449
+ } else {
1450
+ offset.height += legends.height;
1451
+ offset.width += legends.maxWidth;
1452
+ }
1453
+
1454
+ }
1455
+
1456
+ // CLEAR IF EXIST
1457
+ _this.drawing.enabled = cfg.drawing.enabled = cfg.action == "draw";
1458
+ _this.drawing.buffer.enabled = _this.drawing.enabled; // history reasons
1459
+
1460
+ _this.setup.wrapper = document.createElement( "div" );
1461
+ _this.setup.wrapper.setAttribute( "class", _this.setup.chart.classNamePrefix + "-export-canvas" );
1462
+ _this.setup.chart.containerDiv.appendChild( _this.setup.wrapper );
1463
+
1464
+ // STOCK CHART; SELECTOR OFFSET
1465
+ if ( _this.setup.chart.type == "stock" ) {
1466
+ var padding = {
1467
+ top: 0,
1468
+ right: 0,
1469
+ bottom: 0,
1470
+ left: 0
1471
+ }
1472
+ if ( _this.setup.chart.leftContainer ) {
1473
+ offset.width -= _this.setup.chart.leftContainer.offsetWidth;
1474
+ padding.left = _this.setup.chart.leftContainer.offsetWidth + ( _this.setup.chart.panelsSettings.panelSpacing * 2 );
1475
+ }
1476
+ if ( _this.setup.chart.rightContainer ) {
1477
+ offset.width -= _this.setup.chart.rightContainer.offsetWidth;
1478
+ padding.right = _this.setup.chart.rightContainer.offsetWidth + ( _this.setup.chart.panelsSettings.panelSpacing * 2 );
1479
+ }
1480
+ if ( _this.setup.chart.periodSelector && [ "top", "bottom" ].indexOf( _this.setup.chart.periodSelector.position ) != -1 ) {
1481
+ offset.height -= _this.setup.chart.periodSelector.offsetHeight + _this.setup.chart.panelsSettings.panelSpacing;
1482
+ padding[ _this.setup.chart.periodSelector.position ] += _this.setup.chart.periodSelector.offsetHeight + _this.setup.chart.panelsSettings.panelSpacing;
1483
+ }
1484
+ if ( _this.setup.chart.dataSetSelector && [ "top", "bottom" ].indexOf( _this.setup.chart.dataSetSelector.position ) != -1 ) {
1485
+ offset.height -= _this.setup.chart.dataSetSelector.offsetHeight;
1486
+ padding[ _this.setup.chart.dataSetSelector.position ] += _this.setup.chart.dataSetSelector.offsetHeight;
1487
+ }
1488
+
1489
+ // APPLY OFFSET ON WRAPPER
1490
+ _this.setup.wrapper.style.paddingTop = _this.numberToPx( padding.top );
1491
+ _this.setup.wrapper.style.paddingRight = _this.numberToPx( padding.right );
1492
+ _this.setup.wrapper.style.paddingBottom = _this.numberToPx( padding.bottom );
1493
+ _this.setup.wrapper.style.paddingLeft = _this.numberToPx( padding.left );
1494
+ }
1495
+
1496
+ // CREATE CANVAS
1497
+ _this.setup.canvas = document.createElement( "canvas" );
1498
+ _this.setup.wrapper.appendChild( _this.setup.canvas );
1499
+
1500
+ // PREPARE CONFIG FOR FABRIC INSTANCE
1501
+ var fabricCFG = _this.removeFunctionsFromObject(_this.deepMerge( {
1502
+ width: offset.width,
1503
+ height: offset.height,
1504
+ isDrawingMode: true
1505
+ }, cfg ));
1506
+
1507
+ // INITIATE FABRIC INSTANCE
1508
+ _this.setup.fabric = new fabric.Canvas( _this.setup.canvas, fabricCFG );
1509
+
1510
+ // REAPPLY FOR SOME REASON
1511
+ _this.deepMerge( _this.setup.fabric, cfg );
1512
+ _this.deepMerge( _this.setup.fabric.freeDrawingBrush, cfg.drawing );
1513
+
1514
+ // RELIABLE VARIABLES; UPDATE DRAWING
1515
+ _this.deepMerge( _this.drawing, cfg.drawing );
1516
+ _this.drawing.handler.change( cfg.drawing );
1517
+
1518
+ // OBSERVE MOUSE EVENTS
1519
+ _this.setup.fabric.on( "mouse:down", function( e ) {
1520
+ var p = _this.gatherPosition( e.e, 1 );
1521
+ _this.drawing.buffer.pressedTS = Number( new Date() );
1522
+ _this.isPressed( e.e );
1523
+
1524
+ // FLAG ISDRAWING
1525
+ _this.drawing.buffer.isDrawing = false;
1526
+ _this.drawing.buffer.isDrawingTimer = setTimeout( function() {
1527
+ if ( !_this.drawing.buffer.isSelected ) {
1528
+ _this.drawing.buffer.isDrawing = true;
1529
+ }
1530
+ }, 200 );
1531
+ } );
1532
+ _this.setup.fabric.on( "mouse:move", function( e ) {
1533
+ var p = _this.gatherPosition( e.e, 2 );
1534
+ _this.isPressed( e.e );
1535
+
1536
+ // IS PRESSED BUT UNSELECTED
1537
+ if ( _this.drawing.buffer.isPressed && !_this.drawing.buffer.isSelected ) {
1538
+
1539
+ // FLAG ISDRAWING
1540
+ _this.drawing.buffer.isDrawing = true;
1541
+
1542
+ // CREATE INITIAL LINE / ARROW; JUST ON LEFT CLICK
1543
+ if ( !_this.drawing.buffer.line && _this.drawing.mode != "pencil" && ( p.xD > 5 || p.yD > 5 ) ) {
1544
+
1545
+ // FORCE FABRIC TO DISABLE DRAWING MODE WHILE PRESSED / MOVEING MOUSE INPUT
1546
+ _this.setup.fabric.isDrawingMode = false;
1547
+ _this.setup.fabric._isCurrentlyDrawing = false;
1548
+ _this.drawing.buffer.ignoreUndoOnMouseUp = true;
1549
+ _this.setup.fabric.freeDrawingBrush.onMouseUp();
1550
+ _this.setup.fabric.remove( _this.setup.fabric._objects.pop() );
1551
+
1552
+ // INITIAL POINT
1553
+ _this.drawing.buffer.line = _this.drawing.handler.line( {
1554
+ x1: p.x1,
1555
+ y1: p.y1,
1556
+ x2: p.x2,
1557
+ y2: p.y2,
1558
+ arrow: _this.drawing.mode == "line" ? false : _this.drawing.arrow,
1559
+ action: "config"
1560
+ } );
1561
+ }
1562
+ }
1563
+
1564
+ if ( _this.drawing.buffer.isSelected ) {
1565
+ _this.setup.fabric.isDrawingMode = false;
1566
+ }
1567
+
1568
+ // UPDATE LINE / ARROW
1569
+ if ( _this.drawing.buffer.line ) {
1570
+ var obj, top, left;
1571
+ var l = _this.drawing.buffer.line;
1572
+
1573
+ l.x2 = p.x2;
1574
+ l.y2 = p.y2;
1575
+
1576
+ // // RESET INTERNAL FLAGS
1577
+ // _this.drawing.buffer.isDrawing = true;
1578
+ // _this.drawing.buffer.isPressed = true;
1579
+ // _this.drawing.buffer.hasLine = true;
1580
+
1581
+ for ( i1 = 0; i1 < l.group.length; i1++ ) {
1582
+ obj = l.group[ i1 ];
1583
+
1584
+ if ( obj instanceof fabric.Line ) {
1585
+ obj.set( {
1586
+ x2: l.x2,
1587
+ y2: l.y2
1588
+ } );
1589
+ } else if ( obj instanceof fabric.Triangle ) {
1590
+ l.angle = ( _this.getAngle( l.x1, l.y1, l.x2, l.y2 ) + 90 );
1591
+
1592
+ if ( l.arrow == "start" ) {
1593
+ top = l.y1 + ( l.width / 2 );
1594
+ left = l.x1 + ( l.width / 2 );
1595
+ } else if ( l.arrow == "middle" ) {
1596
+ top = l.y2 + ( l.width / 2 ) - ( ( l.y2 - l.y1 ) / 2 );
1597
+ left = l.x2 + ( l.width / 2 ) - ( ( l.x2 - l.x1 ) / 2 );
1598
+ } else { // arrow: end
1599
+ top = l.y2 + ( l.width / 2 );
1600
+ left = l.x2 + ( l.width / 2 );
1601
+ }
1602
+
1603
+ obj.set( {
1604
+ top: top,
1605
+ left: left,
1606
+ angle: l.angle
1607
+ } );
1608
+ }
1609
+ }
1610
+ _this.setup.fabric.renderAll();
1611
+ }
1612
+ } );
1613
+ _this.setup.fabric.on( "mouse:up", function( e ) {
1614
+ // SELECT TARGET
1615
+ if ( !_this.drawing.buffer.isDrawing ) {
1616
+ var target = _this.setup.fabric.findTarget( e.e );
1617
+ if ( target && target.selectable ) {
1618
+ _this.setup.fabric.setActiveObject( target );
1619
+ }
1620
+ }
1621
+
1622
+ // UPDATE LINE / ARROW
1623
+ if ( _this.drawing.buffer.line ) {
1624
+ for ( i1 = 0; i1 < _this.drawing.buffer.line.group.length; i1++ ) {
1625
+ _this.drawing.buffer.line.group[ i1 ].remove();
1626
+ }
1627
+ delete _this.drawing.buffer.line.action;
1628
+ delete _this.drawing.buffer.line.group;
1629
+ _this.drawing.handler.line( _this.drawing.buffer.line );
1630
+ }
1631
+ _this.drawing.buffer.line = false;
1632
+ _this.drawing.buffer.hasLine = false;
1633
+ _this.drawing.buffer.isPressed = false;
1634
+
1635
+ // RESET ISDRAWING FLAG
1636
+ clearTimeout( _this.drawing.buffer.isDrawingTimer );
1637
+ _this.drawing.buffer.isDrawing = false;
1638
+ } );
1639
+
1640
+ // OBSERVE OBJECT SELECTION
1641
+ _this.setup.fabric.on( "object:selected", function( e ) {
1642
+ _this.drawing.buffer.isSelected = true;
1643
+ _this.drawing.buffer.target = e.target;
1644
+ _this.setup.fabric.isDrawingMode = false;
1645
+ } );
1646
+ _this.setup.fabric.on( "selection:cleared", function( e ) {
1647
+ _this.drawing.buffer.target = false;
1648
+
1649
+ // FREEHAND WORKAROUND
1650
+ if ( _this.drawing.buffer.isSelected ) {
1651
+ _this.setup.fabric._isCurrentlyDrawing = false;
1652
+ }
1653
+
1654
+ _this.drawing.buffer.isSelected = false;
1655
+ _this.setup.fabric.isDrawingMode = true;
1656
+ } );
1657
+ _this.setup.fabric.on( "path:created", function( e ) {
1658
+ var item = e.path;
1659
+ if ( !_this.drawing.buffer.isDrawing || _this.drawing.buffer.hasLine ) {
1660
+ _this.setup.fabric.remove( item );
1661
+ _this.setup.fabric.renderAll();
1662
+ return;
1663
+ }
1664
+ } );
1665
+
1666
+ // OBSERVE OBJECT MODIFICATIONS
1667
+ _this.setup.fabric.on( "object:added", function( e ) {
1668
+ var item = e.target;
1669
+ var state = _this.deepMerge( item.saveState()._stateProperties, {
1670
+ cfg: {
1671
+ color: _this.drawing.color,
1672
+ width: _this.drawing.width,
1673
+ opacity: _this.drawing.opacity,
1674
+ fontSize: _this.drawing.fontSize
1675
+ }
1676
+ } );
1677
+
1678
+ state = JSON.stringify( state );
1679
+ item.recentState = state;
1680
+
1681
+ if ( _this.drawing.buffer.ignoreUndoOnMouseUp || !_this.drawing.buffer.isDrawing ) {
1682
+ _this.drawing.buffer.ignoreUndoOnMouseUp = false;
1683
+ return;
1684
+ }
1685
+
1686
+ if ( item.selectable && !item.known && !item.ignoreUndo ) {
1687
+ item.isAnnotation = true;
1688
+ _this.drawing.undos.push( {
1689
+ action: "added",
1690
+ target: item,
1691
+ state: state
1692
+ } );
1693
+ _this.drawing.redos = [];
1694
+ }
1695
+
1696
+ item.known = true;
1697
+ _this.setup.fabric.isDrawingMode = true;
1698
+ } );
1699
+ _this.setup.fabric.on( "object:modified", function( e ) {
1700
+ var item = e.target;
1701
+ var recentState = JSON.parse( item.recentState );
1702
+ var state = _this.deepMerge( item.saveState()._stateProperties, {
1703
+ cfg: recentState.cfg
1704
+ } );
1705
+
1706
+ state = JSON.stringify( state );
1707
+ item.recentState = state;
1708
+
1709
+ _this.drawing.undos.push( {
1710
+ action: "modified",
1711
+ target: item,
1712
+ state: state
1713
+ } );
1714
+
1715
+ _this.drawing.redos = [];
1716
+ } );
1717
+ _this.setup.fabric.on( "text:changed", function( e ) {
1718
+ var item = e.target;
1719
+ clearTimeout( item.timer );
1720
+ item.timer = setTimeout( function() {
1721
+ var state = JSON.stringify( item.saveState()._stateProperties );
1722
+
1723
+ item.recentState = state;
1724
+
1725
+ _this.drawing.redos = [];
1726
+ _this.drawing.undos.push( {
1727
+ action: "modified",
1728
+ target: item,
1729
+ state: state
1730
+ } );
1731
+ }, 250 );
1732
+ } );
1733
+
1734
+ // DRAWING
1735
+ if ( _this.drawing.enabled ) {
1736
+ _this.setup.wrapper.setAttribute( "class", _this.setup.chart.classNamePrefix + "-export-canvas active" );
1737
+ _this.setup.wrapper.style.backgroundColor = cfg.backgroundColor;
1738
+ _this.setup.wrapper.style.display = "block";
1739
+
1740
+ } else {
1741
+ _this.setup.wrapper.setAttribute( "class", _this.setup.chart.classNamePrefix + "-export-canvas" );
1742
+ _this.setup.wrapper.style.display = "none";
1743
+ }
1744
+
1745
+ for ( i1 = 0; i1 < groups.length; i1++ ) {
1746
+ var group = groups[ i1 ];
1747
+
1748
+ // STOCK CHART; SVG OFFSET; SVG OFFSET
1749
+ if ( _this.setup.chart.type == "stock" && _this.setup.chart.legendSettings.position ) {
1750
+
1751
+ // TOP / BOTTOM
1752
+ if ( [ "top", "bottom" ].indexOf( _this.setup.chart.legendSettings.position ) != -1 ) {
1753
+
1754
+ // POSITION; ABSOLUTE
1755
+ if ( group.parent.style.top && group.parent.style.left ) {
1756
+ group.offset.y = _this.pxToNumber( group.parent.style.top );
1757
+ group.offset.x = _this.pxToNumber( group.parent.style.left );
1758
+
1759
+ // POSITION; RELATIVE
1760
+ } else {
1761
+ group.offset.x = offset.x;
1762
+ group.offset.y = offset.y;
1763
+ offset.y += _this.pxToNumber( group.parent.style.height );
1764
+
1765
+ // LEGEND; OFFSET
1766
+ if ( group.has.panel ) {
1767
+ offset.pY = _this.pxToNumber( group.has.panel.style.marginTop );
1768
+ group.offset.y += offset.pY;
1769
+
1770
+ // SCROLLBAR; OFFSET
1771
+ } else if ( group.has.scrollbar ) {
1772
+ group.offset.y += offset.pY;
1773
+ }
1774
+ }
1775
+
1776
+ // LEFT / RIGHT
1777
+ } else if ( [ "left", "right" ].indexOf( _this.setup.chart.legendSettings.position ) != -1 ) {
1778
+ group.offset.y = _this.pxToNumber( group.parent.style.top ) + offset.pY;
1779
+ group.offset.x = _this.pxToNumber( group.parent.style.left ) + offset.pX;
1780
+
1781
+ // LEGEND; OFFSET
1782
+ if ( group.has.legend ) {
1783
+ offset.pY += _this.pxToNumber( group.has.panel.style.height ) + _this.setup.chart.panelsSettings.panelSpacing;
1784
+
1785
+ // SCROLLBAR; OFFSET
1786
+ } else if ( group.has.scrollbar ) {
1787
+ group.offset.y -= _this.setup.chart.panelsSettings.panelSpacing;
1788
+ }
1789
+ }
1790
+
1791
+ // REGULAR CHARTS; SVG OFFSET
1792
+ } else {
1793
+
1794
+ // POSITION; ABSOLUTE
1795
+ if ( group.parent.style.position == "absolute" ) {
1796
+ group.offset.absolute = true;
1797
+ group.offset.top = _this.pxToNumber( group.parent.style.top );
1798
+ group.offset.right = _this.pxToNumber( group.parent.style.right, true );
1799
+ group.offset.bottom = _this.pxToNumber( group.parent.style.bottom, true );
1800
+ group.offset.left = _this.pxToNumber( group.parent.style.left );
1801
+ group.offset.width = _this.pxToNumber( group.parent.style.width );
1802
+ group.offset.height = _this.pxToNumber( group.parent.style.height );
1803
+
1804
+ // POSITION; RELATIVE
1805
+ } else if ( group.parent.style.top && group.parent.style.left ) {
1806
+ group.offset.y = _this.pxToNumber( group.parent.style.top );
1807
+ group.offset.x = _this.pxToNumber( group.parent.style.left );
1808
+
1809
+ // POSITION; GENERIC
1810
+ } else {
1811
+
1812
+ // EXTERNAL LEGEND
1813
+ if ( group.legend ) {
1814
+ if ( group.legend.position == "left" ) {
1815
+ offset.x = legends.maxWidth;
1816
+ } else if ( group.legend.position == "right" ) {
1817
+ group.offset.x = offset.width - legends.maxWidth;
1818
+ } else if ( group.legend.position == "top" ) {
1819
+ offset.y += group.legend.height;
1820
+ } else if ( group.legend.position == "bottom" ) {
1821
+ group.offset.y = offset.height - legends.height;
1822
+ }
1823
+
1824
+ // STACK LEGENDS
1825
+ group.offset.y += offset.lY;
1826
+ offset.lY += group.legend.height;
1827
+
1828
+ // NORMAL
1829
+ } else {
1830
+ group.offset.x = offset.x;
1831
+ group.offset.y = offset.y + offset.pY;
1832
+ offset.y += _this.pxToNumber( group.parent.style.height );
1833
+ }
1834
+ }
1835
+
1836
+ // PANEL OFFSET (STOCK CHARTS)
1837
+ if ( group.has.legend && group.has.panel && group.has.panel.style.marginTop ) {
1838
+ offset.y += _this.pxToNumber( group.has.panel.style.marginTop );
1839
+ group.offset.y += _this.pxToNumber( group.has.panel.style.marginTop );
1840
+
1841
+ // GENERAL LEFT / RIGHT POSITION
1842
+ } else if ( _this.setup.chart.legend && [ "left", "right" ].indexOf( _this.setup.chart.legend.position ) != -1 ) {
1843
+ group.offset.y = _this.pxToNumber( group.parent.style.top );
1844
+ group.offset.x = _this.pxToNumber( group.parent.style.left );
1845
+ }
1846
+ }
1847
+
1848
+ // ADD TO CANVAS
1849
+ fabric.parseSVGDocument( group.svg, ( function( group ) {
1850
+ return function( objects, options ) {
1851
+ var i1, i2;
1852
+ var g = fabric.util.groupSVGElements( objects, options );
1853
+ var paths = [];
1854
+ var tmp = {
1855
+ selectable: false,
1856
+ isCoreElement: true
1857
+ };
1858
+
1859
+ // GROUP OFFSET; ABSOLUTE
1860
+ if ( group.offset.absolute ) {
1861
+ if ( group.offset.bottom !== undefined ) {
1862
+ tmp.top = offset.height - group.offset.height - group.offset.bottom;
1863
+ } else {
1864
+ tmp.top = group.offset.top;
1865
+ }
1866
+
1867
+ if ( group.offset.right !== undefined ) {
1868
+ tmp.left = offset.width - group.offset.width - group.offset.right;
1869
+ } else {
1870
+ tmp.left = group.offset.left;
1871
+ }
1872
+
1873
+ // GROUP OFFSET; REGULAR
1874
+ } else {
1875
+ tmp.top = group.offset.y;
1876
+ tmp.left = group.offset.x;
1877
+ }
1878
+
1879
+ // WALKTHROUGH ELEMENTS
1880
+ for ( i1 = 0; i1 < g.paths.length; i1++ ) {
1881
+ var PID = null;
1882
+
1883
+ // OPACITY; TODO: DISTINGUISH OPACITY TYPES
1884
+ if ( g.paths[ i1 ] ) {
1885
+
1886
+ // CHECK ORIGIN; REMOVE TAINTED
1887
+ if ( _this.removeImage( g.paths[ i1 ][ "xlink:href" ] ) ) {
1888
+ continue;
1889
+ }
1890
+
1891
+ // SET OPACITY
1892
+ if ( g.paths[ i1 ].fill instanceof Object ) {
1893
+
1894
+ // MISINTERPRETATION OF FABRIC
1895
+ if ( g.paths[ i1 ].fill.type == "radial" ) {
1896
+
1897
+ // OTHERS
1898
+ if ( [ "pie", "gauge" ].indexOf( _this.setup.chart.type ) == -1 ) {
1899
+ g.paths[ i1 ].fill.coords.r2 = g.paths[ i1 ].fill.coords.r1 * -1;
1900
+ g.paths[ i1 ].fill.coords.r1 = 0;
1901
+ g.paths[ i1 ].set( {
1902
+ opacity: g.paths[ i1 ].fillOpacity
1903
+ } );
1904
+ }
1905
+ }
1906
+
1907
+ // FILLING; TODO: DISTINGUISH OPACITY TYPES
1908
+ } else if ( PID = _this.isHashbanged( g.paths[ i1 ].fill ) ) {
1909
+
1910
+ // PATTERN
1911
+ if ( group.patterns && group.patterns[ PID ] ) {
1912
+
1913
+ var props = group.patterns[ PID ];
1914
+
1915
+ images.included++;
1916
+
1917
+ // LOAD IMAGE MANUALLY; TO RERENDER THE CANVAS
1918
+ fabric.Image.fromURL( props.source, ( function( props, i1 ) {
1919
+ return function( img ) {
1920
+ images.loaded++;
1921
+
1922
+ // ADAPT IMAGE
1923
+ img.set( {
1924
+ top: props.offsetY,
1925
+ left: props.offsetX,
1926
+ width: props.width,
1927
+ height: props.height
1928
+ } );
1929
+
1930
+ // RETINA DISPLAY
1931
+ if ( _this.setup.fabric._isRetinaScaling() ) {
1932
+ img.set( {
1933
+ top: props.offsetY / 2,
1934
+ left: props.offsetX / 2,
1935
+ scaleX: 0.5,
1936
+ scaleY: 0.5
1937
+ } );
1938
+ }
1939
+
1940
+ // CREATE CANVAS WITH BACKGROUND COLOR
1941
+ var patternSourceCanvas = new fabric.StaticCanvas( undefined, {
1942
+ backgroundColor: props.fill,
1943
+ width: img.getWidth(),
1944
+ height: img.getHeight()
1945
+ } );
1946
+ patternSourceCanvas.add( img );
1947
+
1948
+ // CREATE PATTERN OBTAIN OFFSET TO TARGET
1949
+ var pattern = new fabric.Pattern( {
1950
+ source: patternSourceCanvas.getElement(),
1951
+ offsetX: g.paths[ i1 ].width / 2,
1952
+ offsetY: g.paths[ i1 ].height / 2,
1953
+ repeat: 'repeat',
1954
+ } );
1955
+
1956
+ // ASSIGN TO OBJECT
1957
+ g.paths[ i1 ].set( {
1958
+ fill: pattern,
1959
+ opacity: g.paths[ i1 ].fillOpacity
1960
+ } );
1961
+ }
1962
+ } )( props, i1 ) );
1963
+ }
1964
+ }
1965
+
1966
+ // CLIPPATH;
1967
+ if ( PID = _this.isHashbanged( g.paths[ i1 ].clipPath ) ) {
1968
+
1969
+ if ( group.clippings && group.clippings[ PID ] ) {
1970
+
1971
+ // TODO: WAIT UNTIL FABRICJS HANDLES CLIPPATH FOR SVG OUTPUT
1972
+ ( function( i1, PID ) {
1973
+ var toSVG = g.paths[ i1 ].toSVG;
1974
+
1975
+ g.paths[ i1 ].toSVG = function( original_reviver ) {
1976
+ return toSVG.apply( this, [ function( string ) {
1977
+ return original_reviver( string, group.clippings[ PID ] );
1978
+ } ] );
1979
+ }
1980
+ } )( i1, PID );
1981
+
1982
+ g.paths[ i1 ].set( {
1983
+ clipTo: ( function( i1, PID ) {
1984
+ return function( ctx ) {
1985
+ var cp = group.clippings[ PID ];
1986
+ var tm = this.transformMatrix || [ 1, 0, 0, 1, 0, 0 ];
1987
+ var dim = {
1988
+ top: cp.bbox.y,
1989
+ left: cp.bbox.x,
1990
+ width: cp.bbox.width,
1991
+ height: cp.bbox.height
1992
+ }
1993
+
1994
+ if ( _this.setup.chart.type == "map" ) {
1995
+ dim.top += cp.transform[ 5 ];
1996
+ dim.left += cp.transform[ 4 ];
1997
+ }
1998
+
1999
+ if ( cp.bbox.x && tm[ 4 ] && cp.bbox.y && tm[ 5 ] ) {
2000
+ dim.top -= tm[ 5 ];
2001
+ dim.left -= tm[ 4 ];
2002
+ }
2003
+
2004
+ // SMOOTHCUSTOMBULLETS PLUGIN SUPPORT; ROUND BORDER
2005
+ if (
2006
+ _this.setup.chart.smoothCustomBullets !== undefined &&
2007
+ this.className == _this.setup.chart.classNamePrefix + "-graph-bullet" &&
2008
+ g.paths[ i1 ].svg.tagName == "image"
2009
+ ) {
2010
+ radius = cp.svg.firstChild.rx.baseVal.value / 2 + 2;
2011
+ ctx.beginPath();
2012
+ ctx.moveTo(dim.left + radius, dim.top);
2013
+ ctx.lineTo(dim.left + dim.width - radius, dim.top);
2014
+ ctx.quadraticCurveTo(dim.left + dim.width, dim.top, dim.left + dim.width, dim.top + radius);
2015
+ ctx.lineTo(dim.left + dim.width, dim.top + dim.height - radius);
2016
+ ctx.quadraticCurveTo(dim.left + dim.width, dim.top + dim.height, dim.left + dim.width - radius, dim.top + dim.height);
2017
+ ctx.lineTo(dim.left + radius, dim.top + dim.height);
2018
+ ctx.quadraticCurveTo(dim.left, dim.top + dim.height, dim.left, dim.top + dim.height - radius);
2019
+ ctx.lineTo(dim.left, dim.top + radius);
2020
+ ctx.quadraticCurveTo(dim.left, dim.top, dim.left + radius, dim.top);
2021
+ ctx.closePath();
2022
+ } else {
2023
+ ctx.rect( dim.left, dim.top, dim.width, dim.height );
2024
+ }
2025
+ }
2026
+ } )( i1, PID )
2027
+ } );
2028
+ }
2029
+ }
2030
+ }
2031
+ paths.push( g.paths[ i1 ] );
2032
+ }
2033
+
2034
+ // REPLACE WITH WHITELIST
2035
+ g.paths = paths;
2036
+
2037
+ // SET PROPS
2038
+ g.set( tmp );
2039
+
2040
+ // ADD TO CANVAS
2041
+ _this.setup.fabric.add( g );
2042
+
2043
+ // ADD BALLOONS
2044
+ if ( group.svg.parentNode && group.svg.parentNode.getElementsByTagName ) {
2045
+ var balloons = group.svg.parentNode.getElementsByClassName( _this.setup.chart.classNamePrefix + "-balloon-div" );
2046
+ for ( i1 = 0; i1 < balloons.length; i1++ ) {
2047
+ if ( cfg.balloonFunction instanceof Function ) {
2048
+ cfg.balloonFunction.apply( _this, [ balloons[ i1 ], group ] );
2049
+ } else {
2050
+ var elm_parent = balloons[ i1 ];
2051
+ var style_parent = fabric.parseStyleAttribute( elm_parent );
2052
+ var style_text = fabric.parseStyleAttribute( elm_parent.childNodes[ 0 ] );
2053
+ var fabric_label = new fabric.Text( elm_parent.innerText || elm_parent.textContent || elm_parent.innerHTML, {
2054
+ selectable: false,
2055
+ top: _this.pxToNumber(style_parent.top) + group.offset.y,
2056
+ left: _this.pxToNumber(style_parent.left) + group.offset.x,
2057
+ fill: style_text[ "color" ],
2058
+ fontSize: _this.pxToNumber(style_text[ "fontSize" ] || style_text[ "font-size" ]),
2059
+ fontFamily: style_text[ "fontFamily" ] || style_text[ "font-family" ],
2060
+ textAlign: style_text[ "text-align" ],
2061
+ isCoreElement: true
2062
+ } );
2063
+
2064
+ _this.setup.fabric.add( fabric_label );
2065
+ }
2066
+ }
2067
+ }
2068
+
2069
+ if ( group.svg.nextSibling && group.svg.nextSibling.tagName == "A" ) {
2070
+ var elm_parent = group.svg.nextSibling;
2071
+ var style_parent = fabric.parseStyleAttribute( elm_parent );
2072
+ var fabric_label = new fabric.Text( elm_parent.innerText || elm_parent.textContent || elm_parent.innerHTML, {
2073
+ selectable: false,
2074
+ top: _this.pxToNumber(style_parent.top) + group.offset.y,
2075
+ left: _this.pxToNumber(style_parent.left) + group.offset.x,
2076
+ fill: style_parent[ "color" ],
2077
+ fontSize: _this.pxToNumber(style_parent[ "fontSize" ] || style_parent[ "font-size" ]),
2078
+ fontFamily: style_parent[ "fontFamily" ] || style_parent[ "font-family" ],
2079
+ opacity: style_parent[ "opacity" ],
2080
+ isCoreElement: true
2081
+ } );
2082
+
2083
+ if ( !group.has.scrollbar ) {
2084
+ _this.setup.fabric.add( fabric_label );
2085
+ }
2086
+ }
2087
+
2088
+ groups.pop();
2089
+
2090
+ // TRIGGER CALLBACK WITH SAFETY DELAY
2091
+ if ( !groups.length ) {
2092
+ var ts1 = Number( new Date() );
2093
+ var timer = setInterval( function() {
2094
+ var ts2 = Number( new Date() );
2095
+
2096
+ // WAIT FOR LOADED IMAGES OR UNTIL THE TIMEOUT KICKS IN
2097
+ if ( images.loaded == images.included || ts2 - ts1 > _this.config.fabric.loadTimeout ) {
2098
+ clearTimeout( timer );
2099
+ _this.handleBorder( cfg );
2100
+ _this.handleCallback( cfg.afterCapture, cfg );
2101
+ _this.setup.fabric.renderAll();
2102
+ _this.handleCallback( callback, cfg );
2103
+ }
2104
+ }, AmCharts.updateRate );
2105
+ }
2106
+ }
2107
+
2108
+ // IDENTIFY ELEMENTS THROUGH CLASSNAMES
2109
+ } )( group ), function( svg, obj ) {
2110
+ var i1;
2111
+ var className = _this.gatherAttribute( svg, "class" );
2112
+ var visibility = _this.gatherAttribute( svg, "visibility" );
2113
+ var clipPath = _this.gatherAttribute( svg, "clip-path" );
2114
+
2115
+ obj.className = String( className );
2116
+ obj.classList = String( className ).split( " " );
2117
+ obj.clipPath = clipPath;
2118
+ obj.svg = svg;
2119
+
2120
+ // TRANSPORT FILL/STROKE OPACITY
2121
+ var attrs = [ "fill", "stroke" ];
2122
+ for ( i1 = 0; i1 < attrs.length; i1++ ) {
2123
+ var attr = attrs[ i1 ]
2124
+ var attrVal = String( svg.getAttribute( attr ) || "none" );
2125
+ var attrOpacity = Number( svg.getAttribute( attr + "-opacity" ) || "1" );
2126
+ var attrRGBA = _this.getRGBA( attrVal );
2127
+
2128
+ // HIDE HIDDEN ELEMENTS; TODO: FIND A BETTER WAY TO HANDLE THAT
2129
+ if ( visibility == "hidden" ) {
2130
+ obj.opacity = 0;
2131
+ attrOpacity = 0;
2132
+ }
2133
+
2134
+ // SET COLOR
2135
+ if ( attrRGBA ) {
2136
+ attrRGBA.pop();
2137
+ attrRGBA.push( attrOpacity )
2138
+ obj[ attr ] = "rgba(" + attrRGBA.join() + ")";
2139
+ obj[ attr + _this.capitalize( "opacity" ) ] = attrOpacity;
2140
+ }
2141
+ }
2142
+
2143
+ // REVIVER
2144
+ _this.handleCallback( cfg.reviver, obj, svg );
2145
+ } );
2146
+ }
2147
+ },
2148
+
2149
+ /**
2150
+ * Returns the current canvas
2151
+ */
2152
+ toCanvas: function( options, callback ) {
2153
+ var cfg = _this.deepMerge( {
2154
+ // NUFFIN
2155
+ }, options || {} );
2156
+ var data = _this.setup.canvas;
2157
+
2158
+ // TRIGGER CALLBACK
2159
+ _this.handleCallback( callback, data, cfg );
2160
+
2161
+ return data;
2162
+ },
2163
+
2164
+ /**
2165
+ * Returns an image; by default PNG
2166
+ */
2167
+ toImage: function( options, callback ) {
2168
+ var cfg = _this.deepMerge( {
2169
+ format: "png",
2170
+ quality: 1,
2171
+ multiplier: _this.config.multiplier
2172
+ }, options || {} );
2173
+ var data = cfg.data;
2174
+ var img = document.createElement( "img" );
2175
+
2176
+ // NAMESPACE CHECK
2177
+ if ( !_this.handleNamespace( "fabric", {
2178
+ scope: this,
2179
+ cb: _this.toImage,
2180
+ args: arguments
2181
+ } ) ) {
2182
+ return false;
2183
+ }
2184
+
2185
+ if ( !cfg.data ) {
2186
+ if ( cfg.lossless || cfg.format == "svg" ) {
2187
+ data = _this.toSVG( _this.deepMerge( cfg, {
2188
+ getBase64: true
2189
+ } ) );
2190
+ } else {
2191
+ data = _this.setup.fabric.toDataURL( cfg );
2192
+ }
2193
+ }
2194
+
2195
+ img.setAttribute( "src", data );
2196
+
2197
+ _this.handleCallback( callback, img, cfg );
2198
+
2199
+ return img;
2200
+ },
2201
+
2202
+ /**
2203
+ * Generates a blob instance image; returns base64 datastring
2204
+ */
2205
+ toBlob: function( options, callback ) {
2206
+ var cfg = _this.deepMerge( {
2207
+ data: "empty",
2208
+ type: "text/plain"
2209
+ }, options || {} );
2210
+ var data;
2211
+ var isBase64 = /^data:.+;base64,(.*)$/.exec( cfg.data );
2212
+
2213
+ // GATHER BODY
2214
+ if ( isBase64 ) {
2215
+ cfg.data = isBase64[ 0 ];
2216
+ cfg.type = cfg.data.slice( 5, cfg.data.indexOf( "," ) - 7 );
2217
+ cfg.data = _this.toByteArray( {
2218
+ data: cfg.data.slice( cfg.data.indexOf( "," ) + 1, cfg.data.length )
2219
+ } );
2220
+ }
2221
+
2222
+ if ( cfg.getByteArray ) {
2223
+ data = cfg.data;
2224
+ } else {
2225
+ data = new Blob( [ cfg.data ], {
2226
+ type: cfg.type
2227
+ } );
2228
+ }
2229
+
2230
+ // TRIGGER CALLBACK
2231
+ _this.handleCallback( callback, data, cfg );
2232
+
2233
+ return data;
2234
+ },
2235
+
2236
+ /**
2237
+ * Generates JPG image; returns base64 datastring
2238
+ */
2239
+ toJPG: function( options, callback ) {
2240
+ var cfg = _this.deepMerge( {
2241
+ format: "jpeg",
2242
+ quality: 1,
2243
+ multiplier: _this.config.multiplier
2244
+ }, options || {} );
2245
+ cfg.format = cfg.format.toLowerCase();
2246
+ var data;
2247
+
2248
+ // DISABLE SCALING ON IOS DEVICES
2249
+ if ( /iP(hone|od|ad)/.test(navigator.platform) ) {
2250
+ cfg.multiplier = 1;
2251
+ }
2252
+
2253
+ // NAMESPACE CHECK
2254
+ if ( !_this.handleNamespace( "fabric", {
2255
+ scope: this,
2256
+ cb: _this.toJPG,
2257
+ args: arguments
2258
+ } ) ) {
2259
+ return false;
2260
+ }
2261
+
2262
+ // Get data context from fabric
2263
+ data = _this.setup.fabric.toDataURL( cfg );
2264
+
2265
+ // TRIGGER CALLBACK
2266
+ _this.handleCallback( callback, data, cfg );
2267
+
2268
+ return data;
2269
+ },
2270
+
2271
+ /**
2272
+ * Generates PNG image; returns base64 datastring
2273
+ */
2274
+ toPNG: function( options, callback ) {
2275
+ var cfg = _this.deepMerge( {
2276
+ format: "png",
2277
+ quality: 1,
2278
+ multiplier: _this.config.multiplier
2279
+ }, options || {} );
2280
+ var data;
2281
+
2282
+ // DISABLE SCALING ON IOS DEVICES
2283
+ if ( /iP(hone|od|ad)/.test(navigator.platform) ) {
2284
+ cfg.multiplier = 1;
2285
+ }
2286
+
2287
+ // NAMESPACE CHECK
2288
+ if ( !_this.handleNamespace( "fabric", {
2289
+ scope: this,
2290
+ cb: _this.toPNG,
2291
+ args: arguments
2292
+ } ) ) {
2293
+ return false;
2294
+ }
2295
+
2296
+ // Get data context from fabric
2297
+ data = _this.setup.fabric.toDataURL( cfg );
2298
+
2299
+ // TRIGGER CALLBACK
2300
+ _this.handleCallback( callback, data, cfg );
2301
+
2302
+ return data;
2303
+ },
2304
+
2305
+ /**
2306
+ * Generates SVG image; returns base64 datastring
2307
+ */
2308
+ toSVG: function( options, callback ) {
2309
+ var clipPaths = [];
2310
+ var clipPathIds = [];
2311
+ var cfg = _this.deepMerge( {
2312
+ compress: _this.config.compress,
2313
+ reviver: function( string, clipPath ) {
2314
+ var matcher = new RegExp( /\bstyle=(['"])(.*?)\1/ );
2315
+ var match = matcher.exec( string )[ 0 ].slice( 7, -1 );
2316
+ var styles = match.split( ";" );
2317
+ var replacement = [];
2318
+
2319
+ // BEAUTIFY STYLES
2320
+ for ( i1 = 0; i1 < styles.length; i1++ ) {
2321
+ if ( styles[ i1 ] ) {
2322
+ var pair = styles[ i1 ].replace( /\s/g, "" ).split( ":" );
2323
+ var key = pair[ 0 ];
2324
+ var value = pair[ 1 ];
2325
+
2326
+ if ( [ "fill", "stroke" ].indexOf( key ) != -1 ) {
2327
+ value = _this.getRGBA( value, true );
2328
+ if ( value ) {
2329
+ var color = "#" + value.toHex();
2330
+ var opacity = value._source[ 3 ];
2331
+
2332
+ replacement.push( [ key, color ].join( ":" ) );
2333
+ replacement.push( [ key + "-opacity", opacity ].join( ":" ) );
2334
+ } else {
2335
+ replacement.push( styles[ i1 ] );
2336
+ }
2337
+ } else if ( key != "opactiy" ) {
2338
+ replacement.push( styles[ i1 ] );
2339
+ }
2340
+ }
2341
+ }
2342
+ string = string.replace( match, replacement.join( ";" ) );
2343
+
2344
+ // TODO: WAIT UNTIL FABRICJS HANDLES CLIPPATH FOR SVG OUTPUT
2345
+ if ( clipPath && clipPath.svg ) {
2346
+ var clipPathId = clipPath.svg.id;
2347
+ var sliceOffset = 2;
2348
+ var end = string.slice( -sliceOffset );
2349
+
2350
+ if ( end != "/>" ) {
2351
+ sliceOffset = 3;
2352
+ end = string.slice( -sliceOffset );
2353
+ }
2354
+
2355
+ var start = string.slice( 0, string.length - sliceOffset );
2356
+ var clipPathAttr = " clip-path=\"url(#" + clipPathId + ")\" ";
2357
+ var parentClassList = _this.gatherAttribute(clipPath.svg,"class");
2358
+
2359
+ parentClassList = parentClassList ? parentClassList.split(" ") : [];
2360
+
2361
+ // APPLY CLIP PATH DIRECTLY ON GRAPHLINES
2362
+ if ( parentClassList.indexOf(_this.setup.chart.classNamePrefix + "-graph-line") != -1 ) {
2363
+ string = start + clipPathAttr + end;
2364
+
2365
+ // WRAP ELEMENT TO BE ABLE TO APPLY THE CLIP-PATH
2366
+ } else {
2367
+ string = "<g " + clipPathAttr + ">" + string + "</g>";
2368
+ }
2369
+
2370
+ // INJECT CLIP PATH ONCE INTO THE DOCUMENT
2371
+ if ( clipPathIds.indexOf( clipPathId ) == -1 ) {
2372
+ var clipPathString = new XMLSerializer().serializeToString( clipPath.svg );
2373
+ clipPaths.push( clipPathString );
2374
+ clipPathIds.push( clipPathId );
2375
+ }
2376
+ }
2377
+
2378
+ return string;
2379
+ }
2380
+ }, options || {} );
2381
+ var data;
2382
+
2383
+ // NAMESPACE CHECK
2384
+ if ( !_this.handleNamespace( "fabric", {
2385
+ scope: this,
2386
+ cb: _this.toSVG,
2387
+ args: arguments
2388
+ } ) ) {
2389
+ return false;
2390
+ }
2391
+
2392
+ // Get SVG context from fabric
2393
+ data = _this.setup.fabric.toSVG( cfg, cfg.reviver );
2394
+
2395
+ // TODO: WAIT UNTIL FABRICJS HANDLES CLIPPATH FOR SVG OUTPUT
2396
+ if ( clipPaths.length ) {
2397
+ var start = data.slice( 0, data.length - 6 );
2398
+ var end = data.slice( -6 );
2399
+ data = start + clipPaths.join( "" ) + end;
2400
+ }
2401
+
2402
+ // SOLVES #21840
2403
+ if ( cfg.compress ) {
2404
+ data = data.replace( /[\t\r\n]+/g, "" );
2405
+ }
2406
+
2407
+ if ( cfg.getBase64 ) {
2408
+ data = "data:image/svg+xml;base64," + btoa( data );
2409
+ }
2410
+
2411
+ // TRIGGER CALLBACK
2412
+ _this.handleCallback( callback, data, cfg );
2413
+
2414
+ return data;
2415
+ },
2416
+
2417
+ /**
2418
+ * Generates PDF; returns base64 datastring
2419
+ */
2420
+ toPDF: function( options, callback ) {
2421
+ var cfg = _this.deepMerge( _this.deepMerge( {
2422
+ multiplier: _this.config.multiplier || 2,
2423
+ pageOrigin: _this.config.pageOrigin === undefined ? true : false
2424
+ }, _this.config.pdfMake ), options || {}, true );
2425
+ var data;
2426
+
2427
+ // DISABLE SCALING ON IOS DEVICES
2428
+ if ( /iP(hone|od|ad)/.test(navigator.platform) ) {
2429
+ cfg.multiplier = 1;
2430
+ }
2431
+
2432
+ // NAMESPACE CHECK
2433
+ if ( !_this.handleNamespace( "pdfMake", {
2434
+ scope: this,
2435
+ cb: _this.toPDF,
2436
+ args: arguments
2437
+ } ) ) {
2438
+ return false;
2439
+ }
2440
+
2441
+ // Get image data
2442
+ cfg.images.reference = _this.toPNG( cfg );
2443
+
2444
+ // Get page margins; exported from pdfMake
2445
+ function getMargins( margin ) {
2446
+ if ( typeof margin === 'number' || margin instanceof Number ) {
2447
+ margin = {
2448
+ left: margin,
2449
+ right: margin,
2450
+ top: margin,
2451
+ bottom: margin
2452
+ };
2453
+ } else if ( margin instanceof Array ) {
2454
+ if ( margin.length === 2 ) {
2455
+ margin = {
2456
+ left: margin[ 0 ],
2457
+ top: margin[ 1 ],
2458
+ right: margin[ 0 ],
2459
+ bottom: margin[ 1 ]
2460
+ };
2461
+ } else if ( margin.length === 4 ) {
2462
+ margin = {
2463
+ left: margin[ 0 ],
2464
+ top: margin[ 1 ],
2465
+ right: margin[ 2 ],
2466
+ bottom: margin[ 3 ]
2467
+ };
2468
+ } else throw 'Invalid pageMargins definition';
2469
+ } else {
2470
+ margin = {
2471
+ left: _this.defaults.pdfMake.pageMargins,
2472
+ top: _this.defaults.pdfMake.pageMargins,
2473
+ right: _this.defaults.pdfMake.pageMargins,
2474
+ bottom: _this.defaults.pdfMake.pageMargins
2475
+ };
2476
+ }
2477
+
2478
+ return margin;
2479
+ }
2480
+
2481
+ // Get page dimensions
2482
+ function getSize( pageSize, pageOrientation ) {
2483
+ var pageDimensions = _this.defaults.pdfMake.pageSizes[ String( pageSize ).toUpperCase() ].slice();
2484
+
2485
+ if ( !pageDimensions ) {
2486
+ throw new Error( "The given pageSize \"" + pageSize + "\" does not exist!" );
2487
+ }
2488
+
2489
+ // Revers in case of landscape
2490
+ if ( pageOrientation == "landscape" ) {
2491
+ pageDimensions.reverse();
2492
+ }
2493
+
2494
+ return pageDimensions;
2495
+ }
2496
+
2497
+ // Polyfill default content if none is given
2498
+ if ( !cfg.content ) {
2499
+ var pageContent = [];
2500
+ var pageDimensions = getSize( cfg.pageSize, cfg.pageOrientation );
2501
+ var pageMargins = getMargins( cfg.pageMargins );
2502
+
2503
+ pageDimensions[ 0 ] -= ( pageMargins.left + pageMargins.right );
2504
+ pageDimensions[ 1 ] -= ( pageMargins.top + pageMargins.bottom );
2505
+
2506
+ if ( cfg.pageOrigin ) {
2507
+ pageContent.push( _this.i18l( "label.saved.from" ) );
2508
+ pageContent.push( window.location.href );
2509
+ pageDimensions[ 1 ] -= ( 14.064 * 2 );
2510
+ }
2511
+
2512
+ pageContent.push( {
2513
+ image: "reference",
2514
+ fit: pageDimensions
2515
+ } );
2516
+
2517
+ cfg.content = pageContent;
2518
+ }
2519
+
2520
+ // Create PDF instance
2521
+ data = new pdfMake.createPdf( cfg );
2522
+
2523
+ if ( callback ) {
2524
+ data.getDataUrl( ( function( callback ) {
2525
+ return function( a ) {
2526
+ callback.apply( _this, arguments );
2527
+ }
2528
+ } )( callback ) );
2529
+ }
2530
+
2531
+ return data;
2532
+ },
2533
+
2534
+ /**
2535
+ * Generates an image; hides all elements on page to trigger native print method
2536
+ */
2537
+ toPRINT: function( options, callback ) {
2538
+ var i1;
2539
+ var cfg = _this.deepMerge( {
2540
+ delay: 1,
2541
+ lossless: false
2542
+ }, options || {} );
2543
+ var data = _this.toImage( cfg );
2544
+ var states = [];
2545
+ var items = document.body.childNodes;
2546
+ var scroll = document.documentElement.scrollTop || document.body.scrollTop;
2547
+
2548
+ data.setAttribute( "style", "width: 100%; max-height: 100%;" );
2549
+
2550
+ for ( i1 = 0; i1 < items.length; i1++ ) {
2551
+ if ( _this.isElement( items[ i1 ] ) ) {
2552
+ states[ i1 ] = items[ i1 ].style.display;
2553
+ items[ i1 ].style.display = "none";
2554
+ }
2555
+ }
2556
+
2557
+ document.body.appendChild( data );
2558
+
2559
+ // CONVERT TO SECONDS
2560
+ cfg.delay *= 1000;
2561
+
2562
+ // IOS EXCEPTION DELAY MIN. 1 SECOND
2563
+ var isIOS = /iPad|iPhone|iPod/.test( navigator.userAgent ) && !window.MSStream;
2564
+ if ( isIOS && cfg.delay < 1000 ) {
2565
+ cfg.delay = 1000;
2566
+ }
2567
+
2568
+ // DELAY WHOLE PROCESS
2569
+ setTimeout(function() {
2570
+ // PRINT
2571
+ window.print();
2572
+
2573
+ setTimeout( function() {
2574
+ for ( i1 = 0; i1 < items.length; i1++ ) {
2575
+ if ( _this.isElement( items[ i1 ] ) ) {
2576
+ items[ i1 ].style.display = states[ i1 ];
2577
+ }
2578
+ }
2579
+ document.body.removeChild( data );
2580
+ document.documentElement.scrollTop = document.body.scrollTop = scroll;
2581
+
2582
+ // TRIGGER CALLBACK
2583
+ _this.handleCallback( callback, data, cfg );
2584
+ }, cfg.delay );
2585
+ }, cfg.delay);
2586
+
2587
+ return data;
2588
+ },
2589
+
2590
+ /**
2591
+ * Generates JSON string
2592
+ */
2593
+ toJSON: function( options, callback ) {
2594
+ var cfg = _this.deepMerge( {
2595
+ dateFormat: _this.config.dateFormat || "dateObject"
2596
+ }, options || {}, true );
2597
+ var data = {};
2598
+
2599
+ // NAMESPACE CHECK
2600
+ if ( !_this.handleNamespace( "JSON", {
2601
+ scope: this,
2602
+ cb: _this.toJSON,
2603
+ args: arguments
2604
+ } ) ) {
2605
+ return false;
2606
+ }
2607
+
2608
+ // GATHER DATA
2609
+ cfg.data = cfg.data !== undefined ? cfg.data : _this.getChartData( cfg );
2610
+
2611
+ // STRINGIFY DATA
2612
+ data = JSON.stringify( cfg.data, undefined, "\t" );
2613
+
2614
+ // TRIGGER CALLBACK
2615
+ _this.handleCallback( callback, data, cfg );
2616
+
2617
+ return data;
2618
+ },
2619
+
2620
+ /**
2621
+ * Generates CSV string
2622
+ */
2623
+ toCSV: function( options, callback ) {
2624
+ var row, col;
2625
+ var cfg = _this.deepMerge( {
2626
+ delimiter: ",",
2627
+ quotes: true,
2628
+ escape: true,
2629
+ withHeader: true
2630
+ }, options || {}, true );
2631
+ var buffer = [];
2632
+ var data = "";
2633
+
2634
+ // GATHER DATA
2635
+ buffer = _this.toArray( cfg );
2636
+
2637
+ // MERGE
2638
+ for ( row in buffer ) {
2639
+ if ( !isNaN( row ) ) {
2640
+ data += buffer[ row ].join( cfg.delimiter ) + "\n";
2641
+ }
2642
+ }
2643
+
2644
+ // TRIGGER CALLBACK
2645
+ _this.handleCallback( callback, data, cfg );
2646
+
2647
+ return data;
2648
+ },
2649
+
2650
+ /**
2651
+ * Generates excel sheet; returns base64 datastring
2652
+ */
2653
+ toXLSX: function( options, callback ) {
2654
+ var cfg = _this.deepMerge( {
2655
+ name: "amCharts",
2656
+ dateFormat: _this.config.dateFormat || "dateObject",
2657
+ withHeader: true,
2658
+ stringify: false
2659
+ }, options || {}, true );
2660
+ var buffer = [];
2661
+ var data = "";
2662
+ var wb = {
2663
+ SheetNames: [],
2664
+ Sheets: {}
2665
+ }
2666
+
2667
+ // NAMESPACE CHECK
2668
+ if ( !_this.handleNamespace( "XLSX", {
2669
+ scope: this,
2670
+ cb: _this.toXLSX,
2671
+ args: arguments
2672
+ } ) ) {
2673
+ return false;
2674
+ }
2675
+
2676
+ // GATHER DATA
2677
+ buffer = _this.toArray( cfg );
2678
+
2679
+ function datenum( v, date1904 ) {
2680
+ if ( date1904 ) v += 1462;
2681
+ var epoch = Date.parse( v );
2682
+ var offset = v.getTimezoneOffset() * 60 * 1000;
2683
+ return ( epoch - offset - new Date( Date.UTC( 1899, 11, 30 ) ) ) / ( 24 * 60 * 60 * 1000 );
2684
+ }
2685
+
2686
+ function sheet_from_array_of_arrays( data, opts ) {
2687
+ var ws = {};
2688
+ var range = {
2689
+ s: {
2690
+ c: 10000000,
2691
+ r: 10000000
2692
+ },
2693
+ e: {
2694
+ c: 0,
2695
+ r: 0
2696
+ }
2697
+ };
2698
+ for ( var R = 0; R != data.length; ++R ) {
2699
+ for ( var C = 0; C != data[ R ].length; ++C ) {
2700
+ if ( range.s.r > R ) range.s.r = R;
2701
+ if ( range.s.c > C ) range.s.c = C;
2702
+ if ( range.e.r < R ) range.e.r = R;
2703
+ if ( range.e.c < C ) range.e.c = C;
2704
+ var cell = {
2705
+ v: data[ R ][ C ]
2706
+ };
2707
+ if ( cell.v == null ) continue;
2708
+ var cell_ref = XLSX.utils.encode_cell( {
2709
+ c: C,
2710
+ r: R
2711
+ } );
2712
+
2713
+ if ( typeof cell.v === "number" ) {
2714
+ cell.t = "n";
2715
+ } else if ( typeof cell.v === "boolean" ) {
2716
+ cell.t = "b";
2717
+ } else if ( cell.v instanceof Date ) {
2718
+ cell.t = "n";
2719
+ cell.z = XLSX.SSF._table[ 14 ];
2720
+ cell.v = datenum( cell.v );
2721
+ } else if ( cell.v instanceof Object ) {
2722
+ cell.t = "s";
2723
+ cell.v = JSON.stringify( cell.v );
2724
+ } else {
2725
+ cell.t = "s";
2726
+ }
2727
+
2728
+ ws[ cell_ref ] = cell;
2729
+ }
2730
+ }
2731
+ if ( range.s.c < 10000000 ) ws[ "!ref" ] = XLSX.utils.encode_range( range );
2732
+ return ws;
2733
+ }
2734
+
2735
+ wb.SheetNames.push( cfg.name );
2736
+ wb.Sheets[ cfg.name ] = sheet_from_array_of_arrays( buffer );
2737
+
2738
+ data = XLSX.write( wb, {
2739
+ bookType: "xlsx",
2740
+ bookSST: true,
2741
+ type: "base64"
2742
+ } );
2743
+
2744
+ data = "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," + data;
2745
+
2746
+ // TRIGGER CALLBACK
2747
+ _this.handleCallback( callback, data, cfg );
2748
+
2749
+ return data;
2750
+ },
2751
+
2752
+ /**
2753
+ * Generates an array of arrays
2754
+ */
2755
+ toArray: function( options, callback ) {
2756
+ var row, col;
2757
+ var cfg = _this.deepMerge( {
2758
+ withHeader: false,
2759
+ stringify: true,
2760
+ escape: false,
2761
+ quotes: false
2762
+ }, options || {}, true );
2763
+ var data = [];
2764
+ var cols = [];
2765
+ var buffer = [];
2766
+ var _processData = _this.config.processData;
2767
+
2768
+ // RETRIEVES RIGHT FIELD ORDER OF TRANSLATED FIELDS
2769
+ function processData( data, cfg ) {
2770
+ var fields = cfg.exportFields || Object.keys( cfg.dataFieldsMap );
2771
+
2772
+ // WALKTHROUGH FIELDS
2773
+ for ( col = 0; col < fields.length; col++ ) {
2774
+ var key = fields[ col ];
2775
+ var field = cfg.dataFieldsTitlesMap[ key ];
2776
+ cols.push( field );
2777
+ }
2778
+
2779
+ // TRIGGER GIVEN CALLBACK
2780
+ if ( _processData ) {
2781
+ return _this.handleCallback( _processData, data, cfg );
2782
+ }
2783
+ return data;
2784
+ }
2785
+
2786
+ // STRING PROCESSOR
2787
+ function enchant( value ) {
2788
+
2789
+ if ( typeof value === "string" ) {
2790
+ if ( cfg.escape ) {
2791
+ value = value.replace( '"', '""' );
2792
+ }
2793
+ if ( cfg.quotes ) {
2794
+ value = [ '"', value, '"' ].join( "" );
2795
+ }
2796
+ }
2797
+
2798
+ return value;
2799
+ }
2800
+
2801
+ // INVOKE PROCESS DATA
2802
+ cfg.processData = processData;
2803
+
2804
+ // GET DATA
2805
+ cfg.data = cfg.data !== undefined ? _this.processData( cfg ) : _this.getChartData( cfg );
2806
+
2807
+ // HEADER
2808
+ if ( cfg.withHeader ) {
2809
+ buffer = [];
2810
+ for ( col in cols ) {
2811
+ if ( !isNaN( col ) ) {
2812
+ buffer.push( enchant( cols[ col ] ) );
2813
+ }
2814
+ }
2815
+ data.push( buffer );
2816
+ }
2817
+
2818
+ // BODY
2819
+ for ( row in cfg.data ) {
2820
+ buffer = [];
2821
+ if ( !isNaN( row ) ) {
2822
+ for ( col in cols ) {
2823
+ if ( !isNaN( col ) ) {
2824
+ var col = cols[ col ];
2825
+ var value = cfg.data[ row ][ col ];
2826
+ if ( value == null ) {
2827
+ value = "";
2828
+ } else if ( cfg.stringify ) {
2829
+ value = String( value );
2830
+ } else {
2831
+ value = value;
2832
+ }
2833
+ buffer.push( enchant( value ) );
2834
+ }
2835
+ }
2836
+ data.push( buffer );
2837
+ }
2838
+ }
2839
+
2840
+ // TRIGGER CALLBACK
2841
+ _this.handleCallback( callback, data, cfg );
2842
+
2843
+ return data;
2844
+ },
2845
+
2846
+ /**
2847
+ * Generates byte array with given base64 datastring; returns byte array
2848
+ */
2849
+ toByteArray: function( options, callback ) {
2850
+ var cfg = _this.deepMerge( {
2851
+ // NUFFIN
2852
+ }, options || {} );
2853
+ var Arr = ( typeof Uint8Array !== 'undefined' ) ? Uint8Array : Array
2854
+ var PLUS = '+'.charCodeAt( 0 )
2855
+ var SLASH = '/'.charCodeAt( 0 )
2856
+ var NUMBER = '0'.charCodeAt( 0 )
2857
+ var LOWER = 'a'.charCodeAt( 0 )
2858
+ var UPPER = 'A'.charCodeAt( 0 )
2859
+ var data = b64ToByteArray( cfg.data );
2860
+
2861
+ function decode( elt ) {
2862
+ var code = elt.charCodeAt( 0 )
2863
+ if ( code === PLUS )
2864
+ return 62 // '+'
2865
+ if ( code === SLASH )
2866
+ return 63 // '/'
2867
+ if ( code < NUMBER )
2868
+ return -1 //no match
2869
+ if ( code < NUMBER + 10 )
2870
+ return code - NUMBER + 26 + 26
2871
+ if ( code < UPPER + 26 )
2872
+ return code - UPPER
2873
+ if ( code < LOWER + 26 )
2874
+ return code - LOWER + 26
2875
+ }
2876
+
2877
+ function b64ToByteArray( b64 ) {
2878
+ var i, j, l, tmp, placeHolders, arr
2879
+
2880
+ if ( b64.length % 4 > 0 ) {
2881
+ throw new Error( 'Invalid string. Length must be a multiple of 4' )
2882
+ }
2883
+
2884
+ // THE NUMBER OF EQUAL SIGNS (PLACE HOLDERS)
2885
+ // IF THERE ARE TWO PLACEHOLDERS, THAN THE TWO CHARACTERS BEFORE IT
2886
+ // REPRESENT ONE BYTE
2887
+ // IF THERE IS ONLY ONE, THEN THE THREE CHARACTERS BEFORE IT REPRESENT 2 BYTES
2888
+ // THIS IS JUST A CHEAP HACK TO NOT DO INDEXOF TWICE
2889
+ var len = b64.length
2890
+ placeHolders = '=' === b64.charAt( len - 2 ) ? 2 : '=' === b64.charAt( len - 1 ) ? 1 : 0
2891
+
2892
+ // BASE64 IS 4/3 + UP TO TWO CHARACTERS OF THE ORIGINAL DATA
2893
+ arr = new Arr( b64.length * 3 / 4 - placeHolders )
2894
+
2895
+ // IF THERE ARE PLACEHOLDERS, ONLY GET UP TO THE LAST COMPLETE 4 CHARS
2896
+ l = placeHolders > 0 ? b64.length - 4 : b64.length
2897
+
2898
+ var L = 0
2899
+
2900
+ function push( v ) {
2901
+ arr[ L++ ] = v
2902
+ }
2903
+
2904
+ for ( i = 0, j = 0; i < l; i += 4, j += 3 ) {
2905
+ tmp = ( decode( b64.charAt( i ) ) << 18 ) | ( decode( b64.charAt( i + 1 ) ) << 12 ) | ( decode( b64.charAt( i + 2 ) ) << 6 ) | decode( b64.charAt( i + 3 ) )
2906
+ push( ( tmp & 0xFF0000 ) >> 16 )
2907
+ push( ( tmp & 0xFF00 ) >> 8 )
2908
+ push( tmp & 0xFF )
2909
+ }
2910
+
2911
+ if ( placeHolders === 2 ) {
2912
+ tmp = ( decode( b64.charAt( i ) ) << 2 ) | ( decode( b64.charAt( i + 1 ) ) >> 4 )
2913
+ push( tmp & 0xFF )
2914
+ } else if ( placeHolders === 1 ) {
2915
+ tmp = ( decode( b64.charAt( i ) ) << 10 ) | ( decode( b64.charAt( i + 1 ) ) << 4 ) | ( decode( b64.charAt( i + 2 ) ) >> 2 )
2916
+ push( ( tmp >> 8 ) & 0xFF )
2917
+ push( tmp & 0xFF )
2918
+ }
2919
+
2920
+ return arr
2921
+ }
2922
+
2923
+ // TRIGGER CALLBACK
2924
+ _this.handleCallback( callback, data, cfg );
2925
+
2926
+ return data;
2927
+ },
2928
+
2929
+ /**
2930
+ * Method to remove functions from given object
2931
+ */
2932
+ removeFunctionsFromObject: function( obj ) {
2933
+ for (var key in obj) {
2934
+ if ( typeof obj[key] === "function" ) {
2935
+ delete obj[key];
2936
+ }
2937
+ }
2938
+ return obj;
2939
+ },
2940
+
2941
+ /**
2942
+ * Callback handler; injects additional arguments to callback
2943
+ */
2944
+ handleCallback: function( callback ) {
2945
+ var i1, data = Array();
2946
+ if ( callback && callback instanceof Function ) {
2947
+ for ( i1 = 0; i1 < arguments.length; i1++ ) {
2948
+ if ( i1 > 0 ) {
2949
+ data.push( arguments[ i1 ] );
2950
+ }
2951
+ }
2952
+ return callback.apply( _this, data );
2953
+ }
2954
+ },
2955
+
2956
+ /**
2957
+ * Logger
2958
+ */
2959
+ handleLog: function( msg ) {
2960
+ if ( _this.config.debug === true ) {
2961
+ console.log( msg );
2962
+ }
2963
+ },
2964
+
2965
+ /**
2966
+ * Namespace checker; delays given callback until the dependency is available
2967
+ */
2968
+ handleNamespace: function( namespace, opts ) {
2969
+ var scope = _this.config.scope || window;
2970
+ var exists = false;
2971
+ var startTS = Number( new Date() );
2972
+ var timer;
2973
+
2974
+ // SIMPLE CHECK
2975
+ exists = !!( namespace in scope );
2976
+
2977
+ // RESURSIVE DEPENDENCY CHECK
2978
+ function waitForIt() {
2979
+ var tmpTS = Number( new Date() );
2980
+
2981
+ // SIMPLE CHECK
2982
+ exists = !!( namespace in scope );
2983
+
2984
+ // PDFMAKE EXCEPTION; WAIT ADDITIONALLY FOR FONTS
2985
+ if ( namespace == "pdfMake" && exists ) {
2986
+ exists = scope.pdfMake.vfs;
2987
+ }
2988
+
2989
+ // FOUND TRIGGER GIVEN CALLBACK
2990
+ if ( exists ) {
2991
+ clearTimeout( timer );
2992
+ opts.cb.apply( opts.scope, opts.args );
2993
+ _this.handleLog( [ "AmCharts [export]: Namespace \"", namespace, "\" showed up in: ", String( scope ) ].join( "" ) );
2994
+
2995
+ // NOT FOUND SCHEDULE RECHECK
2996
+ } else if ( tmpTS - startTS < _this.libs.loadTimeout ) {
2997
+ timer = setTimeout( waitForIt, 250 );
2998
+
2999
+ // LIBS TIMEOUT REACHED
3000
+ } else {
3001
+ _this.handleLog( [ "AmCharts [export]: Gave up waiting for \"", namespace, "\" in: ", String( scope ) ].join( "" ) );
3002
+ }
3003
+ }
3004
+
3005
+ // THROW MESSAGE IF IT DOESNT EXIST
3006
+ if ( !exists ) {
3007
+ _this.handleLog( [ "AmCharts [export]: Could not find \"", namespace, "\" in: ", String( scope ) ].join( "" ) );
3008
+ waitForIt();
3009
+ }
3010
+
3011
+ return exists;
3012
+ },
3013
+
3014
+ /**
3015
+ * Border handler; injects additional border to canvas
3016
+ */
3017
+ handleBorder: function( options ) {
3018
+ if ( _this.config.border instanceof Object ) {
3019
+ var cfg = _this.deepMerge( _this.defaults.fabric.border, options.border || {}, true );
3020
+ var border = new fabric.Rect();
3021
+
3022
+ cfg.width = _this.setup.fabric.width - cfg.strokeWidth;
3023
+ cfg.height = _this.setup.fabric.height - cfg.strokeWidth;
3024
+
3025
+ border.set( cfg );
3026
+
3027
+ _this.setup.fabric.add( border );
3028
+ }
3029
+ },
3030
+
3031
+ /**
3032
+ * Handles drag/drop events; loads given imagery
3033
+ */
3034
+ handleDropbox: function( e ) {
3035
+ if ( _this.drawing.enabled ) {
3036
+ e.preventDefault();
3037
+ e.stopPropagation();
3038
+
3039
+ // DRAG OVER
3040
+ if ( e.type == "dragover" ) {
3041
+ _this.setup.wrapper.setAttribute( "class", _this.setup.chart.classNamePrefix + "-export-canvas active dropbox" );
3042
+
3043
+ // DRAGLEAVE; DROP
3044
+ } else {
3045
+ _this.setup.wrapper.setAttribute( "class", _this.setup.chart.classNamePrefix + "-export-canvas active" );
3046
+
3047
+ if ( e.type == "drop" && e.dataTransfer.files.length ) {
3048
+ for ( var i1 = 0; i1 < e.dataTransfer.files.length; i1++ ) {
3049
+ var reader = new FileReader();
3050
+ reader.onloadend = ( function( index ) {
3051
+ return function() {
3052
+ _this.drawing.handler.add( {
3053
+ url: reader.result,
3054
+ top: e.layerY - ( index * 10 ),
3055
+ left: e.layerX - ( index * 10 )
3056
+ } );
3057
+ }
3058
+ } )( i1 );
3059
+ reader.readAsDataURL( e.dataTransfer.files[ i1 ] );
3060
+ }
3061
+ }
3062
+ }
3063
+ }
3064
+ },
3065
+
3066
+ /**
3067
+ * Calls ready callback when dependencies are available within window scope
3068
+ */
3069
+ handleReady: function( callback ) {
3070
+ var t1, t2;
3071
+ var _this = this;
3072
+ var tsStart = Number( new Date() );
3073
+
3074
+ // READY FOR DATA EXPORT
3075
+ _this.handleCallback( callback, "data", false );
3076
+
3077
+ // READY CALLBACK FOR EACH DEPENDENCY
3078
+ for ( filename in _this.libs.namespaces ) {
3079
+ var namespace = _this.libs.namespaces[ filename ];
3080
+
3081
+ ( function( namespace ) {
3082
+ var t1 = setInterval( function() {
3083
+ var tsEnd = Number( new Date() );
3084
+
3085
+ if ( tsEnd - tsStart > _this.libs.loadTimeout || namespace in window ) {
3086
+ clearTimeout( t1 );
3087
+ _this.handleCallback( callback, namespace, tsEnd - tsStart > _this.libs.loadTimeout );
3088
+ }
3089
+ }, AmCharts.updateRate )
3090
+ } )( namespace );
3091
+ }
3092
+ },
3093
+
3094
+ /**
3095
+ * Gathers chart data according to its type
3096
+ */
3097
+ getChartData: function( options ) {
3098
+ var cfg = _this.deepMerge( {
3099
+ data: [],
3100
+ titles: {},
3101
+ dateFields: [],
3102
+ dataFields: [],
3103
+ dataFieldsMap: {},
3104
+ exportTitles: _this.config.exportTitles,
3105
+ exportFields: _this.config.exportFields,
3106
+ exportSelection: _this.config.exportSelection,
3107
+ columnNames: _this.config.columnNames
3108
+ }, options || {}, true );
3109
+ var uid, i1, i2, i3;
3110
+ var lookupFields = [ "valueField", "openField", "closeField", "highField", "lowField", "xField", "yField" ];
3111
+ var buffer;
3112
+
3113
+ // HANDLE FIELDS
3114
+ function addField( field, title, type ) {
3115
+
3116
+ function checkExistance( field, type ) {
3117
+ if ( cfg.dataFields.indexOf( field ) != -1 ) {
3118
+ return checkExistance( [ field, ".", type ].join( "" ) );
3119
+ }
3120
+ return field;
3121
+ }
3122
+
3123
+ if ( field && cfg.exportTitles && _this.setup.chart.type != "gantt" ) {
3124
+ uid = checkExistance( field, type );
3125
+ cfg.dataFieldsMap[ uid ] = field;
3126
+ cfg.dataFields.push( uid );
3127
+ cfg.titles[ uid ] = title || uid;
3128
+ }
3129
+ }
3130
+
3131
+ if ( cfg.data.length == 0 ) {
3132
+
3133
+ // STOCK DATA; GATHER COMPARED GRAPHS
3134
+ if ( _this.setup.chart.type == "stock" ) {
3135
+ cfg.data = _this.cloneObject( _this.setup.chart.mainDataSet.dataProvider );
3136
+
3137
+ // CATEGORY AXIS
3138
+ addField( _this.setup.chart.mainDataSet.categoryField );
3139
+ cfg.dateFields.push( _this.setup.chart.mainDataSet.categoryField );
3140
+
3141
+ // WALKTHROUGH GRAPHS
3142
+ for ( i1 = 0; i1 < _this.setup.chart.mainDataSet.fieldMappings.length; i1++ ) {
3143
+ var fieldMap = _this.setup.chart.mainDataSet.fieldMappings[ i1 ];
3144
+ for ( i2 = 0; i2 < _this.setup.chart.panels.length; i2++ ) {
3145
+ var panel = _this.setup.chart.panels[ i2 ]
3146
+ for ( i3 = 0; i3 < panel.stockGraphs.length; i3++ ) {
3147
+ var graph = panel.stockGraphs[ i3 ];
3148
+
3149
+ for ( i4 = 0; i4 < lookupFields.length; i4++ ) {
3150
+ if ( graph[ lookupFields[ i4 ] ] == fieldMap.toField ) {
3151
+ addField( fieldMap.fromField, graph.title, lookupFields[ i4 ] );
3152
+ }
3153
+ }
3154
+ }
3155
+ }
3156
+ }
3157
+
3158
+ // MERGE DATA OF COMPARED GRAPHS IN RIGHT PLACE
3159
+ if ( _this.setup.chart.comparedGraphs.length ) {
3160
+
3161
+ // BUFFER DATES FROM MAIN DATA SET
3162
+ buffer = [];
3163
+ for ( i1 = 0; i1 < cfg.data.length; i1++ ) {
3164
+ buffer.push( cfg.data[ i1 ][ _this.setup.chart.mainDataSet.categoryField ] );
3165
+ }
3166
+
3167
+ // WALKTHROUGH COMPARISON AND MERGE IT'S DATA
3168
+ for ( i1 = 0; i1 < _this.setup.chart.comparedGraphs.length; i1++ ) {
3169
+ var graph = _this.setup.chart.comparedGraphs[ i1 ];
3170
+ for ( i2 = 0; i2 < graph.dataSet.dataProvider.length; i2++ ) {
3171
+ var categoryField = graph.dataSet.categoryField;
3172
+ var categoryValue = graph.dataSet.dataProvider[ i2 ][ categoryField ];
3173
+ var comparedIndex = buffer.indexOf( categoryValue );
3174
+
3175
+ // PLACE IN RIGHT PLACE
3176
+ if ( comparedIndex != -1 ) {
3177
+ for ( i3 = 0; i3 < graph.dataSet.fieldMappings.length; i3++ ) {
3178
+ var fieldMap = graph.dataSet.fieldMappings[ i3 ];
3179
+ var uid = graph.dataSet.id + "_" + fieldMap.toField;
3180
+
3181
+ cfg.data[ comparedIndex ][ uid ] = graph.dataSet.dataProvider[ i2 ][ fieldMap.fromField ];
3182
+
3183
+ // UNIQUE TITLE
3184
+ if ( !cfg.titles[ uid ] ) {
3185
+ addField( uid, graph.dataSet.title )
3186
+ }
3187
+ }
3188
+ }
3189
+ }
3190
+ }
3191
+ }
3192
+
3193
+ // GANTT DATA; FLATTEN SEGMENTS
3194
+ } else if ( _this.setup.chart.type == "gantt" ) {
3195
+ // CATEGORY AXIS
3196
+ addField( _this.setup.chart.categoryField );
3197
+
3198
+ var field = _this.setup.chart.segmentsField;
3199
+ for ( i1 = 0; i1 < _this.setup.chart.dataProvider.length; i1++ ) {
3200
+ var dataItem = _this.setup.chart.dataProvider[ i1 ];
3201
+ if ( dataItem[ field ] ) {
3202
+ for ( i2 = 0; i2 < dataItem[ field ].length; i2++ ) {
3203
+ dataItem[ field ][ i2 ][ _this.setup.chart.categoryField ] = dataItem[ _this.setup.chart.categoryField ];
3204
+ cfg.data.push( dataItem[ field ][ i2 ] );
3205
+ }
3206
+ }
3207
+ }
3208
+
3209
+ // GRAPHS
3210
+ for ( i1 = 0; i1 < _this.setup.chart.graphs.length; i1++ ) {
3211
+ var graph = _this.setup.chart.graphs[ i1 ];
3212
+
3213
+ for ( i2 = 0; i2 < lookupFields.length; i2++ ) {
3214
+ var dataField = lookupFields[ i2 ];
3215
+ var graphField = graph[ dataField ];
3216
+ var title = graph.title;
3217
+
3218
+ addField( graphField, graph.title, dataField );
3219
+ }
3220
+ }
3221
+
3222
+ // PIE/FUNNEL DATA;
3223
+ } else if ( [ "pie", "funnel" ].indexOf( _this.setup.chart.type ) != -1 ) {
3224
+ cfg.data = _this.setup.chart.dataProvider;
3225
+
3226
+ // CATEGORY AXIS
3227
+ addField( _this.setup.chart.titleField );
3228
+ cfg.dateFields.push( _this.setup.chart.titleField );
3229
+
3230
+ // VALUE
3231
+ addField( _this.setup.chart.valueField );
3232
+
3233
+ // DEFAULT DATA;
3234
+ } else if ( _this.setup.chart.type != "map" ) {
3235
+ cfg.data = _this.setup.chart.dataProvider;
3236
+
3237
+ // CATEGORY AXIS
3238
+ if ( _this.setup.chart.categoryAxis ) {
3239
+ addField( _this.setup.chart.categoryField, _this.setup.chart.categoryAxis.title );
3240
+ if ( _this.setup.chart.categoryAxis.parseDates !== false ) {
3241
+ cfg.dateFields.push( _this.setup.chart.categoryField );
3242
+ }
3243
+ }
3244
+
3245
+ // GRAPHS
3246
+ for ( i1 = 0; i1 < _this.setup.chart.graphs.length; i1++ ) {
3247
+ var graph = _this.setup.chart.graphs[ i1 ];
3248
+
3249
+ for ( i2 = 0; i2 < lookupFields.length; i2++ ) {
3250
+ var dataField = lookupFields[ i2 ];
3251
+ var graphField = graph[ dataField ];
3252
+
3253
+ addField( graphField, graph.title, dataField );
3254
+ }
3255
+ }
3256
+ }
3257
+ }
3258
+ return _this.processData( cfg );
3259
+ },
3260
+
3261
+ /**
3262
+ * Returns embedded annotations in an array
3263
+ */
3264
+ getAnnotations: function( options, callback ) {
3265
+ var cfg = _this.deepMerge( {
3266
+ // For the future
3267
+ }, options || {}, true );
3268
+ var i1;
3269
+ var data = [];
3270
+
3271
+ // Collect annotations
3272
+ for ( i1 = 0; i1 < _this.setup.fabric._objects.length; i1++ ) {
3273
+
3274
+ // Internal flag to distinguish between annotations and "core" elements
3275
+ if ( !_this.setup.fabric._objects[ i1 ].isCoreElement ) {
3276
+ var obj = _this.setup.fabric._objects[ i1 ].toJSON();
3277
+
3278
+ // Revive before adding to allow modifying the object
3279
+ _this.handleCallback( cfg.reviver, obj, i1 );
3280
+
3281
+ // Push into output
3282
+ data.push( obj );
3283
+ }
3284
+ }
3285
+
3286
+ _this.handleCallback( callback, data );
3287
+
3288
+ return data;
3289
+ },
3290
+
3291
+ /**
3292
+ * Inserts the given annotations
3293
+ */
3294
+ setAnnotations: function( options, callback ) {
3295
+ var cfg = _this.deepMerge( {
3296
+ data: []
3297
+ }, options || {}, true );
3298
+
3299
+ // Convert annotations objects into fabric instances
3300
+ fabric.util.enlivenObjects( cfg.data, function( enlivenedObjects ) {
3301
+ enlivenedObjects.forEach( function( obj, i1 ) {
3302
+
3303
+ // Revive before adding to allow modifying the object
3304
+ _this.handleCallback( cfg.reviver, obj, i1 );
3305
+
3306
+ // Add into active instance canvas
3307
+ _this.setup.fabric.add( obj );
3308
+ } );
3309
+
3310
+ _this.handleCallback( callback, cfg );
3311
+ } );
3312
+
3313
+ return cfg.data;
3314
+ },
3315
+
3316
+ /**
3317
+ * Walkthrough data to format dates and titles
3318
+ */
3319
+ processData: function( options ) {
3320
+ var cfg = _this.deepMerge( {
3321
+ data: [],
3322
+ titles: {},
3323
+ dateFields: [],
3324
+ dataFields: [],
3325
+ dataFieldsMap: {},
3326
+ dataFieldsTitlesMap: {},
3327
+ dataDateFormat: _this.setup.chart.dataDateFormat,
3328
+ dateFormat: _this.config.dateFormat || _this.setup.chart.dataDateFormat || "YYYY-MM-DD",
3329
+ exportTitles: _this.config.exportTitles,
3330
+ exportFields: _this.config.exportFields,
3331
+ exportSelection: _this.config.exportSelection,
3332
+ columnNames: _this.config.columnNames,
3333
+ processData: _this.config.processData
3334
+ }, options || {}, true );
3335
+ var i1, i2;
3336
+
3337
+ if ( cfg.data.length ) {
3338
+ // GATHER MISSING FIELDS
3339
+ for ( i1 = 0; i1 < cfg.data.length; i1++ ) {
3340
+ for ( i2 in cfg.data[ i1 ] ) {
3341
+ if ( cfg.dataFields.indexOf( i2 ) == -1 ) {
3342
+ cfg.dataFields.push( i2 );
3343
+ cfg.dataFieldsMap[ i2 ] = i2;
3344
+ }
3345
+ }
3346
+ }
3347
+
3348
+ // REMOVE FIELDS SELECTIVELY
3349
+ if ( cfg.exportFields !== undefined ) {
3350
+ cfg.dataFields = cfg.exportFields.filter( function( n ) {
3351
+ return cfg.dataFields.indexOf( n ) != -1;
3352
+ } );
3353
+ }
3354
+
3355
+ // REBUILD DATA
3356
+ var buffer = [];
3357
+ for ( i1 = 0; i1 < cfg.data.length; i1++ ) {
3358
+ var tmp = {};
3359
+ var skip = false;
3360
+ for ( i2 = 0; i2 < cfg.dataFields.length; i2++ ) {
3361
+ var uniqueField = cfg.dataFields[ i2 ];
3362
+ var dataField = cfg.dataFieldsMap[ uniqueField ];
3363
+ var title = ( cfg.columnNames && cfg.columnNames[ uniqueField ] ) || cfg.titles[ uniqueField ] || uniqueField;
3364
+ var value = cfg.data[ i1 ][ dataField ];
3365
+
3366
+ // SKIP NULL ONES
3367
+ if ( value == null ) {
3368
+ value = undefined;
3369
+ }
3370
+
3371
+ // TITLEFY
3372
+ if ( cfg.exportTitles && _this.setup.chart.type != "gantt" ) {
3373
+ if ( title in tmp ) {
3374
+ title += [ "( ", uniqueField, " )" ].join( "" );
3375
+ }
3376
+ }
3377
+
3378
+ // PROCESS CATEGORY
3379
+ if ( cfg.dateFields.indexOf( dataField ) != -1 ) {
3380
+
3381
+ // CONVERT DATESTRING TO DATE OBJECT
3382
+ if ( cfg.dataDateFormat && ( value instanceof String || typeof value == "string" ) ) {
3383
+ value = AmCharts.stringToDate( value, cfg.dataDateFormat );
3384
+
3385
+ // CONVERT TIMESTAMP TO DATE OBJECT
3386
+ } else if ( cfg.dateFormat && ( value instanceof Number || typeof value == "number" ) ) {
3387
+ value = new Date( value );
3388
+ }
3389
+
3390
+ // CATEGORY RANGE
3391
+ if ( cfg.exportSelection ) {
3392
+ if ( value instanceof Date ) {
3393
+ if ( value < chart.startDate || value > chart.endDate ) {
3394
+ skip = true;
3395
+ }
3396
+
3397
+ } else if ( i1 < chart.startIndex || i1 > chart.endIndex ) {
3398
+ skip = true;
3399
+ }
3400
+ }
3401
+
3402
+ // CATEGORY FORMAT
3403
+ if ( cfg.dateFormat && cfg.dateFormat != "dateObject" && value instanceof Date ) {
3404
+ value = AmCharts.formatDate( value, cfg.dateFormat );
3405
+ }
3406
+ }
3407
+
3408
+ cfg.dataFieldsTitlesMap[ dataField ] = title;
3409
+
3410
+ tmp[ title ] = value;
3411
+ }
3412
+ if ( !skip ) {
3413
+ buffer.push( tmp );
3414
+ }
3415
+ }
3416
+ cfg.data = buffer;
3417
+ }
3418
+
3419
+ if ( cfg.processData !== undefined ) {
3420
+ cfg.data = _this.handleCallback( cfg.processData, cfg.data, cfg );
3421
+ }
3422
+
3423
+ return cfg.data;
3424
+ },
3425
+
3426
+ /**
3427
+ * Prettifies string
3428
+ */
3429
+ capitalize: function( string ) {
3430
+ return string.charAt( 0 ).toUpperCase() + string.slice( 1 ).toLowerCase();
3431
+ },
3432
+
3433
+ /**
3434
+ * Generates export menu; returns UL node
3435
+ */
3436
+ createMenu: function( list, container ) {
3437
+ var div;
3438
+ var buffer = [];
3439
+
3440
+ function buildList( list, container ) {
3441
+ var i1, i2, ul = document.createElement( "ul" );
3442
+ for ( i1 = 0; i1 < list.length; i1++ ) {
3443
+ var item = typeof list[ i1 ] === "string" ? {
3444
+ format: list[ i1 ]
3445
+ } : list[ i1 ];
3446
+ var li = document.createElement( "li" );
3447
+ var a = document.createElement( "a" );
3448
+ var img = document.createElement( "img" );
3449
+ var span = document.createElement( "span" );
3450
+ var action = String( item.action ? item.action : item.format ).toLowerCase();
3451
+
3452
+ item.format = String( item.format ).toUpperCase();
3453
+
3454
+ // REMOVE ACTIVE CLASS ON MOUSELEAVE
3455
+ li.addEventListener("mouseleave",function(e) {
3456
+ this.classList.remove("active");
3457
+ });
3458
+
3459
+ // LISTEN ON FOCUS; NON-TOUCH DEVICES ONLY
3460
+ a.addEventListener( "focus", function( e ) {
3461
+ if ( !_this.setup.hasTouch ) {
3462
+ _this.setup.focusedMenuItem = this;
3463
+ var list = this.parentNode;
3464
+
3465
+ if ( list.tagName != "UL" ) {
3466
+ list = list.parentNode;
3467
+ }
3468
+
3469
+ // REMOVE ACTIVE CLASSES
3470
+ var items = list.getElementsByTagName("li");
3471
+ for ( i1 = 0; i1 < items.length; i1++ ) {
3472
+ items[i1].classList.remove("active");
3473
+ }
3474
+
3475
+ this.parentNode.classList.add( "active" );
3476
+ this.parentNode.parentNode.parentNode.classList.add( "active" );
3477
+ }
3478
+ } );
3479
+
3480
+ // MERGE WITH GIVEN FORMAT
3481
+ if ( _this.config.formats[ item.format ] ) {
3482
+ item = _this.deepMerge( {
3483
+ label: item.icon ? "" : item.format,
3484
+ format: item.format,
3485
+ mimeType: _this.config.formats[ item.format ].mimeType,
3486
+ extension: _this.config.formats[ item.format ].extension,
3487
+ capture: _this.config.formats[ item.format ].capture,
3488
+ action: _this.config.action,
3489
+ fileName: _this.config.fileName
3490
+ }, item );
3491
+ } else if ( !item.label ) {
3492
+ item.label = item.label ? item.label : _this.i18l( "menu.label." + action );
3493
+ }
3494
+
3495
+ // FILTER; TOGGLE FLAG
3496
+ if ( [ "CSV", "JSON", "XLSX" ].indexOf( item.format ) != -1 && [ "map", "gauge" ].indexOf( _this.setup.chart.type ) != -1 ) {
3497
+ continue;
3498
+
3499
+ // BLOB EXCEPTION
3500
+ } else if ( !_this.setup.hasBlob && item.format != "UNDEFINED" ) {
3501
+ if ( item.mimeType && item.mimeType.split( "/" )[ 0 ] != "image" && item.mimeType != "text/plain" ) {
3502
+ continue;
3503
+ }
3504
+ }
3505
+
3506
+ // DRAWING
3507
+ if ( item.action == "draw" ) {
3508
+ if ( _this.config.fabric.drawing.enabled ) {
3509
+ item.menu = item.menu ? item.menu : _this.config.fabric.drawing.menu;
3510
+ item.click = ( function( item ) {
3511
+ return function() {
3512
+ this.capture( item, function() {
3513
+ this.createMenu( item.menu );
3514
+ } );
3515
+ }
3516
+ } )( item );
3517
+ } else {
3518
+ item.menu = [];
3519
+ }
3520
+
3521
+ // DRAWING CHOICES
3522
+ } else if ( !item.populated && item.action && item.action.indexOf( "draw." ) != -1 ) {
3523
+ var type = item.action.split( "." )[ 1 ];
3524
+ var items = item[ type ] || _this.config.fabric.drawing[ type ] || [];
3525
+
3526
+ item.menu = [];
3527
+ item.populated = true;
3528
+
3529
+ for ( i2 = 0; i2 < items.length; i2++ ) {
3530
+ var tmp = {
3531
+ "label": items[ i2 ]
3532
+ }
3533
+
3534
+ if ( type == "shapes" ) {
3535
+ var io = items[ i2 ].indexOf( "//" ) == -1;
3536
+ var url = ( io ? _this.config.path + "shapes/" : "" ) + items[ i2 ];
3537
+
3538
+ tmp.action = "add";
3539
+ tmp.url = url;
3540
+ tmp.icon = url;
3541
+ tmp.ignore = io;
3542
+ tmp[ "class" ] = "export-drawing-shape";
3543
+
3544
+ } else if ( type == "colors" ) {
3545
+ tmp.style = "background-color: " + items[ i2 ];
3546
+ tmp.action = "change";
3547
+ tmp.color = items[ i2 ];
3548
+ tmp[ "class" ] = "export-drawing-color";
3549
+
3550
+ } else if ( type == "widths" ) {
3551
+ tmp.action = "change";
3552
+ tmp.width = items[ i2 ];
3553
+ tmp.label = document.createElement( "span" );
3554
+
3555
+ tmp.label.style.width = _this.numberToPx( items[ i2 ] );
3556
+ tmp.label.style.height = _this.numberToPx( items[ i2 ] );
3557
+ tmp[ "class" ] = "export-drawing-width";
3558
+ } else if ( type == "opacities" ) {
3559
+ tmp.style = "opacity: " + items[ i2 ];
3560
+ tmp.action = "change";
3561
+ tmp.opacity = items[ i2 ];
3562
+ tmp.label = ( items[ i2 ] * 100 ) + "%";
3563
+ tmp[ "class" ] = "export-drawing-opacity";
3564
+ } else if ( type == "modes" ) {
3565
+ tmp.label = _this.i18l( "menu.label.draw.modes." + items[ i2 ] );
3566
+ tmp.click = ( function( mode ) {
3567
+ return function() {
3568
+ _this.drawing.mode = mode;
3569
+ }
3570
+ } )( items[ i2 ] );
3571
+ tmp[ "class" ] = "export-drawing-mode";
3572
+ }
3573
+
3574
+ item.menu.push( tmp );
3575
+ }
3576
+
3577
+ // ADD CLICK HANDLER
3578
+ } else if ( !item.click && !item.menu && !item.items ) {
3579
+ // DRAWING METHODS
3580
+ if ( _this.drawing.handler[ action ] instanceof Function ) {
3581
+ item.action = action;
3582
+ item.click = ( function( item ) {
3583
+ return function() {
3584
+ this.drawing.handler[ item.action ]( item );
3585
+
3586
+ if ( item.action != "cancel" ) {
3587
+ this.createMenu( this.config.fabric.drawing.menu );
3588
+ }
3589
+ }
3590
+ } )( item );
3591
+
3592
+ // DRAWING
3593
+ } else if ( _this.drawing.enabled ) {
3594
+ item.click = ( function( item ) {
3595
+ return function() {
3596
+ if ( this.config.drawing.autoClose ) {
3597
+ this.drawing.handler.done();
3598
+ }
3599
+ this[ "to" + item.format ]( item, function( data ) {
3600
+ if ( item.action == "download" ) {
3601
+ this.download( data, item.mimeType, [ item.fileName, item.extension ].join( "." ) );
3602
+ }
3603
+ } );
3604
+ }
3605
+ } )( item );
3606
+
3607
+ // REGULAR
3608
+ } else if ( item.format != "UNDEFINED" ) {
3609
+ item.click = ( function( item ) {
3610
+ return function() {
3611
+ if ( item.capture || item.action == "print" || item.format == "PRINT" ) {
3612
+ this.capture( item, function() {
3613
+ this.drawing.handler.done();
3614
+ this[ "to" + item.format ]( item, function( data ) {
3615
+ if ( item.action == "download" ) {
3616
+ this.download( data, item.mimeType, [ item.fileName, item.extension ].join( "." ) );
3617
+ }
3618
+ } );
3619
+ } )
3620
+
3621
+ } else if ( this[ "to" + item.format ] ) {
3622
+ this[ "to" + item.format ]( item, function( data ) {
3623
+ this.download( data, item.mimeType, [ item.fileName, item.extension ].join( "." ) );
3624
+ } );
3625
+ } else {
3626
+ throw new Error( 'Invalid format. Could not determine output type.' );
3627
+ }
3628
+ }
3629
+ } )( item );
3630
+ }
3631
+ }
3632
+
3633
+ // HIDE EMPTY ONES
3634
+ if ( item.menu !== undefined && !item.menu.length ) {
3635
+ continue;
3636
+ }
3637
+
3638
+ // ADD LINK ATTR
3639
+ a.setAttribute( "href", "#" );
3640
+
3641
+ // ENABLE MANUAL ACTIVE STATE ON TOUCH DEVICES
3642
+ if ( _this.setup.hasTouch && li.classList ) {
3643
+ a.addEventListener( "touchend", ( function( callback, item ) {
3644
+ return function( e ) {
3645
+ e.preventDefault();
3646
+ var args = [ e, item ];
3647
+
3648
+ // DELAYED
3649
+ if ( ( item.action == "draw" || item.format == "PRINT" || ( item.format != "UNDEFINED" && item.capture ) ) && !_this.drawing.enabled ) {
3650
+
3651
+ // VALIDATE DELAY
3652
+ if ( !isNaN( item.delay ) || !isNaN( _this.config.delay ) ) {
3653
+ item.delay = !isNaN( item.delay ) ? item.delay : _this.config.delay;
3654
+ _this.delay( item, callback );
3655
+ return;
3656
+ }
3657
+ }
3658
+
3659
+ callback.apply( _this, args );
3660
+ }
3661
+ } )( item.click || function( e ) {
3662
+ e.preventDefault();
3663
+ }, item ) );
3664
+
3665
+ a.addEventListener( "touchend", ( function( item ) {
3666
+ return function( e ) {
3667
+ e.preventDefault();
3668
+ var li = item.elements.li;
3669
+ var parentIsActive = hasActiveParent( li );
3670
+ var siblingIsActive = hasActiveSibling( li );
3671
+ var childHasSubmenu = hasSubmenu( li );
3672
+
3673
+ // CHECK IF PARENT IS ACTIVE
3674
+ function hasActiveParent( elm ) {
3675
+ var parentNode = elm.parentNode.parentNode;
3676
+ var classList = parentNode.classList;
3677
+
3678
+ if ( parentNode.tagName == "LI" && classList.contains( "active" ) ) {
3679
+ return true;
3680
+ }
3681
+ return false;
3682
+ }
3683
+
3684
+ // CHECK IF ANY SIBLING IS ACTIVE
3685
+ function hasActiveSibling( elm ) {
3686
+ var siblings = elm.parentNode.children;
3687
+
3688
+ for ( i1 = 0; i1 < siblings.length; i1++ ) {
3689
+ var sibling = siblings[ i1 ];
3690
+ var classList = sibling.classList;
3691
+ if ( sibling !== elm && classList.contains( "active" ) ) {
3692
+ classList.remove( "active" );
3693
+ return true;
3694
+ }
3695
+ }
3696
+
3697
+ return false;
3698
+ }
3699
+
3700
+ // CHECK IF SUBEMNU EXIST
3701
+ function hasSubmenu( elm ) {
3702
+ return elm.getElementsByTagName( "ul" ).length > 0;
3703
+ }
3704
+
3705
+ // CHECK FOR ROOT ITEMS
3706
+ function isRoot( elm ) {
3707
+ return elm.classList.contains( "export-main" ) || elm.classList.contains( "export-drawing" );
3708
+ }
3709
+
3710
+ // TOGGLE MAIN MENU
3711
+ if ( isRoot( li ) || !childHasSubmenu ) {
3712
+ _this.setup.menu.classList.toggle( "active" );
3713
+ }
3714
+
3715
+ // UNTOGGLE BUFFERED ITEMS
3716
+ if ( !parentIsActive || !childHasSubmenu ) {
3717
+ while ( buffer.length ) {
3718
+ var tmp = buffer.pop();
3719
+ var tmpRoot = isRoot( tmp );
3720
+ var tmpOdd = tmp !== li;
3721
+
3722
+ if ( tmpRoot ) {
3723
+ if ( !childHasSubmenu ) {
3724
+ tmp.classList.remove( "active" );
3725
+ }
3726
+ } else if ( tmpOdd ) {
3727
+ tmp.classList.remove( "active" );
3728
+ }
3729
+ }
3730
+ }
3731
+
3732
+ // BUFFER ITEMS
3733
+ buffer.push( li );
3734
+
3735
+ // TOGGLE CLASS
3736
+ if ( childHasSubmenu ) {
3737
+ li.classList.toggle( "active" );
3738
+ }
3739
+ }
3740
+ } )( item ) );
3741
+
3742
+ // NON TOUCH DEVICES
3743
+ } else {
3744
+ a.addEventListener( "click", ( function( callback, item ) {
3745
+ return function( e ) {
3746
+ e.preventDefault();
3747
+ var args = [ e, item ];
3748
+
3749
+ // DELAYED
3750
+ if ( ( item.action == "draw" || item.format == "PRINT" || ( item.format != "UNDEFINED" && item.capture ) ) && !_this.drawing.enabled ) {
3751
+
3752
+ // VALIDATE DELAY
3753
+ if ( !isNaN( item.delay ) || !isNaN( _this.config.delay ) ) {
3754
+ item.delay = !isNaN( item.delay ) ? item.delay : _this.config.delay;
3755
+ _this.delay( item, callback );
3756
+ return;
3757
+ }
3758
+ }
3759
+
3760
+ callback.apply( _this, args );
3761
+ }
3762
+ } )( item.click || function( e ) {
3763
+ e.preventDefault();
3764
+ }, item ) );
3765
+ }
3766
+
3767
+ li.appendChild( a );
3768
+
3769
+ // ADD LABEL
3770
+ if ( _this.isElement( item.label ) ) {
3771
+ span.appendChild( item.label );
3772
+ } else {
3773
+ span.innerHTML = item.label;
3774
+ }
3775
+
3776
+ // APPEND ITEMS
3777
+ if ( item[ "class" ] ) {
3778
+ li.className = item[ "class" ];
3779
+ }
3780
+
3781
+ if ( item.style ) {
3782
+ li.setAttribute( "style", item.style );
3783
+ }
3784
+
3785
+ if ( item.icon ) {
3786
+ img.setAttribute( "src", ( !item.ignore && item.icon.slice( 0, 10 ).indexOf( "//" ) == -1 ? chart.pathToImages : "" ) + item.icon );
3787
+ a.appendChild( img );
3788
+ }
3789
+ if ( item.label ) {
3790
+ a.appendChild( span );
3791
+ }
3792
+ if ( item.title ) {
3793
+ a.setAttribute( "title", item.title );
3794
+ }
3795
+
3796
+ // CALLBACK; REVIVER FOR MENU ITEMS
3797
+ if ( _this.config.menuReviver ) {
3798
+ li = _this.config.menuReviver.apply( _this, [ item, li ] );
3799
+ }
3800
+
3801
+ // ADD ELEMENTS FOR EASY ACCESS
3802
+ item.elements = {
3803
+ li: li,
3804
+ a: a,
3805
+ img: img,
3806
+ span: span
3807
+ }
3808
+
3809
+ // ADD SUBLIST; JUST WITH ENTRIES
3810
+ if ( ( item.menu || item.items ) && item.action != "draw" ) {
3811
+ if ( buildList( item.menu || item.items, li ).childNodes.length ) {
3812
+ ul.appendChild( li );
3813
+ }
3814
+ } else {
3815
+ ul.appendChild( li );
3816
+ }
3817
+ }
3818
+
3819
+ // JUST ADD THOSE WITH ENTRIES
3820
+ if ( ul.childNodes.length ) {
3821
+ container.appendChild( ul );
3822
+ }
3823
+
3824
+ return ul;
3825
+ }
3826
+
3827
+ // DETERMINE CONTAINER
3828
+ if ( !container ) {
3829
+ if ( typeof _this.config.divId == "string" ) {
3830
+ _this.config.divId = container = document.getElementById( _this.config.divId );
3831
+ } else if ( _this.isElement( _this.config.divId ) ) {
3832
+ container = _this.config.divId;
3833
+ } else {
3834
+ container = _this.setup.chart.containerDiv;
3835
+ }
3836
+ }
3837
+
3838
+ // CREATE / RESET MENU CONTAINER
3839
+ if ( _this.isElement( _this.setup.menu ) ) {
3840
+ _this.setup.menu.innerHTML = "";
3841
+ } else {
3842
+ _this.setup.menu = document.createElement( "div" );
3843
+ }
3844
+ _this.setup.menu.setAttribute( "class", _this.setup.chart.classNamePrefix + "-export-menu " + _this.setup.chart.classNamePrefix + "-export-menu-" + _this.config.position + " amExportButton" );
3845
+
3846
+ // CALLBACK; REPLACES THE MENU WALKER
3847
+ if ( _this.config.menuWalker ) {
3848
+ buildList = _this.config.menuWalker;
3849
+ }
3850
+ buildList.apply( this, [ list, _this.setup.menu ] );
3851
+
3852
+ // JUST ADD THOSE WITH ENTRIES
3853
+ if ( _this.setup.menu.childNodes.length ) {
3854
+ container.appendChild( _this.setup.menu );
3855
+ }
3856
+
3857
+ return _this.setup.menu;
3858
+ },
3859
+
3860
+ /**
3861
+ * Method to trigger the callback delayed
3862
+ */
3863
+ delay: function( options, callback ) {
3864
+ var cfg = _this.deepMerge( {
3865
+ delay: 3,
3866
+ precision: 2
3867
+ }, options || {} );
3868
+ var t1, t2, start = Number( new Date() );
3869
+ var menu = _this.createMenu( [ {
3870
+ label: _this.i18l( "capturing.delayed.menu.label" ).replace( "{{duration}}", AmCharts.toFixed( cfg.delay, cfg.precision ) ),
3871
+ title: _this.i18l( "capturing.delayed.menu.title" ),
3872
+ "class": "export-delayed-capturing",
3873
+ click: function() {
3874
+ clearTimeout( t1 );
3875
+ clearTimeout( t2 );
3876
+ _this.createMenu( _this.config.menu );
3877
+ }
3878
+ } ] );
3879
+ var label = menu.getElementsByTagName( "a" )[ 0 ];
3880
+
3881
+ // MENU UPDATE
3882
+ t1 = setInterval( function() {
3883
+ var diff = cfg.delay - ( Number( new Date() ) - start ) / 1000;
3884
+ if ( diff <= 0 ) {
3885
+ clearTimeout( t1 );
3886
+ if ( cfg.action != "draw" ) {
3887
+ _this.createMenu( _this.config.menu );
3888
+ }
3889
+ } else if ( label ) {
3890
+ label.innerHTML = _this.i18l( "capturing.delayed.menu.label" ).replace( "{{duration}}", AmCharts.toFixed( diff, 2 ) );
3891
+ }
3892
+ }, AmCharts.updateRate );
3893
+
3894
+ // CALLBACK
3895
+ t2 = setTimeout( function() {
3896
+ callback.apply( _this, arguments );
3897
+ }, cfg.delay * 1000 );
3898
+ },
3899
+
3900
+ /**
3901
+ * Migration method to support old export setup
3902
+ */
3903
+ migrateSetup: function( setup ) {
3904
+ var cfg = {
3905
+ enabled: true,
3906
+ migrated: true,
3907
+ libs: {
3908
+ autoLoad: true
3909
+ },
3910
+ menu: []
3911
+ };
3912
+
3913
+ function crawler( object ) {
3914
+ var key;
3915
+ for ( key in object ) {
3916
+ var value = object[ key ];
3917
+
3918
+ if ( key.slice( 0, 6 ) == "export" && value ) {
3919
+ cfg.menu.push( key.slice( 6 ) );
3920
+ } else if ( key == "userCFG" ) {
3921
+ crawler( value );
3922
+ } else if ( key == "menuItems" ) {
3923
+ cfg.menu = value;
3924
+ } else if ( key == "libs" ) {
3925
+ cfg.libs = value;
3926
+ } else if ( typeof key == "string" ) {
3927
+ cfg[ key ] = value;
3928
+ }
3929
+ }
3930
+ }
3931
+
3932
+ crawler( setup );
3933
+
3934
+ return cfg;
3935
+ },
3936
+
3937
+ /*
3938
+ ** Method to clear all listeners
3939
+ */
3940
+ clear: function() {
3941
+ var i1, listener;
3942
+
3943
+ // Remove fabric listeners
3944
+ if ( _this.setup.fabric !== undefined ) {
3945
+ _this.setup.fabric.removeListeners();
3946
+ }
3947
+
3948
+ // Loop through the buffered listeners
3949
+ for ( i1 = 0; i1 < _this.listenersToRemove.length; i1++ ) {
3950
+ listener = _this.listenersToRemove[ i1 ];
3951
+ listener.node.removeEventListener( listener.event, listener.method );
3952
+ }
3953
+
3954
+ // Remove wrapper
3955
+ if ( _this.isElement(_this.setup.wrapper) && _this.isElement(_this.setup.wrapper.parentNode) && _this.setup.wrapper.parentNode.removeChild ) {
3956
+ _this.setup.wrapper.parentNode.removeChild(_this.setup.wrapper);
3957
+ }
3958
+
3959
+ // Remove menu
3960
+ if ( _this.isElement(_this.setup.menu) && _this.isElement(_this.setup.wrapper.parentNode) && _this.setup.wrapper.parentNode.removeChild ) {
3961
+ _this.setup.menu.parentNode.removeChild(_this.setup.menu);
3962
+ }
3963
+
3964
+ // Remove references
3965
+ _this.listenersToRemove = [];
3966
+ _this.setup.chart.AmExport = undefined;
3967
+ _this.setup.chart.export = undefined;
3968
+ _this.setup = undefined;
3969
+ },
3970
+
3971
+ /*
3972
+ ** Add event listener
3973
+ */
3974
+ loadListeners: function() {
3975
+ function handleClone( clone ) {
3976
+ if ( clone ) {
3977
+ clone.set( {
3978
+ top: clone.top + 10,
3979
+ left: clone.left + 10
3980
+ } );
3981
+ _this.setup.fabric.add( clone );
3982
+ }
3983
+ }
3984
+
3985
+ // OBSERVE; KEY LISTENER; DRAWING FEATURES
3986
+ if ( _this.config.keyListener && _this.config.keyListener != "attached" ) {
3987
+
3988
+ _this.docListener = function( e ) {
3989
+ var current = _this.drawing.buffer.target;
3990
+ var KEY_WHITELIST = [ 37, 38, 39, 40, 13, 9, 27 ];
3991
+ var MENU_LEFT = [ "top-left", "bottom-left" ].indexOf( _this.config.position ) != -1;
3992
+ var MENU_RIGHT = [ "top-right", "bottom-right" ].indexOf( _this.config.position ) != -1;
3993
+
3994
+ // FOCUS FIRST ITEM IN MENU
3995
+ function focusFirst( list, throughTab ) {
3996
+ for ( i1 = 0; i1 < list.length; i1++ ) {
3997
+ var item = list[ i1 ];
3998
+ item.parentNode.classList.remove( "active" );
3999
+
4000
+ // DO NOT THAT THROUGH TAB COMMANDS
4001
+ if ( i1 == 0 && !throughTab ) {
4002
+ item.focus();
4003
+ }
4004
+ }
4005
+ }
4006
+
4007
+ // FOCUS NEXT MENU
4008
+ function focusNext( throughTab ) {
4009
+ if ( _this.setup.focusedMenuItem && _this.setup.focusedMenuItem.nextSibling ) {
4010
+ _this.setup.focusedMenuItem.parentNode.classList.add( "active" );
4011
+ focusFirst( _this.setup.focusedMenuItem.nextSibling.getElementsByTagName( "a" ), throughTab );
4012
+ }
4013
+ }
4014
+
4015
+ // FOCUS PREVIOUS MENU
4016
+ function focusPrev( throughTab ) {
4017
+ if ( _this.setup.focusedMenuItem && _this.setup.focusedMenuItem.parentNode.parentNode.parentNode ) {
4018
+ _this.setup.focusedMenuItem.parentNode.classList.add( "active" );
4019
+ focusFirst( _this.setup.focusedMenuItem.parentNode.parentNode.parentNode.getElementsByTagName( "a" ), throughTab );
4020
+ }
4021
+ }
4022
+
4023
+ // FOCUS NEXT ITEM
4024
+ function focusDown( throughTab ) {
4025
+ if ( _this.setup.focusedMenuItem && _this.setup.focusedMenuItem.parentNode.nextSibling ) {
4026
+ _this.setup.focusedMenuItem.parentNode.classList.remove( "active" );
4027
+ focusFirst( _this.setup.focusedMenuItem.parentNode.nextSibling.getElementsByTagName( "a" ), throughTab );
4028
+ }
4029
+ }
4030
+ // FOCUS PREVIOUS ITEM
4031
+ function focusUp( throughTab ) {
4032
+ if ( _this.setup.focusedMenuItem && _this.setup.focusedMenuItem.parentNode.previousSibling ) {
4033
+ _this.setup.focusedMenuItem.parentNode.classList.remove( "active" );
4034
+ focusFirst( _this.setup.focusedMenuItem.parentNode.previousSibling.getElementsByTagName( "a" ), throughTab );
4035
+ }
4036
+ }
4037
+
4038
+ // BLUR EVERYTHING
4039
+ function blurAll() {
4040
+ function unselectParents( elm ) {
4041
+ if ( _this.isElement(elm) ) {
4042
+ try {
4043
+ elm.blur();
4044
+ } catch(e) {
4045
+ // Lovely IE
4046
+ }
4047
+
4048
+ // BLUR PARENT
4049
+ if ( elm.parentNode ) {
4050
+ elm.parentNode.classList.remove( "active" );
4051
+ }
4052
+
4053
+ // ENOUGH; EXIT ON MENU WRAPPER
4054
+ if ( !elm.classList.contains( "amExportButton" ) ) {
4055
+ unselectParents( elm.parentNode );
4056
+ }
4057
+ }
4058
+ }
4059
+
4060
+ // TRIGGER PRIV. FUNC. ONLY ON FOCUSED ELEMENT
4061
+ if ( _this.setup.focusedMenuItem ) {
4062
+ unselectParents( _this.setup.focusedMenuItem );
4063
+ _this.setup.focusedMenuItem = undefined;
4064
+ }
4065
+ }
4066
+
4067
+ // IF WE'VE A FOCUSED ELEMENT
4068
+ if ( _this.setup.focusedMenuItem && KEY_WHITELIST.indexOf( e.keyCode ) != -1 ) {
4069
+
4070
+ // TAB (focusedMenuItem holds the previous selected element)
4071
+ if ( e.keyCode == 9 ) {
4072
+
4073
+ // NEXT ITEM AVAILABLE?
4074
+ if ( !_this.setup.focusedMenuItem.nextSibling ) {
4075
+ _this.setup.focusedMenuItem.parentNode.classList.remove( "active" );
4076
+
4077
+ // NEXT PARENT ITEM AVAILABLE?
4078
+ if ( !_this.setup.focusedMenuItem.parentNode.nextSibling ) {
4079
+ _this.setup.focusedMenuItem.parentNode.classList.remove( "active" );
4080
+ _this.setup.focusedMenuItem.parentNode.parentNode.parentNode.classList.remove( "active" );
4081
+ }
4082
+
4083
+ // SHIFT
4084
+ } else if ( e.shiftKey ) {
4085
+ _this.setup.focusedMenuItem.parentNode.classList.remove( "active" );
4086
+ }
4087
+ return;
4088
+ }
4089
+
4090
+ // ENTER
4091
+ if ( e.keyCode == 13 && _this.setup.focusedMenuItem.nextSibling ) {
4092
+ focusNext();
4093
+ }
4094
+
4095
+ // LEFT
4096
+ if ( e.keyCode == 37 ) {
4097
+ if ( MENU_RIGHT ) {
4098
+ focusNext();
4099
+ } else {
4100
+ focusPrev();
4101
+ }
4102
+ }
4103
+
4104
+ // RIGHT
4105
+ if ( e.keyCode == 39 ) {
4106
+ if ( MENU_RIGHT ) {
4107
+ focusPrev();
4108
+ } else {
4109
+ focusNext();
4110
+ }
4111
+ }
4112
+
4113
+ // DOWN
4114
+ if ( e.keyCode == 40 ) {
4115
+ focusDown();
4116
+ }
4117
+ // UP
4118
+ if ( e.keyCode == 38 ) {
4119
+ focusUp();
4120
+ }
4121
+ // ESC
4122
+ if ( e.keyCode == 27 ) {
4123
+ blurAll();
4124
+ }
4125
+ }
4126
+
4127
+ // REMOVE; key: BACKSPACE / DELETE
4128
+ if ( ( e.keyCode == 8 || e.keyCode == 46 ) && current ) {
4129
+ e.preventDefault();
4130
+ _this.setup.fabric.remove( current );
4131
+
4132
+ // ESCAPE DRAWIN MODE; key: escape
4133
+ } else if ( e.keyCode == 27 && _this.drawing.enabled ) {
4134
+ e.preventDefault();
4135
+
4136
+ // DESELECT ACTIVE OBJECTS
4137
+ if ( _this.drawing.buffer.isSelected ) {
4138
+ _this.setup.fabric.discardActiveObject();
4139
+
4140
+ // QUIT DRAWING MODE
4141
+ } else {
4142
+ _this.drawing.handler.done();
4143
+ }
4144
+
4145
+ // COPY; key: C
4146
+ } else if ( e.keyCode == 67 && ( e.metaKey || e.ctrlKey ) && current ) {
4147
+ _this.drawing.buffer.copy = current;
4148
+
4149
+ // CUT; key: X
4150
+ } else if ( e.keyCode == 88 && ( e.metaKey || e.ctrlKey ) && current ) {
4151
+ _this.drawing.buffer.copy = current;
4152
+ _this.setup.fabric.remove( current );
4153
+
4154
+ // PASTE; key: V
4155
+ } else if ( e.keyCode == 86 && ( e.metaKey || e.ctrlKey ) ) {
4156
+ if ( _this.drawing.buffer.copy ) {
4157
+ handleClone( _this.drawing.buffer.copy.clone( handleClone ) )
4158
+ }
4159
+
4160
+ // UNDO / REDO; key: Z
4161
+ } else if ( e.keyCode == 90 && ( e.metaKey || e.ctrlKey ) ) {
4162
+ e.preventDefault();
4163
+ if ( e.shiftKey ) {
4164
+ _this.drawing.handler.redo();
4165
+ } else {
4166
+ _this.drawing.handler.undo();
4167
+ }
4168
+ }
4169
+ }
4170
+
4171
+ _this.config.keyListener = "attached";
4172
+
4173
+ document.addEventListener( "keydown", _this.docListener );
4174
+ _this.addListenerToRemove( "keydown", document, _this.docListener );
4175
+ }
4176
+
4177
+ // OBSERVE; DRAG AND DROP LISTENER; DRAWING FEATURE
4178
+ if ( _this.config.fileListener ) {
4179
+ _this.setup.chart.containerDiv.addEventListener( "dragover", _this.handleDropbox );
4180
+ _this.addListenerToRemove( "dragover", _this.setup.chart.containerDiv, _this.handleDropbox );
4181
+ _this.setup.chart.containerDiv.addEventListener( "dragleave", _this.handleDropbox );
4182
+ _this.addListenerToRemove( "dragleave", _this.setup.chart.containerDiv, _this.handleDropbox );
4183
+ _this.setup.chart.containerDiv.addEventListener( "drop", _this.handleDropbox );
4184
+ _this.addListenerToRemove( "drop", _this.setup.chart.containerDiv, _this.handleDropbox );
4185
+ }
4186
+ },
4187
+
4188
+ /**
4189
+ * Initiate export menu; waits for chart container to place menu
4190
+ */
4191
+ init: function() {
4192
+ clearTimeout( _timer );
4193
+
4194
+ _timer = setInterval( function() {
4195
+ if ( _this.setup && _this.setup.chart.containerDiv ) {
4196
+ clearTimeout( _timer );
4197
+
4198
+ if ( _this.config.enabled ) {
4199
+ // CREATE REFERENCE
4200
+ _this.setup.chart.AmExport = _this;
4201
+
4202
+ // OVERWRITE PARENT OVERFLOW
4203
+ if ( _this.config.overflow ) {
4204
+ _this.setup.chart.div.style.overflow = "visible";
4205
+ }
4206
+
4207
+ // ATTACH EVENTS
4208
+ _this.loadListeners();
4209
+
4210
+ // CREATE MENU
4211
+ _this.createMenu( _this.config.menu );
4212
+
4213
+ _this.handleReady( _this.config.onReady );
4214
+ }
4215
+ }
4216
+ }, AmCharts.updateRate );
4217
+
4218
+ },
4219
+
4220
+ /**
4221
+ * Initiates export instance; merges given config; attaches event listener
4222
+ */
4223
+ construct: function() {
4224
+ // ANNOTATION; MAP "DONE"
4225
+ _this.drawing.handler.cancel = _this.drawing.handler.done;
4226
+
4227
+ // CHECK BLOB CONSTRUCTOR
4228
+ try {
4229
+ _this.setup.hasBlob = !!new Blob;
4230
+ } catch ( e ) {}
4231
+
4232
+ // WORK AROUND TO BYPASS FILESAVER CHECK TRYING TO OPEN THE BLOB URL IN SAFARI BROWSER
4233
+ window.safari = window.safari ? window.safari : {};
4234
+
4235
+ // OVERTAKE CHART FONTSIZE IF GIVEN
4236
+ _this.defaults.fabric.drawing.fontSize = _this.setup.chart.fontSize || 11;
4237
+
4238
+ // MERGE SETTINGS
4239
+ _this.config.drawing = _this.deepMerge( _this.defaults.fabric.drawing, _this.config.drawing || {}, true );
4240
+ if ( _this.config.border ) {
4241
+ _this.config.border = _this.deepMerge( _this.defaults.fabric.border, _this.config.border || {}, true );
4242
+ }
4243
+ _this.deepMerge( _this.defaults.fabric, _this.config, true );
4244
+ _this.deepMerge( _this.defaults.fabric, _this.config.fabric || {}, true );
4245
+ _this.deepMerge( _this.defaults.pdfMake, _this.config, true );
4246
+ _this.deepMerge( _this.defaults.pdfMake, _this.config.pdfMake || {}, true );
4247
+ _this.deepMerge( _this.libs, _this.config.libs || {}, true );
4248
+
4249
+ // UPDATE CONFIG
4250
+ _this.config.drawing = _this.defaults.fabric.drawing;
4251
+ _this.config.fabric = _this.defaults.fabric;
4252
+ _this.config.pdfMake = _this.defaults.pdfMake;
4253
+ _this.config = _this.deepMerge( _this.defaults, _this.config, true );
4254
+
4255
+ // MERGE; SETUP DRAWING MENU
4256
+ if ( _this.config.fabric.drawing.enabled ) {
4257
+ if ( _this.config.fabric.drawing.menu === undefined ) {
4258
+ _this.config.fabric.drawing.menu = [];
4259
+ _this.deepMerge( _this.config.fabric.drawing.menu, [ {
4260
+ "class": "export-drawing",
4261
+ menu: [ {
4262
+ label: _this.i18l( "menu.label.draw.add" ),
4263
+ menu: [ {
4264
+ label: _this.i18l( "menu.label.draw.shapes" ),
4265
+ action: "draw.shapes"
4266
+ }, {
4267
+ label: _this.i18l( "menu.label.draw.text" ),
4268
+ action: "text"
4269
+ } ]
4270
+ }, {
4271
+ label: _this.i18l( "menu.label.draw.change" ),
4272
+ menu: [ {
4273
+ label: _this.i18l( "menu.label.draw.modes" ),
4274
+ action: "draw.modes"
4275
+ }, {
4276
+ label: _this.i18l( "menu.label.draw.colors" ),
4277
+ action: "draw.colors"
4278
+ }, {
4279
+ label: _this.i18l( "menu.label.draw.widths" ),
4280
+ action: "draw.widths"
4281
+ }, {
4282
+ label: _this.i18l( "menu.label.draw.opacities" ),
4283
+ action: "draw.opacities"
4284
+ }, "UNDO", "REDO" ]
4285
+ }, {
4286
+ label: _this.i18l( "menu.label.save.image" ),
4287
+ menu: [ "PNG", "JPG", "SVG", "PDF" ]
4288
+ }, "PRINT", "CANCEL" ]
4289
+ } ] );
4290
+ }
4291
+ }
4292
+
4293
+ // MERGE; SETUP MAIN MENU
4294
+ if ( _this.config.menu === undefined ) {
4295
+ _this.config.menu = [];
4296
+ // PARENT MENU
4297
+ _this.deepMerge( _this.config, {
4298
+ menu: [ {
4299
+ "class": "export-main",
4300
+ menu: [ {
4301
+ label: _this.i18l( "menu.label.save.image" ),
4302
+ menu: [ "PNG", "JPG", "SVG", "PDF" ]
4303
+ }, {
4304
+ label: _this.i18l( "menu.label.save.data" ),
4305
+ menu: [ "CSV", "XLSX", "JSON" ]
4306
+ }, {
4307
+ label: _this.i18l( "menu.label.draw" ),
4308
+ action: "draw",
4309
+ menu: _this.config.fabric.drawing.menu
4310
+ }, {
4311
+ format: "PRINT",
4312
+ label: _this.i18l( "menu.label.print" )
4313
+ } ]
4314
+ } ]
4315
+ } );
4316
+ }
4317
+
4318
+ // ADD MISSING PATH
4319
+ if ( !_this.libs.path ) {
4320
+ _this.libs.path = _this.config.path + "libs/";
4321
+ }
4322
+
4323
+ // ADD CLASSLIST POLYFILL IF NEEDED
4324
+ if (!_this.setup.hasClasslist) {
4325
+ _this.libs.resources.push("classList.js/classList.min.js");
4326
+ }
4327
+
4328
+ // CHECK ACCEPTANCE
4329
+ if ( _this.isSupported() ) {
4330
+ // LOAD DEPENDENCIES
4331
+ _this.loadDependencies( _this.libs.resources, _this.libs.reload );
4332
+ // ADD CLASSNAMES
4333
+ _this.setup.chart.addClassNames = true;
4334
+ // REFERENCE
4335
+ _this.setup.chart[ _this.name ] = _this;
4336
+ // INIT MENU; WAIT FOR CHART INSTANCE
4337
+ _this.init();
4338
+ }
4339
+ }
4340
+ }
4341
+
4342
+ // USE GIVEN CONFIG
4343
+ if ( config ) {
4344
+ _this.config = config;
4345
+
4346
+ // USE CHART EXPORT CONFIG
4347
+ } else if ( _this.setup.chart[ _this.name ] ) {
4348
+ _this.config = _this.setup.chart[ _this.name ];
4349
+
4350
+ // MIGRATE OLD EXPORT CHART CONFIG
4351
+ } else if ( _this.setup.chart.amExport || _this.setup.chart.exportConfig ) {
4352
+ _this.config = _this.migrateSetup( _this.setup.chart.amExport || _this.setup.chart.exportConfig );
4353
+
4354
+ // EXIT; NO CONFIG
4355
+ } else {
4356
+ return;
4357
+ }
4358
+
4359
+ // CONSTRUCT INSTANCE
4360
+ _this.construct();
4361
+
4362
+ // EXPORT SCOPE
4363
+ return _this.deepMerge( this, _this );
4364
+ }
4365
+ } )();
4366
+
4367
+ /**
4368
+ * Set init handler
4369
+ */
4370
+ AmCharts.addInitHandler( function( chart ) {
4371
+ new AmCharts[ "export" ]( chart );
4372
+ }, [ "pie", "serial", "xy", "funnel", "radar", "gauge", "stock", "map", "gantt" ] );
admin/js/amcharts/plugins/export/export.min.js CHANGED
@@ -1,2 +1 @@
1
- AmCharts.translations.export||(AmCharts.translations.export={}),AmCharts.translations.export.en||(AmCharts.translations.export.en={"fallback.save.text":"CTRL + C to copy the data into the clipboard.","fallback.save.image":"Rightclick -> Save picture as... to save the image.","capturing.delayed.menu.label":"{{duration}}","capturing.delayed.menu.title":"Click to cancel","menu.label.print":"Print","menu.label.undo":"Undo","menu.label.redo":"Redo","menu.label.cancel":"Cancel","menu.label.save.image":"Download as ...","menu.label.save.data":"Save as ...","menu.label.draw":"Annotate ...","menu.label.draw.change":"Change ...","menu.label.draw.add":"Add ...","menu.label.draw.shapes":"Shape ...","menu.label.draw.colors":"Color ...","menu.label.draw.widths":"Size ...","menu.label.draw.opacities":"Opacity ...","menu.label.draw.text":"Text","menu.label.draw.modes":"Mode ...","menu.label.draw.modes.pencil":"Pencil","menu.label.draw.modes.line":"Line","menu.label.draw.modes.arrow":"Arrow","label.saved.from":"Saved from: "}),function(){AmCharts.export=function(a,b){var c,d={name:"export",version:"1.4.56",libs:{async:!0,autoLoad:!0,reload:!1,resources:["fabric.js/fabric.min.js","FileSaver.js/FileSaver.min.js",{"jszip/jszip.min.js":["xlsx/xlsx.min.js"],"pdfmake/pdfmake.min.js":["pdfmake/vfs_fonts.js"]}],namespaces:{"pdfmake.min.js":"pdfMake","jszip.min.js":"JSZip","xlsx.min.js":"XLSX","fabric.min.js":"fabric","FileSaver.min.js":"saveAs"},loadTimeout:1e4},config:{},setup:{chart:a,hasBlob:!1,wrapper:!1,isIE:!!window.document.documentMode,IEversion:window.document.documentMode,hasTouch:"object"==typeof window.Touch},drawing:{enabled:!1,undos:[],redos:[],buffer:{position:{x1:0,y1:0,x2:0,y2:0,xD:0,yD:0}},handler:{undo:function(a,b){var c=d.drawing.undos.pop();if(c){c.selectable=!0,d.drawing.redos.push(c),"added"==c.action&&d.setup.fabric.remove(c.target);var e=JSON.parse(c.state);c.target.set(e),c.target instanceof fabric.Group&&d.drawing.handler.change({color:e.cfg.color,width:e.cfg.width,opacity:e.cfg.opacity},!0,c.target),d.setup.fabric.renderAll(),c.state!=c.target.recentState||b||d.drawing.handler.undo(c,!0)}},redo:function(a,b){var c=d.drawing.redos.pop();if(c){c.selectable=!0,d.drawing.undos.push(c),"added"==c.action&&d.setup.fabric.add(c.target);var e=JSON.parse(c.state);c.target.recentState=c.state,c.target.set(e),c.target instanceof fabric.Group&&d.drawing.handler.change({color:e.cfg.color,width:e.cfg.width,opacity:e.cfg.opacity},!0,c.target),d.setup.fabric.renderAll(),"addified"==c.action&&d.drawing.handler.redo()}},done:function(a){d.drawing.enabled=!1,d.drawing.buffer.enabled=!1,d.drawing.undos=[],d.drawing.redos=[],d.createMenu(d.config.menu),d.setup.fabric.deactivateAll(),d.setup.wrapper&&(d.setup.chart.containerDiv.removeChild(d.setup.wrapper),d.setup.wrapper=!1)},add:function(a){var b=d.deepMerge({top:d.setup.fabric.height/2,left:d.setup.fabric.width/2},a||{}),c=b.url.indexOf(".svg")!=-1?fabric.loadSVGFromURL:fabric.Image.fromURL;c(b.url,function(a,c){var e=void 0!==c?fabric.util.groupSVGElements(a,c):a,f=!1;(e.height>d.setup.fabric.height||e.width>d.setup.fabric.width)&&(f=d.setup.fabric.height/2/e.height),b.top>d.setup.fabric.height&&(b.top=d.setup.fabric.height/2),b.left>d.setup.fabric.width&&(b.left=d.setup.fabric.width/2),d.drawing.buffer.isDrawing=!0,e.set({originX:"center",originY:"center",top:b.top,left:b.left,width:f?e.width*f:e.width,height:f?e.height*f:e.height,fill:d.drawing.color}),d.setup.fabric.add(e)})},change:function(a,b,c){var f,g,h,e=d.deepMerge({},a||{}),i=c||d.drawing.buffer.target,j=i?i._objects?i._objects:[i]:null;if(e.mode&&(d.drawing.mode=e.mode),e.width&&(d.drawing.width=e.width,d.drawing.fontSize=e.fontSize=3*e.width,1==d.drawing.width&&(d.drawing.fontSize=e.fontSize=d.defaults.fabric.drawing.fontSize)),e.fontSize&&(d.drawing.fontSize=e.fontSize),e.color&&(d.drawing.color=e.color),e.opacity&&(d.drawing.opacity=e.opacity),h=d.getRGBA(d.drawing.color),h.pop(),h.push(d.drawing.opacity),d.drawing.color="rgba("+h.join()+")",d.setup.fabric.freeDrawingBrush.color=d.drawing.color,d.setup.fabric.freeDrawingBrush.width=d.drawing.width,i){for(f=JSON.parse(i.recentState).cfg,f&&(e.color=e.color||f.color,e.width=e.width||f.width,e.opacity=e.opacity||f.opacity,e.fontSize=e.fontSize||f.fontSize,h=d.getRGBA(e.color),h.pop(),h.push(e.opacity),e.color="rgba("+h.join()+")"),g=0;g<j.length;g++)j[g]instanceof fabric.Text||j[g]instanceof fabric.PathGroup||j[g]instanceof fabric.Triangle?((e.color||e.opacity)&&j[g].set({fill:e.color}),e.fontSize&&j[g].set({fontSize:e.fontSize})):(j[g]instanceof fabric.Path||j[g]instanceof fabric.Line)&&(i instanceof fabric.Group?(e.color||e.opacity)&&j[g].set({stroke:e.color}):((e.color||e.opacity)&&j[g].set({stroke:e.color}),e.width&&j[g].set({strokeWidth:e.width})));b||(f=JSON.stringify(d.deepMerge(i.saveState().originalState,{cfg:{color:e.color,width:e.width,opacity:e.opacity}})),i.recentState=f,d.drawing.redos=[],d.drawing.undos.push({action:"modified",target:i,state:f})),d.setup.fabric.renderAll()}},text:function(a){var b=d.deepMerge({text:d.i18l("menu.label.draw.text"),top:d.setup.fabric.height/2,left:d.setup.fabric.width/2,fontSize:d.drawing.fontSize,fontFamily:d.setup.chart.fontFamily||"Verdana",fill:d.drawing.color},a||{});b.click=function(){};var c=new fabric.IText(b.text,b);return d.drawing.buffer.isDrawing=!0,d.setup.fabric.add(c),d.setup.fabric.setActiveObject(c),c.selectAll(),c.enterEditing(),c},line:function(a){var c,e,f,g,b=d.deepMerge({x1:d.setup.fabric.width/2-d.setup.fabric.width/10,x2:d.setup.fabric.width/2+d.setup.fabric.width/10,y1:d.setup.fabric.height/2,y2:d.setup.fabric.height/2,angle:90,strokeLineCap:d.drawing.lineCap,arrow:d.drawing.arrow,color:d.drawing.color,width:d.drawing.width,group:[]},a||{}),h=new fabric.Line([b.x1,b.y1,b.x2,b.y2],{stroke:b.color,strokeWidth:b.width,strokeLineCap:b.strokeLineCap});if(b.group.push(h),b.arrow&&(b.angle=b.angle?b.angle:d.getAngle(b.x1,b.y1,b.x2,b.y2),"start"==b.arrow?(f=b.y1+b.width/2,g=b.x1+b.width/2):"middle"==b.arrow?(f=b.y2+b.width/2-(b.y2-b.y1)/2,g=b.x2+b.width/2-(b.x2-b.x1)/2):(f=b.y2+b.width/2,g=b.x2+b.width/2),e=new fabric.Triangle({top:f,left:g,fill:b.color,height:7*b.width,width:7*b.width,angle:b.angle,originX:"center",originY:"bottom"}),b.group.push(e)),d.drawing.buffer.isDrawing=!0,"config"!=b.action){if(b.arrow){var i=new fabric.Group(b.group);return i.set({cfg:b,fill:b.color,action:b.action,selectable:!0,known:"change"==b.action}),"change"==b.action&&d.setup.fabric.setActiveObject(i),d.setup.fabric.add(i),i}return d.setup.fabric.add(h),h}for(c=0;c<b.group.length;c++)d.setup.fabric.add(b.group[c]);return b}}},defaults:{position:"top-right",fileName:"amCharts",action:"download",overflow:!0,path:(a.path||"")+"plugins/export/",formats:{JPG:{mimeType:"image/jpg",extension:"jpg",capture:!0},PNG:{mimeType:"image/png",extension:"png",capture:!0},SVG:{mimeType:"text/xml",extension:"svg",capture:!0},PDF:{mimeType:"application/pdf",extension:"pdf",capture:!0},CSV:{mimeType:"text/plain",extension:"csv"},JSON:{mimeType:"text/plain",extension:"json"},XLSX:{mimeType:"application/octet-stream",extension:"xlsx"}},fabric:{backgroundColor:"#FFFFFF",removeImages:!0,forceRemoveImages:!1,selection:!1,loadTimeout:5e3,drawing:{enabled:!0,arrow:"end",lineCap:"butt",mode:"pencil",modes:["pencil","line","arrow"],color:"#000000",colors:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF"],shapes:["11.svg","14.svg","16.svg","17.svg","20.svg","27.svg"],width:1,fontSize:11,widths:[1,5,10,15],opacity:1,opacities:[1,.8,.6,.4,.2],menu:void 0,autoClose:!0},border:{fill:"",fillOpacity:0,stroke:"#000000",strokeWidth:1,strokeOpacity:1}},pdfMake:{images:{},pageOrientation:"portrait",pageMargins:40,pageOrigin:!0,pageSize:"A4",pageSizes:{"4A0":[4767.87,6740.79],"2A0":[3370.39,4767.87],A0:[2383.94,3370.39],A1:[1683.78,2383.94],A2:[1190.55,1683.78],A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],A6:[297.64,419.53],A7:[209.76,297.64],A8:[147.4,209.76],A9:[104.88,147.4],A10:[73.7,104.88],B0:[2834.65,4008.19],B1:[2004.09,2834.65],B2:[1417.32,2004.09],B3:[1000.63,1417.32],B4:[708.66,1000.63],B5:[498.9,708.66],B6:[354.33,498.9],B7:[249.45,354.33],B8:[175.75,249.45],B9:[124.72,175.75],B10:[87.87,124.72],C0:[2599.37,3676.54],C1:[1836.85,2599.37],C2:[1298.27,1836.85],C3:[918.43,1298.27],C4:[649.13,918.43],C5:[459.21,649.13],C6:[323.15,459.21],C7:[229.61,323.15],C8:[161.57,229.61],C9:[113.39,161.57],C10:[79.37,113.39],RA0:[2437.8,3458.27],RA1:[1729.13,2437.8],RA2:[1218.9,1729.13],RA3:[864.57,1218.9],RA4:[609.45,864.57],SRA0:[2551.18,3628.35],SRA1:[1814.17,2551.18],SRA2:[1275.59,1814.17],SRA3:[907.09,1275.59],SRA4:[637.8,907.09],EXECUTIVE:[521.86,756],FOLIO:[612,936],LEGAL:[612,1008],LETTER:[612,792],TABLOID:[792,1224]}},menu:void 0,divId:null,menuReviver:null,menuWalker:null,fallback:!0,keyListener:!0,fileListener:!0,compress:!0,debug:!1},i18l:function(a,b){var c=b?b:d.setup.chart.language?d.setup.chart.language:"en",e=AmCharts.translations[d.name][c]||AmCharts.translations[d.name].en;return e[a]||a},download:function(a,b,c){if(window.saveAs&&d.setup.hasBlob){d.toBlob({data:a,type:b},function(a){saveAs(a,c)})}else if(d.config.fallback&&"text/plain"==b){var f=document.createElement("div"),g=document.createElement("div"),h=document.createElement("textarea");g.innerHTML=d.i18l("fallback.save.text"),f.appendChild(g),f.appendChild(h),g.setAttribute("class","amcharts-export-fallback-message"),f.setAttribute("class","amcharts-export-fallback"),d.setup.chart.containerDiv.appendChild(f),h.setAttribute("readonly",""),h.value=a,h.focus(),h.select(),d.createMenu([{class:"export-main export-close",label:"Done",click:function(){d.createMenu(d.config.menu),d.setup.chart.containerDiv.removeChild(f)}}])}else{if(!d.config.fallback||"image"!=b.split("/")[0])throw new Error("Unable to create file. Ensure saveAs (FileSaver.js) is supported.");var f=document.createElement("div"),g=document.createElement("div"),i=d.toImage({data:a});g.innerHTML=d.i18l("fallback.save.image"),f.appendChild(g),f.appendChild(i),g.setAttribute("class","amcharts-export-fallback-message"),f.setAttribute("class","amcharts-export-fallback"),d.setup.chart.containerDiv.appendChild(f),d.createMenu([{class:"export-main export-close",label:"Done",click:function(){d.createMenu(d.config.menu),d.setup.chart.containerDiv.removeChild(f)}}])}return a},loadResource:function(a,b){var c,e,f,g,h,i,j=a.indexOf("//")!=-1?a:[d.libs.path,a].join(""),k=function(){if(b)for(c=0;c<b.length;c++)d.loadResource(b[c])};for(a.indexOf(".js")!=-1?(f=document.createElement("script"),f.setAttribute("type","text/javascript"),f.setAttribute("src",j),d.libs.async&&f.setAttribute("async","")):a.indexOf(".css")!=-1&&(f=document.createElement("link"),f.setAttribute("type","text/css"),f.setAttribute("rel","stylesheet"),f.setAttribute("href",j)),c=0;c<document.head.childNodes.length;c++)if(g=document.head.childNodes[c],h=!!g&&(g.src||g.href),i=!!g&&g.tagName,g&&h&&h.indexOf(a)!=-1){d.libs.reload&&document.head.removeChild(g),e=!0;break}for(c in d.libs.namespaces){var l=d.libs.namespaces[c],h=a.toLowerCase(),g=c.toLowerCase();if(h.indexOf(g)!=-1&&void 0!==window[l]){e=!0;break}}e&&!d.libs.reload||(f.addEventListener("load",k),f.addEventListener("error",function(){d.handleLog(["amCharts[export]: Loading error on ",this.src||this.href].join(""))}),document.head.appendChild(f),d.listenersToRemove||(d.listenersToRemove=[]),d.listenersToRemove.push({node:f,method:k,event:"load"}))},loadDependencies:function(){var a,b;if(d.libs.autoLoad)for(a=0;a<d.libs.resources.length;a++)if(d.libs.resources[a]instanceof Object)for(b in d.libs.resources[a])d.loadResource(b,d.libs.resources[a][b]);else d.loadResource(d.libs.resources[a])},pxToNumber:function(a,b){if(a||!b)return Number(String(a).replace("px",""))||0},numberToPx:function(a){return String(a)+"px"},cloneObject:function(a){var b,c,e,f,g;b=Array.isArray(a)?[]:{};for(e in a)c=a[e],f="object"==typeof c,g=c instanceof Date,b[e]=f&&!g?d.cloneObject(c):c;return b},deepMerge:function(a,b,c){var e,f,g=b instanceof Array?"array":"object";if(!(a instanceof Object||a instanceof Array))return a;for(e in b)"array"==g&&isNaN(e)||(f=b[e],(void 0==a[e]||c)&&(f instanceof Array?a[e]=new Array:f instanceof Function?a[e]=function(){}:f instanceof Date?a[e]=new Date:f instanceof Object?a[e]=new Object:f instanceof Number?a[e]=new Number:f instanceof String&&(a[e]=new String)),(f instanceof Object||f instanceof Array)&&!(f instanceof Function||f instanceof Date||d.isElement(f))&&"chart"!=e&&"scope"!=e?d.deepMerge(a[e],f,c):a instanceof Array&&!c?a.push(f):a[e]=f);return a},isElement:function(a){return a instanceof Object&&a&&1===a.nodeType},isHashbanged:function(a){var b=String(a).replace(/\"/g,"");return"url"==b.slice(0,3)&&b.slice(b.indexOf("#")+1,b.length-1)},isPressed:function(a){return"mousemove"==a.type&&1===a.which||("touchmove"==a.type||1===a.buttons||1===a.button||1===a.which?d.drawing.buffer.isPressed=!0:d.drawing.buffer.isPressed=!1),d.drawing.buffer.isPressed},removeImage:function(a){if(a){if(d.config.fabric.forceRemoveImages)return!0;if(d.config.fabric.removeImages&&d.isTainted(a))return!0;if(d.setup.isIE&&(10==d.setup.IEversion||11==d.setup.IEversion)&&a.toLowerCase().indexOf(".svg")!=-1)return!0}return!1},isTainted:function(a){var b=String(window.location.origin||window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""));if(a){if(b.indexOf(":\\")!=-1||a.indexOf(":\\")!=-1||b.indexOf("file://")!=-1||a.indexOf("file://")!=-1)return!0;if(a.indexOf("//")!=-1&&a.indexOf(b.replace(/.*:/,""))==-1)return!0}return!1},isSupported:function(){return!!d.config.enabled&&!(d.setup.isIE&&d.setup.IEversion<=9&&(!Array.prototype.indexOf||!document.head||d.config.fallback===!1))},getAngle:function(a,b,c,d){var g,e=c-a,f=d-b;return g=0==e?0==f?0:f>0?Math.PI/2:3*Math.PI/2:0==f?e>0?0:Math.PI:e<0?Math.atan(f/e)+Math.PI:f<0?Math.atan(f/e)+2*Math.PI:Math.atan(f/e),180*g/Math.PI},gatherAttribute:function(a,b,c,e){var f,e=e?e:0,c=c?c:3;return a&&(f=a.getAttribute(b),!f&&e<c)?d.gatherAttribute(a.parentNode,b,c,e+1):f},gatherClassName:function(a,b,c,e){var f,e=e?e:0,c=c?c:3;if(d.isElement(a)){if(f=(a.getAttribute("class")||"").split(" ").indexOf(b)!=-1,!f&&e<c)return d.gatherClassName(a.parentNode,b,c,e+1);f&&(f=a)}return f},gatherElements:function(a,b,c){var e,f;for(e=0;e<a.children.length;e++){var g=a.children[e];if("clipPath"==g.tagName){var h={},i=fabric.parseTransformAttribute(d.gatherAttribute(g,"transform"));for(f=0;f<g.childNodes.length;f++)g.childNodes[f].setAttribute("fill","transparent"),h={x:d.pxToNumber(g.childNodes[f].getAttribute("x")),y:d.pxToNumber(g.childNodes[f].getAttribute("y")),width:d.pxToNumber(g.childNodes[f].getAttribute("width")),height:d.pxToNumber(g.childNodes[f].getAttribute("height"))};a.clippings[g.id]={svg:g,bbox:h,transform:i}}else if("pattern"==g.tagName){var j={node:g,source:g.getAttribute("xlink:href"),width:Number(g.getAttribute("width")),height:Number(g.getAttribute("height")),repeat:"repeat",offsetX:0,offsetY:0};for(f=0;f<g.childNodes.length;f++)if("rect"==g.childNodes[f].tagName)j.fill=g.childNodes[f].getAttribute("fill");else if("image"==g.childNodes[f].tagName){var k=fabric.parseAttributes(g.childNodes[f],fabric.SHARED_ATTRIBUTES);k.transformMatrix&&(j.offsetX=k.transformMatrix[4],j.offsetY=k.transformMatrix[5])}d.removeImage(j.source)?a.patterns[g.id]=j.fill?j.fill:"transparent":a.patterns[j.node.id]=j}else if("image"==g.tagName)c.included++,fabric.Image.fromURL(g.getAttribute("xlink:href"),function(a){c.loaded++});else{var k=["fill","stroke"];for(f=0;f<k.length;f++){var l=k[f],m=g.getAttribute(l),n=d.getRGBA(m),o=d.isHashbanged(m);!m||n||o||(g.setAttribute(l,"none"),g.setAttribute(l+"-opacity","0"))}}}return a},getRGBA:function(a,b){return!("none"==a||"transparent"==a||d.isHashbanged(a)||(a=new fabric.Color(a),!a._source))&&(b?a:a.getSource())},gatherPosition:function(a,b){var f,c=d.drawing.buffer.position,e=fabric.util.invertTransform(d.setup.fabric.viewportTransform);return"touchmove"==a.type&&("touches"in a?a=a.touches[0]:"changedTouches"in a&&(a=a.changedTouches[0])),f=fabric.util.transformPoint(d.setup.fabric.getPointer(a,!0),e),1==b&&(c.x1=f.x,c.y1=f.y),c.x2=f.x,c.y2=f.y,c.xD=c.x1-c.x2<0?(c.x1-c.x2)*-1:c.x1-c.x2,c.yD=c.y1-c.y2<0?(c.y1-c.y2)*-1:c.y1-c.y2,c},modifyFabric:function(){fabric.ElementsParser.prototype.resolveGradient=function(a,b){var c=a.get(b);if(/^url\(/.test(c)){var e=c.slice(c.indexOf("#")+1,c.length-1);if(fabric.gradientDefs[this.svgUid][e]){var f=fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][e],a);f.coords.y1&&"pie"!=d.setup.chart.type&&(f.coords.y2=f.coords.y1*-1,f.coords.y1=0),a.set(b,f)}}},fabric.Text.fromElement=function(a,b){if(!a)return null;var c=fabric.parseAttributes(a,fabric.Text.ATTRIBUTE_NAMES);b=fabric.util.object.extend(b?fabric.util.object.clone(b):{},c),b.top=b.top||0,b.left=b.left||0,"dx"in c&&(b.left+=c.dx),"dy"in c&&(b.top+=c.dy),"fontSize"in b||(b.fontSize=fabric.Text.DEFAULT_SVG_FONT_SIZE),b.originX||(b.originX="left");var d="",e=[];if("textContent"in a)if(a.childNodes)for(var f=0;f<a.childNodes.length;f++)e.push(a.childNodes[f].textContent);else e.push(a.textContent);else"firstChild"in a&&null!==a.firstChild&&"data"in a.firstChild&&null!==a.firstChild.data&&e.push(a.firstChild.data);d=e.join("\n");var g=new fabric.Text(d,b),h=0;return"left"===g.originX&&(h=g.getWidth()/2),"right"===g.originX&&(h=-g.getWidth()/2),e.length>1?g.set({left:g.getLeft()+h,top:g.getTop()+g.fontSize*(e.length-1)*(.18+g._fontSizeFraction),textAlign:b.originX,lineHeight:e.length>1?.965:1.16}):g.set({left:g.getLeft()+h,top:g.getTop()-g.getHeight()/2+g.fontSize*(.18+g._fontSizeFraction)}),g}},capture:function(a,b){var c,e=d.deepMerge(d.deepMerge({},d.config.fabric),a||{}),f=[],g={x:0,y:0,pX:0,pY:0,lX:0,lY:0,width:d.setup.chart.divRealWidth,height:d.setup.chart.divRealHeight},h={loaded:0,included:0},i={items:[],width:0,height:0,maxWidth:0,maxHeight:0};if(!d.handleNamespace("fabric",{scope:this,cb:d.capture,args:arguments}))return!1;d.modifyFabric(),d.handleCallback(e.beforeCapture,e);var j=d.setup.chart.containerDiv.getElementsByTagName("svg");for(c=0;c<j.length;c++){var k={svg:j[c],parent:j[c].parentNode,children:j[c].getElementsByTagName("*"),offset:{x:0,y:0},patterns:{},clippings:{},has:{legend:!1,panel:!1,scrollbar:!1}};k.has.legend=d.gatherClassName(k.parent,d.setup.chart.classNamePrefix+"-legend-div",1),k.has.panel=d.gatherClassName(k.parent,d.setup.chart.classNamePrefix+"-stock-panel-div"),k.has.scrollbar=d.gatherClassName(k.parent,d.setup.chart.classNamePrefix+"-scrollbar-chart-div"),k=d.gatherElements(k,e,h),f.push(k)}if(d.config.legend){if("stock"==d.setup.chart.type)for(c=0;c<d.setup.chart.panels.length;c++)d.setup.chart.panels[c].stockLegend&&d.setup.chart.panels[c].stockLegend.divId&&i.items.push(d.setup.chart.panels[c].stockLegend);else d.setup.chart.legend&&d.setup.chart.legend.divId&&i.items.push(d.setup.chart.legend);for(c=0;c<i.items.length;c++){var l=i.items[c],k={svg:l.container.container,parent:l.container.container.parentNode,children:l.container.container.getElementsByTagName("*"),offset:{x:0,y:0},legend:{id:c,type:["top","left"].indexOf(d.config.legend.position)!=-1?"unshift":"push",position:d.config.legend.position,width:d.config.legend.width?d.config.legend.width:l.container.div.offsetWidth,height:d.config.legend.height?d.config.legend.height:l.container.div.offsetHeight},patterns:{},clippings:{},has:{legend:!1,panel:!1,scrollbar:!1}};i.width+=k.legend.width,i.height+=k.legend.height,i.maxWidth=k.legend.width>i.maxWidth?k.legend.width:i.maxWidth,i.maxHeight=k.legend.height>i.maxHeight?k.legend.height:i.maxHeight,k=d.gatherElements(k,e,h),f[k.legend.type](k)}["top","bottom"].indexOf(d.config.legend.position)!=-1?(g.width=i.maxWidth>g.width?i.maxWidth:g.width,g.height+=i.height):["left","right"].indexOf(d.config.legend.position)!=-1?(g.width+=i.maxWidth,g.height=i.height>g.height?i.height:g.height):(g.height+=i.height,g.width+=i.maxWidth)}if(d.drawing.enabled=e.drawing.enabled="draw"==e.action,d.drawing.buffer.enabled=d.drawing.enabled,d.setup.wrapper=document.createElement("div"),d.setup.wrapper.setAttribute("class",d.setup.chart.classNamePrefix+"-export-canvas"),d.setup.chart.containerDiv.appendChild(d.setup.wrapper),"stock"==d.setup.chart.type){var m={top:0,right:0,bottom:0,left:0};d.setup.chart.leftContainer&&(g.width-=d.setup.chart.leftContainer.offsetWidth,m.left=d.setup.chart.leftContainer.offsetWidth+2*d.setup.chart.panelsSettings.panelSpacing),d.setup.chart.rightContainer&&(g.width-=d.setup.chart.rightContainer.offsetWidth,m.right=d.setup.chart.rightContainer.offsetWidth+2*d.setup.chart.panelsSettings.panelSpacing),d.setup.chart.periodSelector&&["top","bottom"].indexOf(d.setup.chart.periodSelector.position)!=-1&&(g.height-=d.setup.chart.periodSelector.offsetHeight+d.setup.chart.panelsSettings.panelSpacing,m[d.setup.chart.periodSelector.position]+=d.setup.chart.periodSelector.offsetHeight+d.setup.chart.panelsSettings.panelSpacing),d.setup.chart.dataSetSelector&&["top","bottom"].indexOf(d.setup.chart.dataSetSelector.position)!=-1&&(g.height-=d.setup.chart.dataSetSelector.offsetHeight,m[d.setup.chart.dataSetSelector.position]+=d.setup.chart.dataSetSelector.offsetHeight),d.setup.wrapper.style.paddingTop=d.numberToPx(m.top),d.setup.wrapper.style.paddingRight=d.numberToPx(m.right),d.setup.wrapper.style.paddingBottom=d.numberToPx(m.bottom),d.setup.wrapper.style.paddingLeft=d.numberToPx(m.left)}for(d.setup.canvas=document.createElement("canvas"),d.setup.wrapper.appendChild(d.setup.canvas),d.setup.fabric=new fabric.Canvas(d.setup.canvas,d.deepMerge({width:g.width,height:g.height,isDrawingMode:!0},e)),d.deepMerge(d.setup.fabric,e),d.deepMerge(d.setup.fabric.freeDrawingBrush,e.drawing),d.deepMerge(d.drawing,e.drawing),d.drawing.handler.change(e.drawing),d.setup.fabric.on("mouse:down",function(a){d.gatherPosition(a.e,1);d.drawing.buffer.pressedTS=Number(new Date),d.isPressed(a.e),d.drawing.buffer.isDrawing=!1,d.drawing.buffer.isDrawingTimer=setTimeout(function(){d.drawing.buffer.isSelected||(d.drawing.buffer.isDrawing=!0)},200)}),d.setup.fabric.on("mouse:move",function(a){var b=d.gatherPosition(a.e,2);if(d.isPressed(a.e),d.drawing.buffer.isPressed&&!d.drawing.buffer.isSelected&&(d.drawing.buffer.isDrawing=!0,!d.drawing.buffer.line&&"pencil"!=d.drawing.mode&&(b.xD>5||b.yD>5)&&(d.setup.fabric.isDrawingMode=!1,d.setup.fabric._isCurrentlyDrawing=!1,d.setup.fabric.freeDrawingBrush.onMouseUp(),d.setup.fabric.remove(d.setup.fabric._objects.pop()),d.drawing.buffer.line=d.drawing.handler.line({x1:b.x1,y1:b.y1,x2:b.x2,y2:b.y2,arrow:"line"!=d.drawing.mode&&d.drawing.arrow,action:"config"}))),d.drawing.buffer.isSelected&&(d.setup.fabric.isDrawingMode=!1),d.drawing.buffer.line){var e,f,g,h=d.drawing.buffer.line;for(h.x2=b.x2,h.y2=b.y2,c=0;c<h.group.length;c++)e=h.group[c],e instanceof fabric.Line?e.set({x2:h.x2,y2:h.y2}):e instanceof fabric.Triangle&&(h.angle=d.getAngle(h.x1,h.y1,h.x2,h.y2)+90,"start"==h.arrow?(f=h.y1+h.width/2,g=h.x1+h.width/2):"middle"==h.arrow?(f=h.y2+h.width/2-(h.y2-h.y1)/2,g=h.x2+h.width/2-(h.x2-h.x1)/2):(f=h.y2+h.width/2,g=h.x2+h.width/2),e.set({top:f,left:g,angle:h.angle}));d.setup.fabric.renderAll()}}),d.setup.fabric.on("mouse:up",function(a){if(!d.drawing.buffer.isDrawing){var b=d.setup.fabric.findTarget(a.e);b&&b.selectable&&d.setup.fabric.setActiveObject(b)}if(d.drawing.buffer.line){for(c=0;c<d.drawing.buffer.line.group.length;c++)d.drawing.buffer.line.group[c].remove();delete d.drawing.buffer.line.action,delete d.drawing.buffer.line.group,d.drawing.handler.line(d.drawing.buffer.line)}d.drawing.buffer.line=!1,d.drawing.buffer.hasLine=!1,d.drawing.buffer.isPressed=!1,clearTimeout(d.drawing.buffer.isDrawingTimer),d.drawing.buffer.isDrawing=!1}),d.setup.fabric.on("object:selected",function(a){d.drawing.buffer.isSelected=!0,d.drawing.buffer.target=a.target,d.setup.fabric.isDrawingMode=!1}),d.setup.fabric.on("selection:cleared",function(a){d.drawing.buffer.target=!1,d.drawing.buffer.isSelected&&(d.setup.fabric._isCurrentlyDrawing=!1),d.drawing.buffer.isSelected=!1,d.setup.fabric.isDrawingMode=!0}),d.setup.fabric.on("path:created",function(a){var b=a.path;if(!d.drawing.buffer.isDrawing||d.drawing.buffer.hasLine)return d.setup.fabric.remove(b),void d.setup.fabric.renderAll()}),d.setup.fabric.on("object:added",function(a){var b=a.target,c=d.deepMerge(b.saveState().originalState,{cfg:{color:d.drawing.color,width:d.drawing.width,opacity:d.drawing.opacity,fontSize:d.drawing.fontSize}});c=JSON.stringify(c),b.recentState=c,b.selectable&&!b.known&&(b.isAnnotation=!0,d.drawing.undos.push({action:"added",target:b,state:c}),d.drawing.undos.push({action:"addified",target:b,state:c}),d.drawing.redos=[]),b.known=!0,d.setup.fabric.isDrawingMode=!0}),d.setup.fabric.on("object:modified",function(a){var b=a.target,c=JSON.parse(b.recentState),e=d.deepMerge(b.saveState().originalState,{cfg:c.cfg});e=JSON.stringify(e),b.recentState=e,d.drawing.undos.push({action:"modified",target:b,state:e}),d.drawing.redos=[]}),d.setup.fabric.on("text:changed",function(a){var b=a.target;clearTimeout(b.timer),b.timer=setTimeout(function(){var a=JSON.stringify(b.saveState().originalState);b.recentState=a,d.drawing.redos=[],d.drawing.undos.push({action:"modified",target:b,state:a})},250)}),d.drawing.enabled?(d.setup.wrapper.setAttribute("class",d.setup.chart.classNamePrefix+"-export-canvas active"),d.setup.wrapper.style.backgroundColor=e.backgroundColor,d.setup.wrapper.style.display="block"):(d.setup.wrapper.setAttribute("class",d.setup.chart.classNamePrefix+"-export-canvas"),d.setup.wrapper.style.display="none"),c=0;c<f.length;c++){var k=f[c];"stock"==d.setup.chart.type&&d.setup.chart.legendSettings.position?["top","bottom"].indexOf(d.setup.chart.legendSettings.position)!=-1?k.parent.style.top&&k.parent.style.left?(k.offset.y=d.pxToNumber(k.parent.style.top),k.offset.x=d.pxToNumber(k.parent.style.left)):(k.offset.x=g.x,k.offset.y=g.y,g.y+=d.pxToNumber(k.parent.style.height),k.has.panel?(g.pY=d.pxToNumber(k.has.panel.style.marginTop),k.offset.y+=g.pY):k.has.scrollbar&&(k.offset.y+=g.pY)):["left","right"].indexOf(d.setup.chart.legendSettings.position)!=-1&&(k.offset.y=d.pxToNumber(k.parent.style.top)+g.pY,k.offset.x=d.pxToNumber(k.parent.style.left)+g.pX,k.has.legend?g.pY+=d.pxToNumber(k.has.panel.style.height)+d.setup.chart.panelsSettings.panelSpacing:k.has.scrollbar&&(k.offset.y-=d.setup.chart.panelsSettings.panelSpacing)):("absolute"==k.parent.style.position?(k.offset.absolute=!0,k.offset.top=d.pxToNumber(k.parent.style.top),k.offset.right=d.pxToNumber(k.parent.style.right,!0),k.offset.bottom=d.pxToNumber(k.parent.style.bottom,!0),k.offset.left=d.pxToNumber(k.parent.style.left),k.offset.width=d.pxToNumber(k.parent.style.width),k.offset.height=d.pxToNumber(k.parent.style.height)):k.parent.style.top&&k.parent.style.left?(k.offset.y=d.pxToNumber(k.parent.style.top),k.offset.x=d.pxToNumber(k.parent.style.left)):k.legend?("left"==k.legend.position?g.x=i.maxWidth:"right"==k.legend.position?k.offset.x=g.width-i.maxWidth:"top"==k.legend.position?g.y+=k.legend.height:"bottom"==k.legend.position&&(k.offset.y=g.height-i.height),k.offset.y+=g.lY,g.lY+=k.legend.height):(k.offset.x=g.x,k.offset.y=g.y+g.pY,g.y+=d.pxToNumber(k.parent.style.height)),k.has.legend&&k.has.panel&&k.has.panel.style.marginTop?(g.y+=d.pxToNumber(k.has.panel.style.marginTop),k.offset.y+=d.pxToNumber(k.has.panel.style.marginTop)):d.setup.chart.legend&&["left","right"].indexOf(d.setup.chart.legend.position)!=-1&&(k.offset.y=d.pxToNumber(k.parent.style.top),k.offset.x=d.pxToNumber(k.parent.style.left))),fabric.parseSVGDocument(k.svg,function(a){return function(c,i){var j,l=fabric.util.groupSVGElements(c,i),m=[],n={selectable:!1,isCoreElement:!0};for(a.offset.absolute?(void 0!==a.offset.bottom?n.top=g.height-a.offset.height-a.offset.bottom:n.top=a.offset.top,void 0!==a.offset.right?n.left=g.width-a.offset.width-a.offset.right:n.left=a.offset.left):(n.top=a.offset.y,n.left=a.offset.x),j=0;j<l.paths.length;j++){var o=null;if(l.paths[j]){if(d.removeImage(l.paths[j]["xlink:href"]))continue;if(l.paths[j].fill instanceof Object)"radial"==l.paths[j].fill.type&&["pie","gauge"].indexOf(d.setup.chart.type)==-1&&(l.paths[j].fill.coords.r2=l.paths[j].fill.coords.r1*-1,l.paths[j].fill.coords.r1=0,l.paths[j].set({opacity:l.paths[j].fillOpacity}));else if((o=d.isHashbanged(l.paths[j].fill))&&a.patterns&&a.patterns[o]){var p=a.patterns[o];h.included++,fabric.Image.fromURL(p.source,function(a,b){return function(c){h.loaded++,c.set({top:a.offsetY,left:a.offsetX,width:a.width,height:a.height}),d.setup.fabric._isRetinaScaling()&&c.set({top:a.offsetY/2,left:a.offsetX/2,scaleX:.5,scaleY:.5});var e=new fabric.StaticCanvas(void 0,{backgroundColor:a.fill,width:c.getWidth(),height:c.getHeight()});e.add(c);var f=new fabric.Pattern({source:e.getElement(),offsetX:l.paths[b].width/2,offsetY:l.paths[b].height/2,repeat:"repeat"});l.paths[b].set({fill:f,opacity:l.paths[b].fillOpacity})}}(p,j))}(o=d.isHashbanged(l.paths[j].clipPath))&&a.clippings&&a.clippings[o]&&(!function(b,c){var d=l.paths[b].toSVG;l.paths[b].toSVG=function(b){return d.apply(this,[function(d){return b(d,a.clippings[c])}])}}(j,o),l.paths[j].set({clipTo:function(b,c){return function(b){var e=a.clippings[c],f=this.transformMatrix||[1,0,0,1,0,0],g={top:e.bbox.y,left:e.bbox.x,width:e.bbox.width,height:e.bbox.height};"map"==d.setup.chart.type&&(g.top+=e.transform[5],g.left+=e.transform[4]),e.bbox.x&&f[4]&&e.bbox.y&&f[5]&&(g.top-=f[5],g.left-=f[4]),b.rect(g.left,g.top,g.width,g.height)}}(j,o)}))}m.push(l.paths[j])}if(l.paths=m,n.top+=.5,n.left+=.5,l.set(n),d.setup.fabric.add(l),a.svg.parentNode&&a.svg.parentNode.getElementsByTagName){var q=a.svg.parentNode.getElementsByClassName(d.setup.chart.classNamePrefix+"-balloon-div");for(j=0;j<q.length;j++)if(e.balloonFunction instanceof Function)e.balloonFunction.apply(d,[q[j],a]);else{var r=q[j],s=fabric.parseStyleAttribute(r),t=fabric.parseStyleAttribute(r.childNodes[0]),u=new fabric.Text(r.innerText||r.textContent||r.innerHTML,{selectable:!1,top:s.top+a.offset.y,left:s.left+a.offset.x,fill:t.color,fontSize:t.fontSize,fontFamily:t.fontFamily,textAlign:t["text-align"],isCoreElement:!0});d.setup.fabric.add(u)}}if(a.svg.nextSibling&&"A"==a.svg.nextSibling.tagName){var r=a.svg.nextSibling,s=fabric.parseStyleAttribute(r),u=new fabric.Text(r.innerText||r.textContent||r.innerHTML,{selectable:!1,top:s.top+a.offset.y,left:s.left+a.offset.x,fill:s.color,fontSize:s.fontSize,fontFamily:s.fontFamily,opacity:s.opacity,isCoreElement:!0});a.has.scrollbar||d.setup.fabric.add(u)}if(f.pop(),!f.length)var v=Number(new Date),w=setInterval(function(){var a=Number(new Date);(h.loaded==h.included||a-v>d.config.fabric.loadTimeout)&&(clearTimeout(w),d.handleBorder(e),d.handleCallback(e.afterCapture,e),d.setup.fabric.renderAll(),d.handleCallback(b,e))},AmCharts.updateRate)}}(k),function(a,b){var c,f=d.gatherAttribute(a,"class"),g=d.gatherAttribute(a,"visibility"),h=d.gatherAttribute(a,"clip-path");b.className=String(f),b.classList=String(f).split(" "),b.clipPath=h,b.svg=a;var i=["fill","stroke"];for(c=0;c<i.length;c++){var j=i[c],k=String(a.getAttribute(j)||"none"),l=Number(a.getAttribute(j+"-opacity")||"1"),m=d.getRGBA(k);"hidden"==g&&(b.opacity=0,l=0),m&&(m.pop(),m.push(l),b[j]="rgba("+m.join()+")",b[j+d.capitalize("opacity")]=l)}d.handleCallback(e.reviver,b,a)})}},toCanvas:function(a,b){var c=d.deepMerge({},a||{}),e=d.setup.canvas;return d.handleCallback(b,e,c),e},toImage:function(a,b){var c=d.deepMerge({format:"png",quality:1,multiplier:d.config.multiplier},a||{}),e=c.data,f=document.createElement("img");return!!d.handleNamespace("fabric",{scope:this,cb:d.toImage,args:arguments})&&(c.data||(e=c.lossless||"svg"==c.format?d.toSVG(d.deepMerge(c,{getBase64:!0})):d.setup.fabric.toDataURL(c)),f.setAttribute("src",e),d.handleCallback(b,f,c),f)},toBlob:function(a,b){var e,c=d.deepMerge({
2
- data:"empty",type:"text/plain"},a||{}),f=/^data:.+;base64,(.*)$/.exec(c.data);return f&&(c.data=f[0],c.type=c.data.slice(5,c.data.indexOf(",")-7),c.data=d.toByteArray({data:c.data.slice(c.data.indexOf(",")+1,c.data.length)})),e=c.getByteArray?c.data:new Blob([c.data],{type:c.type}),d.handleCallback(b,e,c),e},toJPG:function(a,b){var c=d.deepMerge({format:"jpeg",quality:1,multiplier:d.config.multiplier},a||{});c.format=c.format.toLowerCase();var e;return!!d.handleNamespace("fabric",{scope:this,cb:d.toJPG,args:arguments})&&(e=d.setup.fabric.toDataURL(c),d.handleCallback(b,e,c),e)},toPNG:function(a,b){var e,c=d.deepMerge({format:"png",quality:1,multiplier:d.config.multiplier},a||{});return!!d.handleNamespace("fabric",{scope:this,cb:d.toPNG,args:arguments})&&(e=d.setup.fabric.toDataURL(c),d.handleCallback(b,e,c),e)},toSVG:function(a,b){var g,c=[],e=[],f=d.deepMerge({compress:d.config.compress,reviver:function(a,b){var f=new RegExp(/\bstyle=(['"])(.*?)\1/),g=f.exec(a)[0].slice(7,-1),h=g.split(";"),i=[];for(i1=0;i1<h.length;i1++)if(h[i1]){var j=h[i1].replace(/\s/g,"").split(":"),k=j[0],l=j[1];if(["fill","stroke"].indexOf(k)!=-1)if(l=d.getRGBA(l,!0)){var m="#"+l.toHex(),n=l._source[3];i.push([k,m].join(":")),i.push([k+"-opacity",n].join(":"))}else i.push(h[i1]);else"opactiy"!=k&&i.push(h[i1])}if(a=a.replace(g,i.join(";")),b&&b.svg){var o=b.svg.id;if(e.indexOf(o)==-1){var p=2,q=a.slice(-p);e.push(b.svg.id),"/>"!=q&&(p=3,q=a.slice(-p));var r=a.slice(0,a.length-p),s=' clip-path="url(#'+b.svg.id+')" ',t=(new XMLSerializer).serializeToString(b.svg);a=r+s+q,c.push(t)}}return a}},a||{});if(!d.handleNamespace("fabric",{scope:this,cb:d.toSVG,args:arguments}))return!1;if(g=d.setup.fabric.toSVG(f,f.reviver),c.length){var h=g.slice(0,g.length-6),i=g.slice(-6);g=h+c.join("")+i}return f.compress&&(g=g.replace(/[\t\r\n]+/g,"")),f.getBase64&&(g="data:image/svg+xml;base64,"+btoa(g)),d.handleCallback(b,g,f),g},toPDF:function(a,b){function f(a){if("number"==typeof a||a instanceof Number)a={left:a,right:a,top:a,bottom:a};else if(a instanceof Array)if(2===a.length)a={left:a[0],top:a[1],right:a[0],bottom:a[1]};else{if(4!==a.length)throw"Invalid pageMargins definition";a={left:a[0],top:a[1],right:a[2],bottom:a[3]}}else a={left:d.defaults.pdfMake.pageMargins,top:d.defaults.pdfMake.pageMargins,right:d.defaults.pdfMake.pageMargins,bottom:d.defaults.pdfMake.pageMargins};return a}function g(a,b){var c=d.defaults.pdfMake.pageSizes[String(a).toUpperCase()].slice();if(!c)throw new Error('The given pageSize "'+a+'" does not exist!');return"landscape"==b&&c.reverse(),c}var e,c=d.deepMerge(d.deepMerge({multiplier:d.config.multiplier||2,pageOrigin:void 0===d.config.pageOrigin},d.config.pdfMake),a||{},!0);if(!d.handleNamespace("pdfMake",{scope:this,cb:d.toPDF,args:arguments}))return!1;if(e=new pdfMake.createPdf(c),c.images.reference=d.toPNG(c),!c.content){var h=[],i=g(c.pageSize,c.pageOrientation),j=f(c.pageMargins);i[0]-=j.left+j.right,i[1]-=j.top+j.bottom,c.pageOrigin&&(h.push(d.i18l("label.saved.from")),h.push(window.location.href),i[1]-=28.128),h.push({image:"reference",fit:i}),c.content=h}return b&&e.getDataUrl(function(a){return function(b){a.apply(d,arguments)}}(b)),e},toPRINT:function(a,b){var c,e=d.deepMerge({delay:.01,lossless:!1},a||{}),f=d.toImage(e),g=[],h=document.body.childNodes,i=document.documentElement.scrollTop||document.body.scrollTop;for(f.setAttribute("style","width: 100%; max-height: 100%;"),c=0;c<h.length;c++)d.isElement(h[c])&&(g[c]=h[c].style.display,h[c].style.display="none");document.body.appendChild(f),window.print(),e.delay*=1e3;var j=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return j&&e.delay<1e3&&(e.delay=1e3),setTimeout(function(){for(c=0;c<h.length;c++)d.isElement(h[c])&&(h[c].style.display=g[c]);document.body.removeChild(f),document.documentElement.scrollTop=document.body.scrollTop=i,d.handleCallback(b,f,e)},e.delay),f},toJSON:function(a,b){var c=d.deepMerge({dateFormat:d.config.dateFormat||"dateObject"},a||{},!0),e={};return!!d.handleNamespace("JSON",{scope:this,cb:d.toJSON,args:arguments})&&(c.data=void 0!==c.data?c.data:d.getChartData(c),e=JSON.stringify(c.data,void 0,"\t"),d.handleCallback(b,e,c),e)},toCSV:function(a,b){var c,f=d.deepMerge({delimiter:",",quotes:!0,escape:!0,withHeader:!0},a||{},!0),g=[],h="";g=d.toArray(f);for(c in g)isNaN(c)||(h+=g[c].join(f.delimiter)+"\n");return d.handleCallback(b,h,f),h},toXLSX:function(a,b){function h(a,b){b&&(a+=1462);var c=Date.parse(a),d=60*a.getTimezoneOffset()*1e3;return(c-d-new Date(Date.UTC(1899,11,30)))/864e5}function i(a,b){for(var c={},d={s:{c:1e7,r:1e7},e:{c:0,r:0}},e=0;e!=a.length;++e)for(var f=0;f!=a[e].length;++f){d.s.r>e&&(d.s.r=e),d.s.c>f&&(d.s.c=f),d.e.r<e&&(d.e.r=e),d.e.c<f&&(d.e.c=f);var g={v:a[e][f]};if(null!=g.v){var i=XLSX.utils.encode_cell({c:f,r:e});"number"==typeof g.v?g.t="n":"boolean"==typeof g.v?g.t="b":g.v instanceof Date?(g.t="n",g.z=XLSX.SSF._table[14],g.v=h(g.v)):g.v instanceof Object?(g.t="s",g.v=JSON.stringify(g.v)):g.t="s",c[i]=g}}return d.s.c<1e7&&(c["!ref"]=XLSX.utils.encode_range(d)),c}var c=d.deepMerge({name:"amCharts",dateFormat:d.config.dateFormat||"dateObject",withHeader:!0,stringify:!1},a||{},!0),e=[],f="",g={SheetNames:[],Sheets:{}};return!!d.handleNamespace("XLSX",{scope:this,cb:d.toXLSX,args:arguments})&&(e=d.toArray(c),g.SheetNames.push(c.name),g.Sheets[c.name]=i(e),f=XLSX.write(g,{bookType:"xlsx",bookSST:!0,type:"base64"}),f="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"+f,d.handleCallback(b,f,c),f)},toArray:function(a,b){function k(a,b){var c=b.exportFields||Object.keys(b.dataFieldsMap);for(e=0;e<c.length;e++){var f=c[e],g=b.dataFieldsTitlesMap[f];h.push(g)}return j?d.handleCallback(j,a,b):a}function l(a){return"string"==typeof a&&(f.escape&&(a=a.replace('"','""')),f.quotes&&(a=['"',a,'"'].join(""))),a}var c,e,f=d.deepMerge({withHeader:!1,stringify:!0,escape:!1,quotes:!1},a||{},!0),g=[],h=[],i=[],j=d.config.processData;if(f.processData=k,f.data=void 0!==f.data?d.processData(f):d.getChartData(f),f.withHeader){i=[];for(e in h)isNaN(e)||i.push(l(h[e]));g.push(i)}for(c in f.data)if(i=[],!isNaN(c)){for(e in h)if(!isNaN(e)){var e=h[e],m=f.data[c][e];m=null==m?"":f.stringify?String(m):m,i.push(l(m))}g.push(i)}return d.handleCallback(b,g,f),g},toByteArray:function(a,b){function l(a){var b=a.charCodeAt(0);return b===f?62:b===g?63:b<h?-1:b<h+10?b-h+26+26:b<j+26?b-j:b<i+26?b-i+26:void 0}function m(a){function k(a){h[j++]=a}var b,c,d,f,g,h;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=a.length;g="="===a.charAt(i-2)?2:"="===a.charAt(i-1)?1:0,h=new e(3*a.length/4-g),d=g>0?a.length-4:a.length;var j=0;for(b=0,c=0;b<d;b+=4,c+=3)f=l(a.charAt(b))<<18|l(a.charAt(b+1))<<12|l(a.charAt(b+2))<<6|l(a.charAt(b+3)),k((16711680&f)>>16),k((65280&f)>>8),k(255&f);return 2===g?(f=l(a.charAt(b))<<2|l(a.charAt(b+1))>>4,k(255&f)):1===g&&(f=l(a.charAt(b))<<10|l(a.charAt(b+1))<<4|l(a.charAt(b+2))>>2,k(f>>8&255),k(255&f)),h}var c=d.deepMerge({},a||{}),e="undefined"!=typeof Uint8Array?Uint8Array:Array,f="+".charCodeAt(0),g="/".charCodeAt(0),h="0".charCodeAt(0),i="a".charCodeAt(0),j="A".charCodeAt(0),k=m(c.data);return d.handleCallback(b,k,c),k},handleCallback:function(a){var b,c=Array();if(a&&a instanceof Function){for(b=0;b<arguments.length;b++)b>0&&c.push(arguments[b]);return a.apply(d,c)}},handleLog:function(a){d.config.debug===!0&&console.log(a)},handleNamespace:function(a,b){function h(){var i=Number(new Date);e=!!(a in c),"pdfMake"==a&&e&&(e=c.pdfMake.vfs),e?(clearTimeout(g),b.cb.apply(b.scope,b.args),d.handleLog(['AmCharts [export]: Namespace "',a,'" showed up in: ',String(c)].join(""))):i-f<d.libs.loadTimeout?g=setTimeout(h,250):d.handleLog(['AmCharts [export]: Gave up waiting for "',a,'" in: ',String(c)].join(""))}var g,c=d.config.scope||window,e=!1,f=Number(new Date);return e=!!(a in c),e||(d.handleLog(['AmCharts [export]: Could not find "',a,'" in: ',String(c)].join("")),h()),e},handleBorder:function(a){if(d.config.border instanceof Object){var b=d.deepMerge(d.defaults.fabric.border,a.border||{},!0),c=new fabric.Rect;b.width=d.setup.fabric.width-b.strokeWidth,b.height=d.setup.fabric.height-b.strokeWidth,c.set(b),d.setup.fabric.add(c)}},handleDropbox:function(a){if(d.drawing.enabled)if(a.preventDefault(),a.stopPropagation(),"dragover"==a.type)d.setup.wrapper.setAttribute("class",d.setup.chart.classNamePrefix+"-export-canvas active dropbox");else if(d.setup.wrapper.setAttribute("class",d.setup.chart.classNamePrefix+"-export-canvas active"),"drop"==a.type&&a.dataTransfer.files.length)for(var b=0;b<a.dataTransfer.files.length;b++){var c=new FileReader;c.onloadend=function(b){return function(){d.drawing.handler.add({url:c.result,top:a.layerY-10*b,left:a.layerX-10*b})}}(b),c.readAsDataURL(a.dataTransfer.files[b])}},handleReady:function(a){var d=this,e=Number(new Date);d.handleCallback(a,"data",!1);for(filename in d.libs.namespaces){var f=d.libs.namespaces[filename];!function(b){var c=setInterval(function(){var f=Number(new Date);(f-e>d.libs.loadTimeout||b in window)&&(clearTimeout(c),d.handleCallback(a,b,f-e>d.libs.loadTimeout))},AmCharts.updateRate)}(f)}},getChartData:function(a){function j(a,e,f){function g(a,c){return b.dataFields.indexOf(a)!=-1?g([a,".",c].join("")):a}a&&b.exportTitles&&"gantt"!=d.setup.chart.type&&(c=g(a,f),b.dataFieldsMap[c]=a,b.dataFields.push(c),b.titles[c]=e||c)}var c,e,f,g,i,b=d.deepMerge({data:[],titles:{},dateFields:[],dataFields:[],dataFieldsMap:{},exportTitles:d.config.exportTitles,exportFields:d.config.exportFields,exportSelection:d.config.exportSelection,columnNames:d.config.columnNames},a||{},!0),h=["valueField","openField","closeField","highField","lowField","xField","yField"];if(0==b.data.length)if("stock"==d.setup.chart.type){for(b.data=d.cloneObject(d.setup.chart.mainDataSet.dataProvider),j(d.setup.chart.mainDataSet.categoryField),b.dateFields.push(d.setup.chart.mainDataSet.categoryField),e=0;e<d.setup.chart.mainDataSet.fieldMappings.length;e++){var k=d.setup.chart.mainDataSet.fieldMappings[e];for(f=0;f<d.setup.chart.panels.length;f++){var l=d.setup.chart.panels[f];for(g=0;g<l.stockGraphs.length;g++){var m=l.stockGraphs[g];for(i4=0;i4<h.length;i4++)m[h[i4]]==k.toField&&j(k.fromField,m.title,h[i4])}}}if(d.setup.chart.comparedGraphs.length){for(i=[],e=0;e<b.data.length;e++)i.push(b.data[e][d.setup.chart.mainDataSet.categoryField]);for(e=0;e<d.setup.chart.comparedGraphs.length;e++){var m=d.setup.chart.comparedGraphs[e];for(f=0;f<m.dataSet.dataProvider.length;f++){var n=m.dataSet.categoryField,o=m.dataSet.dataProvider[f][n],p=i.indexOf(o);if(p!=-1)for(g=0;g<m.dataSet.fieldMappings.length;g++){var k=m.dataSet.fieldMappings[g],c=m.dataSet.id+"_"+k.toField;b.data[p][c]=m.dataSet.dataProvider[f][k.fromField],b.titles[c]||j(c,m.dataSet.title)}}}}}else if("gantt"==d.setup.chart.type){j(d.setup.chart.categoryField),b.dateFields.push(d.setup.chart.categoryField);var q=d.setup.chart.segmentsField;for(e=0;e<d.setup.chart.dataProvider.length;e++){var r=d.setup.chart.dataProvider[e];if(r[q])for(f=0;f<r[q].length;f++)r[q][f][d.setup.chart.categoryField]=r[d.setup.chart.categoryField],b.data.push(r[q][f])}for(e=0;e<d.setup.chart.graphs.length;e++){var m=d.setup.chart.graphs[e];for(f=0;f<h.length;f++){var s=h[f],t=m[s];m.title;j(t,m.title,s)}}}else if(["pie","funnel"].indexOf(d.setup.chart.type)!=-1)b.data=d.setup.chart.dataProvider,j(d.setup.chart.titleField),b.dateFields.push(d.setup.chart.titleField),j(d.setup.chart.valueField);else if("map"!=d.setup.chart.type)for(b.data=d.setup.chart.dataProvider,d.setup.chart.categoryAxis&&(j(d.setup.chart.categoryField,d.setup.chart.categoryAxis.title),d.setup.chart.categoryAxis.parseDates!==!1&&b.dateFields.push(d.setup.chart.categoryField)),e=0;e<d.setup.chart.graphs.length;e++){var m=d.setup.chart.graphs[e];for(f=0;f<h.length;f++){var s=h[f],t=m[s];j(t,m.title,s)}}return d.processData(b)},getAnnotations:function(a,b){var e,c=d.deepMerge({},a||{},!0),f=[];for(e=0;e<d.setup.fabric._objects.length;e++)if(!d.setup.fabric._objects[e].isCoreElement){var g=d.setup.fabric._objects[e].toJSON();d.handleCallback(c.reviver,g,e),f.push(g)}return d.handleCallback(b,f),f},setAnnotations:function(a,b){var c=d.deepMerge({data:[]},a||{},!0);return fabric.util.enlivenObjects(c.data,function(a){a.forEach(function(a,b){d.handleCallback(c.reviver,a,b),d.setup.fabric.add(a)}),d.handleCallback(b,c)}),c.data},processData:function(b){var e,f,c=d.deepMerge({data:[],titles:{},dateFields:[],dataFields:[],dataFieldsMap:{},dataFieldsTitlesMap:{},dataDateFormat:d.setup.chart.dataDateFormat,dateFormat:d.config.dateFormat||d.setup.chart.dataDateFormat||"YYYY-MM-DD",exportTitles:d.config.exportTitles,exportFields:d.config.exportFields,exportSelection:d.config.exportSelection,columnNames:d.config.columnNames,processData:d.config.processData},b||{},!0);if(c.data.length){for(e=0;e<c.data.length;e++)for(f in c.data[e])c.dataFields.indexOf(f)==-1&&(c.dataFields.push(f),c.dataFieldsMap[f]=f);void 0!==c.exportFields&&(c.dataFields=c.exportFields.filter(function(a){return c.dataFields.indexOf(a)!=-1}));var g=[];for(e=0;e<c.data.length;e++){var h={},i=!1;for(f=0;f<c.dataFields.length;f++){var j=c.dataFields[f],k=c.dataFieldsMap[j],l=c.columnNames&&c.columnNames[j]||c.titles[j]||j,m=c.data[e][k];null==m&&(m=void 0),c.exportTitles&&"gantt"!=d.setup.chart.type&&l in h&&(l+=["( ",j," )"].join("")),c.dateFields.indexOf(k)!=-1&&(c.dataDateFormat&&(m instanceof String||"string"==typeof m)?m=AmCharts.stringToDate(m,c.dataDateFormat):c.dateFormat&&(m instanceof Number||"number"==typeof m)&&(m=new Date(m)),c.exportSelection&&(m instanceof Date?(m<a.startDate||m>a.endDate)&&(i=!0):(e<a.startIndex||e>a.endIndex)&&(i=!0)),c.dateFormat&&"dateObject"!=c.dateFormat&&m instanceof Date&&(m=AmCharts.formatDate(m,c.dateFormat))),c.dataFieldsTitlesMap[k]=l,h[l]=m}i||g.push(h)}c.data=g}return void 0!==c.processData&&(c.data=d.handleCallback(c.processData,c.data,c)),c.data},capitalize:function(a){return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()},createMenu:function(b,c){function g(b,c){var e,h,i=document.createElement("ul");for(e=0;e<b.length;e++){var j="string"==typeof b[e]?{format:b[e]}:b[e],k=document.createElement("li"),l=document.createElement("a"),m=document.createElement("img"),n=document.createElement("span"),o=String(j.action?j.action:j.format).toLowerCase();if(j.format=String(j.format).toUpperCase(),d.config.formats[j.format]?j=d.deepMerge({label:j.icon?"":j.format,format:j.format,mimeType:d.config.formats[j.format].mimeType,extension:d.config.formats[j.format].extension,capture:d.config.formats[j.format].capture,action:d.config.action,fileName:d.config.fileName},j):j.label||(j.label=j.label?j.label:d.i18l("menu.label."+o)),(["CSV","JSON","XLSX"].indexOf(j.format)==-1||["map","gauge"].indexOf(d.setup.chart.type)==-1)&&(d.setup.hasBlob||"UNDEFINED"==j.format||!j.mimeType||"image"==j.mimeType.split("/")[0]||"text/plain"==j.mimeType)){if("draw"==j.action)d.config.fabric.drawing.enabled?(j.menu=j.menu?j.menu:d.config.fabric.drawing.menu,j.click=function(a){return function(){this.capture(a,function(){this.createMenu(a.menu)})}}(j)):j.menu=[];else if(!j.populated&&j.action&&j.action.indexOf("draw.")!=-1){var p=j.action.split(".")[1],q=j[p]||d.config.fabric.drawing[p]||[];for(j.menu=[],j.populated=!0,h=0;h<q.length;h++){var r={label:q[h]};if("shapes"==p){var s=q[h].indexOf("//")==-1,t=(s?d.config.path+"shapes/":"")+q[h];r.action="add",r.url=t,r.icon=t,r.ignore=s,r.class="export-drawing-shape"}else"colors"==p?(r.style="background-color: "+q[h],r.action="change",r.color=q[h],r.class="export-drawing-color"):"widths"==p?(r.action="change",r.width=q[h],r.label=document.createElement("span"),r.label.style.width=d.numberToPx(q[h]),r.label.style.height=d.numberToPx(q[h]),r.class="export-drawing-width"):"opacities"==p?(r.style="opacity: "+q[h],r.action="change",r.opacity=q[h],r.label=100*q[h]+"%",r.class="export-drawing-opacity"):"modes"==p&&(r.label=d.i18l("menu.label.draw.modes."+q[h]),r.click=function(a){return function(){d.drawing.mode=a}}(q[h]),r.class="export-drawing-mode");j.menu.push(r)}}else j.click||j.menu||j.items||(d.drawing.handler[o]instanceof Function?(j.action=o,j.click=function(a){return function(){this.drawing.handler[a.action](a)}}(j)):d.drawing.enabled?j.click=function(a){return function(){this.config.drawing.autoClose&&this.drawing.handler.done(),this["to"+a.format](a,function(b){"download"==a.action&&this.download(b,a.mimeType,[a.fileName,a.extension].join("."))})}}(j):"UNDEFINED"!=j.format&&(j.click=function(a){return function(){if(a.capture||"print"==a.action||"PRINT"==a.format)this.capture(a,function(){this.drawing.handler.done(),this["to"+a.format](a,function(b){"download"==a.action&&this.download(b,a.mimeType,[a.fileName,a.extension].join("."))})});else{if(!this["to"+a.format])throw new Error("Invalid format. Could not determine output type.");this["to"+a.format](a,function(b){this.download(b,a.mimeType,[a.fileName,a.extension].join("."))})}}}(j)));(void 0===j.menu||j.menu.length)&&(l.setAttribute("href","#"),l.addEventListener("click",function(a,b){return function(c){c.preventDefault();var e=[c,b];return!("draw"==b.action||"PRINT"==b.format||"UNDEFINED"!=b.format&&b.capture)||d.drawing.enabled||isNaN(b.delay)&&isNaN(d.config.delay)?void a.apply(d,e):(b.delay=isNaN(b.delay)?d.config.delay:b.delay,void d.delay(b,a))}}(j.click||function(a){a.preventDefault()},j)),d.setup.hasTouch&&k.classList&&l.addEventListener("click",function(a){return function(b){function j(a){var b=a.parentNode.parentNode,c=b.classList;return!("LI"!=b.tagName||!c.contains("active"))}function k(a){var b=a.parentNode.children;for(e=0;e<b.length;e++){var c=b[e],d=c.classList;if(c!==a&&d.contains("active"))return d.remove("active"),!0}return!1}function l(a){return a.getElementsByTagName("ul").length>0}function m(a){return a.classList.contains("export-main")||a.classList.contains("export-drawing")}b.preventDefault();var c=a.elements.li,g=j(c),i=(k(c),l(c));if(!m(c)&&i||d.setup.menu.classList.toggle("active"),!g||!i)for(;f.length;){var n=f.pop(),o=m(n),p=n!==c;o?i||n.classList.remove("active"):p&&n.classList.remove("active")}f.push(c),i&&c.classList.toggle("active")}}(j)),k.appendChild(l),d.isElement(j.label)?n.appendChild(j.label):n.innerHTML=j.label,j.class&&(k.className=j.class),j.style&&k.setAttribute("style",j.style),j.icon&&(m.setAttribute("src",(j.ignore||j.icon.slice(0,10).indexOf("//")!=-1?"":a.pathToImages)+j.icon),l.appendChild(m)),j.label&&l.appendChild(n),j.title&&l.setAttribute("title",j.title),d.config.menuReviver&&(k=d.config.menuReviver.apply(d,[j,k])),j.elements={li:k,a:l,img:m,span:n},(j.menu||j.items)&&"draw"!=j.action?g(j.menu||j.items,k).childNodes.length&&i.appendChild(k):i.appendChild(k))}}return i.childNodes.length&&c.appendChild(i),i}var f=[];return c||("string"==typeof d.config.divId?d.config.divId=c=document.getElementById(d.config.divId):c=d.isElement(d.config.divId)?d.config.divId:d.setup.chart.containerDiv),d.isElement(d.setup.menu)?d.setup.menu.innerHTML="":d.setup.menu=document.createElement("div"),d.setup.menu.setAttribute("class",d.setup.chart.classNamePrefix+"-export-menu "+d.setup.chart.classNamePrefix+"-export-menu-"+d.config.position+" amExportButton"),d.config.menuWalker&&(g=d.config.menuWalker),g.apply(this,[b,d.setup.menu]),d.setup.menu.childNodes.length&&c.appendChild(d.setup.menu),d.setup.menu},delay:function(a,b){var e,f,c=d.deepMerge({delay:3,precision:2},a||{}),g=Number(new Date),h=d.createMenu([{label:d.i18l("capturing.delayed.menu.label").replace("{{duration}}",AmCharts.toFixed(c.delay,c.precision)),title:d.i18l("capturing.delayed.menu.title"),class:"export-delayed-capturing",click:function(){clearTimeout(e),clearTimeout(f),d.createMenu(d.config.menu)}}]),i=h.getElementsByTagName("a")[0];e=setInterval(function(){var a=c.delay-(Number(new Date)-g)/1e3;a<=0?(clearTimeout(e),"draw"!=c.action&&d.createMenu(d.config.menu)):i&&(i.innerHTML=d.i18l("capturing.delayed.menu.label").replace("{{duration}}",AmCharts.toFixed(a,2)))},AmCharts.updateRate),f=setTimeout(function(){b.apply(d,arguments)},1e3*c.delay)},migrateSetup:function(a){function c(a){var d;for(d in a){var e=a[d];"export"==d.slice(0,6)&&e?b.menu.push(d.slice(6)):"userCFG"==d?c(e):"menuItems"==d?b.menu=e:"libs"==d?b.libs=e:"string"==typeof d&&(b[d]=e)}}var b={enabled:!0,migrated:!0,libs:{autoLoad:!0},menu:[]};return c(a),b},clear:function(){d.setup=void 0,d.docListener&&document.removeEventListener("keydown",d.docListener);var a=d.listenersToRemove;if(a)for(var b=0;b<a.length;b++){var c=a[b];c.node.removeEventListener(c.event,c.method)}d.listenersToRemove=[]},loadListeners:function(){function a(a){a&&(a.set({top:a.top+10,left:a.left+10}),d.setup.fabric.add(a))}d.config.keyListener&&"attached"!=d.config.keyListener&&(d.docListener=function(b){var c=d.drawing.buffer.target;8!=b.keyCode&&46!=b.keyCode||!c?27==b.keyCode&&d.drawing.enabled?(b.preventDefault(),d.drawing.buffer.isSelected?d.setup.fabric.discardActiveObject():d.drawing.handler.done()):67==b.keyCode&&(b.metaKey||b.ctrlKey)&&c?d.drawing.buffer.copy=c:88==b.keyCode&&(b.metaKey||b.ctrlKey)&&c?(d.drawing.buffer.copy=c,d.setup.fabric.remove(c)):86==b.keyCode&&(b.metaKey||b.ctrlKey)?d.drawing.buffer.copy&&a(d.drawing.buffer.copy.clone(a)):90==b.keyCode&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),b.shiftKey?d.drawing.handler.redo():d.drawing.handler.undo()):(b.preventDefault(),d.setup.fabric.remove(c))},d.config.keyListener="attached",document.addEventListener("keydown",d.docListener)),d.config.fileListener&&(d.setup.chart.containerDiv.addEventListener("dragover",d.handleDropbox),d.setup.chart.containerDiv.addEventListener("dragleave",d.handleDropbox),d.setup.chart.containerDiv.addEventListener("drop",d.handleDropbox))},init:function(){clearTimeout(c),c=setInterval(function(){d.setup.chart.containerDiv&&(clearTimeout(c),d.config.enabled&&(d.setup.chart.AmExport=d,d.config.overflow&&(d.setup.chart.div.style.overflow="visible"),d.loadListeners(),d.createMenu(d.config.menu),d.handleReady(d.config.onReady)))},AmCharts.updateRate)},construct:function(){d.drawing.handler.cancel=d.drawing.handler.done;try{d.setup.hasBlob=!!new Blob}catch(a){}window.safari=window.safari?window.safari:{},d.defaults.fabric.drawing.fontSize=d.setup.chart.fontSize||11,d.config.drawing=d.deepMerge(d.defaults.fabric.drawing,d.config.drawing||{},!0),d.config.border&&(d.config.border=d.deepMerge(d.defaults.fabric.border,d.config.border||{},!0)),d.deepMerge(d.defaults.fabric,d.config,!0),d.deepMerge(d.defaults.fabric,d.config.fabric||{},!0),d.deepMerge(d.defaults.pdfMake,d.config,!0),d.deepMerge(d.defaults.pdfMake,d.config.pdfMake||{},!0),d.deepMerge(d.libs,d.config.libs||{},!0),d.config.drawing=d.defaults.fabric.drawing,d.config.fabric=d.defaults.fabric,d.config.pdfMake=d.defaults.pdfMake,d.config=d.deepMerge(d.defaults,d.config,!0),d.config.fabric.drawing.enabled&&void 0===d.config.fabric.drawing.menu&&(d.config.fabric.drawing.menu=[],d.deepMerge(d.config.fabric.drawing.menu,[{class:"export-drawing",menu:[{label:d.i18l("menu.label.draw.add"),menu:[{label:d.i18l("menu.label.draw.shapes"),action:"draw.shapes"},{label:d.i18l("menu.label.draw.text"),action:"text"}]},{label:d.i18l("menu.label.draw.change"),menu:[{label:d.i18l("menu.label.draw.modes"),action:"draw.modes"},{label:d.i18l("menu.label.draw.colors"),action:"draw.colors"},{label:d.i18l("menu.label.draw.widths"),action:"draw.widths"},{label:d.i18l("menu.label.draw.opacities"),action:"draw.opacities"},"UNDO","REDO"]},{label:d.i18l("menu.label.save.image"),menu:["PNG","JPG","SVG","PDF"]},"PRINT","CANCEL"]}])),void 0===d.config.menu&&(d.config.menu=[],d.deepMerge(d.config,{menu:[{class:"export-main",menu:[{label:d.i18l("menu.label.save.image"),menu:["PNG","JPG","SVG","PDF"]},{label:d.i18l("menu.label.save.data"),menu:["CSV","XLSX","JSON"]},{label:d.i18l("menu.label.draw"),action:"draw",menu:d.config.fabric.drawing.menu},{format:"PRINT",label:d.i18l("menu.label.print")}]}]})),d.libs.path||(d.libs.path=d.config.path+"libs/"),d.isSupported()&&(d.loadDependencies(d.libs.resources,d.libs.reload),d.setup.chart.addClassNames=!0,d.setup.chart[d.name]=d,d.init())}};if(b)d.config=b;else if(d.setup.chart[d.name])d.config=d.setup.chart[d.name];else{if(!d.setup.chart.amExport&&!d.setup.chart.exportConfig)return;d.config=d.migrateSetup(d.setup.chart.amExport||d.setup.chart.exportConfig)}return d.construct(),d.deepMerge(this,d)}}(),AmCharts.addInitHandler(function(a){new AmCharts.export(a)},["pie","serial","xy","funnel","radar","gauge","stock","map","gantt"]);
1
+ AmCharts.translations.export||(AmCharts.translations.export={}),AmCharts.translations.export.en||(AmCharts.translations.export.en={"fallback.save.text":"CTRL + C to copy the data into the clipboard.","fallback.save.image":"Rightclick -> Save picture as... to save the image.","capturing.delayed.menu.label":"{{duration}}","capturing.delayed.menu.title":"Click to cancel","menu.label.print":"Print","menu.label.undo":"Undo","menu.label.redo":"Redo","menu.label.cancel":"Cancel","menu.label.save.image":"Download as ...","menu.label.save.data":"Save as ...","menu.label.draw":"Annotate ...","menu.label.draw.change":"Change ...","menu.label.draw.add":"Add ...","menu.label.draw.shapes":"Shape ...","menu.label.draw.colors":"Color ...","menu.label.draw.widths":"Size ...","menu.label.draw.opacities":"Opacity ...","menu.label.draw.text":"Text","menu.label.draw.modes":"Mode ...","menu.label.draw.modes.pencil":"Pencil","menu.label.draw.modes.line":"Line","menu.label.draw.modes.arrow":"Arrow","label.saved.from":"Saved from: "}),AmCharts.export=function(e,t){var a,i={name:"export",version:"1.4.74",libs:{async:!0,autoLoad:!0,reload:!1,resources:["fabric.js/fabric.min.js","FileSaver.js/FileSaver.min.js",{"jszip/jszip.min.js":["xlsx/xlsx.min.js"],"pdfmake/pdfmake.min.js":["pdfmake/vfs_fonts.js"]}],namespaces:{"pdfmake.min.js":"pdfMake","jszip.min.js":"JSZip","xlsx.min.js":"XLSX","fabric.min.js":"fabric","FileSaver.min.js":"saveAs"},loadTimeout:1e4,unsupportedIE9libs:["pdfmake.min.js","jszip.min.js","xlsx.min.js"]},config:{},setup:{chart:e,hasBlob:!1,wrapper:!1,isIE:!!window.document.documentMode,IEversion:window.document.documentMode,hasTouch:"object"==typeof window.Touch,focusedMenuItem:void 0,hasClasslist:"classList"in document.createElement("_")},drawing:{enabled:!1,undos:[],redos:[],buffer:{position:{x1:0,y1:0,x2:0,y2:0,xD:0,yD:0}},handler:{undo:function(e,t){var a=i.drawing.undos.pop();if(a){a.selectable=!0,i.drawing.redos.push(a),"added"==a.action&&i.setup.fabric.remove(a.target);var r=JSON.parse(a.state);a.target.set(r),a.target instanceof fabric.Group&&i.drawing.handler.change({color:r.cfg.color,width:r.cfg.width,opacity:r.cfg.opacity},!0,a.target),i.setup.fabric.renderAll()}},redo:function(e,t){var a=i.drawing.redos.pop();if(a){a.selectable=!0,i.drawing.undos.push(a),"added"==a.action&&i.setup.fabric.add(a.target);var r=JSON.parse(a.state);a.target.recentState=a.state,a.target.set(r),a.target instanceof fabric.Group&&i.drawing.handler.change({color:r.cfg.color,width:r.cfg.width,opacity:r.cfg.opacity},!0,a.target),i.setup.fabric.renderAll()}},done:function(e){i.drawing.enabled=!1,i.drawing.buffer.enabled=!1,i.drawing.undos=[],i.drawing.redos=[],i.createMenu(i.config.menu),i.setup.fabric.deactivateAll(),i.isElement(i.setup.wrapper)&&i.isElement(i.setup.wrapper.parentNode)&&i.setup.wrapper.parentNode.removeChild&&(i.setup.wrapper.parentNode.removeChild(i.setup.wrapper),i.setup.wrapper=!1)},add:function(e){var t=i.deepMerge({top:i.setup.fabric.height/2,left:i.setup.fabric.width/2},e||{});(-1!=t.url.indexOf(".svg")?fabric.loadSVGFromURL:fabric.Image.fromURL)(t.url,function(e,a){var r=void 0!==a?fabric.util.groupSVGElements(e,a):e,n=!1;(r.height>i.setup.fabric.height||r.width>i.setup.fabric.width)&&(n=i.setup.fabric.height/2/r.height),t.top>i.setup.fabric.height&&(t.top=i.setup.fabric.height/2),t.left>i.setup.fabric.width&&(t.left=i.setup.fabric.width/2),i.drawing.buffer.isDrawing=!0,r.set({originX:"center",originY:"center",top:t.top,left:t.left,width:n?r.width*n:r.width,height:n?r.height*n:r.height,fill:i.drawing.color}),i.setup.fabric.add(r)})},change:function(e,t,a){var r,n,o,s=i.deepMerge({},e||{}),l=a||i.drawing.buffer.target,d=l?l._objects?l._objects:[l]:null;if(s.mode&&(i.drawing.mode=s.mode),s.width&&(i.drawing.width=s.width,i.drawing.fontSize=s.fontSize=3*s.width,1==i.drawing.width&&(i.drawing.fontSize=s.fontSize=i.defaults.fabric.drawing.fontSize)),s.fontSize&&(i.drawing.fontSize=s.fontSize),s.color&&(i.drawing.color=s.color),s.opacity&&(i.drawing.opacity=s.opacity),(o=i.getRGBA(i.drawing.color)).pop(),o.push(i.drawing.opacity),i.drawing.color="rgba("+o.join()+")",i.setup.fabric.freeDrawingBrush.color=i.drawing.color,i.setup.fabric.freeDrawingBrush.width=i.drawing.width,l){for((r=JSON.parse(l.recentState).cfg)&&(s.color=s.color||r.color,s.width=s.width||r.width,s.opacity=s.opacity||r.opacity,s.fontSize=s.fontSize||r.fontSize,(o=i.getRGBA(s.color)).pop(),o.push(s.opacity),s.color="rgba("+o.join()+")"),n=0;n<d.length;n++)d[n]instanceof fabric.Text||d[n]instanceof fabric.PathGroup||d[n]instanceof fabric.Triangle?((s.color||s.opacity)&&d[n].set({fill:s.color}),s.fontSize&&d[n].set({fontSize:s.fontSize})):(d[n]instanceof fabric.Path||d[n]instanceof fabric.Line)&&(l instanceof fabric.Group?(s.color||s.opacity)&&d[n].set({stroke:s.color}):((s.color||s.opacity)&&d[n].set({stroke:s.color}),s.width&&d[n].set({strokeWidth:s.width})));t||(r=JSON.stringify(i.deepMerge(l.saveState()._stateProperties,{cfg:{color:s.color,width:s.width,opacity:s.opacity}})),l.recentState=r,i.drawing.redos=[],i.drawing.undos.push({action:"modified",target:l,state:r})),i.setup.fabric.renderAll()}},text:function(e){var t=i.deepMerge({text:i.i18l("menu.label.draw.text"),top:i.setup.fabric.height/2,left:i.setup.fabric.width/2,fontSize:i.drawing.fontSize,fontFamily:i.setup.chart.fontFamily||"Verdana",fill:i.drawing.color},e||{});t.click=function(){};var a=new fabric.IText(t.text,t);return i.drawing.buffer.isDrawing=!0,i.setup.fabric.add(a),i.setup.fabric.setActiveObject(a),a.selectAll(),a.enterEditing(),a},line:function(e){var t,a,r,n,o=i.deepMerge({x1:i.setup.fabric.width/2-i.setup.fabric.width/10,x2:i.setup.fabric.width/2+i.setup.fabric.width/10,y1:i.setup.fabric.height/2,y2:i.setup.fabric.height/2,angle:90,strokeLineCap:i.drawing.lineCap,arrow:i.drawing.arrow,color:i.drawing.color,width:i.drawing.width,group:[]},e||{}),s=new fabric.Line([o.x1,o.y1,o.x2,o.y2],{stroke:o.color,strokeWidth:o.width,strokeLineCap:o.strokeLineCap});if(o.group.push(s),o.arrow&&(o.angle=o.angle?o.angle:i.getAngle(o.x1,o.y1,o.x2,o.y2),"start"==o.arrow?(r=o.y1+o.width/2,n=o.x1+o.width/2):"middle"==o.arrow?(r=o.y2+o.width/2-(o.y2-o.y1)/2,n=o.x2+o.width/2-(o.x2-o.x1)/2):(r=o.y2+o.width/2,n=o.x2+o.width/2),a=new fabric.Triangle({top:r,left:n,fill:o.color,height:7*o.width,width:7*o.width,angle:o.angle,originX:"center",originY:"bottom"}),o.group.push(a)),i.drawing.buffer.isDrawing=!0,"config"!=o.action){if(o.arrow){var l=new fabric.Group(o.group);return l.set({cfg:o,fill:o.color,action:o.action,selectable:!0,known:"change"==o.action}),"change"==o.action&&i.setup.fabric.setActiveObject(l),i.setup.fabric.add(l),l}return i.setup.fabric.add(s),s}for(t=0;t<o.group.length;t++)o.group[t].ignoreUndo=!0,i.setup.fabric.add(o.group[t]);return o}}},defaults:{position:"top-right",fileName:"amCharts",action:"download",overflow:!0,path:(e.path||"")+"plugins/export/",formats:{JPG:{mimeType:"image/jpg",extension:"jpg",capture:!0},PNG:{mimeType:"image/png",extension:"png",capture:!0},SVG:{mimeType:"text/xml",extension:"svg",capture:!0},PDF:{mimeType:"application/pdf",extension:"pdf",capture:!0},CSV:{mimeType:"text/plain",extension:"csv"},JSON:{mimeType:"text/plain",extension:"json"},XLSX:{mimeType:"application/octet-stream",extension:"xlsx"}},fabric:{backgroundColor:"#FFFFFF",removeImages:!0,forceRemoveImages:!1,selection:!1,loadTimeout:5e3,drawing:{enabled:!0,arrow:"end",lineCap:"butt",mode:"pencil",modes:["pencil","line","arrow"],color:"#000000",colors:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF"],shapes:["11.svg","14.svg","16.svg","17.svg","20.svg","27.svg"],width:1,fontSize:11,widths:[1,5,10,15],opacity:1,opacities:[1,.8,.6,.4,.2],menu:void 0,autoClose:!0},border:{fill:"",fillOpacity:0,stroke:"#000000",strokeWidth:1,strokeOpacity:1}},pdfMake:{images:{},pageOrientation:"portrait",pageMargins:40,pageOrigin:!0,pageSize:"A4",pageSizes:{"4A0":[4767.87,6740.79],"2A0":[3370.39,4767.87],A0:[2383.94,3370.39],A1:[1683.78,2383.94],A2:[1190.55,1683.78],A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],A6:[297.64,419.53],A7:[209.76,297.64],A8:[147.4,209.76],A9:[104.88,147.4],A10:[73.7,104.88],B0:[2834.65,4008.19],B1:[2004.09,2834.65],B2:[1417.32,2004.09],B3:[1000.63,1417.32],B4:[708.66,1000.63],B5:[498.9,708.66],B6:[354.33,498.9],B7:[249.45,354.33],B8:[175.75,249.45],B9:[124.72,175.75],B10:[87.87,124.72],C0:[2599.37,3676.54],C1:[1836.85,2599.37],C2:[1298.27,1836.85],C3:[918.43,1298.27],C4:[649.13,918.43],C5:[459.21,649.13],C6:[323.15,459.21],C7:[229.61,323.15],C8:[161.57,229.61],C9:[113.39,161.57],C10:[79.37,113.39],RA0:[2437.8,3458.27],RA1:[1729.13,2437.8],RA2:[1218.9,1729.13],RA3:[864.57,1218.9],RA4:[609.45,864.57],SRA0:[2551.18,3628.35],SRA1:[1814.17,2551.18],SRA2:[1275.59,1814.17],SRA3:[907.09,1275.59],SRA4:[637.8,907.09],EXECUTIVE:[521.86,756],FOLIO:[612,936],LEGAL:[612,1008],LETTER:[612,792],TABLOID:[792,1224]}},menu:void 0,divId:null,menuReviver:null,menuWalker:null,fallback:!0,keyListener:!0,fileListener:!0,compress:!0,debug:!1},listenersToRemove:[],i18l:function(e,t){var a=t||(i.setup.chart.language?i.setup.chart.language:"en");return(AmCharts.translations[i.name][a]||AmCharts.translations[i.name].en)[e]||e},download:function(e,t,a){if(window.saveAs&&i.setup.hasBlob)i.toBlob({data:e,type:t},function(e){saveAs(e,a)});else if(i.config.fallback&&"text/plain"==t){var r=document.createElement("div"),n=document.createElement("div"),o=document.createElement("textarea");n.innerHTML=i.i18l("fallback.save.text"),r.appendChild(n),r.appendChild(o),n.setAttribute("class","amcharts-export-fallback-message"),r.setAttribute("class","amcharts-export-fallback"),i.setup.chart.containerDiv.appendChild(r),o.setAttribute("readonly",""),o.value=e,o.focus(),o.select(),i.createMenu([{class:"export-main export-close",label:"Done",click:function(){i.createMenu(i.config.menu),i.isElement(i.setup.chart.containerDiv)&&i.setup.chart.containerDiv.removeChild(r)}}])}else{if(!i.config.fallback||"image"!=t.split("/")[0])throw new Error("Unable to create file. Ensure saveAs (FileSaver.js) is supported.");var r=document.createElement("div"),n=document.createElement("div"),s=i.toImage({data:e});n.innerHTML=i.i18l("fallback.save.image"),r.appendChild(n),r.appendChild(s),n.setAttribute("class","amcharts-export-fallback-message"),r.setAttribute("class","amcharts-export-fallback"),i.setup.chart.containerDiv.appendChild(r),i.createMenu([{class:"export-main export-close",label:"Done",click:function(){i.createMenu(i.config.menu),i.isElement(i.setup.chart.containerDiv)&&i.setup.chart.containerDiv.removeChild(r)}}])}return e},loadResource:function(e,t){function a(){i.handleLog(["amCharts[export]: Loading error on ",this.src||this.href].join(""))}function r(){if(t)for(n=0;n<t.length;n++)i.loadResource(t[n])}var n,o,s,l=-1!=e.indexOf("//")?e:[i.libs.path,e].join("");for(-1!=e.indexOf(".js")?((s=document.createElement("script")).setAttribute("type","text/javascript"),s.setAttribute("src",l),i.libs.async&&s.setAttribute("async","")):-1!=e.indexOf(".css")&&((s=document.createElement("link")).setAttribute("type","text/css"),s.setAttribute("rel","stylesheet"),s.setAttribute("href",l)),n=0;n<document.head.childNodes.length;n++)if(p=document.head.childNodes[n],c=!!p&&(p.src||p.href),!!p&&p.tagName,p&&c&&-1!=c.indexOf(e)){i.libs.reload&&document.head.removeChild(p),o=!0;break}for(n in i.libs.namespaces){var d=i.libs.namespaces[n],c=e.toLowerCase(),p=n.toLowerCase();if(-1!=c.indexOf(p)){if(i.setup.isIE&&i.setup.IEversion<=9&&i.libs.unsupportedIE9libs&&-1!=i.libs.unsupportedIE9libs.indexOf(p))return;if(void 0!==window[d]){o=!0;break}}}o&&!i.libs.reload||(s.addEventListener("load",r),i.addListenerToRemove("load",s,r),s.addEventListener("error",a),i.addListenerToRemove("error",s,a),document.head.appendChild(s))},addListenerToRemove:function(e,t,a){i.listenersToRemove.push({node:t,method:a,event:e})},loadDependencies:function(){var e,t;if(i.libs.autoLoad)for(e=0;e<i.libs.resources.length;e++)if(i.libs.resources[e]instanceof Object)for(t in i.libs.resources[e])i.loadResource(t,i.libs.resources[e][t]);else i.loadResource(i.libs.resources[e])},pxToNumber:function(e,t){if(e||!t)return Number(String(e).replace("px",""))||0},numberToPx:function(e){return String(e)+"px"},cloneObject:function(e){var t,a,r,n,o;t=Array.isArray(e)?[]:{};for(r in e)n="object"==typeof(a=e[r]),o=a instanceof Date,t[r]=n&&!o?i.cloneObject(a):a;return t},deepMerge:function(e,t,a){var r,n,o=t instanceof Array?"array":"object";if(!(e instanceof Object||e instanceof Array))return e;for(r in t)"array"==o&&isNaN(r)||(n=t[r],(e&&void 0==e[r]||a)&&(n instanceof Array?e[r]=new Array:n instanceof Function?e[r]=function(){}:n instanceof Date?e[r]=new Date:n instanceof Object?e[r]=new Object:n instanceof Number?e[r]=new Number:n instanceof String&&(e[r]=new String)),(n instanceof Object||n instanceof Array)&&!(n instanceof Function||n instanceof Date||i.isElement(n))&&"chart"!=r&&"scope"!=r?i.deepMerge(e[r],n,a):e instanceof Array&&!a?e.push(n):e&&(e[r]=n));return e},isElement:function(e){return e instanceof Object&&e&&1===e.nodeType},isHashbanged:function(e){var t=String(e).replace(/\"/g,"");return"url"==t.slice(0,3)&&t.slice(t.indexOf("#")+1,t.length-1)},isPressed:function(e){return"mousemove"==e.type&&1===e.which||("touchmove"==e.type||1===e.buttons||1===e.button||1===e.which?i.drawing.buffer.isPressed=!0:i.drawing.buffer.isPressed=!1),i.drawing.buffer.isPressed},removeImage:function(e){if(e){if(i.config.fabric.forceRemoveImages)return!0;if(i.config.fabric.removeImages&&i.isTainted(e))return!0;if(i.setup.isIE&&(10==i.setup.IEversion||11==i.setup.IEversion)&&-1!=e.toLowerCase().indexOf(".svg"))return!0}return!1},isTainted:function(e){var t=String(window.location.origin||window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""));if(e){if(-1!=t.indexOf(":\\")||-1!=e.indexOf(":\\")||-1!=t.indexOf("file://")||-1!=e.indexOf("file://"))return!0;if(-1!=e.indexOf("//")&&-1==e.indexOf(t.replace(/.*:/,"")))return!0}return!1},isSupported:function(){return!(!i.config.enabled||i.setup.isIE&&i.setup.IEversion<=9&&(!Array.prototype.indexOf||!document.head||!1===i.config.fallback))},getAngle:function(e,t,a,i){var r=a-e,n=i-t;return 180*(0==r?0==n?0:n>0?Math.PI/2:3*Math.PI/2:0==n?r>0?0:Math.PI:r<0?Math.atan(n/r)+Math.PI:n<0?Math.atan(n/r)+2*Math.PI:Math.atan(n/r))/Math.PI},gatherAttribute:function(e,t,a,r){var n,r=r||0,a=a||3;return e&&!(n=e.getAttribute(t))&&r<a?i.gatherAttribute(e.parentNode,t,a,r+1):n},gatherClassName:function(e,t,a,r){var n,r=r||0,a=a||3;if(i.isElement(e)){if(!(n=-1!=(e.getAttribute("class")||"").split(" ").indexOf(t))&&r<a)return i.gatherClassName(e.parentNode,t,a,r+1);n&&(n=e)}return n},gatherElements:function(e,t,a){var r,n;for(r=0;r<e.children.length;r++){var o=e.children[r];if("clipPath"==o.tagName){var s={},l=fabric.parseTransformAttribute(i.gatherAttribute(o,"transform"));for(n=0;n<o.childNodes.length;n++)o.childNodes[n].setAttribute("fill","transparent"),s={x:i.pxToNumber(o.childNodes[n].getAttribute("x")),y:i.pxToNumber(o.childNodes[n].getAttribute("y")),width:i.pxToNumber(o.childNodes[n].getAttribute("width")),height:i.pxToNumber(o.childNodes[n].getAttribute("height"))};e.clippings[o.id]={svg:o,bbox:s,transform:l}}else if("pattern"==o.tagName){var d={node:o,source:o.getAttribute("xlink:href"),width:Number(o.getAttribute("width")),height:Number(o.getAttribute("height")),repeat:"repeat",offsetX:0,offsetY:0};for(n=0;n<o.childNodes.length;n++)"rect"==o.childNodes[n].tagName?d.fill=o.childNodes[n].getAttribute("fill"):"image"==o.childNodes[n].tagName&&(c=fabric.parseAttributes(o.childNodes[n],fabric.SHARED_ATTRIBUTES)).transformMatrix&&(d.offsetX=c.transformMatrix[4],d.offsetY=c.transformMatrix[5]);i.removeImage(d.source)?e.patterns[o.id]=d.fill?d.fill:"transparent":e.patterns[d.node.id]=d}else if("image"==o.tagName)a.included++,fabric.Image.fromURL(o.getAttribute("xlink:href"),function(e){a.loaded++});else{var c=["fill","stroke"];for(n=0;n<c.length;n++){var p=c[n],f=o.getAttribute(p),u=i.getRGBA(f),g=i.isHashbanged(f);!f||u||g||(o.setAttribute(p,"none"),o.setAttribute(p+"-opacity","0"))}}}return e},getRGBA:function(e,t){return!("none"==e||"transparent"==e||i.isHashbanged(e)||!(e=new fabric.Color(e))._source)&&(t?e:e.getSource())},gatherPosition:function(e,t){var a,r=i.drawing.buffer.position,n=fabric.util.invertTransform(i.setup.fabric.viewportTransform);return"touchmove"==e.type&&("touches"in e?e=e.touches[0]:"changedTouches"in e&&(e=e.changedTouches[0])),a=fabric.util.transformPoint(i.setup.fabric.getPointer(e,!0),n),1==t&&(r.x1=a.x,r.y1=a.y),r.x2=a.x,r.y2=a.y,r.xD=r.x1-r.x2<0?-1*(r.x1-r.x2):r.x1-r.x2,r.yD=r.y1-r.y2<0?-1*(r.y1-r.y2):r.y1-r.y2,r},modifyFabric:function(){fabric.ElementsParser.prototype.resolveGradient=function(e,t){var a=e.get(t);if(/^url\(/.test(a)){var r=a.slice(a.indexOf("#")+1,a.length-1);if(fabric.gradientDefs[this.svgUid][r]){var n=fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][r],e);n.coords.y1&&"pie"!=i.setup.chart.type&&(n.coords.y2=-1*n.coords.y1,n.coords.y1=0),e.set(t,n)}}},fabric.Text.fromElement=function(e,t){if(!e)return null;var a=fabric.parseAttributes(e,fabric.Text.ATTRIBUTE_NAMES);(t=fabric.util.object.extend(t?fabric.util.object.clone(t):{},a)).top=t.top||0,t.left=t.left||0,"dx"in a&&(t.left+=a.dx),"dy"in a&&(t.top+=a.dy),"fontSize"in t||(t.fontSize=fabric.Text.DEFAULT_SVG_FONT_SIZE),t.originX||(t.originX="left");var i="",r=[];if("textContent"in e)if(e.childNodes)for(var n=0;n<e.childNodes.length;n++)r.push(e.childNodes[n].textContent);else r.push(e.textContent);else"firstChild"in e&&null!==e.firstChild&&"data"in e.firstChild&&null!==e.firstChild.data&&r.push(e.firstChild.data);i=r.join("\n");var o=new fabric.Text(i,t),s=0;return"left"===o.originX&&(s=o.getWidth()/2),"right"===o.originX&&(s=-o.getWidth()/2),r.length>1?o.set({left:o.getLeft()+s,top:o.getTop()+o.fontSize*(r.length-1)*(.18+o._fontSizeFraction),textAlign:t.originX,lineHeight:r.length>1?.965:1.16}):o.set({left:o.getLeft()+s,top:o.getTop()-o.getHeight()/2+o.fontSize*(.18+o._fontSizeFraction)}),o}},capture:function(e,t){var a,r=i.deepMerge(i.deepMerge({},i.config.fabric),e||{}),n=[],o={x:0,y:0,pX:0,pY:0,lX:0,lY:0,width:i.setup.chart.divRealWidth,height:i.setup.chart.divRealHeight},s={loaded:0,included:0},l={items:[],width:0,height:0,maxWidth:0,maxHeight:0};if(!i.handleNamespace("fabric",{scope:this,cb:i.capture,args:arguments}))return!1;i.modifyFabric(),i.handleCallback(r.beforeCapture,r);var d=i.setup.chart.containerDiv.getElementsByTagName("svg");for(a=0;a<d.length;a++)(p={svg:d[a],parent:d[a].parentNode,children:d[a].getElementsByTagName("*"),offset:{x:0,y:0},patterns:{},clippings:{},has:{legend:!1,panel:!1,scrollbar:!1}}).has.legend=i.gatherClassName(p.parent,i.setup.chart.classNamePrefix+"-legend-div",1),p.has.panel=i.gatherClassName(p.parent,i.setup.chart.classNamePrefix+"-stock-panel-div"),p.has.scrollbar=i.gatherClassName(p.parent,i.setup.chart.classNamePrefix+"-scrollbar-chart-div"),p=i.gatherElements(p,r,s),n.push(p);if(i.config.legend){if("stock"==i.setup.chart.type)for(a=0;a<i.setup.chart.panels.length;a++)i.setup.chart.panels[a].stockLegend&&i.setup.chart.panels[a].stockLegend.divId&&l.items.push(i.setup.chart.panels[a].stockLegend);else i.setup.chart.legend&&i.setup.chart.legend.divId&&l.items.push(i.setup.chart.legend);for(a=0;a<l.items.length;a++){var c=l.items[a],p={svg:c.container.container,parent:c.container.container.parentNode,children:c.container.container.getElementsByTagName("*"),offset:{x:0,y:0},legend:{id:a,type:-1!=["top","left"].indexOf(i.config.legend.position)?"unshift":"push",position:i.config.legend.position,width:i.config.legend.width?i.config.legend.width:c.container.div.offsetWidth,height:i.config.legend.height?i.config.legend.height:c.container.div.offsetHeight},patterns:{},clippings:{},has:{legend:!1,panel:!1,scrollbar:!1}};l.width+=p.legend.width,l.height+=p.legend.height,l.maxWidth=p.legend.width>l.maxWidth?p.legend.width:l.maxWidth,l.maxHeight=p.legend.height>l.maxHeight?p.legend.height:l.maxHeight,p=i.gatherElements(p,r,s),n[p.legend.type](p)}-1!=["top","bottom"].indexOf(i.config.legend.position)?(o.width=l.maxWidth>o.width?l.maxWidth:o.width,o.height+=l.height):-1!=["left","right"].indexOf(i.config.legend.position)?(o.width+=l.maxWidth,o.height=l.height>o.height?l.height:o.height):(o.height+=l.height,o.width+=l.maxWidth)}if(i.drawing.enabled=r.drawing.enabled="draw"==r.action,i.drawing.buffer.enabled=i.drawing.enabled,i.setup.wrapper=document.createElement("div"),i.setup.wrapper.setAttribute("class",i.setup.chart.classNamePrefix+"-export-canvas"),i.setup.chart.containerDiv.appendChild(i.setup.wrapper),"stock"==i.setup.chart.type){var f={top:0,right:0,bottom:0,left:0};i.setup.chart.leftContainer&&(o.width-=i.setup.chart.leftContainer.offsetWidth,f.left=i.setup.chart.leftContainer.offsetWidth+2*i.setup.chart.panelsSettings.panelSpacing),i.setup.chart.rightContainer&&(o.width-=i.setup.chart.rightContainer.offsetWidth,f.right=i.setup.chart.rightContainer.offsetWidth+2*i.setup.chart.panelsSettings.panelSpacing),i.setup.chart.periodSelector&&-1!=["top","bottom"].indexOf(i.setup.chart.periodSelector.position)&&(o.height-=i.setup.chart.periodSelector.offsetHeight+i.setup.chart.panelsSettings.panelSpacing,f[i.setup.chart.periodSelector.position]+=i.setup.chart.periodSelector.offsetHeight+i.setup.chart.panelsSettings.panelSpacing),i.setup.chart.dataSetSelector&&-1!=["top","bottom"].indexOf(i.setup.chart.dataSetSelector.position)&&(o.height-=i.setup.chart.dataSetSelector.offsetHeight,f[i.setup.chart.dataSetSelector.position]+=i.setup.chart.dataSetSelector.offsetHeight),i.setup.wrapper.style.paddingTop=i.numberToPx(f.top),i.setup.wrapper.style.paddingRight=i.numberToPx(f.right),i.setup.wrapper.style.paddingBottom=i.numberToPx(f.bottom),i.setup.wrapper.style.paddingLeft=i.numberToPx(f.left)}i.setup.canvas=document.createElement("canvas"),i.setup.wrapper.appendChild(i.setup.canvas);var u=i.removeFunctionsFromObject(i.deepMerge({width:o.width,height:o.height,isDrawingMode:!0},r));for(i.setup.fabric=new fabric.Canvas(i.setup.canvas,u),i.deepMerge(i.setup.fabric,r),i.deepMerge(i.setup.fabric.freeDrawingBrush,r.drawing),i.deepMerge(i.drawing,r.drawing),i.drawing.handler.change(r.drawing),i.setup.fabric.on("mouse:down",function(e){i.gatherPosition(e.e,1),i.drawing.buffer.pressedTS=Number(new Date),i.isPressed(e.e),i.drawing.buffer.isDrawing=!1,i.drawing.buffer.isDrawingTimer=setTimeout(function(){i.drawing.buffer.isSelected||(i.drawing.buffer.isDrawing=!0)},200)}),i.setup.fabric.on("mouse:move",function(e){var t=i.gatherPosition(e.e,2);if(i.isPressed(e.e),i.drawing.buffer.isPressed&&!i.drawing.buffer.isSelected&&(i.drawing.buffer.isDrawing=!0,!i.drawing.buffer.line&&"pencil"!=i.drawing.mode&&(t.xD>5||t.yD>5)&&(i.setup.fabric.isDrawingMode=!1,i.setup.fabric._isCurrentlyDrawing=!1,i.drawing.buffer.ignoreUndoOnMouseUp=!0,i.setup.fabric.freeDrawingBrush.onMouseUp(),i.setup.fabric.remove(i.setup.fabric._objects.pop()),i.drawing.buffer.line=i.drawing.handler.line({x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,arrow:"line"!=i.drawing.mode&&i.drawing.arrow,action:"config"}))),i.drawing.buffer.isSelected&&(i.setup.fabric.isDrawingMode=!1),i.drawing.buffer.line){var r,n,o,s=i.drawing.buffer.line;for(s.x2=t.x2,s.y2=t.y2,a=0;a<s.group.length;a++)(r=s.group[a])instanceof fabric.Line?r.set({x2:s.x2,y2:s.y2}):r instanceof fabric.Triangle&&(s.angle=i.getAngle(s.x1,s.y1,s.x2,s.y2)+90,"start"==s.arrow?(n=s.y1+s.width/2,o=s.x1+s.width/2):"middle"==s.arrow?(n=s.y2+s.width/2-(s.y2-s.y1)/2,o=s.x2+s.width/2-(s.x2-s.x1)/2):(n=s.y2+s.width/2,o=s.x2+s.width/2),r.set({top:n,left:o,angle:s.angle}));i.setup.fabric.renderAll()}}),i.setup.fabric.on("mouse:up",function(e){if(!i.drawing.buffer.isDrawing){var t=i.setup.fabric.findTarget(e.e);t&&t.selectable&&i.setup.fabric.setActiveObject(t)}if(i.drawing.buffer.line){for(a=0;a<i.drawing.buffer.line.group.length;a++)i.drawing.buffer.line.group[a].remove();delete i.drawing.buffer.line.action,delete i.drawing.buffer.line.group,i.drawing.handler.line(i.drawing.buffer.line)}i.drawing.buffer.line=!1,i.drawing.buffer.hasLine=!1,i.drawing.buffer.isPressed=!1,clearTimeout(i.drawing.buffer.isDrawingTimer),i.drawing.buffer.isDrawing=!1}),i.setup.fabric.on("object:selected",function(e){i.drawing.buffer.isSelected=!0,i.drawing.buffer.target=e.target,i.setup.fabric.isDrawingMode=!1}),i.setup.fabric.on("selection:cleared",function(e){i.drawing.buffer.target=!1,i.drawing.buffer.isSelected&&(i.setup.fabric._isCurrentlyDrawing=!1),i.drawing.buffer.isSelected=!1,i.setup.fabric.isDrawingMode=!0}),i.setup.fabric.on("path:created",function(e){var t=e.path;if(!i.drawing.buffer.isDrawing||i.drawing.buffer.hasLine)return i.setup.fabric.remove(t),void i.setup.fabric.renderAll()}),i.setup.fabric.on("object:added",function(e){var t=e.target,a=i.deepMerge(t.saveState()._stateProperties,{cfg:{color:i.drawing.color,width:i.drawing.width,opacity:i.drawing.opacity,fontSize:i.drawing.fontSize}});a=JSON.stringify(a),t.recentState=a,!i.drawing.buffer.ignoreUndoOnMouseUp&&i.drawing.buffer.isDrawing?(!t.selectable||t.known||t.ignoreUndo||(t.isAnnotation=!0,i.drawing.undos.push({action:"added",target:t,state:a}),i.drawing.redos=[]),t.known=!0,i.setup.fabric.isDrawingMode=!0):i.drawing.buffer.ignoreUndoOnMouseUp=!1}),i.setup.fabric.on("object:modified",function(e){var t=e.target,a=JSON.parse(t.recentState),r=i.deepMerge(t.saveState()._stateProperties,{cfg:a.cfg});r=JSON.stringify(r),t.recentState=r,i.drawing.undos.push({action:"modified",target:t,state:r}),i.drawing.redos=[]}),i.setup.fabric.on("text:changed",function(e){var t=e.target;clearTimeout(t.timer),t.timer=setTimeout(function(){var e=JSON.stringify(t.saveState()._stateProperties);t.recentState=e,i.drawing.redos=[],i.drawing.undos.push({action:"modified",target:t,state:e})},250)}),i.drawing.enabled?(i.setup.wrapper.setAttribute("class",i.setup.chart.classNamePrefix+"-export-canvas active"),i.setup.wrapper.style.backgroundColor=r.backgroundColor,i.setup.wrapper.style.display="block"):(i.setup.wrapper.setAttribute("class",i.setup.chart.classNamePrefix+"-export-canvas"),i.setup.wrapper.style.display="none"),a=0;a<n.length;a++)p=n[a],"stock"==i.setup.chart.type&&i.setup.chart.legendSettings.position?-1!=["top","bottom"].indexOf(i.setup.chart.legendSettings.position)?p.parent.style.top&&p.parent.style.left?(p.offset.y=i.pxToNumber(p.parent.style.top),p.offset.x=i.pxToNumber(p.parent.style.left)):(p.offset.x=o.x,p.offset.y=o.y,o.y+=i.pxToNumber(p.parent.style.height),p.has.panel?(o.pY=i.pxToNumber(p.has.panel.style.marginTop),p.offset.y+=o.pY):p.has.scrollbar&&(p.offset.y+=o.pY)):-1!=["left","right"].indexOf(i.setup.chart.legendSettings.position)&&(p.offset.y=i.pxToNumber(p.parent.style.top)+o.pY,p.offset.x=i.pxToNumber(p.parent.style.left)+o.pX,p.has.legend?o.pY+=i.pxToNumber(p.has.panel.style.height)+i.setup.chart.panelsSettings.panelSpacing:p.has.scrollbar&&(p.offset.y-=i.setup.chart.panelsSettings.panelSpacing)):("absolute"==p.parent.style.position?(p.offset.absolute=!0,p.offset.top=i.pxToNumber(p.parent.style.top),p.offset.right=i.pxToNumber(p.parent.style.right,!0),p.offset.bottom=i.pxToNumber(p.parent.style.bottom,!0),p.offset.left=i.pxToNumber(p.parent.style.left),p.offset.width=i.pxToNumber(p.parent.style.width),p.offset.height=i.pxToNumber(p.parent.style.height)):p.parent.style.top&&p.parent.style.left?(p.offset.y=i.pxToNumber(p.parent.style.top),p.offset.x=i.pxToNumber(p.parent.style.left)):p.legend?("left"==p.legend.position?o.x=l.maxWidth:"right"==p.legend.position?p.offset.x=o.width-l.maxWidth:"top"==p.legend.position?o.y+=p.legend.height:"bottom"==p.legend.position&&(p.offset.y=o.height-l.height),p.offset.y+=o.lY,o.lY+=p.legend.height):(p.offset.x=o.x,p.offset.y=o.y+o.pY,o.y+=i.pxToNumber(p.parent.style.height)),p.has.legend&&p.has.panel&&p.has.panel.style.marginTop?(o.y+=i.pxToNumber(p.has.panel.style.marginTop),p.offset.y+=i.pxToNumber(p.has.panel.style.marginTop)):i.setup.chart.legend&&-1!=["left","right"].indexOf(i.setup.chart.legend.position)&&(p.offset.y=i.pxToNumber(p.parent.style.top),p.offset.x=i.pxToNumber(p.parent.style.left))),fabric.parseSVGDocument(p.svg,function(e){return function(a,l){var d,c=fabric.util.groupSVGElements(a,l),p=[],f={selectable:!1,isCoreElement:!0};for(e.offset.absolute?(void 0!==e.offset.bottom?f.top=o.height-e.offset.height-e.offset.bottom:f.top=e.offset.top,void 0!==e.offset.right?f.left=o.width-e.offset.width-e.offset.right:f.left=e.offset.left):(f.top=e.offset.y,f.left=e.offset.x),d=0;d<c.paths.length;d++){var u=null;if(c.paths[d]){if(i.removeImage(c.paths[d]["xlink:href"]))continue;if(c.paths[d].fill instanceof Object)"radial"==c.paths[d].fill.type&&-1==["pie","gauge"].indexOf(i.setup.chart.type)&&(c.paths[d].fill.coords.r2=-1*c.paths[d].fill.coords.r1,c.paths[d].fill.coords.r1=0,c.paths[d].set({opacity:c.paths[d].fillOpacity}));else if((u=i.isHashbanged(c.paths[d].fill))&&e.patterns&&e.patterns[u]){var g=e.patterns[u];s.included++,fabric.Image.fromURL(g.source,function(e,t){return function(a){s.loaded++,a.set({top:e.offsetY,left:e.offsetX,width:e.width,height:e.height}),i.setup.fabric._isRetinaScaling()&&a.set({top:e.offsetY/2,left:e.offsetX/2,scaleX:.5,scaleY:.5});var r=new fabric.StaticCanvas(void 0,{backgroundColor:e.fill,width:a.getWidth(),height:a.getHeight()});r.add(a);var n=new fabric.Pattern({source:r.getElement(),offsetX:c.paths[t].width/2,offsetY:c.paths[t].height/2,repeat:"repeat"});c.paths[t].set({fill:n,opacity:c.paths[t].fillOpacity})}}(g,d))}(u=i.isHashbanged(c.paths[d].clipPath))&&e.clippings&&e.clippings[u]&&(function(t,a){var i=c.paths[t].toSVG;c.paths[t].toSVG=function(t){return i.apply(this,[function(i){return t(i,e.clippings[a])}])}}(d,u),c.paths[d].set({clipTo:function(t,a){return function(r){var n=e.clippings[a],o=this.transformMatrix||[1,0,0,1,0,0],s={top:n.bbox.y,left:n.bbox.x,width:n.bbox.width,height:n.bbox.height};"map"==i.setup.chart.type&&(s.top+=n.transform[5],s.left+=n.transform[4]),n.bbox.x&&o[4]&&n.bbox.y&&o[5]&&(s.top-=o[5],s.left-=o[4]),void 0!==i.setup.chart.smoothCustomBullets&&this.className==i.setup.chart.classNamePrefix+"-graph-bullet"&&"image"==c.paths[t].svg.tagName?(radius=n.svg.firstChild.rx.baseVal.value/2+2,r.beginPath(),r.moveTo(s.left+radius,s.top),r.lineTo(s.left+s.width-radius,s.top),r.quadraticCurveTo(s.left+s.width,s.top,s.left+s.width,s.top+radius),r.lineTo(s.left+s.width,s.top+s.height-radius),r.quadraticCurveTo(s.left+s.width,s.top+s.height,s.left+s.width-radius,s.top+s.height),r.lineTo(s.left+radius,s.top+s.height),r.quadraticCurveTo(s.left,s.top+s.height,s.left,s.top+s.height-radius),r.lineTo(s.left,s.top+radius),r.quadraticCurveTo(s.left,s.top,s.left+radius,s.top),r.closePath()):r.rect(s.left,s.top,s.width,s.height)}}(d,u)}))}p.push(c.paths[d])}if(c.paths=p,c.set(f),i.setup.fabric.add(c),e.svg.parentNode&&e.svg.parentNode.getElementsByTagName){var h=e.svg.parentNode.getElementsByClassName(i.setup.chart.classNamePrefix+"-balloon-div");for(d=0;d<h.length;d++)if(r.balloonFunction instanceof Function)r.balloonFunction.apply(i,[h[d],e]);else{var m=h[d],b=fabric.parseStyleAttribute(m),v=fabric.parseStyleAttribute(m.childNodes[0]),w=new fabric.Text(m.innerText||m.textContent||m.innerHTML,{selectable:!1,top:i.pxToNumber(b.top)+e.offset.y,left:i.pxToNumber(b.left)+e.offset.x,fill:v.color,fontSize:i.pxToNumber(v.fontSize||v["font-size"]),fontFamily:v.fontFamily||v["font-family"],textAlign:v["text-align"],isCoreElement:!0});i.setup.fabric.add(w)}}if(e.svg.nextSibling&&"A"==e.svg.nextSibling.tagName){var m=e.svg.nextSibling,b=fabric.parseStyleAttribute(m),w=new fabric.Text(m.innerText||m.textContent||m.innerHTML,{selectable:!1,top:i.pxToNumber(b.top)+e.offset.y,left:i.pxToNumber(b.left)+e.offset.x,fill:b.color,fontSize:i.pxToNumber(b.fontSize||b["font-size"]),fontFamily:b.fontFamily||b["font-family"],opacity:b.opacity,isCoreElement:!0});e.has.scrollbar||i.setup.fabric.add(w)}if(n.pop(),!n.length)var y=Number(new Date),x=setInterval(function(){var e=Number(new Date);(s.loaded==s.included||e-y>i.config.fabric.loadTimeout)&&(clearTimeout(x),i.handleBorder(r),i.handleCallback(r.afterCapture,r),i.setup.fabric.renderAll(),i.handleCallback(t,r))},AmCharts.updateRate)}}(p),function(e,t){var a,n=i.gatherAttribute(e,"class"),o=i.gatherAttribute(e,"visibility"),s=i.gatherAttribute(e,"clip-path");t.className=String(n),t.classList=String(n).split(" "),t.clipPath=s,t.svg=e;var l=["fill","stroke"];for(a=0;a<l.length;a++){var d=l[a],c=String(e.getAttribute(d)||"none"),p=Number(e.getAttribute(d+"-opacity")||"1"),f=i.getRGBA(c);"hidden"==o&&(t.opacity=0,p=0),f&&(f.pop(),f.push(p),t[d]="rgba("+f.join()+")",t[d+i.capitalize("opacity")]=p)}i.handleCallback(r.reviver,t,e)})},toCanvas:function(e,t){var a=i.deepMerge({},e||{}),r=i.setup.canvas;return i.handleCallback(t,r,a),r},toImage:function(e,t){var a=i.deepMerge({format:"png",quality:1,multiplier:i.config.multiplier},e||{}),r=a.data,n=document.createElement("img");return!!i.handleNamespace("fabric",{scope:this,cb:i.toImage,args:arguments})&&(a.data||(r=a.lossless||"svg"==a.format?i.toSVG(i.deepMerge(a,{getBase64:!0})):i.setup.fabric.toDataURL(a)),n.setAttribute("src",r),i.handleCallback(t,n,a),n)},toBlob:function(e,t){var a,r=i.deepMerge({data:"empty",type:"text/plain"},e||{}),n=/^data:.+;base64,(.*)$/.exec(r.data);return n&&(r.data=n[0],r.type=r.data.slice(5,r.data.indexOf(",")-7),r.data=i.toByteArray({data:r.data.slice(r.data.indexOf(",")+1,r.data.length)})),a=r.getByteArray?r.data:new Blob([r.data],{type:r.type}),i.handleCallback(t,a,r),a},toJPG:function(e,t){var a=i.deepMerge({format:"jpeg",quality:1,multiplier:i.config.multiplier},e||{});a.format=a.format.toLowerCase();var r;return/iP(hone|od|ad)/.test(navigator.platform)&&(a.multiplier=1),!!i.handleNamespace("fabric",{scope:this,cb:i.toJPG,args:arguments})&&(r=i.setup.fabric.toDataURL(a),i.handleCallback(t,r,a),r)},toPNG:function(e,t){var a,r=i.deepMerge({format:"png",quality:1,multiplier:i.config.multiplier},e||{});return/iP(hone|od|ad)/.test(navigator.platform)&&(r.multiplier=1),!!i.handleNamespace("fabric",{scope:this,cb:i.toPNG,args:arguments})&&(a=i.setup.fabric.toDataURL(r),i.handleCallback(t,a,r),a)},toSVG:function(e,t){var a,r=[],n=[],o=i.deepMerge({compress:i.config.compress,reviver:function(e,t){var a=new RegExp(/\bstyle=(['"])(.*?)\1/).exec(e)[0].slice(7,-1),o=a.split(";"),s=[];for(i1=0;i1<o.length;i1++)if(o[i1]){var l=o[i1].replace(/\s/g,"").split(":"),d=l[0],c=l[1];if(-1!=["fill","stroke"].indexOf(d))if(c=i.getRGBA(c,!0)){var p="#"+c.toHex(),f=c._source[3];s.push([d,p].join(":")),s.push([d+"-opacity",f].join(":"))}else s.push(o[i1]);else"opactiy"!=d&&s.push(o[i1])}if(e=e.replace(a,s.join(";")),t&&t.svg){var u=t.svg.id,g=2,h=e.slice(-g);"/>"!=h&&(g=3,h=e.slice(-g));var m=e.slice(0,e.length-g),b=' clip-path="url(#'+u+')" ',v=i.gatherAttribute(t.svg,"class");if(v=v?v.split(" "):[],e=-1!=v.indexOf(i.setup.chart.classNamePrefix+"-graph-line")?m+b+h:"<g "+b+">"+e+"</g>",-1==n.indexOf(u)){var w=(new XMLSerializer).serializeToString(t.svg);r.push(w),n.push(u)}}return e}},e||{});if(!i.handleNamespace("fabric",{scope:this,cb:i.toSVG,args:arguments}))return!1;if(a=i.setup.fabric.toSVG(o,o.reviver),r.length){var s=a.slice(0,a.length-6),l=a.slice(-6);a=s+r.join("")+l}return o.compress&&(a=a.replace(/[\t\r\n]+/g,"")),o.getBase64&&(a="data:image/svg+xml;base64,"+btoa(a)),i.handleCallback(t,a,o),a},toPDF:function(e,t){var a,r=i.deepMerge(i.deepMerge({multiplier:i.config.multiplier||2,pageOrigin:void 0===i.config.pageOrigin},i.config.pdfMake),e||{},!0);if(/iP(hone|od|ad)/.test(navigator.platform)&&(r.multiplier=1),!i.handleNamespace("pdfMake",{scope:this,cb:i.toPDF,args:arguments}))return!1;if(r.images.reference=i.toPNG(r),!r.content){var n=[],o=function(e,t){var a=i.defaults.pdfMake.pageSizes[String(e).toUpperCase()].slice();if(!a)throw new Error('The given pageSize "'+e+'" does not exist!');return"landscape"==t&&a.reverse(),a}(r.pageSize,r.pageOrientation),s=function(e){if("number"==typeof e||e instanceof Number)e={left:e,right:e,top:e,bottom:e};else if(e instanceof Array)if(2===e.length)e={left:e[0],top:e[1],right:e[0],bottom:e[1]};else{if(4!==e.length)throw"Invalid pageMargins definition";e={left:e[0],top:e[1],right:e[2],bottom:e[3]}}else e={left:i.defaults.pdfMake.pageMargins,top:i.defaults.pdfMake.pageMargins,right:i.defaults.pdfMake.pageMargins,bottom:i.defaults.pdfMake.pageMargins};return e}(r.pageMargins);o[0]-=s.left+s.right,o[1]-=s.top+s.bottom,r.pageOrigin&&(n.push(i.i18l("label.saved.from")),n.push(window.location.href),o[1]-=28.128),n.push({image:"reference",fit:o}),r.content=n}return a=new pdfMake.createPdf(r),t&&a.getDataUrl(function(e){return function(t){e.apply(i,arguments)}}(t)),a},toPRINT:function(e,t){var a,r=i.deepMerge({delay:1,lossless:!1},e||{}),n=i.toImage(r),o=[],s=document.body.childNodes,l=document.documentElement.scrollTop||document.body.scrollTop;for(n.setAttribute("style","width: 100%; max-height: 100%;"),a=0;a<s.length;a++)i.isElement(s[a])&&(o[a]=s[a].style.display,s[a].style.display="none");return document.body.appendChild(n),r.delay*=1e3,/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream&&r.delay<1e3&&(r.delay=1e3),setTimeout(function(){window.print(),setTimeout(function(){for(a=0;a<s.length;a++)i.isElement(s[a])&&(s[a].style.display=o[a]);document.body.removeChild(n),document.documentElement.scrollTop=document.body.scrollTop=l,i.handleCallback(t,n,r)},r.delay)},r.delay),n},toJSON:function(e,t){var a=i.deepMerge({dateFormat:i.config.dateFormat||"dateObject"},e||{},!0),r={};return!!i.handleNamespace("JSON",{scope:this,cb:i.toJSON,args:arguments})&&(a.data=void 0!==a.data?a.data:i.getChartData(a),r=JSON.stringify(a.data,void 0,"\t"),i.handleCallback(t,r,a),r)},toCSV:function(e,t){var a,r=i.deepMerge({delimiter:",",quotes:!0,escape:!0,withHeader:!0},e||{},!0),n=[],o="";n=i.toArray(r);for(a in n)isNaN(a)||(o+=n[a].join(r.delimiter)+"\n");return i.handleCallback(t,o,r),o},toXLSX:function(e,t){function a(e,t){return t&&(e+=1462),(Date.parse(e)-60*e.getTimezoneOffset()*1e3-new Date(Date.UTC(1899,11,30)))/864e5}var r=i.deepMerge({name:"amCharts",dateFormat:i.config.dateFormat||"dateObject",withHeader:!0,stringify:!1},e||{},!0),n=[],o="",s={SheetNames:[],Sheets:{}};return!!i.handleNamespace("XLSX",{scope:this,cb:i.toXLSX,args:arguments})&&(n=i.toArray(r),s.SheetNames.push(r.name),s.Sheets[r.name]=function(e,t){for(var i={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=0;n!=e.length;++n)for(var o=0;o!=e[n].length;++o){r.s.r>n&&(r.s.r=n),r.s.c>o&&(r.s.c=o),r.e.r<n&&(r.e.r=n),r.e.c<o&&(r.e.c=o);var s={v:e[n][o]};if(null!=s.v){var l=XLSX.utils.encode_cell({c:o,r:n});"number"==typeof s.v?s.t="n":"boolean"==typeof s.v?s.t="b":s.v instanceof Date?(s.t="n",s.z=XLSX.SSF._table[14],s.v=a(s.v)):s.v instanceof Object?(s.t="s",s.v=JSON.stringify(s.v)):s.t="s",i[l]=s}}return r.s.c<1e7&&(i["!ref"]=XLSX.utils.encode_range(r)),i}(n),o=XLSX.write(s,{bookType:"xlsx",bookSST:!0,type:"base64"}),o="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"+o,i.handleCallback(t,o,r),o)},toArray:function(e,t){function a(e){return"string"==typeof e&&(n.escape&&(e=e.replace('"','""')),n.quotes&&(e=['"',e,'"'].join(""))),e}var r,n=i.deepMerge({withHeader:!1,stringify:!0,escape:!1,quotes:!1},e||{},!0),o=[],s=[],l=[],d=i.config.processData;if(n.processData=function(e,t){var a=t.exportFields||Object.keys(t.dataFieldsMap);for(c=0;c<a.length;c++){var r=a[c],n=t.dataFieldsTitlesMap[r];s.push(n)}return d?i.handleCallback(d,e,t):e},n.data=void 0!==n.data?i.processData(n):i.getChartData(n),n.withHeader){l=[];for(c in s)isNaN(c)||l.push(a(s[c]));o.push(l)}for(r in n.data)if(l=[],!isNaN(r)){for(c in s)if(!isNaN(c)){var c=s[c],p=n.data[r][c];p=null==p?"":n.stringify?String(p):p,l.push(a(p))}o.push(l)}return i.handleCallback(t,o,n),o},toByteArray:function(e,t){function a(e){var t=e.charCodeAt(0);return t===o?62:t===s?63:t<l?-1:t<l+10?t-l+26+26:t<c+26?t-c:t<d+26?t-d+26:void 0}var r=i.deepMerge({},e||{}),n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),s="/".charCodeAt(0),l="0".charCodeAt(0),d="a".charCodeAt(0),c="A".charCodeAt(0),p=function(e){function t(e){d[p++]=e}var i,r,o,s,l,d;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=e.length;l="="===e.charAt(c-2)?2:"="===e.charAt(c-1)?1:0,d=new n(3*e.length/4-l),o=l>0?e.length-4:e.length;var p=0;for(i=0,r=0;i<o;i+=4,r+=3)t((16711680&(s=a(e.charAt(i))<<18|a(e.charAt(i+1))<<12|a(e.charAt(i+2))<<6|a(e.charAt(i+3))))>>16),t((65280&s)>>8),t(255&s);return 2===l?t(255&(s=a(e.charAt(i))<<2|a(e.charAt(i+1))>>4)):1===l&&(t((s=a(e.charAt(i))<<10|a(e.charAt(i+1))<<4|a(e.charAt(i+2))>>2)>>8&255),t(255&s)),d}(r.data);return i.handleCallback(t,p,r),p},removeFunctionsFromObject:function(e){for(var t in e)"function"==typeof e[t]&&delete e[t];return e},handleCallback:function(e){var t,a=Array();if(e&&e instanceof Function){for(t=0;t<arguments.length;t++)t>0&&a.push(arguments[t]);return e.apply(i,a)}},handleLog:function(e){!0===i.config.debug&&console.log(e)},handleNamespace:function(e,t){function a(){var l=Number(new Date);o=!!(e in n),"pdfMake"==e&&o&&(o=n.pdfMake.vfs),o?(clearTimeout(r),t.cb.apply(t.scope,t.args),i.handleLog(['AmCharts [export]: Namespace "',e,'" showed up in: ',String(n)].join(""))):l-s<i.libs.loadTimeout?r=setTimeout(a,250):i.handleLog(['AmCharts [export]: Gave up waiting for "',e,'" in: ',String(n)].join(""))}var r,n=i.config.scope||window,o=!1,s=Number(new Date);return(o=!!(e in n))||(i.handleLog(['AmCharts [export]: Could not find "',e,'" in: ',String(n)].join("")),a()),o},handleBorder:function(e){if(i.config.border instanceof Object){var t=i.deepMerge(i.defaults.fabric.border,e.border||{},!0),a=new fabric.Rect;t.width=i.setup.fabric.width-t.strokeWidth,t.height=i.setup.fabric.height-t.strokeWidth,a.set(t),i.setup.fabric.add(a)}},handleDropbox:function(e){if(i.drawing.enabled)if(e.preventDefault(),e.stopPropagation(),"dragover"==e.type)i.setup.wrapper.setAttribute("class",i.setup.chart.classNamePrefix+"-export-canvas active dropbox");else if(i.setup.wrapper.setAttribute("class",i.setup.chart.classNamePrefix+"-export-canvas active"),"drop"==e.type&&e.dataTransfer.files.length)for(var t=0;t<e.dataTransfer.files.length;t++){var a=new FileReader;a.onloadend=function(t){return function(){i.drawing.handler.add({url:a.result,top:e.layerY-10*t,left:e.layerX-10*t})}}(t),a.readAsDataURL(e.dataTransfer.files[t])}},handleReady:function(e){var t=this,a=Number(new Date);t.handleCallback(e,"data",!1);for(filename in t.libs.namespaces)!function(i){var r=setInterval(function(){var n=Number(new Date);(n-a>t.libs.loadTimeout||i in window)&&(clearTimeout(r),t.handleCallback(e,i,n-a>t.libs.loadTimeout))},AmCharts.updateRate)}(t.libs.namespaces[filename])},getChartData:function(e){function t(e,t,a){function r(e,t){return-1!=s.dataFields.indexOf(e)?r([e,".",t].join("")):e}e&&s.exportTitles&&"gantt"!=i.setup.chart.type&&(g=r(e,a),s.dataFieldsMap[g]=e,s.dataFields.push(g),s.titles[g]=t||g)}var a,r,n,o,s=i.deepMerge({data:[],titles:{},dateFields:[],dataFields:[],dataFieldsMap:{},exportTitles:i.config.exportTitles,exportFields:i.config.exportFields,exportSelection:i.config.exportSelection,columnNames:i.config.columnNames},e||{},!0),l=["valueField","openField","closeField","highField","lowField","xField","yField"];if(0==s.data.length)if("stock"==i.setup.chart.type){for(s.data=i.cloneObject(i.setup.chart.mainDataSet.dataProvider),t(i.setup.chart.mainDataSet.categoryField),s.dateFields.push(i.setup.chart.mainDataSet.categoryField),a=0;a<i.setup.chart.mainDataSet.fieldMappings.length;a++)for(u=i.setup.chart.mainDataSet.fieldMappings[a],r=0;r<i.setup.chart.panels.length;r++){var d=i.setup.chart.panels[r];for(n=0;n<d.stockGraphs.length;n++)for(v=d.stockGraphs[n],i4=0;i4<l.length;i4++)v[l[i4]]==u.toField&&t(u.fromField,v.title,l[i4])}if(i.setup.chart.comparedGraphs.length){for(o=[],a=0;a<s.data.length;a++)o.push(s.data[a][i.setup.chart.mainDataSet.categoryField]);for(a=0;a<i.setup.chart.comparedGraphs.length;a++)for(v=i.setup.chart.comparedGraphs[a],r=0;r<v.dataSet.dataProvider.length;r++){var c=v.dataSet.categoryField,p=v.dataSet.dataProvider[r][c],f=o.indexOf(p);if(-1!=f)for(n=0;n<v.dataSet.fieldMappings.length;n++){var u=v.dataSet.fieldMappings[n],g=v.dataSet.id+"_"+u.toField;s.data[f][g]=v.dataSet.dataProvider[r][u.fromField],s.titles[g]||t(g,v.dataSet.title)}}}}else if("gantt"==i.setup.chart.type){t(i.setup.chart.categoryField);var h=i.setup.chart.segmentsField;for(a=0;a<i.setup.chart.dataProvider.length;a++){var m=i.setup.chart.dataProvider[a];if(m[h])for(r=0;r<m[h].length;r++)m[h][r][i.setup.chart.categoryField]=m[i.setup.chart.categoryField],s.data.push(m[h][r])}for(a=0;a<i.setup.chart.graphs.length;a++)for(v=i.setup.chart.graphs[a],r=0;r<l.length;r++){var b=v[w=l[r]];v.title,t(b,v.title,w)}}else if(-1!=["pie","funnel"].indexOf(i.setup.chart.type))s.data=i.setup.chart.dataProvider,t(i.setup.chart.titleField),s.dateFields.push(i.setup.chart.titleField),t(i.setup.chart.valueField);else if("map"!=i.setup.chart.type)for(s.data=i.setup.chart.dataProvider,i.setup.chart.categoryAxis&&(t(i.setup.chart.categoryField,i.setup.chart.categoryAxis.title),!1!==i.setup.chart.categoryAxis.parseDates&&s.dateFields.push(i.setup.chart.categoryField)),a=0;a<i.setup.chart.graphs.length;a++){var v=i.setup.chart.graphs[a];for(r=0;r<l.length;r++){var w=l[r];t(b=v[w],v.title,w)}}return i.processData(s)},getAnnotations:function(e,t){var a,r=i.deepMerge({},e||{},!0),n=[];for(a=0;a<i.setup.fabric._objects.length;a++)if(!i.setup.fabric._objects[a].isCoreElement){var o=i.setup.fabric._objects[a].toJSON();i.handleCallback(r.reviver,o,a),n.push(o)}return i.handleCallback(t,n),n},setAnnotations:function(e,t){var a=i.deepMerge({data:[]},e||{},!0);return fabric.util.enlivenObjects(a.data,function(e){e.forEach(function(e,t){i.handleCallback(a.reviver,e,t),i.setup.fabric.add(e)}),i.handleCallback(t,a)}),a.data},processData:function(t){var a,r,n=i.deepMerge({data:[],titles:{},dateFields:[],dataFields:[],dataFieldsMap:{},dataFieldsTitlesMap:{},dataDateFormat:i.setup.chart.dataDateFormat,dateFormat:i.config.dateFormat||i.setup.chart.dataDateFormat||"YYYY-MM-DD",exportTitles:i.config.exportTitles,exportFields:i.config.exportFields,exportSelection:i.config.exportSelection,columnNames:i.config.columnNames,processData:i.config.processData},t||{},!0);if(n.data.length){for(a=0;a<n.data.length;a++)for(r in n.data[a])-1==n.dataFields.indexOf(r)&&(n.dataFields.push(r),n.dataFieldsMap[r]=r);void 0!==n.exportFields&&(n.dataFields=n.exportFields.filter(function(e){return-1!=n.dataFields.indexOf(e)}));var o=[];for(a=0;a<n.data.length;a++){var s={},l=!1;for(r=0;r<n.dataFields.length;r++){var d=n.dataFields[r],c=n.dataFieldsMap[d],p=n.columnNames&&n.columnNames[d]||n.titles[d]||d,f=n.data[a][c];null==f&&(f=void 0),n.exportTitles&&"gantt"!=i.setup.chart.type&&p in s&&(p+=["( ",d," )"].join("")),-1!=n.dateFields.indexOf(c)&&(n.dataDateFormat&&(f instanceof String||"string"==typeof f)?f=AmCharts.stringToDate(f,n.dataDateFormat):n.dateFormat&&(f instanceof Number||"number"==typeof f)&&(f=new Date(f)),n.exportSelection&&(f instanceof Date?(f<e.startDate||f>e.endDate)&&(l=!0):(a<e.startIndex||a>e.endIndex)&&(l=!0)),n.dateFormat&&"dateObject"!=n.dateFormat&&f instanceof Date&&(f=AmCharts.formatDate(f,n.dateFormat))),n.dataFieldsTitlesMap[c]=p,s[p]=f}l||o.push(s)}n.data=o}return void 0!==n.processData&&(n.data=i.handleCallback(n.processData,n.data,n)),n.data},capitalize:function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},createMenu:function(t,a){function r(t,a){var o,s,l=document.createElement("ul");for(o=0;o<t.length;o++){var d="string"==typeof t[o]?{format:t[o]}:t[o],c=document.createElement("li"),p=document.createElement("a"),f=document.createElement("img"),u=document.createElement("span"),g=String(d.action?d.action:d.format).toLowerCase();if(d.format=String(d.format).toUpperCase(),c.addEventListener("mouseleave",function(e){this.classList.remove("active")}),p.addEventListener("focus",function(e){if(!i.setup.hasTouch){i.setup.focusedMenuItem=this;var t=this.parentNode;"UL"!=t.tagName&&(t=t.parentNode);var a=t.getElementsByTagName("li");for(o=0;o<a.length;o++)a[o].classList.remove("active");this.parentNode.classList.add("active"),this.parentNode.parentNode.parentNode.classList.add("active")}}),i.config.formats[d.format]?d=i.deepMerge({label:d.icon?"":d.format,format:d.format,mimeType:i.config.formats[d.format].mimeType,extension:i.config.formats[d.format].extension,capture:i.config.formats[d.format].capture,action:i.config.action,fileName:i.config.fileName},d):d.label||(d.label=d.label?d.label:i.i18l("menu.label."+g)),(-1==["CSV","JSON","XLSX"].indexOf(d.format)||-1==["map","gauge"].indexOf(i.setup.chart.type))&&(i.setup.hasBlob||"UNDEFINED"==d.format||!d.mimeType||"image"==d.mimeType.split("/")[0]||"text/plain"==d.mimeType)){if("draw"==d.action)i.config.fabric.drawing.enabled?(d.menu=d.menu?d.menu:i.config.fabric.drawing.menu,d.click=function(e){return function(){this.capture(e,function(){this.createMenu(e.menu)})}}(d)):d.menu=[];else if(!d.populated&&d.action&&-1!=d.action.indexOf("draw.")){var h=d.action.split(".")[1],m=d[h]||i.config.fabric.drawing[h]||[];for(d.menu=[],d.populated=!0,s=0;s<m.length;s++){var b={label:m[s]};if("shapes"==h){var v=-1==m[s].indexOf("//"),w=(v?i.config.path+"shapes/":"")+m[s];b.action="add",b.url=w,b.icon=w,b.ignore=v,b.class="export-drawing-shape"}else"colors"==h?(b.style="background-color: "+m[s],b.action="change",b.color=m[s],b.class="export-drawing-color"):"widths"==h?(b.action="change",b.width=m[s],b.label=document.createElement("span"),b.label.style.width=i.numberToPx(m[s]),b.label.style.height=i.numberToPx(m[s]),b.class="export-drawing-width"):"opacities"==h?(b.style="opacity: "+m[s],b.action="change",b.opacity=m[s],b.label=100*m[s]+"%",b.class="export-drawing-opacity"):"modes"==h&&(b.label=i.i18l("menu.label.draw.modes."+m[s]),b.click=function(e){return function(){i.drawing.mode=e}}(m[s]),b.class="export-drawing-mode");d.menu.push(b)}}else d.click||d.menu||d.items||(i.drawing.handler[g]instanceof Function?(d.action=g,d.click=function(e){return function(){this.drawing.handler[e.action](e),"cancel"!=e.action&&this.createMenu(this.config.fabric.drawing.menu)}}(d)):i.drawing.enabled?d.click=function(e){return function(){this.config.drawing.autoClose&&this.drawing.handler.done(),this["to"+e.format](e,function(t){"download"==e.action&&this.download(t,e.mimeType,[e.fileName,e.extension].join("."))})}}(d):"UNDEFINED"!=d.format&&(d.click=function(e){return function(){if(e.capture||"print"==e.action||"PRINT"==e.format)this.capture(e,function(){this.drawing.handler.done(),this["to"+e.format](e,function(t){"download"==e.action&&this.download(t,e.mimeType,[e.fileName,e.extension].join("."))})});else{if(!this["to"+e.format])throw new Error("Invalid format. Could not determine output type.");this["to"+e.format](e,function(t){this.download(t,e.mimeType,[e.fileName,e.extension].join("."))})}}}(d)));(void 0===d.menu||d.menu.length)&&(p.setAttribute("href","#"),i.setup.hasTouch&&c.classList?(p.addEventListener("touchend",function(e,t){return function(a){a.preventDefault();var r=[a,t];if(("draw"==t.action||"PRINT"==t.format||"UNDEFINED"!=t.format&&t.capture)&&!i.drawing.enabled&&(!isNaN(t.delay)||!isNaN(i.config.delay)))return t.delay=isNaN(t.delay)?i.config.delay:t.delay,void i.delay(t,e);e.apply(i,r)}}(d.click||function(e){e.preventDefault()},d)),p.addEventListener("touchend",function(e){return function(t){function a(e){return e.classList.contains("export-main")||e.classList.contains("export-drawing")}t.preventDefault();var r=e.elements.li,s=function(e){var t=e.parentNode.parentNode,a=t.classList;return!("LI"!=t.tagName||!a.contains("active"))}(r),l=(function(e){var t=e.parentNode.children;for(o=0;o<t.length;o++){var a=t[o],i=a.classList;if(a!==e&&i.contains("active"))return i.remove("active"),!0}}(r),r.getElementsByTagName("ul").length>0);if(!a(r)&&l||i.setup.menu.classList.toggle("active"),!s||!l)for(;n.length;){var d=n.pop(),c=d!==r;a(d)?l||d.classList.remove("active"):c&&d.classList.remove("active")}n.push(r),l&&r.classList.toggle("active")}}(d))):p.addEventListener("click",function(e,t){return function(a){a.preventDefault();var r=[a,t];if(("draw"==t.action||"PRINT"==t.format||"UNDEFINED"!=t.format&&t.capture)&&!i.drawing.enabled&&(!isNaN(t.delay)||!isNaN(i.config.delay)))return t.delay=isNaN(t.delay)?i.config.delay:t.delay,void i.delay(t,e);e.apply(i,r)}}(d.click||function(e){e.preventDefault()},d)),c.appendChild(p),i.isElement(d.label)?u.appendChild(d.label):u.innerHTML=d.label,d.class&&(c.className=d.class),d.style&&c.setAttribute("style",d.style),d.icon&&(f.setAttribute("src",(d.ignore||-1!=d.icon.slice(0,10).indexOf("//")?"":e.pathToImages)+d.icon),p.appendChild(f)),d.label&&p.appendChild(u),d.title&&p.setAttribute("title",d.title),i.config.menuReviver&&(c=i.config.menuReviver.apply(i,[d,c])),d.elements={li:c,a:p,img:f,span:u},(d.menu||d.items)&&"draw"!=d.action?r(d.menu||d.items,c).childNodes.length&&l.appendChild(c):l.appendChild(c))}}return l.childNodes.length&&a.appendChild(l),l}var n=[];return a||("string"==typeof i.config.divId?i.config.divId=a=document.getElementById(i.config.divId):a=i.isElement(i.config.divId)?i.config.divId:i.setup.chart.containerDiv),i.isElement(i.setup.menu)?i.setup.menu.innerHTML="":i.setup.menu=document.createElement("div"),i.setup.menu.setAttribute("class",i.setup.chart.classNamePrefix+"-export-menu "+i.setup.chart.classNamePrefix+"-export-menu-"+i.config.position+" amExportButton"),i.config.menuWalker&&(r=i.config.menuWalker),r.apply(this,[t,i.setup.menu]),i.setup.menu.childNodes.length&&a.appendChild(i.setup.menu),i.setup.menu},delay:function(e,t){var a,r,n=i.deepMerge({delay:3,precision:2},e||{}),o=Number(new Date),s=i.createMenu([{label:i.i18l("capturing.delayed.menu.label").replace("{{duration}}",AmCharts.toFixed(n.delay,n.precision)),title:i.i18l("capturing.delayed.menu.title"),class:"export-delayed-capturing",click:function(){clearTimeout(a),clearTimeout(r),i.createMenu(i.config.menu)}}]).getElementsByTagName("a")[0];a=setInterval(function(){var e=n.delay-(Number(new Date)-o)/1e3;e<=0?(clearTimeout(a),"draw"!=n.action&&i.createMenu(i.config.menu)):s&&(s.innerHTML=i.i18l("capturing.delayed.menu.label").replace("{{duration}}",AmCharts.toFixed(e,2)))},AmCharts.updateRate),r=setTimeout(function(){t.apply(i,arguments)},1e3*n.delay)},migrateSetup:function(e){function t(e){var i;for(i in e){var r=e[i];"export"==i.slice(0,6)&&r?a.menu.push(i.slice(6)):"userCFG"==i?t(r):"menuItems"==i?a.menu=r:"libs"==i?a.libs=r:"string"==typeof i&&(a[i]=r)}}var a={enabled:!0,migrated:!0,libs:{autoLoad:!0},menu:[]};return t(e),a},clear:function(){var e,t;for(void 0!==i.setup.fabric&&i.setup.fabric.removeListeners(),e=0;e<i.listenersToRemove.length;e++)(t=i.listenersToRemove[e]).node.removeEventListener(t.event,t.method);i.isElement(i.setup.wrapper)&&i.isElement(i.setup.wrapper.parentNode)&&i.setup.wrapper.parentNode.removeChild&&i.setup.wrapper.parentNode.removeChild(i.setup.wrapper),i.isElement(i.setup.menu)&&i.isElement(i.setup.wrapper.parentNode)&&i.setup.wrapper.parentNode.removeChild&&i.setup.menu.parentNode.removeChild(i.setup.menu),i.listenersToRemove=[],i.setup.chart.AmExport=void 0,i.setup.chart.export=void 0,i.setup=void 0},loadListeners:function(){function e(e){e&&(e.set({top:e.top+10,left:e.left+10}),i.setup.fabric.add(e))}i.config.keyListener&&"attached"!=i.config.keyListener&&(i.docListener=function(t){function a(e,t){for(i1=0;i1<e.length;i1++){var a=e[i1];a.parentNode.classList.remove("active"),0!=i1||t||a.focus()}}function r(e){i.setup.focusedMenuItem&&i.setup.focusedMenuItem.nextSibling&&(i.setup.focusedMenuItem.parentNode.classList.add("active"),a(i.setup.focusedMenuItem.nextSibling.getElementsByTagName("a"),e))}function n(e){i.setup.focusedMenuItem&&i.setup.focusedMenuItem.parentNode.parentNode.parentNode&&(i.setup.focusedMenuItem.parentNode.classList.add("active"),a(i.setup.focusedMenuItem.parentNode.parentNode.parentNode.getElementsByTagName("a"),e))}var o=i.drawing.buffer.target,s=[37,38,39,40,13,9,27],l=(["top-left","bottom-left"].indexOf(i.config.position),-1!=["top-right","bottom-right"].indexOf(i.config.position));if(i.setup.focusedMenuItem&&-1!=s.indexOf(t.keyCode)){if(9==t.keyCode)return void(i.setup.focusedMenuItem.nextSibling?t.shiftKey&&i.setup.focusedMenuItem.parentNode.classList.remove("active"):(i.setup.focusedMenuItem.parentNode.classList.remove("active"),i.setup.focusedMenuItem.parentNode.nextSibling||(i.setup.focusedMenuItem.parentNode.classList.remove("active"),i.setup.focusedMenuItem.parentNode.parentNode.parentNode.classList.remove("active"))));13==t.keyCode&&i.setup.focusedMenuItem.nextSibling&&r(),37==t.keyCode&&(l?r():n()),39==t.keyCode&&(l?n():r()),40==t.keyCode&&function(e){i.setup.focusedMenuItem&&i.setup.focusedMenuItem.parentNode.nextSibling&&(i.setup.focusedMenuItem.parentNode.classList.remove("active"),a(i.setup.focusedMenuItem.parentNode.nextSibling.getElementsByTagName("a"),e))}(),38==t.keyCode&&function(e){i.setup.focusedMenuItem&&i.setup.focusedMenuItem.parentNode.previousSibling&&(i.setup.focusedMenuItem.parentNode.classList.remove("active"),a(i.setup.focusedMenuItem.parentNode.previousSibling.getElementsByTagName("a"),e))}(),27==t.keyCode&&function(){function e(t){if(i.isElement(t)){try{t.blur()}catch(e){}t.parentNode&&t.parentNode.classList.remove("active"),t.classList.contains("amExportButton")||e(t.parentNode)}}i.setup.focusedMenuItem&&(e(i.setup.focusedMenuItem),i.setup.focusedMenuItem=void 0)}()}8!=t.keyCode&&46!=t.keyCode||!o?27==t.keyCode&&i.drawing.enabled?(t.preventDefault(),i.drawing.buffer.isSelected?i.setup.fabric.discardActiveObject():i.drawing.handler.done()):67==t.keyCode&&(t.metaKey||t.ctrlKey)&&o?i.drawing.buffer.copy=o:88==t.keyCode&&(t.metaKey||t.ctrlKey)&&o?(i.drawing.buffer.copy=o,i.setup.fabric.remove(o)):86==t.keyCode&&(t.metaKey||t.ctrlKey)?i.drawing.buffer.copy&&e(i.drawing.buffer.copy.clone(e)):90==t.keyCode&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),t.shiftKey?i.drawing.handler.redo():i.drawing.handler.undo()):(t.preventDefault(),i.setup.fabric.remove(o))},i.config.keyListener="attached",document.addEventListener("keydown",i.docListener),i.addListenerToRemove("keydown",document,i.docListener)),i.config.fileListener&&(i.setup.chart.containerDiv.addEventListener("dragover",i.handleDropbox),i.addListenerToRemove("dragover",i.setup.chart.containerDiv,i.handleDropbox),i.setup.chart.containerDiv.addEventListener("dragleave",i.handleDropbox),i.addListenerToRemove("dragleave",i.setup.chart.containerDiv,i.handleDropbox),i.setup.chart.containerDiv.addEventListener("drop",i.handleDropbox),i.addListenerToRemove("drop",i.setup.chart.containerDiv,i.handleDropbox))},init:function(){clearTimeout(a),a=setInterval(function(){i.setup&&i.setup.chart.containerDiv&&(clearTimeout(a),i.config.enabled&&(i.setup.chart.AmExport=i,i.config.overflow&&(i.setup.chart.div.style.overflow="visible"),i.loadListeners(),i.createMenu(i.config.menu),i.handleReady(i.config.onReady)))},AmCharts.updateRate)},construct:function(){i.drawing.handler.cancel=i.drawing.handler.done;try{i.setup.hasBlob=!!new Blob}catch(e){}window.safari=window.safari?window.safari:{},i.defaults.fabric.drawing.fontSize=i.setup.chart.fontSize||11,i.config.drawing=i.deepMerge(i.defaults.fabric.drawing,i.config.drawing||{},!0),i.config.border&&(i.config.border=i.deepMerge(i.defaults.fabric.border,i.config.border||{},!0)),i.deepMerge(i.defaults.fabric,i.config,!0),i.deepMerge(i.defaults.fabric,i.config.fabric||{},!0),i.deepMerge(i.defaults.pdfMake,i.config,!0),i.deepMerge(i.defaults.pdfMake,i.config.pdfMake||{},!0),i.deepMerge(i.libs,i.config.libs||{},!0),i.config.drawing=i.defaults.fabric.drawing,i.config.fabric=i.defaults.fabric,i.config.pdfMake=i.defaults.pdfMake,i.config=i.deepMerge(i.defaults,i.config,!0),i.config.fabric.drawing.enabled&&void 0===i.config.fabric.drawing.menu&&(i.config.fabric.drawing.menu=[],i.deepMerge(i.config.fabric.drawing.menu,[{class:"export-drawing",menu:[{label:i.i18l("menu.label.draw.add"),menu:[{label:i.i18l("menu.label.draw.shapes"),action:"draw.shapes"},{label:i.i18l("menu.label.draw.text"),action:"text"}]},{label:i.i18l("menu.label.draw.change"),menu:[{label:i.i18l("menu.label.draw.modes"),action:"draw.modes"},{label:i.i18l("menu.label.draw.colors"),action:"draw.colors"},{label:i.i18l("menu.label.draw.widths"),action:"draw.widths"},{label:i.i18l("menu.label.draw.opacities"),action:"draw.opacities"},"UNDO","REDO"]},{label:i.i18l("menu.label.save.image"),menu:["PNG","JPG","SVG","PDF"]},"PRINT","CANCEL"]}])),void 0===i.config.menu&&(i.config.menu=[],i.deepMerge(i.config,{menu:[{class:"export-main",menu:[{label:i.i18l("menu.label.save.image"),menu:["PNG","JPG","SVG","PDF"]},{label:i.i18l("menu.label.save.data"),menu:["CSV","XLSX","JSON"]},{label:i.i18l("menu.label.draw"),action:"draw",menu:i.config.fabric.drawing.menu},{format:"PRINT",label:i.i18l("menu.label.print")}]}]})),i.libs.path||(i.libs.path=i.config.path+"libs/"),i.setup.hasClasslist||i.libs.resources.push("classList.js/classList.min.js"),i.isSupported()&&(i.loadDependencies(i.libs.resources,i.libs.reload),i.setup.chart.addClassNames=!0,i.setup.chart[i.name]=i,i.init())}};if(t)i.config=t;else if(i.setup.chart[i.name])i.config=i.setup.chart[i.name];else{if(!i.setup.chart.amExport&&!i.setup.chart.exportConfig)return;i.config=i.migrateSetup(i.setup.chart.amExport||i.setup.chart.exportConfig)}return i.construct(),i.deepMerge(this,i)},AmCharts.addInitHandler(function(e){new AmCharts.export(e)},["pie","serial","xy","funnel","radar","gauge","stock","map","gantt"]);
 
admin/js/amcharts/plugins/export/lang/cs.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "cs" ] = {
2
+ "fallback.save.text": "Stiskněte CTRL + C pro zkopírování dat do schránky.",
3
+ "fallback.save.image": "Klikněte pravým tlačítkem a zvolte Save picture as... k uložení obrázku.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Kliknutím zrušíte",
7
+
8
+ "menu.label.print": "Tisk",
9
+ "menu.label.undo": "Zpět",
10
+ "menu.label.redo": "Dopředu",
11
+ "menu.label.cancel": "Zrušit",
12
+
13
+ "menu.label.save.image": "Stáhnout obrázek ...",
14
+ "menu.label.save.data": "Stáhnout data ...",
15
+
16
+ "menu.label.draw": "Nakreslit ...",
17
+ "menu.label.draw.change": "Změnit ...",
18
+ "menu.label.draw.add": "Přidat ...",
19
+ "menu.label.draw.shapes": "Tvar ...",
20
+ "menu.label.draw.colors": "Barva ...",
21
+ "menu.label.draw.widths": "Velikost ...",
22
+ "menu.label.draw.opacities": "Průhlednost ...",
23
+ "menu.label.draw.text": "Text",
24
+
25
+ "menu.label.draw.modes": "Režim kreslení ...",
26
+ "menu.label.draw.modes.pencil": "Tužka",
27
+ "menu.label.draw.modes.line": "Čára",
28
+ "menu.label.draw.modes.arrow": "Šipka",
29
+
30
+ "label.saved.from": "Uloženo ze stránky: "
31
+ }
admin/js/amcharts/plugins/export/lang/de.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "de" ] = {
2
+ "fallback.save.text": "CTRL + C um die Daten in die Zwischenablage zu kopieren.",
3
+ "fallback.save.image": "Rechtsklick -> Bild speichern unter... um das Bild zu speichern.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Klicken zum Abbrechen.",
7
+
8
+ "menu.label.print": "Drucken",
9
+ "menu.label.undo": "Rückgängig",
10
+ "menu.label.redo": "Wiederherstellen",
11
+ "menu.label.cancel": "Abbrechen",
12
+
13
+ "menu.label.save.image": "Herunterladen als ...",
14
+ "menu.label.save.data": "Speichern als ...",
15
+
16
+ "menu.label.draw": "Notieren ...",
17
+ "menu.label.draw.change": "Ändern ...",
18
+ "menu.label.draw.add": "Hinzufügen ...",
19
+ "menu.label.draw.shapes": "Form ...",
20
+ "menu.label.draw.colors": "Farbe ...",
21
+ "menu.label.draw.widths": "Größe ...",
22
+ "menu.label.draw.opacities": "Deckkraft ...",
23
+ "menu.label.draw.text": "Text",
24
+
25
+ "menu.label.draw.modes": "Modus...",
26
+ "menu.label.draw.modes.pencil": "Stift",
27
+ "menu.label.draw.modes.line": "Linie",
28
+ "menu.label.draw.modes.arrow": "Pfeil",
29
+
30
+ "label.saved.from": "Gespeichert von: "
31
+ }
admin/js/amcharts/plugins/export/lang/en.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "en" ] = {
2
+ "fallback.save.text": "CTRL + C to copy the data into the clipboard.",
3
+ "fallback.save.image": "Rightclick -> Save picture as... to save the image.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Click to cancel",
7
+
8
+ "menu.label.print": "Print",
9
+ "menu.label.undo": "Undo",
10
+ "menu.label.redo": "Redo",
11
+ "menu.label.cancel": "Cancel",
12
+
13
+ "menu.label.save.image": "Download as ...",
14
+ "menu.label.save.data": "Save as ...",
15
+
16
+ "menu.label.draw": "Annotate ...",
17
+ "menu.label.draw.change": "Change ...",
18
+ "menu.label.draw.add": "Add ...",
19
+ "menu.label.draw.shapes": "Shape ...",
20
+ "menu.label.draw.colors": "Color ...",
21
+ "menu.label.draw.widths": "Size ...",
22
+ "menu.label.draw.opacities": "Opacity ...",
23
+ "menu.label.draw.text": "Text",
24
+
25
+ "menu.label.draw.modes": "Mode ...",
26
+ "menu.label.draw.modes.pencil": "Pencil",
27
+ "menu.label.draw.modes.line": "Line",
28
+ "menu.label.draw.modes.arrow": "Arrow",
29
+
30
+ "label.saved.from": "Saved from: "
31
+ }
admin/js/amcharts/plugins/export/lang/es.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "es" ] = {
2
+ "fallback.save.text": "CTRL + C para copiar datos en el portapapeles.",
3
+ "fallback.save.image": "Botón derecho -> Guardar imagen como... para guardar la imagen.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Click para cancelar",
7
+
8
+ "menu.label.print": "Imprimir",
9
+ "menu.label.undo": "Deshacer",
10
+ "menu.label.redo": "Rehacer",
11
+ "menu.label.cancel": "Cancelar",
12
+
13
+ "menu.label.save.image": "Descargar como ...",
14
+ "menu.label.save.data": "Guardar como ...",
15
+
16
+ "menu.label.draw": "Anotar ...",
17
+ "menu.label.draw.change": "Cambiar ...",
18
+ "menu.label.draw.add": "Añadir ...",
19
+ "menu.label.draw.shapes": "Forma ...",
20
+ "menu.label.draw.colors": "Color ...",
21
+ "menu.label.draw.widths": "Tamaño ...",
22
+ "menu.label.draw.opacities": "Opacidad ...",
23
+ "menu.label.draw.text": "Texto",
24
+
25
+ "menu.label.draw.modes": "Modo ...",
26
+ "menu.label.draw.modes.pencil": "Lápiz",
27
+ "menu.label.draw.modes.line": "Linea",
28
+ "menu.label.draw.modes.arrow": "Flecha",
29
+
30
+ "label.saved.from": "Guardar desde: "
31
+ }
admin/js/amcharts/plugins/export/lang/fr.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "fr" ] = {
2
+ "fallback.save.text": "CTRL + C pour copier dans le presse-papier.",
3
+ "fallback.save.image": "Clic-droit -> Enregistrer sous... pour sauvegarder l'image.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Cliquez pour annuler",
7
+
8
+ "menu.label.print": "Imprimer",
9
+ "menu.label.undo": "Retour",
10
+ "menu.label.redo": "Refaire",
11
+ "menu.label.cancel": "Annuler",
12
+
13
+ "menu.label.save.image": "Téléchargez en ...",
14
+ "menu.label.save.data": "Sauvegarder en ...",
15
+
16
+ "menu.label.draw": "Annoter ...",
17
+ "menu.label.draw.change": "Changer le ...",
18
+ "menu.label.draw.add": "Ajouter ...",
19
+ "menu.label.draw.shapes": "Formes ...",
20
+ "menu.label.draw.colors": "Couleurs ...",
21
+ "menu.label.draw.widths": "Taille ...",
22
+ "menu.label.draw.opacities": "Opacité ...",
23
+ "menu.label.draw.text": "Texte",
24
+
25
+ "menu.label.draw.modes": "Mode ...",
26
+ "menu.label.draw.modes.pencil": "Crayon",
27
+ "menu.label.draw.modes.line": "Ligne",
28
+ "menu.label.draw.modes.arrow": "Flèche",
29
+
30
+ "label.saved.from": "Sauvé de la: "
31
+ }
admin/js/amcharts/plugins/export/lang/hu.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "hu" ] = {
2
+ "fallback.save.text": "CTRL + C az adatok vágólapra történő másolásához.",
3
+ "fallback.save.image": "Jobb egérgomb -> Save picture as... a kép mentéséhez.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Kattints a megszakításhoz",
7
+
8
+ "menu.label.print": "Nyomtatás",
9
+ "menu.label.undo": "Visszavon",
10
+ "menu.label.redo": "Mégis",
11
+ "menu.label.cancel": "Mégse",
12
+
13
+ "menu.label.save.image": "Kép mentése ...",
14
+ "menu.label.save.data": "Mentés másként ...",
15
+
16
+ "menu.label.draw": "Jegyzet ...",
17
+ "menu.label.draw.change": "Módosítás ...",
18
+ "menu.label.draw.add": "Hozzáadás ...",
19
+ "menu.label.draw.shapes": "Alakzat ...",
20
+ "menu.label.draw.colors": "Szín ...",
21
+ "menu.label.draw.widths": "Méret ...",
22
+ "menu.label.draw.opacities": "Átlátszóság ...",
23
+ "menu.label.draw.text": "Szöveg",
24
+
25
+ "menu.label.draw.modes": "Mód ...",
26
+ "menu.label.draw.modes.pencil": "Toll",
27
+ "menu.label.draw.modes.line": "Vonal",
28
+ "menu.label.draw.modes.arrow": "Nyíl",
29
+
30
+ "label.saved.from": "Mentve innen: "
31
+ }
admin/js/amcharts/plugins/export/lang/it.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "it" ] = {
2
+ "fallback.save.text": "CTRL + C per copiare negli appunti.",
3
+ "fallback.save.image": "Tasto destro -> Salva immagine come... per salvare come immagine.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Clicca per annullare",
7
+
8
+ "menu.label.print": "Stampa",
9
+ "menu.label.undo": "Indietro",
10
+ "menu.label.redo": "Avanti",
11
+ "menu.label.cancel": "Annulla",
12
+
13
+ "menu.label.save.image": "Download come ...",
14
+ "menu.label.save.data": "Salva come ...",
15
+
16
+ "menu.label.draw": "Annota ...",
17
+ "menu.label.draw.change": "Modifica ...",
18
+ "menu.label.draw.add": "Aggiungi ...",
19
+ "menu.label.draw.shapes": "Forma ...",
20
+ "menu.label.draw.colors": "Colore ...",
21
+ "menu.label.draw.widths": "Dimensione ...",
22
+ "menu.label.draw.opacities": "Opacità ...",
23
+ "menu.label.draw.text": "Testo",
24
+
25
+ "menu.label.draw.modes": "Modalità ...",
26
+ "menu.label.draw.modes.pencil": "Matita",
27
+ "menu.label.draw.modes.line": "Linea",
28
+ "menu.label.draw.modes.arrow": "Freccia",
29
+
30
+ "label.saved.from": "Salvato da: "
31
+ }
admin/js/amcharts/plugins/export/lang/ko.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "ko" ] = {
2
+ "fallback.save.text": "CTRL + C 를 눌러 클립보드로 데이터를 복사합니다.",
3
+ "fallback.save.image": "마우스 오른쪽 클릭 -> 다른 이름으로 저장... 으로 이미지를 저장합니다.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "취소하려면 클릭",
7
+
8
+ "menu.label.print": "출력",
9
+ "menu.label.undo": "실행 취소",
10
+ "menu.label.redo": "다시 실행",
11
+ "menu.label.cancel": "취소",
12
+
13
+ "menu.label.save.image": "다운로드 ...",
14
+ "menu.label.save.data": "데이터로 저장 ...",
15
+
16
+ "menu.label.draw": "그리기",
17
+ "menu.label.draw.change": "바꾸기 ...",
18
+ "menu.label.draw.add": "삽입하기 ...",
19
+ "menu.label.draw.shapes": "모양 ...",
20
+ "menu.label.draw.colors": "색 변경 ...",
21
+ "menu.label.draw.widths": "크기 변경 ...",
22
+ "menu.label.draw.opacities": "투명도 변경 ...",
23
+ "menu.label.draw.text": "텍스트",
24
+
25
+ "menu.label.draw.modes": "모드 변경 ...",
26
+ "menu.label.draw.modes.pencil": "펜",
27
+ "menu.label.draw.modes.line": "선",
28
+ "menu.label.draw.modes.arrow": "화살표",
29
+
30
+ "label.saved.from": "에서 저장: "
31
+ }
admin/js/amcharts/plugins/export/lang/lt.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "lt" ] = {
2
+ "fallback.save.text": "Spauskite CTRL + C jei norite nukopijuoti paveiksliuką.",
3
+ "fallback.save.image": "Spragtelkite dešinį klavišą ir pasirinkite \"Save picture as...\" jei norite išsaugoti paveiksliuką.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Nutraukti",
7
+
8
+ "menu.label.print": "Spausdinti",
9
+ "menu.label.undo": "Atšaukti",
10
+ "menu.label.redo": "Pakartoti",
11
+ "menu.label.cancel": "Nutraukti",
12
+
13
+ "menu.label.save.image": "Atsisiųsti ...",
14
+ "menu.label.save.data": "Išsaugoti ...",
15
+
16
+ "menu.label.draw": "Anotuoti ...",
17
+ "menu.label.draw.change": "Keisti ...",
18
+ "menu.label.draw.add": "Pridėti ...",
19
+ "menu.label.draw.shapes": "Ikonėlę ...",
20
+ "menu.label.draw.colors": "Spalvą ...",
21
+ "menu.label.draw.widths": "Teptuką ...",
22
+ "menu.label.draw.opacities": "Nepermatomumas ...",
23
+ "menu.label.draw.text": "Tekstą",
24
+
25
+ "menu.label.draw.modes": "Režimas ...",
26
+ "menu.label.draw.modes.pencil": "Tekstą",
27
+ "menu.label.draw.modes.line": "Linija",
28
+ "menu.label.draw.modes.arrow": "Rodyklė",
29
+
30
+ "label.saved.from": "Išsaugoti nuo: "
31
+ }
admin/js/amcharts/plugins/export/lang/pl.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "pl" ] = {
2
+ "fallback.save.text": "Naciśnij CTRL + C by skopiować dane do schowka.",
3
+ "fallback.save.image": "Prawy przycisk myszy -> Zapisz obrazek jako... by zapisać obrazek.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "Kliknij by anulować",
7
+
8
+ "menu.label.print": "Drukuj",
9
+ "menu.label.undo": "Cofnij",
10
+ "menu.label.redo": "Przywróć",
11
+ "menu.label.cancel": "Anuluj",
12
+
13
+ "menu.label.save.image": "Pobierz jako ...",
14
+ "menu.label.save.data": "Zapisz jako ...",
15
+
16
+ "menu.label.draw": "Rysuj ...",
17
+ "menu.label.draw.change": "Zmień ...",
18
+ "menu.label.draw.add": "Dodaj ...",
19
+ "menu.label.draw.shapes": "Kształt ...",
20
+ "menu.label.draw.colors": "Kolor ...",
21
+ "menu.label.draw.widths": "Rozmiar ...",
22
+ "menu.label.draw.opacities": "Przeźroczystość ...",
23
+ "menu.label.draw.text": "Tekst",
24
+
25
+ "menu.label.draw.modes": "Tryb ...",
26
+ "menu.label.draw.modes.pencil": "Ołówek",
27
+ "menu.label.draw.modes.line": "Linia",
28
+ "menu.label.draw.modes.arrow": "Strzałka",
29
+
30
+ "label.saved.from": "Ocalić od: "
31
+ }
admin/js/amcharts/plugins/export/lang/pt.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ ** Versão em Português
3
+ ** Traduzido por Élton Reisdorfer
4
+ ** WebSite: http://eltonrst.tk
5
+ ** Facebook : http://facebook.com/elton.reisdorfer
6
+ */
7
+ AmCharts.translations["export"]["pt"] = {
8
+ "fallback.save.text": "CTRL + C para copiar os dados para a área de transferência.",
9
+ "fallback.save.image": "Clique Direito -> Salvar imagem como... para salvar a imagem.",
10
+
11
+ "capturing.delayed.menu.label": "{{duration}}",
12
+ "capturing.delayed.menu.title": "Clique para cancelar",
13
+
14
+ "menu.label.print": "Imprimir",
15
+ "menu.label.undo": "Desfazer",
16
+ "menu.label.redo": "Refazer",
17
+ "menu.label.cancel": "Cancelar",
18
+
19
+ "menu.label.save.image": "Baixar Como",
20
+ "menu.label.save.data": "Salvar Como",
21
+
22
+ "menu.label.draw": "Editar",
23
+ "menu.label.draw.change": "Alterar",
24
+ "menu.label.draw.add": "Adicionar",
25
+ "menu.label.draw.shapes": "Forma",
26
+ "menu.label.draw.colors": "Cor",
27
+ "menu.label.draw.widths": "Tamanho",
28
+ "menu.label.draw.opacities": "Tranparência",
29
+ "menu.label.draw.text": "Texto",
30
+
31
+ "menu.label.draw.modes": "Ferramenta",
32
+ "menu.label.draw.modes.pencil": "Pincel",
33
+ "menu.label.draw.modes.line": "Linha",
34
+ "menu.label.draw.modes.arrow": "Seta",
35
+
36
+ "label.saved.from": "Salvar de: "
37
+ }
admin/js/amcharts/plugins/export/lang/tr.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "tr" ] = {
2
+ "fallback.save.text": "CTRL + C panoya veriyi kopyalamak için.",
3
+ "fallback.save.image": "Sağ tıkla -> Resim olarak kaydet... resim olarak kaydemek için.",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "İptal etmek için tıkla",
7
+
8
+ "menu.label.print": "Yazdır",
9
+ "menu.label.undo": "Geri al",
10
+ "menu.label.redo": "Yenile",
11
+ "menu.label.cancel": "İptal",
12
+
13
+ "menu.label.save.image": "Farklı kaydet ...",
14
+ "menu.label.save.data": "Farklı kaydet ...",
15
+
16
+ "menu.label.draw": "Açıklama ekle ...",
17
+ "menu.label.draw.change": "Düzenle ...",
18
+ "menu.label.draw.add": "Ekle ...",
19
+ "menu.label.draw.shapes": "Şekil ...",
20
+ "menu.label.draw.colors": "Renk ...",
21
+ "menu.label.draw.widths": "Boyut ...",
22
+ "menu.label.draw.opacities": "Saydamlık ...",
23
+ "menu.label.draw.text": "Yazı",
24
+
25
+ "menu.label.draw.modes": "Mod ...",
26
+ "menu.label.draw.modes.pencil": "Kalem",
27
+ "menu.label.draw.modes.line": "Çizgi",
28
+ "menu.label.draw.modes.arrow": "Ok işareti",
29
+
30
+ "label.saved.from": "Kayıt edildi: "
31
+ }
admin/js/amcharts/plugins/export/lang/zh.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AmCharts.translations[ "export" ][ "zh" ] = {
2
+ "fallback.save.text": "CTRL + C 复制数据到剪贴板。",
3
+ "fallback.save.image": "Rightclick -> 保存图片为... 保存图片。",
4
+
5
+ "capturing.delayed.menu.label": "{{duration}}",
6
+ "capturing.delayed.menu.title": "点击以取消",
7
+
8
+ "menu.label.print": "打印",
9
+ "menu.label.undo": "撤销",
10
+ "menu.label.redo": "重做",
11
+ "menu.label.cancel": "取消",
12
+
13
+ "menu.label.save.image": "下载为 ...",
14
+ "menu.label.save.data": "保存为 ...",
15
+
16
+ "menu.label.draw": "注释 ...",
17
+ "menu.label.draw.change": "修改 ...",
18
+ "menu.label.draw.add": "添加 ...",
19
+ "menu.label.draw.shapes": "形状 ...",
20
+ "menu.label.draw.colors": "颜色 ...",
21
+ "menu.label.draw.widths": "大小 ...",
22
+ "menu.label.draw.opacities": "不透明度 ...",
23
+ "menu.label.draw.text": "文字",
24
+
25
+ "menu.label.draw.modes": "模式 ...",
26
+ "menu.label.draw.modes.pencil": "铅笔",
27
+ "menu.label.draw.modes.line": "线",
28
+ "menu.label.draw.modes.arrow": "箭头",
29
+
30
+ "label.saved.from": "保存自: "
31
+ }
admin/js/amcharts/plugins/export/libs/classList.js/classList.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
2
+ "document"in self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||!function(t){"use strict";if("Element"in t){var e="classList",n="prototype",i=t.Element[n],s=Object,r=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,"")},o=Array[n].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},a=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},c=function(t,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return o.call(t,e)},l=function(t){for(var e=r.call(t.getAttribute("class")||""),n=e?e.split(/\s+/):[],i=0,s=n.length;s>i;i++)this.push(n[i]);this._updateClassName=function(){t.setAttribute("class",""+this)}},u=l[n]=[],h=function(){return new l(this)};if(a[n]=Error[n],u.item=function(t){return this[t]||null},u.contains=function(t){return t+="",-1!==c(this,t)},u.add=function(){var t,e=arguments,n=0,i=e.length,s=!1;do t=e[n]+"",-1===c(this,t)&&(this.push(t),s=!0);while(++n<i);s&&this._updateClassName()},u.remove=function(){var t,e,n=arguments,i=0,s=n.length,r=!1;do for(t=n[i]+"",e=c(this,t);-1!==e;)this.splice(e,1),r=!0,e=c(this,t);while(++i<s);r&&this._updateClassName()},u.toggle=function(t,e){t+="";var n=this.contains(t),i=n?e!==!0&&"remove":e!==!1&&"add";return i&&this[i](t),e===!0||e===!1?e:!n},u.toString=function(){return this.join(" ")},s.defineProperty){var f={get:h,enumerable:!0,configurable:!0};try{s.defineProperty(i,e,f)}catch(g){(void 0===g.number||-2146823252===g.number)&&(f.enumerable=!1,s.defineProperty(i,e,f))}}else s[n].__defineGetter__&&i.__defineGetter__(e,h)}}(self),function(){"use strict";var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var n,i=arguments.length;for(n=0;i>n;n++)t=arguments[n],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:n.call(this,t)}}t=null}());
admin/js/amcharts/plugins/export/libs/fabric.js/fabric.min.js CHANGED
@@ -1,8 +1 @@
1
- var fabric=fabric||{version:"1.6.2"};"undefined"!=typeof exports&&(exports.fabric=fabric),"undefined"!=typeof document&&"undefined"!=typeof window?(fabric.document=document,fabric.window=window,window.fabric=fabric):(fabric.document=require("jsdom").jsdom("<!DOCTYPE html><html><head></head><body></body></html>"),fabric.document.createWindow?fabric.window=fabric.document.createWindow():fabric.window=fabric.document.parentWindow),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,fabric.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id"],fabric.DPI=96,fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)",fabric.fontPaths={},fabric.devicePixelRatio=fabric.window.devicePixelRatio||fabric.window.webkitDevicePixelRatio||fabric.window.mozDevicePixelRatio||1,function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:fabric.util.array.fill(i,!1)}}function e(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this}function i(e,i){if(this.__eventListeners){if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var r in e)t.call(this,r,e[r]);else t.call(this,e,i);return this}}function r(t,e){if(this.__eventListeners){var i=this.__eventListeners[t];if(i){for(var r=0,n=i.length;n>r;r++)i[r]&&i[r].call(this,e||{});return this.__eventListeners[t]=i.filter(function(t){return t!==!1}),this}}}fabric.Observable={observe:e,stopObserving:i,fire:r,on:e,off:i,trigger:r}}(),fabric.Collection={add:function(){this._objects.push.apply(this._objects,arguments);for(var t=0,e=arguments.length;e>t;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.renderAll(),this},insertAt:function(t,e,i){var r=this.getObjects();return i?r[e]=t:r.splice(e,0,t),this._onObjectAdded(t),this.renderOnAddRemove&&this.renderAll(),this},remove:function(){for(var t,e=this.getObjects(),i=0,r=arguments.length;r>i;i++)t=e.indexOf(arguments[i]),-1!==t&&(e.splice(t,1),this._onObjectRemoved(arguments[i]));return this.renderOnAddRemove&&this.renderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),r=i.length;r--;)t.call(e,i[r],r,i);return this},getObjects:function(t){return"undefined"==typeof t?this._objects:this._objects.filter(function(e){return e.type===t})},item:function(t){return this.getObjects()[t]},isEmpty:function(){return 0===this.getObjects().length},size:function(){return this.getObjects().length},contains:function(t){return this.getObjects().indexOf(t)>-1},complexity:function(){return this.getObjects().reduce(function(t,e){return t+=e.complexity?e.complexity():0},0)}},function(t){var e=Math.sqrt,i=Math.atan2,r=Math.pow,n=Math.abs,s=Math.PI/180;fabric.util={removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*s},radiansToDegrees:function(t){return t/s},rotatePoint:function(t,e,i){t.subtractEquals(e);var r=fabric.util.rotateVector(t,i);return new fabric.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=Math.sin(e),r=Math.cos(e),n=t.x*r-t.y*i,s=t.x*i+t.y*r;return{x:n,y:s}},transformPoint:function(t,e,i){return i?new fabric.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new fabric.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t){var e=[t[0].x,t[1].x,t[2].x,t[3].x],i=fabric.util.array.min(e),r=fabric.util.array.max(e),n=Math.abs(i-r),s=[t[0].y,t[1].y,t[2].y,t[3].y],o=fabric.util.array.min(s),a=fabric.util.array.max(s),h=Math.abs(o-a);return{left:i,top:o,width:n,height:h}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],r=fabric.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-r.x,i[5]=-r.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),r=parseFloat(t);switch(e||(e=fabric.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return r*fabric.DPI/25.4;case"cm":return r*fabric.DPI/2.54;case"in":return r*fabric.DPI;case"pt":return r*fabric.DPI/72;case"pc":return r*fabric.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=fabric.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),fabric.util.resolveNamespace(e)[t]},resolveNamespace:function(e){if(!e)return fabric;for(var i=e.split("."),r=i.length,n=t||fabric.window,s=0;r>s;++s)n=n[i[s]];return n},loadImage:function(t,e,i,r){if(!t)return void(e&&e.call(i,t));var n=fabric.util.createImage();n.onload=function(){e&&e.call(i,n),n=n.onload=n.onerror=null},n.onerror=function(){fabric.log("Error loading "+n.src),e&&e.call(i,null,!0),n=n.onload=n.onerror=null},0!==t.indexOf("data")&&r&&(n.crossOrigin=r),n.src=t},enlivenObjects:function(t,e,i,r){function n(){++o===a&&e&&e(s)}t=t||[];var s=[],o=0,a=t.length;return a?void t.forEach(function(t,e){if(!t||!t.type)return void n();var o=fabric.util.getKlass(t.type,i);o.async?o.fromObject(t,function(i,o){o||(s[e]=i,r&&r(t,s[e])),n()}):(s[e]=o.fromObject(t),r&&r(t,s[e]),n())}):void(e&&e(s))},groupSVGElements:function(t,e,i){var r;return r=new fabric.PathGroup(t,e),"undefined"!=typeof i&&r.setSourcePath(i),r},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var r=0,n=i.length;n>r;r++)i[r]in t&&(e[i[r]]=t[i[r]])},drawDashedLine:function(t,r,n,s,o,a){var h=s-r,c=o-n,l=e(h*h+c*c),u=i(c,h),f=a.length,d=0,g=!0;for(t.save(),t.translate(r,n),t.moveTo(0,0),t.rotate(u),r=0;l>r;)r+=a[d++%f],r>l&&(r=l),t[g?"lineTo":"moveTo"](r,0),g=!g;t.restore()},createCanvasElement:function(t){return t||(t=fabric.document.createElement("canvas")),t.getContext||"undefined"==typeof G_vmlCanvasManager||G_vmlCanvasManager.initElement(t),t},createImage:function(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")},createAccessors:function(t){for(var e=t.prototype,i=e.stateProperties.length;i--;){var r=e.stateProperties[i],n=r.charAt(0).toUpperCase()+r.slice(1),s="set"+n,o="get"+n;e[o]||(e[o]=function(t){return new Function('return this.get("'+t+'")')}(r)),e[s]||(e[s]=function(t){return new Function("value",'return this.set("'+t+'", value)')}(r))}},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var n=i(t[1],t[0]),o=r(t[0],2)+r(t[1],2),a=e(o),h=(t[0]*t[3]-t[2]*t[1])/a,c=i(t[0]*t[2]+t[1]*t[3],o);return{angle:n/s,scaleX:a,scaleY:h,skewX:c/s,skewY:0,translateX:t[4],translateY:t[5]}},customTransformMatrix:function(t,e,i){var r=[1,0,n(Math.tan(i*s)),1],o=[n(t),0,0,n(e)];return fabric.util.multiplyTransformMatrices(o,r,!0)},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.setAngle(0)},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,r){r>0&&(e>r?e-=r:e=0,i>r?i-=r:i=0);for(var n=!0,s=t.getImageData(e,i,2*r||1,2*r||1),o=3,a=s.data.length;a>o;o+=4){var h=s.data[o];if(n=0>=h,n===!1)break}return s=null,n},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",r="Mid",n="Mid",s=t.split(" ");return s&&s.length&&(i=s.pop(),"meet"!==i&&"slice"!==i?(e=i,i="meet"):s.length&&(e=s.pop())),r="none"!==e?e.slice(1,4):"none",n="none"!==e?e.slice(5,8):"none",{meetOrSlice:i,alignX:r,alignY:n}}}}("undefined"!=typeof exports?exports:this),function(){function t(t,r,s,o,h,c,l){var u=a.call(arguments);if(n[u])return n[u];var f=Math.PI,d=l*f/180,g=Math.sin(d),p=Math.cos(d),v=0,b=0;s=Math.abs(s),o=Math.abs(o);var m=-p*t*.5-g*r*.5,y=-p*r*.5+g*t*.5,_=s*s,x=o*o,S=y*y,C=m*m,w=_*x-_*S-x*C,O=0;if(0>w){var T=Math.sqrt(1-w/(_*x));s*=T,o*=T}else O=(h===c?-1:1)*Math.sqrt(w/(_*S+x*C));var k=O*s*y/o,j=-O*o*m/s,A=p*k-g*j+.5*t,M=g*k+p*j+.5*r,P=i(1,0,(m-k)/s,(y-j)/o),L=i((m-k)/s,(y-j)/o,(-m-k)/s,(-y-j)/o);0===c&&L>0?L-=2*f:1===c&&0>L&&(L+=2*f);for(var D=Math.ceil(Math.abs(L/f*2)),E=[],I=L/D,R=8/3*Math.sin(I/4)*Math.sin(I/4)/Math.sin(I/2),B=P+I,F=0;D>F;F++)E[F]=e(P,B,p,g,s,o,A,M,R,v,b),v=E[F][4],b=E[F][5],P=B,B+=I;return n[u]=E,E}function e(t,e,i,r,n,o,h,c,l,u,f){var d=a.call(arguments);if(s[d])return s[d];var g=Math.cos(t),p=Math.sin(t),v=Math.cos(e),b=Math.sin(e),m=i*n*v-r*o*b+h,y=r*n*v+i*o*b+c,_=u+l*(-i*n*p-r*o*g),x=f+l*(-r*n*p+i*o*g),S=m+l*(i*n*b+r*o*v),C=y+l*(r*n*b-i*o*v);return s[d]=[_,x,S,C,m,y],s[d]}function i(t,e,i,r){var n=Math.atan2(e,t),s=Math.atan2(r,i);return s>=n?s-n:2*Math.PI-(n-s)}function r(t,e,i,r,n,s,h,c){var l=a.call(arguments);if(o[l])return o[l];var u,f,d,g,p,v,b,m,y=Math.sqrt,_=Math.min,x=Math.max,S=Math.abs,C=[],w=[[],[]];f=6*t-12*i+6*n,u=-3*t+9*i-9*n+3*h,d=3*i-3*t;for(var O=0;2>O;++O)if(O>0&&(f=6*e-12*r+6*s,u=-3*e+9*r-9*s+3*c,d=3*r-3*e),S(u)<1e-12){if(S(f)<1e-12)continue;g=-d/f,g>0&&1>g&&C.push(g)}else b=f*f-4*d*u,0>b||(m=y(b),p=(-f+m)/(2*u),p>0&&1>p&&C.push(p),v=(-f-m)/(2*u),v>0&&1>v&&C.push(v));for(var T,k,j,A=C.length,M=A;A--;)g=C[A],j=1-g,T=j*j*j*t+3*j*j*g*i+3*j*g*g*n+g*g*g*h,w[0][A]=T,k=j*j*j*e+3*j*j*g*r+3*j*g*g*s+g*g*g*c,w[1][A]=k;w[0][M]=t,w[1][M]=e,w[0][M+1]=h,w[1][M+1]=c;var P=[{x:_.apply(null,w[0]),y:_.apply(null,w[1])},{x:x.apply(null,w[0]),y:x.apply(null,w[1])}];return o[l]=P,P}var n={},s={},o={},a=Array.prototype.join;fabric.util.drawArc=function(e,i,r,n){for(var s=n[0],o=n[1],a=n[2],h=n[3],c=n[4],l=n[5],u=n[6],f=[[],[],[],[]],d=t(l-i,u-r,s,o,h,c,a),g=0,p=d.length;p>g;g++)f[g][0]=d[g][0]+i,f[g][1]=d[g][1]+r,f[g][2]=d[g][2]+i,f[g][3]=d[g][3]+r,f[g][4]=d[g][4]+i,f[g][5]=d[g][5]+r,e.bezierCurveTo.apply(e,f[g])},fabric.util.getBoundsOfArc=function(e,i,n,s,o,a,h,c,l){for(var u=0,f=0,d=[],g=[],p=t(c-e,l-i,n,s,a,h,o),v=[[],[]],b=0,m=p.length;m>b;b++)d=r(u,f,p[b][0],p[b][1],p[b][2],p[b][3],p[b][4],p[b][5]),v[0].x=d[0].x+e,v[0].y=d[0].y+i,v[1].x=d[1].x+e,v[1].y=d[1].y+i,g.push(v[0]),g.push(v[1]),u=p[b][4],f=p[b][5];return g},fabric.util.getBoundsOfCurve=r}(),function(){function t(t,e){for(var i=s.call(arguments,2),r=[],n=0,o=t.length;o>n;n++)r[n]=i.length?t[n][e].apply(t[n],i):t[n][e].call(t[n]);return r}function e(t,e){return n(t,e,function(t,e){return t>=e})}function i(t,e){return n(t,e,function(t,e){return e>t})}function r(t,e){for(var i=t.length;i--;)t[i]=e;return t}function n(t,e,i){if(t&&0!==t.length){var r=t.length-1,n=e?t[r][e]:t[r];if(e)for(;r--;)i(t[r][e],n)&&(n=t[r][e]);else for(;r--;)i(t[r],n)&&(n=t[r]);return n}}var s=Array.prototype.slice;Array.prototype.indexOf||(Array.prototype.indexOf=function(t){if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if(0===i)return-1;var r=0;if(arguments.length>0&&(r=Number(arguments[1]),r!==r?r=0:0!==r&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=i)return-1;for(var n=r>=0?r:Math.max(i-Math.abs(r),0);i>n;n++)if(n in e&&e[n]===t)return n;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){for(var i=0,r=this.length>>>0;r>i;i++)i in this&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){for(var i=[],r=0,n=this.length>>>0;n>r;r++)r in this&&(i[r]=t.call(e,this[r],r,this));return i}),Array.prototype.every||(Array.prototype.every=function(t,e){for(var i=0,r=this.length>>>0;r>i;i++)if(i in this&&!t.call(e,this[i],i,this))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(t,e){for(var i=0,r=this.length>>>0;r>i;i++)if(i in this&&t.call(e,this[i],i,this))return!0;return!1}),Array.prototype.filter||(Array.prototype.filter=function(t,e){for(var i,r=[],n=0,s=this.length>>>0;s>n;n++)n in this&&(i=this[n],t.call(e,i,n,this)&&r.push(i));return r}),Array.prototype.reduce||(Array.prototype.reduce=function(t){var e,i=this.length>>>0,r=0;if(arguments.length>1)e=arguments[1];else for(;;){if(r in this){e=this[r++];break}if(++r>=i)throw new TypeError}for(;i>r;r++)r in this&&(e=t.call(null,e,this[r],r,this));return e}),fabric.util.array={fill:r,invoke:t,min:i,max:e}}(),function(){function t(t,e){for(var i in e)t[i]=e[i];return t}function e(e){return t({},e)}fabric.util.object={extend:t,clone:e}}(),function(){function t(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})}function e(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())}function i(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:t,capitalize:e,escapeXml:i}}(),function(){var t=Array.prototype.slice,e=Function.prototype.apply,i=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var n,s=this,o=t.call(arguments,1);return n=o.length?function(){return e.call(s,this instanceof i?this:r,o.concat(t.call(arguments)))}:function(){return e.call(s,this instanceof i?this:r,arguments)},i.prototype=this.prototype,n.prototype=new i,n})}(),function(){function t(){}function e(t){var e=this.constructor.superclass.prototype[t];return arguments.length>1?e.apply(this,r.call(arguments,1)):e.call(this)}function i(){function i(){this.initialize.apply(this,arguments)}var s=null,a=r.call(arguments,0);"function"==typeof a[0]&&(s=a.shift()),i.superclass=s,i.subclasses=[],s&&(t.prototype=s.prototype,i.prototype=new t,s.subclasses.push(i));for(var h=0,c=a.length;c>h;h++)o(i,a[h],s);return i.prototype.initialize||(i.prototype.initialize=n),i.prototype.constructor=i,i.prototype.callSuper=e,i}var r=Array.prototype.slice,n=function(){},s=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),o=function(t,e,i){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&(e[r]+"").indexOf("callSuper")>-1?t.prototype[r]=function(t){return function(){var r=this.constructor.superclass;this.constructor.superclass=i;var n=e[t].apply(this,arguments);return this.constructor.superclass=r,"initialize"!==t?n:void 0}}(r):t.prototype[r]=e[r],s&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};fabric.util.createClass=i}(),function(){function t(t){var e,i,r=Array.prototype.slice.call(arguments,1),n=r.length;for(i=0;n>i;i++)if(e=typeof t[r[i]],!/^(?:function|object|unknown)$/.test(e))return!1;return!0}function e(t,e){return{handler:e,wrappedHandler:i(t,e)}}function i(t,e){return function(i){e.call(o(t),i||fabric.window.event)}}function r(t,e){return function(i){if(p[t]&&p[t][e])for(var r=p[t][e],n=0,s=r.length;s>n;n++)r[n].call(this,i||fabric.window.event)}}function n(t){t||(t=fabric.window.event);var e=t.target||(typeof t.srcElement!==h?t.srcElement:null),i=fabric.util.getScrollLeftTop(e);return{x:v(t)+i.left,y:b(t)+i.top}}function s(t,e,i){var r="touchend"===t.type?"changedTouches":"touches";return t[r]&&t[r][0]?t[r][0][e]-(t[r][0][e]-t[r][0][i])||t[i]:t[i]}var o,a,h="unknown",c=function(){var t=0;return function(e){return e.__uniqueID||(e.__uniqueID="uniqueID__"+t++)}}();!function(){var t={};o=function(e){return t[e]},a=function(e,i){t[e]=i}}();var l,u,f=t(fabric.document.documentElement,"addEventListener","removeEventListener")&&t(fabric.window,"addEventListener","removeEventListener"),d=t(fabric.document.documentElement,"attachEvent","detachEvent")&&t(fabric.window,"attachEvent","detachEvent"),g={},p={};f?(l=function(t,e,i){t.addEventListener(e,i,!1)},u=function(t,e,i){t.removeEventListener(e,i,!1)}):d?(l=function(t,i,r){var n=c(t);a(n,t),g[n]||(g[n]={}),g[n][i]||(g[n][i]=[]);var s=e(n,r);g[n][i].push(s),t.attachEvent("on"+i,s.wrappedHandler)},u=function(t,e,i){var r,n=c(t);if(g[n]&&g[n][e])for(var s=0,o=g[n][e].length;o>s;s++)r=g[n][e][s],r&&r.handler===i&&(t.detachEvent("on"+e,r.wrappedHandler),g[n][e][s]=null)}):(l=function(t,e,i){var n=c(t);if(p[n]||(p[n]={}),!p[n][e]){p[n][e]=[];var s=t["on"+e];s&&p[n][e].push(s),t["on"+e]=r(n,e)}p[n][e].push(i)},u=function(t,e,i){var r=c(t);if(p[r]&&p[r][e])for(var n=p[r][e],s=0,o=n.length;o>s;s++)n[s]===i&&n.splice(s,1)}),fabric.util.addListener=l,fabric.util.removeListener=u;var v=function(t){return typeof t.clientX!==h?t.clientX:0},b=function(t){return typeof t.clientY!==h?t.clientY:0};fabric.isTouchSupported&&(v=function(t){return s(t,"pageX","clientX")},b=function(t){return s(t,"pageY","clientY")}),fabric.util.getPointer=n,fabric.util.object.extend(fabric.util,fabric.Observable)}(),function(){function t(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?s(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var r in e)if("opacity"===r)s(t,e[r]);else{var n="float"===r||"cssFloat"===r?"undefined"==typeof i.styleFloat?"cssFloat":"styleFloat":r;i[n]=e[r]}return t}var e=fabric.document.createElement("div"),i="string"==typeof e.style.opacity,r="string"==typeof e.style.filter,n=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,s=function(t){return t};i?s=function(t,e){return t.style.opacity=e,t}:r&&(s=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),n.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(n,e)):i.filter+=" alpha(opacity="+100*e+")",t}),fabric.util.setStyle=t}(),function(){function t(t){return"string"==typeof t?fabric.document.getElementById(t):t}function e(t,e){var i=fabric.document.createElement(t);for(var r in e)"class"===r?i.className=e[r]:"for"===r?i.htmlFor=e[r]:i.setAttribute(r,e[r]);return i}function i(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)}function r(t,i,r){return"string"==typeof i&&(i=e(i,r)),t.parentNode&&t.parentNode.replaceChild(i,t),i.appendChild(t),i}function n(t){for(var e=0,i=0,r=fabric.document.documentElement,n=fabric.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&(t=t.parentNode||t.host,t===fabric.document?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==fabric.util.getElementStyle(t,"position")););return{left:e,top:i}}function s(t){var e,i,r=t&&t.ownerDocument,s={left:0,top:0},o={left:0,top:0},a={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return o;for(var h in a)o[a[h]]+=parseInt(l(t,h),10)||0;return e=r.documentElement,"undefined"!=typeof t.getBoundingClientRect&&(s=t.getBoundingClientRect()),i=n(t),{left:s.left+i.left-(e.clientLeft||0)+o.left,top:s.top+i.top-(e.clientTop||0)+o.top}}var o,a=Array.prototype.slice,h=function(t){return a.call(t,0)};try{o=h(fabric.document.childNodes)instanceof Array}catch(c){}o||(h=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e});var l;l=fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?function(t,e){var i=fabric.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},function(){function t(t){return"undefined"!=typeof t.onselectstart&&(t.onselectstart=fabric.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t}function e(t){return"undefined"!=typeof t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t}var i=fabric.document.documentElement.style,r="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=t,fabric.util.makeElementSelectable=e}(),function(){function t(t,e){var i=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),n=!0;r.onload=r.onreadystatechange=function(t){if(n){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;n=!1,e(t||fabric.window.event),r=r.onload=r.onreadystatechange=null}},r.src=t,i.appendChild(r)}fabric.util.getScript=t}(),fabric.util.getById=t,fabric.util.toArray=h,fabric.util.makeElement=e,fabric.util.addClass=i,fabric.util.wrapElement=r,fabric.util.getScrollLeftTop=n,fabric.util.getElementOffset=s,fabric.util.getElementStyle=l}(),function(){function t(t,e){return t+(/\?/.test(t)?"&":"?")+e}function e(){}function i(i,n){n||(n={});var s,o=n.method?n.method.toUpperCase():"GET",a=n.onComplete||function(){},h=r();return h.onreadystatechange=function(){4===h.readyState&&(a(h),h.onreadystatechange=e)},"GET"===o&&(s=null,"string"==typeof n.parameters&&(i=t(i,n.parameters))),h.open(o,i,!0),"POST"!==o&&"PUT"!==o||h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(s),h}var r=function(){for(var t=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],e=t.length;e--;)try{var i=t[e]();if(i)return t[e]}catch(r){}}();fabric.util.request=i}(),fabric.log=function(){},fabric.warn=function(){},"undefined"!=typeof console&&["log","warn"].forEach(function(t){"undefined"!=typeof console[t]&&"function"==typeof console[t].apply&&(fabric[t]=function(){return console[t].apply(console,arguments)})}),function(){function t(t){e(function(i){t||(t={});var r,n=i||+new Date,s=t.duration||500,o=n+s,a=t.onChange||function(){},h=t.abort||function(){return!1},c=t.easing||function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},l="startValue"in t?t.startValue:0,u="endValue"in t?t.endValue:100,f=t.byValue||u-l;t.onStart&&t.onStart(),function d(i){r=i||+new Date;var u=r>o?s:r-n;return h()?void(t.onComplete&&t.onComplete()):(a(c(u,l,f,s)),r>o?void(t.onComplete&&t.onComplete()):void e(d))}(n)})}function e(){return i.apply(fabric.window,arguments)}var i=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(t){fabric.window.setTimeout(t,1e3/60)};fabric.util.animate=t,fabric.util.requestAnimFrame=e}(),function(){function t(t,e,i,r){return t<Math.abs(e)?(t=e,r=i/4):r=0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:r}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e}function r(t,e,i,r){return t/=r/2,1>t?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}function n(t,e,i,r){return i*(t/=r)*t*t*t+e}function s(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e}function o(t,e,i,r){return t/=r/2,1>t?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}function a(t,e,i,r){return i*(t/=r)*t*t*t*t+e}function h(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e}function c(t,e,i,r){return t/=r/2,1>t?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}function l(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}function u(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e}function f(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e}function d(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e}function g(t,e,i,r){return t===r?e+i:i*(-Math.pow(2,-10*t/r)+1)+e}function p(t,e,i,r){return 0===t?e:t===r?e+i:(t/=r/2,1>t?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e)}function v(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e}function b(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e}function m(t,e,i,r){return t/=r/2,1>t?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}function y(i,r,n,s){var o=1.70158,a=0,h=n;if(0===i)return r;if(i/=s,1===i)return r+n;a||(a=.3*s);var c=t(h,n,a,o);return-e(c,i,s)+r}function _(e,i,r,n){var s=1.70158,o=0,a=r;if(0===e)return i;if(e/=n,1===e)return i+r;o||(o=.3*n);var h=t(a,r,o,s);return h.a*Math.pow(2,-10*e)*Math.sin((e*n-h.s)*(2*Math.PI)/h.p)+h.c+i}function x(i,r,n,s){var o=1.70158,a=0,h=n;if(0===i)return r;if(i/=s/2,2===i)return r+n;a||(a=s*(.3*1.5));var c=t(h,n,a,o);return 1>i?-.5*e(c,i,s)+r:c.a*Math.pow(2,-10*(i-=1))*Math.sin((i*s-c.s)*(2*Math.PI)/c.p)*.5+c.c+r}function S(t,e,i,r,n){return void 0===n&&(n=1.70158),i*(t/=r)*t*((n+1)*t-n)+e}function C(t,e,i,r,n){return void 0===n&&(n=1.70158),i*((t=t/r-1)*t*((n+1)*t+n)+1)+e}function w(t,e,i,r,n){return void 0===n&&(n=1.70158),t/=r/2,1>t?i/2*(t*t*(((n*=1.525)+1)*t-n))+e:i/2*((t-=2)*t*(((n*=1.525)+1)*t+n)+2)+e}function O(t,e,i,r){return i-T(r-t,0,i,r)+e}function T(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:2/2.75>t?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:2.5/2.75>t?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}function k(t,e,i,r){return r/2>t?.5*O(2*t,0,i,r)+e:.5*T(2*t-r,0,i,r)+.5*i+e}fabric.util.ease={easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return t/=r/2,1>t?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:i,easeInOutCubic:r,easeInQuart:n,easeOutQuart:s,easeInOutQuart:o,easeInQuint:a,easeOutQuint:h,easeInOutQuint:c,easeInSine:l,easeOutSine:u,easeInOutSine:f,easeInExpo:d,easeOutExpo:g,easeInOutExpo:p,easeInCirc:v,easeOutCirc:b,easeInOutCirc:m,easeInElastic:y,easeOutElastic:_,easeInOutElastic:x,easeInBack:S,easeOutBack:C,easeInOutBack:w,easeInBounce:O,easeOutBounce:T,easeInOutBounce:k}}(),function(t){"use strict";function e(t){return t in T?T[t]:t}function i(t,e,i,r){var n,s="[object Array]"===Object.prototype.toString.call(e);return"fill"!==t&&"stroke"!==t||"none"!==e?"strokeDashArray"===t?e=e.replace(/,/g," ").split(/\s+/).map(function(t){return parseFloat(t)}):"transformMatrix"===t?e=i&&i.transformMatrix?x(i.transformMatrix,p.parseTransformAttribute(e)):p.parseTransformAttribute(e):"visible"===t?(e="none"!==e&&"hidden"!==e,i&&i.visible===!1&&(e=!1)):"originX"===t?e="start"===e?"left":"end"===e?"right":"center":n=s?e.map(_):_(e,r):e="",!s&&isNaN(n)?e:n}function r(t){for(var e in k)if("undefined"!=typeof t[k[e]]&&""!==t[e]){if("undefined"==typeof t[e]){if(!p.Object.prototype[e])continue;t[e]=p.Object.prototype[e]}if(0!==t[e].indexOf("url(")){var i=new p.Color(t[e]);t[e]=i.setAlpha(y(i.getAlpha()*t[k[e]],2)).toRgba()}}return t}function n(t,r){var n,s;t.replace(/;\s*$/,"").split(";").forEach(function(t){var o=t.split(":");n=e(o[0].trim().toLowerCase()),s=i(n,o[1].trim()),r[n]=s})}function s(t,r){var n,s;for(var o in t)"undefined"!=typeof t[o]&&(n=e(o.toLowerCase()),s=i(n,t[o]),r[n]=s)}function o(t,e){var i={};for(var r in p.cssRules[e])if(a(t,r.split(" ")))for(var n in p.cssRules[e][r])i[n]=p.cssRules[e][r][n];return i}function a(t,e){var i,r=!0;return i=c(t,e.pop()),i&&e.length&&(r=h(t,e)),i&&r&&0===e.length}function h(t,e){for(var i,r=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)r&&(i=e.pop()),t=t.parentNode,r=c(t,i);return 0===e.length}function c(t,e){var i,r=t.nodeName,n=t.getAttribute("class"),s=t.getAttribute("id");if(i=new RegExp("^"+r,"i"),e=e.replace(i,""),s&&e.length&&(i=new RegExp("#"+s+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),n&&e.length){n=n.split(" ");for(var o=n.length;o--;)i=new RegExp("\\."+n[o]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")}return 0===e.length}function l(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var r,n,s=t.getElementsByTagName("*");for(n=0;n<s.length;n++)if(r=s[n],e===r.getAttribute("id"))return r}function u(t){for(var e=t.getElementsByTagName("use"),i=0;e.length&&i<e.length;){var r,n,s,o,a,h=e[i],c=h.getAttribute("xlink:href").substr(1),u=h.getAttribute("x")||0,d=h.getAttribute("y")||0,g=l(t,c).cloneNode(!0),p=(g.getAttribute("transform")||"")+" translate("+u+", "+d+")",v=e.length;if(f(g),/^svg$/i.test(g.nodeName)){var b=g.ownerDocument.createElement("g");for(s=0,o=g.attributes,a=o.length;a>s;s++)n=o.item(s),b.setAttribute(n.nodeName,n.nodeValue);for(;null!=g.firstChild;)b.appendChild(g.firstChild);g=b}for(s=0,o=h.attributes,a=o.length;a>s;s++)n=o.item(s),"x"!==n.nodeName&&"y"!==n.nodeName&&"xlink:href"!==n.nodeName&&("transform"===n.nodeName?p=n.nodeValue+" "+p:g.setAttribute(n.nodeName,n.nodeValue));g.setAttribute("transform",p),g.setAttribute("instantiated_by_use","1"),g.removeAttribute("id"),r=h.parentNode,r.replaceChild(g,h),e.length===v&&i++}}function f(t){var e,i,r,n,s=t.getAttribute("viewBox"),o=1,a=1,h=0,c=0,l=t.getAttribute("width"),u=t.getAttribute("height"),f=t.getAttribute("x")||0,d=t.getAttribute("y")||0,g=t.getAttribute("preserveAspectRatio")||"",v=!s||!C.test(t.tagName)||!(s=s.match(j)),b=!l||!u||"100%"===l||"100%"===u,m=v&&b,y={},x="";if(y.width=0,y.height=0,y.toBeParsed=m,m)return y;if(v)return y.width=_(l),y.height=_(u),y;if(h=-parseFloat(s[1]),c=-parseFloat(s[2]),e=parseFloat(s[3]),i=parseFloat(s[4]),b?(y.width=e,y.height=i):(y.width=_(l),y.height=_(u),o=y.width/e,a=y.height/i),g=p.util.parsePreserveAspectRatioAttribute(g),"none"!==g.alignX&&(a=o=o>a?a:o),1===o&&1===a&&0===h&&0===c&&0===f&&0===d)return y;if((f||d)&&(x=" translate("+_(f)+" "+_(d)+") "),r=x+" matrix("+o+" 0 0 "+a+" "+h*o+" "+c*a+") ","svg"===t.tagName){for(n=t.ownerDocument.createElement("g");null!=t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n)}else n=t,r=n.getAttribute("transform")+r;return n.setAttribute("transform",r),y}function d(t){var e=t.objects,i=t.options;return e=e.map(function(t){return p[b(t.type)].fromObject(t)}),{objects:e,options:i}}function g(t,e,i){e[i]&&e[i].toSVG&&t.push(' <pattern x="0" y="0" id="',i,'Pattern" ','width="',e[i].source.width,'" height="',e[i].source.height,'" patternUnits="userSpaceOnUse">\n',' <image x="0" y="0" ','width="',e[i].source.width,'" height="',e[i].source.height,'" xlink:href="',e[i].source.src,'"></image>\n </pattern>\n')}var p=t.fabric||(t.fabric={}),v=p.util.object.extend,b=p.util.string.capitalize,m=p.util.object.clone,y=p.util.toFixed,_=p.util.parseUnit,x=p.util.multiplyTransformMatrices,S=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/i,C=/^(symbol|image|marker|pattern|view|svg)$/i,w=/^(?:pattern|defs|symbol|metadata)$/i,O=/^(symbol|g|a|svg)$/i,T={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"originX"},k={stroke:"strokeOpacity",fill:"fillOpacity"};p.cssRules={},p.gradientDefs={},p.parseTransformAttribute=function(){function t(t,e){var i=e[0],r=3===e.length?e[1]:0,n=3===e.length?e[2]:0;t[0]=Math.cos(i),t[1]=Math.sin(i),t[2]=-Math.sin(i),t[3]=Math.cos(i),t[4]=r-(t[0]*r+t[2]*n),t[5]=n-(t[1]*r+t[3]*n)}function e(t,e){var i=e[0],r=2===e.length?e[1]:e[0];t[0]=i,t[3]=r}function i(t,e){t[2]=Math.tan(p.util.degreesToRadians(e[0]))}function r(t,e){t[1]=Math.tan(p.util.degreesToRadians(e[0]))}function n(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}var s=[1,0,0,1,0,0],o=p.reNum,a="(?:\\s+,?\\s*|,\\s*)",h="(?:(skewX)\\s*\\(\\s*("+o+")\\s*\\))",c="(?:(skewY)\\s*\\(\\s*("+o+")\\s*\\))",l="(?:(rotate)\\s*\\(\\s*("+o+")(?:"+a+"("+o+")"+a+"("+o+"))?\\s*\\))",u="(?:(scale)\\s*\\(\\s*("+o+")(?:"+a+"("+o+"))?\\s*\\))",f="(?:(translate)\\s*\\(\\s*("+o+")(?:"+a+"("+o+"))?\\s*\\))",d="(?:(matrix)\\s*\\(\\s*("+o+")"+a+"("+o+")"+a+"("+o+")"+a+"("+o+")"+a+"("+o+")"+a+"("+o+")\\s*\\))",g="(?:"+d+"|"+f+"|"+u+"|"+l+"|"+h+"|"+c+")",v="(?:"+g+"(?:"+a+"*"+g+")*)",b="^\\s*(?:"+v+"?)\\s*$",m=new RegExp(b),y=new RegExp(g,"g");
2
- return function(o){var a=s.concat(),h=[];if(!o||o&&!m.test(o))return a;o.replace(y,function(o){var c=new RegExp(g).exec(o).filter(function(t){return""!==t&&null!=t}),l=c[1],u=c.slice(2).map(parseFloat);switch(l){case"translate":n(a,u);break;case"rotate":u[0]=p.util.degreesToRadians(u[0]),t(a,u);break;case"scale":e(a,u);break;case"skewX":i(a,u);break;case"skewY":r(a,u);break;case"matrix":a=u}h.push(a.concat()),a=s.concat()});for(var c=h[0];h.length>1;)h.shift(),c=p.util.multiplyTransformMatrices(c,h[0]);return c}}();var j=new RegExp("^\\s*("+p.reNum+"+)\\s*,?\\s*("+p.reNum+"+)\\s*,?\\s*("+p.reNum+"+)\\s*,?\\s*("+p.reNum+"+)\\s*$");p.parseSVGDocument=function(){function t(t,e){for(;t&&(t=t.parentNode);)if(e.test(t.nodeName)&&!t.getAttribute("instantiated_by_use"))return!0;return!1}return function(e,i,r){if(e){u(e);var n=new Date,s=p.Object.__uid++,o=f(e),a=p.util.toArray(e.getElementsByTagName("*"));if(o.svgUid=s,0===a.length&&p.isLikelyNode){a=e.selectNodes('//*[name(.)!="svg"]');for(var h=[],c=0,l=a.length;l>c;c++)h[c]=a[c];a=h}var d=a.filter(function(e){return f(e),S.test(e.tagName)&&!t(e,w)});if(!d||d&&!d.length)return void(i&&i([],{}));p.gradientDefs[s]=p.getGradientDefs(e),p.cssRules[s]=p.getCSSRules(e),p.parseElements(d,function(t){p.documentParsingTime=new Date-n,i&&i(t,o)},m(o),r)}}}();var A={has:function(t,e){e(!1)},get:function(){},set:function(){}},M=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+p.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+p.reNum+"))?\\s+(.*)");v(p,{parseFontDeclaration:function(t,e){var i=t.match(M);if(i){var r=i[1],n=i[3],s=i[4],o=i[5],a=i[6];r&&(e.fontStyle=r),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),s&&(e.fontSize=_(s)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}},getGradientDefs:function(t){var e,i,r,n,s=t.getElementsByTagName("linearGradient"),o=t.getElementsByTagName("radialGradient"),a=0,h=[],c={},l={};for(h.length=s.length+o.length,i=s.length;i--;)h[a++]=s[i];for(i=o.length;i--;)h[a++]=o[i];for(;a--;)e=h[a],n=e.getAttribute("xlink:href"),r=e.getAttribute("id"),n&&(l[r]=n.substr(1)),c[r]=e;for(r in l){var u=c[l[r]].cloneNode(!0);for(e=c[r];u.firstChild;)e.appendChild(u.firstChild)}return c},parseAttributes:function(t,n,s){if(t){var a,h,c={};"undefined"==typeof s&&(s=t.getAttribute("svgUid")),t.parentNode&&O.test(t.parentNode.nodeName)&&(c=p.parseAttributes(t.parentNode,n,s)),h=c&&c.fontSize||t.getAttribute("font-size")||p.Text.DEFAULT_SVG_FONT_SIZE;var l=n.reduce(function(r,n){return a=t.getAttribute(n),a&&(n=e(n),a=i(n,a,c,h),r[n]=a),r},{});return l=v(l,v(o(t,s),p.parseStyleAttribute(t))),l.font&&p.parseFontDeclaration(l.font,l),r(v(c,l))}},parseElements:function(t,e,i,r){new p.ElementsParser(t,e,i,r).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?n(i,e):s(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;t=t.replace(/,/g," ").trim(),t=t.split(/\s+/);var e,i,r=[];for(e=0,i=t.length;i>e;e+=2)r.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return r},getCSSRules:function(t){for(var r,n=t.getElementsByTagName("style"),s={},o=0,a=n.length;a>o;o++){var h=n[o].textContent||n[o].text;h=h.replace(/\/\*[\s\S]*?\*\//g,""),""!==h.trim()&&(r=h.match(/[^{]*\{[\s\S]*?\}/g),r=r.map(function(t){return t.trim()}),r.forEach(function(t){for(var r=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),n={},o=r[2].trim(),a=o.replace(/;$/,"").split(/\s*;\s*/),h=0,c=a.length;c>h;h++){var l=a[h].split(/\s*:\s*/),u=e(l[0]),f=i(u,l[1],l[0]);n[u]=f}t=r[1],t.split(",").forEach(function(t){t=t.replace(/^svg/i,"").trim(),""!==t&&(s[t]=p.util.object.clone(n))})}))}return s},loadSVGFromURL:function(t,e,i){function r(r){var n=r.responseXML;n&&!n.documentElement&&p.window.ActiveXObject&&r.responseText&&(n=new ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(r.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),n&&n.documentElement&&p.parseSVGDocument(n.documentElement,function(i,r){A.set(t,{objects:p.util.array.invoke(i,"toObject"),options:r}),e(i,r)},i)}t=t.replace(/^\n\s*/,"").trim(),A.has(t,function(i){i?A.get(t,function(t){var i=d(t);e(i.objects,i.options)}):new p.util.request(t,{method:"get",onComplete:r})})},loadSVGFromString:function(t,e,i){t=t.trim();var r;if("undefined"!=typeof DOMParser){var n=new DOMParser;n&&n.parseFromString&&(r=n.parseFromString(t,"text/xml"))}else p.window.ActiveXObject&&(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));p.parseSVGDocument(r.documentElement,function(t,i){e(t,i)},i)},createSVGFontFacesMarkup:function(t){for(var e,i,r,n,s,o,a,h="",c={},l=p.fontPaths,u=0,f=t.length;f>u;u++)if(e=t[u],i=e.fontFamily,-1!==e.type.indexOf("text")&&!c[i]&&l[i]&&(c[i]=!0,e.styles)){r=e.styles;for(s in r){n=r[s];for(a in n)o=n[a],i=o.fontFamily,!c[i]&&l[i]&&(c[i]=!0)}}for(var d in c)h+=[" @font-face {\n"," font-family: '",d,"';\n"," src: url('",l[d],"');\n"," }\n"].join("");return h&&(h=[' <style type="text/css">',"<![CDATA[\n",h,"]]>","</style>\n"].join("")),h},createSVGRefElementsMarkup:function(t){var e=[];return g(e,t,"backgroundColor"),g(e,t,"overlayColor"),e.join("")}})}("undefined"!=typeof exports?exports:this),fabric.ElementsParser=function(t,e,i,r){this.elements=t,this.callback=e,this.options=i,this.reviver=r,this.svgUid=i&&i.svgUid||0},fabric.ElementsParser.prototype.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},fabric.ElementsParser.prototype.createObjects=function(){for(var t=0,e=this.elements.length;e>t;t++)this.elements[t].setAttribute("svgUid",this.svgUid),function(t,e){setTimeout(function(){t.createObject(t.elements[e],e)},0)}(this,t)},fabric.ElementsParser.prototype.createObject=function(t,e){var i=fabric[fabric.util.string.capitalize(t.tagName)];if(i&&i.fromElement)try{this._createObject(i,t,e)}catch(r){fabric.log(r)}else this.checkIfDone()},fabric.ElementsParser.prototype._createObject=function(t,e,i){if(t.async)t.fromElement(e,this.createCallback(i,e),this.options);else{var r=t.fromElement(e,this.options);this.resolveGradient(r,"fill"),this.resolveGradient(r,"stroke"),this.reviver&&this.reviver(e,r),this.instances[i]=r,this.checkIfDone()}},fabric.ElementsParser.prototype.createCallback=function(t,e){var i=this;return function(r){i.resolveGradient(r,"fill"),i.resolveGradient(r,"stroke"),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},fabric.ElementsParser.prototype.resolveGradient=function(t,e){var i=t.get(e);if(/^url\(/.test(i)){var r=i.slice(5,i.length-1);fabric.gradientDefs[this.svgUid][r]&&t.set(e,fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][r],t))}},fabric.ElementsParser.prototype.checkIfDone=function(){0===--this.numElements&&(this.instances=this.instances.filter(function(t){return null!=t}),this.callback(this.instances))},function(t){"use strict";function e(t,e){this.x=t,this.y=e}var i=t.fabric||(t.fabric={});return i.Point?void i.warn("fabric.Point is already defined"):(i.Point=e,void(e.prototype={constructor:e,add:function(t){return new e(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new e(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new e(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new e(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new e(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new e(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,i){return new e(this.x+(t.x-this.x)*i,this.y+(t.y-this.y)*i)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return new e(this.x+(t.x-this.x)/2,this.y+(t.y-this.y)/2)},min:function(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){this.x=t,this.y=e},setFromPoint:function(t){this.x=t.x,this.y=t.y},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";function e(t){this.status=t,this.points=[]}var i=t.fabric||(t.fabric={});return i.Intersection?void i.warn("fabric.Intersection is already defined"):(i.Intersection=e,i.Intersection.prototype={appendPoint:function(t){this.points.push(t)},appendPoints:function(t){this.points=this.points.concat(t)}},i.Intersection.intersectLineLine=function(t,r,n,s){var o,a=(s.x-n.x)*(t.y-n.y)-(s.y-n.y)*(t.x-n.x),h=(r.x-t.x)*(t.y-n.y)-(r.y-t.y)*(t.x-n.x),c=(s.y-n.y)*(r.x-t.x)-(s.x-n.x)*(r.y-t.y);if(0!==c){var l=a/c,u=h/c;l>=0&&1>=l&&u>=0&&1>=u?(o=new e("Intersection"),o.points.push(new i.Point(t.x+l*(r.x-t.x),t.y+l*(r.y-t.y)))):o=new e}else o=new e(0===a||0===h?"Coincident":"Parallel");return o},i.Intersection.intersectLinePolygon=function(t,i,r){for(var n=new e,s=r.length,o=0;s>o;o++){var a=r[o],h=r[(o+1)%s],c=e.intersectLineLine(t,i,a,h);n.appendPoints(c.points)}return n.points.length>0&&(n.status="Intersection"),n},i.Intersection.intersectPolygonPolygon=function(t,i){for(var r=new e,n=t.length,s=0;n>s;s++){var o=t[s],a=t[(s+1)%n],h=e.intersectLinePolygon(o,a,i);r.appendPoints(h.points)}return r.points.length>0&&(r.status="Intersection"),r},void(i.Intersection.intersectPolygonRectangle=function(t,r,n){var s=r.min(n),o=r.max(n),a=new i.Point(o.x,s.y),h=new i.Point(s.x,o.y),c=e.intersectLinePolygon(s,a,t),l=e.intersectLinePolygon(a,o,t),u=e.intersectLinePolygon(o,h,t),f=e.intersectLinePolygon(h,s,t),d=new e;return d.appendPoints(c.points),d.appendPoints(l.points),d.appendPoints(u.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";function e(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function i(t,e,i){return 0>i&&(i+=1),i>1&&(i-=1),1/6>i?t+6*(e-t)*i:.5>i?e:2/3>i?t+(e-t)*(2/3-i)*6:t}var r=t.fabric||(t.fabric={});return r.Color?void r.warn("fabric.Color is already defined."):(r.Color=e,r.Color.prototype={_tryParsingColor:function(t){var i;t in e.colorNameMap&&(t=e.colorNameMap[t]),"transparent"===t&&(i=[255,255,255,0]),i||(i=e.sourceFromHex(t)),i||(i=e.sourceFromRgb(t)),i||(i=e.sourceFromHsl(t)),i||(i=[0,0,0,1]),i&&this.setSource(i)},_rgbToHsl:function(t,e,i){t/=255,e/=255,i/=255;var n,s,o,a=r.util.array.max([t,e,i]),h=r.util.array.min([t,e,i]);if(o=(a+h)/2,a===h)n=s=0;else{var c=a-h;switch(s=o>.5?c/(2-a-h):c/(a+h),a){case t:n=(e-i)/c+(i>e?6:0);break;case e:n=(i-t)/c+2;break;case i:n=(t-e)/c+4}n/=6}return[Math.round(360*n),Math.round(100*s),Math.round(100*o)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,r=this.getSource();return t=r[0].toString(16),t=1===t.length?"0"+t:t,e=r[1].toString(16),e=1===e.length?"0"+e:e,i=r[2].toString(16),i=1===i.length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),r=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,r]),this},overlayWith:function(t){t instanceof e||(t=new e(t));for(var i=[],r=this.getAlpha(),n=.5,s=this.getSource(),o=t.getSource(),a=0;3>a;a++)i.push(Math.round(s[a]*(1-n)+o[a]*n));return i[3]=r,this.setSource(i),this}},r.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,r.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,r.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i,r.Color.colorNameMap={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",grey:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"},r.Color.fromRgb=function(t){return e.fromSource(e.sourceFromRgb(t))},r.Color.sourceFromRgb=function(t){var i=t.match(e.reRGBa);if(i){var r=parseInt(i[1],10)/(/%$/.test(i[1])?100:1)*(/%$/.test(i[1])?255:1),n=parseInt(i[2],10)/(/%$/.test(i[2])?100:1)*(/%$/.test(i[2])?255:1),s=parseInt(i[3],10)/(/%$/.test(i[3])?100:1)*(/%$/.test(i[3])?255:1);return[parseInt(r,10),parseInt(n,10),parseInt(s,10),i[4]?parseFloat(i[4]):1]}},r.Color.fromRgba=e.fromRgb,r.Color.fromHsl=function(t){return e.fromSource(e.sourceFromHsl(t))},r.Color.sourceFromHsl=function(t){var r=t.match(e.reHSLa);if(r){var n,s,o,a=(parseFloat(r[1])%360+360)%360/360,h=parseFloat(r[2])/(/%$/.test(r[2])?100:1),c=parseFloat(r[3])/(/%$/.test(r[3])?100:1);if(0===h)n=s=o=c;else{var l=.5>=c?c*(h+1):c+h-c*h,u=2*c-l;n=i(u,l,a+1/3),s=i(u,l,a),o=i(u,l,a-1/3)}return[Math.round(255*n),Math.round(255*s),Math.round(255*o),r[4]?parseFloat(r[4]):1]}},r.Color.fromHsla=e.fromHsl,r.Color.fromHex=function(t){return e.fromSource(e.sourceFromHex(t))},r.Color.sourceFromHex=function(t){if(t.match(e.reHex)){var i=t.slice(t.indexOf("#")+1),r=3===i.length,n=r?i.charAt(0)+i.charAt(0):i.substring(0,2),s=r?i.charAt(1)+i.charAt(1):i.substring(2,4),o=r?i.charAt(2)+i.charAt(2):i.substring(4,6);return[parseInt(n,16),parseInt(s,16),parseInt(o,16),1]}},void(r.Color.fromSource=function(t){var i=new e;return i.setSource(t),i}))}("undefined"!=typeof exports?exports:this),function(){function t(t){var e,i,r,n=t.getAttribute("style"),s=t.getAttribute("offset")||0;if(s=parseFloat(s)/(/%$/.test(s)?100:1),s=0>s?0:s>1?1:s,n){var o=n.split(/\s*;\s*/);""===o[o.length-1]&&o.pop();for(var a=o.length;a--;){var h=o[a].split(/\s*:\s*/),c=h[0].trim(),l=h[1].trim();"stop-color"===c?e=l:"stop-opacity"===c&&(r=l)}}return e||(e=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),e=new fabric.Color(e),i=e.getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=i,{offset:s,color:e.toRgb(),opacity:r}}function e(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}function i(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}function r(t,e,i){var r,n=0,s=1,o="";for(var a in e)r=parseFloat(e[a],10),s="string"==typeof e[a]&&/^\d+%$/.test(e[a])?.01:1,"x1"===a||"x2"===a||"r2"===a?(s*="objectBoundingBox"===i?t.width:1,n="objectBoundingBox"===i?t.left||0:0):"y1"!==a&&"y2"!==a||(s*="objectBoundingBox"===i?t.height:1,n="objectBoundingBox"===i?t.top||0:0),e[a]=r*s+n;if("ellipse"===t.type&&null!==e.r2&&"objectBoundingBox"===i&&t.rx!==t.ry){var h=t.ry/t.rx;o=" scale(1, "+h+")",e.y1&&(e.y1/=h),e.y2&&(e.y2/=h)}return o}fabric.Gradient=fabric.util.createClass({offsetX:0,offsetY:0,initialize:function(t){t||(t={});var e={};this.id=fabric.Object.__uid++,this.type=t.type||"linear",e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice(),t.gradientTransform&&(this.gradientTransform=t.gradientTransform),this.offsetX=t.offsetX||this.offsetX,this.offsetY=t.offsetY||this.offsetY},addColorStop:function(t){for(var e in t){var i=new fabric.Color(t[e]);this.colorStops.push({offset:e,color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(){return{type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform}},toSVG:function(t){var e,i,r=fabric.util.object.clone(this.coords);if(this.colorStops.sort(function(t,e){return t.offset-e.offset}),!t.group||"path-group"!==t.group.type)for(var n in r)"x1"===n||"x2"===n||"r2"===n?r[n]+=this.offsetX-t.width/2:"y1"!==n&&"y2"!==n||(r[n]+=this.offsetY-t.height/2);i='id="SVGID_'+this.id+'" gradientUnits="userSpaceOnUse"',this.gradientTransform&&(i+=' gradientTransform="matrix('+this.gradientTransform.join(" ")+')" '),"linear"===this.type?e=["<linearGradient ",i,' x1="',r.x1,'" y1="',r.y1,'" x2="',r.x2,'" y2="',r.y2,'">\n']:"radial"===this.type&&(e=["<radialGradient ",i,' cx="',r.x2,'" cy="',r.y2,'" r="',r.r2,'" fx="',r.x1,'" fy="',r.y1,'">\n']);for(var s=0;s<this.colorStops.length;s++)e.push("<stop ",'offset="',100*this.colorStops[s].offset+"%",'" style="stop-color:',this.colorStops[s].color,null!=this.colorStops[s].opacity?";stop-opacity: "+this.colorStops[s].opacity:";",'"/>\n');return e.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),e.join("")},toLive:function(t,e){var i,r,n=fabric.util.object.clone(this.coords);if(this.type){if(e.group&&"path-group"===e.group.type)for(r in n)"x1"===r||"x2"===r?n[r]+=-this.offsetX+e.width/2:"y1"!==r&&"y2"!==r||(n[r]+=-this.offsetY+e.height/2);"linear"===this.type?i=t.createLinearGradient(n.x1,n.y1,n.x2,n.y2):"radial"===this.type&&(i=t.createRadialGradient(n.x1,n.y1,n.r1,n.x2,n.y2,n.r2));for(var s=0,o=this.colorStops.length;o>s;s++){var a=this.colorStops[s].color,h=this.colorStops[s].opacity,c=this.colorStops[s].offset;"undefined"!=typeof h&&(a=new fabric.Color(a).setAlpha(h).toRgba()),i.addColorStop(parseFloat(c),a)}return i}}}),fabric.util.object.extend(fabric.Gradient,{fromElement:function(n,s){var o,a=n.getElementsByTagName("stop"),h="linearGradient"===n.nodeName?"linear":"radial",c=n.getAttribute("gradientUnits")||"objectBoundingBox",l=n.getAttribute("gradientTransform"),u=[],f={};"linear"===h?f=e(n):"radial"===h&&(f=i(n));for(var d=a.length;d--;)u.push(t(a[d]));o=r(s,f,c);var g=new fabric.Gradient({type:h,coords:f,colorStops:u,offsetX:-s.left,offsetY:-s.top});return(l||""!==o)&&(g.gradientTransform=fabric.parseTransformAttribute((l||"")+o)),g},forObject:function(t,e){return e||(e={}),r(t,e.coords,"userSpaceOnUse"),new fabric.Gradient(e)}})}(),fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(t){if(t||(t={}),this.id=fabric.Object.__uid++,t.source)if("string"==typeof t.source)if("undefined"!=typeof fabric.util.getFunctionBody(t.source))this.source=new Function(fabric.util.getFunctionBody(t.source));else{var e=this;this.source=fabric.util.createImage(),fabric.util.loadImage(t.source,function(t){e.source=t})}else this.source=t.source;t.repeat&&(this.repeat=t.repeat),t.offsetX&&(this.offsetX=t.offsetX),t.offsetY&&(this.offsetY=t.offsetY)},toObject:function(){var t;return"function"==typeof this.source?t=String(this.source):"string"==typeof this.source.src?t=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(t=this.source.toDataURL()),{source:t,repeat:this.repeat,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.getWidth(),r=e.height/t.getHeight(),n=this.offsetX/t.getWidth(),s=this.offsetY/t.getHeight(),o="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(r=1),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1),e.src?o=e.src:e.toDataURL&&(o=e.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+n+'" y="'+s+'" width="'+i+'" height="'+r+'">\n<image x="0" y="0" width="'+e.width+'" height="'+e.height+'" xlink:href="'+o+'"></image>\n</pattern>\n'},toLive:function(t){var e="function"==typeof this.source?this.source():this.source;if(!e)return"";if("undefined"!=typeof e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;return e.Shadow?void e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,initialize:function(t){"string"==typeof t&&(t=this._parseShadow(t));for(var i in t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),r=e.Shadow.reOffsetsAndBlur.exec(i)||[],n=i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:n.trim(),offsetX:parseInt(r[1],10)||0,offsetY:parseInt(r[2],10)||0,blur:parseInt(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var r=40,n=40,s=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=20;return t.width&&t.height&&(r=100*i((Math.abs(o.x)+this.blur)/t.width,s)+a,n=100*i((Math.abs(o.y)+this.blur)/t.height,s)+a),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+n+'%" height="'+(100+2*n)+'%" x="-'+r+'%" width="'+(100+2*r)+'%" >\n <feGaussianBlur in="SourceAlpha" stdDeviation="'+i(this.blur?this.blur/2:0,s)+'"></feGaussianBlur>\n <feOffset dx="'+i(o.x,s)+'" dy="'+i(o.y,s)+'" result="oBlur" ></feOffset>\n <feFlood flood-color="'+this.color+'"/>\n <feComposite in2="oBlur" operator="in" />\n <feMerge>\n <feMergeNode></feMergeNode>\n <feMergeNode in="SourceGraphic"></feMergeNode>\n </feMerge>\n</filter>\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke"].forEach(function(e){this[e]!==i[e]&&(t[e]=this[e])},this),t}}),void(e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/))}("undefined"!=typeof exports?exports:this),function(){"use strict";if(fabric.StaticCanvas)return void fabric.warn("fabric.StaticCanvas is already defined.");var t=fabric.util.object.extend,e=fabric.util.getElementOffset,i=fabric.util.removeFromArray,r=fabric.util.toFixed,n=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=fabric.util.createClass({initialize:function(t,e){e||(e={}),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!0,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,preserveObjectStacking:!1,viewportTransform:[1,0,0,1,0,0],onBeforeScaleRotate:function(){},enableRetinaScaling:!0,_initStatic:function(t,e){this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this._setImageSmoothing(),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,this.renderAll.bind(this)),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,this.renderAll.bind(this)),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,this.renderAll.bind(this)),e.overlayColor&&this.setOverlayColor(e.overlayColor,this.renderAll.bind(this)),this.calcOffset()},_isRetinaScaling:function(){return 1!==fabric.devicePixelRatio&&this.enableRetinaScaling},_initRetinaScaling:function(){this._isRetinaScaling()&&(this.lowerCanvasEl.setAttribute("width",this.width*fabric.devicePixelRatio),this.lowerCanvasEl.setAttribute("height",this.height*fabric.devicePixelRatio),this.contextContainer.scale(fabric.devicePixelRatio,fabric.devicePixelRatio))},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},_setImageSmoothing:function(){var t=this.getContext();t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=this.imageSmoothingEnabled},__setBgOverlayImage:function(t,e,i,r){return"string"==typeof e?fabric.util.loadImage(e,function(e){this[t]=new fabric.Image(e,r),i&&i(e)},this,r&&r.crossOrigin):(r&&e.setOptions(r),this[t]=e,i&&i(e)),this},__setBgOverlayColor:function(t,e,i){if(e&&e.source){var r=this;fabric.util.loadImage(e.source,function(n){r[t]=new fabric.Pattern({source:n,repeat:e.repeat,offsetX:e.offsetX,offsetY:e.offsetY}),i&&i()})}else this[t]=e,i&&i();return this},_createCanvasElement:function(){var t=fabric.document.createElement("canvas");if(t.style||(t.style={}),!t)throw n;return this._initCanvasElement(t),t},_initCanvasElement:function(t){if(fabric.util.createCanvasElement(t),"undefined"==typeof t.getContext)throw n},_initOptions:function(t){for(var e in t)this[e]=t[e];this.width=this.width||parseInt(this.lowerCanvasEl.width,10)||0,this.height=this.height||parseInt(this.lowerCanvasEl.height,10)||0,this.lowerCanvasEl.style&&(this.lowerCanvasEl.width=this.width,this.lowerCanvasEl.height=this.height,this.lowerCanvasEl.style.width=this.width+"px",this.lowerCanvasEl.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){this.lowerCanvasEl=fabric.util.getById(t)||this._createCanvasElement(),this._initCanvasElement(this.lowerCanvasEl),fabric.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;e=e||{};for(var r in t)i=t[r],e.cssOnly||(this._setBackstoreDimension(r,t[r]),i+="px"),e.backstoreOnly||this._setCssDimension(r,i);return this._initRetinaScaling(),this._setImageSmoothing(),this.calcOffset(),e.cssOnly||this.renderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return Math.sqrt(this.viewportTransform[0]*this.viewportTransform[3])},setViewportTransform:function(t){var e=this.getActiveGroup();this.viewportTransform=t,this.renderAll();for(var i=0,r=this._objects.length;r>i;i++)this._objects[i].setCoords();return e&&e.setCoords(),this},zoomToPoint:function(t,e){var i=t;t=fabric.util.transformPoint(t,fabric.util.invertTransform(this.viewportTransform)),this.viewportTransform[0]=e,this.viewportTransform[3]=e;var r=fabric.util.transformPoint(t,this.viewportTransform);this.viewportTransform[4]+=i.x-r.x,this.viewportTransform[5]+=i.y-r.y,this.renderAll();for(var n=0,s=this._objects.length;s>n;n++)this._objects[n].setCoords();return this},setZoom:function(t){return this.zoomToPoint(new fabric.Point(0,0),t),this},absolutePan:function(t){this.viewportTransform[4]=-t.x,this.viewportTransform[5]=-t.y,this.renderAll();for(var e=0,i=this._objects.length;i>e;e++)this._objects[e].setCoords();return this},relativePan:function(t){return this.absolutePan(new fabric.Point(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_onObjectAdded:function(t){this.stateful&&t.setupState(),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added")},_onObjectRemoved:function(t){this.getActiveObject()===t&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared")),this.fire("object:removed",{target:t}),t.fire("removed")},clearContext:function(t){return t.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.discardActiveGroup&&this.discardActiveGroup(),this.discardActiveObject&&this.discardActiveObject(),this.clearContext(this.contextContainer),this.contextTop&&this.clearContext(this.contextTop),this.fire("canvas:cleared"),this.renderAll(),this},_chooseObjectsToRender:function(){var t,e=this.getActiveGroup(),i=[],r=[];if(e&&!this.preserveObjectStacking){for(var n=0,s=this._objects.length;s>n;n++)t=this._objects[n],e.contains(t)?r.push(t):i.push(t);e._set("_objects",r)}else i=this._objects;return i},renderAll:function(){var t,e=this.contextContainer;return this.contextTop&&this.selection&&!this._groupSelector&&!this.isDrawingMode&&this.clearContext(this.contextTop),this.clearContext(e),this.fire("before:render"),this.clipTo&&fabric.util.clipContext(this,e),this._renderBackground(e),e.save(),t=this._chooseObjectsToRender(),e.transform.apply(e,this.viewportTransform),this._renderObjects(e,t),this.preserveObjectStacking||this._renderObjects(e,[this.getActiveGroup()]),e.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(e),this.clipTo&&e.restore(),this._renderOverlay(e),this.controlsAboveOverlay&&this.interactive&&this.drawControls(e),this.fire("after:render"),this},_renderObjects:function(t,e){for(var i=0,r=e.length;r>i;++i)e[i]&&e[i].render(t)},_renderBackgroundOrOverlay:function(t,e){var i=this[e+"Color"];i&&(t.fillStyle=i.toLive?i.toLive(t):i,t.fillRect(i.offsetX||0,i.offsetY||0,this.width,this.height)),i=this[e+"Image"],i&&i.render(t)},_renderBackground:function(t){this._renderBackgroundOrOverlay(t,"background")},_renderOverlay:function(t){this._renderBackgroundOrOverlay(t,"overlay")},renderTop:function(){var t=this.contextTop||this.contextContainer;return this.clearContext(t),this.selection&&this._groupSelector&&this._drawSelection(),this.fire("after:render"),this},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(t){return this._centerObject(t,new fabric.Point(this.getCenter().left,t.getCenterPoint().y)),this.renderAll(),this},centerObjectV:function(t){return this._centerObject(t,new fabric.Point(t.getCenterPoint().x,this.getCenter().top)),this.renderAll(),this},centerObject:function(t){var e=this.getCenter();return this._centerObject(t,new fabric.Point(e.left,e.top)),this.renderAll(),this},_centerObject:function(t,e){return t.setPositionByOrigin(e,"center","center"),this},toDatalessJSON:function(t){return this.toDatalessObject(t)},toObject:function(t){return this._toObjectMethod("toObject",t)},toDatalessObject:function(t){return this._toObjectMethod("toDatalessObject",t)},_toObjectMethod:function(e,i){var r={objects:this._toObjects(e,i)};return t(r,this.__serializeBgOverlay()),fabric.util.populateWithProperties(this,r,i),r},_toObjects:function(t,e){return this.getObjects().map(function(i){
3
- return this._toObject(i,t,e)},this)},_toObject:function(t,e,i){var r;this.includeDefaultValues||(r=t.includeDefaultValues,t.includeDefaultValues=!1);var n=this._realizeGroupTransformOnObject(t),s=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=r),this._unwindGroupTransformOnObject(t,n),s},_realizeGroupTransformOnObject:function(t){var e=["angle","flipX","flipY","height","left","scaleX","scaleY","top","width"];if(t.group&&t.group===this.getActiveGroup()){var i={};return e.forEach(function(e){i[e]=t[e]}),this.getActiveGroup().realizeTransform(t),i}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},__serializeBgOverlay:function(){var t={background:this.backgroundColor&&this.backgroundColor.toObject?this.backgroundColor.toObject():this.backgroundColor};return this.overlayColor&&(t.overlay=this.overlayColor.toObject?this.overlayColor.toObject():this.overlayColor),this.backgroundImage&&(t.backgroundImage=this.backgroundImage.toObject()),this.overlayImage&&(t.overlayImage=this.overlayImage.toObject()),t},svgViewportTransformation:!0,toSVG:function(t,e){t||(t={});var i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this._setSVGBgOverlayColor(i,"backgroundColor"),this._setSVGBgOverlayImage(i,"backgroundImage"),this._setSVGObjects(i,e),this._setSVGBgOverlayColor(i,"overlayColor"),this._setSVGBgOverlayImage(i,"overlayImage"),i.push("</svg>"),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(t,e){var i,n=e.width||this.width,s=e.height||this.height,o='viewBox="0 0 '+this.width+" "+this.height+'" ',a=fabric.Object.NUM_FRACTION_DIGITS;e.viewBox?o='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,o='viewBox="'+r(-i[4]/i[0],a)+" "+r(-i[5]/i[3],a)+" "+r(this.width/i[0],a)+" "+r(this.height/i[3],a)+'" '),t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',n,'" ','height="',s,'" ',this.backgroundColor&&!this.backgroundColor.toLive?'style="background-color: '+this.backgroundColor+'" ':null,o,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",fabric.version,"</desc>\n","<defs>",fabric.createSVGFontFacesMarkup(this.getObjects()),fabric.createSVGRefElementsMarkup(this),"</defs>\n")},_setSVGObjects:function(t,e){for(var i=0,r=this.getObjects(),n=r.length;n>i;i++){var s=r[i],o=this._realizeGroupTransformOnObject(s);t.push(s.toSVG(e)),this._unwindGroupTransformOnObject(s,o)}},_setSVGBgOverlayImage:function(t,e){this[e]&&this[e].toSVG&&t.push(this[e].toSVG())},_setSVGBgOverlayColor:function(t,e){this[e]&&this[e].source?t.push('<rect x="',this[e].offsetX,'" y="',this[e].offsetY,'" ','width="',"repeat-y"===this[e].repeat||"no-repeat"===this[e].repeat?this[e].source.width:this.width,'" height="',"repeat-x"===this[e].repeat||"no-repeat"===this[e].repeat?this[e].source.height:this.height,'" fill="url(#'+e+'Pattern)"',"></rect>\n"):this[e]&&"overlayColor"===e&&t.push('<rect x="0" y="0" ','width="',this.width,'" height="',this.height,'" fill="',this[e],'"',"></rect>\n")},sendToBack:function(t){if(!t)return this;var e,r,n,s=this.getActiveGroup?this.getActiveGroup():null;if(t===s)for(n=s._objects,e=n.length;e--;)r=n[e],i(this._objects,r),this._objects.unshift(r);else i(this._objects,t),this._objects.unshift(t);return this.renderAll&&this.renderAll()},bringToFront:function(t){if(!t)return this;var e,r,n,s=this.getActiveGroup?this.getActiveGroup():null;if(t===s)for(n=s._objects,e=0;e<n.length;e++)r=n[e],i(this._objects,r),this._objects.push(r);else i(this._objects,t),this._objects.push(t);return this.renderAll&&this.renderAll()},sendBackwards:function(t,e){if(!t)return this;var r,n,s,o,a,h=this.getActiveGroup?this.getActiveGroup():null;if(t===h)for(a=h._objects,r=0;r<a.length;r++)n=a[r],s=this._objects.indexOf(n),0!==s&&(o=s-1,i(this._objects,n),this._objects.splice(o,0,n));else s=this._objects.indexOf(t),0!==s&&(o=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderAll&&this.renderAll(),this},_findNewLowerIndex:function(t,e,i){var r;if(i){r=e;for(var n=e-1;n>=0;--n){var s=t.intersectsWithObject(this._objects[n])||t.isContainedWithinObject(this._objects[n])||this._objects[n].isContainedWithinObject(t);if(s){r=n;break}}}else r=e-1;return r},bringForward:function(t,e){if(!t)return this;var r,n,s,o,a,h=this.getActiveGroup?this.getActiveGroup():null;if(t===h)for(a=h._objects,r=a.length;r--;)n=a[r],s=this._objects.indexOf(n),s!==this._objects.length-1&&(o=s+1,i(this._objects,n),this._objects.splice(o,0,n));else s=this._objects.indexOf(t),s!==this._objects.length-1&&(o=this._findNewUpperIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderAll&&this.renderAll(),this},_findNewUpperIndex:function(t,e,i){var r;if(i){r=e;for(var n=e+1;n<this._objects.length;++n){var s=t.intersectsWithObject(this._objects[n])||t.isContainedWithinObject(this._objects[n])||this._objects[n].isContainedWithinObject(t);if(s){r=n;break}}}else r=e+1;return r},moveTo:function(t,e){return i(this._objects,t),this._objects.splice(e,0,t),this.renderAll&&this.renderAll()},dispose:function(){return this.clear(),this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"}}),t(fabric.StaticCanvas.prototype,fabric.Observable),t(fabric.StaticCanvas.prototype,fabric.Collection),t(fabric.StaticCanvas.prototype,fabric.DataURLExporter),t(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=fabric.util.createCanvasElement();if(!e||!e.getContext)return null;var i=e.getContext("2d");if(!i)return null;switch(t){case"getImageData":return"undefined"!=typeof i.getImageData;case"setLineDash":return"undefined"!=typeof i.setLineDash;case"toDataURL":return"undefined"!=typeof e.toDataURL;case"toDataURLWithQuality":try{return e.toDataURL("image/jpeg",0),!0}catch(r){}return!1;default:return null}}}),fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject}(),fabric.BaseBrush=fabric.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeDashArray:null,setShadow:function(t){return this.shadow=new fabric.Shadow(t),this},_setBrushStyles:function(){var t=this.canvas.contextTop;t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.lineJoin=this.strokeLineJoin,this.strokeDashArray&&fabric.StaticCanvas.supports("setLineDash")&&t.setLineDash(this.strokeDashArray)},_setShadow:function(){if(this.shadow){var t=this.canvas.contextTop;t.shadowColor=this.shadow.color,t.shadowBlur=this.shadow.blur,t.shadowOffsetX=this.shadow.offsetX,t.shadowOffsetY=this.shadow.offsetY}},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}}),function(){fabric.PencilBrush=fabric.util.createClass(fabric.BaseBrush,{initialize:function(t){this.canvas=t,this._points=[]},onMouseDown:function(t){this._prepareForDrawing(t),this._captureDrawingPath(t),this._render()},onMouseMove:function(t){this._captureDrawingPath(t),this.canvas.clearContext(this.canvas.contextTop),this._render()},onMouseUp:function(){this._finalizeAndAddPath()},_prepareForDrawing:function(t){var e=new fabric.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){this._points.push(t)},_reset:function(){this._points.length=0,this._setBrushStyles(),this._setShadow()},_captureDrawingPath:function(t){var e=new fabric.Point(t.x,t.y);this._addPoint(e)},_render:function(){var t=this.canvas.contextTop,e=this.canvas.viewportTransform,i=this._points[0],r=this._points[1];t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t.beginPath(),2===this._points.length&&i.x===r.x&&i.y===r.y&&(i.x-=.5,r.x+=.5),t.moveTo(i.x,i.y);for(var n=1,s=this._points.length;s>n;n++){var o=i.midPointFrom(r);t.quadraticCurveTo(i.x,i.y,o.x,o.y),i=this._points[n],r=this._points[n+1]}t.lineTo(i.x,i.y),t.stroke(),t.restore()},convertPointsToSVGPath:function(t){var e=[],i=new fabric.Point(t[0].x,t[0].y),r=new fabric.Point(t[1].x,t[1].y);e.push("M ",t[0].x," ",t[0].y," ");for(var n=1,s=t.length;s>n;n++){var o=i.midPointFrom(r);e.push("Q ",i.x," ",i.y," ",o.x," ",o.y," "),i=new fabric.Point(t[n].x,t[n].y),n+1<t.length&&(r=new fabric.Point(t[n+1].x,t[n+1].y))}return e.push("L ",i.x," ",i.y," "),e},createPath:function(t){var e=new fabric.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray,originX:"center",originY:"center"});return this.shadow&&(this.shadow.affectStroke=!0,e.setShadow(this.shadow)),e},_finalizeAndAddPath:function(){var t=this.canvas.contextTop;t.closePath();var e=this.convertPointsToSVGPath(this._points).join("");if("M 0 0 Q 0 0 0 0 L 0 0"===e)return void this.canvas.renderAll();var i=this.createPath(e);this.canvas.add(i),i.setCoords(),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderAll(),this.canvas.fire("path:created",{path:i})}})}(),fabric.CircleBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop,r=this.canvas.viewportTransform;i.save(),i.transform(r[0],r[1],r[2],r[3],r[4],r[5]),i.fillStyle=e.fill,i.beginPath(),i.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),i.closePath(),i.fill(),i.restore()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},onMouseMove:function(t){this.drawDot(t)},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,r=this.points.length;r>i;i++){var n=this.points[i],s=new fabric.Circle({radius:n.radius,left:n.x,top:n.y,originX:"center",originY:"center",fill:n.fill});this.shadow&&s.setShadow(this.shadow),e.push(s)}var o=new fabric.Group(e,{originX:"center",originY:"center"});o.canvas=this.canvas,this.canvas.add(o),this.canvas.fire("path:created",{path:o}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.renderAll()},addPoint:function(t){var e=new fabric.Point(t.x,t.y),i=fabric.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,r=new fabric.Color(this.color).setAlpha(fabric.util.getRandomInt(0,100)/100).toRgba();return e.radius=i,e.fill=r,this.points.push(e),e}}),fabric.SprayBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(t){this.canvas=t,this.sprayChunks=[]},onMouseDown:function(t){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(t),this.render()},onMouseMove:function(t){this.addSprayChunk(t),this.render()},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,r=this.sprayChunks.length;r>i;i++)for(var n=this.sprayChunks[i],s=0,o=n.length;o>s;s++){var a=new fabric.Rect({width:n[s].width,height:n[s].width,left:n[s].x+1,top:n[s].y+1,originX:"center",originY:"center",fill:this.color});this.shadow&&a.setShadow(this.shadow),e.push(a)}this.optimizeOverlapping&&(e=this._getOptimizedRects(e));var h=new fabric.Group(e,{originX:"center",originY:"center"});h.canvas=this.canvas,this.canvas.add(h),this.canvas.fire("path:created",{path:h}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.renderAll()},_getOptimizedRects:function(t){for(var e,i={},r=0,n=t.length;n>r;r++)e=t[r].left+""+t[r].top,i[e]||(i[e]=t[r]);var s=[];for(e in i)s.push(i[e]);return s},render:function(){var t=this.canvas.contextTop;t.fillStyle=this.color;var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5]);for(var i=0,r=this.sprayChunkPoints.length;r>i;i++){var n=this.sprayChunkPoints[i];"undefined"!=typeof n.opacity&&(t.globalAlpha=n.opacity),t.fillRect(n.x,n.y,n.width,n.width)}t.restore()},addSprayChunk:function(t){this.sprayChunkPoints=[];for(var e,i,r,n=this.width/2,s=0;s<this.density;s++){e=fabric.util.getRandomInt(t.x-n,t.x+n),i=fabric.util.getRandomInt(t.y-n,t.y+n),r=this.dotWidthVariance?fabric.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth;var o=new fabric.Point(e,i);o.width=r,this.randomOpacity&&(o.opacity=fabric.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(o)}this.sprayChunks.push(this.sprayChunkPoints)}}),fabric.PatternBrush=fabric.util.createClass(fabric.PencilBrush,{getPatternSrc:function(){var t=20,e=5,i=fabric.document.createElement("canvas"),r=i.getContext("2d");return i.width=i.height=t+e,r.fillStyle=this.color,r.beginPath(),r.arc(t/2,t/2,t/2,0,2*Math.PI,!1),r.closePath(),r.fill(),i},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles"),this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(t){var e=this.callSuper("createPath",t);return e.stroke=new fabric.Pattern({source:this.source||this.getPatternSrcFunction()}),e}}),function(){var t=fabric.util.getPointer,e=fabric.util.degreesToRadians,i=fabric.util.radiansToDegrees,r=Math.atan2,n=Math.abs,s=.5;fabric.Canvas=fabric.util.createClass(fabric.StaticCanvas,{initialize:function(t,e){e||(e={}),this._initStatic(t,e),this._initInteractive(),this._createCacheCanvas()},uniScaleTransform:!1,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=fabric.PencilBrush&&new fabric.PencilBrush(this),this.calcOffset()},_resetCurrentTransform:function(){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,skewX:t.original.skewX,skewY:t.original.skewY,left:t.original.left,top:t.original.top}),this._shouldCenterTransform(t.target)?"rotate"===t.action?this._setOriginToCenter(t.target):("center"!==t.originX&&("right"===t.originX?t.mouseXSign=-1:t.mouseXSign=1),"center"!==t.originY&&("bottom"===t.originY?t.mouseYSign=-1:t.mouseYSign=1),t.originX="center",t.originY="center"):(t.originX=t.original.originX,t.originY=t.original.originY)},containsPoint:function(t,e){var i=this.getPointer(t,!0),r=this._normalizePointer(e,i);return e.containsPoint(r)||e._findTargetCorner(i)},_normalizePointer:function(t,e){var i,r,n=this.getActiveGroup(),s=n&&"group"!==t.type&&n.contains(t);return s&&(r=fabric.util.multiplyTransformMatrices(this.viewportTransform,n.calcTransformMatrix()),r=fabric.util.invertTransform(r),e=fabric.util.transformPoint(e,r,!1),i=fabric.util.transformPoint(n.getCenterPoint(),r,!1),e.x-=i.x,e.y-=i.y),{x:e.x,y:e.y}},isTargetTransparent:function(t,e,i){var r=t.hasBorders,n=t.transparentCorners,s=this.contextCache,o=t.group&&t.group===this.getActiveGroup();t.hasBorders=t.transparentCorners=!1,o&&(s.save(),s.transform.apply(s,t.group.calcTransformMatrix())),t.render(s),t.active&&t._renderControls(s),t.hasBorders=r,t.transparentCorners=n;var a=fabric.util.isTransparent(s,e,i,this.targetFindTolerance);return o&&s.restore(),this.clearContext(s),a},_shouldClearSelection:function(t,e){var i=this.getActiveGroup(),r=this.getActiveObject();return!e||e&&i&&!i.contains(e)&&i!==e&&!t[this.selectionKey]||e&&!e.evented||e&&!e.selectable&&r&&r!==e},_shouldCenterTransform:function(t){if(t){var e,i=this._currentTransform;return"scale"===i.action||"scaleX"===i.action||"scaleY"===i.action?e=this.centeredScaling||t.centeredScaling:"rotate"===i.action&&(e=this.centeredRotation||t.centeredRotation),e?!i.altKey:i.altKey}},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i){if(!e)return"drag";switch(e){case"mtr":return"rotate";case"ml":case"mr":return i[this.altActionKey]?"skewY":"scaleX";case"mt":case"mb":return i[this.altActionKey]?"skewX":"scaleY";default:return"scale"}},_setupCurrentTransform:function(t,i){if(i){var r=this.getPointer(t),n=i._findTargetCorner(this.getPointer(t,!0)),s=this._getActionFromCorner(i,n,t),o=this._getOriginFromCorner(i,n);this._currentTransform={target:i,action:s,corner:n,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:o.x,originY:o.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,left:i.left,top:i.top,theta:e(i.angle),width:i.width*i.scaleX,mouseXSign:1,mouseYSign:1,shiftKey:t.shiftKey,altKey:t[this.centeredKey]},this._currentTransform.original={left:i.left,top:i.top,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,originX:o.x,originY:o.y},this._resetCurrentTransform()}},_translateObject:function(t,e){var i=this._currentTransform,r=i.target,n=t-i.offsetX,s=e-i.offsetY,o=!r.get("lockMovementX")&&r.left!==n,a=!r.get("lockMovementY")&&r.top!==s;return o&&r.set("left",n),a&&r.set("top",s),o||a},_changeSkewTransformOrigin:function(t,e,i){var r="originX",n={0:"center"},s=e.target.skewX,o="left",a="right",h="mt"===e.corner||"ml"===e.corner?1:-1,c=1;t=t>0?1:-1,"y"===i&&(s=e.target.skewY,o="top",a="bottom",r="originY"),n[-1]=o,n[1]=a,e.target.flipX&&(c*=-1),e.target.flipY&&(c*=-1),0===s?(e.skewSign=-h*t*c,e[r]=n[-t]):(s=s>0?1:-1,e.skewSign=s,e[r]=n[s*h*c])},_skewObject:function(t,e,i){var r=this._currentTransform,n=r.target,s=!1,o=n.get("lockSkewingX"),a=n.get("lockSkewingY");if(o&&"x"===i||a&&"y"===i)return!1;var h,c,l=n.getCenterPoint(),u=n.toLocalPoint(new fabric.Point(t,e),"center","center")[i],f=n.toLocalPoint(new fabric.Point(r.lastX,r.lastY),"center","center")[i],d=n._getTransformedDimensions();return this._changeSkewTransformOrigin(u-f,r,i),h=n.toLocalPoint(new fabric.Point(t,e),r.originX,r.originY)[i],c=n.translateToOriginPoint(l,r.originX,r.originY),s=this._setObjectSkew(h,r,i,d),r.lastX=t,r.lastY=e,n.setPositionByOrigin(c,r.originX,r.originY),s},_setObjectSkew:function(t,e,i,r){var n,s,o,a,h,c,l,u,f,d=e.target,g=!1,p=e.skewSign;return"x"===i?(a="y",h="Y",c="X",u=0,f=d.skewY):(a="x",h="X",c="Y",u=d.skewX,f=0),o=d._getTransformedDimensions(u,f),l=2*Math.abs(t)-o[i],2>=l?n=0:(n=p*Math.atan(l/d["scale"+c]/(o[a]/d["scale"+h])),n=fabric.util.radiansToDegrees(n)),g=d["skew"+c]!==n,d.set("skew"+c,n),0!==d["skew"+h]&&(s=d._getTransformedDimensions(),n=r[a]/s[a]*d["scale"+h],d.set("scale"+h,n)),g},_scaleObject:function(t,e,i){var r=this._currentTransform,n=r.target,s=n.get("lockScalingX"),o=n.get("lockScalingY"),a=n.get("lockScalingFlip");if(s&&o)return!1;var h=n.translateToOriginPoint(n.getCenterPoint(),r.originX,r.originY),c=n.toLocalPoint(new fabric.Point(t,e),r.originX,r.originY),l=n._getTransformedDimensions(),u=!1;return this._setLocalMouse(c,r),u=this._setObjectScale(c,r,s,o,i,a,l),n.setPositionByOrigin(h,r.originX,r.originY),u},_setObjectScale:function(t,e,i,r,n,s,o){var a,h,c,l,u=e.target,f=!1,d=!1,g=!1;return c=t.x*u.scaleX/o.x,l=t.y*u.scaleY/o.y,a=u.scaleX!==c,h=u.scaleY!==l,s&&0>=c&&c<u.scaleX&&(f=!0),s&&0>=l&&l<u.scaleY&&(d=!0),"equally"!==n||i||r?n?"x"!==n||u.get("lockUniScaling")?"y"!==n||u.get("lockUniScaling")||d||r||u.set("scaleY",l)&&(g=g||h):f||i||u.set("scaleX",c)&&(g=g||a):(f||i||u.set("scaleX",c)&&(g=g||a),d||r||u.set("scaleY",l)&&(g=g||h)):f||d||(g=this._scaleObjectEqually(t,u,e,o)),e.newScaleX=c,e.newScaleY=l,f||d||this._flipObject(e,n),g},_scaleObjectEqually:function(t,e,i,r){var n,s=t.y+t.x,o=r.y*i.original.scaleY/e.scaleY+r.x*i.original.scaleX/e.scaleX;return i.newScaleX=i.original.scaleX*s/o,i.newScaleY=i.original.scaleY*s/o,n=i.newScaleX!==e.scaleX||i.newScaleY!==e.scaleY,e.set("scaleX",i.newScaleX),e.set("scaleY",i.newScaleY),n},_flipObject:function(t,e){t.newScaleX<0&&"y"!==e&&("left"===t.originX?t.originX="right":"right"===t.originX&&(t.originX="left")),t.newScaleY<0&&"x"!==e&&("top"===t.originY?t.originY="bottom":"bottom"===t.originY&&(t.originY="top"))},_setLocalMouse:function(t,e){var i=e.target;"right"===e.originX?t.x*=-1:"center"===e.originX&&(t.x*=2*e.mouseXSign,t.x<0&&(e.mouseXSign=-e.mouseXSign)),"bottom"===e.originY?t.y*=-1:"center"===e.originY&&(t.y*=2*e.mouseYSign,t.y<0&&(e.mouseYSign=-e.mouseYSign)),n(t.x)>i.padding?t.x<0?t.x+=i.padding:t.x-=i.padding:t.x=0,n(t.y)>i.padding?t.y<0?t.y+=i.padding:t.y-=i.padding:t.y=0},_rotateObject:function(t,e){var n=this._currentTransform;if(n.target.get("lockRotation"))return!1;var s=r(n.ey-n.top,n.ex-n.left),o=r(e-n.top,t-n.left),a=i(o-s+n.theta);return 0>a&&(a=360+a),n.target.angle=a%360,!0},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.setAngle(0)},_drawSelection:function(){var t=this.contextTop,e=this._groupSelector,i=e.left,r=e.top,o=n(i),a=n(r);if(t.fillStyle=this.selectionColor,t.fillRect(e.ex-(i>0?0:-i),e.ey-(r>0?0:-r),o,a),t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,this.selectionDashArray.length>1){var h=e.ex+s-(i>0?0:o),c=e.ey+s-(r>0?0:a);t.beginPath(),fabric.util.drawDashedLine(t,h,c,h+o,c,this.selectionDashArray),fabric.util.drawDashedLine(t,h,c+a-1,h+o,c+a-1,this.selectionDashArray),fabric.util.drawDashedLine(t,h,c,h,c+a,this.selectionDashArray),fabric.util.drawDashedLine(t,h+o-1,c,h+o-1,c+a,this.selectionDashArray),t.closePath(),t.stroke()}else t.strokeRect(e.ex+s-(i>0?0:o),e.ey+s-(r>0?0:a),o,a)},_isLastRenderedObject:function(t){return this.controlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay.visible&&this.containsPoint(t,this.lastRenderedObjectWithControlsAboveOverlay)&&this.lastRenderedObjectWithControlsAboveOverlay._findTargetCorner(this.getPointer(t,!0))},findTarget:function(t,e){if(!this.skipTargetFind){if(this._isLastRenderedObject(t))return this.lastRenderedObjectWithControlsAboveOverlay;var i=this.getActiveGroup();if(!e&&this._checkTarget(t,i,this.getPointer(t,!0)))return i;var r=this._searchPossibleTargets(t,e);return this._fireOverOutEvents(r,t),r}},_fireOverOutEvents:function(t,e){t?this._hoveredTarget!==t&&(this._hoveredTarget&&(this.fire("mouse:out",{target:this._hoveredTarget,e:e}),this._hoveredTarget.fire("mouseout")),this.fire("mouse:over",{target:t,e:e}),t.fire("mouseover"),this._hoveredTarget=t):this._hoveredTarget&&(this.fire("mouse:out",{target:this._hoveredTarget,e:e}),this._hoveredTarget.fire("mouseout"),this._hoveredTarget=null)},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&this.containsPoint(t,e)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;var r=this.isTargetTransparent(e,i.x,i.y);if(!r)return!0}},_searchPossibleTargets:function(t,e){for(var i,r=this.getPointer(t,!0),n=this._objects.length;n--;)if((!this._objects[n].group||e)&&this._checkTarget(t,this._objects[n],r)){this.relatedTarget=this._objects[n],i=this._objects[n];break}return i},getPointer:function(e,i,r){r||(r=this.upperCanvasEl);var n,s=t(e),o=r.getBoundingClientRect(),a=o.width||0,h=o.height||0;return a&&h||("top"in o&&"bottom"in o&&(h=Math.abs(o.top-o.bottom)),"right"in o&&"left"in o&&(a=Math.abs(o.right-o.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,i||(s=fabric.util.transformPoint(s,fabric.util.invertTransform(this.viewportTransform))),n=0===a||0===h?{width:1,height:1}:{width:r.width/a,height:r.height/h},{x:s.x*n.width,y:s.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,"");this.upperCanvasEl=this._createCanvasElement(),fabric.util.addClass(this.upperCanvasEl,"upper-canvas "+t),this.wrapperEl.appendChild(this.upperCanvasEl),this._copyCanvasStyle(this.lowerCanvasEl,this.upperCanvasEl),this._applyCanvasStyle(this.upperCanvasEl),this.contextTop=this.upperCanvasEl.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{"class":this.containerClass}),fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"}),fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.getWidth()||t.width,i=this.getHeight()||t.height;fabric.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0}),t.width=e,t.height=i,fabric.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},_setActiveObject:function(t){this._activeObject&&this._activeObject.set("active",!1),this._activeObject=t,t.set("active",!0)},setActiveObject:function(t,e){return this._setActiveObject(t),this.renderAll(),this.fire("object:selected",{target:t,e:e}),t.fire("selected",{e:e}),this},getActiveObject:function(){return this._activeObject},_discardActiveObject:function(){this._activeObject&&this._activeObject.set("active",!1),this._activeObject=null},discardActiveObject:function(t){return this._discardActiveObject(),this.renderAll(),this.fire("selection:cleared",{e:t}),this},_setActiveGroup:function(t){this._activeGroup=t,t&&t.set("active",!0)},setActiveGroup:function(t,e){return this._setActiveGroup(t),t&&(this.fire("object:selected",{target:t,e:e}),t.fire("selected",{e:e})),this},getActiveGroup:function(){return this._activeGroup},_discardActiveGroup:function(){var t=this.getActiveGroup();t&&t.destroy(),this.setActiveGroup(null)},discardActiveGroup:function(t){return this._discardActiveGroup(),this.fire("selection:cleared",{e:t}),this},deactivateAll:function(){for(var t=this.getObjects(),e=0,i=t.length;i>e;e++)t[e].set("active",!1);return this._discardActiveGroup(),this._discardActiveObject(),this},deactivateAllWithDispatch:function(t){var e=this.getActiveGroup()||this.getActiveObject();return e&&this.fire("before:selection:cleared",{target:e,e:t}),this.deactivateAll(),e&&this.fire("selection:cleared",{e:t}),this},dispose:function(){this.callSuper("dispose");var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),delete this.upperCanvasEl,t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,this},drawControls:function(t){var e=this.getActiveGroup();e?e._renderControls(t):this._drawObjectsControls(t)},_drawObjectsControls:function(t){for(var e=0,i=this._objects.length;i>e;++e)this._objects[e]&&this._objects[e].active&&(this._objects[e]._renderControls(t),this.lastRenderedObjectWithControlsAboveOverlay=this._objects[e])}});for(var o in fabric.StaticCanvas)"prototype"!==o&&(fabric.Canvas[o]=fabric.StaticCanvas[o]);fabric.isTouchSupported&&(fabric.Canvas.prototype._setCursorFromEvent=function(){}),fabric.Element=fabric.Canvas}(),function(){var t={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},e=fabric.util.addListener,i=fabric.util.removeListener;fabric.util.object.extend(fabric.Canvas.prototype,{cursorMap:["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],_initEventListeners:function(){this._bindEvents(),e(fabric.window,"resize",this._onResize),e(this.upperCanvasEl,"mousedown",this._onMouseDown),e(this.upperCanvasEl,"mousemove",this._onMouseMove),e(this.upperCanvasEl,"mousewheel",this._onMouseWheel),e(this.upperCanvasEl,"mouseout",this._onMouseOut),e(this.upperCanvasEl,"touchstart",this._onMouseDown),e(this.upperCanvasEl,"touchmove",this._onMouseMove),"undefined"!=typeof eventjs&&"add"in eventjs&&(eventjs.add(this.upperCanvasEl,"gesture",this._onGesture),eventjs.add(this.upperCanvasEl,"drag",this._onDrag),eventjs.add(this.upperCanvasEl,"orientation",this._onOrientationChange),eventjs.add(this.upperCanvasEl,"shake",this._onShake),eventjs.add(this.upperCanvasEl,"longpress",this._onLongPress))},_bindEvents:function(){this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this)},removeListeners:function(){i(fabric.window,"resize",this._onResize),i(this.upperCanvasEl,"mousedown",this._onMouseDown),i(this.upperCanvasEl,"mousemove",this._onMouseMove),i(this.upperCanvasEl,"mousewheel",this._onMouseWheel),i(this.upperCanvasEl,"mouseout",this._onMouseOut),i(this.upperCanvasEl,"touchstart",this._onMouseDown),i(this.upperCanvasEl,"touchmove",this._onMouseMove),"undefined"!=typeof eventjs&&"remove"in eventjs&&(eventjs.remove(this.upperCanvasEl,"gesture",this._onGesture),eventjs.remove(this.upperCanvasEl,"drag",this._onDrag),eventjs.remove(this.upperCanvasEl,"orientation",this._onOrientationChange),eventjs.remove(this.upperCanvasEl,"shake",this._onShake),eventjs.remove(this.upperCanvasEl,"longpress",this._onLongPress))},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t,e){this.__onMouseWheel&&this.__onMouseWheel(t,e)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t})},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onMouseDown:function(t){this.__onMouseDown(t),e(fabric.document,"touchend",this._onMouseUp),e(fabric.document,"touchmove",this._onMouseMove),i(this.upperCanvasEl,"mousemove",this._onMouseMove),i(this.upperCanvasEl,"touchmove",this._onMouseMove),"touchstart"===t.type?i(this.upperCanvasEl,"mousedown",this._onMouseDown):(e(fabric.document,"mouseup",this._onMouseUp),e(fabric.document,"mousemove",this._onMouseMove))},_onMouseUp:function(t){if(this.__onMouseUp(t),i(fabric.document,"mouseup",this._onMouseUp),i(fabric.document,"touchend",this._onMouseUp),i(fabric.document,"mousemove",this._onMouseMove),i(fabric.document,"touchmove",this._onMouseMove),e(this.upperCanvasEl,"mousemove",this._onMouseMove),e(this.upperCanvasEl,"touchmove",this._onMouseMove),"touchend"===t.type){var r=this;setTimeout(function(){e(r.upperCanvasEl,"mousedown",r._onMouseDown)},400)}},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),
4
- this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t,e){var i=this.getActiveGroup()||this.getActiveObject();return!!(t&&(t.isMoving||t!==i)||!t&&i||!t&&!i&&!this._groupSelector||e&&this._previousPointer&&this.selection&&(e.x!==this._previousPointer.x||e.y!==this._previousPointer.y))},__onMouseUp:function(t){var e,i=!0,r=this._currentTransform;if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);r&&(this._finalizeCurrentTransform(),i=!r.actionPerformed),e=i?this.findTarget(t,!0):r.target;var n=this._shouldRender(e,this.getPointer(t));this._maybeGroupObjects(t),e&&(e.isMoving=!1),n&&this.renderAll(),this._handleCursorAndEvent(t,e)},_handleCursorAndEvent:function(t,e){this._setCursorFromEvent(t,e),this.fire("mouse:up",{target:e,e:t}),e&&e.fire("mouseup",{e:t})},_finalizeCurrentTransform:function(){var t=this._currentTransform,e=t.target;e._scaling&&(e._scaling=!1),e.setCoords(),this._restoreOriginXY(e),(t.actionPerformed||this.stateful&&e.hasStateChanged())&&(this.fire("object:modified",{target:e}),e.fire("modified"))},_restoreOriginXY:function(t){if(this._previousOriginX&&this._previousOriginY){var e=t.translateToOriginPoint(t.getCenterPoint(),this._previousOriginX,this._previousOriginY);t.originX=this._previousOriginX,t.originY=this._previousOriginY,t.left=e.x,t.top=e.y,this._previousOriginX=null,this._previousOriginY=null}},_onMouseDownInDrawingMode:function(t){this._isCurrentlyDrawing=!0,this.discardActiveObject(t).renderAll(),this.clipTo&&fabric.util.clipContext(this,this.contextTop);var e=fabric.util.invertTransform(this.viewportTransform),i=fabric.util.transformPoint(this.getPointer(t,!0),e);this.freeDrawingBrush.onMouseDown(i),this.fire("mouse:down",{e:t});var r=this.findTarget(t);"undefined"!=typeof r&&r.fire("mousedown",{e:t,target:r})},_onMouseMoveInDrawingMode:function(t){if(this._isCurrentlyDrawing){var e=fabric.util.invertTransform(this.viewportTransform),i=fabric.util.transformPoint(this.getPointer(t,!0),e);this.freeDrawingBrush.onMouseMove(i)}this.setCursor(this.freeDrawingCursor),this.fire("mouse:move",{e:t});var r=this.findTarget(t);"undefined"!=typeof r&&r.fire("mousemove",{e:t,target:r})},_onMouseUpInDrawingMode:function(t){this._isCurrentlyDrawing=!1,this.clipTo&&this.contextTop.restore(),this.freeDrawingBrush.onMouseUp(),this.fire("mouse:up",{e:t});var e=this.findTarget(t);"undefined"!=typeof e&&e.fire("mouseup",{e:t,target:e})},__onMouseDown:function(t){var e="which"in t?1===t.which:0===t.button;if(e||fabric.isTouchSupported){if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._currentTransform){var i=this.findTarget(t),r=this.getPointer(t,!0);this._previousPointer=r;var n=this._shouldRender(i,r),s=this._shouldGroup(t,i);this._shouldClearSelection(t,i)?this._clearSelection(t,i,r):s&&(this._handleGrouping(t,i),i=this.getActiveGroup()),i&&(!i.selectable||!i.__corner&&s||(this._beforeTransform(t,i),this._setupCurrentTransform(t,i)),i!==this.getActiveGroup()&&i!==this.getActiveObject()&&(this.deactivateAll(),i.selectable&&this.setActiveObject(i,t))),n&&this.renderAll(),this.fire("mouse:down",{target:i,e:t}),i&&i.fire("mousedown",{e:t})}}},_beforeTransform:function(t,e){this.stateful&&e.saveState(),e._findTargetCorner(this.getPointer(t))&&this.onBeforeScaleRotate(e)},_clearSelection:function(t,e,i){this.deactivateAllWithDispatch(t),e&&e.selectable?this.setActiveObject(e,t):this.selection&&(this._groupSelector={ex:i.x,ey:i.y,top:0,left:0})},_setOriginToCenter:function(t){this._previousOriginX=this._currentTransform.target.originX,this._previousOriginY=this._currentTransform.target.originY;var e=t.getCenterPoint();t.originX="center",t.originY="center",t.left=e.x,t.top=e.y,this._currentTransform.left=t.left,this._currentTransform.top=t.top},_setCenterToOrigin:function(t){var e=t.translateToOriginPoint(t.getCenterPoint(),this._previousOriginX,this._previousOriginY);t.originX=this._previousOriginX,t.originY=this._previousOriginY,t.left=e.x,t.top=e.y,this._previousOriginX=null,this._previousOriginY=null},__onMouseMove:function(t){var e,i;if(this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!("undefined"!=typeof t.touches&&t.touches.length>1)){var r=this._groupSelector;r?(i=this.getPointer(t,!0),r.left=i.x-r.ex,r.top=i.y-r.ey,this.renderTop()):this._currentTransform?this._transformObject(t):(e=this.findTarget(t),this._setCursorFromEvent(t,e)),this.fire("mouse:move",{target:e,e:t}),e&&e.fire("mousemove",{e:t})}},_transformObject:function(t){var e=this.getPointer(t),i=this._currentTransform;i.reset=!1,i.target.isMoving=!0,this._beforeScaleTransform(t,i),this._performTransformAction(t,i,e),this.renderAll()},_performTransformAction:function(t,e,i){var r=i.x,n=i.y,s=e.target,o=e.action,a=!1;"rotate"===o?(a=this._rotateObject(r,n))&&this._fire("rotating",s,t):"scale"===o?(a=this._onScale(t,e,r,n))&&this._fire("scaling",s,t):"scaleX"===o?(a=this._scaleObject(r,n,"x"))&&this._fire("scaling",s,t):"scaleY"===o?(a=this._scaleObject(r,n,"y"))&&this._fire("scaling",s,t):"skewX"===o?(a=this._skewObject(r,n,"x"))&&this._fire("skewing",s,t):"skewY"===o?(a=this._skewObject(r,n,"y"))&&this._fire("skewing",s,t):(a=this._translateObject(r,n),a&&(this._fire("moving",s,t),this.setCursor(s.moveCursor||this.moveCursor))),e.actionPerformed=a},_fire:function(t,e,i){this.fire("object:"+t,{target:e,e:i}),e.fire(t,{e:i})},_beforeScaleTransform:function(t,e){if("scale"===e.action||"scaleX"===e.action||"scaleY"===e.action){var i=this._shouldCenterTransform(e.target);(i&&("center"!==e.originX||"center"!==e.originY)||!i&&"center"===e.originX&&"center"===e.originY)&&(this._resetCurrentTransform(),e.reset=!0)}},_onScale:function(t,e,i,r){return!t[this.uniScaleKey]&&!this.uniScaleTransform||e.target.get("lockUniScaling")?(e.reset||"scale"!==e.currentAction||this._resetCurrentTransform(),e.currentAction="scaleEqually",this._scaleObject(i,r,"equally")):(e.currentAction="scale",this._scaleObject(i,r))},_setCursorFromEvent:function(t,e){if(!e)return this.setCursor(this.defaultCursor),!1;var i=e.hoverCursor||this.hoverCursor;if(e.selectable){var r=this.getActiveGroup(),n=e._findTargetCorner&&(!r||!r.contains(e))&&e._findTargetCorner(this.getPointer(t,!0));n?this._setCornerCursor(n,e,t):this.setCursor(i)}else this.setCursor(i);return!0},_setCornerCursor:function(e,i,r){if(e in t)this.setCursor(this._getRotatedCornerCursor(e,i,r));else{if("mtr"!==e||!i.hasRotatingPoint)return this.setCursor(this.defaultCursor),!1;this.setCursor(this.rotationCursor)}},_getRotatedCornerCursor:function(e,i,r){var n=Math.round(i.getAngle()%360/45);return 0>n&&(n+=8),n+=t[e],r[this.altActionKey]&&t[e]%2===0&&(n+=2),n%=8,this.cursorMap[n]}})}(),function(){var t=Math.min,e=Math.max;fabric.util.object.extend(fabric.Canvas.prototype,{_shouldGroup:function(t,e){var i=this.getActiveObject();return t[this.selectionKey]&&e&&e.selectable&&(this.getActiveGroup()||i&&i!==e)&&this.selection},_handleGrouping:function(t,e){e===this.getActiveGroup()&&(e=this.findTarget(t,!0),!e||e.isType("group"))||(this.getActiveGroup()?this._updateActiveGroup(e,t):this._createActiveGroup(e,t),this._activeGroup&&this._activeGroup.saveCoords())},_updateActiveGroup:function(t,e){var i=this.getActiveGroup();if(i.contains(t)){if(i.removeWithUpdate(t),t.set("active",!1),1===i.size())return this.discardActiveGroup(e),void this.setActiveObject(i.item(0))}else i.addWithUpdate(t);this.fire("selection:created",{target:i,e:e}),i.set("active",!0)},_createActiveGroup:function(t,e){if(this._activeObject&&t!==this._activeObject){var i=this._createGroup(t);i.addWithUpdate(),this.setActiveGroup(i),this._activeObject=null,this.fire("selection:created",{target:i,e:e})}t.set("active",!0)},_createGroup:function(t){var e=this.getObjects(),i=e.indexOf(this._activeObject)<e.indexOf(t),r=i?[this._activeObject,t]:[t,this._activeObject];return new fabric.Group(r,{canvas:this})},_groupSelectedObjects:function(t){var e=this._collectObjects();1===e.length?this.setActiveObject(e[0],t):e.length>1&&(e=new fabric.Group(e.reverse(),{canvas:this}),e.addWithUpdate(),this.setActiveGroup(e,t),e.saveCoords(),this.fire("selection:created",{target:e}),this.renderAll())},_collectObjects:function(){for(var i,r=[],n=this._groupSelector.ex,s=this._groupSelector.ey,o=n+this._groupSelector.left,a=s+this._groupSelector.top,h=new fabric.Point(t(n,o),t(s,a)),c=new fabric.Point(e(n,o),e(s,a)),l=n===o&&s===a,u=this._objects.length;u--&&(i=this._objects[u],!(i&&i.selectable&&i.visible&&(i.intersectsWithRect(h,c)||i.isContainedWithinRect(h,c)||i.containsPoint(h)||i.containsPoint(c))&&(i.set("active",!0),r.push(i),l))););return r},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t);var e=this.getActiveGroup();e&&(e.setObjectsCoords().setCoords(),e.isMoving=!1,this.setCursor(this.defaultCursor)),this._groupSelector=null,this._currentTransform=null}})}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,r=t.multiplier||1,n={left:t.left,top:t.top,width:t.width,height:t.height};return this._isRetinaScaling()&&(r*=fabric.devicePixelRatio),1!==r?this.__toDataURLWithMultiplier(e,i,n,r):this.__toDataURL(e,i,n)},__toDataURL:function(t,e,i){this.renderAll();var r=this.contextContainer.canvas,n=this.__getCroppedCanvas(r,i);"jpg"===t&&(t="jpeg");var s=fabric.StaticCanvas.supports("toDataURLWithQuality")?(n||r).toDataURL("image/"+t,e):(n||r).toDataURL("image/"+t);return n&&(n=null),s},__getCroppedCanvas:function(t,e){var i,r,n="left"in e||"top"in e||"width"in e||"height"in e;return n&&(i=fabric.util.createCanvasElement(),r=i.getContext("2d"),i.width=e.width||this.width,i.height=e.height||this.height,r.drawImage(t,-e.left||0,-e.top||0)),i},__toDataURLWithMultiplier:function(t,e,i,r){var n=this.getWidth(),s=this.getHeight(),o=n*r,a=s*r,h=this.getActiveObject(),c=this.getActiveGroup(),l=this.getZoom(),u=l*r/fabric.devicePixelRatio;r>1&&this.setDimensions({width:o,height:a}),this.setZoom(u),i.left&&(i.left*=r),i.top&&(i.top*=r),i.width?i.width*=r:1>r&&(i.width=o),i.height?i.height*=r:1>r&&(i.height=a),c?this._tempRemoveBordersControlsFromGroup(c):h&&this.deactivateAll&&this.deactivateAll();var f=this.__toDataURL(t,e,i);return c?this._restoreBordersControlsOnGroup(c):h&&this.setActiveObject&&this.setActiveObject(h),this.setZoom(l),this.setDimensions({width:n,height:s}),f},toDataURLWithMultiplier:function(t,e,i){return this.toDataURL({format:t,multiplier:e,quality:i})},_tempRemoveBordersControlsFromGroup:function(t){t.origHasControls=t.hasControls,t.origBorderColor=t.borderColor,t.hasControls=!0,t.borderColor="rgba(0,0,0,0)",t.forEachObject(function(t){t.origBorderColor=t.borderColor,t.borderColor="rgba(0,0,0,0)"})},_restoreBordersControlsOnGroup:function(t){t.hideControls=t.origHideControls,t.borderColor=t.origBorderColor,t.forEachObject(function(t){t.borderColor=t.origBorderColor,delete t.origBorderColor})}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromDatalessJSON:function(t,e,i){return this.loadFromJSON(t,e,i)},loadFromJSON:function(t,e,i){if(t){var r="string"==typeof t?JSON.parse(t):fabric.util.object.clone(t);this.clear();var n=this;this._enlivenObjects(r.objects,function(){n._setBgOverlay(r,e)},i),delete r.objects,delete r.backgroundImage,delete r.overlayImage,delete r.background,delete r.overlay;for(var s in r)this[s]=r[s];return this}},_setBgOverlay:function(t,e){var i=this,r={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!(t.backgroundImage||t.overlayImage||t.background||t.overlay))return void(e&&e());var n=function(){r.backgroundImage&&r.overlayImage&&r.backgroundColor&&r.overlayColor&&(i.renderAll(),e&&e())};this.__setBgOverlay("backgroundImage",t.backgroundImage,r,n),this.__setBgOverlay("overlayImage",t.overlayImage,r,n),this.__setBgOverlay("backgroundColor",t.background,r,n),this.__setBgOverlay("overlayColor",t.overlay,r,n),n()},__setBgOverlay:function(t,e,i,r){var n=this;return e?void("backgroundImage"===t||"overlayImage"===t?fabric.Image.fromObject(e,function(e){n[t]=e,i[t]=!0,r&&r()}):this["set"+fabric.util.string.capitalize(t,!0)](e,function(){i[t]=!0,r&&r()})):void(i[t]=!0)},_enlivenObjects:function(t,e,i){var r=this;if(!t||0===t.length)return void(e&&e());var n=this.renderOnAddRemove;this.renderOnAddRemove=!1,fabric.util.enlivenObjects(t,function(t){t.forEach(function(t,e){r.insertAt(t,e,!0)}),r.renderOnAddRemove=n,e&&e()},null,i)},_toDataURL:function(t,e){this.clone(function(i){e(i.toDataURL(t))})},_toDataURLWithMultiplier:function(t,e,i){this.clone(function(r){i(r.toDataURLWithMultiplier(t,e))})},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData(function(e){e.loadFromJSON(i,function(){t&&t(e)})})},cloneWithoutData:function(t){var e=fabric.document.createElement("canvas");e.width=this.getWidth(),e.height=this.getHeight();var i=new fabric.Canvas(e);i.clipTo=this.clipTo,this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,function(){i.renderAll(),t&&t(i)}),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.toFixed,n=e.util.string.capitalize,s=e.util.degreesToRadians,o=e.StaticCanvas.supports("setLineDash");e.Object||(e.Object=e.util.createClass({type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",borderDashArray:null,cornerColor:"rgba(102,153,255,0.5)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:10,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:.01,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!0,rotatingPointOffset:40,perPixelTargetFind:!1,includeDefaultValues:!0,clipTo:null,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockUniScaling:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeLineJoin strokeMiterLimit angle opacity fill fillRule globalCompositeOperation shadow clipTo visible backgroundColor alignX alignY meetOrSlice skewX skewY".split(" "),initialize:function(t){t&&this.setOptions(t)},_initGradient:function(t){!t.fill||!t.fill.colorStops||t.fill instanceof e.Gradient||this.set("fill",new e.Gradient(t.fill)),!t.stroke||!t.stroke.colorStops||t.stroke instanceof e.Gradient||this.set("stroke",new e.Gradient(t.stroke))},_initPattern:function(t){!t.fill||!t.fill.source||t.fill instanceof e.Pattern||this.set("fill",new e.Pattern(t.fill)),!t.stroke||!t.stroke.source||t.stroke instanceof e.Pattern||this.set("stroke",new e.Pattern(t.stroke))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var i=e.util.getFunctionBody(t.clipTo);"undefined"!=typeof i&&(this.clipTo=new Function("ctx",i))}},setOptions:function(t){for(var e in t)this.set(e,t[e]);this._initGradient(t),this._initPattern(t),this._initClipping(t)},transform:function(t,e){this.group&&this.canvas.preserveObjectStacking&&this.group===this.canvas._activeGroup&&this.group.transform(t);var i=e?this._getLeftTopCoords():this.getCenterPoint();t.translate(i.x,i.y),t.rotate(s(this.angle)),t.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1)),t.transform(1,0,Math.tan(s(this.skewX)),1,0,0),t.transform(1,Math.tan(s(this.skewY)),0,1,0,0)},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.getAngle(),i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor,fillRule:this.fillRule,globalCompositeOperation:this.globalCompositeOperation,transformMatrix:this.transformMatrix?this.transformMatrix.concat():this.transformMatrix,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.includeDefaultValues||(n=this._removeDefaultValues(n)),e.util.populateWithProperties(this,n,t),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype,r=i.stateProperties;return r.forEach(function(e){t[e]===i[e]&&delete t[e];var r="[object Array]"===Object.prototype.toString.call(t[e])&&"[object Array]"===Object.prototype.toString.call(i[e]);r&&0===t[e].length&&0===i[e].length&&delete t[e]}),t},toString:function(){return"#<fabric."+n(this.type)+">"},get:function(t){return this[t]},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):"function"==typeof e&&"clipTo"!==t?this._set(t,e(this.get(t))):this._set(t,e),this},_set:function(t,i){var r="scaleX"===t||"scaleY"===t;return r&&(i=this._constrainScale(i)),"scaleX"===t&&0>i?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&0>i?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow||(i=new e.Shadow(i)),this[t]=i,"width"!==t&&"height"!==t||(this.minScaleLimit=Math.min(.1,1/Math.max(this.width,this.height))),this},setOnGroup:function(){},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},setSourcePath:function(t){return this.sourcePath=t,this},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:[1,0,0,1,0,0]},render:function(t,i){0===this.width&&0===this.height||!this.visible||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),i||this.transform(t),this._setStrokeStyles(t),this._setFillStyles(t),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this._setOpacity(t),this._setShadow(t),this.clipTo&&e.util.clipContext(this,t),this._render(t,i),this.clipTo&&t.restore(),t.restore())},_setOpacity:function(t){this.group&&this.group._setOpacity(t),t.globalAlpha*=this.opacity},_setStrokeStyles:function(t){this.stroke&&(t.lineWidth=this.strokeWidth,t.lineCap=this.strokeLineCap,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,t.strokeStyle=this.stroke.toLive?this.stroke.toLive(t,this):this.stroke)},_setFillStyles:function(t){this.fill&&(t.fillStyle=this.fill.toLive?this.fill.toLive(t,this):this.fill)},_setLineDash:function(t,e,i){e&&(1&e.length&&e.push.apply(e,e),o?t.setLineDash(e):i&&i(t))},_renderControls:function(t,i){if(!(!this.active||i||this.group&&this.group!==this.canvas.getActiveGroup())){var r,n=this.getViewportTransform(),o=this.calcTransformMatrix();o=e.util.multiplyTransformMatrices(n,o),r=e.util.qrDecompose(o),t.save(),t.translate(r.translateX,r.translateY),t.lineWidth=1/this.borderScaleFactor,t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.group&&this.group===this.canvas.getActiveGroup()?(t.rotate(s(r.angle)),this.drawBordersInGroup(t,r)):(t.rotate(s(this.angle)),this.drawBorders(t)),this.drawControls(t),t.restore()}},_setShadow:function(t){if(this.shadow){var i=this.canvas&&this.canvas.viewportTransform[0]||1,r=this.canvas&&this.canvas.viewportTransform[3]||1;this.canvas&&this.canvas._isRetinaScaling()&&(i*=e.devicePixelRatio,r*=e.devicePixelRatio),t.shadowColor=this.shadow.color,t.shadowBlur=this.shadow.blur*(i+r)*(this.scaleX+this.scaleY)/4,t.shadowOffsetX=this.shadow.offsetX*i*this.scaleX,t.shadowOffsetY=this.shadow.offsetY*r*this.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_renderFill:function(t){if(this.fill){if(t.save(),this.fill.gradientTransform){var e=this.fill.gradientTransform;t.transform.apply(t,e)}this.fill.toLive&&t.translate(-this.width/2+this.fill.offsetX||0,-this.height/2+this.fill.offsetY||0),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore()}},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray,this._renderDashedStroke),this.stroke.gradientTransform){var e=this.stroke.gradientTransform;t.transform.apply(t,e)}this.stroke.toLive&&t.translate(-this.width/2+this.stroke.offsetX||0,-this.height/2+this.stroke.offsetY||0),t.stroke(),t.restore()}},clone:function(t,i){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(i),t):new e.Object(this.toObject(i))},cloneAsImage:function(t){var i=this.toDataURL();return e.util.loadImage(i,function(i){t&&t(new e.Image(i))}),this},toDataURL:function(t){t||(t={});var i=e.util.createCanvasElement(),r=this.getBoundingRect();i.width=r.width,i.height=r.height,e.util.wrapElement(i,"div");var n=new e.StaticCanvas(i);"jpg"===t.format&&(t.format="jpeg"),"jpeg"===t.format&&(n.backgroundColor="#fff");var s={active:this.get("active"),left:this.getLeft(),top:this.getTop()};this.set("active",!1),this.setPositionByOrigin(new e.Point(n.getWidth()/2,n.getHeight()/2),"center","center");var o=this.canvas;n.add(this);var a=n.toDataURL(t);return this.set(s).setCoords(),this.canvas=o,n.dispose(),n=null,a},isType:function(t){return this.type===t},complexity:function(){return 0},toJSON:function(t){return this.toObject(t)},setGradient:function(t,i){i||(i={});var r={colorStops:[]};r.type=i.type||(i.r1||i.r2?"radial":"linear"),r.coords={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},(i.r1||i.r2)&&(r.coords.r1=i.r1,r.coords.r2=i.r2),i.gradientTransform&&(r.gradientTransform=i.gradientTransform);for(var n in i.colorStops){var s=new e.Color(i.colorStops[n]);r.colorStops.push({offset:n,color:s.toRgb(),opacity:s.getAlpha()})}return this.set(t,e.Gradient.forObject(this,r))},setPatternFill:function(t){return this.set("fill",new e.Pattern(t))},setShadow:function(t){return this.set("shadow",t?new e.Shadow(t):null)},setColor:function(t){return this.set("fill",t),this},setAngle:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas.centerObjectH(this),this},centerV:function(){return this.canvas.centerObjectV(this),this},center:function(){return this.canvas.centerObject(this),this},remove:function(){return this.canvas.remove(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var r=new e.Point(i.x,i.y),n=this._getLeftTopCoords();return this.angle&&(r=e.util.rotatePoint(r,n,e.util.degreesToRadians(-this.angle))),{x:r.x-n.x,y:r.y-n.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}}),e.util.createAccessors(e.Object),e.Object.prototype.rotate=e.Object.prototype.setAngle,i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.__uid=0)}("undefined"!=typeof exports?exports:this),function(){var t=fabric.util.degreesToRadians,e={left:-.5,center:0,right:.5},i={top:-.5,center:0,bottom:.5};fabric.util.object.extend(fabric.Object.prototype,{translateToGivenOrigin:function(t,r,n,s,o){var a,h=t.x,c=t.y,l=e[s]-e[r],u=i[o]-i[n];return(l||u)&&(a=this._getTransformedDimensions(),h=t.x+l*a.x,c=t.y+u*a.y),new fabric.Point(h,c)},translateToCenterPoint:function(e,i,r){var n=this.translateToGivenOrigin(e,i,r,"center","center");return this.angle?fabric.util.rotatePoint(n,e,t(this.angle)):n},translateToOriginPoint:function(e,i,r){var n=this.translateToGivenOrigin(e,"center","center",i,r);return this.angle?fabric.util.rotatePoint(n,e,t(this.angle)):n},getCenterPoint:function(){var t=new fabric.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(e,i,r){var n,s,o=this.getCenterPoint();return n=i&&r?this.translateToGivenOrigin(o,"center","center",i,r):new fabric.Point(this.left,this.top),s=new fabric.Point(e.x,e.y),this.angle&&(s=fabric.util.rotatePoint(s,o,-t(this.angle))),s.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var r=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(r,this.originX,this.originY);this.set("left",n.x),this.set("top",n.y)},adjustPosition:function(i){var r=t(this.angle),n=this.getWidth(),s=Math.cos(r)*n,o=Math.sin(r)*n;this.left+=s*(e[i]-e[this.originX]),this.top+=o*(e[i]-e[this.originX]),this.setCoords(),this.originX=i},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})}(),function(){function t(t){return[new fabric.Point(t.tl.x,t.tl.y),new fabric.Point(t.tr.x,t.tr.y),new fabric.Point(t.br.x,t.br.y),new fabric.Point(t.bl.x,t.bl.y)]}var e=fabric.util.degreesToRadians,i=fabric.util.multiplyTransformMatrices;fabric.util.object.extend(fabric.Object.prototype,{oCoords:null,intersectsWithRect:function(e,i){var r=t(this.oCoords),n=fabric.Intersection.intersectPolygonRectangle(r,e,i);return"Intersection"===n.status},intersectsWithObject:function(e){var i=fabric.Intersection.intersectPolygonPolygon(t(this.oCoords),t(e.oCoords));return"Intersection"===i.status},isContainedWithinObject:function(t){var e=t.getBoundingRect(),i=new fabric.Point(e.left,e.top),r=new fabric.Point(e.left+e.width,e.top+e.height);return this.isContainedWithinRect(i,r)},isContainedWithinRect:function(t,e){var i=this.getBoundingRect();return i.left>=t.x&&i.left+i.width<=e.x&&i.top>=t.y&&i.top+i.height<=e.y},containsPoint:function(t){var e=this._getImageLines(this.oCoords),i=this._findCrossPoints(t,e);return 0!==i&&i%2===1},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,r,n,s,o,a,h,c=0;for(var l in e)if(h=e[l],!(h.o.y<t.y&&h.d.y<t.y||h.o.y>=t.y&&h.d.y>=t.y||(h.o.x===h.d.x&&h.o.x>=t.x?(o=h.o.x,a=t.y):(i=0,r=(h.d.y-h.o.y)/(h.d.x-h.o.x),n=t.y-i*t.x,s=h.o.y-r*h.o.x,o=-(n-s)/(i-r),a=n+i*o),o>=t.x&&(c+=1),2!==c)))break;return c},getBoundingRectWidth:function(){return this.getBoundingRect().width},getBoundingRectHeight:function(){return this.getBoundingRect().height},getBoundingRect:function(){return this.oCoords||this.setCoords(),fabric.util.makeBoundingBoxFromPoints([this.oCoords.tl,this.oCoords.tr,this.oCoords.br,this.oCoords.bl])},getWidth:function(){return this._getTransformedDimensions().x},getHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)<this.minScaleLimit?0>t?-this.minScaleLimit:this.minScaleLimit:t},scale:function(t){return t=this._constrainScale(t),0>t&&(this.flipX=!this.flipX,this.flipY=!this.flipY,t*=-1),this.scaleX=t,this.scaleY=t,this.setCoords(),this},scaleToWidth:function(t){var e=this.getBoundingRect().width/this.getWidth();return this.scale(t/this.width/e)},scaleToHeight:function(t){var e=this.getBoundingRect().height/this.getHeight();return this.scale(t/this.height/e)},setCoords:function(){var t=e(this.angle),i=this.getViewportTransform(),r=this._calculateCurrentDimensions(),n=r.x,s=r.y;0>n&&(n=Math.abs(n));var o=Math.sin(t),a=Math.cos(t),h=n>0?Math.atan(s/n):0,c=n/Math.cos(h)/2,l=Math.cos(h+t)*c,u=Math.sin(h+t)*c,f=fabric.util.transformPoint(this.getCenterPoint(),i),d=new fabric.Point(f.x-l,f.y-u),g=new fabric.Point(d.x+n*a,d.y+n*o),p=new fabric.Point(d.x-s*o,d.y+s*a),v=new fabric.Point(f.x+l,f.y+u),b=new fabric.Point((d.x+p.x)/2,(d.y+p.y)/2),m=new fabric.Point((g.x+d.x)/2,(g.y+d.y)/2),y=new fabric.Point((v.x+g.x)/2,(v.y+g.y)/2),_=new fabric.Point((v.x+p.x)/2,(v.y+p.y)/2),x=new fabric.Point(m.x+o*this.rotatingPointOffset,m.y-a*this.rotatingPointOffset);return this.oCoords={tl:d,tr:g,br:v,bl:p,ml:b,mt:m,mr:y,mb:_,mtr:x},this._setCornerCoords&&this._setCornerCoords(),this},_calcRotateMatrix:function(){if(this.angle){var t=e(this.angle),i=Math.cos(t),r=Math.sin(t);return[i,r,-r,i,0,0]}return[1,0,0,1,0,0]},calcTransformMatrix:function(){var t=this.getCenterPoint(),e=[1,0,0,1,t.x,t.y],r=this._calcRotateMatrix(),n=this._calcDimensionsTransformMatrix(this.skewX,this.skewY,!0),s=this.group?this.group.calcTransformMatrix():[1,0,0,1,0,0];return s=i(s,e),s=i(s,r),s=i(s,n)},_calcDimensionsTransformMatrix:function(t,r,n){var s=[1,0,Math.tan(e(t)),1],o=[1,Math.tan(e(r)),0,1],a=this.scaleX*(n&&this.flipX?-1:1),h=this.scaleY*(n&&this.flipY?-1:1),c=[a,0,0,h],l=i(c,s,!0);return i(l,o,!0)}})}(),fabric.util.object.extend(fabric.Object.prototype,{sendToBack:function(){return this.group?fabric.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?fabric.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas.bringToFront(this),this},sendBackwards:function(t){return this.group?fabric.StaticCanvas.prototype.sendBackwards.call(this.group,this,t):this.canvas.sendBackwards(this,t),this},bringForward:function(t){return this.group?fabric.StaticCanvas.prototype.bringForward.call(this.group,this,t):this.canvas.bringForward(this,t),this},moveTo:function(t){return this.group?fabric.StaticCanvas.prototype.moveTo.call(this.group,this,t):this.canvas.moveTo(this,t),this}}),function(){function t(t,e){if(e){if(e.toLive)return t+": url(#SVGID_"+e.id+"); ";var i=new fabric.Color(e),r=t+": "+e+"; ",n=i.getAlpha();return 1!==n&&(r=t+": "+i.toRgb()+"; ",r+=t+"-opacity: "+n.toString()+"; "),r}return t+": none; "}fabric.util.object.extend(fabric.Object.prototype,{getSvgStyles:function(e){var i=this.fillRule,r=this.strokeWidth?this.strokeWidth:"0",n=this.strokeDashArray?this.strokeDashArray.join(" "):"none",s=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",h="undefined"!=typeof this.opacity?this.opacity:"1",c=this.visible?"":" visibility: hidden;",l=e?"":this.getSvgFilter(),u=t("fill",this.fill),f=t("stroke",this.stroke);return[f,"stroke-width: ",r,"; ","stroke-dasharray: ",n,"; ","stroke-linecap: ",s,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",u,"fill-rule: ",i,"; ","opacity: ",h,";",l,c].join("")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgTransform:function(){if(this.group&&"path-group"===this.group.type)return"";var t=fabric.util.toFixed,e=this.getAngle(),i=this.getSkewX()%360,r=this.getSkewY()%360,n=this.getCenterPoint(),s=fabric.Object.NUM_FRACTION_DIGITS,o="path-group"===this.type?"":"translate("+t(n.x,s)+" "+t(n.y,s)+")",a=0!==e?" rotate("+t(e,s)+")":"",h=1===this.scaleX&&1===this.scaleY?"":" scale("+t(this.scaleX,s)+" "+t(this.scaleY,s)+")",c=0!==i?" skewX("+t(i,s)+")":"",l=0!==r?" skewY("+t(r,s)+")":"",u="path-group"===this.type?this.width:0,f=this.flipX?" matrix(-1 0 0 1 "+u+" 0) ":"",d="path-group"===this.type?this.height:0,g=this.flipY?" matrix(1 0 0 -1 0 "+d+")":"";
5
- return[o,a,h,f,g,c,l].join("")},getSvgTransformMatrix:function(){return this.transformMatrix?" matrix("+this.transformMatrix.join(" ")+") ":""},_createBaseSVGMarkup:function(){var t=[];return this.fill&&this.fill.toLive&&t.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&t.push(this.stroke.toSVG(this,!1)),this.shadow&&t.push(this.shadow.toSVG(this)),t}})}(),fabric.util.object.extend(fabric.Object.prototype,{hasStateChanged:function(){return this.stateProperties.some(function(t){return this.get(t)!==this.originalState[t]},this)},saveState:function(t){return this.stateProperties.forEach(function(t){this.originalState[t]=this.get(t)},this),t&&t.stateProperties&&t.stateProperties.forEach(function(t){this.originalState[t]=this.get(t)},this),this},setupState:function(){return this.originalState={},this.saveState(),this}}),function(){var t=fabric.util.degreesToRadians,e=function(){return"undefined"!=typeof G_vmlCanvasManager};fabric.util.object.extend(fabric.Object.prototype,{_controlsVisibility:null,_findTargetCorner:function(t){if(!this.hasControls||!this.active)return!1;var e,i,r=t.x,n=t.y;this.__corner=0;for(var s in this.oCoords)if(this.isControlVisible(s)&&("mtr"!==s||this.hasRotatingPoint)&&(!this.get("lockUniScaling")||"mt"!==s&&"mr"!==s&&"mb"!==s&&"ml"!==s)&&(i=this._getImageLines(this.oCoords[s].corner),e=this._findCrossPoints({x:r,y:n},i),0!==e&&e%2===1))return this.__corner=s,s;return!1},_setCornerCoords:function(){var e,i,r=this.oCoords,n=t(45-this.angle),s=.707106*this.cornerSize,o=s*Math.cos(n),a=s*Math.sin(n);for(var h in r)e=r[h].x,i=r[h].y,r[h].corner={tl:{x:e-a,y:i-o},tr:{x:e+o,y:i-a},bl:{x:e-o,y:i+a},br:{x:e+a,y:i+o}}},_getNonTransformedDimensions:function(){var t=this.strokeWidth,e=this.width,i=this.height,r=!0,n=!0;return"line"===this.type&&"butt"===this.strokeLineCap&&(n=e,r=i),n&&(i+=0>i?-t:t),r&&(e+=0>e?-t:t),{x:e,y:i}},_getTransformedDimensions:function(t,e){"undefined"==typeof t&&(t=this.skewX),"undefined"==typeof e&&(e=this.skewY);var i,r,n=this._getNonTransformedDimensions(),s=n.x/2,o=n.y/2,a=[{x:-s,y:-o},{x:s,y:-o},{x:-s,y:o},{x:s,y:o}],h=this._calcDimensionsTransformMatrix(t,e,!1);for(i=0;i<a.length;i++)a[i]=fabric.util.transformPoint(a[i],h);return r=fabric.util.makeBoundingBoxFromPoints(a),{x:r.width,y:r.height}},_calculateCurrentDimensions:function(){var t=this.getViewportTransform(),e=this._getTransformedDimensions(),i=e.x,r=e.y;return i+=2*this.padding,r+=2*this.padding,fabric.util.transformPoint(new fabric.Point(i,r),t,!0)},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||!this.active||this.group)return this;e.save();var i=this.getCenterPoint(),r=this._calculateCurrentDimensions();return e.translate(i.x,i.y),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-r.x/2,-r.y/2,r.x,r.y),e.restore(),this},drawBorders:function(t){if(!this.hasBorders)return this;var e=this._calculateCurrentDimensions(),i=1/this.borderScaleFactor,r=e.x+i,n=e.y+i;if(t.save(),t.strokeStyle=this.borderColor,this._setLineDash(t,this.borderDashArray,null),t.strokeRect(-r/2,-n/2,r,n),this.hasRotatingPoint&&this.isControlVisible("mtr")&&!this.get("lockRotation")&&this.hasControls){var s=-n/2;t.beginPath(),t.moveTo(0,s),t.lineTo(0,s-this.rotatingPointOffset),t.closePath(),t.stroke()}return t.restore(),this},drawBordersInGroup:function(t,e){if(!this.hasBorders)return this;var i=this._getNonTransformedDimensions(),r=fabric.util.customTransformMatrix(e.scaleX,e.scaleY,e.skewX),n=fabric.util.transformPoint(i,r),s=1/this.borderScaleFactor,o=n.x+s+2*this.padding,a=n.y+s+2*this.padding;return t.save(),this._setLineDash(t,this.borderDashArray,null),t.strokeStyle=this.borderColor,t.strokeRect(-o/2,-a/2,o,a),t.restore(),this},drawControls:function(t){if(!this.hasControls)return this;var e=this._calculateCurrentDimensions(),i=e.x,r=e.y,n=this.cornerSize,s=-(i+n)/2,o=-(r+n)/2,a=this.transparentCorners?"stroke":"fill";return t.save(),t.strokeStyle=t.fillStyle=this.cornerColor,this.transparentCorners||(t.strokeStyle=this.cornerStrokeColor),this._setLineDash(t,this.cornerDashArray,null),this._drawControl("tl",t,a,s,o),this._drawControl("tr",t,a,s+i,o),this._drawControl("bl",t,a,s,o+r),this._drawControl("br",t,a,s+i,o+r),this.get("lockUniScaling")||(this._drawControl("mt",t,a,s+i/2,o),this._drawControl("mb",t,a,s+i/2,o+r),this._drawControl("mr",t,a,s+i,o+r/2),this._drawControl("ml",t,a,s,o+r/2)),this.hasRotatingPoint&&this._drawControl("mtr",t,a,s+i/2,o-this.rotatingPointOffset),t.restore(),this},_drawControl:function(t,i,r,n,s){if(this.isControlVisible(t)){var o=this.cornerSize,a=!this.transparentCorners&&this.cornerStrokeColor;switch(this.cornerStyle){case"circle":i.beginPath(),i.arc(n+o/2,s+o/2,o/2,0,2*Math.PI,!1),i[r](),a&&i.stroke();break;default:e()||this.transparentCorners||i.clearRect(n,s,o,o),i[r+"Rect"](n,s,o,o),a&&i.strokeRect(n,s,o,o)}}},isControlVisible:function(t){return this._getControlsVisibility()[t]},setControlVisible:function(t,e){return this._getControlsVisibility()[t]=e,this},setControlsVisibility:function(t){t||(t={});for(var e in t)this.setControlVisible(e,t[e]);return this},_getControlsVisibility:function(){return this._controlsVisibility||(this._controlsVisibility={tl:!0,tr:!0,br:!0,bl:!0,ml:!0,mt:!0,mr:!0,mb:!0,mtr:!0}),this._controlsVisibility}})}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){e=e||{};var i=function(){},r=e.onComplete||i,n=e.onChange||i,s=this;return fabric.util.animate({startValue:t.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.renderAll(),n()},onComplete:function(){t.setCoords(),r()}}),this},fxCenterObjectV:function(t,e){e=e||{};var i=function(){},r=e.onComplete||i,n=e.onChange||i,s=this;return fabric.util.animate({startValue:t.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.renderAll(),n()},onComplete:function(){t.setCoords(),r()}}),this},fxRemove:function(t,e){e=e||{};var i=function(){},r=e.onComplete||i,n=e.onChange||i,s=this;return fabric.util.animate({startValue:t.get("opacity"),endValue:0,duration:this.FX_DURATION,onStart:function(){t.set("active",!1)},onChange:function(e){t.set("opacity",e),s.renderAll(),n()},onComplete:function(){s.remove(t),r()}}),this}}),fabric.util.object.extend(fabric.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[];for(t in arguments[0])i.push(t);for(var r=0,n=i.length;n>r;r++)t=i[r],e=r!==n-1,this._animate(t,arguments[0][t],arguments[1],e)}else this._animate.apply(this,arguments);return this},_animate:function(t,e,i,r){var n,s=this;e=e.toString(),i=i?fabric.util.object.clone(i):{},~t.indexOf(".")&&(n=t.split("."));var o=n?this.get(n[0])[n[1]]:this.get(t);"from"in i||(i.from=o),e=~e.indexOf("=")?o+parseFloat(e.replace("=","")):parseFloat(e),fabric.util.animate({startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(){return i.abort.call(s)},onChange:function(e){n?s[n[0]][n[1]]=e:s.set(t,e),r||i.onChange&&i.onChange()},onComplete:function(){r||(s.setCoords(),i.onComplete&&i.onComplete())}})}}),function(t){"use strict";function e(t,e){var i=t.origin,r=t.axis1,n=t.axis2,s=t.dimension,o=e.nearest,a=e.center,h=e.farthest;return function(){switch(this.get(i)){case o:return Math.min(this.get(r),this.get(n));case a:return Math.min(this.get(r),this.get(n))+.5*this.get(s);case h:return Math.max(this.get(r),this.get(n))}}}var i=t.fabric||(t.fabric={}),r=i.util.object.extend,n={x1:1,x2:1,y1:1,y2:1},s=i.StaticCanvas.supports("setLineDash");return i.Line?void i.warn("fabric.Line is already defined"):(i.Line=i.util.createClass(i.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,initialize:function(t,e){e=e||{},t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),"undefined"!=typeof n[t]&&this._setWidthHeight(),this},_getLeftToOriginX:e({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:e({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t,e){if(t.beginPath(),e){var i=this.getCenterPoint();t.translate(i.x-this.strokeWidth/2,i.y-this.strokeWidth/2)}if(!this.strokeDashArray||this.strokeDashArray&&s){var r=this.calcLinePoints();t.moveTo(r.x1,r.y1),t.lineTo(r.x2,r.y2)}t.lineWidth=this.strokeWidth;var n=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=n},_renderDashedStroke:function(t){var e=this.calcLinePoints();t.beginPath(),i.util.drawDashedLine(t,e.x1,e.y1,e.x2,e.y2,this.strokeDashArray),t.closePath()},toObject:function(t){return r(this.callSuper("toObject",t),this.calcLinePoints())},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,r=e*this.height*.5,n=t*this.width*-.5,s=e*this.height*-.5;return{x1:i,x2:n,y1:r,y2:s}},toSVG:function(t){var e=this._createBaseSVGMarkup(),i={x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2};return this.group&&"path-group"===this.group.type||(i=this.calcLinePoints()),e.push("<line ",'x1="',i.x1,'" y1="',i.y1,'" x2="',i.x2,'" y2="',i.y2,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),t?t(e.join("")):e.join("")},complexity:function(){return 1}}),i.Line.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),i.Line.fromElement=function(t,e){var n=i.parseAttributes(t,i.Line.ATTRIBUTE_NAMES),s=[n.x1||0,n.y1||0,n.x2||0,n.y2||0];return new i.Line(s,r(n,e))},void(i.Line.fromObject=function(t){var e=[t.x1,t.y1,t.x2,t.y2];return new i.Line(e,t)}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";function e(t){return"radius"in t&&t.radius>=0}var i=t.fabric||(t.fabric={}),r=Math.PI,n=i.util.object.extend;return i.Circle?void i.warn("fabric.Circle is already defined."):(i.Circle=i.util.createClass(i.Object,{type:"circle",radius:0,startAngle:0,endAngle:2*r,initialize:function(t){t=t||{},this.callSuper("initialize",t),this.set("radius",t.radius||0),this.startAngle=t.startAngle||this.startAngle,this.endAngle=t.endAngle||this.endAngle},_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return n(this.callSuper("toObject",t),{radius:this.get("radius"),startAngle:this.startAngle,endAngle:this.endAngle})},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=0,n=0,s=(this.endAngle-this.startAngle)%(2*r);if(0===s)this.group&&"path-group"===this.group.type&&(i=this.left+this.radius,n=this.top+this.radius),e.push("<circle ",'cx="'+i+'" cy="'+n+'" ','r="',this.radius,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n');else{var o=Math.cos(this.startAngle)*this.radius,a=Math.sin(this.startAngle)*this.radius,h=Math.cos(this.endAngle)*this.radius,c=Math.sin(this.endAngle)*this.radius,l=s>r?"1":"0";e.push('<path d="M '+o+" "+a," A "+this.radius+" "+this.radius," 0 ",+l+" 1"," "+h+" "+c,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n')}return t?t(e.join("")):e.join("")},_render:function(t,e){t.beginPath(),t.arc(e?this.left+this.radius:0,e?this.top+this.radius:0,this.radius,this.startAngle,this.endAngle,!1),this._renderFill(t),this._renderStroke(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)},complexity:function(){return 1}}),i.Circle.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),i.Circle.fromElement=function(t,r){r||(r={});var s=i.parseAttributes(t,i.Circle.ATTRIBUTE_NAMES);if(!e(s))throw new Error("value of `r` attribute is required and can not be negative");s.left=s.left||0,s.top=s.top||0;var o=new i.Circle(n(s,r));return o.left-=o.radius,o.top-=o.radius,o},void(i.Circle.fromObject=function(t){return new i.Circle(t)}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});return e.Triangle?void e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",initialize:function(t){t=t||{},this.callSuper("initialize",t),this.set("width",t.width||100).set("height",t.height||100)},_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderFill(t),this._renderStroke(t)},_renderDashedStroke:function(t){var i=this.width/2,r=this.height/2;t.beginPath(),e.util.drawDashedLine(t,-i,r,0,-r,this.strokeDashArray),e.util.drawDashedLine(t,0,-r,i,r,this.strokeDashArray),e.util.drawDashedLine(t,i,r,-i,r,this.strokeDashArray),t.closePath()},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this.width/2,r=this.height/2,n=[-i+" "+r,"0 "+-r,i+" "+r].join(",");return e.push("<polygon ",'points="',n,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),t?t(e.join("")):e.join("")},complexity:function(){return 1}}),void(e.Triangle.fromObject=function(t){return new e.Triangle(t)}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=2*Math.PI,r=e.util.object.extend;return e.Ellipse?void e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,initialize:function(t){t=t||{},this.callSuper("initialize",t),this.set("rx",t.rx||0),this.set("ry",t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return r(this.callSuper("toObject",t),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=0,r=0;return this.group&&"path-group"===this.group.type&&(i=this.left+this.rx,r=this.top+this.ry),e.push("<ellipse ",'cx="',i,'" cy="',r,'" ','rx="',this.rx,'" ry="',this.ry,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),t?t(e.join("")):e.join("")},_render:function(t,e){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(e?this.left+this.rx:0,e?(this.top+this.ry)*this.rx/this.ry:0,this.rx,0,i,!1),t.restore(),this._renderFill(t),this._renderStroke(t)},complexity:function(){return 1}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){i||(i={});var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=n.left||0,n.top=n.top||0;var s=new e.Ellipse(r(n,i));return s.top-=s.ry,s.left-=s.rx,s},void(e.Ellipse.fromObject=function(t){return new e.Ellipse(t)}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;if(e.Rect)return void e.warn("fabric.Rect is already defined");var r=e.Object.prototype.stateProperties.concat();r.push("rx","ry","x","y"),e.Rect=e.util.createClass(e.Object,{stateProperties:r,type:"rect",rx:0,ry:0,strokeDashArray:null,initialize:function(t){t=t||{},this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t,e){if(1===this.width&&1===this.height)return void t.fillRect(-.5,-.5,1,1);var i=this.rx?Math.min(this.rx,this.width/2):0,r=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,s=this.height,o=e?this.left:-this.width/2,a=e?this.top:-this.height/2,h=0!==i||0!==r,c=.4477152502;t.beginPath(),t.moveTo(o+i,a),t.lineTo(o+n-i,a),h&&t.bezierCurveTo(o+n-c*i,a,o+n,a+c*r,o+n,a+r),t.lineTo(o+n,a+s-r),h&&t.bezierCurveTo(o+n,a+s-c*r,o+n-c*i,a+s,o+n-i,a+s),t.lineTo(o+i,a+s),h&&t.bezierCurveTo(o+c*i,a+s,o,a+s-c*r,o,a+s-r),t.lineTo(o,a+r),h&&t.bezierCurveTo(o,a+c*r,o+c*i,a,o+i,a),t.closePath(),this._renderFill(t),this._renderStroke(t)},_renderDashedStroke:function(t){var i=-this.width/2,r=-this.height/2,n=this.width,s=this.height;t.beginPath(),e.util.drawDashedLine(t,i,r,i+n,r,this.strokeDashArray),e.util.drawDashedLine(t,i+n,r,i+n,r+s,this.strokeDashArray),e.util.drawDashedLine(t,i+n,r+s,i,r+s,this.strokeDashArray),e.util.drawDashedLine(t,i,r+s,i,r,this.strokeDashArray),t.closePath()},toObject:function(t){var e=i(this.callSuper("toObject",t),{rx:this.get("rx")||0,ry:this.get("ry")||0});return this.includeDefaultValues||this._removeDefaultValues(e),e},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this.left,r=this.top;return this.group&&"path-group"===this.group.type||(i=-this.width/2,r=-this.height/2),e.push("<rect ",'x="',i,'" y="',r,'" rx="',this.get("rx"),'" ry="',this.get("ry"),'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),t?t(e.join("")):e.join("")},complexity:function(){return 1}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,r){if(!t)return null;r=r||{};var n=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);n.left=n.left||0,n.top=n.top||0;var s=new e.Rect(i(r?e.util.object.clone(r):{},n));return s.visible=s.width>0&&s.height>0,s},e.Rect.fromObject=function(t){return new e.Rect(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});return e.Polyline?void e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,minX:0,minY:0,initialize:function(t,i){return e.Polygon.prototype.initialize.call(this,t,i)},_calcDimensions:function(){return e.Polygon.prototype._calcDimensions.call(this)},_applyPointOffset:function(){return e.Polygon.prototype._applyPointOffset.call(this)},toObject:function(t){return e.Polygon.prototype.toObject.call(this,t)},toSVG:function(t){return e.Polygon.prototype.toSVG.call(this,t)},_render:function(t,i){e.Polygon.prototype.commonRender.call(this,t,i)&&(this._renderFill(t),this._renderStroke(t))},_renderDashedStroke:function(t){var i,r;t.beginPath();for(var n=0,s=this.points.length;s>n;n++)i=this.points[n],r=this.points[n+1]||i,e.util.drawDashedLine(t,i.x,i.y,r.x,r.y,this.strokeDashArray)},complexity:function(){return this.get("points").length}}),e.Polyline.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polyline.fromElement=function(t,i){if(!t)return null;i||(i={});var r=e.parsePointsAttribute(t.getAttribute("points")),n=e.parseAttributes(t,e.Polyline.ATTRIBUTE_NAMES);return new e.Polyline(r,e.util.object.extend(n,i))},void(e.Polyline.fromObject=function(t){var i=t.points;return new e.Polyline(i,t,!0)}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,n=e.util.array.max,s=e.util.toFixed;return e.Polygon?void e.warn("fabric.Polygon is already defined"):(e.Polygon=e.util.createClass(e.Object,{type:"polygon",points:null,minX:0,minY:0,initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._calcDimensions(),"top"in e||(this.top=this.minY),"left"in e||(this.left=this.minX),this.pathOffset={x:this.minX+this.width/2,y:this.minY+this.height/2}},_calcDimensions:function(){var t=this.points,e=r(t,"x"),i=r(t,"y"),s=n(t,"x"),o=n(t,"y");this.width=s-e||0,this.height=o-i||0,this.minX=e||0,this.minY=i||0},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},toSVG:function(t){for(var e,i=[],r=this._createBaseSVGMarkup(),n=0,o=this.points.length;o>n;n++)i.push(s(this.points[n].x,2),",",s(this.points[n].y,2)," ");return this.group&&"path-group"===this.group.type||(e=" translate("+-this.pathOffset.x+", "+-this.pathOffset.y+") "),r.push("<",this.type," ",'points="',i.join(""),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),e," ",this.getSvgTransformMatrix(),'"/>\n'),t?t(r.join("")):r.join("")},_render:function(t,e){this.commonRender(t,e)&&(this._renderFill(t),(this.stroke||this.strokeDashArray)&&(t.closePath(),this._renderStroke(t)))},commonRender:function(t,e){var i,r=this.points.length;if(!r||isNaN(this.points[r-1].y))return!1;e||t.translate(-this.pathOffset.x,-this.pathOffset.y),t.beginPath(),t.moveTo(this.points[0].x,this.points[0].y);for(var n=0;r>n;n++)i=this.points[n],t.lineTo(i.x,i.y);return!0},_renderDashedStroke:function(t){e.Polyline.prototype._renderDashedStroke.call(this,t),t.closePath()},complexity:function(){return this.points.length}}),e.Polygon.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polygon.fromElement=function(t,r){if(!t)return null;r||(r={});var n=e.parsePointsAttribute(t.getAttribute("points")),s=e.parseAttributes(t,e.Polygon.ATTRIBUTE_NAMES);return new e.Polygon(n,i(s,r))},void(e.Polygon.fromObject=function(t){return new e.Polygon(t.points,t,!0)}))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,r=e.util.array.max,n=e.util.object.extend,s=Object.prototype.toString,o=e.util.drawArc,a={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},h={m:"l",M:"L"};return e.Path?void e.warn("fabric.Path is already defined"):(e.Path=e.util.createClass(e.Object,{type:"path",path:null,minX:0,minY:0,initialize:function(t,e){e=e||{},this.setOptions(e),t||(t=[]);var i="[object Array]"===s.call(t);this.path=i?t:t.match&&t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi),this.path&&(i||(this.path=this._parsePath()),this._setPositionDimensions(e),e.sourcePath&&this.setSourcePath(e.sourcePath))},_setPositionDimensions:function(t){var e=this._parseDimensions();this.minX=e.left,this.minY=e.top,this.width=e.width,this.height=e.height,"undefined"==typeof t.left&&(this.left=e.left+("center"===this.originX?this.width/2:"right"===this.originX?this.width:0)),"undefined"==typeof t.top&&(this.top=e.top+("center"===this.originY?this.height/2:"bottom"===this.originY?this.height:0)),this.pathOffset=this.pathOffset||{x:this.minX+this.width/2,y:this.minY+this.height/2}},_render:function(t){var e,i,r,n=null,s=0,a=0,h=0,c=0,l=0,u=0,f=-this.pathOffset.x,d=-this.pathOffset.y;this.group&&"path-group"===this.group.type&&(f=0,d=0),t.beginPath();for(var g=0,p=this.path.length;p>g;++g){switch(e=this.path[g],e[0]){case"l":h+=e[1],c+=e[2],t.lineTo(h+f,c+d);break;case"L":h=e[1],c=e[2],t.lineTo(h+f,c+d);break;case"h":h+=e[1],t.lineTo(h+f,c+d);break;case"H":h=e[1],t.lineTo(h+f,c+d);break;case"v":c+=e[1],t.lineTo(h+f,c+d);break;case"V":c=e[1],t.lineTo(h+f,c+d);break;case"m":h+=e[1],c+=e[2],s=h,a=c,t.moveTo(h+f,c+d);break;case"M":h=e[1],c=e[2],s=h,a=c,t.moveTo(h+f,c+d);break;case"c":i=h+e[5],r=c+e[6],l=h+e[3],u=c+e[4],t.bezierCurveTo(h+e[1]+f,c+e[2]+d,l+f,u+d,i+f,r+d),h=i,c=r;break;case"C":h=e[5],c=e[6],l=e[3],u=e[4],t.bezierCurveTo(e[1]+f,e[2]+d,l+f,u+d,h+f,c+d);break;case"s":i=h+e[3],r=c+e[4],null===n[0].match(/[CcSs]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.bezierCurveTo(l+f,u+d,h+e[1]+f,c+e[2]+d,i+f,r+d),l=h+e[1],u=c+e[2],h=i,c=r;break;case"S":i=e[3],r=e[4],null===n[0].match(/[CcSs]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.bezierCurveTo(l+f,u+d,e[1]+f,e[2]+d,i+f,r+d),h=i,c=r,l=e[1],u=e[2];break;case"q":i=h+e[3],r=c+e[4],l=h+e[1],u=c+e[2],t.quadraticCurveTo(l+f,u+d,i+f,r+d),h=i,c=r;break;case"Q":i=e[3],r=e[4],t.quadraticCurveTo(e[1]+f,e[2]+d,i+f,r+d),h=i,c=r,l=e[1],u=e[2];break;case"t":i=h+e[1],r=c+e[2],null===n[0].match(/[QqTt]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.quadraticCurveTo(l+f,u+d,i+f,r+d),h=i,c=r;break;case"T":i=e[1],r=e[2],null===n[0].match(/[QqTt]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.quadraticCurveTo(l+f,u+d,i+f,r+d),h=i,c=r;break;case"a":o(t,h+f,c+d,[e[1],e[2],e[3],e[4],e[5],e[6]+h+f,e[7]+c+d]),h+=e[6],c+=e[7];break;case"A":o(t,h+f,c+d,[e[1],e[2],e[3],e[4],e[5],e[6]+f,e[7]+d]),h=e[6],c=e[7];break;case"z":case"Z":h=s,c=a,t.closePath()}n=e}this._renderFill(t),this._renderStroke(t)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(t){var e=n(this.callSuper("toObject",t),{path:this.path.map(function(t){return t.slice()}),pathOffset:this.pathOffset});return this.sourcePath&&(e.sourcePath=this.sourcePath),this.transformMatrix&&(e.transformMatrix=this.transformMatrix),e},toDatalessObject:function(t){var e=this.toObject(t);return this.sourcePath&&(e.path=this.sourcePath),delete e.sourcePath,e},toSVG:function(t){for(var e=[],i=this._createBaseSVGMarkup(),r="",n=0,s=this.path.length;s>n;n++)e.push(this.path[n].join(" "));var o=e.join(" ");return this.group&&"path-group"===this.group.type||(r=" translate("+-this.pathOffset.x+", "+-this.pathOffset.y+") "),i.push("<path ",'d="',o,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),r,this.getSvgTransformMatrix(),'" stroke-linecap="round" ',"/>\n"),t?t(i.join("")):i.join("")},complexity:function(){return this.path.length},_parsePath:function(){for(var t,e,i,r,n,s=[],o=[],c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,l=0,u=this.path.length;u>l;l++){for(t=this.path[l],r=t.slice(1).trim(),o.length=0;i=c.exec(r);)o.push(i[0]);n=[t.charAt(0)];for(var f=0,d=o.length;d>f;f++)e=parseFloat(o[f]),isNaN(e)||n.push(e);var g=n[0],p=a[g.toLowerCase()],v=h[g]||g;if(n.length-1>p)for(var b=1,m=n.length;m>b;b+=p)s.push([g].concat(n.slice(b,b+p))),g=v;else s.push(n)}return s},_parseDimensions:function(){for(var t,n,s,o,a=[],h=[],c=null,l=0,u=0,f=0,d=0,g=0,p=0,v=0,b=this.path.length;b>v;++v){switch(t=this.path[v],t[0]){case"l":f+=t[1],d+=t[2],o=[];break;case"L":f=t[1],d=t[2],o=[];break;case"h":f+=t[1],o=[];break;case"H":f=t[1],o=[];break;case"v":d+=t[1],o=[];break;case"V":d=t[1],o=[];break;case"m":f+=t[1],d+=t[2],l=f,u=d,o=[];break;case"M":f=t[1],d=t[2],l=f,u=d,o=[];break;case"c":n=f+t[5],s=d+t[6],g=f+t[3],p=d+t[4],o=e.util.getBoundsOfCurve(f,d,f+t[1],d+t[2],g,p,n,s),f=n,d=s;break;case"C":f=t[5],d=t[6],g=t[3],p=t[4],o=e.util.getBoundsOfCurve(f,d,t[1],t[2],g,p,f,d);break;case"s":n=f+t[3],s=d+t[4],null===c[0].match(/[CcSs]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,f+t[1],d+t[2],n,s),g=f+t[1],p=d+t[2],f=n,d=s;break;case"S":n=t[3],s=t[4],null===c[0].match(/[CcSs]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,t[1],t[2],n,s),f=n,d=s,g=t[1],p=t[2];break;case"q":n=f+t[3],s=d+t[4],g=f+t[1],p=d+t[2],o=e.util.getBoundsOfCurve(f,d,g,p,g,p,n,s),f=n,d=s;break;case"Q":g=t[1],p=t[2],o=e.util.getBoundsOfCurve(f,d,g,p,g,p,t[3],t[4]),f=t[3],d=t[4];break;case"t":n=f+t[1],s=d+t[2],null===c[0].match(/[QqTt]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,g,p,n,s),f=n,d=s;break;case"T":n=t[1],s=t[2],null===c[0].match(/[QqTt]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,g,p,n,s),f=n,d=s;break;case"a":o=e.util.getBoundsOfArc(f,d,t[1],t[2],t[3],t[4],t[5],t[6]+f,t[7]+d),f+=t[6],d+=t[7];break;case"A":o=e.util.getBoundsOfArc(f,d,t[1],t[2],t[3],t[4],t[5],t[6],t[7]),f=t[6],d=t[7];break;case"z":case"Z":f=l,d=u}c=t,o.forEach(function(t){a.push(t.x),h.push(t.y)}),a.push(f),h.push(d)}var m=i(a)||0,y=i(h)||0,_=r(a)||0,x=r(h)||0,S=_-m,C=x-y,w={left:m,top:y,width:S,height:C};return w}}),e.Path.fromObject=function(t,i){"string"==typeof t.path?e.loadSVGFromURL(t.path,function(r){var n=r[0],s=t.path;delete t.path,e.util.object.extend(n,t),n.setSourcePath(s),i(n)}):i(new e.Path(t.path,t))},e.Path.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(["d"]),e.Path.fromElement=function(t,i,r){var s=e.parseAttributes(t,e.Path.ATTRIBUTE_NAMES);i&&i(new e.Path(s.d,n(s,r)))},void(e.Path.async=!0))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.invoke,n=e.Object.prototype.toObject;return e.PathGroup?void e.warn("fabric.PathGroup is already defined"):(e.PathGroup=e.util.createClass(e.Path,{type:"path-group",fill:"",initialize:function(t,e){e=e||{},this.paths=t||[];for(var i=this.paths.length;i--;)this.paths[i].group=this;e.toBeParsed&&(this.parseDimensionsFromPaths(e),delete e.toBeParsed),this.setOptions(e),this.setCoords(),e.sourcePath&&this.setSourcePath(e.sourcePath)},parseDimensionsFromPaths:function(t){for(var i,r,n,s,o,a,h=[],c=[],l=this.paths.length;l--;){n=this.paths[l],s=n.height+n.strokeWidth,o=n.width+n.strokeWidth,i=[{x:n.left,y:n.top},{x:n.left+o,y:n.top},{x:n.left,y:n.top+s},{x:n.left+o,y:n.top+s}],a=this.paths[l].transformMatrix;for(var u=0;u<i.length;u++)r=i[u],a&&(r=e.util.transformPoint(r,a,!1)),h.push(r.x),c.push(r.y)}t.width=Math.max.apply(null,h),t.height=Math.max.apply(null,c)},render:function(t){if(this.visible){t.save(),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this.transform(t),this._setShadow(t),this.clipTo&&e.util.clipContext(this,t),t.translate(-this.width/2,-this.height/2);for(var i=0,r=this.paths.length;r>i;++i)this.paths[i].render(t,!0);this.clipTo&&t.restore(),t.restore()}},_set:function(t,e){if("fill"===t&&e&&this.isSameColor())for(var i=this.paths.length;i--;)this.paths[i]._set(t,e);return this.callSuper("_set",t,e)},toObject:function(t){var e=i(n.call(this,t),{paths:r(this.getObjects(),"toObject",t)});return this.sourcePath&&(e.sourcePath=this.sourcePath),e},toDatalessObject:function(t){var e=this.toObject(t);return this.sourcePath&&(e.paths=this.sourcePath),e},toSVG:function(t){var e=this.getObjects(),i=this.getPointByOrigin("left","top"),r="translate("+i.x+" "+i.y+")",n=this._createBaseSVGMarkup();n.push("<g ",'style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransformMatrix(),r,this.getSvgTransform(),'" ',">\n");for(var s=0,o=e.length;o>s;s++)n.push(" ",e[s].toSVG(t));return n.push("</g>\n"),t?t(n.join("")):n.join("")},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var t=this.getObjects()[0].get("fill")||"";return"string"!=typeof t?!1:(t=t.toLowerCase(),this.getObjects().every(function(e){var i=e.get("fill")||"";return"string"==typeof i&&i.toLowerCase()===t}))},complexity:function(){return this.paths.reduce(function(t,e){return t+(e&&e.complexity?e.complexity():0)},0)},getObjects:function(){return this.paths}}),e.PathGroup.fromObject=function(t,i){"string"==typeof t.paths?e.loadSVGFromURL(t.paths,function(r){var n=t.paths;delete t.paths;var s=e.util.groupSVGElements(r,t,n);i(s)}):e.util.enlivenObjects(t.paths,function(r){delete t.paths,i(new e.PathGroup(r,t))})},void(e.PathGroup.async=!0))}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,n=e.util.array.max,s=e.util.array.invoke;if(!e.Group){var o={lockMovementX:!0,lockMovementY:!0,lockRotation:!0,lockScalingX:!0,lockScalingY:!0,lockUniScaling:!0};e.Group=e.util.createClass(e.Object,e.Collection,{type:"group",strokeWidth:0,initialize:function(t,e,i){e=e||{},this._objects=[],i&&this.callSuper("initialize",e),this._objects=t||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;this.originalState={},e.originX&&(this.originX=e.originX),e.originY&&(this.originY=e.originY),i?this._updateObjectsCoords(!0):(this._calcBounds(),this._updateObjectsCoords(),this.callSuper("initialize",e)),this.setCoords(),this.saveCoords()},_updateObjectsCoords:function(t){for(var e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],t)},_updateObjectCoords:function(t,e){if(t.__origHasControls=t.hasControls,t.hasControls=!1,!e){var i=t.getLeft(),r=t.getTop(),n=this.getCenterPoint();t.set({originalLeft:i,originalTop:r,
6
- left:i-n.x,top:r-n.y}),t.setCoords()}},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this.forEachObject(this._setObjectActive,this),this._calcBounds(),this._updateObjectsCoords(),this},_setObjectActive:function(t){t.set("active",!0),t.group=this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.forEachObject(this._setObjectActive,this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this},_onObjectAdded:function(t){t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){delete t.group,t.set("active",!1)},delegatedProperties:{fill:!0,stroke:!0,strokeWidth:!0,fontFamily:!0,fontWeight:!0,fontSize:!0,fontStyle:!0,lineHeight:!0,textDecoration:!0,textAlign:!0,backgroundColor:!0},_set:function(t,e){var i=this._objects.length;if(this.delegatedProperties[t]||"canvas"===t)for(;i--;)this._objects[i].set(t,e);else for(;i--;)this._objects[i].setOnGroup(t,e);this.callSuper("_set",t,e)},toObject:function(t){return i(this.callSuper("toObject",t),{objects:s(this._objects,"toObject",t)})},render:function(t){if(this.visible){t.save(),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this.transform(t),this._setShadow(t),this.clipTo&&e.util.clipContext(this,t);for(var i=0,r=this._objects.length;r>i;i++)this._renderObject(this._objects[i],t);this.clipTo&&t.restore(),t.restore()}},_renderControls:function(t,e){this.callSuper("_renderControls",t,e);for(var i=0,r=this._objects.length;r>i;i++)this._objects[i]._renderControls(t)},_renderObject:function(t,e){if(t.visible){var i=t.hasRotatingPoint;t.hasRotatingPoint=!1,t.render(e),t.hasRotatingPoint=i}},_restoreObjectsState:function(){return this._objects.forEach(this._restoreObjectState,this),this},realizeTransform:function(t){var i=t.calcTransformMatrix(),r=e.util.qrDecompose(i),n=new e.Point(r.translateX,r.translateY);return t.scaleX=r.scaleX,t.scaleY=r.scaleY,t.skewX=r.skewX,t.skewY=r.skewY,t.angle=r.angle,t.flipX=!1,t.flipY=!1,t.setPositionByOrigin(n,"center","center"),t},_restoreObjectState:function(t){return this.realizeTransform(t),t.setCoords(),t.hasControls=t.__origHasControls,delete t.__origHasControls,t.set("active",!1),delete t.group,this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){return this._originalLeft=this.get("left"),this._originalTop=this.get("top"),this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){return this.forEachObject(function(t){t.setCoords()}),this},_calcBounds:function(t){for(var e,i,r,n=[],s=[],o=["tr","br","bl","tl"],a=0,h=this._objects.length,c=o.length;h>a;++a)for(e=this._objects[a],e.setCoords(),r=0;c>r;r++)i=o[r],n.push(e.oCoords[i].x),s.push(e.oCoords[i].y);this.set(this._getBounds(n,s,t))},_getBounds:function(t,i,s){var o=e.util.invertTransform(this.getViewportTransform()),a=e.util.transformPoint(new e.Point(r(t),r(i)),o),h=e.util.transformPoint(new e.Point(n(t),n(i)),o),c={width:h.x-a.x||0,height:h.y-a.y||0};return s||(c.left=a.x||0,c.top=a.y||0,"center"===this.originX&&(c.left+=c.width/2),"right"===this.originX&&(c.left+=c.width),"center"===this.originY&&(c.top+=c.height/2),"bottom"===this.originY&&(c.top+=c.height)),c},toSVG:function(t){var e=this._createBaseSVGMarkup();e.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'" style="',this.getSvgFilter(),'">\n');for(var i=0,r=this._objects.length;r>i;i++)e.push(" ",this._objects[i].toSVG(t));return e.push("</g>\n"),t?t(e.join("")):e.join("")},get:function(t){if(t in o){if(this[t])return this[t];for(var e=0,i=this._objects.length;i>e;e++)if(this._objects[e][t])return!0;return!1}return t in this.delegatedProperties?this._objects[0]&&this._objects[0].get(t):this[t]}}),e.Group.fromObject=function(t,i){e.util.enlivenObjects(t.objects,function(r){delete t.objects,i&&i(new e.Group(r,t,!0))})},e.Group.async=!0}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=fabric.util.object.extend;return t.fabric||(t.fabric={}),t.fabric.Image?void fabric.warn("fabric.Image is already defined."):(fabric.Image=fabric.util.createClass(fabric.Object,{type:"image",crossOrigin:"",alignX:"none",alignY:"none",meetOrSlice:"meet",strokeWidth:0,_lastScaleX:1,_lastScaleY:1,initialize:function(t,e){e||(e={}),this.filters=[],this.resizeFilters=[],this.callSuper("initialize",e),this._initElement(t,e)},getElement:function(){return this._element},setElement:function(t,e,i){return this._element=t,this._originalElement=t,this._initConfig(i),0!==this.filters.length?this.applyFilters(e):e&&e(),this},setCrossOrigin:function(t){return this.crossOrigin=t,this._element.crossOrigin=t,this},getOriginalSize:function(){var t=this.getElement();return{width:t.width,height:t.height}},_stroke:function(t){if(this.stroke&&0!==this.strokeWidth){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}},_renderDashedStroke:function(t){var e=-this.width/2,i=-this.height/2,r=this.width,n=this.height;t.save(),this._setStrokeStyles(t),t.beginPath(),fabric.util.drawDashedLine(t,e,i,e+r,i,this.strokeDashArray),fabric.util.drawDashedLine(t,e+r,i,e+r,i+n,this.strokeDashArray),fabric.util.drawDashedLine(t,e+r,i+n,e,i+n,this.strokeDashArray),fabric.util.drawDashedLine(t,e,i+n,e,i,this.strokeDashArray),t.closePath(),t.restore()},toObject:function(t){var i=[],r=[],n=this._originalElement,s=1,o=1;this.filters.forEach(function(t){t&&("Resize"===t.type&&(s*=t.scaleX,o*=t.scaleY),i.push(t.toObject()))}),this.resizeFilters.forEach(function(t){t&&r.push(t.toObject())});var a=e(this.callSuper("toObject",t),{src:n?n.src||n._src:"",filters:i,resizeFilters:r,crossOrigin:this.crossOrigin,alignX:this.alignX,alignY:this.alignY,meetOrSlice:this.meetOrSlice});return a.width/=s,a.height/=o,this.includeDefaultValues||this._removeDefaultValues(a),a},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=-this.width/2,r=-this.height/2,n="none";if(this.group&&"path-group"===this.group.type&&(i=this.left,r=this.top),"none"!==this.alignX&&"none"!==this.alignY&&(n="x"+this.alignX+"Y"+this.alignY+" "+this.meetOrSlice),e.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'">\n','<image xlink:href="',this.getSvgSrc(),'" x="',i,'" y="',r,'" style="',this.getSvgStyles(),'" width="',this.width,'" height="',this.height,'" preserveAspectRatio="',n,'"',"></image>\n"),this.stroke||this.strokeDashArray){var s=this.fill;this.fill=null,e.push("<rect ",'x="',i,'" y="',r,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'),this.fill=s}return e.push("</g>\n"),t?t(e.join("")):e.join("")},getSrc:function(){return this.getElement()?this.getElement().src||this.getElement()._src:void 0},setSrc:function(t,e,i){fabric.util.loadImage(t,function(t){return this.setElement(t,e,i)},this,i&&i.crossOrigin)},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(t,e){this.constructor.fromObject(this.toObject(e),t)},applyFilters:function(t,e,i,r){if(e=e||this.filters,i=i||this._originalElement){var n=i,s=fabric.util.createCanvasElement(),o=fabric.util.createImage(),a=this;return s.width=n.width,s.height=n.height,s.getContext("2d").drawImage(n,0,0,n.width,n.height),0===e.length?(this._element=i,t&&t(),s):(e.forEach(function(t){t&&t.applyTo(s,t.scaleX||a.scaleX,t.scaleY||a.scaleY),!r&&t&&"Resize"===t.type&&(a.width*=t.scaleX,a.height*=t.scaleY)}),o.width=s.width,o.height=s.height,fabric.isLikelyNode?(o.src=s.toBuffer(void 0,fabric.Image.pngCompression),a._element=o,!r&&(a._filteredEl=o),t&&t()):(o.onload=function(){a._element=o,!r&&(a._filteredEl=o),t&&t(),o.onload=s=n=null},o.src=s.toDataURL("image/png")),s)}},_render:function(t,e){var i,r,n,s=this._findMargins();i=e?this.left:-this.width/2,r=e?this.top:-this.height/2,"slice"===this.meetOrSlice&&(t.beginPath(),t.rect(i,r,this.width,this.height),t.clip()),this.isMoving===!1&&this.resizeFilters.length&&this._needsResize()?(this._lastScaleX=this.scaleX,this._lastScaleY=this.scaleY,n=this.applyFilters(null,this.resizeFilters,this._filteredEl||this._originalElement,!0)):n=this._element,n&&t.drawImage(n,i+s.marginX,r+s.marginY,s.width,s.height),this._stroke(t),this._renderStroke(t)},_needsResize:function(){return this.scaleX!==this._lastScaleX||this.scaleY!==this._lastScaleY},_findMargins:function(){var t,e,i=this.width,r=this.height,n=0,s=0;return"none"===this.alignX&&"none"===this.alignY||(t=[this.width/this._element.width,this.height/this._element.height],e="meet"===this.meetOrSlice?Math.min.apply(null,t):Math.max.apply(null,t),i=this._element.width*e,r=this._element.height*e,"Mid"===this.alignX&&(n=(this.width-i)/2),"Max"===this.alignX&&(n=this.width-i),"Mid"===this.alignY&&(s=(this.height-r)/2),"Max"===this.alignY&&(s=this.height-r)),{width:i,height:r,marginX:n,marginY:s}},_resetWidthHeight:function(){var t=this.getElement();this.set("width",t.width),this.set("height",t.height)},_initElement:function(t,e){this.setElement(fabric.util.getById(t),null,e),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t),this._element&&this.crossOrigin&&(this._element.crossOrigin=this.crossOrigin)},_initFilters:function(t,e){t&&t.length?fabric.util.enlivenObjects(t,function(t){e&&e(t)},"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){this.width="width"in t?t.width:this.getElement()?this.getElement().width||0:0,this.height="height"in t?t.height:this.getElement()?this.getElement().height||0:0},complexity:function(){return 1}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(t,e){fabric.util.loadImage(t.src,function(i){fabric.Image.prototype._initFilters.call(t,t.filters,function(r){t.filters=r||[],fabric.Image.prototype._initFilters.call(t,t.resizeFilters,function(r){t.resizeFilters=r||[];var n=new fabric.Image(i,t);e&&e(n)})})},null,t.crossOrigin)},fabric.Image.fromURL=function(t,e,i){fabric.util.loadImage(t,function(t){e&&e(new fabric.Image(t,i))},null,i&&i.crossOrigin)},fabric.Image.ATTRIBUTE_NAMES=fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href".split(" ")),fabric.Image.fromElement=function(t,i,r){var n,s=fabric.parseAttributes(t,fabric.Image.ATTRIBUTE_NAMES);s.preserveAspectRatio&&(n=fabric.util.parsePreserveAspectRatioAttribute(s.preserveAspectRatio),e(s,n)),fabric.Image.fromURL(s["xlink:href"],i,e(r?fabric.util.object.clone(r):{},s))},fabric.Image.async=!0,void(fabric.Image.pngCompression=1))}("undefined"!=typeof exports?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.getAngle()%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.setAngle(this._getAngleValueForStraighten()),this},fxStraighten:function(t){t=t||{};var e=function(){},i=t.onComplete||e,r=t.onChange||e,n=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){n.setAngle(t),r()},onComplete:function(){n.setCoords(),i()},onStart:function(){n.set("active",!1)}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.renderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.renderAll.bind(this)}),this}}),fabric.Image.filters=fabric.Image.filters||{},fabric.Image.filters.BaseFilter=fabric.util.createClass({type:"BaseFilter",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},toObject:function(){return{type:this.type}},toJSON:function(){return this.toObject()}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Brightness=e.util.createClass(e.Image.filters.BaseFilter,{type:"Brightness",initialize:function(t){t=t||{},this.brightness=t.brightness||0},applyTo:function(t){for(var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,n=this.brightness,s=0,o=r.length;o>s;s+=4)r[s]+=n,r[s+1]+=n,r[s+2]+=n;e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{brightness:this.brightness})}}),e.Image.filters.Brightness.fromObject=function(t){return new e.Image.filters.Brightness(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Convolute=e.util.createClass(e.Image.filters.BaseFilter,{type:"Convolute",initialize:function(t){t=t||{},this.opaque=t.opaque,this.matrix=t.matrix||[0,0,0,0,1,0,0,0,0]},applyTo:function(t){for(var e,i,r,n,s,o,a,h,c,l=this.matrix,u=t.getContext("2d"),f=u.getImageData(0,0,t.width,t.height),d=Math.round(Math.sqrt(l.length)),g=Math.floor(d/2),p=f.data,v=f.width,b=f.height,m=u.createImageData(v,b),y=m.data,_=this.opaque?1:0,x=0;b>x;x++)for(var S=0;v>S;S++){s=4*(x*v+S),e=0,i=0,r=0,n=0;for(var C=0;d>C;C++)for(var w=0;d>w;w++)a=x+C-g,o=S+w-g,0>a||a>b||0>o||o>v||(h=4*(a*v+o),c=l[C*d+w],e+=p[h]*c,i+=p[h+1]*c,r+=p[h+2]*c,n+=p[h+3]*c);y[s]=e,y[s+1]=i,y[s+2]=r,y[s+3]=n+_*(255-n)}u.putImageData(m,0,0)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=function(t){return new e.Image.filters.Convolute(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.GradientTransparency=e.util.createClass(e.Image.filters.BaseFilter,{type:"GradientTransparency",initialize:function(t){t=t||{},this.threshold=t.threshold||100},applyTo:function(t){for(var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,n=this.threshold,s=r.length,o=0,a=r.length;a>o;o+=4)r[o+3]=n+255*(s-o)/s;e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold})}}),e.Image.filters.GradientTransparency.fromObject=function(t){return new e.Image.filters.GradientTransparency(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Grayscale=e.util.createClass(e.Image.filters.BaseFilter,{type:"Grayscale",applyTo:function(t){for(var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=r.width*r.height*4,o=0;s>o;)e=(n[o]+n[o+1]+n[o+2])/3,n[o]=e,n[o+1]=e,n[o+2]=e,o+=4;i.putImageData(r,0,0)}}),e.Image.filters.Grayscale.fromObject=function(){return new e.Image.filters.Grayscale}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Invert=e.util.createClass(e.Image.filters.BaseFilter,{type:"Invert",applyTo:function(t){var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=n.length;for(e=0;s>e;e+=4)n[e]=255-n[e],n[e+1]=255-n[e+1],n[e+2]=255-n[e+2];i.putImageData(r,0,0)}}),e.Image.filters.Invert.fromObject=function(){return new e.Image.filters.Invert}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Mask=e.util.createClass(e.Image.filters.BaseFilter,{type:"Mask",initialize:function(t){t=t||{},this.mask=t.mask,this.channel=[0,1,2,3].indexOf(t.channel)>-1?t.channel:0},applyTo:function(t){if(this.mask){var i,r=t.getContext("2d"),n=r.getImageData(0,0,t.width,t.height),s=n.data,o=this.mask.getElement(),a=e.util.createCanvasElement(),h=this.channel,c=n.width*n.height*4;a.width=t.width,a.height=t.height,a.getContext("2d").drawImage(o,0,0,t.width,t.height);var l=a.getContext("2d").getImageData(0,0,t.width,t.height),u=l.data;for(i=0;c>i;i+=4)s[i+3]=u[i+h];r.putImageData(n,0,0)}},toObject:function(){return i(this.callSuper("toObject"),{mask:this.mask.toObject(),channel:this.channel})}}),e.Image.filters.Mask.fromObject=function(t,i){e.util.loadImage(t.mask.src,function(r){t.mask=new e.Image(r,t.mask),i&&i(new e.Image.filters.Mask(t))})},e.Image.filters.Mask.async=!0}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Noise=e.util.createClass(e.Image.filters.BaseFilter,{type:"Noise",initialize:function(t){t=t||{},this.noise=t.noise||0},applyTo:function(t){for(var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=this.noise,o=0,a=n.length;a>o;o+=4)e=(.5-Math.random())*s,n[o]+=e,n[o+1]+=e,n[o+2]+=e;i.putImageData(r,0,0)},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}}),e.Image.filters.Noise.fromObject=function(t){return new e.Image.filters.Noise(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Pixelate=e.util.createClass(e.Image.filters.BaseFilter,{type:"Pixelate",initialize:function(t){t=t||{},this.blocksize=t.blocksize||4},applyTo:function(t){var e,i,r,n,s,o,a,h=t.getContext("2d"),c=h.getImageData(0,0,t.width,t.height),l=c.data,u=c.height,f=c.width;for(i=0;u>i;i+=this.blocksize)for(r=0;f>r;r+=this.blocksize){e=4*i*f+4*r,n=l[e],s=l[e+1],o=l[e+2],a=l[e+3];for(var d=i,g=i+this.blocksize;g>d;d++)for(var p=r,v=r+this.blocksize;v>p;p++)e=4*d*f+4*p,l[e]=n,l[e+1]=s,l[e+2]=o,l[e+3]=a}h.putImageData(c,0,0)},toObject:function(){return i(this.callSuper("toObject"),{blocksize:this.blocksize})}}),e.Image.filters.Pixelate.fromObject=function(t){return new e.Image.filters.Pixelate(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.RemoveWhite=e.util.createClass(e.Image.filters.BaseFilter,{type:"RemoveWhite",initialize:function(t){t=t||{},this.threshold=t.threshold||30,this.distance=t.distance||20},applyTo:function(t){for(var e,i,r,n=t.getContext("2d"),s=n.getImageData(0,0,t.width,t.height),o=s.data,a=this.threshold,h=this.distance,c=255-a,l=Math.abs,u=0,f=o.length;f>u;u+=4)e=o[u],i=o[u+1],r=o[u+2],e>c&&i>c&&r>c&&l(e-i)<h&&l(e-r)<h&&l(i-r)<h&&(o[u+3]=0);n.putImageData(s,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold,distance:this.distance})}}),e.Image.filters.RemoveWhite.fromObject=function(t){return new e.Image.filters.RemoveWhite(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Sepia=e.util.createClass(e.Image.filters.BaseFilter,{type:"Sepia",applyTo:function(t){var e,i,r=t.getContext("2d"),n=r.getImageData(0,0,t.width,t.height),s=n.data,o=s.length;for(e=0;o>e;e+=4)i=.3*s[e]+.59*s[e+1]+.11*s[e+2],s[e]=i+100,s[e+1]=i+50,s[e+2]=i+255;r.putImageData(n,0,0)}}),e.Image.filters.Sepia.fromObject=function(){return new e.Image.filters.Sepia}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Sepia2=e.util.createClass(e.Image.filters.BaseFilter,{type:"Sepia2",applyTo:function(t){var e,i,r,n,s=t.getContext("2d"),o=s.getImageData(0,0,t.width,t.height),a=o.data,h=a.length;for(e=0;h>e;e+=4)i=a[e],r=a[e+1],n=a[e+2],a[e]=(.393*i+.769*r+.189*n)/1.351,a[e+1]=(.349*i+.686*r+.168*n)/1.203,a[e+2]=(.272*i+.534*r+.131*n)/2.14;s.putImageData(o,0,0)}}),e.Image.filters.Sepia2.fromObject=function(){return new e.Image.filters.Sepia2}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Tint=e.util.createClass(e.Image.filters.BaseFilter,{type:"Tint",initialize:function(t){t=t||{},this.color=t.color||"#000000",this.opacity="undefined"!=typeof t.opacity?t.opacity:new e.Color(this.color).getAlpha()},applyTo:function(t){var i,r,n,s,o,a,h,c,l,u=t.getContext("2d"),f=u.getImageData(0,0,t.width,t.height),d=f.data,g=d.length;for(l=new e.Color(this.color).getSource(),r=l[0]*this.opacity,n=l[1]*this.opacity,s=l[2]*this.opacity,c=1-this.opacity,i=0;g>i;i+=4)o=d[i],a=d[i+1],h=d[i+2],d[i]=r+o*c,d[i+1]=n+a*c,d[i+2]=s+h*c;u.putImageData(f,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,opacity:this.opacity})}}),e.Image.filters.Tint.fromObject=function(t){return new e.Image.filters.Tint(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Multiply=e.util.createClass(e.Image.filters.BaseFilter,{type:"Multiply",initialize:function(t){t=t||{},this.color=t.color||"#000000"},applyTo:function(t){var i,r,n=t.getContext("2d"),s=n.getImageData(0,0,t.width,t.height),o=s.data,a=o.length;for(r=new e.Color(this.color).getSource(),i=0;a>i;i+=4)o[i]*=r[0]/255,o[i+1]*=r[1]/255,o[i+2]*=r[2]/255;n.putImageData(s,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color})}}),e.Image.filters.Multiply.fromObject=function(t){return new e.Image.filters.Multiply(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric;e.Image.filters.Blend=e.util.createClass(e.Image.filters.BaseFilter,{type:"Blend",initialize:function(t){t=t||{},this.color=t.color||"#000",this.image=t.image||!1,this.mode=t.mode||"multiply",this.alpha=t.alpha||1},applyTo:function(t){var i,r,n,s,o,a,h,c,l,u,f=t.getContext("2d"),d=f.getImageData(0,0,t.width,t.height),g=d.data,p=!1;if(this.image){p=!0;var v=e.util.createCanvasElement();v.width=this.image.width,v.height=this.image.height;var b=new e.StaticCanvas(v);b.add(this.image);var m=b.getContext("2d");u=m.getImageData(0,0,b.width,b.height).data}else u=new e.Color(this.color).getSource(),i=u[0]*this.alpha,r=u[1]*this.alpha,n=u[2]*this.alpha;for(var y=0,_=g.length;_>y;y+=4)switch(s=g[y],o=g[y+1],a=g[y+2],p&&(i=u[y]*this.alpha,r=u[y+1]*this.alpha,n=u[y+2]*this.alpha),this.mode){case"multiply":g[y]=s*i/255,g[y+1]=o*r/255,g[y+2]=a*n/255;break;case"screen":g[y]=1-(1-s)*(1-i),g[y+1]=1-(1-o)*(1-r),g[y+2]=1-(1-a)*(1-n);break;case"add":g[y]=Math.min(255,s+i),g[y+1]=Math.min(255,o+r),g[y+2]=Math.min(255,a+n);break;case"diff":case"difference":g[y]=Math.abs(s-i),g[y+1]=Math.abs(o-r),g[y+2]=Math.abs(a-n);break;case"subtract":h=s-i,c=o-r,l=a-n,g[y]=0>h?0:h,g[y+1]=0>c?0:c,g[y+2]=0>l?0:l;break;case"darken":g[y]=Math.min(s,i),g[y+1]=Math.min(o,r),g[y+2]=Math.min(a,n);break;case"lighten":g[y]=Math.max(s,i),g[y+1]=Math.max(o,r),g[y+2]=Math.max(a,n)}f.putImageData(d,0,0)},toObject:function(){return{color:this.color,image:this.image,mode:this.mode,alpha:this.alpha}}}),e.Image.filters.Blend.fromObject=function(t){return new e.Image.filters.Blend(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.pow,r=Math.floor,n=Math.sqrt,s=Math.abs,o=Math.max,a=Math.round,h=Math.sin,c=Math.ceil;e.Image.filters.Resize=e.util.createClass(e.Image.filters.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:0,scaleY:0,lanczosLobes:3,applyTo:function(t,e,i){this.rcpScaleX=1/e,this.rcpScaleY=1/i;var r,n=t.width,s=t.height,o=a(n*e),h=a(s*i);"sliceHack"===this.resizeType&&(r=this.sliceByTwo(t,n,s,o,h)),"hermite"===this.resizeType&&(r=this.hermiteFastResize(t,n,s,o,h)),"bilinear"===this.resizeType&&(r=this.bilinearFiltering(t,n,s,o,h)),"lanczos"===this.resizeType&&(r=this.lanczosResize(t,n,s,o,h)),t.width=o,t.height=h,t.getContext("2d").putImageData(r,0,0)},sliceByTwo:function(t,i,n,s,a){var h,c=t.getContext("2d"),l=.5,u=.5,f=1,d=1,g=!1,p=!1,v=i,b=n,m=e.util.createCanvasElement(),y=m.getContext("2d");for(s=r(s),a=r(a),m.width=o(s,i),m.height=o(a,n),s>i&&(l=2,f=-1),a>n&&(u=2,d=-1),h=c.getImageData(0,0,i,n),t.width=o(s,i),t.height=o(a,n),c.putImageData(h,0,0);!g||!p;)i=v,n=b,s*f<r(v*l*f)?v=r(v*l):(v=s,g=!0),a*d<r(b*u*d)?b=r(b*u):(b=a,p=!0),h=c.getImageData(0,0,i,n),y.putImageData(h,0,0),c.clearRect(0,0,v,b),c.drawImage(m,0,0,i,n,0,0,v,b);return c.getImageData(0,0,s,a)},lanczosResize:function(t,e,o,a,l){function u(t){return function(e){if(e>t)return 0;if(e*=Math.PI,s(e)<1e-16)return 1;var i=e/t;return h(e)*h(i)/e/i}}function f(t){var h,c,u,d,g,j,A,M,P,L,D;for(T.x=(t+.5)*y,k.x=r(T.x),h=0;l>h;h++){for(T.y=(h+.5)*_,k.y=r(T.y),g=0,j=0,A=0,M=0,P=0,c=k.x-C;c<=k.x+C;c++)if(!(0>c||c>=e)){L=r(1e3*s(c-T.x)),O[L]||(O[L]={});for(var E=k.y-w;E<=k.y+w;E++)0>E||E>=o||(D=r(1e3*s(E-T.y)),O[L][D]||(O[L][D]=m(n(i(L*x,2)+i(D*S,2))/1e3)),u=O[L][D],u>0&&(d=4*(E*e+c),g+=u,j+=u*v[d],A+=u*v[d+1],M+=u*v[d+2],P+=u*v[d+3]))}d=4*(h*a+t),b[d]=j/g,b[d+1]=A/g,b[d+2]=M/g,b[d+3]=P/g}return++t<a?f(t):p}var d=t.getContext("2d"),g=d.getImageData(0,0,e,o),p=d.getImageData(0,0,a,l),v=g.data,b=p.data,m=u(this.lanczosLobes),y=this.rcpScaleX,_=this.rcpScaleY,x=2/this.rcpScaleX,S=2/this.rcpScaleY,C=c(y*this.lanczosLobes/2),w=c(_*this.lanczosLobes/2),O={},T={},k={};return f(0)},bilinearFiltering:function(t,e,i,n,s){var o,a,h,c,l,u,f,d,g,p,v,b,m,y=0,_=this.rcpScaleX,x=this.rcpScaleY,S=t.getContext("2d"),C=4*(e-1),w=S.getImageData(0,0,e,i),O=w.data,T=S.getImageData(0,0,n,s),k=T.data;for(f=0;s>f;f++)for(d=0;n>d;d++)for(l=r(_*d),u=r(x*f),g=_*d-l,p=x*f-u,m=4*(u*e+l),v=0;4>v;v++)o=O[m+v],a=O[m+4+v],h=O[m+C+v],c=O[m+C+4+v],b=o*(1-g)*(1-p)+a*g*(1-p)+h*p*(1-g)+c*g*p,k[y++]=b;return T},hermiteFastResize:function(t,e,i,o,a){for(var h=this.rcpScaleX,l=this.rcpScaleY,u=c(h/2),f=c(l/2),d=t.getContext("2d"),g=d.getImageData(0,0,e,i),p=g.data,v=d.getImageData(0,0,o,a),b=v.data,m=0;a>m;m++)for(var y=0;o>y;y++){for(var _=4*(y+m*o),x=0,S=0,C=0,w=0,O=0,T=0,k=0,j=(m+.5)*l,A=r(m*l);(m+1)*l>A;A++)for(var M=s(j-(A+.5))/f,P=(y+.5)*h,L=M*M,D=r(y*h);(y+1)*h>D;D++){var E=s(P-(D+.5))/u,I=n(L+E*E);I>1&&-1>I||(x=2*I*I*I-3*I*I+1,x>0&&(E=4*(D+A*e),k+=x*p[E+3],C+=x,p[E+3]<255&&(x=x*p[E+3]/250),w+=x*p[E],O+=x*p[E+1],T+=x*p[E+2],S+=x))}b[_]=w/S,b[_+1]=O/S,b[_+2]=T/S,b[_+3]=k/C}return v},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=function(t){return new e.Image.filters.Resize(t)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,n=e.util.toFixed,s=e.StaticCanvas.supports("setLineDash"),o=e.Object.NUM_FRACTION_DIGITS;if(e.Text)return void e.warn("fabric.Text is already defined");var a=e.Object.prototype.stateProperties.concat();a.push("fontFamily","fontWeight","fontSize","text","textDecoration","textAlign","fontStyle","lineHeight","textBackgroundColor"),e.Text=e.util.createClass(e.Object,{_dimensionAffectingProps:{fontSize:!0,fontWeight:!0,fontFamily:!0,fontStyle:!0,lineHeight:!0,stroke:!0,strokeWidth:!0,text:!0,textAlign:!0},_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",textDecoration:"",textAlign:"left",fontStyle:"",lineHeight:1.16,textBackgroundColor:"",stateProperties:a,stroke:null,shadow:null,_fontSizeFraction:.25,_fontSizeMult:1.13,initialize:function(t,e){e=e||{},this.text=t,this.__skipDimension=!0,this.setOptions(e),this.__skipDimension=!1,this._initDimensions()},_initDimensions:function(t){this.__skipDimension||(t||(t=e.util.createCanvasElement().getContext("2d"),this._setTextStyles(t)),this._textLines=this._splitTextIntoLines(),this._clearCache(),this.width=this._getTextWidth(t),this.height=this._getTextHeight(t))},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_render:function(t){this.clipTo&&e.util.clipContext(this,t),this._setOpacity(t),this._setShadow(t),this._setupCompositeOperation(t),this._renderTextBackground(t),this._setStrokeStyles(t),this._setFillStyles(t),this._renderText(t),this._renderTextDecoration(t),this.clipTo&&t.restore()},_renderText:function(t){this._translateForTextAlign(t),this._renderTextFill(t),this._renderTextStroke(t),this._translateForTextAlign(t,!0)},_translateForTextAlign:function(t,e){if("left"!==this.textAlign&&"justify"!==this.textAlign){var i=e?-1:1;t.translate("center"===this.textAlign?i*this.width/2:i*this.width,0)}},_setTextStyles:function(t){t.textBaseline="alphabetic",this.skipTextAlign||(t.textAlign=this.textAlign),t.font=this._getFontDeclaration()},_getTextHeight:function(){return this._textLines.length*this._getHeightOfLine()},_getTextWidth:function(t){for(var e=this._getLineWidth(t,0),i=1,r=this._textLines.length;r>i;i++){var n=this._getLineWidth(t,i);n>e&&(e=n)}return e},_renderChars:function(t,e,i,r,n){var s=t.slice(0,-4);if(this[s].toLive){var o=-this.width/2+this[s].offsetX||0,a=-this.height/2+this[s].offsetY||0;e.save(),e.translate(o,a),r-=o,n-=a}e[t](i,r,n),this[s].toLive&&e.restore()},_renderTextLine:function(t,e,i,r,n,s){n-=this.fontSize*this._fontSizeFraction;var o=this._getLineWidth(e,s);if("justify"!==this.textAlign||this.width<o)return void this._renderChars(t,e,i,r,n,s);for(var a,h=i.split(/\s+/),c=0,l=this._getWidthOfWords(e,i,s,0),u=this.width-l,f=h.length-1,d=f>0?u/f:0,g=0,p=0,v=h.length;v>p;p++){for(;" "===i[c]&&c<i.length;)c++;a=h[p],this._renderChars(t,e,a,r+g,n,s,c),g+=this._getWidthOfWords(e,a,s,c)+d,c+=a.length}},_getWidthOfWords:function(t,e){return t.measureText(e.replace(/\s+/g,"")).width},_getLeftOffset:function(){return-this.width/2},_getTopOffset:function(){return-this.height/2},isEmptyStyles:function(){return!0},_renderTextFill:function(t){if(this.fill||!this.isEmptyStyles())for(var e=0,i=0,r=this._textLines.length;r>i;i++){var n=this._getHeightOfLine(t,i),s=n/this.lineHeight;this._renderTextLine("fillText",t,this._textLines[i],this._getLeftOffset(),this._getTopOffset()+e+s,i),e+=n}},_renderTextStroke:function(t){if(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles()){var e=0;this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeDashArray&&(1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray),s&&t.setLineDash(this.strokeDashArray)),t.beginPath();for(var i=0,r=this._textLines.length;r>i;i++){var n=this._getHeightOfLine(t,i),o=n/this.lineHeight;this._renderTextLine("strokeText",t,this._textLines[i],this._getLeftOffset(),this._getTopOffset()+e+o,i),e+=n}t.closePath(),t.restore()}},_getHeightOfLine:function(){return this.fontSize*this._fontSizeMult*this.lineHeight},_renderTextBackground:function(t){this._renderTextBoxBackground(t),this._renderTextLinesBackground(t)},_renderTextBoxBackground:function(t){this.backgroundColor&&(t.fillStyle=this.backgroundColor,t.fillRect(this._getLeftOffset(),this._getTopOffset(),this.width,this.height),this._removeShadow(t))},_renderTextLinesBackground:function(t){if(this.textBackgroundColor){var e,i,r,n=0;t.fillStyle=this.textBackgroundColor;for(var s=0,o=this._textLines.length;o>s;s++)e=this._getHeightOfLine(t,s),i=this._getLineWidth(t,s),i>0&&(r=this._getLineLeftOffset(i),t.fillRect(this._getLeftOffset()+r,this._getTopOffset()+n,i,e/this.lineHeight)),n+=e;this._removeShadow(t)}},_getLineLeftOffset:function(t){return"center"===this.textAlign?(this.width-t)/2:"right"===this.textAlign?this.width-t:0},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[]},_shouldClearCache:function(){var t=!1;if(this._forceClearCache)return this._forceClearCache=!1,!0;for(var e in this._dimensionAffectingProps)this["__"+e]!==this[e]&&(this["__"+e]=this[e],t=!0);return t},_getLineWidth:function(t,e){if(this.__lineWidths[e])return-1===this.__lineWidths[e]?this.width:this.__lineWidths[e];var i,r,n=this._textLines[e];return i=""===n?0:this._measureLine(t,e),this.__lineWidths[e]=i,i&&"justify"===this.textAlign&&(r=n.split(/\s+/),r.length>1&&(this.__lineWidths[e]=-1)),i},_measureLine:function(t,e){return t.measureText(this._textLines[e]).width},_renderTextDecoration:function(t){function e(e){var n,s,o,a,h,c,l,u=0;for(n=0,s=r._textLines.length;s>n;n++){for(h=r._getLineWidth(t,n),c=r._getLineLeftOffset(h),
7
- l=r._getHeightOfLine(t,n),o=0,a=e.length;a>o;o++)t.fillRect(r._getLeftOffset()+c,u+(r._fontSizeMult-1+e[o])*r.fontSize-i,h,r.fontSize/15);u+=l}}if(this.textDecoration){var i=this.height/2,r=this,n=[];this.textDecoration.indexOf("underline")>-1&&n.push(.85),this.textDecoration.indexOf("line-through")>-1&&n.push(.43),this.textDecoration.indexOf("overline")>-1&&n.push(-.12),n.length>0&&e(n)}},_getFontDeclaration:function(){return[e.isLikelyNode?this.fontWeight:this.fontStyle,e.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",e.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},render:function(t,e){this.visible&&(t.save(),this._setTextStyles(t),this._shouldClearCache()&&this._initDimensions(t),this.drawSelectionBackground(t),e||this.transform(t),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this.group&&"path-group"===this.group.type&&t.translate(this.left,this.top),this._render(t),t.restore())},_splitTextIntoLines:function(){return this.text.split(this._reNewline)},toObject:function(t){var e=i(this.callSuper("toObject",t),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textAlign:this.textAlign,textBackgroundColor:this.textBackgroundColor});return this.includeDefaultValues||this._removeDefaultValues(e),e},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this._getSVGLeftTopOffsets(this.ctx),r=this._getSVGTextAndBg(i.textTop,i.textLeft);return this._wrapSVGTextAndBg(e,r),t?t(e.join("")):e.join("")},_getSVGLeftTopOffsets:function(t){var e=this._getHeightOfLine(t,0),i=-this.width/2,r=0;return{textLeft:i+(this.group&&"path-group"===this.group.type?this.left:0),textTop:r+(this.group&&"path-group"===this.group.type?-this.top:0),lineTop:e}},_wrapSVGTextAndBg:function(t,e){var i=!0,r=this.getSvgFilter(),n=""===r?"":' style="'+r+'"';t.push(' <g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"',n,">\n",e.textBgRects.join("")," <text ",this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",this.textDecoration?'text-decoration="'+this.textDecoration+'" ':"",'style="',this.getSvgStyles(i),'" >\n',e.textSpans.join("")," </text>\n"," </g>\n")},_getSVGTextAndBg:function(t,e){var i=[],r=[],n=0;this._setSVGBg(r);for(var s=0,o=this._textLines.length;o>s;s++)this.textBackgroundColor&&this._setSVGTextLineBg(r,s,e,t,n),this._setSVGTextLineText(s,i,n,e,t,r),n+=this._getHeightOfLine(this.ctx,s);return{textSpans:i,textBgRects:r}},_setSVGTextLineText:function(t,i,r,s,a){var h=this.fontSize*(this._fontSizeMult-this._fontSizeFraction)-a+r-this.height/2;return"justify"===this.textAlign?void this._setSVGTextLineJustifed(t,i,h,s):void i.push(' <tspan x="',n(s+this._getLineLeftOffset(this._getLineWidth(this.ctx,t)),o),'" ','y="',n(h,o),'" ',this._getFillAttributes(this.fill),">",e.util.string.escapeXml(this._textLines[t]),"</tspan>\n")},_setSVGTextLineJustifed:function(t,i,r,s){var a=e.util.createCanvasElement().getContext("2d");this._setTextStyles(a);var h,c,l=this._textLines[t],u=l.split(/\s+/),f=this._getWidthOfWords(a,l),d=this.width-f,g=u.length-1,p=g>0?d/g:0,v=this._getFillAttributes(this.fill);for(s+=this._getLineLeftOffset(this._getLineWidth(a,t)),t=0,c=u.length;c>t;t++)h=u[t],i.push(' <tspan x="',n(s,o),'" ','y="',n(r,o),'" ',v,">",e.util.string.escapeXml(h),"</tspan>\n"),s+=this._getWidthOfWords(a,h)+p},_setSVGTextLineBg:function(t,e,i,r,s){t.push(" <rect ",this._getFillAttributes(this.textBackgroundColor),' x="',n(i+this._getLineLeftOffset(this._getLineWidth(this.ctx,e)),o),'" y="',n(s-this.height/2,o),'" width="',n(this._getLineWidth(this.ctx,e),o),'" height="',n(this._getHeightOfLine(this.ctx,e)/this.lineHeight,o),'"></rect>\n')},_setSVGBg:function(t){this.backgroundColor&&t.push(" <rect ",this._getFillAttributes(this.backgroundColor),' x="',n(-this.width/2,o),'" y="',n(-this.height/2,o),'" width="',n(this.width,o),'" height="',n(this.height,o),'"></rect>\n')},_getFillAttributes:function(t){var i=t&&"string"==typeof t?new e.Color(t):"";return i&&i.getSource()&&1!==i.getAlpha()?'opacity="'+i.getAlpha()+'" fill="'+i.setAlpha(1).toRgb()+'"':'fill="'+t+'"'},_set:function(t,e){this.callSuper("_set",t,e),t in this._dimensionAffectingProps&&(this._initDimensions(),this.setCoords())},complexity:function(){return 1}}),e.Text.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size text-decoration text-anchor".split(" ")),e.Text.DEFAULT_SVG_FONT_SIZE=16,e.Text.fromElement=function(t,i){if(!t)return null;var r=e.parseAttributes(t,e.Text.ATTRIBUTE_NAMES);i=e.util.object.extend(i?e.util.object.clone(i):{},r),i.top=i.top||0,i.left=i.left||0,"dx"in r&&(i.left+=r.dx),"dy"in r&&(i.top+=r.dy),"fontSize"in i||(i.fontSize=e.Text.DEFAULT_SVG_FONT_SIZE),i.originX||(i.originX="left");var n="";"textContent"in t?n=t.textContent:"firstChild"in t&&null!==t.firstChild&&"data"in t.firstChild&&null!==t.firstChild.data&&(n=t.firstChild.data),n=n.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var s=new e.Text(n,i),o=0;return"left"===s.originX&&(o=s.getWidth()/2),"right"===s.originX&&(o=-s.getWidth()/2),s.set({left:s.getLeft()+o,top:s.getTop()-s.getHeight()/2+s.fontSize*(.18+s._fontSizeFraction)}),s},e.Text.fromObject=function(t){return new e.Text(t.text,r(t))},e.util.createAccessors(e.Text)}("undefined"!=typeof exports?exports:this),function(){var t=fabric.util.object.clone;fabric.IText=fabric.util.createClass(fabric.Text,fabric.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"#333",cursorDelay:1e3,cursorDuration:600,styles:null,caching:!0,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,_charWidthsCache:{},__widthOfSpace:[],initialize:function(t,e){this.styles=e?e.styles||{}:{},this.callSuper("initialize",t,e),this.initBehavior()},_clearCache:function(){this.callSuper("_clearCache"),this.__widthOfSpace=[]},isEmptyStyles:function(){if(!this.styles)return!0;var t=this.styles;for(var e in t)for(var i in t[e])for(var r in t[e][i])return!1;return!0},setSelectionStart:function(t){t=Math.max(t,0),this.selectionStart!==t&&(this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this}),this.selectionStart=t),this._updateTextarea()},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this.selectionEnd!==t&&(this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this}),this.selectionEnd=t),this._updateTextarea()},getSelectionStyles:function(t,e){if(2===arguments.length){for(var i=[],r=t;e>r;r++)i.push(this.getSelectionStyles(r));return i}var n=this.get2DCursorLocation(t),s=this._getStyleDeclaration(n.lineIndex,n.charIndex);return s||{}},setSelectionStyles:function(t){if(this.selectionStart===this.selectionEnd)this._extendStyles(this.selectionStart,t);else for(var e=this.selectionStart;e<this.selectionEnd;e++)this._extendStyles(e,t);return this._forceClearCache=!0,this},_extendStyles:function(t,e){var i=this.get2DCursorLocation(t);this._getLineStyle(i.lineIndex)||this._setLineStyle(i.lineIndex,{}),this._getStyleDeclaration(i.lineIndex,i.charIndex)||this._setStyleDeclaration(i.lineIndex,i.charIndex,{}),fabric.util.object.extend(this._getStyleDeclaration(i.lineIndex,i.charIndex),e)},_render:function(t){this.callSuper("_render",t),this.ctx=t,this.isEditing&&this.renderCursorOrSelection()},renderCursorOrSelection:function(){if(this.active){var t,e,i=this.text.split("");this.canvas.contextTop?(e=this.canvas.contextTop,e.save(),e.transform.apply(e,this.canvas.viewportTransform),this.transform(e),this.transformMatrix&&e.transform.apply(e,this.transformMatrix)):(e=this.ctx,e.save()),this.selectionStart===this.selectionEnd?(t=this._getCursorBoundaries(i,"cursor"),this.renderCursor(t,e)):(t=this._getCursorBoundaries(i,"selection"),this.renderSelection(i,t,e)),e.restore()}},get2DCursorLocation:function(t){"undefined"==typeof t&&(t=this.selectionStart);for(var e=this._textLines.length,i=0;e>i;i++){if(t<=this._textLines[i].length)return{lineIndex:i,charIndex:t};t-=this._textLines[i].length+1}return{lineIndex:i-1,charIndex:this._textLines[i-1].length<t?this._textLines[i-1].length:t}},getCurrentCharStyle:function(t,e){var i=this._getStyleDeclaration(t,0===e?0:e-1);return{fontSize:i&&i.fontSize||this.fontSize,fill:i&&i.fill||this.fill,textBackgroundColor:i&&i.textBackgroundColor||this.textBackgroundColor,textDecoration:i&&i.textDecoration||this.textDecoration,fontFamily:i&&i.fontFamily||this.fontFamily,fontWeight:i&&i.fontWeight||this.fontWeight,fontStyle:i&&i.fontStyle||this.fontStyle,stroke:i&&i.stroke||this.stroke,strokeWidth:i&&i.strokeWidth||this.strokeWidth}},getCurrentCharFontSize:function(t,e){var i=this._getStyleDeclaration(t,0===e?0:e-1);return i&&i.fontSize?i.fontSize:this.fontSize},getCurrentCharColor:function(t,e){var i=this._getStyleDeclaration(t,0===e?0:e-1);return i&&i.fill?i.fill:this.cursorColor},_getCursorBoundaries:function(t,e){var i=Math.round(this._getLeftOffset()),r=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:n.left+n.lineLeft,topOffset:n.top}},_getCursorBoundariesOffsets:function(t,e){for(var i=0,r=0,n=0,s=0,o=0,a=0;a<this.selectionStart;a++)"\n"===t[a]?(o=0,s+=this._getHeightOfLine(this.ctx,r),r++,n=0):(o+=this._getWidthOfChar(this.ctx,t[a],r,n),n++),i=this._getLineLeftOffset(this._getLineWidth(this.ctx,r));return"cursor"===e&&(s+=(1-this._fontSizeFraction)*this._getHeightOfLine(this.ctx,r)/this.lineHeight-this.getCurrentCharFontSize(r,n)*(1-this._fontSizeFraction)),{top:s,left:o,lineLeft:i}},renderCursor:function(t,e){var i=this.get2DCursorLocation(),r=i.lineIndex,n=i.charIndex,s=this.getCurrentCharFontSize(r,n),o=0===r&&0===n?this._getLineLeftOffset(this._getLineWidth(e,r)):t.leftOffset;e.fillStyle=this.getCurrentCharColor(r,n),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+o,t.top+t.topOffset,this.cursorWidth/this.scaleX,s)},renderSelection:function(t,e,i){i.fillStyle=this.selectionColor;for(var r=this.get2DCursorLocation(this.selectionStart),n=this.get2DCursorLocation(this.selectionEnd),s=r.lineIndex,o=n.lineIndex,a=s;o>=a;a++){var h=this._getLineLeftOffset(this._getLineWidth(i,a))||0,c=this._getHeightOfLine(this.ctx,a),l=0,u=this._textLines[a];if(a===s)for(var f=0,d=u.length;d>f;f++)f>=r.charIndex&&(a!==o||f<n.charIndex)&&(l+=this._getWidthOfChar(i,u[f],a,f)),f<r.charIndex&&(h+=this._getWidthOfChar(i,u[f],a,f));else if(a>s&&o>a)l+=this._getLineWidth(i,a)||5;else if(a===o)for(var g=0,p=n.charIndex;p>g;g++)l+=this._getWidthOfChar(i,u[g],a,g);i.fillRect(e.left+h,e.top+e.topOffset,l,c),e.topOffset+=c}},_renderChars:function(t,e,i,r,n,s,o){if(this.isEmptyStyles())return this._renderCharsFast(t,e,i,r,n);o=o||0,this.skipTextAlign=!0,r-="center"===this.textAlign?this.width/2:"right"===this.textAlign?this.width:0;var a,h,c=this._getHeightOfLine(e,s),l=this._getLineLeftOffset(this._getLineWidth(e,s)),u="";r+=l||0,e.save(),n-=c/this.lineHeight*this._fontSizeFraction;for(var f=o,d=i.length+o;d>=f;f++)a=a||this.getCurrentCharStyle(s,f),h=this.getCurrentCharStyle(s,f+1),(this._hasStyleChanged(a,h)||f===d)&&(this._renderChar(t,e,s,f-1,u,r,n,c),u="",a=h),u+=i[f-o];e.restore()},_renderCharsFast:function(t,e,i,r,n){this.skipTextAlign=!1,"fillText"===t&&this.fill&&this.callSuper("_renderChars",t,e,i,r,n),"strokeText"===t&&(this.stroke&&this.strokeWidth>0||this.skipFillStrokeCheck)&&this.callSuper("_renderChars",t,e,i,r,n)},_renderChar:function(t,e,i,r,n,s,o,a){var h,c,l,u,f,d,g=this._getStyleDeclaration(i,r);g?(c=this._getHeightOfChar(e,n,i,r),u=g.stroke,l=g.fill,d=g.textDecoration):c=this.fontSize,u=(u||this.stroke)&&"strokeText"===t,l=(l||this.fill)&&"fillText"===t,g&&e.save(),h=this._applyCharStylesGetWidth(e,n,i,r,g||{}),d=d||this.textDecoration,g&&g.textBackgroundColor&&this._removeShadow(e),l&&e.fillText(n,s,o),u&&e.strokeText(n,s,o),(d||""!==d)&&(f=this._fontSizeFraction*a/this.lineHeight,this._renderCharDecoration(e,d,s,o,f,h,c)),g&&e.restore(),e.translate(h,0)},_hasStyleChanged:function(t,e){return t.fill!==e.fill||t.fontSize!==e.fontSize||t.textBackgroundColor!==e.textBackgroundColor||t.textDecoration!==e.textDecoration||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth},_renderCharDecoration:function(t,e,i,r,n,s,o){if(e){var a,h,c=o/15,l={underline:r+o/10,"line-through":r-o*(this._fontSizeFraction+this._fontSizeMult-1)+c,overline:r-(this._fontSizeMult-this._fontSizeFraction)*o},u=["underline","line-through","overline"];for(a=0;a<u.length;a++)h=u[a],e.indexOf(h)>-1&&t.fillRect(i,l[h],s,c)}},_renderTextLine:function(t,e,i,r,n,s){this.isEmptyStyles()||(n+=this.fontSize*(this._fontSizeFraction+.03)),this.callSuper("_renderTextLine",t,e,i,r,n,s)},_renderTextDecoration:function(t){return this.isEmptyStyles()?this.callSuper("_renderTextDecoration",t):void 0},_renderTextLinesBackground:function(t){this.callSuper("_renderTextLinesBackground",t);for(var e,i,r,n,s,o,a=0,h=this._getLeftOffset(),c=this._getTopOffset(),l=0,u=this._textLines.length;u>l;l++)if(e=this._getHeightOfLine(t,l),n=this._textLines[l],""!==n&&this.styles&&this._getLineStyle(l)){i=this._getLineWidth(t,l),r=this._getLineLeftOffset(i);for(var f=0,d=n.length;d>f;f++)o=this._getStyleDeclaration(l,f),o&&o.textBackgroundColor&&(s=n[f],t.fillStyle=o.textBackgroundColor,t.fillRect(h+r+this._getWidthOfCharsAt(t,l,f),c+a,this._getWidthOfChar(t,s,l,f)+1,e/this.lineHeight));a+=e}else a+=e},_getCacheProp:function(t,e){return t+e.fontFamily+e.fontSize+e.fontWeight+e.fontStyle+e.shadow},_applyCharStylesGetWidth:function(e,i,r,n,s){var o,a=this._getStyleDeclaration(r,n),h=s&&t(s)||t(a);this._applyFontStyles(h);var c=this._getCacheProp(i,h);if(!a&&this._charWidthsCache[c]&&this.caching)return this._charWidthsCache[c];"string"==typeof h.shadow&&(h.shadow=new fabric.Shadow(h.shadow));var l=h.fill||this.fill;return e.fillStyle=l.toLive?l.toLive(e,this):l,h.stroke&&(e.strokeStyle=h.stroke&&h.stroke.toLive?h.stroke.toLive(e,this):h.stroke),e.lineWidth=h.strokeWidth||this.strokeWidth,e.font=this._getFontDeclaration.call(h),h.shadow&&(h.scaleX=this.scaleX,h.scaleY=this.scaleY,h.canvas=this.canvas,this._setShadow.call(h,e)),this.caching&&this._charWidthsCache[c]?this._charWidthsCache[c]:(o=e.measureText(i).width,this.caching&&(this._charWidthsCache[c]=o),o)},_applyFontStyles:function(t){t.fontFamily||(t.fontFamily=this.fontFamily),t.fontSize||(t.fontSize=this.fontSize),t.fontWeight||(t.fontWeight=this.fontWeight),t.fontStyle||(t.fontStyle=this.fontStyle)},_getStyleDeclaration:function(e,i,r){return r?this.styles[e]&&this.styles[e][i]?t(this.styles[e][i]):{}:this.styles[e]&&this.styles[e][i]?this.styles[e][i]:null},_setStyleDeclaration:function(t,e,i){this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){delete this.styles[t][e]},_getLineStyle:function(t){return this.styles[t]},_setLineStyle:function(t,e){this.styles[t]=e},_deleteLineStyle:function(t){delete this.styles[t]},_getWidthOfChar:function(t,e,i,r){if(!this._isMeasuring&&"justify"===this.textAlign&&this._reSpacesAndTabs.test(e))return this._getWidthOfSpace(t,i);var n=this._getStyleDeclaration(i,r,!0);this._applyFontStyles(n);var s=this._getCacheProp(e,n);if(this._charWidthsCache[s]&&this.caching)return this._charWidthsCache[s];if(t){t.save();var o=this._applyCharStylesGetWidth(t,e,i,r);return t.restore(),o}},_getHeightOfChar:function(t,e,i){var r=this._getStyleDeclaration(e,i);return r&&r.fontSize?r.fontSize:this.fontSize},_getWidthOfCharsAt:function(t,e,i){var r,n,s=0;for(r=0;i>r;r++)n=this._textLines[e][r],s+=this._getWidthOfChar(t,n,e,r);return s},_measureLine:function(t,e){this._isMeasuring=!0;var i=this._getWidthOfCharsAt(t,e,this._textLines[e].length);return this._isMeasuring=!1,i},_getWidthOfSpace:function(t,e){if(this.__widthOfSpace[e])return this.__widthOfSpace[e];var i=this._textLines[e],r=this._getWidthOfWords(t,i,e,0),n=this.width-r,s=i.length-i.replace(this._reSpacesAndTabs,"").length,o=Math.max(n/s,t.measureText(" ").width);return this.__widthOfSpace[e]=o,o},_getWidthOfWords:function(t,e,i,r){for(var n=0,s=0;s<e.length;s++){var o=e[s];o.match(/\s/)||(n+=this._getWidthOfChar(t,o,i,s+r))}return n},_getHeightOfLine:function(t,e){if(this.__lineHeights[e])return this.__lineHeights[e];for(var i=this._textLines[e],r=this._getHeightOfChar(t,e,0),n=1,s=i.length;s>n;n++){var o=this._getHeightOfChar(t,e,n);o>r&&(r=o)}return this.__lineHeights[e]=r*this.lineHeight*this._fontSizeMult,this.__lineHeights[e]},_getTextHeight:function(t){for(var e=0,i=0,r=this._textLines.length;r>i;i++)e+=this._getHeightOfLine(t,i);return e},toObject:function(e){var i,r,n,s={};for(i in this.styles){n=this.styles[i],s[i]={};for(r in n)s[i][r]=t(n[r])}return fabric.util.object.extend(this.callSuper("toObject",e),{styles:s})}}),fabric.IText.fromObject=function(e){return new fabric.IText(e.text,t(e))}}(),function(){var t=fabric.util.object.clone;fabric.util.object.extend(fabric.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation()},initSelectedHandler:function(){this.on("selected",function(){var t=this;setTimeout(function(){t.selected=!0},100)})},initAddedHandler:function(){var t=this;this.on("added",function(){this.canvas&&!this.canvas._hasITextHandlers&&(this.canvas._hasITextHandlers=!0,this._initCanvasHandlers()),t.canvas&&(t.canvas._iTextInstances=t.canvas._iTextInstances||[],t.canvas._iTextInstances.push(t))})},initRemovedHandler:function(){var t=this;this.on("removed",function(){t.canvas&&(t.canvas._iTextInstances=t.canvas._iTextInstances||[],fabric.util.removeFromArray(t.canvas._iTextInstances,t))})},_initCanvasHandlers:function(){var t=this;this.canvas.on("selection:cleared",function(){fabric.IText.prototype.exitEditingOnOthers(t.canvas)}),this.canvas.on("mouse:up",function(){t.canvas._iTextInstances&&t.canvas._iTextInstances.forEach(function(t){t.__isMousedown=!1})}),this.canvas.on("object:selected",function(){fabric.IText.prototype.exitEditingOnOthers(t.canvas)})},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,r){var n;return n={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){n.isAborted||t[r]()},onChange:function(){t.canvas&&(t.canvas.clearContext(t.canvas.contextTop||t.ctx),t.renderCursorOrSelection())},abort:function(){return n.isAborted}}),n},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),this._currentCursorOpacity=1,this.canvas&&(this.canvas.clearContext(this.canvas.contextTop||this.ctx),this.renderCursorOrSelection()),this._cursorTimeout2&&clearTimeout(this._cursorTimeout2),this._cursorTimeout2=setTimeout(function(){e._tick()},i)},abortCursorAnimation:function(){this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,this.canvas&&this.canvas.clearContext(this.canvas.contextTop||this.ctx)},selectAll:function(){this.setSelectionStart(0),this.setSelectionEnd(this.text.length)},getSelectedText:function(){return this.text.slice(this.selectionStart,this.selectionEnd)},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this.text.charAt(i)))for(;this._reSpace.test(this.text.charAt(i));)e++,i--;for(;/\S/.test(this.text.charAt(i))&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this.text.charAt(i)))for(;this._reSpace.test(this.text.charAt(i));)e++,i++;for(;/\S/.test(this.text.charAt(i))&&i<this.text.length;)e++,i++;return t+e},findLineBoundaryLeft:function(t){for(var e=0,i=t-1;!/\n/.test(this.text.charAt(i))&&i>-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this.text.charAt(i))&&i<this.text.length;)e++,i++;return t+e},getNumNewLinesInSelectedText:function(){for(var t=this.getSelectedText(),e=0,i=0,r=t.length;r>i;i++)"\n"===t[i]&&e++;return e},searchWordBoundary:function(t,e){for(var i=this._reSpace.test(this.text.charAt(t))?t-1:t,r=this.text.charAt(i),n=/[ \n\.,;!\?\-]/;!n.test(r)&&i>0&&i<this.text.length;)i+=e,r=this.text.charAt(i);return n.test(r)&&"\n"!==r&&(i+=1===e?0:1),i},selectWord:function(t){var e=this.searchWordBoundary(t,-1),i=this.searchWordBoundary(t,1);this.setSelectionStart(e),this.setSelectionEnd(i)},selectLine:function(t){var e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.setSelectionStart(e),this.setSelectionEnd(i)},enterEditing:function(t){return!this.isEditing&&this.editable?(this.canvas&&this.exitEditingOnOthers(this.canvas),this.isEditing=!0,this.initHiddenTextarea(t),this.hiddenTextarea.focus(),this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this.canvas?(this.canvas.renderAll(),this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this):this):void 0},exitEditingOnOthers:function(t){t._iTextInstances&&t._iTextInstances.forEach(function(t){t.selected=!1,t.isEditing&&t.exitEditing()})},initMouseMoveHandler:function(){var t=this;this.canvas.on("mouse:move",function(e){if(t.__isMousedown&&t.isEditing){var i=t.getSelectionStartFromPointer(e.e);i>=t.__selectionStartOnMouseDown?(t.setSelectionStart(t.__selectionStartOnMouseDown),t.setSelectionEnd(i)):(t.setSelectionStart(i),t.setSelectionEnd(t.__selectionStartOnMouseDown))}})},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},_updateTextarea:function(){if(this.hiddenTextarea&&!this.inCompositionMode&&(this.hiddenTextarea.value=this.text,this.hiddenTextarea.selectionStart=this.selectionStart,this.hiddenTextarea.selectionEnd=this.selectionEnd,this.selectionStart===this.selectionEnd)){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.x+"px",this.hiddenTextarea.style.top=t.y+"px"}},_calcTextareaPosition:function(){var t=this.text.split(""),e=this._getCursorBoundaries(t,"cursor"),i=this.get2DCursorLocation(),r=i.lineIndex,n=i.charIndex,s=this.getCurrentCharFontSize(r,n),o=0===r&&0===n?this._getLineLeftOffset(this._getLineWidth(this.ctx,r)):e.leftOffset,a=this.calcTransformMatrix(),h={x:e.left+o,y:e.top+e.topOffset+s};return this.hiddenTextarea.style.fontSize=s+"px",fabric.util.transformPoint(h,a)},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.overCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text;return this.selected=!1,this.isEditing=!1,this.selectable=!0,this.selectionEnd=this.selectionStart,this.hiddenTextarea&&this.canvas&&this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},_removeCharsFromTo:function(t,e){for(;e!==t;)this._removeSingleCharAndStyle(t+1),e--;this.setSelectionStart(t)},_removeSingleCharAndStyle:function(t){var e="\n"===this.text[t-1],i=e?t:t-1;this.removeStyleObject(e,i),this.text=this.text.slice(0,t-1)+this.text.slice(t),this._textLines=this._splitTextIntoLines()},insertChars:function(t,e){var i;if(this.selectionEnd-this.selectionStart>1&&(this._removeCharsFromTo(this.selectionStart,this.selectionEnd),this.setSelectionEnd(this.selectionStart)),!e&&this.isEmptyStyles())return void this.insertChar(t,!1);for(var r=0,n=t.length;n>r;r++)e&&(i=fabric.copiedTextStyle[r]),this.insertChar(t[r],n-1>r,i)},insertChar:function(t,e,i){var r="\n"===this.text[this.selectionStart];this.text=this.text.slice(0,this.selectionStart)+t+this.text.slice(this.selectionEnd),this._textLines=this._splitTextIntoLines(),this.insertStyleObjects(t,r,i),this.selectionStart+=t.length,this.selectionEnd=this.selectionStart,e||(this._updateTextarea(),this.canvas&&this.canvas.renderAll(),this.setCoords(),this.fire("changed"),this.canvas&&this.canvas.fire("text:changed",{target:this}))},insertNewlineStyleObject:function(e,i,r){this.shiftLineStyles(e,1),this.styles[e+1]||(this.styles[e+1]={});var n={},s={};if(this.styles[e]&&this.styles[e][i-1]&&(n=this.styles[e][i-1]),r)s[0]=t(n),this.styles[e+1]=s;else{for(var o in this.styles[e])parseInt(o,10)>=i&&(s[parseInt(o,10)-i]=this.styles[e][o],delete this.styles[e][o]);this.styles[e+1]=s}this._forceClearCache=!0},insertCharStyleObject:function(e,i,r){var n=this.styles[e],s=t(n);0!==i||r||(i=1);for(var o in s){var a=parseInt(o,10);a>=i&&(n[a+1]=s[a],s[a-1]||delete n[a])}this.styles[e][i]=r||t(n[i-1]),this._forceClearCache=!0},insertStyleObjects:function(t,e,i){var r=this.get2DCursorLocation(),n=r.lineIndex,s=r.charIndex;this._getLineStyle(n)||this._setLineStyle(n,{}),"\n"===t?this.insertNewlineStyleObject(n,s,e):this.insertCharStyleObject(n,s,i)},shiftLineStyles:function(e,i){var r=t(this.styles);for(var n in this.styles){var s=parseInt(n,10);s>e&&(this.styles[s+i]=r[s],r[s-i]||delete this.styles[s])}},removeStyleObject:function(t,e){var i=this.get2DCursorLocation(e),r=i.lineIndex,n=i.charIndex;this._removeStyleObject(t,i,r,n)},_getTextOnPreviousLine:function(t){return this._textLines[t-1]},_removeStyleObject:function(e,i,r,n){if(e){var s=this._getTextOnPreviousLine(i.lineIndex),o=s?s.length:0;this.styles[r-1]||(this.styles[r-1]={});for(n in this.styles[r])this.styles[r-1][parseInt(n,10)+o]=this.styles[r][n];this.shiftLineStyles(i.lineIndex,-1)}else{var a=this.styles[r];a&&delete a[n];var h=t(a);for(var c in h){var l=parseInt(c,10);l>=n&&0!==l&&(a[l-1]=h[l],delete a[l])}}},insertNewline:function(){this.insertChars("\n")}})}(),fabric.util.object.extend(fabric.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown.bind(this))},onMouseDown:function(t){this.__newClickTime=+new Date;var e=this.canvas.getPointer(t.e);this.isTripleClick(e)?(this.fire("tripleclick",t),this._stopEvent(t.e)):this.isDoubleClick(e)&&(this.fire("dblclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected},isDoubleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y&&this.__lastIsEditing},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initSelectedHandler(),this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},initClicks:function(){this.on("dblclick",function(t){this.selectWord(this.getSelectionStartFromPointer(t.e))}),this.on("tripleclick",function(t){this.selectLine(this.getSelectionStartFromPointer(t.e))})},initMousedownHandler:function(){this.on("mousedown",function(t){if(this.editable){var e=this.canvas.getPointer(t.e);this.__mousedownX=e.x,this.__mousedownY=e.y,this.__isMousedown=!0,this.hiddenTextarea&&this.canvas&&this.canvas.wrapperEl.appendChild(this.hiddenTextarea),this.selected&&this.setCursorByClick(t.e),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.initDelayedCursor(!0))}})},_isObjectMoved:function(t){var e=this.canvas.getPointer(t);return this.__mousedownX!==e.x||this.__mousedownY!==e.y},initMouseupHandler:function(){this.on("mouseup",function(t){this.__isMousedown=!1,this.editable&&!this._isObjectMoved(t.e)&&(this.__lastSelected&&!this.__corner&&(this.enterEditing(t.e),this.initDelayedCursor(!0)),this.selected=!0)})},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t);t.shiftKey?e<this.selectionStart?(this.setSelectionEnd(this.selectionStart),this.setSelectionStart(e)):this.setSelectionEnd(e):(this.setSelectionStart(e),this.setSelectionEnd(e))},getSelectionStartFromPointer:function(t){for(var e,i,r=this.getLocalPointer(t),n=0,s=0,o=0,a=0,h=0,c=this._textLines.length;c>h;h++){i=this._textLines[h],o+=this._getHeightOfLine(this.ctx,h)*this.scaleY;var l=this._getLineWidth(this.ctx,h),u=this._getLineLeftOffset(l);s=u*this.scaleX;for(var f=0,d=i.length;d>f;f++){if(n=s,s+=this._getWidthOfChar(this.ctx,i[f],h,this.flipX?d-f:f)*this.scaleX,!(o<=r.y||s<=r.x))return this._getNewSelectionStartFromOffset(r,n,s,a+h,d);a++}if(r.y<o)return this._getNewSelectionStartFromOffset(r,n,s,a+h-1,d)}return"undefined"==typeof e?this.text.length:void 0},_getNewSelectionStartFromOffset:function(t,e,i,r,n){var s=t.x-e,o=i-t.x,a=o>s?0:1,h=r+a;return this.flipX&&(h=n-h),h>this.text.length&&(h=this.text.length),h}}),fabric.util.object.extend(fabric.IText.prototype,{initHiddenTextarea:function(t){var e;t&&this.canvas?e=this.canvas.getPointer(t):(this.oCoords||this.setCoords(),e=this.oCoords.tl),this.hiddenTextarea=fabric.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.style.cssText="position: absolute; top: "+e.y+"px; left: "+e.x+"px; opacity: 0; width: 0px; height: 0px; z-index: -999;",this.canvas?this.canvas.lowerCanvasEl.parentNode.appendChild(this.hiddenTextarea):fabric.document.body.appendChild(this.hiddenTextarea),fabric.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),fabric.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),fabric.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),fabric.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),fabric.util.addListener(this.hiddenTextarea,"cut",this.cut.bind(this)),fabric.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),
8
- !this._clickHandlerInitialized&&this.canvas&&(fabric.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},_keysMap:{8:"removeChars",9:"exitEditing",27:"exitEditing",13:"insertNewline",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown",46:"forwardDelete"},_ctrlKeysMapUp:{67:"copy",88:"cut"},_ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){if(t.keyCode in this._keysMap)this[this._keysMap[t.keyCode]](t);else{if(!(t.keyCode in this._ctrlKeysMapDown&&(t.ctrlKey||t.metaKey)))return;this[this._ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.renderAll()}},onKeyUp:function(t){return!this.isEditing||this._copyDone?void(this._copyDone=!1):void(t.keyCode in this._ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this._ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.renderAll()))},onInput:function(t){if(this.isEditing&&!this.inCompositionMode){var e,i,r,n=this.selectionStart||0,s=this.selectionEnd||0,o=this.text.length,a=this.hiddenTextarea.value.length;a>o?(r="left"===this._selectionDirection?s:n,e=a-o,i=this.hiddenTextarea.value.slice(r,r+e)):(e=a-o+s-n,i=this.hiddenTextarea.value.slice(n,n+e)),this.insertChars(i),t.stopPropagation()}},onCompositionStart:function(){this.inCompositionMode=!0,this.prevCompositionLength=0,this.compositionStart=this.selectionStart},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(t){var e=t.data;this.selectionStart=this.compositionStart,this.selectionEnd=this.selectionEnd===this.selectionStart?this.compositionStart+this.prevCompositionLength:this.selectionEnd,this.insertChars(e,!1),this.prevCompositionLength=e.length},forwardDelete:function(t){if(this.selectionStart===this.selectionEnd){if(this.selectionStart===this.text.length)return;this.moveCursorRight(t)}this.removeChars(t)},copy:function(t){if(this.selectionStart!==this.selectionEnd){var e=this.getSelectedText(),i=this._getClipboardData(t);i&&i.setData("text",e),fabric.copiedText=e,fabric.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd),t.stopImmediatePropagation(),t.preventDefault(),this._copyDone=!0}},paste:function(t){var e=null,i=this._getClipboardData(t),r=!0;i?(e=i.getData("text").replace(/\r/g,""),fabric.copiedTextStyle&&fabric.copiedText===e||(r=!1)):e=fabric.copiedText,e&&this.insertChars(e,r),t.stopImmediatePropagation(),t.preventDefault()},cut:function(t){this.selectionStart!==this.selectionEnd&&(this.copy(t),this.removeChars(t))},_getClipboardData:function(t){return t&&t.clipboardData||fabric.window.clipboardData},getDownCursorOffset:function(t,e){var i,r,n=e?this.selectionEnd:this.selectionStart,s=this.get2DCursorLocation(n),o=s.lineIndex,a=this._textLines[o].slice(0,s.charIndex),h=this._textLines[o].slice(s.charIndex),c=this._textLines[o+1]||"";if(o===this._textLines.length-1||t.metaKey||34===t.keyCode)return this.text.length-n;var l=this._getLineWidth(this.ctx,o);r=this._getLineLeftOffset(l);for(var u=r,f=0,d=a.length;d>f;f++)i=a[f],u+=this._getWidthOfChar(this.ctx,i,o,f);var g=this._getIndexOnNextLine(s,c,u);return h.length+1+g},_getIndexOnNextLine:function(t,e,i){for(var r,n=t.lineIndex+1,s=this._getLineWidth(this.ctx,n),o=this._getLineLeftOffset(s),a=o,h=0,c=0,l=e.length;l>c;c++){var u=e[c],f=this._getWidthOfChar(this.ctx,u,n,c);if(a+=f,a>i){r=!0;var d=a-f,g=a,p=Math.abs(d-i),v=Math.abs(g-i);h=p>v?c+1:c;break}}return r||(h=e.length),h},moveCursorDown:function(t){this.abortCursorAnimation(),this._currentCursorOpacity=1;var e=this.getDownCursorOffset(t,"right"===this._selectionDirection);t.shiftKey?this.moveCursorDownWithShift(e):this.moveCursorDownWithoutShift(e),this.initDelayedCursor()},moveCursorDownWithoutShift:function(t){this._selectionDirection="right",this.setSelectionStart(this.selectionStart+t),this.setSelectionEnd(this.selectionStart)},swapSelectionPoints:function(){var t=this.selectionEnd;this.setSelectionEnd(this.selectionStart),this.setSelectionStart(t)},moveCursorDownWithShift:function(t){this.selectionEnd===this.selectionStart&&(this._selectionDirection="right"),"right"===this._selectionDirection?this.setSelectionEnd(this.selectionEnd+t):this.setSelectionStart(this.selectionStart+t),this.selectionEnd<this.selectionStart&&"left"===this._selectionDirection&&(this.swapSelectionPoints(),this._selectionDirection="right"),this.selectionEnd>this.text.length&&this.setSelectionEnd(this.text.length)},getUpCursorOffset:function(t,e){var i=e?this.selectionEnd:this.selectionStart,r=this.get2DCursorLocation(i),n=r.lineIndex;if(0===n||t.metaKey||33===t.keyCode)return i;for(var s,o=this._textLines[n].slice(0,r.charIndex),a=this._textLines[n-1]||"",h=this._getLineWidth(this.ctx,r.lineIndex),c=this._getLineLeftOffset(h),l=c,u=0,f=o.length;f>u;u++)s=o[u],l+=this._getWidthOfChar(this.ctx,s,n,u);var d=this._getIndexOnPrevLine(r,a,l);return a.length-d+o.length},_getIndexOnPrevLine:function(t,e,i){for(var r,n=t.lineIndex-1,s=this._getLineWidth(this.ctx,n),o=this._getLineLeftOffset(s),a=o,h=0,c=0,l=e.length;l>c;c++){var u=e[c],f=this._getWidthOfChar(this.ctx,u,n,c);if(a+=f,a>i){r=!0;var d=a-f,g=a,p=Math.abs(d-i),v=Math.abs(g-i);h=p>v?c:c-1;break}}return r||(h=e.length-1),h},moveCursorUp:function(t){this.abortCursorAnimation(),this._currentCursorOpacity=1;var e=this.getUpCursorOffset(t,"right"===this._selectionDirection);t.shiftKey?this.moveCursorUpWithShift(e):this.moveCursorUpWithoutShift(e),this.initDelayedCursor()},moveCursorUpWithShift:function(t){this.selectionEnd===this.selectionStart&&(this._selectionDirection="left"),"right"===this._selectionDirection?this.setSelectionEnd(this.selectionEnd-t):this.setSelectionStart(this.selectionStart-t),this.selectionEnd<this.selectionStart&&"right"===this._selectionDirection&&(this.swapSelectionPoints(),this._selectionDirection="left")},moveCursorUpWithoutShift:function(t){this.selectionStart===this.selectionEnd&&this.setSelectionStart(this.selectionStart-t),this.setSelectionEnd(this.selectionStart),this._selectionDirection="left"},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||(this.abortCursorAnimation(),this._currentCursorOpacity=1,t.shiftKey?this.moveCursorLeftWithShift(t):this.moveCursorLeftWithoutShift(t),this.initDelayedCursor())},_move:function(t,e,i){var r="selectionStart"===e?"setSelectionStart":"setSelectionEnd";t.altKey?this[r](this["findWordBoundary"+i](this[e])):t.metaKey||35===t.keyCode||36===t.keyCode?this[r](this["findLineBoundary"+i](this[e])):this[r](this[e]+("Left"===i?-1:1))},_moveLeft:function(t,e){this._move(t,e,"Left")},_moveRight:function(t,e){this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this._moveLeft(t,"selectionStart"),this.setSelectionEnd(this.selectionStart)},moveCursorLeftWithShift:function(t){"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):(this._selectionDirection="left",this._moveLeft(t,"selectionStart"))},moveCursorRight:function(t){this.selectionStart>=this.text.length&&this.selectionEnd>=this.text.length||(this.abortCursorAnimation(),this._currentCursorOpacity=1,t.shiftKey?this.moveCursorRightWithShift(t):this.moveCursorRightWithoutShift(t),this.initDelayedCursor())},moveCursorRightWithShift:function(t){"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):(this._selectionDirection="right",this._moveRight(t,"selectionEnd"))},moveCursorRightWithoutShift:function(t){this._selectionDirection="right",this.selectionStart===this.selectionEnd?(this._moveRight(t,"selectionStart"),this.setSelectionEnd(this.selectionStart)):(this.setSelectionEnd(this.selectionEnd+this.getNumNewLinesInSelectedText()),this.setSelectionStart(this.selectionEnd))},removeChars:function(t){this.selectionStart===this.selectionEnd?this._removeCharsNearCursor(t):this._removeCharsFromTo(this.selectionStart,this.selectionEnd),this.setSelectionEnd(this.selectionStart),this._removeExtraneousStyles(),this.canvas&&this.canvas.renderAll(),this.setCoords(),this.fire("changed"),this.canvas&&this.canvas.fire("text:changed",{target:this})},_removeCharsNearCursor:function(t){if(0!==this.selectionStart)if(t.metaKey){var e=this.findLineBoundaryLeft(this.selectionStart);this._removeCharsFromTo(e,this.selectionStart),this.setSelectionStart(e)}else if(t.altKey){var i=this.findWordBoundaryLeft(this.selectionStart);this._removeCharsFromTo(i,this.selectionStart),this.setSelectionStart(i)}else this._removeSingleCharAndStyle(this.selectionStart),this.setSelectionStart(this.selectionStart-1)}}),function(){var t=fabric.util.toFixed,e=fabric.Object.NUM_FRACTION_DIGITS;fabric.util.object.extend(fabric.IText.prototype,{_setSVGTextLineText:function(t,e,i,r,n,s){this._getLineStyle(t)?this._setSVGTextLineChars(t,e,i,r,s):fabric.Text.prototype._setSVGTextLineText.call(this,t,e,i,r,n)},_setSVGTextLineChars:function(t,e,i,r,n){for(var s=this._textLines[t],o=0,a=this._getLineLeftOffset(this._getLineWidth(this.ctx,t))-this.width/2,h=this._getSVGLineTopOffset(t),c=this._getHeightOfLine(this.ctx,t),l=0,u=s.length;u>l;l++){var f=this._getStyleDeclaration(t,l)||{};e.push(this._createTextCharSpan(s[l],f,a,h.lineTop+h.offset,o));var d=this._getWidthOfChar(this.ctx,s[l],t,l);f.textBackgroundColor&&n.push(this._createTextCharBg(f,a,h.lineTop,c,d,o)),o+=d}},_getSVGLineTopOffset:function(t){for(var e=0,i=0,r=0;t>r;r++)e+=this._getHeightOfLine(this.ctx,r);return i=this._getHeightOfLine(this.ctx,r),{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}},_createTextCharBg:function(i,r,n,s,o,a){return[' <rect fill="',i.textBackgroundColor,'" x="',t(r+a,e),'" y="',t(n-this.height/2,e),'" width="',t(o,e),'" height="',t(s/this.lineHeight,e),'"></rect>\n'].join("")},_createTextCharSpan:function(i,r,n,s,o){var a=this.getSvgStyles.call(fabric.util.object.extend({visible:!0,fill:this.fill,stroke:this.stroke,type:"text",getSvgFilter:fabric.Object.prototype.getSvgFilter},r));return[' <tspan x="',t(n+o,e),'" y="',t(s-this.height/2,e),'" ',r.fontFamily?'font-family="'+r.fontFamily.replace(/"/g,"'")+'" ':"",r.fontSize?'font-size="'+r.fontSize+'" ':"",r.fontStyle?'font-style="'+r.fontStyle+'" ':"",r.fontWeight?'font-weight="'+r.fontWeight+'" ':"",r.textDecoration?'text-decoration="'+r.textDecoration+'" ':"",'style="',a,'">',fabric.util.string.escapeXml(i),"</tspan>\n"].join("")}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.clone;e.Textbox=e.util.createClass(e.IText,e.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:0,__cachedLines:null,lockScalingY:!0,lockScalingFlip:!0,initialize:function(t,i){this.ctx=e.util.createCanvasElement().getContext("2d"),this.callSuper("initialize",t,i),this.setControlsVisibility(e.Textbox.getTextboxControlVisibility()),this._dimensionAffectingProps.width=!0},_initDimensions:function(t){this.__skipDimension||(t||(t=e.util.createCanvasElement().getContext("2d"),this._setTextStyles(t)),this.dynamicMinWidth=0,this._textLines=this._splitTextIntoLines(),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this._clearCache(),this.height=this._getTextHeight(t))},_generateStyleMap:function(){for(var t=0,e=0,i=0,r={},n=0;n<this._textLines.length;n++)"\n"===this.text[i]?(e=0,i++,t++):" "===this.text[i]&&(e++,i++),r[n]={line:t,offset:e},i+=this._textLines[n].length,e+=this._textLines[n].length;return r},_getStyleDeclaration:function(t,e,i){if(this._styleMap){var r=this._styleMap[t];if(!r)return i?{}:null;t=r.line,e=r.offset+e}return this.callSuper("_getStyleDeclaration",t,e,i)},_setStyleDeclaration:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){var i=this._styleMap[t];t=i.line,e=i.offset+e,delete this.styles[t][e]},_getLineStyle:function(t){var e=this._styleMap[t];return this.styles[e.line]},_setLineStyle:function(t,e){var i=this._styleMap[t];this.styles[i.line]=e},_deleteLineStyle:function(t){var e=this._styleMap[t];delete this.styles[e.line]},_wrapText:function(t,e){var i,r=e.split(this._reNewline),n=[];for(i=0;i<r.length;i++)n=n.concat(this._wrapLine(t,r[i],i));return n},_measureText:function(t,e,i,r){var n=0;r=r||0;for(var s=0,o=e.length;o>s;s++)n+=this._getWidthOfChar(t,e[s],i,s+r);return n},_wrapLine:function(t,e,i){for(var r=0,n=[],s="",o=e.split(" "),a="",h=0,c=" ",l=0,u=0,f=0,d=!0,g=0;g<o.length;g++)a=o[g],l=this._measureText(t,a,i,h),h+=a.length,r+=u+l,r>=this.width&&!d&&(n.push(s),s="",r=l,d=!0),d||(s+=c),s+=a,u=this._measureText(t,c,i,h),h++,d=!1,l>f&&(f=l);return g&&n.push(s),f>this.dynamicMinWidth&&(this.dynamicMinWidth=f),n},_splitTextIntoLines:function(){var t=this.textAlign;this.ctx.save(),this._setTextStyles(this.ctx),this.textAlign="left";var e=this._wrapText(this.ctx,this.text);return this.textAlign=t,this.ctx.restore(),this._textLines=e,this._styleMap=this._generateStyleMap(),e},setOnGroup:function(t,e){"scaleX"===t&&(this.set("scaleX",Math.abs(1/e)),this.set("width",this.get("width")*e/("undefined"==typeof this.__oldScaleX?1:this.__oldScaleX)),this.__oldScaleX=e)},get2DCursorLocation:function(t){"undefined"==typeof t&&(t=this.selectionStart);for(var e=this._textLines.length,i=0,r=0;e>r;r++){var n=this._textLines[r],s=n.length;if(i+s>=t)return{lineIndex:r,charIndex:t-i};i+=s,"\n"!==this.text[i]&&" "!==this.text[i]||i++}return{lineIndex:e-1,charIndex:this._textLines[e-1].length}},_getCursorBoundariesOffsets:function(t,e){for(var i=0,r=0,n=this.get2DCursorLocation(),s=this._textLines[n.lineIndex].split(""),o=this._getLineLeftOffset(this._getLineWidth(this.ctx,n.lineIndex)),a=0;a<n.charIndex;a++)r+=this._getWidthOfChar(this.ctx,s[a],n.lineIndex,a);for(a=0;a<n.lineIndex;a++)i+=this._getHeightOfLine(this.ctx,a);return"cursor"===e&&(i+=(1-this._fontSizeFraction)*this._getHeightOfLine(this.ctx,n.lineIndex)/this.lineHeight-this.getCurrentCharFontSize(n.lineIndex,n.charIndex)*(1-this._fontSizeFraction)),{top:i,left:r,lineLeft:o}},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},toObject:function(t){return e.util.object.extend(this.callSuper("toObject",t),{minWidth:this.minWidth})}}),e.Textbox.fromObject=function(t){return new e.Textbox(t.text,i(t))},e.Textbox.getTextboxControlVisibility=function(){return{tl:!1,tr:!1,br:!1,bl:!1,ml:!0,mt:!1,mr:!0,mb:!1,mtr:!0}},e.Textbox.instances=[]}("undefined"!=typeof exports?exports:this),function(){var t=fabric.Canvas.prototype._setObjectScale;fabric.Canvas.prototype._setObjectScale=function(e,i,r,n,s,o,a){var h=i.target;if(!(h instanceof fabric.Textbox))return t.call(fabric.Canvas.prototype,e,i,r,n,s,o,a);var c=h.width*(e.x/i.scaleX/(h.width+h.strokeWidth));return c>=h.getMinWidth()?(h.set("width",c),!0):void 0},fabric.Group.prototype._refreshControlsVisibility=function(){if("undefined"!=typeof fabric.Textbox)for(var t=this._objects.length;t--;)if(this._objects[t]instanceof fabric.Textbox)return void this.setControlsVisibility(fabric.Textbox.getTextboxControlVisibility())};var e=fabric.util.object.clone;fabric.util.object.extend(fabric.Textbox.prototype,{_removeExtraneousStyles:function(){for(var t in this._styleMap)this._textLines[t]||delete this.styles[this._styleMap[t].line]},insertCharStyleObject:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,fabric.IText.prototype.insertCharStyleObject.apply(this,[t,e,i])},insertNewlineStyleObject:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,fabric.IText.prototype.insertNewlineStyleObject.apply(this,[t,e,i])},shiftLineStyles:function(t,i){var r=e(this.styles),n=this._styleMap[t];t=n.line;for(var s in this.styles){var o=parseInt(s,10);o>t&&(this.styles[o+i]=r[o],r[o-i]||delete this.styles[o])}},_getTextOnPreviousLine:function(t){for(var e=this._textLines[t-1];this._styleMap[t-2]&&this._styleMap[t-2].line===this._styleMap[t-1].line;)e=this._textLines[t-2]+e,t--;return e},removeStyleObject:function(t,e){var i=this.get2DCursorLocation(e),r=this._styleMap[i.lineIndex],n=r.line,s=r.offset+i.charIndex;this._removeStyleObject(t,i,n,s)}})}(),function(){var t=fabric.IText.prototype._getNewSelectionStartFromOffset;fabric.IText.prototype._getNewSelectionStartFromOffset=function(e,i,r,n,s){n=t.call(this,e,i,r,n,s);for(var o=0,a=0,h=0;h<this._textLines.length&&(o+=this._textLines[h].length,!(o+a>=n));h++)"\n"!==this.text[o+a]&&" "!==this.text[o+a]||a++;return n-h+a}}(),function(){function request(t,e,i){var r=URL.parse(t);r.port||(r.port=0===r.protocol.indexOf("https:")?443:80);var n=0===r.protocol.indexOf("https:")?HTTPS:HTTP,s=n.request({hostname:r.hostname,port:r.port,path:r.path,method:"GET"},function(t){var r="";e&&t.setEncoding(e),t.on("end",function(){i(r)}),t.on("data",function(e){200===t.statusCode&&(r+=e)})});s.on("error",function(t){t.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port):fabric.log(t.message),i(null)}),s.end()}function requestFs(t,e){var i=require("fs");i.readFile(t,function(t,i){if(t)throw fabric.log(t),t;e(i)})}if("undefined"==typeof document||"undefined"==typeof window){var DOMParser=require("xmldom").DOMParser,URL=require("url"),HTTP=require("http"),HTTPS=require("https"),Canvas=require("canvas"),Image=require("canvas").Image;fabric.util.loadImage=function(t,e,i){function r(r){r?(n.src=new Buffer(r,"binary"),n._src=t,e&&e.call(i,n)):(n=null,e&&e.call(i,null,!0))}var n=new Image;t&&(t instanceof Buffer||0===t.indexOf("data"))?(n.src=n._src=t,e&&e.call(i,n)):t&&0!==t.indexOf("http")?requestFs(t,r):t?request(t,"binary",r):e&&e.call(i,t)},fabric.loadSVGFromURL=function(t,e,i){t=t.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim(),0!==t.indexOf("http")?requestFs(t,function(t){fabric.loadSVGFromString(t.toString(),e,i)}):request(t,"",function(t){fabric.loadSVGFromString(t,e,i)})},fabric.loadSVGFromString=function(t,e,i){var r=(new DOMParser).parseFromString(t);fabric.parseSVGDocument(r.documentElement,function(t,i){e&&e(t,i)},i)},fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body),callback&&callback()})},fabric.Image.fromObject=function(t,e){fabric.util.loadImage(t.src,function(i){var r=new fabric.Image(i);r._initConfig(t),r._initFilters(t.filters,function(i){r.filters=i||[],r._initFilters(t.resizeFilters,function(t){r.resizeFilters=t||[],e&&e(r)})})})},fabric.createCanvasForNode=function(t,e,i,r){r=r||i;var n=fabric.document.createElement("canvas"),s=new Canvas(t||600,e||600,r);n.style={},n.width=s.width,n.height=s.height;var o=fabric.Canvas||fabric.StaticCanvas,a=new o(n,i);return a.contextContainer=s.getContext("2d"),a.nodeCanvas=s,a.Font=Canvas.Font,a},fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()},fabric.StaticCanvas.prototype.createJPEGStream=function(t){return this.nodeCanvas.createJPEGStream(t)};var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(t,e){return origSetWidth.call(this,t,e),this.nodeCanvas.width=t,this},fabric.Canvas&&(fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth);var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(t,e){return origSetHeight.call(this,t,e),this.nodeCanvas.height=t,this},fabric.Canvas&&(fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight)}}();
1
+ var fabric=fabric||{version:"1.7.19"};"undefined"!=typeof exports&&(exports.fabric=fabric),"undefined"!=typeof document&&"undefined"!=typeof window?(fabric.document=document,fabric.window=window,window.fabric=fabric):(fabric.document=require("jsdom").jsdom(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E")),fabric.document.createWindow?fabric.window=fabric.document.createWindow():fabric.window=fabric.document.parentWindow),fabric.isTouchSupported="ontouchstart"in fabric.window,fabric.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,fabric.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id"],fabric.DPI=96,fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)",fabric.fontPaths={},fabric.iMatrix=[1,0,0,1,0,0],fabric.canvasModule="canvas",fabric.perfLimitSizeTotal=2097152,fabric.maxCacheSideLimit=4096,fabric.minCacheSideLimit=256,fabric.charWidthsCache={},fabric.devicePixelRatio=fabric.window.devicePixelRatio||fabric.window.webkitDevicePixelRatio||fabric.window.mozDevicePixelRatio||1,function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:fabric.util.array.fill(i,!1)}}function e(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this}function i(e,i){if(this.__eventListeners){if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var r in e)t.call(this,r,e[r]);else t.call(this,e,i);return this}}function r(t,e){if(this.__eventListeners){var i=this.__eventListeners[t];if(i){for(var r=0,n=i.length;r<n;r++)i[r]&&i[r].call(this,e||{});return this.__eventListeners[t]=i.filter(function(t){return!1!==t}),this}}}fabric.Observable={observe:e,stopObserving:i,fire:r,on:e,off:i,trigger:r}}(),fabric.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.renderAll(),this},insertAt:function(t,e,i){var r=this.getObjects();return i?r[e]=t:r.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.renderAll(),this},remove:function(){for(var t,e=this.getObjects(),i=!1,r=0,n=arguments.length;r<n;r++)-1!==(t=e.indexOf(arguments[r]))&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[r]));return this.renderOnAddRemove&&i&&this.renderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),r=0,n=i.length;r<n;r++)t.call(e,i[r],r,i);return this},getObjects:function(t){return void 0===t?this._objects:this._objects.filter(function(e){return e.type===t})},item:function(t){return this.getObjects()[t]},isEmpty:function(){return 0===this.getObjects().length},size:function(){return this.getObjects().length},contains:function(t){return this.getObjects().indexOf(t)>-1},complexity:function(){return this.getObjects().reduce(function(t,e){return t+=e.complexity?e.complexity():0},0)}},fabric.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof fabric.Gradient||this.set(e,new fabric.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof fabric.Pattern?i&&i():this.set(e,new fabric.Pattern(t,i))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var e=fabric.util.getFunctionBody(t.clipTo);void 0!==e&&(this.clipTo=new Function("ctx",e))}},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):"function"==typeof e&&"clipTo"!==t?this._set(t,e(this.get(t))):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},function(t){var e=Math.sqrt,i=Math.atan2,r=Math.pow,n=Math.abs,s=Math.PI/180;fabric.util={removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*s},radiansToDegrees:function(t){return t/s},rotatePoint:function(t,e,i){t.subtractEquals(e);var r=fabric.util.rotateVector(t,i);return new fabric.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=Math.sin(e),r=Math.cos(e);return{x:t.x*r-t.y*i,y:t.x*i+t.y*r}},transformPoint:function(t,e,i){return i?new fabric.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new fabric.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t){var e=[t[0].x,t[1].x,t[2].x,t[3].x],i=fabric.util.array.min(e),r=fabric.util.array.max(e),n=Math.abs(i-r),s=[t[0].y,t[1].y,t[2].y,t[3].y],o=fabric.util.array.min(s),a=fabric.util.array.max(s);return{left:i,top:o,width:n,height:Math.abs(o-a)}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],r=fabric.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-r.x,i[5]=-r.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),r=parseFloat(t);switch(e||(e=fabric.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return r*fabric.DPI/25.4;case"cm":return r*fabric.DPI/2.54;case"in":return r*fabric.DPI;case"pt":return r*fabric.DPI/72;case"pc":return r*fabric.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=fabric.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),fabric.util.resolveNamespace(e)[t]},resolveNamespace:function(e){if(!e)return fabric;var i,r=e.split("."),n=r.length,s=t||fabric.window;for(i=0;i<n;++i)s=s[r[i]];return s},loadImage:function(t,e,i,r){if(t){var n=fabric.util.createImage();n.onload=function(){e&&e.call(i,n),n=n.onload=n.onerror=null},n.onerror=function(){fabric.log("Error loading "+n.src),e&&e.call(i,null,!0),n=n.onload=n.onerror=null},0!==t.indexOf("data")&&r&&(n.crossOrigin=r),n.src=t}else e&&e.call(i,t)},enlivenObjects:function(t,e,i,r){function n(){++o===a&&e&&e(s)}var s=[],o=0,a=(t=t||[]).length;a?t.forEach(function(t,e){t&&t.type?fabric.util.getKlass(t.type,i).fromObject(t,function(i,o){o||(s[e]=i),r&&r(t,i,o),n()},!0):n()}):e&&e(s)},enlivenPatterns:function(t,e){function i(){++n===s&&e&&e(r)}var r=[],n=0,s=(t=t||[]).length;s?t.forEach(function(t,e){t&&t.source?new fabric.Pattern(t,function(t){r[e]=t,i()}):(r[e]=t,i())}):e&&e(r)},groupSVGElements:function(t,e,i){var r;return r=new fabric.PathGroup(t,e),void 0!==i&&(r.sourcePath=i),r},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var r=0,n=i.length;r<n;r++)i[r]in t&&(e[i[r]]=t[i[r]])},drawDashedLine:function(t,r,n,s,o,a){var h=s-r,c=o-n,l=e(h*h+c*c),u=i(c,h),f=a.length,d=0,g=!0;for(t.save(),t.translate(r,n),t.moveTo(0,0),t.rotate(u),r=0;l>r;)(r+=a[d++%f])>l&&(r=l),t[g?"lineTo":"moveTo"](r,0),g=!g;t.restore()},createCanvasElement:function(t){return t||(t=fabric.document.createElement("canvas")),t.getContext||"undefined"==typeof G_vmlCanvasManager||G_vmlCanvasManager.initElement(t),t},createImage:function(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")},createAccessors:function(t){var e,i,r,n,s,o=t.prototype;for(e=o.stateProperties.length;e--;)n="set"+(r=(i=o.stateProperties[e]).charAt(0).toUpperCase()+i.slice(1)),o[s="get"+r]||(o[s]=function(t){return new Function('return this.get("'+t+'")')}(i)),o[n]||(o[n]=function(t){return new Function("value",'return this.set("'+t+'", value)')}(i))},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var n=i(t[1],t[0]),o=r(t[0],2)+r(t[1],2),a=e(o),h=(t[0]*t[3]-t[2]*t[1])/a,c=i(t[0]*t[2]+t[1]*t[3],o);return{angle:n/s,scaleX:a,scaleY:h,skewX:c/s,skewY:0,translateX:t[4],translateY:t[5]}},customTransformMatrix:function(t,e,i){var r=[1,0,n(Math.tan(i*s)),1],o=[n(t),0,0,n(e)];return fabric.util.multiplyTransformMatrices(o,r,!0)},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.setAngle(0)},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,r){r>0&&(e>r?e-=r:e=0,i>r?i-=r:i=0);var n,s,o=!0,a=t.getImageData(e,i,2*r||1,2*r||1),h=a.data.length;for(n=3;n<h&&(s=a.data[n],!1!==(o=s<=0));n+=4);return a=null,o},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",r="Mid",n="Mid",s=t.split(" ");return s&&s.length&&("meet"!==(i=s.pop())&&"slice"!==i?(e=i,i="meet"):s.length&&(e=s.pop())),r="none"!==e?e.slice(1,4):"none",n="none"!==e?e.slice(5,8):"none",{meetOrSlice:i,alignX:r,alignY:n}},clearFabricFontCache:function(t){t?fabric.charWidthsCache[t]&&delete fabric.charWidthsCache[t]:fabric.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),r=Math.floor(e/i);return{x:Math.floor(i),y:r}},capValue:function(t,e,i){return Math.max(t,Math.min(e,i))}}}("undefined"!=typeof exports?exports:this),function(){function t(t,r,s,o,h,c,l){var u=a.call(arguments);if(n[u])return n[u];var f=Math.PI,d=l*f/180,g=Math.sin(d),p=Math.cos(d),v=0,b=0,m=-p*t*.5-g*r*.5,_=-p*r*.5+g*t*.5,y=(s=Math.abs(s))*s,x=(o=Math.abs(o))*o,C=_*_,S=m*m,w=y*x-y*C-x*S,O=0;if(w<0){var T=Math.sqrt(1-w/(y*x));s*=T,o*=T}else O=(h===c?-1:1)*Math.sqrt(w/(y*C+x*S));var j=O*s*_/o,k=-O*o*m/s,M=p*j-g*k+.5*t,D=g*j+p*k+.5*r,P=i(1,0,(m-j)/s,(_-k)/o),A=i((m-j)/s,(_-k)/o,(-m-j)/s,(-_-k)/o);0===c&&A>0?A-=2*f:1===c&&A<0&&(A+=2*f);for(var E=Math.ceil(Math.abs(A/f*2)),I=[],L=A/E,F=8/3*Math.sin(L/4)*Math.sin(L/4)/Math.sin(L/2),B=P+L,R=0;R<E;R++)I[R]=e(P,B,p,g,s,o,M,D,F,v,b),v=I[R][4],b=I[R][5],P=B,B+=L;return n[u]=I,I}function e(t,e,i,r,n,o,h,c,l,u,f){var d=a.call(arguments);if(s[d])return s[d];var g=Math.cos(t),p=Math.sin(t),v=Math.cos(e),b=Math.sin(e),m=i*n*v-r*o*b+h,_=r*n*v+i*o*b+c,y=u+l*(-i*n*p-r*o*g),x=f+l*(-r*n*p+i*o*g),C=m+l*(i*n*b+r*o*v),S=_+l*(r*n*b-i*o*v);return s[d]=[y,x,C,S,m,_],s[d]}function i(t,e,i,r){var n=Math.atan2(e,t),s=Math.atan2(r,i);return s>=n?s-n:2*Math.PI-(n-s)}function r(t,e,i,r,n,s,h,c){var l=a.call(arguments);if(o[l])return o[l];var u,f,d,g,p,v,b,m,_=Math.sqrt,y=Math.min,x=Math.max,C=Math.abs,S=[],w=[[],[]];f=6*t-12*i+6*n,u=-3*t+9*i-9*n+3*h,d=3*i-3*t;for(var O=0;O<2;++O)if(O>0&&(f=6*e-12*r+6*s,u=-3*e+9*r-9*s+3*c,d=3*r-3*e),C(u)<1e-12){if(C(f)<1e-12)continue;0<(g=-d/f)&&g<1&&S.push(g)}else(b=f*f-4*d*u)<0||(0<(p=(-f+(m=_(b)))/(2*u))&&p<1&&S.push(p),0<(v=(-f-m)/(2*u))&&v<1&&S.push(v));for(var T,j,k,M=S.length,D=M;M--;)T=(k=1-(g=S[M]))*k*k*t+3*k*k*g*i+3*k*g*g*n+g*g*g*h,w[0][M]=T,j=k*k*k*e+3*k*k*g*r+3*k*g*g*s+g*g*g*c,w[1][M]=j;w[0][D]=t,w[1][D]=e,w[0][D+1]=h,w[1][D+1]=c;var P=[{x:y.apply(null,w[0]),y:y.apply(null,w[1])},{x:x.apply(null,w[0]),y:x.apply(null,w[1])}];return o[l]=P,P}var n={},s={},o={},a=Array.prototype.join;fabric.util.drawArc=function(e,i,r,n){for(var s=n[0],o=n[1],a=n[2],h=n[3],c=n[4],l=[[],[],[],[]],u=t(n[5]-i,n[6]-r,s,o,h,c,a),f=0,d=u.length;f<d;f++)l[f][0]=u[f][0]+i,l[f][1]=u[f][1]+r,l[f][2]=u[f][2]+i,l[f][3]=u[f][3]+r,l[f][4]=u[f][4]+i,l[f][5]=u[f][5]+r,e.bezierCurveTo.apply(e,l[f])},fabric.util.getBoundsOfArc=function(e,i,n,s,o,a,h,c,l){for(var u,f=0,d=0,g=[],p=t(c-e,l-i,n,s,a,h,o),v=0,b=p.length;v<b;v++)u=r(f,d,p[v][0],p[v][1],p[v][2],p[v][3],p[v][4],p[v][5]),g.push({x:u[0].x+e,y:u[0].y+i}),g.push({x:u[1].x+e,y:u[1].y+i}),f=p[v][4],d=p[v][5];return g},fabric.util.getBoundsOfCurve=r}(),function(){function t(t,e,i){if(t&&0!==t.length){var r=t.length-1,n=e?t[r][e]:t[r];if(e)for(;r--;)i(t[r][e],n)&&(n=t[r][e]);else for(;r--;)i(t[r],n)&&(n=t[r]);return n}}var e=Array.prototype.slice;Array.prototype.indexOf||(Array.prototype.indexOf=function(t){if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if(0===i)return-1;var r=0;if(arguments.length>0&&((r=Number(arguments[1]))!==r?r=0:0!==r&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=i)return-1;for(var n=r>=0?r:Math.max(i-Math.abs(r),0);n<i;n++)if(n in e&&e[n]===t)return n;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++)i in this&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){for(var i=[],r=0,n=this.length>>>0;r<n;r++)r in this&&(i[r]=t.call(e,this[r],r,this));return i}),Array.prototype.every||(Array.prototype.every=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++)if(i in this&&!t.call(e,this[i],i,this))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++)if(i in this&&t.call(e,this[i],i,this))return!0;return!1}),Array.prototype.filter||(Array.prototype.filter=function(t,e){for(var i,r=[],n=0,s=this.length>>>0;n<s;n++)n in this&&(i=this[n],t.call(e,i,n,this)&&r.push(i));return r}),Array.prototype.reduce||(Array.prototype.reduce=function(t){var e,i=this.length>>>0,r=0;if(arguments.length>1)e=arguments[1];else for(;;){if(r in this){e=this[r++];break}if(++r>=i)throw new TypeError}for(;r<i;r++)r in this&&(e=t.call(null,e,this[r],r,this));return e}),fabric.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(t,i){for(var r=e.call(arguments,2),n=[],s=0,o=t.length;s<o;s++)n[s]=r.length?t[s][i].apply(t[s],r):t[s][i].call(t[s]);return n},min:function(e,i){return t(e,i,function(t,e){return t<e})},max:function(e,i){return t(e,i,function(t,e){return t>=e})}}}(),function(){function t(e,i,r){if(r)if(!fabric.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var n=0,s=i.length;n<s;n++)e[n]=t({},i[n],r)}else if(i&&"object"==typeof i)for(var o in i)i.hasOwnProperty(o)&&(e[o]=t({},i[o],r));else e=i;else for(var o in i)e[o]=i[o];return e}fabric.util.object={extend:t,clone:function(e,i){return t({},e,i)}}}(),function(){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}}(),function(){var t=Array.prototype.slice,e=Function.prototype.apply,i=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var n,s=this,o=t.call(arguments,1);return n=o.length?function(){return e.call(s,this instanceof i?this:r,o.concat(t.call(arguments)))}:function(){return e.call(s,this instanceof i?this:r,arguments)},i.prototype=this.prototype,n.prototype=new i,n})}(),function(){function t(){}function e(t){for(var e=null,r=this;r.constructor.superclass;){var n=r.constructor.superclass.prototype[t];if(r[t]!==n){e=n;break}r=r.constructor.superclass.prototype}return e?arguments.length>1?e.apply(this,i.call(arguments,1)):e.call(this):console.log("tried to callSuper "+t+", method not found in prototype chain",this)}var i=Array.prototype.slice,r=function(){},n=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),s=function(t,e,i){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&(e[r]+"").indexOf("callSuper")>-1?t.prototype[r]=function(t){return function(){var r=this.constructor.superclass;this.constructor.superclass=i;var n=e[t].apply(this,arguments);if(this.constructor.superclass=r,"initialize"!==t)return n}}(r):t.prototype[r]=e[r],n&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};fabric.util.createClass=function(){function n(){this.initialize.apply(this,arguments)}var o=null,a=i.call(arguments,0);"function"==typeof a[0]&&(o=a.shift()),n.superclass=o,n.subclasses=[],o&&(t.prototype=o.prototype,n.prototype=new t,o.subclasses.push(n));for(var h=0,c=a.length;h<c;h++)s(n,a[h],o);return n.prototype.initialize||(n.prototype.initialize=r),n.prototype.constructor=n,n.prototype.callSuper=e,n}}(),function(){function t(t){var e,i,r=Array.prototype.slice.call(arguments,1),n=r.length;for(i=0;i<n;i++)if(e=typeof t[r[i]],!/^(?:function|object|unknown)$/.test(e))return!1;return!0}function e(t,e){return{handler:e,wrappedHandler:i(t,e)}}function i(t,e){return function(i){e.call(s(t),i||fabric.window.event)}}function r(t,e){return function(i){if(g[t]&&g[t][e])for(var r=g[t][e],n=0,s=r.length;n<s;n++)r[n].call(this,i||fabric.window.event)}}function n(t,e,i){var r="touchend"===t.type?"changedTouches":"touches";return t[r]&&t[r][0]?t[r][0][e]-(t[r][0][e]-t[r][0][i])||t[i]:t[i]}var s,o,a="unknown",h=function(){var t=0;return function(e){return e.__uniqueID||(e.__uniqueID="uniqueID__"+t++)}}();!function(){var t={};s=function(e){return t[e]},o=function(e,i){t[e]=i}}();var c,l,u=t(fabric.document.documentElement,"addEventListener","removeEventListener")&&t(fabric.window,"addEventListener","removeEventListener"),f=t(fabric.document.documentElement,"attachEvent","detachEvent")&&t(fabric.window,"attachEvent","detachEvent"),d={},g={};u?(c=function(t,e,i,r){t&&t.addEventListener(e,i,!f&&r)},l=function(t,e,i,r){t&&t.removeEventListener(e,i,!f&&r)}):f?(c=function(t,i,r){if(t){var n=h(t);o(n,t),d[n]||(d[n]={}),d[n][i]||(d[n][i]=[]);var s=e(n,r);d[n][i].push(s),t.attachEvent("on"+i,s.wrappedHandler)}},l=function(t,e,i){if(t){var r,n=h(t);if(d[n]&&d[n][e])for(var s=0,o=d[n][e].length;s<o;s++)(r=d[n][e][s])&&r.handler===i&&(t.detachEvent("on"+e,r.wrappedHandler),d[n][e][s]=null)}}):(c=function(t,e,i){if(t){var n=h(t);if(g[n]||(g[n]={}),!g[n][e]){g[n][e]=[];var s=t["on"+e];s&&g[n][e].push(s),t["on"+e]=r(n,e)}g[n][e].push(i)}},l=function(t,e,i){if(t){var r=h(t);if(g[r]&&g[r][e])for(var n=g[r][e],s=0,o=n.length;s<o;s++)n[s]===i&&n.splice(s,1)}}),fabric.util.addListener=c,fabric.util.removeListener=l;var p=function(t){return typeof t.clientX!==a?t.clientX:0},v=function(t){return typeof t.clientY!==a?t.clientY:0};fabric.isTouchSupported&&(p=function(t){return n(t,"pageX","clientX")},v=function(t){return n(t,"pageY","clientY")}),fabric.util.getPointer=function(t){t||(t=fabric.window.event);var e=t.target||(typeof t.srcElement!==a?t.srcElement:null),i=fabric.util.getScrollLeftTop(e);return{x:p(t)+i.left,y:v(t)+i.top}},fabric.util.object.extend(fabric.util,fabric.Observable)}(),function(){var t=fabric.document.createElement("div"),e="string"==typeof t.style.opacity,i="string"==typeof t.style.filter,r=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,n=function(t){return t};e?n=function(t,e){return t.style.opacity=e,t}:i&&(n=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),r.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(r,e)):i.filter+=" alpha(opacity="+100*e+")",t}),fabric.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?n(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var r in e)"opacity"===r?n(t,e[r]):i["float"===r||"cssFloat"===r?void 0===i.styleFloat?"cssFloat":"styleFloat":r]=e[r];return t}}(),function(){function t(t,e){var i=fabric.document.createElement(t);for(var r in e)"class"===r?i.className=e[r]:"for"===r?i.htmlFor=e[r]:i.setAttribute(r,e[r]);return i}function e(t){for(var e=0,i=0,r=fabric.document.documentElement,n=fabric.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===fabric.document?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==fabric.util.getElementStyle(t,"position")););return{left:e,top:i}}var i,r=Array.prototype.slice,n=function(t){return r.call(t,0)};try{i=n(fabric.document.childNodes)instanceof Array}catch(t){}i||(n=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e});var s;s=fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?function(t,e){var i=fabric.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},function(){var t=fabric.document.documentElement.style,e="userSelect"in t?"userSelect":"MozUserSelect"in t?"MozUserSelect":"WebkitUserSelect"in t?"WebkitUserSelect":"KhtmlUserSelect"in t?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=fabric.util.falseFunction),e?t.style[e]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},fabric.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),e?t.style[e]="":"string"==typeof t.unselectable&&(t.unselectable=""),t}}(),function(){fabric.util.getScript=function(t,e){var i=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),n=!0;r.onload=r.onreadystatechange=function(t){if(n){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;n=!1,e(t||fabric.window.event),r=r.onload=r.onreadystatechange=null}},r.src=t,i.appendChild(r)}}(),fabric.util.getById=function(t){return"string"==typeof t?fabric.document.getElementById(t):t},fabric.util.toArray=n,fabric.util.makeElement=t,fabric.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},fabric.util.wrapElement=function(e,i,r){return"string"==typeof i&&(i=t(i,r)),e.parentNode&&e.parentNode.replaceChild(i,e),i.appendChild(e),i},fabric.util.getScrollLeftTop=e,fabric.util.getElementOffset=function(t){var i,r,n=t&&t.ownerDocument,o={left:0,top:0},a={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!n)return a;for(var c in h)a[h[c]]+=parseInt(s(t,c),10)||0;return i=n.documentElement,void 0!==t.getBoundingClientRect&&(o=t.getBoundingClientRect()),r=e(t),{left:o.left+r.left-(i.clientLeft||0)+a.left,top:o.top+r.top-(i.clientTop||0)+a.top}},fabric.util.getElementStyle=s}(),function(){function t(t,e){return t+(/\?/.test(t)?"&":"?")+e}function e(){}var i=function(){for(var t=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],e=t.length;e--;)try{if(t[e]())return t[e]}catch(t){}}();fabric.util.request=function(r,n){n||(n={});var s=n.method?n.method.toUpperCase():"GET",o=n.onComplete||function(){},a=i(),h=n.body||n.parameters;return a.onreadystatechange=function(){4===a.readyState&&(o(a),a.onreadystatechange=e)},"GET"===s&&(h=null,"string"==typeof n.parameters&&(r=t(r,n.parameters))),a.open(s,r,!0),"POST"!==s&&"PUT"!==s||a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.send(h),a}}(),fabric.log=function(){},fabric.warn=function(){},"undefined"!=typeof console&&["log","warn"].forEach(function(t){void 0!==console[t]&&"function"==typeof console[t].apply&&(fabric[t]=function(){return console[t].apply(console,arguments)})}),function(){function t(){return!1}function e(){return i.apply(fabric.window,arguments)}var i=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(t){fabric.window.setTimeout(t,1e3/60)};fabric.util.animate=function(i){e(function(r){i||(i={});var n,s=r||+new Date,o=i.duration||500,a=s+o,h=i.onChange||t,c=i.abort||t,l=i.onComplete||t,u=i.easing||function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},f="startValue"in i?i.startValue:0,d="endValue"in i?i.endValue:100,g=i.byValue||d-f;i.onStart&&i.onStart(),function t(r){if(c())l(d,1,1);else{var p=(n=r||+new Date)>a?o:n-s,v=p/o,b=u(p,f,g,o),m=Math.abs((b-f)/g);h(b,m,v),n>a?i.onComplete&&i.onComplete():e(t)}}(s)})},fabric.util.requestAnimFrame=e}(),function(){function t(t,e,i){var r="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return r+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1),r+=")"}fabric.util.animateColor=function(e,i,r,n){var s=new fabric.Color(e).getSource(),o=new fabric.Color(i).getSource();n=n||{},fabric.util.animate(fabric.util.object.extend(n,{duration:r||500,startValue:s,endValue:o,byValue:o,easing:function(e,i,r,s){return t(i,r,n.colorEasing?n.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))}}))}}(),function(){function t(t,e,i,r){return t<Math.abs(e)?(t=e,r=i/4):r=0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:r}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,n){return i-r(n-t,0,i,n)+e}function r(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}fabric.util.ease={easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return 0===t?e:t===r?e+i:(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,r,n,s){var o=0,a=n;return 0===i?r:1==(i/=s)?r+n:(o||(o=.3*s),-e(t(a,n,o,1.70158),i,s)+r)},easeOutElastic:function(e,i,r,n){var s=0,o=r;if(0===e)return i;if(1==(e/=n))return i+r;s||(s=.3*n);var a=t(o,r,s,1.70158);return a.a*Math.pow(2,-10*e)*Math.sin((e*n-a.s)*(2*Math.PI)/a.p)+a.c+i},easeInOutElastic:function(i,r,n,s){var o=0,a=n;if(0===i)return r;if(2==(i/=s/2))return r+n;o||(o=s*(.3*1.5));var h=t(a,n,o,1.70158);return i<1?-.5*e(h,i,s)+r:h.a*Math.pow(2,-10*(i-=1))*Math.sin((i*s-h.s)*(2*Math.PI)/h.p)*.5+h.c+r},easeInBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),i*(t/=r)*t*((n+1)*t-n)+e},easeOutBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),i*((t=t/r-1)*t*((n+1)*t+n)+1)+e},easeInOutBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(n*=1.525))*t-n))+e:i/2*((t-=2)*t*((1+(n*=1.525))*t+n)+2)+e},easeInBounce:i,easeOutBounce:r,easeInOutBounce:function(t,e,n,s){return t<s/2?.5*i(2*t,0,n,s)+e:.5*r(2*t-s,0,n,s)+.5*n+e}}}(),function(t){"use strict";function e(t){return t in O?O[t]:t}function i(t,e,i,r){var n,s="[object Array]"===Object.prototype.toString.call(e);return"fill"!==t&&"stroke"!==t||"none"!==e?"strokeDashArray"===t?e="none"===e?null:e.replace(/,/g," ").split(/\s+/).map(function(t){return parseFloat(t)}):"transformMatrix"===t?e=i&&i.transformMatrix?y(i.transformMatrix,p.parseTransformAttribute(e)):p.parseTransformAttribute(e):"visible"===t?(e="none"!==e&&"hidden"!==e,i&&!1===i.visible&&(e=!1)):"opacity"===t?(e=parseFloat(e),i&&void 0!==i.opacity&&(e*=i.opacity)):"originX"===t?e="start"===e?"left":"end"===e?"right":"center":n=s?e.map(_):_(e,r):e="",!s&&isNaN(n)?e:n}function r(t){for(var e in T)if(void 0!==t[T[e]]&&""!==t[e]){if(void 0===t[e]){if(!p.Object.prototype[e])continue;t[e]=p.Object.prototype[e]}if(0!==t[e].indexOf("url(")){var i=new p.Color(t[e]);t[e]=i.setAlpha(m(i.getAlpha()*t[T[e]],2)).toRgba()}}return t}function n(t,e){for(var i,r,n=[],s=0;s<e.length;s++)i=e[s],r=t.getElementsByTagName(i),n=n.concat(Array.prototype.slice.call(r));return n}function s(t,e){var i,r;t.replace(/;\s*$/,"").split(";").forEach(function(t){var n=t.split(":");i=n[0].trim().toLowerCase(),r=n[1].trim(),e[i]=r})}function o(t,e){var i,r;for(var n in t)void 0!==t[n]&&(i=n.toLowerCase(),r=t[n],e[i]=r)}function a(t,e){var i={};for(var r in p.cssRules[e])if(h(t,r.split(" ")))for(var n in p.cssRules[e][r])i[n]=p.cssRules[e][r][n];return i}function h(t,e){var i,r=!0;return(i=l(t,e.pop()))&&e.length&&(r=c(t,e)),i&&r&&0===e.length}function c(t,e){for(var i,r=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)r&&(i=e.pop()),r=l(t=t.parentNode,i);return 0===e.length}function l(t,e){var i,r=t.nodeName,n=t.getAttribute("class"),s=t.getAttribute("id");if(i=new RegExp("^"+r,"i"),e=e.replace(i,""),s&&e.length&&(i=new RegExp("#"+s+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),n&&e.length)for(var o=(n=n.split(" ")).length;o--;)i=new RegExp("\\."+n[o]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function u(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var r,n,s=t.getElementsByTagName("*");for(n=0;n<s.length;n++)if(r=s[n],e===r.getAttribute("id"))return r}function f(t){for(var e=n(t,["use","svg:use"]),i=0;e.length&&i<e.length;){var r,s,o,a,h=e[i],c=h.getAttribute("xlink:href").substr(1),l=h.getAttribute("x")||0,f=h.getAttribute("y")||0,g=u(t,c).cloneNode(!0),p=(g.getAttribute("transform")||"")+" translate("+l+", "+f+")",v=e.length;if(d(g),/^svg$/i.test(g.nodeName)){var b=g.ownerDocument.createElement("g");for(s=0,a=(o=g.attributes).length;s<a;s++)r=o.item(s),b.setAttribute(r.nodeName,r.nodeValue);for(;g.firstChild;)b.appendChild(g.firstChild);g=b}for(s=0,a=(o=h.attributes).length;s<a;s++)"x"!==(r=o.item(s)).nodeName&&"y"!==r.nodeName&&"xlink:href"!==r.nodeName&&("transform"===r.nodeName?p=r.nodeValue+" "+p:g.setAttribute(r.nodeName,r.nodeValue));g.setAttribute("transform",p),g.setAttribute("instantiated_by_use","1"),g.removeAttribute("id"),h.parentNode.replaceChild(g,h),e.length===v&&i++}}function d(t){var e,i,r,n,s=t.getAttribute("viewBox"),o=1,a=1,h=0,c=0,l=t.getAttribute("width"),u=t.getAttribute("height"),f=t.getAttribute("x")||0,d=t.getAttribute("y")||0,g=t.getAttribute("preserveAspectRatio")||"",v=!s||!C.test(t.nodeName)||!(s=s.match(j)),b=!l||!u||"100%"===l||"100%"===u,m=v&&b,y={},x="";if(y.width=0,y.height=0,y.toBeParsed=m,m)return y;if(v)return y.width=_(l),y.height=_(u),y;if(h=-parseFloat(s[1]),c=-parseFloat(s[2]),e=parseFloat(s[3]),i=parseFloat(s[4]),b?(y.width=e,y.height=i):(y.width=_(l),y.height=_(u),o=y.width/e,a=y.height/i),"none"!==(g=p.util.parsePreserveAspectRatioAttribute(g)).alignX&&(a=o=o>a?a:o),1===o&&1===a&&0===h&&0===c&&0===f&&0===d)return y;if((f||d)&&(x=" translate("+_(f)+" "+_(d)+") "),r=x+" matrix("+o+" 0 0 "+a+" "+h*o+" "+c*a+") ","svg"===t.nodeName){for(n=t.ownerDocument.createElement("g");t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n)}else r=(n=t).getAttribute("transform")+r;return n.setAttribute("transform",r),y}function g(t,e){for(;t&&(t=t.parentNode);)if(t.nodeName&&e.test(t.nodeName.replace("svg:",""))&&!t.getAttribute("instantiated_by_use"))return!0;return!1}var p=t.fabric||(t.fabric={}),v=p.util.object.extend,b=p.util.object.clone,m=p.util.toFixed,_=p.util.parseUnit,y=p.util.multiplyTransformMatrices,x=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/i,C=/^(symbol|image|marker|pattern|view|svg)$/i,S=/^(?:pattern|defs|symbol|metadata|clipPath|mask)$/i,w=/^(symbol|g|a|svg)$/i,O={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"originX",opacity:"opacity"},T={stroke:"strokeOpacity",fill:"fillOpacity"};p.cssRules={},p.gradientDefs={},p.parseTransformAttribute=function(){function t(t,e){var i=Math.cos(e[0]),r=Math.sin(e[0]),n=0,s=0;3===e.length&&(n=e[1],s=e[2]),t[0]=i,t[1]=r,t[2]=-r,t[3]=i,t[4]=n-(i*n-r*s),t[5]=s-(r*n+i*s)}function e(t,e){var i=e[0],r=2===e.length?e[1]:e[0];t[0]=i,t[3]=r}function i(t,e,i){t[i]=Math.tan(p.util.degreesToRadians(e[0]))}function r(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}var n=[1,0,0,1,0,0],s=p.reNum,o="(?:\\s+,?\\s*|,\\s*)",a="(?:"+("(?:(matrix)\\s*\\(\\s*("+s+")"+o+"("+s+")"+o+"("+s+")"+o+"("+s+")"+o+"("+s+")"+o+"("+s+")\\s*\\))")+"|"+("(?:(translate)\\s*\\(\\s*("+s+")(?:"+o+"("+s+"))?\\s*\\))")+"|"+("(?:(scale)\\s*\\(\\s*("+s+")(?:"+o+"("+s+"))?\\s*\\))")+"|"+("(?:(rotate)\\s*\\(\\s*("+s+")(?:"+o+"("+s+")"+o+"("+s+"))?\\s*\\))")+"|"+("(?:(skewX)\\s*\\(\\s*("+s+")\\s*\\))")+"|"+("(?:(skewY)\\s*\\(\\s*("+s+")\\s*\\))")+")",h="^\\s*(?:"+("(?:"+a+"(?:"+o+"*"+a+")*)")+"?)\\s*$",c=new RegExp(h),l=new RegExp(a,"g");return function(s){var o=n.concat(),h=[];if(!s||s&&!c.test(s))return o;s.replace(l,function(s){var c=new RegExp(a).exec(s).filter(function(t){return!!t}),l=c[1],u=c.slice(2).map(parseFloat);switch(l){case"translate":r(o,u);break;case"rotate":u[0]=p.util.degreesToRadians(u[0]),t(o,u);break;case"scale":e(o,u);break;case"skewX":i(o,u,2);break;case"skewY":i(o,u,1);break;case"matrix":o=u}h.push(o.concat()),o=n.concat()});for(var u=h[0];h.length>1;)h.shift(),u=p.util.multiplyTransformMatrices(u,h[0]);return u}}();var j=new RegExp("^\\s*("+p.reNum+"+)\\s*,?\\s*("+p.reNum+"+)\\s*,?\\s*("+p.reNum+"+)\\s*,?\\s*("+p.reNum+"+)\\s*$");p.parseSVGDocument=function(t,e,i,r){if(t){f(t);var n=p.Object.__uid++,s=d(t),o=p.util.toArray(t.getElementsByTagName("*"));if(s.crossOrigin=r&&r.crossOrigin,s.svgUid=n,0===o.length&&p.isLikelyNode){for(var a=[],h=0,c=(o=t.selectNodes('//*[name(.)!="svg"]')).length;h<c;h++)a[h]=o[h];o=a}var l=o.filter(function(t){return d(t),x.test(t.nodeName.replace("svg:",""))&&!g(t,S)});!l||l&&!l.length?e&&e([],{}):(p.gradientDefs[n]=p.getGradientDefs(t),p.cssRules[n]=p.getCSSRules(t),p.parseElements(l,function(t){e&&e(t,s)},b(s),i,r))}};var k=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+p.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+p.reNum+"))?\\s+(.*)");v(p,{parseFontDeclaration:function(t,e){var i=t.match(k);if(i){var r=i[1],n=i[3],s=i[4],o=i[5],a=i[6];r&&(e.fontStyle=r),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),s&&(e.fontSize=_(s)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}},getGradientDefs:function(t){var e,i,r,s=n(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),o=0,a={},h={};for(o=s.length;o--;)r=(e=s[o]).getAttribute("xlink:href"),i=e.getAttribute("id"),r&&(h[i]=r.substr(1)),a[i]=e;for(i in h){var c=a[h[i]].cloneNode(!0);for(e=a[i];c.firstChild;)e.appendChild(c.firstChild)}return a},parseAttributes:function(t,n,s){if(t){var o,h,c={};void 0===s&&(s=t.getAttribute("svgUid")),t.parentNode&&w.test(t.parentNode.nodeName)&&(c=p.parseAttributes(t.parentNode,n,s)),h=c&&c.fontSize||t.getAttribute("font-size")||p.Text.DEFAULT_SVG_FONT_SIZE;var l=n.reduce(function(e,i){return(o=t.getAttribute(i))&&(e[i]=o),e},{});l=v(l,v(a(t,s),p.parseStyleAttribute(t)));var u,f,d={};for(var g in l)f=i(u=e(g),l[g],c,h),d[u]=f;d&&d.font&&p.parseFontDeclaration(d.font,d);var b=v(c,d);return w.test(t.nodeName)?b:r(b)}},parseElements:function(t,e,i,r,n){new p.ElementsParser(t,e,i,r,n).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?s(i,e):o(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;var e,i,r=[];for(e=0,i=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;e<i;e+=2)r.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return r},getCSSRules:function(t){for(var e=t.getElementsByTagName("style"),i={},r=0,n=e.length;r<n;r++){var s=e[r].textContent||e[r].text;""!==(s=s.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&s.match(/[^{]*\{[\s\S]*?\}/g).map(function(t){return t.trim()}).forEach(function(t){for(var e=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),r={},n=e[2].trim().replace(/;$/,"").split(/\s*;\s*/),s=0,o=n.length;s<o;s++){var a=n[s].split(/\s*:\s*/),h=a[0],c=a[1];r[h]=c}(t=e[1]).split(",").forEach(function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(i[t]?p.util.object.extend(i[t],r):i[t]=p.util.object.clone(r))})})}return i},loadSVGFromURL:function(t,e,i,r){t=t.replace(/^\n\s*/,"").trim(),new p.util.request(t,{method:"get",onComplete:function(t){var n=t.responseXML;n&&!n.documentElement&&p.window.ActiveXObject&&t.responseText&&((n=new ActiveXObject("Microsoft.XMLDOM")).async="false",n.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),n&&n.documentElement||e&&e(null),p.parseSVGDocument(n.documentElement,function(t,i){e&&e(t,i)},i,r)}})},loadSVGFromString:function(t,e,i,r){t=t.trim();var n;if("undefined"!=typeof DOMParser){var s=new DOMParser;s&&s.parseFromString&&(n=s.parseFromString(t,"text/xml"))}else p.window.ActiveXObject&&((n=new ActiveXObject("Microsoft.XMLDOM")).async="false",n.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));p.parseSVGDocument(n.documentElement,function(t,i){e(t,i)},i,r)}})}("undefined"!=typeof exports?exports:this),fabric.ElementsParser=function(t,e,i,r,n){this.elements=t,this.callback=e,this.options=i,this.reviver=r,this.svgUid=i&&i.svgUid||0,this.parsingOptions=n},fabric.ElementsParser.prototype.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},fabric.ElementsParser.prototype.createObjects=function(){for(var t=0,e=this.elements.length;t<e;t++)this.elements[t].setAttribute("svgUid",this.svgUid),function(t,e){setTimeout(function(){t.createObject(t.elements[e],e)},0)}(this,t)},fabric.ElementsParser.prototype.createObject=function(t,e){var i=fabric[fabric.util.string.capitalize(t.tagName.replace("svg:",""))];if(i&&i.fromElement)try{this._createObject(i,t,e)}catch(t){fabric.log(t)}else this.checkIfDone()},fabric.ElementsParser.prototype._createObject=function(t,e,i){if(t.async)t.fromElement(e,this.createCallback(i,e),this.options);else{var r=t.fromElement(e,this.options);this.resolveGradient(r,"fill"),this.resolveGradient(r,"stroke"),this.reviver&&this.reviver(e,r),this.instances[i]=r,this.checkIfDone()}},fabric.ElementsParser.prototype.createCallback=function(t,e){var i=this;return function(r){i.resolveGradient(r,"fill"),i.resolveGradient(r,"stroke"),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},fabric.ElementsParser.prototype.resolveGradient=function(t,e){var i=t.get(e);if(/^url\(/.test(i)){var r=i.slice(5,i.length-1);fabric.gradientDefs[this.svgUid][r]&&t.set(e,fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][r],t))}},fabric.ElementsParser.prototype.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter(function(t){return null!=t}),this.callback(this.instances))},function(t){"use strict";function e(t,e){this.x=t,this.y=e}var i=t.fabric||(t.fabric={});i.Point?i.warn("fabric.Point is already defined"):(i.Point=e,e.prototype={type:"point",constructor:e,add:function(t){return new e(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new e(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new e(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new e(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new e(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new e(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,i){return void 0===i&&(i=.5),i=Math.max(Math.min(1,i),0),new e(this.x+(t.x-this.x)*i,this.y+(t.y-this.y)*i)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new e(this.x,this.y)}})}("undefined"!=typeof exports?exports:this),function(t){"use strict";function e(t){this.status=t,this.points=[]}var i=t.fabric||(t.fabric={});i.Intersection?i.warn("fabric.Intersection is already defined"):(i.Intersection=e,i.Intersection.prototype={constructor:e,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},i.Intersection.intersectLineLine=function(t,r,n,s){var o,a=(s.x-n.x)*(t.y-n.y)-(s.y-n.y)*(t.x-n.x),h=(r.x-t.x)*(t.y-n.y)-(r.y-t.y)*(t.x-n.x),c=(s.y-n.y)*(r.x-t.x)-(s.x-n.x)*(r.y-t.y);if(0!==c){var l=a/c,u=h/c;0<=l&&l<=1&&0<=u&&u<=1?(o=new e("Intersection")).appendPoint(new i.Point(t.x+l*(r.x-t.x),t.y+l*(r.y-t.y))):o=new e}else o=new e(0===a||0===h?"Coincident":"Parallel");return o},i.Intersection.intersectLinePolygon=function(t,i,r){for(var n,s,o,a=new e,h=r.length,c=0;c<h;c++)n=r[c],s=r[(c+1)%h],o=e.intersectLineLine(t,i,n,s),a.appendPoints(o.points);return a.points.length>0&&(a.status="Intersection"),a},i.Intersection.intersectPolygonPolygon=function(t,i){for(var r=new e,n=t.length,s=0;s<n;s++){var o=t[s],a=t[(s+1)%n],h=e.intersectLinePolygon(o,a,i);r.appendPoints(h.points)}return r.points.length>0&&(r.status="Intersection"),r},i.Intersection.intersectPolygonRectangle=function(t,r,n){var s=r.min(n),o=r.max(n),a=new i.Point(o.x,s.y),h=new i.Point(s.x,o.y),c=e.intersectLinePolygon(s,a,t),l=e.intersectLinePolygon(a,o,t),u=e.intersectLinePolygon(o,h,t),f=e.intersectLinePolygon(h,s,t),d=new e;return d.appendPoints(c.points),d.appendPoints(l.points),d.appendPoints(u.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d})}("undefined"!=typeof exports?exports:this),function(t){"use strict";function e(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function i(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}var r=t.fabric||(t.fabric={});r.Color?r.warn("fabric.Color is already defined."):(r.Color=e,r.Color.prototype={_tryParsingColor:function(t){var i;t in e.colorNameMap&&(t=e.colorNameMap[t]),"transparent"===t&&(i=[255,255,255,0]),i||(i=e.sourceFromHex(t)),i||(i=e.sourceFromRgb(t)),i||(i=e.sourceFromHsl(t)),i||(i=[0,0,0,1]),i&&this.setSource(i)},_rgbToHsl:function(t,e,i){t/=255,e/=255,i/=255;var n,s,o,a=r.util.array.max([t,e,i]),h=r.util.array.min([t,e,i]);if(o=(a+h)/2,a===h)n=s=0;else{var c=a-h;switch(s=o>.5?c/(2-a-h):c/(a+h),a){case t:n=(e-i)/c+(e<i?6:0);break;case e:n=(i-t)/c+2;break;case i:n=(t-e)/c+4}n/=6}return[Math.round(360*n),Math.round(100*s),Math.round(100*o)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,r=this.getSource();return t=r[0].toString(16),t=1===t.length?"0"+t:t,e=r[1].toString(16),e=1===e.length?"0"+e:e,i=r[2].toString(16),i=1===i.length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},toHexa:function(){var t;return t=255*this.getSource()[3],t=t.toString(16),t=1===t.length?"0"+t:t,this.toHex()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),r=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,r]),this},overlayWith:function(t){t instanceof e||(t=new e(t));for(var i=[],r=this.getAlpha(),n=this.getSource(),s=t.getSource(),o=0;o<3;o++)i.push(Math.round(.5*n[o]+.5*s[o]));return i[3]=r,this.setSource(i),this}},r.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/,r.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,r.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,r.Color.colorNameMap={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",grey:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"},r.Color.fromRgb=function(t){return e.fromSource(e.sourceFromRgb(t))},r.Color.sourceFromRgb=function(t){var i=t.match(e.reRGBa);if(i){var r=parseInt(i[1],10)/(/%$/.test(i[1])?100:1)*(/%$/.test(i[1])?255:1),n=parseInt(i[2],10)/(/%$/.test(i[2])?100:1)*(/%$/.test(i[2])?255:1),s=parseInt(i[3],10)/(/%$/.test(i[3])?100:1)*(/%$/.test(i[3])?255:1);return[parseInt(r,10),parseInt(n,10),parseInt(s,10),i[4]?parseFloat(i[4]):1]}},r.Color.fromRgba=e.fromRgb,r.Color.fromHsl=function(t){return e.fromSource(e.sourceFromHsl(t))},r.Color.sourceFromHsl=function(t){var r=t.match(e.reHSLa);if(r){var n,s,o,a=(parseFloat(r[1])%360+360)%360/360,h=parseFloat(r[2])/(/%$/.test(r[2])?100:1),c=parseFloat(r[3])/(/%$/.test(r[3])?100:1);if(0===h)n=s=o=c;else{var l=c<=.5?c*(h+1):c+h-c*h,u=2*c-l;n=i(u,l,a+1/3),s=i(u,l,a),o=i(u,l,a-1/3)}return[Math.round(255*n),Math.round(255*s),Math.round(255*o),r[4]?parseFloat(r[4]):1]}},r.Color.fromHsla=e.fromHsl,r.Color.fromHex=function(t){return e.fromSource(e.sourceFromHex(t))},r.Color.sourceFromHex=function(t){if(t.match(e.reHex)){var i=t.slice(t.indexOf("#")+1),r=3===i.length||4===i.length,n=8===i.length||4===i.length,s=r?i.charAt(0)+i.charAt(0):i.substring(0,2),o=r?i.charAt(1)+i.charAt(1):i.substring(2,4),a=r?i.charAt(2)+i.charAt(2):i.substring(4,6),h=n?r?i.charAt(3)+i.charAt(3):i.substring(6,8):"FF";return[parseInt(s,16),parseInt(o,16),parseInt(a,16),parseFloat((parseInt(h,16)/255).toFixed(2))]}},r.Color.fromSource=function(t){var i=new e;return i.setSource(t),i})}("undefined"!=typeof exports?exports:this),function(){function t(t){var e,i,r,n=t.getAttribute("style"),s=t.getAttribute("offset")||0;if(s=parseFloat(s)/(/%$/.test(s)?100:1),s=s<0?0:s>1?1:s,n){var o=n.split(/\s*;\s*/);""===o[o.length-1]&&o.pop();for(var a=o.length;a--;){var h=o[a].split(/\s*:\s*/),c=h[0].trim(),l=h[1].trim();"stop-color"===c?e=l:"stop-opacity"===c&&(r=l)}}return e||(e=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),e=new fabric.Color(e),i=e.getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=i,{offset:s,color:e.toRgb(),opacity:r}}function e(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}function i(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}function r(t,e,i){var r,n=0,s=1,o="";for(var a in e)"Infinity"===e[a]?e[a]=1:"-Infinity"===e[a]&&(e[a]=0),r=parseFloat(e[a],10),s="string"==typeof e[a]&&/^\d+%$/.test(e[a])?.01:1,"x1"===a||"x2"===a||"r2"===a?(s*="objectBoundingBox"===i?t.width:1,n="objectBoundingBox"===i?t.left||0:0):"y1"!==a&&"y2"!==a||(s*="objectBoundingBox"===i?t.height:1,n="objectBoundingBox"===i?t.top||0:0),e[a]=r*s+n;if("ellipse"===t.type&&null!==e.r2&&"objectBoundingBox"===i&&t.rx!==t.ry){var h=t.ry/t.rx;o=" scale(1, "+h+")",e.y1&&(e.y1/=h),e.y2&&(e.y2/=h)}return o}var n=fabric.util.object.clone;fabric.Gradient=fabric.util.createClass({offsetX:0,offsetY:0,initialize:function(t){t||(t={});var e={};this.id=fabric.Object.__uid++,this.type=t.type||"linear",e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice(),t.gradientTransform&&(this.gradientTransform=t.gradientTransform),this.offsetX=t.offsetX||this.offsetX,this.offsetY=t.offsetY||this.offsetY},addColorStop:function(t){for(var e in t){var i=new fabric.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return fabric.util.populateWithProperties(this,e,t),e},toSVG:function(t){var e,i,r=n(this.coords,!0),s=n(this.colorStops,!0),o=r.r1>r.r2;if(s.sort(function(t,e){return t.offset-e.offset}),!t.group||"path-group"!==t.group.type)for(var a in r)"x1"===a||"x2"===a?r[a]+=this.offsetX-t.width/2:"y1"!==a&&"y2"!==a||(r[a]+=this.offsetY-t.height/2);if(i='id="SVGID_'+this.id+'" gradientUnits="userSpaceOnUse"',this.gradientTransform&&(i+=' gradientTransform="matrix('+this.gradientTransform.join(" ")+')" '),"linear"===this.type?e=["<linearGradient ",i,' x1="',r.x1,'" y1="',r.y1,'" x2="',r.x2,'" y2="',r.y2,'">\n']:"radial"===this.type&&(e=["<radialGradient ",i,' cx="',o?r.x1:r.x2,'" cy="',o?r.y1:r.y2,'" r="',o?r.r1:r.r2,'" fx="',o?r.x2:r.x1,'" fy="',o?r.y2:r.y1,'">\n']),"radial"===this.type){if(o){(s=s.concat()).reverse();for(l=0;l<s.length;l++)s[l].offset=1-s[l].offset}var h=Math.min(r.r1,r.r2);if(h>0)for(var c=h/Math.max(r.r1,r.r2),l=0;l<s.length;l++)s[l].offset+=c*(1-s[l].offset)}for(l=0;l<s.length;l++){var u=s[l];e.push("<stop ",'offset="',100*u.offset+"%",'" style="stop-color:',u.color,null!==u.opacity?";stop-opacity: "+u.opacity:";",'"/>\n')}return e.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),e.join("")},toLive:function(t,e){var i,r,n=fabric.util.object.clone(this.coords);if(this.type){if(e.group&&"path-group"===e.group.type)for(r in n)"x1"===r||"x2"===r?n[r]+=-this.offsetX+e.width/2:"y1"!==r&&"y2"!==r||(n[r]+=-this.offsetY+e.height/2);"linear"===this.type?i=t.createLinearGradient(n.x1,n.y1,n.x2,n.y2):"radial"===this.type&&(i=t.createRadialGradient(n.x1,n.y1,n.r1,n.x2,n.y2,n.r2));for(var s=0,o=this.colorStops.length;s<o;s++){var a=this.colorStops[s].color,h=this.colorStops[s].opacity,c=this.colorStops[s].offset;void 0!==h&&(a=new fabric.Color(a).setAlpha(h).toRgba()),i.addColorStop(c,a)}return i}}}),fabric.util.object.extend(fabric.Gradient,{fromElement:function(n,s){var o,a,h,c=n.getElementsByTagName("stop"),l=n.getAttribute("gradientUnits")||"objectBoundingBox",u=n.getAttribute("gradientTransform"),f=[];"linear"===(o="linearGradient"===n.nodeName||"LINEARGRADIENT"===n.nodeName?"linear":"radial")?a=e(n):"radial"===o&&(a=i(n));for(var d=c.length;d--;)f.push(t(c[d]));h=r(s,a,l);var g=new fabric.Gradient({type:o,coords:a,colorStops:f,offsetX:-s.left,offsetY:-s.top});return(u||""!==h)&&(g.gradientTransform=fabric.parseTransformAttribute((u||"")+h)),g},forObject:function(t,e){return e||(e={}),r(t,e.coords,"userSpaceOnUse"),new fabric.Gradient(e)}})}(),function(){"use strict";var t=fabric.util.toFixed;fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(t,e){if(t||(t={}),this.id=fabric.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else if(void 0!==fabric.util.getFunctionBody(t.source))this.source=new Function(fabric.util.getFunctionBody(t.source)),e&&e(this);else{var i=this;this.source=fabric.util.createImage(),fabric.util.loadImage(t.source,function(t){i.source=t,e&&e(i)})}},toObject:function(e){var i,r,n=fabric.Object.NUM_FRACTION_DIGITS;return"function"==typeof this.source?i=String(this.source):"string"==typeof this.source.src?i=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(i=this.source.toDataURL()),r={type:"pattern",source:i,repeat:this.repeat,offsetX:t(this.offsetX,n),offsetY:t(this.offsetY,n)},fabric.util.populateWithProperties(this,r,e),r},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,r=e.height/t.height,n=this.offsetX/t.width,s=this.offsetY/t.height,o="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(r=1),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1),e.src?o=e.src:e.toDataURL&&(o=e.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+n+'" y="'+s+'" width="'+i+'" height="'+r+'">\n<image x="0" y="0" width="'+e.width+'" height="'+e.height+'" xlink:href="'+o+'"></image>\n</pattern>\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e="function"==typeof this.source?this.source():this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,initialize:function(t){"string"==typeof t&&(t=this._parseShadow(t));for(var i in t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),r=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseInt(r[1],10)||0,offsetY:parseInt(r[2],10)||0,blur:parseInt(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var r=40,n=40,s=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle));return t.width&&t.height&&(r=100*i((Math.abs(o.x)+this.blur)/t.width,s)+20,n=100*i((Math.abs(o.y)+this.blur)/t.height,s)+20),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+n+'%" height="'+(100+2*n)+'%" x="-'+r+'%" width="'+(100+2*r)+'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="'+i(this.blur?this.blur/2:0,s)+'"></feGaussianBlur>\n\t<feOffset dx="'+i(o.x,s)+'" dy="'+i(o.y,s)+'" result="oBlur" ></feOffset>\n\t<feFlood flood-color="'+this.color+'"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke"].forEach(function(e){this[e]!==i[e]&&(t[e]=this[e])},this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/)}("undefined"!=typeof exports?exports:this),function(){"use strict";if(fabric.StaticCanvas)fabric.warn("fabric.StaticCanvas is already defined.");else{var t=fabric.util.object.extend,e=fabric.util.getElementOffset,i=fabric.util.removeFromArray,r=fabric.util.toFixed,n=fabric.util.transformPoint,s=fabric.util.invertTransform,o=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=fabric.util.createClass(fabric.CommonMethods,{initialize:function(t,e){e||(e={}),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:fabric.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,onBeforeScaleRotate:function(){},enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!1,_initStatic:function(t,e){var i=fabric.StaticCanvas.prototype.renderAll.bind(this);this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this._setImageSmoothing(),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return 1!==fabric.devicePixelRatio&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?fabric.devicePixelRatio:1},_initRetinaScaling:function(){this._isRetinaScaling()&&(this.lowerCanvasEl.setAttribute("width",this.width*fabric.devicePixelRatio),this.lowerCanvasEl.setAttribute("height",this.height*fabric.devicePixelRatio),this.contextContainer.scale(fabric.devicePixelRatio,fabric.devicePixelRatio))},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},_setImageSmoothing:function(){var t=this.getContext();t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=this.imageSmoothingEnabled},__setBgOverlayImage:function(t,e,i,r){return"string"==typeof e?fabric.util.loadImage(e,function(e){e&&(this[t]=new fabric.Image(e,r)),i&&i(e)},this,r&&r.crossOrigin):(r&&e.setOptions(r),this[t]=e,i&&i(e)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(t){var e=fabric.util.createCanvasElement(t);if(e.style||(e.style={}),!e)throw o;if(void 0===e.getContext)throw o;return e},_initOptions:function(t){this._setOptions(t),this.width=this.width||parseInt(this.lowerCanvasEl.width,10)||0,this.height=this.height||parseInt(this.lowerCanvasEl.height,10)||0,this.lowerCanvasEl.style&&(this.lowerCanvasEl.width=this.width,this.lowerCanvasEl.height=this.height,this.lowerCanvasEl.style.width=this.width+"px",this.lowerCanvasEl.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){this.lowerCanvasEl=fabric.util.getById(t)||this._createCanvasElement(t),fabric.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;e=e||{};for(var r in t)i=t[r],e.cssOnly||(this._setBackstoreDimension(r,t[r]),i+="px"),e.backstoreOnly||this._setCssDimension(r,i);return this._initRetinaScaling(),this._setImageSmoothing(),this.calcOffset(),e.cssOnly||this.renderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i=this._activeGroup;this.viewportTransform=t;for(var r=0,n=this._objects.length;r<n;r++)(e=this._objects[r]).group||e.setCoords(!1,!0);return i&&i.setCoords(!1,!0),this.calcViewportBoundaries(),this.renderAll(),this},zoomToPoint:function(t,e){var i=t,r=this.viewportTransform.slice(0);t=n(t,s(this.viewportTransform)),r[0]=e,r[3]=e;var o=n(t,r);return r[4]+=i.x-o.x,r[5]+=i.y-o.y,this.setViewportTransform(r)},setZoom:function(t){return this.zoomToPoint(new fabric.Point(0,0),t),this},absolutePan:function(t){var e=this.viewportTransform.slice(0);return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)},relativePan:function(t){return this.absolutePan(new fabric.Point(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(t){this.stateful&&t.setupState(),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added")},_onObjectRemoved:function(t){this.fire("object:removed",{target:t}),t.fire("removed"),delete t.canvas},clearContext:function(t){return t.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderAll(),this},renderAll:function(){var t=this.contextContainer;return this.renderCanvas(t,this._objects),this},calcViewportBoundaries:function(){var t={},e=this.getWidth(),i=this.getHeight(),r=s(this.viewportTransform);return t.tl=n({x:0,y:0},r),t.br=n({x:e,y:i},r),t.tr=new fabric.Point(t.br.x,t.tl.y),t.bl=new fabric.Point(t.tl.x,t.br.y),this.vptCoords=t,t},renderCanvas:function(t,e){this.calcViewportBoundaries(),this.clearContext(t),this.fire("before:render"),this.clipTo&&fabric.util.clipContext(this,t),this._renderBackground(t),t.save(),t.transform.apply(t,this.viewportTransform),this._renderObjects(t,e),t.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.clipTo&&t.restore(),this._renderOverlay(t),this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.fire("after:render")},_renderObjects:function(t,e){for(var i=0,r=e.length;i<r;++i)e[i]&&e[i].render(t)},_renderBackgroundOrOverlay:function(t,e){var i=this[e+"Color"];i&&(t.fillStyle=i.toLive?i.toLive(t,this):i,t.fillRect(i.offsetX||0,i.offsetY||0,this.width,this.height)),(i=this[e+"Image"])&&(this[e+"Vpt"]&&(t.save(),t.transform.apply(t,this.viewportTransform)),i.render(t),this[e+"Vpt"]&&t.restore())},_renderBackground:function(t){this._renderBackgroundOrOverlay(t,"background")},_renderOverlay:function(t){this._renderBackgroundOrOverlay(t,"overlay")},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(t){return this._centerObject(t,new fabric.Point(this.getCenter().left,t.getCenterPoint().y))},centerObjectV:function(t){return this._centerObject(t,new fabric.Point(t.getCenterPoint().x,this.getCenter().top))},centerObject:function(t){var e=this.getCenter();return this._centerObject(t,new fabric.Point(e.left,e.top))},viewportCenterObject:function(t){var e=this.getVpCenter();return this._centerObject(t,e)},viewportCenterObjectH:function(t){var e=this.getVpCenter();return this._centerObject(t,new fabric.Point(e.x,t.getCenterPoint().y)),this},viewportCenterObjectV:function(t){var e=this.getVpCenter();return this._centerObject(t,new fabric.Point(t.getCenterPoint().x,e.y))},getVpCenter:function(){var t=this.getCenter(),e=s(this.viewportTransform);return n({x:t.left,y:t.top},e)},_centerObject:function(t,e){return t.setPositionByOrigin(e,"center","center"),this.renderAll(),this},toDatalessJSON:function(t){return this.toDatalessObject(t)},toObject:function(t){return this._toObjectMethod("toObject",t)},toDatalessObject:function(t){return this._toObjectMethod("toDatalessObject",t)},_toObjectMethod:function(e,i){var r={objects:this._toObjects(e,i)};return t(r,this.__serializeBgOverlay(e,i)),fabric.util.populateWithProperties(this,r,i),r},_toObjects:function(t,e){return this.getObjects().filter(function(t){return!t.excludeFromExport}).map(function(i){return this._toObject(i,t,e)},this)},_toObject:function(t,e,i){var r;this.includeDefaultValues||(r=t.includeDefaultValues,t.includeDefaultValues=!1);var n=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=r),n},__serializeBgOverlay:function(t,e){var i={},r=this.backgroundImage,n=this.overlayImage;return this.backgroundColor&&(i.background=this.backgroundColor.toObject?this.backgroundColor.toObject(e):this.backgroundColor),this.overlayColor&&(i.overlay=this.overlayColor.toObject?this.overlayColor.toObject(e):this.overlayColor),r&&!r.excludeFromExport&&(i.backgroundImage=this._toObject(r,t,e)),n&&!n.excludeFromExport&&(i.overlayImage=this._toObject(n,t,e)),i},svgViewportTransformation:!0,toSVG:function(t,e){t||(t={});var i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this._setSVGBgOverlayColor(i,"backgroundColor"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this._setSVGBgOverlayColor(i,"overlayColor"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(t,e){var i,n=e.width||this.width,s=e.height||this.height,o='viewBox="0 0 '+this.width+" "+this.height+'" ',a=fabric.Object.NUM_FRACTION_DIGITS;e.viewBox?o='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,o='viewBox="'+r(-i[4]/i[0],a)+" "+r(-i[5]/i[3],a)+" "+r(this.width/i[0],a)+" "+r(this.height/i[3],a)+'" '),t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',n,'" ','height="',s,'" ',o,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",fabric.version,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),"</defs>\n")},createSVGRefElementsMarkup:function(){var t=this;return["backgroundColor","overlayColor"].map(function(e){var i=t[e];if(i&&i.toLive)return i.toSVG(t,!1)}).join("")},createSVGFontFacesMarkup:function(){for(var t,e,i,r,n,s,o="",a={},h=fabric.fontPaths,c=this.getObjects(),l=0,u=c.length;l<u;l++)if(t=c[l],e=t.fontFamily,-1!==t.type.indexOf("text")&&!a[e]&&h[e]&&(a[e]=!0,t.styles)){i=t.styles;for(n in i){r=i[n];for(s in r)!a[e=r[s].fontFamily]&&h[e]&&(a[e]=!0)}}for(var f in a)o+=["\t\t@font-face {\n","\t\t\tfont-family: '",f,"';\n","\t\t\tsrc: url('",h[f],"');\n","\t\t}\n"].join("");return o&&(o=['\t<style type="text/css">',"<![CDATA[\n",o,"]]>","</style>\n"].join("")),o},_setSVGObjects:function(t,e){for(var i,r=0,n=this.getObjects(),s=n.length;r<s;r++)(i=n[r]).excludeFromExport||this._setSVGObject(t,i,e)},_setSVGObject:function(t,e,i){t.push(e.toSVG(i))},_setSVGBgOverlayImage:function(t,e,i){this[e]&&this[e].toSVG&&t.push(this[e].toSVG(i))},_setSVGBgOverlayColor:function(t,e){var i=this[e];if(i)if(i.toLive){var r=i.repeat;t.push('<rect transform="translate(',this.width/2,",",this.height/2,')"',' x="',i.offsetX-this.width/2,'" y="',i.offsetY-this.height/2,'" ','width="',"repeat-y"===r||"no-repeat"===r?i.source.width:this.width,'" height="',"repeat-x"===r||"no-repeat"===r?i.source.height:this.height,'" fill="url(#SVGID_'+i.id+')"',"></rect>\n")}else t.push('<rect x="0" y="0" ','width="',this.width,'" height="',this.height,'" fill="',this[e],'"',"></rect>\n")},sendToBack:function(t){if(!t)return this;var e,r,n,s=this._activeGroup;if(t===s)for(e=(n=s._objects).length;e--;)r=n[e],i(this._objects,r),this._objects.unshift(r);else i(this._objects,t),this._objects.unshift(t);return this.renderAll&&this.renderAll()},bringToFront:function(t){if(!t)return this;var e,r,n,s=this._activeGroup;if(t===s)for(n=s._objects,e=0;e<n.length;e++)r=n[e],i(this._objects,r),this._objects.push(r);else i(this._objects,t),this._objects.push(t);return this.renderAll&&this.renderAll()},sendBackwards:function(t,e){if(!t)return this;var r,n,s,o,a,h=this._activeGroup,c=0;if(t===h)for(a=h._objects,r=0;r<a.length;r++)n=a[r],(s=this._objects.indexOf(n))>0+c&&(o=s-1,i(this._objects,n),this._objects.splice(o,0,n)),c++;else 0!==(s=this._objects.indexOf(t))&&(o=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderAll&&this.renderAll(),this},_findNewLowerIndex:function(t,e,i){var r;if(i){r=e;for(var n=e-1;n>=0;--n)if(t.intersectsWithObject(this._objects[n])||t.isContainedWithinObject(this._objects[n])||this._objects[n].isContainedWithinObject(t)){r=n;break}}else r=e-1;return r},bringForward:function(t,e){if(!t)return this;var r,n,s,o,a,h=this._activeGroup,c=0;if(t===h)for(r=(a=h._objects).length;r--;)n=a[r],(s=this._objects.indexOf(n))<this._objects.length-1-c&&(o=s+1,i(this._objects,n),this._objects.splice(o,0,n)),c++;else(s=this._objects.indexOf(t))!==this._objects.length-1&&(o=this._findNewUpperIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderAll&&this.renderAll(),this},_findNewUpperIndex:function(t,e,i){var r;if(i){r=e;for(var n=e+1;n<this._objects.length;++n)if(t.intersectsWithObject(this._objects[n])||t.isContainedWithinObject(this._objects[n])||this._objects[n].isContainedWithinObject(t)){r=n;break}}else r=e+1;return r},moveTo:function(t,e){return i(this._objects,t),this._objects.splice(e,0,t),this.renderAll&&this.renderAll()},dispose:function(){return this.clear(),this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"}}),t(fabric.StaticCanvas.prototype,fabric.Observable),t(fabric.StaticCanvas.prototype,fabric.Collection),t(fabric.StaticCanvas.prototype,fabric.DataURLExporter),t(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=fabric.util.createCanvasElement();if(!e||!e.getContext)return null;var i=e.getContext("2d");if(!i)return null;switch(t){case"getImageData":return void 0!==i.getImageData;case"setLineDash":return void 0!==i.setLineDash;case"toDataURL":return void 0!==e.toDataURL;case"toDataURLWithQuality":try{return e.toDataURL("image/jpeg",0),!0}catch(t){}return!1;default:return null}}}),fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject}}(),fabric.BaseBrush=fabric.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeDashArray:null,setShadow:function(t){return this.shadow=new fabric.Shadow(t),this},_setBrushStyles:function(){var t=this.canvas.contextTop;t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.lineJoin=this.strokeLineJoin,this.strokeDashArray&&fabric.StaticCanvas.supports("setLineDash")&&t.setLineDash(this.strokeDashArray)},_setShadow:function(){if(this.shadow){var t=this.canvas.contextTop,e=this.canvas.getZoom();t.shadowColor=this.shadow.color,t.shadowBlur=this.shadow.blur*e,t.shadowOffsetX=this.shadow.offsetX*e,t.shadowOffsetY=this.shadow.offsetY*e}},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}}),fabric.PencilBrush=fabric.util.createClass(fabric.BaseBrush,{initialize:function(t){this.canvas=t,this._points=[]},onMouseDown:function(t){this._prepareForDrawing(t),this._captureDrawingPath(t),this._render()},onMouseMove:function(t){this._captureDrawingPath(t),this.canvas.clearContext(this.canvas.contextTop),this._render()},onMouseUp:function(){this._finalizeAndAddPath()},_prepareForDrawing:function(t){var e=new fabric.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){this._points.push(t)},_reset:function(){this._points.length=0,this._setBrushStyles(),this._setShadow()},_captureDrawingPath:function(t){var e=new fabric.Point(t.x,t.y);this._addPoint(e)},_render:function(){var t,e,i=this.canvas.contextTop,r=this.canvas.viewportTransform,n=this._points[0],s=this._points[1];if(i.save(),i.transform(r[0],r[1],r[2],r[3],r[4],r[5]),i.beginPath(),2===this._points.length&&n.x===s.x&&n.y===s.y){var o=this.width/1e3;n=new fabric.Point(n.x,n.y),s=new fabric.Point(s.x,s.y),n.x-=o,s.x+=o}for(i.moveTo(n.x,n.y),t=1,e=this._points.length;t<e;t++){var a=n.midPointFrom(s);i.quadraticCurveTo(n.x,n.y,a.x,a.y),n=this._points[t],s=this._points[t+1]}i.lineTo(n.x,n.y),i.stroke(),i.restore()},convertPointsToSVGPath:function(t){var e,i=[],r=this.width/1e3,n=new fabric.Point(t[0].x,t[0].y),s=new fabric.Point(t[1].x,t[1].y),o=t.length;for(i.push("M ",n.x-r," ",n.y," "),e=1;e<o;e++){if(!n.eq(s)){var a=n.midPointFrom(s);i.push("Q ",n.x," ",n.y," ",a.x," ",a.y," ")}n=t[e],e+1<t.length&&(s=t[e+1])}return i.push("L ",n.x+r," ",n.y," "),i},createPath:function(t){var e=new fabric.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray}),i=new fabric.Point(e.left+e.width/2,e.top+e.height/2);return i=e.translateToGivenOrigin(i,"center","center",e.originX,e.originY),e.top=i.y,e.left=i.x,this.shadow&&(this.shadow.affectStroke=!0,e.setShadow(this.shadow)),e},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath();var t=this.convertPointsToSVGPath(this._points).join("");if("M 0 0 Q 0 0 0 0 L 0 0"!==t){var e=this.createPath(t);this.canvas.add(e),e.setCoords(),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderAll(),this.canvas.fire("path:created",{path:e})}else this.canvas.renderAll()}}),fabric.CircleBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop,r=this.canvas.viewportTransform;i.save(),i.transform(r[0],r[1],r[2],r[3],r[4],r[5]),i.fillStyle=e.fill,i.beginPath(),i.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),i.closePath(),i.fill(),i.restore()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},onMouseMove:function(t){this.drawDot(t)},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,r=this.points.length;i<r;i++){var n=this.points[i],s=new fabric.Circle({radius:n.radius,left:n.x,top:n.y,originX:"center",originY:"center",fill:n.fill});this.shadow&&s.setShadow(this.shadow),e.push(s)}var o=new fabric.Group(e,{originX:"center",originY:"center"});o.canvas=this.canvas,this.canvas.add(o),this.canvas.fire("path:created",{path:o}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.renderAll()},addPoint:function(t){var e=new fabric.Point(t.x,t.y),i=fabric.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,r=new fabric.Color(this.color).setAlpha(fabric.util.getRandomInt(0,100)/100).toRgba();return e.radius=i,e.fill=r,this.points.push(e),e}}),fabric.SprayBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(t){this.canvas=t,this.sprayChunks=[]},onMouseDown:function(t){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(t),this.render()},onMouseMove:function(t){this.addSprayChunk(t),this.render()},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,r=this.sprayChunks.length;i<r;i++)for(var n=this.sprayChunks[i],s=0,o=n.length;s<o;s++){var a=new fabric.Rect({width:n[s].width,height:n[s].width,left:n[s].x+1,top:n[s].y+1,originX:"center",originY:"center",fill:this.color});this.shadow&&a.setShadow(this.shadow),e.push(a)}this.optimizeOverlapping&&(e=this._getOptimizedRects(e));var h=new fabric.Group(e,{originX:"center",originY:"center"});h.canvas=this.canvas,this.canvas.add(h),this.canvas.fire("path:created",{path:h}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.renderAll()},_getOptimizedRects:function(t){for(var e,i={},r=0,n=t.length;r<n;r++)i[e=t[r].left+""+t[r].top]||(i[e]=t[r]);var s=[];for(e in i)s.push(i[e]);return s},render:function(){var t=this.canvas.contextTop;t.fillStyle=this.color;var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5]);for(var i=0,r=this.sprayChunkPoints.length;i<r;i++){var n=this.sprayChunkPoints[i];void 0!==n.opacity&&(t.globalAlpha=n.opacity),t.fillRect(n.x,n.y,n.width,n.width)}t.restore()},addSprayChunk:function(t){this.sprayChunkPoints=[];for(var e,i,r,n=this.width/2,s=0;s<this.density;s++){e=fabric.util.getRandomInt(t.x-n,t.x+n),i=fabric.util.getRandomInt(t.y-n,t.y+n),r=this.dotWidthVariance?fabric.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth;var o=new fabric.Point(e,i);o.width=r,this.randomOpacity&&(o.opacity=fabric.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(o)}this.sprayChunks.push(this.sprayChunkPoints)}}),fabric.PatternBrush=fabric.util.createClass(fabric.PencilBrush,{getPatternSrc:function(){var t=fabric.document.createElement("canvas"),e=t.getContext("2d");return t.width=t.height=25,e.fillStyle=this.color,e.beginPath(),e.arc(10,10,10,0,2*Math.PI,!1),e.closePath(),e.fill(),t},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles"),this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(t){var e=this.callSuper("createPath",t),i=e._getLeftTopCoords().scalarAdd(e.strokeWidth/2);return e.stroke=new fabric.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-i.x,offsetY:-i.y}),e}}),function(){var t=fabric.util.getPointer,e=fabric.util.degreesToRadians,i=fabric.util.radiansToDegrees,r=Math.atan2,n=Math.abs,s=fabric.StaticCanvas.supports("setLineDash");fabric.Canvas=fabric.util.createClass(fabric.StaticCanvas,{initialize:function(t,e){e||(e={}),this._initStatic(t,e),this._initInteractive(),this._createCacheCanvas()},uniScaleTransform:!1,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=fabric.PencilBrush&&new fabric.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t,e=this.getActiveGroup(),i=this.getActiveObject(),r=[],n=[];if(!e&&!i||this.preserveObjectStacking)r=this._objects;else{for(var s=0,o=this._objects.length;s<o;s++)t=this._objects[s],e&&e.contains(t)||t===i?n.push(t):r.push(t);e&&(e._set("_objects",n),r.push(e)),i&&r.push(i)}return r},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.selection&&this._groupSelector&&this._drawSelection(t),this.fire("after:render"),this.contextTopDirty=!0,this},_resetCurrentTransform:function(){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,skewX:t.original.skewX,skewY:t.original.skewY,left:t.original.left,top:t.original.top}),this._shouldCenterTransform(t.target)?"rotate"===t.action?this._setOriginToCenter(t.target):("center"!==t.originX&&("right"===t.originX?t.mouseXSign=-1:t.mouseXSign=1),"center"!==t.originY&&("bottom"===t.originY?t.mouseYSign=-1:t.mouseYSign=1),t.originX="center",t.originY="center"):(t.originX=t.original.originX,t.originY=t.original.originY)},containsPoint:function(t,e,i){var r,n=i||this.getPointer(t,!0);return r=e.group&&e.group===this.getActiveGroup()?this._normalizePointer(e.group,n):{x:n.x,y:n.y},e.containsPoint(r)||e._findTargetCorner(n)},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),r=fabric.util.invertTransform(i),n=this.restorePointerVpt(e);return fabric.util.transformPoint(n,r)},isTargetTransparent:function(t,e,i){var r=t.hasBorders,n=t.transparentCorners,s=this.contextCache,o=t.selectionBackgroundColor;t.hasBorders=t.transparentCorners=!1,t.selectionBackgroundColor="",s.save(),s.transform.apply(s,this.viewportTransform),t.render(s),s.restore(),t.active&&t._renderControls(s),t.hasBorders=r,t.transparentCorners=n,t.selectionBackgroundColor=o;var a=fabric.util.isTransparent(s,e,i,this.targetFindTolerance);return this.clearContext(s),a},_shouldClearSelection:function(t,e){var i=this.getActiveGroup(),r=this.getActiveObject();return!e||e&&i&&!i.contains(e)&&i!==e&&!t[this.selectionKey]||e&&!e.evented||e&&!e.selectable&&r&&r!==e},_shouldCenterTransform:function(t){if(t){var e,i=this._currentTransform;return"scale"===i.action||"scaleX"===i.action||"scaleY"===i.action?e=this.centeredScaling||t.centeredScaling:"rotate"===i.action&&(e=this.centeredRotation||t.centeredRotation),e?!i.altKey:i.altKey}},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i){if(!e)return"drag";switch(e){case"mtr":return"rotate";case"ml":case"mr":return i[this.altActionKey]?"skewY":"scaleX";case"mt":case"mb":return i[this.altActionKey]?"skewX":"scaleY";default:return"scale"}},_setupCurrentTransform:function(t,i){if(i){var r=this.getPointer(t),n=i._findTargetCorner(this.getPointer(t,!0)),s=this._getActionFromCorner(i,n,t),o=this._getOriginFromCorner(i,n);this._currentTransform={target:i,action:s,corner:n,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:o.x,originY:o.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,left:i.left,top:i.top,theta:e(i.angle),width:i.width*i.scaleX,mouseXSign:1,mouseYSign:1,shiftKey:t.shiftKey,altKey:t[this.centeredKey]},this._currentTransform.original={left:i.left,top:i.top,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,originX:o.x,originY:o.y},this._resetCurrentTransform()}},_translateObject:function(t,e){var i=this._currentTransform,r=i.target,n=t-i.offsetX,s=e-i.offsetY,o=!r.get("lockMovementX")&&r.left!==n,a=!r.get("lockMovementY")&&r.top!==s;return o&&r.set("left",n),a&&r.set("top",s),o||a},_changeSkewTransformOrigin:function(t,e,i){var r="originX",n={0:"center"},s=e.target.skewX,o="left",a="right",h="mt"===e.corner||"ml"===e.corner?1:-1,c=1;t=t>0?1:-1,"y"===i&&(s=e.target.skewY,o="top",a="bottom",r="originY"),n[-1]=o,n[1]=a,e.target.flipX&&(c*=-1),e.target.flipY&&(c*=-1),0===s?(e.skewSign=-h*t*c,e[r]=n[-t]):(s=s>0?1:-1,e.skewSign=s,e[r]=n[s*h*c])},_skewObject:function(t,e,i){var r=this._currentTransform,n=r.target,s=!1,o=n.get("lockSkewingX"),a=n.get("lockSkewingY");if(o&&"x"===i||a&&"y"===i)return!1;var h,c,l=n.getCenterPoint(),u=n.toLocalPoint(new fabric.Point(t,e),"center","center")[i],f=n.toLocalPoint(new fabric.Point(r.lastX,r.lastY),"center","center")[i],d=n._getTransformedDimensions();return this._changeSkewTransformOrigin(u-f,r,i),h=n.toLocalPoint(new fabric.Point(t,e),r.originX,r.originY)[i],c=n.translateToOriginPoint(l,r.originX,r.originY),s=this._setObjectSkew(h,r,i,d),r.lastX=t,r.lastY=e,n.setPositionByOrigin(c,r.originX,r.originY),s},_setObjectSkew:function(t,e,i,r){var n,s,o,a,h,c,l,u,f,d=e.target,g=!1,p=e.skewSign;return"x"===i?(a="y",h="Y",c="X",u=0,f=d.skewY):(a="x",h="X",c="Y",u=d.skewX,f=0),o=d._getTransformedDimensions(u,f),(l=2*Math.abs(t)-o[i])<=2?n=0:(n=p*Math.atan(l/d["scale"+c]/(o[a]/d["scale"+h])),n=fabric.util.radiansToDegrees(n)),g=d["skew"+c]!==n,d.set("skew"+c,n),0!==d["skew"+h]&&(s=d._getTransformedDimensions(),n=r[a]/s[a]*d["scale"+h],d.set("scale"+h,n)),g},_scaleObject:function(t,e,i){var r=this._currentTransform,n=r.target,s=n.get("lockScalingX"),o=n.get("lockScalingY"),a=n.get("lockScalingFlip");if(s&&o)return!1;var h=n.translateToOriginPoint(n.getCenterPoint(),r.originX,r.originY),c=n.toLocalPoint(new fabric.Point(t,e),r.originX,r.originY),l=n._getTransformedDimensions(),u=!1;return this._setLocalMouse(c,r),u=this._setObjectScale(c,r,s,o,i,a,l),n.setPositionByOrigin(h,r.originX,r.originY),u},_setObjectScale:function(t,e,i,r,n,s,o){var a,h,c,l,u=e.target,f=!1,d=!1,g=!1;return c=t.x*u.scaleX/o.x,l=t.y*u.scaleY/o.y,a=u.scaleX!==c,h=u.scaleY!==l,s&&c<=0&&c<u.scaleX&&(f=!0),s&&l<=0&&l<u.scaleY&&(d=!0),"equally"!==n||i||r?n?"x"!==n||u.get("lockUniScaling")?"y"!==n||u.get("lockUniScaling")||d||r||u.set("scaleY",l)&&(g=g||h):f||i||u.set("scaleX",c)&&(g=g||a):(f||i||u.set("scaleX",c)&&(g=g||a),d||r||u.set("scaleY",l)&&(g=g||h)):f||d||(g=this._scaleObjectEqually(t,u,e,o)),e.newScaleX=c,e.newScaleY=l,f||d||this._flipObject(e,n),g},_scaleObjectEqually:function(t,e,i,r){var n,s=t.y+t.x,o=r.y*i.original.scaleY/e.scaleY+r.x*i.original.scaleX/e.scaleX,a=t.x/Math.abs(t.x),h=t.y/Math.abs(t.y);return i.newScaleX=a*Math.abs(i.original.scaleX*s/o),i.newScaleY=h*Math.abs(i.original.scaleY*s/o),n=i.newScaleX!==e.scaleX||i.newScaleY!==e.scaleY,e.set("scaleX",i.newScaleX),e.set("scaleY",i.newScaleY),n},_flipObject:function(t,e){t.newScaleX<0&&"y"!==e&&("left"===t.originX?t.originX="right":"right"===t.originX&&(t.originX="left")),t.newScaleY<0&&"x"!==e&&("top"===t.originY?t.originY="bottom":"bottom"===t.originY&&(t.originY="top"))},_setLocalMouse:function(t,e){var i=e.target,r=this.getZoom(),s=i.padding/r;"right"===e.originX?t.x*=-1:"center"===e.originX&&(t.x*=2*e.mouseXSign,t.x<0&&(e.mouseXSign=-e.mouseXSign)),"bottom"===e.originY?t.y*=-1:"center"===e.originY&&(t.y*=2*e.mouseYSign,t.y<0&&(e.mouseYSign=-e.mouseYSign)),n(t.x)>s?t.x<0?t.x+=s:t.x-=s:t.x=0,n(t.y)>s?t.y<0?t.y+=s:t.y-=s:t.y=0},_rotateObject:function(t,e){var n=this._currentTransform;if(n.target.get("lockRotation"))return!1;var s=r(n.ey-n.top,n.ex-n.left),o=r(e-n.top,t-n.left),a=i(o-s+n.theta),h=!0;if(n.target.snapAngle>0){var c=n.target.snapAngle,l=n.target.snapThreshold||c,u=Math.ceil(a/c)*c,f=Math.floor(a/c)*c;Math.abs(a-f)<l?a=f:Math.abs(a-u)<l&&(a=u)}return a<0&&(a=360+a),a%=360,n.target.angle===a?h=!1:n.target.angle=a,h},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.setAngle(0)},_drawSelection:function(t){var e=this._groupSelector,i=e.left,r=e.top,o=n(i),a=n(r);if(this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(e.ex-(i>0?0:-i),e.ey-(r>0?0:-r),o,a)),this.selectionLineWidth&&this.selectionBorderColor)if(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,this.selectionDashArray.length>1&&!s){var h=e.ex+.5-(i>0?0:o),c=e.ey+.5-(r>0?0:a);t.beginPath(),fabric.util.drawDashedLine(t,h,c,h+o,c,this.selectionDashArray),fabric.util.drawDashedLine(t,h,c+a-1,h+o,c+a-1,this.selectionDashArray),fabric.util.drawDashedLine(t,h,c,h,c+a,this.selectionDashArray),fabric.util.drawDashedLine(t,h+o-1,c,h+o-1,c+a,this.selectionDashArray),t.closePath(),t.stroke()}else fabric.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(e.ex+.5-(i>0?0:o),e.ey+.5-(r>0?0:a),o,a)},findTarget:function(t,e){if(!this.skipTargetFind){var i,r,n=this.getPointer(t,!0),s=this.getActiveGroup(),o=this.getActiveObject();if(this.targets=[],s&&!e&&s===this._searchPossibleTargets([s],n))return this._fireOverOutEvents(s,t),s;if(o&&o._findTargetCorner(n))return this._fireOverOutEvents(o,t),o;if(o&&o===this._searchPossibleTargets([o],n)){if(!this.preserveObjectStacking)return this._fireOverOutEvents(o,t),o;i=o,r=this.targets,this.targets=[]}var a=this._searchPossibleTargets(this._objects,n);return t[this.altSelectionKey]&&a&&i&&a!==i&&(a=i,this.targets=r),this._fireOverOutEvents(a,t),a}},_fireOverOutEvents:function(t,e){var i,r,n=this._hoveredTarget;n!==t&&(i={e:e,target:t,previousTarget:this._hoveredTarget},r={e:e,target:this._hoveredTarget,nextTarget:t},this._hoveredTarget=t),t?n!==t&&(n&&(this.fire("mouse:out",r),n.fire("mouseout",r)),this.fire("mouse:over",i),t.fire("mouseover",i)):n&&(this.fire("mouse:out",r),n.fire("mouseout",r))},_checkTarget:function(t,e){if(e&&e.visible&&e.evented&&this.containsPoint(null,e,t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,t.x,t.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,r,n,s=t.length;s--;)if(this._checkTarget(e,t[s])){"group"===(i=t[s]).type&&i.subTargetCheck&&(r=this._normalizePointer(i,e),(n=this._searchPossibleTargets(i._objects,r))&&this.targets.push(n));break}return i},restorePointerVpt:function(t){return fabric.util.transformPoint(t,fabric.util.invertTransform(this.viewportTransform))},getPointer:function(e,i,r){r||(r=this.upperCanvasEl);var n,s=t(e),o=r.getBoundingClientRect(),a=o.width||0,h=o.height||0;return a&&h||("top"in o&&"bottom"in o&&(h=Math.abs(o.top-o.bottom)),"right"in o&&"left"in o&&(a=Math.abs(o.right-o.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,i||(s=this.restorePointerVpt(s)),n=0===a||0===h?{width:1,height:1}:{width:r.width/a,height:r.height/h},{x:s.x*n.width,y:s.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,"");this.upperCanvasEl?this.upperCanvasEl.className="":this.upperCanvasEl=this._createCanvasElement(),fabric.util.addClass(this.upperCanvasEl,"upper-canvas "+t),this.wrapperEl.appendChild(this.upperCanvasEl),this._copyCanvasStyle(this.lowerCanvasEl,this.upperCanvasEl),this._applyCanvasStyle(this.upperCanvasEl),this.contextTop=this.upperCanvasEl.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"}),fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.getWidth()||t.width,i=this.getHeight()||t.height;fabric.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":"none"}),t.width=e,t.height=i,fabric.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},_setActiveObject:function(t){var e=this._activeObject;e&&(e.set("active",!1),t!==e&&e.onDeselect&&"function"==typeof e.onDeselect&&e.onDeselect()),this._activeObject=t,t.set("active",!0)},setActiveObject:function(t,e){var i=this.getActiveObject();return i&&i!==t&&i.fire("deselected",{e:e}),this._setActiveObject(t),this.fire("object:selected",{target:t,e:e}),t.fire("selected",{e:e}),this.renderAll(),this},getActiveObject:function(){return this._activeObject},_onObjectRemoved:function(t){this.getActiveObject()===t&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),this._hoveredTarget===t&&(this._hoveredTarget=null),this.callSuper("_onObjectRemoved",t)},_discardActiveObject:function(){var t=this._activeObject;t&&(t.set("active",!1),t.onDeselect&&"function"==typeof t.onDeselect&&t.onDeselect()),this._activeObject=null},discardActiveObject:function(t){var e=this._activeObject;return e&&(this.fire("before:selection:cleared",{target:e,e:t}),this._discardActiveObject(),this.fire("selection:cleared",{e:t}),e.fire("deselected",{e:t})),this},_setActiveGroup:function(t){this._activeGroup=t,t&&t.set("active",!0)},setActiveGroup:function(t,e){return this._setActiveGroup(t),t&&(this.fire("object:selected",{target:t,e:e}),t.fire("selected",{e:e})),this},getActiveGroup:function(){return this._activeGroup},_discardActiveGroup:function(){var t=this.getActiveGroup();t&&t.destroy(),this.setActiveGroup(null)},discardActiveGroup:function(t){var e=this.getActiveGroup();return e&&(this.fire("before:selection:cleared",{e:t,target:e}),this._discardActiveGroup(),this.fire("selection:cleared",{e:t})),this},deactivateAll:function(){for(var t,e=this.getObjects(),i=0,r=e.length;i<r;i++)(t=e[i])&&t.set("active",!1);return this._discardActiveGroup(),this._discardActiveObject(),this},deactivateAllWithDispatch:function(t){for(var e,i=this.getObjects(),r=0,n=i.length;r<n;r++)(e=i[r])&&e.set("active",!1);return this.discardActiveGroup(t),this.discardActiveObject(t),this},dispose:function(){fabric.StaticCanvas.prototype.dispose.call(this);var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),delete this.upperCanvasEl,t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,this},clear:function(){return this.discardActiveGroup(),this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this.getActiveGroup();e?e._renderControls(t):this._drawObjectsControls(t)},_drawObjectsControls:function(t){for(var e=0,i=this._objects.length;e<i;++e)this._objects[e]&&this._objects[e].active&&this._objects[e]._renderControls(t)},_toObject:function(t,e,i){var r=this._realizeGroupTransformOnObject(t),n=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,r),n},_realizeGroupTransformOnObject:function(t){if(t.group&&t.group===this.getActiveGroup()){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach(function(i){e[i]=t[i]}),this.getActiveGroup().realizeTransform(t),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var r;r=this._realizeGroupTransformOnObject(e),this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,r)}});for(var o in fabric.StaticCanvas)"prototype"!==o&&(fabric.Canvas[o]=fabric.StaticCanvas[o]);fabric.isTouchSupported&&(fabric.Canvas.prototype._setCursorFromEvent=function(){}),fabric.Element=fabric.Canvas}(),function(){function t(t,e){return"which"in t?t.which===e:t.button===e-1}var e={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},i=fabric.util.addListener,r=fabric.util.removeListener;fabric.util.object.extend(fabric.Canvas.prototype,{cursorMap:["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],_initEventListeners:function(){this.removeListeners(),this._bindEvents(),i(fabric.window,"resize",this._onResize),i(this.upperCanvasEl,"mousedown",this._onMouseDown),i(this.upperCanvasEl,"mousemove",this._onMouseMove),i(this.upperCanvasEl,"mouseout",this._onMouseOut),i(this.upperCanvasEl,"mouseenter",this._onMouseEnter),i(this.upperCanvasEl,"wheel",this._onMouseWheel),i(this.upperCanvasEl,"contextmenu",this._onContextMenu),i(this.upperCanvasEl,"touchstart",this._onMouseDown,{passive:!1}),i(this.upperCanvasEl,"touchmove",this._onMouseMove,{passive:!1}),"undefined"!=typeof eventjs&&"add"in eventjs&&(eventjs.add(this.upperCanvasEl,"gesture",this._onGesture),eventjs.add(this.upperCanvasEl,"drag",this._onDrag),eventjs.add(this.upperCanvasEl,"orientation",this._onOrientationChange),eventjs.add(this.upperCanvasEl,"shake",this._onShake),eventjs.add(this.upperCanvasEl,"longpress",this._onLongPress))},_bindEvents:function(){this.eventsBinded||(this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this.eventsBinded=!0)},removeListeners:function(){r(fabric.window,"resize",this._onResize),r(this.upperCanvasEl,"mousedown",this._onMouseDown),r(this.upperCanvasEl,"mousemove",this._onMouseMove),r(this.upperCanvasEl,"mouseout",this._onMouseOut),r(this.upperCanvasEl,"mouseenter",this._onMouseEnter),r(this.upperCanvasEl,"wheel",this._onMouseWheel),r(this.upperCanvasEl,"contextmenu",this._onContextMenu),r(this.upperCanvasEl,"touchstart",this._onMouseDown),r(this.upperCanvasEl,"touchmove",this._onMouseMove),"undefined"!=typeof eventjs&&"remove"in eventjs&&(eventjs.remove(this.upperCanvasEl,"gesture",this._onGesture),eventjs.remove(this.upperCanvasEl,"drag",this._onDrag),eventjs.remove(this.upperCanvasEl,"orientation",this._onOrientationChange),eventjs.remove(this.upperCanvasEl,"shake",this._onShake),eventjs.remove(this.upperCanvasEl,"longpress",this._onLongPress))},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t}),this._iTextInstances&&this._iTextInstances.forEach(function(t){t.isEditing&&t.hiddenTextarea.focus()})},_onMouseEnter:function(t){this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null)},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onMouseDown:function(t){this.__onMouseDown(t),i(fabric.document,"touchend",this._onMouseUp,{passive:!1}),i(fabric.document,"touchmove",this._onMouseMove,{passive:!1}),r(this.upperCanvasEl,"mousemove",this._onMouseMove),r(this.upperCanvasEl,"touchmove",this._onMouseMove),"touchstart"===t.type?r(this.upperCanvasEl,"mousedown",this._onMouseDown):(i(fabric.document,"mouseup",this._onMouseUp),i(fabric.document,"mousemove",this._onMouseMove))},_onMouseUp:function(t){if(this.__onMouseUp(t),r(fabric.document,"mouseup",this._onMouseUp),r(fabric.document,"touchend",this._onMouseUp),r(fabric.document,"mousemove",this._onMouseMove),r(fabric.document,"touchmove",this._onMouseMove),i(this.upperCanvasEl,"mousemove",this._onMouseMove),i(this.upperCanvasEl,"touchmove",this._onMouseMove,{passive:!1}),"touchend"===t.type){var e=this;setTimeout(function(){i(e.upperCanvasEl,"mousedown",e._onMouseDown)},400)}},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t,e){var i=this.getActiveGroup()||this.getActiveObject();return(!i||!i.isEditing||t!==i)&&!!(t&&(t.isMoving||t!==i)||!t&&i||!t&&!i&&!this._groupSelector||e&&this._previousPointer&&this.selection&&(e.x!==this._previousPointer.x||e.y!==this._previousPointer.y))},__onMouseUp:function(e){var i;if(t(e,3))this.fireRightClick&&this._handleEvent(e,"up",i,3);else if(t(e,2))this.fireMiddleClick&&this._handleEvent(e,"up",i,2);else if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(e);else{var r=!0,n=this._currentTransform,s=this._groupSelector,o=!s||0===s.left&&0===s.top;n&&(this._finalizeCurrentTransform(e),r=!n.actionPerformed),i=r?this.findTarget(e,!0):n.target;var a=this._shouldRender(i,this.getPointer(e));i||!o?this._maybeGroupObjects(e):(this._groupSelector=null,this._currentTransform=null),i&&(i.isMoving=!1),this._setCursorFromEvent(e,i),this._handleEvent(e,"up",i||null,1,o),i&&(i.__corner=0),a&&this.renderAll()}},_handleEvent:function(t,e,i,r,n){var s=void 0===i?this.findTarget(t):i,o=this.targets||[],a={e:t,target:s,subTargets:o,button:r||1,isClick:n||!1};this.fire("mouse:"+e,a),s&&s.fire("mouse"+e,a);for(var h=0;h<o.length;h++)o[h].fire("mouse"+e,a)},_finalizeCurrentTransform:function(t){var e=this._currentTransform,i=e.target;i._scaling&&(i._scaling=!1),i.setCoords(),this._restoreOriginXY(i),(e.actionPerformed||this.stateful&&i.hasStateChanged())&&(this.fire("object:modified",{target:i,e:t}),i.fire("modified",{e:t}))},_restoreOriginXY:function(t){if(this._previousOriginX&&this._previousOriginY){var e=t.translateToOriginPoint(t.getCenterPoint(),this._previousOriginX,this._previousOriginY);t.originX=this._previousOriginX,t.originY=this._previousOriginY,t.left=e.x,t.top=e.y,this._previousOriginX=null,this._previousOriginY=null}},_onMouseDownInDrawingMode:function(t){this._isCurrentlyDrawing=!0,this.discardActiveObject(t).renderAll(),this.clipTo&&fabric.util.clipContext(this,this.contextTop);var e=this.getPointer(t);this.freeDrawingBrush.onMouseDown(e),this._handleEvent(t,"down")},_onMouseMoveInDrawingMode:function(t){if(this._isCurrentlyDrawing){var e=this.getPointer(t);this.freeDrawingBrush.onMouseMove(e)}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")},_onMouseUpInDrawingMode:function(t){this._isCurrentlyDrawing=!1,this.clipTo&&this.contextTop.restore(),this.freeDrawingBrush.onMouseUp(),this._handleEvent(t,"up")},__onMouseDown:function(e){var i=this.findTarget(e);if(t(e,3))this.fireRightClick&&this._handleEvent(e,"down",i||null,3);else if(t(e,2))this.fireMiddleClick&&this._handleEvent(e,"down",i||null,2);else if(this.isDrawingMode)this._onMouseDownInDrawingMode(e);else if(!this._currentTransform){var r=this.getPointer(e,!0);this._previousPointer=r;var n=this._shouldRender(i,r),s=this._shouldGroup(e,i);if(this._shouldClearSelection(e,i)?this.deactivateAllWithDispatch(e):s&&(this._handleGrouping(e,i),i=this.getActiveGroup()),!this.selection||i&&(i.selectable||i.isEditing)||(this._groupSelector={ex:r.x,ey:r.y,top:0,left:0}),i){!i.selectable||!i.__corner&&s||(this._beforeTransform(e,i),this._setupCurrentTransform(e,i));var o=this.getActiveObject();i!==this.getActiveGroup()&&i!==o&&(this.deactivateAll(),i.selectable&&(o&&o.fire("deselected",{e:e}),this.setActiveObject(i,e)))}this._handleEvent(e,"down",i||null),n&&this.renderAll()}},_beforeTransform:function(t,e){this.stateful&&e.saveState(),e._findTargetCorner(this.getPointer(t))&&this.onBeforeScaleRotate(e)},_setOriginToCenter:function(t){this._previousOriginX=this._currentTransform.target.originX,this._previousOriginY=this._currentTransform.target.originY;var e=t.getCenterPoint();t.originX="center",t.originY="center",t.left=e.x,t.top=e.y,this._currentTransform.left=t.left,this._currentTransform.top=t.top},_setCenterToOrigin:function(t){var e=t.translateToOriginPoint(t.getCenterPoint(),this._previousOriginX,this._previousOriginY);t.originX=this._previousOriginX,t.originY=this._previousOriginY,t.left=e.x,t.top=e.y,this._previousOriginX=null,this._previousOriginY=null},__onMouseMove:function(t){var e,i;if(this.isDrawingMode)this._onMouseMoveInDrawingMode(t);else if(!(void 0!==t.touches&&t.touches.length>1)){var r=this._groupSelector;r?(i=this.getPointer(t,!0),r.left=i.x-r.ex,r.top=i.y-r.ey,this.renderTop()):this._currentTransform?this._transformObject(t):(e=this.findTarget(t),this._setCursorFromEvent(t,e)),this._handleEvent(t,"move",e||null)}},__onMouseWheel:function(t){this._handleEvent(t,"wheel")},_transformObject:function(t){var e=this.getPointer(t),i=this._currentTransform;i.reset=!1,i.target.isMoving=!0,i.shiftKey=t.shiftKey,i.altKey=t[this.centeredKey],this._beforeScaleTransform(t,i),this._performTransformAction(t,i,e),i.actionPerformed&&this.renderAll()},_performTransformAction:function(t,e,i){var r=i.x,n=i.y,s=e.target,o=e.action,a=!1;"rotate"===o?(a=this._rotateObject(r,n))&&this._fire("rotating",s,t):"scale"===o?(a=this._onScale(t,e,r,n))&&this._fire("scaling",s,t):"scaleX"===o?(a=this._scaleObject(r,n,"x"))&&this._fire("scaling",s,t):"scaleY"===o?(a=this._scaleObject(r,n,"y"))&&this._fire("scaling",s,t):"skewX"===o?(a=this._skewObject(r,n,"x"))&&this._fire("skewing",s,t):"skewY"===o?(a=this._skewObject(r,n,"y"))&&this._fire("skewing",s,t):(a=this._translateObject(r,n))&&(this._fire("moving",s,t),this.setCursor(s.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a},_fire:function(t,e,i){this.fire("object:"+t,{target:e,e:i}),e.fire(t,{e:i})},_beforeScaleTransform:function(t,e){if("scale"===e.action||"scaleX"===e.action||"scaleY"===e.action){var i=this._shouldCenterTransform(e.target);(i&&("center"!==e.originX||"center"!==e.originY)||!i&&"center"===e.originX&&"center"===e.originY)&&(this._resetCurrentTransform(),e.reset=!0)}},_onScale:function(t,e,i,r){return!t[this.uniScaleKey]&&!this.uniScaleTransform||e.target.get("lockUniScaling")?(e.reset||"scale"!==e.currentAction||this._resetCurrentTransform(),e.currentAction="scaleEqually",this._scaleObject(i,r,"equally")):(e.currentAction="scale",this._scaleObject(i,r))},_setCursorFromEvent:function(t,e){if(!e)return this.setCursor(this.defaultCursor),!1;var i=e.hoverCursor||this.hoverCursor,r=this.getActiveGroup(),n=e._findTargetCorner&&(!r||!r.contains(e))&&e._findTargetCorner(this.getPointer(t,!0));return n?this._setCornerCursor(n,e,t):this.setCursor(i),!0},_setCornerCursor:function(t,i,r){if(t in e)this.setCursor(this._getRotatedCornerCursor(t,i,r));else{if("mtr"!==t||!i.hasRotatingPoint)return this.setCursor(this.defaultCursor),!1;this.setCursor(this.rotationCursor)}},_getRotatedCornerCursor:function(t,i,r){var n=Math.round(i.getAngle()%360/45);return n<0&&(n+=8),n+=e[t],r[this.altActionKey]&&e[t]%2==0&&(n+=2),n%=8,this.cursorMap[n]}})}(),function(){var t=Math.min,e=Math.max;fabric.util.object.extend(fabric.Canvas.prototype,{_shouldGroup:function(t,e){var i=this.getActiveObject();return t[this.selectionKey]&&e&&e.selectable&&(this.getActiveGroup()||i&&i!==e)&&this.selection},_handleGrouping:function(t,e){var i=this.getActiveGroup();(e!==i||(e=this.findTarget(t,!0)))&&(i?this._updateActiveGroup(e,t):this._createActiveGroup(e,t),this._activeGroup&&this._activeGroup.saveCoords())},_updateActiveGroup:function(t,e){var i=this.getActiveGroup();if(i.contains(t)){if(i.removeWithUpdate(t),t.set("active",!1),1===i.size())return this.discardActiveGroup(e),void this.setActiveObject(i.item(0),e)}else i.addWithUpdate(t);this.fire("selection:created",{target:i,e:e}),i.set("active",!0)},_createActiveGroup:function(t,e){if(this._activeObject&&t!==this._activeObject){var i=this._createGroup(t);i.addWithUpdate(),this.setActiveGroup(i,e),this._activeObject=null,this.fire("selection:created",{target:i,e:e})}t.set("active",!0)},_createGroup:function(t){var e=this.getObjects(),i=e.indexOf(this._activeObject)<e.indexOf(t)?[this._activeObject,t]:[t,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new fabric.Group(i,{canvas:this})},_groupSelectedObjects:function(t){var e=this._collectObjects();1===e.length?this.setActiveObject(e[0],t):e.length>1&&((e=new fabric.Group(e.reverse(),{canvas:this})).addWithUpdate(),this.setActiveGroup(e,t),e.saveCoords(),this.fire("selection:created",{target:e,e:t}),this.renderAll())},_collectObjects:function(){for(var i,r=[],n=this._groupSelector.ex,s=this._groupSelector.ey,o=n+this._groupSelector.left,a=s+this._groupSelector.top,h=new fabric.Point(t(n,o),t(s,a)),c=new fabric.Point(e(n,o),e(s,a)),l=n===o&&s===a,u=this._objects.length;u--&&!((i=this._objects[u])&&i.selectable&&i.visible&&(i.intersectsWithRect(h,c)||i.isContainedWithinRect(h,c)||i.containsPoint(h)||i.containsPoint(c))&&(i.set("active",!0),r.push(i),l)););return r},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t);var e=this.getActiveGroup();e&&(e.setObjectsCoords().setCoords(),e.isMoving=!1,this.setCursor(this.defaultCursor)),this._groupSelector=null,this._currentTransform=null}})}(),function(){var t=fabric.StaticCanvas.supports("toDataURLWithQuality");fabric.util.object.extend(fabric.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,r=t.multiplier||1,n={left:t.left||0,top:t.top||0,width:t.width||0,height:t.height||0};return this.__toDataURLWithMultiplier(e,i,n,r)},__toDataURLWithMultiplier:function(t,e,i,r){var n=this.getWidth(),s=this.getHeight(),o=(i.width||this.getWidth())*r,a=(i.height||this.getHeight())*r,h=this.getZoom()*r,c=this.viewportTransform,l=[h,0,0,h,(c[4]-i.left)*r,(c[5]-i.top)*r],u=this.interactive;this.viewportTransform=l,this.interactive&&(this.interactive=!1),n!==o||s!==a?this.setDimensions({width:o,height:a}):this.renderAll();var f=this.__toDataURL(t,e,i);return u&&(this.interactive=u),this.viewportTransform=c,this.setDimensions({width:n,height:s}),f},__toDataURL:function(e,i){var r=this.contextContainer.canvas;return"jpg"===e&&(e="jpeg"),t?r.toDataURL("image/"+e,i):r.toDataURL("image/"+e)},toDataURLWithMultiplier:function(t,e,i){return this.toDataURL({format:t,multiplier:e,quality:i})}})}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromDatalessJSON:function(t,e,i){return this.loadFromJSON(t,e,i)},loadFromJSON:function(t,e,i){if(t){var r="string"==typeof t?JSON.parse(t):fabric.util.object.clone(t),n=this,s=this.renderOnAddRemove;return this.renderOnAddRemove=!1,this._enlivenObjects(r.objects,function(t){n.clear(),n._setBgOverlay(r,function(){t.forEach(function(t,e){n.insertAt(t,e)}),n.renderOnAddRemove=s,delete r.objects,delete r.backgroundImage,delete r.overlayImage,delete r.background,delete r.overlay,n._setOptions(r),n.renderAll(),e&&e()})},i),this}},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var r=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,r),this.__setBgOverlay("overlayImage",t.overlayImage,i,r),this.__setBgOverlay("backgroundColor",t.background,i,r),this.__setBgOverlay("overlayColor",t.overlay,i,r)}else e&&e()},__setBgOverlay:function(t,e,i,r){var n=this;if(!e)return i[t]=!0,void(r&&r());"backgroundImage"===t||"overlayImage"===t?fabric.util.enlivenObjects([e],function(e){n[t]=e[0],i[t]=!0,r&&r()}):this["set"+fabric.util.string.capitalize(t,!0)](e,function(){i[t]=!0,r&&r()})},_enlivenObjects:function(t,e,i){t&&0!==t.length?fabric.util.enlivenObjects(t,function(t){e&&e(t)},null,i):e&&e([])},_toDataURL:function(t,e){this.clone(function(i){e(i.toDataURL(t))})},_toDataURLWithMultiplier:function(t,e,i){this.clone(function(r){i(r.toDataURLWithMultiplier(t,e))})},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData(function(e){e.loadFromJSON(i,function(){t&&t(e)})})},cloneWithoutData:function(t){var e=fabric.document.createElement("canvas");e.width=this.getWidth(),e.height=this.getHeight();var i=new fabric.Canvas(e);i.clipTo=this.clipTo,this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,function(){i.renderAll(),t&&t(i)}),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,n=e.util.toFixed,s=e.util.string.capitalize,o=e.util.degreesToRadians,a=e.StaticCanvas.supports("setLineDash"),h=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",borderDashArray:null,cornerColor:"rgba(102,153,255,0.5)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:10,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:.01,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!0,rotatingPointOffset:40,perPixelTargetFind:!1,includeDefaultValues:!0,clipTo:null,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockUniScaling:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:h,statefullCache:!1,noScaleCache:!0,dirty:!0,stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow clipTo visible backgroundColor skewX skewY fillRule".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height strokeLineCap strokeLineJoin strokeMiterLimit backgroundColor".split(" "),initialize:function(t){(t=t||{})&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.document.createElement("canvas"),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas()},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,r=e.cacheSideLimit,n=t.width,s=t.height,o=n/s,a=e.util.limitDimsByArea(o,i,r),h=e.util.capValue,c=e.maxCacheSideLimit,l=e.minCacheSideLimit,u=h(l,a.x,c),f=h(l,a.y,c);return n>u?(t.zoomX/=n/u,t.width=u):n<l&&(t.width=l),s>f?(t.zoomY/=s/f,t.height=f):s<l&&(t.height=l),t},_getCacheCanvasDimensions:function(){var t=this.canvas&&this.canvas.getZoom()||1,i=this.getObjectScaling(),r=this._getNonTransformedDimensions(),n=this.canvas&&this.canvas._isRetinaScaling()?e.devicePixelRatio:1,s=i.scaleX*t*n,o=i.scaleY*t*n;return{width:r.x*s+2,height:r.y*o+2,zoomX:s,zoomY:o}},_updateCacheCanvas:function(){if(this.noScaleCache&&this.canvas&&this.canvas._currentTransform){var t=this.canvas._currentTransform.action;if(t.slice&&"scale"===t.slice(0,5))return!1}var i=this._limitCacheSize(this._getCacheCanvasDimensions()),r=e.minCacheSideLimit,n=i.width,s=i.height,o=i.zoomX,a=i.zoomY,h=n!==this.cacheWidth||s!==this.cacheHeight,c=this.zoomX!==o||this.zoomY!==a,l=h||c,u=0,f=0,d=!1;if(h){var g=this._cacheCanvas.width,p=this._cacheCanvas.height,v=n>g||s>p,b=(n<.9*g||s<.9*p)&&g>r&&p>r;d=v||b,v&&(u=.1*n&-2,f=.1*s&-2)}return!!l&&(d?(this._cacheCanvas.width=Math.max(Math.ceil(n)+u,r),this._cacheCanvas.height=Math.max(Math.ceil(s)+f,r),this.cacheTranslationX=(n+u)/2,this.cacheTranslationY=(s+f)/2):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,this._cacheCanvas.width,this._cacheCanvas.height)),this.cacheWidth=n,this.cacheHeight=s,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(o,a),this.zoomX=o,this.zoomY=a,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initClipping(t),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t,e){this.group&&!this.group._transformDone&&this.group===this.canvas._activeGroup&&this.group.transform(t);var i=e?this._getLeftTopCoords():this.getCenterPoint();t.translate(i.x,i.y),this.angle&&t.rotate(o(this.angle)),t.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1)),this.skewX&&t.transform(1,0,Math.tan(o(this.skewX)),1,0,0),this.skewY&&t.transform(1,Math.tan(o(this.skewY)),0,1,0,0)},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,r={type:this.type,originX:this.originX,originY:this.originY,left:n(this.left,i),top:n(this.top,i),width:n(this.width,i),height:n(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:n(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:n(this.strokeMiterLimit,i),scaleX:n(this.scaleX,i),scaleY:n(this.scaleY,i),angle:n(this.getAngle(),i),flipX:this.flipX,flipY:this.flipY,opacity:n(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor,fillRule:this.fillRule,globalCompositeOperation:this.globalCompositeOperation,transformMatrix:this.transformMatrix?this.transformMatrix.concat():null,skewX:n(this.skewX,i),skewY:n(this.skewY,i)};return e.util.populateWithProperties(this,r,t),this.includeDefaultValues||(r=this._removeDefaultValues(r)),r},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach(function(e){t[e]===i[e]&&delete t[e],"[object Array]"===Object.prototype.toString.call(t[e])&&"[object Array]"===Object.prototype.toString.call(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e]}),t},toString:function(){return"#<fabric."+s(this.type)+">"},getObjectScaling:function(){var t=this.scaleX,e=this.scaleY;if(this.group){var i=this.group.getObjectScaling();t*=i.scaleX,e*=i.scaleY}return{scaleX:t,scaleY:e}},_set:function(t,i){return("scaleX"===t||"scaleY"===t)&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,this.cacheProperties.indexOf(t)>-1&&(this.group&&this.group.set("dirty",!0),this.dirty=!0),this.group&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0),"width"!==t&&"height"!==t||(this.minScaleLimit=Math.min(.1,1/Math.max(this.width,this.height))),this},setOnGroup:function(){},setSourcePath:function(t){return this.sourcePath=t,this},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||0===this.width&&0===this.height||!this.visible},render:function(t,i){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),i||this.transform(t),this._setOpacity(t),this._setShadow(t),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this.clipTo&&e.util.clipContext(this,t),this.shouldCache(i)?(this._cacheCanvas||this._createCacheCanvas(),this.isCacheDirty(i)&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,i),this.dirty=!1),this.drawCacheOnCanvas(t)):(this.dirty=!1,this.drawObject(t,i),i&&this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),this.clipTo&&t.restore(),t.restore())},needsItsOwnCache:function(){return!1},shouldCache:function(t){return!t&&this.objectCaching&&(!this.group||this.needsItsOwnCache()||!this.group.isCaching())},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawObject:function(t,e){this._renderBackground(t),this._setStrokeStyles(t),this._setFillStyles(t),this._render(t,e)},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){t.globalAlpha*=this.opacity},_setStrokeStyles:function(t){this.stroke&&(t.lineWidth=this.strokeWidth,t.lineCap=this.strokeLineCap,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,t.strokeStyle=this.stroke.toLive?this.stroke.toLive(t,this):this.stroke)},_setFillStyles:function(t){this.fill&&(t.fillStyle=this.fill.toLive?this.fill.toLive(t,this):this.fill)},_setLineDash:function(t,e,i){e&&(1&e.length&&e.push.apply(e,e),a?t.setLineDash(e):i&&i(t))},_renderControls:function(t){if(this.active&&(!this.group||this.group===this.canvas.getActiveGroup())){var i,r=this.getViewportTransform(),n=this.calcTransformMatrix();n=e.util.multiplyTransformMatrices(r,n),i=e.util.qrDecompose(n),t.save(),t.translate(i.translateX,i.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.group&&this.group===this.canvas.getActiveGroup()?(t.rotate(o(i.angle)),this.drawBordersInGroup(t,i)):(t.rotate(o(this.angle)),this.drawBorders(t)),this.drawControls(t),t.restore()}},_setShadow:function(t){if(this.shadow){var i=this.canvas&&this.canvas.viewportTransform[0]||1,r=this.canvas&&this.canvas.viewportTransform[3]||1,n=this.getObjectScaling();this.canvas&&this.canvas._isRetinaScaling()&&(i*=e.devicePixelRatio,r*=e.devicePixelRatio),t.shadowColor=this.shadow.color,t.shadowBlur=this.shadow.blur*(i+r)*(n.scaleX+n.scaleY)/4,t.shadowOffsetX=this.shadow.offsetX*i*n.scaleX,t.shadowOffsetY=this.shadow.offsetY*r*n.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(e.toLive){var i=e.gradientTransform||e.patternTransform;i&&t.transform.apply(t,i);var r=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;t.translate(r,n)}},_renderFill:function(t){this.fill&&(t.save(),this._applyPatternGradientTransform(t,this.fill),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){this.stroke&&0!==this.strokeWidth&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray,this._renderDashedStroke),this._applyPatternGradientTransform(t,this.stroke),t.stroke(),t.restore())},clone:function(t,i){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(i),t):new e.Object(this.toObject(i))},cloneAsImage:function(t,i){var r=this.toDataURL(i);return e.util.loadImage(r,function(i){t&&t(new e.Image(i))}),this},toDataURL:function(t){t||(t={});var i=e.util.createCanvasElement(),r=this.getBoundingRect();i.width=r.width,i.height=r.height,e.util.wrapElement(i,"div");var n=new e.StaticCanvas(i,{enableRetinaScaling:t.enableRetinaScaling});"jpg"===t.format&&(t.format="jpeg"),"jpeg"===t.format&&(n.backgroundColor="#fff");var s={active:this.get("active"),left:this.getLeft(),top:this.getTop()};this.set("active",!1),this.setPositionByOrigin(new e.Point(n.getWidth()/2,n.getHeight()/2),"center","center");var o=this.canvas;n.add(this);var a=n.toDataURL(t);return this.set(s).setCoords(),this.canvas=o,n.dispose(),n=null,a},isType:function(t){return this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},setGradient:function(t,i){i||(i={});var r={colorStops:[]};return r.type=i.type||(i.r1||i.r2?"radial":"linear"),r.coords={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},(i.r1||i.r2)&&(r.coords.r1=i.r1,r.coords.r2=i.r2),r.gradientTransform=i.gradientTransform,e.Gradient.prototype.addColorStop.call(r,i.colorStops),this.set(t,e.Gradient.forObject(this,r))},setPatternFill:function(t){return this.set("fill",new e.Pattern(t))},setShadow:function(t){return this.set("shadow",t?new e.Shadow(t):null)},setColor:function(t){return this.set("fill",t),this},setAngle:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},remove:function(){return this.canvas&&(this.group&&this.group===this.canvas._activeGroup&&this.group.remove(this),this.canvas.remove(this)),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var r=new e.Point(i.x,i.y),n=this._getLeftTopCoords();return this.angle&&(r=e.util.rotatePoint(r,n,o(-this.angle))),{x:r.x-n.x,y:r.y-n.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}}),e.util.createAccessors(e.Object),e.Object.prototype.rotate=e.Object.prototype.setAngle,i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object._fromObject=function(t,i,n,s,o){var a=e[t];if(i=r(i,!0),!s){var h=o?new a(i[o],i):new a(i);return n&&n(h),h}e.util.enlivenPatterns([i.fill,i.stroke],function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]);var e=o?new a(i[o],i):new a(i);n&&n(e)})},e.Object.__uid=0)}("undefined"!=typeof exports?exports:this),function(){var t=fabric.util.degreesToRadians,e={left:-.5,center:0,right:.5},i={top:-.5,center:0,bottom:.5};fabric.util.object.extend(fabric.Object.prototype,{translateToGivenOrigin:function(t,r,n,s,o){var a,h,c,l=t.x,u=t.y;return"string"==typeof r?r=e[r]:r-=.5,"string"==typeof s?s=e[s]:s-=.5,a=s-r,"string"==typeof n?n=i[n]:n-=.5,"string"==typeof o?o=i[o]:o-=.5,h=o-n,(a||h)&&(c=this._getTransformedDimensions(),l=t.x+a*c.x,u=t.y+h*c.y),new fabric.Point(l,u)},translateToCenterPoint:function(e,i,r){var n=this.translateToGivenOrigin(e,i,r,"center","center");return this.angle?fabric.util.rotatePoint(n,e,t(this.angle)):n},translateToOriginPoint:function(e,i,r){var n=this.translateToGivenOrigin(e,"center","center",i,r);return this.angle?fabric.util.rotatePoint(n,e,t(this.angle)):n},getCenterPoint:function(){var t=new fabric.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(e,i,r){var n,s,o=this.getCenterPoint();return n=void 0!==i&&void 0!==r?this.translateToGivenOrigin(o,"center","center",i,r):new fabric.Point(this.left,this.top),s=new fabric.Point(e.x,e.y),this.angle&&(s=fabric.util.rotatePoint(s,o,-t(this.angle))),s.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var r=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(r,this.originX,this.originY);this.set("left",n.x),this.set("top",n.y)},adjustPosition:function(i){var r,n,s=t(this.angle),o=this.getWidth(),a=Math.cos(s)*o,h=Math.sin(s)*o;r="string"==typeof this.originX?e[this.originX]:this.originX-.5,n="string"==typeof i?e[i]:i-.5,this.left+=a*(n-r),this.top+=h*(n-r),this.setCoords(),this.originX=i},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")},onDeselect:function(){}})}(),function(){function t(t){return[new fabric.Point(t.tl.x,t.tl.y),new fabric.Point(t.tr.x,t.tr.y),new fabric.Point(t.br.x,t.br.y),new fabric.Point(t.bl.x,t.bl.y)]}var e=fabric.util.degreesToRadians,i=fabric.util.multiplyTransformMatrices;fabric.util.object.extend(fabric.Object.prototype,{oCoords:null,aCoords:null,getCoords:function(e,i){this.oCoords||this.setCoords();var r=e?this.aCoords:this.oCoords;return t(i?this.calcCoords(e):r)},intersectsWithRect:function(t,e,i,r){var n=this.getCoords(i,r);return"Intersection"===fabric.Intersection.intersectPolygonRectangle(n,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===fabric.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var r=this.getCoords(e,i),n=0,s=t._getImageLines(i?t.calcCoords(e):e?t.aCoords:t.oCoords);n<4;n++)if(!t.containsPoint(r[n],s))return!1;return!0},isContainedWithinRect:function(t,e,i,r){var n=this.getBoundingRect(i,r);return n.left>=t.x&&n.left+n.width<=e.x&&n.top>=t.y&&n.top+n.height<=e.y},containsPoint:function(t,e,i,r){var e=e||this._getImageLines(r?this.calcCoords(i):i?this.aCoords:this.oCoords),n=this._findCrossPoints(t,e);return 0!==n&&n%2==1},isOnScreen:function(t){if(!this.canvas)return!1;for(var e,i=this.canvas.vptCoords.tl,r=this.canvas.vptCoords.br,n=this.getCoords(!0,t),s=0;s<4;s++)if((e=n[s]).x<=r.x&&e.x>=i.x&&e.y<=r.y&&e.y>=i.y)return!0;if(this.intersectsWithRect(i,r,!0))return!0;var o={x:(i.x+r.x)/2,y:(i.y+r.y)/2};return!!this.containsPoint(o,null,!0)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,r,n,s,o=0;for(var a in e)if(!((s=e[a]).o.y<t.y&&s.d.y<t.y||s.o.y>=t.y&&s.d.y>=t.y||(s.o.x===s.d.x&&s.o.x>=t.x?n=s.o.x:(i=0,r=(s.d.y-s.o.y)/(s.d.x-s.o.x),n=-(t.y-i*t.x-(s.o.y-r*s.o.x))/(i-r)),n>=t.x&&(o+=1),2!==o)))break;return o},getBoundingRectWidth:function(){return this.getBoundingRect().width},getBoundingRectHeight:function(){return this.getBoundingRect().height},getBoundingRect:function(t,e){var i=this.getCoords(t,e);return fabric.util.makeBoundingBoxFromPoints(i)},getWidth:function(){return this._getTransformedDimensions().x},getHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t},scale:function(t){return(t=this._constrainScale(t))<0&&(this.flipX=!this.flipX,this.flipY=!this.flipY,t*=-1),this.scaleX=t,this.scaleY=t,this.setCoords()},scaleToWidth:function(t){var e=this.getBoundingRect().width/this.getWidth();return this.scale(t/this.width/e)},scaleToHeight:function(t){var e=this.getBoundingRect().height/this.getHeight();return this.scale(t/this.height/e)},calcCoords:function(t){var i=e(this.angle),r=this.getViewportTransform(),n=t?this._getTransformedDimensions():this._calculateCurrentDimensions(),s=n.x,o=n.y,a=Math.sin(i),h=Math.cos(i),c=s>0?Math.atan(o/s):0,l=s/Math.cos(c)/2,u=Math.cos(c+i)*l,f=Math.sin(c+i)*l,d=this.getCenterPoint(),g=t?d:fabric.util.transformPoint(d,r),p=new fabric.Point(g.x-u,g.y-f),v=new fabric.Point(p.x+s*h,p.y+s*a),b=new fabric.Point(p.x-o*a,p.y+o*h),m=new fabric.Point(g.x+u,g.y+f);if(!t)var _=new fabric.Point((p.x+b.x)/2,(p.y+b.y)/2),y=new fabric.Point((v.x+p.x)/2,(v.y+p.y)/2),x=new fabric.Point((m.x+v.x)/2,(m.y+v.y)/2),C=new fabric.Point((m.x+b.x)/2,(m.y+b.y)/2),S=new fabric.Point(y.x+a*this.rotatingPointOffset,y.y-h*this.rotatingPointOffset);g={tl:p,tr:v,br:m,bl:b};return t||(g.ml=_,g.mt=y,g.mr=x,g.mb=C,g.mtr=S),g},setCoords:function(t,e){return this.oCoords=this.calcCoords(t),e||(this.aCoords=this.calcCoords(!0)),t||this._setCornerCoords&&this._setCornerCoords(),this},_calcRotateMatrix:function(){if(this.angle){var t=e(this.angle),i=Math.cos(t),r=Math.sin(t);return 6.123233995736766e-17!==i&&-1.8369701987210297e-16!==i||(i=0),[i,r,-r,i,0,0]}return fabric.iMatrix.concat()},calcTransformMatrix:function(t){var e,r,n=this.getCenterPoint(),s=[1,0,0,1,n.x,n.y],o=this._calcDimensionsTransformMatrix(this.skewX,this.skewY,!0);return r=this.group&&!t?i(this.group.calcTransformMatrix(),s):s,this.angle&&(e=this._calcRotateMatrix(),r=i(r,e)),r=i(r,o)},_calcDimensionsTransformMatrix:function(t,r,n){var s,o=[this.scaleX*(n&&this.flipX?-1:1),0,0,this.scaleY*(n&&this.flipY?-1:1),0,0];return t&&(s=[1,0,Math.tan(e(t)),1],o=i(o,s,!0)),r&&(s=[1,Math.tan(e(r)),0,1],o=i(o,s,!0)),o},_getNonTransformedDimensions:function(){var t=this.strokeWidth;return{x:this.width+t,y:this.height+t}},_getTransformedDimensions:function(t,e){void 0===t&&(t=this.skewX),void 0===e&&(e=this.skewY);var i,r,n=this._getNonTransformedDimensions(),s=n.x/2,o=n.y/2,a=[{x:-s,y:-o},{x:s,y:-o},{x:-s,y:o},{x:s,y:o}],h=this._calcDimensionsTransformMatrix(t,e,!1);for(i=0;i<a.length;i++)a[i]=fabric.util.transformPoint(a[i],h);return r=fabric.util.makeBoundingBoxFromPoints(a),{x:r.width,y:r.height}},_calculateCurrentDimensions:function(){var t=this.getViewportTransform(),e=this._getTransformedDimensions();return fabric.util.transformPoint(e,t,!0).scalarAdd(2*this.padding)}})}(),fabric.util.object.extend(fabric.Object.prototype,{sendToBack:function(){return this.group?fabric.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?fabric.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas.bringToFront(this),this},sendBackwards:function(t){return this.group?fabric.StaticCanvas.prototype.sendBackwards.call(this.group,this,t):this.canvas.sendBackwards(this,t),this},bringForward:function(t){return this.group?fabric.StaticCanvas.prototype.bringForward.call(this.group,this,t):this.canvas.bringForward(this,t),this},moveTo:function(t){return this.group?fabric.StaticCanvas.prototype.moveTo.call(this.group,this,t):this.canvas.moveTo(this,t),this}}),function(){function t(t,e){if(e){if(e.toLive)return t+": url(#SVGID_"+e.id+"); ";var i=new fabric.Color(e),r=t+": "+i.toRgb()+"; ",n=i.getAlpha();return 1!==n&&(r+=t+"-opacity: "+n.toString()+"; "),r}return t+": none; "}fabric.util.object.extend(fabric.Object.prototype,{getSvgStyles:function(e){var i=this.fillRule,r=this.strokeWidth?this.strokeWidth:"0",n=this.strokeDashArray?this.strokeDashArray.join(" "):"none",s=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",h=void 0!==this.opacity?this.opacity:"1",c=this.visible?"":" visibility: hidden;",l=e?"":this.getSvgFilter(),u=t("fill",this.fill);return[t("stroke",this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",n,"; ","stroke-linecap: ",s,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",u,"fill-rule: ",i,"; ","opacity: ",h,";",l,c].join("")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgId:function(){return this.id?'id="'+this.id+'" ':""},getSvgTransform:function(){if(this.group&&"path-group"===this.group.type)return"";var t=fabric.util.toFixed,e=this.getAngle(),i=this.getSkewX()%360,r=this.getSkewY()%360,n=this.getCenterPoint(),s=fabric.Object.NUM_FRACTION_DIGITS,o="path-group"===this.type?"":"translate("+t(n.x,s)+" "+t(n.y,s)+")",a=0!==e?" rotate("+t(e,s)+")":"",h=1===this.scaleX&&1===this.scaleY?"":" scale("+t(this.scaleX,s)+" "+t(this.scaleY,s)+")",c=0!==i?" skewX("+t(i,s)+")":"",l=0!==r?" skewY("+t(r,s)+")":"",u="path-group"===this.type?this.width:0,f=this.flipX?" matrix(-1 0 0 1 "+u+" 0) ":"",d="path-group"===this.type?this.height:0;return[o,a,h,f,this.flipY?" matrix(1 0 0 -1 0 "+d+")":"",c,l].join("")},getSvgTransformMatrix:function(){return this.transformMatrix?" matrix("+this.transformMatrix.join(" ")+") ":""},_createBaseSVGMarkup:function(){var t=[];return this.fill&&this.fill.toLive&&t.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&t.push(this.stroke.toSVG(this,!1)),this.shadow&&t.push(this.shadow.toSVG(this)),t}})}(),function(){function t(t,e,r){var n={};r.forEach(function(e){n[e]=t[e]}),i(t[e],n,!0)}function e(t,i,r){if(t===i)return!0;if(Array.isArray(t)){if(t.length!==i.length)return!1;for(var n=0,s=t.length;n<s;n++)if(!e(t[n],i[n]))return!1;return!0}if(t&&"object"==typeof t){var o,a=Object.keys(t);if(!r&&a.length!==Object.keys(i).length)return!1;for(var n=0,s=a.length;n<s;n++)if(o=a[n],!e(t[o],i[o]))return!1;return!0}}var i=fabric.util.object.extend;fabric.util.object.extend(fabric.Object.prototype,{hasStateChanged:function(t){var i="_"+(t=t||"stateProperties");return Object.keys(this[i]).length<this[t].length||!e(this[i],this,!0)},saveState:function(e){var i=e&&e.propertySet||"stateProperties",r="_"+i;return this[r]?(t(this,r,this[i]),e&&e.stateProperties&&t(this,r,e.stateProperties),this):this.setupState(e)},setupState:function(t){var e=(t=t||{}).propertySet||"stateProperties";return t.propertySet=e,this["_"+e]={},this.saveState(t),this}})}(),function(){var t=fabric.util.degreesToRadians,e=function(){return"undefined"!=typeof G_vmlCanvasManager};fabric.util.object.extend(fabric.Object.prototype,{_controlsVisibility:null,_findTargetCorner:function(t){if(!this.hasControls||!this.active)return!1;var e,i,r=t.x,n=t.y;this.__corner=0;for(var s in this.oCoords)if(this.isControlVisible(s)&&("mtr"!==s||this.hasRotatingPoint)&&(!this.get("lockUniScaling")||"mt"!==s&&"mr"!==s&&"mb"!==s&&"ml"!==s)&&(i=this._getImageLines(this.oCoords[s].corner),0!==(e=this._findCrossPoints({x:r,y:n},i))&&e%2==1))return this.__corner=s,s;return!1},_setCornerCoords:function(){var e,i,r=this.oCoords,n=t(45-this.angle),s=.707106*this.cornerSize,o=s*Math.cos(n),a=s*Math.sin(n);for(var h in r)e=r[h].x,i=r[h].y,r[h].corner={tl:{x:e-a,y:i-o},tr:{x:e+o,y:i-a},bl:{x:e-o,y:i+a},br:{x:e+a,y:i+o}}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.group||!this.active||this.canvas&&!this.canvas.interactive)return this;e.save();var i=this.getCenterPoint(),r=this._calculateCurrentDimensions(),n=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/n[0],1/n[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-r.x/2,-r.y/2,r.x,r.y),e.restore(),this},drawBorders:function(t){if(!this.hasBorders)return this;var e=this._calculateCurrentDimensions(),i=1/this.borderScaleFactor,r=e.x+i,n=e.y+i;if(t.save(),t.strokeStyle=this.borderColor,this._setLineDash(t,this.borderDashArray,null),t.strokeRect(-r/2,-n/2,r,n),this.hasRotatingPoint&&this.isControlVisible("mtr")&&!this.get("lockRotation")&&this.hasControls){var s=-n/2;t.beginPath(),t.moveTo(0,s),t.lineTo(0,s-this.rotatingPointOffset),t.closePath(),t.stroke()}return t.restore(),this},drawBordersInGroup:function(t,e){if(!this.hasBorders)return this;var i=this._getNonTransformedDimensions(),r=fabric.util.customTransformMatrix(e.scaleX,e.scaleY,e.skewX),n=fabric.util.transformPoint(i,r),s=1/this.borderScaleFactor,o=n.x+s,a=n.y+s;return t.save(),this._setLineDash(t,this.borderDashArray,null),t.strokeStyle=this.borderColor,t.strokeRect(-o/2,-a/2,o,a),t.restore(),this},drawControls:function(t){if(!this.hasControls)return this;var e=this._calculateCurrentDimensions(),i=e.x,r=e.y,n=this.cornerSize,s=-(i+n)/2,o=-(r+n)/2,a=this.transparentCorners?"stroke":"fill";return t.save(),t.strokeStyle=t.fillStyle=this.cornerColor,this.transparentCorners||(t.strokeStyle=this.cornerStrokeColor),this._setLineDash(t,this.cornerDashArray,null),this._drawControl("tl",t,a,s,o),this._drawControl("tr",t,a,s+i,o),this._drawControl("bl",t,a,s,o+r),this._drawControl("br",t,a,s+i,o+r),this.get("lockUniScaling")||(this._drawControl("mt",t,a,s+i/2,o),this._drawControl("mb",t,a,s+i/2,o+r),this._drawControl("mr",t,a,s+i,o+r/2),this._drawControl("ml",t,a,s,o+r/2)),this.hasRotatingPoint&&this._drawControl("mtr",t,a,s+i/2,o-this.rotatingPointOffset),t.restore(),this},_drawControl:function(t,i,r,n,s){if(this.isControlVisible(t)){var o=this.cornerSize,a=!this.transparentCorners&&this.cornerStrokeColor;switch(this.cornerStyle){case"circle":i.beginPath(),i.arc(n+o/2,s+o/2,o/2,0,2*Math.PI,!1),i[r](),a&&i.stroke();break;default:e()||this.transparentCorners||i.clearRect(n,s,o,o),i[r+"Rect"](n,s,o,o),a&&i.strokeRect(n,s,o,o)}}},isControlVisible:function(t){return this._getControlsVisibility()[t]},setControlVisible:function(t,e){return this._getControlsVisibility()[t]=e,this},setControlsVisibility:function(t){t||(t={});for(var e in t)this.setControlVisible(e,t[e]);return this},_getControlsVisibility:function(){return this._controlsVisibility||(this._controlsVisibility={tl:!0,tr:!0,br:!0,bl:!0,ml:!0,mt:!0,mr:!0,mb:!0,mtr:!0}),this._controlsVisibility}})}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},r=(e=e||{}).onComplete||i,n=e.onChange||i,s=this;return fabric.util.animate({startValue:t.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.renderAll(),n()},onComplete:function(){t.setCoords(),r()}}),this},fxCenterObjectV:function(t,e){var i=function(){},r=(e=e||{}).onComplete||i,n=e.onChange||i,s=this;return fabric.util.animate({startValue:t.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.renderAll(),n()},onComplete:function(){t.setCoords(),r()}}),this},fxRemove:function(t,e){var i=function(){},r=(e=e||{}).onComplete||i,n=e.onChange||i,s=this;return fabric.util.animate({startValue:t.get("opacity"),endValue:0,duration:this.FX_DURATION,onStart:function(){t.set("active",!1)},onChange:function(e){t.set("opacity",e),s.renderAll(),n()},onComplete:function(){s.remove(t),r()}}),this}}),fabric.util.object.extend(fabric.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[];for(t in arguments[0])i.push(t);for(var r=0,n=i.length;r<n;r++)t=i[r],e=r!==n-1,this._animate(t,arguments[0][t],arguments[1],e)}else this._animate.apply(this,arguments);return this},_animate:function(t,e,i,r){var n,s=this;e=e.toString(),i=i?fabric.util.object.clone(i):{},~t.indexOf(".")&&(n=t.split("."));var o=n?this.get(n[0])[n[1]]:this.get(t);"from"in i||(i.from=o),e=~e.indexOf("=")?o+parseFloat(e.replace("=","")):parseFloat(e),fabric.util.animate({startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(){return i.abort.call(s)},onChange:function(e,o,a){n?s[n[0]][n[1]]=e:s.set(t,e),r||i.onChange&&i.onChange(e,o,a)},onComplete:function(t,e,n){r||(s.setCoords(),i.onComplete&&i.onComplete(t,e,n))}})}}),function(t){"use strict";function e(t,e){var i=t.origin,r=t.axis1,n=t.axis2,s=t.dimension,o=e.nearest,a=e.center,h=e.farthest;return function(){switch(this.get(i)){case o:return Math.min(this.get(r),this.get(n));case a:return Math.min(this.get(r),this.get(n))+.5*this.get(s);case h:return Math.max(this.get(r),this.get(n))}}}var i=t.fabric||(t.fabric={}),r=i.util.object.extend,n=i.util.object.clone,s={x1:1,x2:1,y1:1,y2:1},o=i.StaticCanvas.supports("setLineDash");if(i.Line)i.warn("fabric.Line is already defined");else{var a=i.Object.prototype.cacheProperties.concat();a.push("x1","x2","y1","y2"),i.Line=i.util.createClass(i.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:a,initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==s[t]&&this._setWidthHeight(),this},_getLeftToOriginX:e({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:e({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t,e){if(t.beginPath(),e){var i=this.getCenterPoint(),r=this.strokeWidth/2;t.translate(i.x-("butt"===this.strokeLineCap&&0===this.height?0:r),i.y-("butt"===this.strokeLineCap&&0===this.width?0:r))}if(!this.strokeDashArray||this.strokeDashArray&&o){var n=this.calcLinePoints();t.moveTo(n.x1,n.y1),t.lineTo(n.x2,n.y2)}t.lineWidth=this.strokeWidth;var s=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=s},_renderDashedStroke:function(t){var e=this.calcLinePoints();t.beginPath(),i.util.drawDashedLine(t,e.x1,e.y1,e.x2,e.y2,this.strokeDashArray),t.closePath()},toObject:function(t){return r(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,r=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:r,y2:e*this.height*-.5}},toSVG:function(t){var e=this._createBaseSVGMarkup(),i={x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2};return this.group&&"path-group"===this.group.type||(i=this.calcLinePoints()),e.push("<line ",this.getSvgId(),'x1="',i.x1,'" y1="',i.y1,'" x2="',i.x2,'" y2="',i.y2,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),t?t(e.join("")):e.join("")}}),i.Line.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),i.Line.fromElement=function(t,e){e=e||{};var n=i.parseAttributes(t,i.Line.ATTRIBUTE_NAMES),s=[n.x1||0,n.y1||0,n.x2||0,n.y2||0];return e.originX="left",e.originY="top",new i.Line(s,r(n,e))},i.Line.fromObject=function(t,e,r){var s=n(t,!0);s.points=[t.x1,t.y1,t.x2,t.y2];var o=i.Object._fromObject("Line",s,function(t){delete t.points,e&&e(t)},r,"points");return o&&delete o.points,o}}}("undefined"!=typeof exports?exports:this),function(t){"use strict";function e(t){return"radius"in t&&t.radius>=0}var i=t.fabric||(t.fabric={}),r=Math.PI,n=i.util.object.extend;if(i.Circle)i.warn("fabric.Circle is already defined.");else{var s=i.Object.prototype.cacheProperties.concat();s.push("radius"),i.Circle=i.util.createClass(i.Object,{type:"circle",radius:0,startAngle:0,endAngle:2*r,cacheProperties:s,initialize:function(t){this.callSuper("initialize",t),this.set("radius",t&&t.radius||0)},_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=0,n=0,s=(this.endAngle-this.startAngle)%(2*r);if(0===s)this.group&&"path-group"===this.group.type&&(i=this.left+this.radius,n=this.top+this.radius),e.push("<circle ",this.getSvgId(),'cx="'+i+'" cy="'+n+'" ','r="',this.radius,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n');else{var o=Math.cos(this.startAngle)*this.radius,a=Math.sin(this.startAngle)*this.radius,h=Math.cos(this.endAngle)*this.radius,c=Math.sin(this.endAngle)*this.radius,l=s>r?"1":"0";e.push('<path d="M '+o+" "+a," A "+this.radius+" "+this.radius," 0 ",+l+" 1"," "+h+" "+c,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n')}return t?t(e.join("")):e.join("")},_render:function(t,e){t.beginPath(),t.arc(e?this.left+this.radius:0,e?this.top+this.radius:0,this.radius,this.startAngle,this.endAngle,!1),this._renderFill(t),this._renderStroke(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),i.Circle.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),i.Circle.fromElement=function(t,r){r||(r={});var s=i.parseAttributes(t,i.Circle.ATTRIBUTE_NAMES);if(!e(s))throw new Error("value of `r` attribute is required and can not be negative");s.left=s.left||0,s.top=s.top||0;var o=new i.Circle(n(s,r));return o.left-=o.radius,o.top-=o.radius,o},i.Circle.fromObject=function(t,e,r){return i.Object._fromObject("Circle",t,e,r)}}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",initialize:function(t){this.callSuper("initialize",t),this.set("width",t&&t.width||100).set("height",t&&t.height||100)},_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderFill(t),this._renderStroke(t)},_renderDashedStroke:function(t){var i=this.width/2,r=this.height/2;t.beginPath(),e.util.drawDashedLine(t,-i,r,0,-r,this.strokeDashArray),e.util.drawDashedLine(t,0,-r,i,r,this.strokeDashArray),e.util.drawDashedLine(t,i,r,-i,r,this.strokeDashArray),t.closePath()},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this.width/2,r=this.height/2,n=[-i+" "+r,"0 "+-r,i+" "+r].join(",");return e.push("<polygon ",this.getSvgId(),'points="',n,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),t?t(e.join("")):e.join("")}}),e.Triangle.fromObject=function(t,i,r){return e.Object._fromObject("Triangle",t,i,r)})}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=2*Math.PI,r=e.util.object.extend;if(e.Ellipse)e.warn("fabric.Ellipse is already defined.");else{var n=e.Object.prototype.cacheProperties.concat();n.push("rx","ry"),e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:n,initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=0,r=0;return this.group&&"path-group"===this.group.type&&(i=this.left+this.rx,r=this.top+this.ry),e.push("<ellipse ",this.getSvgId(),'cx="',i,'" cy="',r,'" ','rx="',this.rx,'" ry="',this.ry,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),t?t(e.join("")):e.join("")},_render:function(t,e){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(e?this.left+this.rx:0,e?(this.top+this.ry)*this.rx/this.ry:0,this.rx,0,i,!1),t.restore(),this._renderFill(t),this._renderStroke(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){i||(i={});var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=n.left||0,n.top=n.top||0;var s=new e.Ellipse(r(n,i));return s.top-=s.ry,s.left-=s.rx,s},e.Ellipse.fromObject=function(t,i,r){return e.Object._fromObject("Ellipse",t,i,r)}}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;if(e.Rect)e.warn("fabric.Rect is already defined");else{var r=e.Object.prototype.stateProperties.concat();r.push("rx","ry");var n=e.Object.prototype.cacheProperties.concat();n.push("rx","ry"),e.Rect=e.util.createClass(e.Object,{stateProperties:r,type:"rect",rx:0,ry:0,cacheProperties:n,initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t,e){if(1!==this.width||1!==this.height){var i=this.rx?Math.min(this.rx,this.width/2):0,r=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,s=this.height,o=e?this.left:-this.width/2,a=e?this.top:-this.height/2,h=0!==i||0!==r,c=.4477152502;t.beginPath(),t.moveTo(o+i,a),t.lineTo(o+n-i,a),h&&t.bezierCurveTo(o+n-c*i,a,o+n,a+c*r,o+n,a+r),t.lineTo(o+n,a+s-r),h&&t.bezierCurveTo(o+n,a+s-c*r,o+n-c*i,a+s,o+n-i,a+s),t.lineTo(o+i,a+s),h&&t.bezierCurveTo(o+c*i,a+s,o,a+s-c*r,o,a+s-r),t.lineTo(o,a+r),h&&t.bezierCurveTo(o,a+c*r,o+c*i,a,o+i,a),t.closePath(),this._renderFill(t),this._renderStroke(t)}else t.fillRect(-.5,-.5,1,1)},_renderDashedStroke:function(t){var i=-this.width/2,r=-this.height/2,n=this.width,s=this.height;t.beginPath(),e.util.drawDashedLine(t,i,r,i+n,r,this.strokeDashArray),e.util.drawDashedLine(t,i+n,r,i+n,r+s,this.strokeDashArray),e.util.drawDashedLine(t,i+n,r+s,i,r+s,this.strokeDashArray),e.util.drawDashedLine(t,i,r+s,i,r,this.strokeDashArray),t.closePath()},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this.left,r=this.top;return this.group&&"path-group"===this.group.type||(i=-this.width/2,r=-this.height/2),e.push("<rect ",this.getSvgId(),'x="',i,'" y="',r,'" rx="',this.get("rx"),'" ry="',this.get("ry"),'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),t?t(e.join("")):e.join("")}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,r){if(!t)return null;r=r||{};var n=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);n.left=n.left||0,n.top=n.top||0;var s=new e.Rect(i(r?e.util.object.clone(r):{},n));return s.visible=s.visible&&s.width>0&&s.height>0,s},e.Rect.fromObject=function(t,i,r){return e.Object._fromObject("Rect",t,i,r)}}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,n=e.util.array.max,s=e.util.toFixed,o=e.Object.NUM_FRACTION_DIGITS;if(e.Polyline)e.warn("fabric.Polyline is already defined");else{var a=e.Object.prototype.cacheProperties.concat();a.push("points"),e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,minX:0,minY:0,cacheProperties:a,initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._calcDimensions(),"top"in e||(this.top=this.minY),"left"in e||(this.left=this.minX),this.pathOffset={x:this.minX+this.width/2,y:this.minY+this.height/2}},_calcDimensions:function(){var t=this.points,e=r(t,"x"),i=r(t,"y"),s=n(t,"x"),o=n(t,"y");this.width=s-e||0,this.height=o-i||0,this.minX=e||0,this.minY=i||0},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},toSVG:function(t){var e=[],i=0,r=0,n=this._createBaseSVGMarkup();this.group&&"path-group"===this.group.type||(i=this.pathOffset.x,r=this.pathOffset.y);for(var a=0,h=this.points.length;a<h;a++)e.push(s(this.points[a].x-i,o),",",s(this.points[a].y-r,o)," ");return n.push("<",this.type," ",this.getSvgId(),'points="',e.join(""),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n'),t?t(n.join("")):n.join("")},commonRender:function(t,e){var i,r=this.points.length,n=e?0:this.pathOffset.x,s=e?0:this.pathOffset.y;if(!r||isNaN(this.points[r-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-s);for(var o=0;o<r;o++)i=this.points[o],t.lineTo(i.x-n,i.y-s);return!0},_render:function(t,e){this.commonRender(t,e)&&(this._renderFill(t),this._renderStroke(t))},_renderDashedStroke:function(t){var i,r;t.beginPath();for(var n=0,s=this.points.length;n<s;n++)i=this.points[n],r=this.points[n+1]||i,e.util.drawDashedLine(t,i.x,i.y,r.x,r.y,this.strokeDashArray)},complexity:function(){return this.get("points").length}}),e.Polyline.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polyline.fromElement=function(t,i){if(!t)return null;i||(i={});var r=e.parsePointsAttribute(t.getAttribute("points")),n=e.parseAttributes(t,e.Polyline.ATTRIBUTE_NAMES);return new e.Polyline(r,e.util.object.extend(n,i))},e.Polyline.fromObject=function(t,i,r){return e.Object._fromObject("Polyline",t,i,r,"points")}}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Polygon?e.warn("fabric.Polygon is already defined"):(e.Polygon=e.util.createClass(e.Polyline,{type:"polygon",_render:function(t,e){this.commonRender(t,e)&&(t.closePath(),this._renderFill(t),this._renderStroke(t))},_renderDashedStroke:function(t){this.callSuper("_renderDashedStroke",t),t.closePath()}}),e.Polygon.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polygon.fromElement=function(t,r){if(!t)return null;r||(r={});var n=e.parsePointsAttribute(t.getAttribute("points")),s=e.parseAttributes(t,e.Polygon.ATTRIBUTE_NAMES);return new e.Polygon(n,i(s,r))},e.Polygon.fromObject=function(t,i,r){return e.Object._fromObject("Polygon",t,i,r,"points")})}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,r=e.util.array.max,n=e.util.object.extend,s=Object.prototype.toString,o=e.util.drawArc,a={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},h={m:"l",M:"L"};if(e.Path)e.warn("fabric.Path is already defined");else{var c=e.Object.prototype.stateProperties.concat();c.push("path");var l=e.Object.prototype.cacheProperties.concat();l.push("path","fillRule"),e.Path=e.util.createClass(e.Object,{type:"path",path:null,minX:0,minY:0,cacheProperties:l,stateProperties:c,initialize:function(t,e){e=e||{},this.callSuper("initialize",e),t||(t=[]);var i="[object Array]"===s.call(t);this.path=i?t:t.match&&t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi),this.path&&(i||(this.path=this._parsePath()),this._setPositionDimensions(e))},_setPositionDimensions:function(t){var e=this._parseDimensions();this.minX=e.left,this.minY=e.top,this.width=e.width,this.height=e.height,void 0===t.left&&(this.left=e.left+("center"===this.originX?this.width/2:"right"===this.originX?this.width:0)),void 0===t.top&&(this.top=e.top+("center"===this.originY?this.height/2:"bottom"===this.originY?this.height:0)),this.pathOffset=this.pathOffset||{x:this.minX+this.width/2,y:this.minY+this.height/2}},_renderPathCommands:function(t){var e,i,r,n=null,s=0,a=0,h=0,c=0,l=0,u=0,f=-this.pathOffset.x,d=-this.pathOffset.y;this.group&&"path-group"===this.group.type&&(f=0,d=0),t.beginPath();for(var g=0,p=this.path.length;g<p;++g){switch((e=this.path[g])[0]){case"l":h+=e[1],c+=e[2],t.lineTo(h+f,c+d);break;case"L":h=e[1],c=e[2],t.lineTo(h+f,c+d);break;case"h":h+=e[1],t.lineTo(h+f,c+d);break;case"H":h=e[1],t.lineTo(h+f,c+d);break;case"v":c+=e[1],t.lineTo(h+f,c+d);break;case"V":c=e[1],t.lineTo(h+f,c+d);break;case"m":s=h+=e[1],a=c+=e[2],t.moveTo(h+f,c+d);break;case"M":s=h=e[1],a=c=e[2],t.moveTo(h+f,c+d);break;case"c":i=h+e[5],r=c+e[6],l=h+e[3],u=c+e[4],t.bezierCurveTo(h+e[1]+f,c+e[2]+d,l+f,u+d,i+f,r+d),h=i,c=r;break;case"C":h=e[5],c=e[6],l=e[3],u=e[4],t.bezierCurveTo(e[1]+f,e[2]+d,l+f,u+d,h+f,c+d);break;case"s":i=h+e[3],r=c+e[4],null===n[0].match(/[CcSs]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.bezierCurveTo(l+f,u+d,h+e[1]+f,c+e[2]+d,i+f,r+d),l=h+e[1],u=c+e[2],h=i,c=r;break;case"S":i=e[3],r=e[4],null===n[0].match(/[CcSs]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.bezierCurveTo(l+f,u+d,e[1]+f,e[2]+d,i+f,r+d),h=i,c=r,l=e[1],u=e[2];break;case"q":i=h+e[3],r=c+e[4],l=h+e[1],u=c+e[2],t.quadraticCurveTo(l+f,u+d,i+f,r+d),h=i,c=r;break;case"Q":i=e[3],r=e[4],t.quadraticCurveTo(e[1]+f,e[2]+d,i+f,r+d),h=i,c=r,l=e[1],u=e[2];break;case"t":i=h+e[1],r=c+e[2],null===n[0].match(/[QqTt]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.quadraticCurveTo(l+f,u+d,i+f,r+d),h=i,c=r;break;case"T":i=e[1],r=e[2],null===n[0].match(/[QqTt]/)?(l=h,u=c):(l=2*h-l,u=2*c-u),t.quadraticCurveTo(l+f,u+d,i+f,r+d),h=i,c=r;break;case"a":o(t,h+f,c+d,[e[1],e[2],e[3],e[4],e[5],e[6]+h+f,e[7]+c+d]),h+=e[6],c+=e[7];break;case"A":o(t,h+f,c+d,[e[1],e[2],e[3],e[4],e[5],e[6]+f,e[7]+d]),h=e[6],c=e[7];break;case"z":case"Z":h=s,c=a,t.closePath()}n=e}},_render:function(t){this._renderPathCommands(t),this._renderFill(t),this._renderStroke(t)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(t){return n(this.callSuper("toObject",["sourcePath","pathOffset"].concat(t)),{path:this.path.map(function(t){return t.slice()}),top:this.top,left:this.left})},toDatalessObject:function(t){var e=this.toObject(t);return this.sourcePath&&(e.path=this.sourcePath),delete e.sourcePath,e},toSVG:function(t){for(var e=[],i=this._createBaseSVGMarkup(),r="",n=0,s=this.path.length;n<s;n++)e.push(this.path[n].join(" "));var o=e.join(" ");return this.group&&"path-group"===this.group.type||(r=" translate("+-this.pathOffset.x+", "+-this.pathOffset.y+") "),i.push("<path ",this.getSvgId(),'d="',o,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),r,this.getSvgTransformMatrix(),'" stroke-linecap="round" ',"/>\n"),t?t(i.join("")):i.join("")},complexity:function(){return this.path.length},_parsePath:function(){for(var t,e,i,r,n,s=[],o=[],c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,l=0,u=this.path.length;l<u;l++){for(r=(t=this.path[l]).slice(1).trim(),o.length=0;i=c.exec(r);)o.push(i[0]);n=[t.charAt(0)];for(var f=0,d=o.length;f<d;f++)e=parseFloat(o[f]),isNaN(e)||n.push(e);var g=n[0],p=a[g.toLowerCase()],v=h[g]||g;if(n.length-1>p)for(var b=1,m=n.length;b<m;b+=p)s.push([g].concat(n.slice(b,b+p))),g=v;else s.push(n)}return s},_parseDimensions:function(){for(var t,n,s,o,a=[],h=[],c=null,l=0,u=0,f=0,d=0,g=0,p=0,v=0,b=this.path.length;v<b;++v){switch((t=this.path[v])[0]){case"l":f+=t[1],d+=t[2],o=[];break;case"L":f=t[1],d=t[2],o=[];break;case"h":f+=t[1],o=[];break;case"H":f=t[1],o=[];break;case"v":d+=t[1],o=[];break;case"V":d=t[1],o=[];break;case"m":l=f+=t[1],u=d+=t[2],o=[];break;case"M":l=f=t[1],u=d=t[2],o=[];break;case"c":n=f+t[5],s=d+t[6],g=f+t[3],p=d+t[4],o=e.util.getBoundsOfCurve(f,d,f+t[1],d+t[2],g,p,n,s),f=n,d=s;break;case"C":g=t[3],p=t[4],o=e.util.getBoundsOfCurve(f,d,t[1],t[2],g,p,t[5],t[6]),f=t[5],d=t[6];break;case"s":n=f+t[3],s=d+t[4],null===c[0].match(/[CcSs]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,f+t[1],d+t[2],n,s),g=f+t[1],p=d+t[2],f=n,d=s;break;case"S":n=t[3],s=t[4],null===c[0].match(/[CcSs]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,t[1],t[2],n,s),f=n,d=s,g=t[1],p=t[2];break;case"q":n=f+t[3],s=d+t[4],g=f+t[1],p=d+t[2],o=e.util.getBoundsOfCurve(f,d,g,p,g,p,n,s),f=n,d=s;break;case"Q":g=t[1],p=t[2],o=e.util.getBoundsOfCurve(f,d,g,p,g,p,t[3],t[4]),f=t[3],d=t[4];break;case"t":n=f+t[1],s=d+t[2],null===c[0].match(/[QqTt]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,g,p,n,s),f=n,d=s;break;case"T":n=t[1],s=t[2],null===c[0].match(/[QqTt]/)?(g=f,p=d):(g=2*f-g,p=2*d-p),o=e.util.getBoundsOfCurve(f,d,g,p,g,p,n,s),f=n,d=s;break;case"a":o=e.util.getBoundsOfArc(f,d,t[1],t[2],t[3],t[4],t[5],t[6]+f,t[7]+d),f+=t[6],d+=t[7];break;case"A":o=e.util.getBoundsOfArc(f,d,t[1],t[2],t[3],t[4],t[5],t[6],t[7]),f=t[6],d=t[7];break;case"z":case"Z":f=l,d=u}c=t,o.forEach(function(t){a.push(t.x),h.push(t.y)}),a.push(f),h.push(d)}var m=i(a)||0,_=i(h)||0;return{left:m,top:_,width:(r(a)||0)-m,height:(r(h)||0)-_}}}),e.Path.fromObject=function(t,i,r){var n;if("string"!=typeof t.path)return e.Object._fromObject("Path",t,i,r,"path");e.loadSVGFromURL(t.path,function(e){var r=t.path;n=e[0],delete t.path,n.setOptions(t),n.setSourcePath(r),i&&i(n)})},e.Path.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(["d"]),e.Path.fromElement=function(t,i,r){var s=e.parseAttributes(t,e.Path.ATTRIBUTE_NAMES);i&&i(new e.Path(s.d,n(s,r)))},e.Path.async=!0}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.PathGroup?e.warn("fabric.PathGroup is already defined"):(e.PathGroup=e.util.createClass(e.Object,{type:"path-group",fill:"",cacheProperties:[],initialize:function(t,e){e=e||{},this.paths=t||[];for(var i=this.paths.length;i--;)this.paths[i].group=this;e.toBeParsed&&(this.parseDimensionsFromPaths(e),delete e.toBeParsed),this.setOptions(e),this.setCoords()},parseDimensionsFromPaths:function(t){for(var i,r,n,s,o,a,h=[],c=[],l=this.paths.length;l--;){s=(n=this.paths[l]).height+n.strokeWidth,o=n.width+n.strokeWidth,i=[{x:n.left,y:n.top},{x:n.left+o,y:n.top},{x:n.left,y:n.top+s},{x:n.left+o,y:n.top+s}],a=this.paths[l].transformMatrix;for(var u=0;u<i.length;u++)r=i[u],a&&(r=e.util.transformPoint(r,a,!1)),h.push(r.x),c.push(r.y)}t.width=Math.max.apply(null,h),t.height=Math.max.apply(null,c)},drawObject:function(t){t.save(),t.translate(-this.width/2,-this.height/2);for(var e=0,i=this.paths.length;e<i;++e)this.paths[e].render(t,!0);t.restore()},shouldCache:function(){var t=this.objectCaching&&(!this.group||this.needsItsOwnCache()||!this.group.isCaching());if(this.caching=t,t)for(var e=0,i=this.paths.length;e<i;e++)if(this.paths[e].willDrawShadow())return this.caching=!1,!1;return t},willDrawShadow:function(){if(this.shadow)return!0;for(var t=0,e=this.paths.length;t<e;t++)if(this.paths[t].willDrawShadow())return!0;return!1},isCaching:function(){return this.caching||this.group&&this.group.isCaching()},isCacheDirty:function(){if(this.callSuper("isCacheDirty"))return!0;if(!this.statefullCache)return!1;for(var t=0,e=this.paths.length;t<e;t++)if(this.paths[t].isCacheDirty(!0)){if(this._cacheCanvas){var i=this.cacheWidth/this.zoomX,r=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-i/2,-r/2,i,r)}return!0}return!1},_set:function(t,e){if("fill"===t&&e&&this.isSameColor())for(var i=this.paths.length;i--;)this.paths[i]._set(t,e);return this.callSuper("_set",t,e)},toObject:function(t){var e=this.paths.map(function(e){var i=e.includeDefaultValues;e.includeDefaultValues=e.group.includeDefaultValues;var r=e.toObject(t);return e.includeDefaultValues=i,r});return i(this.callSuper("toObject",["sourcePath"].concat(t)),{paths:e})},toDatalessObject:function(t){var e=this.toObject(t);return this.sourcePath&&(e.paths=this.sourcePath),e},toSVG:function(t){var e=this.getObjects(),i=this.getPointByOrigin("left","top"),r="translate("+i.x+" "+i.y+")",n=this._createBaseSVGMarkup();n.push("<g ",this.getSvgId(),'style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransformMatrix(),r,this.getSvgTransform(),'" ',">\n");for(var s=0,o=e.length;s<o;s++)n.push("\t",e[s].toSVG(t));return n.push("</g>\n"),t?t(n.join("")):n.join("")},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var t=this.getObjects()[0].get("fill")||"";return"string"==typeof t&&(t=t.toLowerCase(),this.getObjects().every(function(e){var i=e.get("fill")||"";return"string"==typeof i&&i.toLowerCase()===t}))},complexity:function(){return this.paths.reduce(function(t,e){return t+(e&&e.complexity?e.complexity():0)},0)},getObjects:function(){return this.paths}}),e.PathGroup.fromObject=function(t,i){var r=t.paths;delete t.paths,"string"==typeof r?e.loadSVGFromURL(r,function(n){var s=r,o=e.util.groupSVGElements(n,t,s);t.paths=r,i(o)}):e.util.enlivenObjects(r,function(n){var s=new e.PathGroup(n,t);t.paths=r,i(s)})},e.PathGroup.async=!0)}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,n=e.util.array.max;if(!e.Group){var s={lockMovementX:!0,lockMovementY:!0,lockRotation:!0,lockScalingX:!0,lockScalingY:!0,lockUniScaling:!0};e.Group=e.util.createClass(e.Object,e.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],initialize:function(t,e,i){e=e||{},this._objects=[],i&&this.callSuper("initialize",e),this._objects=t||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;e.originX&&(this.originX=e.originX),e.originY&&(this.originY=e.originY),i?this._updateObjectsCoords(!0):(this._calcBounds(),this._updateObjectsCoords(),this.callSuper("initialize",e)),this.setCoords(),this.saveCoords()},_updateObjectsCoords:function(t){for(var e=this.getCenterPoint(),i=this._objects.length;i--;)this._updateObjectCoords(this._objects[i],e,t)},_updateObjectCoords:function(t,e,i){if(t.__origHasControls=t.hasControls,t.hasControls=!1,!i){var r=t.getLeft(),n=t.getTop();t.set({left:r-e.x,top:n-e.y}),t.setCoords(!0,!0)}},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this.forEachObject(this._setObjectActive,this),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_setObjectActive:function(t){t.set("active",!0),t.group=this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.forEachObject(this._setObjectActive,this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group,t.set("active",!1)},delegatedProperties:{fill:!0,stroke:!0,strokeWidth:!0,fontFamily:!0,fontWeight:!0,fontSize:!0,fontStyle:!0,lineHeight:!0,textDecoration:!0,textAlign:!0,backgroundColor:!0},_set:function(t,e){var i=this._objects.length;if(this.delegatedProperties[t]||"canvas"===t)for(;i--;)this._objects[i].set(t,e);else for(;i--;)this._objects[i].setOnGroup(t,e);this.callSuper("_set",t,e)},toObject:function(t){var e=this.getObjects().map(function(e){var i=e.includeDefaultValues;e.includeDefaultValues=e.group.includeDefaultValues;var r=e.toObject(t);return e.includeDefaultValues=i,r});return i(this.callSuper("toObject",t),{objects:e})},toDatalessObject:function(t){var e=this.getObjects().map(function(e){var i=e.includeDefaultValues;e.includeDefaultValues=e.group.includeDefaultValues;var r=e.toDatalessObject(t);return e.includeDefaultValues=i,r});return i(this.callSuper("toDatalessObject",t),{objects:e})},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=this.objectCaching&&(!this.group||this.needsItsOwnCache()||!this.group.isCaching());if(this.caching=t,t)for(var e=0,i=this._objects.length;e<i;e++)if(this._objects[e].willDrawShadow())return this.caching=!1,!1;return t},willDrawShadow:function(){if(this.callSuper("willDrawShadow"))return!0;for(var t=0,e=this._objects.length;t<e;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isCaching:function(){return this.caching||this.group&&this.group.isCaching()},drawObject:function(t){for(var e=0,i=this._objects.length;e<i;e++)this._renderObject(this._objects[e],t)},isCacheDirty:function(){if(this.callSuper("isCacheDirty"))return!0;if(!this.statefullCache)return!1;for(var t=0,e=this._objects.length;t<e;t++)if(this._objects[t].isCacheDirty(!0)){if(this._cacheCanvas){var i=this.cacheWidth/this.zoomX,r=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-i/2,-r/2,i,r)}return!0}return!1},_renderControls:function(t,e){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e);for(var i=0,r=this._objects.length;i<r;i++)this._objects[i]._renderControls(t);t.restore()},_renderObject:function(t,e){if(t.visible){var i=t.hasRotatingPoint;t.hasRotatingPoint=!1,t.render(e),t.hasRotatingPoint=i}},_restoreObjectsState:function(){return this._objects.forEach(this._restoreObjectState,this),this},realizeTransform:function(t){var i=t.calcTransformMatrix(),r=e.util.qrDecompose(i),n=new e.Point(r.translateX,r.translateY);return t.flipX=!1,t.flipY=!1,t.set("scaleX",r.scaleX),t.set("scaleY",r.scaleY),t.skewX=r.skewX,t.skewY=r.skewY,t.angle=r.angle,t.setPositionByOrigin(n,"center","center"),t},_restoreObjectState:function(t){return this.realizeTransform(t),t.setCoords(),t.hasControls=t.__origHasControls,delete t.__origHasControls,t.set("active",!1),delete t.group,this},destroy:function(){return this._objects.forEach(function(t){t.set("dirty",!0)}),this._restoreObjectsState()},saveCoords:function(){return this._originalLeft=this.get("left"),this._originalTop=this.get("top"),this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){return this.forEachObject(function(t){t.setCoords(!0,!0)}),this},_calcBounds:function(t){for(var e,i,r,n=[],s=[],o=["tr","br","bl","tl"],a=0,h=this._objects.length,c=o.length;a<h;++a)for((e=this._objects[a]).setCoords(!0),r=0;r<c;r++)i=o[r],n.push(e.oCoords[i].x),s.push(e.oCoords[i].y);this.set(this._getBounds(n,s,t))},_getBounds:function(t,i,s){var o=new e.Point(r(t),r(i)),a=new e.Point(n(t),n(i)),h={width:a.x-o.x||0,height:a.y-o.y||0};return s||(h.left=o.x||0,h.top=o.y||0,"center"===this.originX&&(h.left+=h.width/2),"right"===this.originX&&(h.left+=h.width),"center"===this.originY&&(h.top+=h.height/2),"bottom"===this.originY&&(h.top+=h.height)),h},toSVG:function(t){var e=this._createBaseSVGMarkup();e.push("<g ",this.getSvgId(),'transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'" style="',this.getSvgFilter(),'">\n');for(var i=0,r=this._objects.length;i<r;i++)e.push("\t",this._objects[i].toSVG(t));return e.push("</g>\n"),t?t(e.join("")):e.join("")},get:function(t){if(t in s){if(this[t])return this[t];for(var e=0,i=this._objects.length;e<i;e++)if(this._objects[e][t])return!0;return!1}return t in this.delegatedProperties?this._objects[0]&&this._objects[0].get(t):this[t]}}),e.Group.fromObject=function(t,i){e.util.enlivenObjects(t.objects,function(r){var n=e.util.object.clone(t,!0);delete n.objects,i&&i(new e.Group(r,n,!0))})},e.Group.async=!0}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=fabric.util.object.extend;if(t.fabric||(t.fabric={}),t.fabric.Image)fabric.warn("fabric.Image is already defined.");else{var i=fabric.Object.prototype.stateProperties.concat();i.push("alignX","alignY","meetOrSlice"),fabric.Image=fabric.util.createClass(fabric.Object,{type:"image",crossOrigin:"",alignX:"none",alignY:"none",meetOrSlice:"meet",strokeWidth:0,_lastScaleX:1,_lastScaleY:1,minimumScaleTrigger:.5,stateProperties:i,objectCaching:!1,initialize:function(t,e,i){e||(e={}),this.filters=[],this.resizeFilters=[],this.callSuper("initialize",e),this._initElement(t,e,i)},getElement:function(){return this._element},setElement:function(t,e,i){var r,n;return this._element=t,this._originalElement=t,this._initConfig(i),0===this.resizeFilters.length?r=e:(n=this,r=function(){n.applyFilters(e,n.resizeFilters,n._filteredEl||n._originalElement,!0)}),0!==this.filters.length?this.applyFilters(r):r&&r(this),this},setCrossOrigin:function(t){return this.crossOrigin=t,this._element.crossOrigin=t,this},getOriginalSize:function(){var t=this.getElement();return{width:t.width,height:t.height}},_stroke:function(t){if(this.stroke&&0!==this.strokeWidth){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}},_renderDashedStroke:function(t){var e=-this.width/2,i=-this.height/2,r=this.width,n=this.height;t.save(),this._setStrokeStyles(t),t.beginPath(),fabric.util.drawDashedLine(t,e,i,e+r,i,this.strokeDashArray),fabric.util.drawDashedLine(t,e+r,i,e+r,i+n,this.strokeDashArray),fabric.util.drawDashedLine(t,e+r,i+n,e,i+n,this.strokeDashArray),fabric.util.drawDashedLine(t,e,i+n,e,i,this.strokeDashArray),t.closePath(),t.restore()},toObject:function(t){var i=[],r=[],n=1,s=1;this.filters.forEach(function(t){t&&("Resize"===t.type&&(n*=t.scaleX,s*=t.scaleY),i.push(t.toObject()))}),this.resizeFilters.forEach(function(t){t&&r.push(t.toObject())});var o=e(this.callSuper("toObject",["crossOrigin","alignX","alignY","meetOrSlice"].concat(t)),{src:this.getSrc(),filters:i,resizeFilters:r});return o.width/=n,o.height/=s,o},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=-this.width/2,r=-this.height/2,n="none";if(this.group&&"path-group"===this.group.type&&(i=this.left,r=this.top),"none"!==this.alignX&&"none"!==this.alignY&&(n="x"+this.alignX+"Y"+this.alignY+" "+this.meetOrSlice),e.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'">\n',"<image ",this.getSvgId(),'xlink:href="',this.getSvgSrc(!0),'" x="',i,'" y="',r,'" style="',this.getSvgStyles(),'" width="',this.width,'" height="',this.height,'" preserveAspectRatio="',n,'"',"></image>\n"),this.stroke||this.strokeDashArray){var s=this.fill;this.fill=null,e.push("<rect ",'x="',i,'" y="',r,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'),this.fill=s}return e.push("</g>\n"),t?t(e.join("")):e.join("")},getSrc:function(t){var e=t?this._element:this._originalElement;return e?fabric.isLikelyNode?e._src:e.src:this.src||""},setSrc:function(t,e,i){fabric.util.loadImage(t,function(t){return this.setElement(t,e,i)},this,i&&i.crossOrigin)},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyFilters:function(t,e,i,r){if(e=e||this.filters,i=i||this._originalElement){var n,s,o=fabric.util.createImage(),a=this.canvas?this.canvas.getRetinaScaling():fabric.devicePixelRatio,h=this.minimumScaleTrigger/a,c=this;if(0===e.length)return this._element=i,t&&t(this),i;var l=fabric.util.createCanvasElement();return l.width=i.width,l.height=i.height,l.getContext("2d").drawImage(i,0,0,i.width,i.height),e.forEach(function(t){t&&(r?(n=c.scaleX<h?c.scaleX:1,s=c.scaleY<h?c.scaleY:1,n*a<1&&(n*=a),s*a<1&&(s*=a)):(n=t.scaleX,s=t.scaleY),t.applyTo(l,n,s),r||"Resize"!==t.type||(c.width*=t.scaleX,c.height*=t.scaleY))}),o.width=l.width,o.height=l.height,fabric.isLikelyNode?(o.src=l.toBuffer(void 0,fabric.Image.pngCompression),c._element=o,!r&&(c._filteredEl=o),t&&t(c)):(o.onload=function(){c._element=o,!r&&(c._filteredEl=o),t&&t(c),o.onload=l=null},o.src=l.toDataURL("image/png")),l}},_render:function(t,e){var i,r,n,s=this._findMargins();i=e?this.left:-this.width/2,r=e?this.top:-this.height/2,"slice"===this.meetOrSlice&&(t.beginPath(),t.rect(i,r,this.width,this.height),t.clip()),!1===this.isMoving&&this.resizeFilters.length&&this._needsResize()?(this._lastScaleX=this.scaleX,this._lastScaleY=this.scaleY,n=this.applyFilters(null,this.resizeFilters,this._filteredEl||this._originalElement,!0)):n=this._element,n&&t.drawImage(n,i+s.marginX,r+s.marginY,s.width,s.height),this._stroke(t),this._renderStroke(t)},_needsResize:function(){return this.scaleX!==this._lastScaleX||this.scaleY!==this._lastScaleY},_findMargins:function(){var t,e,i=this.width,r=this.height,n=0,s=0;return"none"===this.alignX&&"none"===this.alignY||(t=[this.width/this._element.width,this.height/this._element.height],e="meet"===this.meetOrSlice?Math.min.apply(null,t):Math.max.apply(null,t),i=this._element.width*e,r=this._element.height*e,"Mid"===this.alignX&&(n=(this.width-i)/2),"Max"===this.alignX&&(n=this.width-i),"Mid"===this.alignY&&(s=(this.height-r)/2),"Max"===this.alignY&&(s=this.height-r)),{width:i,height:r,marginX:n,marginY:s}},_resetWidthHeight:function(){var t=this.getElement();this.set("width",t.width),this.set("height",t.height)},_initElement:function(t,e,i){this.setElement(fabric.util.getById(t),i,e),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t),this._element&&this.crossOrigin&&(this._element.crossOrigin=this.crossOrigin)},_initFilters:function(t,e){t&&t.length?fabric.util.enlivenObjects(t,function(t){e&&e(t)},"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){this.width="width"in t?t.width:this.getElement()?this.getElement().width||0:0,this.height="height"in t?t.height:this.getElement()?this.getElement().height||0:0}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(t,e){fabric.util.loadImage(t.src,function(i,r){r?e&&e(null,r):fabric.Image.prototype._initFilters.call(t,t.filters,function(r){t.filters=r||[],fabric.Image.prototype._initFilters.call(t,t.resizeFilters,function(r){return t.resizeFilters=r||[],new fabric.Image(i,t,e)})})},null,t.crossOrigin)},fabric.Image.fromURL=function(t,e,i){fabric.util.loadImage(t,function(t){e&&e(new fabric.Image(t,i))},null,i&&i.crossOrigin)},fabric.Image.ATTRIBUTE_NAMES=fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin".split(" ")),fabric.Image.fromElement=function(t,i,r){var n,s=fabric.parseAttributes(t,fabric.Image.ATTRIBUTE_NAMES);s.preserveAspectRatio&&(n=fabric.util.parsePreserveAspectRatioAttribute(s.preserveAspectRatio),e(s,n)),fabric.Image.fromURL(s["xlink:href"],i,e(r?fabric.util.object.clone(r):{},s))},fabric.Image.async=!0,fabric.Image.pngCompression=1}}("undefined"!=typeof exports?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.getAngle()%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.setAngle(this._getAngleValueForStraighten()),this},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,r=t.onChange||e,n=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){n.setAngle(t),r()},onComplete:function(){n.setCoords(),i()},onStart:function(){n.set("active",!1)}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.renderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.renderAll.bind(this)}),this}}),fabric.Image.filters=fabric.Image.filters||{},fabric.Image.filters.BaseFilter=fabric.util.createClass({type:"BaseFilter",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},toObject:function(){return{type:this.type}},toJSON:function(){return this.toObject()}}),fabric.Image.filters.BaseFilter.fromObject=function(t,e){var i=new fabric.Image.filters[t.type](t);return e&&e(i),i},function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Brightness=n(r.BaseFilter,{type:"Brightness",initialize:function(t){t=t||{},this.brightness=t.brightness||0},applyTo:function(t){for(var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,n=this.brightness,s=0,o=r.length;s<o;s+=4)r[s]+=n,r[s+1]+=n,r[s+2]+=n;e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{brightness:this.brightness})}}),e.Image.filters.Brightness.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Convolute=n(r.BaseFilter,{type:"Convolute",initialize:function(t){t=t||{},this.opaque=t.opaque,this.matrix=t.matrix||[0,0,0,0,1,0,0,0,0]},applyTo:function(t){for(var e,i,r,n,s,o,a,h,c,l=this.matrix,u=t.getContext("2d"),f=u.getImageData(0,0,t.width,t.height),d=Math.round(Math.sqrt(l.length)),g=Math.floor(d/2),p=f.data,v=f.width,b=f.height,m=u.createImageData(v,b),_=m.data,y=this.opaque?1:0,x=0;x<b;x++)for(var C=0;C<v;C++){s=4*(x*v+C),e=0,i=0,r=0,n=0;for(var S=0;S<d;S++)for(var w=0;w<d;w++)o=C+w-g,(a=x+S-g)<0||a>b||o<0||o>v||(h=4*(a*v+o),c=l[S*d+w],e+=p[h]*c,i+=p[h+1]*c,r+=p[h+2]*c,n+=p[h+3]*c);_[s]=e,_[s+1]=i,_[s+2]=r,_[s+3]=n+y*(255-n)}u.putImageData(m,0,0)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.GradientTransparency=n(r.BaseFilter,{type:"GradientTransparency",initialize:function(t){t=t||{},this.threshold=t.threshold||100},applyTo:function(t){for(var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,n=this.threshold,s=r.length,o=0,a=r.length;o<a;o+=4)r[o+3]=n+255*(s-o)/s;e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold})}}),e.Image.filters.GradientTransparency.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Grayscale=r(i.BaseFilter,{type:"Grayscale",applyTo:function(t){for(var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=r.width*r.height*4,o=0;o<s;)e=(n[o]+n[o+1]+n[o+2])/3,n[o]=e,n[o+1]=e,n[o+2]=e,o+=4;i.putImageData(r,0,0)}}),e.Image.filters.Grayscale.fromObject=function(t,i){return t=t||{},t.type="Grayscale",e.Image.filters.BaseFilter.fromObject(t,i)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Invert=r(i.BaseFilter,{type:"Invert",applyTo:function(t){var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=n.length;for(e=0;e<s;e+=4)n[e]=255-n[e],n[e+1]=255-n[e+1],n[e+2]=255-n[e+2];i.putImageData(r,0,0)}}),e.Image.filters.Invert.fromObject=function(t,i){return t=t||{},t.type="Invert",e.Image.filters.BaseFilter.fromObject(t,i)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Mask=n(r.BaseFilter,{type:"Mask",initialize:function(t){t=t||{},this.mask=t.mask,this.channel=[0,1,2,3].indexOf(t.channel)>-1?t.channel:0},applyTo:function(t){if(this.mask){var i,r=t.getContext("2d"),n=r.getImageData(0,0,t.width,t.height),s=n.data,o=this.mask.getElement(),a=e.util.createCanvasElement(),h=this.channel,c=n.width*n.height*4;a.width=t.width,a.height=t.height,a.getContext("2d").drawImage(o,0,0,t.width,t.height);var l=a.getContext("2d").getImageData(0,0,t.width,t.height).data;for(i=0;i<c;i+=4)s[i+3]=l[i+h];r.putImageData(n,0,0)}},toObject:function(){return i(this.callSuper("toObject"),{mask:this.mask.toObject(),channel:this.channel})}}),e.Image.filters.Mask.fromObject=function(t,i){e.util.loadImage(t.mask.src,function(r){return t.mask=new e.Image(r,t.mask),e.Image.filters.BaseFilter.fromObject(t,i)})},e.Image.filters.Mask.async=!0}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Noise=n(r.BaseFilter,{type:"Noise",initialize:function(t){t=t||{},this.noise=t.noise||0},applyTo:function(t){for(var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=this.noise,o=0,a=n.length;o<a;o+=4)e=(.5-Math.random())*s,n[o]+=e,n[o+1]+=e,n[o+2]+=e;i.putImageData(r,0,0)},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}}),e.Image.filters.Noise.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Pixelate=n(r.BaseFilter,{type:"Pixelate",initialize:function(t){t=t||{},this.blocksize=t.blocksize||4},applyTo:function(t){var e,i,r,n,s,o,a,h=t.getContext("2d"),c=h.getImageData(0,0,t.width,t.height),l=c.data,u=c.height,f=c.width;for(i=0;i<u;i+=this.blocksize)for(r=0;r<f;r+=this.blocksize){n=l[e=4*i*f+4*r],s=l[e+1],o=l[e+2],a=l[e+3];for(var d=i,g=i+this.blocksize;d<g;d++)for(var p=r,v=r+this.blocksize;p<v;p++)l[e=4*d*f+4*p]=n,l[e+1]=s,l[e+2]=o,l[e+3]=a}h.putImageData(c,0,0)},toObject:function(){return i(this.callSuper("toObject"),{blocksize:this.blocksize})}}),e.Image.filters.Pixelate.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.RemoveWhite=n(r.BaseFilter,{type:"RemoveWhite",initialize:function(t){t=t||{},this.threshold=t.threshold||30,this.distance=t.distance||20},applyTo:function(t){for(var e,i,r,n=t.getContext("2d"),s=n.getImageData(0,0,t.width,t.height),o=s.data,a=this.threshold,h=this.distance,c=255-a,l=Math.abs,u=0,f=o.length;u<f;u+=4)e=o[u],i=o[u+1],r=o[u+2],e>c&&i>c&&r>c&&l(e-i)<h&&l(e-r)<h&&l(i-r)<h&&(o[u+3]=0);n.putImageData(s,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold,distance:this.distance})}}),e.Image.filters.RemoveWhite.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Sepia=r(i.BaseFilter,{type:"Sepia",applyTo:function(t){var e,i,r=t.getContext("2d"),n=r.getImageData(0,0,t.width,t.height),s=n.data,o=s.length;for(e=0;e<o;e+=4)i=.3*s[e]+.59*s[e+1]+.11*s[e+2],s[e]=i+100,s[e+1]=i+50,s[e+2]=i+255;r.putImageData(n,0,0)}}),e.Image.filters.Sepia.fromObject=function(t,i){return t=t||{},t.type="Sepia",new e.Image.filters.BaseFilter.fromObject(t,i)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Sepia2=r(i.BaseFilter,{type:"Sepia2",applyTo:function(t){var e,i,r,n,s=t.getContext("2d"),o=s.getImageData(0,0,t.width,t.height),a=o.data,h=a.length;for(e=0;e<h;e+=4)i=a[e],r=a[e+1],n=a[e+2],a[e]=(.393*i+.769*r+.189*n)/1.351,a[e+1]=(.349*i+.686*r+.168*n)/1.203,a[e+2]=(.272*i+.534*r+.131*n)/2.14;s.putImageData(o,0,0)}}),e.Image.filters.Sepia2.fromObject=function(t,i){return t=t||{},t.type="Sepia2",new e.Image.filters.BaseFilter.fromObject(t,i)}}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Tint=n(r.BaseFilter,{type:"Tint",initialize:function(t){t=t||{},this.color=t.color||"#000000",this.opacity=void 0!==t.opacity?t.opacity:new e.Color(this.color).getAlpha()},applyTo:function(t){var i,r,n,s,o,a,h,c,l,u=t.getContext("2d"),f=u.getImageData(0,0,t.width,t.height),d=f.data,g=d.length;for(r=(l=new e.Color(this.color).getSource())[0]*this.opacity,n=l[1]*this.opacity,s=l[2]*this.opacity,c=1-this.opacity,i=0;i<g;i+=4)o=d[i],a=d[i+1],h=d[i+2],d[i]=r+o*c,d[i+1]=n+a*c,d[i+2]=s+h*c;u.putImageData(f,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,opacity:this.opacity})}}),e.Image.filters.Tint.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Multiply=n(r.BaseFilter,{type:"Multiply",initialize:function(t){t=t||{},this.color=t.color||"#000000"},applyTo:function(t){var i,r,n=t.getContext("2d"),s=n.getImageData(0,0,t.width,t.height),o=s.data,a=o.length;for(r=new e.Color(this.color).getSource(),i=0;i<a;i+=4)o[i]*=r[0]/255,o[i+1]*=r[1]/255,o[i+2]*=r[2]/255;n.putImageData(s,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color})}}),e.Image.filters.Multiply.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric,i=e.Image.filters,r=e.util.createClass;i.Blend=r(i.BaseFilter,{type:"Blend",initialize:function(t){t=t||{},this.color=t.color||"#000",this.image=t.image||!1,this.mode=t.mode||"multiply",this.alpha=t.alpha||1},applyTo:function(t){var i,r,n,s,o,a,h,c,l,u,f=t.getContext("2d"),d=f.getImageData(0,0,t.width,t.height),g=d.data,p=!1;if(this.image){p=!0;var v=e.util.createCanvasElement();v.width=this.image.width,v.height=this.image.height;var b=new e.StaticCanvas(v);b.add(this.image),u=b.getContext("2d").getImageData(0,0,b.width,b.height).data}else i=(u=new e.Color(this.color).getSource())[0]*this.alpha,r=u[1]*this.alpha,n=u[2]*this.alpha;for(var m=0,_=g.length;m<_;m+=4)switch(s=g[m],o=g[m+1],a=g[m+2],p&&(i=u[m]*this.alpha,r=u[m+1]*this.alpha,n=u[m+2]*this.alpha),this.mode){case"multiply":g[m]=s*i/255,g[m+1]=o*r/255,g[m+2]=a*n/255;break;case"screen":g[m]=1-(1-s)*(1-i),g[m+1]=1-(1-o)*(1-r),g[m+2]=1-(1-a)*(1-n);break;case"add":g[m]=Math.min(255,s+i),g[m+1]=Math.min(255,o+r),g[m+2]=Math.min(255,a+n);break;case"diff":case"difference":g[m]=Math.abs(s-i),g[m+1]=Math.abs(o-r),g[m+2]=Math.abs(a-n);break;case"subtract":h=s-i,c=o-r,l=a-n,g[m]=h<0?0:h,g[m+1]=c<0?0:c,g[m+2]=l<0?0:l;break;case"darken":g[m]=Math.min(s,i),g[m+1]=Math.min(o,r),g[m+2]=Math.min(a,n);break;case"lighten":g[m]=Math.max(s,i),g[m+1]=Math.max(o,r),g[m+2]=Math.max(a,n)}f.putImageData(d,0,0)},toObject:function(){return{color:this.color,image:this.image,mode:this.mode,alpha:this.alpha}}}),e.Image.filters.Blend.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.pow,r=Math.floor,n=Math.sqrt,s=Math.abs,o=Math.max,a=Math.round,h=Math.sin,c=Math.ceil,l=e.Image.filters,u=e.util.createClass;l.Resize=u(l.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:0,scaleY:0,lanczosLobes:3,applyTo:function(t,e,i){if(1!==e||1!==i){this.rcpScaleX=1/e,this.rcpScaleY=1/i;var r,n=t.width,s=t.height,o=a(n*e),h=a(s*i);"sliceHack"===this.resizeType&&(r=this.sliceByTwo(t,n,s,o,h)),"hermite"===this.resizeType&&(r=this.hermiteFastResize(t,n,s,o,h)),"bilinear"===this.resizeType&&(r=this.bilinearFiltering(t,n,s,o,h)),"lanczos"===this.resizeType&&(r=this.lanczosResize(t,n,s,o,h)),t.width=o,t.height=h,t.getContext("2d").putImageData(r,0,0)}},sliceByTwo:function(t,i,n,s,a){var h,c=t.getContext("2d"),l=.5,u=.5,f=1,d=1,g=!1,p=!1,v=i,b=n,m=e.util.createCanvasElement(),_=m.getContext("2d");for(s=r(s),a=r(a),m.width=o(s,i),m.height=o(a,n),s>i&&(l=2,f=-1),a>n&&(u=2,d=-1),h=c.getImageData(0,0,i,n),t.width=o(s,i),t.height=o(a,n),c.putImageData(h,0,0);!g||!p;)i=v,n=b,s*f<r(v*l*f)?v=r(v*l):(v=s,g=!0),a*d<r(b*u*d)?b=r(b*u):(b=a,p=!0),h=c.getImageData(0,0,i,n),_.putImageData(h,0,0),c.clearRect(0,0,v,b),c.drawImage(m,0,0,i,n,0,0,v,b);return c.getImageData(0,0,s,a)},lanczosResize:function(t,e,o,a,l){function u(t){var h,c,f,d,j,k,M,D,P,A,E;for(O.x=(t+.5)*m,T.x=r(O.x),h=0;h<l;h++){for(O.y=(h+.5)*_,T.y=r(O.y),j=0,k=0,M=0,D=0,P=0,c=T.x-C;c<=T.x+C;c++)if(!(c<0||c>=e)){A=r(1e3*s(c-O.x)),w[A]||(w[A]={});for(var I=T.y-S;I<=T.y+S;I++)I<0||I>=o||(E=r(1e3*s(I-O.y)),w[A][E]||(w[A][E]=b(n(i(A*y,2)+i(E*x,2))/1e3)),(f=w[A][E])>0&&(j+=f,k+=f*p[d=4*(I*e+c)],M+=f*p[d+1],D+=f*p[d+2],P+=f*p[d+3]))}v[d=4*(h*a+t)]=k/j,v[d+1]=M/j,v[d+2]=D/j,v[d+3]=P/j}return++t<a?u(t):g}var f=t.getContext("2d"),d=f.getImageData(0,0,e,o),g=f.getImageData(0,0,a,l),p=d.data,v=g.data,b=function(t){return function(e){if(e>t)return 0;if(e*=Math.PI,s(e)<1e-16)return 1;var i=e/t;return h(e)*h(i)/e/i}}(this.lanczosLobes),m=this.rcpScaleX,_=this.rcpScaleY,y=2/this.rcpScaleX,x=2/this.rcpScaleY,C=c(m*this.lanczosLobes/2),S=c(_*this.lanczosLobes/2),w={},O={},T={};return u(0)},bilinearFiltering:function(t,e,i,n,s){var o,a,h,c,l,u,f,d,g,p=0,v=this.rcpScaleX,b=this.rcpScaleY,m=t.getContext("2d"),_=4*(e-1),y=m.getImageData(0,0,e,i).data,x=m.getImageData(0,0,n,s),C=x.data;for(h=0;h<s;h++)for(c=0;c<n;c++)for(l=v*c-(o=r(v*c)),u=b*h-(a=r(b*h)),g=4*(a*e+o),f=0;f<4;f++)d=y[g+f]*(1-l)*(1-u)+y[g+4+f]*l*(1-u)+y[g+_+f]*u*(1-l)+y[g+_+4+f]*l*u,C[p++]=d;return x},hermiteFastResize:function(t,e,i,o,a){for(var h=this.rcpScaleX,l=this.rcpScaleY,u=c(h/2),f=c(l/2),d=t.getContext("2d"),g=d.getImageData(0,0,e,i).data,p=d.getImageData(0,0,o,a),v=p.data,b=0;b<a;b++)for(var m=0;m<o;m++){for(var _=4*(m+b*o),y=0,x=0,C=0,S=0,w=0,O=0,T=0,j=(b+.5)*l,k=r(b*l);k<(b+1)*l;k++)for(var M=s(j-(k+.5))/f,D=(m+.5)*h,P=M*M,A=r(m*h);A<(m+1)*h;A++){var E=s(D-(A+.5))/u,I=n(P+E*E);I>1&&I<-1||(y=2*I*I*I-3*I*I+1)>0&&(T+=y*g[(E=4*(A+k*e))+3],C+=y,g[E+3]<255&&(y=y*g[E+3]/250),S+=y*g[E],w+=y*g[E+1],O+=y*g[E+2],x+=y)}v[_]=S/x,v[_+1]=w/x,v[_+2]=O/x,v[_+3]=T/C}return p},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.ColorMatrix=n(r.BaseFilter,{type:"ColorMatrix",initialize:function(t){t||(t={}),this.matrix=t.matrix||[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]},applyTo:function(t){var e,i,r,n,s,o=t.getContext("2d"),a=o.getImageData(0,0,t.width,t.height),h=a.data,c=h.length,l=this.matrix;for(e=0;e<c;e+=4)i=h[e],r=h[e+1],n=h[e+2],s=h[e+3],h[e]=i*l[0]+r*l[1]+n*l[2]+s*l[3]+l[4],h[e+1]=i*l[5]+r*l[6]+n*l[7]+s*l[8]+l[9],h[e+2]=i*l[10]+r*l[11]+n*l[12]+s*l[13]+l[14],h[e+3]=i*l[15]+r*l[16]+n*l[17]+s*l[18]+l[19];o.putImageData(a,0,0)},toObject:function(){return i(this.callSuper("toObject"),{type:this.type,matrix:this.matrix})}}),e.Image.filters.ColorMatrix.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Contrast=n(r.BaseFilter,{type:"Contrast",initialize:function(t){t=t||{},this.contrast=t.contrast||0},applyTo:function(t){for(var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,n=259*(this.contrast+255)/(255*(259-this.contrast)),s=0,o=r.length;s<o;s+=4)r[s]=n*(r[s]-128)+128,r[s+1]=n*(r[s+1]-128)+128,r[s+2]=n*(r[s+2]-128)+128;e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{contrast:this.contrast})}}),e.Image.filters.Contrast.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Saturate=n(r.BaseFilter,{type:"Saturate",initialize:function(t){t=t||{},this.saturate=t.saturate||0},applyTo:function(t){for(var e,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=r.data,s=.01*-this.saturate,o=0,a=n.length;o<a;o+=4)e=Math.max(n[o],n[o+1],n[o+2]),n[o]+=e!==n[o]?(e-n[o])*s:0,n[o+1]+=e!==n[o+1]?(e-n[o+1])*s:0,n[o+2]+=e!==n[o+2]?(e-n[o+2])*s:0;i.putImageData(r,0,0)},toObject:function(){return i(this.callSuper("toObject"),{saturate:this.saturate})}}),e.Image.filters.Saturate.fromObject=e.Image.filters.BaseFilter.fromObject}("undefined"!=typeof exports?exports:this),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed,r=e.Object.NUM_FRACTION_DIGITS;if(e.Text)e.warn("fabric.Text is already defined");else{var n=e.Object.prototype.stateProperties.concat();n.push("fontFamily","fontWeight","fontSize","text","textDecoration","textAlign","fontStyle","lineHeight","textBackgroundColor","charSpacing");var s=e.Object.prototype.cacheProperties.concat();s.push("fontFamily","fontWeight","fontSize","text","textDecoration","textAlign","fontStyle","lineHeight","textBackgroundColor","charSpacing","styles"),e.Text=e.util.createClass(e.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",textDecoration:"",textAlign:"left",fontStyle:"",lineHeight:1.16,textBackgroundColor:"",stateProperties:n,cacheProperties:s,stroke:null,shadow:null,_fontSizeFraction:.25,_fontSizeMult:1.13,charSpacing:0,initialize:function(t,e){e=e||{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",e),this.__skipDimension=!1,this._initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},_initDimensions:function(t){this.__skipDimension||(t||(t=e.util.createCanvasElement().getContext("2d"),this._setTextStyles(t)),this._textLines=this._splitTextIntoLines(),this._clearCache(),this.width=this._getTextWidth(t)||this.cursorWidth||2,this.height=this._getTextHeight(t))},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){this._setTextStyles(t),this.group&&"path-group"===this.group.type&&t.translate(this.left,this.top),this._renderTextLinesBackground(t),this._renderText(t),this._renderTextDecoration(t)},_renderText:function(t){this._renderTextFill(t),this._renderTextStroke(t)},_setTextStyles:function(t){t.textBaseline="alphabetic",t.font=this._getFontDeclaration()},_getTextHeight:function(){return this._getHeightOfSingleLine()+(this._textLines.length-1)*this._getHeightOfLine()},_getTextWidth:function(t){for(var e=this._getLineWidth(t,0),i=1,r=this._textLines.length;i<r;i++){var n=this._getLineWidth(t,i);n>e&&(e=n)}return e},_renderChars:function(t,e,i,r,n){var s,o,a=t.slice(0,-4);if(this[a].toLive){var h=-this.width/2+this[a].offsetX||0,c=-this.height/2+this[a].offsetY||0;e.save(),e.translate(h,c),r-=h,n-=c}if(0!==this.charSpacing)for(var l=this._getWidthOfCharSpacing(),u=0,f=(i=i.split("")).length;u<f;u++)s=i[u],o=e.measureText(s).width+l,e[t](s,r,n),r+=o>0?o:0;else e[t](i,r,n);this[a].toLive&&e.restore()},_renderTextLine:function(t,e,i,r,n,s){n-=this.fontSize*this._fontSizeFraction;var o=this._getLineWidth(e,s);if("justify"!==this.textAlign||this.width<o)this._renderChars(t,e,i,r,n,s);else for(var a,h=i.split(/\s+/),c=0,l=this._getWidthOfWords(e,h.join(" "),s,0),u=this.width-l,f=h.length-1,d=f>0?u/f:0,g=0,p=0,v=h.length;p<v;p++){for(;" "===i[c]&&c<i.length;)c++;a=h[p],this._renderChars(t,e,a,r+g,n,s,c),g+=this._getWidthOfWords(e,a,s,c)+d,c+=a.length}},_getWidthOfWords:function(t,e){var i=t.measureText(e).width;return 0!==this.charSpacing&&(i+=e.split("").length*this._getWidthOfCharSpacing()),i>0?i:0},_getLeftOffset:function(){return-this.width/2},_getTopOffset:function(){return-this.height/2},isEmptyStyles:function(){return!0},_renderTextCommon:function(t,e){for(var i=0,r=this._getLeftOffset(),n=this._getTopOffset(),s=0,o=this._textLines.length;s<o;s++){var a=this._getHeightOfLine(t,s),h=a/this.lineHeight,c=this._getLineWidth(t,s),l=this._getLineLeftOffset(c);this._renderTextLine(e,t,this._textLines[s],r+l,n+i+h,s),i+=a}},_renderTextFill:function(t){!this.fill&&this.isEmptyStyles()||this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_getHeightOfLine:function(){return this._getHeightOfSingleLine()*this.lineHeight},_getHeightOfSingleLine:function(){return this.fontSize*this._fontSizeMult},_renderTextLinesBackground:function(t){if(this.textBackgroundColor){var e,i,r,n=0,s=t.fillStyle;t.fillStyle=this.textBackgroundColor;for(var o=0,a=this._textLines.length;o<a;o++)e=this._getHeightOfLine(t,o),(i=this._getLineWidth(t,o))>0&&(r=this._getLineLeftOffset(i),t.fillRect(this._getLeftOffset()+r,this._getTopOffset()+n,i,e/this.lineHeight)),n+=e;t.fillStyle=s,this._removeShadow(t)}},_getLineLeftOffset:function(t){return"center"===this.textAlign?(this.width-t)/2:"right"===this.textAlign?this.width-t:0},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.saveState({propertySet:"_dimensionAffectingProps"}),this.dirty=!0),t},_getLineWidth:function(t,e){if(this.__lineWidths[e])return-1===this.__lineWidths[e]?this.width:this.__lineWidths[e];var i,r=this._textLines[e];return i=""===r?0:this._measureLine(t,e),this.__lineWidths[e]=i,i&&"justify"===this.textAlign&&r.split(/\s+/).length>1&&(this.__lineWidths[e]=-1),i},_getWidthOfCharSpacing:function(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0},_measureLine:function(t,e){var i,r=this._textLines[e],n=t.measureText(r).width,s=0;return 0!==this.charSpacing&&(s=(r.split("").length-1)*this._getWidthOfCharSpacing()),(i=n+s)>0?i:0},_renderTextDecoration:function(t){if(this.textDecoration){var e=this.height/2,i=this,r=[];this.textDecoration.indexOf("underline")>-1&&r.push(.85),this.textDecoration.indexOf("line-through")>-1&&r.push(.43),this.textDecoration.indexOf("overline")>-1&&r.push(-.12),r.length>0&&function(r){var n,s,o,a,h,c,l,u=0;for(n=0,s=i._textLines.length;n<s;n++){for(h=i._getLineWidth(t,n),c=i._getLineLeftOffset(h),l=i._getHeightOfLine(t,n),o=0,a=r.length;o<a;o++)t.fillRect(i._getLeftOffset()+c,u+(i._fontSizeMult-1+r[o])*i.fontSize-e,h,i.fontSize/15);u+=l}}(r)}},_getFontDeclaration:function(){return[e.isLikelyNode?this.fontWeight:this.fontStyle,e.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",e.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},render:function(t,e){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&(this._setTextStyles(t),this._initDimensions(t)),this.callSuper("render",t,e)))},_splitTextIntoLines:function(){return this.text.split(this._reNewline)},toObject:function(t){var e=["text","fontSize","fontWeight","fontFamily","fontStyle","lineHeight","textDecoration","textAlign","textBackgroundColor","charSpacing"].concat(t);return this.callSuper("toObject",e)},toSVG:function(t){this.ctx||(this.ctx=e.util.createCanvasElement().getContext("2d"));var i=this._createBaseSVGMarkup(),r=this._getSVGLeftTopOffsets(this.ctx),n=this._getSVGTextAndBg(r.textTop,r.textLeft);return this._wrapSVGTextAndBg(i,n),t?t(i.join("")):i.join("")},_getSVGLeftTopOffsets:function(t){var e=this._getHeightOfLine(t,0);return{textLeft:-this.width/2+(this.group&&"path-group"===this.group.type?this.left:0),textTop:0+(this.group&&"path-group"===this.group.type?-this.top:0),lineTop:e}},_wrapSVGTextAndBg:function(t,e){var i=this.getSvgFilter(),r=""===i?"":' style="'+i+'"';t.push("\t<g ",this.getSvgId(),'transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"',r,">\n",e.textBgRects.join(""),'\t\t<text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",this.textDecoration?'text-decoration="'+this.textDecoration+'" ':"",'style="',this.getSvgStyles(!0),'" >\n',e.textSpans.join(""),"\t\t</text>\n","\t</g>\n")},getSvgStyles:function(t){return e.Object.prototype.getSvgStyles.call(this,t)+" white-space: pre;"},_getSVGTextAndBg:function(t,e){var i=[],r=[],n=0;this._setSVGBg(r);for(var s=0,o=this._textLines.length;s<o;s++)this.textBackgroundColor&&this._setSVGTextLineBg(r,s,e,t,n),this._setSVGTextLineText(s,i,n,e,t,r),n+=this._getHeightOfLine(this.ctx,s);return{textSpans:i,textBgRects:r}},_setSVGTextLineText:function(t,n,s,o,a){var h=this.fontSize*(this._fontSizeMult-this._fontSizeFraction)-a+s-this.height/2;"justify"!==this.textAlign?n.push('\t\t\t<tspan x="',i(o+this._getLineLeftOffset(this._getLineWidth(this.ctx,t)),r),'" ','y="',i(h,r),'" ',this._getFillAttributes(this.fill),">",e.util.string.escapeXml(this._textLines[t]),"</tspan>\n"):this._setSVGTextLineJustifed(t,n,h,o)},_setSVGTextLineJustifed:function(t,n,s,o){var a=e.util.createCanvasElement().getContext("2d");this._setTextStyles(a);var h,c,l=this._textLines[t].split(/\s+/),u=this._getWidthOfWords(a,l.join("")),f=this.width-u,d=l.length-1,g=d>0?f/d:0,p=this._getFillAttributes(this.fill);for(o+=this._getLineLeftOffset(this._getLineWidth(a,t)),t=0,c=l.length;t<c;t++)h=l[t],n.push('\t\t\t<tspan x="',i(o,r),'" ','y="',i(s,r),'" ',p,">",e.util.string.escapeXml(h),"</tspan>\n"),o+=this._getWidthOfWords(a,h)+g},_setSVGTextLineBg:function(t,e,n,s,o){t.push("\t\t<rect ",this._getFillAttributes(this.textBackgroundColor),' x="',i(n+this._getLineLeftOffset(this._getLineWidth(this.ctx,e)),r),'" y="',i(o-this.height/2,r),'" width="',i(this._getLineWidth(this.ctx,e),r),'" height="',i(this._getHeightOfLine(this.ctx,e)/this.lineHeight,r),'"></rect>\n')},_setSVGBg:function(t){this.backgroundColor&&t.push("\t\t<rect ",this._getFillAttributes(this.backgroundColor),' x="',i(-this.width/2,r),'" y="',i(-this.height/2,r),'" width="',i(this.width,r),'" height="',i(this.height,r),'"></rect>\n')},_getFillAttributes:function(t){var i=t&&"string"==typeof t?new e.Color(t):"";return i&&i.getSource()&&1!==i.getAlpha()?'opacity="'+i.getAlpha()+'" fill="'+i.setAlpha(1).toRgb()+'"':'fill="'+t+'"'},_set:function(t,e){this.callSuper("_set",t,e),this._dimensionAffectingProps.indexOf(t)>-1&&(this._initDimensions(),this.setCoords())},complexity:function(){return 1}}),e.Text.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size text-decoration text-anchor".split(" ")),e.Text.DEFAULT_SVG_FONT_SIZE=16,e.Text.fromElement=function(t,i){if(!t)return null;var r=e.parseAttributes(t,e.Text.ATTRIBUTE_NAMES);(i=e.util.object.extend(i?e.util.object.clone(i):{},r)).top=i.top||0,i.left=i.left||0,"dx"in r&&(i.left+=r.dx),"dy"in r&&(i.top+=r.dy),"fontSize"in i||(i.fontSize=e.Text.DEFAULT_SVG_FONT_SIZE),i.originX||(i.originX="left");var n="";"textContent"in t?n=t.textContent:"firstChild"in t&&null!==t.firstChild&&"data"in t.firstChild&&null!==t.firstChild.data&&(n=t.firstChild.data),n=n.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var s=new e.Text(n,i),o=s.getHeight()/s.height,a=((s.height+s.strokeWidth)*s.lineHeight-s.height)*o,h=s.getHeight()+a,c=0;return"left"===s.originX&&(c=s.getWidth()/2),"right"===s.originX&&(c=-s.getWidth()/2),s.set({left:s.getLeft()+c,top:s.getTop()-h/2+s.fontSize*(.18+s._fontSizeFraction)/s.lineHeight}),s},e.Text.fromObject=function(t,i,r){return e.Object._fromObject("Text",t,i,r,"text")},e.util.createAccessors(e.Text)}}("undefined"!=typeof exports?exports:this),function(){var t=fabric.util.object.clone;fabric.IText=fabric.util.createClass(fabric.Text,fabric.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"#333",cursorDelay:1e3,cursorDuration:600,styles:null,caching:!0,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],initialize:function(t,e){this.styles=e?e.styles||{}:{},this.callSuper("initialize",t,e),this.initBehavior()},_clearCache:function(){this.callSuper("_clearCache"),this.__widthOfSpace=[]},isEmptyStyles:function(){if(!this.styles)return!0;var t=this.styles;for(var e in t)for(var i in t[e])for(var r in t[e][i])return!1;return!0},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},getSelectionStyles:function(t,e){if(2===arguments.length){for(var i=[],r=t;r<e;r++)i.push(this.getSelectionStyles(r));return i}var n=this.get2DCursorLocation(t);return this._getStyleDeclaration(n.lineIndex,n.charIndex)||{}},setSelectionStyles:function(t){if(this.selectionStart===this.selectionEnd)this._extendStyles(this.selectionStart,t);else for(var e=this.selectionStart;e<this.selectionEnd;e++)this._extendStyles(e,t);return this._forceClearCache=!0,this},_extendStyles:function(t,e){var i=this.get2DCursorLocation(t);this._getLineStyle(i.lineIndex)||this._setLineStyle(i.lineIndex,{}),this._getStyleDeclaration(i.lineIndex,i.charIndex)||this._setStyleDeclaration(i.lineIndex,i.charIndex,{}),fabric.util.object.extend(this._getStyleDeclaration(i.lineIndex,i.charIndex),e)},_initDimensions:function(t){t||this.clearContextTop(),this.callSuper("_initDimensions",t)},render:function(t,e){this.clearContextTop(),this.callSuper("render",t,e),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t),this.ctx=t},clearContextTop:function(){if(this.active&&this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this.canvas.contextTop;t.save(),t.transform.apply(t,this.canvas.viewportTransform),this.transform(t),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this._clearTextArea(t),t.restore()}},renderCursorOrSelection:function(){if(this.active&&this.isEditing){var t,e,i=this.text.split("");this.canvas&&this.canvas.contextTop?((e=this.canvas.contextTop).save(),e.transform.apply(e,this.canvas.viewportTransform),this.transform(e),this.transformMatrix&&e.transform.apply(e,this.transformMatrix),this._clearTextArea(e)):(e=this.ctx).save(),this.selectionStart===this.selectionEnd?(t=this._getCursorBoundaries(i,"cursor"),this.renderCursor(t,e)):(t=this._getCursorBoundaries(i,"selection"),this.renderSelection(i,t,e)),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},get2DCursorLocation:function(t){void 0===t&&(t=this.selectionStart);for(var e=this._textLines.length,i=0;i<e;i++){if(t<=this._textLines[i].length)return{lineIndex:i,charIndex:t};t-=this._textLines[i].length+1}return{lineIndex:i-1,charIndex:this._textLines[i-1].length<t?this._textLines[i-1].length:t}},getCurrentCharStyle:function(t,e){var i=this._getStyleDeclaration(t,0===e?0:e-1);return{fontSize:i&&i.fontSize||this.fontSize,fill:i&&i.fill||this.fill,textBackgroundColor:i&&i.textBackgroundColor||this.textBackgroundColor,textDecoration:i&&i.textDecoration||this.textDecoration,fontFamily:i&&i.fontFamily||this.fontFamily,fontWeight:i&&i.fontWeight||this.fontWeight,fontStyle:i&&i.fontStyle||this.fontStyle,stroke:i&&i.stroke||this.stroke,strokeWidth:i&&i.strokeWidth||this.strokeWidth}},getCurrentCharFontSize:function(t,e){var i=this._getStyleDeclaration(t,0===e?0:e-1);return i&&i.fontSize?i.fontSize:this.fontSize},getCurrentCharColor:function(t,e){var i=this._getStyleDeclaration(t,0===e?0:e-1);return i&&i.fill?i.fill:this.cursorColor},_getCursorBoundaries:function(t,e){var i=Math.round(this._getLeftOffset()),r=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:n.left+n.lineLeft,topOffset:n.top}},_getCursorBoundariesOffsets:function(t,e){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;for(var i,r=0,n=0,s=0,o=0,a=0,h=0;h<this.selectionStart;h++)"\n"===t[h]?(a=0,o+=this._getHeightOfLine(this.ctx,n),n++,s=0):(a+=this._getWidthOfChar(this.ctx,t[h],n,s),s++),r=this._getLineLeftOffset(this._getLineWidth(this.ctx,n));return"cursor"===e&&(o+=(1-this._fontSizeFraction)*this._getHeightOfLine(this.ctx,n)/this.lineHeight-this.getCurrentCharFontSize(n,s)*(1-this._fontSizeFraction)),0!==this.charSpacing&&s===this._textLines[n].length&&(a-=this._getWidthOfCharSpacing()),i={top:o,left:a>0?a:0,lineLeft:r},this.cursorOffsetCache=i,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),r=i.lineIndex,n=i.charIndex,s=this.getCurrentCharFontSize(r,n),o=t.leftOffset,a=this.scaleX*this.canvas.getZoom(),h=this.cursorWidth/a;e.fillStyle=this.getCurrentCharColor(r,n),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+o-h/2,t.top+t.topOffset,h,s)},renderSelection:function(t,e,i){i.fillStyle=this.selectionColor;for(var r=this.get2DCursorLocation(this.selectionStart),n=this.get2DCursorLocation(this.selectionEnd),s=r.lineIndex,o=n.lineIndex,a=s;a<=o;a++){var h=this._getLineLeftOffset(this._getLineWidth(i,a))||0,c=this._getHeightOfLine(this.ctx,a),l=0,u=0,f=this._textLines[a];if(a===s){for(var d=0,g=f.length;d<g;d++)d>=r.charIndex&&(a!==o||d<n.charIndex)&&(u+=this._getWidthOfChar(i,f[d],a,d)),d<r.charIndex&&(h+=this._getWidthOfChar(i,f[d],a,d));d===f.length&&(u-=this._getWidthOfCharSpacing())}else if(a>s&&a<o)u+=this._getLineWidth(i,a)||5;else if(a===o){for(var p=0,v=n.charIndex;p<v;p++)u+=this._getWidthOfChar(i,f[p],a,p);n.charIndex===f.length&&(u-=this._getWidthOfCharSpacing())}l=c,(this.lineHeight<1||a===o&&this.lineHeight>1)&&(c/=this.lineHeight),i.fillRect(e.left+h,e.top+e.topOffset,u>0?u:0,c),e.topOffset+=l}},_renderChars:function(t,e,i,r,n,s,o){if(this.isEmptyStyles())return this._renderCharsFast(t,e,i,r,n);o=o||0;var a,h,c=this._getHeightOfLine(e,s),l="";e.save(),n-=c/this.lineHeight*this._fontSizeFraction;for(var u=o,f=i.length+o;u<=f;u++)a=a||this.getCurrentCharStyle(s,u),h=this.getCurrentCharStyle(s,u+1),(this._hasStyleChanged(a,h)||u===f)&&(this._renderChar(t,e,s,u-1,l,r,n,c),l="",a=h),l+=i[u-o];e.restore()},_renderCharsFast:function(t,e,i,r,n){"fillText"===t&&this.fill&&this.callSuper("_renderChars",t,e,i,r,n),"strokeText"===t&&(this.stroke&&this.strokeWidth>0||this.skipFillStrokeCheck)&&this.callSuper("_renderChars",t,e,i,r,n)},_renderChar:function(t,e,i,r,n,s,o,a){var h,c,l,u,f,d,g,p,v,b=this._getStyleDeclaration(i,r);if(b?(c=this._getHeightOfChar(e,n,i,r),u=b.stroke,l=b.fill,d=b.textDecoration):c=this.fontSize,u=(u||this.stroke)&&"strokeText"===t,l=(l||this.fill)&&"fillText"===t,b&&e.save(),h=this._applyCharStylesGetWidth(e,n,i,r,b||null),d=d||this.textDecoration,b&&b.textBackgroundColor&&this._removeShadow(e),0!==this.charSpacing){p=this._getWidthOfCharSpacing(),h=0;for(var m,_=0,y=(g=n.split("")).length;_<y;_++)m=g[_],l&&e.fillText(m,s+h,o),u&&e.strokeText(m,s+h,o),h+=(v=e.measureText(m).width+p)>0?v:0}else l&&e.fillText(n,s,o),u&&e.strokeText(n,s,o);(d||""!==d)&&(f=this._fontSizeFraction*a/this.lineHeight,this._renderCharDecoration(e,d,s,o,f,h,c)),b&&e.restore(),e.translate(h,0)},_hasStyleChanged:function(t,e){return t.fill!==e.fill||t.fontSize!==e.fontSize||t.textBackgroundColor!==e.textBackgroundColor||t.textDecoration!==e.textDecoration||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth},_renderCharDecoration:function(t,e,i,r,n,s,o){if(e){var a,h,c=o/15,l={underline:r+o/10,"line-through":r-o*(this._fontSizeFraction+this._fontSizeMult-1)+c,overline:r-(this._fontSizeMult-this._fontSizeFraction)*o},u=["underline","line-through","overline"];for(a=0;a<u.length;a++)h=u[a],e.indexOf(h)>-1&&t.fillRect(i,l[h],s,c)}},_renderTextLine:function(t,e,i,r,n,s){this.isEmptyStyles()||(n+=this.fontSize*(this._fontSizeFraction+.03)),this.callSuper("_renderTextLine",t,e,i,r,n,s)},_renderTextDecoration:function(t){if(this.isEmptyStyles())return this.callSuper("_renderTextDecoration",t)},_renderTextLinesBackground:function(t){this.callSuper("_renderTextLinesBackground",t);var e,i,r,n,s,o,a,h,c,l,u=0,f=this._getLeftOffset(),d=this._getTopOffset(),g="";t.save();for(var p=0,v=this._textLines.length;p<v;p++)if(e=this._getHeightOfLine(t,p),""!==(n=this._textLines[p])&&this.styles&&this._getLineStyle(p)){i=this._getLineWidth(t,p),r=this._getLineLeftOffset(i),a=h=c=l=0;for(var b=0,m=n.length;b<m;b++)g!==(o=this._getStyleDeclaration(p,b)||{}).textBackgroundColor&&(l&&c&&(t.fillStyle=g,t.fillRect(a,h,c,l)),a=h=c=l=0,g=o.textBackgroundColor||""),o.textBackgroundColor?(s=n[b],g===o.textBackgroundColor&&(g=o.textBackgroundColor,a||(a=f+r+this._getWidthOfCharsAt(t,p,b)),h=d+u,c+=this._getWidthOfChar(t,s,p,b),l=e/this.lineHeight)):g="";l&&c&&(t.fillStyle=g,t.fillRect(a,h,c,l),a=h=c=l=0),u+=e}else u+=e;t.restore()},_getCacheProp:function(t,e){return t+e.fontSize+e.fontWeight+e.fontStyle},_getFontCache:function(t){return fabric.charWidthsCache[t]||(fabric.charWidthsCache[t]={}),fabric.charWidthsCache[t]},_applyCharStylesGetWidth:function(e,i,r,n,s){var o,a,h,c=s||this._getStyleDeclaration(r,n),l=t(c);if(this._applyFontStyles(l),h=this._getFontCache(l.fontFamily),a=this._getCacheProp(i,l),!c&&h[a]&&this.caching)return h[a];"string"==typeof l.shadow&&(l.shadow=new fabric.Shadow(l.shadow));var u=l.fill||this.fill;return e.fillStyle=u.toLive?u.toLive(e,this):u,l.stroke&&(e.strokeStyle=l.stroke&&l.stroke.toLive?l.stroke.toLive(e,this):l.stroke),e.lineWidth=l.strokeWidth||this.strokeWidth,e.font=this._getFontDeclaration.call(l),l.shadow&&(l.scaleX=this.scaleX,l.scaleY=this.scaleY,l.canvas=this.canvas,l.getObjectScaling=this.getObjectScaling,this._setShadow.call(l,e)),this.caching&&h[a]?h[a]:(o=e.measureText(i).width,this.caching&&(h[a]=o),o)},_applyFontStyles:function(t){t.fontFamily||(t.fontFamily=this.fontFamily),t.fontSize||(t.fontSize=this.fontSize),t.fontWeight||(t.fontWeight=this.fontWeight),t.fontStyle||(t.fontStyle=this.fontStyle)},_getStyleDeclaration:function(e,i,r){return r?this.styles[e]&&this.styles[e][i]?t(this.styles[e][i]):{}:this.styles[e]&&this.styles[e][i]?this.styles[e][i]:null},_setStyleDeclaration:function(t,e,i){this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){delete this.styles[t][e]},_getLineStyle:function(t){return this.styles[t]},_setLineStyle:function(t,e){this.styles[t]=e},_deleteLineStyle:function(t){delete this.styles[t]},_getWidthOfChar:function(t,e,i,r){if(!this._isMeasuring&&"justify"===this.textAlign&&this._reSpacesAndTabs.test(e))return this._getWidthOfSpace(t,i);t.save();var n=this._applyCharStylesGetWidth(t,e,i,r);return 0!==this.charSpacing&&(n+=this._getWidthOfCharSpacing()),t.restore(),n>0?n:0},_getHeightOfChar:function(t,e,i){var r=this._getStyleDeclaration(e,i);return r&&r.fontSize?r.fontSize:this.fontSize},_getWidthOfCharsAt:function(t,e,i){var r,n,s=0;for(r=0;r<i;r++)n=this._textLines[e][r],s+=this._getWidthOfChar(t,n,e,r);return s},_measureLine:function(t,e){this._isMeasuring=!0;var i=this._getWidthOfCharsAt(t,e,this._textLines[e].length);return 0!==this.charSpacing&&(i-=this._getWidthOfCharSpacing()),this._isMeasuring=!1,i>0?i:0},_getWidthOfSpace:function(t,e){if(this.__widthOfSpace[e])return this.__widthOfSpace[e];var i=this._textLines[e],r=this._getWidthOfWords(t,i,e,0),n=this.width-r,s=i.length-i.replace(this._reSpacesAndTabs,"").length,o=Math.max(n/s,t.measureText(" ").width);return this.__widthOfSpace[e]=o,o},_getWidthOfWords:function(t,e,i,r){for(var n=0,s=0;s<e.length;s++){var o=e[s];o.match(/\s/)||(n+=this._getWidthOfChar(t,o,i,s+r))}return n},_getHeightOfLine:function(t,e){if(this.__lineHeights[e])return this.__lineHeights[e];for(var i=this._textLines[e],r=this._getHeightOfChar(t,e,0),n=1,s=i.length;n<s;n++){var o=this._getHeightOfChar(t,e,n);o>r&&(r=o)}return this.__lineHeights[e]=r*this.lineHeight*this._fontSizeMult,this.__lineHeights[e]},_getTextHeight:function(t){for(var e,i=0,r=0,n=this._textLines.length;r<n;r++)e=this._getHeightOfLine(t,r),i+=r===n-1?e/this.lineHeight:e;return i},toObject:function(e){return fabric.util.object.extend(this.callSuper("toObject",e),{styles:t(this.styles,!0)})}}),fabric.IText.fromObject=function(t,e,i){return fabric.Object._fromObject("IText",t,e,i,"text")}}(),function(){var t=fabric.util.object.clone;fabric.util.object.extend(fabric.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1,this.callSuper("onDeselect")},initAddedHandler:function(){var t=this;this.on("added",function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))})},initRemovedHandler:function(){var t=this;this.on("removed",function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],fabric.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))})},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach(function(t){t.__isMousedown=!1})}.bind(this),t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,r){var n;return n={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){n.isAborted||t[r]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return n.isAborted}}),n},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){e._tick()},i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&this.canvas&&this.canvas.clearContext(this.canvas.contextTop||this.ctx)},selectAll:function(){this.selectionStart=0,this.selectionEnd=this.text.length,this._fireSelectionChanged(),this._updateTextarea()},getSelectedText:function(){return this.text.slice(this.selectionStart,this.selectionEnd)},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this.text.charAt(i)))for(;this._reSpace.test(this.text.charAt(i));)e++,i--;for(;/\S/.test(this.text.charAt(i))&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this.text.charAt(i)))for(;this._reSpace.test(this.text.charAt(i));)e++,i++;for(;/\S/.test(this.text.charAt(i))&&i<this.text.length;)e++,i++;return t+e},findLineBoundaryLeft:function(t){for(var e=0,i=t-1;!/\n/.test(this.text.charAt(i))&&i>-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this.text.charAt(i))&&i<this.text.length;)e++,i++;return t+e},getNumNewLinesInSelectedText:function(){for(var t=this.getSelectedText(),e=0,i=0,r=t.length;i<r;i++)"\n"===t[i]&&e++;return e},searchWordBoundary:function(t,e){for(var i=this._reSpace.test(this.text.charAt(t))?t-1:t,r=this.text.charAt(i),n=/[ \n\.,;!\?\-]/;!n.test(r)&&i>0&&i<this.text.length;)i+=e,r=this.text.charAt(i);return n.test(r)&&"\n"!==r&&(i+=1===e?0:1),i},selectWord:function(t){t=t||this.selectionStart;var e=this.searchWordBoundary(t,-1),i=this.searchWordBoundary(t,1);this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(t){t=t||this.selectionStart;var e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea()},enterEditing:function(t){if(!this.isEditing&&this.editable)return this.canvas&&this.exitEditingOnOthers(this.canvas),this.isEditing=!0,this.selected=!0,this.initHiddenTextarea(t),this.hiddenTextarea.focus(),this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.renderAll(),this):this},exitEditingOnOthers:function(t){t._iTextInstances&&t._iTextInstances.forEach(function(t){t.selected=!1,t.isEditing&&t.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(t){if(this.__isMousedown&&this.isEditing){var e=this.getSelectionStartFromPointer(t.e),i=this.selectionStart,r=this.selectionEnd;(e===this.__selectionStartOnMouseDown&&i!==r||i!==e&&r!==e)&&(e>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===r||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},_updateTextarea:function(){if(this.hiddenTextarea&&!this.inCompositionMode&&(this.cursorOffsetCache={},this.hiddenTextarea.value=this.text,this.hiddenTextarea.selectionStart=this.selectionStart,this.hiddenTextarea.selectionEnd=this.selectionEnd,this.selectionStart===this.selectionEnd)){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top,this.hiddenTextarea.style.fontSize=t.fontSize}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.text.split(""),e=this._getCursorBoundaries(t,"cursor"),i=this.get2DCursorLocation(),r=i.lineIndex,n=i.charIndex,s=this.getCurrentCharFontSize(r,n),o=e.leftOffset,a=this.calcTransformMatrix(),h={x:e.left+o,y:e.top+e.topOffset+s},c=this.canvas.upperCanvasEl,l=c.width-s,u=c.height-s;return h=fabric.util.transformPoint(h,a),(h=fabric.util.transformPoint(h,this.canvas.viewportTransform)).x<0&&(h.x=0),h.x>l&&(h.x=l),h.y<0&&(h.y=0),h.y>u&&(h.y=u),h.x+=this.canvas._offset.left,h.y+=this.canvas._offset.top,{left:h.x+"px",top:h.y+"px",fontSize:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.overCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text;return this.selected=!1,this.isEditing=!1,this.selectable=!0,this.selectionEnd=this.selectionStart,this.hiddenTextarea&&(this.hiddenTextarea.blur&&this.hiddenTextarea.blur(),this.canvas&&this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea),this.hiddenTextarea=null),this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},_removeCharsFromTo:function(t,e){for(;e!==t;)this._removeSingleCharAndStyle(t+1),e--;this.selectionStart=t,this.selectionEnd=t},_removeSingleCharAndStyle:function(t){var e="\n"===this.text[t-1],i=e?t:t-1;this.removeStyleObject(e,i),this.text=this.text.slice(0,t-1)+this.text.slice(t),this._textLines=this._splitTextIntoLines()},insertChars:function(t,e){var i;if(this.selectionEnd-this.selectionStart>1&&this._removeCharsFromTo(this.selectionStart,this.selectionEnd),e||!this.isEmptyStyles())for(var r=0,n=t.length;r<n;r++)e&&(i=fabric.util.object.clone(fabric.copiedTextStyle[r],!0)),this.insertChar(t[r],r<n-1,i);else this.insertChar(t,!1)},insertChar:function(t,e,i){var r="\n"===this.text[this.selectionStart];this.text=this.text.slice(0,this.selectionStart)+t+this.text.slice(this.selectionEnd),this._textLines=this._splitTextIntoLines(),this.insertStyleObjects(t,r,i),this.selectionStart+=t.length,this.selectionEnd=this.selectionStart,e||(this._updateTextarea(),this.setCoords(),this._fireSelectionChanged(),this.fire("changed"),this.restartCursorIfNeeded(),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.renderAll()))},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(e,i,r){this.shiftLineStyles(e,1);var n={},s={};if(this.styles[e]&&this.styles[e][i-1]&&(n=this.styles[e][i-1]),r&&n)s[0]=t(n),this.styles[e+1]=s;else{var o=!1;for(var a in this.styles[e]){var h=parseInt(a,10);h>=i&&(o=!0,s[h-i]=this.styles[e][a],delete this.styles[e][a])}o&&(this.styles[e+1]=s)}this._forceClearCache=!0},insertCharStyleObject:function(e,i,r){var n=this.styles[e],s=t(n);0!==i||r||(i=1);for(var o in s){var a=parseInt(o,10);a>=i&&(n[a+1]=s[a],s[a-1]||delete n[a])}var h=r||t(n[i-1]);h&&(this.styles[e][i]=h),this._forceClearCache=!0},insertStyleObjects:function(t,e,i){var r=this.get2DCursorLocation(),n=r.lineIndex,s=r.charIndex;this._getLineStyle(n)||this._setLineStyle(n,{}),"\n"===t?this.insertNewlineStyleObject(n,s,e):this.insertCharStyleObject(n,s,i)},shiftLineStyles:function(e,i){var r=t(this.styles);for(var n in r)(s=parseInt(n,10))<=e&&delete r[s];for(var n in this.styles){var s=parseInt(n,10);s>e&&(this.styles[s+i]=r[s],r[s-i]||delete this.styles[s])}},removeStyleObject:function(t,e){var i=this.get2DCursorLocation(e),r=i.lineIndex,n=i.charIndex;this._removeStyleObject(t,i,r,n)},_getTextOnPreviousLine:function(t){return this._textLines[t-1]},_removeStyleObject:function(e,i,r,n){if(e){var s=this._getTextOnPreviousLine(i.lineIndex),o=s?s.length:0;this.styles[r-1]||(this.styles[r-1]={});for(n in this.styles[r])this.styles[r-1][parseInt(n,10)+o]=this.styles[r][n];this.shiftLineStyles(i.lineIndex,-1)}else{var a=this.styles[r];a&&delete a[n];var h=t(a);for(var c in h){var l=parseInt(c,10);l>=n&&0!==l&&(a[l-1]=h[l],delete a[l])}}},insertNewline:function(){this.insertChars("\n")},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?"right"===this._selectionDirection?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection="right":"left"===this._selectionDirection&&(this._selectionDirection="right",this.selectionStart=e),this.selectionEnd=i)},setSelectionInBoundaries:function(){var t=this.text.length;this.selectionStart>t?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}})}(),fabric.util.object.extend(fabric.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown.bind(this))},onMouseDown:function(t){this.__newClickTime=+new Date;var e=this.canvas.getPointer(t.e);this.isTripleClick(e,t.e)?(this.fire("tripleclick",t),this._stopEvent(t.e)):this.isDoubleClick(e)&&(this.fire("dblclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected},isDoubleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y&&this.__lastIsEditing},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},initClicks:function(){this.on("dblclick",function(t){this.selectWord(this.getSelectionStartFromPointer(t.e))}),this.on("tripleclick",function(t){this.selectLine(this.getSelectionStartFromPointer(t.e))})},initMousedownHandler:function(){this.on("mousedown",function(t){if(this.editable&&(!t.e.button||1===t.e.button)){var e=this.canvas.getPointer(t.e);this.__mousedownX=e.x,this.__mousedownY=e.y,this.__isMousedown=!0,this.selected&&this.setCursorByClick(t.e),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())}})},_isObjectMoved:function(t){var e=this.canvas.getPointer(t);return this.__mousedownX!==e.x||this.__mousedownY!==e.y},initMouseupHandler:function(){this.on("mouseup",function(t){this.__isMousedown=!1,!this.editable||this._isObjectMoved(t.e)||t.e.button&&1!==t.e.button||(this.__lastSelected&&!this.__corner&&(this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()),this.selected=!0)})},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,r=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,r,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),r=0,n=0,s=0,o=0,a=0,h=this._textLines.length;a<h;a++){e=this._textLines[a],s+=this._getHeightOfLine(this.ctx,a)*this.scaleY;var c=this._getLineWidth(this.ctx,a);n=this._getLineLeftOffset(c)*this.scaleX;for(var l=0,u=e.length;l<u;l++){if(r=n,n+=this._getWidthOfChar(this.ctx,e[l],a,this.flipX?u-l:l)*this.scaleX,!(s<=i.y||n<=i.x))return this._getNewSelectionStartFromOffset(i,r,n,o+a,u);o++}if(i.y<s)return this._getNewSelectionStartFromOffset(i,r,n,o+a-1,u)}return this.text.length},_getNewSelectionStartFromOffset:function(t,e,i,r,n){var s=t.x-e,o=r+(i-t.x>s?0:1);return this.flipX&&(o=n-o),o>this.text.length&&(o=this.text.length),o}}),fabric.util.object.extend(fabric.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=fabric.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; line-height: 1px; paddingーtop: "+t.fontSize+";",fabric.document.body.appendChild(this.hiddenTextarea),fabric.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),fabric.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),fabric.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),fabric.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),fabric.util.addListener(this.hiddenTextarea,"cut",this.cut.bind(this)),fabric.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(fabric.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{8:"removeChars",9:"exitEditing",27:"exitEditing",13:"insertNewline",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown",46:"forwardDelete"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){if(t.keyCode in this.keysMap)this[this.keysMap[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown&&(t.ctrlKey||t.metaKey)))return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.renderAll()}},onKeyUp:function(t){this.isEditing&&!this._copyDone?t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.renderAll()):this._copyDone=!1},onInput:function(t){if(this.isEditing&&!this.inCompositionMode){var e,i,r,n=this.selectionStart||0,s=this.selectionEnd||0,o=this.text.length,a=this.hiddenTextarea.value.length;a>o?(r="left"===this._selectionDirection?s:n,e=a-o,i=this.hiddenTextarea.value.slice(r,r+e)):(e=a-o+s-n,i=this.hiddenTextarea.value.slice(n,n+e)),this.insertChars(i),t.stopPropagation()}},onCompositionStart:function(){this.inCompositionMode=!0,this.prevCompositionLength=0,this.compositionStart=this.selectionStart},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(t){var e=t.data;this.selectionStart=this.compositionStart,this.selectionEnd=this.selectionEnd===this.selectionStart?this.compositionStart+this.prevCompositionLength:this.selectionEnd,this.insertChars(e,!1),this.prevCompositionLength=e.length},forwardDelete:function(t){if(this.selectionStart===this.selectionEnd){if(this.selectionStart===this.text.length)return;this.moveCursorRight(t)}this.removeChars(t)},copy:function(t){if(this.selectionStart!==this.selectionEnd){var e=this.getSelectedText(),i=this._getClipboardData(t);i&&i.setData("text",e),fabric.copiedText=e,fabric.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd),t.stopImmediatePropagation(),t.preventDefault(),this._copyDone=!0}},paste:function(t){var e=null,i=this._getClipboardData(t),r=!0;i?(e=i.getData("text").replace(/\r/g,""),fabric.copiedTextStyle&&fabric.copiedText===e||(r=!1)):e=fabric.copiedText,e&&this.insertChars(e,r),t.stopImmediatePropagation(),t.preventDefault()},cut:function(t){this.selectionStart!==this.selectionEnd&&(this.copy(t),this.removeChars(t))},_getClipboardData:function(t){return t&&t.clipboardData||fabric.window.clipboardData},_getWidthBeforeCursor:function(t,e){for(var i,r=this._textLines[t].slice(0,e),n=this._getLineWidth(this.ctx,t),s=this._getLineLeftOffset(n),o=0,a=r.length;o<a;o++)i=r[o],s+=this._getWidthOfChar(this.ctx,i,t,o);return s},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),n=r.lineIndex;if(n===this._textLines.length-1||t.metaKey||34===t.keyCode)return this.text.length-i;var s=r.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n+1,o);return this._textLines[n].slice(s).length+a+2},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),n=r.lineIndex;if(0===n||t.metaKey||33===t.keyCode)return-i;var s=r.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n-1,o),h=this._textLines[n].slice(0,s);return-this._textLines[n-1].length+a-h.length},_getIndexOnLine:function(t,e){for(var i,r=this._getLineWidth(this.ctx,t),n=this._textLines[t],s=this._getLineLeftOffset(r),o=0,a=0,h=n.length;a<h;a++){var c=n[a],l=this._getWidthOfChar(this.ctx,c,t,a);if((s+=l)>e){i=!0;var u=s-l,f=s,d=Math.abs(u-e);o=Math.abs(f-e)<d?a:a-1;break}}return i||(o=n.length-1),o},moveCursorDown:function(t){this.selectionStart>=this.text.length&&this.selectionEnd>=this.text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var r;if(t.altKey)r=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;r=this["findLineBoundary"+i](this[e])}if(void 0!==typeof r&&this[e]!==r)return this[e]=r,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this.text.length&&this.selectionEnd>=this.text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this.text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t){this.selectionStart===this.selectionEnd?this._removeCharsNearCursor(t):this._removeCharsFromTo(this.selectionStart,this.selectionEnd),this.set("dirty",!0),this.setSelectionEnd(this.selectionStart),this._removeExtraneousStyles(),this.canvas&&this.canvas.renderAll(),this.setCoords(),this.fire("changed"),this.canvas&&this.canvas.fire("text:changed",{target:this})},_removeCharsNearCursor:function(t){if(0!==this.selectionStart)if(t.metaKey){var e=this.findLineBoundaryLeft(this.selectionStart);this._removeCharsFromTo(e,this.selectionStart),this.setSelectionStart(e)}else if(t.altKey){var i=this.findWordBoundaryLeft(this.selectionStart);this._removeCharsFromTo(i,this.selectionStart),this.setSelectionStart(i)}else this._removeSingleCharAndStyle(this.selectionStart),this.setSelectionStart(this.selectionStart-1)}}),function(){var t=fabric.util.toFixed,e=fabric.Object.NUM_FRACTION_DIGITS;fabric.util.object.extend(fabric.IText.prototype,{_setSVGTextLineText:function(t,e,i,r,n,s){this._getLineStyle(t)?this._setSVGTextLineChars(t,e,i,r,s):fabric.Text.prototype._setSVGTextLineText.call(this,t,e,i,r,n)},_setSVGTextLineChars:function(t,e,i,r,n){for(var s=this._textLines[t],o=0,a=this._getLineLeftOffset(this._getLineWidth(this.ctx,t))-this.width/2,h=this._getSVGLineTopOffset(t),c=this._getHeightOfLine(this.ctx,t),l=0,u=s.length;l<u;l++){var f=this._getStyleDeclaration(t,l)||{};e.push(this._createTextCharSpan(s[l],f,a,h.lineTop+h.offset,o));var d=this._getWidthOfChar(this.ctx,s[l],t,l);f.textBackgroundColor&&n.push(this._createTextCharBg(f,a,h.lineTop,c,d,o)),o+=d}},_getSVGLineTopOffset:function(t){for(var e=0,i=0,r=0;r<t;r++)e+=this._getHeightOfLine(this.ctx,r);return i=this._getHeightOfLine(this.ctx,r),{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}},_createTextCharBg:function(i,r,n,s,o,a){return['\t\t<rect fill="',i.textBackgroundColor,'" x="',t(r+a,e),'" y="',t(n-this.height/2,e),'" width="',t(o,e),'" height="',t(s/this.lineHeight,e),'"></rect>\n'].join("")},_createTextCharSpan:function(i,r,n,s,o){var a=this.getSvgStyles.call(fabric.util.object.extend({visible:!0,fill:this.fill,stroke:this.stroke,type:"text",getSvgFilter:fabric.Object.prototype.getSvgFilter},r));return['\t\t\t<tspan x="',t(n+o,e),'" y="',t(s-this.height/2,e),'" ',r.fontFamily?'font-family="'+r.fontFamily.replace(/"/g,"'")+'" ':"",r.fontSize?'font-size="'+r.fontSize+'" ':"",r.fontStyle?'font-style="'+r.fontStyle+'" ':"",r.fontWeight?'font-weight="'+r.fontWeight+'" ':"",r.textDecoration?'text-decoration="'+r.textDecoration+'" ':"",'style="',a,'">',fabric.util.string.escapeXml(i),"</tspan>\n"].join("")}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Textbox=e.util.createClass(e.IText,e.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingY:!0,lockScalingFlip:!0,noScaleCache:!1,initialize:function(t,i){this.callSuper("initialize",t,i),this.setControlsVisibility(e.Textbox.getTextboxControlVisibility()),this.ctx=this.objectCaching?this._cacheContext:e.util.createCanvasElement().getContext("2d"),this._dimensionAffectingProps.push("width")},_initDimensions:function(t){this.__skipDimension||(t||(t=e.util.createCanvasElement().getContext("2d"),this._setTextStyles(t),this.clearContextTop()),this.dynamicMinWidth=0,this._textLines=this._splitTextIntoLines(t),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this._clearCache(),this.height=this._getTextHeight(t))},_generateStyleMap:function(){for(var t=0,e=0,i=0,r={},n=0;n<this._textLines.length;n++)"\n"===this.text[i]&&n>0?(e=0,i++,t++):" "===this.text[i]&&n>0&&(e++,i++),r[n]={line:t,offset:e},i+=this._textLines[n].length,e+=this._textLines[n].length;return r},_getStyleDeclaration:function(t,e,i){if(this._styleMap){var r=this._styleMap[t];if(!r)return i?{}:null;t=r.line,e=r.offset+e}return this.callSuper("_getStyleDeclaration",t,e,i)},_setStyleDeclaration:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){var i=this._styleMap[t];t=i.line,e=i.offset+e,delete this.styles[t][e]},_getLineStyle:function(t){var e=this._styleMap[t];return this.styles[e.line]},_setLineStyle:function(t,e){var i=this._styleMap[t];this.styles[i.line]=e},_deleteLineStyle:function(t){var e=this._styleMap[t];delete this.styles[e.line]},_wrapText:function(t,e){var i,r=e.split(this._reNewline),n=[];for(i=0;i<r.length;i++)n=n.concat(this._wrapLine(t,r[i],i));return n},_measureText:function(t,e,i,r){var n=0;r=r||0;for(var s=0,o=e.length;s<o;s++)n+=this._getWidthOfChar(t,e[s],i,s+r);return n},_wrapLine:function(t,e,i){for(var r=0,n=[],s="",o=e.split(" "),a="",h=0,c=0,l=0,u=0,f=!0,d=this._getWidthOfCharSpacing(),g=0;g<o.length;g++)a=o[g],c=this._measureText(t,a,i,h),h+=a.length,(r+=l+c-d)>=this.width&&!f?(n.push(s),s="",r=c,f=!0):r+=d,f||(s+=" "),s+=a,l=this._measureText(t," ",i,h),h++,f=!1,c>u&&(u=c);return g&&n.push(s),u>this.dynamicMinWidth&&(this.dynamicMinWidth=u-d),n},_splitTextIntoLines:function(t){t=t||this.ctx;var e=this.textAlign;this._styleMap=null,t.save(),this._setTextStyles(t),this.textAlign="left";var i=this._wrapText(t,this.text);return this.textAlign=e,t.restore(),this._textLines=i,this._styleMap=this._generateStyleMap(),i},setOnGroup:function(t,e){"scaleX"===t&&(this.set("scaleX",Math.abs(1/e)),this.set("width",this.get("width")*e/(void 0===this.__oldScaleX?1:this.__oldScaleX)),this.__oldScaleX=e)},get2DCursorLocation:function(t){void 0===t&&(t=this.selectionStart);for(var e=this._textLines.length,i=0,r=0;r<e;r++){var n=this._textLines[r].length;if(t<=i+n)return{lineIndex:r,charIndex:t-i};i+=n,"\n"!==this.text[i]&&" "!==this.text[i]||i++}return{lineIndex:e-1,charIndex:this._textLines[e-1].length}},_getCursorBoundariesOffsets:function(t,e){for(var i=0,r=0,n=this.get2DCursorLocation(),s=this._textLines[n.lineIndex].split(""),o=this._getLineLeftOffset(this._getLineWidth(this.ctx,n.lineIndex)),a=0;a<n.charIndex;a++)r+=this._getWidthOfChar(this.ctx,s[a],n.lineIndex,a);for(a=0;a<n.lineIndex;a++)i+=this._getHeightOfLine(this.ctx,a);return"cursor"===e&&(i+=(1-this._fontSizeFraction)*this._getHeightOfLine(this.ctx,n.lineIndex)/this.lineHeight-this.getCurrentCharFontSize(n.lineIndex,n.charIndex)*(1-this._fontSizeFraction)),{top:i,left:r,lineLeft:o}},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},toObject:function(t){return this.callSuper("toObject",["minWidth"].concat(t))}}),e.Textbox.fromObject=function(t,i,r){return e.Object._fromObject("Textbox",t,i,r,"text")},e.Textbox.getTextboxControlVisibility=function(){return{tl:!1,tr:!1,br:!1,bl:!1,ml:!0,mt:!1,mr:!0,mb:!1,mtr:!0}}}("undefined"!=typeof exports?exports:this),function(){var t=fabric.Canvas.prototype._setObjectScale;fabric.Canvas.prototype._setObjectScale=function(e,i,r,n,s,o,a){var h=i.target;if(!(h instanceof fabric.Textbox))return t.call(fabric.Canvas.prototype,e,i,r,n,s,o,a);var c=h.width*(e.x/i.scaleX/(h.width+h.strokeWidth));return c>=h.getMinWidth()?(h.set("width",c),!0):void 0},fabric.Group.prototype._refreshControlsVisibility=function(){if(void 0!==fabric.Textbox)for(var t=this._objects.length;t--;)if(this._objects[t]instanceof fabric.Textbox)return void this.setControlsVisibility(fabric.Textbox.getTextboxControlVisibility())},fabric.util.object.extend(fabric.Textbox.prototype,{_removeExtraneousStyles:function(){for(var t in this._styleMap)this._textLines[t]||delete this.styles[this._styleMap[t].line]},insertCharStyleObject:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,fabric.IText.prototype.insertCharStyleObject.apply(this,[t,e,i])},insertNewlineStyleObject:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,fabric.IText.prototype.insertNewlineStyleObject.apply(this,[t,e,i])},shiftLineStyles:function(t,e){t=this._styleMap[t].line,fabric.IText.prototype.shiftLineStyles.call(this,t,e)},_getTextOnPreviousLine:function(t){for(var e=this._textLines[t-1];this._styleMap[t-2]&&this._styleMap[t-2].line===this._styleMap[t-1].line;)e=this._textLines[t-2]+e,t--;return e},removeStyleObject:function(t,e){var i=this.get2DCursorLocation(e),r=this._styleMap[i.lineIndex],n=r.line,s=r.offset+i.charIndex;this._removeStyleObject(t,i,n,s)}})}(),function(){var t=fabric.IText.prototype._getNewSelectionStartFromOffset;fabric.IText.prototype._getNewSelectionStartFromOffset=function(e,i,r,n,s){n=t.call(this,e,i,r,n,s);for(var o=0,a=0,h=0;h<this._textLines.length&&!((o+=this._textLines[h].length)+a>=n);h++)"\n"!==this.text[o+a]&&" "!==this.text[o+a]||a++;return n-h+a}}(),function(){function request(t,e,i){var r=URL.parse(t);r.port||(r.port=0===r.protocol.indexOf("https:")?443:80);var n=(0===r.protocol.indexOf("https:")?HTTPS:HTTP).request({hostname:r.hostname,port:r.port,path:r.path,method:"GET"},function(t){var r="";e&&t.setEncoding(e),t.on("end",function(){i(r)}),t.on("data",function(e){200===t.statusCode&&(r+=e)})});n.on("error",function(t){t.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port):fabric.log(t.message),i(null)}),n.end()}function requestFs(t,e){require("fs").readFile(t,function(t,i){if(t)throw fabric.log(t),t;e(i)})}if("undefined"==typeof document||"undefined"==typeof window){var DOMParser=require("xmldom").DOMParser,URL=require("url"),HTTP=require("http"),HTTPS=require("https"),Canvas=require("canvas"),Image=require("canvas").Image;fabric.util.loadImage=function(t,e,i){function r(r){r?(n.src=new Buffer(r,"binary"),n._src=t,e&&e.call(i,n)):(n=null,e&&e.call(i,null,!0))}var n=new Image;t&&(t instanceof Buffer||0===t.indexOf("data"))?(n.src=n._src=t,e&&e.call(i,n)):t&&0!==t.indexOf("http")?requestFs(t,r):t?request(t,"binary",r):e&&e.call(i,t)},fabric.loadSVGFromURL=function(t,e,i){0!==(t=t.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim()).indexOf("http")?requestFs(t,function(t){fabric.loadSVGFromString(t.toString(),e,i)}):request(t,"",function(t){fabric.loadSVGFromString(t,e,i)})},fabric.loadSVGFromString=function(t,e,i){var r=(new DOMParser).parseFromString(t);fabric.parseSVGDocument(r.documentElement,function(t,i){e&&e(t,i)},i)},fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body),callback&&callback()})},fabric.createCanvasForNode=function(t,e,i,r){r=r||i;var n=fabric.document.createElement("canvas"),s=new Canvas(t||600,e||600,r),o=new Canvas(t||600,e||600,r);n.style={},n.width=s.width,n.height=s.height,(i=i||{}).nodeCanvas=s,i.nodeCacheCanvas=o;var a=new(fabric.Canvas||fabric.StaticCanvas)(n,i);return a.nodeCanvas=s,a.nodeCacheCanvas=o,a.contextContainer=s.getContext("2d"),a.contextCache=o.getContext("2d"),a.Font=Canvas.Font,a};var originaInitStatic=fabric.StaticCanvas.prototype._initStatic;fabric.StaticCanvas.prototype._initStatic=function(t,e){t=t||fabric.document.createElement("canvas"),this.nodeCanvas=new Canvas(t.width,t.height),this.nodeCacheCanvas=new Canvas(t.width,t.height),originaInitStatic.call(this,t,e),this.contextContainer=this.nodeCanvas.getContext("2d"),this.contextCache=this.nodeCacheCanvas.getContext("2d"),this.Font=Canvas.Font},fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()},fabric.StaticCanvas.prototype.createJPEGStream=function(t){return this.nodeCanvas.createJPEGStream(t)},fabric.StaticCanvas.prototype._initRetinaScaling=function(){if(this._isRetinaScaling())return this.lowerCanvasEl.setAttribute("width",this.width*fabric.devicePixelRatio),this.lowerCanvasEl.setAttribute("height",this.height*fabric.devicePixelRatio),this.nodeCanvas.width=this.width*fabric.devicePixelRatio,this.nodeCanvas.height=this.height*fabric.devicePixelRatio,this.contextContainer.scale(fabric.devicePixelRatio,fabric.devicePixelRatio),this},fabric.Canvas&&(fabric.Canvas.prototype._initRetinaScaling=fabric.StaticCanvas.prototype._initRetinaScaling);var origSetBackstoreDimension=fabric.StaticCanvas.prototype._setBackstoreDimension;fabric.StaticCanvas.prototype._setBackstoreDimension=function(t,e){return origSetBackstoreDimension.call(this,t,e),this.nodeCanvas[t]=e,this},fabric.Canvas&&(fabric.Canvas.prototype._setBackstoreDimension=fabric.StaticCanvas.prototype._setBackstoreDimension)}}();
 
 
 
 
 
 
 
admin/js/amcharts/plugins/export/libs/jszip/jszip.js CHANGED
@@ -9,7 +9,17 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
9
  JSZip uses the library pako released under the MIT license :
10
  https://github.com/nodeca/pako/blob/master/LICENSE
11
  */
12
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSZip=e()}}(function(){var define,module,exports;return (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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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})({1:[function(_dereq_,module,exports){
 
 
 
 
 
 
 
 
 
 
13
  'use strict';
14
  // private property
15
  var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@@ -115,7 +125,7 @@ module.exports = CompressedObject;
115
  'use strict';
116
  exports.STORE = {
117
  magic: "\x00\x00",
118
- compress: function(content, compressionOptions) {
119
  return content; // no compression
120
  },
121
  uncompress: function(content) {
@@ -347,10 +357,7 @@ exports.dir = false;
347
  exports.createFolders = false;
348
  exports.date = null;
349
  exports.compression = null;
350
- exports.compressionOptions = null;
351
  exports.comment = null;
352
- exports.unixPermissions = null;
353
- exports.dosPermissions = null;
354
 
355
  },{}],7:[function(_dereq_,module,exports){
356
  'use strict';
@@ -468,10 +475,8 @@ exports.uncompressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
468
  exports.compressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
469
 
470
  exports.magic = "\x08\x00";
471
- exports.compress = function(input, compressionOptions) {
472
- return pako.deflateRaw(input, {
473
- level : compressionOptions.level || -1 // default compression
474
- });
475
  };
476
  exports.uncompress = function(input) {
477
  return pako.inflateRaw(input);
@@ -579,8 +584,6 @@ module.exports = function(data, options) {
579
  date: input.date,
580
  dir: input.dir,
581
  comment : input.fileComment.length ? input.fileComment : null,
582
- unixPermissions : input.unixPermissions,
583
- dosPermissions : input.dosPermissions,
584
  createFolders: options.createFolders
585
  });
586
  }
@@ -600,7 +603,6 @@ module.exports = function(data, encoding){
600
  module.exports.test = function(b){
601
  return Buffer.isBuffer(b);
602
  };
603
-
604
  }).call(this,(typeof Buffer !== "undefined" ? Buffer : undefined))
605
  },{}],12:[function(_dereq_,module,exports){
606
  'use strict';
@@ -726,8 +728,6 @@ var ZipObject = function(name, data, options) {
726
  this.dir = options.dir;
727
  this.date = options.date;
728
  this.comment = options.comment;
729
- this.unixPermissions = options.unixPermissions;
730
- this.dosPermissions = options.dosPermissions;
731
 
732
  this._data = data;
733
  this.options = options;
@@ -852,23 +852,6 @@ var fileAdd = function(name, data, o) {
852
 
853
  o = prepareFileAttrs(o);
854
 
855
- if (typeof o.unixPermissions === "string") {
856
- o.unixPermissions = parseInt(o.unixPermissions, 8);
857
- }
858
-
859
- // UNX_IFDIR 0040000 see zipinfo.c
860
- if (o.unixPermissions && (o.unixPermissions & 0x4000)) {
861
- o.dir = true;
862
- }
863
- // Bit 4 Directory
864
- if (o.dosPermissions && (o.dosPermissions & 0x0010)) {
865
- o.dir = true;
866
- }
867
-
868
- if (o.dir) {
869
- name = forceTrailingSlash(name);
870
- }
871
-
872
  if (o.createFolders && (parent = parentFolder(name))) {
873
  folderAdd.call(this, parent, true);
874
  }
@@ -877,7 +860,6 @@ var fileAdd = function(name, data, o) {
877
  o.base64 = false;
878
  o.binary = false;
879
  data = null;
880
- dataType = null;
881
  }
882
  else if (dataType === "string") {
883
  if (o.binary && !o.base64) {
@@ -922,20 +904,6 @@ var parentFolder = function (path) {
922
  return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
923
  };
924
 
925
-
926
- /**
927
- * Returns the path with a slash at the end.
928
- * @private
929
- * @param {String} path the path to check.
930
- * @return {String} the path with a trailing slash.
931
- */
932
- var forceTrailingSlash = function(path) {
933
- // Check the name ends with a /
934
- if (path.slice(-1) != "/") {
935
- path += "/"; // IE doesn't like substr(-1)
936
- }
937
- return path;
938
- };
939
  /**
940
  * Add a (sub) folder in the current folder.
941
  * @private
@@ -945,9 +913,12 @@ var forceTrailingSlash = function(path) {
945
  * @return {Object} the new folder.
946
  */
947
  var folderAdd = function(name, createFolders) {
948
- createFolders = (typeof createFolders !== 'undefined') ? createFolders : false;
 
 
 
949
 
950
- name = forceTrailingSlash(name);
951
 
952
  // Does this folder already exist?
953
  if (!this.files[name]) {
@@ -963,10 +934,9 @@ var folderAdd = function(name, createFolders) {
963
  * Generate a JSZip.CompressedObject for a given zipOject.
964
  * @param {ZipObject} file the object to read.
965
  * @param {JSZip.compression} compression the compression to use.
966
- * @param {Object} compressionOptions the options to use when compressing.
967
  * @return {JSZip.CompressedObject} the compressed result.
968
  */
969
- var generateCompressedObjectFrom = function(file, compression, compressionOptions) {
970
  var result = new CompressedObject(),
971
  content;
972
 
@@ -986,7 +956,7 @@ var generateCompressedObjectFrom = function(file, compression, compressionOption
986
  else {
987
  content = file._data.getContent();
988
  // need to decompress / recompress
989
- result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);
990
  }
991
  }
992
  else {
@@ -998,7 +968,7 @@ var generateCompressedObjectFrom = function(file, compression, compressionOption
998
  }
999
  result.uncompressedSize = content.length;
1000
  result.crc32 = crc32(content);
1001
- result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);
1002
  }
1003
 
1004
  result.compressedSize = result.compressedContent.length;
@@ -1007,67 +977,15 @@ var generateCompressedObjectFrom = function(file, compression, compressionOption
1007
  return result;
1008
  };
1009
 
1010
-
1011
-
1012
-
1013
- /**
1014
- * Generate the UNIX part of the external file attributes.
1015
- * @param {Object} unixPermissions the unix permissions or null.
1016
- * @param {Boolean} isDir true if the entry is a directory, false otherwise.
1017
- * @return {Number} a 32 bit integer.
1018
- *
1019
- * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
1020
- *
1021
- * TTTTsstrwxrwxrwx0000000000ADVSHR
1022
- * ^^^^____________________________ file type, see zipinfo.c (UNX_*)
1023
- * ^^^_________________________ setuid, setgid, sticky
1024
- * ^^^^^^^^^________________ permissions
1025
- * ^^^^^^^^^^______ not used ?
1026
- * ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
1027
- */
1028
- var generateUnixExternalFileAttr = function (unixPermissions, isDir) {
1029
-
1030
- var result = unixPermissions;
1031
- if (!unixPermissions) {
1032
- // I can't use octal values in strict mode, hence the hexa.
1033
- // 040775 => 0x41fd
1034
- // 0100664 => 0x81b4
1035
- result = isDir ? 0x41fd : 0x81b4;
1036
- }
1037
-
1038
- return (result & 0xFFFF) << 16;
1039
- };
1040
-
1041
- /**
1042
- * Generate the DOS part of the external file attributes.
1043
- * @param {Object} dosPermissions the dos permissions or null.
1044
- * @param {Boolean} isDir true if the entry is a directory, false otherwise.
1045
- * @return {Number} a 32 bit integer.
1046
- *
1047
- * Bit 0 Read-Only
1048
- * Bit 1 Hidden
1049
- * Bit 2 System
1050
- * Bit 3 Volume Label
1051
- * Bit 4 Directory
1052
- * Bit 5 Archive
1053
- */
1054
- var generateDosExternalFileAttr = function (dosPermissions, isDir) {
1055
-
1056
- // the dir flag is already set for compatibility
1057
-
1058
- return (dosPermissions || 0) & 0x3F;
1059
- };
1060
-
1061
  /**
1062
  * Generate the various parts used in the construction of the final zip file.
1063
  * @param {string} name the file name.
1064
  * @param {ZipObject} file the file content.
1065
  * @param {JSZip.CompressedObject} compressedObject the compressed object.
1066
  * @param {number} offset the current offset from the start of the zip file.
1067
- * @param {String} platform let's pretend we are this platform (change platform dependents fields)
1068
  * @return {object} the zip parts.
1069
  */
1070
- var generateZipParts = function(name, file, compressedObject, offset, platform) {
1071
  var data = compressedObject.compressedContent,
1072
  utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
1073
  comment = file.comment || "",
@@ -1097,24 +1015,6 @@ var generateZipParts = function(name, file, compressedObject, offset, platform)
1097
  date = o.date;
1098
  }
1099
 
1100
- var extFileAttr = 0;
1101
- var versionMadeBy = 0;
1102
- if (dir) {
1103
- // dos or unix, we set the dos dir flag
1104
- extFileAttr |= 0x00010;
1105
- }
1106
- if(platform === "UNIX") {
1107
- versionMadeBy = 0x031E; // UNIX, version 3.0
1108
- extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
1109
- } else { // DOS or other, fallback to DOS
1110
- versionMadeBy = 0x0014; // DOS, version 2.0
1111
- extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
1112
- }
1113
-
1114
- // date
1115
- // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
1116
- // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
1117
- // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
1118
 
1119
  dosTime = date.getHours();
1120
  dosTime = dosTime << 6;
@@ -1203,7 +1103,7 @@ var generateZipParts = function(name, file, compressedObject, offset, platform)
1203
 
1204
  var dirRecord = signature.CENTRAL_FILE_HEADER +
1205
  // version made by (00: DOS)
1206
- decToHex(versionMadeBy, 2) +
1207
  // file header (common to file and central directory)
1208
  header +
1209
  // file comment length
@@ -1213,7 +1113,7 @@ var generateZipParts = function(name, file, compressedObject, offset, platform)
1213
  // internal file attributes TODO
1214
  "\x00\x00" +
1215
  // external file attributes
1216
- decToHex(extFileAttr, 4) +
1217
  // relative offset of local header
1218
  decToHex(offset, 4) +
1219
  // file name
@@ -1371,28 +1271,12 @@ var out = {
1371
  options = extend(options || {}, {
1372
  base64: true,
1373
  compression: "STORE",
1374
- compressionOptions : null,
1375
  type: "base64",
1376
- platform: "DOS",
1377
- comment: null,
1378
- mimeType: 'application/zip'
1379
  });
1380
 
1381
  utils.checkSupport(options.type);
1382
 
1383
- // accept nodejs `process.platform`
1384
- if(
1385
- options.platform === 'darwin' ||
1386
- options.platform === 'freebsd' ||
1387
- options.platform === 'linux' ||
1388
- options.platform === 'sunos'
1389
- ) {
1390
- options.platform = "UNIX";
1391
- }
1392
- if (options.platform === 'win32') {
1393
- options.platform = "DOS";
1394
- }
1395
-
1396
  var zipData = [],
1397
  localDirLength = 0,
1398
  centralDirLength = 0,
@@ -1411,11 +1295,10 @@ var out = {
1411
  if (!compression) {
1412
  throw new Error(compressionName + " is not a valid compression method !");
1413
  }
1414
- var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
1415
 
1416
- var compressedObject = generateCompressedObjectFrom.call(this, file, compression, compressionOptions);
1417
 
1418
- var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength, options.platform);
1419
  localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize;
1420
  centralDirLength += zipPart.dirRecord.length;
1421
  zipData.push(zipPart);
@@ -1473,7 +1356,7 @@ var out = {
1473
  case "nodebuffer" :
1474
  return utils.transformTo(options.type.toLowerCase(), zip);
1475
  case "blob" :
1476
- return utils.arrayBuffer2Blob(utils.transformTo("arraybuffer", zip), options.mimeType);
1477
  // case "zip is a string"
1478
  case "base64" :
1479
  return (options.base64) ? base64.encode(zip) : zip;
@@ -1939,14 +1822,13 @@ exports.string2binary = function(str) {
1939
  }
1940
  return result;
1941
  };
1942
- exports.arrayBuffer2Blob = function(buffer, mimeType) {
1943
  exports.checkSupport("blob");
1944
- mimeType = mimeType || 'application/zip';
1945
 
1946
  try {
1947
  // Blob constructor
1948
  return new Blob([buffer], {
1949
- type: mimeType
1950
  });
1951
  }
1952
  catch (e) {
@@ -1956,7 +1838,7 @@ exports.arrayBuffer2Blob = function(buffer, mimeType) {
1956
  var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
1957
  var builder = new Builder();
1958
  builder.append(buffer);
1959
- return builder.getBlob(mimeType);
1960
  }
1961
  catch (e) {
1962
 
@@ -2362,7 +2244,6 @@ ZipEntries.prototype = {
2362
  this.checkSignature(sig.LOCAL_FILE_HEADER);
2363
  file.readLocalPart(this.reader);
2364
  file.handleUTF8();
2365
- file.processAttributes();
2366
  }
2367
  },
2368
  /**
@@ -2386,24 +2267,7 @@ ZipEntries.prototype = {
2386
  readEndOfCentral: function() {
2387
  var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
2388
  if (offset === -1) {
2389
- // Check if the content is a truncated zip or complete garbage.
2390
- // A "LOCAL_FILE_HEADER" is not required at the beginning (auto
2391
- // extractible zip for example) but it can give a good hint.
2392
- // If an ajax request was used without responseType, we will also
2393
- // get unreadable data.
2394
- var isGarbage = true;
2395
- try {
2396
- this.reader.setIndex(0);
2397
- this.checkSignature(sig.LOCAL_FILE_HEADER);
2398
- isGarbage = false;
2399
- } catch (e) {}
2400
-
2401
- if (isGarbage) {
2402
- throw new Error("Can't find end of central directory : is this a zip file ? " +
2403
- "If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html");
2404
- } else {
2405
- throw new Error("Corrupted zip : can't find end of central directory");
2406
- }
2407
  }
2408
  this.reader.setIndex(offset);
2409
  this.checkSignature(sig.CENTRAL_DIRECTORY_END);
@@ -2479,10 +2343,6 @@ var StringReader = _dereq_('./stringReader');
2479
  var utils = _dereq_('./utils');
2480
  var CompressedObject = _dereq_('./compressedObject');
2481
  var jszipProto = _dereq_('./object');
2482
-
2483
- var MADE_BY_DOS = 0x00;
2484
- var MADE_BY_UNIX = 0x03;
2485
-
2486
  // class ZipEntry {{{
2487
  /**
2488
  * An entry in the zip file.
@@ -2609,7 +2469,7 @@ ZipEntry.prototype = {
2609
  * @param {DataReader} reader the reader to use.
2610
  */
2611
  readCentralPart: function(reader) {
2612
- this.versionMadeBy = reader.readInt(2);
2613
  this.versionNeeded = reader.readInt(2);
2614
  this.bitFlag = reader.readInt(2);
2615
  this.compressionMethod = reader.readString(2);
@@ -2633,37 +2493,10 @@ ZipEntry.prototype = {
2633
  this.readExtraFields(reader);
2634
  this.parseZIP64ExtraField(reader);
2635
  this.fileComment = reader.readString(this.fileCommentLength);
2636
- },
2637
-
2638
- /**
2639
- * Parse the external file attributes and get the unix/dos permissions.
2640
- */
2641
- processAttributes: function () {
2642
- this.unixPermissions = null;
2643
- this.dosPermissions = null;
2644
- var madeBy = this.versionMadeBy >> 8;
2645
-
2646
- // Check if we have the DOS directory flag set.
2647
- // We look for it in the DOS and UNIX permissions
2648
- // but some unknown platform could set it as a compatibility flag.
2649
- this.dir = this.externalFileAttributes & 0x0010 ? true : false;
2650
-
2651
- if(madeBy === MADE_BY_DOS) {
2652
- // first 6 bits (0 to 5)
2653
- this.dosPermissions = this.externalFileAttributes & 0x3F;
2654
- }
2655
 
2656
- if(madeBy === MADE_BY_UNIX) {
2657
- this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;
2658
- // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
2659
- }
2660
-
2661
- // fail safe : if the name ends with a / it probably means a folder
2662
- if (!this.dir && this.fileName.slice(-1) === '/') {
2663
- this.dir = true;
2664
- }
2665
  },
2666
-
2667
  /**
2668
  * Parse the ZIP64 extra field and merge the info in the current ZipEntry.
2669
  * @param {DataReader} reader the reader to use.
@@ -5727,7 +5560,7 @@ function GZheader() {
5727
  // but leave for few code modifications
5728
 
5729
  //
5730
- // Setup limits is not necessary because in js we should not preallocate memory
5731
  // for inflate use constant limit in 65536 bytes
5732
  //
5733
 
@@ -9152,4 +8985,4 @@ function ZStream() {
9152
  module.exports = ZStream;
9153
  },{}]},{},[9])
9154
  (9)
9155
- });
9
  JSZip uses the library pako released under the MIT license :
10
  https://github.com/nodeca/pako/blob/master/LICENSE
11
  */
12
+ (function(e){
13
+ if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();
14
+ else if("function"==typeof define&&define.amd){JSZip=e();define([],e);}
15
+ else{
16
+ var f;
17
+ "undefined"!=typeof window?f=window:
18
+ "undefined"!=typeof global?f=global:
19
+ "undefined"!=typeof $ && $.global?f=$.global:
20
+ "undefined"!=typeof self&&(f=self),f.JSZip=e()
21
+ }
22
+ }(function(){var define,module,exports;return (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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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})({1:[function(_dereq_,module,exports){
23
  'use strict';
24
  // private property
25
  var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
125
  'use strict';
126
  exports.STORE = {
127
  magic: "\x00\x00",
128
+ compress: function(content) {
129
  return content; // no compression
130
  },
131
  uncompress: function(content) {
357
  exports.createFolders = false;
358
  exports.date = null;
359
  exports.compression = null;
 
360
  exports.comment = null;
 
 
361
 
362
  },{}],7:[function(_dereq_,module,exports){
363
  'use strict';
475
  exports.compressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
476
 
477
  exports.magic = "\x08\x00";
478
+ exports.compress = function(input) {
479
+ return pako.deflateRaw(input);
 
 
480
  };
481
  exports.uncompress = function(input) {
482
  return pako.inflateRaw(input);
584
  date: input.date,
585
  dir: input.dir,
586
  comment : input.fileComment.length ? input.fileComment : null,
 
 
587
  createFolders: options.createFolders
588
  });
589
  }
603
  module.exports.test = function(b){
604
  return Buffer.isBuffer(b);
605
  };
 
606
  }).call(this,(typeof Buffer !== "undefined" ? Buffer : undefined))
607
  },{}],12:[function(_dereq_,module,exports){
608
  'use strict';
728
  this.dir = options.dir;
729
  this.date = options.date;
730
  this.comment = options.comment;
 
 
731
 
732
  this._data = data;
733
  this.options = options;
852
 
853
  o = prepareFileAttrs(o);
854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
  if (o.createFolders && (parent = parentFolder(name))) {
856
  folderAdd.call(this, parent, true);
857
  }
860
  o.base64 = false;
861
  o.binary = false;
862
  data = null;
 
863
  }
864
  else if (dataType === "string") {
865
  if (o.binary && !o.base64) {
904
  return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
905
  };
906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
907
  /**
908
  * Add a (sub) folder in the current folder.
909
  * @private
913
  * @return {Object} the new folder.
914
  */
915
  var folderAdd = function(name, createFolders) {
916
+ // Check the name ends with a /
917
+ if (name.slice(-1) != "/") {
918
+ name += "/"; // IE doesn't like substr(-1)
919
+ }
920
 
921
+ createFolders = (typeof createFolders !== 'undefined') ? createFolders : false;
922
 
923
  // Does this folder already exist?
924
  if (!this.files[name]) {
934
  * Generate a JSZip.CompressedObject for a given zipOject.
935
  * @param {ZipObject} file the object to read.
936
  * @param {JSZip.compression} compression the compression to use.
 
937
  * @return {JSZip.CompressedObject} the compressed result.
938
  */
939
+ var generateCompressedObjectFrom = function(file, compression) {
940
  var result = new CompressedObject(),
941
  content;
942
 
956
  else {
957
  content = file._data.getContent();
958
  // need to decompress / recompress
959
+ result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content));
960
  }
961
  }
962
  else {
968
  }
969
  result.uncompressedSize = content.length;
970
  result.crc32 = crc32(content);
971
+ result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content));
972
  }
973
 
974
  result.compressedSize = result.compressedContent.length;
977
  return result;
978
  };
979
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
980
  /**
981
  * Generate the various parts used in the construction of the final zip file.
982
  * @param {string} name the file name.
983
  * @param {ZipObject} file the file content.
984
  * @param {JSZip.CompressedObject} compressedObject the compressed object.
985
  * @param {number} offset the current offset from the start of the zip file.
 
986
  * @return {object} the zip parts.
987
  */
988
+ var generateZipParts = function(name, file, compressedObject, offset) {
989
  var data = compressedObject.compressedContent,
990
  utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
991
  comment = file.comment || "",
1015
  date = o.date;
1016
  }
1017
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1018
 
1019
  dosTime = date.getHours();
1020
  dosTime = dosTime << 6;
1103
 
1104
  var dirRecord = signature.CENTRAL_FILE_HEADER +
1105
  // version made by (00: DOS)
1106
+ "\x14\x00" +
1107
  // file header (common to file and central directory)
1108
  header +
1109
  // file comment length
1113
  // internal file attributes TODO
1114
  "\x00\x00" +
1115
  // external file attributes
1116
+ (dir === true ? "\x10\x00\x00\x00" : "\x00\x00\x00\x00") +
1117
  // relative offset of local header
1118
  decToHex(offset, 4) +
1119
  // file name
1271
  options = extend(options || {}, {
1272
  base64: true,
1273
  compression: "STORE",
 
1274
  type: "base64",
1275
+ comment: null
 
 
1276
  });
1277
 
1278
  utils.checkSupport(options.type);
1279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1280
  var zipData = [],
1281
  localDirLength = 0,
1282
  centralDirLength = 0,
1295
  if (!compression) {
1296
  throw new Error(compressionName + " is not a valid compression method !");
1297
  }
 
1298
 
1299
+ var compressedObject = generateCompressedObjectFrom.call(this, file, compression);
1300
 
1301
+ var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength);
1302
  localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize;
1303
  centralDirLength += zipPart.dirRecord.length;
1304
  zipData.push(zipPart);
1356
  case "nodebuffer" :
1357
  return utils.transformTo(options.type.toLowerCase(), zip);
1358
  case "blob" :
1359
+ return utils.arrayBuffer2Blob(utils.transformTo("arraybuffer", zip));
1360
  // case "zip is a string"
1361
  case "base64" :
1362
  return (options.base64) ? base64.encode(zip) : zip;
1822
  }
1823
  return result;
1824
  };
1825
+ exports.arrayBuffer2Blob = function(buffer) {
1826
  exports.checkSupport("blob");
 
1827
 
1828
  try {
1829
  // Blob constructor
1830
  return new Blob([buffer], {
1831
+ type: "application/zip"
1832
  });
1833
  }
1834
  catch (e) {
1838
  var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
1839
  var builder = new Builder();
1840
  builder.append(buffer);
1841
+ return builder.getBlob('application/zip');
1842
  }
1843
  catch (e) {
1844
 
2244
  this.checkSignature(sig.LOCAL_FILE_HEADER);
2245
  file.readLocalPart(this.reader);
2246
  file.handleUTF8();
 
2247
  }
2248
  },
2249
  /**
2267
  readEndOfCentral: function() {
2268
  var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
2269
  if (offset === -1) {
2270
+ throw new Error("Corrupted zip : can't find end of central directory");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2271
  }
2272
  this.reader.setIndex(offset);
2273
  this.checkSignature(sig.CENTRAL_DIRECTORY_END);
2343
  var utils = _dereq_('./utils');
2344
  var CompressedObject = _dereq_('./compressedObject');
2345
  var jszipProto = _dereq_('./object');
 
 
 
 
2346
  // class ZipEntry {{{
2347
  /**
2348
  * An entry in the zip file.
2469
  * @param {DataReader} reader the reader to use.
2470
  */
2471
  readCentralPart: function(reader) {
2472
+ this.versionMadeBy = reader.readString(2);
2473
  this.versionNeeded = reader.readInt(2);
2474
  this.bitFlag = reader.readInt(2);
2475
  this.compressionMethod = reader.readString(2);
2493
  this.readExtraFields(reader);
2494
  this.parseZIP64ExtraField(reader);
2495
  this.fileComment = reader.readString(this.fileCommentLength);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2496
 
2497
+ // warning, this is true only for zip with madeBy == DOS (plateform dependent feature)
2498
+ this.dir = this.externalFileAttributes & 0x00000010 ? true : false;
 
 
 
 
 
 
 
2499
  },
 
2500
  /**
2501
  * Parse the ZIP64 extra field and merge the info in the current ZipEntry.
2502
  * @param {DataReader} reader the reader to use.
5560
  // but leave for few code modifications
5561
 
5562
  //
5563
+ // Setup limits is not necessary because in js we should not preallocate memory
5564
  // for inflate use constant limit in 65536 bytes
5565
  //
5566
 
8985
  module.exports = ZStream;
8986
  },{}]},{},[9])
8987
  (9)
8988
+ }));
admin/js/amcharts/plugins/export/libs/jszip/jszip.min.js CHANGED
@@ -1,14 +1 @@
1
- /*!
2
-
3
- JSZip - A Javascript class for generating and reading zip files
4
- <http://stuartk.com/jszip>
5
-
6
- (c) 2009-2014 Stuart Knightley <stuart [at] stuartk.com>
7
- Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
8
-
9
- JSZip uses the library pako released under the MIT license :
10
- https://github.com/nodeca/pako/blob/master/LICENSE
11
- */
12
- !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSZip=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";c.encode=function(a){for(var b,c,e,f,g,h,i,j="",k=0;k<a.length;)b=a.charCodeAt(k++),c=a.charCodeAt(k++),e=a.charCodeAt(k++),f=b>>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)f=d.indexOf(a.charAt(k++)),g=d.indexOf(a.charAt(k++)),h=d.indexOf(a.charAt(k++)),i=d.indexOf(a.charAt(k++)),b=f<<2|g>>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":8}],4:[function(a,b){"use strict";var c=a("./utils"),d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var e="string"!==c.getTypeOf(a);"undefined"==typeof b&&(b=0);var f=0,g=0,h=0;b=-1^b;for(var i=0,j=a.length;j>i;i++)h=e?a[i]:a.charCodeAt(i),g=255&(b^h),f=d[g],b=b>>>8^f;return-1^b}},{"./utils":21}],5:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<a||0>a)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":21}],6:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!1,c.date=null,c.compression=null,c.compressionOptions=null,c.comment=null,c.unixPermissions=null,c.dosPermissions=null},{}],7:[function(a,b,c){"use strict";var d=a("./utils");c.string2binary=function(a){return d.string2binary(a)},c.string2Uint8Array=function(a){return d.transformTo("uint8array",a)},c.uint8Array2String=function(a){return d.transformTo("string",a)},c.string2Blob=function(a){var b=d.transformTo("arraybuffer",a);return d.arrayBuffer2Blob(b)},c.arrayBuffer2Blob=function(a){return d.arrayBuffer2Blob(a)},c.transformTo=function(a,b){return d.transformTo(a,b)},c.getTypeOf=function(a){return d.getTypeOf(a)},c.checkSupport=function(a){return d.checkSupport(a)},c.MAX_VALUE_16BITS=d.MAX_VALUE_16BITS,c.MAX_VALUE_32BITS=d.MAX_VALUE_32BITS,c.pretty=function(a){return d.pretty(a)},c.findCompression=function(a){return d.findCompression(a)},c.isRegExp=function(a){return d.isRegExp(a)}},{"./utils":21}],8:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("pako");c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a,b){return e.deflateRaw(a,{level:b.level||-1})},c.uncompress=function(a){return e.inflateRaw(a)}},{pako:24}],9:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.comment=null,this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}var d=a("./base64");c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./deprecatedPublicUtils"),c.base64={encode:function(a){return d.encode(a)},decode:function(a){return d.decode(a)}},c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;g<e.length;g++)h=e[g],this.file(h.fileName,h.decompressed,{binary:!0,optimizedBinaryString:!0,date:h.date,dir:h.dir,comment:h.fileComment.length?h.fileComment:null,unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions,createFolders:b.createFolders});return f.zipComment.length&&(this.comment=f.zipComment),this}},{"./base64":1,"./zipEntries":22}],11:[function(a,b){(function(a){"use strict";b.exports=function(b,c){return new a(b,c)},b.exports.test=function(b){return a.isBuffer(b)}}).call(this,"undefined"!=typeof Buffer?Buffer:void 0)},{}],12:[function(a,b){"use strict";function c(a){this.data=a,this.length=this.data.length,this.index=0}var d=a("./uint8ArrayReader");c.prototype=new d,c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./uint8ArrayReader":18}],13:[function(a,b){"use strict";var c=a("./support"),d=a("./utils"),e=a("./crc32"),f=a("./signature"),g=a("./defaults"),h=a("./base64"),i=a("./compressions"),j=a("./compressedObject"),k=a("./nodeBuffer"),l=a("./utf8"),m=a("./stringWriter"),n=a("./uint8ArrayWriter"),o=function(a){if(a._data instanceof j&&(a._data=a._data.getContent(),a.options.binary=!0,a.options.base64=!1,"uint8array"===d.getTypeOf(a._data))){var b=a._data;a._data=new Uint8Array(b.length),0!==b.length&&a._data.set(b,0)}return a._data},p=function(a){var b=o(a),e=d.getTypeOf(b);return"string"===e?!a.options.binary&&c.nodebuffer?k(b,"utf-8"):a.asBinary():b},q=function(a){var b=o(this);return null===b||"undefined"==typeof b?"":(this.options.base64&&(b=h.decode(b)),b=a&&this.options.binary?D.utf8decode(b):d.transformTo("string",b),a||this.options.binary||(b=d.transformTo("string",D.utf8encode(b))),b)},r=function(a,b,c){this.name=a,this.dir=c.dir,this.date=c.date,this.comment=c.comment,this.unixPermissions=c.unixPermissions,this.dosPermissions=c.dosPermissions,this._data=b,this.options=c,this._initialMetadata={dir:c.dir,date:c.date}};r.prototype={asText:function(){return q.call(this,!0)},asBinary:function(){return q.call(this,!1)},asNodeBuffer:function(){var a=p(this);return d.transformTo("nodebuffer",a)},asUint8Array:function(){var a=p(this);return d.transformTo("uint8array",a)},asArrayBuffer:function(){return this.asUint8Array().buffer}};var s=function(a,b){var c,d="";for(c=0;b>c;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},t=function(){var a,b,c={};for(a=0;a<arguments.length;a++)for(b in arguments[a])arguments[a].hasOwnProperty(b)&&"undefined"==typeof c[b]&&(c[b]=arguments[a][b]);return c},u=function(a){return a=a||{},a.base64!==!0||null!==a.binary&&void 0!==a.binary||(a.binary=!0),a=t(a,g),a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),a},v=function(a,b,c){var e,f=d.getTypeOf(b);if(c=u(c),"string"==typeof c.unixPermissions&&(c.unixPermissions=parseInt(c.unixPermissions,8)),c.unixPermissions&&16384&c.unixPermissions&&(c.dir=!0),c.dosPermissions&&16&c.dosPermissions&&(c.dir=!0),c.dir&&(a=x(a)),c.createFolders&&(e=w(a))&&y.call(this,e,!0),c.dir||null===b||"undefined"==typeof b)c.base64=!1,c.binary=!1,b=null,f=null;else if("string"===f)c.binary&&!c.base64&&c.optimizedBinaryString!==!0&&(b=d.string2binary(b));else{if(c.base64=!1,c.binary=!0,!(f||b instanceof j))throw new Error("The data of '"+a+"' is in an unsupported format !");"arraybuffer"===f&&(b=d.transformTo("uint8array",b))}var g=new r(a,b,c);return this.files[a]=g,g},w=function(a){"/"==a.slice(-1)&&(a=a.substring(0,a.length-1));var b=a.lastIndexOf("/");return b>0?a.substring(0,b):""},x=function(a){return"/"!=a.slice(-1)&&(a+="/"),a},y=function(a,b){return b="undefined"!=typeof b?b:!1,a=x(a),this.files[a]||v.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},z=function(a,b,c){var f,g=new j;return a._data instanceof j?(g.uncompressedSize=a._data.uncompressedSize,g.crc32=a._data.crc32,0===g.uncompressedSize||a.dir?(b=i.STORE,g.compressedContent="",g.crc32=0):a._data.compressionMethod===b.magic?g.compressedContent=a._data.getCompressedContent():(f=a._data.getContent(),g.compressedContent=b.compress(d.transformTo(b.compressInputType,f),c))):(f=p(a),(!f||0===f.length||a.dir)&&(b=i.STORE,f=""),g.uncompressedSize=f.length,g.crc32=e(f),g.compressedContent=b.compress(d.transformTo(b.compressInputType,f),c)),g.compressedSize=g.compressedContent.length,g.compressionMethod=b.magic,g},A=function(a,b){var c=a;return a||(c=b?16893:33204),(65535&c)<<16},B=function(a){return 63&(a||0)},C=function(a,b,c,g,h){var i,j,k,m,n=(c.compressedContent,d.transformTo("string",l.utf8encode(b.name))),o=b.comment||"",p=d.transformTo("string",l.utf8encode(o)),q=n.length!==b.name.length,r=p.length!==o.length,t=b.options,u="",v="",w="";k=b._initialMetadata.dir!==b.dir?b.dir:t.dir,m=b._initialMetadata.date!==b.date?b.date:t.date;var x=0,y=0;k&&(x|=16),"UNIX"===h?(y=798,x|=A(b.unixPermissions,k)):(y=20,x|=B(b.dosPermissions,k)),i=m.getHours(),i<<=6,i|=m.getMinutes(),i<<=5,i|=m.getSeconds()/2,j=m.getFullYear()-1980,j<<=4,j|=m.getMonth()+1,j<<=5,j|=m.getDate(),q&&(v=s(1,1)+s(e(n),4)+n,u+="up"+s(v.length,2)+v),r&&(w=s(1,1)+s(this.crc32(p),4)+p,u+="uc"+s(w.length,2)+w);var z="";z+="\n\x00",z+=q||r?"\x00\b":"\x00\x00",z+=c.compressionMethod,z+=s(i,2),z+=s(j,2),z+=s(c.crc32,4),z+=s(c.compressedSize,4),z+=s(c.uncompressedSize,4),z+=s(n.length,2),z+=s(u.length,2);var C=f.LOCAL_FILE_HEADER+z+n+u,D=f.CENTRAL_FILE_HEADER+s(y,2)+z+s(p.length,2)+"\x00\x00\x00\x00"+s(x,4)+s(g,4)+n+u+p;return{fileRecord:C,dirRecord:D,compressedObject:c}},D={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new r(d.name,d._data,t(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(d.isRegExp(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}return this.filter(function(b,c){return!c.dir&&b===a})[0]||null}return a=this.root+a,v.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d.isRegExp(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=y.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d<c.length;d++)delete this.files[c[d].name];return this},generate:function(a){a=t(a||{},{base64:!0,compression:"STORE",compressionOptions:null,type:"base64",platform:"DOS",comment:null,mimeType:"application/zip"}),d.checkSupport(a.type),("darwin"===a.platform||"freebsd"===a.platform||"linux"===a.platform||"sunos"===a.platform)&&(a.platform="UNIX"),"win32"===a.platform&&(a.platform="DOS");var b,c,e=[],g=0,j=0,k=d.transformTo("string",this.utf8encode(a.comment||this.comment||""));for(var l in this.files)if(this.files.hasOwnProperty(l)){var o=this.files[l],p=o.options.compression||a.compression.toUpperCase(),q=i[p];if(!q)throw new Error(p+" is not a valid compression method !");var r=o.options.compressionOptions||a.compressionOptions||{},u=z.call(this,o,q,r),v=C.call(this,l,o,u,g,a.platform);g+=v.fileRecord.length+u.compressedSize,j+=v.dirRecord.length,e.push(v)}var w="";w=f.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+s(e.length,2)+s(e.length,2)+s(j,4)+s(g,4)+s(k.length,2)+k;var x=a.type.toLowerCase();for(b="uint8array"===x||"arraybuffer"===x||"blob"===x||"nodebuffer"===x?new n(g+j+w.length):new m(g+j+w.length),c=0;c<e.length;c++)b.append(e[c].fileRecord),b.append(e[c].compressedObject.compressedContent);for(c=0;c<e.length;c++)b.append(e[c].dirRecord);b.append(w);var y=b.finalize();switch(a.type.toLowerCase()){case"uint8array":case"arraybuffer":case"nodebuffer":return d.transformTo(a.type.toLowerCase(),y);case"blob":return d.arrayBuffer2Blob(d.transformTo("arraybuffer",y),a.mimeType);case"base64":return a.base64?h.encode(y):y;default:return y}},crc32:function(a,b){return e(a,b)},utf8encode:function(a){return d.transformTo("string",l.utf8encode(a))},utf8decode:function(a){return l.utf8decode(a)}};b.exports=D},{"./base64":1,"./compressedObject":2,"./compressions":3,"./crc32":4,"./defaults":6,"./nodeBuffer":11,"./signature":14,"./stringWriter":16,"./support":17,"./uint8ArrayWriter":19,"./utf8":20,"./utils":21}],14:[function(a,b,c){"use strict";c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\b"},{}],15:[function(a,b){"use strict";function c(a,b){this.data=a,b||(this.data=e.string2binary(this.data)),this.length=this.data.length,this.index=0}var d=a("./dataReader"),e=a("./utils");c.prototype=new d,c.prototype.byteAt=function(a){return this.data.charCodeAt(a)},c.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":5,"./utils":21}],16:[function(a,b){"use strict";var c=a("./utils"),d=function(){this.data=[]};d.prototype={append:function(a){a=c.transformTo("string",a),this.data.push(a)},finalize:function(){return this.data.join("")}},b.exports=d},{"./utils":21}],17:[function(a,b,c){(function(a){"use strict";if(c.base64=!0,c.array=!0,c.string=!0,c.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c.nodebuffer="undefined"!=typeof a,c.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)c.blob=!1;else{var b=new ArrayBuffer(0);try{c.blob=0===new Blob([b],{type:"application/zip"}).size}catch(d){try{var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,f=new e;f.append(b),c.blob=0===f.getBlob("application/zip").size}catch(d){c.blob=!1}}}}).call(this,"undefined"!=typeof Buffer?Buffer:void 0)},{}],18:[function(a,b){"use strict";function c(a){a&&(this.data=a,this.length=this.data.length,this.index=0)}var d=a("./dataReader");c.prototype=new d,c.prototype.byteAt=function(a){return this.data[a]},c.prototype.lastIndexOfSignature=function(a){for(var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.length-4;f>=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":5}],19:[function(a,b){"use strict";var c=a("./utils"),d=function(a){this.data=new Uint8Array(a),this.index=0};d.prototype={append:function(a){0!==a.length&&(a=c.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}},b.exports=d},{"./utils":21}],20:[function(a,b,c){"use strict";for(var d=a("./utils"),e=a("./support"),f=a("./nodeBuffer"),g=new Array(256),h=0;256>h;h++)g[h]=h>=252?6:h>=248?5:h>=240?4:h>=224?3:h>=192?2:1;g[254]=g[254]=1;var i=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=e.uint8array?new Uint8Array(i):new Array(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},j=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+g[a[c]]>b?c:b},k=function(a){var b,c,e,f,h=a.length,i=new Array(2*h);for(c=0,b=0;h>b;)if(e=a[b++],128>e)i[c++]=e;else if(f=g[e],f>4)i[c++]=65533,b+=f-1;else{for(e&=2===f?31:3===f?15:7;f>1&&h>b;)e=e<<6|63&a[b++],f--;f>1?i[c++]=65533:65536>e?i[c++]=e:(e-=65536,i[c++]=55296|e>>10&1023,i[c++]=56320|1023&e)}return i.length!==c&&(i.subarray?i=i.subarray(0,c):i.length=c),d.applyFromCharCode(i)};c.utf8encode=function(a){return e.nodebuffer?f(a,"utf-8"):i(a)},c.utf8decode=function(a){if(e.nodebuffer)return d.transformTo("nodebuffer",a).toString("utf-8");a=d.transformTo(e.uint8array?"uint8array":"array",a);for(var b=[],c=0,f=a.length,g=65536;f>c;){var h=j(a,Math.min(c+g,f));b.push(e.uint8array?k(a.subarray(c,h)):k(a.slice(c,h))),c=h}return b.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;c<a.length;++c)b[c]=255&a.charCodeAt(c);return b}function f(a){var b=65536,d=[],e=a.length,f=c.getTypeOf(a),g=0,h=!0;try{switch(f){case"uint8array":String.fromCharCode.apply(null,new Uint8Array(0));break;case"nodebuffer":String.fromCharCode.apply(null,j(0))}}catch(i){h=!1}if(!h){for(var k="",l=0;l<a.length;l++)k+=String.fromCharCode(a[l]);return k}for(;e>g&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;c<a.length;c++)b[c]=a[c];return b}var h=a("./support"),i=a("./compressions"),j=a("./nodeBuffer");c.string2binary=function(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(255&a.charCodeAt(c));return b},c.arrayBuffer2Blob=function(a,b){c.checkSupport("blob"),b=b||"application/zip";try{return new Blob([a],{type:b})}catch(d){try{var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,f=new e;return f.append(a),f.getBlob(b)}catch(d){throw new Error("Bug : can't construct the Blob.")}}},c.applyFromCharCode=f;var k={};k.string={string:d,array:function(a){return e(a,new Array(a.length))},arraybuffer:function(a){return k.string.uint8array(a).buffer},uint8array:function(a){return e(a,new Uint8Array(a.length))},nodebuffer:function(a){return e(a,j(a.length))}},k.array={string:f,array:d,arraybuffer:function(a){return new Uint8Array(a).buffer},uint8array:function(a){return new Uint8Array(a)},nodebuffer:function(a){return j(a)}},k.arraybuffer={string:function(a){return f(new Uint8Array(a))},array:function(a){return g(new Uint8Array(a),new Array(a.byteLength))},arraybuffer:d,uint8array:function(a){return new Uint8Array(a)},nodebuffer:function(a){return j(new Uint8Array(a))}},k.uint8array={string:f,array:function(a){return g(a,new Array(a.length))},arraybuffer:function(a){return a.buffer},uint8array:d,nodebuffer:function(a){return j(a)}},k.nodebuffer={string:f,array:function(a){return g(a,new Array(a.length))},arraybuffer:function(a){return k.nodebuffer.uint8array(a).buffer},uint8array:function(a){return g(a,new Uint8Array(a.length))},nodebuffer:d},c.transformTo=function(a,b){if(b||(b=""),!a)return b;c.checkSupport(a);var d=c.getTypeOf(b),e=k[d][a](b);return e},c.getTypeOf=function(a){return"string"==typeof a?"string":"[object Array]"===Object.prototype.toString.call(a)?"array":h.nodebuffer&&j.test(a)?"nodebuffer":h.uint8array&&a instanceof Uint8Array?"uint8array":h.arraybuffer&&a instanceof ArrayBuffer?"arraybuffer":void 0},c.checkSupport=function(a){var b=h[a.toLowerCase()];if(!b)throw new Error(a+" is not supported by this browser")},c.MAX_VALUE_16BITS=65535,c.MAX_VALUE_32BITS=-1,c.pretty=function(a){var b,c,d="";for(c=0;c<(a||"").length;c++)b=a.charCodeAt(c),d+="\\x"+(16>b?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support"),k=a("./object");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength),this.zipComment=k.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a<this.files.length;a++)b=this.files[a],this.reader.setIndex(b.localHeaderOffset),this.checkSignature(h.LOCAL_FILE_HEADER),b.readLocalPart(this.reader),b.handleUTF8(),b.processAttributes()},readCentralDir:function(){var a;for(this.reader.setIndex(this.centralDirOffset);this.reader.readString(4)===h.CENTRAL_FILE_HEADER;)a=new i({zip64:this.zip64},this.loadOptions),a.readCentralPart(this.reader),this.files.push(a)},readEndOfCentral:function(){var a=this.reader.lastIndexOfSignature(h.CENTRAL_DIRECTORY_END);if(-1===a){var b=!0;try{this.reader.setIndex(0),this.checkSignature(h.LOCAL_FILE_HEADER),b=!1}catch(c){}throw new Error(b?"Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html":"Corrupted zip : can't find end of central directory")}if(this.reader.setIndex(a),this.checkSignature(h.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===g.MAX_VALUE_16BITS||this.diskWithCentralDirStart===g.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===g.MAX_VALUE_16BITS||this.centralDirRecords===g.MAX_VALUE_16BITS||this.centralDirSize===g.MAX_VALUE_32BITS||this.centralDirOffset===g.MAX_VALUE_32BITS){if(this.zip64=!0,a=this.reader.lastIndexOfSignature(h.ZIP64_CENTRAL_DIRECTORY_LOCATOR),-1===a)throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");this.reader.setIndex(a),this.checkSignature(h.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(h.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}},prepareReader:function(a){var b=g.getTypeOf(a);this.reader="string"!==b||j.uint8array?"nodebuffer"===b?new e(a):new f(g.transformTo("uint8array",a)):new d(a,this.loadOptions.optimizedBinaryString)},load:function(a){this.prepareReader(a),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},b.exports=c},{"./nodeBufferReader":12,"./object":13,"./signature":14,"./stringReader":15,"./support":17,"./uint8ArrayReader":18,"./utils":21,"./zipEntry":23}],23:[function(a,b){"use strict";function c(a,b){this.options=a,this.loadOptions=b}var d=a("./stringReader"),e=a("./utils"),f=a("./compressedObject"),g=a("./object"),h=0,i=3;c.prototype={isEncrypted:function(){return 1===(1&this.bitFlag)},useUTF8:function(){return 2048===(2048&this.bitFlag)},prepareCompressedContent:function(a,b,c){return function(){var d=a.index;a.setIndex(b);var e=a.readData(c);return a.setIndex(d),e}},prepareContent:function(a,b,c,d,f){return function(){var a=e.transformTo(d.uncompressInputType,this.getCompressedContent()),b=d.uncompress(a);if(b.length!==f)throw new Error("Bug : uncompressed data size mismatch");return b}},readLocalPart:function(a){var b,c;if(a.skip(22),this.fileNameLength=a.readInt(2),c=a.readInt(2),this.fileName=a.readString(this.fileNameLength),a.skip(c),-1==this.compressedSize||-1==this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory (compressedSize == -1 || uncompressedSize == -1)");if(b=e.findCompression(this.compressionMethod),null===b)throw new Error("Corrupted zip : compression "+e.pretty(this.compressionMethod)+" unknown (inner file : "+this.fileName+")");if(this.decompressed=new f,this.decompressed.compressedSize=this.compressedSize,this.decompressed.uncompressedSize=this.uncompressedSize,this.decompressed.crc32=this.crc32,this.decompressed.compressionMethod=this.compressionMethod,this.decompressed.getCompressedContent=this.prepareCompressedContent(a,a.index,this.compressedSize,b),this.decompressed.getContent=this.prepareContent(a,a.index,this.compressedSize,b,this.uncompressedSize),this.loadOptions.checkCRC32&&(this.decompressed=e.transformTo("string",this.decompressed.getContent()),g.crc32(this.decompressed)!==this.crc32))throw new Error("Corrupted zip : CRC32 mismatch")},readCentralPart:function(a){if(this.versionMadeBy=a.readInt(2),this.versionNeeded=a.readInt(2),this.bitFlag=a.readInt(2),this.compressionMethod=a.readString(2),this.date=a.readDate(),this.crc32=a.readInt(4),this.compressedSize=a.readInt(4),this.uncompressedSize=a.readInt(4),this.fileNameLength=a.readInt(2),this.extraFieldsLength=a.readInt(2),this.fileCommentLength=a.readInt(2),this.diskNumberStart=a.readInt(2),this.internalFileAttributes=a.readInt(2),this.externalFileAttributes=a.readInt(4),this.localHeaderOffset=a.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");this.fileName=a.readString(this.fileNameLength),this.readExtraFields(a),this.parseZIP64ExtraField(a),this.fileComment=a.readString(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var a=this.versionMadeBy>>8;this.dir=16&this.externalFileAttributes?!0:!1,a===h&&(this.dosPermissions=63&this.externalFileAttributes),a===i&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileName.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var a=new d(this.extraFields[1].value);this.uncompressedSize===e.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===e.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===e.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===e.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(a){var b,c,d,e=a.index;for(this.extraFields=this.extraFields||{};a.index<e+this.extraFieldsLength;)b=a.readInt(2),c=a.readInt(2),d=a.readString(c),this.extraFields[b]={id:b,length:c,value:d}},handleUTF8:function(){if(this.useUTF8())this.fileName=g.utf8decode(this.fileName),this.fileComment=g.utf8decode(this.fileComment);else{var a=this.findExtraFieldUnicodePath();null!==a&&(this.fileName=a);var b=this.findExtraFieldUnicodeComment();null!==b&&(this.fileComment=b)}},findExtraFieldUnicodePath:function(){var a=this.extraFields[28789];if(a){var b=new d(a.value);return 1!==b.readInt(1)?null:g.crc32(this.fileName)!==b.readInt(4)?null:g.utf8decode(b.readString(a.length-5))
13
- }return null},findExtraFieldUnicodeComment:function(){var a=this.extraFields[25461];if(a){var b=new d(a.value);return 1!==b.readInt(1)?null:g.crc32(this.fileComment)!==b.readInt(4)?null:g.utf8decode(b.readString(a.length-5))}return null}},b.exports=c},{"./compressedObject":2,"./object":13,"./stringReader":15,"./utils":21}],24:[function(a,b){"use strict";var c=a("./lib/utils/common").assign,d=a("./lib/deflate"),e=a("./lib/inflate"),f=a("./lib/zlib/constants"),g={};c(g,d,e,f),b.exports=g},{"./lib/deflate":25,"./lib/inflate":26,"./lib/utils/common":27,"./lib/zlib/constants":30}],25:[function(a,b,c){"use strict";function d(a,b){var c=new s(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}function f(a,b){return b=b||{},b.gzip=!0,d(a,b)}var g=a("./zlib/deflate.js"),h=a("./utils/common"),i=a("./utils/strings"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=0,m=4,n=0,o=1,p=-1,q=0,r=8,s=function(a){this.options=h.assign({level:p,method:r,chunkSize:16384,windowBits:15,memLevel:8,strategy:q,to:""},a||{});var b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=g.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==n)throw new Error(j[c]);b.header&&g.deflateSetHeader(this.strm,b.header)};s.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?m:l,e.input="string"==typeof a?i.string2buf(a):a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new h.Buf8(f),e.next_out=0,e.avail_out=f),c=g.deflate(e,d),c!==o&&c!==n)return this.onEnd(c),this.ended=!0,!1;(0===e.avail_out||0===e.avail_in&&d===m)&&this.onData("string"===this.options.to?i.buf2binstring(h.shrinkBuf(e.output,e.next_out)):h.shrinkBuf(e.output,e.next_out))}while((e.avail_in>0||0===e.avail_out)&&c!==o);return d===m?(c=g.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===n):!0},s.prototype.onData=function(a){this.chunks.push(a)},s.prototype.onEnd=function(a){a===n&&(this.result="string"===this.options.to?this.chunks.join(""):h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=s,c.deflate=d,c.deflateRaw=e,c.gzip=f},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(a,b,c){"use strict";function d(a,b){var c=new m(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};m.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,m=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,l.input="string"==typeof a?h.binstring2buf(a):a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(m),l.next_out=0,l.avail_out=m),c=f.inflate(l,i.Z_NO_FLUSH),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&d===i.Z_FINISH)&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=m-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out)))}while(l.avail_in>0&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):!0},m.prototype.onData=function(a){this.chunks.push(a)},m.prototype.onEnd=function(a){a===i.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=m,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],28:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":27}],29:[function(a,b){"use strict";function c(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=c},{}],30:[function(a,b){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(a,b){"use strict";function c(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function d(a,b,c,d){var f=e,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^f[255&(a^b[h])];return-1^a}var e=c();b.exports=d},{}],32:[function(a,b,c){"use strict";function d(a,b){return a.msg=G[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(C.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){D._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,C.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=E(a.adler,b,e,c):2===a.state.wrap&&(a.adler=F(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-jb?a.strstart-(a.w_size-jb):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ib,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&m>f);if(d=ib-(m-f),f=m-ib,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-jb)){C.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=hb)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<<a.hash_shift^a.window[f+1])&a.hash_mask;a.insert&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[f+hb-1])&a.hash_mask,a.prev[f&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=f,f++,a.insert--,!(a.lookahead+a.insert<hb)););}while(a.lookahead<jb&&0!==a.strm.avail_in)}function n(a,b){var c=65535;for(c>a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===H)return sb;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return sb;if(a.strstart-a.block_start>=a.w_size-jb&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?sb:sb}function o(a,b){for(var c,d;;){if(a.lookahead<jb){if(m(a),a.lookahead<jb&&b===H)return sb;if(0===a.lookahead)break}if(c=0,a.lookahead>=hb&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+hb-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),0!==c&&a.strstart-c<=a.w_size-jb&&(a.match_length=l(a,c)),a.match_length>=hb)if(d=D._tr_tally(a,a.strstart-a.match_start,a.match_length-hb),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=hb){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+hb-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart;while(0!==--a.match_length);a.strstart++}else a.strstart+=a.match_length,a.match_length=0,a.ins_h=a.window[a.strstart],a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+1])&a.hash_mask;else d=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++;if(d&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=a.strstart<hb-1?a.strstart:hb-1,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function p(a,b){for(var c,d,e;;){if(a.lookahead<jb){if(m(a),a.lookahead<jb&&b===H)return sb;if(0===a.lookahead)break}if(c=0,a.lookahead>=hb&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+hb-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),a.prev_length=a.match_length,a.prev_match=a.match_start,a.match_length=hb-1,0!==c&&a.prev_length<a.max_lazy_match&&a.strstart-c<=a.w_size-jb&&(a.match_length=l(a,c),a.match_length<=5&&(a.strategy===S||a.match_length===hb&&a.strstart-a.match_start>4096)&&(a.match_length=hb-1)),a.prev_length>=hb&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-hb,d=D._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-hb),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+hb-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart);while(0!==--a.prev_length);if(a.match_available=0,a.match_length=hb-1,a.strstart++,d&&(h(a,!1),0===a.strm.avail_out))return sb}else if(a.match_available){if(d=D._tr_tally(a,0,a.window[a.strstart-1]),d&&h(a,!1),a.strstart++,a.lookahead--,0===a.strm.avail_out)return sb}else a.match_available=1,a.strstart++,a.lookahead--}return a.match_available&&(d=D._tr_tally(a,0,a.window[a.strstart-1]),a.match_available=0),a.insert=a.strstart<hb-1?a.strstart:hb-1,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function q(a,b){for(var c,d,e,f,g=a.window;;){if(a.lookahead<=ib){if(m(a),a.lookahead<=ib&&b===H)return sb;if(0===a.lookahead)break}if(a.match_length=0,a.lookahead>=hb&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ib;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&f>e);a.match_length=ib-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=hb?(c=D._tr_tally(a,1,a.match_length-hb),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===H)return sb;break}if(a.match_length=0,c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function s(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=B[a.level].max_lazy,a.good_match=B[a.level].good_length,a.nice_match=B[a.level].nice_length,a.max_chain_length=B[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=hb-1,a.match_available=0,a.ins_h=0}function t(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(2*fb),this.dyn_dtree=new C.Buf16(2*(2*db+1)),this.bl_tree=new C.Buf16(2*(2*eb+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(gb+1),this.heap=new C.Buf16(2*cb+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*cb+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function u(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=X,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?lb:qb,a.adler=2===b.wrap?0:1,b.last_flush=H,D._tr_init(b),M):d(a,O)}function v(a){var b=u(a);return b===M&&s(a.state),b}function w(a,b){return a&&a.state?2!==a.state.wrap?O:(a.state.gzhead=b,M):O}function x(a,b,c,e,f,g){if(!a)return O;var h=1;if(b===R&&(b=6),0>e?(h=0,e=-e):e>15&&(h=2,e-=16),1>f||f>Z||c!==Y||8>e||e>15||0>b||b>9||0>g||g>V)return d(a,O);8===e&&(e=9);var i=new t;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<<i.w_bits,i.w_mask=i.w_size-1,i.hash_bits=f+7,i.hash_size=1<<i.hash_bits,i.hash_mask=i.hash_size-1,i.hash_shift=~~((i.hash_bits+hb-1)/hb),i.window=new C.Buf8(2*i.w_size),i.head=new C.Buf16(i.hash_size),i.prev=new C.Buf16(i.w_size),i.lit_bufsize=1<<f+6,i.pending_buf_size=4*i.lit_bufsize,i.pending_buf=new C.Buf8(i.pending_buf_size),i.d_buf=i.lit_bufsize>>1,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,v(a)}function y(a,b){return x(a,b,Y,$,_,W)}function z(a,b){var c,h,k,l;if(!a||!a.state||b>L||0>b)return a?d(a,O):O;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===rb&&b!==K)return d(a,0===a.avail_out?Q:O);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===lb)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=F(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=mb):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,wb),h.status=qb);else{var m=Y+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=T||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=kb),m+=31-m%31,h.status=qb,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===mb)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=nb)}else h.status=nb;if(h.status===nb)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindex<h.gzhead.name.length?255&h.gzhead.name.charCodeAt(h.gzindex++):0,i(h,l)}while(0!==l);h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=ob)}else h.status=ob;if(h.status===ob)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindex<h.gzhead.comment.length?255&h.gzhead.comment.charCodeAt(h.gzindex++):0,i(h,l)}while(0!==l);h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=pb)}else h.status=pb;if(h.status===pb&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=qb)):h.status=qb),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,M}else if(0===a.avail_in&&e(b)<=e(c)&&b!==K)return d(a,Q);if(h.status===rb&&0!==a.avail_in)return d(a,Q);if(0!==a.avail_in||0!==h.lookahead||b!==H&&h.status!==rb){var o=h.strategy===T?r(h,b):h.strategy===U?q(h,b):B[h.level].func(h,b);if((o===ub||o===vb)&&(h.status=rb),o===sb||o===ub)return 0===a.avail_out&&(h.last_flush=-1),M;if(o===tb&&(b===I?D._tr_align(h):b!==L&&(D._tr_stored_block(h,0,0,!1),b===J&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,M}return b!==K?M:h.wrap<=0?N:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?M:N)}function A(a){var b;return a&&a.state?(b=a.state.status,b!==lb&&b!==mb&&b!==nb&&b!==ob&&b!==pb&&b!==qb&&b!==rb?d(a,O):(a.state=null,b===qb?d(a,P):M)):O}var B,C=a("../utils/common"),D=a("./trees"),E=a("./adler32"),F=a("./crc32"),G=a("./messages"),H=0,I=1,J=3,K=4,L=5,M=0,N=1,O=-2,P=-3,Q=-5,R=-1,S=1,T=2,U=3,V=4,W=0,X=2,Y=8,Z=9,$=15,_=8,ab=29,bb=256,cb=bb+1+ab,db=30,eb=19,fb=2*cb+1,gb=15,hb=3,ib=258,jb=ib+hb+1,kb=32,lb=42,mb=69,nb=73,ob=91,pb=103,qb=113,rb=666,sb=1,tb=2,ub=3,vb=4,wb=3,xb=function(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e};B=[new xb(0,0,0,0,n),new xb(4,4,8,4,o),new xb(4,5,16,8,o),new xb(4,6,32,32,o),new xb(4,4,16,16,p),new xb(8,16,32,32,p),new xb(8,16,128,128,p),new xb(8,32,128,256,p),new xb(32,128,258,1024,p),new xb(32,258,258,4096,p)],c.deflateInit=y,c.deflateInit2=x,c.deflateReset=v,c.deflateResetKeep=u,c.deflateSetHeader=w,c.deflate=z,c.deflateEnd=A,c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(a,b){"use strict";function c(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=c},{}],34:[function(a,b){"use strict";var c=30,d=12;b.exports=function(a,b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;e=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=e.dmax,l=e.wsize,m=e.whave,n=e.wnext,o=e.window,p=e.hold,q=e.bits,r=e.lencode,s=e.distcode,t=(1<<e.lenbits)-1,u=(1<<e.distbits)-1;a:do{15>q&&(p+=B[f++]<<q,q+=8,p+=B[f++]<<q,q+=8),v=r[p&t];b:for(;;){if(w=v>>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<<w)-1)];continue b}if(32&w){e.mode=d;break a}a.msg="invalid literal/length code",e.mode=c;break a}x=65535&v,w&=15,w&&(w>q&&(p+=B[f++]<<q,q+=8),x+=p&(1<<w)-1,p>>>=w,q-=w),15>q&&(p+=B[f++]<<q,q+=8,p+=B[f++]<<q,q+=8),v=s[p&u];c:for(;;){if(w=v>>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<<w)-1)];continue c}a.msg="invalid distance code",e.mode=c;break a}if(y=65535&v,w&=15,w>q&&(p+=B[f++]<<q,q+=8,w>q&&(p+=B[f++]<<q,q+=8)),y+=p&(1<<w)-1,y>k){a.msg="invalid distance too far back",e.mode=c;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&e.sane){a.msg="invalid distance too far back",e.mode=c;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<<q)-1,a.next_in=f,a.next_out=h,a.avail_in=g>f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),e.hold=p,e.bits=q}},{}],35:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(ob),b.distcode=b.distdyn=new r.Buf32(pb),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,rb)}function k(a){if(sb){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sb=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<<f.wbits,f.wnext=0,f.whave=0,f.window=new r.Buf8(f.wsize)),d>=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whave<f.wsize&&(f.whave+=e))),0}function m(a,b){var c,e,f,g,h,i,j,m,n,o,p,q,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,yb,zb,Ab=0,Bb=new r.Buf8(4),Cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!a||!a.state||!a.output||!a.input&&0!==a.avail_in)return F;c=a.state,c.mode===V&&(c.mode=W),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,o=i,p=j,xb=C;a:for(;;)switch(c.mode){case K:if(0===c.wrap){c.mode=W;break}for(;16>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(2&c.wrap&&35615===m){c.check=0,Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=lb;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=lb;break}if(m>>>=4,n-=4,wb=(15&m)+8,0===c.wbits)c.wbits=wb;else if(wb>c.wbits){a.msg="invalid window size",c.mode=lb;break}c.dmax=1<<wb,a.adler=c.check=1,c.mode=512&m?T:V,m=0,n=0;break;case L:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(c.flags=m,(255&c.flags)!==J){a.msg="unknown compression method",c.mode=lb;break}if(57344&c.flags){a.msg="unknown header flags set",c.mode=lb;break}c.head&&(c.head.text=m>>8&1),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.head&&(c.head.time=m),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,Bb[2]=m>>>16&255,Bb[3]=m>>>24&255,c.check=t(c.check,Bb,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.head&&(c.head.xflags=255&m,c.head.os=m>>8),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.length=m,c.head&&(c.head.extra_len=m),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wb=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wb)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.name+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.comment+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(m!==(65535&c.check)){a.msg="header crc mismatch",c.mode=lb;break}m=0,n=0}c.head&&(c.head.hcrc=c.flags>>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}a.adler=c.check=d(m),m=0,n=0,c.mode=U;case U:if(0===c.havedict)return a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,E;a.adler=c.check=1,c.mode=V;case V:if(b===A||b===B)break a;case W:if(c.last){m>>>=7&n,n-=7&n,c.mode=ib;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}switch(c.last=1&m,m>>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=bb,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=lb}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if((65535&m)!==(m>>>16^65535)){a.msg="invalid stored block lengths",c.mode=lb;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(c.nlen=(31&m)+257,m>>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=lb;break}c.have=0,c.mode=_;case _:for(;c.have<c.ncode;){for(;3>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.lens[Cb[c.have++]]=7&m,m>>>=3,n-=3}for(;c.have<19;)c.lens[Cb[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,yb={bits:c.lenbits},xb=v(w,c.lens,0,19,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid code lengths set",c.mode=lb;break}c.have=0,c.mode=ab;case ab:for(;c.have<c.nlen+c.ndist;){for(;Ab=c.lencode[m&(1<<c.lenbits)-1],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(16>sb)m>>>=qb,n-=qb,c.lens[c.have++]=sb;else{if(16===sb){for(zb=qb+2;zb>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(m>>>=qb,n-=qb,0===c.have){a.msg="invalid bit length repeat",c.mode=lb;break}wb=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sb){for(zb=qb+3;zb>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=qb,n-=qb,wb=0,q=3+(7&m),m>>>=3,n-=3}else{for(zb=qb+7;zb>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=qb,n-=qb,wb=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=lb;break}for(;q--;)c.lens[c.have++]=wb}}if(c.mode===lb)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=lb;break}if(c.lenbits=9,yb={bits:c.lenbits},xb=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid literal/lengths set",c.mode=lb;break}if(c.distbits=6,c.distcode=c.distdyn,yb={bits:c.distbits},xb=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,yb),c.distbits=yb.bits,xb){a.msg="invalid distances set",c.mode=lb;break}if(c.mode=bb,b===B)break a;case bb:c.mode=cb;case cb:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1);
14
- break}for(c.back=0;Ab=c.lencode[m&(1<<c.lenbits)-1],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(rb&&0===(240&rb)){for(tb=qb,ub=rb,vb=sb;Ab=c.lencode[vb+((m&(1<<tb+ub)-1)>>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,c.length=sb,0===rb){c.mode=hb;break}if(32&rb){c.back=-1,c.mode=V;break}if(64&rb){a.msg="invalid literal/length code",c.mode=lb;break}c.extra=15&rb,c.mode=db;case db:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.length+=m&(1<<c.extra)-1,m>>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=eb;case eb:for(;Ab=c.distcode[m&(1<<c.distbits)-1],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(0===(240&rb)){for(tb=qb,ub=rb,vb=sb;Ab=c.distcode[vb+((m&(1<<tb+ub)-1)>>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,64&rb){a.msg="invalid distance code",c.mode=lb;break}c.offset=sb,c.extra=15&rb,c.mode=fb;case fb:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.offset+=m&(1<<c.extra)-1,m>>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=lb;break}c.mode=gb;case gb:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=lb;break}q>c.wnext?(q-=c.wnext,ob=c.wsize-q):ob=c.wnext-q,q>c.length&&(q=c.length),pb=c.window}else pb=f,ob=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pb[ob++];while(--q);0===c.length&&(c.mode=cb);break;case hb:if(0===j)break a;f[h++]=c.length,j--,c.mode=cb;break;case ib:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<<n,n+=8}if(p-=j,a.total_out+=p,c.total+=p,p&&(a.adler=c.check=c.flags?t(c.check,f,p,h-p):s(c.check,f,p,h-p)),p=j,(c.flags?m:d(m))!==c.check){a.msg="incorrect data check",c.mode=lb;break}m=0,n=0}c.mode=jb;case jb:if(c.wrap&&c.flags){for(;32>n;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(m!==(4294967295&c.total)){a.msg="incorrect length check",c.mode=lb;break}m=0,n=0}c.mode=kb;case kb:xb=D;break a;case lb:xb=G;break a;case mb:return H;case nb:default:return F}return a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,(c.wsize||p!==a.avail_out&&c.mode<lb&&(c.mode<ib||b!==z))&&l(a,a.output,a.next_out,p-a.avail_out)?(c.mode=mb,H):(o-=a.avail_in,p-=a.avail_out,a.total_in+=o,a.total_out+=p,c.total+=p,c.wrap&&p&&(a.adler=c.check=c.flags?t(c.check,f,p,a.next_out-p):s(c.check,f,p,a.next_out-p)),a.data_type=c.bits+(c.last?64:0)+(c.mode===V?128:0)+(c.mode===bb||c.mode===Y?256:0),(0===o&&0===p||b===z)&&xb===C&&(xb=I),xb)}function n(a){if(!a||!a.state)return F;var b=a.state;return b.window&&(b.window=null),a.state=null,C}function o(a,b){var c;return a&&a.state?(c=a.state,0===(2&c.wrap)?F:(c.head=b,b.done=!1,C)):F}var p,q,r=a("../utils/common"),s=a("./adler32"),t=a("./crc32"),u=a("./inffast"),v=a("./inftrees"),w=0,x=1,y=2,z=4,A=5,B=6,C=0,D=1,E=2,F=-2,G=-3,H=-4,I=-5,J=8,K=1,L=2,M=3,N=4,O=5,P=6,Q=7,R=8,S=9,T=10,U=11,V=12,W=13,X=14,Y=15,Z=16,$=17,_=18,ab=19,bb=20,cb=21,db=22,eb=23,fb=24,gb=25,hb=26,ib=27,jb=28,kb=29,lb=30,mb=31,nb=32,ob=852,pb=592,qb=15,rb=qb,sb=!0;c.inflateReset=g,c.inflateReset2=h,c.inflateResetKeep=f,c.inflateInit=j,c.inflateInit2=i,c.inflate=m,c.inflateEnd=n,c.inflateGetHeader=o,c.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./inffast":34,"./inftrees":36}],36:[function(a,b){"use strict";var c=a("../utils/common"),d=15,e=852,f=592,g=0,h=1,i=2,j=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],k=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],m=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];b.exports=function(a,b,n,o,p,q,r,s){var t,u,v,w,x,y,z,A,B,C=s.bits,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=null,O=0,P=new c.Buf16(d+1),Q=new c.Buf16(d+1),R=null,S=0;for(D=0;d>=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[n+E]]++;for(H=C,G=d;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;d>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===g||1!==G))return-1;for(Q[1]=0,D=1;d>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[n+E]&&(r[Q[b[n+E]]++]=E);if(a===g?(N=R=r,y=19):a===h?(N=j,O-=257,R=k,S-=257,y=256):(N=l,R=m,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<<H,w=L-1,a===h&&L>e||a===i&&L>f)return 1;for(var T=0;;){T++,z=D-J,r[E]<y?(A=0,B=r[E]):r[E]>y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<<D-J,u=1<<I,F=u;do u-=t,p[x+(M>>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<<D-1;M&t;)t>>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[n+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<<I;G>I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<<I,a===h&&L>e||a===i&&L>f)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":27}],37:[function(a,b){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a){return 256>a?gb[a]:gb[256+(a>>>7)]}function f(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function g(a,b,c){a.bi_valid>V-c?(a.bi_buf|=b<<a.bi_valid&65535,f(a,a.bi_buf),a.bi_buf=b>>V-a.bi_valid,a.bi_valid+=c-V):(a.bi_buf|=b<<a.bi_valid&65535,a.bi_valid+=c)}function h(a,b,c){g(a,c[2*b],c[2*b+1])}function i(a,b){var c=0;do c|=1&a,a>>>=1,c<<=1;while(--b>0);return c>>>1}function j(a){16===a.bi_valid?(f(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function k(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;U>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;T>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function l(a,b,c){var d,e,f=new Array(U+1),g=0;for(d=1;U>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=i(f[h]++,h))}}function m(){var a,b,c,d,e,f=new Array(U+1);for(c=0,d=0;O-1>d;d++)for(ib[d]=c,a=0;a<1<<_[d];a++)hb[c++]=d;for(hb[c-1]=d,e=0,d=0;16>d;d++)for(jb[d]=e,a=0;a<1<<ab[d];a++)gb[e++]=d;for(e>>=7;R>d;d++)for(jb[d]=e<<7,a=0;a<1<<ab[d]-7;a++)gb[256+e++]=d;for(b=0;U>=b;b++)f[b]=0;for(a=0;143>=a;)eb[2*a+1]=8,a++,f[8]++;for(;255>=a;)eb[2*a+1]=9,a++,f[9]++;for(;279>=a;)eb[2*a+1]=7,a++,f[7]++;for(;287>=a;)eb[2*a+1]=8,a++,f[8]++;for(l(eb,Q+1,f),a=0;R>a;a++)fb[2*a+1]=5,fb[2*a]=i(a,5);kb=new nb(eb,_,P+1,Q,U),lb=new nb(fb,ab,0,R,U),mb=new nb(new Array(0),bb,0,S,W)}function n(a){var b;for(b=0;Q>b;b++)a.dyn_ltree[2*b]=0;for(b=0;R>b;b++)a.dyn_dtree[2*b]=0;for(b=0;S>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*X]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function o(a){a.bi_valid>8?f(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function p(a,b,c,d){o(a),d&&(f(a,c),f(a,~c)),E.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function q(a,b,c,d){var e=2*b,f=2*c;return a[e]<a[f]||a[e]===a[f]&&d[b]<=d[c]}function r(a,b,c){for(var d=a.heap[c],e=c<<1;e<=a.heap_len&&(e<a.heap_len&&q(b,a.heap[e+1],a.heap[e],a.depth)&&e++,!q(b,d,a.heap[e],a.depth));)a.heap[c]=a.heap[e],c=e,e<<=1;a.heap[c]=d}function s(a,b,c){var d,f,i,j,k=0;if(0!==a.last_lit)do d=a.pending_buf[a.d_buf+2*k]<<8|a.pending_buf[a.d_buf+2*k+1],f=a.pending_buf[a.l_buf+k],k++,0===d?h(a,f,b):(i=hb[f],h(a,i+P+1,b),j=_[i],0!==j&&(f-=ib[i],g(a,f,j)),d--,i=e(d),h(a,i,c),j=ab[i],0!==j&&(d-=jb[i],g(a,d,j)));while(k<a.last_lit);h(a,X,b)}function t(a,b){var c,d,e,f=b.dyn_tree,g=b.stat_desc.static_tree,h=b.stat_desc.has_stree,i=b.stat_desc.elems,j=-1;for(a.heap_len=0,a.heap_max=T,c=0;i>c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)r(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],r(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,r(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],k(a,b),l(f,j,a.bl_count)}function u(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1],++h<i&&e===g||(j>h?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*Y]++):10>=h?a.bl_tree[2*Z]++:a.bl_tree[2*$]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function v(a,b,c){var d,e,f=-1,i=b[1],j=0,k=7,l=4;for(0===i&&(k=138,l=3),d=0;c>=d;d++)if(e=i,i=b[2*(d+1)+1],!(++j<k&&e===i)){if(l>j){do h(a,e,a.bl_tree);while(0!==--j)}else 0!==e?(e!==f&&(h(a,e,a.bl_tree),j--),h(a,Y,a.bl_tree),g(a,j-3,2)):10>=j?(h(a,Z,a.bl_tree),g(a,j-3,3)):(h(a,$,a.bl_tree),g(a,j-11,7));j=0,f=e,0===i?(k=138,l=3):e===i?(k=6,l=3):(k=7,l=4)}}function w(a){var b;for(u(a,a.dyn_ltree,a.l_desc.max_code),u(a,a.dyn_dtree,a.d_desc.max_code),t(a,a.bl_desc),b=S-1;b>=3&&0===a.bl_tree[2*cb[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function x(a,b,c,d){var e;for(g(a,b-257,5),g(a,c-1,5),g(a,d-4,4),e=0;d>e;e++)g(a,a.bl_tree[2*cb[e]+1],3);v(a,a.dyn_ltree,b-1),v(a,a.dyn_dtree,c-1)}function y(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return G;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return H;for(b=32;P>b;b++)if(0!==a.dyn_ltree[2*b])return H;return G}function z(a){pb||(m(),pb=!0),a.l_desc=new ob(a.dyn_ltree,kb),a.d_desc=new ob(a.dyn_dtree,lb),a.bl_desc=new ob(a.bl_tree,mb),a.bi_buf=0,a.bi_valid=0,n(a)}function A(a,b,c,d){g(a,(J<<1)+(d?1:0),3),p(a,b,c,!0)}function B(a){g(a,K<<1,3),h(a,X,eb),j(a)}function C(a,b,c,d){var e,f,h=0;a.level>0?(a.strm.data_type===I&&(a.strm.data_type=y(a)),t(a,a.l_desc),t(a,a.d_desc),h=w(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?A(a,b,c,d):a.strategy===F||f===e?(g(a,(K<<1)+(d?1:0),3),s(a,eb,fb)):(g(a,(L<<1)+(d?1:0),3),x(a,a.l_desc.max_code+1,a.d_desc.max_code+1,h+1),s(a,a.dyn_ltree,a.dyn_dtree)),n(a),d&&o(a)}function D(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(hb[c]+P+1)]++,a.dyn_dtree[2*e(b)]++),a.last_lit===a.lit_bufsize-1}var E=a("../utils/common"),F=4,G=0,H=1,I=2,J=0,K=1,L=2,M=3,N=258,O=29,P=256,Q=P+1+O,R=30,S=19,T=2*Q+1,U=15,V=16,W=7,X=256,Y=16,Z=17,$=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ab=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],db=512,eb=new Array(2*(Q+2));d(eb);var fb=new Array(2*R);d(fb);var gb=new Array(db);d(gb);var hb=new Array(N-M+1);d(hb);var ib=new Array(O);d(ib);var jb=new Array(R);d(jb);var kb,lb,mb,nb=function(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length},ob=function(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b},pb=!1;c._tr_init=z,c._tr_stored_block=A,c._tr_flush_block=C,c._tr_tally=D,c._tr_align=B},{"../utils/common":27}],39:[function(a,b){"use strict";function c(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=c},{}]},{},[9])(9)});
1
+ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)JSZip=t(),define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof $&&$.global?e=$.global:"undefined"!=typeof self&&(e=self),e.JSZip=t()}}(function(){return function t(e,r,n){function i(s,o){if(!r[s]){if(!e[s]){var d="function"==typeof require&&require;if(!o&&d)return d(s,!0);if(a)return a(s,!0);throw new Error("Cannot find module '"+s+"'")}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return i(r||t)},h,h.exports,t,e,r,n)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){"use strict";var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(t,e){for(var r,i,a,s,o,d,h,l="",f=0;f<t.length;)s=(r=t.charCodeAt(f++))>>2,o=(3&r)<<4|(i=t.charCodeAt(f++))>>4,d=(15&i)<<2|(a=t.charCodeAt(f++))>>6,h=63&a,isNaN(i)?d=h=64:isNaN(a)&&(h=64),l=l+n.charAt(s)+n.charAt(o)+n.charAt(d)+n.charAt(h);return l},r.decode=function(t,e){var r,i,a,s,o,d,h="",l=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<t.length;)r=n.indexOf(t.charAt(l++))<<2|(s=n.indexOf(t.charAt(l++)))>>4,i=(15&s)<<4|(o=n.indexOf(t.charAt(l++)))>>2,a=(3&o)<<6|(d=n.indexOf(t.charAt(l++))),h+=String.fromCharCode(r),64!=o&&(h+=String.fromCharCode(i)),64!=d&&(h+=String.fromCharCode(a));return h}},{}],2:[function(t,e,r){"use strict";function n(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}n.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},e.exports=n},{}],3:[function(t,e,r){"use strict";r.STORE={magic:"\0\0",compress:function(t){return t},uncompress:function(t){return t},compressInputType:null,uncompressInputType:null},r.DEFLATE=t("./flate")},{"./flate":8}],4:[function(t,e,r){"use strict";var n=t("./utils"),i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];e.exports=function(t,e){if(void 0===t||!t.length)return 0;var r="string"!==n.getTypeOf(t);void 0===e&&(e=0);var a=0;e^=-1;for(var s=0,o=t.length;s<o;s++)a=r?t[s]:t.charCodeAt(s),e=e>>>8^i[255&(e^a)];return-1^e}},{"./utils":21}],5:[function(t,e,r){"use strict";function n(t){this.data=null,this.length=0,this.index=0}var i=t("./utils");n.prototype={checkOffset:function(t){this.checkIndex(this.index+t)},checkIndex:function(t){if(this.length<t||t<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+t+"). Corrupted zip ?")},setIndex:function(t){this.checkIndex(t),this.index=t},skip:function(t){this.setIndex(this.index+t)},byteAt:function(t){},readInt:function(t){var e,r=0;for(this.checkOffset(t),e=this.index+t-1;e>=this.index;e--)r=(r<<8)+this.byteAt(e);return this.index+=t,r},readString:function(t){return i.transformTo("string",this.readData(t))},readData:function(t){},lastIndexOfSignature:function(t){},readDate:function(){var t=this.readInt(4);return new Date(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1)}},e.exports=n},{"./utils":21}],6:[function(t,e,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!1,r.date=null,r.compression=null,r.comment=null},{}],7:[function(t,e,r){"use strict";var n=t("./utils");r.string2binary=function(t){return n.string2binary(t)},r.string2Uint8Array=function(t){return n.transformTo("uint8array",t)},r.uint8Array2String=function(t){return n.transformTo("string",t)},r.string2Blob=function(t){var e=n.transformTo("arraybuffer",t);return n.arrayBuffer2Blob(e)},r.arrayBuffer2Blob=function(t){return n.arrayBuffer2Blob(t)},r.transformTo=function(t,e){return n.transformTo(t,e)},r.getTypeOf=function(t){return n.getTypeOf(t)},r.checkSupport=function(t){return n.checkSupport(t)},r.MAX_VALUE_16BITS=n.MAX_VALUE_16BITS,r.MAX_VALUE_32BITS=n.MAX_VALUE_32BITS,r.pretty=function(t){return n.pretty(t)},r.findCompression=function(t){return n.findCompression(t)},r.isRegExp=function(t){return n.isRegExp(t)}},{"./utils":21}],8:[function(t,e,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=t("pako");r.uncompressInputType=n?"uint8array":"array",r.compressInputType=n?"uint8array":"array",r.magic="\b\0",r.compress=function(t){return i.deflateRaw(t)},r.uncompress=function(t){return i.inflateRaw(t)}},{pako:24}],9:[function(t,e,r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);this.files={},this.comment=null,this.root="",t&&this.load(t,e),this.clone=function(){var t=new n;for(var e in this)"function"!=typeof this[e]&&(t[e]=this[e]);return t}}var i=t("./base64");n.prototype=t("./object"),n.prototype.load=t("./load"),n.support=t("./support"),n.defaults=t("./defaults"),n.utils=t("./deprecatedPublicUtils"),n.base64={encode:function(t){return i.encode(t)},decode:function(t){return i.decode(t)}},n.compressions=t("./compressions"),e.exports=n},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(t,e,r){"use strict";var n=t("./base64"),i=t("./zipEntries");e.exports=function(t,e){var r,a,s,o;for((e=e||{}).base64&&(t=n.decode(t)),r=(a=new i(t,e)).files,s=0;s<r.length;s++)o=r[s],this.file(o.fileName,o.decompressed,{binary:!0,optimizedBinaryString:!0,date:o.date,dir:o.dir,comment:o.fileComment.length?o.fileComment:null,createFolders:e.createFolders});return a.zipComment.length&&(this.comment=a.zipComment),this}},{"./base64":1,"./zipEntries":22}],11:[function(t,e,r){(function(t){"use strict";e.exports=function(e,r){return new t(e,r)},e.exports.test=function(e){return t.isBuffer(e)}}).call(this,"undefined"!=typeof Buffer?Buffer:void 0)},{}],12:[function(t,e,r){"use strict";function n(t){this.data=t,this.length=this.data.length,this.index=0}var i=t("./uint8ArrayReader");n.prototype=new i,n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.index,this.index+t);return this.index+=t,e},e.exports=n},{"./uint8ArrayReader":18}],13:[function(t,e,r){"use strict";var n=t("./support"),i=t("./utils"),a=t("./crc32"),s=t("./signature"),o=t("./defaults"),d=t("./base64"),h=t("./compressions"),l=t("./compressedObject"),f=t("./nodeBuffer"),u=t("./utf8"),c=t("./stringWriter"),_=t("./uint8ArrayWriter"),p=function(t){if(t._data instanceof l&&(t._data=t._data.getContent(),t.options.binary=!0,t.options.base64=!1,"uint8array"===i.getTypeOf(t._data))){var e=t._data;t._data=new Uint8Array(e.length),0!==e.length&&t._data.set(e,0)}return t._data},m=function(t){var e=p(t);return"string"===i.getTypeOf(e)?!t.options.binary&&n.nodebuffer?f(e,"utf-8"):t.asBinary():e},g=function(t){var e=p(this);return null===e||void 0===e?"":(this.options.base64&&(e=d.decode(e)),e=t&&this.options.binary?E.utf8decode(e):i.transformTo("string",e),t||this.options.binary||(e=i.transformTo("string",E.utf8encode(e))),e)},b=function(t,e,r){this.name=t,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this._data=e,this.options=r,this._initialMetadata={dir:r.dir,date:r.date}};b.prototype={asText:function(){return g.call(this,!0)},asBinary:function(){return g.call(this,!1)},asNodeBuffer:function(){var t=m(this);return i.transformTo("nodebuffer",t)},asUint8Array:function(){var t=m(this);return i.transformTo("uint8array",t)},asArrayBuffer:function(){return this.asUint8Array().buffer}};var w=function(t,e){var r,n="";for(r=0;r<e;r++)n+=String.fromCharCode(255&t),t>>>=8;return n},v=function(){var t,e,r={};for(t=0;t<arguments.length;t++)for(e in arguments[t])arguments[t].hasOwnProperty(e)&&void 0===r[e]&&(r[e]=arguments[t][e]);return r},y=function(t){return!0!==(t=t||{}).base64||null!==t.binary&&void 0!==t.binary||(t.binary=!0),t=v(t,o),t.date=t.date||new Date,null!==t.compression&&(t.compression=t.compression.toUpperCase()),t},k=function(t,e,r){var n,a=i.getTypeOf(e);if((r=y(r)).createFolders&&(n=x(t))&&z.call(this,n,!0),r.dir||null===e||void 0===e)r.base64=!1,r.binary=!1,e=null;else if("string"===a)r.binary&&!r.base64&&!0!==r.optimizedBinaryString&&(e=i.string2binary(e));else{if(r.base64=!1,r.binary=!0,!(a||e instanceof l))throw new Error("The data of '"+t+"' is in an unsupported format !");"arraybuffer"===a&&(e=i.transformTo("uint8array",e))}var s=new b(t,e,r);return this.files[t]=s,s},x=function(t){"/"==t.slice(-1)&&(t=t.substring(0,t.length-1));var e=t.lastIndexOf("/");return e>0?t.substring(0,e):""},z=function(t,e){return"/"!=t.slice(-1)&&(t+="/"),e=void 0!==e&&e,this.files[t]||k.call(this,t,null,{dir:!0,createFolders:e}),this.files[t]},C=function(t,e){var r,n=new l;return t._data instanceof l?(n.uncompressedSize=t._data.uncompressedSize,n.crc32=t._data.crc32,0===n.uncompressedSize||t.dir?(e=h.STORE,n.compressedContent="",n.crc32=0):t._data.compressionMethod===e.magic?n.compressedContent=t._data.getCompressedContent():(r=t._data.getContent(),n.compressedContent=e.compress(i.transformTo(e.compressInputType,r)))):((r=m(t))&&0!==r.length&&!t.dir||(e=h.STORE,r=""),n.uncompressedSize=r.length,n.crc32=a(r),n.compressedContent=e.compress(i.transformTo(e.compressInputType,r))),n.compressedSize=n.compressedContent.length,n.compressionMethod=e.magic,n},A=function(t,e,r,n){r.compressedContent;var o,d,h,l,f=i.transformTo("string",u.utf8encode(e.name)),c=e.comment||"",_=i.transformTo("string",u.utf8encode(c)),p=f.length!==e.name.length,m=_.length!==c.length,g=e.options,b="",v="",y="";h=e._initialMetadata.dir!==e.dir?e.dir:g.dir,o=(l=e._initialMetadata.date!==e.date?e.date:g.date).getHours(),o<<=6,o|=l.getMinutes(),o<<=5,o|=l.getSeconds()/2,d=l.getFullYear()-1980,d<<=4,d|=l.getMonth()+1,d<<=5,d|=l.getDate(),p&&(v=w(1,1)+w(a(f),4)+f,b+="up"+w(v.length,2)+v),m&&(y=w(1,1)+w(this.crc32(_),4)+_,b+="uc"+w(y.length,2)+y);var k="";return k+="\n\0",k+=p||m?"\0\b":"\0\0",k+=r.compressionMethod,k+=w(o,2),k+=w(d,2),k+=w(r.crc32,4),k+=w(r.compressedSize,4),k+=w(r.uncompressedSize,4),k+=w(f.length,2),k+=w(b.length,2),{fileRecord:s.LOCAL_FILE_HEADER+k+f+b,dirRecord:s.CENTRAL_FILE_HEADER+"\0"+k+w(_.length,2)+"\0\0\0\0"+(!0===h?"\0\0\0":"\0\0\0\0")+w(n,4)+f+b+_,compressedObject:r}},E={load:function(t,e){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(t){var e,r,n,i,a=[];for(e in this.files)this.files.hasOwnProperty(e)&&(n=this.files[e],i=new b(n.name,n._data,v(n.options)),r=e.slice(this.root.length,e.length),e.slice(0,this.root.length)===this.root&&t(r,i)&&a.push(i));return a},file:function(t,e,r){if(1===arguments.length){if(i.isRegExp(t)){var n=t;return this.filter(function(t,e){return!e.dir&&n.test(t)})}return this.filter(function(e,r){return!r.dir&&e===t})[0]||null}return t=this.root+t,k.call(this,t,e,r),this},folder:function(t){if(!t)return this;if(i.isRegExp(t))return this.filter(function(e,r){return r.dir&&t.test(e)});var e=this.root+t,r=z.call(this,e),n=this.clone();return n.root=r.name,n},remove:function(t){t=this.root+t;var e=this.files[t];if(e||("/"!=t.slice(-1)&&(t+="/"),e=this.files[t]),e&&!e.dir)delete this.files[t];else for(var r=this.filter(function(e,r){return r.name.slice(0,t.length)===t}),n=0;n<r.length;n++)delete this.files[r[n].name];return this},generate:function(t){t=v(t||{},{base64:!0,compression:"STORE",type:"base64",comment:null}),i.checkSupport(t.type);var e,r,n=[],a=0,o=0,l=i.transformTo("string",this.utf8encode(t.comment||this.comment||""));for(var f in this.files)if(this.files.hasOwnProperty(f)){var u=this.files[f],p=u.options.compression||t.compression.toUpperCase(),m=h[p];if(!m)throw new Error(p+" is not a valid compression method !");var g=C.call(this,u,m),b=A.call(this,f,u,g,a);a+=b.fileRecord.length+g.compressedSize,o+=b.dirRecord.length,n.push(b)}var y="";y=s.CENTRAL_DIRECTORY_END+"\0\0\0\0"+w(n.length,2)+w(n.length,2)+w(o,4)+w(a,4)+w(l.length,2)+l;var k=t.type.toLowerCase();for(e="uint8array"===k||"arraybuffer"===k||"blob"===k||"nodebuffer"===k?new _(a+o+y.length):new c(a+o+y.length),r=0;r<n.length;r++)e.append(n[r].fileRecord),e.append(n[r].compressedObject.compressedContent);for(r=0;r<n.length;r++)e.append(n[r].dirRecord);e.append(y);var x=e.finalize();switch(t.type.toLowerCase()){case"uint8array":case"arraybuffer":case"nodebuffer":return i.transformTo(t.type.toLowerCase(),x);case"blob":return i.arrayBuffer2Blob(i.transformTo("arraybuffer",x));case"base64":return t.base64?d.encode(x):x;default:return x}},crc32:function(t,e){return a(t,e)},utf8encode:function(t){return i.transformTo("string",u.utf8encode(t))},utf8decode:function(t){return u.utf8decode(t)}};e.exports=E},{"./base64":1,"./compressedObject":2,"./compressions":3,"./crc32":4,"./defaults":6,"./nodeBuffer":11,"./signature":14,"./stringWriter":16,"./support":17,"./uint8ArrayWriter":19,"./utf8":20,"./utils":21}],14:[function(t,e,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],15:[function(t,e,r){"use strict";function n(t,e){this.data=t,e||(this.data=a.string2binary(this.data)),this.length=this.data.length,this.index=0}var i=t("./dataReader"),a=t("./utils");n.prototype=new i,n.prototype.byteAt=function(t){return this.data.charCodeAt(t)},n.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)},n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.index,this.index+t);return this.index+=t,e},e.exports=n},{"./dataReader":5,"./utils":21}],16:[function(t,e,r){"use strict";var n=t("./utils"),i=function(){this.data=[]};i.prototype={append:function(t){t=n.transformTo("string",t),this.data.push(t)},finalize:function(){return this.data.join("")}},e.exports=i},{"./utils":21}],17:[function(t,e,r){(function(t){"use strict";if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer=void 0!==t,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var e=new ArrayBuffer(0);try{r.blob=0===new Blob([e],{type:"application/zip"}).size}catch(t){try{var n=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder);n.append(e),r.blob=0===n.getBlob("application/zip").size}catch(t){r.blob=!1}}}}).call(this,"undefined"!=typeof Buffer?Buffer:void 0)},{}],18:[function(t,e,r){"use strict";function n(t){t&&(this.data=t,this.length=this.data.length,this.index=0)}var i=t("./dataReader");n.prototype=new i,n.prototype.byteAt=function(t){return this.data[t]},n.prototype.lastIndexOfSignature=function(t){for(var e=t.charCodeAt(0),r=t.charCodeAt(1),n=t.charCodeAt(2),i=t.charCodeAt(3),a=this.length-4;a>=0;--a)if(this.data[a]===e&&this.data[a+1]===r&&this.data[a+2]===n&&this.data[a+3]===i)return a;return-1},n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.index,this.index+t);return this.index+=t,e},e.exports=n},{"./dataReader":5}],19:[function(t,e,r){"use strict";var n=t("./utils"),i=function(t){this.data=new Uint8Array(t),this.index=0};i.prototype={append:function(t){0!==t.length&&(t=n.transformTo("uint8array",t),this.data.set(t,this.index),this.index+=t.length)},finalize:function(){return this.data}},e.exports=i},{"./utils":21}],20:[function(t,e,r){"use strict";for(var n=t("./utils"),i=t("./support"),a=t("./nodeBuffer"),s=new Array(256),o=0;o<256;o++)s[o]=o>=252?6:o>=248?5:o>=240?4:o>=224?3:o>=192?2:1;s[254]=s[254]=1;var d=function(t){var e,r,n,a,s,o=t.length,d=0;for(a=0;a<o;a++)55296==(64512&(r=t.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=t.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),d+=r<128?1:r<2048?2:r<65536?3:4;for(e=i.uint8array?new Uint8Array(d):new Array(d),s=0,a=0;s<d;a++)55296==(64512&(r=t.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=t.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},h=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+s[t[r]]>e?r:e},l=function(t){var e,r,i,a,o=t.length,d=new Array(2*o);for(r=0,e=0;e<o;)if((i=t[e++])<128)d[r++]=i;else if((a=s[i])>4)d[r++]=65533,e+=a-1;else{for(i&=2===a?31:3===a?15:7;a>1&&e<o;)i=i<<6|63&t[e++],a--;a>1?d[r++]=65533:i<65536?d[r++]=i:(i-=65536,d[r++]=55296|i>>10&1023,d[r++]=56320|1023&i)}return d.length!==r&&(d.subarray?d=d.subarray(0,r):d.length=r),n.applyFromCharCode(d)};r.utf8encode=function(t){return i.nodebuffer?a(t,"utf-8"):d(t)},r.utf8decode=function(t){if(i.nodebuffer)return n.transformTo("nodebuffer",t).toString("utf-8");for(var e=[],r=0,a=(t=n.transformTo(i.uint8array?"uint8array":"array",t)).length;r<a;){var s=h(t,Math.min(r+65536,a));i.uint8array?e.push(l(t.subarray(r,s))):e.push(l(t.slice(r,s))),r=s}return e.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(t,e,r){"use strict";function n(t){return t}function i(t,e){for(var r=0;r<t.length;++r)e[r]=255&t.charCodeAt(r);return e}function a(t){var e=65536,n=[],i=t.length,a=r.getTypeOf(t),s=0,o=!0;try{switch(a){case"uint8array":String.fromCharCode.apply(null,new Uint8Array(0));break;case"nodebuffer":String.fromCharCode.apply(null,h(0))}}catch(t){o=!1}if(!o){for(var d="",l=0;l<t.length;l++)d+=String.fromCharCode(t[l]);return d}for(;s<i&&e>1;)try{"array"===a||"nodebuffer"===a?n.push(String.fromCharCode.apply(null,t.slice(s,Math.min(s+e,i)))):n.push(String.fromCharCode.apply(null,t.subarray(s,Math.min(s+e,i)))),s+=e}catch(t){e=Math.floor(e/2)}return n.join("")}function s(t,e){for(var r=0;r<t.length;r++)e[r]=t[r];return e}var o=t("./support"),d=t("./compressions"),h=t("./nodeBuffer");r.string2binary=function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(255&t.charCodeAt(r));return e},r.arrayBuffer2Blob=function(t){r.checkSupport("blob");try{return new Blob([t],{type:"application/zip"})}catch(r){try{var e=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder);return e.append(t),e.getBlob("application/zip")}catch(t){throw new Error("Bug : can't construct the Blob.")}}},r.applyFromCharCode=a;var l={};l.string={string:n,array:function(t){return i(t,new Array(t.length))},arraybuffer:function(t){return l.string.uint8array(t).buffer},uint8array:function(t){return i(t,new Uint8Array(t.length))},nodebuffer:function(t){return i(t,h(t.length))}},l.array={string:a,array:n,arraybuffer:function(t){return new Uint8Array(t).buffer},uint8array:function(t){return new Uint8Array(t)},nodebuffer:function(t){return h(t)}},l.arraybuffer={string:function(t){return a(new Uint8Array(t))},array:function(t){return s(new Uint8Array(t),new Array(t.byteLength))},arraybuffer:n,uint8array:function(t){return new Uint8Array(t)},nodebuffer:function(t){return h(new Uint8Array(t))}},l.uint8array={string:a,array:function(t){return s(t,new Array(t.length))},arraybuffer:function(t){return t.buffer},uint8array:n,nodebuffer:function(t){return h(t)}},l.nodebuffer={string:a,array:function(t){return s(t,new Array(t.length))},arraybuffer:function(t){return l.nodebuffer.uint8array(t).buffer},uint8array:function(t){return s(t,new Uint8Array(t.length))},nodebuffer:n},r.transformTo=function(t,e){if(e||(e=""),!t)return e;r.checkSupport(t);var n=r.getTypeOf(e);return l[n][t](e)},r.getTypeOf=function(t){return"string"==typeof t?"string":"[object Array]"===Object.prototype.toString.call(t)?"array":o.nodebuffer&&h.test(t)?"nodebuffer":o.uint8array&&t instanceof Uint8Array?"uint8array":o.arraybuffer&&t instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(t){if(!o[t.toLowerCase()])throw new Error(t+" is not supported by this browser")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(t){var e,r,n="";for(r=0;r<(t||"").length;r++)n+="\\x"+((e=t.charCodeAt(r))<16?"0":"")+e.toString(16).toUpperCase();return n},r.findCompression=function(t){for(var e in d)if(d.hasOwnProperty(e)&&d[e].magic===t)return d[e];return null},r.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(t,e,r){"use strict";function n(t,e){this.files=[],this.loadOptions=e,t&&this.load(t)}var i=t("./stringReader"),a=t("./nodeBufferReader"),s=t("./uint8ArrayReader"),o=t("./utils"),d=t("./signature"),h=t("./zipEntry"),l=t("./support"),f=t("./object");n.prototype={checkSignature:function(t){var e=this.reader.readString(4);if(e!==t)throw new Error("Corrupted zip or bug : unexpected signature ("+o.pretty(e)+", expected "+o.pretty(t)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength),this.zipComment=f.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var t,e,r,n=this.zip64EndOfCentralSize-44;0<n;)t=this.reader.readInt(2),e=this.reader.readInt(4),r=this.reader.readString(e),this.zip64ExtensibleData[t]={id:t,length:e,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var t,e;for(t=0;t<this.files.length;t++)e=this.files[t],this.reader.setIndex(e.localHeaderOffset),this.checkSignature(d.LOCAL_FILE_HEADER),e.readLocalPart(this.reader),e.handleUTF8()},readCentralDir:function(){var t;for(this.reader.setIndex(this.centralDirOffset);this.reader.readString(4)===d.CENTRAL_FILE_HEADER;)(t=new h({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(t)},readEndOfCentral:function(){var t=this.reader.lastIndexOfSignature(d.CENTRAL_DIRECTORY_END);if(-1===t)throw new Error("Corrupted zip : can't find end of central directory");if(this.reader.setIndex(t),this.checkSignature(d.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,-1===(t=this.reader.lastIndexOfSignature(d.ZIP64_CENTRAL_DIRECTORY_LOCATOR)))throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");this.reader.setIndex(t),this.checkSignature(d.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(d.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}},prepareReader:function(t){var e=o.getTypeOf(t);"string"!==e||l.uint8array?this.reader="nodebuffer"===e?new a(t):new s(o.transformTo("uint8array",t)):this.reader=new i(t,this.loadOptions.optimizedBinaryString)},load:function(t){this.prepareReader(t),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},e.exports=n},{"./nodeBufferReader":12,"./object":13,"./signature":14,"./stringReader":15,"./support":17,"./uint8ArrayReader":18,"./utils":21,"./zipEntry":23}],23:[function(t,e,r){"use strict";function n(t,e){this.options=t,this.loadOptions=e}var i=t("./stringReader"),a=t("./utils"),s=t("./compressedObject"),o=t("./object");n.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},prepareCompressedContent:function(t,e,r){return function(){var n=t.index;t.setIndex(e);var i=t.readData(r);return t.setIndex(n),i}},prepareContent:function(t,e,r,n,i){return function(){var t=a.transformTo(n.uncompressInputType,this.getCompressedContent()),e=n.uncompress(t);if(e.length!==i)throw new Error("Bug : uncompressed data size mismatch");return e}},readLocalPart:function(t){var e,r;if(t.skip(22),this.fileNameLength=t.readInt(2),r=t.readInt(2),this.fileName=t.readString(this.fileNameLength),t.skip(r),-1==this.compressedSize||-1==this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory (compressedSize == -1 || uncompressedSize == -1)");if(null===(e=a.findCompression(this.compressionMethod)))throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+this.fileName+")");if(this.decompressed=new s,this.decompressed.compressedSize=this.compressedSize,this.decompressed.uncompressedSize=this.uncompressedSize,this.decompressed.crc32=this.crc32,this.decompressed.compressionMethod=this.compressionMethod,this.decompressed.getCompressedContent=this.prepareCompressedContent(t,t.index,this.compressedSize,e),this.decompressed.getContent=this.prepareContent(t,t.index,this.compressedSize,e,this.uncompressedSize),this.loadOptions.checkCRC32&&(this.decompressed=a.transformTo("string",this.decompressed.getContent()),o.crc32(this.decompressed)!==this.crc32))throw new Error("Corrupted zip : CRC32 mismatch")},readCentralPart:function(t){if(this.versionMadeBy=t.readString(2),this.versionNeeded=t.readInt(2),this.bitFlag=t.readInt(2),this.compressionMethod=t.readString(2),this.date=t.readDate(),this.crc32=t.readInt(4),this.compressedSize=t.readInt(4),this.uncompressedSize=t.readInt(4),this.fileNameLength=t.readInt(2),this.extraFieldsLength=t.readInt(2),this.fileCommentLength=t.readInt(2),this.diskNumberStart=t.readInt(2),this.internalFileAttributes=t.readInt(2),this.externalFileAttributes=t.readInt(4),this.localHeaderOffset=t.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");this.fileName=t.readString(this.fileNameLength),this.readExtraFields(t),this.parseZIP64ExtraField(t),this.fileComment=t.readString(this.fileCommentLength),this.dir=!!(16&this.externalFileAttributes)},parseZIP64ExtraField:function(t){if(this.extraFields[1]){var e=new i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(t){var e,r,n,i=t.index;for(this.extraFields=this.extraFields||{};t.index<i+this.extraFieldsLength;)e=t.readInt(2),r=t.readInt(2),n=t.readString(r),this.extraFields[e]={id:e,length:r,value:n}},handleUTF8:function(){if(this.useUTF8())this.fileName=o.utf8decode(this.fileName),this.fileComment=o.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();null!==t&&(this.fileName=t);var e=this.findExtraFieldUnicodeComment();null!==e&&(this.fileComment=e)}},findExtraFieldUnicodePath:function(){var t=this.extraFields[28789];if(t){var e=new i(t.value);return 1!==e.readInt(1)?null:o.crc32(this.fileName)!==e.readInt(4)?null:o.utf8decode(e.readString(t.length-5))}return null},findExtraFieldUnicodeComment:function(){var t=this.extraFields[25461];if(t){var e=new i(t.value);return 1!==e.readInt(1)?null:o.crc32(this.fileComment)!==e.readInt(4)?null:o.utf8decode(e.readString(t.length-5))}return null}},e.exports=n},{"./compressedObject":2,"./object":13,"./stringReader":15,"./utils":21}],24:[function(t,e,r){"use strict";var n={};(0,t("./lib/utils/common").assign)(n,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),e.exports=n},{"./lib/deflate":25,"./lib/inflate":26,"./lib/utils/common":27,"./lib/zlib/constants":30}],25:[function(t,e,r){"use strict";function n(t,e){var r=new f(e);if(r.push(t,!0),r.err)throw r.msg;return r.result}function i(t,e){return e=e||{},e.raw=!0,n(t,e)}function a(t,e){return e=e||{},e.gzip=!0,n(t,e)}var s=t("./zlib/deflate.js"),o=t("./utils/common"),d=t("./utils/strings"),h=t("./zlib/messages"),l=t("./zlib/zstream"),f=function(t){this.options=o.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var r=s.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==r)throw new Error(h[r]);e.header&&s.deflateSetHeader(this.strm,e.header)};f.prototype.push=function(t,e){var r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;n=e===~~e?e:!0===e?4:0,i.input="string"==typeof t?d.string2buf(t):t,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new o.Buf8(a),i.next_out=0,i.avail_out=a),1!==(r=s.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;(0===i.avail_out||0===i.avail_in&&4===n)&&("string"===this.options.to?this.onData(d.buf2binstring(o.shrinkBuf(i.output,i.next_out))):this.onData(o.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4!==n||(r=s.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r)},f.prototype.onData=function(t){this.chunks.push(t)},f.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},r.Deflate=f,r.deflate=n,r.deflateRaw=i,r.gzip=a},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(t,e,r){"use strict";function n(t,e){var r=new u(e);if(r.push(t,!0),r.err)throw r.msg;return r.result}function i(t,e){return e=e||{},e.raw=!0,n(t,e)}var a=t("./zlib/inflate.js"),s=t("./utils/common"),o=t("./utils/strings"),d=t("./zlib/constants"),h=t("./zlib/messages"),l=t("./zlib/zstream"),f=t("./zlib/gzheader"),u=function(t){this.options=s.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var r=a.inflateInit2(this.strm,e.windowBits);if(r!==d.Z_OK)throw new Error(h[r]);this.header=new f,a.inflateGetHeader(this.strm,this.header)};u.prototype.push=function(t,e){var r,n,i,h,l,f=this.strm,u=this.options.chunkSize;if(this.ended)return!1;n=e===~~e?e:!0===e?d.Z_FINISH:d.Z_NO_FLUSH,f.input="string"==typeof t?o.binstring2buf(t):t,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new s.Buf8(u),f.next_out=0,f.avail_out=u),(r=a.inflate(f,d.Z_NO_FLUSH))!==d.Z_STREAM_END&&r!==d.Z_OK)return this.onEnd(r),this.ended=!0,!1;f.next_out&&(0===f.avail_out||r===d.Z_STREAM_END||0===f.avail_in&&n===d.Z_FINISH)&&("string"===this.options.to?(i=o.utf8border(f.output,f.next_out),h=f.next_out-i,l=o.buf2string(f.output,i),f.next_out=h,f.avail_out=u-h,h&&s.arraySet(f.output,f.output,i,h,0),this.onData(l)):this.onData(s.shrinkBuf(f.output,f.next_out)))}while(f.avail_in>0&&r!==d.Z_STREAM_END);return r===d.Z_STREAM_END&&(n=d.Z_FINISH),n!==d.Z_FINISH||(r=a.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===d.Z_OK)},u.prototype.onData=function(t){this.chunks.push(t)},u.prototype.onEnd=function(t){t===d.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},r.Inflate=u,r.inflate=n,r.inflateRaw=i,r.ungzip=n},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(t,e,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])}}return t},r.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var a=0;a<n;a++)t[i+a]=e[r+a]},flattenChunks:function(t){var e,r,n,i,a,s;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(s=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)a=t[e],s.set(a,i),i+=a.length;return s}},a={arraySet:function(t,e,r,n,i){for(var a=0;a<n;a++)t[i+a]=e[r+a]},flattenChunks:function(t){return[].concat.apply([],t)}};r.setTyped=function(t){t?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(n)},{}],28:[function(t,e,r){"use strict";function n(t,e){if(e<65537&&(t.subarray&&s||!t.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(t,e));for(var r="",n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r}var i=t("./common"),a=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(t){a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){s=!1}for(var o=new i.Buf8(256),d=0;d<256;d++)o[d]=d>=252?6:d>=248?5:d>=240?4:d>=224?3:d>=192?2:1;o[254]=o[254]=1,r.string2buf=function(t){var e,r,n,a,s,o=t.length,d=0;for(a=0;a<o;a++)55296==(64512&(r=t.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=t.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),d+=r<128?1:r<2048?2:r<65536?3:4;for(e=new i.Buf8(d),s=0,a=0;s<d;a++)55296==(64512&(r=t.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=t.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},r.buf2binstring=function(t){return n(t,t.length)},r.binstring2buf=function(t){for(var e=new i.Buf8(t.length),r=0,n=e.length;r<n;r++)e[r]=t.charCodeAt(r);return e},r.buf2string=function(t,e){var r,i,a,s,d=e||t.length,h=new Array(2*d);for(i=0,r=0;r<d;)if((a=t[r++])<128)h[i++]=a;else if((s=o[a])>4)h[i++]=65533,r+=s-1;else{for(a&=2===s?31:3===s?15:7;s>1&&r<d;)a=a<<6|63&t[r++],s--;s>1?h[i++]=65533:a<65536?h[i++]=a:(a-=65536,h[i++]=55296|a>>10&1023,h[i++]=56320|1023&a)}return n(h,i)},r.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+o[t[r]]>e?r:e}},{"./common":27}],29:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=65535&t|0,a=t>>>16&65535|0,s=0;0!==r;){r-=s=r>2e3?2e3:r;do{a=a+(i=i+e[n++]|0)|0}while(--s);i%=65521,a%=65521}return i|a<<16|0}e.exports=n},{}],30:[function(t,e,r){e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(t,e,r){"use strict";function n(t,e,r,n){var a=i,s=n+r;t^=-1;for(var o=n;o<s;o++)t=t>>>8^a[255&(t^e[o])];return-1^t}var i=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();e.exports=n},{}],32:[function(t,e,r){"use strict";function n(t,e){return t.msg=R[e],e}function i(t){return(t<<1)-(t>4?9:0)}function a(t){for(var e=t.length;--e>=0;)t[e]=0}function s(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(S.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function o(t,e){B._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,s(t.strm)}function d(t,e){t.pending_buf[t.pending++]=e}function h(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function l(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,S.arraySet(e,t.input,t.next_in,i,r),1===t.state.wrap?t.adler=I(t.adler,e,i,r):2===t.state.wrap&&(t.adler=T(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)}function f(t,e){var r,n,i=t.max_chain_length,a=t.strstart,s=t.prev_length,o=t.nice_match,d=t.strstart>t.w_size-ot?t.strstart-(t.w_size-ot):0,h=t.window,l=t.w_mask,f=t.prev,u=t.strstart+st,c=h[a+s-1],_=h[a+s];t.prev_length>=t.good_match&&(i>>=2),o>t.lookahead&&(o=t.lookahead);do{if(r=e,h[r+s]===_&&h[r+s-1]===c&&h[r]===h[a]&&h[++r]===h[a+1]){a+=2,r++;do{}while(h[++a]===h[++r]&&h[++a]===h[++r]&&h[++a]===h[++r]&&h[++a]===h[++r]&&h[++a]===h[++r]&&h[++a]===h[++r]&&h[++a]===h[++r]&&h[++a]===h[++r]&&a<u);if(n=st-(u-a),a=u-st,n>s){if(t.match_start=e,s=n,n>=o)break;c=h[a+s-1],_=h[a+s]}}}while((e=f[e&l])>d&&0!=--i);return s<=t.lookahead?s:t.lookahead}function u(t){var e,r,n,i,a,s=t.w_size;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-ot)){S.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=s?n-s:0}while(--r);e=r=s;do{n=t.prev[--e],t.prev[e]=n>=s?n-s:0}while(--r);i+=s}if(0===t.strm.avail_in)break;if(r=l(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=r,t.lookahead+t.insert>=at)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<<t.hash_shift^t.window[a+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[a+at-1])&t.hash_mask,t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<at)););}while(t.lookahead<ot&&0!==t.strm.avail_in)}function c(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(u(t),0===t.lookahead&&e===O)return mt;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,o(t,!1),0===t.strm.avail_out))return mt;if(t.strstart-t.block_start>=t.w_size-ot&&(o(t,!1),0===t.strm.avail_out))return mt}return t.insert=0,e===N?(o(t,!0),0===t.strm.avail_out?bt:wt):(t.strstart>t.block_start&&(o(t,!1),t.strm.avail_out),mt)}function _(t,e){for(var r,n;;){if(t.lookahead<ot){if(u(t),t.lookahead<ot&&e===O)return mt;if(0===t.lookahead)break}if(r=0,t.lookahead>=at&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+at-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-ot&&(t.match_length=f(t,r)),t.match_length>=at)if(n=B._tr_tally(t,t.strstart-t.match_start,t.match_length-at),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=at){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+at-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=B._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(o(t,!1),0===t.strm.avail_out))return mt}return t.insert=t.strstart<at-1?t.strstart:at-1,e===N?(o(t,!0),0===t.strm.avail_out?bt:wt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?mt:gt}function p(t,e){for(var r,n,i;;){if(t.lookahead<ot){if(u(t),t.lookahead<ot&&e===O)return mt;if(0===t.lookahead)break}if(r=0,t.lookahead>=at&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+at-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=at-1,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-ot&&(t.match_length=f(t,r),t.match_length<=5&&(t.strategy===X||t.match_length===at&&t.strstart-t.match_start>4096)&&(t.match_length=at-1)),t.prev_length>=at&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-at,n=B._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-at),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+at-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=at-1,t.strstart++,n&&(o(t,!1),0===t.strm.avail_out))return mt}else if(t.match_available){if((n=B._tr_tally(t,0,t.window[t.strstart-1]))&&o(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return mt}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=B._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<at-1?t.strstart:at-1,e===N?(o(t,!0),0===t.strm.avail_out?bt:wt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?mt:gt}function m(t,e){for(var r,n,i,a,s=t.window;;){if(t.lookahead<=st){if(u(t),t.lookahead<=st&&e===O)return mt;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=at&&t.strstart>0&&(i=t.strstart-1,(n=s[i])===s[++i]&&n===s[++i]&&n===s[++i])){a=t.strstart+st;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);t.match_length=st-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=at?(r=B._tr_tally(t,1,t.match_length-at),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=B._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(o(t,!1),0===t.strm.avail_out))return mt}return t.insert=0,e===N?(o(t,!0),0===t.strm.avail_out?bt:wt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?mt:gt}function g(t,e){for(var r;;){if(0===t.lookahead&&(u(t),0===t.lookahead)){if(e===O)return mt;break}if(t.match_length=0,r=B._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(o(t,!1),0===t.strm.avail_out))return mt}return t.insert=0,e===N?(o(t,!0),0===t.strm.avail_out?bt:wt):t.last_lit&&(o(t,!1),0===t.strm.avail_out)?mt:gt}function b(t){t.window_size=2*t.w_size,a(t.head),t.max_lazy_match=E[t.level].max_lazy,t.good_match=E[t.level].good_length,t.nice_match=E[t.level].nice_length,t.max_chain_length=E[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=at-1,t.match_available=0,t.ins_h=0}function w(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=G,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new S.Buf16(2*nt),this.dyn_dtree=new S.Buf16(2*(2*et+1)),this.bl_tree=new S.Buf16(2*(2*rt+1)),a(this.dyn_ltree),a(this.dyn_dtree),a(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new S.Buf16(it+1),this.heap=new S.Buf16(2*tt+1),a(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new S.Buf16(2*tt+1),a(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function v(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=q,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?ht:_t,t.adler=2===e.wrap?0:1,e.last_flush=O,B._tr_init(e),F):n(t,M)}function y(t){var e=v(t);return e===F&&b(t.state),e}function k(t,e){return t&&t.state?2!==t.state.wrap?M:(t.state.gzhead=e,F):M}function x(t,e,r,i,a,s){if(!t)return M;var o=1;if(e===H&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),a<1||a>J||r!==G||i<8||i>15||e<0||e>9||s<0||s>Y)return n(t,M);8===i&&(i=9);var d=new w;return t.state=d,d.strm=t,d.wrap=o,d.gzhead=null,d.w_bits=i,d.w_size=1<<d.w_bits,d.w_mask=d.w_size-1,d.hash_bits=a+7,d.hash_size=1<<d.hash_bits,d.hash_mask=d.hash_size-1,d.hash_shift=~~((d.hash_bits+at-1)/at),d.window=new S.Buf8(2*d.w_size),d.head=new S.Buf16(d.hash_size),d.prev=new S.Buf16(d.w_size),d.lit_bufsize=1<<a+6,d.pending_buf_size=4*d.lit_bufsize,d.pending_buf=new S.Buf8(d.pending_buf_size),d.d_buf=d.lit_bufsize>>1,d.l_buf=3*d.lit_bufsize,d.level=e,d.strategy=s,d.method=r,y(t)}function z(t,e){return x(t,e,G,$,Q,W)}function C(t,e){var r,o,l,f;if(!t||!t.state||e>U||e<0)return t?n(t,M):M;if(o=t.state,!t.output||!t.input&&0!==t.avail_in||o.status===pt&&e!==N)return n(t,0===t.avail_out?j:M);if(o.strm=t,r=o.last_flush,o.last_flush=e,o.status===ht)if(2===o.wrap)t.adler=0,d(o,31),d(o,139),d(o,8),o.gzhead?(d(o,(o.gzhead.text?1:0)+(o.gzhead.hcrc?2:0)+(o.gzhead.extra?4:0)+(o.gzhead.name?8:0)+(o.gzhead.comment?16:0)),d(o,255&o.gzhead.time),d(o,o.gzhead.time>>8&255),d(o,o.gzhead.time>>16&255),d(o,o.gzhead.time>>24&255),d(o,9===o.level?2:o.strategy>=K||o.level<2?4:0),d(o,255&o.gzhead.os),o.gzhead.extra&&o.gzhead.extra.length&&(d(o,255&o.gzhead.extra.length),d(o,o.gzhead.extra.length>>8&255)),o.gzhead.hcrc&&(t.adler=T(t.adler,o.pending_buf,o.pending,0)),o.gzindex=0,o.status=lt):(d(o,0),d(o,0),d(o,0),d(o,0),d(o,0),d(o,9===o.level?2:o.strategy>=K||o.level<2?4:0),d(o,vt),o.status=_t);else{var u=G+(o.w_bits-8<<4)<<8;u|=(o.strategy>=K||o.level<2?0:o.level<6?1:6===o.level?2:3)<<6,0!==o.strstart&&(u|=dt),u+=31-u%31,o.status=_t,h(o,u),0!==o.strstart&&(h(o,t.adler>>>16),h(o,65535&t.adler)),t.adler=1}if(o.status===lt)if(o.gzhead.extra){for(l=o.pending;o.gzindex<(65535&o.gzhead.extra.length)&&(o.pending!==o.pending_buf_size||(o.gzhead.hcrc&&o.pending>l&&(t.adler=T(t.adler,o.pending_buf,o.pending-l,l)),s(t),l=o.pending,o.pending!==o.pending_buf_size));)d(o,255&o.gzhead.extra[o.gzindex]),o.gzindex++;o.gzhead.hcrc&&o.pending>l&&(t.adler=T(t.adler,o.pending_buf,o.pending-l,l)),o.gzindex===o.gzhead.extra.length&&(o.gzindex=0,o.status=ft)}else o.status=ft;if(o.status===ft)if(o.gzhead.name){l=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>l&&(t.adler=T(t.adler,o.pending_buf,o.pending-l,l)),s(t),l=o.pending,o.pending===o.pending_buf_size)){f=1;break}f=o.gzindex<o.gzhead.name.length?255&o.gzhead.name.charCodeAt(o.gzindex++):0,d(o,f)}while(0!==f);o.gzhead.hcrc&&o.pending>l&&(t.adler=T(t.adler,o.pending_buf,o.pending-l,l)),0===f&&(o.gzindex=0,o.status=ut)}else o.status=ut;if(o.status===ut)if(o.gzhead.comment){l=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>l&&(t.adler=T(t.adler,o.pending_buf,o.pending-l,l)),s(t),l=o.pending,o.pending===o.pending_buf_size)){f=1;break}f=o.gzindex<o.gzhead.comment.length?255&o.gzhead.comment.charCodeAt(o.gzindex++):0,d(o,f)}while(0!==f);o.gzhead.hcrc&&o.pending>l&&(t.adler=T(t.adler,o.pending_buf,o.pending-l,l)),0===f&&(o.status=ct)}else o.status=ct;if(o.status===ct&&(o.gzhead.hcrc?(o.pending+2>o.pending_buf_size&&s(t),o.pending+2<=o.pending_buf_size&&(d(o,255&t.adler),d(o,t.adler>>8&255),t.adler=0,o.status=_t)):o.status=_t),0!==o.pending){if(s(t),0===t.avail_out)return o.last_flush=-1,F}else if(0===t.avail_in&&i(e)<=i(r)&&e!==N)return n(t,j);if(o.status===pt&&0!==t.avail_in)return n(t,j);if(0!==t.avail_in||0!==o.lookahead||e!==O&&o.status!==pt){var c=o.strategy===K?g(o,e):o.strategy===V?m(o,e):E[o.level].func(o,e);if(c!==bt&&c!==wt||(o.status=pt),c===mt||c===bt)return 0===t.avail_out&&(o.last_flush=-1),F;if(c===gt&&(e===L?B._tr_align(o):e!==U&&(B._tr_stored_block(o,0,0,!1),e===D&&(a(o.head),0===o.lookahead&&(o.strstart=0,o.block_start=0,o.insert=0))),s(t),0===t.avail_out))return o.last_flush=-1,F}return e!==N?F:o.wrap<=0?Z:(2===o.wrap?(d(o,255&t.adler),d(o,t.adler>>8&255),d(o,t.adler>>16&255),d(o,t.adler>>24&255),d(o,255&t.total_in),d(o,t.total_in>>8&255),d(o,t.total_in>>16&255),d(o,t.total_in>>24&255)):(h(o,t.adler>>>16),h(o,65535&t.adler)),s(t),o.wrap>0&&(o.wrap=-o.wrap),0!==o.pending?F:Z)}function A(t){var e;return t&&t.state?(e=t.state.status)!==ht&&e!==lt&&e!==ft&&e!==ut&&e!==ct&&e!==_t&&e!==pt?n(t,M):(t.state=null,e===_t?n(t,P):F):M}var E,S=t("../utils/common"),B=t("./trees"),I=t("./adler32"),T=t("./crc32"),R=t("./messages"),O=0,L=1,D=3,N=4,U=5,F=0,Z=1,M=-2,P=-3,j=-5,H=-1,X=1,K=2,V=3,Y=4,W=0,q=2,G=8,J=9,$=15,Q=8,tt=286,et=30,rt=19,nt=2*tt+1,it=15,at=3,st=258,ot=st+at+1,dt=32,ht=42,lt=69,ft=73,ut=91,ct=103,_t=113,pt=666,mt=1,gt=2,bt=3,wt=4,vt=3,yt=function(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i};E=[new yt(0,0,0,0,c),new yt(4,4,8,4,_),new yt(4,5,16,8,_),new yt(4,6,32,32,_),new yt(4,4,16,16,p),new yt(8,16,32,32,p),new yt(8,16,128,128,p),new yt(8,32,128,256,p),new yt(32,128,258,1024,p),new yt(32,258,258,4096,p)],r.deflateInit=z,r.deflateInit2=x,r.deflateReset=y,r.deflateResetKeep=v,r.deflateSetHeader=k,r.deflate=C,r.deflateEnd=A,r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(t,e,r){"use strict";function n(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}e.exports=n},{}],34:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,i,a,s,o,d,h,l,f,u,c,_,p,m,g,b,w,v,y,k,x,z,C,A;r=t.state,n=t.next_in,C=t.input,i=n+(t.avail_in-5),a=t.next_out,A=t.output,s=a-(e-t.avail_out),o=a+(t.avail_out-257),d=r.dmax,h=r.wsize,l=r.whave,f=r.wnext,u=r.window,c=r.hold,_=r.bits,p=r.lencode,m=r.distcode,g=(1<<r.lenbits)-1,b=(1<<r.distbits)-1;t:do{_<15&&(c+=C[n++]<<_,_+=8,c+=C[n++]<<_,_+=8),w=p[c&g];e:for(;;){if(v=w>>>24,c>>>=v,_-=v,0===(v=w>>>16&255))A[a++]=65535&w;else{if(!(16&v)){if(0==(64&v)){w=p[(65535&w)+(c&(1<<v)-1)];continue e}if(32&v){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}y=65535&w,(v&=15)&&(_<v&&(c+=C[n++]<<_,_+=8),y+=c&(1<<v)-1,c>>>=v,_-=v),_<15&&(c+=C[n++]<<_,_+=8,c+=C[n++]<<_,_+=8),w=m[c&b];r:for(;;){if(v=w>>>24,c>>>=v,_-=v,!(16&(v=w>>>16&255))){if(0==(64&v)){w=m[(65535&w)+(c&(1<<v)-1)];continue r}t.msg="invalid distance code",r.mode=30;break t}if(k=65535&w,v&=15,_<v&&(c+=C[n++]<<_,(_+=8)<v&&(c+=C[n++]<<_,_+=8)),(k+=c&(1<<v)-1)>d){t.msg="invalid distance too far back",r.mode=30;break t}if(c>>>=v,_-=v,v=a-s,k>v){if((v=k-v)>l&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(x=0,z=u,0===f){if(x+=h-v,v<y){y-=v;do{A[a++]=u[x++]}while(--v);x=a-k,z=A}}else if(f<v){if(x+=h+f-v,(v-=f)<y){y-=v;do{A[a++]=u[x++]}while(--v);if(x=0,f<y){y-=v=f;do{A[a++]=u[x++]}while(--v);x=a-k,z=A}}}else if(x+=f-v,v<y){y-=v;do{A[a++]=u[x++]}while(--v);x=a-k,z=A}for(;y>2;)A[a++]=z[x++],A[a++]=z[x++],A[a++]=z[x++],y-=3;y&&(A[a++]=z[x++],y>1&&(A[a++]=z[x++]))}else{x=a-k;do{A[a++]=A[x++],A[a++]=A[x++],A[a++]=A[x++],y-=3}while(y>2);y&&(A[a++]=A[x++],y>1&&(A[a++]=A[x++]))}break}}break}}while(n<i&&a<o);n-=y=_>>3,c&=(1<<(_-=y<<3))-1,t.next_in=n,t.next_out=a,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=a<o?o-a+257:257-(a-o),r.hold=c,r.bits=_}},{}],35:[function(t,e,r){"use strict";function n(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function i(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new g.Buf16(320),this.work=new g.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=N,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new g.Buf32(_t),e.distcode=e.distdyn=new g.Buf32(pt),e.sane=1,e.back=-1,S):T}function s(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,a(t)):T}function o(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?T:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,s(t))):T}function d(t,e){var r,n;return t?(n=new i,t.state=n,n.window=null,(r=o(t,e))!==S&&(t.state=null),r):T}function h(t){return d(t,mt)}function l(t){if(gt){var e;for(p=new g.Buf32(512),m=new g.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(y(x,t.lens,0,288,p,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;y(z,t.lens,0,32,m,0,t.work,{bits:5}),gt=!1}t.lencode=p,t.lenbits=9,t.distcode=m,t.distbits=5}function f(t,e,r,n){var i,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new g.Buf8(a.wsize)),n>=a.wsize?(g.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),g.arraySet(a.window,e,r-n,i,a.wnext),(n-=i)?(g.arraySet(a.window,e,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function u(t,e){var r,i,a,s,o,d,h,u,c,_,p,m,_t,pt,mt,gt,bt,wt,vt,yt,kt,xt,zt,Ct,At=0,Et=new g.Buf8(4),St=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return T;(r=t.state).mode===Y&&(r.mode=W),o=t.next_out,a=t.output,h=t.avail_out,s=t.next_in,i=t.input,d=t.avail_in,u=r.hold,c=r.bits,_=d,p=h,xt=S;t:for(;;)switch(r.mode){case N:if(0===r.wrap){r.mode=W;break}for(;c<16;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(2&r.wrap&&35615===u){r.check=0,Et[0]=255&u,Et[1]=u>>>8&255,r.check=w(r.check,Et,2,0),u=0,c=0,r.mode=U;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=ft;break}if((15&u)!==D){t.msg="unknown compression method",r.mode=ft;break}if(u>>>=4,c-=4,kt=8+(15&u),0===r.wbits)r.wbits=kt;else if(kt>r.wbits){t.msg="invalid window size",r.mode=ft;break}r.dmax=1<<kt,t.adler=r.check=1,r.mode=512&u?K:Y,u=0,c=0;break;case U:for(;c<16;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(r.flags=u,(255&r.flags)!==D){t.msg="unknown compression method",r.mode=ft;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=ft;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(Et[0]=255&u,Et[1]=u>>>8&255,r.check=w(r.check,Et,2,0)),u=0,c=0,r.mode=F;case F:for(;c<32;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}r.head&&(r.head.time=u),512&r.flags&&(Et[0]=255&u,Et[1]=u>>>8&255,Et[2]=u>>>16&255,Et[3]=u>>>24&255,r.check=w(r.check,Et,4,0)),u=0,c=0,r.mode=Z;case Z:for(;c<16;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(Et[0]=255&u,Et[1]=u>>>8&255,r.check=w(r.check,Et,2,0)),u=0,c=0,r.mode=M;case M:if(1024&r.flags){for(;c<16;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(Et[0]=255&u,Et[1]=u>>>8&255,r.check=w(r.check,Et,2,0)),u=0,c=0}else r.head&&(r.head.extra=null);r.mode=P;case P:if(1024&r.flags&&((m=r.length)>d&&(m=d),m&&(r.head&&(kt=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),g.arraySet(r.head.extra,i,s,m,kt)),512&r.flags&&(r.check=w(r.check,i,m,s)),d-=m,s+=m,r.length-=m),r.length))break t;r.length=0,r.mode=j;case j:if(2048&r.flags){if(0===d)break t;m=0;do{kt=i[s+m++],r.head&&kt&&r.length<65536&&(r.head.name+=String.fromCharCode(kt))}while(kt&&m<d);if(512&r.flags&&(r.check=w(r.check,i,m,s)),d-=m,s+=m,kt)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=H;case H:if(4096&r.flags){if(0===d)break t;m=0;do{kt=i[s+m++],r.head&&kt&&r.length<65536&&(r.head.comment+=String.fromCharCode(kt))}while(kt&&m<d);if(512&r.flags&&(r.check=w(r.check,i,m,s)),d-=m,s+=m,kt)break t}else r.head&&(r.head.comment=null);r.mode=X;case X:if(512&r.flags){for(;c<16;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(u!==(65535&r.check)){t.msg="header crc mismatch",r.mode=ft;break}u=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Y;break;case K:for(;c<32;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}t.adler=r.check=n(u),u=0,c=0,r.mode=V;case V:if(0===r.havedict)return t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=d,r.hold=u,r.bits=c,I;t.adler=r.check=1,r.mode=Y;case Y:if(e===A||e===E)break t;case W:if(r.last){u>>>=7&c,c-=7&c,r.mode=dt;break}for(;c<3;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}switch(r.last=1&u,u>>>=1,c-=1,3&u){case 0:r.mode=q;break;case 1:if(l(r),r.mode=et,e===E){u>>>=2,c-=2;break t}break;case 2:r.mode=$;break;case 3:t.msg="invalid block type",r.mode=ft}u>>>=2,c-=2;break;case q:for(u>>>=7&c,c-=7&c;c<32;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if((65535&u)!=(u>>>16^65535)){t.msg="invalid stored block lengths",r.mode=ft;break}if(r.length=65535&u,u=0,c=0,r.mode=G,e===E)break t;case G:r.mode=J;case J:if(m=r.length){if(m>d&&(m=d),m>h&&(m=h),0===m)break t;g.arraySet(a,i,s,m,o),d-=m,s+=m,h-=m,o+=m,r.length-=m;break}r.mode=Y;break;case $:for(;c<14;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(r.nlen=257+(31&u),u>>>=5,c-=5,r.ndist=1+(31&u),u>>>=5,c-=5,r.ncode=4+(15&u),u>>>=4,c-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=ft;break}r.have=0,r.mode=Q;case Q:for(;r.have<r.ncode;){for(;c<3;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}r.lens[St[r.have++]]=7&u,u>>>=3,c-=3}for(;r.have<19;)r.lens[St[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,zt={bits:r.lenbits},xt=y(k,r.lens,0,19,r.lencode,0,r.work,zt),r.lenbits=zt.bits,xt){t.msg="invalid code lengths set",r.mode=ft;break}r.have=0,r.mode=tt;case tt:for(;r.have<r.nlen+r.ndist;){for(;At=r.lencode[u&(1<<r.lenbits)-1],mt=At>>>24,gt=At>>>16&255,bt=65535&At,!(mt<=c);){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(bt<16)u>>>=mt,c-=mt,r.lens[r.have++]=bt;else{if(16===bt){for(Ct=mt+2;c<Ct;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(u>>>=mt,c-=mt,0===r.have){t.msg="invalid bit length repeat",r.mode=ft;break}kt=r.lens[r.have-1],m=3+(3&u),u>>>=2,c-=2}else if(17===bt){for(Ct=mt+3;c<Ct;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}c-=mt,kt=0,m=3+(7&(u>>>=mt)),u>>>=3,c-=3}else{for(Ct=mt+7;c<Ct;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}c-=mt,kt=0,m=11+(127&(u>>>=mt)),u>>>=7,c-=7}if(r.have+m>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=ft;break}for(;m--;)r.lens[r.have++]=kt}}if(r.mode===ft)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=ft;break}if(r.lenbits=9,zt={bits:r.lenbits},xt=y(x,r.lens,0,r.nlen,r.lencode,0,r.work,zt),r.lenbits=zt.bits,xt){t.msg="invalid literal/lengths set",r.mode=ft;break}if(r.distbits=6,r.distcode=r.distdyn,zt={bits:r.distbits},xt=y(z,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,zt),r.distbits=zt.bits,xt){t.msg="invalid distances set",r.mode=ft;break}if(r.mode=et,e===E)break t;case et:r.mode=rt;case rt:if(d>=6&&h>=258){t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=d,r.hold=u,r.bits=c,v(t,p),o=t.next_out,a=t.output,h=t.avail_out,s=t.next_in,i=t.input,d=t.avail_in,u=r.hold,c=r.bits,r.mode===Y&&(r.back=-1);break}for(r.back=0;At=r.lencode[u&(1<<r.lenbits)-1],mt=At>>>24,gt=At>>>16&255,bt=65535&At,!(mt<=c);){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(gt&&0==(240&gt)){for(wt=mt,vt=gt,yt=bt;At=r.lencode[yt+((u&(1<<wt+vt)-1)>>wt)],mt=At>>>24,gt=At>>>16&255,bt=65535&At,!(wt+mt<=c);){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}u>>>=wt,c-=wt,r.back+=wt}if(u>>>=mt,c-=mt,r.back+=mt,r.length=bt,0===gt){r.mode=ot;break}if(32&gt){r.back=-1,r.mode=Y;break}if(64&gt){t.msg="invalid literal/length code",r.mode=ft;break}r.extra=15&gt,r.mode=nt;case nt:if(r.extra){for(Ct=r.extra;c<Ct;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=it;case it:for(;At=r.distcode[u&(1<<r.distbits)-1],mt=At>>>24,gt=At>>>16&255,bt=65535&At,!(mt<=c);){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(0==(240&gt)){for(wt=mt,vt=gt,yt=bt;At=r.distcode[yt+((u&(1<<wt+vt)-1)>>wt)],mt=At>>>24,gt=At>>>16&255,bt=65535&At,!(wt+mt<=c);){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}u>>>=wt,c-=wt,r.back+=wt}if(u>>>=mt,c-=mt,r.back+=mt,64&gt){t.msg="invalid distance code",r.mode=ft;break}r.offset=bt,r.extra=15&gt,r.mode=at;case at:if(r.extra){for(Ct=r.extra;c<Ct;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=ft;break}r.mode=st;case st:if(0===h)break t;if(m=p-h,r.offset>m){if((m=r.offset-m)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=ft;break}m>r.wnext?(m-=r.wnext,_t=r.wsize-m):_t=r.wnext-m,m>r.length&&(m=r.length),pt=r.window}else pt=a,_t=o-r.offset,m=r.length;m>h&&(m=h),h-=m,r.length-=m;do{a[o++]=pt[_t++]}while(--m);0===r.length&&(r.mode=rt);break;case ot:if(0===h)break t;a[o++]=r.length,h--,r.mode=rt;break;case dt:if(r.wrap){for(;c<32;){if(0===d)break t;d--,u|=i[s++]<<c,c+=8}if(p-=h,t.total_out+=p,r.total+=p,p&&(t.adler=r.check=r.flags?w(r.check,a,p,o-p):b(r.check,a,p,o-p)),p=h,(r.flags?u:n(u))!==r.check){t.msg="incorrect data check",r.mode=ft;break}u=0,c=0}r.mode=ht;case ht:if(r.wrap&&r.flags){for(;c<32;){if(0===d)break t;d--,u+=i[s++]<<c,c+=8}if(u!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=ft;break}u=0,c=0}r.mode=lt;case lt:xt=B;break t;case ft:xt=R;break t;case ut:return O;case ct:default:return T}return t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=d,r.hold=u,r.bits=c,(r.wsize||p!==t.avail_out&&r.mode<ft&&(r.mode<dt||e!==C))&&f(t,t.output,t.next_out,p-t.avail_out)?(r.mode=ut,O):(_-=t.avail_in,p-=t.avail_out,t.total_in+=_,t.total_out+=p,r.total+=p,r.wrap&&p&&(t.adler=r.check=r.flags?w(r.check,a,p,t.next_out-p):b(r.check,a,p,t.next_out-p)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Y?128:0)+(r.mode===et||r.mode===G?256:0),(0===_&&0===p||e===C)&&xt===S&&(xt=L),xt)}function c(t){if(!t||!t.state)return T;var e=t.state;return e.window&&(e.window=null),t.state=null,S}function _(t,e){var r;return t&&t.state?0==(2&(r=t.state).wrap)?T:(r.head=e,e.done=!1,S):T}var p,m,g=t("../utils/common"),b=t("./adler32"),w=t("./crc32"),v=t("./inffast"),y=t("./inftrees"),k=0,x=1,z=2,C=4,A=5,E=6,S=0,B=1,I=2,T=-2,R=-3,O=-4,L=-5,D=8,N=1,U=2,F=3,Z=4,M=5,P=6,j=7,H=8,X=9,K=10,V=11,Y=12,W=13,q=14,G=15,J=16,$=17,Q=18,tt=19,et=20,rt=21,nt=22,it=23,at=24,st=25,ot=26,dt=27,ht=28,lt=29,ft=30,ut=31,ct=32,_t=852,pt=592,mt=15,gt=!0;r.inflateReset=s,r.inflateReset2=o,r.inflateResetKeep=a,r.inflateInit=h,r.inflateInit2=d,r.inflate=u,r.inflateEnd=c,r.inflateGetHeader=_,r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./inffast":34,"./inftrees":36}],36:[function(t,e,r){"use strict";var n=t("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(t,e,r,d,h,l,f,u){var c,_,p,m,g,b,w,v,y,k=u.bits,x=0,z=0,C=0,A=0,E=0,S=0,B=0,I=0,T=0,R=0,O=null,L=0,D=new n.Buf16(16),N=new n.Buf16(16),U=null,F=0;for(x=0;x<=15;x++)D[x]=0;for(z=0;z<d;z++)D[e[r+z]]++;for(E=k,A=15;A>=1&&0===D[A];A--);if(E>A&&(E=A),0===A)return h[l++]=20971520,h[l++]=20971520,u.bits=1,0;for(C=1;C<A&&0===D[C];C++);for(E<C&&(E=C),I=1,x=1;x<=15;x++)if(I<<=1,(I-=D[x])<0)return-1;if(I>0&&(0===t||1!==A))return-1;for(N[1]=0,x=1;x<15;x++)N[x+1]=N[x]+D[x];for(z=0;z<d;z++)0!==e[r+z]&&(f[N[e[r+z]]++]=z);if(0===t?(O=U=f,b=19):1===t?(O=i,L-=257,U=a,F-=257,b=256):(O=s,U=o,b=-1),R=0,z=0,x=C,g=l,S=E,B=0,p=-1,T=1<<E,m=T-1,1===t&&T>852||2===t&&T>592)return 1;for(var Z=0;;){Z++,w=x-B,f[z]<b?(v=0,y=f[z]):f[z]>b?(v=U[F+f[z]],y=O[L+f[z]]):(v=96,y=0),c=1<<x-B,C=_=1<<S;do{h[g+(R>>B)+(_-=c)]=w<<24|v<<16|y|0}while(0!==_);for(c=1<<x-1;R&c;)c>>=1;if(0!==c?(R&=c-1,R+=c):R=0,z++,0==--D[x]){if(x===A)break;x=e[r+f[z]]}if(x>E&&(R&m)!==p){for(0===B&&(B=E),g+=C,I=1<<(S=x-B);S+B<A&&!((I-=D[S+B])<=0);)S++,I<<=1;if(T+=1<<S,1===t&&T>852||2===t&&T>592)return 1;h[p=R&m]=E<<24|S<<16|g-l|0}}return 0!==R&&(h[g+R]=x-B<<24|64<<16|0),u.bits=E,0}},{"../utils/common":27}],37:[function(t,e,r){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(t,e,r){"use strict";function n(t){for(var e=t.length;--e>=0;)t[e]=0}function i(t){return t<256?nt[t]:nt[256+(t>>>7)]}function a(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function s(t,e,r){t.bi_valid>K-r?(t.bi_buf|=e<<t.bi_valid&65535,a(t,t.bi_buf),t.bi_buf=e>>K-t.bi_valid,t.bi_valid+=r-K):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function o(t,e,r){s(t,r[2*e],r[2*e+1])}function d(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function h(t){16===t.bi_valid?(a(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}function l(t,e){var r,n,i,a,s,o,d=e.dyn_tree,h=e.max_code,l=e.stat_desc.static_tree,f=e.stat_desc.has_stree,u=e.stat_desc.extra_bits,c=e.stat_desc.extra_base,_=e.stat_desc.max_length,p=0;for(a=0;a<=X;a++)t.bl_count[a]=0;for(d[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<H;r++)(a=d[2*d[2*(n=t.heap[r])+1]+1]+1)>_&&(a=_,p++),d[2*n+1]=a,n>h||(t.bl_count[a]++,s=0,n>=c&&(s=u[n-c]),o=d[2*n],t.opt_len+=o*(a+s),f&&(t.static_len+=o*(l[2*n+1]+s)));if(0!==p){do{for(a=_-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[_]--,p-=2}while(p>0);for(a=_;0!==a;a--)for(n=t.bl_count[a];0!==n;)(i=t.heap[--r])>h||(d[2*i+1]!==a&&(t.opt_len+=(a-d[2*i+1])*d[2*i],d[2*i+1]=a),n--)}}function f(t,e,r){var n,i,a=new Array(X+1),s=0;for(n=1;n<=X;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=e;i++){var o=t[2*i+1];0!==o&&(t[2*i]=d(a[o]++,o))}}function u(){var t,e,r,n,i,a=new Array(X+1);for(r=0,n=0;n<F-1;n++)for(at[n]=r,t=0;t<1<<J[n];t++)it[r++]=n;for(it[r-1]=n,i=0,n=0;n<16;n++)for(st[n]=i,t=0;t<1<<$[n];t++)nt[i++]=n;for(i>>=7;n<P;n++)for(st[n]=i<<7,t=0;t<1<<$[n]-7;t++)nt[256+i++]=n;for(e=0;e<=X;e++)a[e]=0;for(t=0;t<=143;)et[2*t+1]=8,t++,a[8]++;for(;t<=255;)et[2*t+1]=9,t++,a[9]++;for(;t<=279;)et[2*t+1]=7,t++,a[7]++;for(;t<=287;)et[2*t+1]=8,t++,a[8]++;for(f(et,M+1,a),t=0;t<P;t++)rt[2*t+1]=5,rt[2*t]=d(t,5);ot=new lt(et,J,Z+1,M,X),dt=new lt(rt,$,0,P,X),ht=new lt(new Array(0),Q,0,j,V)}function c(t){var e;for(e=0;e<M;e++)t.dyn_ltree[2*e]=0;for(e=0;e<P;e++)t.dyn_dtree[2*e]=0;for(e=0;e<j;e++)t.bl_tree[2*e]=0;t.dyn_ltree[2*Y]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function _(t){t.bi_valid>8?a(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function p(t,e,r,n){_(t),n&&(a(t,r),a(t,~r)),I.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}function m(t,e,r,n){var i=2*e,a=2*r;return t[i]<t[a]||t[i]===t[a]&&n[e]<=n[r]}function g(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&m(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!m(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function b(t,e,r){var n,a,d,h,l=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*l]<<8|t.pending_buf[t.d_buf+2*l+1],a=t.pending_buf[t.l_buf+l],l++,0===n?o(t,a,e):(o(t,(d=it[a])+Z+1,e),0!==(h=J[d])&&s(t,a-=at[d],h),o(t,d=i(--n),r),0!==(h=$[d])&&s(t,n-=st[d],h))}while(l<t.last_lit);o(t,Y,e)}function w(t,e){var r,n,i,a=e.dyn_tree,s=e.stat_desc.static_tree,o=e.stat_desc.has_stree,d=e.stat_desc.elems,h=-1;for(t.heap_len=0,t.heap_max=H,r=0;r<d;r++)0!==a[2*r]?(t.heap[++t.heap_len]=h=r,t.depth[r]=0):a[2*r+1]=0;for(;t.heap_len<2;)a[2*(i=t.heap[++t.heap_len]=h<2?++h:0)]=1,t.depth[i]=0,t.opt_len--,o&&(t.static_len-=s[2*i+1]);for(e.max_code=h,r=t.heap_len>>1;r>=1;r--)g(t,a,r);i=d;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],g(t,a,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,a[2*i]=a[2*r]+a[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,a[2*r+1]=a[2*n+1]=i,t.heap[1]=i++,g(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],l(t,e),f(a,h,t.bl_count)}function v(t,e,r){var n,i,a=-1,s=e[1],o=0,d=7,h=4;for(0===s&&(d=138,h=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=e[2*(n+1)+1],++o<d&&i===s||(o<h?t.bl_tree[2*i]+=o:0!==i?(i!==a&&t.bl_tree[2*i]++,t.bl_tree[2*W]++):o<=10?t.bl_tree[2*q]++:t.bl_tree[2*G]++,o=0,a=i,0===s?(d=138,h=3):i===s?(d=6,h=3):(d=7,h=4))}function y(t,e,r){var n,i,a=-1,d=e[1],h=0,l=7,f=4;for(0===d&&(l=138,f=3),n=0;n<=r;n++)if(i=d,d=e[2*(n+1)+1],!(++h<l&&i===d)){if(h<f)do{o(t,i,t.bl_tree)}while(0!=--h);else 0!==i?(i!==a&&(o(t,i,t.bl_tree),h--),o(t,W,t.bl_tree),s(t,h-3,2)):h<=10?(o(t,q,t.bl_tree),s(t,h-3,3)):(o(t,G,t.bl_tree),s(t,h-11,7));h=0,a=i,0===d?(l=138,f=3):i===d?(l=6,f=3):(l=7,f=4)}}function k(t){var e;for(v(t,t.dyn_ltree,t.l_desc.max_code),v(t,t.dyn_dtree,t.d_desc.max_code),w(t,t.bl_desc),e=j-1;e>=3&&0===t.bl_tree[2*tt[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}function x(t,e,r,n){var i;for(s(t,e-257,5),s(t,r-1,5),s(t,n-4,4),i=0;i<n;i++)s(t,t.bl_tree[2*tt[i]+1],3);y(t,t.dyn_ltree,e-1),y(t,t.dyn_dtree,r-1)}function z(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return R;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return O;for(e=32;e<Z;e++)if(0!==t.dyn_ltree[2*e])return O;return R}function C(t){ut||(u(),ut=!0),t.l_desc=new ft(t.dyn_ltree,ot),t.d_desc=new ft(t.dyn_dtree,dt),t.bl_desc=new ft(t.bl_tree,ht),t.bi_buf=0,t.bi_valid=0,c(t)}function A(t,e,r,n){s(t,(D<<1)+(n?1:0),3),p(t,e,r,!0)}function E(t){s(t,N<<1,3),o(t,Y,et),h(t)}function S(t,e,r,n){var i,a,o=0;t.level>0?(t.strm.data_type===L&&(t.strm.data_type=z(t)),w(t,t.l_desc),w(t,t.d_desc),o=k(t),i=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==e?A(t,e,r,n):t.strategy===T||a===i?(s(t,(N<<1)+(n?1:0),3),b(t,et,rt)):(s(t,(U<<1)+(n?1:0),3),x(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),b(t,t.dyn_ltree,t.dyn_dtree)),c(t),n&&_(t)}function B(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(it[r]+Z+1)]++,t.dyn_dtree[2*i(e)]++),t.last_lit===t.lit_bufsize-1}var I=t("../utils/common"),T=4,R=0,O=1,L=2,D=0,N=1,U=2,F=29,Z=256,M=Z+1+F,P=30,j=19,H=2*M+1,X=15,K=16,V=7,Y=256,W=16,q=17,G=18,J=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],$=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Q=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],tt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],et=new Array(2*(M+2));n(et);var rt=new Array(2*P);n(rt);var nt=new Array(512);n(nt);var it=new Array(256);n(it);var at=new Array(F);n(at);var st=new Array(P);n(st);var ot,dt,ht,lt=function(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length},ft=function(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e},ut=!1;r._tr_init=C,r._tr_stored_block=A,r._tr_flush_block=S,r._tr_tally=B,r._tr_align=E},{"../utils/common":27}],39:[function(t,e,r){"use strict";function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}e.exports=n},{}]},{},[9])(9)});
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/amcharts/plugins/export/libs/pdfmake/pdfmake.js CHANGED
@@ -1,4 +1,15 @@
1
- /******/ (function(modules) { // webpackBootstrap
 
 
 
 
 
 
 
 
 
 
 
2
  /******/ // The module cache
3
  /******/ var installedModules = {};
4
 
@@ -42,39 +53,53 @@
42
  /************************************************************************/
43
  /******/ ([
44
  /* 0 */
45
- /***/ function(module, exports, __webpack_require__) {
46
 
47
  /* WEBPACK VAR INJECTION */(function(global) {module.exports = global["pdfMake"] = __webpack_require__(1);
48
  /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
49
 
50
- /***/ },
51
  /* 1 */
52
- /***/ function(module, exports, __webpack_require__) {
53
 
54
- /* WEBPACK VAR INJECTION */(function(Buffer) {/* jslint node: true */
55
  /* jslint browser: true */
56
- /* global BlobBuilder */
57
  'use strict';
58
 
59
  var PdfPrinter = __webpack_require__(6);
60
- var saveAs = __webpack_require__(105);
 
61
 
62
  var defaultClientFonts = {
63
  Roboto: {
64
  normal: 'Roboto-Regular.ttf',
65
  bold: 'Roboto-Medium.ttf',
66
  italics: 'Roboto-Italic.ttf',
67
- bolditalics: 'Roboto-Italic.ttf'
68
  }
69
  };
70
 
71
- function Document(docDefinition, fonts, vfs) {
72
  this.docDefinition = docDefinition;
 
73
  this.fonts = fonts || defaultClientFonts;
74
  this.vfs = vfs;
75
  }
76
 
77
- Document.prototype._createDoc = function(options, callback) {
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  var printer = new PdfPrinter(this.fonts);
79
  printer.fs.bindFS(this.vfs);
80
 
@@ -82,127 +107,169 @@
82
  var chunks = [];
83
  var result;
84
 
85
- doc.on('data', function(chunk) {
86
- chunks.push(chunk);
 
 
 
87
  });
88
- doc.on('end', function() {
89
  result = Buffer.concat(chunks);
90
  callback(result, doc._pdfMakePages);
91
  });
92
  doc.end();
93
  };
94
 
95
- Document.prototype._getPages = function(options, cb){
96
- if (!cb) throw 'getBuffer is an async method and needs a callback argument';
97
- this._createDoc(options, function(ignoreBuffer, pages){
98
- cb(pages);
99
- });
 
 
100
  };
101
 
102
- Document.prototype.open = function(message) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  // we have to open the window immediately and store the reference
104
  // otherwise popup blockers will stop us
105
- var win = window.open('', '_blank');
 
 
 
 
 
 
106
 
 
 
 
 
107
  try {
108
- this.getDataUrl(function(result) {
109
- win.location.href = result;
110
- });
111
- } catch(e) {
 
 
112
  win.close();
113
  throw e;
114
  }
115
  };
116
 
 
 
 
 
117
 
118
- Document.prototype.print = function() {
119
- this.getDataUrl(function(dataUrl) {
120
- var iFrame = document.createElement('iframe');
121
- iFrame.style.position = 'absolute';
122
- iFrame.style.left = '-99999px';
123
- iFrame.src = dataUrl;
124
- iFrame.onload = function() {
125
- function removeIFrame(){
126
- document.body.removeChild(iFrame);
127
- document.removeEventListener('click', removeIFrame);
128
- }
129
- document.addEventListener('click', removeIFrame, false);
130
- };
131
 
132
- document.body.appendChild(iFrame);
133
- }, { autoPrint: true });
 
 
 
 
 
134
  };
135
 
136
- Document.prototype.download = function(defaultFileName, cb) {
137
- if(typeof defaultFileName === "function") {
138
- cb = defaultFileName;
139
- defaultFileName = null;
140
- }
141
-
142
- defaultFileName = defaultFileName || 'file.pdf';
143
- this.getBuffer(function (result) {
144
- var blob;
145
- try {
146
- blob = new Blob([result], { type: 'application/pdf' });
147
- }
148
- catch (e) {
149
- // Old browser which can't handle it without making it an byte array (ie10)
150
- if (e.name == "InvalidStateError") {
151
- var byteArray = new Uint8Array(result);
152
- blob = new Blob([byteArray.buffer], { type: 'application/pdf' });
153
- }
154
- }
155
- if (blob) {
156
- saveAs(blob, defaultFileName);
157
- }
158
- else {
159
- throw 'Could not generate blob';
160
- }
161
- if (typeof cb === "function") {
162
- cb();
163
- }
164
- });
165
  };
166
 
167
- Document.prototype.getBase64 = function(cb, options) {
168
- if (!cb) throw 'getBase64 is an async method and needs a callback argument';
169
- this._createDoc(options, function(buffer) {
 
 
170
  cb(buffer.toString('base64'));
171
- });
172
  };
173
 
174
- Document.prototype.getDataUrl = function(cb, options) {
175
- if (!cb) throw 'getDataUrl is an async method and needs a callback argument';
176
- this._createDoc(options, function(buffer) {
 
 
177
  cb('data:application/pdf;base64,' + buffer.toString('base64'));
178
- });
179
  };
180
 
181
- Document.prototype.getBuffer = function(cb, options) {
182
- if (!cb) throw 'getBuffer is an async method and needs a callback argument';
183
- this._createDoc(options, function(buffer){
184
- cb(buffer);
185
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  };
187
 
188
  module.exports = {
189
- createPdf: function(docDefinition) {
190
- return new Document(docDefinition, window.pdfMake.fonts, window.pdfMake.vfs);
 
 
 
191
  }
192
  };
193
 
194
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer))
195
 
196
- /***/ },
197
  /* 2 */
198
- /***/ function(module, exports, __webpack_require__) {
199
 
200
- /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
201
  * The buffer module from node.js, for the browser.
202
  *
203
  * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
204
  * @license MIT
205
  */
 
 
 
206
 
207
  var base64 = __webpack_require__(3)
208
  var ieee754 = __webpack_require__(4)
@@ -211,9 +278,6 @@
211
  exports.Buffer = Buffer
212
  exports.SlowBuffer = SlowBuffer
213
  exports.INSPECT_MAX_BYTES = 50
214
- Buffer.poolSize = 8192 // not used by this implementation
215
-
216
- var rootParent = {}
217
 
218
  /**
219
  * If `Buffer.TYPED_ARRAY_SUPPORT`:
@@ -231,9 +295,6 @@
231
  * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
232
  * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
233
  *
234
- * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
235
- * on objects.
236
- *
237
  * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
238
  *
239
  * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
@@ -242,20 +303,26 @@
242
  * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
243
  * get the Object implementation, which is slower but behaves correctly.
244
  */
245
- Buffer.TYPED_ARRAY_SUPPORT = (function () {
246
- function Bar () {}
 
 
 
 
 
 
 
 
247
  try {
248
  var arr = new Uint8Array(1)
249
- arr.foo = function () { return 42 }
250
- arr.constructor = Bar
251
  return arr.foo() === 42 && // typed array instances can be augmented
252
- arr.constructor === Bar && // constructor can be set
253
  typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
254
  arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
255
  } catch (e) {
256
  return false
257
  }
258
- })()
259
 
260
  function kMaxLength () {
261
  return Buffer.TYPED_ARRAY_SUPPORT
@@ -263,172 +330,252 @@
263
  : 0x3fffffff
264
  }
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  /**
267
- * Class: Buffer
268
- * =============
269
- *
270
- * The Buffer constructor returns instances of `Uint8Array` that are augmented
271
- * with function properties for all the node `Buffer` API functions. We use
272
- * `Uint8Array` so that square bracket notation works as expected -- it returns
273
- * a single octet.
274
  *
275
- * By augmenting the instances, we can avoid modifying the `Uint8Array`
276
- * prototype.
277
  */
278
- function Buffer (arg) {
279
- if (!(this instanceof Buffer)) {
280
- // Avoid going through an ArgumentsAdaptorTrampoline in the common case.
281
- if (arguments.length > 1) return new Buffer(arg, arguments[1])
282
- return new Buffer(arg)
283
- }
284
 
285
- this.length = 0
286
- this.parent = undefined
 
 
287
 
288
  // Common case.
289
  if (typeof arg === 'number') {
290
- return fromNumber(this, arg)
 
 
 
 
 
291
  }
 
 
292
 
293
- // Slightly less common case.
294
- if (typeof arg === 'string') {
295
- return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
296
- }
297
 
298
- // Unusual.
299
- return fromObject(this, arg)
 
 
300
  }
301
 
302
- function fromNumber (that, length) {
303
- that = allocate(that, length < 0 ? 0 : checked(length) | 0)
304
- if (!Buffer.TYPED_ARRAY_SUPPORT) {
305
- for (var i = 0; i < length; i++) {
306
- that[i] = 0
307
- }
308
  }
309
- return that
310
- }
311
 
312
- function fromString (that, string, encoding) {
313
- if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
 
314
 
315
- // Assumption: byteLength() return value is always < kMaxLength.
316
- var length = byteLength(string, encoding) | 0
317
- that = allocate(that, length)
318
 
319
- that.write(string, encoding)
320
- return that
321
  }
322
 
323
- function fromObject (that, object) {
324
- if (Buffer.isBuffer(object)) return fromBuffer(that, object)
325
-
326
- if (isArray(object)) return fromArray(that, object)
 
 
 
 
 
 
 
327
 
328
- if (object == null) {
329
- throw new TypeError('must start with number, buffer, array or string')
 
 
 
 
 
 
 
 
330
  }
 
331
 
332
- if (typeof ArrayBuffer !== 'undefined') {
333
- if (object.buffer instanceof ArrayBuffer) {
334
- return fromTypedArray(that, object)
335
- }
336
- if (object instanceof ArrayBuffer) {
337
- return fromArrayBuffer(that, object)
338
- }
339
  }
 
340
 
341
- if (object.length) return fromArrayLike(that, object)
342
-
343
- return fromJsonObject(that, object)
 
 
 
 
 
 
 
 
 
 
 
344
  }
345
 
346
- function fromBuffer (that, buffer) {
347
- var length = checked(buffer.length) | 0
348
- that = allocate(that, length)
349
- buffer.copy(that, 0, 0, length)
350
- return that
 
351
  }
352
 
353
- function fromArray (that, array) {
354
- var length = checked(array.length) | 0
355
- that = allocate(that, length)
356
- for (var i = 0; i < length; i += 1) {
357
- that[i] = array[i] & 255
 
 
358
  }
359
  return that
360
  }
361
 
362
- // Duplicate of fromArray() to keep fromArray() monomorphic.
363
- function fromTypedArray (that, array) {
364
- var length = checked(array.length) | 0
365
- that = allocate(that, length)
366
- // Truncating the elements is probably not what people expect from typed
367
- // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
368
- // of the old Buffer constructor.
369
- for (var i = 0; i < length; i += 1) {
370
- that[i] = array[i] & 255
371
- }
372
- return that
373
  }
374
 
375
- function fromArrayBuffer (that, array) {
376
- if (Buffer.TYPED_ARRAY_SUPPORT) {
377
- // Return an augmented `Uint8Array` instance, for best performance
378
- array.byteLength
379
- that = Buffer._augment(new Uint8Array(array))
380
- } else {
381
- // Fallback: Return an object instance of the Buffer class
382
- that = fromTypedArray(that, new Uint8Array(array))
 
 
 
 
 
 
 
 
 
 
 
383
  }
 
384
  return that
385
  }
386
 
387
  function fromArrayLike (that, array) {
388
- var length = checked(array.length) | 0
389
- that = allocate(that, length)
390
  for (var i = 0; i < length; i += 1) {
391
  that[i] = array[i] & 255
392
  }
393
  return that
394
  }
395
 
396
- // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
397
- // Returns a zero-length buffer for inputs that don't conform to the spec.
398
- function fromJsonObject (that, object) {
399
- var array
400
- var length = 0
401
 
402
- if (object.type === 'Buffer' && isArray(object.data)) {
403
- array = object.data
404
- length = checked(array.length) | 0
405
  }
406
- that = allocate(that, length)
407
 
408
- for (var i = 0; i < length; i += 1) {
409
- that[i] = array[i] & 255
 
 
 
 
 
 
 
 
410
  }
411
- return that
412
- }
413
 
414
- function allocate (that, length) {
415
  if (Buffer.TYPED_ARRAY_SUPPORT) {
416
  // Return an augmented `Uint8Array` instance, for best performance
417
- that = Buffer._augment(new Uint8Array(length))
 
418
  } else {
419
  // Fallback: Return an object instance of the Buffer class
420
- that.length = length
421
- that._isBuffer = true
422
  }
 
 
423
 
424
- var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
425
- if (fromPool) that.parent = rootParent
 
 
426
 
427
- return that
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  }
429
 
430
  function checked (length) {
431
- // Note: cannot use `length < kMaxLength` here because that fails when
432
  // length is NaN (which is otherwise coerced to zero.)
433
  if (length >= kMaxLength()) {
434
  throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
@@ -437,12 +584,11 @@
437
  return length | 0
438
  }
439
 
440
- function SlowBuffer (subject, encoding) {
441
- if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
442
-
443
- var buf = new Buffer(subject, encoding)
444
- delete buf.parent
445
- return buf
446
  }
447
 
448
  Buffer.isBuffer = function isBuffer (b) {
@@ -459,17 +605,12 @@
459
  var x = a.length
460
  var y = b.length
461
 
462
- var i = 0
463
- var len = Math.min(x, y)
464
- while (i < len) {
465
- if (a[i] !== b[i]) break
466
-
467
- ++i
468
- }
469
-
470
- if (i !== len) {
471
- x = a[i]
472
- y = b[i]
473
  }
474
 
475
  if (x < y) return -1
@@ -483,9 +624,9 @@
483
  case 'utf8':
484
  case 'utf-8':
485
  case 'ascii':
 
486
  case 'binary':
487
  case 'base64':
488
- case 'raw':
489
  case 'ucs2':
490
  case 'ucs-2':
491
  case 'utf16le':
@@ -497,32 +638,46 @@
497
  }
498
 
499
  Buffer.concat = function concat (list, length) {
500
- if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
 
 
501
 
502
  if (list.length === 0) {
503
- return new Buffer(0)
504
  }
505
 
506
  var i
507
  if (length === undefined) {
508
  length = 0
509
- for (i = 0; i < list.length; i++) {
510
  length += list[i].length
511
  }
512
  }
513
 
514
- var buf = new Buffer(length)
515
  var pos = 0
516
- for (i = 0; i < list.length; i++) {
517
- var item = list[i]
518
- item.copy(buf, pos)
519
- pos += item.length
 
 
 
520
  }
521
- return buf
522
  }
523
 
524
  function byteLength (string, encoding) {
525
- if (typeof string !== 'string') string = '' + string
 
 
 
 
 
 
 
 
 
526
 
527
  var len = string.length
528
  if (len === 0) return 0
@@ -532,13 +687,12 @@
532
  for (;;) {
533
  switch (encoding) {
534
  case 'ascii':
 
535
  case 'binary':
536
- // Deprecated
537
- case 'raw':
538
- case 'raws':
539
  return len
540
  case 'utf8':
541
  case 'utf-8':
 
542
  return utf8ToBytes(string).length
543
  case 'ucs2':
544
  case 'ucs-2':
@@ -558,20 +712,42 @@
558
  }
559
  Buffer.byteLength = byteLength
560
 
561
- // pre-set for values that may exist in the future
562
- Buffer.prototype.length = undefined
563
- Buffer.prototype.parent = undefined
564
-
565
  function slowToString (encoding, start, end) {
566
  var loweredCase = false
567
 
568
- start = start | 0
569
- end = end === undefined || end === Infinity ? this.length : end | 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
570
 
571
  if (!encoding) encoding = 'utf8'
572
- if (start < 0) start = 0
573
- if (end > this.length) end = this.length
574
- if (end <= start) return ''
575
 
576
  while (true) {
577
  switch (encoding) {
@@ -585,8 +761,9 @@
585
  case 'ascii':
586
  return asciiSlice(this, start, end)
587
 
 
588
  case 'binary':
589
- return binarySlice(this, start, end)
590
 
591
  case 'base64':
592
  return base64Slice(this, start, end)
@@ -605,6 +782,53 @@
605
  }
606
  }
607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  Buffer.prototype.toString = function toString () {
609
  var length = this.length | 0
610
  if (length === 0) return ''
@@ -628,63 +852,197 @@
628
  return '<Buffer ' + str + '>'
629
  }
630
 
631
- Buffer.prototype.compare = function compare (b) {
632
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
633
- if (this === b) return 0
634
- return Buffer.compare(this, b)
635
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
 
637
- Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
638
- if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
639
- else if (byteOffset < -0x80000000) byteOffset = -0x80000000
640
- byteOffset >>= 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
641
 
642
- if (this.length === 0) return -1
643
- if (byteOffset >= this.length) return -1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
 
645
- // Negative offsets start from the end of the buffer
646
- if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
 
 
 
 
 
 
 
647
 
 
648
  if (typeof val === 'string') {
649
- if (val.length === 0) return -1 // special case: looking for empty string always fails
650
- return String.prototype.indexOf.call(this, val, byteOffset)
651
  }
 
 
652
  if (Buffer.isBuffer(val)) {
653
- return arrayIndexOf(this, val, byteOffset)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
654
  }
655
- if (typeof val === 'number') {
656
- if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
657
- return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  }
659
- return arrayIndexOf(this, [ val ], byteOffset)
660
  }
661
 
662
- function arrayIndexOf (arr, val, byteOffset) {
 
 
 
 
 
 
 
 
 
663
  var foundIndex = -1
664
- for (var i = 0; byteOffset + i < arr.length; i++) {
665
- if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
666
  if (foundIndex === -1) foundIndex = i
667
- if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
668
  } else {
 
669
  foundIndex = -1
670
  }
671
  }
672
- return -1
 
 
 
 
 
 
 
 
 
 
 
673
  }
674
 
675
- throw new TypeError('val must be string, number or Buffer')
676
  }
677
 
678
- // `get` is deprecated
679
- Buffer.prototype.get = function get (offset) {
680
- console.log('.get() is deprecated. Access using array indexes instead.')
681
- return this.readUInt8(offset)
682
  }
683
 
684
- // `set` is deprecated
685
- Buffer.prototype.set = function set (v, offset) {
686
- console.log('.set() is deprecated. Access using array indexes instead.')
687
- return this.writeUInt8(v, offset)
 
 
688
  }
689
 
690
  function hexWrite (buf, string, offset, length) {
@@ -701,14 +1059,14 @@
701
 
702
  // must be an even number of digits
703
  var strLen = string.length
704
- if (strLen % 2 !== 0) throw new Error('Invalid hex string')
705
 
706
  if (length > strLen / 2) {
707
  length = strLen / 2
708
  }
709
- for (var i = 0; i < length; i++) {
710
  var parsed = parseInt(string.substr(i * 2, 2), 16)
711
- if (isNaN(parsed)) throw new Error('Invalid hex string')
712
  buf[offset + i] = parsed
713
  }
714
  return i
@@ -722,7 +1080,7 @@
722
  return blitBuffer(asciiToBytes(string), buf, offset, length)
723
  }
724
 
725
- function binaryWrite (buf, string, offset, length) {
726
  return asciiWrite(buf, string, offset, length)
727
  }
728
 
@@ -757,17 +1115,16 @@
757
  }
758
  // legacy write(string, encoding, offset, length) - remove in v0.13
759
  } else {
760
- var swap = encoding
761
- encoding = offset
762
- offset = length | 0
763
- length = swap
764
  }
765
 
766
  var remaining = this.length - offset
767
  if (length === undefined || length > remaining) length = remaining
768
 
769
  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
770
- throw new RangeError('attempt to write outside buffer bounds')
771
  }
772
 
773
  if (!encoding) encoding = 'utf8'
@@ -785,8 +1142,9 @@
785
  case 'ascii':
786
  return asciiWrite(this, string, offset, length)
787
 
 
788
  case 'binary':
789
- return binaryWrite(this, string, offset, length)
790
 
791
  case 'base64':
792
  // Warning: maxLength not taken into account in base64Write
@@ -921,17 +1279,17 @@
921
  var ret = ''
922
  end = Math.min(buf.length, end)
923
 
924
- for (var i = start; i < end; i++) {
925
  ret += String.fromCharCode(buf[i] & 0x7F)
926
  }
927
  return ret
928
  }
929
 
930
- function binarySlice (buf, start, end) {
931
  var ret = ''
932
  end = Math.min(buf.length, end)
933
 
934
- for (var i = start; i < end; i++) {
935
  ret += String.fromCharCode(buf[i])
936
  }
937
  return ret
@@ -944,7 +1302,7 @@
944
  if (!end || end < 0 || end > len) end = len
945
 
946
  var out = ''
947
- for (var i = start; i < end; i++) {
948
  out += toHex(buf[i])
949
  }
950
  return out
@@ -982,17 +1340,16 @@
982
 
983
  var newBuf
984
  if (Buffer.TYPED_ARRAY_SUPPORT) {
985
- newBuf = Buffer._augment(this.subarray(start, end))
 
986
  } else {
987
  var sliceLen = end - start
988
  newBuf = new Buffer(sliceLen, undefined)
989
- for (var i = 0; i < sliceLen; i++) {
990
  newBuf[i] = this[i + start]
991
  }
992
  }
993
 
994
- if (newBuf.length) newBuf.parent = this.parent || this
995
-
996
  return newBuf
997
  }
998
 
@@ -1161,16 +1518,19 @@
1161
  }
1162
 
1163
  function checkInt (buf, value, offset, ext, max, min) {
1164
- if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
1165
- if (value > max || value < min) throw new RangeError('value is out of bounds')
1166
- if (offset + ext > buf.length) throw new RangeError('index out of range')
1167
  }
1168
 
1169
  Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1170
  value = +value
1171
  offset = offset | 0
1172
  byteLength = byteLength | 0
1173
- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
 
 
 
1174
 
1175
  var mul = 1
1176
  var i = 0
@@ -1186,7 +1546,10 @@
1186
  value = +value
1187
  offset = offset | 0
1188
  byteLength = byteLength | 0
1189
- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
 
 
 
1190
 
1191
  var i = byteLength - 1
1192
  var mul = 1
@@ -1203,13 +1566,13 @@
1203
  offset = offset | 0
1204
  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1205
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1206
- this[offset] = value
1207
  return offset + 1
1208
  }
1209
 
1210
  function objectWriteUInt16 (buf, value, offset, littleEndian) {
1211
  if (value < 0) value = 0xffff + value + 1
1212
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
1213
  buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1214
  (littleEndian ? i : 1 - i) * 8
1215
  }
@@ -1220,7 +1583,7 @@
1220
  offset = offset | 0
1221
  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1222
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1223
- this[offset] = value
1224
  this[offset + 1] = (value >>> 8)
1225
  } else {
1226
  objectWriteUInt16(this, value, offset, true)
@@ -1234,7 +1597,7 @@
1234
  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1235
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1236
  this[offset] = (value >>> 8)
1237
- this[offset + 1] = value
1238
  } else {
1239
  objectWriteUInt16(this, value, offset, false)
1240
  }
@@ -1243,7 +1606,7 @@
1243
 
1244
  function objectWriteUInt32 (buf, value, offset, littleEndian) {
1245
  if (value < 0) value = 0xffffffff + value + 1
1246
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
1247
  buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1248
  }
1249
  }
@@ -1256,7 +1619,7 @@
1256
  this[offset + 3] = (value >>> 24)
1257
  this[offset + 2] = (value >>> 16)
1258
  this[offset + 1] = (value >>> 8)
1259
- this[offset] = value
1260
  } else {
1261
  objectWriteUInt32(this, value, offset, true)
1262
  }
@@ -1271,7 +1634,7 @@
1271
  this[offset] = (value >>> 24)
1272
  this[offset + 1] = (value >>> 16)
1273
  this[offset + 2] = (value >>> 8)
1274
- this[offset + 3] = value
1275
  } else {
1276
  objectWriteUInt32(this, value, offset, false)
1277
  }
@@ -1289,9 +1652,12 @@
1289
 
1290
  var i = 0
1291
  var mul = 1
1292
- var sub = value < 0 ? 1 : 0
1293
  this[offset] = value & 0xFF
1294
  while (++i < byteLength && (mul *= 0x100)) {
 
 
 
1295
  this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1296
  }
1297
 
@@ -1309,9 +1675,12 @@
1309
 
1310
  var i = byteLength - 1
1311
  var mul = 1
1312
- var sub = value < 0 ? 1 : 0
1313
  this[offset + i] = value & 0xFF
1314
  while (--i >= 0 && (mul *= 0x100)) {
 
 
 
1315
  this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1316
  }
1317
 
@@ -1324,7 +1693,7 @@
1324
  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1325
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1326
  if (value < 0) value = 0xff + value + 1
1327
- this[offset] = value
1328
  return offset + 1
1329
  }
1330
 
@@ -1333,7 +1702,7 @@
1333
  offset = offset | 0
1334
  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1335
  if (Buffer.TYPED_ARR
1
+ /*! pdfmake v0.1.29, @license MIT, @link http://pdfmake.org */
2
+ (function webpackUniversalModuleDefinition(root, factory) {
3
+ if(typeof exports === 'object' && typeof module === 'object')
4
+ module.exports = factory();
5
+ else if(typeof define === 'function' && define.amd)
6
+ define([], factory);
7
+ else {
8
+ var a = factory();
9
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
10
+ }
11
+ })(this, function() {
12
+ return /******/ (function(modules) { // webpackBootstrap
13
  /******/ // The module cache
14
  /******/ var installedModules = {};
15
 
53
  /************************************************************************/
54
  /******/ ([
55
  /* 0 */
56
+ /***/ (function(module, exports, __webpack_require__) {
57
 
58
  /* WEBPACK VAR INJECTION */(function(global) {module.exports = global["pdfMake"] = __webpack_require__(1);
59
  /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
60
 
61
+ /***/ }),
62
  /* 1 */
63
+ /***/ (function(module, exports, __webpack_require__) {
64
 
65
+ /* WEBPACK VAR INJECTION */(function(Buffer, global) {/* jslint node: true */
66
  /* jslint browser: true */
 
67
  'use strict';
68
 
69
  var PdfPrinter = __webpack_require__(6);
70
+ var FileSaver = __webpack_require__(300);
71
+ var saveAs = FileSaver.saveAs;
72
 
73
  var defaultClientFonts = {
74
  Roboto: {
75
  normal: 'Roboto-Regular.ttf',
76
  bold: 'Roboto-Medium.ttf',
77
  italics: 'Roboto-Italic.ttf',
78
+ bolditalics: 'Roboto-MediumItalic.ttf'
79
  }
80
  };
81
 
82
+ function Document(docDefinition, tableLayouts, fonts, vfs) {
83
  this.docDefinition = docDefinition;
84
+ this.tableLayouts = tableLayouts || null;
85
  this.fonts = fonts || defaultClientFonts;
86
  this.vfs = vfs;
87
  }
88
 
89
+ function canCreatePdf() {
90
+ // Ensure the browser provides the level of support needed
91
+ if (!Object.keys) {
92
+ return false;
93
+ }
94
+ return true;
95
+ }
96
+
97
+ Document.prototype._createDoc = function (options, callback) {
98
+ options = options || {};
99
+ if (this.tableLayouts) {
100
+ options.tableLayouts = this.tableLayouts;
101
+ }
102
+
103
  var printer = new PdfPrinter(this.fonts);
104
  printer.fs.bindFS(this.vfs);
105
 
107
  var chunks = [];
108
  var result;
109
 
110
+ doc.on('readable', function () {
111
+ var chunk;
112
+ while ((chunk = doc.read(9007199254740991)) !== null) {
113
+ chunks.push(chunk);
114
+ }
115
  });
116
+ doc.on('end', function () {
117
  result = Buffer.concat(chunks);
118
  callback(result, doc._pdfMakePages);
119
  });
120
  doc.end();
121
  };
122
 
123
+ Document.prototype._getPages = function (options, cb) {
124
+ if (!cb) {
125
+ throw '_getPages is an async method and needs a callback argument';
126
+ }
127
+ this._createDoc(options, function (ignoreBuffer, pages) {
128
+ cb(pages);
129
+ });
130
  };
131
 
132
+ Document.prototype._bufferToBlob = function (buffer) {
133
+ var blob;
134
+ try {
135
+ blob = new Blob([buffer], {type: 'application/pdf'});
136
+ } catch (e) {
137
+ // Old browser which can't handle it without making it an byte array (ie10)
138
+ if (e.name === 'InvalidStateError') {
139
+ var byteArray = new Uint8Array(buffer);
140
+ blob = new Blob([byteArray.buffer], {type: 'application/pdf'});
141
+ }
142
+ }
143
+
144
+ if (!blob) {
145
+ throw 'Could not generate blob';
146
+ }
147
+
148
+ return blob;
149
+ };
150
+
151
+ Document.prototype._openWindow = function () {
152
  // we have to open the window immediately and store the reference
153
  // otherwise popup blockers will stop us
154
+ var win = global.open('', '_blank');
155
+ if (win === null) {
156
+ throw 'Open PDF in new window blocked by browser';
157
+ }
158
+
159
+ return win;
160
+ };
161
 
162
+ Document.prototype._openPdf = function (options, win) {
163
+ if (!win) {
164
+ win = this._openWindow();
165
+ }
166
  try {
167
+ this.getBlob(function (result) {
168
+ var urlCreator = global.URL || global.webkitURL;
169
+ var pdfUrl = urlCreator.createObjectURL(result);
170
+ win.location.href = pdfUrl;
171
+ }, options);
172
+ } catch (e) {
173
  win.close();
174
  throw e;
175
  }
176
  };
177
 
178
+ Document.prototype.open = function (options, win) {
179
+ options = options || {};
180
+ options.autoPrint = false;
181
+ win = win || null;
182
 
183
+ this._openPdf(options, win);
184
+ };
 
 
 
 
 
 
 
 
 
 
 
185
 
186
+
187
+ Document.prototype.print = function (options, win) {
188
+ options = options || {};
189
+ options.autoPrint = true;
190
+ win = win || null;
191
+
192
+ this._openPdf(options, win);
193
  };
194
 
195
+ Document.prototype.download = function (defaultFileName, cb, options) {
196
+ if (typeof defaultFileName === 'function') {
197
+ cb = defaultFileName;
198
+ defaultFileName = null;
199
+ }
200
+
201
+ defaultFileName = defaultFileName || 'file.pdf';
202
+ this.getBlob(function (result) {
203
+ saveAs(result, defaultFileName);
204
+
205
+ if (typeof cb === 'function') {
206
+ cb();
207
+ }
208
+ }, options);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  };
210
 
211
+ Document.prototype.getBase64 = function (cb, options) {
212
+ if (!cb) {
213
+ throw 'getBase64 is an async method and needs a callback argument';
214
+ }
215
+ this.getBuffer(function (buffer) {
216
  cb(buffer.toString('base64'));
217
+ }, options);
218
  };
219
 
220
+ Document.prototype.getDataUrl = function (cb, options) {
221
+ if (!cb) {
222
+ throw 'getDataUrl is an async method and needs a callback argument';
223
+ }
224
+ this.getBuffer(function (buffer) {
225
  cb('data:application/pdf;base64,' + buffer.toString('base64'));
226
+ }, options);
227
  };
228
 
229
+ Document.prototype.getBlob = function (cb, options) {
230
+ if (!cb) {
231
+ throw 'getBlob is an async method and needs a callback argument';
232
+ }
233
+ var that = this;
234
+ this.getBuffer(function (result) {
235
+ var blob = that._bufferToBlob(result);
236
+ cb(blob);
237
+ }, options);
238
+ };
239
+
240
+ Document.prototype.getBuffer = function (cb, options) {
241
+ if (!cb) {
242
+ throw 'getBuffer is an async method and needs a callback argument';
243
+ }
244
+ this._createDoc(options, function (buffer) {
245
+ cb(buffer);
246
+ });
247
  };
248
 
249
  module.exports = {
250
+ createPdf: function (docDefinition) {
251
+ if (!canCreatePdf()) {
252
+ throw 'Your browser does not provide the level of support needed';
253
+ }
254
+ return new Document(docDefinition, global.pdfMake.tableLayouts, global.pdfMake.fonts, global.pdfMake.vfs);
255
  }
256
  };
257
 
258
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer, (function() { return this; }())))
259
 
260
+ /***/ }),
261
  /* 2 */
262
+ /***/ (function(module, exports, __webpack_require__) {
263
 
264
+ /* WEBPACK VAR INJECTION */(function(global) {/*!
265
  * The buffer module from node.js, for the browser.
266
  *
267
  * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
268
  * @license MIT
269
  */
270
+ /* eslint-disable no-proto */
271
+
272
+ 'use strict'
273
 
274
  var base64 = __webpack_require__(3)
275
  var ieee754 = __webpack_require__(4)
278
  exports.Buffer = Buffer
279
  exports.SlowBuffer = SlowBuffer
280
  exports.INSPECT_MAX_BYTES = 50
 
 
 
281
 
282
  /**
283
  * If `Buffer.TYPED_ARRAY_SUPPORT`:
295
  * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
296
  * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
297
  *
 
 
 
298
  * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
299
  *
300
  * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
303
  * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
304
  * get the Object implementation, which is slower but behaves correctly.
305
  */
306
+ Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
307
+ ? global.TYPED_ARRAY_SUPPORT
308
+ : typedArraySupport()
309
+
310
+ /*
311
+ * Export kMaxLength after typed array support is determined.
312
+ */
313
+ exports.kMaxLength = kMaxLength()
314
+
315
+ function typedArraySupport () {
316
  try {
317
  var arr = new Uint8Array(1)
318
+ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
 
319
  return arr.foo() === 42 && // typed array instances can be augmented
 
320
  typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
321
  arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
322
  } catch (e) {
323
  return false
324
  }
325
+ }
326
 
327
  function kMaxLength () {
328
  return Buffer.TYPED_ARRAY_SUPPORT
330
  : 0x3fffffff
331
  }
332
 
333
+ function createBuffer (that, length) {
334
+ if (kMaxLength() < length) {
335
+ throw new RangeError('Invalid typed array length')
336
+ }
337
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
338
+ // Return an augmented `Uint8Array` instance, for best performance
339
+ that = new Uint8Array(length)
340
+ that.__proto__ = Buffer.prototype
341
+ } else {
342
+ // Fallback: Return an object instance of the Buffer class
343
+ if (that === null) {
344
+ that = new Buffer(length)
345
+ }
346
+ that.length = length
347
+ }
348
+
349
+ return that
350
+ }
351
+
352
  /**
353
+ * The Buffer constructor returns instances of `Uint8Array` that have their
354
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
355
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
356
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
357
+ * returns a single octet.
 
 
358
  *
359
+ * The `Uint8Array` prototype remains unmodified.
 
360
  */
 
 
 
 
 
 
361
 
362
+ function Buffer (arg, encodingOrOffset, length) {
363
+ if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
364
+ return new Buffer(arg, encodingOrOffset, length)
365
+ }
366
 
367
  // Common case.
368
  if (typeof arg === 'number') {
369
+ if (typeof encodingOrOffset === 'string') {
370
+ throw new Error(
371
+ 'If encoding is specified then the first argument must be a string'
372
+ )
373
+ }
374
+ return allocUnsafe(this, arg)
375
  }
376
+ return from(this, arg, encodingOrOffset, length)
377
+ }
378
 
379
+ Buffer.poolSize = 8192 // not used by this implementation
 
 
 
380
 
381
+ // TODO: Legacy, not needed anymore. Remove in next major version.
382
+ Buffer._augment = function (arr) {
383
+ arr.__proto__ = Buffer.prototype
384
+ return arr
385
  }
386
 
387
+ function from (that, value, encodingOrOffset, length) {
388
+ if (typeof value === 'number') {
389
+ throw new TypeError('"value" argument must not be a number')
 
 
 
390
  }
 
 
391
 
392
+ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
393
+ return fromArrayBuffer(that, value, encodingOrOffset, length)
394
+ }
395
 
396
+ if (typeof value === 'string') {
397
+ return fromString(that, value, encodingOrOffset)
398
+ }
399
 
400
+ return fromObject(that, value)
 
401
  }
402
 
403
+ /**
404
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
405
+ * if value is a number.
406
+ * Buffer.from(str[, encoding])
407
+ * Buffer.from(array)
408
+ * Buffer.from(buffer)
409
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
410
+ **/
411
+ Buffer.from = function (value, encodingOrOffset, length) {
412
+ return from(null, value, encodingOrOffset, length)
413
+ }
414
 
415
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
416
+ Buffer.prototype.__proto__ = Uint8Array.prototype
417
+ Buffer.__proto__ = Uint8Array
418
+ if (typeof Symbol !== 'undefined' && Symbol.species &&
419
+ Buffer[Symbol.species] === Buffer) {
420
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
421
+ Object.defineProperty(Buffer, Symbol.species, {
422
+ value: null,
423
+ configurable: true
424
+ })
425
  }
426
+ }
427
 
428
+ function assertSize (size) {
429
+ if (typeof size !== 'number') {
430
+ throw new TypeError('"size" argument must be a number')
431
+ } else if (size < 0) {
432
+ throw new RangeError('"size" argument must not be negative')
 
 
433
  }
434
+ }
435
 
436
+ function alloc (that, size, fill, encoding) {
437
+ assertSize(size)
438
+ if (size <= 0) {
439
+ return createBuffer(that, size)
440
+ }
441
+ if (fill !== undefined) {
442
+ // Only pay attention to encoding if it's a string. This
443
+ // prevents accidentally sending in a number that would
444
+ // be interpretted as a start offset.
445
+ return typeof encoding === 'string'
446
+ ? createBuffer(that, size).fill(fill, encoding)
447
+ : createBuffer(that, size).fill(fill)
448
+ }
449
+ return createBuffer(that, size)
450
  }
451
 
452
+ /**
453
+ * Creates a new filled Buffer instance.
454
+ * alloc(size[, fill[, encoding]])
455
+ **/
456
+ Buffer.alloc = function (size, fill, encoding) {
457
+ return alloc(null, size, fill, encoding)
458
  }
459
 
460
+ function allocUnsafe (that, size) {
461
+ assertSize(size)
462
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
463
+ if (!Buffer.TYPED_ARRAY_SUPPORT) {
464
+ for (var i = 0; i < size; ++i) {
465
+ that[i] = 0
466
+ }
467
  }
468
  return that
469
  }
470
 
471
+ /**
472
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
473
+ * */
474
+ Buffer.allocUnsafe = function (size) {
475
+ return allocUnsafe(null, size)
476
+ }
477
+ /**
478
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
479
+ */
480
+ Buffer.allocUnsafeSlow = function (size) {
481
+ return allocUnsafe(null, size)
482
  }
483
 
484
+ function fromString (that, string, encoding) {
485
+ if (typeof encoding !== 'string' || encoding === '') {
486
+ encoding = 'utf8'
487
+ }
488
+
489
+ if (!Buffer.isEncoding(encoding)) {
490
+ throw new TypeError('"encoding" must be a valid string encoding')
491
+ }
492
+
493
+ var length = byteLength(string, encoding) | 0
494
+ that = createBuffer(that, length)
495
+
496
+ var actual = that.write(string, encoding)
497
+
498
+ if (actual !== length) {
499
+ // Writing a hex string, for example, that contains invalid characters will
500
+ // cause everything after the first invalid character to be ignored. (e.g.
501
+ // 'abxxcd' will be treated as 'ab')
502
+ that = that.slice(0, actual)
503
  }
504
+
505
  return that
506
  }
507
 
508
  function fromArrayLike (that, array) {
509
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
510
+ that = createBuffer(that, length)
511
  for (var i = 0; i < length; i += 1) {
512
  that[i] = array[i] & 255
513
  }
514
  return that
515
  }
516
 
517
+ function fromArrayBuffer (that, array, byteOffset, length) {
518
+ array.byteLength // this throws if `array` is not a valid ArrayBuffer
 
 
 
519
 
520
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
521
+ throw new RangeError('\'offset\' is out of bounds')
 
522
  }
 
523
 
524
+ if (array.byteLength < byteOffset + (length || 0)) {
525
+ throw new RangeError('\'length\' is out of bounds')
526
+ }
527
+
528
+ if (byteOffset === undefined && length === undefined) {
529
+ array = new Uint8Array(array)
530
+ } else if (length === undefined) {
531
+ array = new Uint8Array(array, byteOffset)
532
+ } else {
533
+ array = new Uint8Array(array, byteOffset, length)
534
  }
 
 
535
 
 
536
  if (Buffer.TYPED_ARRAY_SUPPORT) {
537
  // Return an augmented `Uint8Array` instance, for best performance
538
+ that = array
539
+ that.__proto__ = Buffer.prototype
540
  } else {
541
  // Fallback: Return an object instance of the Buffer class
542
+ that = fromArrayLike(that, array)
 
543
  }
544
+ return that
545
+ }
546
 
547
+ function fromObject (that, obj) {
548
+ if (Buffer.isBuffer(obj)) {
549
+ var len = checked(obj.length) | 0
550
+ that = createBuffer(that, len)
551
 
552
+ if (that.length === 0) {
553
+ return that
554
+ }
555
+
556
+ obj.copy(that, 0, 0, len)
557
+ return that
558
+ }
559
+
560
+ if (obj) {
561
+ if ((typeof ArrayBuffer !== 'undefined' &&
562
+ obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
563
+ if (typeof obj.length !== 'number' || isnan(obj.length)) {
564
+ return createBuffer(that, 0)
565
+ }
566
+ return fromArrayLike(that, obj)
567
+ }
568
+
569
+ if (obj.type === 'Buffer' && isArray(obj.data)) {
570
+ return fromArrayLike(that, obj.data)
571
+ }
572
+ }
573
+
574
+ throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
575
  }
576
 
577
  function checked (length) {
578
+ // Note: cannot use `length < kMaxLength()` here because that fails when
579
  // length is NaN (which is otherwise coerced to zero.)
580
  if (length >= kMaxLength()) {
581
  throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
584
  return length | 0
585
  }
586
 
587
+ function SlowBuffer (length) {
588
+ if (+length != length) { // eslint-disable-line eqeqeq
589
+ length = 0
590
+ }
591
+ return Buffer.alloc(+length)
 
592
  }
593
 
594
  Buffer.isBuffer = function isBuffer (b) {
605
  var x = a.length
606
  var y = b.length
607
 
608
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
609
+ if (a[i] !== b[i]) {
610
+ x = a[i]
611
+ y = b[i]
612
+ break
613
+ }
 
 
 
 
 
614
  }
615
 
616
  if (x < y) return -1
624
  case 'utf8':
625
  case 'utf-8':
626
  case 'ascii':
627
+ case 'latin1':
628
  case 'binary':
629
  case 'base64':
 
630
  case 'ucs2':
631
  case 'ucs-2':
632
  case 'utf16le':
638
  }
639
 
640
  Buffer.concat = function concat (list, length) {
641
+ if (!isArray(list)) {
642
+ throw new TypeError('"list" argument must be an Array of Buffers')
643
+ }
644
 
645
  if (list.length === 0) {
646
+ return Buffer.alloc(0)
647
  }
648
 
649
  var i
650
  if (length === undefined) {
651
  length = 0
652
+ for (i = 0; i < list.length; ++i) {
653
  length += list[i].length
654
  }
655
  }
656
 
657
+ var buffer = Buffer.allocUnsafe(length)
658
  var pos = 0
659
+ for (i = 0; i < list.length; ++i) {
660
+ var buf = list[i]
661
+ if (!Buffer.isBuffer(buf)) {
662
+ throw new TypeError('"list" argument must be an Array of Buffers')
663
+ }
664
+ buf.copy(buffer, pos)
665
+ pos += buf.length
666
  }
667
+ return buffer
668
  }
669
 
670
  function byteLength (string, encoding) {
671
+ if (Buffer.isBuffer(string)) {
672
+ return string.length
673
+ }
674
+ if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
675
+ (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
676
+ return string.byteLength
677
+ }
678
+ if (typeof string !== 'string') {
679
+ string = '' + string
680
+ }
681
 
682
  var len = string.length
683
  if (len === 0) return 0
687
  for (;;) {
688
  switch (encoding) {
689
  case 'ascii':
690
+ case 'latin1':
691
  case 'binary':
 
 
 
692
  return len
693
  case 'utf8':
694
  case 'utf-8':
695
+ case undefined:
696
  return utf8ToBytes(string).length
697
  case 'ucs2':
698
  case 'ucs-2':
712
  }
713
  Buffer.byteLength = byteLength
714
 
 
 
 
 
715
  function slowToString (encoding, start, end) {
716
  var loweredCase = false
717
 
718
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
719
+ // property of a typed array.
720
+
721
+ // This behaves neither like String nor Uint8Array in that we set start/end
722
+ // to their upper/lower bounds if the value passed is out of range.
723
+ // undefined is handled specially as per ECMA-262 6th Edition,
724
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
725
+ if (start === undefined || start < 0) {
726
+ start = 0
727
+ }
728
+ // Return early if start > this.length. Done here to prevent potential uint32
729
+ // coercion fail below.
730
+ if (start > this.length) {
731
+ return ''
732
+ }
733
+
734
+ if (end === undefined || end > this.length) {
735
+ end = this.length
736
+ }
737
+
738
+ if (end <= 0) {
739
+ return ''
740
+ }
741
+
742
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
743
+ end >>>= 0
744
+ start >>>= 0
745
+
746
+ if (end <= start) {
747
+ return ''
748
+ }
749
 
750
  if (!encoding) encoding = 'utf8'
 
 
 
751
 
752
  while (true) {
753
  switch (encoding) {
761
  case 'ascii':
762
  return asciiSlice(this, start, end)
763
 
764
+ case 'latin1':
765
  case 'binary':
766
+ return latin1Slice(this, start, end)
767
 
768
  case 'base64':
769
  return base64Slice(this, start, end)
782
  }
783
  }
784
 
785
+ // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
786
+ // Buffer instances.
787
+ Buffer.prototype._isBuffer = true
788
+
789
+ function swap (b, n, m) {
790
+ var i = b[n]
791
+ b[n] = b[m]
792
+ b[m] = i
793
+ }
794
+
795
+ Buffer.prototype.swap16 = function swap16 () {
796
+ var len = this.length
797
+ if (len % 2 !== 0) {
798
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
799
+ }
800
+ for (var i = 0; i < len; i += 2) {
801
+ swap(this, i, i + 1)
802
+ }
803
+ return this
804
+ }
805
+
806
+ Buffer.prototype.swap32 = function swap32 () {
807
+ var len = this.length
808
+ if (len % 4 !== 0) {
809
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
810
+ }
811
+ for (var i = 0; i < len; i += 4) {
812
+ swap(this, i, i + 3)
813
+ swap(this, i + 1, i + 2)
814
+ }
815
+ return this
816
+ }
817
+
818
+ Buffer.prototype.swap64 = function swap64 () {
819
+ var len = this.length
820
+ if (len % 8 !== 0) {
821
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
822
+ }
823
+ for (var i = 0; i < len; i += 8) {
824
+ swap(this, i, i + 7)
825
+ swap(this, i + 1, i + 6)
826
+ swap(this, i + 2, i + 5)
827
+ swap(this, i + 3, i + 4)
828
+ }
829
+ return this
830
+ }
831
+
832
  Buffer.prototype.toString = function toString () {
833
  var length = this.length | 0
834
  if (length === 0) return ''
852
  return '<Buffer ' + str + '>'
853
  }
854
 
855
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
856
+ if (!Buffer.isBuffer(target)) {
857
+ throw new TypeError('Argument must be a Buffer')
858
+ }
859
+
860
+ if (start === undefined) {
861
+ start = 0
862
+ }
863
+ if (end === undefined) {
864
+ end = target ? target.length : 0
865
+ }
866
+ if (thisStart === undefined) {
867
+ thisStart = 0
868
+ }
869
+ if (thisEnd === undefined) {
870
+ thisEnd = this.length
871
+ }
872
+
873
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
874
+ throw new RangeError('out of range index')
875
+ }
876
 
877
+ if (thisStart >= thisEnd && start >= end) {
878
+ return 0
879
+ }
880
+ if (thisStart >= thisEnd) {
881
+ return -1
882
+ }
883
+ if (start >= end) {
884
+ return 1
885
+ }
886
+
887
+ start >>>= 0
888
+ end >>>= 0
889
+ thisStart >>>= 0
890
+ thisEnd >>>= 0
891
+
892
+ if (this === target) return 0
893
+
894
+ var x = thisEnd - thisStart
895
+ var y = end - start
896
+ var len = Math.min(x, y)
897
+
898
+ var thisCopy = this.slice(thisStart, thisEnd)
899
+ var targetCopy = target.slice(start, end)
900
+
901
+ for (var i = 0; i < len; ++i) {
902
+ if (thisCopy[i] !== targetCopy[i]) {
903
+ x = thisCopy[i]
904
+ y = targetCopy[i]
905
+ break
906
+ }
907
+ }
908
+
909
+ if (x < y) return -1
910
+ if (y < x) return 1
911
+ return 0
912
+ }
913
 
914
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
915
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
916
+ //
917
+ // Arguments:
918
+ // - buffer - a Buffer to search
919
+ // - val - a string, Buffer, or number
920
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
921
+ // - encoding - an optional encoding, relevant is val is a string
922
+ // - dir - true for indexOf, false for lastIndexOf
923
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
924
+ // Empty buffer means no match
925
+ if (buffer.length === 0) return -1
926
+
927
+ // Normalize byteOffset
928
+ if (typeof byteOffset === 'string') {
929
+ encoding = byteOffset
930
+ byteOffset = 0
931
+ } else if (byteOffset > 0x7fffffff) {
932
+ byteOffset = 0x7fffffff
933
+ } else if (byteOffset < -0x80000000) {
934
+ byteOffset = -0x80000000
935
+ }
936
+ byteOffset = +byteOffset // Coerce to Number.
937
+ if (isNaN(byteOffset)) {
938
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
939
+ byteOffset = dir ? 0 : (buffer.length - 1)
940
+ }
941
 
942
+ // Normalize byteOffset: negative offsets start from the end of the buffer
943
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
944
+ if (byteOffset >= buffer.length) {
945
+ if (dir) return -1
946
+ else byteOffset = buffer.length - 1
947
+ } else if (byteOffset < 0) {
948
+ if (dir) byteOffset = 0
949
+ else return -1
950
+ }
951
 
952
+ // Normalize val
953
  if (typeof val === 'string') {
954
+ val = Buffer.from(val, encoding)
 
955
  }
956
+
957
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
958
  if (Buffer.isBuffer(val)) {
959
+ // Special case: looking for empty string/buffer always fails
960
+ if (val.length === 0) {
961
+ return -1
962
+ }
963
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
964
+ } else if (typeof val === 'number') {
965
+ val = val & 0xFF // Search for a byte value [0-255]
966
+ if (Buffer.TYPED_ARRAY_SUPPORT &&
967
+ typeof Uint8Array.prototype.indexOf === 'function') {
968
+ if (dir) {
969
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
970
+ } else {
971
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
972
+ }
973
+ }
974
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
975
  }
976
+
977
+ throw new TypeError('val must be string, number or Buffer')
978
+ }
979
+
980
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
981
+ var indexSize = 1
982
+ var arrLength = arr.length
983
+ var valLength = val.length
984
+
985
+ if (encoding !== undefined) {
986
+ encoding = String(encoding).toLowerCase()
987
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
988
+ encoding === 'utf16le' || encoding === 'utf-16le') {
989
+ if (arr.length < 2 || val.length < 2) {
990
+ return -1
991
+ }
992
+ indexSize = 2
993
+ arrLength /= 2
994
+ valLength /= 2
995
+ byteOffset /= 2
996
  }
 
997
  }
998
 
999
+ function read (buf, i) {
1000
+ if (indexSize === 1) {
1001
+ return buf[i]
1002
+ } else {
1003
+ return buf.readUInt16BE(i * indexSize)
1004
+ }
1005
+ }
1006
+
1007
+ var i
1008
+ if (dir) {
1009
  var foundIndex = -1
1010
+ for (i = byteOffset; i < arrLength; i++) {
1011
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1012
  if (foundIndex === -1) foundIndex = i
1013
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1014
  } else {
1015
+ if (foundIndex !== -1) i -= i - foundIndex
1016
  foundIndex = -1
1017
  }
1018
  }
1019
+ } else {
1020
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1021
+ for (i = byteOffset; i >= 0; i--) {
1022
+ var found = true
1023
+ for (var j = 0; j < valLength; j++) {
1024
+ if (read(arr, i + j) !== read(val, j)) {
1025
+ found = false
1026
+ break
1027
+ }
1028
+ }
1029
+ if (found) return i
1030
+ }
1031
  }
1032
 
1033
+ return -1
1034
  }
1035
 
1036
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1037
+ return this.indexOf(val, byteOffset, encoding) !== -1
 
 
1038
  }
1039
 
1040
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1041
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1042
+ }
1043
+
1044
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1045
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1046
  }
1047
 
1048
  function hexWrite (buf, string, offset, length) {
1059
 
1060
  // must be an even number of digits
1061
  var strLen = string.length
1062
+ if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1063
 
1064
  if (length > strLen / 2) {
1065
  length = strLen / 2
1066
  }
1067
+ for (var i = 0; i < length; ++i) {
1068
  var parsed = parseInt(string.substr(i * 2, 2), 16)
1069
+ if (isNaN(parsed)) return i
1070
  buf[offset + i] = parsed
1071
  }
1072
  return i
1080
  return blitBuffer(asciiToBytes(string), buf, offset, length)
1081
  }
1082
 
1083
+ function latin1Write (buf, string, offset, length) {
1084
  return asciiWrite(buf, string, offset, length)
1085
  }
1086
 
1115
  }
1116
  // legacy write(string, encoding, offset, length) - remove in v0.13
1117
  } else {
1118
+ throw new Error(
1119
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1120
+ )
 
1121
  }
1122
 
1123
  var remaining = this.length - offset
1124
  if (length === undefined || length > remaining) length = remaining
1125
 
1126
  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1127
+ throw new RangeError('Attempt to write outside buffer bounds')
1128
  }
1129
 
1130
  if (!encoding) encoding = 'utf8'
1142
  case 'ascii':
1143
  return asciiWrite(this, string, offset, length)
1144
 
1145
+ case 'latin1':
1146
  case 'binary':
1147
+ return latin1Write(this, string, offset, length)
1148
 
1149
  case 'base64':
1150
  // Warning: maxLength not taken into account in base64Write
1279
  var ret = ''
1280
  end = Math.min(buf.length, end)
1281
 
1282
+ for (var i = start; i < end; ++i) {
1283
  ret += String.fromCharCode(buf[i] & 0x7F)
1284
  }
1285
  return ret
1286
  }
1287
 
1288
+ function latin1Slice (buf, start, end) {
1289
  var ret = ''
1290
  end = Math.min(buf.length, end)
1291
 
1292
+ for (var i = start; i < end; ++i) {
1293
  ret += String.fromCharCode(buf[i])
1294
  }
1295
  return ret
1302
  if (!end || end < 0 || end > len) end = len
1303
 
1304
  var out = ''
1305
+ for (var i = start; i < end; ++i) {
1306
  out += toHex(buf[i])
1307
  }
1308
  return out
1340
 
1341
  var newBuf
1342
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1343
+ newBuf = this.subarray(start, end)
1344
+ newBuf.__proto__ = Buffer.prototype
1345
  } else {
1346
  var sliceLen = end - start
1347
  newBuf = new Buffer(sliceLen, undefined)
1348
+ for (var i = 0; i < sliceLen; ++i) {
1349
  newBuf[i] = this[i + start]
1350
  }
1351
  }
1352
 
 
 
1353
  return newBuf
1354
  }
1355
 
1518
  }
1519
 
1520
  function checkInt (buf, value, offset, ext, max, min) {
1521
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1522
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1523
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
1524
  }
1525
 
1526
  Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1527
  value = +value
1528
  offset = offset | 0
1529
  byteLength = byteLength | 0
1530
+ if (!noAssert) {
1531
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
1532
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
1533
+ }
1534
 
1535
  var mul = 1
1536
  var i = 0
1546
  value = +value
1547
  offset = offset | 0
1548
  byteLength = byteLength | 0
1549
+ if (!noAssert) {
1550
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
1551
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
1552
+ }
1553
 
1554
  var i = byteLength - 1
1555
  var mul = 1
1566
  offset = offset | 0
1567
  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1568
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1569
+ this[offset] = (value & 0xff)
1570
  return offset + 1
1571
  }
1572
 
1573
  function objectWriteUInt16 (buf, value, offset, littleEndian) {
1574
  if (value < 0) value = 0xffff + value + 1
1575
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1576
  buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1577
  (littleEndian ? i : 1 - i) * 8
1578
  }
1583
  offset = offset | 0
1584
  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1585
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1586
+ this[offset] = (value & 0xff)
1587
  this[offset + 1] = (value >>> 8)
1588
  } else {
1589
  objectWriteUInt16(this, value, offset, true)
1597
  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1598
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1599
  this[offset] = (value >>> 8)
1600
+ this[offset + 1] = (value & 0xff)
1601
  } else {
1602
  objectWriteUInt16(this, value, offset, false)
1603
  }
1606
 
1607
  function objectWriteUInt32 (buf, value, offset, littleEndian) {
1608
  if (value < 0) value = 0xffffffff + value + 1
1609
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1610
  buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1611
  }
1612
  }
1619
  this[offset + 3] = (value >>> 24)
1620
  this[offset + 2] = (value >>> 16)
1621
  this[offset + 1] = (value >>> 8)
1622
+ this[offset] = (value & 0xff)
1623
  } else {
1624
  objectWriteUInt32(this, value, offset, true)
1625
  }
1634
  this[offset] = (value >>> 24)
1635
  this[offset + 1] = (value >>> 16)
1636
  this[offset + 2] = (value >>> 8)
1637
+ this[offset + 3] = (value & 0xff)
1638
  } else {
1639
  objectWriteUInt32(this, value, offset, false)
1640
  }
1652
 
1653
  var i = 0
1654
  var mul = 1
1655
+ var sub = 0
1656
  this[offset] = value & 0xFF
1657
  while (++i < byteLength && (mul *= 0x100)) {
1658
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1659
+ sub = 1
1660
+ }
1661
  this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1662
  }
1663
 
1675
 
1676
  var i = byteLength - 1
1677
  var mul = 1
1678
+ var sub = 0
1679
  this[offset + i] = value & 0xFF
1680
  while (--i >= 0 && (mul *= 0x100)) {
1681
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1682
+ sub = 1
1683
+ }
1684
  this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1685
  }
1686
 
1693
  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1694
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1695
  if (value < 0) value = 0xff + value + 1
1696
+ this[offset] = (value & 0xff)
1697
  return offset + 1
1698
  }
1699
 
1702
  offset = offset | 0
1703
  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1704
  if (Buffer.TYPED_ARR