mirror of
https://github.com/janeczku/calibre-web
synced 2024-08-18 19:59:27 +00:00
2 lines
173 KiB
JavaScript
Vendored
2 lines
173 KiB
JavaScript
Vendored
(function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t(require('xmldom'),function(){try{return require('jszip')}catch(t){}}()):'function'==typeof define&&define.amd?define(['xmldom','jszip'],t):'object'==typeof exports?exports.ePub=t(require('xmldom'),function(){try{return require('jszip')}catch(t){}}()):e.ePub=t(e.xmldom,e.jszip)})(this,function(e,t){var n=String.prototype,a=Math.ceil,i=Math.round,o=Math.max,s=Math.floor;return function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(n,'a',n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='/dist/',t(t.s=25)}([function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function i(){var e=new Date().getTime(),t='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(t){var n=0|(e+16*Math.random())%16;return e=s(e/16),('x'==t?n:8|7&n).toString(16)});return t}function r(e){return!isNaN(parseFloat(e))&&isFinite(e)}function l(e,t,n,a,i){var o=a||0,s=i||t.length,r=parseInt(o+(s-o)/2),d;return(n||(n=function(e,t){return e>t?1:e<t?-1:e==t?0:void 0}),0>=s-o)?r:(d=n(t[r],e),1==s-o?0<=d?r:r+1:0===d?r:-1===d?l(e,t,n,r,s):l(e,t,n,o,r))}function d(e,t,n,a,i){var o=a||0,s=i||t.length,r=parseInt(o+(s-o)/2),l;return(n||(n=function(e,t){return e>t?1:e<t?-1:e==t?0:void 0}),0>=s-o)?-1:(l=n(t[r],e),1==s-o?0===l?r:-1:0===l?r:-1===l?d(e,t,n,r,s):d(e,t,n,o,r))}function u(e,t){for(var n=e.parentNode,a=n.childNodes,o=-1,s=0,i;s<a.length&&(i=a[s],i.nodeType===t&&o++,i!=e);s++);return o}function c(e,t){return new Blob([e],{type:t})}function p(e,t){return'undefined'==typeof e.querySelector?e.getElementsByTagName(t):e.querySelectorAll(t)}function h(e,t,n){for(var a=document.createTreeWalker(e,n,null,!1),i;i=a.nextNode();)t(i)}function g(e,t){if(t(e))return!0;if(e=e.firstChild,e)do{var n=g(e,t);if(n)return!0;e=e.nextSibling}while(e)}function f(e){for(var t=[e];e;e=e.parentNode)t.unshift(e);return t}Object.defineProperty(t,'__esModule',{value:!0});var m=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();t.uuid=i,t.documentHeight=function(){return o(document.documentElement.clientHeight,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight)},t.isElement=function(e){return!!(e&&1==e.nodeType)},t.isNumber=r,t.isFloat=function(e){var t=parseFloat(e);return t===e&&r(e)&&s(t)!==e},t.prefixed=function(e){var t=['Webkit','webkit','Moz','O','ms'],n=['-webkit-','-webkit-','-moz-','-o-','-ms-'],a=e[0].toUpperCase()+e.slice(1),o=t.length;if('undefined'==typeof document||'undefined'!=typeof document.body.style[e])return e;for(var s=0;s<o;s++)if('undefined'!=typeof document.body.style[t[s]+a])return n[s]+e;return e},t.defaults=function(e){for(var t=1,n=arguments.length,a;t<n;t++)for(var i in a=arguments[t],a)void 0===e[i]&&(e[i]=a[i]);return e},t.extend=function(e){var t=[].slice.call(arguments,1);return t.forEach(function(t){t&&Object.getOwnPropertyNames(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}),e},t.insert=function(e,t,n){var a=l(e,t,n);return t.splice(a,0,e),a},t.locationOf=l,t.indexOfSorted=d,t.bounds=function(e){var t=window.getComputedStyle(e),n=0,a=0;return['width','paddingRight','paddingLeft','marginRight','marginLeft','borderRightWidth','borderLeftWidth'].forEach(function(e){n+=parseFloat(t[e])||0}),['height','paddingTop','paddingBottom','marginTop','marginBottom','borderTopWidth','borderBottomWidth'].forEach(function(e){a+=parseFloat(t[e])||0}),{height:a,width:n}},t.borders=function(e){var t=window.getComputedStyle(e),n=0,a=0;return['paddingRight','paddingLeft','marginRight','marginLeft','borderRightWidth','borderLeftWidth'].forEach(function(e){n+=parseFloat(t[e])||0}),['paddingTop','paddingBottom','marginTop','marginBottom','borderTopWidth','borderBottomWidth'].forEach(function(e){a+=parseFloat(t[e])||0}),{height:a,width:n}},t.windowBounds=function(){var e=window.innerWidth,t=window.innerHeight;return{top:0,left:0,right:e,bottom:t,width:e,height:t}},t.indexOfNode=u,t.indexOfTextNode=function(e){return u(e,b)},t.indexOfElementNode=function(e){return u(e,v)},t.isXml=function(e){return-1<['xml','opf','ncx'].indexOf(e)},t.createBlob=c,t.createBlobUrl=function(e,t){var n=c(e,t),a;return a=k.createObjectURL(n),a},t.revokeBlobUrl=function(e){return k.revokeObjectURL(e)},t.createBase64Url=function(e,t){var n,a;if('string'==typeof e)return n=btoa(encodeURIComponent(e)),a='data:'+t+';base64,'+n,a},t.type=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.parse=function(e,t,a){var i,o;return o='undefined'==typeof DOMParser||a?n(16).DOMParser:DOMParser,65279===e.charCodeAt(0)&&(e=e.slice(1)),i=new o().parseFromString(e,t),i},t.qs=function(e,t){var n;if(!e)throw new Error('No Element Provided');return'undefined'==typeof e.querySelector?(n=e.getElementsByTagName(t),n.length)?n[0]:void 0:e.querySelector(t)},t.qsa=p,t.qsp=function(e,t,n){var a,i;if('undefined'!=typeof e.querySelector){for(var o in t+='[',n)t+=o+'~=\''+n[o]+'\'';return t+=']',e.querySelector(t)}return(a=e.getElementsByTagName(t),i=Array.prototype.slice.call(a,0).filter(function(e){for(var t in n)if(e.getAttribute(t)===n[t])return!0;return!1}),i)?i[0]:void 0},t.sprint=function(e,t){var n=e.ownerDocument||e;'undefined'==typeof n.createTreeWalker?g(e,function(e){e&&3===e.nodeType&&t(e)},!0):h(e,t,NodeFilter.SHOW_TEXT)},t.treeWalker=h,t.walk=g,t.blob2base64=function(e){return new Promise(function(t){var n=new FileReader;n.readAsDataURL(e),n.onloadend=function(){t(n.result)}})},t.defer=function(){var e=this;this.resolve=null,this.reject=null,this.id=i(),this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n}),Object.freeze(this)},t.querySelectorByType=function(e,t,n){var a;if('undefined'!=typeof e.querySelector&&(a=e.querySelector(t+'[*|type="'+n+'"]')),!a||0===a.length){a=p(e,t);for(var o=0;o<a.length;o++)if(a[o].getAttributeNS('http://www.idpf.org/2007/ops','type')===n||a[o].getAttribute('epub:type')===n)return a[o]}else return a},t.findChildren=function(e){for(var t=[],n=e.childNodes,a=0,i;a<n.length;a++)i=n[a],1===i.nodeType&&t.push(i);return t},t.parents=f,t.filterChildren=function(e,t,n){for(var a=[],o=e.childNodes,s=0,i;s<o.length;s++)if(i=o[s],1===i.nodeType&&i.nodeName.toLowerCase()===t){if(n)return i;a.push(i)}if(!n)return a},t.getParentByTagName=function(e,t){var n;if(null!==e&&''!==t)for(n=e.parentNode;1===n.nodeType;){if(n.tagName.toLowerCase()===t)return n;n=n.parentNode}};var y=t.requestAnimationFrame='undefined'!=typeof window&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),v=1,b=3,k='undefined'==typeof URL?'undefined'==typeof window?void 0:window.URL||window.webkitURL||window.mozURL:URL,x=t.RangeObject=function(){function e(){a(this,e),this.collapsed=!1,this.commonAncestorContainer=void 0,this.endContainer=void 0,this.endOffset=void 0,this.startContainer=void 0,this.startOffset=void 0}return m(e,[{key:'setStart',value:function(e,t){this.startContainer=e,this.startOffset=t,this.endContainer?this.commonAncestorContainer=this._commonAncestorContainer():this.collapse(!0),this._checkCollapsed()}},{key:'setEnd',value:function(e,t){this.endContainer=e,this.endOffset=t,this.startContainer?(this.collapsed=!1,this.commonAncestorContainer=this._commonAncestorContainer()):this.collapse(!1),this._checkCollapsed()}},{key:'collapse',value:function(e){this.collapsed=!0,e?(this.endContainer=this.startContainer,this.endOffset=this.startOffset,this.commonAncestorContainer=this.startContainer.parentNode):(this.startContainer=this.endContainer,this.startOffset=this.endOffset,this.commonAncestorContainer=this.endOffset.parentNode)}},{key:'selectNode',value:function(e){var t=e.parentNode,n=Array.prototype.indexOf.call(t.childNodes,e);this.setStart(t,n),this.setEnd(t,n+1)}},{key:'selectNodeContents',value:function(e){var t=e.childNodes[e.childNodes-1],n=3===e.nodeType?e.textContent.length:parent.childNodes.length;this.setStart(e,0),this.setEnd(e,n)}},{key:'_commonAncestorContainer',value:function(e,t){var n=f(e||this.startContainer),a=f(t||this.endContainer);if(n[0]==a[0])for(var o=0;o<n.length;o++)if(n[o]!=a[o])return n[o-1]}},{key:'_checkCollapsed',value:function(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset}},{key:'toString',value:function(){}}]),e}()},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(0),r=1,l=3,d=function(){function e(t,n,i){a(this,e);var r;if(this.str='',this.base={},this.spinePos=0,this.range=!1,this.path={},this.start=null,this.end=null,!(this instanceof e))return new e(t,n,i);if('string'==typeof n?this.base=this.parseComponent(n):'object'===('undefined'==typeof n?'undefined':o(n))&&n.steps&&(this.base=n),r=this.checkType(t),'string'===r)return this.str=t,(0,s.extend)(this,this.parse(t));if('range'===r)return(0,s.extend)(this,this.fromRange(t,this.base,i));if('node'===r)return(0,s.extend)(this,this.fromNode(t,this.base,i));if('EpubCFI'===r&&t.path)return t;if(!t)return this;throw new TypeError('not a valid argument for EpubCFI')}return i(e,[{key:'checkType',value:function(t){return this.isCfiString(t)?'string':'object'===('undefined'==typeof t?'undefined':o(t))&&('Range'===(0,s.type)(t)||'undefined'!=typeof t.startContainer)?'range':'object'===('undefined'==typeof t?'undefined':o(t))&&'undefined'!=typeof t.nodeType?'node':'object'===('undefined'==typeof t?'undefined':o(t))&&t instanceof e&&'EpubCFI'}},{key:'parse',value:function(e){var t={spinePos:-1,range:!1,base:{},path:{},start:null,end:null},n,a,i;return'string'==typeof e?(0===e.indexOf('epubcfi(')&&')'===e[e.length-1]&&(e=e.slice(8,e.length-1)),n=this.getChapterComponent(e),!n)?{spinePos:-1}:(t.base=this.parseComponent(n),a=this.getPathComponent(e),t.path=this.parseComponent(a),i=this.getRange(e),i&&(t.range=!0,t.start=this.parseComponent(i[0]),t.end=this.parseComponent(i[1])),t.spinePos=t.base.steps[1].index,t):{spinePos:-1}}},{key:'parseComponent',value:function(e){var t={steps:[],terminal:{offset:null,assertion:null}},n=e.split(':'),a=n[0].split('/'),i;return 1<n.length&&(i=n[1],t.terminal=this.parseTerminal(i)),''===a[0]&&a.shift(),t.steps=a.map(function(e){return this.parseStep(e)}.bind(this)),t}},{key:'parseStep',value:function(e){var t,n,a,i,o;if(i=e.match(/\[(.*)\]/),i&&i[1]&&(o=i[1]),n=parseInt(e),!isNaN(n))return 0==n%2?(t='element',a=n/2-1):(t='text',a=(n-1)/2),{type:t,index:a,id:o||null}}},{key:'parseTerminal',value:function(e){var t=e.match(/\[(.*)\]/),n,a;return t&&t[1]?(n=parseInt(e.split('[')[0]),a=t[1]):n=parseInt(e),(0,s.isNumber)(n)||(n=null),{offset:n,assertion:a}}},{key:'getChapterComponent',value:function(e){var t=e.split('!');return t[0]}},{key:'getPathComponent',value:function(e){var t=e.split('!');if(t[1]){var n=t[1].split(',');return n[0]}}},{key:'getRange',value:function(e){var t=e.split(',');return 3===t.length&&[t[1],t[2]]}},{key:'getCharecterOffsetComponent',value:function(e){var t=e.split(':');return t[1]||''}},{key:'joinSteps',value:function(e){return e?e.map(function(e){var t='';return'element'===e.type&&(t+=2*(e.index+1)),'text'===e.type&&(t+=1+2*e.index),e.id&&(t+='['+e.id+']'),t}).join('/'):''}},{key:'segmentString',value:function(e){var t='/';return t+=this.joinSteps(e.steps),e.terminal&&null!=e.terminal.offset&&(t+=':'+e.terminal.offset),e.terminal&&null!=e.terminal.assertion&&(t+='['+e.terminal.assertion+']'),t}},{key:'toString',value:function(){var e='epubcfi(';return e+=this.segmentString(this.base),e+='!',e+=this.segmentString(this.path),this.range&&this.start&&(e+=',',e+=this.segmentString(this.start)),this.range&&this.end&&(e+=',',e+=this.segmentString(this.end)),e+=')',e}},{key:'compare',value:function(t,n){var a,o,s,r,l,l;if('string'==typeof t&&(t=new e(t)),'string'==typeof n&&(n=new e(n)),t.spinePos>n.spinePos)return 1;if(t.spinePos<n.spinePos)return-1;t.range?(a=t.path.steps.concat(t.start.steps),s=t.start.terminal):(a=t.path.steps,s=t.path.terminal),n.range?(o=n.path.steps.concat(n.start.steps),r=n.start.terminal):(o=n.path.steps,r=n.path.terminal);for(var d=0;d<a.length;d++){if(!a[d])return-1;if(!o[d])return 1;if(a[d].index>o[d].index)return 1;if(a[d].index<o[d].index)return-1}return a.length<o.length?1:s.offset>r.offset?1:s.offset<r.offset?-1:0}},{key:'step',value:function(e){var t=e.nodeType===l?'text':'element';return{id:e.id,tagName:e.tagName,type:t,index:this.position(e)}}},{key:'filteredStep',value:function(e,t){var n=this.filter(e,t),a;if(n)return a=n.nodeType===l?'text':'element',{id:n.id,tagName:n.tagName,type:a,index:this.filteredPosition(n,t)}}},{key:'pathTo',value:function(e,t,n){for(var a={steps:[],terminal:{offset:null,assertion:null}},i=e,o;i&&i.parentNode&&i.parentNode.nodeType!=9;)o=n?this.filteredStep(i,n):this.step(i),o&&a.steps.unshift(o),i=i.parentNode;return null!=t&&0<=t&&(a.terminal.offset=t,'text'!=a.steps[a.steps.length-1].type&&a.steps.push({type:'text',index:0})),a}},{key:'equalStep',value:function(e,t){return e&&t&&e.index===t.index&&e.id===t.id&&e.type===t.type}},{key:'fromRange',value:function(e,t,n){var a={range:!1,base:{},path:{},start:null,end:null},s=e.startContainer,r=e.endContainer,l=e.startOffset,d=e.endOffset,u=!1;if(n&&(u=null!=s.ownerDocument.querySelector('.'+n)),'string'==typeof t?(a.base=this.parseComponent(t),a.spinePos=a.base.steps[1].index):'object'===('undefined'==typeof t?'undefined':o(t))&&(a.base=t),e.collapsed)u&&(l=this.patchOffset(s,l,n)),a.path=this.pathTo(s,l,n);else{a.range=!0,u&&(l=this.patchOffset(s,l,n)),a.start=this.pathTo(s,l,n),u&&(d=this.patchOffset(r,d,n)),a.end=this.pathTo(r,d,n),a.path={steps:[],terminal:null};var c=a.start.steps.length,p;for(p=0;p<c&&this.equalStep(a.start.steps[p],a.end.steps[p]);p++)p===c-1?a.start.terminal===a.end.terminal&&(a.path.steps.push(a.start.steps[p]),a.range=!1):a.path.steps.push(a.start.steps[p]);a.start.steps=a.start.steps.slice(a.path.steps.length),a.end.steps=a.end.steps.slice(a.path.steps.length)}return a}},{key:'fromNode',value:function(e,t,n){var a={range:!1,base:{},path:{},start:null,end:null};return'string'==typeof t?(a.base=this.parseComponent(t),a.spinePos=a.base.steps[1].index):'object'===('undefined'==typeof t?'undefined':o(t))&&(a.base=t),a.path=this.pathTo(e,null,n),a}},{key:'filter',value:function(e,t){var n=!1,a,i,o,s,r;return e.nodeType===l?(n=!0,o=e.parentNode,a=e.parentNode.classList.contains(t)):(n=!1,a=e.classList.contains(t)),a&&n?(s=o.previousSibling,r=o.nextSibling,s&&s.nodeType===l?i=s:r&&r.nodeType===l&&(i=r),i?i:e):a&&!n?!1:e}},{key:'patchOffset',value:function(e,t,n){if(e.nodeType!=l)throw new Error('Anchor must be a text node');var a=e,i=t;for(e.parentNode.classList.contains(n)&&(a=e.parentNode);a.previousSibling;){if(a.previousSibling.nodeType!==r)i+=a.previousSibling.textContent.length;else if(a.previousSibling.classList.contains(n))i+=a.previousSibling.textContent.length;else break;a=a.previousSibling}return i}},{key:'normalizedMap',value:function(e,t,n){var a={},o=-1,s=e.length,d,i,u;for(d=0;d<s;d++)i=e[d].nodeType,i===r&&e[d].classList.contains(n)&&(i=l),0<d&&i===l&&u===l?a[d]=o:t===i&&(++o,a[d]=o),u=i;return a}},{key:'position',value:function(e){var t,n;return e.nodeType===r?(t=e.parentNode.children,!t&&(t=(0,s.findChildren)(e.parentNode)),n=Array.prototype.indexOf.call(t,e)):(t=this.textNodes(e.parentNode),n=t.indexOf(e)),n}},{key:'filteredPosition',value:function(e,t){var n,a,i;return e.nodeType===r?(n=e.parentNode.children,i=this.normalizedMap(n,r,t)):(n=e.parentNode.childNodes,e.parentNode.classList.contains(t)&&(e=e.parentNode,n=e.parentNode.childNodes),i=this.normalizedMap(n,l,t)),a=Array.prototype.indexOf.call(n,e),i[a]}},{key:'stepsToXpath',value:function(e){var t=['.','*'];return e.forEach(function(e){var n=e.index+1;e.id?t.push('*[position()='+n+' and @id=\''+e.id+'\']'):'text'===e.type?t.push('text()['+n+']'):t.push('*['+n+']')}),t.join('/')}},{key:'stepsToQuerySelector',value:function(e){var t=['html'];return e.forEach(function(e){var n=e.index+1;e.id?t.push('#'+e.id):'text'===e.type||t.push('*:nth-child('+n+')')}),t.join('>')}},{key:'textNodes',value:function(e,t){return Array.prototype.slice.call(e.childNodes).filter(function(e){return e.nodeType===l||t&&e.classList.contains(t)})}},{key:'walkToNode',value:function(e,t,n){var a=t||document,o=a.documentElement,r=e.length,l,d,u;for(u=0;u<r&&(d=e[u],'element'===d.type?d.id?o=a.getElementById(d.id):(l=o.children||(0,s.findChildren)(o),o=l[d.index]):'text'===d.type&&(o=this.textNodes(o,n)[d.index]),!!o);u++);return o}},{key:'findNode',value:function(e,t,n){var a=t||document,i,o;return n||'undefined'==typeof a.evaluate?n?i=this.walkToNode(e,a,n):i=this.walkToNode(e,a):(o=this.stepsToXpath(e),i=a.evaluate(o,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),i}},{key:'fixMiss',value:function(e,t,n,a){var i=this.findNode(e.slice(0,-1),n,a),o=i.childNodes,s=this.normalizedMap(o,l,a),d=e[e.length-1].index,u,c;for(var p in s){if(!s.hasOwnProperty(p))return;if(s[p]===d)if(u=o[p],c=u.textContent.length,t>c)t-=c;else{i=u.nodeType===r?u.childNodes[0]:u;break}}return{container:i,offset:t}}},{key:'toRange',value:function(e,t){var n=e||document,a=this,i=!!t&&null!=n.querySelector('.'+t),o,r,l,d,u,c,p,h;if(o='undefined'==typeof n.createRange?new s.RangeObject:n.createRange(),a.range?(r=a.start,c=a.path.steps.concat(r.steps),d=this.findNode(c,n,i?t:null),l=a.end,p=a.path.steps.concat(l.steps),u=this.findNode(p,n,i?t:null)):(r=a.path,c=a.path.steps,d=this.findNode(a.path.steps,n,i?t:null)),d)try{null==r.terminal.offset?o.setStart(d,0):o.setStart(d,r.terminal.offset)}catch(a){h=this.fixMiss(c,r.terminal.offset,n,i?t:null),o.setStart(h.container,h.offset)}else return console.log('No startContainer found for',this.toString()),null;if(u)try{null==l.terminal.offset?o.setEnd(u,0):o.setEnd(u,l.terminal.offset)}catch(s){h=this.fixMiss(p,a.end.terminal.offset,n,i?t:null),o.setEnd(h.container,h.offset)}return o}},{key:'isCfiString',value:function(e){return'string'==typeof e&&0===e.indexOf('epubcfi(')&&')'===e[e.length-1]}},{key:'generateChapterComponent',value:function(e,t,n){var a=parseInt(t),i='/'+2*(e+1)+'/';return i+=2*(a+1),n&&(i+='['+n+']'),i}},{key:'collapse',value:function(e){this.range&&(this.range=!1,e?(this.path.steps=this.path.steps.concat(this.start.steps),this.path.terminal=this.start.terminal):(this.path.steps=this.path.steps.concat(this.end.steps),this.path.terminal=this.end.terminal))}}]),e}();t.default=d,e.exports=t['default']},function(e,t,n){'use strict';var a=n(27),o=n(41),s=Function.prototype.apply,r=Function.prototype.call,i=Object.create,l=Object.defineProperty,d=Object.defineProperties,u=Object.prototype.hasOwnProperty,c={configurable:!0,enumerable:!1,writable:!0},p,h,g,f,m,y,v;p=function(e,t){var n;return o(t),u.call(this,'__ee__')?n=this.__ee__:(n=c.value=i(null),l(this,'__ee__',c),c.value=null),n[e]?'object'==typeof n[e]?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},h=function(e,t){var n,a;return o(t),a=this,p.call(this,e,n=function(){g.call(a,e,n),s.call(t,this,arguments)}),n.__eeOnceListener__=t,this},g=function(e,t){var n,a,s,r;if(o(t),!u.call(this,'__ee__'))return this;if(n=this.__ee__,!n[e])return this;if(a=n[e],'object'==typeof a)for(r=0;s=a[r];++r)(s===t||s.__eeOnceListener__===t)&&(2===a.length?n[e]=a[r?0:1]:a.splice(r,1));else(a===t||a.__eeOnceListener__===t)&&delete n[e];return this},f=function(e){var t,n,a,i,o;if(u.call(this,'__ee__')&&(i=this.__ee__[e],!!i))if('object'==typeof i){for(n=arguments.length,o=Array(n-1),t=1;t<n;++t)o[t-1]=arguments[t];for(i=i.slice(),t=0;a=i[t];++t)s.call(a,this,o)}else switch(arguments.length){case 1:r.call(i,this);break;case 2:r.call(i,this,arguments[1]);break;case 3:r.call(i,this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=Array(n-1),t=1;t<n;++t)o[t-1]=arguments[t];s.call(i,this,o);}},m={on:p,once:h,off:g,emit:f},y={on:a(p),once:a(h),off:a(g),emit:a(f)},v=d({},y),e.exports=t=function(e){return null==e?i(v):d(Object(e),y)},t.methods=m},function(e,t){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var n=t.DOM_EVENTS=['keydown','keyup','keypressed','mouseup','mousedown','click','touchend','touchstart'],a=t.EVENTS={BOOK:{OPEN_FAILED:'openFailed'},CONTENTS:{EXPAND:'expand',RESIZE:'resize',SELECTED:'selected',SELECTED_RANGE:'selectedRange',LINK_CLICKED:'linkClicked'},LOCATIONS:{CHANGED:'changed'},MANAGERS:{RESIZE:'resize',RESIZED:'resized',ORIENTATION_CHANGE:'orientationchange',ADDED:'added',SCROLL:'scroll',SCROLLED:'scrolled'},VIEWS:{AXIS:'axis',LOAD_ERROR:'loaderror',RENDERED:'rendered',RESIZED:'resized',DISPLAYED:'displayed',SHOWN:'shown',HIDDEN:'hidden',MARK_CLICKED:'markClicked'},RENDITION:{STARTED:'started',ATTACHED:'attached',DISPLAYED:'displayed',DISPLAY_ERROR:'displayerror',RENDERED:'rendered',REMOVED:'removed',RESIZED:'resized',ORIENTATION_CHANGE:'orientationchange',LOCATION_CHANGED:'locationChanged',RELOCATED:'relocated',MARK_CLICKED:'markClicked',SELECTED:'selected',LAYOUT:'layout'},LAYOUT:{UPDATED:'updated'}}},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(6),s=function(e){return e&&e.__esModule?e:{default:e}}(o),r=function(){function e(t){a(this,e);var n,i;n=t.indexOf('://'),-1<n&&(t=new URL(t).pathname),i=this.parse(t),this.path=t,this.directory=this.isDirectory(t)?t:i.dir+'/',this.filename=i.base,this.extension=i.ext.slice(1)}return i(e,[{key:'parse',value:function(e){return s.default.parse(e)}},{key:'isAbsolute',value:function(e){return s.default.isAbsolute(e||this.path)}},{key:'isDirectory',value:function(e){return'/'===e.charAt(e.length-1)}},{key:'resolve',value:function(e){return s.default.resolve(this.directory,e)}},{key:'relative',value:function(e){return s.default.relative(this.directory,e)}},{key:'splitPath',value:function(e){return this.splitPathRe.exec(e).slice(1)}},{key:'toString',value:function(){return this.path}}]),e}();t.default=r,e.exports=t['default']},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(4),r=a(s),l=n(6),d=a(l),u=function(){function e(t,n){i(this,e);var a=-1<t.indexOf('://'),o=t,s;if(this.Url=void 0,this.href=t,this.protocol='',this.origin='',this.hash='',this.hash='',this.search='',this.base=n,!a&&!1!==n&&'string'!=typeof n&&window&&window.location&&(this.base=window.location.href),a||this.base)try{this.Url=this.base?new URL(t,this.base):new URL(t),this.href=this.Url.href,this.protocol=this.Url.protocol,this.origin=this.Url.origin,this.hash=this.Url.hash,this.search=this.Url.search,o=this.Url.pathname}catch(t){this.Url=void 0,this.base&&(s=new r.default(this.base),o=s.resolve(o))}this.Path=new r.default(o),this.directory=this.Path.directory,this.filename=this.Path.filename,this.extension=this.Path.extension}return o(e,[{key:'path',value:function(){return this.Path}},{key:'resolve',value:function(e){var t=-1<e.indexOf('://'),n;return t?e:(n=d.default.resolve(this.directory,e),this.origin+n)}},{key:'relative',value:function(e){return d.default.relative(e,this.directory)}},{key:'toString',value:function(){return this.href}}]),e}();t.default=u,e.exports=t['default']},function(e){'use strict';function t(e){if('string'!=typeof e)throw new TypeError('Path must be a string. Received '+e)}function n(e,t){for(var n='',a=-1,o=0,s=0,i;s<=e.length;++s){if(s<e.length)i=e.charCodeAt(s);else if(47===i)break;else i=47;if(47===i){if(a==s-1||1==o);else if(a!=s-1&&2==o){if(2>n.length||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(2<n.length){for(var r=n.length-1,l=r;0<=l&&47!==n.charCodeAt(l);--l);if(l!=r){n=-1==l?'':n.slice(0,l),a=s,o=0;continue}}else if(2===n.length||1===n.length){n='',a=s,o=0;continue}t&&(0<n.length?n+='/..':n='..')}else 0<n.length?n+='/'+e.slice(a+1,s):n=e.slice(a+1,s);a=s,o=0}else 46===i&&-1!=o?++o:o=-1}return n}function a(e,t){var n=t.dir||t.root,a=t.base||(t.name||'')+(t.ext||'');return n?n===t.root?n+a:n+e+a:a}if(!o)var o={cwd:function(){return'/'}};var s={resolve:function(){for(var e='',a=!1,s=arguments.length-1,i;-1<=s&&!a;s--){var r;(0<=s?r=arguments[s]:(void 0==i&&(i=o.cwd()),r=i),t(r),0!==r.length)&&(e=r+'/'+e,a=47===r.charCodeAt(0))}return e=n(e,!a),a?0<e.length?'/'+e:'/':0<e.length?e:'.'},normalize:function(e){if(t(e),0===e.length)return'.';var a=47===e.charCodeAt(0),i=47===e.charCodeAt(e.length-1);return e=n(e,!a),0!==e.length||a||(e='.'),0<e.length&&i&&(e+='/'),a?'/'+e:e},isAbsolute:function(e){return t(e),0<e.length&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return'.';for(var e=0,n,a;e<arguments.length;++e)a=arguments[e],t(a),0<a.length&&(void 0==n?n=a:n+='/'+a);return void 0===n?'.':s.normalize(n)},relative:function(e,n){if(t(e),t(n),e===n)return'';if(e=s.resolve(e),n=s.resolve(n),e===n)return'';for(var a=1;a<e.length&&47===e.charCodeAt(a);++a);for(var o=e.length,r=o-a,l=1;l<n.length&&47===n.charCodeAt(l);++l);for(var d=n.length,u=d-l,c=r<u?r:u,p=-1,h=0;h<=c;++h){if(h==c){if(u>c){if(47===n.charCodeAt(l+h))return n.slice(l+h+1);if(0==h)return n.slice(l+h)}else r>c&&(47===e.charCodeAt(a+h)?p=h:0==h&&(p=0));break}var i=e.charCodeAt(a+h),g=n.charCodeAt(l+h);if(i!==g)break;else 47===i&&(p=h)}var f='';for(h=a+p+1;h<=o;++h)(h===o||47===e.charCodeAt(h))&&(f+=0===f.length?'..':'/..');return 0<f.length?f+n.slice(l+p):(l+=p,47===n.charCodeAt(l)&&++l,n.slice(l))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return'.';for(var n=e.charCodeAt(0),a=47===n,o=-1,s=!0,r=e.length-1;1<=r;--r)if(n=e.charCodeAt(r),47!==n)s=!1;else if(!s){o=r;break}return-1===o?a?'/':'.':a&&1===o?'//':e.slice(0,o)},basename:function(e,n){if(n!==void 0&&'string'!=typeof n)throw new TypeError('"ext" argument must be a string');t(e);var a=0,o=-1,s=!0,r;if(void 0!==n&&0<n.length&&n.length<=e.length){if(n.length===e.length&&n===e)return'';var i=n.length-1,l=-1;for(r=e.length-1;0<=r;--r){var d=e.charCodeAt(r);if(47!==d)-1==l&&(s=!1,l=r+1),0<=i&&(d===n.charCodeAt(i)?-1==--i&&(o=r):(i=-1,o=l));else if(!s){a=r+1;break}}return a===o?o=l:-1===o&&(o=e.length),e.slice(a,o)}for(r=e.length-1;0<=r;--r)if(47!==e.charCodeAt(r))-1==o&&(s=!1,o=r+1);else if(!s){a=r+1;break}return-1===o?'':e.slice(a,o)},extname:function(e){t(e);for(var n=-1,a=0,o=-1,s=!0,r=0,l=e.length-1,i;0<=l;--l){if(i=e.charCodeAt(l),47===i){if(!s){a=l+1;break}continue}-1==o&&(s=!1,o=l+1),46===i?-1==n?n=l:1!=r&&(r=1):-1!==n&&(r=-1)}return-1===n||-1===o||0==r||1==r&&n===o-1&&n===a+1?'':e.slice(n,o)},format:function(e){if(null===e||'object'!=typeof e)throw new TypeError('Parameter "pathObject" must be an object, not '+typeof e);return a('/',e)},parse:function(e){t(e);var n={root:'',dir:'',base:'',ext:'',name:''};if(0===e.length)return n;var a=e.charCodeAt(0),o=47===a,s;o?(n.root='/',s=1):s=0;for(var r=-1,l=0,d=-1,u=!0,c=e.length-1,i=0;c>=s;--c){if(a=e.charCodeAt(c),47===a){if(!u){l=c+1;break}continue}-1==d&&(u=!1,d=c+1),46===a?-1==r?r=c:1!=i&&(i=1):-1!=r&&(i=-1)}return-1==r||-1==d||0==i||1==i&&r==d-1&&r==l+1?-1!=d&&(0==l&&o?n.base=n.name=e.slice(1,d):n.base=n.name=e.slice(l,d)):(0==l&&o?(n.name=e.slice(1,r),n.base=e.slice(1,d)):(n.name=e.slice(l,r),n.base=e.slice(l,d)),n.ext=e.slice(r,d)),0<l?n.dir=e.slice(0,l-1):o&&(n.dir='/'),n},sep:'/',delimiter:':',posix:null};e.exports=s},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0}),t.replaceBase=function(e,t){var n=t.url,a=-1<n.indexOf('://'),i,s;e&&(s=(0,o.qs)(e,'head'),i=(0,o.qs)(s,'base'),!i&&(i=e.createElement('base'),s.insertBefore(i,s.firstChild)),!a&&window&&window.location&&(n=window.location.origin+n),i.setAttribute('href',n))},t.replaceCanonical=function(e,t){var n=t.canonical,a,i;e&&(a=(0,o.qs)(e,'head'),i=(0,o.qs)(a,'link[rel=\'canonical\']'),i?i.setAttribute('href',n):(i=e.createElement('link'),i.setAttribute('rel','canonical'),i.setAttribute('href',n),a.appendChild(i)))},t.replaceMeta=function(e,t){var n=t.idref,a,i;e&&(a=(0,o.qs)(e,'head'),i=(0,o.qs)(a,'link[property=\'dc.identifier\']'),i?i.setAttribute('content',n):(i=e.createElement('meta'),i.setAttribute('name','dc.identifier'),i.setAttribute('content',n),a.appendChild(i)))},t.replaceLinks=function(e,t){var n=e.querySelectorAll('a[href]');if(n.length)for(var a=(0,o.qs)(e.ownerDocument,'base'),r=a?a.getAttribute('href'):void 0,l=function(e){var n=e.getAttribute('href');if(0!==n.indexOf('mailto:')){var a=-1<n.indexOf('://'),i=new s.default(n,r);a?e.setAttribute('target','_blank'):e.onclick=function(){return i&&i.hash?t(i.Path.path+i.hash):i?t(i.Path.path):t(n),!1}}}.bind(this),d=0;d<n.length;d++)l(n[d])},t.substitute=function(e,t,n){return t.forEach(function(t,a){t&&n[a]&&(e=e.replace(new RegExp(t,'g'),n[a]))}),e};var o=n(0),i=n(5),s=a(i),r=n(4),l=a(r)},function(e){var t=function(){return this}();try{t=t||Function('return this')()||(1,eval)('this')}catch(n){'object'==typeof window&&(t=window)}e.exports=t},function(e,t,n){'use strict';var a=n(34)();e.exports=function(e){return e!==a&&null!==e}},function(e,t){'use strict';function n(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var a=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),i=function(){function e(t){n(this,e),this.context=t||this,this.hooks=[]}return a(e,[{key:'register',value:function(){for(var e=0;e<arguments.length;++e)if('function'==typeof arguments[e])this.hooks.push(arguments[e]);else for(var t=0;t<arguments[e].length;++t)this.hooks.push(arguments[e][t])}},{key:'trigger',value:function(){var e=arguments,t=this.context,n=[];return this.hooks.forEach(function(a){var i=a.apply(t,e);i&&'function'==typeof i.then&&n.push(i)}),Promise.all(n)}},{key:'list',value:function(){return this.hooks}},{key:'clear',value:function(){return this.hooks=[]}}]),e}();t.default=i,e.exports=t['default']},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var a=n(0),i=n(4),o=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=function(e,t,n,i){function s(t){u.reject(t)}function r(){if(this.readyState===XMLHttpRequest.DONE){var e=!1;if((''===this.responseType||'document'===this.responseType)&&(e=this.responseXML),200===this.status||e){var n;if(!this.response&&!e)return u.reject({status:this.status,message:'Empty Response',stack:new Error().stack}),u.promise;if(403===this.status)return u.reject({status:this.status,response:this.response,message:'Forbidden',stack:new Error().stack}),u.promise;n=e?this.responseXML:(0,a.isXml)(t)?(0,a.parse)(this.response,'text/xml'):'xhtml'==t?(0,a.parse)(this.response,'application/xhtml+xml'):'html'==t||'htm'==t?(0,a.parse)(this.response,'text/html'):'json'==t?JSON.parse(this.response):'blob'==t?l?this.response:new Blob([this.response]):this.response,u.resolve(n)}else u.reject({status:this.status,message:this.response,stack:new Error().stack})}}var l='undefined'!=typeof window&&window.URL,d=l?'blob':'arraybuffer',u=new a.defer,c=new XMLHttpRequest,p=XMLHttpRequest.prototype,h;for(h in'overrideMimeType'in p||Object.defineProperty(p,'overrideMimeType',{value:function(){}}),n&&(c.withCredentials=!0),c.onreadystatechange=r,c.onerror=s,c.open('GET',e,!0),i)c.setRequestHeader(h,i[h]);return'json'==t&&c.setRequestHeader('Accept','application/json'),t||(t=new o.default(e).extension),'blob'==t&&(c.responseType=d),(0,a.isXml)(t)&&c.overrideMimeType('text/xml'),'xhtml'==t,'html'!=t&&'htm'!=t,'binary'==t&&(c.responseType='arraybuffer'),c.send(),u.promise},e.exports=t['default']},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0}),t.Task=void 0;var i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(0),s=function(){function e(t){a(this,e),this._q=[],this.context=t,this.tick=o.requestAnimationFrame,this.running=!1,this.paused=!1}return i(e,[{key:'enqueue',value:function(){var e=[].shift.call(arguments),t=arguments,n,a,i;if(!e)throw new Error('No Task Provided');return'function'==typeof e?(n=new o.defer,a=n.promise,i={task:e,args:t,deferred:n,promise:a}):i={promise:e},this._q.push(i),!1!=this.paused||this.running||this.run(),i.promise}},{key:'dequeue',value:function(){var e,t,n;if(this._q.length&&!this.paused){if(e=this._q.shift(),t=e.task,t)return n=t.apply(this.context,e.args),n&&'function'==typeof n.then?n.then(function(){e.deferred.resolve.apply(this.context,arguments)}.bind(this),function(){e.deferred.reject.apply(this.context,arguments)}.bind(this)):(e.deferred.resolve.apply(this.context,n),e.promise);if(e.promise)return e.promise}else return e=new o.defer,e.deferred.resolve(),e.promise}},{key:'dump',value:function(){for(;this._q.length;)this.dequeue()}},{key:'run',value:function(){var e=this;return this.running||(this.running=!0,this.defered=new o.defer),this.tick.call(window,function(){e._q.length?e.dequeue().then(function(){this.run()}.bind(e)):(e.defered.resolve(),e.running=void 0)}),!0==this.paused&&(this.paused=!1),this.defered.promise}},{key:'flush',value:function(){return this.running?this.running:this._q.length?(this.running=this.dequeue().then(function(){return this.running=void 0,this.flush()}.bind(this)),this.running):void 0}},{key:'clear',value:function(){this._q=[]}},{key:'length',value:function(){return this._q.length}},{key:'pause',value:function(){this.paused=!0}},{key:'stop',value:function(){this._q=[],this.running=!1,this.paused=!0}}]),e}();t.default=s,t.Task=function e(t,n,i){return a(this,e),function(){var e=this,n=arguments||[];return new Promise(function(a,o){n.push(function(e,t){!e&&t?o(t):a(e)}),t.apply(i||e,n)})}}},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var s=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),l=a(r),d=n(0),u=n(1),c=a(u),p=n(19),h=a(p),g=n(7),f=n(3),m=/Chrome/.test(navigator.userAgent),y=!m&&/AppleWebKit/.test(navigator.userAgent),v=function(){function e(t,n,a,i){o(this,e),this.epubcfi=new c.default,this.document=t,this.documentElement=this.document.documentElement,this.content=n||this.document.body,this.window=this.document.defaultView,this._size={width:0,height:0},this.sectionIndex=i||0,this.cfiBase=a||'',this.epubReadingSystem('epub.js',ePub.VERSION),this.listeners()}return s(e,[{key:'width',value:function(e){var t=this.content;return e&&(0,d.isNumber)(e)&&(e+='px'),e&&(t.style.width=e),this.window.getComputedStyle(t).width}},{key:'height',value:function(e){var t=this.content;return e&&(0,d.isNumber)(e)&&(e+='px'),e&&(t.style.height=e),this.window.getComputedStyle(t).height}},{key:'contentWidth',value:function(e){var t=this.content||this.document.body;return e&&(0,d.isNumber)(e)&&(e+='px'),e&&(t.style.width=e),this.window.getComputedStyle(t).width}},{key:'contentHeight',value:function(e){var t=this.content||this.document.body;return e&&(0,d.isNumber)(e)&&(e+='px'),e&&(t.style.height=e),this.window.getComputedStyle(t).height}},{key:'textWidth',value:function(){var e=this.document.createRange(),t=this.content||this.document.body,n=(0,d.borders)(t),a;return e.selectNodeContents(t),a=e.getBoundingClientRect().width,n&&n.width&&(a+=n.width),i(a)}},{key:'textHeight',value:function(){var e=this.document.createRange(),t=this.content||this.document.body,n=(0,d.borders)(t),a;return e.selectNodeContents(t),a=e.getBoundingClientRect().height,a&&n.height&&(a+=n.height),i(a)}},{key:'scrollWidth',value:function(){var e=this.documentElement.scrollWidth;return e}},{key:'scrollHeight',value:function(){var e=this.documentElement.scrollHeight;return e}},{key:'overflow',value:function(e){return e&&(this.documentElement.style.overflow=e),this.window.getComputedStyle(this.documentElement).overflow}},{key:'overflowX',value:function(e){return e&&(this.documentElement.style.overflowX=e),this.window.getComputedStyle(this.documentElement).overflowX}},{key:'overflowY',value:function(e){return e&&(this.documentElement.style.overflowY=e),this.window.getComputedStyle(this.documentElement).overflowY}},{key:'css',value:function(e,t,n){var a=this.content||this.document.body;return t&&a.style.setProperty(e,t,n?'important':''),this.window.getComputedStyle(a)[e]}},{key:'viewport',value:function(e){var t=this.document.querySelector('meta[name=\'viewport\']'),n={width:void 0,height:void 0,scale:void 0,minimum:void 0,maximum:void 0,scalable:void 0},a=[],i={};if(t&&t.hasAttribute('content')){var o=t.getAttribute('content'),s=o.match(/width\s*=\s*([^,]*)/),r=o.match(/height\s*=\s*([^,]*)/),l=o.match(/initial-scale\s*=\s*([^,]*)/),u=o.match(/minimum-scale\s*=\s*([^,]*)/),c=o.match(/maximum-scale\s*=\s*([^,]*)/),p=o.match(/user-scalable\s*=\s*([^,]*)/);s&&s.length&&'undefined'!=typeof s[1]&&(n.width=s[1]),r&&r.length&&'undefined'!=typeof r[1]&&(n.height=r[1]),l&&l.length&&'undefined'!=typeof l[1]&&(n.scale=l[1]),u&&u.length&&'undefined'!=typeof u[1]&&(n.minimum=u[1]),c&&c.length&&'undefined'!=typeof c[1]&&(n.maximum=c[1]),p&&p.length&&'undefined'!=typeof p[1]&&(n.scalable=p[1])}return i=(0,d.defaults)(e||{},n),e&&(i.width&&a.push('width='+i.width),i.height&&a.push('height='+i.height),i.scale&&a.push('initial-scale='+i.scale),'no'===i.scalable?(a.push('minimum-scale='+i.scale),a.push('maximum-scale='+i.scale),a.push('user-scalable='+i.scalable)):(i.scalable&&a.push('user-scalable='+i.scalable),i.minimum&&a.push('minimum-scale='+i.minimum),i.maximum&&a.push('minimum-scale='+i.maximum)),!t&&(t=this.document.createElement('meta'),t.setAttribute('name','viewport'),this.document.querySelector('head').appendChild(t)),t.setAttribute('content',a.join(', ')),this.window.scrollTo(0,0)),i}},{key:'expand',value:function(){this.emit(f.EVENTS.CONTENTS.EXPAND)}},{key:'listeners',value:function(){this.imageLoadListeners(),this.mediaQueryListeners(),this.addEventListeners(),this.addSelectionListeners(),this.resizeListeners(),this.linksHandler()}},{key:'removeListeners',value:function(){this.removeEventListeners(),this.removeSelectionListeners(),clearTimeout(this.expanding)}},{key:'resizeCheck',value:function(){var e=this.textWidth(),t=this.textHeight();(e!=this._size.width||t!=this._size.height)&&(this._size={width:e,height:t},this.onResize&&this.onResize(this._size),this.emit(f.EVENTS.CONTENTS.RESIZE,this._size))}},{key:'resizeListeners',value:function(){clearTimeout(this.expanding),requestAnimationFrame(this.resizeCheck.bind(this)),this.expanding=setTimeout(this.resizeListeners.bind(this),350)}},{key:'transitionListeners',value:function(){var e=this.content;e.style.transitionProperty='font, font-size, font-size-adjust, font-stretch, font-variation-settings, font-weight, width, height',e.style.transitionDuration='0.001ms',e.style.transitionTimingFunction='linear',e.style.transitionDelay='0',this.document.addEventListener('transitionend',this.resizeCheck.bind(this))}},{key:'mediaQueryListeners',value:function(){for(var e=this.document.styleSheets,t=function(e){e.matches&&!this._expanding&&setTimeout(this.expand.bind(this),1)}.bind(this),n=0;n<e.length;n+=1){var a;try{a=e[n].cssRules}catch(t){return}if(!a)return;for(var i=0;i<a.length;i+=1)if(a[i].media){var o=this.window.matchMedia(a[i].media.mediaText);o.addListener(t)}}}},{key:'resizeObservers',value:function(){var e=this;this.observer=new MutationObserver(function(){e.resizeCheck()});this.observer.observe(this.document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}},{key:'imageLoadListeners',value:function(){for(var e=this.document.querySelectorAll('img'),t=0,n;t<e.length;t++)n=e[t],'undefined'!=typeof n.naturalWidth&&0===n.naturalWidth&&(n.onload=this.expand.bind(this))}},{key:'fontLoadListeners',value:function(){this.document&&this.document.fonts&&this.document.fonts.ready.then(function(){this.resizeCheck()}.bind(this))}},{key:'root',value:function(){return this.document?this.document.documentElement:null}},{key:'locationOf',value:function(e,t){var n={left:0,top:0},a;if(!this.document)return n;if(this.epubcfi.isCfiString(e)){var i=new c.default(e).toRange(this.document,t);if(i)if(i.startContainer.nodeType===Node.ELEMENT_NODE)a=i.startContainer.getBoundingClientRect(),n.left=a.left,n.top=a.top;else if(y){var o=i.startContainer,s=new Range;try{o.nodeType===1?a=o.getBoundingClientRect():i.startOffset+2<o.length?(s.setStart(o,i.startOffset),s.setEnd(o,i.startOffset+2),a=s.getBoundingClientRect()):0<i.startOffset-2?(s.setStart(o,i.startOffset-2),s.setEnd(o,i.startOffset),a=s.getBoundingClientRect()):a=o.parentNode.getBoundingClientRect()}catch(t){console.error(t,t.stack)}}else a=i.getBoundingClientRect()}else if('string'==typeof e&&-1<e.indexOf('#')){var r=e.substring(e.indexOf('#')+1),l=this.document.getElementById(r);l&&(a=l.getBoundingClientRect())}return a&&(n.left=a.left,n.top=a.top),n}},{key:'addStylesheet',value:function(e){return new Promise(function(t){var n=!1,a;return this.document?(a=this.document.querySelector('link[href=\''+e+'\']'),a?void t(!0):void(a=this.document.createElement('link'),a.type='text/css',a.rel='stylesheet',a.href=e,a.onload=a.onreadystatechange=function(){n||this.readyState&&'complete'!=this.readyState||(n=!0,setTimeout(function(){t(!0)},1))},this.document.head.appendChild(a))):void t(!1)}.bind(this))}},{key:'addStylesheetRules',value:function(e){var t='epubjs-inserted-css',n,a;if(this.document&&e&&0!==e.length)if(n=this.document.getElementById('#'+t),n||(n=this.document.createElement('style'),n.id=t),this.document.head.appendChild(n),a=n.sheet,'[object Array]'===Object.prototype.toString.call(e))for(var o=0,i=e.length;o<i;o++){var s=1,r=e[o],l=e[o][0],d='';'[object Array]'===Object.prototype.toString.call(r[1][0])&&(r=r[1],s=0);for(var u=r.length,c;s<u;s++)c=r[s],d+=c[0]+':'+c[1]+(c[2]?' !important':'')+';\n';a.insertRule(l+'{'+d+'}',a.cssRules.length)}else{var p=Object.keys(e);p.forEach(function(t){var n=e[t];if(Array.isArray(n))n.forEach(function(e){var n=Object.keys(e),i=n.map(function(t){return t+':'+e[t]}).join(';');a.insertRule(t+'{'+i+'}',a.cssRules.length)});else{var i=Object.keys(n),o=i.map(function(e){return e+':'+n[e]}).join(';');a.insertRule(t+'{'+o+'}',a.cssRules.length)}})}}},{key:'addScript',value:function(e){return new Promise(function(t){var n=!1,a;return this.document?void(a=this.document.createElement('script'),a.type='text/javascript',a.async=!0,a.src=e,a.onload=a.onreadystatechange=function(){n||this.readyState&&'complete'!=this.readyState||(n=!0,setTimeout(function(){t(!0)},1))},this.document.head.appendChild(a)):void t(!1)}.bind(this))}},{key:'addClass',value:function(e){var t;this.document&&(t=this.content||this.document.body,t&&t.classList.add(e))}},{key:'removeClass',value:function(e){var t;this.document&&(t=this.content||this.document.body,t&&t.classList.remove(e))}},{key:'addEventListeners',value:function(){this.document&&f.DOM_EVENTS.forEach(function(e){this.document.addEventListener(e,this.triggerEvent.bind(this),!1)},this)}},{key:'removeEventListeners',value:function(){this.document&&f.DOM_EVENTS.forEach(function(e){this.document.removeEventListener(e,this.triggerEvent,!1)},this)}},{key:'triggerEvent',value:function(t){this.emit(t.type,t)}},{key:'addSelectionListeners',value:function(){this.document&&this.document.addEventListener('selectionchange',this.onSelectionChange.bind(this),!1)}},{key:'removeSelectionListeners',value:function(){this.document&&this.document.removeEventListener('selectionchange',this.onSelectionChange,!1)}},{key:'onSelectionChange',value:function(){this.selectionEndTimeout&&clearTimeout(this.selectionEndTimeout),this.selectionEndTimeout=setTimeout(function(){var e=this.window.getSelection();this.triggerSelectedEvent(e)}.bind(this),250)}},{key:'triggerSelectedEvent',value:function(e){var t,n;e&&0<e.rangeCount&&(t=e.getRangeAt(0),!t.collapsed&&(n=new c.default(t,this.cfiBase).toString(),this.emit(f.EVENTS.CONTENTS.SELECTED,n),this.emit(f.EVENTS.CONTENTS.SELECTED_RANGE,t)))}},{key:'range',value:function(e,t){var n=new c.default(e);return n.toRange(this.document,t)}},{key:'cfiFromRange',value:function(e,t){return new c.default(e,this.cfiBase,t).toString()}},{key:'cfiFromNode',value:function(e,t){return new c.default(e,this.cfiBase,t).toString()}},{key:'map',value:function(e){var t=new h.default(e);return t.section()}},{key:'size',value:function(e,t){var n={scale:1,scalable:'no'};this.layoutStyle('scrolling'),0<=e&&(this.width(e),n.width=e,this.css('padding','0 '+e/12+'px',!0)),0<=t&&(this.height(t),n.height=t),this.css('margin','0'),this.css('box-sizing','border-box'),this.viewport(n)}},{key:'columns',value:function(e,t,n,a){var i=(0,d.prefixed)('column-axis'),o=(0,d.prefixed)('column-gap'),s=(0,d.prefixed)('column-width'),r=(0,d.prefixed)('column-fill'),l=this.writingMode(),u=0===l.indexOf('vertical')?'vertical':'horizontal';this.layoutStyle('paginated'),'rtl'===this.content.dir&&this.direction('rtl'),this.width(e),this.height(t),this.viewport({width:e,height:t,scale:1,scalable:'no'}),this.css('overflow-y','hidden'),this.css('margin','0',!0),'vertical'==u?this.css('padding',a/2+'px 20px',!0):this.css('padding','20px '+a/2+'px',!0),this.css('box-sizing','border-box'),this.css('max-width','inherit'),this.css(i,'horizontal'),this.css(r,'auto'),this.css(o,a+'px'),this.css(s,n+'px')}},{key:'scaler',value:function(e,t,n){var a='';this.css('transform-origin','top left'),(0<=t||0<=n)&&(a=' translate('+(t||0)+'px, '+(n||0)+'px )'),this.css('transform','scale('+e+')'+a)}},{key:'fit',value:function(e,t){var n=this.viewport(),a=e/parseInt(n.width),i=t/parseInt(n.height),o=a<i?a:i,s=(t-n.height*o)/2;this.layoutStyle('paginated'),this.width(e),this.height(t),this.overflow('hidden'),this.scaler(o,0,s),this.css('background-color','transparent')}},{key:'direction',value:function(e){this.documentElement&&(this.documentElement.style.direction=e)}},{key:'mapPage',value:function(e,t,n,a,i){var o=new h.default(t,i);return o.page(this,e,n,a)}},{key:'linksHandler',value:function(){var e=this;(0,g.replaceLinks)(this.content,function(t){e.emit(f.EVENTS.CONTENTS.LINK_CLICKED,t)})}},{key:'writingMode',value:function(e){var t=(0,d.prefixed)('writing-mode');return e&&this.documentElement&&(this.documentElement.style[t]=e),this.window.getComputedStyle(this.documentElement)[t]||''}},{key:'layoutStyle',value:function(e){return e&&(this._layoutStyle=e,navigator.epubReadingSystem.layoutStyle=this._layoutStyle),this._layoutStyle||'paginated'}},{key:'epubReadingSystem',value:function(e,t){return navigator.epubReadingSystem={name:e,version:t,layoutStyle:this.layoutStyle(),hasFeature:function(e){return'dom-manipulation'===e||'layout-changes'===e||'touch-events'===e||'mouse-events'===e||'keyboard-events'===e||'spine-scripting'!==e&&!1}},navigator.epubReadingSystem}},{key:'destroy',value:function(){this.observer&&this.observer.disconnect(),this.document.removeEventListener('transitionend',this.resizeCheck),this.removeListeners()}}],[{key:'listenedEvents',get:function(){return f.DOM_EVENTS}}]),e}();(0,l.default)(v.prototype),t.default=v,e.exports=t['default']},function(e,t,n){'use strict';function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var r=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),l=n(2),d=i(l),u=n(0),c=n(19),p=i(c),h=n(12),g=i(h),f=n(56),m=i(f),y=n(66),v=i(y),b=n(3),k=function(){function e(t){o(this,e),this.name='default',this.View=t.view,this.request=t.request,this.renditionQueue=t.queue,this.q=new g.default(this),this.settings=(0,u.extend)(this.settings||{},{infinite:!0,hidden:!1,width:void 0,height:void 0,axis:void 0,flow:'scrolled',ignoreClass:''}),(0,u.extend)(this.settings,t.settings||{}),this.viewSettings={ignoreClass:this.settings.ignoreClass,axis:this.settings.axis,flow:this.settings.flow,layout:this.layout,method:this.settings.method,width:0,height:0,forceEvenPages:!0},this.rendered=!1}return r(e,[{key:'render',value:function(e,t){var n=e.tagName;n&&('body'==n.toLowerCase()||'html'==n.toLowerCase())&&(this.fullsize=!0),this.fullsize&&(this.settings.overflow='visible',this.overflow=this.settings.overflow),this.settings.size=t,this.stage=new m.default({width:t.width,height:t.height,overflow:this.overflow,hidden:this.settings.hidden,axis:this.settings.axis,fullsize:this.fullsize,direction:this.settings.direction}),this.stage.attachTo(e),this.container=this.stage.getContainer(),this.views=new v.default(this.container),this._bounds=this.bounds(),this._stageSize=this.stage.size(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.stage.onResize(this.onResized.bind(this)),this.stage.onOrientationChange(this.onOrientationChange.bind(this)),this.addEventListeners(),this.layout&&this.updateLayout(),this.rendered=!0}},{key:'addEventListeners',value:function(){var e;window.addEventListener('unload',function(){this.destroy()}.bind(this)),e=this.fullsize?window:this.container,e.addEventListener('scroll',this.onScroll.bind(this))}},{key:'removeEventListeners',value:function(){var e;e=this.fullsize?window:this.container,e.removeEventListener('scroll',this.onScroll.bind(this))}},{key:'destroy',value:function(){clearTimeout(this.orientationTimeout),clearTimeout(this.resizeTimeout),clearTimeout(this.afterScrolled),this.clear(),this.removeEventListeners(),this.stage.destroy(),this.rendered=!1}},{key:'onOrientationChange',value:function(){var e=window,t=e.orientation;this.resize(),clearTimeout(this.orientationTimeout),this.orientationTimeout=setTimeout(function(){this.orientationTimeout=void 0,this.resize(),this.emit(b.EVENTS.MANAGERS.ORIENTATION_CHANGE,t)}.bind(this),500)}},{key:'onResized',value:function(){this.resize()}},{key:'resize',value:function(e,t){var n=this.stage.size(e,t);return this.winBounds=(0,u.windowBounds)(),this.orientationTimeout&&this.winBounds.width===this.winBounds.height?void(this._stageSize=void 0):void(this._stageSize&&this._stageSize.width===n.width&&this._stageSize.height===n.height||(this._stageSize=n,this._bounds=this.bounds(),this.clear(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.updateLayout(),this.emit(b.EVENTS.MANAGERS.RESIZED,{width:this._stageSize.width,height:this._stageSize.height})))}},{key:'createView',value:function(e){return new this.View(e,this.viewSettings)}},{key:'display',value:function(e,t){var n=new u.defer,a=n.promise;(t===e.href||(0,u.isNumber)(t))&&(t=void 0);var i=this.views.find(e);if(i&&e){var o=i.offset();if('ltr'===this.settings.direction)this.scrollTo(o.left,o.top,!0);else{var s=i.width();this.scrollTo(o.left+s,o.top,!0)}if(t){var r=i.locationOf(t);this.moveTo(r)}return n.resolve(),a}return this.clear(),this.add(e).then(function(e){if(t){var n=e.locationOf(t);this.moveTo(n)}}.bind(this),function(e){n.reject(e)}).then(function(){var t;if('pre-paginated'===this.layout.name&&1<this.layout.divisor&&(t=e.next(),t))return this.add(t)}.bind(this)).then(function(){this.views.show(),n.resolve()}.bind(this)),a}},{key:'afterDisplayed',value:function(e){this.emit(b.EVENTS.MANAGERS.ADDED,e)}},{key:'afterResized',value:function(e){this.emit(b.EVENTS.MANAGERS.RESIZE,e.section)}},{key:'moveTo',value:function(e){var t=0,n=0;this.isPaginated?(t=s(e.left/this.layout.delta)*this.layout.delta,t+this.layout.delta>this.container.scrollWidth&&(t=this.container.scrollWidth-this.layout.delta)):n=e.top,this.scrollTo(t,n,!0)}},{key:'add',value:function(e){var t=this,n=this.createView(e);return this.views.append(n),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.on(b.EVENTS.VIEWS.AXIS,function(e){t.updateAxis(e)}),n.display(this.request)}},{key:'append',value:function(e){var t=this,n=this.createView(e);return this.views.append(n),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.on(b.EVENTS.VIEWS.AXIS,function(e){t.updateAxis(e)}),n.display(this.request)}},{key:'prepend',value:function(e){var t=this,n=this.createView(e);return n.on(b.EVENTS.VIEWS.RESIZED,function(e){t.counter(e)}),this.views.prepend(n),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.on(b.EVENTS.VIEWS.AXIS,function(e){t.updateAxis(e)}),n.display(this.request)}},{key:'counter',value:function(e){'vertical'===this.settings.axis?this.scrollBy(0,e.heightDelta,!0):this.scrollBy(e.widthDelta,0,!0)}},{key:'next',value:function(){var e=this.settings.direction,t,n;if(this.views.length){if(this.isPaginated&&'horizontal'===this.settings.axis&&(!e||'ltr'===e))this.scrollLeft=this.container.scrollLeft,n=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,n<=this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next();else if(this.isPaginated&&'horizontal'===this.settings.axis&&'rtl'===e)this.scrollLeft=this.container.scrollLeft,n=this.container.scrollLeft,0<n?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next();else if(this.isPaginated&&'vertical'===this.settings.axis){this.scrollTop=this.container.scrollTop;var a=this.container.scrollTop+this.container.offsetHeight;a<this.container.scrollHeight?this.scrollBy(0,this.layout.height,!0):t=this.views.last().section.next()}else t=this.views.last().section.next();return t?(this.clear(),this.append(t).then(function(){var e;if('pre-paginated'===this.layout.name&&1<this.layout.divisor&&(e=t.next(),e))return this.append(e)}.bind(this),function(e){displaying.reject(e)}).then(function(){this.views.show()}.bind(this))):void 0}}},{key:'prev',value:function(){var e=this.settings.direction,t,n;if(this.views.length){if(this.isPaginated&&'horizontal'===this.settings.axis&&(!e||'ltr'===e))this.scrollLeft=this.container.scrollLeft,n=this.container.scrollLeft,0<n?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev();else if(this.isPaginated&&'horizontal'===this.settings.axis&&'rtl'===e)this.scrollLeft=this.container.scrollLeft,n=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,n<=this.container.scrollWidth?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev();else if(this.isPaginated&&'vertical'===this.settings.axis){this.scrollTop=this.container.scrollTop;var a=this.container.scrollTop;0<a?this.scrollBy(0,-this.layout.height,!0):t=this.views.first().section.prev()}else t=this.views.first().section.prev();return t?(this.clear(),this.prepend(t).then(function(){var e;if('pre-paginated'===this.layout.name&&1<this.layout.divisor&&(e=t.prev(),e))return this.prepend(e)}.bind(this),function(e){displaying.reject(e)}).then(function(){this.isPaginated&&'horizontal'===this.settings.axis&&('rtl'===this.settings.direction?this.scrollTo(0,0,!0):this.scrollTo(this.container.scrollWidth-this.layout.delta,0,!0)),this.views.show()}.bind(this))):void 0}}},{key:'current',value:function(){var e=this.visible();return e.length?e[e.length-1]:null}},{key:'clear',value:function(){this.views&&(this.views.hide(),this.scrollTo(0,0,!0),this.views.clear())}},{key:'currentLocation',value:function(){return this.location='vertical'===this.settings.axis?this.scrolledLocation():this.paginatedLocation(),this.location}},{key:'scrolledLocation',value:function(){var e=this,t=this.visible(),n=this.container.getBoundingClientRect(),o=n.height<window.innerHeight?n.height:window.innerHeight,s=0,r=0;this.fullsize&&(s=window.scrollY);var i=t.map(function(t){var l=t.section,d=l.index,u=l.href,c=t.position(),p=t.height(),h=s+n.top-c.top+r,g=h+o-r;g>p&&(g=p,r=g-h);var f=e.layout.count(p,o).pages,m=a(h/o),y=[],v=a(g/o);y=[];for(var b=m,i;b<=v;b++)i=b+1,y.push(i);var k=e.mapping.page(t.contents,t.section.cfiBase,h,g);return{index:d,href:u,pages:y,totalPages:f,mapping:k}});return i}},{key:'paginatedLocation',value:function(){var e=this,t=this.visible(),n=this.container.getBoundingClientRect(),a=0,o=0;this.fullsize&&(a=window.scrollX);var i=t.map(function(t){var r=t.section,l=r.index,d=r.href,u=t.offset().left,c=t.position().left,p=t.width(),h=a+n.left-c+o,g=h+e.layout.width-o,f=e.mapping.page(t.contents,t.section.cfiBase,h,g),m=e.layout.count(p).pages,y=s(h/e.layout.pageWidth),v=[],b=s(g/e.layout.pageWidth);if(0>y&&(y=0,++b),'rtl'===e.settings.direction){var k=y;y=m-b,b=m-k}for(var x=y+1,i;x<=b;x++)i=x,v.push(i);return{index:l,href:d,pages:v,totalPages:m,mapping:f}});return i}},{key:'isVisible',value:function(e,t,n,a){var i=e.position(),o=a||this.bounds();return'horizontal'===this.settings.axis&&i.right>o.left-t&&i.left<o.right+n||'vertical'===this.settings.axis&&i.bottom>o.top-t&&i.top<o.bottom+n}},{key:'visible',value:function(){for(var e=this.bounds(),t=this.views.displayed(),n=t.length,a=[],o=0,i,s;o<n;o++)s=t[o],i=this.isVisible(s,0,0,e),!0===i&&a.push(s);return a}},{key:'scrollBy',value:function(e,t,n){var a='rtl'===this.settings.direction?-1:1;n&&(this.ignore=!0),this.fullsize?window.scrollBy(e*a,t*a):(e&&(this.container.scrollLeft+=e*a),t&&(this.container.scrollTop+=t)),this.scrolled=!0}},{key:'scrollTo',value:function(e,t,n){n&&(this.ignore=!0),this.fullsize?window.scrollTo(e,t):(this.container.scrollLeft=e,this.container.scrollTop=t),this.scrolled=!0}},{key:'onScroll',value:function(){var e,t;this.fullsize?(e=window.scrollY,t=window.scrollX):(e=this.container.scrollTop,t=this.container.scrollLeft),this.scrollTop=e,this.scrollLeft=t,this.ignore?this.ignore=!1:(this.emit(b.EVENTS.MANAGERS.SCROLL,{top:e,left:t}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.emit(b.EVENTS.MANAGERS.SCROLLED,{top:this.scrollTop,left:this.scrollLeft})}.bind(this),20))}},{key:'bounds',value:function(){var e;return e=this.stage.bounds(),e}},{key:'applyLayout',value:function(e){this.layout=e,this.updateLayout()}},{key:'updateLayout',value:function(){this.stage&&(this._stageSize=this.stage.size(),this.isPaginated?(this.layout.calculate(this._stageSize.width,this._stageSize.height,this.settings.gap),this.settings.offset=this.layout.delta):this.layout.calculate(this._stageSize.width,this._stageSize.height),this.viewSettings.width=this.layout.width,this.viewSettings.height=this.layout.height,this.setLayout(this.layout))}},{key:'setLayout',value:function(e){this.viewSettings.layout=e,this.mapping=new p.default(e.props,this.settings.direction,this.settings.axis),this.views&&this.views.forEach(function(t){t&&t.setLayout(e)})}},{key:'updateAxis',value:function(e,t){this.isPaginated||(e='vertical'),(t||e!==this.settings.axis)&&(this.settings.axis=e,this.stage&&this.stage.axis(e),this.viewSettings.axis=e,this.mapping&&(this.mapping=new p.default(this.layout.props,this.settings.direction,this.settings.axis)),this.layout&&('vertical'===e?this.layout.spread('none'):this.layout.spread(this.layout.settings.spread)))}},{key:'updateFlow',value:function(e){var t='paginated'===e||'auto'===e;this.isPaginated=t,('scrolled-doc'===e||'scrolled-continuous'===e||'scrolled'===e)&&this.updateAxis('vertical'),this.viewSettings.flow=e,this.overflow=this.settings.overflow?this.settings.overflow:t?'hidden':'auto',this.updateLayout()}},{key:'getContents',value:function(){var e=[];return this.views?(this.views.forEach(function(t){var n=t&&t.contents;n&&e.push(n)}),e):e}},{key:'direction',value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'ltr';this.settings.direction=e,this.stage&&this.stage.direction(e),this.viewSettings.direction=e,this.updateLayout()}},{key:'isRendered',value:function(){return this.rendered}}]),e}();(0,d.default)(k.prototype),t.default=k,e.exports=t['default']},function(e){e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(t){t.exports=e},function(e){'use strict';var t={application:{ecmascript:['es','ecma'],javascript:'js',ogg:'ogx',pdf:'pdf',postscript:['ps','ai','eps','epsi','epsf','eps2','eps3'],"rdf+xml":'rdf',smil:['smi','smil'],"xhtml+xml":['xhtml','xht'],xml:['xml','xsl','xsd','opf','ncx'],zip:'zip',"x-httpd-eruby":'rhtml',"x-latex":'latex',"x-maker":['frm','maker','frame','fm','fb','book','fbdoc'],"x-object":'o',"x-shockwave-flash":['swf','swfl'],"x-silverlight":'scr',"epub+zip":'epub',"font-tdpfr":'pfr',"inkml+xml":['ink','inkml'],json:'json',"jsonml+json":'jsonml',"mathml+xml":'mathml',"metalink+xml":'metalink',mp4:'mp4s',"omdoc+xml":'omdoc',oxps:'oxps',"vnd.amazon.ebook":'azw',widget:'wgt',"x-dtbook+xml":'dtb',"x-dtbresource+xml":'res',"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-mobipocket-ebook":['prc','mobi'],"x-mspublisher":'pub',"x-nzb":'nzb',"x-tgif":'obj',"xaml+xml":'xaml',"xml-dtd":'dtd',"xproc+xml":'xpl',"xslt+xml":'xslt',"internet-property-stream":'acx',"x-compress":'z',"x-compressed":'tgz',"x-gzip":'gz'},audio:{flac:'flac',midi:['mid','midi','kar','rmi'],mpeg:['mpga','mpega','mp2','mp3','m4a','mp2a','m2a','m3a'],mpegurl:'m3u',ogg:['oga','ogg','spx'],"x-aiff":['aif','aiff','aifc'],"x-ms-wma":'wma',"x-wav":'wav',adpcm:'adp',mp4:'mp4a',webm:'weba',"x-aac":'aac',"x-caf":'caf',"x-matroska":'mka',"x-pn-realaudio-plugin":'rmp',xm:'xm',mid:['mid','rmi']},image:{gif:'gif',ief:'ief',jpeg:['jpeg','jpg','jpe'],pcx:'pcx',png:'png',"svg+xml":['svg','svgz'],tiff:['tiff','tif'],"x-icon":'ico',bmp:'bmp',webp:'webp',"x-pict":['pic','pct'],"x-tga":'tga',"cis-cod":'cod'},text:{"cache-manifest":['manifest','appcache'],css:'css',csv:'csv',html:['html','htm','shtml','stm'],mathml:'mml',plain:['txt','text','brf','conf','def','list','log','in','bas'],richtext:'rtx',"tab-separated-values":'tsv',"x-bibtex":'bib'},video:{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.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'}},n=function(){var e={},n,a,i,o;for(n in t)if(t.hasOwnProperty(n))for(a in t[n])if(t[n].hasOwnProperty(a))if(i=t[n][a],'string'==typeof i)e[i]=n+'/'+a;else for(o=0;o<i.length;o++)e[i[o]]=n+'/'+a;return e}();e.exports={lookup:function(e){return e&&n[e.split('.').pop().toLowerCase()]||'text/plain'}}},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},s=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),l=a(r),d=n(0),u=n(10),c=a(u),p=n(1),h=a(p),g=n(12),f=a(g),m=n(50),y=a(m),v=n(51),b=a(v),k=n(13),x=a(k),E=n(52),_=a(E),w=n(3),S=n(20),C=a(S),T=n(14),N=a(T),R=n(24),L=a(R),P=function(){function e(t,n){i(this,e),this.settings=(0,d.extend)(this.settings||{},{width:null,height:null,ignoreClass:'',manager:'default',view:'iframe',flow:null,layout:null,spread:null,minSpreadWidth:800,stylesheet:null,script:null}),(0,d.extend)(this.settings,n),'object'===o(this.settings.manager)&&(this.manager=this.settings.manager),this.book=t,this.hooks={},this.hooks.display=new c.default(this),this.hooks.serialize=new c.default(this),this.hooks.content=new c.default(this),this.hooks.unloaded=new c.default(this),this.hooks.layout=new c.default(this),this.hooks.render=new c.default(this),this.hooks.show=new c.default(this),this.hooks.content.register(this.handleLinks.bind(this)),this.hooks.content.register(this.passEvents.bind(this)),this.hooks.content.register(this.adjustImages.bind(this)),this.book.spine.hooks.content.register(this.injectIdentifier.bind(this)),this.settings.stylesheet&&this.book.spine.hooks.content.register(this.injectStylesheet.bind(this)),this.settings.script&&this.book.spine.hooks.content.register(this.injectScript.bind(this)),this.themes=new b.default(this),this.annotations=new _.default(this),this.epubcfi=new h.default,this.q=new f.default(this),this.location=void 0,this.q.enqueue(this.book.opened),this.starting=new d.defer,this.started=this.starting.promise,this.q.enqueue(this.start)}return s(e,[{key:'setManager',value:function(e){this.manager=e}},{key:'requireManager',value:function(e){var t;return t='string'==typeof e&&'default'===e?N.default:'string'==typeof e&&'continuous'===e?L.default:e,t}},{key:'requireView',value:function(e){var t;return t='string'==typeof e&&'iframe'===e?C.default:e,t}},{key:'start',value:function(){this.manager||(this.ViewManager=this.requireManager(this.settings.manager),this.View=this.requireView(this.settings.view),this.manager=new this.ViewManager({view:this.View,queue:this.q,request:this.book.load.bind(this.book),settings:this.settings})),this.direction(this.book.package.metadata.direction),this.settings.globalLayoutProperties=this.determineLayoutProperties(this.book.package.metadata),this.flow(this.settings.globalLayoutProperties.flow),this.layout(this.settings.globalLayoutProperties),this.manager.on(w.EVENTS.MANAGERS.ADDED,this.afterDisplayed.bind(this)),this.manager.on(w.EVENTS.MANAGERS.REMOVED,this.afterRemoved.bind(this)),this.manager.on(w.EVENTS.MANAGERS.RESIZED,this.onResized.bind(this)),this.manager.on(w.EVENTS.MANAGERS.ORIENTATION_CHANGE,this.onOrientationChange.bind(this)),this.manager.on(w.EVENTS.MANAGERS.SCROLLED,this.reportLocation.bind(this)),this.emit(w.EVENTS.RENDITION.STARTED),this.starting.resolve()}},{key:'attachTo',value:function(e){return this.q.enqueue(function(){this.manager.render(e,{width:this.settings.width,height:this.settings.height}),this.emit(w.EVENTS.RENDITION.ATTACHED)}.bind(this))}},{key:'display',value:function(e){return this.displaying&&this.displaying.resolve(),this.q.enqueue(this._display,e)}},{key:'_display',value:function(e){var t=this;if(this.book){var n=this.epubcfi.isCfiString(e),a=new d.defer,i=a.promise,o;return(this.displaying=a,this.book.locations.length()&&((0,d.isFloat)(e)||'1.0'===e)&&(e=this.book.locations.cfiFromPercentage(parseFloat(e))),o=this.book.spine.get(e),!o)?(a.reject(new Error('No Section Found')),i):(this.manager.display(o,e).then(function(){a.resolve(o),t.displaying=void 0,t.emit(w.EVENTS.RENDITION.DISPLAYED,o),t.reportLocation()},function(e){t.emit(w.EVENTS.RENDITION.DISPLAY_ERROR,e)}),i)}}},{key:'afterDisplayed',value:function(e){var t=this;e.on(w.EVENTS.VIEWS.MARK_CLICKED,function(n,a){return t.triggerMarkEvent(n,a,e)}),this.hooks.render.trigger(e,this).then(function(){e.contents?t.hooks.content.trigger(e.contents,t).then(function(){t.emit(w.EVENTS.RENDITION.RENDERED,e.section,e)}):t.emit(w.EVENTS.RENDITION.RENDERED,e.section,e)})}},{key:'afterRemoved',value:function(e){var t=this;this.hooks.unloaded.trigger(e,this).then(function(){t.emit(w.EVENTS.RENDITION.REMOVED,e.section,e)})}},{key:'onResized',value:function(e){this.emit(w.EVENTS.RENDITION.RESIZED,{width:e.width,height:e.height}),this.location&&this.location.start&&this.display(this.location.start.cfi)}},{key:'onOrientationChange',value:function(e){this.emit(w.EVENTS.RENDITION.ORIENTATION_CHANGE,e)}},{key:'moveTo',value:function(e){this.manager.moveTo(e)}},{key:'resize',value:function(e,t){e&&(this.settings.width=e),t&&(this.settings.height=t),this.manager.resize(e,t)}},{key:'clear',value:function(){this.manager.clear()}},{key:'next',value:function(){return this.q.enqueue(this.manager.next.bind(this.manager)).then(this.reportLocation.bind(this))}},{key:'prev',value:function(){return this.q.enqueue(this.manager.prev.bind(this.manager)).then(this.reportLocation.bind(this))}},{key:'determineLayoutProperties',value:function(e){var t=this.settings.layout||e.layout||'reflowable',n=this.settings.spread||e.spread||'auto',a=this.settings.orientation||e.orientation||'auto',i=this.settings.flow||e.flow||'auto',o=e.viewport||'',s=this.settings.minSpreadWidth||e.minSpreadWidth||800,r=this.settings.direction||e.direction||'ltr',l;return(0===this.settings.width||0<this.settings.width)&&(0===this.settings.height||0<this.settings.height),l={layout:t,spread:n,orientation:a,flow:i,viewport:o,minSpreadWidth:s,direction:r},l}},{key:'flow',value:function(e){var t=e;('scrolled'===e||'scrolled-doc'===e||'scrolled-continuous'===e)&&(t='scrolled'),('auto'===e||'paginated'===e)&&(t='paginated'),this.settings.flow=e,this._layout&&this._layout.flow(t),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this.manager&&this.manager.updateFlow(t),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:'layout',value:function(e){var t=this;return e&&(this._layout=new y.default(e),this._layout.spread(e.spread,this.settings.minSpreadWidth),this._layout.on(w.EVENTS.LAYOUT.UPDATED,function(e,n){t.emit(w.EVENTS.RENDITION.LAYOUT,e,n)})),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this._layout}},{key:'spread',value:function(e,t){this._layout.spread(e,t),this.manager.isRendered()&&this.manager.updateLayout()}},{key:'direction',value:function(e){this.settings.direction=e||'ltr',this.manager&&this.manager.direction(this.settings.direction),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:'reportLocation',value:function(){return this.q.enqueue(function(){requestAnimationFrame(function(){var e=this.manager.currentLocation();if(e&&e.then&&'function'==typeof e.then)e.then(function(e){var t=this.located(e);t&&t.start&&t.end&&(this.location=t,this.emit(w.EVENTS.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(w.EVENTS.RENDITION.RELOCATED,this.location))}.bind(this));else if(e){var t=this.located(e);if(!t||!t.start||!t.end)return;this.location=t,this.emit(w.EVENTS.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(w.EVENTS.RENDITION.RELOCATED,this.location)}}.bind(this))}.bind(this))}},{key:'currentLocation',value:function(){var e=this.manager.currentLocation();if(e&&e.then&&'function'==typeof e.then)e.then(function(e){var t=this.located(e);return t}.bind(this));else if(e){var t=this.located(e);return t}}},{key:'located',value:function(e){if(!e.length)return{};var t=e[0],n=e[e.length-1],a={start:{index:t.index,href:t.href,cfi:t.mapping.start,displayed:{page:t.pages[0]||1,total:t.totalPages}},end:{index:n.index,href:n.href,cfi:n.mapping.end,displayed:{page:n.pages[n.pages.length-1]||1,total:n.totalPages}}},i=this.book.locations.locationFromCfi(t.mapping.start),o=this.book.locations.locationFromCfi(n.mapping.end);null!=i&&(a.start.location=i,a.start.percentage=this.book.locations.percentageFromLocation(i)),null!=o&&(a.end.location=o,a.end.percentage=this.book.locations.percentageFromLocation(o));var s=this.book.pageList.pageFromCfi(t.mapping.start),r=this.book.pageList.pageFromCfi(n.mapping.end);return-1!=s&&(a.start.page=s),-1!=r&&(a.end.page=r),n.index===this.book.spine.last().index&&a.end.displayed.page>=a.end.displayed.total&&(a.atEnd=!0),t.index===this.book.spine.first().index&&1===a.start.displayed.page&&(a.atStart=!0),a}},{key:'destroy',value:function(){this.manager&&this.manager.destroy(),this.book=void 0}},{key:'passEvents',value:function(t){var n=this,e=x.default.listenedEvents;e.forEach(function(a){t.on(a,function(e){return n.triggerViewEvent(e,t)})}),t.on(w.EVENTS.CONTENTS.SELECTED,function(a){return n.triggerSelectedEvent(a,t)})}},{key:'triggerViewEvent',value:function(t,e){this.emit(t.type,t,e)}},{key:'triggerSelectedEvent',value:function(e,t){this.emit(w.EVENTS.RENDITION.SELECTED,e,t)}},{key:'triggerMarkEvent',value:function(e,t,n){this.emit(w.EVENTS.RENDITION.MARK_CLICKED,e,t,n)}},{key:'getRange',value:function(e,t){var n=new h.default(e),a=this.manager.visible().filter(function(e){if(n.spinePos===e.index)return!0});if(a.length)return a[0].contents.range(n,t)}},{key:'adjustImages',value:function(e){return'pre-paginated'===this._layout.name?new Promise(function(e){e()}):(e.addStylesheetRules({img:{"max-width":(this._layout.columnWidth?this._layout.columnWidth+'px':'100%')+'!important',"max-height":(this._layout.height?0.6*this._layout.height+'px':'60%')+'!important',"object-fit":'contain',"page-break-inside":'avoid'},svg:{"max-width":(this._layout.columnWidth?this._layout.columnWidth+'px':'100%')+'!important',"max-height":(this._layout.height?0.6*this._layout.height+'px':'60%')+'!important',"page-break-inside":'avoid'}}),new Promise(function(e){setTimeout(function(){e()},1)}))}},{key:'getContents',value:function(){return this.manager?this.manager.getContents():[]}},{key:'views',value:function(){var e=this.manager?this.manager.views:void 0;return e||[]}},{key:'handleLinks',value:function(e){var t=this;e&&e.on(w.EVENTS.CONTENTS.LINK_CLICKED,function(e){var n=t.book.path.relative(e);t.display(n)})}},{key:'injectStylesheet',value:function(e){var t=e.createElement('link');t.setAttribute('type','text/css'),t.setAttribute('rel','stylesheet'),t.setAttribute('href',this.settings.stylesheet),e.getElementsByTagName('head')[0].appendChild(t)}},{key:'injectScript',value:function(e){var t=e.createElement('script');t.setAttribute('type','text/javascript'),t.setAttribute('src',this.settings.script),t.textContent=' ',e.getElementsByTagName('head')[0].appendChild(t)}},{key:'injectIdentifier',value:function(e){var t=this.book.package.metadata.identifier,n=e.createElement('meta');n.setAttribute('name','dc.relation.ispartof'),t&&n.setAttribute('content',t),e.getElementsByTagName('head')[0].appendChild(n)}}]),e}();(0,l.default)(P.prototype),t.default=P,e.exports=t['default']},function(e,t,n){'use strict';function o(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var s=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(1),l=function(e){return e&&e.__esModule?e:{default:e}}(r),d=function(){function e(t,n,a,i){o(this,e),this.layout=t,this.horizontal='horizontal'===a,this.direction=n||'ltr',this._dev=i}return s(e,[{key:'section',value:function(e){var t=this.findRanges(e),n=this.rangeListToCfiList(e.section.cfiBase,t);return n}},{key:'page',value:function(e,t,n,a){var i=e&&e.document&&e.document.body,o;if(i){if(o=this.rangePairToCfiPair(t,{start:this.findStart(i,n,a),end:this.findEnd(i,n,a)}),!0===this._dev){var s=e.document,d=new l.default(o.start).toRange(s),u=new l.default(o.end).toRange(s),c=s.defaultView.getSelection(),p=s.createRange();c.removeAllRanges(),p.setStart(d.startContainer,d.startOffset),p.setEnd(u.endContainer,u.endOffset),c.addRange(p)}return o}}},{key:'walk',value:function(e,t){if(!(e&&e.nodeType===Node.TEXT_NODE)){var n={acceptNode:function(e){return 0<e.data.trim().length?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}},a=n.acceptNode;a.acceptNode=n.acceptNode;for(var i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,a,!1),o,s;(o=i.nextNode())&&(s=t(o),!s););return s}}},{key:'findRanges',value:function(e){for(var t=[],n=e.contents.scrollWidth(),o=a(n/this.layout.spreadWidth),s=o*this.layout.divisor,r=this.layout.columnWidth,l=this.layout.gap,d=0,i,u;d<s.pages;d++)i=(r+l)*d,u=r*(d+1)+l*d,t.push({start:this.findStart(e.document.body,i,u),end:this.findEnd(e.document.body,i,u)});return t}},{key:'findStart',value:function(e,t,n){for(var a=this,i=[e],o=e,s,r;i.length;)if(s=i.shift(),r=this.walk(s,function(e){var s,r,l,d,u;if(u=a.getBounds(e),a.horizontal&&'ltr'===a.direction){if(s=a.horizontal?u.left:u.top,r=a.horizontal?u.right:u.bottom,s>=t&&s<=n)return e;if(r>t)return e;o=e,i.push(e)}else if(a.horizontal&&'rtl'===a.direction){if(s=u.left,r=u.right,r<=n&&r>=t)return e;if(s<n)return e;o=e,i.push(e)}else{if(l=u.top,d=u.bottom,l>=t&&l<=n)return e;if(d>t)return e;o=e,i.push(e)}}),r)return this.findTextStartRange(r,t,n);return this.findTextStartRange(o,t,n)}},{key:'findEnd',value:function(e,t,n){for(var a=this,o=[e],s=e,r,l;o.length;)if(r=o.shift(),l=this.walk(r,function(e){var r,l,d,u,c;if(c=a.getBounds(e),a.horizontal&&'ltr'===a.direction){if(r=i(c.left),l=i(c.right),r>n&&s)return s;if(l>n)return e;s=e,o.push(e)}else if(a.horizontal&&'rtl'===a.direction){if(r=i(a.horizontal?c.left:c.top),l=i(a.horizontal?c.right:c.bottom),l<t&&s)return s;if(r<t)return e;s=e,o.push(e)}else{if(d=i(c.top),u=i(c.bottom),d>n&&s)return s;if(u>n)return e;s=e,o.push(e)}}),l)return this.findTextEndRange(l,t,n);return this.findTextEndRange(s,t,n)}},{key:'findTextStartRange',value:function(e,t,n){for(var a=this.splitTextNodeIntoRanges(e),o=0,i,s,r,l,d;o<a.length;o++)if(i=a[o],s=i.getBoundingClientRect(),this.horizontal&&'ltr'===this.direction){if(r=s.left,r>=t)return i;}else if(this.horizontal&&'rtl'===this.direction){if(d=s.right,d<=n)return i;}else if(l=s.top,l>=t)return i;return a[0]}},{key:'findTextEndRange',value:function(e,t,n){for(var a=this.splitTextNodeIntoRanges(e),o=0,i,s,r,l,d,u,c;o<a.length;o++){if(s=a[o],r=s.getBoundingClientRect(),this.horizontal&&'ltr'===this.direction){if(l=r.left,d=r.right,l>n&&i)return i;if(d>n)return s}else if(this.horizontal&&'rtl'===this.direction){if(l=r.left,d=r.right,d<t&&i)return i;if(l<t)return s}else{if(u=r.top,c=r.bottom,u>n&&i)return i;if(c>n)return s}i=s}return a[a.length-1]}},{key:'splitTextNodeIntoRanges',value:function(e,t){var n=[],a=e.textContent||'',i=a.trim(),o=e.ownerDocument,s=t||' ',r=i.indexOf(s),l;if(-1===r||e.nodeType!=Node.TEXT_NODE)return l=o.createRange(),l.selectNodeContents(e),[l];for(l=o.createRange(),l.setStart(e,0),l.setEnd(e,r),n.push(l),l=!1;-1!=r;)r=i.indexOf(s,r+1),0<r&&(l&&(l.setEnd(e,r),n.push(l)),l=o.createRange(),l.setStart(e,r+1));return l&&(l.setEnd(e,i.length),n.push(l)),n}},{key:'rangePairToCfiPair',value:function(e,t){var n=t.start,a=t.end;n.collapse(!0),a.collapse(!1);var i=new l.default(n,e).toString(),o=new l.default(a,e).toString();return{start:i,end:o}}},{key:'rangeListToCfiList',value:function(e,t){for(var n=[],a=0,i;a<t.length;a++)i=this.rangePairToCfiPair(e,t[a]),n.push(i);return n}},{key:'getBounds',value:function(e){var t;if(e.nodeType==Node.TEXT_NODE){var n=document.createRange();n.selectNodeContents(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();return t}},{key:'axis',value:function(e){return e&&(this.horizontal='horizontal'===e),this.horizontal}}]),e}();t.default=d,e.exports=t['default']},function(e,t,n){'use strict';function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var s=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),l=i(r),d=n(0),u=n(1),c=i(u),p=n(13),h=i(p),g=n(3),f=n(53),m=function(){function e(t,n){o(this,e),this.settings=(0,d.extend)({ignoreClass:'',axis:n.layout&&'scrolled'===n.layout.props.flow?'vertical':'horizontal',direction:void 0,width:0,height:0,layout:void 0,globalLayoutProperties:{},method:void 0},n||{}),this.id='epubjs-view-'+(0,d.uuid)(),this.section=t,this.index=t.index,this.element=this.container(this.settings.axis),this.added=!1,this.displayed=!1,this.rendered=!1,this.fixedWidth=0,this.fixedHeight=0,this.epubcfi=new c.default,this.layout=this.settings.layout,this.pane=void 0,this.highlights={},this.underlines={},this.marks={}}return s(e,[{key:'container',value:function(e){var t=document.createElement('div');return t.classList.add('epub-view'),t.style.height='0px',t.style.width='0px',t.style.overflow='hidden',t.style.position='relative',t.style.display='block',t.style.flex=e&&'horizontal'==e?'none':'initial',t}},{key:'create',value:function(){return this.iframe?this.iframe:(this.element||(this.element=this.createContainer()),this.iframe=document.createElement('iframe'),this.iframe.id=this.id,this.iframe.scrolling='no',this.iframe.style.overflow='hidden',this.iframe.seamless='seamless',this.iframe.style.border='none',this.iframe.setAttribute('enable-annotation','true'),this.resizing=!0,this.element.style.visibility='hidden',this.iframe.style.visibility='hidden',this.iframe.style.width='0',this.iframe.style.height='0',this._width=0,this._height=0,this.element.setAttribute('ref',this.index),this.element.appendChild(this.iframe),this.added=!0,this.elementBounds=(0,d.bounds)(this.element),this.supportsSrcdoc=!!('srcdoc'in this.iframe),this.settings.method||(this.settings.method=this.supportsSrcdoc?'srcdoc':'write'),this.iframe)}},{key:'render',value:function(e){return this.create(),this.size(),this.sectionRender||(this.sectionRender=this.section.render(e)),this.sectionRender.then(function(e){return this.load(e)}.bind(this)).then(function(){var e=this;this.layout.format(this.contents);var t=this.contents.writingMode(),n=0===t.indexOf('vertical')?'vertical':'horizontal';return this.setAxis(n),this.emit(g.EVENTS.VIEWS.AXIS,n),this.addListeners(),new Promise(function(t){e.expand(),t()})}.bind(this),function(t){return this.emit(g.EVENTS.VIEWS.LOAD_ERROR,t),new Promise(function(e,n){n(t)})}.bind(this)).then(function(){this.emit(g.EVENTS.VIEWS.RENDERED,this.section)}.bind(this))}},{key:'reset',value:function(){this.iframe&&(this.iframe.style.width='0',this.iframe.style.height='0',this._width=0,this._height=0,this._textWidth=void 0,this._contentWidth=void 0,this._textHeight=void 0,this._contentHeight=void 0),this._needsReframe=!0}},{key:'size',value:function(e,t){var n=e||this.settings.width,a=t||this.settings.height;'pre-paginated'===this.layout.name?this.lock('both',n,a):'horizontal'===this.settings.axis?this.lock('height',n,a):this.lock('width',n,a),this.settings.width=n,this.settings.height=a}},{key:'lock',value:function(e,t,n){var a=(0,d.borders)(this.element),i;i=this.iframe?(0,d.borders)(this.iframe):{width:0,height:0},'width'==e&&(0,d.isNumber)(t)&&(this.lockedWidth=t-a.width-i.width),'height'==e&&(0,d.isNumber)(n)&&(this.lockedHeight=n-a.height-i.height),'both'===e&&(0,d.isNumber)(t)&&(0,d.isNumber)(n)&&(this.lockedWidth=t-a.width-i.width,this.lockedHeight=n-a.height-i.height),this.displayed&&this.iframe&&this.expand()}},{key:'expand',value:function(){var e=this.lockedWidth,t=this.lockedHeight,n;!this.iframe||this._expanding||(this._expanding=!0,'pre-paginated'===this.layout.name?(e=this.layout.columnWidth,t=this.layout.height):'horizontal'===this.settings.axis?(e=this.contents.textWidth(),0<e%this.layout.pageWidth&&(e=a(e/this.layout.pageWidth)*this.layout.pageWidth),this.settings.forceEvenPages&&(n=e/this.layout.delta,1<this.layout.divisor&&'reflowable'===this.layout.name&&0<n%2&&(e+=this.layout.gap+this.layout.columnWidth))):'vertical'===this.settings.axis&&(t=this.contents.textHeight()),(this._needsReframe||e!=this._width||t!=this._height)&&this.reframe(e,t),this._expanding=!1)}},{key:'reframe',value:function(e,t){var n;(0,d.isNumber)(e)&&(this.element.style.width=e+'px',this.iframe.style.width=e+'px',this._width=e),(0,d.isNumber)(t)&&(this.element.style.height=t+'px',this.iframe.style.height=t+'px',this._height=t);var a=this.prevBounds?e-this.prevBounds.width:e,i=this.prevBounds?t-this.prevBounds.height:t;n={width:e,height:t,widthDelta:a,heightDelta:i},this.pane&&this.pane.render(),this.onResize(this,n),this.emit(g.EVENTS.VIEWS.RESIZED,n),this.prevBounds=n,this.elementBounds=(0,d.bounds)(this.element)}},{key:'load',value:function(e){var t=new d.defer,n=t.promise;if(!this.iframe)return t.reject(new Error('No Iframe Available')),n;if(this.iframe.onload=function(e){this.onLoad(e,t)}.bind(this),'blobUrl'===this.settings.method)this.blobUrl=(0,d.createBlobUrl)(e,'application/xhtml+xml'),this.iframe.src=this.blobUrl;else if('srcdoc'===this.settings.method)this.iframe.srcdoc=e;else{if(this.document=this.iframe.contentDocument,!this.document)return t.reject(new Error('No Document Available')),n;this.iframe.contentDocument.open(),this.iframe.contentDocument.write(e),this.iframe.contentDocument.close()}return n}},{key:'onLoad',value:function(e,t){var n=this;this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,this.contents=new h.default(this.document,this.document.body,this.section.cfiBase,this.section.index),this.rendering=!1;var a=this.document.querySelector('link[rel=\'canonical\']');a?a.setAttribute('href',this.section.canonical):(a=this.document.createElement('link'),a.setAttribute('rel','canonical'),a.setAttribute('href',this.section.canonical),this.document.querySelector('head').appendChild(a)),this.contents.on(g.EVENTS.CONTENTS.EXPAND,function(){n.displayed&&n.iframe&&(n.expand(),n.contents&&n.layout.format(n.contents))}),this.contents.on(g.EVENTS.CONTENTS.RESIZE,function(){n.displayed&&n.iframe&&(n.expand(),n.contents&&n.layout.format(n.contents))}),t.resolve(this.contents)}},{key:'setLayout',value:function(e){this.layout=e,this.contents&&(this.layout.format(this.contents),this.expand())}},{key:'setAxis',value:function(e){'scrolled'===this.layout.props.flow&&(e='vertical'),this.settings.axis=e,this.element.style.flex='horizontal'==e?'none':'initial',this.size()}},{key:'addListeners',value:function(){}},{key:'removeListeners',value:function(){}},{key:'display',value:function(e){var t=new d.defer;return this.displayed?t.resolve(this):this.render(e).then(function(){this.emit(g.EVENTS.VIEWS.DISPLAYED,this),this.onDisplayed(this),this.displayed=!0,t.resolve(this)}.bind(this),function(e){t.reject(e,this)}),t.promise}},{key:'show',value:function(){this.element.style.visibility='visible',this.iframe&&(this.iframe.style.visibility='visible'),this.emit(g.EVENTS.VIEWS.SHOWN,this)}},{key:'hide',value:function(){this.element.style.visibility='hidden',this.iframe.style.visibility='hidden',this.stopExpanding=!0,this.emit(g.EVENTS.VIEWS.HIDDEN,this)}},{key:'offset',value:function(){return{top:this.element.offsetTop,left:this.element.offsetLeft}}},{key:'width',value:function(){return this._width}},{key:'height',value:function(){return this._height}},{key:'position',value:function(){return this.element.getBoundingClientRect()}},{key:'locationOf',value:function(e){var t=this.iframe.getBoundingClientRect(),n=this.contents.locationOf(e,this.settings.ignoreClass);return{left:n.left,top:n.top}}},{key:'onDisplayed',value:function(){}},{key:'onResize',value:function(){}},{key:'bounds',value:function(e){return(e||!this.elementBounds)&&(this.elementBounds=(0,d.bounds)(this.element)),this.elementBounds}},{key:'highlight',value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},a=arguments[2];if(this.contents){var i=this.contents.range(e),o=function(){t.emit(g.EVENTS.VIEWS.MARK_CLICKED,e,n)};n.epubcfi=e,this.pane||(this.pane=new f.Pane(this.iframe,this.element));var s=new f.Highlight(i,'epubjs-hl',n,{fill:'yellow',"fill-opacity":'0.3',"mix-blend-mode":'multiply'}),r=this.pane.addMark(s);return this.highlights[e]={mark:r,element:r.element,listeners:[o,a]},r.element.setAttribute('ref','epubjs-hl'),r.element.addEventListener('click',o),r.element.addEventListener('touchstart',o),a&&(r.element.addEventListener('click',a),r.element.addEventListener('touchstart',a)),r}}},{key:'underline',value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},a=arguments[2];if(this.contents){var i=this.contents.range(e),o=function(){t.emit(g.EVENTS.VIEWS.MARK_CLICKED,e,n)};n.epubcfi=e,this.pane||(this.pane=new f.Pane(this.iframe,this.element));var s=new f.Underline(i,'epubjs-ul',n,{stroke:'black',"stroke-opacity":'0.3',"mix-blend-mode":'multiply'}),r=this.pane.addMark(s);return this.underlines[e]={mark:r,element:r.element,listeners:[o,a]},r.element.setAttribute('ref','epubjs-ul'),r.element.addEventListener('click',o),r.element.addEventListener('touchstart',o),a&&(r.element.addEventListener('click',a),r.element.addEventListener('touchstart',a)),r}}},{key:'mark',value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},a=arguments[2];if(this.contents){if(e in this.marks){var o=this.marks[e];return o}var s=this.contents.range(e);if(s){var r=s.commonAncestorContainer,l=1===r.nodeType?r:r.parentNode,d=function(){t.emit(g.EVENTS.VIEWS.MARK_CLICKED,e,n)};s.collapsed&&1===r.nodeType?(s=new Range,s.selectNodeContents(r)):s.collapsed&&(s=new Range,s.selectNodeContents(l));var u,c,p;if('pre-paginated'===this.layout.name||'horizontal'!==this.settings.axis){var h=s.getBoundingClientRect();u=h.top,c=h.right}else for(var f=s.getClientRects(),m=void 0,y=0;y!=f.length;y++)m=f[y],(!p||m.left<p)&&(p=m.left,c=p+this.layout.columnWidth-this.layout.gap,u=m.top);var i=this.document.createElement('a');return i.setAttribute('ref','epubjs-mk'),i.style.position='absolute',i.style.top=u+'px',i.style.left=c+'px',i.dataset.epubcfi=e,n&&Object.keys(n).forEach(function(e){i.dataset[e]=n[e]}),a&&(i.addEventListener('click',a),i.addEventListener('touchstart',a)),i.addEventListener('click',d),i.addEventListener('touchstart',d),this.element.appendChild(i),this.marks[e]={element:i,listeners:[d,a]},l}}}},{key:'unhighlight',value:function(e){var t;e in this.highlights&&(t=this.highlights[e],this.pane.removeMark(t.mark),t.listeners.forEach(function(e){e&&t.element.removeEventListener('click',e)}),delete this.highlights[e])}},{key:'ununderline',value:function(e){var t;e in this.underlines&&(t=this.underlines[e],this.pane.removeMark(t.mark),t.listeners.forEach(function(e){e&&t.element.removeEventListener('click',e)}),delete this.underlines[e])}},{key:'unmark',value:function(e){var t;e in this.marks&&(t=this.marks[e],this.element.removeChild(t.element),t.listeners.forEach(function(e){e&&t.element.removeEventListener('click',e)}),delete this.marks[e])}},{key:'destroy',value:function(){for(var e in this.highlights)this.unhighlight(e);for(var t in this.underlines)this.ununderline(t);for(var n in this.marks)this.unmark(n);this.blobUrl&&(0,d.revokeBlobUrl)(this.blobUrl),this.displayed&&(this.displayed=!1,this.removeListeners(),this.stopExpanding=!0,this.element.removeChild(this.iframe),this.iframe=null,this._textWidth=null,this._textHeight=null,this._width=null,this._height=null)}}]),e}();(0,l.default)(m.prototype),t.default=m,e.exports=t['default']},function(e,t,n){var a=n(15),i=n(58),s=n(60),r=Math.min;e.exports=function(e,t,n){function l(t){var n=b,a=k;return b=k=void 0,f=t,E=e.apply(a,n),E}function d(e){return f=e,_=setTimeout(p,t),m?l(e):E}function u(e){var n=e-w,a=e-f,i=t-n;return y?r(i,x-a):i}function c(e){var n=e-w,a=e-f;return void 0==w||n>=t||0>n||y&&a>=x}function p(){var e=i();return c(e)?h(e):void(_=setTimeout(p,u(e)))}function h(e){return(_=void 0,v&&b)?l(e):(b=k=void 0,E)}function g(){var e=i(),n=c(e);if(b=arguments,k=this,w=e,n){if(void 0===_)return d(w);if(y)return _=setTimeout(p,t),l(w)}return void 0===_&&(_=setTimeout(p,t)),E}var f=0,m=!1,y=!1,v=!0,b,k,x,E,_,w;if('function'!=typeof e)throw new TypeError('Expected a function');return t=s(t)||0,a(n)&&(m=!!n.leading,y='maxWait'in n,x=y?o(s(n.maxWait)||0,t):x,v='trailing'in n?!!n.trailing:v),g.cancel=function(){void 0!==_&&clearTimeout(_),f=0,b=w=k=_=void 0},g.flush=function(){return void 0===_?E:h(i())},g}},function(e,t,n){var a=n(59),i='object'==typeof self&&self&&self.Object===Object&&self,o=a||i||Function('return this')();e.exports=o},function(e,t,n){var a=n(22),i=a.Symbol;e.exports=i},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){if(!e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t&&('object'==typeof t||'function'==typeof t)?t:e}function r(e,t){if('function'!=typeof t&&null!==t)throw new TypeError('Super expression must either be null or a function, not '+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,'__esModule',{value:!0});var l=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),d=n(0),u=n(14),c=a(u),p=n(3),h=n(21),g=a(h),f=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.name='continuous',n.settings=(0,d.extend)(n.settings||{},{infinite:!0,overflow:void 0,axis:void 0,flow:'scrolled',offset:500,offsetDelta:250,width:void 0,height:void 0}),(0,d.extend)(n.settings,e.settings||{}),'undefined'!=e.settings.gap&&0===e.settings.gap&&(n.settings.gap=e.settings.gap),n.viewSettings={ignoreClass:n.settings.ignoreClass,axis:n.settings.axis,flow:n.settings.flow,layout:n.layout,width:0,height:0,forceEvenPages:!1},n.scrollTop=0,n.scrollLeft=0,n}return r(t,e),l(t,[{key:'display',value:function(e,t){return c.default.prototype.display.call(this,e,t).then(function(){return this.fill()}.bind(this))}},{key:'fill',value:function(e){var t=this,n=e||new d.defer;return this.q.enqueue(function(){return t.check()}).then(function(e){e?t.fill(n):n.resolve()}),n.promise}},{key:'moveTo',value:function(e){var t=0,n=0,a=0,i=0;this.isPaginated?(t=s(e.left/this.layout.delta)*this.layout.delta,a=t+this.settings.offset):(n=e.top,i=e.top+this.settings.offset),(0<t||0<n)&&this.scrollBy(t,n,!0)}},{key:'afterResized',value:function(e){this.emit(p.EVENTS.MANAGERS.RESIZE,e.section)}},{key:'removeShownListeners',value:function(e){e.onDisplayed=function(){}}},{key:'add',value:function(e){var t=this,n=this.createView(e);return this.views.append(n),n.on(p.EVENTS.VIEWS.RESIZED,function(){n.expanded=!0}),n.on(p.EVENTS.VIEWS.AXIS,function(e){t.updateAxis(e)}),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.display(this.request)}},{key:'append',value:function(e){var t=this.createView(e);return t.on(p.EVENTS.VIEWS.RESIZED,function(){t.expanded=!0}),this.views.append(t),t.onDisplayed=this.afterDisplayed.bind(this),t}},{key:'prepend',value:function(e){var t=this,n=this.createView(e);return n.on(p.EVENTS.VIEWS.RESIZED,function(e){t.counter(e),n.expanded=!0}),this.views.prepend(n),n.onDisplayed=this.afterDisplayed.bind(this),n}},{key:'counter',value:function(e){'vertical'===this.settings.axis?this.scrollBy(0,e.heightDelta,!0):this.scrollBy(e.widthDelta,0,!0)}},{key:'update',value:function(e){for(var t=this.bounds(),n=this.views.all(),a=n.length,o=[],s='undefined'==typeof e?this.settings.offset||0:e,r=new d.defer,l=[],u=0,i,c;u<a;u++)if(c=n[u],i=this.isVisible(c,s,s,t),!0===i){if(!c.displayed){var p=c.display(this.request).then(function(e){e.show()},function(){c.hide()});l.push(p)}else c.show();o.push(c)}else this.q.enqueue(c.destroy.bind(c)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.q.enqueue(this.trim.bind(this))}.bind(this),250);return l.length?Promise.all(l).catch(function(e){r.reject(e)}):(r.resolve(),r.promise)}},{key:'check',value:function(e,t){var n=this,a=new d.defer,i=[],o='horizontal'===this.settings.axis,s=this.settings.offset||0;e&&o&&(s=e),t&&!o&&(s=t);var r=this._bounds,l='rtl'===this.settings.direction,u=o&&l?-1:1,c=o?this.scrollLeft:this.scrollTop*u,p=o?r.width:r.height,h=o?this.container.scrollWidth:this.container.scrollHeight,g=function(){var e=n.views.first(),t=e&&e.section.prev();t&&i.push(n.prepend(t))},f=function(){var e=n.views.last(),t=e&&e.section.next();t&&i.push(n.append(t))};c+p+s>=h&&(o&&l?g():f()),0>c-s&&(o&&l?f():g());var m=i.map(function(e){return e.displayed});return i.length?Promise.all(m).then(function(){if('pre-paginated'===n.layout.name&&n.layout.props.spread)return n.check()}).then(function(){return n.update(s)},function(e){return e}):(this.q.enqueue(function(){this.update()}.bind(this)),a.resolve(!1),a.promise)}},{key:'trim',value:function(){for(var e=new d.defer,t=this.views.displayed(),n=t[0],a=t[t.length-1],o=this.views.indexOf(n),s=this.views.indexOf(a),r=this.views.slice(0,o),l=this.views.slice(s+1),u=0;u<r.length-1;u++)this.erase(r[u],r);for(var i=1;i<l.length;i++)this.erase(l[i]);return e.resolve(),e.promise}},{key:'erase',value:function(e,t){var n,a;this.settings.height?(n=this.container.scrollTop,a=this.container.scrollLeft):(n=window.scrollY,a=window.scrollX);var i=e.bounds();this.views.remove(e),t&&('vertical'===this.settings.axis?this.scrollTo(0,n-i.height,!0):this.scrollTo(a-i.width,0,!0))}},{key:'addEventListeners',value:function(){window.addEventListener('unload',function(){this.ignore=!0,this.destroy()}.bind(this)),this.addScrollListeners()}},{key:'addScrollListeners',value:function(){var e;this.tick=d.requestAnimationFrame,this.settings.height?(this.prevScrollTop=this.container.scrollTop,this.prevScrollLeft=this.container.scrollLeft):(this.prevScrollTop=window.scrollY,this.prevScrollLeft=window.scrollX),this.scrollDeltaVert=0,this.scrollDeltaHorz=0,this.settings.height?(e=this.container,this.scrollTop=this.container.scrollTop,this.scrollLeft=this.container.scrollLeft):(e=window,this.scrollTop=window.scrollY,this.scrollLeft=window.scrollX),e.addEventListener('scroll',this.onScroll.bind(this)),this._scrolled=(0,g.default)(this.scrolled.bind(this),30),this.didScroll=!1}},{key:'removeEventListeners',value:function(){var e;e=this.settings.height?this.container:window,e.removeEventListener('scroll',this.onScroll.bind(this))}},{key:'onScroll',value:function(){var e=Math.abs,t=void 0,n=void 0,a='rtl'===this.settings.direction?-1:1;this.settings.height?(t=this.container.scrollTop,n=this.container.scrollLeft):(t=window.scrollY*a,n=window.scrollX*a),this.scrollTop=t,this.scrollLeft=n,this.ignore?this.ignore=!1:this._scrolled(),this.scrollDeltaVert+=e(t-this.prevScrollTop),this.scrollDeltaHorz+=e(n-this.prevScrollLeft),this.prevScrollTop=t,this.prevScrollLeft=n,clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(function(){this.scrollDeltaVert=0,this.scrollDeltaHorz=0}.bind(this),150),this.didScroll=!1}},{key:'scrolled',value:function(){this.q.enqueue(function(){this.check()}.bind(this)),this.emit(p.EVENTS.MANAGERS.SCROLL,{top:this.scrollTop,left:this.scrollLeft}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.emit(p.EVENTS.MANAGERS.SCROLLED,{top:this.scrollTop,left:this.scrollLeft})}.bind(this))}},{key:'next',value:function(){var e=this.settings.direction,t='pre-paginated'===this.layout.props.name&&this.layout.props.spread?2*this.layout.props.delta:this.layout.props.delta;this.views.length&&(this.isPaginated&&'horizontal'===this.settings.axis?this.scrollBy(t,0,!0):this.scrollBy(0,this.layout.height,!0),this.q.enqueue(function(){this.check()}.bind(this)))}},{key:'prev',value:function(){var e=this.settings.direction,t='pre-paginated'===this.layout.props.name&&this.layout.props.spread?2*this.layout.props.delta:this.layout.props.delta;this.views.length&&(this.isPaginated&&'horizontal'===this.settings.axis?this.scrollBy(-t,0,!0):this.scrollBy(0,-this.layout.height,!0),this.q.enqueue(function(){this.check()}.bind(this)))}},{key:'updateAxis',value:function(e,t){this.isPaginated||(e='vertical'),(t||e!==this.settings.axis)&&(this.settings.axis=e,this.stage&&this.stage.axis(e),this.viewSettings.axis=e,this.mapping&&this.mapping.axis(e),this.layout&&('vertical'===e?this.layout.spread('none'):this.layout.spread(this.layout.settings.spread)),this.settings.infinite='vertical'===e)}}]),t}(c.default);t.default=f,e.exports=t['default']},function(e,t,n){'use strict';(function(a){function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){return new r.default(e,t)}Object.defineProperty(t,'__esModule',{value:!0});var s=n(26),r=i(s),l=n(18),d=i(l),u=n(1),c=i(u),p=n(13),h=i(p),g=n(0),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(g);n(69);var m=n(20),y=i(m),v=n(14),b=i(v),k=n(24),x=i(k);o.VERSION='0.3','undefined'!=typeof a&&(a.EPUBJS_VERSION=o.VERSION),o.Book=r.default,o.Rendition=d.default,o.Contents=h.default,o.CFI=c.default,o.utils=f,t.default=o,e.exports=t['default']}).call(t,n(8))},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},s=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),l=a(r),d=n(0),u=n(5),c=a(u),p=n(4),h=a(p),g=n(42),f=a(g),m=n(44),y=a(m),v=n(45),b=a(v),k=n(46),x=a(k),E=n(47),_=a(E),w=n(48),S=a(w),C=n(49),T=a(C),N=n(18),R=a(N),L=n(67),P=a(L),A=n(11),I=a(A),O=n(1),z=a(O),D=n(3),B='META-INF/container.xml',q={BINARY:'binary',BASE64:'base64',EPUB:'epub',OPF:'opf',MANIFEST:'json',DIRECTORY:'directory'},M=function(){function e(t,n){var a=this;i(this,e),'undefined'==typeof n&&'object'===('undefined'==typeof t?'undefined':o(t))&&(n=t,t=void 0),this.settings=(0,d.extend)(this.settings||{},{requestMethod:void 0,requestCredentials:void 0,requestHeaders:void 0,encoding:void 0,replacements:void 0,canonical:void 0}),(0,d.extend)(this.settings,n),this.opening=new d.defer,this.opened=this.opening.promise,this.isOpen=!1,this.loading={manifest:new d.defer,spine:new d.defer,metadata:new d.defer,cover:new d.defer,navigation:new d.defer,pageList:new d.defer,resources:new d.defer},this.loaded={manifest:this.loading.manifest.promise,spine:this.loading.spine.promise,metadata:this.loading.metadata.promise,cover:this.loading.cover.promise,navigation:this.loading.navigation.promise,pageList:this.loading.pageList.promise,resources:this.loading.resources.promise},this.ready=Promise.all([this.loaded.manifest,this.loaded.spine,this.loaded.metadata,this.loaded.cover,this.loaded.navigation,this.loaded.resources]),this.isRendered=!1,this.request=this.settings.requestMethod||I.default,this.spine=new f.default,this.locations=new y.default(this.spine,this.load.bind(this)),this.navigation=void 0,this.pageList=void 0,this.url=void 0,this.path=void 0,this.archived=!1,this.archive=void 0,this.resources=void 0,this.rendition=void 0,this.container=void 0,this.packaging=void 0,t&&this.open(t).catch(function(){var e=new Error('Cannot load book at '+t);a.emit(D.EVENTS.BOOK.OPEN_FAILED,e)})}return s(e,[{key:'open',value:function(e,t){var n=t||this.determineType(e),a;return n===q.BINARY?(this.archived=!0,this.url=new c.default('/',''),a=this.openEpub(e)):n===q.BASE64?(this.archived=!0,this.url=new c.default('/',''),a=this.openEpub(e,n)):n===q.EPUB?(this.archived=!0,this.url=new c.default('/',''),a=this.request(e,'binary').then(this.openEpub.bind(this))):n==q.OPF?(this.url=new c.default(e),a=this.openPackaging(this.url.Path.toString())):n==q.MANIFEST?(this.url=new c.default(e),a=this.openManifest(this.url.Path.toString())):(this.url=new c.default(e),a=this.openContainer(B).then(this.openPackaging.bind(this))),a}},{key:'openEpub',value:function(e,t){var n=this;return this.unarchive(e,t||this.settings.encoding).then(function(){return n.openContainer(B)}).then(function(e){return n.openPackaging(e)})}},{key:'openContainer',value:function(e){var t=this;return this.load(e).then(function(e){return t.container=new b.default(e),t.resolve(t.container.packagePath)})}},{key:'openPackaging',value:function(e){var t=this;return this.path=new h.default(e),this.load(e).then(function(e){return t.packaging=new x.default(e),t.unpack(t.packaging)})}},{key:'openManifest',value:function(e){var t=this;return this.path=new h.default(e),this.load(e).then(function(e){return t.packaging=new x.default,t.packaging.load(e),t.unpack(t.packaging)})}},{key:'load',value:function(e){var t;return this.archived?(t=this.resolve(e),this.archive.request(t)):(t=this.resolve(e),this.request(t,null,this.settings.requestCredentials,this.settings.requestHeaders))}},{key:'resolve',value:function(e,t){if(e){var n=e,a=-1<e.indexOf('://');return a?e:(this.path&&(n=this.path.resolve(e)),!1!=t&&this.url&&(n=this.url.resolve(n)),n)}}},{key:'canonical',value:function(e){var t=e;return e?(t=this.settings.canonical?this.settings.canonical(e):this.resolve(e,!0),t):''}},{key:'determineType',value:function(e){var t,n,a;return'base64'===this.settings.encoding?q.BASE64:'string'==typeof e?(t=new c.default(e),n=t.path(),a=n.extension,a?'epub'===a?q.EPUB:'opf'===a?q.OPF:'json'===a?q.MANIFEST:void 0:q.DIRECTORY):q.BINARY}},{key:'unpack',value:function(e){var t=this;this.package=e,this.spine.unpack(this.package,this.resolve.bind(this),this.canonical.bind(this)),this.resources=new S.default(this.package.manifest,{archive:this.archive,resolver:this.resolve.bind(this),request:this.request.bind(this),replacements:this.settings.replacements||(this.archived?'blobUrl':'base64')}),this.loadNavigation(this.package).then(function(){t.loading.navigation.resolve(t.navigation)}),this.package.coverPath&&(this.cover=this.resolve(this.package.coverPath)),this.loading.manifest.resolve(this.package.manifest),this.loading.metadata.resolve(this.package.metadata),this.loading.spine.resolve(this.spine),this.loading.cover.resolve(this.cover),this.loading.resources.resolve(this.resources),this.loading.pageList.resolve(this.pageList),this.isOpen=!0,this.archived||this.settings.replacements&&'none'!=this.settings.replacements?this.replacements().then(function(){t.opening.resolve(t)}).catch(function(e){console.error(e)}):this.opening.resolve(this)}},{key:'loadNavigation',value:function(e){var t=this,n=e.navPath||e.ncxPath,a=e.toc;return a?new Promise(function(n){t.navigation=new _.default(a),e.pageList&&(t.pageList=new T.default(e.pageList)),n(t.navigation)}):n?this.load(n,'xml').then(function(e){return t.navigation=new _.default(e),t.pageList=new T.default(e),t.navigation}):new Promise(function(e){t.navigation=new _.default,t.pageList=new T.default,e(t.navigation)})}},{key:'section',value:function(e){return this.spine.get(e)}},{key:'renderTo',value:function(e,t){return this.rendition=new R.default(this,t),this.rendition.attachTo(e),this.rendition}},{key:'setRequestCredentials',value:function(e){this.settings.requestCredentials=e}},{key:'setRequestHeaders',value:function(e){this.settings.requestHeaders=e}},{key:'unarchive',value:function(e,t){return this.archive=new P.default,this.archive.open(e,t)}},{key:'coverUrl',value:function(){var e=this,t=this.loaded.cover.then(function(){return e.archived?e.resources.get(e.cover):e.cover});return t}},{key:'replacements',value:function(){var e=this;return this.spine.hooks.serialize.register(function(t,n){n.output=e.resources.substitute(t,n.url)}),this.resources.replacements().then(function(){return e.resources.replaceCss()})}},{key:'getRange',value:function(e){var t=new z.default(e),n=this.spine.get(t.spinePos),a=this.load.bind(this);return n?n.load(a).then(function(){var e=t.toRange(n.document);return e}):new Promise(function(e,t){t('CFI could not be found')})}},{key:'key',value:function(e){var t=e||this.package.metadata.identifier||this.url.filename;return'epubjs:'+'0.3'+':'+t}},{key:'destroy',value:function(){this.opened=void 0,this.loading=void 0,this.loaded=void 0,this.ready=void 0,this.isOpen=!1,this.isRendered=!1,this.spine&&this.spine.destroy(),this.locations&&this.locations.destroy(),this.pageList&&this.pageList.destroy(),this.archive&&this.archive.destroy(),this.resources&&this.resources.destroy(),this.container&&this.container.destroy(),this.packaging&&this.packaging.destroy(),this.rendition&&this.rendition.destroy(),this.spine=void 0,this.locations=void 0,this.pageList=void 0,this.archive=void 0,this.resources=void 0,this.container=void 0,this.packaging=void 0,this.rendition=void 0,this.navigation=void 0,this.url=void 0,this.path=void 0,this.archived=!1}}]),e}();(0,l.default)(M.prototype),t.default=M,e.exports=t['default']},function(e,t,n){'use strict';var a=n(28),i=n(36),o=n(37),s=n(38),r;r=e.exports=function(t,n){var o,r,l,d,u;return 2>arguments.length||'string'!=typeof t?(d=n,n=t,t=null):d=arguments[2],null==t?(o=l=!0,r=!1):(o=s.call(t,'c'),r=s.call(t,'e'),l=s.call(t,'w')),u={value:n,configurable:o,enumerable:r,writable:l},d?a(i(d),u):u},r.gs=function(t,n,r){var l,d,u,p;return'string'==typeof t?u=arguments[3]:(u=r,r=n,n=t,t=null),null==n?n=void 0:o(n)?null==r?r=void 0:!o(r)&&(u=r,r=void 0):(u=n,n=r=void 0),null==t?(l=!0,d=!1):(l=s.call(t,'c'),d=s.call(t,'e')),p={get:n,set:r,configurable:l,enumerable:d},u?a(i(u),p):p}},function(e,t,n){'use strict';e.exports=n(29)()?Object.assign:n(30)},function(e){'use strict';e.exports=function(){var e=Object.assign,t;return!('function'!=typeof e)&&(t={foo:'raz'},e(t,{bar:'dwa'},{trzy:'trzy'}),'razdwatrzy'===t.foo+t.bar+t.trzy)}},function(e,t,n){'use strict';var a=n(31),s=n(35);e.exports=function(e,t){var n=o(arguments.length,2),r,l,i;for(e=Object(s(e)),i=function(n){try{e[n]=t[n]}catch(t){r||(r=t)}},l=1;l<n;++l)t=arguments[l],a(t).forEach(i);if(r!==void 0)throw r;return e}},function(e,t,n){'use strict';e.exports=n(32)()?Object.keys:n(33)},function(e){'use strict';e.exports=function(){try{return Object.keys('primitive'),!0}catch(t){return!1}}},function(e,t,n){'use strict';var a=n(9),i=Object.keys;e.exports=function(e){return i(a(e)?Object(e):e)}},function(e){'use strict';e.exports=function(){}},function(e,t,n){'use strict';var a=n(9);e.exports=function(e){if(!a(e))throw new TypeError('Cannot use null or undefined');return e}},function(e,t,n){'use strict';var a=n(9),i=Array.prototype.forEach,o=Object.create,s=function(e,t){for(var n in e)t[n]=e[n]};e.exports=function(){var e=o(null);return i.call(arguments,function(t){a(t)&&s(Object(t),e)}),e}},function(e){'use strict';e.exports=function(e){return'function'==typeof e}},function(e,t,a){'use strict';e.exports=a(39)()?n.contains:a(40)},function(e){'use strict';var t='razdwatrzy';e.exports=function(){return!('function'!=typeof t.contains)&&!0===t.contains('dwa')&&!1===t.contains('foo')}},function(e){'use strict';var t=n.indexOf;e.exports=function(e){return-1<t.call(this,e,arguments[1])}},function(e){'use strict';e.exports=function(e){if('function'!=typeof e)throw new TypeError(e+' is not a function');return e}},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(1),r=a(s),l=n(10),d=a(l),u=n(43),c=a(u),p=n(7),h=function(){function e(){i(this,e),this.spineItems=[],this.spineByHref={},this.spineById={},this.hooks={},this.hooks.serialize=new d.default,this.hooks.content=new d.default,this.hooks.content.register(p.replaceBase),this.hooks.content.register(p.replaceCanonical),this.hooks.content.register(p.replaceMeta),this.epubcfi=new r.default,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}return o(e,[{key:'unpack',value:function(e,t,n){var a=this;this.items=e.spine,this.manifest=e.manifest,this.spineNodeIndex=e.spineNodeIndex,this.baseUrl=e.baseUrl||e.basePath||'',this.length=this.items.length,this.items.forEach(function(e,i){var o=a.manifest[e.idref],s;e.index=i,e.cfiBase=a.epubcfi.generateChapterComponent(a.spineNodeIndex,e.index,e.idref),e.href&&(e.url=t(e.href,!0),e.canonical=n(e.href)),o&&(e.href=o.href,e.url=t(e.href,!0),e.canonical=n(e.href),o.properties.length&&e.properties.push.apply(e.properties,o.properties)),'yes'===e.linear?(e.prev=function(){for(var t=e.index,n;0<t;){if(n=this.get(t-1),n&&n.linear)return n;t-=1}}.bind(a),e.next=function(){for(var t=e.index,n;t<this.spineItems.length-1;){if(n=this.get(t+1),n&&n.linear)return n;t+=1}}.bind(a)):(e.prev=function(){},e.next=function(){}),s=new c.default(e,a.hooks),a.append(s)}),this.loaded=!0}},{key:'get',value:function(e){var t=0;if('undefined'==typeof e)for(;t<this.spineItems.length;){var n=this.spineItems[t];if(n&&n.linear)break;t+=1}else if(this.epubcfi.isCfiString(e)){var a=new r.default(e);t=a.spinePos}else'number'==typeof e||!1===isNaN(e)?t=e:'string'==typeof e&&0===e.indexOf('#')?t=this.spineById[e.substring(1)]:'string'==typeof e&&(e=e.split('#')[0],t=this.spineByHref[e]||this.spineByHref[encodeURI(e)]);return this.spineItems[t]||null}},{key:'append',value:function(e){var t=this.spineItems.length;return e.index=t,this.spineItems.push(e),this.spineByHref[decodeURI(e.href)]=t,this.spineByHref[encodeURI(e.href)]=t,this.spineByHref[e.href]=t,this.spineById[e.idref]=t,t}},{key:'prepend',value:function(e){return this.spineByHref[e.href]=0,this.spineById[e.idref]=0,this.spineItems.forEach(function(e,t){e.index=t}),0}},{key:'remove',value:function(e){var t=this.spineItems.indexOf(e);if(-1<t)return delete this.spineByHref[e.href],delete this.spineById[e.idref],this.spineItems.splice(t,1)}},{key:'each',value:function(){return this.spineItems.forEach.apply(this.spineItems,arguments)}},{key:'first',value:function(){var e=0;do{var t=this.get(e);if(t&&t.linear)return t;e+=1}while(e<this.spineItems.length)}},{key:'last',value:function(){var e=this.spineItems.length-1;do{var t=this.get(e);if(t&&t.linear)return t;e-=1}while(0<=e)}},{key:'destroy',value:function(){this.each(function(e){return e.destroy()}),this.spineItems=void 0,this.spineByHref=void 0,this.spineById=void 0,this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.epubcfi=void 0,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}}]),e}();t.default=h,e.exports=t['default']},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(0),r=n(1),l=a(r),d=n(10),u=a(d),c=n(7),p=function(){function e(t,n){i(this,e),this.idref=t.idref,this.linear='yes'===t.linear,this.properties=t.properties,this.index=t.index,this.href=t.href,this.url=t.url,this.canonical=t.canonical,this.next=t.next,this.prev=t.prev,this.cfiBase=t.cfiBase,n?this.hooks=n:(this.hooks={},this.hooks.serialize=new u.default(this),this.hooks.content=new u.default(this)),this.document=void 0,this.contents=void 0,this.output=void 0}return o(e,[{key:'load',value:function(e){var t=e||this.request||n(11),a=new s.defer,i=a.promise;return this.contents?a.resolve(this.contents):t(this.url).then(function(e){return this.document=e,this.contents=e.documentElement,this.hooks.content.trigger(this.document,this)}.bind(this)).then(function(){a.resolve(this.contents)}.bind(this)).catch(function(e){a.reject(e)}),i}},{key:'base',value:function(){return(0,c.replaceBase)(this.document,this)}},{key:'render',value:function(e){var t=new s.defer,a=t.promise;return this.output,this.load(e).then(function(e){var t='undefined'!=typeof navigator&&navigator.userAgent||'',a=0<=t.indexOf('Trident'),i;i='undefined'==typeof XMLSerializer||a?n(16).XMLSerializer:XMLSerializer;var o=new i;return this.output=o.serializeToString(e),this.output}.bind(this)).then(function(){return this.hooks.serialize.trigger(this.output,this)}.bind(this)).then(function(){t.resolve(this.output)}.bind(this)).catch(function(e){t.reject(e)}),a}},{key:'find',value:function(e){var t=this,n=[],a=e.toLowerCase(),i=function(e){for(var i=e.textContent.toLowerCase(),o=t.document.createRange(),s=-1,r=150,l,d,u;-1!=d;)d=i.indexOf(a,s+1),-1!=d&&(o=t.document.createRange(),o.setStart(e,d),o.setEnd(e,d+a.length),l=t.cfiFromRange(o),e.textContent.length<r?u=e.textContent:(u=e.textContent.substring(d-r/2,d+r/2),u='...'+u+'...'),n.push({cfi:l,excerpt:u})),s=d};return(0,s.sprint)(t.document,function(e){i(e)}),n}},{key:'reconcileLayoutSettings',value:function(e){var t={layout:e.layout,spread:e.spread,orientation:e.orientation};return this.properties.forEach(function(e){var n=e.replace('rendition:',''),a=n.indexOf('-'),i,o;-1!=a&&(i=n.slice(0,a),o=n.slice(a+1),t[i]=o)}),t}},{key:'cfiFromRange',value:function(e){return new l.default(e,this.cfiBase).toString()}},{key:'cfiFromElement',value:function(e){return new l.default(e,this.cfiBase).toString()}},{key:'unload',value:function(){this.document=void 0,this.contents=void 0,this.output=void 0}},{key:'destroy',value:function(){this.unload(),this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.idref=void 0,this.linear=void 0,this.properties=void 0,this.index=void 0,this.href=void 0,this.url=void 0,this.next=void 0,this.prev=void 0,this.cfiBase=void 0}}]),e}();t.default=p,e.exports=t['default']},function(e,t,n){'use strict';function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var s=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(0),l=n(12),d=i(l),u=n(1),c=i(u),p=n(3),h=n(2),g=i(h),f=function(){function e(t,n,a){o(this,e),this.spine=t,this.request=n,this.pause=a||100,this.q=new d.default(this),this.epubcfi=new c.default,this._locations=[],this.total=0,this.break=150,this._current=0,this.currentLocation='',this._currentCfi='',this.processingTimeout=void 0}return s(e,[{key:'generate',value:function(e){return e&&(this.break=e),this.q.pause(),this.spine.each(function(e){e.linear&&this.q.enqueue(this.process.bind(this),e)}.bind(this)),this.q.run().then(function(){return this.total=this._locations.length-1,this._currentCfi&&(this.currentLocation=this._currentCfi),this._locations}.bind(this))}},{key:'createRange',value:function(){return{startContainer:void 0,startOffset:void 0,endContainer:void 0,endOffset:void 0}}},{key:'process',value:function(e){return e.load(this.request).then(function(t){var n=new r.defer,a=this.parse(t,e.cfiBase);return this._locations=this._locations.concat(a),e.unload(),this.processingTimeout=setTimeout(function(){return n.resolve(a)},this.pause),n.promise}.bind(this))}},{key:'parse',value:function(e,t,n){var a=[],i=e.ownerDocument,o=(0,r.qs)(i,'body'),s=0,l=n||this.break,d,u;if((0,r.sprint)(o,function(e){var n=e.length,i=0,o;if(0===e.textContent.trim().length)return!1;for(0==s&&(d=this.createRange(),d.startContainer=e,d.startOffset=0),o=l-s,o>n&&(s+=n,i=n);i<n;)if(o=l-s,0===s&&(i+=1,d=this.createRange(),d.startContainer=e,d.startOffset=i),i+o>=n)s+=n-i,i=n;else{i+=o,d.endContainer=e,d.endOffset=i;var r=new c.default(d,t).toString();a.push(r),s=0}u=e}.bind(this)),d&&d.startContainer&&u){d.endContainer=u,d.endOffset=u.length;var p=new c.default(d,t).toString();a.push(p),s=0}return a}},{key:'locationFromCfi',value:function(e){var t;return(c.default.prototype.isCfiString(e)&&(e=new c.default(e)),0===this._locations.length)?-1:(t=(0,r.locationOf)(e,this._locations,this.epubcfi.compare),t>this.total?this.total:t)}},{key:'percentageFromCfi',value:function(e){if(0===this._locations.length)return null;var t=this.locationFromCfi(e);return this.percentageFromLocation(t)}},{key:'percentageFromLocation',value:function(e){return e&&this.total?e/this.total:0}},{key:'cfiFromLocation',value:function(e){var t=-1;return'number'!=typeof e&&(e=parseInt(e)),0<=e&&e<this._locations.length&&(t=this._locations[e]),t}},{key:'cfiFromPercentage',value:function(e){var t;if(1<e&&console.warn('Normalize cfiFromPercentage value to between 0 - 1'),1<=e){var n=new c.default(this._locations[this.total]);return n.collapse(),n.toString()}return t=a(this.total*e),this.cfiFromLocation(t)}},{key:'load',value:function(e){return this._locations='string'==typeof e?JSON.parse(e):e,this.total=this._locations.length-1,this._locations}},{key:'save',value:function(){return JSON.stringify(this._locations)}},{key:'getCurrent',value:function(){return this._current}},{key:'setCurrent',value:function(e){var t;if('string'==typeof e)this._currentCfi=e;else if('number'==typeof e)this._current=e;else return;0===this._locations.length||('string'==typeof e?(t=this.locationFromCfi(e),this._current=t):t=e,this.emit(p.EVENTS.LOCATIONS.CHANGED,{percentage:this.percentageFromLocation(t)}))}},{key:'length',value:function(){return this._locations.length}},{key:'destroy',value:function(){this.spine=void 0,this.request=void 0,this.pause=void 0,this.q.stop(),this.q=void 0,this.epubcfi=void 0,this._locations=void 0,this.total=void 0,this.break=void 0,this._current=void 0,this.currentLocation=void 0,this._currentCfi=void 0,clearTimeout(this.processingTimeout)}},{key:'currentLocation',get:function(){return this._current},set:function(e){this.setCurrent(e)}}]),e}();(0,g.default)(f.prototype),t.default=f,e.exports=t['default']},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(6),s=function(e){return e&&e.__esModule?e:{default:e}}(o),r=n(0),l=function(){function e(t){a(this,e),this.packagePath='',this.directory='',this.encoding='',t&&this.parse(t)}return i(e,[{key:'parse',value:function(e){var t;if(!e)throw new Error('Container File Not Found');if(t=(0,r.qs)(e,'rootfile'),!t)throw new Error('No RootFile Found');this.packagePath=t.getAttribute('full-path'),this.directory=s.default.dirname(this.packagePath),this.encoding=e.xmlEncoding}},{key:'destroy',value:function(){this.packagePath=void 0,this.directory=void 0,this.encoding=void 0}}]),e}();t.default=l,e.exports=t['default']},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(0),s=function(){function e(t){a(this,e),this.manifest={},this.navPath='',this.ncxPath='',this.coverPath='',this.spineNodeIndex=0,this.spine=[],this.metadata={},t&&this.parse(t)}return i(e,[{key:'parse',value:function(e){var t,n,a;if(!e)throw new Error('Package File Not Found');if(t=(0,o.qs)(e,'metadata'),!t)throw new Error('No Metadata Found');if(n=(0,o.qs)(e,'manifest'),!n)throw new Error('No Manifest Found');if(a=(0,o.qs)(e,'spine'),!a)throw new Error('No Spine Found');return this.manifest=this.parseManifest(n),this.navPath=this.findNavPath(n),this.ncxPath=this.findNcxPath(n,a),this.coverPath=this.findCoverPath(e),this.spineNodeIndex=(0,o.indexOfElementNode)(a),this.spine=this.parseSpine(a,this.manifest),this.metadata=this.parseMetadata(t),this.metadata.direction=a.getAttribute('page-progression-direction'),{metadata:this.metadata,spine:this.spine,manifest:this.manifest,navPath:this.navPath,ncxPath:this.ncxPath,coverPath:this.coverPath,spineNodeIndex:this.spineNodeIndex}}},{key:'parseMetadata',value:function(e){var t={title:this.getElementText(e,'title'),creator:this.getElementText(e,'creator'),description:this.getElementText(e,'description'),pubdate:this.getElementText(e,'date'),publisher:this.getElementText(e,'publisher'),identifier:this.getElementText(e,'identifier'),language:this.getElementText(e,'language'),rights:this.getElementText(e,'rights'),modified_date:this.getPropertyText(e,'dcterms:modified'),layout:this.getPropertyText(e,'rendition:layout'),orientation:this.getPropertyText(e,'rendition:orientation'),flow:this.getPropertyText(e,'rendition:flow'),viewport:this.getPropertyText(e,'rendition:viewport')};return t}},{key:'parseManifest',value:function(e){var t={},n=(0,o.qsa)(e,'item'),a=Array.prototype.slice.call(n);return a.forEach(function(e){var n=e.getAttribute('id'),a=e.getAttribute('href')||'',i=e.getAttribute('media-type')||'',o=e.getAttribute('properties')||'';t[n]={href:a,type:i,properties:o.length?o.split(' '):[]}}),t}},{key:'parseSpine',value:function(e){var t=[],n=(0,o.qsa)(e,'itemref'),a=Array.prototype.slice.call(n);return a.forEach(function(e,n){var a=e.getAttribute('idref'),i=e.getAttribute('properties')||'',o=i.length?i.split(' '):[],s={idref:a,linear:e.getAttribute('linear')||'yes',properties:o,index:n};t.push(s)}),t}},{key:'findNavPath',value:function(e){var t=(0,o.qsp)(e,'item',{properties:'nav'});return!!t&&t.getAttribute('href')}},{key:'findNcxPath',value:function(e,t){var n=(0,o.qsp)(e,'item',{"media-type":'application/x-dtbncx+xml'}),a;return n||(a=t.getAttribute('toc'),a&&(n=e.getElementById(a))),!!n&&n.getAttribute('href')}},{key:'findCoverPath',value:function(e){var t=(0,o.qs)(e,'package'),n=t.getAttribute('version');if('2.0'===n){var a=(0,o.qsp)(e,'meta',{name:'cover'});if(a){var i=a.getAttribute('content'),s=e.getElementById(i);return s?s.getAttribute('href'):''}return!1}var r=(0,o.qsp)(e,'item',{properties:'cover-image'});return r?r.getAttribute('href'):''}},{key:'getElementText',value:function(e,t){var n=e.getElementsByTagNameNS('http://purl.org/dc/elements/1.1/',t),a;return n&&0!==n.length?(a=n[0],a.childNodes.length?a.childNodes[0].nodeValue:''):''}},{key:'getPropertyText',value:function(e,t){var n=(0,o.qsp)(e,'meta',{property:t});return n&&n.childNodes.length?n.childNodes[0].nodeValue:''}},{key:'load',value:function(e){var t=this;return this.metadata=e.metadata,this.spine=e.spine.map(function(e,t){return e.index=t,e}),e.resources.forEach(function(e,n){t.manifest[n]=e,e.rel&&'cover'===e.rel[0]&&(t.coverPath=e.href)}),this.spineNodeIndex=0,this.toc=e.toc.map(function(e){return e.label=e.title,e}),{metadata:this.metadata,spine:this.spine,manifest:this.manifest,navPath:this.navPath,ncxPath:this.ncxPath,coverPath:this.coverPath,spineNodeIndex:this.spineNodeIndex,toc:this.toc}}},{key:'destroy',value:function(){this.manifest=void 0,this.navPath=void 0,this.ncxPath=void 0,this.coverPath=void 0,this.spineNodeIndex=void 0,this.spine=void 0,this.metadata=void 0}}]),e}();t.default=s,e.exports=t['default']},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(0),s=function(){function e(t){a(this,e),this.toc=[],this.tocByHref={},this.tocById={},this.landmarks=[],this.landmarksByType={},this.length=0,t&&this.parse(t)}return i(e,[{key:'parse',value:function(e){var t=e.nodeType,n,a;t&&(n=(0,o.qs)(e,'html'),a=(0,o.qs)(e,'ncx')),t?n?(this.toc=this.parseNav(e),this.landmarks=this.parseLandmarks(e)):a&&(this.toc=this.parseNcx(e)):this.toc=this.load(e),this.length=0,this.unpack(this.toc)}},{key:'unpack',value:function(e){for(var t=0,n;t<e.length;t++)n=e[t],n.href&&(this.tocByHref[n.href]=t),n.id&&(this.tocById[n.id]=t),this.length++,n.subitems.length&&this.unpack(n.subitems)}},{key:'get',value:function(e){var t;return e?(0===e.indexOf('#')?t=this.tocById[e.substring(1)]:e in this.tocByHref&&(t=this.tocByHref[e]),this.toc[t]):this.toc}},{key:'landmark',value:function(e){var t;return e?(t=this.landmarksByType[e],this.landmarks[t]):this.landmarks}},{key:'parseNav',value:function(e){var t=(0,o.querySelectorByType)(e,'nav','toc'),n=t?(0,o.qsa)(t,'li'):[],a=n.length,s={},r=[],l,i,d;if(!n||0===a)return r;for(l=0;l<a;++l)i=this.navItem(n[l]),i&&(s[i.id]=i,i.parent?(d=s[i.parent],d.subitems.push(i)):r.push(i));return r}},{key:'navItem',value:function(e){var t=e.getAttribute('id')||void 0,n=(0,o.filterChildren)(e,'a',!0);if(n){var a=n.getAttribute('href')||'',i=n.textContent||'',s=(0,o.getParentByTagName)(e,'li'),r;for(s&&(r=s.getAttribute('id'));!r&&s;)s=(0,o.getParentByTagName)(s,'li'),s&&(r=s.getAttribute('id'));return{id:t,href:a,label:i,subitems:[],parent:r}}}},{key:'parseLandmarks',value:function(e){var t=(0,o.querySelectorByType)(e,'nav','landmarks'),n=t?(0,o.qsa)(t,'li'):[],a=n.length,s=[],r,i;if(!n||0===a)return s;for(r=0;r<a;++r)i=this.landmarkItem(n[r]),i&&(s.push(i),this.landmarksByType[i.type]=r);return s}},{key:'landmarkItem',value:function(e){var t=(0,o.filterChildren)(e,'a',!0);if(t){var n=t.getAttributeNS('http://www.idpf.org/2007/ops','type')||void 0,a=t.getAttribute('href')||'',i=t.textContent||'';return{href:a,label:i,type:n}}}},{key:'parseNcx',value:function(e){var t=(0,o.qsa)(e,'navPoint'),n=t.length,a={},s=[],r,i,l;if(!t||0===n)return s;for(r=0;r<n;++r)i=this.ncxItem(t[r]),a[i.id]=i,i.parent?(l=a[i.parent],l.subitems.push(i)):s.push(i);return s}},{key:'ncxItem',value:function(e){var t=e.getAttribute('id')||!1,n=(0,o.qs)(e,'content'),a=n.getAttribute('src'),i=(0,o.qs)(e,'navLabel'),s=i.textContent?i.textContent:'',r=e.parentNode,l;return r&&'navPoint'===r.nodeName&&(l=r.getAttribute('id')),{id:t,href:a,label:s,subitems:[],parent:l}}},{key:'load',value:function(e){var t=this;return e.map(function(e){return e.label=e.title,e.children&&(e.subitems=t.load(e.children)),e})}},{key:'forEach',value:function(e){return this.toc.forEach(e)}}]),e}();t.default=s,e.exports=t['default']},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(7),r=n(0),l=n(5),d=a(l),u=n(17),c=a(u),p=n(4),h=a(p),g=n(6),f=a(g),m=function(){function e(t,n){i(this,e),this.settings={replacements:n&&n.replacements||'base64',archive:n&&n.archive,resolver:n&&n.resolver,request:n&&n.request},this.manifest=t,this.resources=Object.keys(t).map(function(e){return t[e]}),this.replacementUrls=[],this.html=[],this.assets=[],this.css=[],this.urls=[],this.cssUrls=[],this.split(),this.splitUrls()}return o(e,[{key:'split',value:function(){this.html=this.resources.filter(function(e){if('application/xhtml+xml'===e.type||'text/html'===e.type)return!0}),this.assets=this.resources.filter(function(e){if('application/xhtml+xml'!==e.type&&'text/html'!==e.type)return!0}),this.css=this.resources.filter(function(e){if('text/css'===e.type)return!0})}},{key:'splitUrls',value:function(){this.urls=this.assets.map(function(e){return e.href}.bind(this)),this.cssUrls=this.css.map(function(e){return e.href})}},{key:'createUrl',value:function(e){var t=new d.default(e),n=c.default.lookup(t.filename);return this.settings.archive?this.settings.archive.createUrl(e,{base64:'base64'===this.settings.replacements}):'base64'===this.settings.replacements?this.settings.request(e,'blob').then(function(e){return(0,r.blob2base64)(e)}).then(function(e){return(0,r.createBase64Url)(e,n)}):this.settings.request(e,'blob').then(function(e){return(0,r.createBlobUrl)(e,n)})}},{key:'replacements',value:function(){var e=this;if('none'===this.settings.replacements)return new Promise(function(e){e(this.urls)}.bind(this));var t=this.urls.map(function(t){var n=e.settings.resolver(t);return e.createUrl(n).catch(function(e){return console.error(e),null})});return Promise.all(t).then(function(t){return e.replacementUrls=t.filter(function(e){return'string'==typeof e}),t})}},{key:'replaceCss',value:function(e,t){var n=[];return e=e||this.settings.archive,t=t||this.settings.resolver,this.cssUrls.forEach(function(a){var i=this.createCssFile(a,e,t).then(function(e){var t=this.urls.indexOf(a);-1<t&&(this.replacementUrls[t]=e)}.bind(this));n.push(i)}.bind(this)),Promise.all(n)}},{key:'createCssFile',value:function(e){var t=this,n;if(f.default.isAbsolute(e))return new Promise(function(e){e()});var a=this.settings.resolver(e),i;i=this.settings.archive?this.settings.archive.getText(a):this.settings.request(a,'text');var o=this.urls.map(function(e){var n=t.settings.resolver(e),i=new h.default(a).relative(n);return i});return i?i.then(function(e){return e=(0,s.substitute)(e,o,t.replacementUrls),n='base64'===t.settings.replacements?(0,r.createBase64Url)(e,'text/css'):(0,r.createBlobUrl)(e,'text/css'),n},function(){return new Promise(function(e){e()})}):new Promise(function(e){e()})}},{key:'relativeTo',value:function(e,t){return t=t||this.settings.resolver,this.urls.map(function(n){var a=t(n),i=new h.default(e).relative(a);return i}.bind(this))}},{key:'get',value:function(e){var t=this.urls.indexOf(e);return-1===t?void 0:this.replacementUrls.length?new Promise(function(e){e(this.replacementUrls[t])}.bind(this)):this.createUrl(e)}},{key:'substitute',value:function(e,t){var n;return n=t?this.relativeTo(t):this.urls,(0,s.substitute)(e,n,this.replacementUrls)}},{key:'destroy',value:function(){this.settings=void 0,this.manifest=void 0,this.resources=void 0,this.replacementUrls=void 0,this.html=void 0,this.assets=void 0,this.css=void 0,this.urls=void 0,this.cssUrls=void 0}}]),e}();t.default=m,e.exports=t['default']},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(1),r=function(e){return e&&e.__esModule?e:{default:e}}(s),l=n(0),d=function(){function e(t){a(this,e),this.pages=[],this.locations=[],this.epubcfi=new r.default,this.firstPage=0,this.lastPage=0,this.totalPages=0,this.toc=void 0,this.ncx=void 0,t&&(this.pageList=this.parse(t)),this.pageList&&this.pageList.length&&this.process(this.pageList)}return o(e,[{key:'parse',value:function(e){var t=(0,l.qs)(e,'html'),n=(0,l.qs)(e,'ncx');return t?this.parseNav(e):void n}},{key:'parseNav',value:function(e){var t=(0,l.querySelectorByType)(e,'nav','page-list'),n=t?(0,l.qsa)(t,'li'):[],a=n.length,o=[],s,i;if(!n||0===a)return o;for(s=0;s<a;++s)i=this.item(n[s]),o.push(i);return o}},{key:'item',value:function(e){var t=(0,l.qs)(e,'a'),n=t.getAttribute('href')||'',a=t.textContent||'',i=parseInt(a),o=n.indexOf('epubcfi'),s,r,d;return-1==o?{href:n,page:i}:(s=n.split('#'),r=s[0],d=!!(1<s.length)&&s[1],{cfi:d,href:n,packageUrl:r,page:i})}},{key:'process',value:function(e){e.forEach(function(e){this.pages.push(e.page),e.cfi&&this.locations.push(e.cfi)},this),this.firstPage=parseInt(this.pages[0]),this.lastPage=parseInt(this.pages[this.pages.length-1]),this.totalPages=this.lastPage-this.firstPage}},{key:'pageFromCfi',value:function(e){var t=-1;if(0===this.locations.length)return-1;var n=(0,l.indexOfSorted)(e,this.locations,this.epubcfi.compare);return-1==n?(n=(0,l.locationOf)(e,this.locations,this.epubcfi.compare),t=0<=n-1?this.pages[n-1]:this.pages[0],void 0!==t||(t=-1)):t=this.pages[n],t}},{key:'cfiFromPage',value:function(e){var t=-1;'number'!=typeof e&&(e=parseInt(e));var n=this.pages.indexOf(e);return-1!=n&&(t=this.locations[n]),t}},{key:'pageFromPercentage',value:function(e){var t=i(this.totalPages*e);return t}},{key:'percentageFromPage',value:function(e){var t=(e-this.firstPage)/this.totalPages;return i(1e3*t)/1e3}},{key:'percentageFromCfi',value:function(e){var t=this.pageFromCfi(e),n=this.percentageFromPage(t);return n}},{key:'destroy',value:function(){this.pages=void 0,this.locations=void 0,this.epubcfi=void 0,this.pageList=void 0,this.toc=void 0,this.ncx=void 0}}]),e}();t.default=d,e.exports=t['default']},function(e,t,n){'use strict';function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(0),l=n(3),d=n(2),u=function(e){return e&&e.__esModule?e:{default:e}}(d),c=function(){function e(t){i(this,e),this.settings=t,this.name=t.layout||'reflowable',this._spread='none'!==t.spread,this._minSpreadWidth=t.minSpreadWidth||800,this._evenSpreads=t.evenSpreads||!1,this._flow='scrolled'===t.flow||'scrolled-continuous'===t.flow||'scrolled-doc'===t.flow?'scrolled':'paginated',this.width=0,this.height=0,this.spreadWidth=0,this.delta=0,this.columnWidth=0,this.gap=0,this.divisor=1,this.props={name:this.name,spread:this._spread,flow:this._flow,width:0,height:0,spreadWidth:0,delta:0,columnWidth:0,gap:0,divisor:1}}return o(e,[{key:'flow',value:function(e){return'undefined'!=typeof e&&(this._flow='scrolled'===e||'scrolled-continuous'===e||'scrolled-doc'===e?'scrolled':'paginated',this.update({flow:this._flow})),this._flow}},{key:'spread',value:function(e,t){return e&&(this._spread='none'!==e,this.update({spread:this._spread})),0<=t&&(this._minSpreadWidth=t),this._spread}},{key:'calculate',value:function(e,t,n){var a=1,i=n||0,o=e,r=t,l=s(o/12),d,u,c,p;a=this._spread&&o>=this._minSpreadWidth?2:1,'reflowable'!==this.name||'paginated'!==this._flow||0<=n||(i=0==l%2?l:l-1),'pre-paginated'===this.name&&(i=0),1<a?(d=o/a-i,c=d+i):(d=o,c=o),'pre-paginated'===this.name&&1<a&&(o=d),u=d*a+i,p=o,this.width=o,this.height=r,this.spreadWidth=u,this.pageWidth=c,this.delta=p,this.columnWidth=d,this.gap=i,this.divisor=a,this.update({width:o,height:r,spreadWidth:u,pageWidth:c,delta:p,columnWidth:d,gap:i,divisor:a})}},{key:'format',value:function(e){var t;return t='pre-paginated'===this.name?e.fit(this.columnWidth,this.height):'paginated'===this._flow?e.columns(this.width,this.height,this.columnWidth,this.gap):e.size(this.width,null),t}},{key:'count',value:function(e,t){var n,i;return'pre-paginated'===this.name?(n=1,i=1):'paginated'===this._flow?(t=t||this.delta,n=a(e/t),i=n*this.divisor):(t=t||this.height,n=a(e/t),i=n),{spreads:n,pages:i}}},{key:'update',value:function(e){var t=this;if(Object.keys(e).forEach(function(n){t.props[n]===e[n]&&delete e[n]}),0<Object.keys(e).length){var n=(0,r.extend)(this.props,e);this.emit(l.EVENTS.LAYOUT.UPDATED,n,e)}}}]),e}();(0,u.default)(c.prototype),t.default=c,e.exports=t['default']},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var i='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(5),r=function(e){return e&&e.__esModule?e:{default:e}}(s),l=function(){function e(t){a(this,e),this.rendition=t,this._themes={default:{rules:{},url:'',serialized:''}},this._overrides={},this._current='default',this._injected=[],this.rendition.hooks.content.register(this.inject.bind(this)),this.rendition.hooks.content.register(this.overrides.bind(this))}return o(e,[{key:'register',value:function(){return 0===arguments.length?void 0:1===arguments.length&&'object'===i(arguments[0])?this.registerThemes(arguments[0]):1===arguments.length&&'string'==typeof arguments[0]?this.default(arguments[0]):2===arguments.length&&'string'==typeof arguments[1]?this.registerUrl(arguments[0],arguments[1]):2===arguments.length&&'object'===i(arguments[1])?this.registerRules(arguments[0],arguments[1]):void 0}},{key:'default',value:function(e){return e?'string'==typeof e?this.registerUrl('default',e):'object'===('undefined'==typeof e?'undefined':i(e))?this.registerRules('default',e):void 0:void 0}},{key:'registerThemes',value:function(e){for(var t in e)e.hasOwnProperty(t)&&('string'==typeof e[t]?this.registerUrl(t,e[t]):this.registerRules(t,e[t]))}},{key:'registerUrl',value:function(e,t){var n=new r.default(t);this._themes[e]={url:n.toString()},this._injected[e]&&this.update(e)}},{key:'registerRules',value:function(e,t){this._themes[e]={rules:t},this._injected[e]&&this.update(e)}},{key:'select',value:function(e){var t=this._current,n;this._current=e,this.update(e),n=this.rendition.getContents(),n.forEach(function(n){n.removeClass(t),n.addClass(e)})}},{key:'update',value:function(e){var t=this,n=this.rendition.getContents();n.forEach(function(n){t.add(e,n)})}},{key:'inject',value:function(e){var t=[],n=this._themes,a;for(var i in n)n.hasOwnProperty(i)&&(i===this._current||'default'==i)&&(a=n[i],(a.rules&&0<Object.keys(a.rules).length||a.url&&-1===t.indexOf(a.url))&&this.add(i,e),this._injected.push(i));'default'!=this._current&&e.addClass(this._current)}},{key:'add',value:function(e,t){var n=this._themes[e];n&&t&&(n.url?t.addStylesheet(n.url):n.serialized||n.rules&&(t.addStylesheetRules(n.rules),n.injected=!0))}},{key:'override',value:function(e,t){var n=this,a=this.rendition.getContents();this._overrides[e]=t,a.forEach(function(t){t.css(e,n._overrides[e])})}},{key:'overrides',value:function(e){var t=this._overrides;for(var n in t)t.hasOwnProperty(n)&&e.css(n,t[n])}},{key:'fontSize',value:function(e){this.override('font-size',e)}},{key:'font',value:function(e){this.override('font-family',e)}},{key:'destroy',value:function(){this.rendition=void 0,this._themes=void 0,this._overrides=void 0,this._current=void 0,this._injected=void 0}}]),e}();t.default=l,e.exports=t['default']},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(2),r=a(s),l=n(1),d=a(l),u=function(){function e(t){i(this,e),this.rendition=t,this.highlights=[],this.underlines=[],this.marks=[],this._annotations={},this._annotationsBySectionIndex={},this.rendition.hooks.render.register(this.inject.bind(this)),this.rendition.hooks.unloaded.register(this.clear.bind(this))}return o(e,[{key:'add',value:function(e,t,n,a){var i=encodeURI(t),o=new d.default(t),s=o.spinePos,r=new c({type:e,cfiRange:t,data:n,sectionIndex:s,cb:a});this._annotations[i]=r,s in this._annotationsBySectionIndex?this._annotationsBySectionIndex[s].push(i):this._annotationsBySectionIndex[s]=[i];var l=this.rendition.views();return l.forEach(function(e){r.sectionIndex===e.index&&r.attach(e)}),r}},{key:'remove',value:function(e,t){var n=this,a=encodeURI(e);if(a in this._annotations){var i=this._annotations[a];if(t&&i.type!==t)return;var o=this.rendition.views();o.forEach(function(e){n._removeFromAnnotationBySectionIndex(i.sectionIndex,a),i.sectionIndex===e.index&&i.detach(e)}),delete this._annotations[a]}}},{key:'_removeFromAnnotationBySectionIndex',value:function(e,t){this._annotationsBySectionIndex[e]=this._annotationsAt(e).filter(function(e){return e!==t})}},{key:'_annotationsAt',value:function(e){return this._annotationsBySectionIndex[e]}},{key:'highlight',value:function(e,t,n){this.add('highlight',e,t,n)}},{key:'underline',value:function(e,t,n){this.add('underline',e,t,n)}},{key:'mark',value:function(e,t,n){this.add('mark',e,t,n)}},{key:'each',value:function(){return this._annotations.forEach.apply(this._annotations,arguments)}},{key:'inject',value:function(e){var t=this,n=e.index;if(n in this._annotationsBySectionIndex){var a=this._annotationsBySectionIndex[n];a.forEach(function(n){var a=t._annotations[n];a.attach(e)})}}},{key:'clear',value:function(e){var t=this,n=e.index;if(n in this._annotationsBySectionIndex){var a=this._annotationsBySectionIndex[n];a.forEach(function(n){var a=t._annotations[n];a.detach(e)})}}},{key:'show',value:function(){}},{key:'hide',value:function(){}}]),e}(),c=function(){function e(t){var n=t.type,a=t.cfiRange,o=t.data,s=t.sectionIndex,r=t.cb;i(this,e),this.type=n,this.cfiRange=a,this.data=o,this.sectionIndex=s,this.mark=void 0,this.cb=r}return o(e,[{key:'update',value:function(e){this.data=e}},{key:'attach',value:function(e){var t=this.cfiRange,n=this.data,a=this.type,i=this.mark,o=this.cb,s;return'highlight'===a?s=e.highlight(t,n,o):'underline'===a?s=e.underline(t,n,o):'mark'===a&&(s=e.mark(t,n,o)),this.mark=s,s}},{key:'detach',value:function(e){var t=this.cfiRange,n=this.type,a;return e&&('highlight'===n?a=e.unhighlight(t):'underline'===n?a=e.ununderline(t):'mark'===n&&(a=e.unmark(t))),this.mark=void 0,a}},{key:'text',value:function(){}}]),e}();(0,r.default)(c.prototype),t.default=u,e.exports=t['default']},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t&&('object'===('undefined'==typeof t?'undefined':u(t))||'function'==typeof t)?t:e}function o(e,t){if('function'!=typeof t&&null!==t)throw new TypeError('Super expression must either be null or a function, not '+('undefined'==typeof t?'undefined':u(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function r(e,t){var n=t.getBoundingClientRect(),a=e.getBoundingClientRect();return{top:a.top-n.top,left:a.left-n.left,height:e.scrollHeight,width:e.scrollWidth}}function l(e,t){e.style.top=t.top+'px',e.style.left=t.left+'px',e.style.height=t.height+'px',e.style.width=t.width+'px'}function d(e,t){return t.right<=e.right&&t.left>=e.left&&t.top>=e.top&&t.bottom<=e.bottom}var u='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e};Object.defineProperty(t,'__esModule',{value:!0}),t.Underline=t.Highlight=t.Mark=t.Pane=void 0;var c=function e(t,n,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(i===void 0){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,a)}if('value'in i)return i.value;var s=i.get;return void 0===s?void 0:s.call(a)},p=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),h=n(54),f=a(h),g=n(55),m=a(g),y=t.Pane=function(){function e(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document.body;s(this,e),this.target=t,this.element=f.default.createElement('svg'),this.marks=[],this.element.style.position='absolute',this.element.setAttribute('pointer-events','none'),m.default.proxyMouse(this.target,this.marks),this.container=n,this.container.appendChild(this.element),this.render()}return p(e,[{key:'addMark',value:function(e){var t=f.default.createElement('g');return this.element.appendChild(t),e.bind(t,this.container),this.marks.push(e),e.render(),e}},{key:'removeMark',value:function(e){var t=this.marks.indexOf(e);if(-1!==t){var n=e.unbind();this.element.removeChild(n),this.marks.splice(t,1)}}},{key:'render',value:function(){l(this.element,r(this.target,this.container));var e=!0,t=!1,n;try{for(var a=this.marks[Symbol.iterator](),i,o;!(e=(i=a.next()).done);e=!0)o=i.value,o.render()}catch(e){t=!0,n=e}finally{try{!e&&a.return&&a.return()}finally{if(t)throw n}}}}]),e}(),v=t.Mark=function(){function e(){s(this,e),this.element=null}return p(e,[{key:'bind',value:function(e,t){this.element=e,this.container=t}},{key:'unbind',value:function(){var e=this.element;return this.element=null,e}},{key:'render',value:function(){}},{key:'dispatchEvent',value:function(t){this.element&&this.element.dispatchEvent(t)}},{key:'getBoundingClientRect',value:function(){return this.element.getBoundingClientRect()}},{key:'getClientRects',value:function(){for(var e=[],t=this.element.firstChild;t;)e.push(t.getBoundingClientRect()),t=t.nextSibling;return e}},{key:'filteredRanges',value:function(){var e=Array.from(this.range.getClientRects());return e.filter(function(t){for(var n=0;n<e.length;n++){if(e[n]===t)return!0;var a=d(e[n],t);if(a)return!1}return!0})}}]),e}(),b=t.Highlight=function(e){function t(e,n,a,o){s(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.range=e,r.className=n,r.data=a||{},r.attributes=o||{},r}return o(t,e),p(t,[{key:'bind',value:function(e,n){for(var a in c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),'bind',this).call(this,e,n),this.data)this.data.hasOwnProperty(a)&&(this.element.dataset[a]=this.data[a]);for(var a in this.attributes)this.attributes.hasOwnProperty(a)&&this.element.setAttribute(a,this.attributes[a]);this.className&&this.element.classList.add(this.className)}},{key:'render',value:function(){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(var e=this.element.ownerDocument.createDocumentFragment(),t=this.filteredRanges(),n=this.element.getBoundingClientRect(),a=this.container.getBoundingClientRect(),o=0,i=t.length;o<i;o++){var s=t[o],r=f.default.createElement('rect');r.setAttribute('x',s.left-n.left+a.left),r.setAttribute('y',s.top-n.top+a.top),r.setAttribute('height',s.height),r.setAttribute('width',s.width),e.appendChild(r)}this.element.appendChild(e)}}]),t}(v),k=t.Underline=function(e){function t(e,n,a,o){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,a,o))}return o(t,e),p(t,[{key:'render',value:function(){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(var e=this.element.ownerDocument.createDocumentFragment(),t=this.filteredRanges(),n=this.element.getBoundingClientRect(),a=this.container.getBoundingClientRect(),o=0,i=t.length;o<i;o++){var s=t[o],r=f.default.createElement('rect');r.setAttribute('x',s.left-n.left+a.left),r.setAttribute('y',s.top-n.top+a.top),r.setAttribute('height',s.height),r.setAttribute('width',s.width),r.setAttribute('fill','none');var l=f.default.createElement('line');l.setAttribute('x1',s.left-n.left+a.left),l.setAttribute('x2',s.left-n.left+a.left+s.width),l.setAttribute('y1',s.top-n.top+a.top+s.height-1),l.setAttribute('y2',s.top-n.top+a.top+s.height-1),l.setAttribute('stroke-width',1),l.setAttribute('stroke','black'),l.setAttribute('stroke-linecap','square'),e.appendChild(r),e.appendChild(l)}this.element.appendChild(e)}}]),t}(b)},function(e,t){'use strict';function n(e){return document.createElementNS('http://www.w3.org/2000/svg',e)}Object.defineProperty(t,'__esModule',{value:!0}),t.createElement=n,t.default={createElement:n}},function(e,t){'use strict';function n(n,s){function t(r){for(var e=s.length-1;0<=e;e--){var i=s[e],t=r.clientX,l=r.clientY;if(r.touches&&r.touches.length&&(t=r.touches[0].clientX,l=r.touches[0].clientY),!!o(i,n,t,l)){i.dispatchEvent(a(r));break}}}if('iframe'===n.nodeName||'IFRAME'===n.nodeName)try{this.target=n.contentDocument}catch(e){this.target=n}else this.target=n;for(var e=['mouseup','mousedown','click','touchstart'],i=0,r;i<e.length;i++)r=e[i],this.target.addEventListener(r,function(n){return t(n)},!1)}function a(t){var e=Object.assign({},t,{bubbles:!1});try{return new MouseEvent(t.type,e)}catch(a){var n=document.createEvent('MouseEvents');return n.initMouseEvent(t.type,!1,e.cancelable,e.view,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget),n}}function o(e,t,n,a){function o(e,t,n){var a=e.top-s.top,i=e.left-s.left,o=a+e.height,r=i+e.width;return a<=n&&i<=t&&o>n&&r>t}var s=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(!o(r,n,a))return!1;for(var l=e.getClientRects(),d=0,i=l.length;d<i;d++)if(o(l[d],n,a))return!0;return!1}Object.defineProperty(t,'__esModule',{value:!0}),t.proxyMouse=n,t.clone=a,t.default={proxyMouse:n}},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var i=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(0),s=n(57),r=function(e){return e&&e.__esModule?e:{default:e}}(s),l=function(){function e(t){a(this,e),this.settings=t||{},this.id='epubjs-container-'+(0,o.uuid)(),this.container=this.create(this.settings),this.settings.hidden&&(this.wrapper=this.wrap(this.container))}return i(e,[{key:'create',value:function(e){var t=e.height,n=e.width,a=e.overflow||!1,i=e.axis||'vertical',s=e.direction;e.height&&(0,o.isNumber)(e.height)&&(t=e.height+'px'),e.width&&(0,o.isNumber)(e.width)&&(n=e.width+'px');var r=document.createElement('div');return r.id=this.id,r.classList.add('epub-container'),r.style.wordSpacing='0',r.style.lineHeight='0',r.style.verticalAlign='top',r.style.position='relative','horizontal'===i&&(r.style.display='flex',r.style.flexDirection='row',r.style.flexWrap='nowrap'),n&&(r.style.width=n),t&&(r.style.height=t),a&&(r.style.overflow=a),s&&(r.dir=s,r.style.direction=s),s&&this.settings.fullsize&&(document.body.style.direction=s),r}},{key:'wrap',value:function(e){var t=document.createElement('div');return t.style.visibility='hidden',t.style.overflow='hidden',t.style.width='0',t.style.height='0',t.appendChild(e),t}},{key:'getElement',value:function(e){var t;if((0,o.isElement)(e)?t=e:'string'==typeof e&&(t=document.getElementById(e)),!t)throw new Error('Not an Element');return t}},{key:'attachTo',value:function(e){var t=this.getElement(e),n;if(t)return n=this.settings.hidden?this.wrapper:this.container,t.appendChild(n),this.element=t,t}},{key:'getContainer',value:function(){return this.container}},{key:'onResize',value:function(e){(0,o.isNumber)(this.settings.width)&&(0,o.isNumber)(this.settings.height)||(this.resizeFunc=(0,r.default)(e,50),window.addEventListener('resize',this.resizeFunc,!1))}},{key:'onOrientationChange',value:function(e){this.orientationChangeFunc=e,window.addEventListener('orientationchange',this.orientationChangeFunc,!1)}},{key:'size',value:function(e,t){var n;null===e&&(n=this.element.getBoundingClientRect(),n.width&&(e=n.width,this.container.style.width=n.width+'px')),null===t&&(n=n||this.element.getBoundingClientRect(),n.height&&(t=n.height,this.container.style.height=n.height+'px')),(0,o.isNumber)(e)||(n=this.container.getBoundingClientRect(),e=n.width),(0,o.isNumber)(t)||(n=n||this.container.getBoundingClientRect(),t=n.height),this.containerStyles=window.getComputedStyle(this.container),this.containerPadding={left:parseFloat(this.containerStyles['padding-left'])||0,right:parseFloat(this.containerStyles['padding-right'])||0,top:parseFloat(this.containerStyles['padding-top'])||0,bottom:parseFloat(this.containerStyles['padding-bottom'])||0};var a=(0,o.windowBounds)();return e||(e=a.width),(this.settings.fullsize||!t)&&(t=a.height),{width:e-this.containerPadding.left-this.containerPadding.right,height:t-this.containerPadding.top-this.containerPadding.bottom}}},{key:'bounds',value:function(){var e;return'visible'!==this.container.style.overflow&&(e=this.container&&this.container.getBoundingClientRect()),e&&e.width&&e.height?e:(0,o.windowBounds)()}},{key:'getSheet',value:function(){var e=document.createElement('style');return e.appendChild(document.createTextNode('')),document.head.appendChild(e),e.sheet}},{key:'addStyleRules',value:function(e,t){var n='#'+this.id+' ',a='';this.sheet||(this.sheet=this.getSheet()),t.forEach(function(e){for(var t in e)e.hasOwnProperty(t)&&(a+=t+':'+e[t]+';')}),this.sheet.insertRule(n+e+' {'+a+'}',0)}},{key:'axis',value:function(e){'horizontal'===e?(this.container.style.display='flex',this.container.style.flexDirection='row',this.container.style.flexWrap='nowrap'):this.container.style.display='block'}},{key:'direction',value:function(e){this.container&&(this.container.dir=e,this.container.style.direction=e),this.settings.fullsize&&(document.body.style.direction=e)}},{key:'destroy',value:function(){var e;this.element&&(e=this.settings.hidden?this.wrapper:this.container,this.element.contains(this.container)&&this.element.removeChild(this.container),window.removeEventListener('resize',this.resizeFunc),window.removeEventListener('orientationChange',this.orientationChangeFunc))}}]),e}();t.default=l,e.exports=t['default']},function(e,t,n){var a=n(21),i=n(15);e.exports=function(e,t,n){var o=!0,s=!0;if('function'!=typeof e)throw new TypeError('Expected a function');return i(n)&&(o='leading'in n?!!n.leading:o,s='trailing'in n?!!n.trailing:s),a(e,t,{leading:o,maxWait:t,trailing:s})}},function(e,t,n){var a=n(22);e.exports=function(){return a.Date.now()}},function(e,t,n){(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(t,n(8))},function(e,t,n){var a=n(15),i=n(61),o=0/0,s=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,d=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(i(e))return o;if(a(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=a(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=l.test(e);return n||d.test(e)?u(e.slice(2),n?2:8):r.test(e)?o:+e}},function(e,t,n){var a=n(62),i=n(65);e.exports=function(e){return'symbol'==typeof e||i(e)&&a(e)=='[object Symbol]'}},function(e,t,n){var a=n(23),i=n(63),o=n(64),s=a?a.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?'[object Undefined]':'[object Null]':s&&s in Object(e)?i(e):o(e)}},function(e,t,n){var a=n(23),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,r=a?a.toStringTag:void 0;e.exports=function(e){var t=o.call(e,r),n=e[r];try{e[r]=void 0}catch(t){}var a=s.call(e);return t?e[r]=n:delete e[r],a}},function(e){var t=Object.prototype,n=t.toString;e.exports=function(e){return n.call(e)}},function(e){e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t){'use strict';function n(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var a=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),i=function(){function e(t){n(this,e),this.container=t,this._views=[],this.length=0,this.hidden=!1}return a(e,[{key:'all',value:function(){return this._views}},{key:'first',value:function(){return this._views[0]}},{key:'last',value:function(){return this._views[this._views.length-1]}},{key:'indexOf',value:function(e){return this._views.indexOf(e)}},{key:'slice',value:function(){return this._views.slice.apply(this._views,arguments)}},{key:'get',value:function(e){return this._views[e]}},{key:'append',value:function(e){return this._views.push(e),this.container&&this.container.appendChild(e.element),this.length++,e}},{key:'prepend',value:function(e){return this._views.unshift(e),this.container&&this.container.insertBefore(e.element,this.container.firstChild),this.length++,e}},{key:'insert',value:function(e,t){return this._views.splice(t,0,e),this.container&&(t<this.container.children.length?this.container.insertBefore(e.element,this.container.children[t]):this.container.appendChild(e.element)),this.length++,e}},{key:'remove',value:function(e){var t=this._views.indexOf(e);-1<t&&this._views.splice(t,1),this.destroy(e),this.length--}},{key:'destroy',value:function(e){e.displayed&&e.destroy(),this.container&&this.container.removeChild(e.element),e=null}},{key:'forEach',value:function(){return this._views.forEach.apply(this._views,arguments)}},{key:'clear',value:function(){var e=this.length,t;if(this.length){for(var n=0;n<e;n++)t=this._views[n],this.destroy(t);this._views=[],this.length=0}}},{key:'find',value:function(e){for(var t=this.length,n=0,a;n<t;n++)if(a=this._views[n],a.displayed&&a.section.index==e.index)return a}},{key:'displayed',value:function(){for(var e=[],t=this.length,n=0,a;n<t;n++)a=this._views[n],a.displayed&&e.push(a);return e}},{key:'show',value:function(){for(var e=this.length,t=0,n;t<e;t++)n=this._views[t],n.displayed&&n.show();this.hidden=!1}},{key:'hide',value:function(){for(var e=this.length,t=0,n;t<e;t++)n=this._views[t],n.displayed&&n.hide();this.hidden=!0}}]),e}();t.default=i,e.exports=t['default']},function(e,t,n){'use strict';function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}Object.defineProperty(t,'__esModule',{value:!0});var o=function(){function e(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=n(0),r=n(11),l=a(r),d=n(17),u=a(d),c=n(4),p=a(c),h=function(){function e(){i(this,e),this.zip=void 0,this.urlCache={},this.checkRequirements()}return o(e,[{key:'checkRequirements',value:function(){try{if('undefined'==typeof JSZip){var e=n(68);this.zip=new e}else this.zip=new JSZip}catch(t){throw new Error('JSZip lib not loaded')}}},{key:'open',value:function(e,t){return this.zip.loadAsync(e,{base64:t})}},{key:'openUrl',value:function(e,t){return(0,l.default)(e,'binary').then(function(e){return this.zip.loadAsync(e,{base64:t})}.bind(this))}},{key:'request',value:function(e,t){var n=new s.defer,a=new p.default(e),i;return t||(t=a.extension),i='blob'==t?this.getBlob(e):this.getText(e),i?i.then(function(e){var a=this.handleResponse(e,t);n.resolve(a)}.bind(this)):n.reject({message:'File not found in the epub: '+e,stack:new Error().stack}),n.promise}},{key:'handleResponse',value:function(e,t){var n;return n='json'==t?JSON.parse(e):(0,s.isXml)(t)?(0,s.parse)(e,'text/xml'):'xhtml'==t?(0,s.parse)(e,'application/xhtml+xml'):'html'==t||'htm'==t?(0,s.parse)(e,'text/html'):e,n}},{key:'getBlob',value:function(e,t){var n=window.decodeURIComponent(e.substr(1)),a=this.zip.file(n);if(a)return t=t||u.default.lookup(a.name),a.async('uint8array').then(function(e){return new Blob([e],{type:t})})}},{key:'getText',value:function(e){var t=window.decodeURIComponent(e.substr(1)),n=this.zip.file(t);if(n)return n.async('string').then(function(e){return e})}},{key:'getBase64',value:function(e,t){var n=window.decodeURIComponent(e.substr(1)),a=this.zip.file(n);if(a)return t=t||u.default.lookup(a.name),a.async('base64').then(function(e){return'data:'+t+';base64,'+e})}},{key:'createUrl',value:function(e,t){var n=new s.defer,a=window.URL||window.webkitURL||window.mozURL,i=t&&t.base64,o,r;return e in this.urlCache?(n.resolve(this.urlCache[e]),n.promise):(i?(r=this.getBase64(e),r&&r.then(function(t){this.urlCache[e]=t,n.resolve(t)}.bind(this))):(r=this.getBlob(e),r&&r.then(function(t){o=a.createObjectURL(t),this.urlCache[e]=o,n.resolve(o)}.bind(this))),r||n.reject({message:'File not found in the epub: '+e,stack:new Error().stack}),n.promise)}},{key:'revokeUrl',value:function(e){var t=window.URL||window.webkitURL||window.mozURL,n=this.urlCache[e];n&&t.revokeObjectURL(n)}},{key:'destroy',value:function(){var e=window.URL||window.webkitURL||window.mozURL;for(var t in this.urlCache)e.revokeObjectURL(t);this.zip=void 0,this.urlCache={}}}]),e}();t.default=h,e.exports=t['default']},function(n){if('undefined'==typeof t){var a=new Error('Cannot find module "jszip"');throw a.code='MODULE_NOT_FOUND',a}n.exports=t},function(e,t,n){'use strict';(function(e,n){var a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},i,o,s;(function(r,l){r||(r=window||e),'object'===a(n)&&n.exports?n.exports=l(r):(o=[],i=l,s='function'==typeof i?i.apply(t,o):i,!(s!==void 0&&(n.exports=s)))})(void 0,function(e){function t(e){return void 0!==u[e]}function n(){r.call(this),this._isInvalid=!0}function a(e){return''==e&&n.call(this),e.toLowerCase()}function o(e){var t=e.charCodeAt(0);return 32<t&&127>t&&-1==[34,35,60,62,63,96].indexOf(t)?e:encodeURIComponent(e)}function s(e){var t=e.charCodeAt(0);return 32<t&&127>t&&-1==[34,35,60,62,96].indexOf(t)?e:encodeURIComponent(e)}function i(e,r,l){function d(e){x.push(e)}var m=r||'scheme start',y=0,v='',b=!1,k=!1,x=[];loop:for(;(e[y-1]!=f||0==y)&&!this._isInvalid;){var E=e[y];switch(m){case'scheme start':if(E&&h.test(E))v+=E.toLowerCase(),m='scheme';else if(!r){v='',m='no scheme';continue}else{d('Invalid scheme.');break loop}break;case'scheme':if(E&&g.test(E))v+=E.toLowerCase();else if(':'==E){if(this._scheme=v,v='',r)break loop;t(this._scheme)&&(this._isRelative=!0),m='file'==this._scheme?'relative':this._isRelative&&l&&l._scheme==this._scheme?'relative or authority':this._isRelative?'authority first slash':'scheme data'}else if(!r){v='',y=0,m='no scheme';continue}else if(f==E)break loop;else{d('Code point not allowed in scheme: '+E);break loop}break;case'scheme data':'?'==E?(this._query='?',m='query'):'#'==E?(this._fragment='#',m='fragment'):f!=E&&'\t'!=E&&'\n'!=E&&'\r'!=E&&(this._schemeData+=o(E));break;case'no scheme':if(!l||!t(l._scheme))d('Missing scheme.'),n.call(this);else{m='relative';continue}break;case'relative or authority':if('/'==E&&'/'==e[y+1])m='authority ignore slashes';else{d('Expected /, got: '+E),m='relative';continue}break;case'relative':if(this._isRelative=!0,'file'!=this._scheme&&(this._scheme=l._scheme),f==E){this._host=l._host,this._port=l._port,this._path=l._path.slice(),this._query=l._query,this._username=l._username,this._password=l._password;break loop}else if('/'==E||'\\'==E)'\\'==E&&d('\\ is an invalid code point.'),m='relative slash';else if('?'==E)this._host=l._host,this._port=l._port,this._path=l._path.slice(),this._query='?',this._username=l._username,this._password=l._password,m='query';else if('#'==E)this._host=l._host,this._port=l._port,this._path=l._path.slice(),this._query=l._query,this._fragment='#',this._username=l._username,this._password=l._password,m='fragment';else{var c=e[y+1],_=e[y+2];'file'==this._scheme&&h.test(E)&&(':'==c||'|'==c)&&(f==_||'/'==_||'\\'==_||'?'==_||'#'==_)||(this._host=l._host,this._port=l._port,this._username=l._username,this._password=l._password,this._path=l._path.slice(),this._path.pop()),m='relative path';continue}break;case'relative slash':if('/'==E||'\\'==E)'\\'==E&&d('\\ is an invalid code point.'),m='file'==this._scheme?'file host':'authority ignore slashes';else{'file'!=this._scheme&&(this._host=l._host,this._port=l._port,this._username=l._username,this._password=l._password),m='relative path';continue}break;case'authority first slash':if('/'==E)m='authority second slash';else{d('Expected \'/\', got: '+E),m='authority ignore slashes';continue}break;case'authority second slash':if(m='authority ignore slashes','/'!=E){d('Expected \'/\', got: '+E);continue}break;case'authority ignore slashes':if('/'!=E&&'\\'!=E){m='authority';continue}else d('Expected authority, got: '+E);break;case'authority':if('@'==E){b&&(d('@ already seen.'),v+='%40'),b=!0;for(var w=0,i;w<v.length;w++){if(i=v[w],'\t'==i||'\n'==i||'\r'==i){d('Invalid whitespace in authority.');continue}if(':'==i&&null===this._password){this._password='';continue}var S=o(i);null===this._password?this._username+=S:this._password+=S}v=''}else if(f==E||'/'==E||'\\'==E||'?'==E||'#'==E){y-=v.length,v='',m='host';continue}else v+=E;break;case'file host':if(f==E||'/'==E||'\\'==E||'?'==E||'#'==E){2==v.length&&h.test(v[0])&&(':'==v[1]||'|'==v[1])?m='relative path':0==v.length?m='relative path start':(this._host=a.call(this,v),v='',m='relative path start');continue}else'\t'==E||'\n'==E||'\r'==E?d('Invalid whitespace in file host.'):v+=E;break;case'host':case'hostname':if(':'==E&&!k){if(this._host=a.call(this,v),v='',m='port','hostname'==r)break loop;}else if(f==E||'/'==E||'\\'==E||'?'==E||'#'==E){if(this._host=a.call(this,v),v='',m='relative path start',r)break loop;continue}else'\t'!=E&&'\n'!=E&&'\r'!=E?('['==E?k=!0:']'==E&&(k=!1),v+=E):d('Invalid code point in host/hostname: '+E);break;case'port':if(/[0-9]/.test(E))v+=E;else if(f==E||'/'==E||'\\'==E||'?'==E||'#'==E||r){if(''!=v){var C=parseInt(v,10);C!=u[this._scheme]&&(this._port=C+''),v=''}if(r)break loop;m='relative path start';continue}else'\t'==E||'\n'==E||'\r'==E?d('Invalid code point in port: '+E):n.call(this);break;case'relative path start':if('\\'==E&&d('\'\\\' not allowed in path.'),m='relative path','/'!=E&&'\\'!=E)continue;break;case'relative path':if(f==E||'/'==E||'\\'==E||!r&&('?'==E||'#'==E)){'\\'==E&&d('\\ not allowed in relative path.');var T;(T=p[v.toLowerCase()])&&(v=T),'..'==v?(this._path.pop(),'/'!=E&&'\\'!=E&&this._path.push('')):'.'==v&&'/'!=E&&'\\'!=E?this._path.push(''):'.'!=v&&('file'==this._scheme&&0==this._path.length&&2==v.length&&h.test(v[0])&&'|'==v[1]&&(v=v[0]+':'),this._path.push(v)),v='','?'==E?(this._query='?',m='query'):'#'==E&&(this._fragment='#',m='fragment')}else'\t'!=E&&'\n'!=E&&'\r'!=E&&(v+=o(E));break;case'query':r||'#'!=E?f!=E&&'\t'!=E&&'\n'!=E&&'\r'!=E&&(this._query+=s(E)):(this._fragment='#',m='fragment');break;case'fragment':f!=E&&'\t'!=E&&'\n'!=E&&'\r'!=E&&(this._fragment+=E);}y++}}function r(){this._scheme='',this._schemeData='',this._username='',this._password=null,this._host='',this._port='',this._path=[],this._query='',this._fragment='',this._isInvalid=!1,this._isRelative=!1}function l(e,t){void 0===t||t instanceof l||(t=new l(t+'')),this._url=e,r.call(this);var n=e.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,'');i.call(this,n,null,t)}var d=!1;if(!e.forceJURL)try{var c=new URL('b','http://a');c.pathname='c%20d',d='http://a/c%20d'===c.href}catch(t){}if(d)return e.URL;var u=Object.create(null);u.ftp=21,u.file=0,u.gopher=70,u.http=80,u.https=443,u.ws=80,u.wss=443;var p=Object.create(null);p['%2e']='.',p['.%2e']='..',p['%2e.']='..',p['%2e%2e']='..';var h=/[a-zA-Z]/,g=/[a-zA-Z0-9\+\-\.]/,f;l.prototype={toString:function(){return this.href},get href(){if(this._isInvalid)return this._url;var e='';return(''!=this._username||null!=this._password)&&(e=this._username+(null==this._password?'':':'+this._password)+'@'),this.protocol+(this._isRelative?'//'+e+this.host:'')+this.pathname+this._query+this._fragment},set href(e){r.call(this),i.call(this,e)},get protocol(){return this._scheme+':'},set protocol(e){this._isInvalid||i.call(this,e+':','scheme start')},get host(){return this._isInvalid?'':this._port?this._host+':'+this._port:this._host},set host(e){this._isInvalid||!this._isRelative||i.call(this,e,'host')},get hostname(){return this._host},set hostname(e){this._isInvalid||!this._isRelative||i.call(this,e,'hostname')},get port(){return this._port},set port(e){this._isInvalid||!this._isRelative||i.call(this,e,'port')},get pathname(){return this._isInvalid?'':this._isRelative?'/'+this._path.join('/'):this._schemeData},set pathname(e){this._isInvalid||!this._isRelative||(this._path=[],i.call(this,e,'relative path start'))},get search(){return this._isInvalid||!this._query||'?'==this._query?'':this._query},set search(e){this._isInvalid||!this._isRelative||(this._query='?','?'==e[0]&&(e=e.slice(1)),i.call(this,e,'query'))},get hash(){return this._isInvalid||!this._fragment||'#'==this._fragment?'':this._fragment},set hash(e){this._isInvalid||(this._fragment='#','#'==e[0]&&(e=e.slice(1)),i.call(this,e,'fragment'))},get origin(){var e;if(this._isInvalid||!this._scheme)return'';switch(this._scheme){case'file':return'file://';case'data':case'javascript':case'mailto':return'null';}return e=this.host,e?this._scheme+'://'+e:''}};var m=e.URL;return m&&(l.createObjectURL=function(){return m.createObjectURL.apply(m,arguments)},l.revokeObjectURL=function(e){m.revokeObjectURL(e)}),l})}).call(t,n(8),n(70)(e))},function(e){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],!e.children&&(e.children=[]),Object.defineProperty(e,'loaded',{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,'id',{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}}])});
|