genoverse 3.2.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/.eslintrc.js +93 -162
  2. package/.github/workflows/test.yml +9 -10
  3. package/.github/workflows/update-gh-pages.yml +33 -0
  4. package/LICENSE.TXT +2 -2
  5. package/README.md +174 -3
  6. package/{i → assets}/sort_handle.png +0 -0
  7. package/babel.config.js +19 -0
  8. package/dist/129.css +334 -0
  9. package/dist/129.css.map +1 -0
  10. package/dist/129.genoverse.js +2 -0
  11. package/dist/129.genoverse.js.map +1 -0
  12. package/dist/15d98c18221c8bcb2334.ttf +0 -0
  13. package/dist/166.css +2 -0
  14. package/dist/166.genoverse.js +1 -0
  15. package/dist/216.css +20 -0
  16. package/dist/216.css.map +1 -0
  17. package/dist/232.css +114 -0
  18. package/dist/232.css.map +1 -0
  19. package/dist/232.genoverse.js +2 -0
  20. package/dist/232.genoverse.js.map +1 -0
  21. package/dist/2e659e443f3e98569e9f.png +0 -0
  22. package/dist/394.css +114 -0
  23. package/dist/394.css.map +1 -0
  24. package/dist/394.genoverse.js +2 -0
  25. package/dist/394.genoverse.js.map +1 -0
  26. package/dist/469.css +24 -0
  27. package/dist/469.css.map +1 -0
  28. package/dist/469.genoverse.js +2 -0
  29. package/dist/469.genoverse.js.map +1 -0
  30. package/dist/4896d4b04430cc3dfb06.woff2 +0 -0
  31. package/dist/530.css +39 -0
  32. package/dist/530.css.map +1 -0
  33. package/dist/530.genoverse.js +2 -0
  34. package/dist/530.genoverse.js.map +1 -0
  35. package/dist/547.css +469 -0
  36. package/dist/547.css.map +1 -0
  37. package/dist/547.genoverse.js +1 -0
  38. package/dist/729.css +315 -0
  39. package/dist/729.css.map +1 -0
  40. package/dist/79da213423ac0def2058.ttf +0 -0
  41. package/dist/804.genoverse.js +2 -0
  42. package/dist/804.genoverse.js.map +1 -0
  43. package/dist/842.genoverse.js +2 -0
  44. package/dist/842.genoverse.js.map +1 -0
  45. package/dist/893.genoverse.js +2 -0
  46. package/dist/893.genoverse.js.map +1 -0
  47. package/dist/949.css +315 -0
  48. package/dist/949.css.map +1 -0
  49. package/dist/949.genoverse.js +2 -0
  50. package/dist/949.genoverse.js.map +1 -0
  51. package/dist/952.css +315 -0
  52. package/dist/952.css.map +1 -0
  53. package/dist/952.genoverse.js +2 -0
  54. package/dist/952.genoverse.js.map +1 -0
  55. package/dist/d79c2ec96ab9ff1161a2.woff2 +0 -0
  56. package/dist/genoverse.js +2 -0
  57. package/dist/genoverse.js.map +1 -0
  58. package/index.html +13 -14
  59. package/jest.config.js +5 -0
  60. package/jest.setup.js +13 -0
  61. package/package.json +29 -12
  62. package/{css → src/css}/controlPanel.css +0 -0
  63. package/{css → src/css}/fileDrop.css +0 -0
  64. package/src/css/fontawesome.css +3 -0
  65. package/{css → src/css}/fullscreen.css +0 -0
  66. package/{css → src/css}/genoverse.css +1 -1
  67. package/{css → src/css}/karyotype.css +2 -0
  68. package/{css → src/css}/resizer.css +0 -0
  69. package/{css → src/css}/tooltips.css +0 -0
  70. package/{css → src/css}/trackControls.css +0 -0
  71. package/src/js/Genoverse.js +1747 -0
  72. package/{js → src/js}/Track/Controller/Sequence.js +6 -4
  73. package/src/js/Track/Controller/Stranded.js +83 -0
  74. package/{js → src/js}/Track/Controller.js +201 -160
  75. package/src/js/Track/Model/File/BAM.js +47 -0
  76. package/src/js/Track/Model/File/BED.js +122 -0
  77. package/src/js/Track/Model/File/GFF.js +42 -0
  78. package/src/js/Track/Model/File/VCF.js +109 -0
  79. package/src/js/Track/Model/File/WIG.js +82 -0
  80. package/src/js/Track/Model/File.js +36 -0
  81. package/src/js/Track/Model/Gene/Ensembl.js +24 -0
  82. package/{js → src/js}/Track/Model/Gene.js +3 -1
  83. package/src/js/Track/Model/Sequence/Ensembl.js +6 -0
  84. package/{js → src/js}/Track/Model/Sequence/Fasta.js +24 -17
  85. package/{js → src/js}/Track/Model/Sequence.js +10 -7
  86. package/{js → src/js}/Track/Model/SequenceVariation.js +17 -11
  87. package/{js → src/js}/Track/Model/Stranded.js +11 -8
  88. package/src/js/Track/Model/Transcript/Ensembl.js +73 -0
  89. package/{js → src/js}/Track/Model/Transcript.js +3 -1
  90. package/{js → src/js}/Track/Model.js +125 -93
  91. package/{js → src/js}/Track/View/Gene/Ensembl.js +6 -4
  92. package/src/js/Track/View/Gene.js +8 -0
  93. package/{js → src/js}/Track/View/Sequence.js +18 -22
  94. package/src/js/Track/View/SequenceVariation.js +117 -0
  95. package/src/js/Track/View/Transcript/Ensembl.js +17 -0
  96. package/src/js/Track/View/Transcript.js +32 -0
  97. package/{js → src/js}/Track/View.js +200 -159
  98. package/{js → src/js}/Track/library/Chromosome.js +18 -13
  99. package/src/js/Track/library/File/BAM.js +34 -0
  100. package/src/js/Track/library/File/BED.js +27 -0
  101. package/src/js/Track/library/File/BIGBED.js +51 -0
  102. package/src/js/Track/library/File/BIGWIG.js +54 -0
  103. package/src/js/Track/library/File/GFF.js +10 -0
  104. package/{js → src/js}/Track/library/File/VCF.js +29 -22
  105. package/src/js/Track/library/File/WIG.js +8 -0
  106. package/{js → src/js}/Track/library/File.js +4 -2
  107. package/src/js/Track/library/Gene.js +44 -0
  108. package/src/js/Track/library/Graph/Bar.js +263 -0
  109. package/src/js/Track/library/Graph/Line.js +335 -0
  110. package/{js → src/js}/Track/library/Graph.js +137 -114
  111. package/{js → src/js}/Track/library/HighlightRegion.js +118 -93
  112. package/src/js/Track/library/Legend.js +258 -0
  113. package/{js → src/js}/Track/library/Scalebar.js +69 -49
  114. package/{js → src/js}/Track/library/Scaleline.js +29 -27
  115. package/src/js/Track/library/Static.js +82 -0
  116. package/{js → src/js}/Track/library/dbSNP.js +47 -50
  117. package/src/js/Track.js +651 -0
  118. package/{js → src/js}/genomes/grch37.js +52 -52
  119. package/{js → src/js}/genomes/grch38.js +52 -52
  120. package/src/js/lib/BWReader.js +562 -0
  121. package/src/js/lib/VCFReader.js +296 -0
  122. package/src/js/lib/dalliance/bam.js +517 -0
  123. package/src/js/lib/dalliance/bin.js +317 -0
  124. package/src/js/lib/dalliance/jszlib-inflate.js +2159 -0
  125. package/src/js/lib/dalliance/lh3utils.js +105 -0
  126. package/src/js/lib/dalliance/sha1.js +334 -0
  127. package/src/js/lib/import-tracks.js +42 -0
  128. package/{js/lib → src/js/lib/jquery-plugins}/jquery.mousehold.js +0 -0
  129. package/{js/lib → src/js/lib/jquery-plugins}/jquery.mousewheel.js +0 -0
  130. package/{js/lib → src/js/lib/jquery-plugins}/jquery.tipsy.js +0 -0
  131. package/src/js/lib/jquery.js +26 -0
  132. package/src/js/lib/polyfills.js +11 -0
  133. package/src/js/lib/wrap-functions.js +88 -0
  134. package/src/js/plugins/controlPanel.js +388 -0
  135. package/src/js/plugins/fileDrop.js +81 -0
  136. package/src/js/plugins/focusRegion.js +13 -0
  137. package/{js → src/js}/plugins/fullscreen.js +18 -14
  138. package/{js → src/js}/plugins/karyotype.js +51 -45
  139. package/src/js/plugins/resizer.js +52 -0
  140. package/{js → src/js}/plugins/tooltips.js +31 -29
  141. package/src/js/plugins/trackControls.js +159 -0
  142. package/test/View/render-legends.test.js +1 -1
  143. package/test/change-width.test.js +71 -0
  144. package/test/create-and-destroy.test.js +2 -2
  145. package/test/track-ordering.test.js +3 -2
  146. package/test/track_config/config-settings.test.js +1 -1
  147. package/test/utils.js +4 -2
  148. package/webpack.config.js +103 -34
  149. package/css/font-awesome.css +0 -3
  150. package/expanded.html +0 -120
  151. package/fontawesome/css/fontawesome.min.css +0 -5
  152. package/fontawesome/css/regular.min.css +0 -5
  153. package/fontawesome/css/solid.min.css +0 -5
  154. package/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  155. package/fontawesome/webfonts/fa-brands-400.woff +0 -0
  156. package/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  157. package/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  158. package/fontawesome/webfonts/fa-regular-400.woff +0 -0
  159. package/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  160. package/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  161. package/fontawesome/webfonts/fa-solid-900.woff +0 -0
  162. package/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  163. package/help.pdf +0 -0
  164. package/index.js +0 -83
  165. package/js/Genoverse.js +0 -1681
  166. package/js/Track/Controller/Stranded.js +0 -73
  167. package/js/Track/Model/File/BAM.js +0 -44
  168. package/js/Track/Model/File/BED.js +0 -116
  169. package/js/Track/Model/File/GFF.js +0 -40
  170. package/js/Track/Model/File/VCF.js +0 -101
  171. package/js/Track/Model/File/WIG.js +0 -67
  172. package/js/Track/Model/File.js +0 -36
  173. package/js/Track/Model/Gene/Ensembl.js +0 -22
  174. package/js/Track/Model/Sequence/Ensembl.js +0 -4
  175. package/js/Track/Model/Transcript/Ensembl.js +0 -67
  176. package/js/Track/View/Gene.js +0 -6
  177. package/js/Track/View/Sequence/Variation.js +0 -115
  178. package/js/Track/View/Transcript/Ensembl.js +0 -12
  179. package/js/Track/View/Transcript.js +0 -28
  180. package/js/Track/library/File/BAM.js +0 -30
  181. package/js/Track/library/File/BED.js +0 -24
  182. package/js/Track/library/File/BIGBED.js +0 -47
  183. package/js/Track/library/File/BIGWIG.js +0 -52
  184. package/js/Track/library/File/GFF.js +0 -9
  185. package/js/Track/library/File/WIG.js +0 -5
  186. package/js/Track/library/Gene.js +0 -37
  187. package/js/Track/library/Graph/Bar.js +0 -235
  188. package/js/Track/library/Graph/Line.js +0 -296
  189. package/js/Track/library/Legend.js +0 -224
  190. package/js/Track/library/Static.js +0 -78
  191. package/js/Track.js +0 -632
  192. package/js/genoverse.min.js +0 -2
  193. package/js/genoverse.min.js.map +0 -1
  194. package/js/lib/BWReader.js +0 -578
  195. package/js/lib/Base.js +0 -145
  196. package/js/lib/VCFReader.js +0 -286
  197. package/js/lib/dalliance/js/bam.js +0 -494
  198. package/js/lib/dalliance/js/bin.js +0 -185
  199. package/js/lib/dalliance/js/das.js +0 -749
  200. package/js/lib/dalliance/js/utils.js +0 -370
  201. package/js/lib/dalliance-lib.js +0 -3594
  202. package/js/lib/dalliance-lib.min.js +0 -68
  203. package/js/lib/jDataView.js +0 -2
  204. package/js/lib/jParser.js +0 -192
  205. package/js/lib/jquery-ui.js +0 -8
  206. package/js/lib/jquery.js +0 -2
  207. package/js/lib/rtree.js +0 -1
  208. package/js/plugins/controlPanel.js +0 -395
  209. package/js/plugins/fileDrop.js +0 -62
  210. package/js/plugins/focusRegion.js +0 -12
  211. package/js/plugins/resizer.js +0 -45
  212. package/js/plugins/trackControls.js +0 -143
  213. package/utils/expandedTemplate.html +0 -46
  214. package/utils/git-hooks/post-commit +0 -9
  215. package/utils/git-hooks/pre-commit +0 -7
  216. package/utils/git-hooks/setup +0 -6
  217. package/utils/makeExpanded.js +0 -19
@@ -0,0 +1,2159 @@
1
+ // Adapted from https://github.com/dasmoth/jszlib/blob/master/js/inflate.js
2
+
3
+ /* -*- mode: javascript; c-basic-offset: 4; indent-tabs-mode: nil -*- */
4
+
5
+ //
6
+ // Javascript ZLib
7
+ // By Thomas Down 2010-2011
8
+ //
9
+ // Based very heavily on portions of jzlib (by ymnk@jcraft.com), who in
10
+ // turn credits Jean-loup Gailly and Mark Adler for the original zlib code.
11
+ //
12
+ // inflate.js: ZLib inflate code
13
+ //
14
+
15
+ //
16
+ // Shared constants
17
+ //
18
+
19
+ var MAX_WBITS=15; // 32K LZ77 window
20
+ var DEF_WBITS=MAX_WBITS;
21
+ var MAX_MEM_LEVEL=9;
22
+ var MANY=1440;
23
+ var BMAX = 15;
24
+
25
+ // preset dictionary flag in zlib header
26
+ var PRESET_DICT=0x20;
27
+
28
+ var Z_NO_FLUSH=0;
29
+ var Z_PARTIAL_FLUSH=1;
30
+ var Z_SYNC_FLUSH=2;
31
+ var Z_FULL_FLUSH=3;
32
+ var Z_FINISH=4;
33
+
34
+ var Z_DEFLATED=8;
35
+
36
+ var Z_OK=0;
37
+ var Z_STREAM_END=1;
38
+ var Z_NEED_DICT=2;
39
+ var Z_ERRNO=-1;
40
+ var Z_STREAM_ERROR=-2;
41
+ var Z_DATA_ERROR=-3;
42
+ var Z_MEM_ERROR=-4;
43
+ var Z_BUF_ERROR=-5;
44
+ var Z_VERSION_ERROR=-6;
45
+
46
+ var METHOD=0; // waiting for method byte
47
+ var FLAG=1; // waiting for flag byte
48
+ var DICT4=2; // four dictionary check bytes to go
49
+ var DICT3=3; // three dictionary check bytes to go
50
+ var DICT2=4; // two dictionary check bytes to go
51
+ var DICT1=5; // one dictionary check byte to go
52
+ var DICT0=6; // waiting for inflateSetDictionary
53
+ var BLOCKS=7; // decompressing blocks
54
+ var CHECK4=8; // four check bytes to go
55
+ var CHECK3=9; // three check bytes to go
56
+ var CHECK2=10; // two check bytes to go
57
+ var CHECK1=11; // one check byte to go
58
+ var DONE=12; // finished check, done
59
+ var BAD=13; // got an error--stay here
60
+
61
+ var inflate_mask = [0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff];
62
+
63
+ var IB_TYPE=0; // get type bits (3, including end bit)
64
+ var IB_LENS=1; // get lengths for stored
65
+ var IB_STORED=2;// processing stored block
66
+ var IB_TABLE=3; // get table lengths
67
+ var IB_BTREE=4; // get bit lengths tree for a dynamic block
68
+ var IB_DTREE=5; // get length, distance trees for a dynamic block
69
+ var IB_CODES=6; // processing fixed or dynamic block
70
+ var IB_DRY=7; // output remaining window bytes
71
+ var IB_DONE=8; // finished last block, done
72
+ var IB_BAD=9; // ot a data error--stuck here
73
+
74
+ var fixed_bl = 9;
75
+ var fixed_bd = 5;
76
+
77
+ var fixed_tl = [
78
+ 96,7,256, 0,8,80, 0,8,16, 84,8,115,
79
+ 82,7,31, 0,8,112, 0,8,48, 0,9,192,
80
+ 80,7,10, 0,8,96, 0,8,32, 0,9,160,
81
+ 0,8,0, 0,8,128, 0,8,64, 0,9,224,
82
+ 80,7,6, 0,8,88, 0,8,24, 0,9,144,
83
+ 83,7,59, 0,8,120, 0,8,56, 0,9,208,
84
+ 81,7,17, 0,8,104, 0,8,40, 0,9,176,
85
+ 0,8,8, 0,8,136, 0,8,72, 0,9,240,
86
+ 80,7,4, 0,8,84, 0,8,20, 85,8,227,
87
+ 83,7,43, 0,8,116, 0,8,52, 0,9,200,
88
+ 81,7,13, 0,8,100, 0,8,36, 0,9,168,
89
+ 0,8,4, 0,8,132, 0,8,68, 0,9,232,
90
+ 80,7,8, 0,8,92, 0,8,28, 0,9,152,
91
+ 84,7,83, 0,8,124, 0,8,60, 0,9,216,
92
+ 82,7,23, 0,8,108, 0,8,44, 0,9,184,
93
+ 0,8,12, 0,8,140, 0,8,76, 0,9,248,
94
+ 80,7,3, 0,8,82, 0,8,18, 85,8,163,
95
+ 83,7,35, 0,8,114, 0,8,50, 0,9,196,
96
+ 81,7,11, 0,8,98, 0,8,34, 0,9,164,
97
+ 0,8,2, 0,8,130, 0,8,66, 0,9,228,
98
+ 80,7,7, 0,8,90, 0,8,26, 0,9,148,
99
+ 84,7,67, 0,8,122, 0,8,58, 0,9,212,
100
+ 82,7,19, 0,8,106, 0,8,42, 0,9,180,
101
+ 0,8,10, 0,8,138, 0,8,74, 0,9,244,
102
+ 80,7,5, 0,8,86, 0,8,22, 192,8,0,
103
+ 83,7,51, 0,8,118, 0,8,54, 0,9,204,
104
+ 81,7,15, 0,8,102, 0,8,38, 0,9,172,
105
+ 0,8,6, 0,8,134, 0,8,70, 0,9,236,
106
+ 80,7,9, 0,8,94, 0,8,30, 0,9,156,
107
+ 84,7,99, 0,8,126, 0,8,62, 0,9,220,
108
+ 82,7,27, 0,8,110, 0,8,46, 0,9,188,
109
+ 0,8,14, 0,8,142, 0,8,78, 0,9,252,
110
+ 96,7,256, 0,8,81, 0,8,17, 85,8,131,
111
+ 82,7,31, 0,8,113, 0,8,49, 0,9,194,
112
+ 80,7,10, 0,8,97, 0,8,33, 0,9,162,
113
+ 0,8,1, 0,8,129, 0,8,65, 0,9,226,
114
+ 80,7,6, 0,8,89, 0,8,25, 0,9,146,
115
+ 83,7,59, 0,8,121, 0,8,57, 0,9,210,
116
+ 81,7,17, 0,8,105, 0,8,41, 0,9,178,
117
+ 0,8,9, 0,8,137, 0,8,73, 0,9,242,
118
+ 80,7,4, 0,8,85, 0,8,21, 80,8,258,
119
+ 83,7,43, 0,8,117, 0,8,53, 0,9,202,
120
+ 81,7,13, 0,8,101, 0,8,37, 0,9,170,
121
+ 0,8,5, 0,8,133, 0,8,69, 0,9,234,
122
+ 80,7,8, 0,8,93, 0,8,29, 0,9,154,
123
+ 84,7,83, 0,8,125, 0,8,61, 0,9,218,
124
+ 82,7,23, 0,8,109, 0,8,45, 0,9,186,
125
+ 0,8,13, 0,8,141, 0,8,77, 0,9,250,
126
+ 80,7,3, 0,8,83, 0,8,19, 85,8,195,
127
+ 83,7,35, 0,8,115, 0,8,51, 0,9,198,
128
+ 81,7,11, 0,8,99, 0,8,35, 0,9,166,
129
+ 0,8,3, 0,8,131, 0,8,67, 0,9,230,
130
+ 80,7,7, 0,8,91, 0,8,27, 0,9,150,
131
+ 84,7,67, 0,8,123, 0,8,59, 0,9,214,
132
+ 82,7,19, 0,8,107, 0,8,43, 0,9,182,
133
+ 0,8,11, 0,8,139, 0,8,75, 0,9,246,
134
+ 80,7,5, 0,8,87, 0,8,23, 192,8,0,
135
+ 83,7,51, 0,8,119, 0,8,55, 0,9,206,
136
+ 81,7,15, 0,8,103, 0,8,39, 0,9,174,
137
+ 0,8,7, 0,8,135, 0,8,71, 0,9,238,
138
+ 80,7,9, 0,8,95, 0,8,31, 0,9,158,
139
+ 84,7,99, 0,8,127, 0,8,63, 0,9,222,
140
+ 82,7,27, 0,8,111, 0,8,47, 0,9,190,
141
+ 0,8,15, 0,8,143, 0,8,79, 0,9,254,
142
+ 96,7,256, 0,8,80, 0,8,16, 84,8,115,
143
+ 82,7,31, 0,8,112, 0,8,48, 0,9,193,
144
+
145
+ 80,7,10, 0,8,96, 0,8,32, 0,9,161,
146
+ 0,8,0, 0,8,128, 0,8,64, 0,9,225,
147
+ 80,7,6, 0,8,88, 0,8,24, 0,9,145,
148
+ 83,7,59, 0,8,120, 0,8,56, 0,9,209,
149
+ 81,7,17, 0,8,104, 0,8,40, 0,9,177,
150
+ 0,8,8, 0,8,136, 0,8,72, 0,9,241,
151
+ 80,7,4, 0,8,84, 0,8,20, 85,8,227,
152
+ 83,7,43, 0,8,116, 0,8,52, 0,9,201,
153
+ 81,7,13, 0,8,100, 0,8,36, 0,9,169,
154
+ 0,8,4, 0,8,132, 0,8,68, 0,9,233,
155
+ 80,7,8, 0,8,92, 0,8,28, 0,9,153,
156
+ 84,7,83, 0,8,124, 0,8,60, 0,9,217,
157
+ 82,7,23, 0,8,108, 0,8,44, 0,9,185,
158
+ 0,8,12, 0,8,140, 0,8,76, 0,9,249,
159
+ 80,7,3, 0,8,82, 0,8,18, 85,8,163,
160
+ 83,7,35, 0,8,114, 0,8,50, 0,9,197,
161
+ 81,7,11, 0,8,98, 0,8,34, 0,9,165,
162
+ 0,8,2, 0,8,130, 0,8,66, 0,9,229,
163
+ 80,7,7, 0,8,90, 0,8,26, 0,9,149,
164
+ 84,7,67, 0,8,122, 0,8,58, 0,9,213,
165
+ 82,7,19, 0,8,106, 0,8,42, 0,9,181,
166
+ 0,8,10, 0,8,138, 0,8,74, 0,9,245,
167
+ 80,7,5, 0,8,86, 0,8,22, 192,8,0,
168
+ 83,7,51, 0,8,118, 0,8,54, 0,9,205,
169
+ 81,7,15, 0,8,102, 0,8,38, 0,9,173,
170
+ 0,8,6, 0,8,134, 0,8,70, 0,9,237,
171
+ 80,7,9, 0,8,94, 0,8,30, 0,9,157,
172
+ 84,7,99, 0,8,126, 0,8,62, 0,9,221,
173
+ 82,7,27, 0,8,110, 0,8,46, 0,9,189,
174
+ 0,8,14, 0,8,142, 0,8,78, 0,9,253,
175
+ 96,7,256, 0,8,81, 0,8,17, 85,8,131,
176
+ 82,7,31, 0,8,113, 0,8,49, 0,9,195,
177
+ 80,7,10, 0,8,97, 0,8,33, 0,9,163,
178
+ 0,8,1, 0,8,129, 0,8,65, 0,9,227,
179
+ 80,7,6, 0,8,89, 0,8,25, 0,9,147,
180
+ 83,7,59, 0,8,121, 0,8,57, 0,9,211,
181
+ 81,7,17, 0,8,105, 0,8,41, 0,9,179,
182
+ 0,8,9, 0,8,137, 0,8,73, 0,9,243,
183
+ 80,7,4, 0,8,85, 0,8,21, 80,8,258,
184
+ 83,7,43, 0,8,117, 0,8,53, 0,9,203,
185
+ 81,7,13, 0,8,101, 0,8,37, 0,9,171,
186
+ 0,8,5, 0,8,133, 0,8,69, 0,9,235,
187
+ 80,7,8, 0,8,93, 0,8,29, 0,9,155,
188
+ 84,7,83, 0,8,125, 0,8,61, 0,9,219,
189
+ 82,7,23, 0,8,109, 0,8,45, 0,9,187,
190
+ 0,8,13, 0,8,141, 0,8,77, 0,9,251,
191
+ 80,7,3, 0,8,83, 0,8,19, 85,8,195,
192
+ 83,7,35, 0,8,115, 0,8,51, 0,9,199,
193
+ 81,7,11, 0,8,99, 0,8,35, 0,9,167,
194
+ 0,8,3, 0,8,131, 0,8,67, 0,9,231,
195
+ 80,7,7, 0,8,91, 0,8,27, 0,9,151,
196
+ 84,7,67, 0,8,123, 0,8,59, 0,9,215,
197
+ 82,7,19, 0,8,107, 0,8,43, 0,9,183,
198
+ 0,8,11, 0,8,139, 0,8,75, 0,9,247,
199
+ 80,7,5, 0,8,87, 0,8,23, 192,8,0,
200
+ 83,7,51, 0,8,119, 0,8,55, 0,9,207,
201
+ 81,7,15, 0,8,103, 0,8,39, 0,9,175,
202
+ 0,8,7, 0,8,135, 0,8,71, 0,9,239,
203
+ 80,7,9, 0,8,95, 0,8,31, 0,9,159,
204
+ 84,7,99, 0,8,127, 0,8,63, 0,9,223,
205
+ 82,7,27, 0,8,111, 0,8,47, 0,9,191,
206
+ 0,8,15, 0,8,143, 0,8,79, 0,9,255
207
+ ];
208
+ var fixed_td = [
209
+ 80,5,1, 87,5,257, 83,5,17, 91,5,4097,
210
+ 81,5,5, 89,5,1025, 85,5,65, 93,5,16385,
211
+ 80,5,3, 88,5,513, 84,5,33, 92,5,8193,
212
+ 82,5,9, 90,5,2049, 86,5,129, 192,5,24577,
213
+ 80,5,2, 87,5,385, 83,5,25, 91,5,6145,
214
+ 81,5,7, 89,5,1537, 85,5,97, 93,5,24577,
215
+ 80,5,4, 88,5,769, 84,5,49, 92,5,12289,
216
+ 82,5,13, 90,5,3073, 86,5,193, 192,5,24577
217
+ ];
218
+
219
+ // Tables for deflate from PKZIP's appnote.txt.
220
+ var cplens = [ // Copy lengths for literal codes 257..285
221
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
222
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
223
+ ];
224
+
225
+ // see note #13 above about 258
226
+ var cplext = [ // Extra bits for literal codes 257..285
227
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
228
+ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112 // 112==invalid
229
+ ];
230
+
231
+ var cpdist = [ // Copy offsets for distance codes 0..29
232
+ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
233
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
234
+ 8193, 12289, 16385, 24577
235
+ ];
236
+
237
+ var cpdext = [ // Extra bits for distance codes
238
+ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
239
+ 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
240
+ 12, 12, 13, 13];
241
+
242
+ //
243
+ // ZStream.java
244
+ //
245
+
246
+ function ZStream() {
247
+ }
248
+
249
+
250
+ ZStream.prototype.inflateInit = function(w, nowrap) {
251
+ if (!w) {
252
+ w = DEF_WBITS;
253
+ }
254
+ if (nowrap) {
255
+ nowrap = false;
256
+ }
257
+ this.istate = new Inflate();
258
+ return this.istate.inflateInit(this, nowrap?-w:w);
259
+ }
260
+
261
+ ZStream.prototype.inflate = function(f) {
262
+ if(this.istate==null) return Z_STREAM_ERROR;
263
+ return this.istate.inflate(this, f);
264
+ }
265
+
266
+ ZStream.prototype.inflateEnd = function(){
267
+ if(this.istate==null) return Z_STREAM_ERROR;
268
+ var ret=istate.inflateEnd(this);
269
+ this.istate = null;
270
+ return ret;
271
+ }
272
+ ZStream.prototype.inflateSync = function(){
273
+ // if(istate == null) return Z_STREAM_ERROR;
274
+ return istate.inflateSync(this);
275
+ }
276
+ ZStream.prototype.inflateSetDictionary = function(dictionary, dictLength){
277
+ // if(istate == null) return Z_STREAM_ERROR;
278
+ return istate.inflateSetDictionary(this, dictionary, dictLength);
279
+ }
280
+
281
+ /*
282
+
283
+ public int deflateInit(int level){
284
+ return deflateInit(level, MAX_WBITS);
285
+ }
286
+ public int deflateInit(int level, boolean nowrap){
287
+ return deflateInit(level, MAX_WBITS, nowrap);
288
+ }
289
+ public int deflateInit(int level, int bits){
290
+ return deflateInit(level, bits, false);
291
+ }
292
+ public int deflateInit(int level, int bits, boolean nowrap){
293
+ dstate=new Deflate();
294
+ return dstate.deflateInit(this, level, nowrap?-bits:bits);
295
+ }
296
+ public int deflate(int flush){
297
+ if(dstate==null){
298
+ return Z_STREAM_ERROR;
299
+ }
300
+ return dstate.deflate(this, flush);
301
+ }
302
+ public int deflateEnd(){
303
+ if(dstate==null) return Z_STREAM_ERROR;
304
+ int ret=dstate.deflateEnd();
305
+ dstate=null;
306
+ return ret;
307
+ }
308
+ public int deflateParams(int level, int strategy){
309
+ if(dstate==null) return Z_STREAM_ERROR;
310
+ return dstate.deflateParams(this, level, strategy);
311
+ }
312
+ public int deflateSetDictionary (byte[] dictionary, int dictLength){
313
+ if(dstate == null)
314
+ return Z_STREAM_ERROR;
315
+ return dstate.deflateSetDictionary(this, dictionary, dictLength);
316
+ }
317
+
318
+ */
319
+
320
+ /*
321
+ // Flush as much pending output as possible. All deflate() output goes
322
+ // through this function so some applications may wish to modify it
323
+ // to avoid allocating a large strm->next_out buffer and copying into it.
324
+ // (See also read_buf()).
325
+ void flush_pending(){
326
+ int len=dstate.pending;
327
+
328
+ if(len>avail_out) len=avail_out;
329
+ if(len==0) return;
330
+
331
+ if(dstate.pending_buf.length<=dstate.pending_out ||
332
+ next_out.length<=next_out_index ||
333
+ dstate.pending_buf.length<(dstate.pending_out+len) ||
334
+ next_out.length<(next_out_index+len)){
335
+ System.out.println(dstate.pending_buf.length+", "+dstate.pending_out+
336
+ ", "+next_out.length+", "+next_out_index+", "+len);
337
+ System.out.println("avail_out="+avail_out);
338
+ }
339
+
340
+ System.arraycopy(dstate.pending_buf, dstate.pending_out,
341
+ next_out, next_out_index, len);
342
+
343
+ next_out_index+=len;
344
+ dstate.pending_out+=len;
345
+ total_out+=len;
346
+ avail_out-=len;
347
+ dstate.pending-=len;
348
+ if(dstate.pending==0){
349
+ dstate.pending_out=0;
350
+ }
351
+ }
352
+
353
+ // Read a new buffer from the current input stream, update the adler32
354
+ // and total number of bytes read. All deflate() input goes through
355
+ // this function so some applications may wish to modify it to avoid
356
+ // allocating a large strm->next_in buffer and copying from it.
357
+ // (See also flush_pending()).
358
+ int read_buf(byte[] buf, int start, int size) {
359
+ int len=avail_in;
360
+
361
+ if(len>size) len=size;
362
+ if(len==0) return 0;
363
+
364
+ avail_in-=len;
365
+
366
+ if(dstate.noheader==0) {
367
+ adler=_adler.adler32(adler, next_in, next_in_index, len);
368
+ }
369
+ System.arraycopy(next_in, next_in_index, buf, start, len);
370
+ next_in_index += len;
371
+ total_in += len;
372
+ return len;
373
+ }
374
+
375
+ public void free(){
376
+ next_in=null;
377
+ next_out=null;
378
+ msg=null;
379
+ _adler=null;
380
+ }
381
+ }
382
+ */
383
+
384
+
385
+ //
386
+ // Inflate.java
387
+ //
388
+
389
+ function Inflate() {
390
+ this.was = [0];
391
+ }
392
+
393
+ Inflate.prototype.inflateReset = function(z) {
394
+ if(z == null || z.istate == null) return Z_STREAM_ERROR;
395
+
396
+ z.total_in = z.total_out = 0;
397
+ z.msg = null;
398
+ z.istate.mode = z.istate.nowrap!=0 ? BLOCKS : METHOD;
399
+ z.istate.blocks.reset(z, null);
400
+ return Z_OK;
401
+ }
402
+
403
+ Inflate.prototype.inflateEnd = function(z){
404
+ if(this.blocks != null)
405
+ this.blocks.free(z);
406
+ this.blocks=null;
407
+ return Z_OK;
408
+ }
409
+
410
+ Inflate.prototype.inflateInit = function(z, w){
411
+ z.msg = null;
412
+ this.blocks = null;
413
+
414
+ // handle undocumented nowrap option (no zlib header or check)
415
+ nowrap = 0;
416
+ if(w < 0){
417
+ w = - w;
418
+ nowrap = 1;
419
+ }
420
+
421
+ // set window size
422
+ if(w<8 ||w>15){
423
+ this.inflateEnd(z);
424
+ return Z_STREAM_ERROR;
425
+ }
426
+ this.wbits=w;
427
+
428
+ z.istate.blocks=new InfBlocks(z,
429
+ z.istate.nowrap!=0 ? null : this,
430
+ 1<<w);
431
+
432
+ // reset state
433
+ this.inflateReset(z);
434
+ return Z_OK;
435
+ }
436
+
437
+ Inflate.prototype.inflate = function(z, f){
438
+ var r, b;
439
+
440
+ if(z == null || z.istate == null || z.next_in == null)
441
+ return Z_STREAM_ERROR;
442
+ f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
443
+ r = Z_BUF_ERROR;
444
+ while (true){
445
+ switch (z.istate.mode){
446
+ case METHOD:
447
+
448
+ if(z.avail_in==0)return r;r=f;
449
+
450
+ z.avail_in--; z.total_in++;
451
+ if(((z.istate.method = z.next_in[z.next_in_index++])&0xf)!=Z_DEFLATED){
452
+ z.istate.mode = BAD;
453
+ z.msg="unknown compression method";
454
+ z.istate.marker = 5; // can't try inflateSync
455
+ break;
456
+ }
457
+ if((z.istate.method>>4)+8>z.istate.wbits){
458
+ z.istate.mode = BAD;
459
+ z.msg="invalid window size";
460
+ z.istate.marker = 5; // can't try inflateSync
461
+ break;
462
+ }
463
+ z.istate.mode=FLAG;
464
+ case FLAG:
465
+
466
+ if(z.avail_in==0)return r;r=f;
467
+
468
+ z.avail_in--; z.total_in++;
469
+ b = (z.next_in[z.next_in_index++])&0xff;
470
+
471
+ if((((z.istate.method << 8)+b) % 31)!=0){
472
+ z.istate.mode = BAD;
473
+ z.msg = "incorrect header check";
474
+ z.istate.marker = 5; // can't try inflateSync
475
+ break;
476
+ }
477
+
478
+ if((b&PRESET_DICT)==0){
479
+ z.istate.mode = BLOCKS;
480
+ break;
481
+ }
482
+ z.istate.mode = DICT4;
483
+ case DICT4:
484
+
485
+ if(z.avail_in==0)return r;r=f;
486
+
487
+ z.avail_in--; z.total_in++;
488
+ z.istate.need=((z.next_in[z.next_in_index++]&0xff)<<24)&0xff000000;
489
+ z.istate.mode=DICT3;
490
+ case DICT3:
491
+
492
+ if(z.avail_in==0)return r;r=f;
493
+
494
+ z.avail_in--; z.total_in++;
495
+ z.istate.need+=((z.next_in[z.next_in_index++]&0xff)<<16)&0xff0000;
496
+ z.istate.mode=DICT2;
497
+ case DICT2:
498
+
499
+ if(z.avail_in==0)return r;r=f;
500
+
501
+ z.avail_in--; z.total_in++;
502
+ z.istate.need+=((z.next_in[z.next_in_index++]&0xff)<<8)&0xff00;
503
+ z.istate.mode=DICT1;
504
+ case DICT1:
505
+
506
+ if(z.avail_in==0)return r;r=f;
507
+
508
+ z.avail_in--; z.total_in++;
509
+ z.istate.need += (z.next_in[z.next_in_index++]&0xff);
510
+ z.adler = z.istate.need;
511
+ z.istate.mode = DICT0;
512
+ return Z_NEED_DICT;
513
+ case DICT0:
514
+ z.istate.mode = BAD;
515
+ z.msg = "need dictionary";
516
+ z.istate.marker = 0; // can try inflateSync
517
+ return Z_STREAM_ERROR;
518
+ case BLOCKS:
519
+
520
+ r = z.istate.blocks.proc(z, r);
521
+ if(r == Z_DATA_ERROR){
522
+ z.istate.mode = BAD;
523
+ z.istate.marker = 0; // can try inflateSync
524
+ break;
525
+ }
526
+ if(r == Z_OK){
527
+ r = f;
528
+ }
529
+ if(r != Z_STREAM_END){
530
+ return r;
531
+ }
532
+ r = f;
533
+ z.istate.blocks.reset(z, z.istate.was);
534
+ if(z.istate.nowrap!=0){
535
+ z.istate.mode=DONE;
536
+ break;
537
+ }
538
+ z.istate.mode=CHECK4;
539
+ case CHECK4:
540
+
541
+ if(z.avail_in==0)return r;r=f;
542
+
543
+ z.avail_in--; z.total_in++;
544
+ z.istate.need=((z.next_in[z.next_in_index++]&0xff)<<24)&0xff000000;
545
+ z.istate.mode=CHECK3;
546
+ case CHECK3:
547
+
548
+ if(z.avail_in==0)return r;r=f;
549
+
550
+ z.avail_in--; z.total_in++;
551
+ z.istate.need+=((z.next_in[z.next_in_index++]&0xff)<<16)&0xff0000;
552
+ z.istate.mode = CHECK2;
553
+ case CHECK2:
554
+
555
+ if(z.avail_in==0)return r;r=f;
556
+
557
+ z.avail_in--; z.total_in++;
558
+ z.istate.need+=((z.next_in[z.next_in_index++]&0xff)<<8)&0xff00;
559
+ z.istate.mode = CHECK1;
560
+ case CHECK1:
561
+
562
+ if(z.avail_in==0)return r;r=f;
563
+
564
+ z.avail_in--; z.total_in++;
565
+ z.istate.need+=(z.next_in[z.next_in_index++]&0xff);
566
+
567
+ if(((z.istate.was[0])) != ((z.istate.need))){
568
+ z.istate.mode = BAD;
569
+ z.msg = "incorrect data check";
570
+ z.istate.marker = 5; // can't try inflateSync
571
+ break;
572
+ }
573
+
574
+ z.istate.mode = DONE;
575
+ case DONE:
576
+ return Z_STREAM_END;
577
+ case BAD:
578
+ return Z_DATA_ERROR;
579
+ default:
580
+ return Z_STREAM_ERROR;
581
+ }
582
+ }
583
+ }
584
+
585
+
586
+ Inflate.prototype.inflateSetDictionary = function(z, dictionary, dictLength) {
587
+ var index=0;
588
+ var length = dictLength;
589
+ if(z==null || z.istate == null|| z.istate.mode != DICT0)
590
+ return Z_STREAM_ERROR;
591
+
592
+ if(z._adler.adler32(1, dictionary, 0, dictLength)!=z.adler){
593
+ return Z_DATA_ERROR;
594
+ }
595
+
596
+ z.adler = z._adler.adler32(0, null, 0, 0);
597
+
598
+ if(length >= (1<<z.istate.wbits)){
599
+ length = (1<<z.istate.wbits)-1;
600
+ index=dictLength - length;
601
+ }
602
+ z.istate.blocks.set_dictionary(dictionary, index, length);
603
+ z.istate.mode = BLOCKS;
604
+ return Z_OK;
605
+ }
606
+
607
+ // static private byte[] mark = {(byte)0, (byte)0, (byte)0xff, (byte)0xff};
608
+ var mark = [0, 0, 255, 255]
609
+
610
+ Inflate.prototype.inflateSync = function(z){
611
+ var n; // number of bytes to look at
612
+ var p; // pointer to bytes
613
+ var m; // number of marker bytes found in a row
614
+ var r, w; // temporaries to save total_in and total_out
615
+
616
+ // set up
617
+ if(z == null || z.istate == null)
618
+ return Z_STREAM_ERROR;
619
+ if(z.istate.mode != BAD){
620
+ z.istate.mode = BAD;
621
+ z.istate.marker = 0;
622
+ }
623
+ if((n=z.avail_in)==0)
624
+ return Z_BUF_ERROR;
625
+ p=z.next_in_index;
626
+ m=z.istate.marker;
627
+
628
+ // search
629
+ while (n!=0 && m < 4){
630
+ if(z.next_in[p] == mark[m]){
631
+ m++;
632
+ }
633
+ else if(z.next_in[p]!=0){
634
+ m = 0;
635
+ }
636
+ else{
637
+ m = 4 - m;
638
+ }
639
+ p++; n--;
640
+ }
641
+
642
+ // restore
643
+ z.total_in += p-z.next_in_index;
644
+ z.next_in_index = p;
645
+ z.avail_in = n;
646
+ z.istate.marker = m;
647
+
648
+ // return no joy or set up to restart on a new block
649
+ if(m != 4){
650
+ return Z_DATA_ERROR;
651
+ }
652
+ r=z.total_in; w=z.total_out;
653
+ this.inflateReset(z);
654
+ z.total_in=r; z.total_out = w;
655
+ z.istate.mode = BLOCKS;
656
+ return Z_OK;
657
+ }
658
+
659
+ // Returns true if inflate is currently at the end of a block generated
660
+ // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
661
+ // implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
662
+ // but removes the length bytes of the resulting empty stored block. When
663
+ // decompressing, PPP checks that at the end of input packet, inflate is
664
+ // waiting for these length bytes.
665
+ Inflate.prototype.inflateSyncPoint = function(z){
666
+ if(z == null || z.istate == null || z.istate.blocks == null)
667
+ return Z_STREAM_ERROR;
668
+ return z.istate.blocks.sync_point();
669
+ }
670
+
671
+
672
+ //
673
+ // InfBlocks.java
674
+ //
675
+
676
+ var INFBLOCKS_BORDER = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
677
+
678
+ function InfBlocks(z, checkfn, w) {
679
+ this.hufts=new Int32Array(MANY*3);
680
+ this.window=new Uint8Array(w);
681
+ this.end=w;
682
+ this.checkfn = checkfn;
683
+ this.mode = IB_TYPE;
684
+ this.reset(z, null);
685
+
686
+ this.left = 0; // if STORED, bytes left to copy
687
+
688
+ this.table = 0; // table lengths (14 bits)
689
+ this.index = 0; // index into blens (or border)
690
+ this.blens = null; // bit lengths of codes
691
+ this.bb=new Int32Array(1); // bit length tree depth
692
+ this.tb=new Int32Array(1); // bit length decoding tree
693
+
694
+ this.codes = new InfCodes();
695
+
696
+ this.last = 0; // true if this block is the last block
697
+
698
+ // mode independent information
699
+ this.bitk = 0; // bits in bit buffer
700
+ this.bitb = 0; // bit buffer
701
+ this.read = 0; // window read pointer
702
+ this.write = 0; // window write pointer
703
+ this.check = 0; // check on output
704
+
705
+ this.inftree=new InfTree();
706
+ }
707
+
708
+
709
+
710
+
711
+ InfBlocks.prototype.reset = function(z, c){
712
+ if(c) c[0]=this.check;
713
+ if(this.mode==IB_CODES){
714
+ this.codes.free(z);
715
+ }
716
+ this.mode=IB_TYPE;
717
+ this.bitk=0;
718
+ this.bitb=0;
719
+ this.read=this.write=0;
720
+
721
+ if(this.checkfn)
722
+ z.adler=this.check=z._adler.adler32(0, null, 0, 0);
723
+ }
724
+
725
+ InfBlocks.prototype.proc = function(z, r){
726
+ var t; // temporary storage
727
+ var b; // bit buffer
728
+ var k; // bits in bit buffer
729
+ var p; // input data pointer
730
+ var n; // bytes available there
731
+ var q; // output window write pointer
732
+ var m; // bytes to end of window or read pointer
733
+
734
+ // copy input/output information to locals (UPDATE macro restores)
735
+ {p=z.next_in_index;n=z.avail_in;b=this.bitb;k=this.bitk;}
736
+ {q=this.write;m=(q<this.read ? this.read-q-1 : this.end-q);}
737
+
738
+ // process input based on current state
739
+ while(true){
740
+ switch (this.mode){
741
+ case IB_TYPE:
742
+
743
+ while(k<(3)){
744
+ if(n!=0){
745
+ r=Z_OK;
746
+ }
747
+ else{
748
+ this.bitb=b; this.bitk=k;
749
+ z.avail_in=n;
750
+ z.total_in+=p-z.next_in_index;z.next_in_index=p;
751
+ this.write=q;
752
+ return this.inflate_flush(z,r);
753
+ };
754
+ n--;
755
+ b|=(z.next_in[p++]&0xff)<<k;
756
+ k+=8;
757
+ }
758
+ t = (b & 7);
759
+ this.last = t & 1;
760
+
761
+ switch (t >>> 1){
762
+ case 0: // stored
763
+ {b>>>=(3);k-=(3);}
764
+ t = k & 7; // go to byte boundary
765
+
766
+ {b>>>=(t);k-=(t);}
767
+ this.mode = IB_LENS; // get length of stored block
768
+ break;
769
+ case 1: // fixed
770
+ {
771
+ var bl=new Int32Array(1);
772
+ var bd=new Int32Array(1);
773
+ var tl=[];
774
+ var td=[];
775
+
776
+ inflate_trees_fixed(bl, bd, tl, td, z);
777
+ this.codes.init(bl[0], bd[0], tl[0], 0, td[0], 0, z);
778
+ }
779
+
780
+ {b>>>=(3);k-=(3);}
781
+
782
+ this.mode = IB_CODES;
783
+ break;
784
+ case 2: // dynamic
785
+
786
+ {b>>>=(3);k-=(3);}
787
+
788
+ this.mode = IB_TABLE;
789
+ break;
790
+ case 3: // illegal
791
+
792
+ {b>>>=(3);k-=(3);}
793
+ this.mode = BAD;
794
+ z.msg = "invalid block type";
795
+ r = Z_DATA_ERROR;
796
+
797
+ this.bitb=b; this.bitk=k;
798
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
799
+ this.write=q;
800
+ return this.inflate_flush(z,r);
801
+ }
802
+ break;
803
+ case IB_LENS:
804
+ while(k<(32)){
805
+ if(n!=0){
806
+ r=Z_OK;
807
+ }
808
+ else{
809
+ this.bitb=b; this.bitk=k;
810
+ z.avail_in=n;
811
+ z.total_in+=p-z.next_in_index;z.next_in_index=p;
812
+ this.write=q;
813
+ return this.inflate_flush(z,r);
814
+ };
815
+ n--;
816
+ b|=(z.next_in[p++]&0xff)<<k;
817
+ k+=8;
818
+ }
819
+
820
+ if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)){
821
+ this.mode = BAD;
822
+ z.msg = "invalid stored block lengths";
823
+ r = Z_DATA_ERROR;
824
+
825
+ this.bitb=b; this.bitk=k;
826
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
827
+ this.write=q;
828
+ return this.inflate_flush(z,r);
829
+ }
830
+ this.left = (b & 0xffff);
831
+ b = k = 0; // dump bits
832
+ this.mode = this.left!=0 ? IB_STORED : (this.last!=0 ? IB_DRY : IB_TYPE);
833
+ break;
834
+ case IB_STORED:
835
+ if (n == 0){
836
+ this.bitb=b; this.bitk=k;
837
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
838
+ write=q;
839
+ return this.inflate_flush(z,r);
840
+ }
841
+
842
+ if(m==0){
843
+ if(q==end&&read!=0){
844
+ q=0; m=(q<this.read ? this.read-q-1 : this.end-q);
845
+ }
846
+ if(m==0){
847
+ this.write=q;
848
+ r=this.inflate_flush(z,r);
849
+ q=this.write; m = (q < this.read ? this.read-q-1 : this.end-q);
850
+ if(q==this.end && this.read != 0){
851
+ q=0; m = (q < this.read ? this.read-q-1 : this.end-q);
852
+ }
853
+ if(m==0){
854
+ this.bitb=b; this.bitk=k;
855
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
856
+ this.write=q;
857
+ return this.inflate_flush(z,r);
858
+ }
859
+ }
860
+ }
861
+ r=Z_OK;
862
+
863
+ t = this.left;
864
+ if(t>n) t = n;
865
+ if(t>m) t = m;
866
+ arrayCopy(z.next_in, p, this.window, q, t);
867
+ p += t; n -= t;
868
+ q += t; m -= t;
869
+ if ((this.left -= t) != 0)
870
+ break;
871
+ this.mode = (this.last != 0 ? IB_DRY : IB_TYPE);
872
+ break;
873
+ case IB_TABLE:
874
+
875
+ while(k<(14)){
876
+ if(n!=0){
877
+ r=Z_OK;
878
+ }
879
+ else{
880
+ this.bitb=b; this.bitk=k;
881
+ z.avail_in=n;
882
+ z.total_in+=p-z.next_in_index;z.next_in_index=p;
883
+ this.write=q;
884
+ return this.inflate_flush(z,r);
885
+ };
886
+ n--;
887
+ b|=(z.next_in[p++]&0xff)<<k;
888
+ k+=8;
889
+ }
890
+
891
+ this.table = t = (b & 0x3fff);
892
+ if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
893
+ {
894
+ this.mode = IB_BAD;
895
+ z.msg = "too many length or distance symbols";
896
+ r = Z_DATA_ERROR;
897
+
898
+ this.bitb=b; this.bitk=k;
899
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
900
+ this.write=q;
901
+ return this.inflate_flush(z,r);
902
+ }
903
+ t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
904
+ if(this.blens==null || this.blens.length<t){
905
+ this.blens=new Int32Array(t);
906
+ }
907
+ else{
908
+ for(var i=0; i<t; i++){
909
+ this.blens[i]=0;
910
+ }
911
+ }
912
+
913
+ {b>>>=(14);k-=(14);}
914
+
915
+ this.index = 0;
916
+ mode = IB_BTREE;
917
+ case IB_BTREE:
918
+ while (this.index < 4 + (this.table >>> 10)){
919
+ while(k<(3)){
920
+ if(n!=0){
921
+ r=Z_OK;
922
+ }
923
+ else{
924
+ this.bitb=b; this.bitk=k;
925
+ z.avail_in=n;
926
+ z.total_in+=p-z.next_in_index;z.next_in_index=p;
927
+ this.write=q;
928
+ return this.inflate_flush(z,r);
929
+ };
930
+ n--;
931
+ b|=(z.next_in[p++]&0xff)<<k;
932
+ k+=8;
933
+ }
934
+
935
+ this.blens[INFBLOCKS_BORDER[this.index++]] = b&7;
936
+
937
+ {b>>>=(3);k-=(3);}
938
+ }
939
+
940
+ while(this.index < 19){
941
+ this.blens[INFBLOCKS_BORDER[this.index++]] = 0;
942
+ }
943
+
944
+ this.bb[0] = 7;
945
+ t = this.inftree.inflate_trees_bits(this.blens, this.bb, this.tb, this.hufts, z);
946
+ if (t != Z_OK){
947
+ r = t;
948
+ if (r == Z_DATA_ERROR){
949
+ this.blens=null;
950
+ this.mode = IB_BAD;
951
+ }
952
+
953
+ this.bitb=b; this.bitk=k;
954
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
955
+ write=q;
956
+ return this.inflate_flush(z,r);
957
+ }
958
+
959
+ this.index = 0;
960
+ this.mode = IB_DTREE;
961
+ case IB_DTREE:
962
+ while (true){
963
+ t = this.table;
964
+ if(!(this.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))){
965
+ break;
966
+ }
967
+
968
+ var h; //int[]
969
+ var i, j, c;
970
+
971
+ t = this.bb[0];
972
+
973
+ while(k<(t)){
974
+ if(n!=0){
975
+ r=Z_OK;
976
+ }
977
+ else{
978
+ this.bitb=b; this.bitk=k;
979
+ z.avail_in=n;
980
+ z.total_in+=p-z.next_in_index;z.next_in_index=p;
981
+ this.write=q;
982
+ return this.inflate_flush(z,r);
983
+ };
984
+ n--;
985
+ b|=(z.next_in[p++]&0xff)<<k;
986
+ k+=8;
987
+ }
988
+
989
+ // if (this.tb[0]==-1){
990
+ // dlog("null...");
991
+ // }
992
+
993
+ t=this.hufts[(this.tb[0]+(b & inflate_mask[t]))*3+1];
994
+ c=this.hufts[(this.tb[0]+(b & inflate_mask[t]))*3+2];
995
+
996
+ if (c < 16){
997
+ b>>>=(t);k-=(t);
998
+ this.blens[this.index++] = c;
999
+ }
1000
+ else { // c == 16..18
1001
+ i = c == 18 ? 7 : c - 14;
1002
+ j = c == 18 ? 11 : 3;
1003
+
1004
+ while(k<(t+i)){
1005
+ if(n!=0){
1006
+ r=Z_OK;
1007
+ }
1008
+ else{
1009
+ this.bitb=b; this.bitk=k;
1010
+ z.avail_in=n;
1011
+ z.total_in+=p-z.next_in_index;z.next_in_index=p;
1012
+ this.write=q;
1013
+ return this.inflate_flush(z,r);
1014
+ };
1015
+ n--;
1016
+ b|=(z.next_in[p++]&0xff)<<k;
1017
+ k+=8;
1018
+ }
1019
+
1020
+ b>>>=(t);k-=(t);
1021
+
1022
+ j += (b & inflate_mask[i]);
1023
+
1024
+ b>>>=(i);k-=(i);
1025
+
1026
+ i = this.index;
1027
+ t = this.table;
1028
+ if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
1029
+ (c == 16 && i < 1)){
1030
+ this.blens=null;
1031
+ this.mode = IB_BAD;
1032
+ z.msg = "invalid bit length repeat";
1033
+ r = Z_DATA_ERROR;
1034
+
1035
+ this.bitb=b; this.bitk=k;
1036
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1037
+ this.write=q;
1038
+ return this.inflate_flush(z,r);
1039
+ }
1040
+
1041
+ c = c == 16 ? this.blens[i-1] : 0;
1042
+ do{
1043
+ this.blens[i++] = c;
1044
+ }
1045
+ while (--j!=0);
1046
+ this.index = i;
1047
+ }
1048
+ }
1049
+
1050
+ this.tb[0]=-1;
1051
+ {
1052
+ var bl=new Int32Array(1);
1053
+ var bd=new Int32Array(1);
1054
+ var tl=new Int32Array(1);
1055
+ var td=new Int32Array(1);
1056
+ bl[0] = 9; // must be <= 9 for lookahead assumptions
1057
+ bd[0] = 6; // must be <= 9 for lookahead assumptions
1058
+
1059
+ t = this.table;
1060
+ t = this.inftree.inflate_trees_dynamic(257 + (t & 0x1f),
1061
+ 1 + ((t >> 5) & 0x1f),
1062
+ this.blens, bl, bd, tl, td, this.hufts, z);
1063
+
1064
+ if (t != Z_OK){
1065
+ if (t == Z_DATA_ERROR){
1066
+ this.blens=null;
1067
+ this.mode = BAD;
1068
+ }
1069
+ r = t;
1070
+
1071
+ this.bitb=b; this.bitk=k;
1072
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1073
+ this.write=q;
1074
+ return this.inflate_flush(z,r);
1075
+ }
1076
+ this.codes.init(bl[0], bd[0], this.hufts, tl[0], this.hufts, td[0], z);
1077
+ }
1078
+ this.mode = IB_CODES;
1079
+ case IB_CODES:
1080
+ this.bitb=b; this.bitk=k;
1081
+ z.avail_in=n; z.total_in+=p-z.next_in_index;z.next_in_index=p;
1082
+ this.write=q;
1083
+
1084
+ if ((r = this.codes.proc(this, z, r)) != Z_STREAM_END){
1085
+ return this.inflate_flush(z, r);
1086
+ }
1087
+ r = Z_OK;
1088
+ this.codes.free(z);
1089
+
1090
+ p=z.next_in_index; n=z.avail_in;b=this.bitb;k=this.bitk;
1091
+ q=this.write;m = (q < this.read ? this.read-q-1 : this.end-q);
1092
+
1093
+ if (this.last==0){
1094
+ this.mode = IB_TYPE;
1095
+ break;
1096
+ }
1097
+ this.mode = IB_DRY;
1098
+ case IB_DRY:
1099
+ this.write=q;
1100
+ r = this.inflate_flush(z, r);
1101
+ q=this.write; m = (q < this.read ? this.read-q-1 : this.end-q);
1102
+ if (this.read != this.write){
1103
+ this.bitb=b; this.bitk=k;
1104
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1105
+ this.write=q;
1106
+ return this.inflate_flush(z, r);
1107
+ }
1108
+ mode = DONE;
1109
+ case IB_DONE:
1110
+ r = Z_STREAM_END;
1111
+
1112
+ this.bitb=b; this.bitk=k;
1113
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1114
+ this.write=q;
1115
+ return this.inflate_flush(z, r);
1116
+ case IB_BAD:
1117
+ r = Z_DATA_ERROR;
1118
+
1119
+ this.bitb=b; this.bitk=k;
1120
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1121
+ this.write=q;
1122
+ return this.inflate_flush(z, r);
1123
+
1124
+ default:
1125
+ r = Z_STREAM_ERROR;
1126
+
1127
+ this.bitb=b; this.bitk=k;
1128
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1129
+ this.write=q;
1130
+ return this.inflate_flush(z, r);
1131
+ }
1132
+ }
1133
+ }
1134
+
1135
+ InfBlocks.prototype.free = function(z){
1136
+ this.reset(z, null);
1137
+ this.window=null;
1138
+ this.hufts=null;
1139
+ }
1140
+
1141
+ InfBlocks.prototype.set_dictionary = function(d, start, n){
1142
+ arrayCopy(d, start, window, 0, n);
1143
+ this.read = this.write = n;
1144
+ }
1145
+
1146
+ // Returns true if inflate is currently at the end of a block generated
1147
+ // by Z_SYNC_FLUSH or Z_FULL_FLUSH.
1148
+ InfBlocks.prototype.sync_point = function(){
1149
+ return this.mode == IB_LENS;
1150
+ }
1151
+
1152
+ // copy as much as possible from the sliding window to the output area
1153
+ InfBlocks.prototype.inflate_flush = function(z, r){
1154
+ var n;
1155
+ var p;
1156
+ var q;
1157
+
1158
+ // local copies of source and destination pointers
1159
+ p = z.next_out_index;
1160
+ q = this.read;
1161
+
1162
+ // compute number of bytes to copy as far as end of window
1163
+ n = ((q <= this.write ? this.write : this.end) - q);
1164
+ if (n > z.avail_out) n = z.avail_out;
1165
+ if (n!=0 && r == Z_BUF_ERROR) r = Z_OK;
1166
+
1167
+ // update counters
1168
+ z.avail_out -= n;
1169
+ z.total_out += n;
1170
+
1171
+ // update check information
1172
+ if(this.checkfn != null)
1173
+ z.adler=this.check=z._adler.adler32(this.check, this.window, q, n);
1174
+
1175
+ // copy as far as end of window
1176
+ arrayCopy(this.window, q, z.next_out, p, n);
1177
+ p += n;
1178
+ q += n;
1179
+
1180
+ // see if more to copy at beginning of window
1181
+ if (q == this.end){
1182
+ // wrap pointers
1183
+ q = 0;
1184
+ if (this.write == this.end)
1185
+ this.write = 0;
1186
+
1187
+ // compute bytes to copy
1188
+ n = this.write - q;
1189
+ if (n > z.avail_out) n = z.avail_out;
1190
+ if (n!=0 && r == Z_BUF_ERROR) r = Z_OK;
1191
+
1192
+ // update counters
1193
+ z.avail_out -= n;
1194
+ z.total_out += n;
1195
+
1196
+ // update check information
1197
+ if(this.checkfn != null)
1198
+ z.adler=this.check=z._adler.adler32(this.check, this.window, q, n);
1199
+
1200
+ // copy
1201
+ arrayCopy(this.window, q, z.next_out, p, n);
1202
+ p += n;
1203
+ q += n;
1204
+ }
1205
+
1206
+ // update pointers
1207
+ z.next_out_index = p;
1208
+ this.read = q;
1209
+
1210
+ // done
1211
+ return r;
1212
+ }
1213
+
1214
+ //
1215
+ // InfCodes.java
1216
+ //
1217
+
1218
+ var IC_START=0; // x: set up for LEN
1219
+ var IC_LEN=1; // i: get length/literal/eob next
1220
+ var IC_LENEXT=2; // i: getting length extra (have base)
1221
+ var IC_DIST=3; // i: get distance next
1222
+ var IC_DISTEXT=4;// i: getting distance extra
1223
+ var IC_COPY=5; // o: copying bytes in window, waiting for space
1224
+ var IC_LIT=6; // o: got literal, waiting for output space
1225
+ var IC_WASH=7; // o: got eob, possibly still output waiting
1226
+ var IC_END=8; // x: got eob and all data flushed
1227
+ var IC_BADCODE=9;// x: got error
1228
+
1229
+ function InfCodes() {
1230
+ }
1231
+
1232
+ InfCodes.prototype.init = function(bl, bd, tl, tl_index, td, td_index, z) {
1233
+ this.mode=IC_START;
1234
+ this.lbits=bl;
1235
+ this.dbits=bd;
1236
+ this.ltree=tl;
1237
+ this.ltree_index=tl_index;
1238
+ this.dtree = td;
1239
+ this.dtree_index=td_index;
1240
+ this.tree=null;
1241
+ }
1242
+
1243
+ InfCodes.prototype.proc = function(s, z, r){
1244
+ var j; // temporary storage
1245
+ var t; // temporary pointer (int[])
1246
+ var tindex; // temporary pointer
1247
+ var e; // extra bits or operation
1248
+ var b=0; // bit buffer
1249
+ var k=0; // bits in bit buffer
1250
+ var p=0; // input data pointer
1251
+ var n; // bytes available there
1252
+ var q; // output window write pointer
1253
+ var m; // bytes to end of window or read pointer
1254
+ var f; // pointer to copy strings from
1255
+
1256
+ // copy input/output information to locals (UPDATE macro restores)
1257
+ p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
1258
+ q=s.write;m=q<s.read?s.read-q-1:s.end-q;
1259
+
1260
+ // process input and output based on current state
1261
+ while (true){
1262
+ switch (this.mode){
1263
+ // waiting for "i:"=input, "o:"=output, "x:"=nothing
1264
+ case IC_START: // x: set up for LEN
1265
+ if (m >= 258 && n >= 10){
1266
+
1267
+ s.bitb=b;s.bitk=k;
1268
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1269
+ s.write=q;
1270
+ r = this.inflate_fast(this.lbits, this.dbits,
1271
+ this.ltree, this.ltree_index,
1272
+ this.dtree, this.dtree_index,
1273
+ s, z);
1274
+
1275
+ p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
1276
+ q=s.write;m=q<s.read?s.read-q-1:s.end-q;
1277
+
1278
+ if (r != Z_OK){
1279
+ this.mode = r == Z_STREAM_END ? IC_WASH : IC_BADCODE;
1280
+ break;
1281
+ }
1282
+ }
1283
+ this.need = this.lbits;
1284
+ this.tree = this.ltree;
1285
+ this.tree_index=this.ltree_index;
1286
+
1287
+ this.mode = IC_LEN;
1288
+ case IC_LEN: // i: get length/literal/eob next
1289
+ j = this.need;
1290
+
1291
+ while(k<(j)){
1292
+ if(n!=0)r=Z_OK;
1293
+ else{
1294
+
1295
+ s.bitb=b;s.bitk=k;
1296
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1297
+ s.write=q;
1298
+ return s.inflate_flush(z,r);
1299
+ }
1300
+ n--;
1301
+ b|=(z.next_in[p++]&0xff)<<k;
1302
+ k+=8;
1303
+ }
1304
+
1305
+ tindex=(this.tree_index+(b&inflate_mask[j]))*3;
1306
+
1307
+ b>>>=(this.tree[tindex+1]);
1308
+ k-=(this.tree[tindex+1]);
1309
+
1310
+ e=this.tree[tindex];
1311
+
1312
+ if(e == 0){ // literal
1313
+ this.lit = this.tree[tindex+2];
1314
+ this.mode = IC_LIT;
1315
+ break;
1316
+ }
1317
+ if((e & 16)!=0 ){ // length
1318
+ this.get = e & 15;
1319
+ this.len = this.tree[tindex+2];
1320
+ this.mode = IC_LENEXT;
1321
+ break;
1322
+ }
1323
+ if ((e & 64) == 0){ // next table
1324
+ this.need = e;
1325
+ this.tree_index = tindex/3 + this.tree[tindex+2];
1326
+ break;
1327
+ }
1328
+ if ((e & 32)!=0){ // end of block
1329
+ this.mode = IC_WASH;
1330
+ break;
1331
+ }
1332
+ this.mode = IC_BADCODE; // invalid code
1333
+ z.msg = "invalid literal/length code";
1334
+ r = Z_DATA_ERROR;
1335
+
1336
+ s.bitb=b;s.bitk=k;
1337
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1338
+ s.write=q;
1339
+ return s.inflate_flush(z,r);
1340
+
1341
+ case IC_LENEXT: // i: getting length extra (have base)
1342
+ j = this.get;
1343
+
1344
+ while(k<(j)){
1345
+ if(n!=0)r=Z_OK;
1346
+ else{
1347
+
1348
+ s.bitb=b;s.bitk=k;
1349
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1350
+ s.write=q;
1351
+ return s.inflate_flush(z,r);
1352
+ }
1353
+ n--; b|=(z.next_in[p++]&0xff)<<k;
1354
+ k+=8;
1355
+ }
1356
+
1357
+ this.len += (b & inflate_mask[j]);
1358
+
1359
+ b>>=j;
1360
+ k-=j;
1361
+
1362
+ this.need = this.dbits;
1363
+ this.tree = this.dtree;
1364
+ this.tree_index = this.dtree_index;
1365
+ this.mode = IC_DIST;
1366
+ case IC_DIST: // i: get distance next
1367
+ j = this.need;
1368
+
1369
+ while(k<(j)){
1370
+ if(n!=0)r=Z_OK;
1371
+ else{
1372
+
1373
+ s.bitb=b;s.bitk=k;
1374
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1375
+ s.write=q;
1376
+ return s.inflate_flush(z,r);
1377
+ }
1378
+ n--; b|=(z.next_in[p++]&0xff)<<k;
1379
+ k+=8;
1380
+ }
1381
+
1382
+ tindex=(this.tree_index+(b & inflate_mask[j]))*3;
1383
+
1384
+ b>>=this.tree[tindex+1];
1385
+ k-=this.tree[tindex+1];
1386
+
1387
+ e = (this.tree[tindex]);
1388
+ if((e & 16)!=0){ // distance
1389
+ this.get = e & 15;
1390
+ this.dist = this.tree[tindex+2];
1391
+ this.mode = IC_DISTEXT;
1392
+ break;
1393
+ }
1394
+ if ((e & 64) == 0){ // next table
1395
+ this.need = e;
1396
+ this.tree_index = tindex/3 + this.tree[tindex+2];
1397
+ break;
1398
+ }
1399
+ this.mode = IC_BADCODE; // invalid code
1400
+ z.msg = "invalid distance code";
1401
+ r = Z_DATA_ERROR;
1402
+
1403
+ s.bitb=b;s.bitk=k;
1404
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1405
+ s.write=q;
1406
+ return s.inflate_flush(z,r);
1407
+
1408
+ case IC_DISTEXT: // i: getting distance extra
1409
+ j = this.get;
1410
+
1411
+ while(k<(j)){
1412
+ if(n!=0)r=Z_OK;
1413
+ else{
1414
+
1415
+ s.bitb=b;s.bitk=k;
1416
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1417
+ s.write=q;
1418
+ return s.inflate_flush(z,r);
1419
+ }
1420
+ n--; b|=(z.next_in[p++]&0xff)<<k;
1421
+ k+=8;
1422
+ }
1423
+
1424
+ this.dist += (b & inflate_mask[j]);
1425
+
1426
+ b>>=j;
1427
+ k-=j;
1428
+
1429
+ this.mode = IC_COPY;
1430
+ case IC_COPY: // o: copying bytes in window, waiting for space
1431
+ f = q - this.dist;
1432
+ while(f < 0){ // modulo window size-"while" instead
1433
+ f += s.end; // of "if" handles invalid distances
1434
+ }
1435
+ while (this.len!=0){
1436
+
1437
+ if(m==0){
1438
+ if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
1439
+ if(m==0){
1440
+ s.write=q; r=s.inflate_flush(z,r);
1441
+ q=s.write;m=q<s.read?s.read-q-1:s.end-q;
1442
+
1443
+ if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
1444
+
1445
+ if(m==0){
1446
+ s.bitb=b;s.bitk=k;
1447
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1448
+ s.write=q;
1449
+ return s.inflate_flush(z,r);
1450
+ }
1451
+ }
1452
+ }
1453
+
1454
+ s.window[q++]=s.window[f++]; m--;
1455
+
1456
+ if (f == s.end)
1457
+ f = 0;
1458
+ this.len--;
1459
+ }
1460
+ this.mode = IC_START;
1461
+ break;
1462
+ case IC_LIT: // o: got literal, waiting for output space
1463
+ if(m==0){
1464
+ if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
1465
+ if(m==0){
1466
+ s.write=q; r=s.inflate_flush(z,r);
1467
+ q=s.write;m=q<s.read?s.read-q-1:s.end-q;
1468
+
1469
+ if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
1470
+ if(m==0){
1471
+ s.bitb=b;s.bitk=k;
1472
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1473
+ s.write=q;
1474
+ return s.inflate_flush(z,r);
1475
+ }
1476
+ }
1477
+ }
1478
+ r=Z_OK;
1479
+
1480
+ s.window[q++]=this.lit; m--;
1481
+
1482
+ this.mode = IC_START;
1483
+ break;
1484
+ case IC_WASH: // o: got eob, possibly more output
1485
+ if (k > 7){ // return unused byte, if any
1486
+ k -= 8;
1487
+ n++;
1488
+ p--; // can always return one
1489
+ }
1490
+
1491
+ s.write=q; r=s.inflate_flush(z,r);
1492
+ q=s.write;m=q<s.read?s.read-q-1:s.end-q;
1493
+
1494
+ if (s.read != s.write){
1495
+ s.bitb=b;s.bitk=k;
1496
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1497
+ s.write=q;
1498
+ return s.inflate_flush(z,r);
1499
+ }
1500
+ this.mode = IC_END;
1501
+ case IC_END:
1502
+ r = Z_STREAM_END;
1503
+ s.bitb=b;s.bitk=k;
1504
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1505
+ s.write=q;
1506
+ return s.inflate_flush(z,r);
1507
+
1508
+ case IC_BADCODE: // x: got error
1509
+
1510
+ r = Z_DATA_ERROR;
1511
+
1512
+ s.bitb=b;s.bitk=k;
1513
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1514
+ s.write=q;
1515
+ return s.inflate_flush(z,r);
1516
+
1517
+ default:
1518
+ r = Z_STREAM_ERROR;
1519
+
1520
+ s.bitb=b;s.bitk=k;
1521
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1522
+ s.write=q;
1523
+ return s.inflate_flush(z,r);
1524
+ }
1525
+ }
1526
+ }
1527
+
1528
+ InfCodes.prototype.free = function(z){
1529
+ // ZFREE(z, c);
1530
+ }
1531
+
1532
+ // Called with number of bytes left to write in window at least 258
1533
+ // (the maximum string length) and number of input bytes available
1534
+ // at least ten. The ten bytes are six bytes for the longest length/
1535
+ // distance pair plus four bytes for overloading the bit buffer.
1536
+
1537
+ InfCodes.prototype.inflate_fast = function(bl, bd, tl, tl_index, td, td_index, s, z) {
1538
+ var t; // temporary pointer
1539
+ var tp; // temporary pointer (int[])
1540
+ var tp_index; // temporary pointer
1541
+ var e; // extra bits or operation
1542
+ var b; // bit buffer
1543
+ var k; // bits in bit buffer
1544
+ var p; // input data pointer
1545
+ var n; // bytes available there
1546
+ var q; // output window write pointer
1547
+ var m; // bytes to end of window or read pointer
1548
+ var ml; // mask for literal/length tree
1549
+ var md; // mask for distance tree
1550
+ var c; // bytes to copy
1551
+ var d; // distance back to copy from
1552
+ var r; // copy source pointer
1553
+
1554
+ var tp_index_t_3; // (tp_index+t)*3
1555
+
1556
+ // load input, output, bit values
1557
+ p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
1558
+ q=s.write;m=q<s.read?s.read-q-1:s.end-q;
1559
+
1560
+ // initialize masks
1561
+ ml = inflate_mask[bl];
1562
+ md = inflate_mask[bd];
1563
+
1564
+ // do until not enough input or output space for fast loop
1565
+ do { // assume called with m >= 258 && n >= 10
1566
+ // get literal/length code
1567
+ while(k<(20)){ // max bits for literal/length code
1568
+ n--;
1569
+ b|=(z.next_in[p++]&0xff)<<k;k+=8;
1570
+ }
1571
+
1572
+ t= b&ml;
1573
+ tp=tl;
1574
+ tp_index=tl_index;
1575
+ tp_index_t_3=(tp_index+t)*3;
1576
+ if ((e = tp[tp_index_t_3]) == 0){
1577
+ b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
1578
+
1579
+ s.window[q++] = tp[tp_index_t_3+2];
1580
+ m--;
1581
+ continue;
1582
+ }
1583
+ do {
1584
+
1585
+ b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
1586
+
1587
+ if((e&16)!=0){
1588
+ e &= 15;
1589
+ c = tp[tp_index_t_3+2] + (b & inflate_mask[e]);
1590
+
1591
+ b>>=e; k-=e;
1592
+
1593
+ // decode distance base of block to copy
1594
+ while(k<(15)){ // max bits for distance code
1595
+ n--;
1596
+ b|=(z.next_in[p++]&0xff)<<k;k+=8;
1597
+ }
1598
+
1599
+ t= b&md;
1600
+ tp=td;
1601
+ tp_index=td_index;
1602
+ tp_index_t_3=(tp_index+t)*3;
1603
+ e = tp[tp_index_t_3];
1604
+
1605
+ do {
1606
+
1607
+ b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
1608
+
1609
+ if((e&16)!=0){
1610
+ // get extra bits to add to distance base
1611
+ e &= 15;
1612
+ while(k<(e)){ // get extra bits (up to 13)
1613
+ n--;
1614
+ b|=(z.next_in[p++]&0xff)<<k;k+=8;
1615
+ }
1616
+
1617
+ d = tp[tp_index_t_3+2] + (b&inflate_mask[e]);
1618
+
1619
+ b>>=(e); k-=(e);
1620
+
1621
+ // do the copy
1622
+ m -= c;
1623
+ if (q >= d){ // offset before dest
1624
+ // just copy
1625
+ r=q-d;
1626
+ if(q-r>0 && 2>(q-r)){
1627
+ s.window[q++]=s.window[r++]; // minimum count is three,
1628
+ s.window[q++]=s.window[r++]; // so unroll loop a little
1629
+ c-=2;
1630
+ }
1631
+ else{
1632
+ s.window[q++]=s.window[r++]; // minimum count is three,
1633
+ s.window[q++]=s.window[r++]; // so unroll loop a little
1634
+ c-=2;
1635
+ }
1636
+ }
1637
+ else{ // else offset after destination
1638
+ r=q-d;
1639
+ do{
1640
+ r+=s.end; // force pointer in window
1641
+ }while(r<0); // covers invalid distances
1642
+ e=s.end-r;
1643
+ if(c>e){ // if source crosses,
1644
+ c-=e; // wrapped copy
1645
+ if(q-r>0 && e>(q-r)){
1646
+ do{s.window[q++] = s.window[r++];}
1647
+ while(--e!=0);
1648
+ }
1649
+ else{
1650
+ arrayCopy(s.window, r, s.window, q, e);
1651
+ q+=e; r+=e; e=0;
1652
+ }
1653
+ r = 0; // copy rest from start of window
1654
+ }
1655
+
1656
+ }
1657
+
1658
+ // copy all or what's left
1659
+ do{s.window[q++] = s.window[r++];}
1660
+ while(--c!=0);
1661
+ break;
1662
+ }
1663
+ else if((e&64)==0){
1664
+ t+=tp[tp_index_t_3+2];
1665
+ t+=(b&inflate_mask[e]);
1666
+ tp_index_t_3=(tp_index+t)*3;
1667
+ e=tp[tp_index_t_3];
1668
+ }
1669
+ else{
1670
+ z.msg = "invalid distance code";
1671
+
1672
+ c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
1673
+
1674
+ s.bitb=b;s.bitk=k;
1675
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1676
+ s.write=q;
1677
+
1678
+ return Z_DATA_ERROR;
1679
+ }
1680
+ }
1681
+ while(true);
1682
+ break;
1683
+ }
1684
+
1685
+ if((e&64)==0){
1686
+ t+=tp[tp_index_t_3+2];
1687
+ t+=(b&inflate_mask[e]);
1688
+ tp_index_t_3=(tp_index+t)*3;
1689
+ if((e=tp[tp_index_t_3])==0){
1690
+
1691
+ b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
1692
+
1693
+ s.window[q++]=tp[tp_index_t_3+2];
1694
+ m--;
1695
+ break;
1696
+ }
1697
+ }
1698
+ else if((e&32)!=0){
1699
+
1700
+ c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
1701
+
1702
+ s.bitb=b;s.bitk=k;
1703
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1704
+ s.write=q;
1705
+
1706
+ return Z_STREAM_END;
1707
+ }
1708
+ else{
1709
+ z.msg="invalid literal/length code";
1710
+
1711
+ c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
1712
+
1713
+ s.bitb=b;s.bitk=k;
1714
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1715
+ s.write=q;
1716
+
1717
+ return Z_DATA_ERROR;
1718
+ }
1719
+ }
1720
+ while(true);
1721
+ }
1722
+ while(m>=258 && n>= 10);
1723
+
1724
+ // not enough input or output--restore pointers and return
1725
+ c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
1726
+
1727
+ s.bitb=b;s.bitk=k;
1728
+ z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
1729
+ s.write=q;
1730
+
1731
+ return Z_OK;
1732
+ }
1733
+
1734
+ //
1735
+ // InfTree.java
1736
+ //
1737
+
1738
+ function InfTree() {
1739
+ }
1740
+
1741
+ InfTree.prototype.huft_build = function(b, bindex, n, s, d, e, t, m, hp, hn, v) {
1742
+
1743
+ // Given a list of code lengths and a maximum table size, make a set of
1744
+ // tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
1745
+ // if the given code set is incomplete (the tables are still built in this
1746
+ // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
1747
+ // lengths), or Z_MEM_ERROR if not enough memory.
1748
+
1749
+ var a; // counter for codes of length k
1750
+ var f; // i repeats in table every f entries
1751
+ var g; // maximum code length
1752
+ var h; // table level
1753
+ var i; // counter, current code
1754
+ var j; // counter
1755
+ var k; // number of bits in current code
1756
+ var l; // bits per table (returned in m)
1757
+ var mask; // (1 << w) - 1, to avoid cc -O bug on HP
1758
+ var p; // pointer into c[], b[], or v[]
1759
+ var q; // points to current table
1760
+ var w; // bits before this table == (l * h)
1761
+ var xp; // pointer into x
1762
+ var y; // number of dummy codes added
1763
+ var z; // number of entries in current table
1764
+
1765
+ // Generate counts for each bit length
1766
+
1767
+ p = 0; i = n;
1768
+ do {
1769
+ this.c[b[bindex+p]]++; p++; i--; // assume all entries <= BMAX
1770
+ }while(i!=0);
1771
+
1772
+ if(this.c[0] == n){ // null input--all zero length codes
1773
+ t[0] = -1;
1774
+ m[0] = 0;
1775
+ return Z_OK;
1776
+ }
1777
+
1778
+ // Find minimum and maximum length, bound *m by those
1779
+ l = m[0];
1780
+ for (j = 1; j <= BMAX; j++)
1781
+ if(this.c[j]!=0) break;
1782
+ k = j; // minimum code length
1783
+ if(l < j){
1784
+ l = j;
1785
+ }
1786
+ for (i = BMAX; i!=0; i--){
1787
+ if(this.c[i]!=0) break;
1788
+ }
1789
+ g = i; // maximum code length
1790
+ if(l > i){
1791
+ l = i;
1792
+ }
1793
+ m[0] = l;
1794
+
1795
+ // Adjust last length count to fill out codes, if needed
1796
+ for (y = 1 << j; j < i; j++, y <<= 1){
1797
+ if ((y -= this.c[j]) < 0){
1798
+ return Z_DATA_ERROR;
1799
+ }
1800
+ }
1801
+ if ((y -= this.c[i]) < 0){
1802
+ return Z_DATA_ERROR;
1803
+ }
1804
+ this.c[i] += y;
1805
+
1806
+ // Generate starting offsets into the value table for each length
1807
+ this.x[1] = j = 0;
1808
+ p = 1; xp = 2;
1809
+ while (--i!=0) { // note that i == g from above
1810
+ this.x[xp] = (j += this.c[p]);
1811
+ xp++;
1812
+ p++;
1813
+ }
1814
+
1815
+ // Make a table of values in order of bit lengths
1816
+ i = 0; p = 0;
1817
+ do {
1818
+ if ((j = b[bindex+p]) != 0){
1819
+ this.v[this.x[j]++] = i;
1820
+ }
1821
+ p++;
1822
+ }
1823
+ while (++i < n);
1824
+ n = this.x[g]; // set n to length of v
1825
+
1826
+ // Generate the Huffman codes and for each, make the table entries
1827
+ this.x[0] = i = 0; // first Huffman code is zero
1828
+ p = 0; // grab values in bit order
1829
+ h = -1; // no tables yet--level -1
1830
+ w = -l; // bits decoded == (l * h)
1831
+ this.u[0] = 0; // just to keep compilers happy
1832
+ q = 0; // ditto
1833
+ z = 0; // ditto
1834
+
1835
+ // go through the bit lengths (k already is bits in shortest code)
1836
+ for (; k <= g; k++){
1837
+ a = this.c[k];
1838
+ while (a--!=0){
1839
+ // here i is the Huffman code of length k bits for value *p
1840
+ // make tables up to required level
1841
+ while (k > w + l){
1842
+ h++;
1843
+ w += l; // previous table always l bits
1844
+ // compute minimum size table less than or equal to l bits
1845
+ z = g - w;
1846
+ z = (z > l) ? l : z; // table size upper limit
1847
+ if((f=1<<(j=k-w))>a+1){ // try a k-w bit table
1848
+ // too few codes for k-w bit table
1849
+ f -= a + 1; // deduct codes from patterns left
1850
+ xp = k;
1851
+ if(j < z){
1852
+ while (++j < z){ // try smaller tables up to z bits
1853
+ if((f <<= 1) <= this.c[++xp])
1854
+ break; // enough codes to use up j bits
1855
+ f -= this.c[xp]; // else deduct codes from patterns
1856
+ }
1857
+ }
1858
+ }
1859
+ z = 1 << j; // table entries for j-bit table
1860
+
1861
+ // allocate new table
1862
+ if (this.hn[0] + z > MANY){ // (note: doesn't matter for fixed)
1863
+ return Z_DATA_ERROR; // overflow of MANY
1864
+ }
1865
+ this.u[h] = q = /*hp+*/ this.hn[0]; // DEBUG
1866
+ this.hn[0] += z;
1867
+
1868
+ // connect to last table, if there is one
1869
+ if(h!=0){
1870
+ this.x[h]=i; // save pattern for backing up
1871
+ this.r[0]=j; // bits in this table
1872
+ this.r[1]=l; // bits to dump before this table
1873
+ j=i>>>(w - l);
1874
+ this.r[2] = (q - this.u[h-1] - j); // offset to this table
1875
+ arrayCopy(this.r, 0, hp, (this.u[h-1]+j)*3, 3); // connect to last table
1876
+ }
1877
+ else{
1878
+ t[0] = q; // first table is returned result
1879
+ }
1880
+ }
1881
+
1882
+ // set up table entry in r
1883
+ this.r[1] = (k - w);
1884
+ if (p >= n){
1885
+ this.r[0] = 128 + 64; // out of values--invalid code
1886
+ }
1887
+ else if (v[p] < s){
1888
+ this.r[0] = (this.v[p] < 256 ? 0 : 32 + 64); // 256 is end-of-block
1889
+ this.r[2] = this.v[p++]; // simple code is just the value
1890
+ }
1891
+ else{
1892
+ this.r[0]=(e[this.v[p]-s]+16+64); // non-simple--look up in lists
1893
+ this.r[2]=d[this.v[p++] - s];
1894
+ }
1895
+
1896
+ // fill code-like entries with r
1897
+ f=1<<(k-w);
1898
+ for (j=i>>>w;j<z;j+=f){
1899
+ arrayCopy(this.r, 0, hp, (q+j)*3, 3);
1900
+ }
1901
+
1902
+ // backwards increment the k-bit code i
1903
+ for (j = 1 << (k - 1); (i & j)!=0; j >>>= 1){
1904
+ i ^= j;
1905
+ }
1906
+ i ^= j;
1907
+
1908
+ // backup over finished tables
1909
+ mask = (1 << w) - 1; // needed on HP, cc -O bug
1910
+ while ((i & mask) != this.x[h]){
1911
+ h--; // don't need to update q
1912
+ w -= l;
1913
+ mask = (1 << w) - 1;
1914
+ }
1915
+ }
1916
+ }
1917
+ // Return Z_BUF_ERROR if we were given an incomplete table
1918
+ return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
1919
+ }
1920
+
1921
+ InfTree.prototype.inflate_trees_bits = function(c, bb, tb, hp, z) {
1922
+ var result;
1923
+ this.initWorkArea(19);
1924
+ this.hn[0]=0;
1925
+ result = this.huft_build(c, 0, 19, 19, null, null, tb, bb, hp, this.hn, this.v);
1926
+
1927
+ if(result == Z_DATA_ERROR){
1928
+ z.msg = "oversubscribed dynamic bit lengths tree";
1929
+ }
1930
+ else if(result == Z_BUF_ERROR || bb[0] == 0){
1931
+ z.msg = "incomplete dynamic bit lengths tree";
1932
+ result = Z_DATA_ERROR;
1933
+ }
1934
+ return result;
1935
+ }
1936
+
1937
+ InfTree.prototype.inflate_trees_dynamic = function(nl, nd, c, bl, bd, tl, td, hp, z) {
1938
+ var result;
1939
+
1940
+ // build literal/length tree
1941
+ this.initWorkArea(288);
1942
+ this.hn[0]=0;
1943
+ result = this.huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, this.hn, this.v);
1944
+ if (result != Z_OK || bl[0] == 0){
1945
+ if(result == Z_DATA_ERROR){
1946
+ z.msg = "oversubscribed literal/length tree";
1947
+ }
1948
+ else if (result != Z_MEM_ERROR){
1949
+ z.msg = "incomplete literal/length tree";
1950
+ result = Z_DATA_ERROR;
1951
+ }
1952
+ return result;
1953
+ }
1954
+
1955
+ // build distance tree
1956
+ this.initWorkArea(288);
1957
+ result = this.huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, this.hn, this.v);
1958
+
1959
+ if (result != Z_OK || (bd[0] == 0 && nl > 257)){
1960
+ if (result == Z_DATA_ERROR){
1961
+ z.msg = "oversubscribed distance tree";
1962
+ }
1963
+ else if (result == Z_BUF_ERROR) {
1964
+ z.msg = "incomplete distance tree";
1965
+ result = Z_DATA_ERROR;
1966
+ }
1967
+ else if (result != Z_MEM_ERROR){
1968
+ z.msg = "empty distance tree with lengths";
1969
+ result = Z_DATA_ERROR;
1970
+ }
1971
+ return result;
1972
+ }
1973
+
1974
+ return Z_OK;
1975
+ }
1976
+ /*
1977
+ static int inflate_trees_fixed(int[] bl, //literal desired/actual bit depth
1978
+ int[] bd, //distance desired/actual bit depth
1979
+ int[][] tl,//literal/length tree result
1980
+ int[][] td,//distance tree result
1981
+ ZStream z //for memory allocation
1982
+ ){
1983
+
1984
+ */
1985
+
1986
+ function inflate_trees_fixed(bl, bd, tl, td, z) {
1987
+ bl[0]=fixed_bl;
1988
+ bd[0]=fixed_bd;
1989
+ tl[0]=fixed_tl;
1990
+ td[0]=fixed_td;
1991
+ return Z_OK;
1992
+ }
1993
+
1994
+ InfTree.prototype.initWorkArea = function(vsize){
1995
+ if(this.hn==null){
1996
+ this.hn=new Int32Array(1);
1997
+ this.v=new Int32Array(vsize);
1998
+ this.c=new Int32Array(BMAX+1);
1999
+ this.r=new Int32Array(3);
2000
+ this.u=new Int32Array(BMAX);
2001
+ this.x=new Int32Array(BMAX+1);
2002
+ }
2003
+ if(this.v.length<vsize){
2004
+ this.v=new Int32Array(vsize);
2005
+ }
2006
+ for(var i=0; i<vsize; i++){this.v[i]=0;}
2007
+ for(var i=0; i<BMAX+1; i++){this.c[i]=0;}
2008
+ for(var i=0; i<3; i++){this.r[i]=0;}
2009
+ // for(int i=0; i<BMAX; i++){u[i]=0;}
2010
+ arrayCopy(this.c, 0, this.u, 0, BMAX);
2011
+ // for(int i=0; i<BMAX+1; i++){x[i]=0;}
2012
+ arrayCopy(this.c, 0, this.x, 0, BMAX+1);
2013
+ }
2014
+
2015
+ var testArray = new Uint8Array(1);
2016
+ var hasSubarray = (typeof testArray.subarray === 'function');
2017
+ var hasSlice = false; /* (typeof testArray.slice === 'function'); */ // Chrome slice performance is so dire that we're currently not using it...
2018
+
2019
+ function arrayCopy(src, srcOffset, dest, destOffset, count) {
2020
+ if (count == 0) {
2021
+ return;
2022
+ }
2023
+ if (!src) {
2024
+ throw "Undef src";
2025
+ } else if (!dest) {
2026
+ throw "Undef dest";
2027
+ }
2028
+
2029
+ if (srcOffset == 0 && count == src.length) {
2030
+ arrayCopy_fast(src, dest, destOffset);
2031
+ } else if (hasSubarray) {
2032
+ arrayCopy_fast(src.subarray(srcOffset, srcOffset + count), dest, destOffset);
2033
+ } else if (src.BYTES_PER_ELEMENT == 1 && count > 100) {
2034
+ arrayCopy_fast(new Uint8Array(src.buffer, src.byteOffset + srcOffset, count), dest, destOffset);
2035
+ } else {
2036
+ arrayCopy_slow(src, srcOffset, dest, destOffset, count);
2037
+ }
2038
+
2039
+ }
2040
+
2041
+ function arrayCopy_slow(src, srcOffset, dest, destOffset, count) {
2042
+
2043
+ // dlog('_slow call: srcOffset=' + srcOffset + '; destOffset=' + destOffset + '; count=' + count);
2044
+
2045
+ for (var i = 0; i < count; ++i) {
2046
+ dest[destOffset + i] = src[srcOffset + i];
2047
+ }
2048
+ }
2049
+
2050
+ function arrayCopy_fast(src, dest, destOffset) {
2051
+ dest.set(src, destOffset);
2052
+ }
2053
+
2054
+
2055
+ // largest prime smaller than 65536
2056
+ var ADLER_BASE=65521;
2057
+ // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
2058
+ var ADLER_NMAX=5552;
2059
+
2060
+ function adler32(adler, /* byte[] */ buf, index, len){
2061
+ if(buf == null){ return 1; }
2062
+
2063
+ var s1=adler&0xffff;
2064
+ var s2=(adler>>16)&0xffff;
2065
+ var k;
2066
+
2067
+ while(len > 0) {
2068
+ k=len<ADLER_NMAX?len:ADLER_NMAX;
2069
+ len-=k;
2070
+ while(k>=16){
2071
+ s1+=buf[index++]&0xff; s2+=s1;
2072
+ s1+=buf[index++]&0xff; s2+=s1;
2073
+ s1+=buf[index++]&0xff; s2+=s1;
2074
+ s1+=buf[index++]&0xff; s2+=s1;
2075
+ s1+=buf[index++]&0xff; s2+=s1;
2076
+ s1+=buf[index++]&0xff; s2+=s1;
2077
+ s1+=buf[index++]&0xff; s2+=s1;
2078
+ s1+=buf[index++]&0xff; s2+=s1;
2079
+ s1+=buf[index++]&0xff; s2+=s1;
2080
+ s1+=buf[index++]&0xff; s2+=s1;
2081
+ s1+=buf[index++]&0xff; s2+=s1;
2082
+ s1+=buf[index++]&0xff; s2+=s1;
2083
+ s1+=buf[index++]&0xff; s2+=s1;
2084
+ s1+=buf[index++]&0xff; s2+=s1;
2085
+ s1+=buf[index++]&0xff; s2+=s1;
2086
+ s1+=buf[index++]&0xff; s2+=s1;
2087
+ k-=16;
2088
+ }
2089
+ if(k!=0){
2090
+ do{
2091
+ s1+=buf[index++]&0xff; s2+=s1;
2092
+ }
2093
+ while(--k!=0);
2094
+ }
2095
+ s1%=ADLER_BASE;
2096
+ s2%=ADLER_BASE;
2097
+ }
2098
+ return (s2<<16)|s1;
2099
+ }
2100
+
2101
+
2102
+
2103
+ function jszlib_inflate_buffer(buffer, start, length, afterUncOffset) {
2104
+ if (!start) {
2105
+ buffer = new Uint8Array(buffer);
2106
+ } else if (!length) {
2107
+ buffer = new Uint8Array(buffer, start, buffer.byteLength - start);
2108
+ } else {
2109
+ buffer = new Uint8Array(buffer, start, length);
2110
+ }
2111
+
2112
+ var z = new ZStream();
2113
+ z.inflateInit(DEF_WBITS, true);
2114
+ z.next_in = buffer;
2115
+ z.next_in_index = 0;
2116
+ z.avail_in = buffer.length;
2117
+
2118
+ var oBlockList = [];
2119
+ var totalSize = 0;
2120
+ while (true) {
2121
+ var obuf = new Uint8Array(32000);
2122
+ z.next_out = obuf;
2123
+ z.next_out_index = 0;
2124
+ z.avail_out = obuf.length;
2125
+ var status = z.inflate(Z_NO_FLUSH);
2126
+ if (status != Z_OK && status != Z_STREAM_END && status != Z_BUF_ERROR) {
2127
+ throw z.msg;
2128
+ }
2129
+ if (z.avail_out != 0) {
2130
+ var newob = new Uint8Array(obuf.length - z.avail_out);
2131
+ arrayCopy(obuf, 0, newob, 0, (obuf.length - z.avail_out));
2132
+ obuf = newob;
2133
+ }
2134
+ oBlockList.push(obuf);
2135
+ totalSize += obuf.length;
2136
+ if (status == Z_STREAM_END || status == Z_BUF_ERROR) {
2137
+ break;
2138
+ }
2139
+ }
2140
+
2141
+ if (afterUncOffset) {
2142
+ afterUncOffset[0] = (start || 0) + z.next_in_index;
2143
+ }
2144
+
2145
+ if (oBlockList.length == 1) {
2146
+ return oBlockList[0].buffer;
2147
+ } else {
2148
+ var out = new Uint8Array(totalSize);
2149
+ var cursor = 0;
2150
+ for (var i = 0; i < oBlockList.length; ++i) {
2151
+ var b = oBlockList[i];
2152
+ arrayCopy(b, 0, out, cursor, b.length);
2153
+ cursor += b.length;
2154
+ }
2155
+ return out.buffer;
2156
+ }
2157
+ }
2158
+
2159
+ export default jszlib_inflate_buffer;