diff --git a/Gruntfile.js b/Gruntfile.js index bf0dc9a..9bdcffe 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,23 +8,34 @@ module.exports = function(grunt) { '<%= grunt.template.today("yyyy-mm-dd") %> */' }, concat : { - 'build/epub.js': ['', 'src/*.js'], + 'build/epub.js': ['', 'libs/rsvp/rsvp.min.js', 'src/*.js'], 'build/reader.js': ['', 'reader/*.js'], 'build/hooks.js': ['', 'hooks/default/*.js'], 'demo/js/libs/fileStorage.min.js': 'libs/fileStorage/fileStorage.min.js', 'demo/js/libs/loader_filesystem.min.js': 'libs/fileStorage/workers/loader_filesystem.min.js', - 'demo/js/libs/jquery-1.9.0.min.js': 'libs/jquery/jquery-1.9.0.min.js' + 'demo/js/libs/jquery-1.9.0.min.js': 'libs/jquery/jquery-1.9.0.min.js', + 'demo/js/libs/inflate.js': 'libs/zip/inflate.js' }, - min: { - 'demo/js/epub.min.js': ['libs/underscore/underscore-min.js', 'libs/rsvp/rsvp.min.js', 'build/epub.js'], - 'demo/js/reader.min.js': 'build/reader.js', - 'demo/js/hooks.min.js': 'build/hooks.js', - 'demo/js/libs/zip.min.js': ['libs/zip/*.js'], - 'demo/js/libs/inflate.min.js': ['libs/zip/inflate.js'] + uglify: { + options: { + preserveComments: 'some' + }, + my_target: { + files: { + 'demo/js/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'], + 'demo/js/reader.min.js': 'build/reader.js', + 'demo/js/hooks.min.js': 'build/hooks.js', + 'demo/js/libs/zip.min.js': ['libs/zip/zip.js', 'libs/zip/zip-fs.js', 'libs/zip/zip-ext.js', 'libs/zip/mime-types.js'], + 'demo/js/libs/inflate.min.js': ['libs/zip/inflate.js'] + } + } } }); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + // Default task(s). - grunt.registerTask('default', ['concat', 'min']); + grunt.registerTask('default', ['concat', 'uglify']); }; diff --git a/build/epub.js b/build/epub.js index 0fea99b..7ef23cf 100644 --- a/build/epub.js +++ b/build/epub.js @@ -1,4 +1,4 @@ -/*! FuturePress - v0.1.0 - 2013-07-08 */ +(function(e){"use strict";function v(e,n){t.async(function(){e.trigger("promise:resolved",{detail:n}),e.isResolved=!0,e.resolvedValue=n})}function m(e,n){t.async(function(){e.trigger("promise:failed",{detail:n}),e.isRejected=!0,e.rejectedValue=n})}function g(e){var t,n=[],r=new h,i=e.length;i===0&&r.resolve([]);var s=function(e){return function(t){o(e,t)}},o=function(e,t){n[e]=t,--i===0&&r.resolve(n)},u=function(e){r.reject(e)};for(t=0;t 0) { part = sections.shift(); - + if(part.id){ - console.log(part.id) - element = cfi.doc.querySelector("#" + part.id); + + element = doc.querySelector("#" + part.id); + }else{ element = children[part.index]; @@ -1440,15 +1441,28 @@ EPUBJS.Parser.prototype.spine = function(spineXml, manifest){ } EPUBJS.Parser.prototype.toc = function(tocXml){ - var toc = []; - - var navMap = tocXml.querySelector("navMap"); - function getTOC(nodes, parent, list){ - var list = list || []; + var navMap = tocXml.querySelector("navMap"); - items = Array.prototype.slice.call(nodes); + function getTOC(parent){ + var list = [], + items = [], + nodes = parent.childNodes, + nodesArray = Array.prototype.slice.call(nodes), + length = nodesArray.length, + iter = length, + node; + + if(length == 0) return false; + + while(iter--){ + node = nodesArray[iter]; + if(node.nodeName === "navPoint") { + items.push(node); + } + } + items.forEach(function(item){ var id = item.getAttribute('id'), content = item.querySelector("content"), @@ -1456,23 +1470,21 @@ EPUBJS.Parser.prototype.toc = function(tocXml){ split = src.split("#"), navLabel = item.querySelector("navLabel"), text = navLabel.textContent ? navLabel.textContent : "", - subitems = item.querySelectorAll("navPoint"); - - - list.push({ + subitems = getTOC(item); + list.unshift({ "id": id, "href": src, "label": text, - "subitems" : subitems.length ? getTOC(item.querySelectorAll("navPoint"), item, list) : false + "subitems" : subitems }); }); return list; } - - - return getTOC(navMap.querySelectorAll("navPoint"), navMap); + + + return getTOC(navMap); } @@ -1647,7 +1659,7 @@ EPUBJS.Renderer.prototype.crossBrowserColumnCss = function(){ EPUBJS.Renderer.columnAxis = EPUBJS.core.prefixed('columnAxis'); EPUBJS.Renderer.columnGap = EPUBJS.core.prefixed('columnGap'); EPUBJS.Renderer.columnWidth = EPUBJS.core.prefixed('columnWidth'); - + EPUBJS.Renderer.transform = EPUBJS.core.prefixed('transform'); } @@ -1665,7 +1677,7 @@ EPUBJS.Renderer.prototype.setIframeSrc = function(url){ renderer.doc = renderer.iframe.contentDocument; renderer.docEl = renderer.doc.documentElement; renderer.bodyEl = renderer.doc.body; - + renderer.applyStyles(); renderer.formatSpread(); @@ -1714,7 +1726,7 @@ EPUBJS.Renderer.prototype.formatSpread = function(){ this.gap = this.gap || Math.ceil(this.elWidth / 8); - if(this.elWidth < cutoff || this.settings.single) { + if(this.elWidth < cutoff || !this.book.settings.spreads) { this.spread = false; //-- Single Page divisor = 1; @@ -1867,7 +1879,9 @@ EPUBJS.Renderer.prototype.chapterEnd = function(){ EPUBJS.Renderer.prototype.setLeft = function(leftPos){ // this.bodyEl.style.marginLeft = -leftPos + "px"; - this.doc.defaultView.scrollTo(leftPos, 0) + // this.docEl.style.marginLeft = -leftPos + "px"; + // this.docEl.style[EPUBJS.Renderer.transform] = 'translate('+ (-leftPos) + 'px, 0)'; + this.doc.defaultView.scrollTo(leftPos, 0); } EPUBJS.Renderer.prototype.replace = function(query, func, callback){ @@ -2056,9 +2070,14 @@ EPUBJS.Renderer.prototype.replaceLinks = function(callback){ links.forEach(function(link){ var path, href = link.getAttribute("href"), - relative = href.search("://"), - fragment = href[0] == "#"; - + relative, + fragment; + + if(!href) return; + + relative = href.search("://"), + fragment = href[0] == "#"; + if(relative != -1){ link.setAttribute("target", "_blank"); @@ -2067,10 +2086,10 @@ EPUBJS.Renderer.prototype.replaceLinks = function(callback){ link.onclick = function(){ that.book.goto(href); + return false; } } - }); if(callback) callback(); @@ -2273,7 +2292,7 @@ RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype); EPUBJS.Unarchiver = function(url){ - this.libPath = EPUBJS.filePath + "zip/"; + this.libPath = EPUBJS.filePath; this.zipUrl = url; this.loadLib() this.urlCache = {}; diff --git a/build/hooks.js b/build/hooks.js index f2ad3e1..e158d42 100644 --- a/build/hooks.js +++ b/build/hooks.js @@ -1,5 +1,3 @@ -/*! FuturePress - v0.1.0 - 2013-07-08 */ - EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chapter){ var notes = chapter.doc.querySelectorAll('a[href]'), @@ -8,10 +6,9 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap type = "noteref", popups = {}; + EPUBJS.core.addCss("../demo/css/popup.css", false, chapter.doc.head); - // EPUBJS.core.addCss("css/popup.css", false, chapter.doc.head); - //console.log("notes", items) items.forEach(function(item){ var epubType = item.getAttribute(attr), href, @@ -24,7 +21,7 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap txt; if(epubType != type) return; - + href = item.getAttribute("href"); id = href.replace("#", ''); el = chapter.doc.getElementById(id); @@ -63,11 +60,13 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap //-- TODO: will these leak memory? - Fred popups[id].addEventListener("mouseover", onPop, false); popups[id].addEventListener("mouseout", offPop, false); - + //-- Add hide on page change - chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", hidePop); - chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", offPop); - + // chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", hidePop); + // chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", offPop); + chapter.book.on("book:pageChanged", hidePop, this); + chapter.book.on("book:pageChanged", offPop, this); + // chapter.book.on("book:chapterDestroy", hidePop, this); } pop = popups[id]; @@ -77,7 +76,7 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap itemRect = item.getBoundingClientRect(); left = itemRect.left; top = itemRect.top; - + //-- show the popup pop.classList.add("show"); diff --git a/build/reader.js b/build/reader.js index bacc1eb..7341939 100644 --- a/build/reader.js +++ b/build/reader.js @@ -1,5 +1,3 @@ -/*! FuturePress - v0.1.0 - 2013-07-08 */ - var EPUBJSR = EPUBJSR || {}; EPUBJSR.app = {}; @@ -64,6 +62,7 @@ EPUBJSR.app.init = (function($){ controls(); }); + return Book; } diff --git a/demo/index.html b/demo/index.html index ee0ab9b..9909e7d 100755 --- a/demo/index.html +++ b/demo/index.html @@ -14,6 +14,8 @@ + + + diff --git a/demo/js/epub.min.js b/demo/js/epub.min.js index a2632f4..121068e 100644 --- a/demo/js/epub.min.js +++ b/demo/js/epub.min.js @@ -1 +1,2 @@ -(function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){return e instanceof x?e:this instanceof x?(this._wrapped=e,void 0):new x(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.4.4";var T=x.each=x.forEach=function(e,t,r){if(null!=e)if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;s>i;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(x.has(e,o)&&t.call(r,e[o],o,e)===n)return};x.map=x.collect=function(e,t,n){var r=[];return null==e?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r[r.length]=t.call(n,e,i,s)}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;if(null==e&&(e=[]),p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);if(T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)}),!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;if(null==e&&(e=[]),d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}if(T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)}),!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){return t.call(n,e,i,s)?(r=e,!0):void 0}),r},x.filter=x.select=function(e,t,n){var r=[];return null==e?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return null==e?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){return(i=i&&t.call(r,e,s,o))?void 0:n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return null==e?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){return i||(i=t.call(r,e,s,o))?n:void 0}),!!i)};x.contains=x.include=function(e,t){return null==e?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,function(e){return e[t]})},x.where=function(e,t,n){return x.isEmpty(t)?n?null:[]:x[n?"find":"filter"](e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},x.findWhere=function(e,t){return x.where(e,t,!0)},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.max.apply(Math,e);if(!t&&x.isEmpty(e))return-1/0;var r={computed:-1/0,value:-1/0};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.min.apply(Math,e);if(!t&&x.isEmpty(e))return 1/0;var r={computed:1/0,value:1/0};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;r.computed>o&&(r={value:e,computed:o})}),r.value},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return x.isFunction(e)?e:function(t){return t[e]}};x.sortBy=function(e,t,n){var r=k(t);return x.pluck(x.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(r>n||r===void 0)return-1}return e.indexs;){var u=s+o>>>1;i>n.call(r,e[u])?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return null==e?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:u.call(e,0,t)},x.initial=function(e,t,n){return u.call(e,0,e.length-(null==t||n?1:t))},x.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:u.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,null==t||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n){return T(e,function(e){x.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};x.flatten=function(e,t){return A(e,t,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.uniq=x.unique=function(e,t,n,r){x.isFunction(t)&&(r=n,n=t,t=!1);var i=n?x.map(e,n,r):e,s=[],o=[];return T(i,function(n,r){(t?r&&o[o.length-1]===n:x.contains(o,n))||(o.push(n),s.push(e[r]))}),s},x.union=function(){return x.uniq(a.apply(r,arguments))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.indexOf(t,e)>=0})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){for(var e=u.call(arguments),t=x.max(x.pluck(e,"length")),n=Array(t),r=0;t>r;r++)n[r]=x.pluck(e,""+r);return n},x.object=function(e,t){if(null==e)return{};for(var n={},r=0,i=e.length;i>r;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(null==e)return-1;var r=0,i=e.length;if(n){if("number"!=typeof n)return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=0>n?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;i>r;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(null==e)return-1;var r=null!=n;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);for(var i=r?n:e.length;i--;)if(e[i]===t)return i;return-1},x.range=function(e,t,n){1>=arguments.length&&(t=e||0,e=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=Array(r);r>i;)s[i++]=e,e+=n;return s},x.bind=function(e,t){if(e.bind===S&&S)return S.apply(e,u.call(arguments,1));var n=u.call(arguments,2);return function(){return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){return e.apply(this,t.concat(u.call(arguments)))}},x.bindAll=function(e){var t=u.call(arguments,1);return 0===t.length&&(t=x.functions(e)),T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t){var n,r,i,s,o=0,u=function(){o=new Date,i=null,s=e.apply(n,r)};return function(){var a=new Date,f=t-(a-o);return n=this,r=arguments,0>=f?(clearTimeout(i),i=null,o=a,s=e.apply(n,r)):i||(i=setTimeout(u,f)),s}},x.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},x.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},x.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},x.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return 0>=e?t():function(){return 1>--e?t.apply(this,arguments):void 0}},x.keys=E||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)x.has(e,n)&&(t[t.length]=n);return t},x.values=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push(e[n]);return t},x.pairs=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push([n,e[n]]);return t},x.invert=function(e){var t={};for(var n in e)x.has(e,n)&&(t[e[n]]=n);return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)null==e[n]&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var O=function(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==t+"";case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var s=n.length;s--;)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if("[object Array]"==i){if(o=e.length,u=o==t.length)for(;o--&&(u=O(e[o],t[o],n,r)););}else{var a=e.constructor,l=t.constructor;if(a!==l&&!(x.isFunction(a)&&a instanceof a&&x.isFunction(l)&&l instanceof l))return!1;for(var c in e)if(x.has(e,c)&&(o++,!(u=x.has(t,c)&&O(e[c],t[c],n,r))))break;if(u){for(c in t)if(x.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};x.isEqual=function(e,t){return O(e,t,[],[])},x.isEmpty=function(e){if(null==e)return!0;if(x.isArray(e)||x.isString(e))return 0===e.length;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&1===e.nodeType},x.isArray=w||function(e){return"[object Array]"==f.call(e)},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),"function"!=typeof /./&&(x.isFunction=function(e){return"function"==typeof e}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==f.call(e)},x.isNull=function(e){return null===e},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.times=function(e,t,n){for(var r=Array(e),i=0;e>i;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=x.invert(M.escape);var _={escape:RegExp("["+x.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+x.keys(M.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return null==t?"":(""+t).replace(_[e],function(t){return M[e][t]})}}),x.result=function(e,t){if(null==e)return null;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),j.call(this,n.apply(x,e))}})};var D=0;x.uniqueId=function(e){var t=++D+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,H={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=RegExp([(n.escape||P).source,(n.interpolate||P).source,(n.evaluate||P).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(B,function(e){return"\\"+H[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var j=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!=e&&"splice"!=e||0!==n.length||delete n[0],j.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return j.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this),function(e){"use strict";function t(e,t){s.async(function(){e.trigger("promise:resolved",{detail:t}),e.isResolved=!0,e.resolvedValue=t})}function n(e,t){s.async(function(){e.trigger("promise:failed",{detail:t}),e.isRejected=!0,e.rejectedValue=t})}function r(e){var t,n=[],r=new m,i=e.length;i===0&&r.resolve([]);var s=function(e){return function(t){o(e,t)}},o=function(e,t){n[e]=t,--i===0&&r.resolve(n)},u=function(e){r.reject(e)};for(t=0;t=this.spine.length?!1:s<0?!1:(this.spinePos=s,this.chapter=new EPUBJS.Chapter(this.spine[s]),r=n.render.chapter(this.chapter),i?r.then(function(t){t.currentLocationCfi=e,t.gotoCfiFragment(i)}):t&&r.then(function(e){e.gotoChapterEnd()}),!this.settings.fromStorage&&!this.settings.contained&&r.then(function(){n.preloadNextChapter()}),r)},EPUBJS.Book.prototype.nextPage=function(){var e=this.render.nextPage();if(!e)return this.nextChapter()},EPUBJS.Book.prototype.prevPage=function(){var e=this.render.prevPage();if(!e)return this.prevChapter()},EPUBJS.Book.prototype.nextChapter=function(){return this.spinePos++,this.displayChapter(this.spinePos)},EPUBJS.Book.prototype.prevChapter=function(){return this.spinePos--,this.displayChapter(this.spinePos,!0)},EPUBJS.Book.prototype.goto=function(e){var t=e.split("#"),n=t[0],r=t[1]||!1,i=n.search("://")==-1?this.settings.contentsPath+n:n,s=this.spineIndexByURL[i],o;return n||(s=this.chapter.spinePos),typeof s!="number"?!1:s!=this.chapter.spinePos||!this.chapter?this.displayChapter(s).then(function(){r&&o.render.section(r)}):(r&&this.render.section(r),(new RSVP.Promise).resolve(this.currentChapter))},EPUBJS.Book.prototype.preloadNextChapter=function(){var e=document.createElement("iframe");next;if(this.spinePos>=this.spine.length)return!1;next=new EPUBJS.Chapter(this.spine[this.spinePos+1]),EPUBJS.core.request(next.href)},EPUBJS.Book.prototype.storeOffline=function(){var e=this,t=_.values(this.manifest);return EPUBJS.storage.batch(t).then(function(){e.settings.stored=!0,e.trigger("book:stored")})},EPUBJS.Book.prototype.availableOffline=function(){return this.settings.stored>0?!0:!1},EPUBJS.Book.prototype.setStyle=function(e,t,n){this.renderer.setStyle(e,t,n),this.settings.styles[e]=t},EPUBJS.Book.prototype.removeStyle=function(e,t,n){this.renderer.removeStyle(e),delete this.settings.styles[e]},EPUBJS.Book.prototype.getHooks=function(){var e=this,t;plugTypes=_.values(this.hooks);for(plugType in this.hooks)t=_.values(EPUBJS.Hooks[plugType]),t.forEach(function(t){e.registerHook(plugType,t)})},EPUBJS.Book.prototype.registerHook=function(e,t,n){var r=this;typeof this.hooks[e]!="undefined"?typeof t=="function"?n?this.hooks[e].unshift(t):this.hooks[e].push(t):Array.isArray(t)&&t.forEach(function(t){n?r.hooks[e].unshift(t):r.hooks[e].push(t)}):this.hooks[e]=[func]},EPUBJS.Book.prototype.triggerHooks=function(e,t,n){function s(){i--,i<=0&&t&&t()}var r,i;if(typeof this.hooks[e]=="undefined")return!1;r=this.hooks[e],i=r.length,r.forEach(function(e){e(s,n)})},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),EPUBJS.Chapter=function(e){this.href=e.href,this.id=e.id,this.spinePos=e.index,this.properties=e.properties,this.linear=e.linear,this.pages=1},EPUBJS.Chapter.prototype.contents=function(e){return e?e.get(href):EPUBJS.core.request(href,"xml")},EPUBJS.Chapter.prototype.url=function(e){var t=new RSVP.Promise;return e?(this.tempUrl||(this.tempUrl=e.getUrl(this.href)),this.tempUrl):(t.resolve(this.href),t)},EPUBJS.Chapter.prototype.setPages=function(e){this.pages=e},EPUBJS.Chapter.prototype.getPages=function(e){return this.pages},EPUBJS.Chapter.prototype.getID=function(){return this.ID},EPUBJS.Chapter.prototype.unload=function(e){this.tempUrl&&e&&(e.revokeUrl(this.tempUrl),this.tempUrl=!1)};var EPUBJS=EPUBJS||{};EPUBJS.core={},EPUBJS.core.getEl=function(e){return document.getElementById(e)},EPUBJS.core.getEls=function(e){return document.getElementsByClassName(e)},EPUBJS.core.request=function(e,t){function i(){if(this.readyState===this.DONE)if(this.status===200||this.responseXML){var e;t=="xml"?e=this.responseXML:t=="json"?e=JSON.parse(this.response):e=this.response,n.resolve(e)}else n.reject(this)}var n=new RSVP.Promise,r=new XMLHttpRequest;return r.open("GET",e),r.onreadystatechange=i,t=="blob"&&(r.responseType=t),t=="json"&&r.setRequestHeader("Accept","application/json"),t=="xml"&&r.overrideMimeType("text/xml"),r.send(),n},EPUBJS.core.toArray=function(e){var t=[];for(member in e){var n;e.hasOwnProperty(member)&&(n=e[member],n.ident=member,t.push(n))}return t},EPUBJS.core.folder=function(e){var t=e.lastIndexOf("/"),n=e.slice(0,t+1);return n},EPUBJS.core.dataURLToBlob=function(e){var t=";base64,";if(e.indexOf(t)==-1){var n=e.split(","),r=n[0].split(":")[1],i=n[1];return new Blob([i],{type:r})}var n=e.split(t),r=n[0].split(":")[1],i=window.atob(n[1]),s=i.length,o=new Uint8Array(s);for(var u=0;u0)u=n.shift(),u.id?(console.log(u.id),r=e.doc.querySelector("#"+u.id)):(r=i[u.index],i||console.error("No Kids",r)),r||console.error("No Element For",u),i=Array.prototype.slice.call(r.children);return r},EPUBJS.Events=function(e,t){return this.events={},t?this.el=t:this.el=document.createElement("div"),e.createEvent=this.createEvent,e.tell=this.tell,e.listen=this.listen,e.deafen=this.deafen,e.listenUntil=this.listenUntil,this},EPUBJS.Events.prototype.createEvent=function(e){var t=new CustomEvent(e);return this.events[e]=t,t},EPUBJS.Events.prototype.tell=function(e,t){var n;this.events[e]?n=this.events[e]:(console.warn("No event:",e,"defined yet, creating."),n=this.createEvent(e)),t&&(n.msg=t),this.el.dispatchEvent(n)},EPUBJS.Events.prototype.listen=function(e,t,n){if(!this.events[e]){console.warn("No event:",e,"defined yet, creating."),this.createEvent(e);return}n?this.el.addEventListener(e,t.bind(n),!1):this.el.addEventListener(e,t,!1)},EPUBJS.Events.prototype.deafen=function(e,t){this.el.removeEventListener(e,t,!1)},EPUBJS.Events.prototype.listenUntil=function(e,t,n,r){function i(){this.deafen(e,n),this.deafen(t,i)}this.listen(e,n,r),this.listen(t,i,this)},EPUBJS.Hooks=function(){"use strict";return{register:function(e){this[e]===undefined&&(this[e]={});if(typeof this[e]!="object")throw"Already registered: "+e;return this[e]}}}(),EPUBJS.Parser=function(e){this.baseUrl=e||""},EPUBJS.Parser.prototype.container=function(e){var t=e.querySelector("rootfile"),n=t.getAttribute("full-path"),r=EPUBJS.core.folder(n);return{packagePath:n,basePath:r}},EPUBJS.Parser.prototype.package=function(e,t){var n=this;t&&(this.baseUrl=t);var r=e.querySelector("metadata"),i=e.querySelector("manifest"),s=e.querySelector("spine"),o=n.manifest(i),u=n.findTocPath(i),a=n.findCoverPath(i),f=Array.prototype.indexOf.call(s.parentNode.childNodes,s),l=n.spine(s,o),c={};return l.forEach(function(e){c[e.href]=e.index}),{metadata:n.metadata(r),spine:l,manifest:o,tocPath:u,coverPath:a,spineNodeIndex:f,spineIndexByURL:c}},EPUBJS.Parser.prototype.findTocPath=function(e){var t=e.querySelector("item[media-type='application/x-dtbncx+xml']");return t?t.getAttribute("href"):!1},EPUBJS.Parser.prototype.findCoverPath=function(e){var t=e.querySelector("item[properties='cover-image']");return t?t.getAttribute("href"):!1},EPUBJS.Parser.prototype.metadata=function(e){var t={},n=this;return t.bookTitle=n.getElement(e,"title"),t.creator=n.getElement(e,"creator"),t.description=n.getElement(e,"description"),t.pubdate=n.getElement(e,"date"),t.publisher=n.getElement(e,"publisher"),t.identifier=n.getElement(e,"identifier"),t.language=n.getElement(e,"language"),t.rights=n.getElement(e,"rights"),t.modified_date=n.querySelector(e,"meta[property='dcterms:modified']"),t.layout=n.querySelector(e,"meta[property='rendition:orientation']"),t.orientation=n.querySelector(e,"meta[property='rendition:orientation']"),t.spread=n.querySelector(e,"meta[property='rendition:spread']"),t},EPUBJS.Parser.prototype.getElement=function(e,t){var n=e.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",t),r;return n?(r=n[0],r?r.childNodes[0].nodeValue:""):""},EPUBJS.Parser.prototype.querySelector=function(e,t){var n=e.querySelector(t);return n?n.childNodes[0].nodeValue:""},EPUBJS.Parser.prototype.manifest=function(e){var t=this.baseUrl,n={},r=e.querySelectorAll("item"),i=Array.prototype.slice.call(r);return i.forEach(function(e){var r=e.getAttribute("id"),i=e.getAttribute("href")||"",s=e.getAttribute("media-type")||"";n[r]={href:t+i,type:s}}),n},EPUBJS.Parser.prototype.spine=function(e,t){var n=[],r=e.getElementsByTagName("itemref"),i=Array.prototype.slice.call(r);return i.forEach(function(e,r){var i=e.getAttribute("idref"),s={id:i,linear:e.getAttribute("linear")||"",properties:e.getAttribute("properties")||"",href:t[i].href,index:r};n.push(s)}),n},EPUBJS.Parser.prototype.toc=function(e){function r(e,t,n){var n=n||[];return items=Array.prototype.slice.call(e),items.forEach(function(e){var t=e.getAttribute("id"),i=e.querySelector("content"),s=i.getAttribute("src"),o=s.split("#"),u=e.querySelector("navLabel"),a=u.textContent?u.textContent:"",f=e.querySelectorAll("navPoint");n.push({id:t,href:s,label:a,subitems:f.length?r(e.querySelectorAll("navPoint"),e,n):!1})}),n}var t=[],n=e.querySelector("navMap");return r(n.querySelectorAll("navPoint"),n)},EPUBJS.Renderer=function(e){var t=e.settings.element;this.book=e,this.settings=e.settings;if(_.isElement(t))this.el=t;else{if(typeof t!="string"){console.error("Not an Element");return}this.el=EPUBJS.core.getEl(t)}e.registerHook("beforeChapterDisplay",[this.replaceLinks.bind(this),this.replaceResources.bind(this),this.replaceHead.bind(this)],!0),this.crossBrowserColumnCss(),this.epubcfi=new EPUBJS.EpubCFI,this.initialize(),this.listeners()},EPUBJS.Renderer.prototype.initialize=function(){this.iframe=document.createElement("iframe"),this.resizeIframe(!1,this.el.clientWidth,this.el.clientHeight),this.on("book:resized",this.resizeIframe,this),this.el.appendChild(this.iframe)},EPUBJS.Renderer.prototype.listeners=function(){this.resized=_.debounce(this.onResized.bind(this),10),window.addEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.chapter=function(e){var t=this,n=!1;return this.book.settings.contained&&(n=this.book.zip),this.currentChapter&&(this.currentChapter.unload(),this.trigger("book:chapterDestroyed")),this.currentChapter=e,this.chapterPos=1,this.pageIds={},this.leftPos=0,this.currentChapterCfi=this.epubcfi.generateChapter(this.book.spineNodeIndex,e.spinePos,e.id),this.visibileEl=!1,e.url(n).then(function(e){return t.setIframeSrc(e)})},EPUBJS.Renderer.prototype.onResized=function(){this.trigger("book:resized",{width:this.el.clientWidth,height:this.el.clientHeight}),this.reformat()},EPUBJS.Renderer.prototype.reformat=function(){var e=this;this.formatSpread(),setTimeout(function(){e.calcPages(),e.currentLocationCfi&&e.gotoCfiFragment(e.currentLocationCfi)},10)},EPUBJS.Renderer.prototype.destroy=function(){window.removeEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.resizeIframe=function(e,t,n){var r,i;e?(r=e.width,i=e.height):(r=t,i=n),this.iframe.height=i,r%2!=0&&(r+=1),this.iframe.width=r},EPUBJS.Renderer.prototype.crossBrowserColumnCss=function(){EPUBJS.Renderer.columnAxis=EPUBJS.core.prefixed("columnAxis"),EPUBJS.Renderer.columnGap=EPUBJS.core.prefixed("columnGap"),EPUBJS.Renderer.columnWidth=EPUBJS.core.prefixed("columnWidth")},EPUBJS.Renderer.prototype.setIframeSrc=function(e){var t=this,n=new RSVP.Promise;return this.visible(!1),this.iframe.src=e,this.iframe.onload=function(){t.doc=t.iframe.contentDocument,t.docEl=t.doc.documentElement,t.bodyEl=t.doc.body,t.applyStyles(),t.formatSpread(),t.beforeDisplay(function(){t.calcPages(),n.resolve(t),t.currentLocationCfi=t.getPageCfi(),t.trigger("book:chapterDisplayed"),t.visible(!0)})},n},EPUBJS.Renderer.prototype.formatSpread=function(){var e=2,t=800;this.colWidth&&(this.OldcolWidth=this.colWidth,this.OldspreadWidth=this.spreadWidth),this.elWidth=this.iframe.width,this.gap=this.gap||Math.ceil(this.elWidth/8),this.elWidth1?(this.chapterPos--,this.leftPos-=this.spreadWidth,this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.trigger("book:pageChanged",this.currentLocationCfi),this.chapterPos):!1},EPUBJS.Renderer.prototype.chapterEnd=function(){this.page(this.displayedPages),this.currentLocationCfi=this.getPageCfi()},EPUBJS.Renderer.prototype.setLeft=function(e){this.doc.defaultView.scrollTo(e,0)},EPUBJS.Renderer.prototype.replace=function(e,t,n){var r,i,s;r=this.doc.querySelectorAll(e),i=Array.prototype.slice.call(r),s=i.length,i.forEach(function(e){t(e,function(){s--,s<=0&&n&&n()})}.bind(this)),s===0&&n()},EPUBJS.Renderer.prototype.determineStore=function(e){return this.book.fromStorage?this.book.storage.getStorageType()=="filesystem"?!1:this.book.store:this.book.contained?this.book.zip:!1},EPUBJS.Renderer.prototype.replaceHead=function(e){var t,n,r,i,s={},o=this,u=this.determineStore(),a=function(e,t){e.setAttribute("href",t),e.onload=function(){r--,r<=0&&f()}},f=function(){e&&e(),_.each(i,function(e){u.revokeUrl(e)}),o.urlCache=s};if(!u)return e&&e(),!1;t=this.doc.head.querySelectorAll("[href]"),n=Array.prototype.slice.call(t),r=n.length,this.urlCache||(this.urlCache={}),i=_.clone(this.urlCache),n.forEach(function(e){var t=e.getAttribute("href"),n=this.book.settings.contentsPath+t;n in i?(a(e,i[n]),s[n]=i[n],delete i[n]):e.getAttribute("rel")==="stylesheet"?u.getText(n).then(function(t){var r;o.replaceUrlsInCss(n,t).then(function(t){var r=window.URL||window.webkitURL||window.mozURL,i=new Blob([t],{type:"text/css"}),o=r.createObjectURL(i);a(e,o),s[n]=o},function(e){console.error(e)})}):u.getUrl(n).then(function(t){a(e,t),s[n]=t})}.bind(this)),r===0&&f()},EPUBJS.Renderer.prototype.replaceUrlsInCss=function(e,t){var n=new RSVP.Promise,r=[],i=this.determineStore(),s=t.match(/url\(\'?\"?([^\'|^\"]*)\'?\"?\)/g);return s.forEach(function(n){var s=EPUBJS.core.resolveUrl(e,n.replace(/url\(|[|\)|\'|\"]/g,""));replaced=i.getUrl(s).then(function(e){t=t.replace(n,'url("'+e+'")')},function(e){console.error(e)}),r.push(replaced)}),RSVP.all(r).then(function(){n.resolve(t)}),n},EPUBJS.Renderer.prototype.replaceLinks=function(e){var t=this.doc.querySelectorAll("a"),n=Array.prototype.slice.call(t),r=this;n.forEach(function(e){var t,n=e.getAttribute("href"),i=n.search("://"),s=n[0]=="#";i!=-1?e.setAttribute("target","_blank"):e.onclick=function(){r.book.goto(n)}}),e&&e()},EPUBJS.Renderer.prototype.replaceResources=function(e){var t,n,r,i=this.determineStore();if(!i)return e&&e(),!1;t=this.doc.querySelectorAll("[src]"),n=Array.prototype.slice.call(t),r=n.length,n.forEach(function(t){var n=t.getAttribute("src"),s=this.book.settings.contentsPath+n;i.getUrl(s).then(function(n){t.src=n,t.onload=function(){r--,r<=0&&e&&e()}})}.bind(this)),r===0&&e()},EPUBJS.Renderer.prototype.page=function(e){return e>=1&&e<=this.displayedPages?(this.chapterPos=e,this.leftPos=this.spreadWidth*(e-1),this.setLeft(this.leftPos),!0):!1},EPUBJS.Renderer.prototype.section=function(e){var t=this.doc.getElementById(e),n,r;t&&this.pageByElement(t)},EPUBJS.Renderer.prototype.pageByElement=function(e){var t,n;if(!e)return;t=this.leftPos+e.getBoundingClientRect().left,n=Math.floor(t/this.spreadWidth)+1,this.page(n)},EPUBJS.Renderer.prototype.beforeDisplay=function(e){this.book.triggerHooks("beforeChapterDisplay",e.bind(this),this)},EPUBJS.Renderer.prototype.walk=function(e){var t,e,n,r,i=e,s,o=[i],u=1e4,a=0;while(!t&&o.length){e=o.shift(),this.isElementVisible(e)&&(t=e);if(!t&&e&&e.childElementCount>0){n=e.children,r=n.length;for(var f=0;fu){console.error("ENDLESS LOOP");break}}return t},EPUBJS.Renderer.prototype.getPageCfi=function(){var e=this.visibileEl;return this.visibileEl=this.findFirstVisible(e),this.visibileEl.id||(this.visibileEl.id="EPUBJS-PAGE-"+this.chapterPos),this.pageIds[this.chapterPos]=this.visibileEl.id,this.epubcfi.generateFragment(this.visibileEl,this.currentChapterCfi)},EPUBJS.Renderer.prototype.gotoCfiFragment=function(e){var t;_.isString(e)&&(e=this.epubcfi.parse(e)),t=this.epubcfi.getElement(e,this.doc),this.pageByElement(t)},EPUBJS.Renderer.prototype.findFirstVisible=function(e){var t=e||this.bodyEl,n;return n=this.walk(t),n?n:e},EPUBJS.Renderer.prototype.isElementVisible=function(e){var t;if(e){t=e.getBoundingClientRect().left;if(t>=0&&te;e++)if(b.call(d,a[e],e,a)===c)return}else for(var g in a)if(x.has(a,g)&&b.call(d,a[g],g,a)===c)return};x.map=x.collect=function(a,b,c){var d=[];return null==a?d:m&&a.map===m?a.map(b,c):(y(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),d)};var z="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),n&&a.reduce===n)return d&&(b=x.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(y(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError(z);return c},x.reduceRight=x.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),o&&a.reduceRight===o)return d&&(b=x.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=x.keys(a);f=g.length}if(y(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)}),!e)throw new TypeError(z);return c},x.find=x.detect=function(a,b,c){var d;return A(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},x.filter=x.select=function(a,b,c){var d=[];return null==a?d:p&&a.filter===p?a.filter(b,c):(y(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},x.reject=function(a,b,c){return x.filter(a,function(a,d,e){return!b.call(c,a,d,e)},c)},x.every=x.all=function(a,b,d){b||(b=x.identity);var e=!0;return null==a?e:q&&a.every===q?a.every(b,d):(y(a,function(a,f,g){return(e=e&&b.call(d,a,f,g))?void 0:c}),!!e)};var A=x.some=x.any=function(a,b,d){b||(b=x.identity);var e=!1;return null==a?e:r&&a.some===r?a.some(b,d):(y(a,function(a,f,g){return e||(e=b.call(d,a,f,g))?c:void 0}),!!e)};x.contains=x.include=function(a,b){return null==a?!1:s&&a.indexOf===s?-1!=a.indexOf(b):A(a,function(a){return a===b})},x.invoke=function(a,b){var c=h.call(arguments,2),d=x.isFunction(b);return x.map(a,function(a){return(d?b:a[b]).apply(a,c)})},x.pluck=function(a,b){return x.map(a,function(a){return a[b]})},x.where=function(a,b,c){return x.isEmpty(b)?c?null:[]:x[c?"find":"filter"](a,function(a){for(var c in b)if(b[c]!==a[c])return!1;return!0})},x.findWhere=function(a,b){return x.where(a,b,!0)},x.max=function(a,b,c){if(!b&&x.isArray(a)&&a[0]===+a[0]&&65535>a.length)return Math.max.apply(Math,a);if(!b&&x.isEmpty(a))return-1/0;var d={computed:-1/0,value:-1/0};return y(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},x.min=function(a,b,c){if(!b&&x.isArray(a)&&a[0]===+a[0]&&65535>a.length)return Math.min.apply(Math,a);if(!b&&x.isEmpty(a))return 1/0;var d={computed:1/0,value:1/0};return y(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;d.computed>g&&(d={value:a,computed:g})}),d.value},x.shuffle=function(a){var b,c=0,d=[];return y(a,function(a){b=x.random(c++),d[c-1]=d[b],d[b]=a}),d};var B=function(a){return x.isFunction(a)?a:function(b){return b[a]}};x.sortBy=function(a,b,c){var d=B(b);return x.pluck(x.map(a,function(a,b,e){return{value:a,index:b,criteria:d.call(c,a,b,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.indexf;){var h=f+g>>>1;e>c.call(d,a[h])?f=h+1:g=h}return f},x.toArray=function(a){return a?x.isArray(a)?h.call(a):a.length===+a.length?x.map(a,x.identity):x.values(a):[]},x.size=function(a){return null==a?0:a.length===+a.length?a.length:x.keys(a).length},x.first=x.head=x.take=function(a,b,c){return null==a?void 0:null==b||c?a[0]:h.call(a,0,b)},x.initial=function(a,b,c){return h.call(a,0,a.length-(null==b||c?1:b))},x.last=function(a,b,c){return null==a?void 0:null==b||c?a[a.length-1]:h.call(a,Math.max(a.length-b,0))},x.rest=x.tail=x.drop=function(a,b,c){return h.call(a,null==b||c?1:b)},x.compact=function(a){return x.filter(a,x.identity)};var D=function(a,b,c){return y(a,function(a){x.isArray(a)?b?g.apply(c,a):D(a,b,c):c.push(a)}),c};x.flatten=function(a,b){return D(a,b,[])},x.without=function(a){return x.difference(a,h.call(arguments,1))},x.uniq=x.unique=function(a,b,c,d){x.isFunction(b)&&(d=c,c=b,b=!1);var e=c?x.map(a,c,d):a,f=[],g=[];return y(e,function(c,d){(b?d&&g[g.length-1]===c:x.contains(g,c))||(g.push(c),f.push(a[d]))}),f},x.union=function(){return x.uniq(i.apply(d,arguments))},x.intersection=function(a){var b=h.call(arguments,1);return x.filter(x.uniq(a),function(a){return x.every(b,function(b){return x.indexOf(b,a)>=0})})},x.difference=function(a){var b=i.apply(d,h.call(arguments,1));return x.filter(a,function(a){return!x.contains(b,a)})},x.zip=function(){for(var a=h.call(arguments),b=x.max(x.pluck(a,"length")),c=Array(b),d=0;b>d;d++)c[d]=x.pluck(a,""+d);return c},x.object=function(a,b){if(null==a)return{};for(var c={},d=0,e=a.length;e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},x.indexOf=function(a,b,c){if(null==a)return-1;var d=0,e=a.length;if(c){if("number"!=typeof c)return d=x.sortedIndex(a,b),a[d]===b?d:-1;d=0>c?Math.max(0,e+c):c}if(s&&a.indexOf===s)return a.indexOf(b,c);for(;e>d;d++)if(a[d]===b)return d;return-1},x.lastIndexOf=function(a,b,c){if(null==a)return-1;var d=null!=c;if(t&&a.lastIndexOf===t)return d?a.lastIndexOf(b,c):a.lastIndexOf(b);for(var e=d?c:a.length;e--;)if(a[e]===b)return e;return-1},x.range=function(a,b,c){1>=arguments.length&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=Array(d);d>e;)f[e++]=a,a+=c;return f},x.bind=function(a,b){if(a.bind===w&&w)return w.apply(a,h.call(arguments,1));var c=h.call(arguments,2);return function(){return a.apply(b,c.concat(h.call(arguments)))}},x.partial=function(a){var b=h.call(arguments,1);return function(){return a.apply(this,b.concat(h.call(arguments)))}},x.bindAll=function(a){var b=h.call(arguments,1);return 0===b.length&&(b=x.functions(a)),y(b,function(b){a[b]=x.bind(a[b],a)}),a},x.memoize=function(a,b){var c={};return b||(b=x.identity),function(){var d=b.apply(this,arguments);return x.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},x.delay=function(a,b){var c=h.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},x.defer=function(a){return x.delay.apply(x,[a,1].concat(h.call(arguments,1)))},x.throttle=function(a,b){var c,d,e,f,g=0,h=function(){g=new Date,e=null,f=a.apply(c,d)};return function(){var i=new Date,j=b-(i-g);return c=this,d=arguments,0>=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},x.debounce=function(a,b,c){var d,e;return function(){var f=this,g=arguments,h=function(){d=null,c||(e=a.apply(f,g))},i=c&&!d;return clearTimeout(d),d=setTimeout(h,b),i&&(e=a.apply(f,g)),e}},x.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}},x.wrap=function(a,b){return function(){var c=[a];return g.apply(c,arguments),b.apply(this,c)}},x.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},x.after=function(a,b){return 0>=a?b():function(){return 1>--a?b.apply(this,arguments):void 0}},x.keys=v||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)x.has(a,c)&&(b[b.length]=c);return b},x.values=function(a){var b=[];for(var c in a)x.has(a,c)&&b.push(a[c]);return b},x.pairs=function(a){var b=[];for(var c in a)x.has(a,c)&&b.push([c,a[c]]);return b},x.invert=function(a){var b={};for(var c in a)x.has(a,c)&&(b[a[c]]=c);return b},x.functions=x.methods=function(a){var b=[];for(var c in a)x.isFunction(a[c])&&b.push(c);return b.sort()},x.extend=function(a){return y(h.call(arguments,1),function(b){if(b)for(var c in b)a[c]=b[c]}),a},x.pick=function(a){var b={},c=i.apply(d,h.call(arguments,1));return y(c,function(c){c in a&&(b[c]=a[c])}),b},x.omit=function(a){var b={},c=i.apply(d,h.call(arguments,1));for(var e in a)x.contains(c,e)||(b[e]=a[e]);return b},x.defaults=function(a){return y(h.call(arguments,1),function(b){if(b)for(var c in b)null==a[c]&&(a[c]=b[c])}),a},x.clone=function(a){return x.isObject(a)?x.isArray(a)?a.slice():x.extend({},a):a},x.tap=function(a,b){return b(a),a};var E=function(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;if(null==a||null==b)return a===b;a instanceof x&&(a=a._wrapped),b instanceof x&&(b=b._wrapped);var e=j.call(a);if(e!=j.call(b))return!1;switch(e){case"[object String]":return a==b+"";case"[object Number]":return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if("object"!=typeof a||"object"!=typeof b)return!1;for(var f=c.length;f--;)if(c[f]==a)return d[f]==b;c.push(a),d.push(b);var g=0,h=!0;if("[object Array]"==e){if(g=a.length,h=g==b.length)for(;g--&&(h=E(a[g],b[g],c,d)););}else{var i=a.constructor,k=b.constructor;if(i!==k&&!(x.isFunction(i)&&i instanceof i&&x.isFunction(k)&&k instanceof k))return!1;for(var l in a)if(x.has(a,l)&&(g++,!(h=x.has(b,l)&&E(a[l],b[l],c,d))))break;if(h){for(l in b)if(x.has(b,l)&&!g--)break;h=!g}}return c.pop(),d.pop(),h};x.isEqual=function(a,b){return E(a,b,[],[])},x.isEmpty=function(a){if(null==a)return!0;if(x.isArray(a)||x.isString(a))return 0===a.length;for(var b in a)if(x.has(a,b))return!1;return!0},x.isElement=function(a){return!(!a||1!==a.nodeType)},x.isArray=u||function(a){return"[object Array]"==j.call(a)},x.isObject=function(a){return a===Object(a)},y(["Arguments","Function","String","Number","Date","RegExp"],function(a){x["is"+a]=function(b){return j.call(b)=="[object "+a+"]"}}),x.isArguments(arguments)||(x.isArguments=function(a){return!(!a||!x.has(a,"callee"))}),"function"!=typeof/./&&(x.isFunction=function(a){return"function"==typeof a}),x.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},x.isNaN=function(a){return x.isNumber(a)&&a!=+a},x.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"==j.call(a)},x.isNull=function(a){return null===a},x.isUndefined=function(a){return void 0===a},x.has=function(a,b){return k.call(a,b)},x.noConflict=function(){return a._=b,this},x.identity=function(a){return a},x.times=function(a,b,c){for(var d=Array(a),e=0;a>e;e++)d[e]=b.call(c,e);return d},x.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))};var F={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};F.unescape=x.invert(F.escape);var G={escape:RegExp("["+x.keys(F.escape).join("")+"]","g"),unescape:RegExp("("+x.keys(F.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(a){x[a]=function(b){return null==b?"":(""+b).replace(G[a],function(b){return F[a][b]})}}),x.result=function(a,b){if(null==a)return null;var c=a[b];return x.isFunction(c)?c.call(a):c},x.mixin=function(a){y(x.functions(a),function(b){var c=x[b]=a[b];x.prototype[b]=function(){var a=[this._wrapped];return g.apply(a,arguments),L.call(this,c.apply(x,a))}})};var H=0;x.uniqueId=function(a){var b=++H+"";return a?a+b:b},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var I=/(.)^/,J={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},K=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(a,b,c){var d;c=x.defaults({},c,x.templateSettings);var e=RegExp([(c.escape||I).source,(c.interpolate||I).source,(c.evaluate||I).source].join("|")+"|$","g"),f=0,g="__p+='";a.replace(e,function(b,c,d,e,h){return g+=a.slice(f,h).replace(K,function(a){return"\\"+J[a]}),c&&(g+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'"),d&&(g+="'+\n((__t=("+d+"))==null?'':__t)+\n'"),e&&(g+="';\n"+e+"\n__p+='"),f=h+b.length,b}),g+="';\n",c.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{d=Function(c.variable||"obj","_",g)}catch(h){throw h.source=g,h}if(b)return d(b,x);var i=function(a){return d.call(this,a,x)};return i.source="function("+(c.variable||"obj")+"){\n"+g+"}",i},x.chain=function(a){return x(a).chain()};var L=function(a){return this._chain?x(a).chain():a};x.mixin(x),y(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];x.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!=a&&"splice"!=a||0!==c.length||delete c[0],L.call(this,c)}}),y(["concat","join","slice"],function(a){var b=d[a];x.prototype[a]=function(){return L.call(this,b.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),function(a){"use strict";function b(a,b){f.async(function(){a.trigger("promise:resolved",{detail:b}),a.isResolved=!0,a.resolvedValue=b})}function c(a,b){f.async(function(){a.trigger("promise:failed",{detail:b}),a.isRejected=!0,a.rejectedValue=b})}function d(a){var b,c=[],d=new p,e=a.length;0===e&&d.resolve([]);var f=function(a){return function(b){g(a,b)}},g=function(a,b){c[a]=b,0===--e&&d.resolve(c)},h=function(a){d.reject(a)};for(b=0;e>b;b++)a[b].then(f(b),h);return d}function e(a,b){f[a]=b}var f={},g="undefined"!=typeof window?window:{},h=g.MutationObserver||g.WebKitMutationObserver;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))f.async=function(a,b){process.nextTick(function(){a.call(b)})};else if(h){var i=[],j=new h(function(){var a=i.slice();i=[],a.forEach(function(a){var b=a[0],c=a[1];b.call(c)})}),k=document.createElement("div");j.observe(k,{attributes:!0}),window.addEventListener("unload",function(){j.disconnect(),j=null}),f.async=function(a,b){i.push([a,b]),k.setAttribute("drainQueue","drainQueue")}}else f.async=function(a,b){setTimeout(function(){a.call(b)},1)};var l=function(a,b){this.type=a;for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])},m=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c][0]===b)return c;return-1},n=function(a){var b=a._promiseCallbacks;return b||(b=a._promiseCallbacks={}),b},o={mixin:function(a){return a.on=this.on,a.off=this.off,a.trigger=this.trigger,a},on:function(a,b,c){var d,e,f=n(this);for(a=a.split(/\s+/),c=c||this;e=a.shift();)d=f[e],d||(d=f[e]=[]),-1===m(d,b)&&d.push([b,c])},off:function(a,b){var c,d,e,f=n(this);for(a=a.split(/\s+/);d=a.shift();)b?(c=f[d],e=m(c,b),-1!==e&&c.splice(e,1)):f[d]=[]},trigger:function(a,b){var c,d,e,f,g,h=n(this);if(c=h[a])for(var i=0,j=c.length;j>i;i++)d=c[i],e=d[0],f=d[1],"object"!=typeof b&&(b={detail:b}),g=new l(a,b),e.call(f,g)}},p=function(){this.on("promise:resolved",function(a){this.trigger("success",{detail:a.detail})},this),this.on("promise:failed",function(a){this.trigger("error",{detail:a.detail})},this)},q=function(){},r=function(a,b,c,d){var e,f,g,h,i="function"==typeof c;if(i)try{e=c(d.detail),g=!0}catch(j){h=!0,f=j}else e=d.detail,g=!0;e&&"function"==typeof e.then?e.then(function(a){b.resolve(a)},function(a){b.reject(a)}):i&&g?b.resolve(e):h?b.reject(f):b[a](e)};p.prototype={then:function(a,b){var c=new p;return this.isResolved&&f.async(function(){r("resolve",c,a,{detail:this.resolvedValue})},this),this.isRejected&&f.async(function(){r("reject",c,b,{detail:this.rejectedValue})},this),this.on("promise:resolved",function(b){r("resolve",c,a,b)}),this.on("promise:failed",function(a){r("reject",c,b,a)}),c},resolve:function(a){b(this,a),this.resolve=q,this.reject=q},reject:function(a){c(this,a),this.resolve=q,this.reject=q}},o.mixin(p.prototype),a.Promise=p,a.Event=l,a.EventTarget=o,a.all=d,a.configure=e}(window.RSVP={});var EPUBJS=EPUBJS||{};EPUBJS.VERSION="0.1.5",EPUBJS.plugins=EPUBJS.plugins||{},EPUBJS.filePath=EPUBJS.filePath||"/epubjs/",EPUBJS.Book=function(a,b){this.settings=_.defaults(b||{},{element:!1,storage:!1,fromStorage:!1,saved:!1,online:!0,contained:!1,width:!1,height:!1,spreads:!0,responsive:!0,version:1.1,restore:!0}),this.settings.EPUBJSVERSION=EPUBJS.VERSION,this.spinePos=0,this.stored=!1,this.hooks={beforeChapterDisplay:[]},this.getHooks(),this.online=this.settings.online||navigator.onLine,this.networkListeners(),0!=this.settings.storage&&(this.storage=new fileStorage.storage(this.settings.storage)),this.ready={manifest:new RSVP.Promise,spine:new RSVP.Promise,metadata:new RSVP.Promise,cover:new RSVP.Promise,toc:new RSVP.Promise},this.ready.all=RSVP.all(_.values(this.ready)),a&&(this.opened=this.open(a)),a&&this.settings.element&&this.opened.then(function(){this.rendered=this.renderTo(el)})},EPUBJS.Book.prototype.open=function(a,b){var c,d=this,e=this.isSaved(a);return this.settings.bookPath=a,this.bookUrl=this.urlFrom(a),e&&!b&&this.applySavedSettings(),this.settings.contained||this.isContained(a)?(this.settings.contained=this.contained=!0,this.bookUrl="",c=this.unarchive(a).then(function(){return e&&d.settings.restore&&!b?d.restore():d.unpack()})):c=e&&this.settings.restore&&!b?this.restore():this.unpack(),this.online&&this.settings.storage&&!this.settings.contained&&(this.settings.stored||c.then(d.storeOffline())),c},EPUBJS.Book.prototype.unpack=function(a){var b=this,c=new EPUBJS.Parser,a=a||"META-INF/container.xml";return b.loadXml(b.bookUrl+a).then(function(a){return c.container(a)}).then(function(a){return b.settings.contentsPath=b.bookUrl+a.basePath,b.settings.packageUrl=b.bookUrl+a.packagePath,b.loadXml(b.settings.packageUrl)}).then(function(a){return c.package(a,b.settings.contentsPath)}).then(function(a){return b.contents=a,b.manifest=b.contents.manifest,b.spine=b.contents.spine,b.spineIndexByURL=b.contents.spineIndexByURL,b.metadata=b.contents.metadata,b.cover=b.contents.cover=b.settings.contentsPath+a.coverPath,b.spineNodeIndex=b.contents.spineNodeIndex=a.spineNodeIndex,b.ready.manifest.resolve(b.contents.manifest),b.ready.spine.resolve(b.contents.spine),b.ready.metadata.resolve(b.contents.metadata),b.ready.cover.resolve(b.contents.cover),b.settings.tocUrl=b.settings.contentsPath+a.tocPath,b.loadXml(b.settings.tocUrl)}).then(function(a){return c.toc(a)}).then(function(a){b.toc=b.contents.toc=a,b.ready.toc.resolve(b.contents.toc)}).then(null,function(a){console.error(a)})},EPUBJS.Book.prototype.getMetadata=function(){return this.ready.metadata},EPUBJS.Book.prototype.getToc=function(){return this.ready.toc},EPUBJS.Book.prototype.networkListeners=function(){var a=this;window.addEventListener("offline",function(){a.online=!1,a.trigger("book:offline")},!1),window.addEventListener("online",function(){a.online=!0,a.trigger("book:online")},!1),window.addEventListener("beforeunload",function(){a.saveSettings(),a.settings.restore&&a.saveContents(),a.trigger("book:unload")},!1)},EPUBJS.Book.prototype.loadXml=function(a){return this.settings.fromStorage?this.storage.getXml(a):this.settings.contained?this.zip.getXml(a):EPUBJS.core.request(a,"xml")},EPUBJS.Book.prototype.urlFrom=function(a){var b=-1!=a.search("://"),c="/"==a[0],d=window.location,e=d.origin||d.protocol+"//"+d.host;return b?a:!b&&c?e+a:b||c?void 0:e+EPUBJS.core.folder(d.pathname)+a},EPUBJS.Book.prototype.unarchive=function(a){return this.zip=new EPUBJS.Unarchiver,this.zip.openZip(a)},EPUBJS.Book.prototype.isContained=function(a){var b=a.lastIndexOf("."),c=a.slice(b+1);return!c||"epub"!=c&&"zip"!=c?!1:!0},EPUBJS.Book.prototype.isSaved=function(a){var b=a+":"+this.settings.version,c=localStorage.getItem(b);return localStorage&&null!==c?!0:!1},EPUBJS.Book.prototype.removeSavedSettings=function(){var a=this.settings.bookPath+":"+this.settings.version;localStorage.removeItem(a),this.settings.stored=!1},EPUBJS.Book.prototype.applySavedSettings=function(){var a=this.settings.bookPath+":"+this.settings.version;return stored=JSON.parse(localStorage.getItem(a)),EPUBJS.VERSION!=stored.EPUBJSVERSION?!1:(this.settings=_.defaults(this.settings,stored),void 0)},EPUBJS.Book.prototype.saveSettings=function(){var a=this.settings.bookPath+":"+this.settings.version;this.render&&(this.settings.previousLocationCfi=this.render.currentLocationCfi),localStorage.setItem(a,JSON.stringify(this.settings))},EPUBJS.Book.prototype.saveContents=function(){var a=this.settings.bookPath+":contents:"+this.settings.version;localStorage.setItem(a,JSON.stringify(this.contents))},EPUBJS.Book.prototype.renderTo=function(a){var b=this;return this.settings.element=a,this.opened.then(function(){return b.render=new EPUBJS.Renderer(b),b.startDisplay()})},EPUBJS.Book.prototype.startDisplay=function(){var a;return a=this.settings.restore&&this.settings.previousLocationCfi?this.displayChapter(this.settings.previousLocationCfi):this.displayChapter(this.spinePos)},EPUBJS.Book.prototype.restore=function(){var a=this,b=this.settings.bookPath+":contents:"+this.settings.version,c=new RSVP.Promise,d=["manifest","spine","metadata","cover","toc","spineNodeIndex","spineIndexByURL"],e=!1,f=localStorage.getItem(b);return"undefined"!=f&&"null"!=f&&(this.contents=JSON.parse(f),d.forEach(function(b){a[b]=a.contents[b],a[b]||(e=!0)})),!e&&f&&this.contents&&this.settings.contentsPath?(this.ready.manifest.resolve(this.manifest),this.ready.spine.resolve(this.spine),this.ready.metadata.resolve(this.metadata),this.ready.cover.resolve(this.cover),this.ready.toc.resolve(this.toc),c.resolve(),c):this.open(this.settings.bookPath,!0)},EPUBJS.Book.prototype.displayChapter=function(a,b){var c,d,e,f=this;return _.isNumber(a)?e=a:(d=new EPUBJS.EpubCFI(a),e=d.spinePos),e>=this.spine.length?!1:0>e?!1:(this.spinePos=e,this.chapter=new EPUBJS.Chapter(this.spine[e]),c=f.render.chapter(this.chapter),d?c.then(function(b){b.currentLocationCfi=a,b.gotoCfiFragment(d)}):b&&c.then(function(a){a.gotoChapterEnd()}),this.settings.fromStorage||this.settings.contained||c.then(function(){f.preloadNextChapter()}),c)},EPUBJS.Book.prototype.nextPage=function(){var a=this.render.nextPage();return a?void 0:this.nextChapter()},EPUBJS.Book.prototype.prevPage=function(){var a=this.render.prevPage();return a?void 0:this.prevChapter()},EPUBJS.Book.prototype.nextChapter=function(){return this.spinePos++,this.displayChapter(this.spinePos)},EPUBJS.Book.prototype.prevChapter=function(){return this.spinePos--,this.displayChapter(this.spinePos,!0)},EPUBJS.Book.prototype.goto=function(a){var b,c=a.split("#"),d=c[0],e=c[1]||!1,f=-1==d.search("://")?this.settings.contentsPath+d:d,g=this.spineIndexByURL[f];return d||(g=this.chapter.spinePos),"number"!=typeof g?!1:g==this.chapter.spinePos&&this.chapter?(e&&this.render.section(e),(new RSVP.Promise).resolve(this.currentChapter)):this.displayChapter(g).then(function(){e&&b.render.section(e)})},EPUBJS.Book.prototype.preloadNextChapter=function(){return document.createElement("iframe"),this.spinePos>=this.spine.length?!1:(next=new EPUBJS.Chapter(this.spine[this.spinePos+1]),EPUBJS.core.request(next.href),void 0)},EPUBJS.Book.prototype.storeOffline=function(){var a=this,b=_.values(this.manifest);return EPUBJS.storage.batch(b).then(function(){a.settings.stored=!0,a.trigger("book:stored")})},EPUBJS.Book.prototype.availableOffline=function(){return this.settings.stored>0?!0:!1},EPUBJS.Book.prototype.setStyle=function(a,b,c){this.renderer.setStyle(a,b,c),this.settings.styles[a]=b},EPUBJS.Book.prototype.removeStyle=function(a){this.renderer.removeStyle(a),delete this.settings.styles[a]},EPUBJS.Book.prototype.getHooks=function(){var a,b=this;plugTypes=_.values(this.hooks);for(plugType in this.hooks)a=_.values(EPUBJS.Hooks[plugType]),a.forEach(function(a){b.registerHook(plugType,a)})},EPUBJS.Book.prototype.registerHook=function(a,b,c){var d=this;"undefined"!=typeof this.hooks[a]?"function"==typeof b?c?this.hooks[a].unshift(b):this.hooks[a].push(b):Array.isArray(b)&&b.forEach(function(b){c?d.hooks[a].unshift(b):d.hooks[a].push(b)}):this.hooks[a]=[func]},EPUBJS.Book.prototype.triggerHooks=function(a,b,c){function d(){f--,0>=f&&b&&b()}var e,f;return"undefined"==typeof this.hooks[a]?!1:(e=this.hooks[a],f=e.length,e.forEach(function(a){a(d,c)}),void 0)},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),EPUBJS.Chapter=function(a){this.href=a.href,this.id=a.id,this.spinePos=a.index,this.properties=a.properties,this.linear=a.linear,this.pages=1},EPUBJS.Chapter.prototype.contents=function(a){return a?a.get(href):EPUBJS.core.request(href,"xml")},EPUBJS.Chapter.prototype.url=function(a){var b=new RSVP.Promise;return a?(this.tempUrl||(this.tempUrl=a.getUrl(this.href)),this.tempUrl):(b.resolve(this.href),b)},EPUBJS.Chapter.prototype.setPages=function(a){this.pages=a},EPUBJS.Chapter.prototype.getPages=function(){return this.pages},EPUBJS.Chapter.prototype.getID=function(){return this.ID},EPUBJS.Chapter.prototype.unload=function(a){this.tempUrl&&a&&(a.revokeUrl(this.tempUrl),this.tempUrl=!1)};var EPUBJS=EPUBJS||{};EPUBJS.core={},EPUBJS.core.getEl=function(a){return document.getElementById(a)},EPUBJS.core.getEls=function(a){return document.getElementsByClassName(a)},EPUBJS.core.request=function(a,b){function c(){if(this.readyState===this.DONE)if(200===this.status||this.responseXML){var a;a="xml"==b?this.responseXML:"json"==b?JSON.parse(this.response):this.response,d.resolve(a)}else d.reject(this)}var d=new RSVP.Promise,e=new XMLHttpRequest;return e.open("GET",a),e.onreadystatechange=c,"blob"==b&&(e.responseType=b),"json"==b&&e.setRequestHeader("Accept","application/json"),"xml"==b&&e.overrideMimeType("text/xml"),e.send(),d},EPUBJS.core.toArray=function(a){var b=[];for(member in a){var c;a.hasOwnProperty(member)&&(c=a[member],c.ident=member,b.push(c))}return b},EPUBJS.core.folder=function(a){var b=a.lastIndexOf("/"),c=a.slice(0,b+1);return c},EPUBJS.core.dataURLToBlob=function(a){var b=";base64,";if(-1==a.indexOf(b)){var c=a.split(","),d=c[0].split(":")[1],e=c[1];return new Blob([e],{type:d})}for(var c=a.split(b),d=c[0].split(":")[1],e=window.atob(c[1]),f=e.length,g=new Uint8Array(f),h=0;f>h;++h)g[h]=e.charCodeAt(h);return new Blob([g],{type:d})},EPUBJS.core.addScript=function(a,b,c){var d,e;e=!1,d=document.createElement("script"),d.type="text/javascript",d.async=!1,d.src=a,d.onload=d.onreadystatechange=function(){e||this.readyState&&"complete"!=this.readyState||(e=!0,b&&b())},c=c||document.body,c.appendChild(d)},EPUBJS.core.addScripts=function(a,b,c){var d=a.length,e=0,f=function(){e++,d==e?b&&b():EPUBJS.core.loadScript(a[e],f,c)};EPUBJS.core.addScript(a[e],f,c)},EPUBJS.core.addCss=function(a,b,c){var d,e;e=!1,d=document.createElement("link"),d.type="text/css",d.rel="stylesheet",d.href=a,d.onload=d.onreadystatechange=function(){e||this.readyState&&"complete"!=this.readyState||(e=!0,b&&b())},c=c||document.body,c.appendChild(d)},EPUBJS.core.prefixed=function(a){var b=["Webkit","Moz","O","ms"],c=a[0].toUpperCase()+a.slice(1),d=b.length,e=0;if("undefined"!=typeof document.body.style[a])return a;for(;d>e;e++)if("undefined"!=typeof document.body.style[b[e]+c])return b[e]+c;return a},EPUBJS.core.resolveUrl=function(a,b){var c,d,e=[],f=a.split("/");return f.pop(),d=b.split("/"),d.forEach(function(a){".."===a?f.pop():e.push(a)}),c=f.concat(e),c.join("/")},EPUBJS.EpubCFI=function(a){return a?this.parse(a):void 0},EPUBJS.EpubCFI.prototype.generateChapter=function(a,b,c){var a=a+1,d="/"+a+"/";return d+=2*(b+1),c&&(d+="["+c+"]"),d+="!"},EPUBJS.EpubCFI.prototype.generateFragment=function(a,b){var c=this.pathTo(a),d=[];return b&&d.push(b),c.forEach(function(a){d.push(2*(a.index+1)),a.id&&"EPUBJS"!=a.id.slice(0,6)&&d.push("["+a.id+"]")}),d.join("/")},EPUBJS.EpubCFI.prototype.pathTo=function(a){for(var b,c=[];a&&null!==a.parentNode;)b=a.parentNode.children,c.unshift({id:a.id,tagName:a.tagName,index:b?Array.prototype.indexOf.call(b,a):0}),a=a.parentNode;return c},EPUBJS.EpubCFI.prototype.getChapter=function(a){var b=a.split("!");return b[0]},EPUBJS.EpubCFI.prototype.getFragment=function(a){var b=a.split("!");return b[1]},EPUBJS.EpubCFI.prototype.getOffset=function(a){var b=a.split(":");return[b[0],b[1]]},EPUBJS.EpubCFI.prototype.parse=function(a){var b,c,d,e,f={};return f.chapter=this.getChapter(a),f.fragment=this.getFragment(a),f.spinePos=parseInt(f.chapter.split("/")[2])/2-1||0,b=f.chapter.match(/\[(.*)\]/),f.spineId=b[1]||!1,c=f.fragment.split("/"),d=c[c.length-1],f.sections=[],parseInt(d)%2&&(e=this.getOffset(),f.text=parseInt(e[0]),f.character=parseInt(e[1]),c.pop()),c.forEach(function(a){var b,c,d;a&&(b=parseInt(a)/2-1,c=a.match(/\[(.*)\]/),c&&c[1]&&(d=c[1]),f.sections.push({index:b,id:d||!1}))}),f},EPUBJS.EpubCFI.prototype.getElement=function(a,b){var c,b=b||document,d=a.sections,e=b.getElementsByTagName("html")[0],f=Array.prototype.slice.call(e.children);for(d.shift();d.length>0;)c=d.shift(),c.id?e=b.querySelector("#"+c.id):(e=f[c.index],f||console.error("No Kids",e)),e||console.error("No Element For",c),f=Array.prototype.slice.call(e.children);return e},EPUBJS.Events=function(a,b){return this.events={},this.el=b?b:document.createElement("div"),a.createEvent=this.createEvent,a.tell=this.tell,a.listen=this.listen,a.deafen=this.deafen,a.listenUntil=this.listenUntil,this},EPUBJS.Events.prototype.createEvent=function(a){var b=new CustomEvent(a);return this.events[a]=b,b},EPUBJS.Events.prototype.tell=function(a,b){var c;this.events[a]?c=this.events[a]:(console.warn("No event:",a,"defined yet, creating."),c=this.createEvent(a)),b&&(c.msg=b),this.el.dispatchEvent(c)},EPUBJS.Events.prototype.listen=function(a,b,c){return this.events[a]?(c?this.el.addEventListener(a,b.bind(c),!1):this.el.addEventListener(a,b,!1),void 0):(console.warn("No event:",a,"defined yet, creating."),this.createEvent(a),void 0)},EPUBJS.Events.prototype.deafen=function(a,b){this.el.removeEventListener(a,b,!1)},EPUBJS.Events.prototype.listenUntil=function(a,b,c,d){function e(){this.deafen(a,c),this.deafen(b,e)}this.listen(a,c,d),this.listen(b,e,this)},EPUBJS.Hooks=function(){"use strict";return{register:function(a){if(void 0===this[a]&&(this[a]={}),"object"!=typeof this[a])throw"Already registered: "+a;return this[a]}}}(),EPUBJS.Parser=function(a){this.baseUrl=a||""},EPUBJS.Parser.prototype.container=function(a){var b=a.querySelector("rootfile"),c=b.getAttribute("full-path"),d=EPUBJS.core.folder(c);return{packagePath:c,basePath:d}},EPUBJS.Parser.prototype.package=function(a,b){var c=this;b&&(this.baseUrl=b);var d=a.querySelector("metadata"),e=a.querySelector("manifest"),f=a.querySelector("spine"),g=c.manifest(e),h=c.findTocPath(e),i=c.findCoverPath(e),j=Array.prototype.indexOf.call(f.parentNode.childNodes,f),k=c.spine(f,g),l={};return k.forEach(function(a){l[a.href]=a.index}),{metadata:c.metadata(d),spine:k,manifest:g,tocPath:h,coverPath:i,spineNodeIndex:j,spineIndexByURL:l}},EPUBJS.Parser.prototype.findTocPath=function(a){var b=a.querySelector("item[media-type='application/x-dtbncx+xml']");return b?b.getAttribute("href"):!1},EPUBJS.Parser.prototype.findCoverPath=function(a){var b=a.querySelector("item[properties='cover-image']");return b?b.getAttribute("href"):!1},EPUBJS.Parser.prototype.metadata=function(a){var b={},c=this;return b.bookTitle=c.getElement(a,"title"),b.creator=c.getElement(a,"creator"),b.description=c.getElement(a,"description"),b.pubdate=c.getElement(a,"date"),b.publisher=c.getElement(a,"publisher"),b.identifier=c.getElement(a,"identifier"),b.language=c.getElement(a,"language"),b.rights=c.getElement(a,"rights"),b.modified_date=c.querySelector(a,"meta[property='dcterms:modified']"),b.layout=c.querySelector(a,"meta[property='rendition:orientation']"),b.orientation=c.querySelector(a,"meta[property='rendition:orientation']"),b.spread=c.querySelector(a,"meta[property='rendition:spread']"),b +},EPUBJS.Parser.prototype.getElement=function(a,b){var c,d=a.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",b);return d?(c=d[0],c?c.childNodes[0].nodeValue:""):""},EPUBJS.Parser.prototype.querySelector=function(a,b){var c=a.querySelector(b);return c?c.childNodes[0].nodeValue:""},EPUBJS.Parser.prototype.manifest=function(a){var b=this.baseUrl,c={},d=a.querySelectorAll("item"),e=Array.prototype.slice.call(d);return e.forEach(function(a){var d=a.getAttribute("id"),e=a.getAttribute("href")||"",f=a.getAttribute("media-type")||"";c[d]={href:b+e,type:f}}),c},EPUBJS.Parser.prototype.spine=function(a,b){var c=[],d=a.getElementsByTagName("itemref"),e=Array.prototype.slice.call(d);return e.forEach(function(a,d){var e=a.getAttribute("idref"),f={id:e,linear:a.getAttribute("linear")||"",properties:a.getAttribute("properties")||"",href:b[e].href,index:d};c.push(f)}),c},EPUBJS.Parser.prototype.toc=function(a){function b(a){var c,d=[],e=[],f=a.childNodes,g=Array.prototype.slice.call(f),h=g.length,i=h;if(0==h)return!1;for(;i--;)c=g[i],"navPoint"===c.nodeName&&e.push(c);return e.forEach(function(a){var c=a.getAttribute("id"),e=a.querySelector("content"),f=e.getAttribute("src"),g=(f.split("#"),a.querySelector("navLabel")),h=g.textContent?g.textContent:"",i=b(a);d.unshift({id:c,href:f,label:h,subitems:i})}),d}var c=a.querySelector("navMap");return b(c)},EPUBJS.Renderer=function(a){var b=a.settings.element;if(this.book=a,this.settings=a.settings,_.isElement(b))this.el=b;else{if("string"!=typeof b)return console.error("Not an Element"),void 0;this.el=EPUBJS.core.getEl(b)}a.registerHook("beforeChapterDisplay",[this.replaceLinks.bind(this),this.replaceResources.bind(this),this.replaceHead.bind(this)],!0),this.crossBrowserColumnCss(),this.epubcfi=new EPUBJS.EpubCFI,this.initialize(),this.listeners()},EPUBJS.Renderer.prototype.initialize=function(){this.iframe=document.createElement("iframe"),this.resizeIframe(!1,this.el.clientWidth,this.el.clientHeight),this.on("book:resized",this.resizeIframe,this),this.el.appendChild(this.iframe)},EPUBJS.Renderer.prototype.listeners=function(){this.resized=_.debounce(this.onResized.bind(this),10),window.addEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.chapter=function(a){var b=this,c=!1;return this.book.settings.contained&&(c=this.book.zip),this.currentChapter&&(this.currentChapter.unload(),this.trigger("book:chapterDestroyed")),this.currentChapter=a,this.chapterPos=1,this.pageIds={},this.leftPos=0,this.currentChapterCfi=this.epubcfi.generateChapter(this.book.spineNodeIndex,a.spinePos,a.id),this.visibileEl=!1,a.url(c).then(function(a){return b.setIframeSrc(a)})},EPUBJS.Renderer.prototype.onResized=function(){this.trigger("book:resized",{width:this.el.clientWidth,height:this.el.clientHeight}),this.reformat()},EPUBJS.Renderer.prototype.reformat=function(){var a=this;this.formatSpread(),setTimeout(function(){a.calcPages(),a.currentLocationCfi&&a.gotoCfiFragment(a.currentLocationCfi)},10)},EPUBJS.Renderer.prototype.destroy=function(){window.removeEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.resizeIframe=function(a,b,c){var d,e;a?(d=a.width,e=a.height):(d=b,e=c),this.iframe.height=e,0!=d%2&&(d+=1),this.iframe.width=d},EPUBJS.Renderer.prototype.crossBrowserColumnCss=function(){EPUBJS.Renderer.columnAxis=EPUBJS.core.prefixed("columnAxis"),EPUBJS.Renderer.columnGap=EPUBJS.core.prefixed("columnGap"),EPUBJS.Renderer.columnWidth=EPUBJS.core.prefixed("columnWidth"),EPUBJS.Renderer.transform=EPUBJS.core.prefixed("transform")},EPUBJS.Renderer.prototype.setIframeSrc=function(a){var b=this,c=new RSVP.Promise;return this.visible(!1),this.iframe.src=a,this.iframe.onload=function(){b.doc=b.iframe.contentDocument,b.docEl=b.doc.documentElement,b.bodyEl=b.doc.body,b.applyStyles(),b.formatSpread(),b.beforeDisplay(function(){b.calcPages(),c.resolve(b),b.currentLocationCfi=b.getPageCfi(),b.trigger("book:chapterDisplayed"),b.visible(!0)})},c},EPUBJS.Renderer.prototype.formatSpread=function(){var a=2,b=800;this.colWidth&&(this.OldcolWidth=this.colWidth,this.OldspreadWidth=this.spreadWidth),this.elWidth=this.iframe.width,this.gap=this.gap||Math.ceil(this.elWidth/8),this.elWidth1?(this.chapterPos--,this.leftPos-=this.spreadWidth,this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.trigger("book:pageChanged",this.currentLocationCfi),this.chapterPos):!1},EPUBJS.Renderer.prototype.chapterEnd=function(){this.page(this.displayedPages),this.currentLocationCfi=this.getPageCfi()},EPUBJS.Renderer.prototype.setLeft=function(a){this.doc.defaultView.scrollTo(a,0)},EPUBJS.Renderer.prototype.replace=function(a,b,c){var d,e,f;d=this.doc.querySelectorAll(a),e=Array.prototype.slice.call(d),f=e.length,e.forEach(function(a){b(a,function(){f--,0>=f&&c&&c()})}.bind(this)),0===f&&c()},EPUBJS.Renderer.prototype.determineStore=function(){return this.book.fromStorage?"filesystem"==this.book.storage.getStorageType()?!1:this.book.store:this.book.contained?this.book.zip:!1},EPUBJS.Renderer.prototype.replaceHead=function(a){var b,c,d,e,f={},g=this,h=this.determineStore(),i=function(a,b){a.setAttribute("href",b),a.onload=function(){d--,0>=d&&j()}},j=function(){a&&a(),_.each(e,function(a){h.revokeUrl(a)}),g.urlCache=f};return h?(b=this.doc.head.querySelectorAll("[href]"),c=Array.prototype.slice.call(b),d=c.length,this.urlCache||(this.urlCache={}),e=_.clone(this.urlCache),c.forEach(function(a){var b=a.getAttribute("href"),c=this.book.settings.contentsPath+b;c in e?(i(a,e[c]),f[c]=e[c],delete e[c]):"stylesheet"===a.getAttribute("rel")?h.getText(c).then(function(b){g.replaceUrlsInCss(c,b).then(function(b){var d=window.URL||window.webkitURL||window.mozURL,e=new Blob([b],{type:"text/css"}),g=d.createObjectURL(e);i(a,g),f[c]=g},function(a){console.error(a)})}):h.getUrl(c).then(function(b){i(a,b),f[c]=b})}.bind(this)),0===d&&j(),void 0):(a&&a(),!1)},EPUBJS.Renderer.prototype.replaceUrlsInCss=function(a,b){var c=new RSVP.Promise,d=[],e=this.determineStore(),f=b.match(/url\(\'?\"?([^\'|^\"]*)\'?\"?\)/g);return f.forEach(function(c){var f=EPUBJS.core.resolveUrl(a,c.replace(/url\(|[|\)|\'|\"]/g,""));replaced=e.getUrl(f).then(function(a){b=b.replace(c,'url("'+a+'")')},function(a){console.error(a)}),d.push(replaced)}),RSVP.all(d).then(function(){c.resolve(b)}),c},EPUBJS.Renderer.prototype.replaceLinks=function(a){var b=this.doc.querySelectorAll("a"),c=Array.prototype.slice.call(b),d=this;c.forEach(function(a){var b,c,e=a.getAttribute("href");e&&(b=e.search("://"),c="#"==e[0],-1!=b?a.setAttribute("target","_blank"):a.onclick=function(){return d.book.goto(e),!1})}),a&&a()},EPUBJS.Renderer.prototype.replaceResources=function(a){var b,c,d,e=this.determineStore();return e?(b=this.doc.querySelectorAll("[src]"),c=Array.prototype.slice.call(b),d=c.length,c.forEach(function(b){var c=b.getAttribute("src"),f=this.book.settings.contentsPath+c;e.getUrl(f).then(function(c){b.src=c,b.onload=function(){d--,0>=d&&a&&a()}})}.bind(this)),0===d&&a(),void 0):(a&&a(),!1)},EPUBJS.Renderer.prototype.page=function(a){return a>=1&&a<=this.displayedPages?(this.chapterPos=a,this.leftPos=this.spreadWidth*(a-1),this.setLeft(this.leftPos),!0):!1},EPUBJS.Renderer.prototype.section=function(a){var b=this.doc.getElementById(a);b&&this.pageByElement(b)},EPUBJS.Renderer.prototype.pageByElement=function(a){var b,c;a&&(b=this.leftPos+a.getBoundingClientRect().left,c=Math.floor(b/this.spreadWidth)+1,this.page(c))},EPUBJS.Renderer.prototype.beforeDisplay=function(a){this.book.triggerHooks("beforeChapterDisplay",a.bind(this),this)},EPUBJS.Renderer.prototype.walk=function(a){for(var b,a,c,d,e,f=a,g=[f],h=1e4,i=0;!b&&g.length;){if(a=g.shift(),this.isElementVisible(a)&&(b=a),!b&&a&&a.childElementCount>0){c=a.children,d=c.length;for(var j=0;d>j;j++)c[j]!=e&&g.push(c[j])}if(!b&&0==g.length&&f&&null!==f.parentNode&&(g.push(f.parentNode),e=f,f=f.parentNode),i++,i>h){console.error("ENDLESS LOOP");break}}return b},EPUBJS.Renderer.prototype.getPageCfi=function(){var a=this.visibileEl;return this.visibileEl=this.findFirstVisible(a),this.visibileEl.id||(this.visibileEl.id="EPUBJS-PAGE-"+this.chapterPos),this.pageIds[this.chapterPos]=this.visibileEl.id,this.epubcfi.generateFragment(this.visibileEl,this.currentChapterCfi)},EPUBJS.Renderer.prototype.gotoCfiFragment=function(a){var b;_.isString(a)&&(a=this.epubcfi.parse(a)),b=this.epubcfi.getElement(a,this.doc),this.pageByElement(b)},EPUBJS.Renderer.prototype.findFirstVisible=function(a){var b,c=a||this.bodyEl;return b=this.walk(c),b?b:a},EPUBJS.Renderer.prototype.isElementVisible=function(a){var b;return a&&(b=a.getBoundingClientRect().left,b>=0&&br/2.5&&(l=r/2.5,pop_content.style.maxHeight=l+"px"),popRect.height+h>=r-25?(f.style.top=h-popRect.height+"px",f.classList.add("above")):f.classList.remove("above"),c-popRect.width<=0?(f.style.left=c+"px",f.classList.add("left")):f.classList.remove("left"),c+popRect.width/2>=i?(f.style.left=c-300+"px",popRect=f.getBoundingClientRect(),f.style.left=c-popRect.width+"px",popRect.height+h>=r-25?(f.style.top=h-popRect.height+"px",f.classList.add("above")):f.classList.remove("above"),f.classList.add("right")):f.classList.remove("right")}function v(){o[u].classList.add("on")}function m(){o[u].classList.remove("on")}function g(){setTimeout(function(){o[u].classList.remove("show")},100)}var n=e.getAttribute(i),r,u,a,f,l,c,h,p;if(n!=s)return;r=e.getAttribute("href"),u=r.replace("#",""),a=t.doc.getElementById(u),e.addEventListener("mouseover",d,!1),e.addEventListener("mouseout",g,!1)}),e&&e()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(e,t){var n=t.doc.querySelectorAll("img"),r=Array.prototype.slice.call(n),i=t.height(),s;r.forEach(function(e){function n(){var n=e.getBoundingClientRect(),r=n.height,s=n.top,o=e.getAttribute("data-height"),u=o||r,a;i=t.height(),s<0&&(s=0),u+s>=i?(st.colWidth&&(f=t.colWidth/u,u=t.colWidth,a*=f),r.width=u,r.height=a}var n=e.getAttribute("ref"),r=document.createElement("iframe"),i=e.getAttribute("width"),s=e.getAttribute("height"),o=e.parentNode,u=i,a=s,f;l(),t.book.listenUntil("book:resized","book:chapterDestroy",l),r.src=n,o.replaceChild(r,e)}),e&&e()}; \ No newline at end of file +EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(a,b){var c=b.doc.querySelectorAll("a[href]"),d=Array.prototype.slice.call(c),e="epub:type",f="noteref",g={};EPUBJS.core.addCss("../demo/css/popup.css",!1,b.doc.head),d.forEach(function(a){function c(){var c,e=b.iframe.height,f=b.iframe.width,j=225;o||(c=l.cloneNode(!0),o=c.querySelector("p")),g[k]||(g[k]=document.createElement("div"),g[k].setAttribute("class","popup"),pop_content=document.createElement("div"),g[k].appendChild(pop_content),pop_content.appendChild(o),pop_content.setAttribute("class","pop_content"),b.bodyEl.appendChild(g[k]),g[k].addEventListener("mouseover",d,!1),g[k].addEventListener("mouseout",h,!1),b.book.on("book:pageChanged",i,this),b.book.on("book:pageChanged",h,this)),c=g[k],itemRect=a.getBoundingClientRect(),m=itemRect.left,n=itemRect.top,c.classList.add("show"),popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width/2+"px",c.style.top=n+"px",j>e/2.5&&(j=e/2.5,pop_content.style.maxHeight=j+"px"),popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),m-popRect.width<=0?(c.style.left=m+"px",c.classList.add("left")):c.classList.remove("left"),m+popRect.width/2>=f?(c.style.left=m-300+"px",popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width+"px",popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),c.classList.add("right")):c.classList.remove("right")}function d(){g[k].classList.add("on")}function h(){g[k].classList.remove("on")}function i(){setTimeout(function(){g[k].classList.remove("show")},100)}var j,k,l,m,n,o,p=a.getAttribute(e);p==f&&(j=a.getAttribute("href"),k=j.replace("#",""),l=b.doc.getElementById(k),a.addEventListener("mouseover",c,!1),a.addEventListener("mouseout",i,!1))}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(a,b){var c=b.doc.querySelectorAll("img"),d=Array.prototype.slice.call(c),e=b.height();d.forEach(function(a){function c(){var c,d=a.getBoundingClientRect(),f=d.height,g=d.top,h=a.getAttribute("data-height"),i=h||f;e=b.height(),0>g&&(g=0),i+g>=e?(e/2>g?(c=e-g,a.style.maxHeight=c+"px",a.style.width="auto"):(i=e>i?i:e,a.style.maxHeight=c+"px",a.style.marginTop=e-g+"px",a.style.width="auto"),a.setAttribute("data-height",c)):(a.style.removeProperty("max-height"),a.style.removeProperty("margin-top"))}a.addEventListener("load",c,!1),b.on("book:resized",c),b.on("book:chapterDestroyed",function(){a.removeEventListener("load",c),b.off("book:resized",c)}),c()}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(a,b){var c=b.doc.querySelectorAll("[transclusion]"),d=Array.prototype.slice.call(c);d.forEach(function(a){function c(){j=g,k=h,j>b.colWidth&&(d=b.colWidth/j,j=b.colWidth,k*=d),f.width=j,f.height=k}var d,e=a.getAttribute("ref"),f=document.createElement("iframe"),g=a.getAttribute("width"),h=a.getAttribute("height"),i=a.parentNode,j=g,k=h;c(),b.book.listenUntil("book:resized","book:chapterDestroy",c),f.src=e,i.replaceChild(f,a)}),a&&a()}; \ No newline at end of file diff --git a/demo/js/libs/inflate.js b/demo/js/libs/inflate.js new file mode 100644 index 0000000..cc0e012 --- /dev/null +++ b/demo/js/libs/inflate.js @@ -0,0 +1,2163 @@ +/* + Copyright (c) 2013 Gildas Lormeau. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This program is based on JZlib 1.0.2 ymnk, JCraft,Inc. + * JZlib is based on zlib-1.1.3, so all credit should go authors + * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) + * and contributors of zlib. + */ + +(function(obj) { + + // Global + var MAX_BITS = 15; + + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_NEED_DICT = 2; + var Z_STREAM_ERROR = -2; + var Z_DATA_ERROR = -3; + var Z_MEM_ERROR = -4; + var Z_BUF_ERROR = -5; + + var inflate_mask = [ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, + 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff ]; + + var MANY = 1440; + + // JZlib version : "1.0.2" + var Z_NO_FLUSH = 0; + var Z_FINISH = 4; + + // InfTree + var fixed_bl = 9; + var fixed_bd = 5; + + var fixed_tl = [ 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, + 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, + 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, + 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, + 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, + 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, + 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, + 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, + 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, + 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, + 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, + 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, + 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, + 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, + 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, + 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, + 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, + 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, + 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, + 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, + 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, + 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, + 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, + 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, + 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, + 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, + 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, + 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, + 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, + 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, + 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, + 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, + 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, + 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, + 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, + 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, + 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255 ]; + var fixed_td = [ 80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, + 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, + 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577 ]; + + // Tables for deflate from PKZIP's appnote.txt. + var cplens = [ // Copy lengths for literal codes 257..285 + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ]; + + // see note #13 above about 258 + var cplext = [ // Extra bits for literal codes 257..285 + 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, 112, 112 // 112==invalid + ]; + + var cpdist = [ // Copy offsets for distance codes 0..29 + 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 ]; + + var cpdext = [ // Extra bits for distance codes + 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 ]; + + // If BMAX needs to be larger than 16, then h and x[] should be uLong. + var BMAX = 15; // maximum bit length of any code + + function InfTree() { + var that = this; + + var hn; // hufts used in space + var v; // work area for huft_build + var c; // bit length count table + var r; // table entry for structure assignment + var u; // table stack + var x; // bit offsets, then code stack + + function huft_build(b, // code lengths in bits (all assumed <= + // BMAX) + bindex, n, // number of codes (assumed <= 288) + s, // number of simple-valued codes (0..s-1) + d, // list of base values for non-simple codes + e, // list of extra bits for non-simple codes + t, // result: starting table + m, // maximum lookup bits, returns actual + hp,// space for trees + hn,// hufts used in space + v // working area: values in order of bit length + ) { + // Given a list of code lengths and a maximum table size, make a set of + // tables to decode that set of codes. Return Z_OK on success, + // Z_BUF_ERROR + // if the given code set is incomplete (the tables are still built in + // this + // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set + // of + // lengths), or Z_MEM_ERROR if not enough memory. + + var a; // counter for codes of length k + var f; // i repeats in table every f entries + var g; // maximum code length + var h; // table level + var i; // counter, current code + var j; // counter + var k; // number of bits in current code + var l; // bits per table (returned in m) + var mask; // (1 << w) - 1, to avoid cc -O bug on HP + var p; // pointer into c[], b[], or v[] + var q; // points to current table + var w; // bits before this table == (l * h) + var xp; // pointer into x + var y; // number of dummy codes added + var z; // number of entries in current table + + // Generate counts for each bit length + + p = 0; + i = n; + do { + c[b[bindex + p]]++; + p++; + i--; // assume all entries <= BMAX + } while (i !== 0); + + if (c[0] == n) { // null input--all zero length codes + t[0] = -1; + m[0] = 0; + return Z_OK; + } + + // Find minimum and maximum length, bound *m by those + l = m[0]; + for (j = 1; j <= BMAX; j++) + if (c[j] !== 0) + break; + k = j; // minimum code length + if (l < j) { + l = j; + } + for (i = BMAX; i !== 0; i--) { + if (c[i] !== 0) + break; + } + g = i; // maximum code length + if (l > i) { + l = i; + } + m[0] = l; + + // Adjust last length count to fill out codes, if needed + for (y = 1 << j; j < i; j++, y <<= 1) { + if ((y -= c[j]) < 0) { + return Z_DATA_ERROR; + } + } + if ((y -= c[i]) < 0) { + return Z_DATA_ERROR; + } + c[i] += y; + + // Generate starting offsets into the value table for each length + x[1] = j = 0; + p = 1; + xp = 2; + while (--i !== 0) { // note that i == g from above + x[xp] = (j += c[p]); + xp++; + p++; + } + + // Make a table of values in order of bit lengths + i = 0; + p = 0; + do { + if ((j = b[bindex + p]) !== 0) { + v[x[j]++] = i; + } + p++; + } while (++i < n); + n = x[g]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[0] = i = 0; // first Huffman code is zero + p = 0; // grab values in bit order + h = -1; // no tables yet--level -1 + w = -l; // bits decoded == (l * h) + u[0] = 0; // just to keep compilers happy + q = 0; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for (; k <= g; k++) { + a = c[k]; + while (a-- !== 0) { + // here i is the Huffman code of length k bits for value *p + // make tables up to required level + while (k > w + l) { + h++; + w += l; // previous table always l bits + // compute minimum size table less than or equal to l bits + z = g - w; + z = (z > l) ? l : z; // table size upper limit + if ((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table + // too few codes for + // k-w bit table + f -= a + 1; // deduct codes from patterns left + xp = k; + if (j < z) { + while (++j < z) { // try smaller tables up to z bits + if ((f <<= 1) <= c[++xp]) + break; // enough codes to use up j bits + f -= c[xp]; // else deduct codes from patterns + } + } + } + z = 1 << j; // table entries for j-bit table + + // allocate new table + if (hn[0] + z > MANY) { // (note: doesn't matter for fixed) + return Z_DATA_ERROR; // overflow of MANY + } + u[h] = q = /* hp+ */hn[0]; // DEBUG + hn[0] += z; + + // connect to last table, if there is one + if (h !== 0) { + x[h] = i; // save pattern for backing up + r[0] = /* (byte) */j; // bits in this table + r[1] = /* (byte) */l; // bits to dump before this table + j = i >>> (w - l); + r[2] = /* (int) */(q - u[h - 1] - j); // offset to this table + hp.set(r, (u[h - 1] + j) * 3); + // to + // last + // table + } else { + t[0] = q; // first table is returned result + } + } + + // set up table entry in r + r[1] = /* (byte) */(k - w); + if (p >= n) { + r[0] = 128 + 64; // out of values--invalid code + } else if (v[p] < s) { + r[0] = /* (byte) */(v[p] < 256 ? 0 : 32 + 64); // 256 is + // end-of-block + r[2] = v[p++]; // simple code is just the value + } else { + r[0] = /* (byte) */(e[v[p] - s] + 16 + 64); // non-simple--look + // up in lists + r[2] = d[v[p++] - s]; + } + + // fill code-like entries with r + f = 1 << (k - w); + for (j = i >>> w; j < z; j += f) { + hp.set(r, (q + j) * 3); + } + + // backwards increment the k-bit code i + for (j = 1 << (k - 1); (i & j) !== 0; j >>>= 1) { + i ^= j; + } + i ^= j; + + // backup over finished tables + mask = (1 << w) - 1; // needed on HP, cc -O bug + while ((i & mask) != x[h]) { + h--; // don't need to update q + w -= l; + mask = (1 << w) - 1; + } + } + } + // Return Z_BUF_ERROR if we were given an incomplete table + return y !== 0 && g != 1 ? Z_BUF_ERROR : Z_OK; + } + + function initWorkArea(vsize) { + var i; + if (!hn) { + hn = []; // []; //new Array(1); + v = []; // new Array(vsize); + c = new Int32Array(BMAX + 1); // new Array(BMAX + 1); + r = []; // new Array(3); + u = new Int32Array(BMAX); // new Array(BMAX); + x = new Int32Array(BMAX + 1); // new Array(BMAX + 1); + } + if (v.length < vsize) { + v = []; // new Array(vsize); + } + for (i = 0; i < vsize; i++) { + v[i] = 0; + } + for (i = 0; i < BMAX + 1; i++) { + c[i] = 0; + } + for (i = 0; i < 3; i++) { + r[i] = 0; + } + // for(int i=0; i 257)) { + if (result == Z_DATA_ERROR) { + z.msg = "oversubscribed distance tree"; + } else if (result == Z_BUF_ERROR) { + z.msg = "incomplete distance tree"; + result = Z_DATA_ERROR; + } else if (result != Z_MEM_ERROR) { + z.msg = "empty distance tree with lengths"; + result = Z_DATA_ERROR; + } + return result; + } + + return Z_OK; + }; + + } + + InfTree.inflate_trees_fixed = function(bl, // literal desired/actual bit depth + bd, // distance desired/actual bit depth + tl,// literal/length tree result + td// distance tree result + ) { + bl[0] = fixed_bl; + bd[0] = fixed_bd; + tl[0] = fixed_tl; + td[0] = fixed_td; + return Z_OK; + }; + + // InfCodes + + // waiting for "i:"=input, + // "o:"=output, + // "x:"=nothing + var START = 0; // x: set up for LEN + var LEN = 1; // i: get length/literal/eob next + var LENEXT = 2; // i: getting length extra (have base) + var DIST = 3; // i: get distance next + var DISTEXT = 4;// i: getting distance extra + var COPY = 5; // o: copying bytes in window, waiting + // for space + var LIT = 6; // o: got literal, waiting for output + // space + var WASH = 7; // o: got eob, possibly still output + // waiting + var END = 8; // x: got eob and all data flushed + var BADCODE = 9;// x: got error + + function InfCodes() { + var that = this; + + var mode; // current inflate_codes mode + + // mode dependent information + var len = 0; + + var tree; // pointer into tree + var tree_index = 0; + var need = 0; // bits needed + + var lit = 0; + + // if EXT or COPY, where and how much + var get = 0; // bits to get for extra + var dist = 0; // distance back to copy from + + var lbits = 0; // ltree bits decoded per branch + var dbits = 0; // dtree bits decoder per branch + var ltree; // literal/length/eob tree + var ltree_index = 0; // literal/length/eob tree + var dtree; // distance tree + var dtree_index = 0; // distance tree + + // Called with number of bytes left to write in window at least 258 + // (the maximum string length) and number of input bytes available + // at least ten. The ten bytes are six bytes for the longest length/ + // distance pair plus four bytes for overloading the bit buffer. + + function inflate_fast(bl, bd, tl, tl_index, td, td_index, s, z) { + var t; // temporary pointer + var tp; // temporary pointer + var tp_index; // temporary pointer + var e; // extra bits or operation + var b; // bit buffer + var k; // bits in bit buffer + var p; // input data pointer + var n; // bytes available there + var q; // output window write pointer + var m; // bytes to end of window or read pointer + var ml; // mask for literal/length tree + var md; // mask for distance tree + var c; // bytes to copy + var d; // distance back to copy from + var r; // copy source pointer + + var tp_index_t_3; // (tp_index+t)*3 + + // load input, output, bit values + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + // initialize masks + ml = inflate_mask[bl]; + md = inflate_mask[bd]; + + // do until not enough input or output space for fast loop + do { // assume called with m >= 258 && n >= 10 + // get literal/length code + while (k < (20)) { // max bits for literal/length code + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + t = b & ml; + tp = tl; + tp_index = tl_index; + tp_index_t_3 = (tp_index + t) * 3; + if ((e = tp[tp_index_t_3]) === 0) { + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; + m--; + continue; + } + do { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + if ((e & 16) !== 0) { + e &= 15; + c = tp[tp_index_t_3 + 2] + (/* (int) */b & inflate_mask[e]); + + b >>= e; + k -= e; + + // decode distance base of block to copy + while (k < (15)) { // max bits for distance code + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + t = b & md; + tp = td; + tp_index = td_index; + tp_index_t_3 = (tp_index + t) * 3; + e = tp[tp_index_t_3]; + + do { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + if ((e & 16) !== 0) { + // get extra bits to add to distance base + e &= 15; + while (k < (e)) { // get extra bits (up to 13) + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + d = tp[tp_index_t_3 + 2] + (b & inflate_mask[e]); + + b >>= (e); + k -= (e); + + // do the copy + m -= c; + if (q >= d) { // offset before dest + // just copy + r = q - d; + if (q - r > 0 && 2 > (q - r)) { + s.window[q++] = s.window[r++]; // minimum + // count is + // three, + s.window[q++] = s.window[r++]; // so unroll + // loop a + // little + c -= 2; + } else { + s.window.set(s.window.subarray(r, r + 2), q); + q += 2; + r += 2; + c -= 2; + } + } else { // else offset after destination + r = q - d; + do { + r += s.end; // force pointer in window + } while (r < 0); // covers invalid distances + e = s.end - r; + if (c > e) { // if source crosses, + c -= e; // wrapped copy + if (q - r > 0 && e > (q - r)) { + do { + s.window[q++] = s.window[r++]; + } while (--e !== 0); + } else { + s.window.set(s.window.subarray(r, r + e), q); + q += e; + r += e; + e = 0; + } + r = 0; // copy rest from start of window + } + + } + + // copy all or what's left + if (q - r > 0 && c > (q - r)) { + do { + s.window[q++] = s.window[r++]; + } while (--c !== 0); + } else { + s.window.set(s.window.subarray(r, r + c), q); + q += c; + r += c; + c = 0; + } + break; + } else if ((e & 64) === 0) { + t += tp[tp_index_t_3 + 2]; + t += (b & inflate_mask[e]); + tp_index_t_3 = (tp_index + t) * 3; + e = tp[tp_index_t_3]; + } else { + z.msg = "invalid distance code"; + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_DATA_ERROR; + } + } while (true); + break; + } + + if ((e & 64) === 0) { + t += tp[tp_index_t_3 + 2]; + t += (b & inflate_mask[e]); + tp_index_t_3 = (tp_index + t) * 3; + if ((e = tp[tp_index_t_3]) === 0) { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; + m--; + break; + } + } else if ((e & 32) !== 0) { + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_STREAM_END; + } else { + z.msg = "invalid literal/length code"; + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_DATA_ERROR; + } + } while (true); + } while (m >= 258 && n >= 10); + + // not enough input or output--restore pointers and return + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_OK; + } + + that.init = function(bl, bd, tl, tl_index, td, td_index) { + mode = START; + lbits = /* (byte) */bl; + dbits = /* (byte) */bd; + ltree = tl; + ltree_index = tl_index; + dtree = td; + dtree_index = td_index; + tree = null; + }; + + that.proc = function(s, z, r) { + var j; // temporary storage + var tindex; // temporary pointer + var e; // extra bits or operation + var b = 0; // bit buffer + var k = 0; // bits in bit buffer + var p = 0; // input data pointer + var n; // bytes available there + var q; // output window write pointer + var m; // bytes to end of window or read pointer + var f; // pointer to copy strings from + + // copy input/output information to locals (UPDATE macro restores) + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + // process input and output based on current state + while (true) { + switch (mode) { + // waiting for "i:"=input, "o:"=output, "x:"=nothing + case START: // x: set up for LEN + if (m >= 258 && n >= 10) { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); + + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (r != Z_OK) { + mode = r == Z_STREAM_END ? WASH : BADCODE; + break; + } + } + need = lbits; + tree = ltree; + tree_index = ltree_index; + + mode = LEN; + case LEN: // i: get length/literal/eob next + j = need; + + while (k < (j)) { + if (n !== 0) + r = Z_OK; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & inflate_mask[j])) * 3; + + b >>>= (tree[tindex + 1]); + k -= (tree[tindex + 1]); + + e = tree[tindex]; + + if (e === 0) { // literal + lit = tree[tindex + 2]; + mode = LIT; + break; + } + if ((e & 16) !== 0) { // length + get = e & 15; + len = tree[tindex + 2]; + mode = LENEXT; + break; + } + if ((e & 64) === 0) { // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + if ((e & 32) !== 0) { // end of block + mode = WASH; + break; + } + mode = BADCODE; // invalid code + z.msg = "invalid literal/length code"; + r = Z_DATA_ERROR; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case LENEXT: // i: getting length extra (have base) + j = get; + + while (k < (j)) { + if (n !== 0) + r = Z_OK; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + len += (b & inflate_mask[j]); + + b >>= j; + k -= j; + + need = dbits; + tree = dtree; + tree_index = dtree_index; + mode = DIST; + case DIST: // i: get distance next + j = need; + + while (k < (j)) { + if (n !== 0) + r = Z_OK; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & inflate_mask[j])) * 3; + + b >>= tree[tindex + 1]; + k -= tree[tindex + 1]; + + e = (tree[tindex]); + if ((e & 16) !== 0) { // distance + get = e & 15; + dist = tree[tindex + 2]; + mode = DISTEXT; + break; + } + if ((e & 64) === 0) { // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + mode = BADCODE; // invalid code + z.msg = "invalid distance code"; + r = Z_DATA_ERROR; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case DISTEXT: // i: getting distance extra + j = get; + + while (k < (j)) { + if (n !== 0) + r = Z_OK; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + dist += (b & inflate_mask[j]); + + b >>= j; + k -= j; + + mode = COPY; + case COPY: // o: copying bytes in window, waiting for space + f = q - dist; + while (f < 0) { // modulo window size-"while" instead + f += s.end; // of "if" handles invalid distances + } + while (len !== 0) { + + if (m === 0) { + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + + if (m === 0) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + } + + s.window[q++] = s.window[f++]; + m--; + + if (f == s.end) + f = 0; + len--; + } + mode = START; + break; + case LIT: // o: got literal, waiting for output space + if (m === 0) { + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + } + r = Z_OK; + + s.window[q++] = /* (byte) */lit; + m--; + + mode = START; + break; + case WASH: // o: got eob, possibly more output + if (k > 7) { // return unused byte, if any + k -= 8; + n++; + p--; // can always return one + } + + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (s.read != s.write) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + mode = END; + case END: + r = Z_STREAM_END; + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case BADCODE: // x: got error + + r = Z_DATA_ERROR; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + default: + r = Z_STREAM_ERROR; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + }; + + that.free = function() { + // ZFREE(z, c); + }; + + } + + // InfBlocks + + // Table for deflate from PKZIP's appnote.txt. + var border = [ // Order of the bit length code lengths + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; + + var TYPE = 0; // get type bits (3, including end bit) + var LENS = 1; // get lengths for stored + var STORED = 2;// processing stored block + var TABLE = 3; // get table lengths + var BTREE = 4; // get bit lengths tree for a dynamic + // block + var DTREE = 5; // get length, distance trees for a + // dynamic block + var CODES = 6; // processing fixed or dynamic block + var DRY = 7; // output remaining window bytes + var DONELOCKS = 8; // finished last block, done + var BADBLOCKS = 9; // ot a data error--stuck here + + function InfBlocks(z, w) { + var that = this; + + var mode = TYPE; // current inflate_block mode + + var left = 0; // if STORED, bytes left to copy + + var table = 0; // table lengths (14 bits) + var index = 0; // index into blens (or border) + var blens; // bit lengths of codes + var bb = [ 0 ]; // bit length tree depth + var tb = [ 0 ]; // bit length decoding tree + + var codes = new InfCodes(); // if CODES, current state + + var last = 0; // true if this block is the last block + + var hufts = new Int32Array(MANY * 3); // single malloc for tree space + var check = 0; // check on output + var inftree = new InfTree(); + + that.bitk = 0; // bits in bit buffer + that.bitb = 0; // bit buffer + that.window = new Uint8Array(w); // sliding window + that.end = w; // one byte after sliding window + that.read = 0; // window read pointer + that.write = 0; // window write pointer + + that.reset = function(z, c) { + if (c) + c[0] = check; + // if (mode == BTREE || mode == DTREE) { + // } + if (mode == CODES) { + codes.free(z); + } + mode = TYPE; + that.bitk = 0; + that.bitb = 0; + that.read = that.write = 0; + }; + + that.reset(z, null); + + // copy as much as possible from the sliding window to the output area + that.inflate_flush = function(z, r) { + var n; + var p; + var q; + + // local copies of source and destination pointers + p = z.next_out_index; + q = that.read; + + // compute number of bytes to copy as far as end of window + n = /* (int) */((q <= that.write ? that.write : that.end) - q); + if (n > z.avail_out) + n = z.avail_out; + if (n !== 0 && r == Z_BUF_ERROR) + r = Z_OK; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // copy as far as end of window + z.next_out.set(that.window.subarray(q, q + n), p); + p += n; + q += n; + + // see if more to copy at beginning of window + if (q == that.end) { + // wrap pointers + q = 0; + if (that.write == that.end) + that.write = 0; + + // compute bytes to copy + n = that.write - q; + if (n > z.avail_out) + n = z.avail_out; + if (n !== 0 && r == Z_BUF_ERROR) + r = Z_OK; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // copy + z.next_out.set(that.window.subarray(q, q + n), p); + p += n; + q += n; + } + + // update pointers + z.next_out_index = p; + that.read = q; + + // done + return r; + }; + + that.proc = function(z, r) { + var t; // temporary storage + var b; // bit buffer + var k; // bits in bit buffer + var p; // input data pointer + var n; // bytes available there + var q; // output window write pointer + var m; // bytes to end of window or read pointer + + var i; + + // copy input/output information to locals (UPDATE macro restores) + // { + p = z.next_in_index; + n = z.avail_in; + b = that.bitb; + k = that.bitk; + // } + // { + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + // } + + // process input based on current state + // DEBUG dtree + while (true) { + switch (mode) { + case TYPE: + + while (k < (3)) { + if (n !== 0) { + r = Z_OK; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + t = /* (int) */(b & 7); + last = t & 1; + + switch (t >>> 1) { + case 0: // stored + // { + b >>>= (3); + k -= (3); + // } + t = k & 7; // go to byte boundary + + // { + b >>>= (t); + k -= (t); + // } + mode = LENS; // get length of stored block + break; + case 1: // fixed + // { + var bl = []; // new Array(1); + var bd = []; // new Array(1); + var tl = [ [] ]; // new Array(1); + var td = [ [] ]; // new Array(1); + + InfTree.inflate_trees_fixed(bl, bd, tl, td); + codes.init(bl[0], bd[0], tl[0], 0, td[0], 0); + // } + + // { + b >>>= (3); + k -= (3); + // } + + mode = CODES; + break; + case 2: // dynamic + + // { + b >>>= (3); + k -= (3); + // } + + mode = TABLE; + break; + case 3: // illegal + + // { + b >>>= (3); + k -= (3); + // } + mode = BADBLOCKS; + z.msg = "invalid block type"; + r = Z_DATA_ERROR; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + break; + case LENS: + + while (k < (32)) { + if (n !== 0) { + r = Z_OK; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)) { + mode = BADBLOCKS; + z.msg = "invalid stored block lengths"; + r = Z_DATA_ERROR; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + left = (b & 0xffff); + b = k = 0; // dump bits + mode = left !== 0 ? STORED : (last !== 0 ? DRY : TYPE); + break; + case STORED: + if (n === 0) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + if (m === 0) { + if (q == that.end && that.read !== 0) { + q = 0; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + } + if (m === 0) { + that.write = q; + r = that.inflate_flush(z, r); + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + if (q == that.end && that.read !== 0) { + q = 0; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + } + if (m === 0) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + } + } + r = Z_OK; + + t = left; + if (t > n) + t = n; + if (t > m) + t = m; + that.window.set(z.read_buf(p, t), q); + p += t; + n -= t; + q += t; + m -= t; + if ((left -= t) !== 0) + break; + mode = last !== 0 ? DRY : TYPE; + break; + case TABLE: + + while (k < (14)) { + if (n !== 0) { + r = Z_OK; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + table = t = (b & 0x3fff); + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { + mode = BADBLOCKS; + z.msg = "too many length or distance symbols"; + r = Z_DATA_ERROR; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if (!blens || blens.length < t) { + blens = []; // new Array(t); + } else { + for (i = 0; i < t; i++) { + blens[i] = 0; + } + } + + // { + b >>>= (14); + k -= (14); + // } + + index = 0; + mode = BTREE; + case BTREE: + while (index < 4 + (table >>> 10)) { + while (k < (3)) { + if (n !== 0) { + r = Z_OK; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + blens[border[index++]] = b & 7; + + // { + b >>>= (3); + k -= (3); + // } + } + + while (index < 19) { + blens[border[index++]] = 0; + } + + bb[0] = 7; + t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z); + if (t != Z_OK) { + r = t; + if (r == Z_DATA_ERROR) { + blens = null; + mode = BADBLOCKS; + } + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + index = 0; + mode = DTREE; + case DTREE: + while (true) { + t = table; + if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) { + break; + } + + var j, c; + + t = bb[0]; + + while (k < (t)) { + if (n !== 0) { + r = Z_OK; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + // if (tb[0] == -1) { + // System.err.println("null..."); + // } + + t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1]; + c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2]; + + if (c < 16) { + b >>>= (t); + k -= (t); + blens[index++] = c; + } else { // c == 16..18 + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + + while (k < (t + i)) { + if (n !== 0) { + r = Z_OK; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + b >>>= (t); + k -= (t); + + j += (b & inflate_mask[i]); + + b >>>= (i); + k -= (i); + + i = index; + t = table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { + blens = null; + mode = BADBLOCKS; + z.msg = "invalid bit length repeat"; + r = Z_DATA_ERROR; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + c = c == 16 ? blens[i - 1] : 0; + do { + blens[i++] = c; + } while (--j !== 0); + index = i; + } + } + + tb[0] = -1; + // { + var bl_ = []; // new Array(1); + var bd_ = []; // new Array(1); + var tl_ = []; // new Array(1); + var td_ = []; // new Array(1); + bl_[0] = 9; // must be <= 9 for lookahead assumptions + bd_[0] = 6; // must be <= 9 for lookahead assumptions + + t = table; + t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl_, bd_, tl_, td_, hufts, z); + + if (t != Z_OK) { + if (t == Z_DATA_ERROR) { + blens = null; + mode = BADBLOCKS; + } + r = t; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + codes.init(bl_[0], bd_[0], hufts, tl_[0], hufts, td_[0]); + // } + mode = CODES; + case CODES: + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + + if ((r = codes.proc(that, z, r)) != Z_STREAM_END) { + return that.inflate_flush(z, r); + } + r = Z_OK; + codes.free(z); + + p = z.next_in_index; + n = z.avail_in; + b = that.bitb; + k = that.bitk; + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + + if (last === 0) { + mode = TYPE; + break; + } + mode = DRY; + case DRY: + that.write = q; + r = that.inflate_flush(z, r); + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + if (that.read != that.write) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + mode = DONELOCKS; + case DONELOCKS: + r = Z_STREAM_END; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + case BADBLOCKS: + r = Z_DATA_ERROR; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + + default: + r = Z_STREAM_ERROR; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + } + }; + + that.free = function(z) { + that.reset(z, null); + that.window = null; + hufts = null; + // ZFREE(z, s); + }; + + that.set_dictionary = function(d, start, n) { + that.window.set(d.subarray(start, start + n), 0); + that.read = that.write = n; + }; + + // Returns true if inflate is currently at the end of a block generated + // by Z_SYNC_FLUSH or Z_FULL_FLUSH. + that.sync_point = function() { + return mode == LENS ? 1 : 0; + }; + + } + + // Inflate + + // preset dictionary flag in zlib header + var PRESET_DICT = 0x20; + + var Z_DEFLATED = 8; + + var METHOD = 0; // waiting for method byte + var FLAG = 1; // waiting for flag byte + var DICT4 = 2; // four dictionary check bytes to go + var DICT3 = 3; // three dictionary check bytes to go + var DICT2 = 4; // two dictionary check bytes to go + var DICT1 = 5; // one dictionary check byte to go + var DICT0 = 6; // waiting for inflateSetDictionary + var BLOCKS = 7; // decompressing blocks + var DONE = 12; // finished check, done + var BAD = 13; // got an error--stay here + + var mark = [ 0, 0, 0xff, 0xff ]; + + function Inflate() { + var that = this; + + that.mode = 0; // current inflate mode + + // mode dependent information + that.method = 0; // if FLAGS, method byte + + // if CHECK, check values to compare + that.was = [ 0 ]; // new Array(1); // computed check value + that.need = 0; // stream check value + + // if BAD, inflateSync's marker bytes count + that.marker = 0; + + // mode independent information + that.wbits = 0; // log2(window size) (8..15, defaults to 15) + + // this.blocks; // current inflate_blocks state + + function inflateReset(z) { + if (!z || !z.istate) + return Z_STREAM_ERROR; + + z.total_in = z.total_out = 0; + z.msg = null; + z.istate.mode = BLOCKS; + z.istate.blocks.reset(z, null); + return Z_OK; + } + + that.inflateEnd = function(z) { + if (that.blocks) + that.blocks.free(z); + that.blocks = null; + // ZFREE(z, z->state); + return Z_OK; + }; + + that.inflateInit = function(z, w) { + z.msg = null; + that.blocks = null; + + // set window size + if (w < 8 || w > 15) { + that.inflateEnd(z); + return Z_STREAM_ERROR; + } + that.wbits = w; + + z.istate.blocks = new InfBlocks(z, 1 << w); + + // reset state + inflateReset(z); + return Z_OK; + }; + + that.inflate = function(z, f) { + var r; + var b; + + if (!z || !z.istate || !z.next_in) + return Z_STREAM_ERROR; + f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; + r = Z_BUF_ERROR; + while (true) { + // System.out.println("mode: "+z.istate.mode); + switch (z.istate.mode) { + case METHOD: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + if (((z.istate.method = z.read_byte(z.next_in_index++)) & 0xf) != Z_DEFLATED) { + z.istate.mode = BAD; + z.msg = "unknown compression method"; + z.istate.marker = 5; // can't try inflateSync + break; + } + if ((z.istate.method >> 4) + 8 > z.istate.wbits) { + z.istate.mode = BAD; + z.msg = "invalid window size"; + z.istate.marker = 5; // can't try inflateSync + break; + } + z.istate.mode = FLAG; + case FLAG: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + b = (z.read_byte(z.next_in_index++)) & 0xff; + + if ((((z.istate.method << 8) + b) % 31) !== 0) { + z.istate.mode = BAD; + z.msg = "incorrect header check"; + z.istate.marker = 5; // can't try inflateSync + break; + } + + if ((b & PRESET_DICT) === 0) { + z.istate.mode = BLOCKS; + break; + } + z.istate.mode = DICT4; + case DICT4: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + z.istate.need = ((z.read_byte(z.next_in_index++) & 0xff) << 24) & 0xff000000; + z.istate.mode = DICT3; + case DICT3: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + z.istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 16) & 0xff0000; + z.istate.mode = DICT2; + case DICT2: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + z.istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 8) & 0xff00; + z.istate.mode = DICT1; + case DICT1: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + z.istate.need += (z.read_byte(z.next_in_index++) & 0xff); + z.istate.mode = DICT0; + return Z_NEED_DICT; + case DICT0: + z.istate.mode = BAD; + z.msg = "need dictionary"; + z.istate.marker = 0; // can try inflateSync + return Z_STREAM_ERROR; + case BLOCKS: + + r = z.istate.blocks.proc(z, r); + if (r == Z_DATA_ERROR) { + z.istate.mode = BAD; + z.istate.marker = 0; // can try inflateSync + break; + } + if (r == Z_OK) { + r = f; + } + if (r != Z_STREAM_END) { + return r; + } + r = f; + z.istate.blocks.reset(z, z.istate.was); + z.istate.mode = DONE; + case DONE: + return Z_STREAM_END; + case BAD: + return Z_DATA_ERROR; + default: + return Z_STREAM_ERROR; + } + } + }; + + that.inflateSetDictionary = function(z, dictionary, dictLength) { + var index = 0; + var length = dictLength; + if (!z || !z.istate || z.istate.mode != DICT0) + return Z_STREAM_ERROR; + + if (length >= (1 << z.istate.wbits)) { + length = (1 << z.istate.wbits) - 1; + index = dictLength - length; + } + z.istate.blocks.set_dictionary(dictionary, index, length); + z.istate.mode = BLOCKS; + return Z_OK; + }; + + that.inflateSync = function(z) { + var n; // number of bytes to look at + var p; // pointer to bytes + var m; // number of marker bytes found in a row + var r, w; // temporaries to save total_in and total_out + + // set up + if (!z || !z.istate) + return Z_STREAM_ERROR; + if (z.istate.mode != BAD) { + z.istate.mode = BAD; + z.istate.marker = 0; + } + if ((n = z.avail_in) === 0) + return Z_BUF_ERROR; + p = z.next_in_index; + m = z.istate.marker; + + // search + while (n !== 0 && m < 4) { + if (z.read_byte(p) == mark[m]) { + m++; + } else if (z.read_byte(p) !== 0) { + m = 0; + } else { + m = 4 - m; + } + p++; + n--; + } + + // restore + z.total_in += p - z.next_in_index; + z.next_in_index = p; + z.avail_in = n; + z.istate.marker = m; + + // return no joy or set up to restart on a new block + if (m != 4) { + return Z_DATA_ERROR; + } + r = z.total_in; + w = z.total_out; + inflateReset(z); + z.total_in = r; + z.total_out = w; + z.istate.mode = BLOCKS; + return Z_OK; + }; + + // Returns true if inflate is currently at the end of a block generated + // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + // implementation to provide an additional safety check. PPP uses + // Z_SYNC_FLUSH + // but removes the length bytes of the resulting empty stored block. When + // decompressing, PPP checks that at the end of input packet, inflate is + // waiting for these length bytes. + that.inflateSyncPoint = function(z) { + if (!z || !z.istate || !z.istate.blocks) + return Z_STREAM_ERROR; + return z.istate.blocks.sync_point(); + }; + } + + // ZStream + + function ZStream() { + } + + ZStream.prototype = { + inflateInit : function(bits) { + var that = this; + that.istate = new Inflate(); + if (!bits) + bits = MAX_BITS; + return that.istate.inflateInit(that, bits); + }, + + inflate : function(f) { + var that = this; + if (!that.istate) + return Z_STREAM_ERROR; + return that.istate.inflate(that, f); + }, + + inflateEnd : function() { + var that = this; + if (!that.istate) + return Z_STREAM_ERROR; + var ret = that.istate.inflateEnd(that); + that.istate = null; + return ret; + }, + + inflateSync : function() { + var that = this; + if (!that.istate) + return Z_STREAM_ERROR; + return that.istate.inflateSync(that); + }, + inflateSetDictionary : function(dictionary, dictLength) { + var that = this; + if (!that.istate) + return Z_STREAM_ERROR; + return that.istate.inflateSetDictionary(that, dictionary, dictLength); + }, + read_byte : function(start) { + var that = this; + return that.next_in.subarray(start, start + 1)[0]; + }, + read_buf : function(start, size) { + var that = this; + return that.next_in.subarray(start, start + size); + } + }; + + // Inflater + + function Inflater() { + var that = this; + var z = new ZStream(); + var bufsize = 512; + var flush = Z_NO_FLUSH; + var buf = new Uint8Array(bufsize); + var nomoreinput = false; + + z.inflateInit(); + z.next_out = buf; + + that.append = function(data, onprogress) { + var err, buffers = [], lastIndex = 0, bufferIndex = 0, bufferSize = 0, array; + if (data.length === 0) + return; + z.next_in_index = 0; + z.next_in = data; + z.avail_in = data.length; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + if ((z.avail_in === 0) && (!nomoreinput)) { // if buffer is empty and more input is available, refill it + z.next_in_index = 0; + nomoreinput = true; + } + err = z.inflate(flush); + if (nomoreinput && (err == Z_BUF_ERROR)) + return -1; + if (err != Z_OK && err != Z_STREAM_END) + throw "inflating: " + z.msg; + if ((nomoreinput || err == Z_STREAM_END) && (z.avail_in == data.length)) + return -1; + if (z.next_out_index) + if (z.next_out_index == bufsize) + buffers.push(new Uint8Array(buf)); + else + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { + onprogress(z.next_in_index); + lastIndex = z.next_in_index; + } + } while (z.avail_in > 0 || z.avail_out === 0); + array = new Uint8Array(bufferSize); + buffers.forEach(function(chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + that.flush = function() { + z.inflateEnd(); + }; + } + + var inflater; + + if (obj.zip) + obj.zip.Inflater = Inflater; + else { + inflater = new Inflater(); + obj.addEventListener("message", function(event) { + var message = event.data; + + if (message.append) + obj.postMessage({ + onappend : true, + data : inflater.append(message.data, function(current) { + obj.postMessage({ + progress : true, + current : current + }); + }) + }); + if (message.flush) { + inflater.flush(); + obj.postMessage({ + onflush : true + }); + } + }, false); + } + +})(this); diff --git a/demo/js/libs/inflate.min.js b/demo/js/libs/inflate.min.js index d396359..0a745ad 100644 --- a/demo/js/libs/inflate.min.js +++ b/demo/js/libs/inflate.min.js @@ -1 +1 @@ -(function(e){function S(){function h(e,t,r,u,h,p,d,v,m,g,y){var b,w,S,x,T,N,C,k,L,A,O,M,_,D,P;A=0,T=r;do i[e[t+A]]++,A++,T--;while(T!==0);if(i[0]==r)return d[0]=-1,v[0]=0,n;k=v[0];for(N=1;N<=E;N++)if(i[N]!==0)break;C=N,kT&&(k=T),v[0]=k;for(D=1<M+k){x++,M+=k,P=S-M,P=P>k?k:P;if((w=1<<(N=C-M))>b+1){w-=b+1,_=C;if(Nl)return o;f[x]=O=g[0],g[0]+=P,x!==0?(c[x]=T,s[0]=N,s[1]=k,N=T>>>M-k,s[2]=O-f[x-1]-N,m.set(s,(f[x-1]+N)*3)):d[0]=O}s[1]=C-M,A>=r?s[0]=192:y[A]>>M;N>>=1)T^=N;T^=N,L=(1<257?(E==o?m.msg="oversubscribed distance tree":E==a?(m.msg="incomplete distance tree",E=o):E!=u&&(m.msg="empty distance tree with lengths",E=o),E):n)}}function D(){function w(e,t,i,s,u,a,l,c){var h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k;y=c.next_in_index,b=c.avail_in,m=l.bitb,g=l.bitk,w=l.write,E=w>=p[k+1],g-=p[k+1],l.window[w++]=p[k+2],E--;continue}do{m>>=p[k+1],g-=p[k+1];if((v&16)!==0){v&=15,T=p[k+2]+(m&f[v]),m>>=v,g-=v;while(g<15)b--,m|=(c.read_byte(y++)&255)<>=p[k+1],g-=p[k+1];if((v&16)!==0){v&=15;while(g>=v,g-=v,E-=T;if(w>=N)C=w-N,w-C>0&&2>w-C?(l.window[w++]=l.window[C++],l.window[w++]=l.window[C++],T-=2):(l.window.set(l.window.subarray(C,C+2),w),w+=2,C+=2,T-=2);else{C=w-N;do C+=l.end;while(C<0);v=l.end-C;if(T>v){T-=v;if(w-C>0&&v>w-C){do l.window[w++]=l.window[C++];while(--v!==0)}else l.window.set(l.window.subarray(C,C+v),w),w+=v,C+=v,v=0;C=0}}if(w-C>0&&T>w-C){do l.window[w++]=l.window[C++];while(--T!==0)}else l.window.set(l.window.subarray(C,C+T),w),w+=T,C+=T,T=0;break}if((v&64)!==0)return c.msg="invalid distance code",T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,o;h+=p[k+2],h+=m&f[v],k=(d+h)*3,v=p[k]}while(!0);break}if((v&64)!==0)return(v&32)!==0?(T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,r):(c.msg="invalid literal/length code",T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,o);h+=p[k+2],h+=m&f[v],k=(d+h)*3;if((v=p[k])===0){m>>=p[k+1],g-=p[k+1],l.window[w++]=p[k+2],E--;break}}while(!0)}while(E>=258&&b>=10);return T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,n}var e=this,t,i=0,u,a=0,l=0,c=0,h=0,p=0,d=0,v=0,m,g=0,y,b=0;e.init=function(e,n,r,i,s,o){t=x,d=e,v=n,m=r,g=i,y=s,b=o,u=null},e.proc=function(e,E,S){var D,P,H,B=0,j=0,F=0,I,q,R,U;F=E.next_in_index,I=E.avail_in,B=e.bitb,j=e.bitk,q=e.write,R=q=258&&I>=10){e.bitb=B,e.bitk=j,E.avail_in=I,E.total_in+=F-E.next_in_index,E.next_in_index=F,e.write=q,S=w(d,v,m,g,y,b,e,E),F=E.next_in_index,I=E.avail_in,B=e.bitb,j=e.bitk,q=e.write,R=q>>=u[P+1],j-=u[P+1],H=u[P];if(H===0){c=u[P+2],t=A;break}if((H&16)!==0){h=H&15,i=u[P+2],t=N;break}if((H&64)===0){l=H,a=P/3+u[P+2];break}if((H&32)!==0){t=O;break}return t=_,E.msg="invalid literal/length code",S=o,e.bitb=B,e.bitk=j,E.avail_in=I,E.total_in+=F-E.next_in_index,E.next_in_index=F,e.write=q,e.inflate_flush(E,S);case N:D=h;while(j>=D,j-=D,l=v,u=y,a=b,t=C;case C:D=l;while(j>=u[P+1],j-=u[P+1],H=u[P];if((H&16)!==0){h=H&15,p=u[P+2],t=k;break}if((H&64)===0){l=H,a=P/3+u[P+2];break}return t=_,E.msg="invalid distance code",S=o,e.bitb=B,e.bitk=j,E.avail_in=I,E.total_in+=F-E.next_in_index,E.next_in_index=F,e.write=q,e.inflate_flush(E,S);case k:D=h;while(j>=D,j-=D,t=L;case L:U=q-p;while(U<0)U+=e.end;while(i!==0){if(R===0){q==e.end&&e.read!==0&&(q=0,R=q7&&(j-=8,I++,F--),e.write=q,S=e.inflate_flush(E,S),q=e.write,R=qe.avail_out&&(r=e.avail_out),r!==0&&t==a&&(t=n),e.avail_out-=r,e.total_out+=r,e.next_out.set(i.window.subarray(o,o+r),s),s+=r,o+=r,o==i.end&&(o=0,i.write==i.end&&(i.write=0),r=i.write-o,r>e.avail_out&&(r=e.avail_out),r!==0&&t==a&&(t=n),e.avail_out-=r,e.total_out+=r,e.next_out.set(i.window.subarray(o,o+r),s),s+=r,o+=r),e.next_out_index=s,i.read=o,t},i.proc=function(e,t){var a,l,w,x,T,N,C,k;x=e.next_in_index,T=e.avail_in,l=i.bitb,w=i.bitk,N=i.write,C=N>>1){case 0:l>>>=3,w-=3,a=w&7,l>>>=a,w-=a,u=B;break;case 1:var L=[],A=[],O=[[]],M=[[]];S.inflate_trees_fixed(L,A,O,M),g.init(L[0],A[0],O[0],0,M[0],0),l>>>=3,w-=3,u=R;break;case 2:l>>>=3,w-=3,u=F;break;case 3:return l>>>=3,w-=3,u=W,e.msg="invalid block type",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t)}break;case B:while(w<32){if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);t=n,T--,l|=(e.read_byte(x++)&255)<>>16&65535)!=(l&65535))return u=W,e.msg="invalid stored block lengths",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);c=l&65535,l=w=0,u=c!==0?j:y!==0?U:H;break;case j:if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);if(C===0){N==i.end&&i.read!==0&&(N=0,C=NT&&(a=T),a>C&&(a=C),i.window.set(e.read_buf(x,a),N),x+=a,T-=a,N+=a,C-=a;if((c-=a)!==0)break;u=y!==0?U:H;break;case F:while(w<14){if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);t=n,T--,l|=(e.read_byte(x++)&255)<29||(a>>5&31)>29)return u=W,e.msg="too many length or distance symbols",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);a=258+(a&31)+(a>>5&31);if(!d||d.length>>=14,w-=14,p=0,u=I;case I:while(p<4+(h>>>10)){while(w<3){if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);t=n,T--,l|=(e.read_byte(x++)&255)<>>=3,w-=3}while(p<19)d[P[p++]]=0;v[0]=7,a=E.inflate_trees_bits(d,v,m,b,e);if(a!=n)return t=a,t==o&&(d=null,u=W),i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);p=0,u=q;case q:for(;;){a=h;if(!(p<258+(a&31)+(a>>5&31)))break;var _,D;a=v[0];while(w>>=a,w-=a,d[p++]=D;else{k=D==18?7:D-14,_=D==18?11:3;while(w>>=a,w-=a,_+=l&f[k],l>>>=k,w-=k,k=p,a=h;if(k+_>258+(a&31)+(a>>5&31)||D==16&&k<1)return d=null,u=W,e.msg="invalid bit length repeat",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);D=D==16?d[k-1]:0;do d[k++]=D;while(--_!==0);p=k}}m[0]=-1;var X=[],V=[],$=[],J=[];X[0]=9,V[0]=6,a=h,a=E.inflate_trees_dynamic(257+(a&31),1+(a>>5&31),d,X,V,$,J,b,e);if(a!=n)return a==o&&(d=null,u=W),t=a,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);g.init(X[0],V[0],b,$[0],b,J[0]),u=R;case R:i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N;if((t=g.proc(i,e,t))!=r)return i.inflate_flush(e,t);t=n,g.free(e),x=e.next_in_index,T=e.avail_in,l=i.bitb,w=i.bitk,N=i.write,C=N15?(e.inflateEnd(r),s):(e.wbits=i,r.istate.blocks=new X(r,1<>4)+8>e.istate.wbits){e.istate.mode=rt,e.msg="invalid window size",e.istate.marker=5;break}e.istate.mode=K;case K:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,f=e.read_byte(e.next_in_index++)&255;if(((e.istate.method<<8)+f)%31!==0){e.istate.mode=rt,e.msg="incorrect header check",e.istate.marker=5;break}if((f&V)===0){e.istate.mode=tt;break}e.istate.mode=Q;case Q:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,e.istate.need=(e.read_byte(e.next_in_index++)&255)<<24&4278190080,e.istate.mode=G;case G:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,e.istate.need+=(e.read_byte(e.next_in_index++)&255)<<16&16711680,e.istate.mode=Y;case Y:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,e.istate.need+=(e.read_byte(e.next_in_index++)&255)<<8&65280,e.istate.mode=Z;case Z:if(e.avail_in===0)return u;return u=t,e.avail_in--,e.total_in++,e.istate.need+=e.read_byte(e.next_in_index++)&255,e.istate.mode=et,i;case et:return e.istate.mode=rt,e.msg="need dictionary",e.istate.marker=0,s;case tt:u=e.istate.blocks.proc(e,u);if(u==o){e.istate.mode=rt,e.istate.marker=0;break}u==n&&(u=t);if(u!=r)return u;u=t,e.istate.blocks.reset(e,e.istate.was),e.istate.mode=nt;case nt:return r;case rt:return o;default:return s}},e.inflateSetDictionary=function(e,t,r){var i=0,o=r;return!e||!e.istate||e.istate.mode!=et?s:(o>=1<0&&t.next_in_index!=h&&(f(t.next_in_index),h=t.next_in_index)}while(t.avail_in>0||t.avail_out===0);return v=new Uint8Array(d),c.forEach(function(e){v.set(e,p),p+=e.length}),v},e.flush=function(){t.inflateEnd()}}var t=15,n=0,r=1,i=2,s=-2,o=-3,u=-4,a=-5,f=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],l=1440,c=0,h=4,p=9,d=5,v=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],m=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],g=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],y=[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,112,112],b=[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],w=[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],E=15;S.inflate_trees_fixed=function(e,t,r,i){return e[0]=p,t[0]=d,r[0]=v,i[0]=m,n};var x=0,T=1,N=2,C=3,k=4,L=5,A=6,O=7,M=8,_=9,P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=0,B=1,j=2,F=3,I=4,q=5,R=6,U=7,z=8,W=9,V=32,$=8,J=0,K=1,Q=2,G=3,Y=4,Z=5,et=6,tt=7,nt=12,rt=13,it=[0,0,255,255];ot.prototype={inflateInit:function(e){var n=this;return n.istate=new st,e||(e=t),n.istate.inflateInit(n,e)},inflate:function(e){var t=this;return t.istate?t.istate.inflate(t,e):s},inflateEnd:function(){var e=this;if(!e.istate)return s;var t=e.istate.inflateEnd(e);return e.istate=null,t},inflateSync:function(){var e=this;return e.istate?e.istate.inflateSync(e):s},inflateSetDictionary:function(e,t){var n=this;return n.istate?n.istate.inflateSetDictionary(n,e,t):s},read_byte:function(e){var t=this;return t.next_in.subarray(e,e+1)[0]},read_buf:function(e,t){var n=this;return n.next_in.subarray(e,e+t)}};var at;e.zip?e.zip.Inflater=ut:(at=new ut,e.addEventListener("message",function(t){var n=t.data;n.append&&e.postMessage({onappend:!0,data:at.append(n.data,function(t){e.postMessage({progress:!0,current:t})})}),n.flush&&(at.flush(),e.postMessage({onflush:!0}))},!1))})(this); \ No newline at end of file +!function(a){function b(){function a(a,b,c,d,j,k,l,n,p,r,s){var t,u,v,w,x,y,z,A,C,D,E,F,G,H,I;D=0,x=c;do e[a[b+D]]++,D++,x--;while(0!==x);if(e[0]==c)return l[0]=-1,n[0]=0,i;for(A=n[0],y=1;B>=y&&0===e[y];y++);for(z=y,y>A&&(A=y),x=B;0!==x&&0===e[x];x--);for(v=x,A>x&&(A=x),n[0]=A,H=1<y;y++,H<<=1)if((H-=e[y])<0)return m;if((H-=e[x])<0)return m;for(e[x]+=H,h[1]=y=0,D=1,G=2;0!==--x;)h[G]=y+=e[D],G++,D++;x=0,D=0;do 0!==(y=a[b+D])&&(s[h[y]++]=x),D++;while(++x=z;z++)for(t=e[z];0!==t--;){for(;z>F+A;){if(w++,F+=A,I=v-F,I=I>A?A:I,(u=1<<(y=z-F))>t+1&&(u-=t+1,G=z,I>y))for(;++yq)return m;g[w]=E=r[0],r[0]+=I,0!==w?(h[w]=x,f[0]=y,f[1]=A,y=x>>>F-A,f[2]=E-g[w-1]-y,p.set(f,3*(g[w-1]+y))):l[0]=E}for(f[1]=z-F,D>=c?f[0]=192:s[D]>>F;I>y;y+=u)p.set(f,3*(E+y));for(y=1<>>=1)x^=y;for(x^=y,C=(1<b;b++)d[b]=0;for(b=0;B+1>b;b++)e[b]=0;for(b=0;3>b;b++)f[b]=0;g.set(e.subarray(0,B),0),h.set(e.subarray(0,B+1),0)}var c,d,e,f,g,h,j=this;j.inflate_trees_bits=function(e,f,g,h,i){var j;return b(19),c[0]=0,j=a(e,0,19,19,null,null,g,f,h,c,d),j==m?i.msg="oversubscribed dynamic bit lengths tree":(j==o||0===f[0])&&(i.msg="incomplete dynamic bit lengths tree",j=m),j},j.inflate_trees_dynamic=function(e,f,g,h,j,k,l,p,q){var r;return b(288),c[0]=0,r=a(g,0,e,257,x,y,k,h,p,c,d),r!=i||0===h[0]?(r==m?q.msg="oversubscribed literal/length tree":r!=n&&(q.msg="incomplete literal/length tree",r=m),r):(b(288),r=a(g,e,f,0,z,A,l,j,p,c,d),r!=i||0===j[0]&&e>257?(r==m?q.msg="oversubscribed distance tree":r==o?(q.msg="incomplete distance tree",r=m):r!=n&&(q.msg="empty distance tree with lengths",r=m),r):i)}}function c(){function a(a,b,c,d,e,f,g,h){var k,l,n,o,q,r,s,t,u,v,w,x,y,z,A,B;s=h.next_in_index,t=h.avail_in,q=g.bitb,r=g.bitk,u=g.write,v=ur;)t--,q|=(255&h.read_byte(s++))<>=l[B+1],r-=l[B+1],0!==(16&o)){for(o&=15,y=l[B+2]+(q&p[o]),q>>=o,r-=o;15>r;)t--,q|=(255&h.read_byte(s++))<>=l[B+1],r-=l[B+1],0!==(16&o)){for(o&=15;o>r;)t--,q|=(255&h.read_byte(s++))<>=o,r-=o,v-=y,u>=z)A=u-z,u-A>0&&2>u-A?(g.window[u++]=g.window[A++],g.window[u++]=g.window[A++],y-=2):(g.window.set(g.window.subarray(A,A+2),u),u+=2,A+=2,y-=2);else{A=u-z;do A+=g.end;while(0>A);if(o=g.end-A,y>o){if(y-=o,u-A>0&&o>u-A){do g.window[u++]=g.window[A++];while(0!==--o)}else g.window.set(g.window.subarray(A,A+o),u),u+=o,A+=o,o=0;A=0}}if(u-A>0&&y>u-A){do g.window[u++]=g.window[A++];while(0!==--y)}else g.window.set(g.window.subarray(A,A+y),u),u+=y,A+=y,y=0;break}if(0!==(64&o))return h.msg="invalid distance code",y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,m;k+=l[B+2],k+=q&p[o],B=3*(n+k),o=l[B]}break}if(0!==(64&o))return 0!==(32&o)?(y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,j):(h.msg="invalid literal/length code",y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,m);if(k+=l[B+2],k+=q&p[o],B=3*(n+k),0===(o=l[B])){q>>=l[B+1],r-=l[B+1],g.window[u++]=l[B+2],v--;break}}else q>>=l[B+1],r-=l[B+1],g.window[u++]=l[B+2],v--}while(v>=258&&t>=10);return y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,i}var b,c,d,e,f=this,g=0,h=0,k=0,n=0,o=0,q=0,r=0,s=0,t=0,u=0;f.init=function(a,f,g,h,i,j){b=C,r=a,s=f,d=g,t=h,e=i,u=j,c=null},f.proc=function(f,v,w){var x,y,z,A,B,M,N,O=0,P=0,Q=0;for(Q=v.next_in_index,A=v.avail_in,O=f.bitb,P=f.bitk,B=f.write,M=B=258&&A>=10&&(f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,w=a(r,s,d,t,e,u,f,v),Q=v.next_in_index,A=v.avail_in,O=f.bitb,P=f.bitk,B=f.write,M=BP;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>>=c[y+1],P-=c[y+1],z=c[y],0===z){n=c[y+2],b=I;break}if(0!==(16&z)){o=15&z,g=c[y+2],b=E;break}if(0===(64&z)){k=z,h=y/3+c[y+2];break}if(0!==(32&z)){b=J;break}return b=L,v.msg="invalid literal/length code",w=m,f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);case E:for(x=o;x>P;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>=x,P-=x,k=s,c=e,h=u,b=F;case F:for(x=k;x>P;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>=c[y+1],P-=c[y+1],z=c[y],0!==(16&z)){o=15&z,q=c[y+2],b=G;break}if(0===(64&z)){k=z,h=y/3+c[y+2];break}return b=L,v.msg="invalid distance code",w=m,f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);case G:for(x=o;x>P;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>=x,P-=x,b=H;case H:for(N=B-q;0>N;)N+=f.end;for(;0!==g;){if(0===M&&(B==f.end&&0!==f.read&&(B=0,M=B7&&(P-=8,A++,Q--),f.write=B,w=f.inflate_flush(v,w),B=f.write,M=Ba.avail_out&&(c=a.avail_out),0!==c&&b==o&&(b=i),a.avail_out-=c,a.total_out+=c,a.next_out.set(f.window.subarray(e,e+c),d),d+=c,e+=c,e==f.end&&(e=0,f.write==f.end&&(f.write=0),c=f.write-e,c>a.avail_out&&(c=a.avail_out),0!==c&&b==o&&(b=i),a.avail_out-=c,a.total_out+=c,a.next_out.set(f.window.subarray(e,e+c),d),d+=c,e+=c),a.next_out_index=d,f.read=e,b},f.proc=function(a,c){var d,o,q,w,y,z,A,B;for(w=a.next_in_index,y=a.avail_in,o=f.bitb,q=f.bitk,z=f.write,A=zq;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>1){case 0:o>>>=3,q-=3,d=7&q,o>>>=d,q-=d,g=O;break;case 1:var C=[],D=[],E=[[]],F=[[]];b.inflate_trees_fixed(C,D,E,F),t.init(C[0],D[0],E[0],0,F[0],0),o>>>=3,q-=3,g=T;break;case 2:o>>>=3,q-=3,g=Q;break;case 3:return o>>>=3,q-=3,g=W,a.msg="invalid block type",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c)}break;case O:for(;32>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>16)!=(65535&o))return g=W,a.msg="invalid stored block lengths",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);h=65535&o,o=q=0,g=0!==h?P:0!==u?U:N;break;case P:if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);if(0===A&&(z==f.end&&0!==f.read&&(z=0,A=zy&&(d=y),d>A&&(d=A),f.window.set(a.read_buf(w,d),z),w+=d,y-=d,z+=d,A-=d,0!==(h-=d))break;g=0!==u?U:N;break;case Q:for(;14>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<29||(31&d>>5)>29)return g=W,a.msg="too many length or distance symbols",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);if(d=258+(31&d)+(31&d>>5),!e||e.lengthB;B++)e[B]=0;o>>>=14,q-=14,n=0,g=R;case R:for(;4+(k>>>10)>n;){for(;3>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>=3,q-=3}for(;19>n;)e[M[n++]]=0;if(r[0]=7,d=x.inflate_trees_bits(e,r,s,v,a),d!=i)return c=d,c==m&&(e=null,g=W),f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);n=0,g=S;case S:for(;;){if(d=k,!(258+(31&d)+(31&d>>5)>n))break;var G,H;for(d=r[0];d>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<H)o>>>=d,q-=d,e[n++]=H;else{for(B=18==H?7:H-14,G=18==H?11:3;d+B>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>=d,q-=d,G+=o&p[B],o>>>=B,q-=B,B=n,d=k,B+G>258+(31&d)+(31&d>>5)||16==H&&1>B)return e=null,g=W,a.msg="invalid bit length repeat",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);H=16==H?e[B-1]:0;do e[B++]=H;while(0!==--G);n=B}}s[0]=-1;var I=[],J=[],K=[],L=[];if(I[0]=9,J[0]=6,d=k,d=x.inflate_trees_dynamic(257+(31&d),1+(31&d>>5),e,I,J,K,L,v,a),d!=i)return d==m&&(e=null,g=W),c=d,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);t.init(I[0],J[0],v,K[0],v,L[0]),g=T;case T:if(f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,(c=t.proc(f,a,c))!=j)return f.inflate_flush(a,c);if(c=i,t.free(a),w=a.next_in_index,y=a.avail_in,o=f.bitb,q=f.bitk,z=f.write,A=ze||e>15?(b.inflateEnd(c),l):(b.wbits=e,c.istate.blocks=new d(c,1<>4)+8>a.istate.wbits){a.istate.mode=gb,a.msg="invalid window size",a.istate.marker=5;break}a.istate.mode=$;case $:if(0===a.avail_in)return c;if(c=b,a.avail_in--,a.total_in++,d=255&a.read_byte(a.next_in_index++),0!==((a.istate.method<<8)+d)%31){a.istate.mode=gb,a.msg="incorrect header check",a.istate.marker=5;break}if(0===(d&X)){a.istate.mode=eb;break}a.istate.mode=_;case _:if(0===a.avail_in)return c;c=b,a.avail_in--,a.total_in++,a.istate.need=4278190080&(255&a.read_byte(a.next_in_index++))<<24,a.istate.mode=ab;case ab:if(0===a.avail_in)return c;c=b,a.avail_in--,a.total_in++,a.istate.need+=16711680&(255&a.read_byte(a.next_in_index++))<<16,a.istate.mode=bb;case bb:if(0===a.avail_in)return c;c=b,a.avail_in--,a.total_in++,a.istate.need+=65280&(255&a.read_byte(a.next_in_index++))<<8,a.istate.mode=cb;case cb:return 0===a.avail_in?c:(c=b,a.avail_in--,a.total_in++,a.istate.need+=255&a.read_byte(a.next_in_index++),a.istate.mode=db,k);case db:return a.istate.mode=gb,a.msg="need dictionary",a.istate.marker=0,l;case eb:if(c=a.istate.blocks.proc(a,c),c==m){a.istate.mode=gb,a.istate.marker=0;break}if(c==i&&(c=b),c!=j)return c;c=b,a.istate.blocks.reset(a,a.istate.was),a.istate.mode=fb;case fb:return j;case gb:return m;default:return l}},b.inflateSetDictionary=function(a,b,c){var d=0,e=c;return a&&a.istate&&a.istate.mode==db?(e>=1<e;)b.read_byte(d)==hb[e]?e++:e=0!==b.read_byte(d)?0:4-e,d++,c--;return b.total_in+=d-b.next_in_index,b.next_in_index=d,b.avail_in=c,b.istate.marker=e,4!=e?m:(f=b.total_in,g=b.total_out,a(b),b.total_in=f,b.total_out=g,b.istate.mode=eb,i)},b.inflateSyncPoint=function(a){return a&&a.istate&&a.istate.blocks?a.istate.blocks.sync_point():l}}function f(){}function g(){var a=this,b=new f,c=512,d=r,e=new Uint8Array(c),g=!1;b.inflateInit(),b.next_out=e,a.append=function(a,f){var h,k,l=[],m=0,n=0,p=0;if(0!==a.length){b.next_in_index=0,b.next_in=a,b.avail_in=a.length;do{if(b.next_out_index=0,b.avail_out=c,0!==b.avail_in||g||(b.next_in_index=0,g=!0),h=b.inflate(d),g&&h==o)return-1;if(h!=i&&h!=j)throw"inflating: "+b.msg;if((g||h==j)&&b.avail_in==a.length)return-1;b.next_out_index&&(b.next_out_index==c?l.push(new Uint8Array(e)):l.push(new Uint8Array(e.subarray(0,b.next_out_index)))),p+=b.next_out_index,f&&b.next_in_index>0&&b.next_in_index!=m&&(f(b.next_in_index),m=b.next_in_index)}while(b.avail_in>0||0===b.avail_out);return k=new Uint8Array(p),l.forEach(function(a){k.set(a,n),n+=a.length}),k}},a.flush=function(){b.inflateEnd()}}var h=15,i=0,j=1,k=2,l=-2,m=-3,n=-4,o=-5,p=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],q=1440,r=0,s=4,t=9,u=5,v=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],w=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],x=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],y=[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,112,112],z=[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],A=[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],B=15;b.inflate_trees_fixed=function(a,b,c,d){return a[0]=t,b[0]=u,c[0]=v,d[0]=w,i};var C=0,D=1,E=2,F=3,G=4,H=5,I=6,J=7,K=8,L=9,M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=0,O=1,P=2,Q=3,R=4,S=5,T=6,U=7,V=8,W=9,X=32,Y=8,Z=0,$=1,_=2,ab=3,bb=4,cb=5,db=6,eb=7,fb=12,gb=13,hb=[0,0,255,255];f.prototype={inflateInit:function(a){var b=this;return b.istate=new e,a||(a=h),b.istate.inflateInit(b,a)},inflate:function(a){var b=this;return b.istate?b.istate.inflate(b,a):l},inflateEnd:function(){var a=this;if(!a.istate)return l;var b=a.istate.inflateEnd(a);return a.istate=null,b},inflateSync:function(){var a=this;return a.istate?a.istate.inflateSync(a):l},inflateSetDictionary:function(a,b){var c=this;return c.istate?c.istate.inflateSetDictionary(c,a,b):l},read_byte:function(a){var b=this;return b.next_in.subarray(a,a+1)[0]},read_buf:function(a,b){var c=this;return c.next_in.subarray(a,a+b)}};var ib;a.zip?a.zip.Inflater=g:(ib=new g,a.addEventListener("message",function(b){var c=b.data;c.append&&a.postMessage({onappend:!0,data:ib.append(c.data,function(b){a.postMessage({progress:!0,current:b})})}),c.flush&&(ib.flush(),a.postMessage({onflush:!0}))},!1))}(this); \ No newline at end of file diff --git a/demo/js/libs/zip.min.js b/demo/js/libs/zip.min.js index 087a174..a6fd40c 100644 --- a/demo/js/libs/zip.min.js +++ b/demo/js/libs/zip.min.js @@ -1 +1,29 @@ -(function(e){function A(){function n(n){var r=e.dyn_tree,i=e.stat_desc.static_tree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,a=e.stat_desc.max_length,f,l,c,h,p,d,v=0;for(h=0;h<=t;h++)n.bl_count[h]=0;r[n.heap[n.heap_max]*2+1]=0;for(f=n.heap_max+1;fa&&(h=a,v++),r[l*2+1]=h;if(l>e.max_code)continue;n.bl_count[h]++,p=0,l>=o&&(p=s[l-o]),d=r[l*2],n.opt_len+=d*(h+p),i&&(n.static_len+=d*(i[l*2+1]+p))}if(v===0)return;do{h=a-1;while(n.bl_count[h]===0)h--;n.bl_count[h]--,n.bl_count[h+1]+=2,n.bl_count[a]--,v-=2}while(v>0);for(h=a;h!==0;h--){l=n.bl_count[h];while(l!==0){c=n.heap[--f];if(c>e.max_code)continue;r[c*2+1]!=h&&(n.opt_len+=(h-r[c*2+1])*r[c*2],r[c*2+1]=h),l--}}}function r(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function i(e,n,i){var s=[],o=0,u,a,f;for(u=1;u<=t;u++)s[u]=o=o+i[u-1]<<1;for(a=0;a<=n;a++){f=e[a*2+1];if(f===0)continue;e[a*2]=r(s[f]++,f)}}var e=this;e.build_tree=function(t){var r=e.dyn_tree,s=e.stat_desc.static_tree,o=e.stat_desc.elems,a,f,l=-1,c;t.heap_len=0,t.heap_max=u;for(a=0;a=1;a--)t.pqdownheap(r,a);c=o;do a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],t.pqdownheap(r,1),f=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=f,r[c*2]=r[a*2]+r[f*2],t.depth[c]=Math.max(t.depth[a],t.depth[f])+1,r[a*2+1]=r[f*2+1]=c,t.heap[1]=c++,t.pqdownheap(r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],n(t),i(r,e.max_code,t.bl_count)}}function O(e,t,n,r,i){var s=this;s.static_tree=e,s.extra_bits=t,s.extra_base=n,s.elems=r,s.max_length=i}function D(e,t,n,r,i){var s=this;s.good_length=e,s.max_lazy=t,s.nice_length=n,s.max_chain=r,s.func=i}function et(e,t,n,r){var i=e[t*2],s=e[n*2];return i=3;t--)if(Lt[A.bl_order[t]*2+1]!==0)break;return e.opt_len+=3*(t+1)+5+5+4,t}function Xt(t){e.pending_buf[e.pending++]=t}function Vt(e){Xt(e&255),Xt(e>>>8&255)}function $t(e){Xt(e>>8&255),Xt(e&255&255)}function Jt(e,t){var n,r=t;It>p-r?(n=e,Ft|=n<>>p-It,It+=r-p):(Ft|=e<=8&&(Xt(Ft&255),Ft>>>=8,It-=8)}function Zt(){Jt(K<<1,3),Kt(a,O.static_ltree),Yt(),1+jt+10-It<9&&(Jt(K<<1,3),Kt(a,O.static_ltree),Yt()),jt=7}function en(t,r){var i,o,u;e.pending_buf[Ht+Pt*2]=t>>>8&255,e.pending_buf[Ht+Pt*2+1]=t&255,e.pending_buf[_t+Pt]=r&255,Pt++,t===0?Ct[r*2]++:(Bt++,t--,Ct[(A._length_code[r]+s+1)*2]++,kt[A.d_code(t)*2]++);if((Pt&8191)===0&&St>2){i=Pt*8,o=mt-ht;for(u=0;u>>=3;if(Bt8?Vt(Ft):It>0&&Xt(Ft&255),Ft=0,It=0}function rn(t,n,r){nn(),jt=8,r&&(Vt(n),Vt(~n)),e.pending_buf.set(rt.subarray(t,t+n),e.pending),e.pending+=n}function sn(e,t,n){Jt((J<<1)+(n?1:0),3),rn(e,t,!0)}function on(t,n,r){var i,s,o=0;St>0?(At.build_tree(e),Ot.build_tree(e),o=Wt(),i=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=i&&(i=s)):i=s=n+5,n+4<=i&&t!=-1?sn(t,n,r):s==i?(Jt((K<<1)+(r?1:0),3),tn(O.static_ltree,O.static_dtree)):(Jt((Q<<1)+(r?1:0),3),Gt(At.max_code+1,Ot.max_code+1,o+1),tn(Ct,kt)),Rt(),r&&nn()}function un(e){on(ht>=0?ht:-1,mt-ht,e),ht=mt,t.flush_pending()}function an(){var e,n,r,i;do{i=it-yt-mt;if(i===0&&mt===0&&yt===0)i=D;else if(i==-1)i--;else if(mt>=D+D-Z){rt.set(rt.subarray(D,D+D),0),gt-=D,mt-=D,ht-=D,e=at,r=e;do n=ot[--r]&65535,ot[r]=n>=D?n-D:0;while(--e!==0);e=D,r=e;do n=st[--r]&65535,st[r]=n>=D?n-D:0;while(--e!==0);i+=D}if(t.avail_in===0)return;e=t.read_buf(rt,mt+yt,i),yt+=e,yt>=G&&(ut=rt[mt]&255,ut=(ut<u-5&&(n=u-5);for(;;){if(yt<=1){an();if(yt===0&&e==y)return I;if(yt===0)break}mt+=yt,yt=0,r=ht+n;if(mt===0||mt>=r){yt=mt-r,mt=r,un(!1);if(t.avail_out===0)return I}if(mt-ht>=D-Z){un(!1);if(t.avail_out===0)return I}}return un(e==E),t.avail_out===0?e==E?R:I:e==E?U:q}function ln(e){var t=wt,n=mt,r,i,s=bt,o=mt>D-Z?mt-(D-Z):0,u=Nt,a=nt,f=mt+Y,l=rt[n+s-1],c=rt[n+s];bt>=Tt&&(t>>=2),u>yt&&(u=yt);do{r=e;if(rt[r+s]!=c||rt[r+s-1]!=l||rt[r]!=rt[n]||rt[++r]!=rt[n+1])continue;n+=2,r++;do;while(rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&rt[++n]==rt[++r]&&ns){gt=e,s=i;if(i>=u)break;l=rt[n+s-1],c=rt[n+s]}}while((e=st[e&a]&65535)>o&&--t!==0);return s<=yt?s:yt}function cn(e){var n=0,r;for(;;){if(yt=G&&(ut=(ut<=G){r=en(mt-gt,pt-G),yt-=pt;if(pt<=Et&&yt>=G){pt--;do mt++,ut=(ut<=G&&(ut=(ut<4096)&&(pt=G-1));if(bt>=G&&pt<=bt){i=mt+yt-G,r=en(mt-1-dt,bt-G),yt-=bt-1,bt-=2;do++mt<=i&&(ut=(ut<M||i!=$||r<9||r>15||n<0||n>9||o<0||o>m?N:(t.dstate=e,tt=r,D=1<9||n<0||n>m?N:(j[St].func!=j[t].func&&e.total_in!==0&&(r=e.deflate(b)),St!=t&&(St=t,Et=j[St].max_lazy,Tt=j[St].good_length,Nt=j[St].nice_length,wt=j[St].max_chain),xt=n,r)},e.deflateSetDictionary=function(e,t,n){var r=n,s,o=0;if(!t||i!=W)return N;if(rD-Z&&(r=D-Z,o=n-r),rt.set(t.subarray(o,o+r),0),mt=r,ht=r,ut=rt[0]&255,ut=(ut<E||r<0)return N;if(!n.next_out||!n.next_in&&n.avail_in!==0||i==V&&r!=E)return n.msg=F[T-N],N;if(n.avail_out===0)return n.msg=F[T-k],k;t=n,a=L,L=r,i==W&&(o=$+(tt-8<<4)<<8,u=(St-1&255)>>1,u>3&&(u=3),o|=u<<6,mt!==0&&(o|=z),o+=31-o%31,i=X,$t(o));if(e.pending!==0){t.flush_pending();if(t.avail_out===0)return L=-1,S}else if(t.avail_in===0&&r<=a&&r!=E)return t.msg=F[T-k],k;if(i==V&&t.avail_in!==0)return n.msg=F[T-k],k;if(t.avail_in!==0||yt!==0||r!=y&&i!=V){f=-1;switch(j[St].func){case P:f=fn(r);break;case H:f=cn(r);break;case B:f=hn(r);break;default:}if(f==R||f==U)i=V;if(f==I||f==R)return t.avail_out===0&&(L=-1),S;if(f==q){if(r==b)Zt();else{sn(0,0,!1);if(r==w)for(s=0;s0&&n.next_in_index!=a&&(t(n.next_in_index),a=n.next_in_index)}while(n.avail_in>0||n.avail_out===0);return c=new Uint8Array(l),u.forEach(function(e){c.set(e,f),f+=e.length}),c},t.flush=function(){var e,t=[],i=0,o=0,u;do{n.next_out_index=0,n.avail_out=r,e=n.deflate(E);if(e!=x&&e!=S)throw"deflating: "+n.msg;r-n.avail_out>0&&t.push(new Uint8Array(s.subarray(0,n.next_out_index))),o+=n.next_out_index}while(n.avail_in>0||n.avail_out===0);return n.deflateEnd(),u=new Uint8Array(o),t.forEach(function(e){u.set(e,i),i+=e.length}),u}}var t=15,n=30,r=19,i=29,s=256,o=s+1+i,u=2*o+1,a=256,f=7,l=16,c=17,h=18,p=16,d=-1,v=1,m=2,g=0,y=0,b=1,w=3,E=4,S=0,x=1,T=2,N=-2,C=-3,k=-5,L=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];A._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],A.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],A.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],A.d_code=function(e){return e<256?L[e]:L[256+(e>>>7)]},A.extra_lbits=[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],A.extra_dbits=[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],A.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],A.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],O.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],O.static_l_desc=new O(O.static_ltree,A.extra_lbits,s+1,o,t),O.static_d_desc=new O(O.static_dtree,A.extra_dbits,0,n,t),O.static_bl_desc=new O(null,A.extra_blbits,0,r,f);var M=9,_=8,P=0,H=1,B=2,j=[new D(0,0,0,0,P),new D(4,4,8,4,H),new D(4,5,16,8,H),new D(4,6,32,32,H),new D(4,4,16,16,B),new D(8,16,32,32,B),new D(8,16,128,128,B),new D(8,32,128,256,B),new D(32,128,258,1024,B),new D(32,258,258,4096,B)],F=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],I=0,q=1,R=2,U=3,z=32,W=42,X=113,V=666,$=8,J=0,K=1,Q=2,G=3,Y=258,Z=Y+G+1;nt.prototype={deflateInit:function(e,n){var r=this;return r.dstate=new tt,n||(n=t),r.dstate.deflateInit(r,e,n)},deflate:function(e){var t=this;return t.dstate?t.dstate.deflate(t,e):N},deflateEnd:function(){var e=this;if(!e.dstate)return N;var t=e.dstate.deflateEnd();return e.dstate=null,t},deflateParams:function(e,t){var n=this;return n.dstate?n.dstate.deflateParams(n,e,t):N},deflateSetDictionary:function(e,t){var n=this;return n.dstate?n.dstate.deflateSetDictionary(n,e,t):N},read_buf:function(e,t,n){var r=this,i=r.avail_in;return i>n&&(i=n),i===0?0:(r.avail_in-=i,e.set(r.next_in.subarray(r.next_in_index,r.next_in_index+i),t),r.next_in_index+=i,r.total_in+=i,i)},flush_pending:function(){var e=this,t=e.dstate.pending;t>e.avail_out&&(t=e.avail_out);if(t===0)return;e.next_out.set(e.dstate.pending_buf.subarray(e.dstate.pending_out,e.dstate.pending_out+t),e.next_out_index),e.next_out_index+=t,e.dstate.pending_out+=t,e.total_out+=t,e.avail_out-=t,e.dstate.pending-=t,e.dstate.pending===0&&(e.dstate.pending_out=0)}};var it;e.zip?e.zip.Deflater=rt:(it=new rt,e.addEventListener("message",function(t){var n=t.data;n.init&&(it=new rt(n.level),e.postMessage({oninit:!0})),n.append&&e.postMessage({onappend:!0,data:it.append(n.data,function(t){e.postMessage({progress:!0,current:t})})}),n.flush&&e.postMessage({onflush:!0,data:it.flush()})},!1))})(this),function(e){function S(){function h(e,t,r,u,h,p,d,v,m,g,y){var b,w,S,x,T,N,C,k,L,A,O,M,_,D,P;A=0,T=r;do i[e[t+A]]++,A++,T--;while(T!==0);if(i[0]==r)return d[0]=-1,v[0]=0,n;k=v[0];for(N=1;N<=E;N++)if(i[N]!==0)break;C=N,kT&&(k=T),v[0]=k;for(D=1<M+k){x++,M+=k,P=S-M,P=P>k?k:P;if((w=1<<(N=C-M))>b+1){w-=b+1,_=C;if(Nl)return o;f[x]=O=g[0],g[0]+=P,x!==0?(c[x]=T,s[0]=N,s[1]=k,N=T>>>M-k,s[2]=O-f[x-1]-N,m.set(s,(f[x-1]+N)*3)):d[0]=O}s[1]=C-M,A>=r?s[0]=192:y[A]>>M;N>>=1)T^=N;T^=N,L=(1<257?(E==o?m.msg="oversubscribed distance tree":E==a?(m.msg="incomplete distance tree",E=o):E!=u&&(m.msg="empty distance tree with lengths",E=o),E):n)}}function D(){function w(e,t,i,s,u,a,l,c){var h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k;y=c.next_in_index,b=c.avail_in,m=l.bitb,g=l.bitk,w=l.write,E=w>=p[k+1],g-=p[k+1],l.window[w++]=p[k+2],E--;continue}do{m>>=p[k+1],g-=p[k+1];if((v&16)!==0){v&=15,T=p[k+2]+(m&f[v]),m>>=v,g-=v;while(g<15)b--,m|=(c.read_byte(y++)&255)<>=p[k+1],g-=p[k+1];if((v&16)!==0){v&=15;while(g>=v,g-=v,E-=T;if(w>=N)C=w-N,w-C>0&&2>w-C?(l.window[w++]=l.window[C++],l.window[w++]=l.window[C++],T-=2):(l.window.set(l.window.subarray(C,C+2),w),w+=2,C+=2,T-=2);else{C=w-N;do C+=l.end;while(C<0);v=l.end-C;if(T>v){T-=v;if(w-C>0&&v>w-C){do l.window[w++]=l.window[C++];while(--v!==0)}else l.window.set(l.window.subarray(C,C+v),w),w+=v,C+=v,v=0;C=0}}if(w-C>0&&T>w-C){do l.window[w++]=l.window[C++];while(--T!==0)}else l.window.set(l.window.subarray(C,C+T),w),w+=T,C+=T,T=0;break}if((v&64)!==0)return c.msg="invalid distance code",T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,o;h+=p[k+2],h+=m&f[v],k=(d+h)*3,v=p[k]}while(!0);break}if((v&64)!==0)return(v&32)!==0?(T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,r):(c.msg="invalid literal/length code",T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,o);h+=p[k+2],h+=m&f[v],k=(d+h)*3;if((v=p[k])===0){m>>=p[k+1],g-=p[k+1],l.window[w++]=p[k+2],E--;break}}while(!0)}while(E>=258&&b>=10);return T=c.avail_in-b,T=g>>3>3:T,b+=T,y-=T,g-=T<<3,l.bitb=m,l.bitk=g,c.avail_in=b,c.total_in+=y-c.next_in_index,c.next_in_index=y,l.write=w,n}var e=this,t,i=0,u,a=0,l=0,c=0,h=0,p=0,d=0,v=0,m,g=0,y,b=0;e.init=function(e,n,r,i,s,o){t=x,d=e,v=n,m=r,g=i,y=s,b=o,u=null},e.proc=function(e,E,S){var D,P,H,B=0,j=0,F=0,I,q,R,U;F=E.next_in_index,I=E.avail_in,B=e.bitb,j=e.bitk,q=e.write,R=q=258&&I>=10){e.bitb=B,e.bitk=j,E.avail_in=I,E.total_in+=F-E.next_in_index,E.next_in_index=F,e.write=q,S=w(d,v,m,g,y,b,e,E),F=E.next_in_index,I=E.avail_in,B=e.bitb,j=e.bitk,q=e.write,R=q>>=u[P+1],j-=u[P+1],H=u[P];if(H===0){c=u[P+2],t=A;break}if((H&16)!==0){h=H&15,i=u[P+2],t=N;break}if((H&64)===0){l=H,a=P/3+u[P+2];break}if((H&32)!==0){t=O;break}return t=_,E.msg="invalid literal/length code",S=o,e.bitb=B,e.bitk=j,E.avail_in=I,E.total_in+=F-E.next_in_index,E.next_in_index=F,e.write=q,e.inflate_flush(E,S);case N:D=h;while(j>=D,j-=D,l=v,u=y,a=b,t=C;case C:D=l;while(j>=u[P+1],j-=u[P+1],H=u[P];if((H&16)!==0){h=H&15,p=u[P+2],t=k;break}if((H&64)===0){l=H,a=P/3+u[P+2];break}return t=_,E.msg="invalid distance code",S=o,e.bitb=B,e.bitk=j,E.avail_in=I,E.total_in+=F-E.next_in_index,E.next_in_index=F,e.write=q,e.inflate_flush(E,S);case k:D=h;while(j>=D,j-=D,t=L;case L:U=q-p;while(U<0)U+=e.end;while(i!==0){if(R===0){q==e.end&&e.read!==0&&(q=0,R=q7&&(j-=8,I++,F--),e.write=q,S=e.inflate_flush(E,S),q=e.write,R=qe.avail_out&&(r=e.avail_out),r!==0&&t==a&&(t=n),e.avail_out-=r,e.total_out+=r,e.next_out.set(i.window.subarray(o,o+r),s),s+=r,o+=r,o==i.end&&(o=0,i.write==i.end&&(i.write=0),r=i.write-o,r>e.avail_out&&(r=e.avail_out),r!==0&&t==a&&(t=n),e.avail_out-=r,e.total_out+=r,e.next_out.set(i.window.subarray(o,o+r),s),s+=r,o+=r),e.next_out_index=s,i.read=o,t},i.proc=function(e,t){var a,l,w,x,T,N,C,k;x=e.next_in_index,T=e.avail_in,l=i.bitb,w=i.bitk,N=i.write,C=N>>1){case 0:l>>>=3,w-=3,a=w&7,l>>>=a,w-=a,u=B;break;case 1:var L=[],A=[],O=[[]],M=[[]];S.inflate_trees_fixed(L,A,O,M),g.init(L[0],A[0],O[0],0,M[0],0),l>>>=3,w-=3,u=R;break;case 2:l>>>=3,w-=3,u=F;break;case 3:return l>>>=3,w-=3,u=W,e.msg="invalid block type",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t)}break;case B:while(w<32){if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);t=n,T--,l|=(e.read_byte(x++)&255)<>>16&65535)!=(l&65535))return u=W,e.msg="invalid stored block lengths",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);c=l&65535,l=w=0,u=c!==0?j:y!==0?U:H;break;case j:if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);if(C===0){N==i.end&&i.read!==0&&(N=0,C=NT&&(a=T),a>C&&(a=C),i.window.set(e.read_buf(x,a),N),x+=a,T-=a,N+=a,C-=a;if((c-=a)!==0)break;u=y!==0?U:H;break;case F:while(w<14){if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);t=n,T--,l|=(e.read_byte(x++)&255)<29||(a>>5&31)>29)return u=W,e.msg="too many length or distance symbols",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);a=258+(a&31)+(a>>5&31);if(!d||d.length>>=14,w-=14,p=0,u=I;case I:while(p<4+(h>>>10)){while(w<3){if(T===0)return i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);t=n,T--,l|=(e.read_byte(x++)&255)<>>=3,w-=3}while(p<19)d[P[p++]]=0;v[0]=7,a=E.inflate_trees_bits(d,v,m,b,e);if(a!=n)return t=a,t==o&&(d=null,u=W),i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);p=0,u=q;case q:for(;;){a=h;if(!(p<258+(a&31)+(a>>5&31)))break;var _,D;a=v[0];while(w>>=a,w-=a,d[p++]=D;else{k=D==18?7:D-14,_=D==18?11:3;while(w>>=a,w-=a,_+=l&f[k],l>>>=k,w-=k,k=p,a=h;if(k+_>258+(a&31)+(a>>5&31)||D==16&&k<1)return d=null,u=W,e.msg="invalid bit length repeat",t=o,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);D=D==16?d[k-1]:0;do d[k++]=D;while(--_!==0);p=k}}m[0]=-1;var X=[],V=[],$=[],J=[];X[0]=9,V[0]=6,a=h,a=E.inflate_trees_dynamic(257+(a&31),1+(a>>5&31),d,X,V,$,J,b,e);if(a!=n)return a==o&&(d=null,u=W),t=a,i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N,i.inflate_flush(e,t);g.init(X[0],V[0],b,$[0],b,J[0]),u=R;case R:i.bitb=l,i.bitk=w,e.avail_in=T,e.total_in+=x-e.next_in_index,e.next_in_index=x,i.write=N;if((t=g.proc(i,e,t))!=r)return i.inflate_flush(e,t);t=n,g.free(e),x=e.next_in_index,T=e.avail_in,l=i.bitb,w=i.bitk,N=i.write,C=N15?(e.inflateEnd(r),s):(e.wbits=i,r.istate.blocks=new X(r,1<>4)+8>e.istate.wbits){e.istate.mode=rt,e.msg="invalid window size",e.istate.marker=5;break}e.istate.mode=K;case K:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,f=e.read_byte(e.next_in_index++)&255;if(((e.istate.method<<8)+f)%31!==0){e.istate.mode=rt,e.msg="incorrect header check",e.istate.marker=5;break}if((f&V)===0){e.istate.mode=tt;break}e.istate.mode=Q;case Q:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,e.istate.need=(e.read_byte(e.next_in_index++)&255)<<24&4278190080,e.istate.mode=G;case G:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,e.istate.need+=(e.read_byte(e.next_in_index++)&255)<<16&16711680,e.istate.mode=Y;case Y:if(e.avail_in===0)return u;u=t,e.avail_in--,e.total_in++,e.istate.need+=(e.read_byte(e.next_in_index++)&255)<<8&65280,e.istate.mode=Z;case Z:if(e.avail_in===0)return u;return u=t,e.avail_in--,e.total_in++,e.istate.need+=e.read_byte(e.next_in_index++)&255,e.istate.mode=et,i;case et:return e.istate.mode=rt,e.msg="need dictionary",e.istate.marker=0,s;case tt:u=e.istate.blocks.proc(e,u);if(u==o){e.istate.mode=rt,e.istate.marker=0;break}u==n&&(u=t);if(u!=r)return u;u=t,e.istate.blocks.reset(e,e.istate.was),e.istate.mode=nt;case nt:return r;case rt:return o;default:return s}},e.inflateSetDictionary=function(e,t,r){var i=0,o=r;return!e||!e.istate||e.istate.mode!=et?s:(o>=1<0&&t.next_in_index!=h&&(f(t.next_in_index),h=t.next_in_index)}while(t.avail_in>0||t.avail_out===0);return v=new Uint8Array(d),c.forEach(function(e){v.set(e,p),p+=e.length}),v},e.flush=function(){t.inflateEnd()}}var t=15,n=0,r=1,i=2,s=-2,o=-3,u=-4,a=-5,f=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],l=1440,c=0,h=4,p=9,d=5,v=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],m=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],g=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],y=[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,112,112],b=[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],w=[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],E=15;S.inflate_trees_fixed=function(e,t,r,i){return e[0]=p,t[0]=d,r[0]=v,i[0]=m,n};var x=0,T=1,N=2,C=3,k=4,L=5,A=6,O=7,M=8,_=9,P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=0,B=1,j=2,F=3,I=4,q=5,R=6,U=7,z=8,W=9,V=32,$=8,J=0,K=1,Q=2,G=3,Y=4,Z=5,et=6,tt=7,nt=12,rt=13,it=[0,0,255,255];ot.prototype={inflateInit:function(e){var n=this;return n.istate=new st,e||(e=t),n.istate.inflateInit(n,e)},inflate:function(e){var t=this;return t.istate?t.istate.inflate(t,e):s},inflateEnd:function(){var e=this;if(!e.istate)return s;var t=e.istate.inflateEnd(e);return e.istate=null,t},inflateSync:function(){var e=this;return e.istate?e.istate.inflateSync(e):s},inflateSetDictionary:function(e,t){var n=this;return n.istate?n.istate.inflateSetDictionary(n,e,t):s},read_byte:function(e){var t=this;return t.next_in.subarray(e,e+1)[0]},read_buf:function(e,t){var n=this;return n.next_in.subarray(e,e+t)}};var at;e.zip?e.zip.Inflater=ut:(at=new ut,e.addEventListener("message",function(t){var n=t.data;n.append&&e.postMessage({onappend:!0,data:at.append(n.data,function(t){e.postMessage({progress:!0,current:t})})}),n.flush&&(at.flush(),e.postMessage({onflush:!0}))},!1))}(this),function(){var e={application:{"andrew-inset":"ez",annodex:"anx","atom+xml":"atom","atomcat+xml":"atomcat","atomserv+xml":"atomsrv",bbolin:"lin",cap:["cap","pcap"],"cu-seeme":"cu","davmount+xml":"davmount",dsptype:"tsp",ecmascript:["es","ecma"],futuresplash:"spl",hta:"hta","java-archive":"jar","java-serialized-object":"ser","java-vm":"class",javascript:"js",m3g:"m3g","mac-binhex40":"hqx",mathematica:["nb","ma","mb"],msaccess:"mdb",msword:["doc","dot"],mxf:"mxf",oda:"oda",ogg:"ogx",pdf:"pdf","pgp-keys":"key","pgp-signature":["asc","sig"],"pics-rules":"prf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],rar:"rar","rdf+xml":"rdf","rss+xml":"rss",rtf:"rtf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd"],"xspf+xml":"xspf",zip:"zip","vnd.android.package-archive":"apk","vnd.cinderella":"cdy","vnd.google-earth.kml+xml":"kml","vnd.google-earth.kmz":"kmz","vnd.mozilla.xul+xml":"xul","vnd.ms-excel":["xls","xlb","xlt","xlm","xla","xlc","xlw"],"vnd.ms-pki.seccat":"cat","vnd.ms-pki.stl":"stl","vnd.ms-powerpoint":["ppt","pps","pot"],"vnd.oasis.opendocument.chart":"odc","vnd.oasis.opendocument.database":"odb","vnd.oasis.opendocument.formula":"odf","vnd.oasis.opendocument.graphics":"odg","vnd.oasis.opendocument.graphics-template":"otg","vnd.oasis.opendocument.image":"odi","vnd.oasis.opendocument.presentation":"odp","vnd.oasis.opendocument.presentation-template":"otp","vnd.oasis.opendocument.spreadsheet":"ods","vnd.oasis.opendocument.spreadsheet-template":"ots","vnd.oasis.opendocument.text":"odt","vnd.oasis.opendocument.text-master":"odm","vnd.oasis.opendocument.text-template":"ott","vnd.oasis.opendocument.text-web":"oth","vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","vnd.openxmlformats-officedocument.spreadsheetml.template":"xltx","vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","vnd.openxmlformats-officedocument.presentationml.slideshow":"ppsx","vnd.openxmlformats-officedocument.presentationml.template":"potx","vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","vnd.openxmlformats-officedocument.wordprocessingml.template":"dotx","vnd.smaf":"mmf","vnd.stardivision.calc":"sdc","vnd.stardivision.chart":"sds","vnd.stardivision.draw":"sda","vnd.stardivision.impress":"sdd","vnd.stardivision.math":["sdf","smf"],"vnd.stardivision.writer":["sdw","vor"],"vnd.stardivision.writer-global":"sgl","vnd.sun.xml.calc":"sxc","vnd.sun.xml.calc.template":"stc","vnd.sun.xml.draw":"sxd","vnd.sun.xml.draw.template":"std","vnd.sun.xml.impress":"sxi","vnd.sun.xml.impress.template":"sti","vnd.sun.xml.math":"sxm","vnd.sun.xml.writer":"sxw","vnd.sun.xml.writer.global":"sxg","vnd.sun.xml.writer.template":"stw","vnd.symbian.install":["sis","sisx"],"vnd.visio":["vsd","vst","vss","vsw"],"vnd.wap.wbxml":"wbxml","vnd.wap.wmlc":"wmlc","vnd.wap.wmlscriptc":"wmlsc","vnd.wordperfect":"wpd","vnd.wordperfect5.1":"wp5","x-123":"wk","x-7z-compressed":"7z","x-abiword":"abw","x-apple-diskimage":"dmg","x-bcpio":"bcpio","x-bittorrent":"torrent","x-cbr":["cbr","cba","cbt","cb7"],"x-cbz":"cbz","x-cdf":["cdf","cda"],"x-cdlink":"vcd","x-chess-pgn":"pgn","x-cpio":"cpio","x-csh":"csh","x-debian-package":["deb","udeb"],"x-director":["dcr","dir","dxr","cst","cct","cxt","w3d","fgd","swa"],"x-dms":"dms","x-doom":"wad","x-dvi":"dvi","x-httpd-eruby":"rhtml","x-font":"pcf.Z","x-freemind":"mm","x-gnumeric":"gnumeric","x-go-sgf":"sgf","x-graphing-calculator":"gcf","x-gtar":["gtar","taz"],"x-hdf":"hdf","x-httpd-php":["phtml","pht","php"],"x-httpd-php-source":"phps","x-httpd-php3":"php3","x-httpd-php3-preprocessed":"php3p","x-httpd-php4":"php4","x-httpd-php5":"php5","x-ica":"ica","x-info":"info","x-internet-signup":["ins","isp"],"x-iphone":"iii","x-iso9660-image":"iso","x-java-jnlp-file":"jnlp","x-jmol":"jmz","x-killustrator":"kil","x-koan":["skp","skd","skt","skm"],"x-kpresenter":["kpr","kpt"],"x-kword":["kwd","kwt"],"x-latex":"latex","x-lha":"lha","x-lyx":"lyx","x-lzh":"lzh","x-lzx":"lzx","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-ms-wmd":"wmd","x-ms-wmz":"wmz","x-msdos-program":["com","exe","bat","dll"],"x-msi":"msi","x-netcdf":["nc","cdf"],"x-ns-proxy-autoconfig":["pac","dat"],"x-nwc":"nwc","x-object":"o","x-oz-application":"oza","x-pkcs7-certreqresp":"p7r","x-python-code":["pyc","pyo"],"x-qgis":["qgs","shp","shx"],"x-quicktimeplayer":"qtl","x-redhat-package-manager":"rpm","x-ruby":"rb","x-sh":"sh","x-shar":"shar","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","x-stuffit":"sit","x-sv4cpio":"sv4cpio","x-sv4crc":"sv4crc","x-tar":"tar","x-tcl":"tcl","x-tex-gf":"gf","x-tex-pk":"pk","x-texinfo":["texinfo","texi"],"x-trash":["~","%","bak","old","sik"],"x-troff":["t","tr","roff"],"x-troff-man":"man","x-troff-me":"me","x-troff-ms":"ms","x-ustar":"ustar","x-wais-source":"src","x-wingz":"wz","x-x509-ca-cert":["crt","der","cer"],"x-xcf":"xcf","x-xfig":"fig","x-xpinstall":"xpi",applixware:"aw","atomsvc+xml":"atomsvc","ccxml+xml":"ccxml","cdmi-capability":"cdmia","cdmi-container":"cdmic","cdmi-domain":"cdmid","cdmi-object":"cdmio","cdmi-queue":"cdmiq","docbook+xml":"dbk","dssc+der":"dssc","dssc+xml":"xdssc","emma+xml":"emma","epub+zip":"epub",exi:"exi","font-tdpfr":"pfr","gml+xml":"gml","gpx+xml":"gpx",gxf:"gxf",hyperstudio:"stk","inkml+xml":["ink","inkml"],ipfix:"ipfix",json:"json","jsonml+json":"jsonml","lost+xml":"lostxml","mads+xml":"mads",marc:"mrc","marcxml+xml":"mrcx","mathml+xml":"mathml",mbox:"mbox","mediaservercontrol+xml":"mscml","metalink+xml":"metalink","metalink4+xml":"meta4","mets+xml":"mets","mods+xml":"mods",mp21:["m21","mp21"],mp4:"mp4s","oebps-package+xml":"opf","omdoc+xml":"omdoc",onenote:["onetoc","onetoc2","onetmp","onepkg"],oxps:"oxps","patch-ops-error+xml":"xer","pgp-encrypted":"pgp",pkcs10:"p10","pkcs7-mime":["p7m","p7c"],"pkcs7-signature":"p7s",pkcs8:"p8","pkix-attr-cert":"ac","pkix-crl":"crl","pkix-pkipath":"pkipath",pkixcmp:"pki","pls+xml":"pls","prs.cww":"cww","pskc+xml":"pskcxml","reginfo+xml":"rif","relax-ng-compact-syntax":"rnc","resource-lists+xml":"rl","resource-lists-diff+xml":"rld","rls-services+xml":"rs","rpki-ghostbusters":"gbr","rpki-manifest":"mft","rpki-roa":"roa","rsd+xml":"rsd","sbml+xml":"sbml","scvp-cv-request":"scq","scvp-cv-response":"scs","scvp-vp-request":"spq","scvp-vp-response":"spp",sdp:"sdp","set-payment-initiation":"setpay","set-registration-initiation":"setreg","shf+xml":"shf","sparql-query":"rq","sparql-results+xml":"srx",srgs:"gram","srgs+xml":"grxml","sru+xml":"sru","ssdl+xml":"ssdl","ssml+xml":"ssml","tei+xml":["tei","teicorpus"],"thraud+xml":"tfi","timestamped-data":"tsd","vnd.3gpp.pic-bw-large":"plb","vnd.3gpp.pic-bw-small":"psb","vnd.3gpp.pic-bw-var":"pvb","vnd.3gpp2.tcap":"tcap","vnd.3m.post-it-notes":"pwn","vnd.accpac.simply.aso":"aso","vnd.accpac.simply.imp":"imp","vnd.acucobol":"acu","vnd.acucorp":["atc","acutc"],"vnd.adobe.air-application-installer-package+zip":"air","vnd.adobe.formscentral.fcdt":"fcdt","vnd.adobe.fxp":["fxp","fxpl"],"vnd.adobe.xdp+xml":"xdp","vnd.adobe.xfdf":"xfdf","vnd.ahead.space":"ahead","vnd.airzip.filesecure.azf":"azf","vnd.airzip.filesecure.azs":"azs","vnd.amazon.ebook":"azw","vnd.americandynamics.acc":"acc","vnd.amiga.ami":"ami","vnd.anser-web-certificate-issue-initiation":"cii","vnd.anser-web-funds-transfer-initiation":"fti","vnd.antix.game-component":"atx","vnd.apple.installer+xml":"mpkg","vnd.apple.mpegurl":"m3u8","vnd.aristanetworks.swi":"swi","vnd.astraea-software.iota":"iota","vnd.audiograph":"aep","vnd.blueice.multipass":"mpm","vnd.bmi":"bmi","vnd.businessobjects":"rep","vnd.chemdraw+xml":"cdxml","vnd.chipnuts.karaoke-mmd":"mmd","vnd.claymore":"cla","vnd.cloanto.rp9":"rp9","vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"vnd.cluetrust.cartomobile-config":"c11amc","vnd.cluetrust.cartomobile-config-pkg":"c11amz","vnd.commonspace":"csp","vnd.contact.cmsg":"cdbcmsg","vnd.cosmocaller":"cmc","vnd.crick.clicker":"clkx","vnd.crick.clicker.keyboard":"clkk","vnd.crick.clicker.palette":"clkp","vnd.crick.clicker.template":"clkt","vnd.crick.clicker.wordbank":"clkw","vnd.criticaltools.wbs+xml":"wbs","vnd.ctc-posml":"pml","vnd.cups-ppd":"ppd","vnd.curl.car":"car","vnd.curl.pcurl":"pcurl","vnd.dart":"dart","vnd.data-vision.rdz":"rdz","vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"vnd.dece.ttml+xml":["uvt","uvvt"],"vnd.dece.unspecified":["uvx","uvvx"],"vnd.dece.zip":["uvz","uvvz"],"vnd.denovo.fcselayout-link":"fe_launch","vnd.dna":"dna","vnd.dolby.mlp":"mlp","vnd.dpgraph":"dpg","vnd.dreamfactory":"dfac","vnd.ds-keypoint":"kpxx","vnd.dvb.ait":"ait","vnd.dvb.service":"svc","vnd.dynageo":"geo","vnd.ecowin.chart":"mag","vnd.enliven":"nml","vnd.epson.esf":"esf","vnd.epson.msf":"msf","vnd.epson.quickanime":"qam","vnd.epson.salt":"slt","vnd.epson.ssf":"ssf","vnd.eszigno3+xml":["es3","et3"],"vnd.ezpix-album":"ez2","vnd.ezpix-package":"ez3","vnd.fdf":"fdf","vnd.fdsn.mseed":"mseed","vnd.fdsn.seed":["seed","dataless"],"vnd.flographit":"gph","vnd.fluxtime.clip":"ftc","vnd.framemaker":["fm","frame","maker","book"],"vnd.frogans.fnc":"fnc","vnd.frogans.ltf":"ltf","vnd.fsc.weblaunch":"fsc","vnd.fujitsu.oasys":"oas","vnd.fujitsu.oasys2":"oa2","vnd.fujitsu.oasys3":"oa3","vnd.fujitsu.oasysgp":"fg5","vnd.fujitsu.oasysprs":"bh2","vnd.fujixerox.ddd":"ddd","vnd.fujixerox.docuworks":"xdw","vnd.fujixerox.docuworks.binder":"xbd","vnd.fuzzysheet":"fzs","vnd.genomatix.tuxedo":"txd","vnd.geogebra.file":"ggb","vnd.geogebra.tool":"ggt","vnd.geometry-explorer":["gex","gre"],"vnd.geonext":"gxt","vnd.geoplan":"g2w","vnd.geospace":"g3w","vnd.gmx":"gmx","vnd.grafeq":["gqf","gqs"],"vnd.groove-account":"gac","vnd.groove-help":"ghf","vnd.groove-identity-message":"gim","vnd.groove-injector":"grv","vnd.groove-tool-message":"gtm","vnd.groove-tool-template":"tpl","vnd.groove-vcard":"vcg","vnd.hal+xml":"hal","vnd.handheld-entertainment+xml":"zmm","vnd.hbci":"hbci","vnd.hhe.lesson-player":"les","vnd.hp-hpgl":"hpgl","vnd.hp-hpid":"hpid","vnd.hp-hps":"hps","vnd.hp-jlyt":"jlt","vnd.hp-pcl":"pcl","vnd.hp-pclxl":"pclxl","vnd.hydrostatix.sof-data":"sfd-hdstx","vnd.ibm.minipay":"mpy","vnd.ibm.modcap":["afp","listafp","list3820"],"vnd.ibm.rights-management":"irm","vnd.ibm.secure-container":"sc","vnd.iccprofile":["icc","icm"],"vnd.igloader":"igl","vnd.immervision-ivp":"ivp","vnd.immervision-ivu":"ivu","vnd.insors.igm":"igm","vnd.intercon.formnet":["xpw","xpx"],"vnd.intergeo":"i2g","vnd.intu.qbo":"qbo","vnd.intu.qfx":"qfx","vnd.ipunplugged.rcprofile":"rcprofile","vnd.irepository.package+xml":"irp","vnd.is-xpr":"xpr","vnd.isac.fcs":"fcs","vnd.jam":"jam","vnd.jcp.javame.midlet-rms":"rms","vnd.jisp":"jisp","vnd.joost.joda-archive":"joda","vnd.kahootz":["ktz","ktr"],"vnd.kde.karbon":"karbon","vnd.kde.kchart":"chrt","vnd.kde.kformula":"kfo","vnd.kde.kivio":"flw","vnd.kde.kontour":"kon","vnd.kde.kpresenter":["kpr","kpt"],"vnd.kde.kspread":"ksp","vnd.kde.kword":["kwd","kwt"],"vnd.kenameaapp":"htke","vnd.kidspiration":"kia","vnd.kinar":["kne","knp"],"vnd.koan":["skp","skd","skt","skm"],"vnd.kodak-descriptor":"sse","vnd.las.las+xml":"lasxml","vnd.llamagraphics.life-balance.desktop":"lbd","vnd.llamagraphics.life-balance.exchange+xml":"lbe","vnd.lotus-1-2-3":"123","vnd.lotus-approach":"apr","vnd.lotus-freelance":"pre","vnd.lotus-notes":"nsf","vnd.lotus-organizer":"org","vnd.lotus-screencam":"scm","vnd.lotus-wordpro":"lwp","vnd.macports.portpkg":"portpkg","vnd.mcd":"mcd","vnd.medcalcdata":"mc1","vnd.mediastation.cdkey":"cdkey","vnd.mfer":"mwf","vnd.mfmp":"mfm","vnd.micrografx.flo":"flo","vnd.micrografx.igx":"igx","vnd.mif":"mif","vnd.mobius.daf":"daf","vnd.mobius.dis":"dis","vnd.mobius.mbk":"mbk","vnd.mobius.mqy":"mqy","vnd.mobius.msl":"msl","vnd.mobius.plc":"plc","vnd.mobius.txf":"txf","vnd.mophun.application":"mpn","vnd.mophun.certificate":"mpc","vnd.ms-artgalry":"cil","vnd.ms-cab-compressed":"cab","vnd.ms-excel.addin.macroenabled.12":"xlam","vnd.ms-excel.sheet.binary.macroenabled.12":"xlsb","vnd.ms-excel.sheet.macroenabled.12":"xlsm","vnd.ms-excel.template.macroenabled.12":"xltm","vnd.ms-fontobject":"eot","vnd.ms-htmlhelp":"chm","vnd.ms-ims":"ims","vnd.ms-lrm":"lrm","vnd.ms-officetheme":"thmx","vnd.ms-powerpoint.addin.macroenabled.12":"ppam","vnd.ms-powerpoint.presentation.macroenabled.12":"pptm","vnd.ms-powerpoint.slide.macroenabled.12":"sldm","vnd.ms-powerpoint.slideshow.macroenabled.12":"ppsm","vnd.ms-powerpoint.template.macroenabled.12":"potm","vnd.ms-project":["mpp","mpt"],"vnd.ms-word.document.macroenabled.12":"docm","vnd.ms-word.template.macroenabled.12":"dotm","vnd.ms-works":["wps","wks","wcm","wdb"],"vnd.ms-wpl":"wpl","vnd.ms-xpsdocument":"xps","vnd.mseq":"mseq","vnd.musician":"mus","vnd.muvee.style":"msty","vnd.mynfc":"taglet","vnd.neurolanguage.nlu":"nlu","vnd.nitf":["ntf","nitf"],"vnd.noblenet-directory":"nnd","vnd.noblenet-sealer":"nns","vnd.noblenet-web":"nnw","vnd.nokia.n-gage.data":"ngdat","vnd.nokia.n-gage.symbian.install":"n-gage","vnd.nokia.radio-preset":"rpst","vnd.nokia.radio-presets":"rpss","vnd.novadigm.edm":"edm","vnd.novadigm.edx":"edx","vnd.novadigm.ext":"ext","vnd.oasis.opendocument.chart-template":"otc","vnd.oasis.opendocument.formula-template":"odft","vnd.oasis.opendocument.image-template":"oti","vnd.olpc-sugar":"xo","vnd.oma.dd2+xml":"dd2","vnd.openofficeorg.extension":"oxt","vnd.openxmlformats-officedocument.presentationml.slide":"sldx","vnd.osgeo.mapguide.package":"mgp","vnd.osgi.dp":"dp","vnd.osgi.subsystem":"esa","vnd.palm":["pdb","pqa","oprc"],"vnd.pawaafile":"paw","vnd.pg.format":"str","vnd.pg.osasli":"ei6","vnd.picsel":"efif","vnd.pmi.widget":"wg","vnd.pocketlearn":"plf","vnd.powerbuilder6":"pbd","vnd.previewsystems.box":"box","vnd.proteus.magazine":"mgz","vnd.publishare-delta-tree":"qps","vnd.pvi.ptid1":"ptid","vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"vnd.realvnc.bed":"bed","vnd.recordare.musicxml":"mxl","vnd.recordare.musicxml+xml":"musicxml","vnd.rig.cryptonote":"cryptonote","vnd.rn-realmedia":"rm","vnd.rn-realmedia-vbr":"rmvb","vnd.route66.link66+xml":"link66","vnd.sailingtracker.track":"st","vnd.seemail":"see","vnd.sema":"sema","vnd.semd":"semd","vnd.semf":"semf","vnd.shana.informed.formdata":"ifm","vnd.shana.informed.formtemplate":"itp","vnd.shana.informed.interchange":"iif","vnd.shana.informed.package":"ipk","vnd.simtech-mindmapper":["twd","twds"],"vnd.smart.teacher":"teacher","vnd.solent.sdkm+xml":["sdkm","sdkd"],"vnd.spotfire.dxp":"dxp","vnd.spotfire.sfs":"sfs","vnd.stepmania.package":"smzip","vnd.stepmania.stepchart":"sm","vnd.sus-calendar":["sus","susp"],"vnd.svd":"svd","vnd.syncml+xml":"xsm","vnd.syncml.dm+wbxml":"bdm","vnd.syncml.dm+xml":"xdm","vnd.tao.intent-module-archive":"tao","vnd.tcpdump.pcap":["pcap","cap","dmp"],"vnd.tmobile-livetv":"tmo","vnd.trid.tpt":"tpt","vnd.triscape.mxs":"mxs","vnd.trueapp":"tra","vnd.ufdl":["ufd","ufdl"],"vnd.uiq.theme":"utz","vnd.umajin":"umj","vnd.unity":"unityweb","vnd.uoml+xml":"uoml","vnd.vcx":"vcx","vnd.visionary":"vis","vnd.vsf":"vsf","vnd.webturbo":"wtb","vnd.wolfram.player":"nbp","vnd.wqd":"wqd","vnd.wt.stf":"stf","vnd.xara":"xar","vnd.xfdl":"xfdl","vnd.yamaha.hv-dic":"hvd","vnd.yamaha.hv-script":"hvs","vnd.yamaha.hv-voice":"hvp","vnd.yamaha.openscoreformat":"osf","vnd.yamaha.openscoreformat.osfpvg+xml":"osfpvg","vnd.yamaha.smaf-audio":"saf","vnd.yamaha.smaf-phrase":"spf","vnd.yellowriver-custom-menu":"cmp","vnd.zul":["zir","zirz"],"vnd.zzazz.deck+xml":"zaz","voicexml+xml":"vxml",widget:"wgt",winhlp:"hlp","wsdl+xml":"wsdl","wspolicy+xml":"wspolicy","x-ace-compressed":"ace","x-authorware-bin":["aab","x32","u32","vox"],"x-authorware-map":"aam","x-authorware-seg":"aas","x-blorb":["blb","blorb"],"x-bzip":"bz","x-bzip2":["bz2","boz"],"x-cfs-compressed":"cfs","x-chat":"chat","x-conference":"nsc","x-dgc-compressed":"dgc","x-dtbncx+xml":"ncx","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-eva":"eva","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-freearc":"arc","x-gca-compressed":"gca","x-glulx":"ulx","x-gramps-xml":"gramps","x-install-instructions":"install","x-lzh-compressed":["lzh","lha"],"x-mie":"mie","x-mobipocket-ebook":["prc","mobi"],"x-ms-application":"application","x-ms-shortcut":"lnk","x-ms-xbap":"xbap","x-msbinder":"obd","x-mscardfile":"crd","x-msclip":"clp","x-msdownload":["exe","dll","com","bat","msi"],"x-msmediaview":["mvb","m13","m14"],"x-msmetafile":["wmf","wmz","emf","emz"],"x-msmoney":"mny","x-mspublisher":"pub","x-msschedule":"scd","x-msterminal":"trm","x-mswrite":"wri","x-nzb":"nzb","x-pkcs12":["p12","pfx"],"x-pkcs7-certificates":["p7b","spc"],"x-research-info-systems":"ris","x-silverlight-app":"xap","x-sql":"sql","x-stuffitx":"sitx","x-subrip":"srt","x-t3vm-image":"t3","x-tads":"gam","x-tex":"tex","x-tex-tfm":"tfm","x-tgif":"obj","x-xliff+xml":"xlf","x-xz":"xz","x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"xaml+xml":"xaml","xcap-diff+xml":"xdf","xenc+xml":"xenc","xml-dtd":"dtd","xop+xml":"xop","xproc+xml":"xpl","xslt+xml":"xslt","xv+xml":["mxml","xhvml","xvml","xvm"],yang:"yang","yin+xml":"yin",envoy:"evy",fractals:"fif","internet-property-stream":"acx",olescript:"axs","vnd.ms-outlook":"msg","vnd.ms-pkicertstore":"sst","x-compress":"z","x-compressed":"tgz","x-gzip":"gz","x-perfmon":["pma","pmc","pml","pmr","pmw"],"x-pkcs7-mime":["p7c","p7m"],"ynd.ms-pkipko":"pko"},audio:{amr:"amr","amr-wb":"awb",annodex:"axa",basic:["au","snd"],flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"prs.sid":"sid","x-aiff":["aif","aiff","aifc"],"x-gsm":"gsm","x-ms-wma":"wma","x-ms-wax":"wax","x-pn-realaudio":"ram","x-realaudio":"ra","x-sd2":"sd2","x-wav":"wav",adpcm:"adp",mp4:"mp4a",s3m:"s3m",silk:"sil","vnd.dece.audio":["uva","uvva"],"vnd.digital-winds":"eol","vnd.dra":"dra","vnd.dts":"dts","vnd.dts.hd":"dtshd","vnd.lucent.voice":"lvp","vnd.ms-playready.media.pya":"pya","vnd.nuera.ecelp4800":"ecelp4800","vnd.nuera.ecelp7470":"ecelp7470","vnd.nuera.ecelp9600":"ecelp9600","vnd.rip":"rip",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},chemical:{"x-alchemy":"alc","x-cache":["cac","cache"],"x-cache-csf":"csf","x-cactvs-binary":["cbin","cascii","ctab"],"x-cdx":"cdx","x-chem3d":"c3d","x-cif":"cif","x-cmdf":"cmdf","x-cml":"cml","x-compass":"cpa","x-crossfire":"bsd","x-csml":["csml","csm"],"x-ctx":"ctx","x-cxf":["cxf","cef"],"x-embl-dl-nucleotide":["emb","embl"],"x-gamess-input":["inp","gam","gamin"],"x-gaussian-checkpoint":["fch","fchk"],"x-gaussian-cube":"cub","x-gaussian-input":["gau","gjc","gjf"],"x-gaussian-log":"gal","x-gcg8-sequence":"gcg","x-genbank":"gen","x-hin":"hin","x-isostar":["istr","ist"],"x-jcamp-dx":["jdx","dx"],"x-kinemage":"kin","x-macmolecule":"mcm","x-macromodel-input":["mmd","mmod"],"x-mdl-molfile":"mol","x-mdl-rdfile":"rd","x-mdl-rxnfile":"rxn","x-mdl-sdfile":["sd","sdf"],"x-mdl-tgf":"tgf","x-mmcif":"mcif","x-mol2":"mol2","x-molconn-Z":"b","x-mopac-graph":"gpt","x-mopac-input":["mop","mopcrt","mpc","zmt"],"x-mopac-out":"moo","x-ncbi-asn1":"asn","x-ncbi-asn1-ascii":["prt","ent"],"x-ncbi-asn1-binary":["val","aso"],"x-pdb":["pdb","ent"],"x-rosdal":"ros","x-swissprot":"sw","x-vamas-iso14976":"vms","x-vmd":"vmd","x-xtel":"xtel","x-xyz":"xyz"},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"vnd.djvu":["djvu","djv"],"vnd.wap.wbmp":"wbmp","x-canon-cr2":"cr2","x-canon-crw":"crw","x-cmu-raster":"ras","x-coreldraw":"cdr","x-coreldrawpattern":"pat","x-coreldrawtemplate":"cdt","x-corelphotopaint":"cpt","x-epson-erf":"erf","x-icon":"ico","x-jg":"art","x-jng":"jng","x-nikon-nef":"nef","x-olympus-orf":"orf","x-photoshop":"psd","x-portable-anymap":"pnm","x-portable-bitmap":"pbm","x-portable-graymap":"pgm","x-portable-pixmap":"ppm","x-rgb":"rgb","x-xbitmap":"xbm","x-xpixmap":"xpm","x-xwindowdump":"xwd",bmp:"bmp",cgm:"cgm",g3fax:"g3",ktx:"ktx","prs.btif":"btif",sgi:"sgi","vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"vnd.dwg":"dwg","vnd.dxf":"dxf","vnd.fastbidsheet":"fbs","vnd.fpx":"fpx","vnd.fst":"fst","vnd.fujixerox.edmics-mmr":"mmr","vnd.fujixerox.edmics-rlc":"rlc","vnd.ms-modi":"mdi","vnd.ms-photo":"wdp","vnd.net-fpx":"npx","vnd.xiff":"xif",webp:"webp","x-3ds":"3ds","x-cmx":"cmx","x-freehand":["fh","fhc","fh4","fh5","fh7"],"x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod",pipeg:"jfif"},message:{rfc822:["eml","mime","mht","mhtml","nws"]},model:{iges:["igs","iges"],mesh:["msh","mesh","silo"],vrml:["wrl","vrml"],"x3d+vrml":["x3dv","x3dvz"],"x3d+xml":["x3d","x3dz"],"x3d+binary":["x3db","x3dbz"],"vnd.collada+xml":"dae","vnd.dwf":"dwf","vnd.gdl":"gdl","vnd.gtw":"gtw","vnd.mts":"mts","vnd.vtu":"vtu"},text:{"cache-manifest":["manifest","appcache"],calendar:["ics","icz","ifb"],css:"css",csv:"csv",h323:"323",html:["html","htm","shtml","stm"],iuls:"uls",mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx",scriptlet:["sct","wsc"],texmacs:["tm","ts"],"tab-separated-values":"tsv","vnd.sun.j2me.app-descriptor":"jad","vnd.wap.wml":"wml","vnd.wap.wmlscript":"wmls","x-bibtex":"bib","x-boo":"boo","x-c++hdr":["h++","hpp","hxx","hh"],"x-c++src":["c++","cpp","cxx","cc"],"x-component":"htc","x-dsrc":"d","x-diff":["diff","patch"],"x-haskell":"hs","x-java":"java","x-literate-haskell":"lhs","x-moc":"moc","x-pascal":["p","pas"],"x-pcs-gcd":"gcd","x-perl":["pl","pm"],"x-python":"py","x-scala":"scala","x-setext":"etx","x-tcl":["tcl","tk"],"x-tex":["tex","ltx","sty","cls"],"x-vcalendar":"vcs","x-vcard":"vcf",n3:"n3","prs.lines.tag":"dsc",sgml:["sgml","sgm"],troff:["t","tr","roff","man","me","ms"],turtle:"ttl","uri-list":["uri","uris","urls"],vcard:"vcard","vnd.curl":"curl","vnd.curl.dcurl":"dcurl","vnd.curl.scurl":"scurl","vnd.curl.mcurl":"mcurl","vnd.dvb.subtitle":"sub","vnd.fly":"fly","vnd.fmi.flexstor":"flx","vnd.graphviz":"gv","vnd.in3d.3dml":"3dml","vnd.in3d.spot":"spot","x-asm":["s","asm"],"x-c":["c","cc","cxx","cpp","h","hh","dic"],"x-fortran":["f","for","f77","f90"],"x-opml":"opml","x-nfo":"nfo","x-sfv":"sfv","x-uuencode":"uu",webviewhtml:"htt"},video:{"3gpp":"3gp",annodex:"axv",dl:"dl",dv:["dif","dv"],fli:"fli",gl:"gl",mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.dece.hd":["uvh","uvvh"],"vnd.dece.mobile":["uvm","uvvm"],"vnd.dece.pd":["uvp","uvvp"],"vnd.dece.sd":["uvs","uvvs"],"vnd.dece.video":["uvv","uvvv"],"vnd.dvb.file":"dvb","vnd.fvt":"fvt","vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"},"x-conference":{"x-cooltalk":"ice"},"x-world":{"x-vrml":["vrm","vrml","wrl","flr","wrz","xaf","xof"]}},t=function(){var t,n,r,i,s={};for(t in e)if(e.hasOwnProperty(t))for(n in e[t])if(e[t].hasOwnProperty(n)){r=e[t][n];if(typeof r=="string")s[r]=t+"/"+n;else for(i=0;i>>8^i[(e^n[r])&255]},t.get=function(){return~e}}function g(e,t,n){if(e.slice)return e.slice(t,t+n);if(e.webkitSlice)return e.webkitSlice(t,t+n);if(e.mozSlice)return e.mozSlice(t,t+n);if(e.msSlice)return e.msSlice(t,t+n)}function y(e,t){var n,r;return n=new ArrayBuffer(e),r=new Uint8Array(n),t&&r.set(t,0),{buffer:n,array:r,view:new DataView(n)}}function b(){}function w(e){function r(r,i){var s=new Blob([e],{type:h});n=new S(s),n.init(function(){t.size=n.size,r()},i)}function i(e,t,r,i){n.readUint8Array(e,t,r,i)}var t=this,n;t.size=0,t.init=r,t.readUint8Array=i}function E(t){function i(e){var i=t.length;while(t.charAt(i-1)=="=")i--;r=t.indexOf(",")+1,n.size=Math.floor((i-r)*.75),e()}function s(n,i,s){var o,u=y(i),a=Math.floor(n/3)*4,f=Math.ceil((n+i)/3)*4,l=e.atob(t.substring(a+r,f+r)),c=n-Math.floor(a/4)*3;for(o=c;o2?r+=e.btoa(u):i=u,n()}function u(t){t(r+e.btoa(i))}var n=this,r="",i="";n.init=s,n.writeUint8Array=o,n.getData=u}function C(e){function r(n){t=new Blob([],{type:e}),n()}function i(n,r){t=new Blob([t,d?n:n.buffer],{type:e}),r()}function s(e){e(t)}var t,n=this;n.init=r,n.writeUint8Array=i,n.getData=s}function k(e,t,n,r,i,s,o,u,a,l){function v(){e.removeEventListener(p,m,!1),u(d)}function m(e){var t=e.data,r=t.data;t.onappend&&(d+=r.length,n.writeUint8Array(r,function(){s(!1,r),g()},l)),t.onflush&&(r?(d+=r.length,n.writeUint8Array(r,function(){s(!1,r),v()},l)):v()),t.progress&&o&&o(h+t.current,i)}function g(){h=c*f,h127?n+=i[r-128]:n+=String.fromCharCode(r);return n}function D(e){return decodeURIComponent(escape(e))}function P(e){var t,n="";for(t=0;t>16,n=e&65535;try{return new Date(1980+((t&65024)>>9),((t&480)>>5)-1,t&31,(n&63488)>>11,(n&2016)>>5,(n&31)*2,0)}catch(r){}}function B(e,t,i,s,o){e.version=t.view.getUint16(i,!0),e.bitFlag=t.view.getUint16(i+2,!0),e.compressionMethod=t.view.getUint16(i+4,!0),e.lastModDateRaw=t.view.getUint32(i+6,!0),e.lastModDate=H(e.lastModDateRaw);if((e.bitFlag&1)===1){o(n);return}if(s||(e.bitFlag&8)!=8)e.crc32=t.view.getUint32(i+10,!0),e.compressedSize=t.view.getUint32(i+14,!0),e.uncompressedSize=t.view.getUint32(i+18,!0);if(e.compressedSize===4294967295||e.uncompressedSize===4294967295){o(r);return}e.filenameLength=t.view.getUint16(i+22,!0),e.extraFieldLength=t.view.getUint16(i+24,!0)}function j(e,n){function r(){}function s(t,r){e.readUint8Array(e.size-t,t,function(e){var n=y(e.length,e).view;n.getUint32(0)!=1347093766?s(t+1,r):r(n)},function(){n(i)})}return r.prototype.getData=function(r,i,s,a){function c(e,t){l&&l.terminate(),l=null,e&&e(t)}function h(e){var t=y(4);return t.view.setUint32(0,e),f.crc32==t.view.getUint32(0)}function p(e,t){a&&!h(t)?d():r.getData(function(e){c(i,e)})}function d(){c(n,u)}function v(){c(n,o)}var f=this,l;e.readUint8Array(f.offset,30,function(i){var o=y(i.length,i),u;if(o.view.getUint32(0)!=1347093252){n(t);return}B(f,o,4,!1,n),u=f.offset+30+f.filenameLength+f.extraFieldLength,r.init(function(){f.compressionMethod===0?M(e,r,u,f.compressedSize,a,p,s,d,v):l=A(e,r,u,f.compressedSize,a,p,s,d,v)},v)},d)},{getEntries:function(o){if(e.size<22){n(t);return}s(22,function(s){var u,a;u=s.getUint32(16,!0),a=s.getUint16(8,!0),e.readUint8Array(u,e.size-u,function(e){var i,s=0,u=[],f,l,c,h=y(e.length,e);for(i=0;i>>1^3988292384:n>>>=1;r[e]=n}return r}(),w.prototype=new b,w.prototype.constructor=w,E.prototype=new b,E.prototype.constructor=E,S.prototype=new b,S.prototype.constructor=S,x.prototype.getData=function(e){e(this.data)},T.prototype=new x,T.prototype.constructor=T,N.prototype=new x,N.prototype.constructor=N,C.prototype=new x,C.prototype.constructor=C,e.zip={Reader:b,Writer:x,BlobReader:S,Data64URIReader:E,TextReader:w,BlobWriter:C,Data64URIWriter:N,TextWriter:T,createReader:function(e,t,n){e.init(function(){t(j(e,n))},n)},createWriter:function(e,t,n,r){e.init(function(){t(q(e,n,r))},n)},workerScriptsPath:"",useWebWorkers:!0}}(this); \ No newline at end of file +/*! + Copyright (c) 2013 Gildas Lormeau. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +!function(a){function b(){var a=-1,b=this;b.append=function(c){var d,e=b.table;for(d=0;d>>8^e[255&(a^c[d])]},b.get=function(){return~a}}function c(a,b,c){return a.slice?a.slice(b,b+c):a.webkitSlice?a.webkitSlice(b,b+c):a.mozSlice?a.mozSlice(b,b+c):a.msSlice?a.msSlice(b,b+c):void 0}function d(a,b){var c,d;return c=new ArrayBuffer(a),d=new Uint8Array(c),b&&d.set(b,0),{buffer:c,array:d,view:new DataView(c)}}function e(){}function f(a){function b(b,c){var f=new Blob([a],{type:M});d=new h(f),d.init(function(){e.size=d.size,b()},c)}function c(a,b,c,e){d.readUint8Array(a,b,c,e)}var d,e=this;e.size=0,e.init=b,e.readUint8Array=c}function g(b){function c(a){for(var c=b.length;"="==b.charAt(c-1);)c--;f=b.indexOf(",")+1,g.size=Math.floor(.75*(c-f)),a()}function e(c,e,g){var h,i=d(e),j=4*Math.floor(c/3),k=4*Math.ceil((c+e)/3),l=a.atob(b.substring(j+f,k+f)),m=c-3*Math.floor(j/4);for(h=m;m+e>h;h++)i.array[h-m]=l.charCodeAt(h);g(i.array)}var f,g=this;g.size=0,g.init=c,g.readUint8Array=e}function h(a){function b(b){this.size=a.size,b()}function d(b,d,e,f){var g=new FileReader;g.onload=function(a){e(new Uint8Array(a.target.result))},g.onerror=f,g.readAsArrayBuffer(c(a,b,d))}var e=this;e.size=0,e.init=b,e.readUint8Array=d}function i(){}function j(a){function b(a){e=new Blob([],{type:M}),a()}function c(a,b){e=new Blob([e,A?a:a.buffer],{type:M}),b()}function d(b,c){var d=new FileReader;d.onload=function(a){b(a.target.result)},d.onerror=c,d.readAsText(e,a)}var e,f=this;f.init=b,f.writeUint8Array=c,f.getData=d}function k(b){function c(a){g+="data:"+(b||"")+";base64,",a()}function d(b,c){var d,e=h.length,f=h;for(h="",d=0;d<3*Math.floor((e+b.length)/3)-e;d++)f+=String.fromCharCode(b[d]);for(;d2?g+=a.btoa(f):h=f,c()}function e(b){b(g+a.btoa(h))}var f=this,g="",h="";f.init=c,f.writeUint8Array=d,f.getData=e}function l(a){function b(b){e=new Blob([],{type:a}),b()}function c(b,c){e=new Blob([e,A?b:b.buffer],{type:a}),c()}function d(a){a(e)}var e,f=this;f.init=b,f.writeUint8Array=c,f.getData=d}function m(a,b,c,d,e,f,g,h,i,j){function k(){a.removeEventListener(N,l,!1),h(o)}function l(a){var b=a.data,d=b.data;b.onappend&&(o+=d.length,c.writeUint8Array(d,function(){f(!1,d),m()},j)),b.onflush&&(d?(o+=d.length,c.writeUint8Array(d,function(){f(!1,d),k()},j)):k()),b.progress&&g&&g(n+b.current,e)}function m(){n=p*J,e>n?b.readUint8Array(d+n,Math.min(J,e-n),function(b){a.postMessage({append:!0,data:b}),p++,g&&g(n,e),f(!0,b)},i):a.postMessage({flush:!0})}var n,o,p=0;o=0,a.addEventListener(N,l,!1),m()}function n(a,b,c,d,e,f,g,h,i,j){function k(){var o;l=m*J,e>l?b.readUint8Array(d+l,Math.min(J,e-l),function(b){var h=a.append(b,function(){g&&g(d+l,e)});n+=h.length,f(!0,b),c.writeUint8Array(h,function(){f(!1,h),m++,setTimeout(k,1)},j),g&&g(l,e)},i):(o=a.flush(),o?(n+=o.length,c.writeUint8Array(o,function(){f(!1,o),h(n)},j)):h(n))}var l,m=0,n=0;k()}function o(c,d,e,f,g,h,i,j,k){function l(a,b){g&&!a&&q.append(b)}function o(a){h(a,q.get())}var p,q=new b;return a.zip.useWebWorkers?(p=new Worker(a.zip.workerScriptsPath+K),m(p,c,d,e,f,l,i,o,j,k)):n(new a.zip.Inflater,c,d,e,f,l,i,o,j,k),p}function p(c,d,e,f,g,h,i){function j(a,b){a&&p.append(b)}function k(a){f(a,p.get())}function l(){o.removeEventListener(N,l,!1),m(o,c,d,0,c.size,j,g,k,h,i)}var o,p=new b;return a.zip.useWebWorkers?(o=new Worker(a.zip.workerScriptsPath+L),o.addEventListener(N,l,!1),o.postMessage({init:!0,level:e})):n(new a.zip.Deflater,c,d,0,c.size,j,g,k,h,i),o}function q(a,c,d,e,f,g,h,i,j){function k(){var b=l*J;e>b?a.readUint8Array(d+b,Math.min(J,e-b),function(a){f&&m.append(a),h&&h(b,e,a),c.writeUint8Array(a,function(){l++,k()},j)},i):g(e,m.get())}var l=0,m=new b;k()}function r(a){var b,c,d="",e=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];for(b=0;b127?e[c-128]:String.fromCharCode(c);return d}function s(a){return decodeURIComponent(escape(a))}function t(a){var b,c="";for(b=0;b>16,c=65535&a;try{return new Date(1980+((65024&b)>>9),((480&b)>>5)-1,31&b,(63488&c)>>11,(2016&c)>>5,2*(31&c),0)}catch(d){}}function v(a,b,c,d,e){return a.version=b.view.getUint16(c,!0),a.bitFlag=b.view.getUint16(c+2,!0),a.compressionMethod=b.view.getUint16(c+4,!0),a.lastModDateRaw=b.view.getUint32(c+6,!0),a.lastModDate=u(a.lastModDateRaw),1===(1&a.bitFlag)?(e(C),void 0):((d||8!=(8&a.bitFlag))&&(a.crc32=b.view.getUint32(c+10,!0),a.compressedSize=b.view.getUint32(c+14,!0),a.uncompressedSize=b.view.getUint32(c+18,!0)),4294967295===a.compressedSize||4294967295===a.uncompressedSize?(e(D),void 0):(a.filenameLength=b.view.getUint16(c+22,!0),a.extraFieldLength=b.view.getUint16(c+24,!0),void 0))}function w(a,b){function c(){}function e(c,f){a.readUint8Array(a.size-c,c,function(a){var b=d(a.length,a).view;1347093766!=b.getUint32(0)?e(c+1,f):f(b)},function(){b(E)})}return c.prototype.getData=function(c,e,f,g){function h(a,b){m&&m.terminate(),m=null,a&&a(b)}function i(a){var b=d(4);return b.view.setUint32(0,a),n.crc32==b.view.getUint32(0)}function j(a,b){g&&!i(b)?k():c.getData(function(a){h(e,a)})}function k(){h(b,H)}function l(){h(b,G)}var m,n=this;a.readUint8Array(n.offset,30,function(e){var h,i=d(e.length,e);return 1347093252!=i.view.getUint32(0)?(b(B),void 0):(v(n,i,4,!1,b),h=n.offset+30+n.filenameLength+n.extraFieldLength,c.init(function(){0===n.compressionMethod?q(a,c,h,n.compressedSize,g,j,f,k,l):m=o(a,c,h,n.compressedSize,g,j,f,k,l)},l),void 0)},k)},{getEntries:function(f){return a.size<22?(b(B),void 0):(e(22,function(e){var g,h;g=e.getUint32(16,!0),h=e.getUint16(8,!0),a.readUint8Array(g,a.size-g,function(a){var e,g,i,j,k=0,l=[],m=d(a.length,a);for(e=0;h>e;e++){if(g=new c,1347092738!=m.view.getUint32(k))return b(B),void 0;v(g,m,k+6,!0,b),g.commentLength=m.view.getUint16(k+32,!0),g.directory=16==(16&m.view.getUint8(k+38)),g.offset=m.view.getUint32(k+42,!0),i=t(m.array.subarray(k+46,k+46+g.filenameLength)),g.filename=2048===(2048&g.bitFlag)?s(i):r(i),g.directory||"/"!=g.filename.charAt(g.filename.length-1)||(g.directory=!0),j=t(m.array.subarray(k+46+g.filenameLength+g.extraFieldLength,k+46+g.filenameLength+g.extraFieldLength+g.commentLength)),g.comment=2048===(2048&g.bitFlag)?s(j):r(j),l.push(g),k+=46+g.filenameLength+g.extraFieldLength+g.commentLength}f(l)},function(){b(E)})}),void 0)},close:function(a){a&&a()}}}function x(a){return unescape(encodeURIComponent(a))}function y(a){var b,c=[];for(b=0;ba;a++){for(c=a,b=0;8>b;b++)1&c?c=3988292384^c>>>1:c>>>=1;d[a]=c}return d}(),f.prototype=new e,f.prototype.constructor=f,g.prototype=new e,g.prototype.constructor=g,h.prototype=new e,h.prototype.constructor=h,i.prototype.getData=function(a){a(this.data)},j.prototype=new i,j.prototype.constructor=j,k.prototype=new i,k.prototype.constructor=k,l.prototype=new i,l.prototype.constructor=l,a.zip={Reader:e,Writer:i,BlobReader:h,Data64URIReader:g,TextReader:f,BlobWriter:l,Data64URIWriter:k,TextWriter:j,createReader:function(a,b,c){a.init(function(){b(w(a,c))},c)},createWriter:function(a,b,c,d){a.init(function(){b(z(a,c,d))},c)},workerScriptsPath:"",useWebWorkers:!0}}(this),function(){function a(a){function b(b){this.size=a.uncompressedSize,b()}function c(b){f.data?b():a.getData(new r,function(a){f.data=a,e=new v(a),b()},null,f.checkCrc32)}function d(a,b,d,f){c(function(){e.readUint8Array(a,b,d,f)},f)}var e,f=this;f.size=0,f.init=b,f.readUint8Array=d}function b(a){function b(a){c+=a.uncompressedSize||0,a.children.forEach(b)}var c=0;return b(a),c}function c(a,b,d){function e(){g++,g550?e("#main").width(i-r):e("#main").width(i),t=new EPUBJS.Book(n),t.on("book:online",c),t.on("book:offline",h),t.getMetadata().then(o),t.getToc().then(u),t.ready.all.then(l),t.renderTo("area"),e(function(){d()})}function o(t){var n=t.bookTitle,r=t.creator,i=e("#book-title"),s=e("#chapter-title"),o=e("#title-seperator");document.title=n+" – "+r,i.html(n),s.html(r),o.show()}function u(n){var r=e("#toc"),i,s;r.empty(),s=f(n,1),r.append(s),i=e(".toc_link"),i.on("click",function(n){var r=e(this),i=r.data("url");e(".openChapter").removeClass("openChapter"),r.parents("li").addClass("openChapter"),t.goto(i),n.preventDefault()})}function a(){var n="";localStorage.getItem("fontSize")?n=localStorage.getItem("fontSize"):(n="medium",localStorage.setItem("fontSize",n));var r=e("#settingsPanel");r.append("
    ");var i=e("
  • "),s=e("Extra Small
    Small
    Medium
    Large
    Extra Large");i.find("h3").text("Font Size").after(s),r.find("ul").append(i);var o=e('input[name="fontSize"]');o.each(function(){e(this).attr("value")==n&&e(this).attr("checked","checked"),e(this).on("click",function(){localStorage.setItem("fontSize",e(this).attr("value")),t.iframe.contentDocument.location.reload(!0)})})}function f(t,n){var r=e("
      "),i=n==1?"chapter":"section";return t.forEach(function(t){var s,o=e("
    • "),u=e(""+t.label+"");o.append(u),t.subitems&&t.subitems.length&&(n++,s=f(t.subitems,n),o.append(s)),r.append(o)}),r}function l(){var n=e("#divider"),r=e("#loader");r.hide(),t.single||n.addClass("show")}function c(){var t=e("#store");n=!1,t.attr("src",t.data("save"))}function h(){var t=e("#store");n=!0,t.attr("src",t.data("saved"))}function p(t){var n=t.msg,r=e("#toc-"+n),i=e(".currentChapter");r.length&&(i.removeClass("currentChapter"),r.addClass("currentChapter"))}function d(){function y(){f.addClass("open"),u.addClass("closed"),c.attr("src",c.data("close"))}function b(){a.css("pointer-events","visible"),f.removeClass("open"),u.removeClass("closed"),c.attr("src",c.data("open"))}function w(){v.hide(),d.show()}function E(){d.hide(),v.show()}var s=e("#next"),o=e("#prev"),u=e("#main"),a=e("#area"),f=e("#sidebar"),l=e("#open"),c=l.find("img"),h=e("#network"),p=e("#setting"),d=e("#settingsPanel"),v=e("#toc"),m=e(window);m.on("resize",function(){i=e(window).width(),i>550?u.width(i-r):u.width(i)}),s.on("click",function(){t.nextPage()}),o.on("click",function(){t.prevPage()}),p.on("click",function(){d.is(":visible")?E():w()});var g=!1;e(document).keydown(function(e){if(g)return;if(e.keyCode==37)return o.trigger("click"),g=!0,setTimeout(function(){g=!1},100),!1;if(e.keyCode==39)return s.trigger("click"),g=!0,setTimeout(function(){g=!1},100),!1}),l.on("click",function(){f.hasClass("open")?b():y()}),h.on("click",function(){n=!n,t.fromStorage(n)})}var t,n=!1,r=0,i;return s}(jQuery),jQuery.fn.extend({clickOutside:function(e,t){var n=this;return jQuery(document).on("click.offer",function(r){if(t&&jQuery.inArray(r.target,t)>-1)return;if(jQuery.contains(n[0],r.target))return;jQuery(document).off("click.offer"),e(r,n)}),this}}); \ No newline at end of file +var EPUBJSR=EPUBJSR||{};EPUBJSR.app={},EPUBJSR.app.init=function(a){"use strict";function b(b){var e=window.location.search.match(/book=(.*)/),b=b||(e?e[1]:"moby-dick");return k=a(window).width(),k>550?a("#main").width(k-m):a("#main").width(k),j=new EPUBJS.Book(b),j.on("book:online",g),j.on("book:offline",h),j.getMetadata().then(c),j.getToc().then(d),j.ready.all.then(f),j.renderTo("area"),a(function(){i()}),j}function c(b){var c=b.bookTitle,d=b.creator,e=a("#book-title"),f=a("#chapter-title"),g=a("#title-seperator");document.title=c+" – "+d,e.html(c),f.html(d),g.show()}function d(b){var c,d,f=a("#toc");f.empty(),d=e(b,1),f.append(d),c=a(".toc_link"),c.on("click",function(b){var c=a(this),d=c.data("url");a(".openChapter").removeClass("openChapter"),c.parents("li").addClass("openChapter"),j.goto(d),b.preventDefault()})}function e(b,c){var d=a("
        "),f=1==c?"chapter":"section";return b.forEach(function(b){var g,h=a("
      • "),i=a(""+b.label+"");h.append(i),b.subitems&&b.subitems.length&&(c++,g=e(b.subitems,c),h.append(g)),d.append(h)}),d}function f(){var b=a("#divider"),c=a("#loader");c.hide(),j.single||b.addClass("show")}function g(){var b=a("#store");l=!1,b.attr("src",b.data("save"))}function h(){var b=a("#store");l=!0,b.attr("src",b.data("saved"))}function i(){function b(){n.addClass("open"),h.addClass("closed"),p.attr("src",p.data("close"))}function c(){i.css("pointer-events","visible"),n.removeClass("open"),h.removeClass("closed"),p.attr("src",p.data("open"))}function d(){t.hide(),s.show()}function e(){s.hide(),t.show()}var f=a("#next"),g=a("#prev"),h=a("#main"),i=a("#area"),n=a("#sidebar"),o=a("#open"),p=o.find("img"),q=a("#network"),r=a("#setting"),s=a("#settingsPanel"),t=a("#toc"),u=a(window);u.on("resize",function(){k=a(window).width(),k>550?h.width(k-m):h.width(k)}),f.on("click",function(){j.nextPage()}),g.on("click",function(){j.prevPage()}),r.on("click",function(){s.is(":visible")?e():d()});var v=!1;a(document).keydown(function(a){return v?void 0:37==a.keyCode?(g.trigger("click"),v=!0,setTimeout(function(){v=!1},100),!1):39==a.keyCode?(f.trigger("click"),v=!0,setTimeout(function(){v=!1},100),!1):void 0}),o.on("click",function(){n.hasClass("open")?c():b()}),q.on("click",function(){l=!l,j.fromStorage(l)})}var j,k,l=!1,m=0;return b}(jQuery),jQuery.fn.extend({clickOutside:function(a,b){var c=this;return jQuery(document).on("click.offer",function(d){b&&jQuery.inArray(d.target,b)>-1||jQuery.contains(c[0],d.target)||(jQuery(document).off("click.offer"),a(d,c))}),this}}); \ No newline at end of file diff --git a/examples/dev.html b/examples/dev.html index 90ff8db..cfafeef 100755 --- a/examples/dev.html +++ b/examples/dev.html @@ -24,7 +24,8 @@ fileStorage.filePath = "../libs/fileStorage/workers/"; EPUBJS.VERSION = "0.1.5"; - EPUBJSR.app.init('/demo/moby-dick.epub'); + // EPUBJSR.app.init('/demo/moby-dick.epub'); + window.book = EPUBJSR.app.init('/demo/moby-dick/'); } }; diff --git a/hooks/default/endnotes.js b/hooks/default/endnotes.js index 07d73db..f9dd533 100644 --- a/hooks/default/endnotes.js +++ b/hooks/default/endnotes.js @@ -6,10 +6,9 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap type = "noteref", popups = {}; + EPUBJS.core.addCss("../demo/css/popup.css", false, chapter.doc.head); - // EPUBJS.core.addCss("css/popup.css", false, chapter.doc.head); - //console.log("notes", items) items.forEach(function(item){ var epubType = item.getAttribute(attr), href, @@ -22,7 +21,7 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap txt; if(epubType != type) return; - + href = item.getAttribute("href"); id = href.replace("#", ''); el = chapter.doc.getElementById(id); @@ -61,11 +60,13 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap //-- TODO: will these leak memory? - Fred popups[id].addEventListener("mouseover", onPop, false); popups[id].addEventListener("mouseout", offPop, false); - + //-- Add hide on page change - chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", hidePop); - chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", offPop); - + // chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", hidePop); + // chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", offPop); + chapter.book.on("book:pageChanged", hidePop, this); + chapter.book.on("book:pageChanged", offPop, this); + // chapter.book.on("book:chapterDestroy", hidePop, this); } pop = popups[id]; @@ -75,7 +76,7 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap itemRect = item.getBoundingClientRect(); left = itemRect.left; top = itemRect.top; - + //-- show the popup pop.classList.add("show"); diff --git a/libs/underscore/underscore.js b/libs/underscore/underscore.js index a12f0d9..bf628f5 100644 --- a/libs/underscore/underscore.js +++ b/libs/underscore/underscore.js @@ -1,8 +1,9 @@ +/*! // Underscore.js 1.4.4 // http://underscorejs.org // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. - +*/ (function() { // Baseline setup diff --git a/libs/zip/zip.js b/libs/zip/zip.js index 6c6ebd3..db61f98 100644 --- a/libs/zip/zip.js +++ b/libs/zip/zip.js @@ -1,4 +1,4 @@ -/* +/*! Copyright (c) 2013 Gildas Lormeau. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/package.json b/package.json index 6d6eba2..3238490 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "connect": "~2.8.4", "colors": "~0.6.0-1", "optimist": "~0.6.0", - "portfinder": "~0.2.1" + "portfinder": "~0.2.1", + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-uglify": "~0.2.2" } } diff --git a/reader/app.js b/reader/app.js index e31e42a..d48e4a4 100644 --- a/reader/app.js +++ b/reader/app.js @@ -62,6 +62,7 @@ EPUBJSR.app.init = (function($){ controls(); }); + return Book; } diff --git a/src/book.js b/src/book.js index e878176..c2d9e67 100644 --- a/src/book.js +++ b/src/book.js @@ -5,6 +5,7 @@ EPUBJS.Book = function(bookPath, options){ this.settings = _.defaults(options || {}, { element : false, storage: false, //-- true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem' + fromStorage : false, saved : false, online : true, contained : false, @@ -12,7 +13,7 @@ EPUBJS.Book = function(bookPath, options){ height: false, spreads: true, responsive: true, - version: 1, + version: 1.1, restore: true }); @@ -385,9 +386,8 @@ EPUBJS.Book.prototype.restore = function(){ reject = false, fromStore = localStorage.getItem(contentsKey); - if(fromStore != 'undefined'){ + if(fromStore != 'undefined' && fromStore != 'null'){ this.contents = JSON.parse(fromStore); - fetch.forEach(function(item){ book[item] = book.contents[item]; if(!book[item]) { diff --git a/src/epubcfi.js b/src/epubcfi.js index 086999d..c8ffff0 100644 --- a/src/epubcfi.js +++ b/src/epubcfi.js @@ -147,10 +147,11 @@ EPUBJS.EpubCFI.prototype.getElement = function(cfi, doc) { while(sections.length > 0) { part = sections.shift(); - + if(part.id){ - console.log(part.id) - element = cfi.doc.querySelector("#" + part.id); + + element = doc.querySelector("#" + part.id); + }else{ element = children[part.index]; diff --git a/src/parser.js b/src/parser.js index 1e7c6aa..0fc70a3 100644 --- a/src/parser.js +++ b/src/parser.js @@ -159,15 +159,28 @@ EPUBJS.Parser.prototype.spine = function(spineXml, manifest){ } EPUBJS.Parser.prototype.toc = function(tocXml){ - var toc = []; - - var navMap = tocXml.querySelector("navMap"); - function getTOC(nodes, parent, list){ - var list = list || []; + var navMap = tocXml.querySelector("navMap"); - items = Array.prototype.slice.call(nodes); + function getTOC(parent){ + var list = [], + items = [], + nodes = parent.childNodes, + nodesArray = Array.prototype.slice.call(nodes), + length = nodesArray.length, + iter = length, + node; + + if(length == 0) return false; + + while(iter--){ + node = nodesArray[iter]; + if(node.nodeName === "navPoint") { + items.push(node); + } + } + items.forEach(function(item){ var id = item.getAttribute('id'), content = item.querySelector("content"), @@ -175,23 +188,21 @@ EPUBJS.Parser.prototype.toc = function(tocXml){ split = src.split("#"), navLabel = item.querySelector("navLabel"), text = navLabel.textContent ? navLabel.textContent : "", - subitems = item.querySelectorAll("navPoint"); - - - list.push({ + subitems = getTOC(item); + list.unshift({ "id": id, "href": src, "label": text, - "subitems" : subitems.length ? getTOC(item.querySelectorAll("navPoint"), item, list) : false + "subitems" : subitems }); }); return list; } - - - return getTOC(navMap.querySelectorAll("navPoint"), navMap); + + + return getTOC(navMap); } diff --git a/src/renderer.js b/src/renderer.js index bb7c363..499516a 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -167,7 +167,7 @@ EPUBJS.Renderer.prototype.crossBrowserColumnCss = function(){ EPUBJS.Renderer.columnAxis = EPUBJS.core.prefixed('columnAxis'); EPUBJS.Renderer.columnGap = EPUBJS.core.prefixed('columnGap'); EPUBJS.Renderer.columnWidth = EPUBJS.core.prefixed('columnWidth'); - + EPUBJS.Renderer.transform = EPUBJS.core.prefixed('transform'); } @@ -185,7 +185,7 @@ EPUBJS.Renderer.prototype.setIframeSrc = function(url){ renderer.doc = renderer.iframe.contentDocument; renderer.docEl = renderer.doc.documentElement; renderer.bodyEl = renderer.doc.body; - + renderer.applyStyles(); renderer.formatSpread(); @@ -234,7 +234,7 @@ EPUBJS.Renderer.prototype.formatSpread = function(){ this.gap = this.gap || Math.ceil(this.elWidth / 8); - if(this.elWidth < cutoff || this.settings.single) { + if(this.elWidth < cutoff || !this.book.settings.spreads) { this.spread = false; //-- Single Page divisor = 1; @@ -387,7 +387,9 @@ EPUBJS.Renderer.prototype.chapterEnd = function(){ EPUBJS.Renderer.prototype.setLeft = function(leftPos){ // this.bodyEl.style.marginLeft = -leftPos + "px"; - this.doc.defaultView.scrollTo(leftPos, 0) + // this.docEl.style.marginLeft = -leftPos + "px"; + // this.docEl.style[EPUBJS.Renderer.transform] = 'translate('+ (-leftPos) + 'px, 0)'; + this.doc.defaultView.scrollTo(leftPos, 0); } EPUBJS.Renderer.prototype.replace = function(query, func, callback){ @@ -576,9 +578,14 @@ EPUBJS.Renderer.prototype.replaceLinks = function(callback){ links.forEach(function(link){ var path, href = link.getAttribute("href"), - relative = href.search("://"), - fragment = href[0] == "#"; - + relative, + fragment; + + if(!href) return; + + relative = href.search("://"), + fragment = href[0] == "#"; + if(relative != -1){ link.setAttribute("target", "_blank"); @@ -587,10 +594,10 @@ EPUBJS.Renderer.prototype.replaceLinks = function(callback){ link.onclick = function(){ that.book.goto(href); + return false; } } - }); if(callback) callback(); diff --git a/src/unarchiver.js b/src/unarchiver.js index 7f759b9..5cc3e26 100644 --- a/src/unarchiver.js +++ b/src/unarchiver.js @@ -1,7 +1,7 @@ EPUBJS.Unarchiver = function(url){ - this.libPath = EPUBJS.filePath + "zip/"; + this.libPath = EPUBJS.filePath; this.zipUrl = url; this.loadLib() this.urlCache = {};