zlib.pretty.js 122 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752
  1. /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';var COMPILED = false;
  2. var goog = goog || {};
  3. goog.global = this;
  4. goog.DEBUG = true;
  5. goog.LOCALE = "en";
  6. goog.provide = function(name) {
  7. if(!COMPILED) {
  8. if(goog.isProvided_(name)) {
  9. throw Error('Namespace "' + name + '" already declared.');
  10. }
  11. delete goog.implicitNamespaces_[name];
  12. var namespace = name;
  13. while(namespace = namespace.substring(0, namespace.lastIndexOf("."))) {
  14. if(goog.getObjectByName(namespace)) {
  15. break
  16. }
  17. goog.implicitNamespaces_[namespace] = true
  18. }
  19. }
  20. goog.exportPath_(name)
  21. };
  22. goog.setTestOnly = function(opt_message) {
  23. if(COMPILED && !goog.DEBUG) {
  24. opt_message = opt_message || "";
  25. throw Error("Importing test-only code into non-debug environment" + opt_message ? ": " + opt_message : ".");
  26. }
  27. };
  28. if(!COMPILED) {
  29. goog.isProvided_ = function(name) {
  30. return!goog.implicitNamespaces_[name] && !!goog.getObjectByName(name)
  31. };
  32. goog.implicitNamespaces_ = {}
  33. }
  34. goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) {
  35. var parts = name.split(".");
  36. var cur = opt_objectToExportTo || goog.global;
  37. if(!(parts[0] in cur) && cur.execScript) {
  38. cur.execScript("var " + parts[0])
  39. }
  40. for(var part;parts.length && (part = parts.shift());) {
  41. if(!parts.length && goog.isDef(opt_object)) {
  42. cur[part] = opt_object
  43. }else {
  44. if(cur[part]) {
  45. cur = cur[part]
  46. }else {
  47. cur = cur[part] = {}
  48. }
  49. }
  50. }
  51. };
  52. goog.getObjectByName = function(name, opt_obj) {
  53. var parts = name.split(".");
  54. var cur = opt_obj || goog.global;
  55. for(var part;part = parts.shift();) {
  56. if(goog.isDefAndNotNull(cur[part])) {
  57. cur = cur[part]
  58. }else {
  59. return null
  60. }
  61. }
  62. return cur
  63. };
  64. goog.globalize = function(obj, opt_global) {
  65. var global = opt_global || goog.global;
  66. for(var x in obj) {
  67. global[x] = obj[x]
  68. }
  69. };
  70. goog.addDependency = function(relPath, provides, requires) {
  71. if(!COMPILED) {
  72. var provide, require;
  73. var path = relPath.replace(/\\/g, "/");
  74. var deps = goog.dependencies_;
  75. for(var i = 0;provide = provides[i];i++) {
  76. deps.nameToPath[provide] = path;
  77. if(!(path in deps.pathToNames)) {
  78. deps.pathToNames[path] = {}
  79. }
  80. deps.pathToNames[path][provide] = true
  81. }
  82. for(var j = 0;require = requires[j];j++) {
  83. if(!(path in deps.requires)) {
  84. deps.requires[path] = {}
  85. }
  86. deps.requires[path][require] = true
  87. }
  88. }
  89. };
  90. goog.ENABLE_DEBUG_LOADER = true;
  91. goog.require = function(name) {
  92. if(!COMPILED) {
  93. if(goog.isProvided_(name)) {
  94. return
  95. }
  96. if(goog.ENABLE_DEBUG_LOADER) {
  97. var path = goog.getPathFromDeps_(name);
  98. if(path) {
  99. goog.included_[path] = true;
  100. goog.writeScripts_();
  101. return
  102. }
  103. }
  104. var errorMessage = "goog.require could not find: " + name;
  105. if(goog.global.console) {
  106. goog.global.console["error"](errorMessage)
  107. }
  108. throw Error(errorMessage);
  109. }
  110. };
  111. goog.basePath = "";
  112. goog.global.CLOSURE_BASE_PATH;
  113. goog.global.CLOSURE_NO_DEPS;
  114. goog.global.CLOSURE_IMPORT_SCRIPT;
  115. goog.nullFunction = function() {
  116. };
  117. goog.identityFunction = function(opt_returnValue, var_args) {
  118. return opt_returnValue
  119. };
  120. goog.abstractMethod = function() {
  121. throw Error("unimplemented abstract method");
  122. };
  123. goog.addSingletonGetter = function(ctor) {
  124. ctor.getInstance = function() {
  125. if(ctor.instance_) {
  126. return ctor.instance_
  127. }
  128. if(goog.DEBUG) {
  129. goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor
  130. }
  131. return ctor.instance_ = new ctor
  132. }
  133. };
  134. goog.instantiatedSingletons_ = [];
  135. if(!COMPILED && goog.ENABLE_DEBUG_LOADER) {
  136. goog.included_ = {};
  137. goog.dependencies_ = {pathToNames:{}, nameToPath:{}, requires:{}, visited:{}, written:{}};
  138. goog.inHtmlDocument_ = function() {
  139. var doc = goog.global.document;
  140. return typeof doc != "undefined" && "write" in doc
  141. };
  142. goog.findBasePath_ = function() {
  143. if(goog.global.CLOSURE_BASE_PATH) {
  144. goog.basePath = goog.global.CLOSURE_BASE_PATH;
  145. return
  146. }else {
  147. if(!goog.inHtmlDocument_()) {
  148. return
  149. }
  150. }
  151. var doc = goog.global.document;
  152. var scripts = doc.getElementsByTagName("script");
  153. for(var i = scripts.length - 1;i >= 0;--i) {
  154. var src = scripts[i].src;
  155. var qmark = src.lastIndexOf("?");
  156. var l = qmark == -1 ? src.length : qmark;
  157. if(src.substr(l - 7, 7) == "base.js") {
  158. goog.basePath = src.substr(0, l - 7);
  159. return
  160. }
  161. }
  162. };
  163. goog.importScript_ = function(src) {
  164. var importScript = goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_;
  165. if(!goog.dependencies_.written[src] && importScript(src)) {
  166. goog.dependencies_.written[src] = true
  167. }
  168. };
  169. goog.writeScriptTag_ = function(src) {
  170. if(goog.inHtmlDocument_()) {
  171. var doc = goog.global.document;
  172. doc.write('<script type="text/javascript" src="' + src + '"></' + "script>");
  173. return true
  174. }else {
  175. return false
  176. }
  177. };
  178. goog.writeScripts_ = function() {
  179. var scripts = [];
  180. var seenScript = {};
  181. var deps = goog.dependencies_;
  182. function visitNode(path) {
  183. if(path in deps.written) {
  184. return
  185. }
  186. if(path in deps.visited) {
  187. if(!(path in seenScript)) {
  188. seenScript[path] = true;
  189. scripts.push(path)
  190. }
  191. return
  192. }
  193. deps.visited[path] = true;
  194. if(path in deps.requires) {
  195. for(var requireName in deps.requires[path]) {
  196. if(!goog.isProvided_(requireName)) {
  197. if(requireName in deps.nameToPath) {
  198. visitNode(deps.nameToPath[requireName])
  199. }else {
  200. throw Error("Undefined nameToPath for " + requireName);
  201. }
  202. }
  203. }
  204. }
  205. if(!(path in seenScript)) {
  206. seenScript[path] = true;
  207. scripts.push(path)
  208. }
  209. }
  210. for(var path in goog.included_) {
  211. if(!deps.written[path]) {
  212. visitNode(path)
  213. }
  214. }
  215. for(var i = 0;i < scripts.length;i++) {
  216. if(scripts[i]) {
  217. goog.importScript_(goog.basePath + scripts[i])
  218. }else {
  219. throw Error("Undefined script input");
  220. }
  221. }
  222. };
  223. goog.getPathFromDeps_ = function(rule) {
  224. if(rule in goog.dependencies_.nameToPath) {
  225. return goog.dependencies_.nameToPath[rule]
  226. }else {
  227. return null
  228. }
  229. };
  230. goog.findBasePath_();
  231. if(!goog.global.CLOSURE_NO_DEPS) {
  232. goog.importScript_(goog.basePath + "deps.js")
  233. }
  234. }
  235. goog.typeOf = function(value) {
  236. var s = typeof value;
  237. if(s == "object") {
  238. if(value) {
  239. if(value instanceof Array) {
  240. return"array"
  241. }else {
  242. if(value instanceof Object) {
  243. return s
  244. }
  245. }
  246. var className = Object.prototype.toString.call((value));
  247. if(className == "[object Window]") {
  248. return"object"
  249. }
  250. if(className == "[object Array]" || typeof value.length == "number" && typeof value.splice != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("splice")) {
  251. return"array"
  252. }
  253. if(className == "[object Function]" || typeof value.call != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("call")) {
  254. return"function"
  255. }
  256. }else {
  257. return"null"
  258. }
  259. }else {
  260. if(s == "function" && typeof value.call == "undefined") {
  261. return"object"
  262. }
  263. }
  264. return s
  265. };
  266. goog.isDef = function(val) {
  267. return val !== undefined
  268. };
  269. goog.isNull = function(val) {
  270. return val === null
  271. };
  272. goog.isDefAndNotNull = function(val) {
  273. return val != null
  274. };
  275. goog.isArray = function(val) {
  276. return goog.typeOf(val) == "array"
  277. };
  278. goog.isArrayLike = function(val) {
  279. var type = goog.typeOf(val);
  280. return type == "array" || type == "object" && typeof val.length == "number"
  281. };
  282. goog.isDateLike = function(val) {
  283. return goog.isObject(val) && typeof val.getFullYear == "function"
  284. };
  285. goog.isString = function(val) {
  286. return typeof val == "string"
  287. };
  288. goog.isBoolean = function(val) {
  289. return typeof val == "boolean"
  290. };
  291. goog.isNumber = function(val) {
  292. return typeof val == "number"
  293. };
  294. goog.isFunction = function(val) {
  295. return goog.typeOf(val) == "function"
  296. };
  297. goog.isObject = function(val) {
  298. var type = typeof val;
  299. return type == "object" && val != null || type == "function"
  300. };
  301. goog.getUid = function(obj) {
  302. return obj[goog.UID_PROPERTY_] || (obj[goog.UID_PROPERTY_] = ++goog.uidCounter_)
  303. };
  304. goog.removeUid = function(obj) {
  305. if("removeAttribute" in obj) {
  306. obj.removeAttribute(goog.UID_PROPERTY_)
  307. }
  308. try {
  309. delete obj[goog.UID_PROPERTY_]
  310. }catch(ex) {
  311. }
  312. };
  313. goog.UID_PROPERTY_ = "closure_uid_" + Math.floor(Math.random() * 2147483648).toString(36);
  314. goog.uidCounter_ = 0;
  315. goog.getHashCode = goog.getUid;
  316. goog.removeHashCode = goog.removeUid;
  317. goog.cloneObject = function(obj) {
  318. var type = goog.typeOf(obj);
  319. if(type == "object" || type == "array") {
  320. if(obj.clone) {
  321. return obj.clone()
  322. }
  323. var clone = type == "array" ? [] : {};
  324. for(var key in obj) {
  325. clone[key] = goog.cloneObject(obj[key])
  326. }
  327. return clone
  328. }
  329. return obj
  330. };
  331. Object.prototype.clone;
  332. goog.bindNative_ = function(fn, selfObj, var_args) {
  333. return(fn.call.apply(fn.bind, arguments))
  334. };
  335. goog.bindJs_ = function(fn, selfObj, var_args) {
  336. if(!fn) {
  337. throw new Error;
  338. }
  339. if(arguments.length > 2) {
  340. var boundArgs = Array.prototype.slice.call(arguments, 2);
  341. return function() {
  342. var newArgs = Array.prototype.slice.call(arguments);
  343. Array.prototype.unshift.apply(newArgs, boundArgs);
  344. return fn.apply(selfObj, newArgs)
  345. }
  346. }else {
  347. return function() {
  348. return fn.apply(selfObj, arguments)
  349. }
  350. }
  351. };
  352. goog.bind = function(fn, selfObj, var_args) {
  353. if(Function.prototype.bind && Function.prototype.bind.toString().indexOf("native code") != -1) {
  354. goog.bind = goog.bindNative_
  355. }else {
  356. goog.bind = goog.bindJs_
  357. }
  358. return goog.bind.apply(null, arguments)
  359. };
  360. goog.partial = function(fn, var_args) {
  361. var args = Array.prototype.slice.call(arguments, 1);
  362. return function() {
  363. var newArgs = Array.prototype.slice.call(arguments);
  364. newArgs.unshift.apply(newArgs, args);
  365. return fn.apply(this, newArgs)
  366. }
  367. };
  368. goog.mixin = function(target, source) {
  369. for(var x in source) {
  370. target[x] = source[x]
  371. }
  372. };
  373. goog.now = Date.now || function() {
  374. return+new Date
  375. };
  376. goog.globalEval = function(script) {
  377. if(goog.global.execScript) {
  378. goog.global.execScript(script, "JavaScript")
  379. }else {
  380. if(goog.global.eval) {
  381. if(goog.evalWorksForGlobals_ == null) {
  382. goog.global.eval("var _et_ = 1;");
  383. if(typeof goog.global["_et_"] != "undefined") {
  384. delete goog.global["_et_"];
  385. goog.evalWorksForGlobals_ = true
  386. }else {
  387. goog.evalWorksForGlobals_ = false
  388. }
  389. }
  390. if(goog.evalWorksForGlobals_) {
  391. goog.global.eval(script)
  392. }else {
  393. var doc = goog.global.document;
  394. var scriptElt = doc.createElement("script");
  395. scriptElt.type = "text/javascript";
  396. scriptElt.defer = false;
  397. scriptElt.appendChild(doc.createTextNode(script));
  398. doc.body.appendChild(scriptElt);
  399. doc.body.removeChild(scriptElt)
  400. }
  401. }else {
  402. throw Error("goog.globalEval not available");
  403. }
  404. }
  405. };
  406. goog.evalWorksForGlobals_ = null;
  407. goog.cssNameMapping_;
  408. goog.cssNameMappingStyle_;
  409. goog.getCssName = function(className, opt_modifier) {
  410. var getMapping = function(cssName) {
  411. return goog.cssNameMapping_[cssName] || cssName
  412. };
  413. var renameByParts = function(cssName) {
  414. var parts = cssName.split("-");
  415. var mapped = [];
  416. for(var i = 0;i < parts.length;i++) {
  417. mapped.push(getMapping(parts[i]))
  418. }
  419. return mapped.join("-")
  420. };
  421. var rename;
  422. if(goog.cssNameMapping_) {
  423. rename = goog.cssNameMappingStyle_ == "BY_WHOLE" ? getMapping : renameByParts
  424. }else {
  425. rename = function(a) {
  426. return a
  427. }
  428. }
  429. if(opt_modifier) {
  430. return className + "-" + rename(opt_modifier)
  431. }else {
  432. return rename(className)
  433. }
  434. };
  435. goog.setCssNameMapping = function(mapping, opt_style) {
  436. goog.cssNameMapping_ = mapping;
  437. goog.cssNameMappingStyle_ = opt_style
  438. };
  439. goog.global.CLOSURE_CSS_NAME_MAPPING;
  440. if(!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) {
  441. goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING
  442. }
  443. goog.getMsg = function(str, opt_values) {
  444. var values = opt_values || {};
  445. for(var key in values) {
  446. var value = ("" + values[key]).replace(/\$/g, "$$$$");
  447. str = str.replace(new RegExp("\\{\\$" + key + "\\}", "gi"), value)
  448. }
  449. return str
  450. };
  451. goog.exportSymbol = function(publicPath, object, opt_objectToExportTo) {
  452. goog.exportPath_(publicPath, object, opt_objectToExportTo)
  453. };
  454. goog.exportProperty = function(object, publicName, symbol) {
  455. object[publicName] = symbol
  456. };
  457. goog.inherits = function(childCtor, parentCtor) {
  458. function tempCtor() {
  459. }
  460. tempCtor.prototype = parentCtor.prototype;
  461. childCtor.superClass_ = parentCtor.prototype;
  462. childCtor.prototype = new tempCtor;
  463. childCtor.prototype.constructor = childCtor
  464. };
  465. goog.base = function(me, opt_methodName, var_args) {
  466. var caller = arguments.callee.caller;
  467. if(caller.superClass_) {
  468. return caller.superClass_.constructor.apply(me, Array.prototype.slice.call(arguments, 1))
  469. }
  470. var args = Array.prototype.slice.call(arguments, 2);
  471. var foundCaller = false;
  472. for(var ctor = me.constructor;ctor;ctor = ctor.superClass_ && ctor.superClass_.constructor) {
  473. if(ctor.prototype[opt_methodName] === caller) {
  474. foundCaller = true
  475. }else {
  476. if(foundCaller) {
  477. return ctor.prototype[opt_methodName].apply(me, args)
  478. }
  479. }
  480. }
  481. if(me[opt_methodName] === caller) {
  482. return me.constructor.prototype[opt_methodName].apply(me, args)
  483. }else {
  484. throw Error("goog.base called from a method of one name " + "to a method of a different name");
  485. }
  486. };
  487. goog.scope = function(fn) {
  488. fn.call(goog.global)
  489. };
  490. goog.provide("USE_TYPEDARRAY");
  491. var USE_TYPEDARRAY = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Uint32Array !== "undefined" && typeof DataView !== "undefined";
  492. goog.provide("Zlib.BitStream");
  493. goog.require("USE_TYPEDARRAY");
  494. goog.scope(function() {
  495. Zlib.BitStream = function(buffer, bufferPosition) {
  496. this.index = typeof bufferPosition === "number" ? bufferPosition : 0;
  497. this.bitindex = 0;
  498. this.buffer = buffer instanceof (USE_TYPEDARRAY ? Uint8Array : Array) ? buffer : new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.BitStream.DefaultBlockSize);
  499. if(this.buffer.length * 2 <= this.index) {
  500. throw new Error("invalid index");
  501. }else {
  502. if(this.buffer.length <= this.index) {
  503. this.expandBuffer()
  504. }
  505. }
  506. };
  507. Zlib.BitStream.DefaultBlockSize = 32768;
  508. Zlib.BitStream.prototype.expandBuffer = function() {
  509. var oldbuf = this.buffer;
  510. var i;
  511. var il = oldbuf.length;
  512. var buffer = new (USE_TYPEDARRAY ? Uint8Array : Array)(il << 1);
  513. if(USE_TYPEDARRAY) {
  514. buffer.set(oldbuf)
  515. }else {
  516. for(i = 0;i < il;++i) {
  517. buffer[i] = oldbuf[i]
  518. }
  519. }
  520. return this.buffer = buffer
  521. };
  522. Zlib.BitStream.prototype.writeBits = function(number, n, reverse) {
  523. var buffer = this.buffer;
  524. var index = this.index;
  525. var bitindex = this.bitindex;
  526. var current = buffer[index];
  527. var i;
  528. function rev32_(n) {
  529. return Zlib.BitStream.ReverseTable[n & 255] << 24 | Zlib.BitStream.ReverseTable[n >>> 8 & 255] << 16 | Zlib.BitStream.ReverseTable[n >>> 16 & 255] << 8 | Zlib.BitStream.ReverseTable[n >>> 24 & 255]
  530. }
  531. if(reverse && n > 1) {
  532. number = n > 8 ? rev32_(number) >> 32 - n : Zlib.BitStream.ReverseTable[number] >> 8 - n
  533. }
  534. if(n + bitindex < 8) {
  535. current = current << n | number;
  536. bitindex += n
  537. }else {
  538. for(i = 0;i < n;++i) {
  539. current = current << 1 | number >> n - i - 1 & 1;
  540. if(++bitindex === 8) {
  541. bitindex = 0;
  542. buffer[index++] = Zlib.BitStream.ReverseTable[current];
  543. current = 0;
  544. if(index === buffer.length) {
  545. buffer = this.expandBuffer()
  546. }
  547. }
  548. }
  549. }
  550. buffer[index] = current;
  551. this.buffer = buffer;
  552. this.bitindex = bitindex;
  553. this.index = index
  554. };
  555. Zlib.BitStream.prototype.finish = function() {
  556. var buffer = this.buffer;
  557. var index = this.index;
  558. var output;
  559. if(this.bitindex > 0) {
  560. buffer[index] <<= 8 - this.bitindex;
  561. buffer[index] = Zlib.BitStream.ReverseTable[buffer[index]];
  562. index++
  563. }
  564. if(USE_TYPEDARRAY) {
  565. output = buffer.subarray(0, index)
  566. }else {
  567. buffer.length = index;
  568. output = buffer
  569. }
  570. return output
  571. };
  572. Zlib.BitStream.ReverseTable = function(table) {
  573. return table
  574. }(function() {
  575. var table = new (USE_TYPEDARRAY ? Uint8Array : Array)(256);
  576. var i;
  577. for(i = 0;i < 256;++i) {
  578. table[i] = function(n) {
  579. var r = n;
  580. var s = 7;
  581. for(n >>>= 1;n;n >>>= 1) {
  582. r <<= 1;
  583. r |= n & 1;
  584. --s
  585. }
  586. return(r << s & 255) >>> 0
  587. }(i)
  588. }
  589. return table
  590. }())
  591. });
  592. goog.provide("Zlib.CRC32");
  593. goog.require("USE_TYPEDARRAY");
  594. var ZLIB_CRC32_COMPACT = false;
  595. goog.scope(function() {
  596. Zlib.CRC32.calc = function(data, pos, length) {
  597. return Zlib.CRC32.update(data, 0, pos, length)
  598. };
  599. Zlib.CRC32.update = function(data, crc, pos, length) {
  600. var table = Zlib.CRC32.Table;
  601. var i = typeof pos === "number" ? pos : pos = 0;
  602. var il = typeof length === "number" ? length : data.length;
  603. crc ^= 4294967295;
  604. for(i = il & 7;i--;++pos) {
  605. crc = crc >>> 8 ^ table[(crc ^ data[pos]) & 255]
  606. }
  607. for(i = il >> 3;i--;pos += 8) {
  608. crc = crc >>> 8 ^ table[(crc ^ data[pos]) & 255];
  609. crc = crc >>> 8 ^ table[(crc ^ data[pos + 1]) & 255];
  610. crc = crc >>> 8 ^ table[(crc ^ data[pos + 2]) & 255];
  611. crc = crc >>> 8 ^ table[(crc ^ data[pos + 3]) & 255];
  612. crc = crc >>> 8 ^ table[(crc ^ data[pos + 4]) & 255];
  613. crc = crc >>> 8 ^ table[(crc ^ data[pos + 5]) & 255];
  614. crc = crc >>> 8 ^ table[(crc ^ data[pos + 6]) & 255];
  615. crc = crc >>> 8 ^ table[(crc ^ data[pos + 7]) & 255]
  616. }
  617. return(crc ^ 4294967295) >>> 0
  618. };
  619. Zlib.CRC32.single = function(num, crc) {
  620. return(Zlib.CRC32.Table[(num ^ crc) & 255] ^ num >>> 8) >>> 0
  621. };
  622. Zlib.CRC32.Table_ = [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,
  623. 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,
  624. 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,
  625. 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,
  626. 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,
  627. 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];
  628. Zlib.CRC32.Table = ZLIB_CRC32_COMPACT ? function() {
  629. var table = new (USE_TYPEDARRAY ? Uint32Array : Array)(256);
  630. var c;
  631. var i;
  632. var j;
  633. for(i = 0;i < 256;++i) {
  634. c = i;
  635. for(j = 0;j < 8;++j) {
  636. c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1
  637. }
  638. table[i] = c >>> 0
  639. }
  640. return table
  641. }() : USE_TYPEDARRAY ? new Uint32Array(Zlib.CRC32.Table_) : Zlib.CRC32.Table_
  642. });
  643. goog.provide("FixPhantomJSFunctionApplyBug_StringFromCharCode");
  644. if(goog.global["Uint8Array"] !== void 0) {
  645. try {
  646. eval("String.fromCharCode.apply(null, new Uint8Array([0]));")
  647. }catch(e) {
  648. String.fromCharCode.apply = function(fromCharCodeApply) {
  649. return function(thisobj, args) {
  650. return fromCharCodeApply.call(String.fromCharCode, thisobj, Array.prototype.slice.call(args))
  651. }
  652. }(String.fromCharCode.apply)
  653. }
  654. }
  655. ;goog.provide("Zlib.GunzipMember");
  656. goog.scope(function() {
  657. Zlib.GunzipMember = function() {
  658. this.id1;
  659. this.id2;
  660. this.cm;
  661. this.flg;
  662. this.mtime;
  663. this.xfl;
  664. this.os;
  665. this.crc16;
  666. this.xlen;
  667. this.crc32;
  668. this.isize;
  669. this.name;
  670. this.comment;
  671. this.data
  672. };
  673. Zlib.GunzipMember.prototype.getName = function() {
  674. return this.name
  675. };
  676. Zlib.GunzipMember.prototype.getData = function() {
  677. return this.data
  678. };
  679. Zlib.GunzipMember.prototype.getMtime = function() {
  680. return this.mtime
  681. }
  682. });
  683. goog.provide("Zlib.Heap");
  684. goog.require("USE_TYPEDARRAY");
  685. goog.scope(function() {
  686. Zlib.Heap = function(length) {
  687. this.buffer = new (USE_TYPEDARRAY ? Uint16Array : Array)(length * 2);
  688. this.length = 0
  689. };
  690. Zlib.Heap.prototype.getParent = function(index) {
  691. return((index - 2) / 4 | 0) * 2
  692. };
  693. Zlib.Heap.prototype.getChild = function(index) {
  694. return 2 * index + 2
  695. };
  696. Zlib.Heap.prototype.push = function(index, value) {
  697. var current, parent, heap = this.buffer, swap;
  698. current = this.length;
  699. heap[this.length++] = value;
  700. heap[this.length++] = index;
  701. while(current > 0) {
  702. parent = this.getParent(current);
  703. if(heap[current] > heap[parent]) {
  704. swap = heap[current];
  705. heap[current] = heap[parent];
  706. heap[parent] = swap;
  707. swap = heap[current + 1];
  708. heap[current + 1] = heap[parent + 1];
  709. heap[parent + 1] = swap;
  710. current = parent
  711. }else {
  712. break
  713. }
  714. }
  715. return this.length
  716. };
  717. Zlib.Heap.prototype.pop = function() {
  718. var index, value, heap = this.buffer, swap, current, parent;
  719. value = heap[0];
  720. index = heap[1];
  721. this.length -= 2;
  722. heap[0] = heap[this.length];
  723. heap[1] = heap[this.length + 1];
  724. parent = 0;
  725. while(true) {
  726. current = this.getChild(parent);
  727. if(current >= this.length) {
  728. break
  729. }
  730. if(current + 2 < this.length && heap[current + 2] > heap[current]) {
  731. current += 2
  732. }
  733. if(heap[current] > heap[parent]) {
  734. swap = heap[parent];
  735. heap[parent] = heap[current];
  736. heap[current] = swap;
  737. swap = heap[parent + 1];
  738. heap[parent + 1] = heap[current + 1];
  739. heap[current + 1] = swap
  740. }else {
  741. break
  742. }
  743. parent = current
  744. }
  745. return{index:index, value:value, length:this.length}
  746. }
  747. });
  748. goog.provide("Zlib.Huffman");
  749. goog.require("USE_TYPEDARRAY");
  750. goog.scope(function() {
  751. Zlib.Huffman.buildHuffmanTable = function(lengths) {
  752. var listSize = lengths.length;
  753. var maxCodeLength = 0;
  754. var minCodeLength = Number.POSITIVE_INFINITY;
  755. var size;
  756. var table;
  757. var bitLength;
  758. var code;
  759. var skip;
  760. var reversed;
  761. var rtemp;
  762. var i;
  763. var il;
  764. var j;
  765. var value;
  766. for(i = 0, il = listSize;i < il;++i) {
  767. if(lengths[i] > maxCodeLength) {
  768. maxCodeLength = lengths[i]
  769. }
  770. if(lengths[i] < minCodeLength) {
  771. minCodeLength = lengths[i]
  772. }
  773. }
  774. size = 1 << maxCodeLength;
  775. table = new (USE_TYPEDARRAY ? Uint32Array : Array)(size);
  776. for(bitLength = 1, code = 0, skip = 2;bitLength <= maxCodeLength;) {
  777. for(i = 0;i < listSize;++i) {
  778. if(lengths[i] === bitLength) {
  779. for(reversed = 0, rtemp = code, j = 0;j < bitLength;++j) {
  780. reversed = reversed << 1 | rtemp & 1;
  781. rtemp >>= 1
  782. }
  783. value = bitLength << 16 | i;
  784. for(j = reversed;j < size;j += skip) {
  785. table[j] = value
  786. }
  787. ++code
  788. }
  789. }
  790. ++bitLength;
  791. code <<= 1;
  792. skip <<= 1
  793. }
  794. return[table, maxCodeLength, minCodeLength]
  795. }
  796. });
  797. goog.provide("Zlib.RawDeflate");
  798. goog.require("USE_TYPEDARRAY");
  799. goog.require("Zlib.BitStream");
  800. goog.require("Zlib.Heap");
  801. goog.scope(function() {
  802. Zlib.RawDeflate = function(input, opt_params) {
  803. this.compressionType = Zlib.RawDeflate.CompressionType.DYNAMIC;
  804. this.lazy = 0;
  805. this.freqsLitLen;
  806. this.freqsDist;
  807. this.input = USE_TYPEDARRAY && input instanceof Array ? new Uint8Array(input) : input;
  808. this.output;
  809. this.op = 0;
  810. if(opt_params) {
  811. if(opt_params["lazy"]) {
  812. this.lazy = opt_params["lazy"]
  813. }
  814. if(typeof opt_params["compressionType"] === "number") {
  815. this.compressionType = opt_params["compressionType"]
  816. }
  817. if(opt_params["outputBuffer"]) {
  818. this.output = USE_TYPEDARRAY && opt_params["outputBuffer"] instanceof Array ? new Uint8Array(opt_params["outputBuffer"]) : opt_params["outputBuffer"]
  819. }
  820. if(typeof opt_params["outputIndex"] === "number") {
  821. this.op = opt_params["outputIndex"]
  822. }
  823. }
  824. if(!this.output) {
  825. this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(32768)
  826. }
  827. };
  828. Zlib.RawDeflate.CompressionType = {NONE:0, FIXED:1, DYNAMIC:2, RESERVED:3};
  829. Zlib.RawDeflate.Lz77MinLength = 3;
  830. Zlib.RawDeflate.Lz77MaxLength = 258;
  831. Zlib.RawDeflate.WindowSize = 32768;
  832. Zlib.RawDeflate.MaxCodeLength = 16;
  833. Zlib.RawDeflate.HUFMAX = 286;
  834. Zlib.RawDeflate.FixedHuffmanTable = function() {
  835. var table = [], i;
  836. for(i = 0;i < 288;i++) {
  837. switch(true) {
  838. case i <= 143:
  839. table.push([i + 48, 8]);
  840. break;
  841. case i <= 255:
  842. table.push([i - 144 + 400, 9]);
  843. break;
  844. case i <= 279:
  845. table.push([i - 256 + 0, 7]);
  846. break;
  847. case i <= 287:
  848. table.push([i - 280 + 192, 8]);
  849. break;
  850. default:
  851. throw"invalid literal: " + i;
  852. }
  853. }
  854. return table
  855. }();
  856. Zlib.RawDeflate.prototype.compress = function() {
  857. var blockArray;
  858. var position;
  859. var length;
  860. var input = this.input;
  861. switch(this.compressionType) {
  862. case Zlib.RawDeflate.CompressionType.NONE:
  863. for(position = 0, length = input.length;position < length;) {
  864. blockArray = USE_TYPEDARRAY ? input.subarray(position, position + 65535) : input.slice(position, position + 65535);
  865. position += blockArray.length;
  866. this.makeNocompressBlock(blockArray, position === length)
  867. }
  868. break;
  869. case Zlib.RawDeflate.CompressionType.FIXED:
  870. this.output = this.makeFixedHuffmanBlock(input, true);
  871. this.op = this.output.length;
  872. break;
  873. case Zlib.RawDeflate.CompressionType.DYNAMIC:
  874. this.output = this.makeDynamicHuffmanBlock(input, true);
  875. this.op = this.output.length;
  876. break;
  877. default:
  878. throw"invalid compression type";
  879. }
  880. return this.output
  881. };
  882. Zlib.RawDeflate.prototype.makeNocompressBlock = function(blockArray, isFinalBlock) {
  883. var bfinal;
  884. var btype;
  885. var len;
  886. var nlen;
  887. var i;
  888. var il;
  889. var output = this.output;
  890. var op = this.op;
  891. if(USE_TYPEDARRAY) {
  892. output = new Uint8Array(this.output.buffer);
  893. while(output.length <= op + blockArray.length + 5) {
  894. output = new Uint8Array(output.length << 1)
  895. }
  896. output.set(this.output)
  897. }
  898. bfinal = isFinalBlock ? 1 : 0;
  899. btype = Zlib.RawDeflate.CompressionType.NONE;
  900. output[op++] = bfinal | btype << 1;
  901. len = blockArray.length;
  902. nlen = ~len + 65536 & 65535;
  903. output[op++] = len & 255;
  904. output[op++] = len >>> 8 & 255;
  905. output[op++] = nlen & 255;
  906. output[op++] = nlen >>> 8 & 255;
  907. if(USE_TYPEDARRAY) {
  908. output.set(blockArray, op);
  909. op += blockArray.length;
  910. output = output.subarray(0, op)
  911. }else {
  912. for(i = 0, il = blockArray.length;i < il;++i) {
  913. output[op++] = blockArray[i]
  914. }
  915. output.length = op
  916. }
  917. this.op = op;
  918. this.output = output;
  919. return output
  920. };
  921. Zlib.RawDeflate.prototype.makeFixedHuffmanBlock = function(blockArray, isFinalBlock) {
  922. var stream = new Zlib.BitStream(USE_TYPEDARRAY ? new Uint8Array(this.output.buffer) : this.output, this.op);
  923. var bfinal;
  924. var btype;
  925. var data;
  926. bfinal = isFinalBlock ? 1 : 0;
  927. btype = Zlib.RawDeflate.CompressionType.FIXED;
  928. stream.writeBits(bfinal, 1, true);
  929. stream.writeBits(btype, 2, true);
  930. data = this.lz77(blockArray);
  931. this.fixedHuffman(data, stream);
  932. return stream.finish()
  933. };
  934. Zlib.RawDeflate.prototype.makeDynamicHuffmanBlock = function(blockArray, isFinalBlock) {
  935. var stream = new Zlib.BitStream(USE_TYPEDARRAY ? new Uint8Array(this.output.buffer) : this.output, this.op);
  936. var bfinal;
  937. var btype;
  938. var data;
  939. var hlit;
  940. var hdist;
  941. var hclen;
  942. var hclenOrder = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  943. var litLenLengths;
  944. var litLenCodes;
  945. var distLengths;
  946. var distCodes;
  947. var treeSymbols;
  948. var treeLengths;
  949. var transLengths = new Array(19);
  950. var treeCodes;
  951. var code;
  952. var bitlen;
  953. var i;
  954. var il;
  955. bfinal = isFinalBlock ? 1 : 0;
  956. btype = Zlib.RawDeflate.CompressionType.DYNAMIC;
  957. stream.writeBits(bfinal, 1, true);
  958. stream.writeBits(btype, 2, true);
  959. data = this.lz77(blockArray);
  960. litLenLengths = this.getLengths_(this.freqsLitLen, 15);
  961. litLenCodes = this.getCodesFromLengths_(litLenLengths);
  962. distLengths = this.getLengths_(this.freqsDist, 7);
  963. distCodes = this.getCodesFromLengths_(distLengths);
  964. for(hlit = 286;hlit > 257 && litLenLengths[hlit - 1] === 0;hlit--) {
  965. }
  966. for(hdist = 30;hdist > 1 && distLengths[hdist - 1] === 0;hdist--) {
  967. }
  968. treeSymbols = this.getTreeSymbols_(hlit, litLenLengths, hdist, distLengths);
  969. treeLengths = this.getLengths_(treeSymbols.freqs, 7);
  970. for(i = 0;i < 19;i++) {
  971. transLengths[i] = treeLengths[hclenOrder[i]]
  972. }
  973. for(hclen = 19;hclen > 4 && transLengths[hclen - 1] === 0;hclen--) {
  974. }
  975. treeCodes = this.getCodesFromLengths_(treeLengths);
  976. stream.writeBits(hlit - 257, 5, true);
  977. stream.writeBits(hdist - 1, 5, true);
  978. stream.writeBits(hclen - 4, 4, true);
  979. for(i = 0;i < hclen;i++) {
  980. stream.writeBits(transLengths[i], 3, true)
  981. }
  982. for(i = 0, il = treeSymbols.codes.length;i < il;i++) {
  983. code = treeSymbols.codes[i];
  984. stream.writeBits(treeCodes[code], treeLengths[code], true);
  985. if(code >= 16) {
  986. i++;
  987. switch(code) {
  988. case 16:
  989. bitlen = 2;
  990. break;
  991. case 17:
  992. bitlen = 3;
  993. break;
  994. case 18:
  995. bitlen = 7;
  996. break;
  997. default:
  998. throw"invalid code: " + code;
  999. }
  1000. stream.writeBits(treeSymbols.codes[i], bitlen, true)
  1001. }
  1002. }
  1003. this.dynamicHuffman(data, [litLenCodes, litLenLengths], [distCodes, distLengths], stream);
  1004. return stream.finish()
  1005. };
  1006. Zlib.RawDeflate.prototype.dynamicHuffman = function(dataArray, litLen, dist, stream) {
  1007. var index;
  1008. var length;
  1009. var literal;
  1010. var code;
  1011. var litLenCodes;
  1012. var litLenLengths;
  1013. var distCodes;
  1014. var distLengths;
  1015. litLenCodes = litLen[0];
  1016. litLenLengths = litLen[1];
  1017. distCodes = dist[0];
  1018. distLengths = dist[1];
  1019. for(index = 0, length = dataArray.length;index < length;++index) {
  1020. literal = dataArray[index];
  1021. stream.writeBits(litLenCodes[literal], litLenLengths[literal], true);
  1022. if(literal > 256) {
  1023. stream.writeBits(dataArray[++index], dataArray[++index], true);
  1024. code = dataArray[++index];
  1025. stream.writeBits(distCodes[code], distLengths[code], true);
  1026. stream.writeBits(dataArray[++index], dataArray[++index], true)
  1027. }else {
  1028. if(literal === 256) {
  1029. break
  1030. }
  1031. }
  1032. }
  1033. return stream
  1034. };
  1035. Zlib.RawDeflate.prototype.fixedHuffman = function(dataArray, stream) {
  1036. var index;
  1037. var length;
  1038. var literal;
  1039. for(index = 0, length = dataArray.length;index < length;index++) {
  1040. literal = dataArray[index];
  1041. Zlib.BitStream.prototype.writeBits.apply(stream, Zlib.RawDeflate.FixedHuffmanTable[literal]);
  1042. if(literal > 256) {
  1043. stream.writeBits(dataArray[++index], dataArray[++index], true);
  1044. stream.writeBits(dataArray[++index], 5);
  1045. stream.writeBits(dataArray[++index], dataArray[++index], true)
  1046. }else {
  1047. if(literal === 256) {
  1048. break
  1049. }
  1050. }
  1051. }
  1052. return stream
  1053. };
  1054. Zlib.RawDeflate.Lz77Match = function(length, backwardDistance) {
  1055. this.length = length;
  1056. this.backwardDistance = backwardDistance
  1057. };
  1058. Zlib.RawDeflate.Lz77Match.LengthCodeTable = function(table) {
  1059. return USE_TYPEDARRAY ? new Uint32Array(table) : table
  1060. }(function() {
  1061. var table = [];
  1062. var i;
  1063. var c;
  1064. for(i = 3;i <= 258;i++) {
  1065. c = code(i);
  1066. table[i] = c[2] << 24 | c[1] << 16 | c[0]
  1067. }
  1068. function code(length) {
  1069. switch(true) {
  1070. case length === 3:
  1071. return[257, length - 3, 0];
  1072. break;
  1073. case length === 4:
  1074. return[258, length - 4, 0];
  1075. break;
  1076. case length === 5:
  1077. return[259, length - 5, 0];
  1078. break;
  1079. case length === 6:
  1080. return[260, length - 6, 0];
  1081. break;
  1082. case length === 7:
  1083. return[261, length - 7, 0];
  1084. break;
  1085. case length === 8:
  1086. return[262, length - 8, 0];
  1087. break;
  1088. case length === 9:
  1089. return[263, length - 9, 0];
  1090. break;
  1091. case length === 10:
  1092. return[264, length - 10, 0];
  1093. break;
  1094. case length <= 12:
  1095. return[265, length - 11, 1];
  1096. break;
  1097. case length <= 14:
  1098. return[266, length - 13, 1];
  1099. break;
  1100. case length <= 16:
  1101. return[267, length - 15, 1];
  1102. break;
  1103. case length <= 18:
  1104. return[268, length - 17, 1];
  1105. break;
  1106. case length <= 22:
  1107. return[269, length - 19, 2];
  1108. break;
  1109. case length <= 26:
  1110. return[270, length - 23, 2];
  1111. break;
  1112. case length <= 30:
  1113. return[271, length - 27, 2];
  1114. break;
  1115. case length <= 34:
  1116. return[272, length - 31, 2];
  1117. break;
  1118. case length <= 42:
  1119. return[273, length - 35, 3];
  1120. break;
  1121. case length <= 50:
  1122. return[274, length - 43, 3];
  1123. break;
  1124. case length <= 58:
  1125. return[275, length - 51, 3];
  1126. break;
  1127. case length <= 66:
  1128. return[276, length - 59, 3];
  1129. break;
  1130. case length <= 82:
  1131. return[277, length - 67, 4];
  1132. break;
  1133. case length <= 98:
  1134. return[278, length - 83, 4];
  1135. break;
  1136. case length <= 114:
  1137. return[279, length - 99, 4];
  1138. break;
  1139. case length <= 130:
  1140. return[280, length - 115, 4];
  1141. break;
  1142. case length <= 162:
  1143. return[281, length - 131, 5];
  1144. break;
  1145. case length <= 194:
  1146. return[282, length - 163, 5];
  1147. break;
  1148. case length <= 226:
  1149. return[283, length - 195, 5];
  1150. break;
  1151. case length <= 257:
  1152. return[284, length - 227, 5];
  1153. break;
  1154. case length === 258:
  1155. return[285, length - 258, 0];
  1156. break;
  1157. default:
  1158. throw"invalid length: " + length;
  1159. }
  1160. }
  1161. return table
  1162. }());
  1163. Zlib.RawDeflate.Lz77Match.prototype.getDistanceCode_ = function(dist) {
  1164. var r;
  1165. switch(true) {
  1166. case dist === 1:
  1167. r = [0, dist - 1, 0];
  1168. break;
  1169. case dist === 2:
  1170. r = [1, dist - 2, 0];
  1171. break;
  1172. case dist === 3:
  1173. r = [2, dist - 3, 0];
  1174. break;
  1175. case dist === 4:
  1176. r = [3, dist - 4, 0];
  1177. break;
  1178. case dist <= 6:
  1179. r = [4, dist - 5, 1];
  1180. break;
  1181. case dist <= 8:
  1182. r = [5, dist - 7, 1];
  1183. break;
  1184. case dist <= 12:
  1185. r = [6, dist - 9, 2];
  1186. break;
  1187. case dist <= 16:
  1188. r = [7, dist - 13, 2];
  1189. break;
  1190. case dist <= 24:
  1191. r = [8, dist - 17, 3];
  1192. break;
  1193. case dist <= 32:
  1194. r = [9, dist - 25, 3];
  1195. break;
  1196. case dist <= 48:
  1197. r = [10, dist - 33, 4];
  1198. break;
  1199. case dist <= 64:
  1200. r = [11, dist - 49, 4];
  1201. break;
  1202. case dist <= 96:
  1203. r = [12, dist - 65, 5];
  1204. break;
  1205. case dist <= 128:
  1206. r = [13, dist - 97, 5];
  1207. break;
  1208. case dist <= 192:
  1209. r = [14, dist - 129, 6];
  1210. break;
  1211. case dist <= 256:
  1212. r = [15, dist - 193, 6];
  1213. break;
  1214. case dist <= 384:
  1215. r = [16, dist - 257, 7];
  1216. break;
  1217. case dist <= 512:
  1218. r = [17, dist - 385, 7];
  1219. break;
  1220. case dist <= 768:
  1221. r = [18, dist - 513, 8];
  1222. break;
  1223. case dist <= 1024:
  1224. r = [19, dist - 769, 8];
  1225. break;
  1226. case dist <= 1536:
  1227. r = [20, dist - 1025, 9];
  1228. break;
  1229. case dist <= 2048:
  1230. r = [21, dist - 1537, 9];
  1231. break;
  1232. case dist <= 3072:
  1233. r = [22, dist - 2049, 10];
  1234. break;
  1235. case dist <= 4096:
  1236. r = [23, dist - 3073, 10];
  1237. break;
  1238. case dist <= 6144:
  1239. r = [24, dist - 4097, 11];
  1240. break;
  1241. case dist <= 8192:
  1242. r = [25, dist - 6145, 11];
  1243. break;
  1244. case dist <= 12288:
  1245. r = [26, dist - 8193, 12];
  1246. break;
  1247. case dist <= 16384:
  1248. r = [27, dist - 12289, 12];
  1249. break;
  1250. case dist <= 24576:
  1251. r = [28, dist - 16385, 13];
  1252. break;
  1253. case dist <= 32768:
  1254. r = [29, dist - 24577, 13];
  1255. break;
  1256. default:
  1257. throw"invalid distance";
  1258. }
  1259. return r
  1260. };
  1261. Zlib.RawDeflate.Lz77Match.prototype.toLz77Array = function() {
  1262. var length = this.length;
  1263. var dist = this.backwardDistance;
  1264. var codeArray = [];
  1265. var pos = 0;
  1266. var code;
  1267. code = Zlib.RawDeflate.Lz77Match.LengthCodeTable[length];
  1268. codeArray[pos++] = code & 65535;
  1269. codeArray[pos++] = code >> 16 & 255;
  1270. codeArray[pos++] = code >> 24;
  1271. code = this.getDistanceCode_(dist);
  1272. codeArray[pos++] = code[0];
  1273. codeArray[pos++] = code[1];
  1274. codeArray[pos++] = code[2];
  1275. return codeArray
  1276. };
  1277. Zlib.RawDeflate.prototype.lz77 = function(dataArray) {
  1278. var position;
  1279. var length;
  1280. var i;
  1281. var il;
  1282. var matchKey;
  1283. var table = {};
  1284. var windowSize = Zlib.RawDeflate.WindowSize;
  1285. var matchList;
  1286. var longestMatch;
  1287. var prevMatch;
  1288. var lz77buf = USE_TYPEDARRAY ? new Uint16Array(dataArray.length * 2) : [];
  1289. var pos = 0;
  1290. var skipLength = 0;
  1291. var freqsLitLen = new (USE_TYPEDARRAY ? Uint32Array : Array)(286);
  1292. var freqsDist = new (USE_TYPEDARRAY ? Uint32Array : Array)(30);
  1293. var lazy = this.lazy;
  1294. var tmp;
  1295. if(!USE_TYPEDARRAY) {
  1296. for(i = 0;i <= 285;) {
  1297. freqsLitLen[i++] = 0
  1298. }
  1299. for(i = 0;i <= 29;) {
  1300. freqsDist[i++] = 0
  1301. }
  1302. }
  1303. freqsLitLen[256] = 1;
  1304. function writeMatch(match, offset) {
  1305. var lz77Array = match.toLz77Array();
  1306. var i;
  1307. var il;
  1308. for(i = 0, il = lz77Array.length;i < il;++i) {
  1309. lz77buf[pos++] = lz77Array[i]
  1310. }
  1311. freqsLitLen[lz77Array[0]]++;
  1312. freqsDist[lz77Array[3]]++;
  1313. skipLength = match.length + offset - 1;
  1314. prevMatch = null
  1315. }
  1316. for(position = 0, length = dataArray.length;position < length;++position) {
  1317. for(matchKey = 0, i = 0, il = Zlib.RawDeflate.Lz77MinLength;i < il;++i) {
  1318. if(position + i === length) {
  1319. break
  1320. }
  1321. matchKey = matchKey << 8 | dataArray[position + i]
  1322. }
  1323. if(table[matchKey] === void 0) {
  1324. table[matchKey] = []
  1325. }
  1326. matchList = table[matchKey];
  1327. if(skipLength-- > 0) {
  1328. matchList.push(position);
  1329. continue
  1330. }
  1331. while(matchList.length > 0 && position - matchList[0] > windowSize) {
  1332. matchList.shift()
  1333. }
  1334. if(position + Zlib.RawDeflate.Lz77MinLength >= length) {
  1335. if(prevMatch) {
  1336. writeMatch(prevMatch, -1)
  1337. }
  1338. for(i = 0, il = length - position;i < il;++i) {
  1339. tmp = dataArray[position + i];
  1340. lz77buf[pos++] = tmp;
  1341. ++freqsLitLen[tmp]
  1342. }
  1343. break
  1344. }
  1345. if(matchList.length > 0) {
  1346. longestMatch = this.searchLongestMatch_(dataArray, position, matchList);
  1347. if(prevMatch) {
  1348. if(prevMatch.length < longestMatch.length) {
  1349. tmp = dataArray[position - 1];
  1350. lz77buf[pos++] = tmp;
  1351. ++freqsLitLen[tmp];
  1352. writeMatch(longestMatch, 0)
  1353. }else {
  1354. writeMatch(prevMatch, -1)
  1355. }
  1356. }else {
  1357. if(longestMatch.length < lazy) {
  1358. prevMatch = longestMatch
  1359. }else {
  1360. writeMatch(longestMatch, 0)
  1361. }
  1362. }
  1363. }else {
  1364. if(prevMatch) {
  1365. writeMatch(prevMatch, -1)
  1366. }else {
  1367. tmp = dataArray[position];
  1368. lz77buf[pos++] = tmp;
  1369. ++freqsLitLen[tmp]
  1370. }
  1371. }
  1372. matchList.push(position)
  1373. }
  1374. lz77buf[pos++] = 256;
  1375. freqsLitLen[256]++;
  1376. this.freqsLitLen = freqsLitLen;
  1377. this.freqsDist = freqsDist;
  1378. return(USE_TYPEDARRAY ? lz77buf.subarray(0, pos) : lz77buf)
  1379. };
  1380. Zlib.RawDeflate.prototype.searchLongestMatch_ = function(data, position, matchList) {
  1381. var match, currentMatch, matchMax = 0, matchLength, i, j, l, dl = data.length;
  1382. permatch:for(i = 0, l = matchList.length;i < l;i++) {
  1383. match = matchList[l - i - 1];
  1384. matchLength = Zlib.RawDeflate.Lz77MinLength;
  1385. if(matchMax > Zlib.RawDeflate.Lz77MinLength) {
  1386. for(j = matchMax;j > Zlib.RawDeflate.Lz77MinLength;j--) {
  1387. if(data[match + j - 1] !== data[position + j - 1]) {
  1388. continue permatch
  1389. }
  1390. }
  1391. matchLength = matchMax
  1392. }
  1393. while(matchLength < Zlib.RawDeflate.Lz77MaxLength && position + matchLength < dl && data[match + matchLength] === data[position + matchLength]) {
  1394. ++matchLength
  1395. }
  1396. if(matchLength > matchMax) {
  1397. currentMatch = match;
  1398. matchMax = matchLength
  1399. }
  1400. if(matchLength === Zlib.RawDeflate.Lz77MaxLength) {
  1401. break
  1402. }
  1403. }
  1404. return new Zlib.RawDeflate.Lz77Match(matchMax, position - currentMatch)
  1405. };
  1406. Zlib.RawDeflate.prototype.getTreeSymbols_ = function(hlit, litlenLengths, hdist, distLengths) {
  1407. var src = new (USE_TYPEDARRAY ? Uint32Array : Array)(hlit + hdist), i, j, runLength, l, result = new (USE_TYPEDARRAY ? Uint32Array : Array)(286 + 30), nResult, rpt, freqs = new (USE_TYPEDARRAY ? Uint8Array : Array)(19);
  1408. j = 0;
  1409. for(i = 0;i < hlit;i++) {
  1410. src[j++] = litlenLengths[i]
  1411. }
  1412. for(i = 0;i < hdist;i++) {
  1413. src[j++] = distLengths[i]
  1414. }
  1415. if(!USE_TYPEDARRAY) {
  1416. for(i = 0, l = freqs.length;i < l;++i) {
  1417. freqs[i] = 0
  1418. }
  1419. }
  1420. nResult = 0;
  1421. for(i = 0, l = src.length;i < l;i += j) {
  1422. for(j = 1;i + j < l && src[i + j] === src[i];++j) {
  1423. }
  1424. runLength = j;
  1425. if(src[i] === 0) {
  1426. if(runLength < 3) {
  1427. while(runLength-- > 0) {
  1428. result[nResult++] = 0;
  1429. freqs[0]++
  1430. }
  1431. }else {
  1432. while(runLength > 0) {
  1433. rpt = runLength < 138 ? runLength : 138;
  1434. if(rpt > runLength - 3 && rpt < runLength) {
  1435. rpt = runLength - 3
  1436. }
  1437. if(rpt <= 10) {
  1438. result[nResult++] = 17;
  1439. result[nResult++] = rpt - 3;
  1440. freqs[17]++
  1441. }else {
  1442. result[nResult++] = 18;
  1443. result[nResult++] = rpt - 11;
  1444. freqs[18]++
  1445. }
  1446. runLength -= rpt
  1447. }
  1448. }
  1449. }else {
  1450. result[nResult++] = src[i];
  1451. freqs[src[i]]++;
  1452. runLength--;
  1453. if(runLength < 3) {
  1454. while(runLength-- > 0) {
  1455. result[nResult++] = src[i];
  1456. freqs[src[i]]++
  1457. }
  1458. }else {
  1459. while(runLength > 0) {
  1460. rpt = runLength < 6 ? runLength : 6;
  1461. if(rpt > runLength - 3 && rpt < runLength) {
  1462. rpt = runLength - 3
  1463. }
  1464. result[nResult++] = 16;
  1465. result[nResult++] = rpt - 3;
  1466. freqs[16]++;
  1467. runLength -= rpt
  1468. }
  1469. }
  1470. }
  1471. }
  1472. return{codes:USE_TYPEDARRAY ? result.subarray(0, nResult) : result.slice(0, nResult), freqs:freqs}
  1473. };
  1474. Zlib.RawDeflate.prototype.getLengths_ = function(freqs, limit) {
  1475. var nSymbols = freqs.length;
  1476. var heap = new Zlib.Heap(2 * Zlib.RawDeflate.HUFMAX);
  1477. var length = new (USE_TYPEDARRAY ? Uint8Array : Array)(nSymbols);
  1478. var nodes;
  1479. var values;
  1480. var codeLength;
  1481. var i;
  1482. var il;
  1483. if(!USE_TYPEDARRAY) {
  1484. for(i = 0;i < nSymbols;i++) {
  1485. length[i] = 0
  1486. }
  1487. }
  1488. for(i = 0;i < nSymbols;++i) {
  1489. if(freqs[i] > 0) {
  1490. heap.push(i, freqs[i])
  1491. }
  1492. }
  1493. nodes = new Array(heap.length / 2);
  1494. values = new (USE_TYPEDARRAY ? Uint32Array : Array)(heap.length / 2);
  1495. if(nodes.length === 1) {
  1496. length[heap.pop().index] = 1;
  1497. return length
  1498. }
  1499. for(i = 0, il = heap.length / 2;i < il;++i) {
  1500. nodes[i] = heap.pop();
  1501. values[i] = nodes[i].value
  1502. }
  1503. codeLength = this.reversePackageMerge_(values, values.length, limit);
  1504. for(i = 0, il = nodes.length;i < il;++i) {
  1505. length[nodes[i].index] = codeLength[i]
  1506. }
  1507. return length
  1508. };
  1509. Zlib.RawDeflate.prototype.reversePackageMerge_ = function(freqs, symbols, limit) {
  1510. var minimumCost = new (USE_TYPEDARRAY ? Uint16Array : Array)(limit);
  1511. var flag = new (USE_TYPEDARRAY ? Uint8Array : Array)(limit);
  1512. var codeLength = new (USE_TYPEDARRAY ? Uint8Array : Array)(symbols);
  1513. var value = new Array(limit);
  1514. var type = new Array(limit);
  1515. var currentPosition = new Array(limit);
  1516. var excess = (1 << limit) - symbols;
  1517. var half = 1 << limit - 1;
  1518. var i;
  1519. var j;
  1520. var t;
  1521. var weight;
  1522. var next;
  1523. function takePackage(j) {
  1524. var x = type[j][currentPosition[j]];
  1525. if(x === symbols) {
  1526. takePackage(j + 1);
  1527. takePackage(j + 1)
  1528. }else {
  1529. --codeLength[x]
  1530. }
  1531. ++currentPosition[j]
  1532. }
  1533. minimumCost[limit - 1] = symbols;
  1534. for(j = 0;j < limit;++j) {
  1535. if(excess < half) {
  1536. flag[j] = 0
  1537. }else {
  1538. flag[j] = 1;
  1539. excess -= half
  1540. }
  1541. excess <<= 1;
  1542. minimumCost[limit - 2 - j] = (minimumCost[limit - 1 - j] / 2 | 0) + symbols
  1543. }
  1544. minimumCost[0] = flag[0];
  1545. value[0] = new Array(minimumCost[0]);
  1546. type[0] = new Array(minimumCost[0]);
  1547. for(j = 1;j < limit;++j) {
  1548. if(minimumCost[j] > 2 * minimumCost[j - 1] + flag[j]) {
  1549. minimumCost[j] = 2 * minimumCost[j - 1] + flag[j]
  1550. }
  1551. value[j] = new Array(minimumCost[j]);
  1552. type[j] = new Array(minimumCost[j])
  1553. }
  1554. for(i = 0;i < symbols;++i) {
  1555. codeLength[i] = limit
  1556. }
  1557. for(t = 0;t < minimumCost[limit - 1];++t) {
  1558. value[limit - 1][t] = freqs[t];
  1559. type[limit - 1][t] = t
  1560. }
  1561. for(i = 0;i < limit;++i) {
  1562. currentPosition[i] = 0
  1563. }
  1564. if(flag[limit - 1] === 1) {
  1565. --codeLength[0];
  1566. ++currentPosition[limit - 1]
  1567. }
  1568. for(j = limit - 2;j >= 0;--j) {
  1569. i = 0;
  1570. weight = 0;
  1571. next = currentPosition[j + 1];
  1572. for(t = 0;t < minimumCost[j];t++) {
  1573. weight = value[j + 1][next] + value[j + 1][next + 1];
  1574. if(weight > freqs[i]) {
  1575. value[j][t] = weight;
  1576. type[j][t] = symbols;
  1577. next += 2
  1578. }else {
  1579. value[j][t] = freqs[i];
  1580. type[j][t] = i;
  1581. ++i
  1582. }
  1583. }
  1584. currentPosition[j] = 0;
  1585. if(flag[j] === 1) {
  1586. takePackage(j)
  1587. }
  1588. }
  1589. return codeLength
  1590. };
  1591. Zlib.RawDeflate.prototype.getCodesFromLengths_ = function(lengths) {
  1592. var codes = new (USE_TYPEDARRAY ? Uint16Array : Array)(lengths.length), count = [], startCode = [], code = 0, i, il, j, m;
  1593. for(i = 0, il = lengths.length;i < il;i++) {
  1594. count[lengths[i]] = (count[lengths[i]] | 0) + 1
  1595. }
  1596. for(i = 1, il = Zlib.RawDeflate.MaxCodeLength;i <= il;i++) {
  1597. startCode[i] = code;
  1598. code += count[i] | 0;
  1599. code <<= 1
  1600. }
  1601. for(i = 0, il = lengths.length;i < il;i++) {
  1602. code = startCode[lengths[i]];
  1603. startCode[lengths[i]] += 1;
  1604. codes[i] = 0;
  1605. for(j = 0, m = lengths[i];j < m;j++) {
  1606. codes[i] = codes[i] << 1 | code & 1;
  1607. code >>>= 1
  1608. }
  1609. }
  1610. return codes
  1611. }
  1612. });
  1613. goog.provide("Zlib.Gzip");
  1614. goog.require("USE_TYPEDARRAY");
  1615. goog.require("Zlib.CRC32");
  1616. goog.require("Zlib.RawDeflate");
  1617. goog.scope(function() {
  1618. Zlib.Gzip = function(input, opt_params) {
  1619. this.input = input;
  1620. this.ip = 0;
  1621. this.output;
  1622. this.op = 0;
  1623. this.flags = {};
  1624. this.filename;
  1625. this.comment;
  1626. this.deflateOptions;
  1627. if(opt_params) {
  1628. if(opt_params["flags"]) {
  1629. this.flags = opt_params["flags"]
  1630. }
  1631. if(typeof opt_params["filename"] === "string") {
  1632. this.filename = opt_params["filename"]
  1633. }
  1634. if(typeof opt_params["comment"] === "string") {
  1635. this.comment = opt_params["comment"]
  1636. }
  1637. if(opt_params["deflateOptions"]) {
  1638. this.deflateOptions = opt_params["deflateOptions"]
  1639. }
  1640. }
  1641. if(!this.deflateOptions) {
  1642. this.deflateOptions = {}
  1643. }
  1644. };
  1645. Zlib.Gzip.DefaultBufferSize = 32768;
  1646. Zlib.Gzip.prototype.compress = function() {
  1647. var flg;
  1648. var mtime;
  1649. var crc16;
  1650. var crc32;
  1651. var rawdeflate;
  1652. var c;
  1653. var i;
  1654. var il;
  1655. var output = new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.Gzip.DefaultBufferSize);
  1656. var op = 0;
  1657. var input = this.input;
  1658. var ip = this.ip;
  1659. var filename = this.filename;
  1660. var comment = this.comment;
  1661. output[op++] = 31;
  1662. output[op++] = 139;
  1663. output[op++] = 8;
  1664. flg = 0;
  1665. if(this.flags["fname"]) {
  1666. flg |= Zlib.Gzip.FlagsMask.FNAME
  1667. }
  1668. if(this.flags["fcomment"]) {
  1669. flg |= Zlib.Gzip.FlagsMask.FCOMMENT
  1670. }
  1671. if(this.flags["fhcrc"]) {
  1672. flg |= Zlib.Gzip.FlagsMask.FHCRC
  1673. }
  1674. output[op++] = flg;
  1675. mtime = (Date.now ? Date.now() : +new Date) / 1E3 | 0;
  1676. output[op++] = mtime & 255;
  1677. output[op++] = mtime >>> 8 & 255;
  1678. output[op++] = mtime >>> 16 & 255;
  1679. output[op++] = mtime >>> 24 & 255;
  1680. output[op++] = 0;
  1681. output[op++] = Zlib.Gzip.OperatingSystem.UNKNOWN;
  1682. if(this.flags["fname"] !== void 0) {
  1683. for(i = 0, il = filename.length;i < il;++i) {
  1684. c = filename.charCodeAt(i);
  1685. if(c > 255) {
  1686. output[op++] = c >>> 8 & 255
  1687. }
  1688. output[op++] = c & 255
  1689. }
  1690. output[op++] = 0
  1691. }
  1692. if(this.flags["comment"]) {
  1693. for(i = 0, il = comment.length;i < il;++i) {
  1694. c = comment.charCodeAt(i);
  1695. if(c > 255) {
  1696. output[op++] = c >>> 8 & 255
  1697. }
  1698. output[op++] = c & 255
  1699. }
  1700. output[op++] = 0
  1701. }
  1702. if(this.flags["fhcrc"]) {
  1703. crc16 = Zlib.CRC32.calc(output, 0, op) & 65535;
  1704. output[op++] = crc16 & 255;
  1705. output[op++] = crc16 >>> 8 & 255
  1706. }
  1707. this.deflateOptions["outputBuffer"] = output;
  1708. this.deflateOptions["outputIndex"] = op;
  1709. rawdeflate = new Zlib.RawDeflate(input, this.deflateOptions);
  1710. output = rawdeflate.compress();
  1711. op = rawdeflate.op;
  1712. if(USE_TYPEDARRAY) {
  1713. if(op + 8 > output.buffer.byteLength) {
  1714. this.output = new Uint8Array(op + 8);
  1715. this.output.set(new Uint8Array(output.buffer));
  1716. output = this.output
  1717. }else {
  1718. output = new Uint8Array(output.buffer)
  1719. }
  1720. }
  1721. crc32 = Zlib.CRC32.calc(input);
  1722. output[op++] = crc32 & 255;
  1723. output[op++] = crc32 >>> 8 & 255;
  1724. output[op++] = crc32 >>> 16 & 255;
  1725. output[op++] = crc32 >>> 24 & 255;
  1726. il = input.length;
  1727. output[op++] = il & 255;
  1728. output[op++] = il >>> 8 & 255;
  1729. output[op++] = il >>> 16 & 255;
  1730. output[op++] = il >>> 24 & 255;
  1731. this.ip = ip;
  1732. if(USE_TYPEDARRAY && op < output.length) {
  1733. this.output = output = output.subarray(0, op)
  1734. }
  1735. return output
  1736. };
  1737. Zlib.Gzip.OperatingSystem = {FAT:0, AMIGA:1, VMS:2, UNIX:3, VM_CMS:4, ATARI_TOS:5, HPFS:6, MACINTOSH:7, Z_SYSTEM:8, CP_M:9, TOPS_20:10, NTFS:11, QDOS:12, ACORN_RISCOS:13, UNKNOWN:255};
  1738. Zlib.Gzip.FlagsMask = {FTEXT:1, FHCRC:2, FEXTRA:4, FNAME:8, FCOMMENT:16}
  1739. });
  1740. goog.provide("Zlib.RawInflateStream");
  1741. goog.require("USE_TYPEDARRAY");
  1742. goog.require("Zlib.Huffman");
  1743. var ZLIB_STREAM_RAW_INFLATE_BUFFER_SIZE = 32768;
  1744. goog.scope(function() {
  1745. var buildHuffmanTable = Zlib.Huffman.buildHuffmanTable;
  1746. Zlib.RawInflateStream = function(input, ip, opt_buffersize) {
  1747. this.blocks = [];
  1748. this.bufferSize = opt_buffersize ? opt_buffersize : ZLIB_STREAM_RAW_INFLATE_BUFFER_SIZE;
  1749. this.totalpos = 0;
  1750. this.ip = ip === void 0 ? 0 : ip;
  1751. this.bitsbuf = 0;
  1752. this.bitsbuflen = 0;
  1753. this.input = USE_TYPEDARRAY ? new Uint8Array(input) : input;
  1754. this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(this.bufferSize);
  1755. this.op = 0;
  1756. this.bfinal = false;
  1757. this.blockLength;
  1758. this.resize = false;
  1759. this.litlenTable;
  1760. this.distTable;
  1761. this.sp = 0;
  1762. this.status = Zlib.RawInflateStream.Status.INITIALIZED;
  1763. this.ip_;
  1764. this.bitsbuflen_;
  1765. this.bitsbuf_
  1766. };
  1767. Zlib.RawInflateStream.BlockType = {UNCOMPRESSED:0, FIXED:1, DYNAMIC:2};
  1768. Zlib.RawInflateStream.Status = {INITIALIZED:0, BLOCK_HEADER_START:1, BLOCK_HEADER_END:2, BLOCK_BODY_START:3, BLOCK_BODY_END:4, DECODE_BLOCK_START:5, DECODE_BLOCK_END:6};
  1769. Zlib.RawInflateStream.prototype.decompress = function(newInput, ip) {
  1770. var stop = false;
  1771. if(newInput !== void 0) {
  1772. this.input = newInput
  1773. }
  1774. if(ip !== void 0) {
  1775. this.ip = ip
  1776. }
  1777. while(!stop) {
  1778. switch(this.status) {
  1779. case Zlib.RawInflateStream.Status.INITIALIZED:
  1780. ;
  1781. case Zlib.RawInflateStream.Status.BLOCK_HEADER_START:
  1782. if(this.readBlockHeader() < 0) {
  1783. stop = true
  1784. }
  1785. break;
  1786. case Zlib.RawInflateStream.Status.BLOCK_HEADER_END:
  1787. ;
  1788. case Zlib.RawInflateStream.Status.BLOCK_BODY_START:
  1789. switch(this.currentBlockType) {
  1790. case Zlib.RawInflateStream.BlockType.UNCOMPRESSED:
  1791. if(this.readUncompressedBlockHeader() < 0) {
  1792. stop = true
  1793. }
  1794. break;
  1795. case Zlib.RawInflateStream.BlockType.FIXED:
  1796. if(this.parseFixedHuffmanBlock() < 0) {
  1797. stop = true
  1798. }
  1799. break;
  1800. case Zlib.RawInflateStream.BlockType.DYNAMIC:
  1801. if(this.parseDynamicHuffmanBlock() < 0) {
  1802. stop = true
  1803. }
  1804. break
  1805. }
  1806. break;
  1807. case Zlib.RawInflateStream.Status.BLOCK_BODY_END:
  1808. ;
  1809. case Zlib.RawInflateStream.Status.DECODE_BLOCK_START:
  1810. switch(this.currentBlockType) {
  1811. case Zlib.RawInflateStream.BlockType.UNCOMPRESSED:
  1812. if(this.parseUncompressedBlock() < 0) {
  1813. stop = true
  1814. }
  1815. break;
  1816. case Zlib.RawInflateStream.BlockType.FIXED:
  1817. ;
  1818. case Zlib.RawInflateStream.BlockType.DYNAMIC:
  1819. if(this.decodeHuffman() < 0) {
  1820. stop = true
  1821. }
  1822. break
  1823. }
  1824. break;
  1825. case Zlib.RawInflateStream.Status.DECODE_BLOCK_END:
  1826. if(this.bfinal) {
  1827. stop = true
  1828. }else {
  1829. this.status = Zlib.RawInflateStream.Status.INITIALIZED
  1830. }
  1831. break
  1832. }
  1833. }
  1834. return this.concatBuffer()
  1835. };
  1836. Zlib.RawInflateStream.MaxBackwardLength = 32768;
  1837. Zlib.RawInflateStream.MaxCopyLength = 258;
  1838. Zlib.RawInflateStream.Order = function(table) {
  1839. return USE_TYPEDARRAY ? new Uint16Array(table) : table
  1840. }([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  1841. Zlib.RawInflateStream.LengthCodeTable = function(table) {
  1842. return USE_TYPEDARRAY ? new Uint16Array(table) : table
  1843. }([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, 258, 258]);
  1844. Zlib.RawInflateStream.LengthExtraTable = function(table) {
  1845. return USE_TYPEDARRAY ? new Uint8Array(table) : table
  1846. }([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]);
  1847. Zlib.RawInflateStream.DistCodeTable = function(table) {
  1848. return USE_TYPEDARRAY ? new Uint16Array(table) : table
  1849. }([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]);
  1850. Zlib.RawInflateStream.DistExtraTable = function(table) {
  1851. return USE_TYPEDARRAY ? new Uint8Array(table) : table
  1852. }([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]);
  1853. Zlib.RawInflateStream.FixedLiteralLengthTable = function(table) {
  1854. return table
  1855. }(function() {
  1856. var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(288);
  1857. var i, il;
  1858. for(i = 0, il = lengths.length;i < il;++i) {
  1859. lengths[i] = i <= 143 ? 8 : i <= 255 ? 9 : i <= 279 ? 7 : 8
  1860. }
  1861. return buildHuffmanTable(lengths)
  1862. }());
  1863. Zlib.RawInflateStream.FixedDistanceTable = function(table) {
  1864. return table
  1865. }(function() {
  1866. var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(30);
  1867. var i, il;
  1868. for(i = 0, il = lengths.length;i < il;++i) {
  1869. lengths[i] = 5
  1870. }
  1871. return buildHuffmanTable(lengths)
  1872. }());
  1873. Zlib.RawInflateStream.prototype.readBlockHeader = function() {
  1874. var hdr;
  1875. this.status = Zlib.RawInflateStream.Status.BLOCK_HEADER_START;
  1876. this.save_();
  1877. if((hdr = this.readBits(3)) < 0) {
  1878. this.restore_();
  1879. return-1
  1880. }
  1881. if(hdr & 1) {
  1882. this.bfinal = true
  1883. }
  1884. hdr >>>= 1;
  1885. switch(hdr) {
  1886. case 0:
  1887. this.currentBlockType = Zlib.RawInflateStream.BlockType.UNCOMPRESSED;
  1888. break;
  1889. case 1:
  1890. this.currentBlockType = Zlib.RawInflateStream.BlockType.FIXED;
  1891. break;
  1892. case 2:
  1893. this.currentBlockType = Zlib.RawInflateStream.BlockType.DYNAMIC;
  1894. break;
  1895. default:
  1896. throw new Error("unknown BTYPE: " + hdr);
  1897. }
  1898. this.status = Zlib.RawInflateStream.Status.BLOCK_HEADER_END
  1899. };
  1900. Zlib.RawInflateStream.prototype.readBits = function(length) {
  1901. var bitsbuf = this.bitsbuf;
  1902. var bitsbuflen = this.bitsbuflen;
  1903. var input = this.input;
  1904. var ip = this.ip;
  1905. var octet;
  1906. while(bitsbuflen < length) {
  1907. if(input.length <= ip) {
  1908. return-1
  1909. }
  1910. octet = input[ip++];
  1911. bitsbuf |= octet << bitsbuflen;
  1912. bitsbuflen += 8
  1913. }
  1914. octet = bitsbuf & (1 << length) - 1;
  1915. bitsbuf >>>= length;
  1916. bitsbuflen -= length;
  1917. this.bitsbuf = bitsbuf;
  1918. this.bitsbuflen = bitsbuflen;
  1919. this.ip = ip;
  1920. return octet
  1921. };
  1922. Zlib.RawInflateStream.prototype.readCodeByTable = function(table) {
  1923. var bitsbuf = this.bitsbuf;
  1924. var bitsbuflen = this.bitsbuflen;
  1925. var input = this.input;
  1926. var ip = this.ip;
  1927. var codeTable = table[0];
  1928. var maxCodeLength = table[1];
  1929. var octet;
  1930. var codeWithLength;
  1931. var codeLength;
  1932. while(bitsbuflen < maxCodeLength) {
  1933. if(input.length <= ip) {
  1934. return-1
  1935. }
  1936. octet = input[ip++];
  1937. bitsbuf |= octet << bitsbuflen;
  1938. bitsbuflen += 8
  1939. }
  1940. codeWithLength = codeTable[bitsbuf & (1 << maxCodeLength) - 1];
  1941. codeLength = codeWithLength >>> 16;
  1942. if(codeLength > bitsbuflen) {
  1943. throw new Error("invalid code length: " + codeLength);
  1944. }
  1945. this.bitsbuf = bitsbuf >> codeLength;
  1946. this.bitsbuflen = bitsbuflen - codeLength;
  1947. this.ip = ip;
  1948. return codeWithLength & 65535
  1949. };
  1950. Zlib.RawInflateStream.prototype.readUncompressedBlockHeader = function() {
  1951. var len;
  1952. var nlen;
  1953. var input = this.input;
  1954. var ip = this.ip;
  1955. this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_START;
  1956. if(ip + 4 >= input.length) {
  1957. return-1
  1958. }
  1959. len = input[ip++] | input[ip++] << 8;
  1960. nlen = input[ip++] | input[ip++] << 8;
  1961. if(len === ~nlen) {
  1962. throw new Error("invalid uncompressed block header: length verify");
  1963. }
  1964. this.bitsbuf = 0;
  1965. this.bitsbuflen = 0;
  1966. this.ip = ip;
  1967. this.blockLength = len;
  1968. this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_END
  1969. };
  1970. Zlib.RawInflateStream.prototype.parseUncompressedBlock = function() {
  1971. var input = this.input;
  1972. var ip = this.ip;
  1973. var output = this.output;
  1974. var op = this.op;
  1975. var len = this.blockLength;
  1976. this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_START;
  1977. while(len--) {
  1978. if(op === output.length) {
  1979. output = this.expandBuffer({fixRatio:2})
  1980. }
  1981. if(ip >= input.length) {
  1982. this.ip = ip;
  1983. this.op = op;
  1984. this.blockLength = len + 1;
  1985. return-1
  1986. }
  1987. output[op++] = input[ip++]
  1988. }
  1989. if(len < 0) {
  1990. this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_END
  1991. }
  1992. this.ip = ip;
  1993. this.op = op;
  1994. return 0
  1995. };
  1996. Zlib.RawInflateStream.prototype.parseFixedHuffmanBlock = function() {
  1997. this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_START;
  1998. this.litlenTable = Zlib.RawInflateStream.FixedLiteralLengthTable;
  1999. this.distTable = Zlib.RawInflateStream.FixedDistanceTable;
  2000. this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_END;
  2001. return 0
  2002. };
  2003. Zlib.RawInflateStream.prototype.save_ = function() {
  2004. this.ip_ = this.ip;
  2005. this.bitsbuflen_ = this.bitsbuflen;
  2006. this.bitsbuf_ = this.bitsbuf
  2007. };
  2008. Zlib.RawInflateStream.prototype.restore_ = function() {
  2009. this.ip = this.ip_;
  2010. this.bitsbuflen = this.bitsbuflen_;
  2011. this.bitsbuf = this.bitsbuf_
  2012. };
  2013. Zlib.RawInflateStream.prototype.parseDynamicHuffmanBlock = function() {
  2014. var hlit;
  2015. var hdist;
  2016. var hclen;
  2017. var codeLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.RawInflateStream.Order.length);
  2018. var codeLengthsTable;
  2019. var litlenLengths;
  2020. var distLengths;
  2021. this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_START;
  2022. this.save_();
  2023. hlit = this.readBits(5) + 257;
  2024. hdist = this.readBits(5) + 1;
  2025. hclen = this.readBits(4) + 4;
  2026. if(hlit < 0 || hdist < 0 || hclen < 0) {
  2027. this.restore_();
  2028. return-1
  2029. }
  2030. try {
  2031. parseDynamicHuffmanBlockImpl.call(this)
  2032. }catch(e) {
  2033. this.restore_();
  2034. return-1
  2035. }
  2036. function parseDynamicHuffmanBlockImpl() {
  2037. var bits;
  2038. var code;
  2039. var prev = 0;
  2040. var repeat;
  2041. var lengthTable;
  2042. var i;
  2043. var il;
  2044. for(i = 0;i < hclen;++i) {
  2045. if((bits = this.readBits(3)) < 0) {
  2046. throw new Error("not enough input");
  2047. }
  2048. codeLengths[Zlib.RawInflateStream.Order[i]] = bits
  2049. }
  2050. codeLengthsTable = buildHuffmanTable(codeLengths);
  2051. lengthTable = new (USE_TYPEDARRAY ? Uint8Array : Array)(hlit + hdist);
  2052. for(i = 0, il = hlit + hdist;i < il;) {
  2053. code = this.readCodeByTable(codeLengthsTable);
  2054. if(code < 0) {
  2055. throw new Error("not enough input");
  2056. }
  2057. switch(code) {
  2058. case 16:
  2059. if((bits = this.readBits(2)) < 0) {
  2060. throw new Error("not enough input");
  2061. }
  2062. repeat = 3 + bits;
  2063. while(repeat--) {
  2064. lengthTable[i++] = prev
  2065. }
  2066. break;
  2067. case 17:
  2068. if((bits = this.readBits(3)) < 0) {
  2069. throw new Error("not enough input");
  2070. }
  2071. repeat = 3 + bits;
  2072. while(repeat--) {
  2073. lengthTable[i++] = 0
  2074. }
  2075. prev = 0;
  2076. break;
  2077. case 18:
  2078. if((bits = this.readBits(7)) < 0) {
  2079. throw new Error("not enough input");
  2080. }
  2081. repeat = 11 + bits;
  2082. while(repeat--) {
  2083. lengthTable[i++] = 0
  2084. }
  2085. prev = 0;
  2086. break;
  2087. default:
  2088. lengthTable[i++] = code;
  2089. prev = code;
  2090. break
  2091. }
  2092. }
  2093. litlenLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(hlit);
  2094. distLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(hdist);
  2095. this.litlenTable = USE_TYPEDARRAY ? buildHuffmanTable(lengthTable.subarray(0, hlit)) : buildHuffmanTable(lengthTable.slice(0, hlit));
  2096. this.distTable = USE_TYPEDARRAY ? buildHuffmanTable(lengthTable.subarray(hlit)) : buildHuffmanTable(lengthTable.slice(hlit))
  2097. }
  2098. this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_END;
  2099. return 0
  2100. };
  2101. Zlib.RawInflateStream.prototype.decodeHuffman = function() {
  2102. var output = this.output;
  2103. var op = this.op;
  2104. var code;
  2105. var ti;
  2106. var codeDist;
  2107. var codeLength;
  2108. var litlen = this.litlenTable;
  2109. var dist = this.distTable;
  2110. var olength = output.length;
  2111. var bits;
  2112. this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_START;
  2113. while(true) {
  2114. this.save_();
  2115. code = this.readCodeByTable(litlen);
  2116. if(code < 0) {
  2117. this.op = op;
  2118. this.restore_();
  2119. return-1
  2120. }
  2121. if(code === 256) {
  2122. break
  2123. }
  2124. if(code < 256) {
  2125. if(op === olength) {
  2126. output = this.expandBuffer();
  2127. olength = output.length
  2128. }
  2129. output[op++] = code;
  2130. continue
  2131. }
  2132. ti = code - 257;
  2133. codeLength = Zlib.RawInflateStream.LengthCodeTable[ti];
  2134. if(Zlib.RawInflateStream.LengthExtraTable[ti] > 0) {
  2135. bits = this.readBits(Zlib.RawInflateStream.LengthExtraTable[ti]);
  2136. if(bits < 0) {
  2137. this.op = op;
  2138. this.restore_();
  2139. return-1
  2140. }
  2141. codeLength += bits
  2142. }
  2143. code = this.readCodeByTable(dist);
  2144. if(code < 0) {
  2145. this.op = op;
  2146. this.restore_();
  2147. return-1
  2148. }
  2149. codeDist = Zlib.RawInflateStream.DistCodeTable[code];
  2150. if(Zlib.RawInflateStream.DistExtraTable[code] > 0) {
  2151. bits = this.readBits(Zlib.RawInflateStream.DistExtraTable[code]);
  2152. if(bits < 0) {
  2153. this.op = op;
  2154. this.restore_();
  2155. return-1
  2156. }
  2157. codeDist += bits
  2158. }
  2159. if(op + codeLength >= olength) {
  2160. output = this.expandBuffer();
  2161. olength = output.length
  2162. }
  2163. while(codeLength--) {
  2164. output[op] = output[op++ - codeDist]
  2165. }
  2166. if(this.ip === this.input.length) {
  2167. this.op = op;
  2168. return-1
  2169. }
  2170. }
  2171. while(this.bitsbuflen >= 8) {
  2172. this.bitsbuflen -= 8;
  2173. this.ip--
  2174. }
  2175. this.op = op;
  2176. this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_END
  2177. };
  2178. Zlib.RawInflateStream.prototype.expandBuffer = function(opt_param) {
  2179. var buffer;
  2180. var ratio = this.input.length / this.ip + 1 | 0;
  2181. var maxHuffCode;
  2182. var newSize;
  2183. var maxInflateSize;
  2184. var input = this.input;
  2185. var output = this.output;
  2186. if(opt_param) {
  2187. if(typeof opt_param.fixRatio === "number") {
  2188. ratio = opt_param.fixRatio
  2189. }
  2190. if(typeof opt_param.addRatio === "number") {
  2191. ratio += opt_param.addRatio
  2192. }
  2193. }
  2194. if(ratio < 2) {
  2195. maxHuffCode = (input.length - this.ip) / this.litlenTable[2];
  2196. maxInflateSize = maxHuffCode / 2 * 258 | 0;
  2197. newSize = maxInflateSize < output.length ? output.length + maxInflateSize : output.length << 1
  2198. }else {
  2199. newSize = output.length * ratio
  2200. }
  2201. if(USE_TYPEDARRAY) {
  2202. buffer = new Uint8Array(newSize);
  2203. buffer.set(output)
  2204. }else {
  2205. buffer = output
  2206. }
  2207. this.output = buffer;
  2208. return this.output
  2209. };
  2210. Zlib.RawInflateStream.prototype.concatBuffer = function() {
  2211. var buffer;
  2212. var op = this.op;
  2213. var tmp;
  2214. if(this.resize) {
  2215. if(USE_TYPEDARRAY) {
  2216. buffer = new Uint8Array(this.output.subarray(this.sp, op))
  2217. }else {
  2218. buffer = this.output.slice(this.sp, op)
  2219. }
  2220. }else {
  2221. buffer = USE_TYPEDARRAY ? this.output.subarray(this.sp, op) : this.output.slice(this.sp, op)
  2222. }
  2223. this.sp = op;
  2224. if(op > Zlib.RawInflateStream.MaxBackwardLength + this.bufferSize) {
  2225. this.op = this.sp = Zlib.RawInflateStream.MaxBackwardLength;
  2226. if(USE_TYPEDARRAY) {
  2227. tmp = (this.output);
  2228. this.output = new Uint8Array(this.bufferSize + Zlib.RawInflateStream.MaxBackwardLength);
  2229. this.output.set(tmp.subarray(op - Zlib.RawInflateStream.MaxBackwardLength, op))
  2230. }else {
  2231. this.output = this.output.slice(op - Zlib.RawInflateStream.MaxBackwardLength)
  2232. }
  2233. }
  2234. return buffer
  2235. }
  2236. });
  2237. goog.provide("Zlib.RawInflate");
  2238. goog.require("USE_TYPEDARRAY");
  2239. goog.require("Zlib.Huffman");
  2240. var ZLIB_RAW_INFLATE_BUFFER_SIZE = 32768;
  2241. goog.scope(function() {
  2242. var buildHuffmanTable = Zlib.Huffman.buildHuffmanTable;
  2243. Zlib.RawInflate = function(input, opt_params) {
  2244. this.buffer;
  2245. this.blocks = [];
  2246. this.bufferSize = ZLIB_RAW_INFLATE_BUFFER_SIZE;
  2247. this.totalpos = 0;
  2248. this.ip = 0;
  2249. this.bitsbuf = 0;
  2250. this.bitsbuflen = 0;
  2251. this.input = USE_TYPEDARRAY ? new Uint8Array(input) : input;
  2252. this.output;
  2253. this.op;
  2254. this.bfinal = false;
  2255. this.bufferType = Zlib.RawInflate.BufferType.ADAPTIVE;
  2256. this.resize = false;
  2257. if(opt_params || !(opt_params = {})) {
  2258. if(opt_params["index"]) {
  2259. this.ip = opt_params["index"]
  2260. }
  2261. if(opt_params["bufferSize"]) {
  2262. this.bufferSize = opt_params["bufferSize"]
  2263. }
  2264. if(opt_params["bufferType"]) {
  2265. this.bufferType = opt_params["bufferType"]
  2266. }
  2267. if(opt_params["resize"]) {
  2268. this.resize = opt_params["resize"]
  2269. }
  2270. }
  2271. switch(this.bufferType) {
  2272. case Zlib.RawInflate.BufferType.BLOCK:
  2273. this.op = Zlib.RawInflate.MaxBackwardLength;
  2274. this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.RawInflate.MaxBackwardLength + this.bufferSize + Zlib.RawInflate.MaxCopyLength);
  2275. break;
  2276. case Zlib.RawInflate.BufferType.ADAPTIVE:
  2277. this.op = 0;
  2278. this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(this.bufferSize);
  2279. this.expandBuffer = this.expandBufferAdaptive;
  2280. this.concatBuffer = this.concatBufferDynamic;
  2281. this.decodeHuffman = this.decodeHuffmanAdaptive;
  2282. break;
  2283. default:
  2284. throw new Error("invalid inflate mode");
  2285. }
  2286. };
  2287. Zlib.RawInflate.BufferType = {BLOCK:0, ADAPTIVE:1};
  2288. Zlib.RawInflate.prototype.decompress = function() {
  2289. while(!this.bfinal) {
  2290. this.parseBlock()
  2291. }
  2292. return this.concatBuffer()
  2293. };
  2294. Zlib.RawInflate.MaxBackwardLength = 32768;
  2295. Zlib.RawInflate.MaxCopyLength = 258;
  2296. Zlib.RawInflate.Order = function(table) {
  2297. return USE_TYPEDARRAY ? new Uint16Array(table) : table
  2298. }([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  2299. Zlib.RawInflate.LengthCodeTable = function(table) {
  2300. return USE_TYPEDARRAY ? new Uint16Array(table) : table
  2301. }([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, 258, 258]);
  2302. Zlib.RawInflate.LengthExtraTable = function(table) {
  2303. return USE_TYPEDARRAY ? new Uint8Array(table) : table
  2304. }([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]);
  2305. Zlib.RawInflate.DistCodeTable = function(table) {
  2306. return USE_TYPEDARRAY ? new Uint16Array(table) : table
  2307. }([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]);
  2308. Zlib.RawInflate.DistExtraTable = function(table) {
  2309. return USE_TYPEDARRAY ? new Uint8Array(table) : table
  2310. }([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]);
  2311. Zlib.RawInflate.FixedLiteralLengthTable = function(table) {
  2312. return table
  2313. }(function() {
  2314. var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(288);
  2315. var i, il;
  2316. for(i = 0, il = lengths.length;i < il;++i) {
  2317. lengths[i] = i <= 143 ? 8 : i <= 255 ? 9 : i <= 279 ? 7 : 8
  2318. }
  2319. return buildHuffmanTable(lengths)
  2320. }());
  2321. Zlib.RawInflate.FixedDistanceTable = function(table) {
  2322. return table
  2323. }(function() {
  2324. var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(30);
  2325. var i, il;
  2326. for(i = 0, il = lengths.length;i < il;++i) {
  2327. lengths[i] = 5
  2328. }
  2329. return buildHuffmanTable(lengths)
  2330. }());
  2331. Zlib.RawInflate.prototype.parseBlock = function() {
  2332. var hdr = this.readBits(3);
  2333. if(hdr & 1) {
  2334. this.bfinal = true
  2335. }
  2336. hdr >>>= 1;
  2337. switch(hdr) {
  2338. case 0:
  2339. this.parseUncompressedBlock();
  2340. break;
  2341. case 1:
  2342. this.parseFixedHuffmanBlock();
  2343. break;
  2344. case 2:
  2345. this.parseDynamicHuffmanBlock();
  2346. break;
  2347. default:
  2348. throw new Error("unknown BTYPE: " + hdr);
  2349. }
  2350. };
  2351. Zlib.RawInflate.prototype.readBits = function(length) {
  2352. var bitsbuf = this.bitsbuf;
  2353. var bitsbuflen = this.bitsbuflen;
  2354. var input = this.input;
  2355. var ip = this.ip;
  2356. var inputLength = input.length;
  2357. var octet;
  2358. while(bitsbuflen < length) {
  2359. if(ip >= inputLength) {
  2360. throw new Error("input buffer is broken");
  2361. }
  2362. bitsbuf |= input[ip++] << bitsbuflen;
  2363. bitsbuflen += 8
  2364. }
  2365. octet = bitsbuf & (1 << length) - 1;
  2366. bitsbuf >>>= length;
  2367. bitsbuflen -= length;
  2368. this.bitsbuf = bitsbuf;
  2369. this.bitsbuflen = bitsbuflen;
  2370. this.ip = ip;
  2371. return octet
  2372. };
  2373. Zlib.RawInflate.prototype.readCodeByTable = function(table) {
  2374. var bitsbuf = this.bitsbuf;
  2375. var bitsbuflen = this.bitsbuflen;
  2376. var input = this.input;
  2377. var ip = this.ip;
  2378. var inputLength = input.length;
  2379. var codeTable = table[0];
  2380. var maxCodeLength = table[1];
  2381. var codeWithLength;
  2382. var codeLength;
  2383. while(bitsbuflen < maxCodeLength) {
  2384. if(ip >= inputLength) {
  2385. break
  2386. }
  2387. bitsbuf |= input[ip++] << bitsbuflen;
  2388. bitsbuflen += 8
  2389. }
  2390. codeWithLength = codeTable[bitsbuf & (1 << maxCodeLength) - 1];
  2391. codeLength = codeWithLength >>> 16;
  2392. if(codeLength > bitsbuflen) {
  2393. throw new Error("invalid code length: " + codeLength);
  2394. }
  2395. this.bitsbuf = bitsbuf >> codeLength;
  2396. this.bitsbuflen = bitsbuflen - codeLength;
  2397. this.ip = ip;
  2398. return codeWithLength & 65535
  2399. };
  2400. Zlib.RawInflate.prototype.parseUncompressedBlock = function() {
  2401. var input = this.input;
  2402. var ip = this.ip;
  2403. var output = this.output;
  2404. var op = this.op;
  2405. var inputLength = input.length;
  2406. var len;
  2407. var nlen;
  2408. var olength = output.length;
  2409. var preCopy;
  2410. this.bitsbuf = 0;
  2411. this.bitsbuflen = 0;
  2412. if(ip + 1 >= inputLength) {
  2413. throw new Error("invalid uncompressed block header: LEN");
  2414. }
  2415. len = input[ip++] | input[ip++] << 8;
  2416. if(ip + 1 >= inputLength) {
  2417. throw new Error("invalid uncompressed block header: NLEN");
  2418. }
  2419. nlen = input[ip++] | input[ip++] << 8;
  2420. if(len === ~nlen) {
  2421. throw new Error("invalid uncompressed block header: length verify");
  2422. }
  2423. if(ip + len > input.length) {
  2424. throw new Error("input buffer is broken");
  2425. }
  2426. switch(this.bufferType) {
  2427. case Zlib.RawInflate.BufferType.BLOCK:
  2428. while(op + len > output.length) {
  2429. preCopy = olength - op;
  2430. len -= preCopy;
  2431. if(USE_TYPEDARRAY) {
  2432. output.set(input.subarray(ip, ip + preCopy), op);
  2433. op += preCopy;
  2434. ip += preCopy
  2435. }else {
  2436. while(preCopy--) {
  2437. output[op++] = input[ip++]
  2438. }
  2439. }
  2440. this.op = op;
  2441. output = this.expandBuffer();
  2442. op = this.op
  2443. }
  2444. break;
  2445. case Zlib.RawInflate.BufferType.ADAPTIVE:
  2446. while(op + len > output.length) {
  2447. output = this.expandBuffer({fixRatio:2})
  2448. }
  2449. break;
  2450. default:
  2451. throw new Error("invalid inflate mode");
  2452. }
  2453. if(USE_TYPEDARRAY) {
  2454. output.set(input.subarray(ip, ip + len), op);
  2455. op += len;
  2456. ip += len
  2457. }else {
  2458. while(len--) {
  2459. output[op++] = input[ip++]
  2460. }
  2461. }
  2462. this.ip = ip;
  2463. this.op = op;
  2464. this.output = output
  2465. };
  2466. Zlib.RawInflate.prototype.parseFixedHuffmanBlock = function() {
  2467. this.decodeHuffman(Zlib.RawInflate.FixedLiteralLengthTable, Zlib.RawInflate.FixedDistanceTable)
  2468. };
  2469. Zlib.RawInflate.prototype.parseDynamicHuffmanBlock = function() {
  2470. var hlit = this.readBits(5) + 257;
  2471. var hdist = this.readBits(5) + 1;
  2472. var hclen = this.readBits(4) + 4;
  2473. var codeLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.RawInflate.Order.length);
  2474. var codeLengthsTable;
  2475. var litlenTable;
  2476. var distTable;
  2477. var lengthTable;
  2478. var code;
  2479. var prev;
  2480. var repeat;
  2481. var i;
  2482. var il;
  2483. for(i = 0;i < hclen;++i) {
  2484. codeLengths[Zlib.RawInflate.Order[i]] = this.readBits(3)
  2485. }
  2486. if(!USE_TYPEDARRAY) {
  2487. for(i = hclen, hclen = codeLengths.length;i < hclen;++i) {
  2488. codeLengths[Zlib.RawInflate.Order[i]] = 0
  2489. }
  2490. }
  2491. codeLengthsTable = buildHuffmanTable(codeLengths);
  2492. lengthTable = new (USE_TYPEDARRAY ? Uint8Array : Array)(hlit + hdist);
  2493. for(i = 0, il = hlit + hdist;i < il;) {
  2494. code = this.readCodeByTable(codeLengthsTable);
  2495. switch(code) {
  2496. case 16:
  2497. repeat = 3 + this.readBits(2);
  2498. while(repeat--) {
  2499. lengthTable[i++] = prev
  2500. }
  2501. break;
  2502. case 17:
  2503. repeat = 3 + this.readBits(3);
  2504. while(repeat--) {
  2505. lengthTable[i++] = 0
  2506. }
  2507. prev = 0;
  2508. break;
  2509. case 18:
  2510. repeat = 11 + this.readBits(7);
  2511. while(repeat--) {
  2512. lengthTable[i++] = 0
  2513. }
  2514. prev = 0;
  2515. break;
  2516. default:
  2517. lengthTable[i++] = code;
  2518. prev = code;
  2519. break
  2520. }
  2521. }
  2522. litlenTable = USE_TYPEDARRAY ? buildHuffmanTable(lengthTable.subarray(0, hlit)) : buildHuffmanTable(lengthTable.slice(0, hlit));
  2523. distTable = USE_TYPEDARRAY ? buildHuffmanTable(lengthTable.subarray(hlit)) : buildHuffmanTable(lengthTable.slice(hlit));
  2524. this.decodeHuffman(litlenTable, distTable)
  2525. };
  2526. Zlib.RawInflate.prototype.decodeHuffman = function(litlen, dist) {
  2527. var output = this.output;
  2528. var op = this.op;
  2529. this.currentLitlenTable = litlen;
  2530. var olength = output.length - Zlib.RawInflate.MaxCopyLength;
  2531. var code;
  2532. var ti;
  2533. var codeDist;
  2534. var codeLength;
  2535. while((code = this.readCodeByTable(litlen)) !== 256) {
  2536. if(code < 256) {
  2537. if(op >= olength) {
  2538. this.op = op;
  2539. output = this.expandBuffer();
  2540. op = this.op
  2541. }
  2542. output[op++] = code;
  2543. continue
  2544. }
  2545. ti = code - 257;
  2546. codeLength = Zlib.RawInflate.LengthCodeTable[ti];
  2547. if(Zlib.RawInflate.LengthExtraTable[ti] > 0) {
  2548. codeLength += this.readBits(Zlib.RawInflate.LengthExtraTable[ti])
  2549. }
  2550. code = this.readCodeByTable(dist);
  2551. codeDist = Zlib.RawInflate.DistCodeTable[code];
  2552. if(Zlib.RawInflate.DistExtraTable[code] > 0) {
  2553. codeDist += this.readBits(Zlib.RawInflate.DistExtraTable[code])
  2554. }
  2555. if(op >= olength) {
  2556. this.op = op;
  2557. output = this.expandBuffer();
  2558. op = this.op
  2559. }
  2560. while(codeLength--) {
  2561. output[op] = output[op++ - codeDist]
  2562. }
  2563. }
  2564. while(this.bitsbuflen >= 8) {
  2565. this.bitsbuflen -= 8;
  2566. this.ip--
  2567. }
  2568. this.op = op
  2569. };
  2570. Zlib.RawInflate.prototype.decodeHuffmanAdaptive = function(litlen, dist) {
  2571. var output = this.output;
  2572. var op = this.op;
  2573. this.currentLitlenTable = litlen;
  2574. var olength = output.length;
  2575. var code;
  2576. var ti;
  2577. var codeDist;
  2578. var codeLength;
  2579. while((code = this.readCodeByTable(litlen)) !== 256) {
  2580. if(code < 256) {
  2581. if(op >= olength) {
  2582. output = this.expandBuffer();
  2583. olength = output.length
  2584. }
  2585. output[op++] = code;
  2586. continue
  2587. }
  2588. ti = code - 257;
  2589. codeLength = Zlib.RawInflate.LengthCodeTable[ti];
  2590. if(Zlib.RawInflate.LengthExtraTable[ti] > 0) {
  2591. codeLength += this.readBits(Zlib.RawInflate.LengthExtraTable[ti])
  2592. }
  2593. code = this.readCodeByTable(dist);
  2594. codeDist = Zlib.RawInflate.DistCodeTable[code];
  2595. if(Zlib.RawInflate.DistExtraTable[code] > 0) {
  2596. codeDist += this.readBits(Zlib.RawInflate.DistExtraTable[code])
  2597. }
  2598. if(op + codeLength > olength) {
  2599. output = this.expandBuffer();
  2600. olength = output.length
  2601. }
  2602. while(codeLength--) {
  2603. output[op] = output[op++ - codeDist]
  2604. }
  2605. }
  2606. while(this.bitsbuflen >= 8) {
  2607. this.bitsbuflen -= 8;
  2608. this.ip--
  2609. }
  2610. this.op = op
  2611. };
  2612. Zlib.RawInflate.prototype.expandBuffer = function(opt_param) {
  2613. var buffer = new (USE_TYPEDARRAY ? Uint8Array : Array)(this.op - Zlib.RawInflate.MaxBackwardLength);
  2614. var backward = this.op - Zlib.RawInflate.MaxBackwardLength;
  2615. var i;
  2616. var il;
  2617. var output = this.output;
  2618. if(USE_TYPEDARRAY) {
  2619. buffer.set(output.subarray(Zlib.RawInflate.MaxBackwardLength, buffer.length))
  2620. }else {
  2621. for(i = 0, il = buffer.length;i < il;++i) {
  2622. buffer[i] = output[i + Zlib.RawInflate.MaxBackwardLength]
  2623. }
  2624. }
  2625. this.blocks.push(buffer);
  2626. this.totalpos += buffer.length;
  2627. if(USE_TYPEDARRAY) {
  2628. output.set(output.subarray(backward, backward + Zlib.RawInflate.MaxBackwardLength))
  2629. }else {
  2630. for(i = 0;i < Zlib.RawInflate.MaxBackwardLength;++i) {
  2631. output[i] = output[backward + i]
  2632. }
  2633. }
  2634. this.op = Zlib.RawInflate.MaxBackwardLength;
  2635. return output
  2636. };
  2637. Zlib.RawInflate.prototype.expandBufferAdaptive = function(opt_param) {
  2638. var buffer;
  2639. var ratio = this.input.length / this.ip + 1 | 0;
  2640. var maxHuffCode;
  2641. var newSize;
  2642. var maxInflateSize;
  2643. var input = this.input;
  2644. var output = this.output;
  2645. if(opt_param) {
  2646. if(typeof opt_param.fixRatio === "number") {
  2647. ratio = opt_param.fixRatio
  2648. }
  2649. if(typeof opt_param.addRatio === "number") {
  2650. ratio += opt_param.addRatio
  2651. }
  2652. }
  2653. if(ratio < 2) {
  2654. maxHuffCode = (input.length - this.ip) / this.currentLitlenTable[2];
  2655. maxInflateSize = maxHuffCode / 2 * 258 | 0;
  2656. newSize = maxInflateSize < output.length ? output.length + maxInflateSize : output.length << 1
  2657. }else {
  2658. newSize = output.length * ratio
  2659. }
  2660. if(USE_TYPEDARRAY) {
  2661. buffer = new Uint8Array(newSize);
  2662. buffer.set(output)
  2663. }else {
  2664. buffer = output
  2665. }
  2666. this.output = buffer;
  2667. return this.output
  2668. };
  2669. Zlib.RawInflate.prototype.concatBuffer = function() {
  2670. var pos = 0;
  2671. var limit = this.totalpos + (this.op - Zlib.RawInflate.MaxBackwardLength);
  2672. var output = this.output;
  2673. var blocks = this.blocks;
  2674. var block;
  2675. var buffer = new (USE_TYPEDARRAY ? Uint8Array : Array)(limit);
  2676. var i;
  2677. var il;
  2678. var j;
  2679. var jl;
  2680. if(blocks.length === 0) {
  2681. return USE_TYPEDARRAY ? this.output.subarray(Zlib.RawInflate.MaxBackwardLength, this.op) : this.output.slice(Zlib.RawInflate.MaxBackwardLength, this.op)
  2682. }
  2683. for(i = 0, il = blocks.length;i < il;++i) {
  2684. block = blocks[i];
  2685. for(j = 0, jl = block.length;j < jl;++j) {
  2686. buffer[pos++] = block[j]
  2687. }
  2688. }
  2689. for(i = Zlib.RawInflate.MaxBackwardLength, il = this.op;i < il;++i) {
  2690. buffer[pos++] = output[i]
  2691. }
  2692. this.blocks = [];
  2693. this.buffer = buffer;
  2694. return this.buffer
  2695. };
  2696. Zlib.RawInflate.prototype.concatBufferDynamic = function() {
  2697. var buffer;
  2698. var op = this.op;
  2699. if(USE_TYPEDARRAY) {
  2700. if(this.resize) {
  2701. buffer = new Uint8Array(op);
  2702. buffer.set(this.output.subarray(0, op))
  2703. }else {
  2704. buffer = this.output.subarray(0, op)
  2705. }
  2706. }else {
  2707. if(this.output.length > op) {
  2708. this.output.length = op
  2709. }
  2710. buffer = this.output
  2711. }
  2712. this.buffer = buffer;
  2713. return this.buffer
  2714. }
  2715. });
  2716. goog.provide("Zlib.Gunzip");
  2717. goog.require("USE_TYPEDARRAY");
  2718. goog.require("Zlib.CRC32");
  2719. goog.require("Zlib.Gzip");
  2720. goog.require("Zlib.RawInflate");
  2721. goog.require("Zlib.GunzipMember");
  2722. goog.scope(function() {
  2723. Zlib.Gunzip = function(input, opt_params) {
  2724. this.input = input;
  2725. this.ip = 0;
  2726. this.member = [];
  2727. this.decompressed = false
  2728. };
  2729. Zlib.Gunzip.prototype.getMembers = function() {
  2730. if(!this.decompressed) {
  2731. this.decompress()
  2732. }
  2733. return this.member.slice()
  2734. };
  2735. Zlib.Gunzip.prototype.decompress = function() {
  2736. var il = this.input.length;
  2737. while(this.ip < il) {
  2738. this.decodeMember()
  2739. }
  2740. this.decompressed = true;
  2741. return this.concatMember()
  2742. };
  2743. Zlib.Gunzip.prototype.decodeMember = function() {
  2744. var member = new Zlib.GunzipMember;
  2745. var isize;
  2746. var rawinflate;
  2747. var inflated;
  2748. var inflen;
  2749. var c;
  2750. var ci;
  2751. var str;
  2752. var mtime;
  2753. var crc32;
  2754. var input = this.input;
  2755. var ip = this.ip;
  2756. member.id1 = input[ip++];
  2757. member.id2 = input[ip++];
  2758. if(member.id1 !== 31 || member.id2 !== 139) {
  2759. throw new Error("invalid file signature:" + member.id1 + "," + member.id2);
  2760. }
  2761. member.cm = input[ip++];
  2762. switch(member.cm) {
  2763. case 8:
  2764. break;
  2765. default:
  2766. throw new Error("unknown compression method: " + member.cm);
  2767. }
  2768. member.flg = input[ip++];
  2769. mtime = input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24;
  2770. member.mtime = new Date(mtime * 1E3);
  2771. member.xfl = input[ip++];
  2772. member.os = input[ip++];
  2773. if((member.flg & Zlib.Gzip.FlagsMask.FEXTRA) > 0) {
  2774. member.xlen = input[ip++] | input[ip++] << 8;
  2775. ip = this.decodeSubField(ip, member.xlen)
  2776. }
  2777. if((member.flg & Zlib.Gzip.FlagsMask.FNAME) > 0) {
  2778. for(str = [], ci = 0;(c = input[ip++]) > 0;) {
  2779. str[ci++] = String.fromCharCode(c)
  2780. }
  2781. member.name = str.join("")
  2782. }
  2783. if((member.flg & Zlib.Gzip.FlagsMask.FCOMMENT) > 0) {
  2784. for(str = [], ci = 0;(c = input[ip++]) > 0;) {
  2785. str[ci++] = String.fromCharCode(c)
  2786. }
  2787. member.comment = str.join("")
  2788. }
  2789. if((member.flg & Zlib.Gzip.FlagsMask.FHCRC) > 0) {
  2790. member.crc16 = Zlib.CRC32.calc(input, 0, ip) & 65535;
  2791. if(member.crc16 !== (input[ip++] | input[ip++] << 8)) {
  2792. throw new Error("invalid header crc16");
  2793. }
  2794. }
  2795. isize = input[input.length - 4] | input[input.length - 3] << 8 | input[input.length - 2] << 16 | input[input.length - 1] << 24;
  2796. if(input.length - ip - 4 - 4 < isize * 512) {
  2797. inflen = isize
  2798. }
  2799. rawinflate = new Zlib.RawInflate(input, {"index":ip, "bufferSize":inflen});
  2800. member.data = inflated = rawinflate.decompress();
  2801. ip = rawinflate.ip;
  2802. member.crc32 = crc32 = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  2803. if(Zlib.CRC32.calc(inflated) !== crc32) {
  2804. throw new Error("invalid CRC-32 checksum: 0x" + Zlib.CRC32.calc(inflated).toString(16) + " / 0x" + crc32.toString(16));
  2805. }
  2806. member.isize = isize = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  2807. if((inflated.length & 4294967295) !== isize) {
  2808. throw new Error("invalid input size: " + (inflated.length & 4294967295) + " / " + isize);
  2809. }
  2810. this.member.push(member);
  2811. this.ip = ip
  2812. };
  2813. Zlib.Gunzip.prototype.decodeSubField = function(ip, length) {
  2814. return ip + length
  2815. };
  2816. Zlib.Gunzip.prototype.concatMember = function() {
  2817. var member = this.member;
  2818. var i;
  2819. var il;
  2820. var p = 0;
  2821. var size = 0;
  2822. var buffer;
  2823. for(i = 0, il = member.length;i < il;++i) {
  2824. size += member[i].data.length
  2825. }
  2826. if(USE_TYPEDARRAY) {
  2827. buffer = new Uint8Array(size);
  2828. for(i = 0;i < il;++i) {
  2829. buffer.set(member[i].data, p);
  2830. p += member[i].data.length
  2831. }
  2832. }else {
  2833. buffer = [];
  2834. for(i = 0;i < il;++i) {
  2835. buffer[i] = member[i].data
  2836. }
  2837. buffer = Array.prototype.concat.apply([], buffer)
  2838. }
  2839. return buffer
  2840. }
  2841. });
  2842. goog.provide("Zlib.Util");
  2843. goog.scope(function() {
  2844. Zlib.Util.stringToByteArray = function(str) {
  2845. var tmp = str.split("");
  2846. var i;
  2847. var il;
  2848. for(i = 0, il = tmp.length;i < il;i++) {
  2849. tmp[i] = (tmp[i].charCodeAt(0) & 255) >>> 0
  2850. }
  2851. return tmp
  2852. }
  2853. });
  2854. goog.provide("Zlib.Adler32");
  2855. goog.require("USE_TYPEDARRAY");
  2856. goog.require("Zlib.Util");
  2857. goog.scope(function() {
  2858. Zlib.Adler32 = function(array) {
  2859. if(typeof array === "string") {
  2860. array = Zlib.Util.stringToByteArray(array)
  2861. }
  2862. return Zlib.Adler32.update(1, array)
  2863. };
  2864. Zlib.Adler32.update = function(adler, array) {
  2865. var s1 = adler & 65535;
  2866. var s2 = adler >>> 16 & 65535;
  2867. var len = array.length;
  2868. var tlen;
  2869. var i = 0;
  2870. while(len > 0) {
  2871. tlen = len > Zlib.Adler32.OptimizationParameter ? Zlib.Adler32.OptimizationParameter : len;
  2872. len -= tlen;
  2873. do {
  2874. s1 += array[i++];
  2875. s2 += s1
  2876. }while(--tlen);
  2877. s1 %= 65521;
  2878. s2 %= 65521
  2879. }
  2880. return(s2 << 16 | s1) >>> 0
  2881. };
  2882. Zlib.Adler32.OptimizationParameter = 1024
  2883. });
  2884. goog.provide("Zlib.Inflate");
  2885. goog.require("USE_TYPEDARRAY");
  2886. goog.require("Zlib.Adler32");
  2887. goog.require("Zlib.RawInflate");
  2888. goog.scope(function() {
  2889. Zlib.Inflate = function(input, opt_params) {
  2890. var bufferSize;
  2891. var bufferType;
  2892. var cmf;
  2893. var flg;
  2894. this.input = input;
  2895. this.ip = 0;
  2896. this.rawinflate;
  2897. this.verify;
  2898. if(opt_params || !(opt_params = {})) {
  2899. if(opt_params["index"]) {
  2900. this.ip = opt_params["index"]
  2901. }
  2902. if(opt_params["verify"]) {
  2903. this.verify = opt_params["verify"]
  2904. }
  2905. }
  2906. cmf = input[this.ip++];
  2907. flg = input[this.ip++];
  2908. switch(cmf & 15) {
  2909. case Zlib.CompressionMethod.DEFLATE:
  2910. this.method = Zlib.CompressionMethod.DEFLATE;
  2911. break;
  2912. default:
  2913. throw new Error("unsupported compression method");
  2914. }
  2915. if(((cmf << 8) + flg) % 31 !== 0) {
  2916. throw new Error("invalid fcheck flag:" + ((cmf << 8) + flg) % 31);
  2917. }
  2918. if(flg & 32) {
  2919. throw new Error("fdict flag is not supported");
  2920. }
  2921. this.rawinflate = new Zlib.RawInflate(input, {"index":this.ip, "bufferSize":opt_params["bufferSize"], "bufferType":opt_params["bufferType"], "resize":opt_params["resize"]})
  2922. };
  2923. Zlib.Inflate.BufferType = Zlib.RawInflate.BufferType;
  2924. Zlib.Inflate.prototype.decompress = function() {
  2925. var input = this.input;
  2926. var buffer;
  2927. var adler32;
  2928. buffer = this.rawinflate.decompress();
  2929. this.ip = this.rawinflate.ip;
  2930. if(this.verify) {
  2931. adler32 = (input[this.ip++] << 24 | input[this.ip++] << 16 | input[this.ip++] << 8 | input[this.ip++]) >>> 0;
  2932. if(adler32 !== Zlib.Adler32(buffer)) {
  2933. throw new Error("invalid adler-32 checksum");
  2934. }
  2935. }
  2936. return buffer
  2937. }
  2938. });
  2939. goog.provide("Zlib.Zip");
  2940. goog.require("USE_TYPEDARRAY");
  2941. goog.require("Zlib.RawDeflate");
  2942. goog.require("Zlib.CRC32");
  2943. goog.scope(function() {
  2944. Zlib.Zip = function(opt_params) {
  2945. opt_params = opt_params || {};
  2946. this.files = [];
  2947. this.comment = opt_params["comment"];
  2948. this.password
  2949. };
  2950. Zlib.Zip.CompressionMethod = {STORE:0, DEFLATE:8};
  2951. Zlib.Zip.OperatingSystem = {MSDOS:0, UNIX:3, MACINTOSH:7};
  2952. Zlib.Zip.Flags = {ENCRYPT:1, DESCRIPTOR:8, UTF8:2048};
  2953. Zlib.Zip.FileHeaderSignature = [80, 75, 1, 2];
  2954. Zlib.Zip.LocalFileHeaderSignature = [80, 75, 3, 4];
  2955. Zlib.Zip.CentralDirectorySignature = [80, 75, 5, 6];
  2956. Zlib.Zip.prototype.addFile = function(input, opt_params) {
  2957. opt_params = opt_params || {};
  2958. var filename = "" || opt_params["filename"];
  2959. var compressed;
  2960. var size = input.length;
  2961. var crc32 = 0;
  2962. if(USE_TYPEDARRAY && input instanceof Array) {
  2963. input = new Uint8Array(input)
  2964. }
  2965. if(typeof opt_params["compressionMethod"] !== "number") {
  2966. opt_params["compressionMethod"] = Zlib.Zip.CompressionMethod.DEFLATE
  2967. }
  2968. if(opt_params["compress"]) {
  2969. switch(opt_params["compressionMethod"]) {
  2970. case Zlib.Zip.CompressionMethod.STORE:
  2971. break;
  2972. case Zlib.Zip.CompressionMethod.DEFLATE:
  2973. crc32 = Zlib.CRC32.calc(input);
  2974. input = this.deflateWithOption(input, opt_params);
  2975. compressed = true;
  2976. break;
  2977. default:
  2978. throw new Error("unknown compression method:" + opt_params["compressionMethod"]);
  2979. }
  2980. }
  2981. this.files.push({buffer:input, option:opt_params, compressed:compressed, encrypted:false, size:size, crc32:crc32})
  2982. };
  2983. Zlib.Zip.prototype.setPassword = function(password) {
  2984. this.password = password
  2985. };
  2986. Zlib.Zip.prototype.compress = function() {
  2987. var files = this.files;
  2988. var file;
  2989. var output;
  2990. var op1;
  2991. var op2;
  2992. var op3;
  2993. var localFileSize = 0;
  2994. var centralDirectorySize = 0;
  2995. var endOfCentralDirectorySize;
  2996. var offset;
  2997. var needVersion;
  2998. var flags;
  2999. var compressionMethod;
  3000. var date;
  3001. var crc32;
  3002. var size;
  3003. var plainSize;
  3004. var filenameLength;
  3005. var extraFieldLength;
  3006. var commentLength;
  3007. var filename;
  3008. var extraField;
  3009. var comment;
  3010. var buffer;
  3011. var tmp;
  3012. var key;
  3013. var i;
  3014. var il;
  3015. var j;
  3016. var jl;
  3017. for(i = 0, il = files.length;i < il;++i) {
  3018. file = files[i];
  3019. filenameLength = file.option["filename"] ? file.option["filename"].length : 0;
  3020. extraFieldLength = file.option["extraField"] ? file.option["extraField"].length : 0;
  3021. commentLength = file.option["comment"] ? file.option["comment"].length : 0;
  3022. if(!file.compressed) {
  3023. file.crc32 = Zlib.CRC32.calc(file.buffer);
  3024. switch(file.option["compressionMethod"]) {
  3025. case Zlib.Zip.CompressionMethod.STORE:
  3026. break;
  3027. case Zlib.Zip.CompressionMethod.DEFLATE:
  3028. file.buffer = this.deflateWithOption(file.buffer, file.option);
  3029. file.compressed = true;
  3030. break;
  3031. default:
  3032. throw new Error("unknown compression method:" + file.option["compressionMethod"]);
  3033. }
  3034. }
  3035. if(file.option["password"] !== void 0 || this.password !== void 0) {
  3036. key = this.createEncryptionKey(file.option["password"] || this.password);
  3037. buffer = file.buffer;
  3038. if(USE_TYPEDARRAY) {
  3039. tmp = new Uint8Array(buffer.length + 12);
  3040. tmp.set(buffer, 12);
  3041. buffer = tmp
  3042. }else {
  3043. buffer.unshift(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  3044. }
  3045. for(j = 0;j < 12;++j) {
  3046. buffer[j] = this.encode(key, i === 11 ? file.crc32 & 255 : Math.random() * 256 | 0)
  3047. }
  3048. for(jl = buffer.length;j < jl;++j) {
  3049. buffer[j] = this.encode(key, buffer[j])
  3050. }
  3051. file.buffer = buffer
  3052. }
  3053. localFileSize += 30 + filenameLength + file.buffer.length;
  3054. centralDirectorySize += 46 + filenameLength + commentLength
  3055. }
  3056. endOfCentralDirectorySize = 22 + (this.comment ? this.comment.length : 0);
  3057. output = new (USE_TYPEDARRAY ? Uint8Array : Array)(localFileSize + centralDirectorySize + endOfCentralDirectorySize);
  3058. op1 = 0;
  3059. op2 = localFileSize;
  3060. op3 = op2 + centralDirectorySize;
  3061. for(i = 0, il = files.length;i < il;++i) {
  3062. file = files[i];
  3063. filenameLength = file.option["filename"] ? file.option["filename"].length : 0;
  3064. extraFieldLength = 0;
  3065. commentLength = file.option["comment"] ? file.option["comment"].length : 0;
  3066. offset = op1;
  3067. output[op1++] = Zlib.Zip.LocalFileHeaderSignature[0];
  3068. output[op1++] = Zlib.Zip.LocalFileHeaderSignature[1];
  3069. output[op1++] = Zlib.Zip.LocalFileHeaderSignature[2];
  3070. output[op1++] = Zlib.Zip.LocalFileHeaderSignature[3];
  3071. output[op2++] = Zlib.Zip.FileHeaderSignature[0];
  3072. output[op2++] = Zlib.Zip.FileHeaderSignature[1];
  3073. output[op2++] = Zlib.Zip.FileHeaderSignature[2];
  3074. output[op2++] = Zlib.Zip.FileHeaderSignature[3];
  3075. needVersion = 20;
  3076. output[op2++] = needVersion & 255;
  3077. output[op2++] = (file.option["os"]) || Zlib.Zip.OperatingSystem.MSDOS;
  3078. output[op1++] = output[op2++] = needVersion & 255;
  3079. output[op1++] = output[op2++] = needVersion >> 8 & 255;
  3080. flags = 0;
  3081. if(file.option["password"] || this.password) {
  3082. flags |= Zlib.Zip.Flags.ENCRYPT
  3083. }
  3084. output[op1++] = output[op2++] = flags & 255;
  3085. output[op1++] = output[op2++] = flags >> 8 & 255;
  3086. compressionMethod = (file.option["compressionMethod"]);
  3087. output[op1++] = output[op2++] = compressionMethod & 255;
  3088. output[op1++] = output[op2++] = compressionMethod >> 8 & 255;
  3089. date = (file.option["date"]) || new Date;
  3090. output[op1++] = output[op2++] = (date.getMinutes() & 7) << 5 | date.getSeconds() / 2 | 0;
  3091. output[op1++] = output[op2++] = date.getHours() << 3 | date.getMinutes() >> 3;
  3092. output[op1++] = output[op2++] = (date.getMonth() + 1 & 7) << 5 | date.getDate();
  3093. output[op1++] = output[op2++] = (date.getFullYear() - 1980 & 127) << 1 | date.getMonth() + 1 >> 3;
  3094. crc32 = file.crc32;
  3095. output[op1++] = output[op2++] = crc32 & 255;
  3096. output[op1++] = output[op2++] = crc32 >> 8 & 255;
  3097. output[op1++] = output[op2++] = crc32 >> 16 & 255;
  3098. output[op1++] = output[op2++] = crc32 >> 24 & 255;
  3099. size = file.buffer.length;
  3100. output[op1++] = output[op2++] = size & 255;
  3101. output[op1++] = output[op2++] = size >> 8 & 255;
  3102. output[op1++] = output[op2++] = size >> 16 & 255;
  3103. output[op1++] = output[op2++] = size >> 24 & 255;
  3104. plainSize = file.size;
  3105. output[op1++] = output[op2++] = plainSize & 255;
  3106. output[op1++] = output[op2++] = plainSize >> 8 & 255;
  3107. output[op1++] = output[op2++] = plainSize >> 16 & 255;
  3108. output[op1++] = output[op2++] = plainSize >> 24 & 255;
  3109. output[op1++] = output[op2++] = filenameLength & 255;
  3110. output[op1++] = output[op2++] = filenameLength >> 8 & 255;
  3111. output[op1++] = output[op2++] = extraFieldLength & 255;
  3112. output[op1++] = output[op2++] = extraFieldLength >> 8 & 255;
  3113. output[op2++] = commentLength & 255;
  3114. output[op2++] = commentLength >> 8 & 255;
  3115. output[op2++] = 0;
  3116. output[op2++] = 0;
  3117. output[op2++] = 0;
  3118. output[op2++] = 0;
  3119. output[op2++] = 0;
  3120. output[op2++] = 0;
  3121. output[op2++] = 0;
  3122. output[op2++] = 0;
  3123. output[op2++] = offset & 255;
  3124. output[op2++] = offset >> 8 & 255;
  3125. output[op2++] = offset >> 16 & 255;
  3126. output[op2++] = offset >> 24 & 255;
  3127. filename = file.option["filename"];
  3128. if(filename) {
  3129. if(USE_TYPEDARRAY) {
  3130. output.set(filename, op1);
  3131. output.set(filename, op2);
  3132. op1 += filenameLength;
  3133. op2 += filenameLength
  3134. }else {
  3135. for(j = 0;j < filenameLength;++j) {
  3136. output[op1++] = output[op2++] = filename[j]
  3137. }
  3138. }
  3139. }
  3140. extraField = file.option["extraField"];
  3141. if(extraField) {
  3142. if(USE_TYPEDARRAY) {
  3143. output.set(extraField, op1);
  3144. output.set(extraField, op2);
  3145. op1 += extraFieldLength;
  3146. op2 += extraFieldLength
  3147. }else {
  3148. for(j = 0;j < commentLength;++j) {
  3149. output[op1++] = output[op2++] = extraField[j]
  3150. }
  3151. }
  3152. }
  3153. comment = file.option["comment"];
  3154. if(comment) {
  3155. if(USE_TYPEDARRAY) {
  3156. output.set(comment, op2);
  3157. op2 += commentLength
  3158. }else {
  3159. for(j = 0;j < commentLength;++j) {
  3160. output[op2++] = comment[j]
  3161. }
  3162. }
  3163. }
  3164. if(USE_TYPEDARRAY) {
  3165. output.set(file.buffer, op1);
  3166. op1 += file.buffer.length
  3167. }else {
  3168. for(j = 0, jl = file.buffer.length;j < jl;++j) {
  3169. output[op1++] = file.buffer[j]
  3170. }
  3171. }
  3172. }
  3173. output[op3++] = Zlib.Zip.CentralDirectorySignature[0];
  3174. output[op3++] = Zlib.Zip.CentralDirectorySignature[1];
  3175. output[op3++] = Zlib.Zip.CentralDirectorySignature[2];
  3176. output[op3++] = Zlib.Zip.CentralDirectorySignature[3];
  3177. output[op3++] = 0;
  3178. output[op3++] = 0;
  3179. output[op3++] = 0;
  3180. output[op3++] = 0;
  3181. output[op3++] = il & 255;
  3182. output[op3++] = il >> 8 & 255;
  3183. output[op3++] = il & 255;
  3184. output[op3++] = il >> 8 & 255;
  3185. output[op3++] = centralDirectorySize & 255;
  3186. output[op3++] = centralDirectorySize >> 8 & 255;
  3187. output[op3++] = centralDirectorySize >> 16 & 255;
  3188. output[op3++] = centralDirectorySize >> 24 & 255;
  3189. output[op3++] = localFileSize & 255;
  3190. output[op3++] = localFileSize >> 8 & 255;
  3191. output[op3++] = localFileSize >> 16 & 255;
  3192. output[op3++] = localFileSize >> 24 & 255;
  3193. commentLength = this.comment ? this.comment.length : 0;
  3194. output[op3++] = commentLength & 255;
  3195. output[op3++] = commentLength >> 8 & 255;
  3196. if(this.comment) {
  3197. if(USE_TYPEDARRAY) {
  3198. output.set(this.comment, op3);
  3199. op3 += commentLength
  3200. }else {
  3201. for(j = 0, jl = commentLength;j < jl;++j) {
  3202. output[op3++] = this.comment[j]
  3203. }
  3204. }
  3205. }
  3206. return output
  3207. };
  3208. Zlib.Zip.prototype.deflateWithOption = function(input, opt_params) {
  3209. var deflator = new Zlib.RawDeflate(input, opt_params["deflateOption"]);
  3210. return deflator.compress()
  3211. };
  3212. Zlib.Zip.prototype.getByte = function(key) {
  3213. var tmp = key[2] & 65535 | 2;
  3214. return tmp * (tmp ^ 1) >> 8 & 255
  3215. };
  3216. Zlib.Zip.prototype.encode = function(key, n) {
  3217. var tmp = this.getByte((key));
  3218. this.updateKeys((key), n);
  3219. return tmp ^ n
  3220. };
  3221. Zlib.Zip.prototype.updateKeys = function(key, n) {
  3222. key[0] = Zlib.CRC32.single(key[0], n);
  3223. key[1] = (((key[1] + (key[0] & 255)) * 20173 >>> 0) * 6681 >>> 0) + 1 >>> 0;
  3224. key[2] = Zlib.CRC32.single(key[2], key[1] >>> 24)
  3225. };
  3226. Zlib.Zip.prototype.createEncryptionKey = function(password) {
  3227. var key = [305419896, 591751049, 878082192];
  3228. var i;
  3229. var il;
  3230. if(USE_TYPEDARRAY) {
  3231. key = new Uint32Array(key)
  3232. }
  3233. for(i = 0, il = password.length;i < il;++i) {
  3234. this.updateKeys(key, password[i] & 255)
  3235. }
  3236. return key
  3237. }
  3238. });
  3239. goog.provide("Zlib.Unzip");
  3240. goog.require("USE_TYPEDARRAY");
  3241. goog.require("FixPhantomJSFunctionApplyBug_StringFromCharCode");
  3242. goog.require("Zlib.RawInflate");
  3243. goog.require("Zlib.CRC32");
  3244. goog.require("Zlib.Zip");
  3245. goog.scope(function() {
  3246. Zlib.Unzip = function(input, opt_params) {
  3247. opt_params = opt_params || {};
  3248. this.input = USE_TYPEDARRAY && input instanceof Array ? new Uint8Array(input) : input;
  3249. this.ip = 0;
  3250. this.eocdrOffset;
  3251. this.numberOfThisDisk;
  3252. this.startDisk;
  3253. this.totalEntriesThisDisk;
  3254. this.totalEntries;
  3255. this.centralDirectorySize;
  3256. this.centralDirectoryOffset;
  3257. this.commentLength;
  3258. this.comment;
  3259. this.fileHeaderList;
  3260. this.filenameToIndex;
  3261. this.verify = opt_params["verify"] || false;
  3262. this.password = opt_params["password"]
  3263. };
  3264. Zlib.Unzip.CompressionMethod = Zlib.Zip.CompressionMethod;
  3265. Zlib.Unzip.FileHeaderSignature = Zlib.Zip.FileHeaderSignature;
  3266. Zlib.Unzip.LocalFileHeaderSignature = Zlib.Zip.LocalFileHeaderSignature;
  3267. Zlib.Unzip.CentralDirectorySignature = Zlib.Zip.CentralDirectorySignature;
  3268. Zlib.Unzip.FileHeader = function(input, ip) {
  3269. this.input = input;
  3270. this.offset = ip;
  3271. this.length;
  3272. this.version;
  3273. this.os;
  3274. this.needVersion;
  3275. this.flags;
  3276. this.compression;
  3277. this.time;
  3278. this.date;
  3279. this.crc32;
  3280. this.compressedSize;
  3281. this.plainSize;
  3282. this.fileNameLength;
  3283. this.extraFieldLength;
  3284. this.fileCommentLength;
  3285. this.diskNumberStart;
  3286. this.internalFileAttributes;
  3287. this.externalFileAttributes;
  3288. this.relativeOffset;
  3289. this.filename;
  3290. this.extraField;
  3291. this.comment
  3292. };
  3293. Zlib.Unzip.FileHeader.prototype.parse = function() {
  3294. var input = this.input;
  3295. var ip = this.offset;
  3296. if(input[ip++] !== Zlib.Unzip.FileHeaderSignature[0] || input[ip++] !== Zlib.Unzip.FileHeaderSignature[1] || input[ip++] !== Zlib.Unzip.FileHeaderSignature[2] || input[ip++] !== Zlib.Unzip.FileHeaderSignature[3]) {
  3297. throw new Error("invalid file header signature");
  3298. }
  3299. this.version = input[ip++];
  3300. this.os = input[ip++];
  3301. this.needVersion = input[ip++] | input[ip++] << 8;
  3302. this.flags = input[ip++] | input[ip++] << 8;
  3303. this.compression = input[ip++] | input[ip++] << 8;
  3304. this.time = input[ip++] | input[ip++] << 8;
  3305. this.date = input[ip++] | input[ip++] << 8;
  3306. this.crc32 = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3307. this.compressedSize = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3308. this.plainSize = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3309. this.fileNameLength = input[ip++] | input[ip++] << 8;
  3310. this.extraFieldLength = input[ip++] | input[ip++] << 8;
  3311. this.fileCommentLength = input[ip++] | input[ip++] << 8;
  3312. this.diskNumberStart = input[ip++] | input[ip++] << 8;
  3313. this.internalFileAttributes = input[ip++] | input[ip++] << 8;
  3314. this.externalFileAttributes = input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24;
  3315. this.relativeOffset = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3316. this.filename = String.fromCharCode.apply(null, USE_TYPEDARRAY ? input.subarray(ip, ip += this.fileNameLength) : input.slice(ip, ip += this.fileNameLength));
  3317. this.extraField = USE_TYPEDARRAY ? input.subarray(ip, ip += this.extraFieldLength) : input.slice(ip, ip += this.extraFieldLength);
  3318. this.comment = USE_TYPEDARRAY ? input.subarray(ip, ip + this.fileCommentLength) : input.slice(ip, ip + this.fileCommentLength);
  3319. this.length = ip - this.offset
  3320. };
  3321. Zlib.Unzip.LocalFileHeader = function(input, ip) {
  3322. this.input = input;
  3323. this.offset = ip;
  3324. this.length;
  3325. this.needVersion;
  3326. this.flags;
  3327. this.compression;
  3328. this.time;
  3329. this.date;
  3330. this.crc32;
  3331. this.compressedSize;
  3332. this.plainSize;
  3333. this.fileNameLength;
  3334. this.extraFieldLength;
  3335. this.filename;
  3336. this.extraField
  3337. };
  3338. Zlib.Unzip.LocalFileHeader.Flags = Zlib.Zip.Flags;
  3339. Zlib.Unzip.LocalFileHeader.prototype.parse = function() {
  3340. var input = this.input;
  3341. var ip = this.offset;
  3342. if(input[ip++] !== Zlib.Unzip.LocalFileHeaderSignature[0] || input[ip++] !== Zlib.Unzip.LocalFileHeaderSignature[1] || input[ip++] !== Zlib.Unzip.LocalFileHeaderSignature[2] || input[ip++] !== Zlib.Unzip.LocalFileHeaderSignature[3]) {
  3343. throw new Error("invalid local file header signature");
  3344. }
  3345. this.needVersion = input[ip++] | input[ip++] << 8;
  3346. this.flags = input[ip++] | input[ip++] << 8;
  3347. this.compression = input[ip++] | input[ip++] << 8;
  3348. this.time = input[ip++] | input[ip++] << 8;
  3349. this.date = input[ip++] | input[ip++] << 8;
  3350. this.crc32 = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3351. this.compressedSize = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3352. this.plainSize = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3353. this.fileNameLength = input[ip++] | input[ip++] << 8;
  3354. this.extraFieldLength = input[ip++] | input[ip++] << 8;
  3355. this.filename = String.fromCharCode.apply(null, USE_TYPEDARRAY ? input.subarray(ip, ip += this.fileNameLength) : input.slice(ip, ip += this.fileNameLength));
  3356. this.extraField = USE_TYPEDARRAY ? input.subarray(ip, ip += this.extraFieldLength) : input.slice(ip, ip += this.extraFieldLength);
  3357. this.length = ip - this.offset
  3358. };
  3359. Zlib.Unzip.prototype.searchEndOfCentralDirectoryRecord = function() {
  3360. var input = this.input;
  3361. var ip;
  3362. for(ip = input.length - 12;ip > 0;--ip) {
  3363. if(input[ip] === Zlib.Unzip.CentralDirectorySignature[0] && input[ip + 1] === Zlib.Unzip.CentralDirectorySignature[1] && input[ip + 2] === Zlib.Unzip.CentralDirectorySignature[2] && input[ip + 3] === Zlib.Unzip.CentralDirectorySignature[3]) {
  3364. this.eocdrOffset = ip;
  3365. return
  3366. }
  3367. }
  3368. throw new Error("End of Central Directory Record not found");
  3369. };
  3370. Zlib.Unzip.prototype.parseEndOfCentralDirectoryRecord = function() {
  3371. var input = this.input;
  3372. var ip;
  3373. if(!this.eocdrOffset) {
  3374. this.searchEndOfCentralDirectoryRecord()
  3375. }
  3376. ip = this.eocdrOffset;
  3377. if(input[ip++] !== Zlib.Unzip.CentralDirectorySignature[0] || input[ip++] !== Zlib.Unzip.CentralDirectorySignature[1] || input[ip++] !== Zlib.Unzip.CentralDirectorySignature[2] || input[ip++] !== Zlib.Unzip.CentralDirectorySignature[3]) {
  3378. throw new Error("invalid signature");
  3379. }
  3380. this.numberOfThisDisk = input[ip++] | input[ip++] << 8;
  3381. this.startDisk = input[ip++] | input[ip++] << 8;
  3382. this.totalEntriesThisDisk = input[ip++] | input[ip++] << 8;
  3383. this.totalEntries = input[ip++] | input[ip++] << 8;
  3384. this.centralDirectorySize = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3385. this.centralDirectoryOffset = (input[ip++] | input[ip++] << 8 | input[ip++] << 16 | input[ip++] << 24) >>> 0;
  3386. this.commentLength = input[ip++] | input[ip++] << 8;
  3387. this.comment = USE_TYPEDARRAY ? input.subarray(ip, ip + this.commentLength) : input.slice(ip, ip + this.commentLength)
  3388. };
  3389. Zlib.Unzip.prototype.parseFileHeader = function() {
  3390. var filelist = [];
  3391. var filetable = {};
  3392. var ip;
  3393. var fileHeader;
  3394. var i;
  3395. var il;
  3396. if(this.fileHeaderList) {
  3397. return
  3398. }
  3399. if(this.centralDirectoryOffset === void 0) {
  3400. this.parseEndOfCentralDirectoryRecord()
  3401. }
  3402. ip = this.centralDirectoryOffset;
  3403. for(i = 0, il = this.totalEntries;i < il;++i) {
  3404. fileHeader = new Zlib.Unzip.FileHeader(this.input, ip);
  3405. fileHeader.parse();
  3406. ip += fileHeader.length;
  3407. filelist[i] = fileHeader;
  3408. filetable[fileHeader.filename] = i
  3409. }
  3410. if(this.centralDirectorySize < ip - this.centralDirectoryOffset) {
  3411. throw new Error("invalid file header size");
  3412. }
  3413. this.fileHeaderList = filelist;
  3414. this.filenameToIndex = filetable
  3415. };
  3416. Zlib.Unzip.prototype.getFileData = function(index, opt_params) {
  3417. opt_params = opt_params || {};
  3418. var input = this.input;
  3419. var fileHeaderList = this.fileHeaderList;
  3420. var localFileHeader;
  3421. var offset;
  3422. var length;
  3423. var buffer;
  3424. var crc32;
  3425. var key;
  3426. var i;
  3427. var il;
  3428. if(!fileHeaderList) {
  3429. this.parseFileHeader()
  3430. }
  3431. if(fileHeaderList[index] === void 0) {
  3432. throw new Error("wrong index");
  3433. }
  3434. offset = fileHeaderList[index].relativeOffset;
  3435. localFileHeader = new Zlib.Unzip.LocalFileHeader(this.input, offset);
  3436. localFileHeader.parse();
  3437. offset += localFileHeader.length;
  3438. length = localFileHeader.compressedSize;
  3439. if((localFileHeader.flags & Zlib.Unzip.LocalFileHeader.Flags.ENCRYPT) !== 0) {
  3440. if(!(opt_params["password"] || this.password)) {
  3441. throw new Error("please set password");
  3442. }
  3443. key = this.createDecryptionKey(opt_params["password"] || this.password);
  3444. for(i = offset, il = offset + 12;i < il;++i) {
  3445. this.decode(key, input[i])
  3446. }
  3447. offset += 12;
  3448. length -= 12;
  3449. for(i = offset, il = offset + length;i < il;++i) {
  3450. input[i] = this.decode(key, input[i])
  3451. }
  3452. }
  3453. switch(localFileHeader.compression) {
  3454. case Zlib.Unzip.CompressionMethod.STORE:
  3455. buffer = USE_TYPEDARRAY ? this.input.subarray(offset, offset + length) : this.input.slice(offset, offset + length);
  3456. break;
  3457. case Zlib.Unzip.CompressionMethod.DEFLATE:
  3458. buffer = (new Zlib.RawInflate(this.input, {"index":offset, "bufferSize":localFileHeader.plainSize})).decompress();
  3459. break;
  3460. default:
  3461. throw new Error("unknown compression type");
  3462. }
  3463. if(this.verify) {
  3464. crc32 = Zlib.CRC32.calc(buffer);
  3465. if(localFileHeader.crc32 !== crc32) {
  3466. throw new Error("wrong crc: file=0x" + localFileHeader.crc32.toString(16) + ", data=0x" + crc32.toString(16));
  3467. }
  3468. }
  3469. return buffer
  3470. };
  3471. Zlib.Unzip.prototype.getFilenames = function() {
  3472. var filenameList = [];
  3473. var i;
  3474. var il;
  3475. var fileHeaderList;
  3476. if(!this.fileHeaderList) {
  3477. this.parseFileHeader()
  3478. }
  3479. fileHeaderList = this.fileHeaderList;
  3480. for(i = 0, il = fileHeaderList.length;i < il;++i) {
  3481. filenameList[i] = fileHeaderList[i].filename
  3482. }
  3483. return filenameList
  3484. };
  3485. Zlib.Unzip.prototype.decompress = function(filename, opt_params) {
  3486. var index;
  3487. if(!this.filenameToIndex) {
  3488. this.parseFileHeader()
  3489. }
  3490. index = this.filenameToIndex[filename];
  3491. if(index === void 0) {
  3492. throw new Error(filename + " not found");
  3493. }
  3494. return this.getFileData(index, opt_params)
  3495. };
  3496. Zlib.Unzip.prototype.setPassword = function(password) {
  3497. this.password = password
  3498. };
  3499. Zlib.Unzip.prototype.decode = function(key, n) {
  3500. n ^= this.getByte((key));
  3501. this.updateKeys((key), n);
  3502. return n
  3503. };
  3504. Zlib.Unzip.prototype.updateKeys = Zlib.Zip.prototype.updateKeys;
  3505. Zlib.Unzip.prototype.createDecryptionKey = Zlib.Zip.prototype.createEncryptionKey;
  3506. Zlib.Unzip.prototype.getByte = Zlib.Zip.prototype.getByte
  3507. });
  3508. goog.provide("Zlib");
  3509. goog.scope(function() {
  3510. Zlib.CompressionMethod = {DEFLATE:8, RESERVED:15}
  3511. });
  3512. goog.provide("Zlib.Deflate");
  3513. goog.require("USE_TYPEDARRAY");
  3514. goog.require("Zlib");
  3515. goog.require("Zlib.Adler32");
  3516. goog.require("Zlib.RawDeflate");
  3517. goog.scope(function() {
  3518. Zlib.Deflate = function(input, opt_params) {
  3519. this.input = input;
  3520. this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.Deflate.DefaultBufferSize);
  3521. this.compressionType = Zlib.Deflate.CompressionType.DYNAMIC;
  3522. this.rawDeflate;
  3523. var rawDeflateOption = {};
  3524. var prop;
  3525. if(opt_params || !(opt_params = {})) {
  3526. if(typeof opt_params["compressionType"] === "number") {
  3527. this.compressionType = opt_params["compressionType"]
  3528. }
  3529. }
  3530. for(prop in opt_params) {
  3531. rawDeflateOption[prop] = opt_params[prop]
  3532. }
  3533. rawDeflateOption["outputBuffer"] = this.output;
  3534. this.rawDeflate = new Zlib.RawDeflate(this.input, rawDeflateOption)
  3535. };
  3536. Zlib.Deflate.DefaultBufferSize = 32768;
  3537. Zlib.Deflate.CompressionType = Zlib.RawDeflate.CompressionType;
  3538. Zlib.Deflate.compress = function(input, opt_params) {
  3539. return(new Zlib.Deflate(input, opt_params)).compress()
  3540. };
  3541. Zlib.Deflate.prototype.compress = function() {
  3542. var cm;
  3543. var cinfo;
  3544. var cmf;
  3545. var flg;
  3546. var fcheck;
  3547. var fdict;
  3548. var flevel;
  3549. var clevel;
  3550. var adler;
  3551. var error = false;
  3552. var output;
  3553. var pos = 0;
  3554. output = this.output;
  3555. cm = Zlib.CompressionMethod.DEFLATE;
  3556. switch(cm) {
  3557. case Zlib.CompressionMethod.DEFLATE:
  3558. cinfo = Math.LOG2E * Math.log(Zlib.RawDeflate.WindowSize) - 8;
  3559. break;
  3560. default:
  3561. throw new Error("invalid compression method");
  3562. }
  3563. cmf = cinfo << 4 | cm;
  3564. output[pos++] = cmf;
  3565. fdict = 0;
  3566. switch(cm) {
  3567. case Zlib.CompressionMethod.DEFLATE:
  3568. switch(this.compressionType) {
  3569. case Zlib.Deflate.CompressionType.NONE:
  3570. flevel = 0;
  3571. break;
  3572. case Zlib.Deflate.CompressionType.FIXED:
  3573. flevel = 1;
  3574. break;
  3575. case Zlib.Deflate.CompressionType.DYNAMIC:
  3576. flevel = 2;
  3577. break;
  3578. default:
  3579. throw new Error("unsupported compression type");
  3580. }
  3581. break;
  3582. default:
  3583. throw new Error("invalid compression method");
  3584. }
  3585. flg = flevel << 6 | fdict << 5;
  3586. fcheck = 31 - (cmf * 256 + flg) % 31;
  3587. flg |= fcheck;
  3588. output[pos++] = flg;
  3589. adler = Zlib.Adler32(this.input);
  3590. this.rawDeflate.op = pos;
  3591. output = this.rawDeflate.compress();
  3592. pos = output.length;
  3593. if(USE_TYPEDARRAY) {
  3594. output = new Uint8Array(output.buffer);
  3595. if(output.length <= pos + 4) {
  3596. this.output = new Uint8Array(output.length + 4);
  3597. this.output.set(output);
  3598. output = this.output
  3599. }
  3600. output = output.subarray(0, pos + 4)
  3601. }
  3602. output[pos++] = adler >> 24 & 255;
  3603. output[pos++] = adler >> 16 & 255;
  3604. output[pos++] = adler >> 8 & 255;
  3605. output[pos++] = adler & 255;
  3606. return output
  3607. }
  3608. });
  3609. goog.provide("Zlib.exportObject");
  3610. goog.require("Zlib");
  3611. goog.scope(function() {
  3612. Zlib.exportObject = function(enumString, exportKeyValue) {
  3613. var keys;
  3614. var key;
  3615. var i;
  3616. var il;
  3617. if(Object.keys) {
  3618. keys = Object.keys(exportKeyValue)
  3619. }else {
  3620. keys = [];
  3621. i = 0;
  3622. for(key in exportKeyValue) {
  3623. keys[i++] = key
  3624. }
  3625. }
  3626. for(i = 0, il = keys.length;i < il;++i) {
  3627. key = keys[i];
  3628. goog.exportSymbol(enumString + "." + key, exportKeyValue[key])
  3629. }
  3630. }
  3631. });
  3632. goog.provide("Zlib.InflateStream");
  3633. goog.require("USE_TYPEDARRAY");
  3634. goog.require("Zlib");
  3635. goog.require("Zlib.RawInflateStream");
  3636. goog.scope(function() {
  3637. Zlib.InflateStream = function(input) {
  3638. this.input = input === void 0 ? new (USE_TYPEDARRAY ? Uint8Array : Array) : input;
  3639. this.ip = 0;
  3640. this.rawinflate = new Zlib.RawInflateStream(this.input, this.ip);
  3641. this.method;
  3642. this.output = this.rawinflate.output
  3643. };
  3644. Zlib.InflateStream.prototype.decompress = function(input) {
  3645. var buffer;
  3646. var adler32;
  3647. if(input !== void 0) {
  3648. if(USE_TYPEDARRAY) {
  3649. var tmp = new Uint8Array(this.input.length + input.length);
  3650. tmp.set(this.input, 0);
  3651. tmp.set(input, this.input.length);
  3652. this.input = tmp
  3653. }else {
  3654. this.input = this.input.concat(input)
  3655. }
  3656. }
  3657. if(this.method === void 0) {
  3658. if(this.readHeader() < 0) {
  3659. return new (USE_TYPEDARRAY ? Uint8Array : Array)
  3660. }
  3661. }
  3662. buffer = this.rawinflate.decompress(this.input, this.ip);
  3663. if(this.rawinflate.ip !== 0) {
  3664. this.input = USE_TYPEDARRAY ? this.input.subarray(this.rawinflate.ip) : this.input.slice(this.rawinflate.ip);
  3665. this.ip = 0
  3666. }
  3667. return buffer
  3668. };
  3669. Zlib.InflateStream.prototype.readHeader = function() {
  3670. var ip = this.ip;
  3671. var input = this.input;
  3672. var cmf = input[ip++];
  3673. var flg = input[ip++];
  3674. if(cmf === void 0 || flg === void 0) {
  3675. return-1
  3676. }
  3677. switch(cmf & 15) {
  3678. case Zlib.CompressionMethod.DEFLATE:
  3679. this.method = Zlib.CompressionMethod.DEFLATE;
  3680. break;
  3681. default:
  3682. throw new Error("unsupported compression method");
  3683. }
  3684. if(((cmf << 8) + flg) % 31 !== 0) {
  3685. throw new Error("invalid fcheck flag:" + ((cmf << 8) + flg) % 31);
  3686. }
  3687. if(flg & 32) {
  3688. throw new Error("fdict flag is not supported");
  3689. }
  3690. this.ip = ip
  3691. }
  3692. });
  3693. goog.require("Zlib.Adler32");
  3694. goog.exportSymbol("Zlib.Adler32", Zlib.Adler32);
  3695. goog.exportSymbol("Zlib.Adler32.update", Zlib.Adler32.update);
  3696. goog.require("Zlib.CRC32");
  3697. goog.exportSymbol("Zlib.CRC32", Zlib.CRC32);
  3698. goog.exportSymbol("Zlib.CRC32.calc", Zlib.CRC32.calc);
  3699. goog.exportSymbol("Zlib.CRC32.update", Zlib.CRC32.update);
  3700. goog.require("Zlib.Deflate");
  3701. goog.require("Zlib.exportObject");
  3702. goog.exportSymbol("Zlib.Deflate", Zlib.Deflate);
  3703. goog.exportSymbol("Zlib.Deflate.compress", Zlib.Deflate.compress);
  3704. goog.exportSymbol("Zlib.Deflate.prototype.compress", Zlib.Deflate.prototype.compress);
  3705. Zlib.exportObject("Zlib.Deflate.CompressionType", {"NONE":Zlib.Deflate.CompressionType.NONE, "FIXED":Zlib.Deflate.CompressionType.FIXED, "DYNAMIC":Zlib.Deflate.CompressionType.DYNAMIC});
  3706. goog.require("Zlib.GunzipMember");
  3707. goog.exportSymbol("Zlib.GunzipMember", Zlib.GunzipMember);
  3708. goog.exportSymbol("Zlib.GunzipMember.prototype.getName", Zlib.GunzipMember.prototype.getName);
  3709. goog.exportSymbol("Zlib.GunzipMember.prototype.getData", Zlib.GunzipMember.prototype.getData);
  3710. goog.exportSymbol("Zlib.GunzipMember.prototype.getMtime", Zlib.GunzipMember.prototype.getMtime);
  3711. goog.require("Zlib.Gunzip");
  3712. goog.exportSymbol("Zlib.Gunzip", Zlib.Gunzip);
  3713. goog.exportSymbol("Zlib.Gunzip.prototype.decompress", Zlib.Gunzip.prototype.decompress);
  3714. goog.exportSymbol("Zlib.Gunzip.prototype.getMembers", Zlib.Gunzip.prototype.getMembers);
  3715. goog.require("Zlib.Gzip");
  3716. goog.exportSymbol("Zlib.Gzip", Zlib.Gzip);
  3717. goog.exportSymbol("Zlib.Gzip.prototype.compress", Zlib.Gzip.prototype.compress);
  3718. goog.require("Zlib.InflateStream");
  3719. goog.exportSymbol("Zlib.InflateStream", Zlib.InflateStream);
  3720. goog.exportSymbol("Zlib.InflateStream.prototype.decompress", Zlib.InflateStream.prototype.decompress);
  3721. goog.require("Zlib.Inflate");
  3722. goog.require("Zlib.exportObject");
  3723. goog.exportSymbol("Zlib.Inflate", Zlib.Inflate);
  3724. goog.exportSymbol("Zlib.Inflate.prototype.decompress", Zlib.Inflate.prototype.decompress);
  3725. Zlib.exportObject("Zlib.Inflate.BufferType", {"ADAPTIVE":Zlib.Inflate.BufferType.ADAPTIVE, "BLOCK":Zlib.Inflate.BufferType.BLOCK});
  3726. goog.require("Zlib.RawDeflate");
  3727. goog.require("Zlib.exportObject");
  3728. goog.exportSymbol("Zlib.RawDeflate", Zlib.RawDeflate);
  3729. goog.exportSymbol("Zlib.RawDeflate.prototype.compress", Zlib.RawDeflate.prototype.compress);
  3730. Zlib.exportObject("Zlib.RawDeflate.CompressionType", {"NONE":Zlib.RawDeflate.CompressionType.NONE, "FIXED":Zlib.RawDeflate.CompressionType.FIXED, "DYNAMIC":Zlib.RawDeflate.CompressionType.DYNAMIC});
  3731. goog.require("Zlib.RawInflateStream");
  3732. goog.exportSymbol("Zlib.RawInflateStream", Zlib.RawInflateStream);
  3733. goog.exportSymbol("Zlib.RawInflateStream.prototype.decompress", Zlib.RawInflateStream.prototype.decompress);
  3734. goog.require("Zlib.RawInflate");
  3735. goog.require("Zlib.exportObject");
  3736. goog.exportSymbol("Zlib.RawInflate", Zlib.RawInflate);
  3737. goog.exportSymbol("Zlib.RawInflate.prototype.decompress", Zlib.RawInflate.prototype.decompress);
  3738. Zlib.exportObject("Zlib.RawInflate.BufferType", {"ADAPTIVE":Zlib.RawInflate.BufferType.ADAPTIVE, "BLOCK":Zlib.RawInflate.BufferType.BLOCK});
  3739. goog.require("Zlib.Unzip");
  3740. goog.exportSymbol("Zlib.Unzip", Zlib.Unzip);
  3741. goog.exportSymbol("Zlib.Unzip.prototype.decompress", Zlib.Unzip.prototype.decompress);
  3742. goog.exportSymbol("Zlib.Unzip.prototype.getFilenames", Zlib.Unzip.prototype.getFilenames);
  3743. goog.exportSymbol("Zlib.Unzip.prototype.setPassword", Zlib.Unzip.prototype.setPassword);
  3744. goog.require("Zlib.Zip");
  3745. goog.require("Zlib.exportObject");
  3746. goog.exportSymbol("Zlib.Zip", Zlib.Zip);
  3747. goog.exportSymbol("Zlib.Zip.prototype.addFile", Zlib.Zip.prototype.addFile);
  3748. goog.exportSymbol("Zlib.Zip.prototype.compress", Zlib.Zip.prototype.compress);
  3749. goog.exportSymbol("Zlib.Zip.prototype.setPassword", Zlib.Zip.prototype.setPassword);
  3750. Zlib.exportObject("Zlib.Zip.CompressionMethod", {"STORE":Zlib.Zip.CompressionMethod.STORE, "DEFLATE":Zlib.Zip.CompressionMethod.DEFLATE});
  3751. Zlib.exportObject("Zlib.Zip.OperatingSystem", {"MSDOS":Zlib.Zip.OperatingSystem.MSDOS, "UNIX":Zlib.Zip.OperatingSystem.UNIX, "MACINTOSH":Zlib.Zip.OperatingSystem.MACINTOSH});
  3752. }).call(this);