mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
48 lines
No EOL
143 KiB
JavaScript
48 lines
No EOL
143 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("xmldom"),function(){try{return require("JSZip")}catch(t){}}()):"function"==typeof define&&define.amd?define(["xmldom","JSZip"],e):"object"==typeof exports?exports.ePub=e(require("xmldom"),function(){try{return require("JSZip")}catch(t){}}()):t.ePub=e(t.xmldom,t.JSZip)}(this,function(t,e){return function(t){function e(n){if(i[n])return i[n].exports;var r=i[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){function n(t){return new r(t)}var r=i(1),o=i(15),s=i(24),a=i(30),h=i(2);n.VERSION="0.3.0",n.CFI=o,n.Rendition=s,n.Contents=a,n.RSVP=h,n.ViewManagers={},n.Views={},n.register={manager:function(t,e){return n.ViewManagers[t]=e},view:function(t,e){return n.Views[t]=e}},n.register.view("iframe",i(31)),n.register.manager("single",i(32)),n.register.manager("continuous",i(35)),t.exports=n},function(t,e,i){function n(t,e){this.settings=s.extend(this.settings||{},{requestMethod:this.requestMethod}),s.extend(this.settings,e),this.opening=new r.defer,this.opened=this.opening.promise,this.isOpen=!1,this.url=void 0,this.loading={manifest:new r.defer,spine:new r.defer,metadata:new r.defer,cover:new r.defer,navigation:new r.defer,pageList:new r.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},this.ready=r.hash(this.loaded),this.isRendered=!1,this.request=this.settings.requestMethod.bind(this),this.spine=new a(this.request),this.locations=new h(this.spine,this.request),t&&this.open(t)["catch"](function(e){var i=new Error("Cannot load book at "+t);console.error(i),this.trigger("loadFailed",e)}.bind(this))}var r=i(2),o=i(6),s=i(11),a=i(14),h=i(20),u=i(22),c=i(23),l=i(24),p=i(27),d=i(18),f=i(15);n.prototype.open=function(t,e){var i,n,r,s,a=new u,h=this,c="META-INF/container.xml",l=!1,p=e&&e.base64;return t?(t instanceof ArrayBuffer||p?(l=!0,this.url="/"):i=o(t),window&&window.location&&i?(s=i.absoluteTo(window.location.href),this.url=s.toString()):window&&window.location?this.url=window.location.href:this.url=t,i&&"opf"===i.suffix()?(this.packageUrl=t,this.containerUrl="",i.origin()?this.baseUrl=i.origin()+"/"+i.directory()+"/":s?(this.baseUrl=s.origin(),this.baseUrl+=s.directory()+"/"):this.baseUrl=i.directory()+"/",n=this.request(this.packageUrl)["catch"](function(t){h.opening.reject(t)})):l||p||this.isArchivedUrl(i)?(this.url="/",this.containerUrl=o(c).absoluteTo(this.url).toString(),r=this.unarchive(t,p).then(function(){return this.request(this.containerUrl)}.bind(this))["catch"](function(t){h.opening.reject(t)})):i.suffix()||(this.containerUrl=this.url+c,r=this.request(this.containerUrl)["catch"](function(t){h.opening.reject(t)})),r&&(n=r.then(function(t){return a.container(t)}).then(function(t){var e=o(t.packagePath),i=e.absoluteTo(h.url);return h.packageUrl=i.toString(),h.encoding=t.encoding,i.origin()?h.baseUrl=i.origin()+i.directory()+"/":e.directory()?h.baseUrl="/"+e.directory()+"/":h.baseUrl="/",h.request(h.packageUrl)})["catch"](function(t){h.opening.reject(t)})),n.then(function(t){t&&(h.unpack(t),h.loading.manifest.resolve(h["package"].manifest),h.loading.metadata.resolve(h["package"].metadata),h.loading.spine.resolve(h.spine),h.loading.cover.resolve(h.cover),h.isOpen=!0,h.opening.resolve(h))})["catch"](function(t){h.opening.reject(t)}),this.opened):(this.opening.resolve(this),this.opened)},n.prototype.unpack=function(t){var e=this,i=new u;e["package"]=i.packageContents(t),e["package"]&&(e["package"].baseUrl=e.baseUrl,this.spine.load(e["package"]),e.navigation=new c(e["package"],this.request),e.navigation.load().then(function(t){e.toc=t,e.loading.navigation.resolve(e.toc)}),e.cover=o(e["package"].coverPath).absoluteTo(e.baseUrl).toString())},n.prototype.section=function(t){return this.spine.get(t)},n.prototype.renderTo=function(t,e){return this.rendition=new l(this,e),this.rendition.attachTo(t),this.rendition},n.prototype.requestMethod=function(t){return this.unarchived?this.unarchived.request(t):d(t,null,this.requestCredentials,this.requestHeaders)},n.prototype.setRequestCredentials=function(t){this.requestCredentials=t},n.prototype.setRequestHeaders=function(t){this.requestHeaders=t},n.prototype.unarchive=function(t,e){return this.unarchived=new p,this.unarchived.open(t,e)},n.prototype.isArchivedUrl=function(t){var e,i;return t instanceof ArrayBuffer||(e=o(t),i=e.suffix(),!(!i||"epub"!=i&&"zip"!=i))},n.prototype.coverUrl=function(){var t=this.loaded.cover.then(function(t){return this.unarchived?this.unarchived.createUrl(this.cover):this.cover}.bind(this));return t},n.prototype.range=function(t){var e=new f(t),i=this.spine.get(e.spinePos);return i.load().then(function(t){var n=e.toRange(i.document);return n})},t.exports=n,r.EventTarget.mixin(n.prototype),r.on("error",function(t){console.error(t)}),r.configure("instrument",!1),r.on("rejected",function(t){console.error(t.detail.message,t.detail.stack)})},function(t,e,i){(function(t,n,r){/*!
|
|
* @overview RSVP - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2016 Yehuda Katz, Tom Dale, Stefan Penner and contributors
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE
|
|
* @version 3.3.2
|
|
*/
|
|
!function(t,i){i(e)}(this,function(e){"use strict";function o(t,e){for(var i=0,n=t.length;i<n;i++)if(t[i]===e)return i;return-1}function s(t){var e=t._promiseCallbacks;return e||(e=t._promiseCallbacks={}),e}function a(t,e){return"onerror"===t?void St.on("error",e):2!==arguments.length?St[t]:void(St[t]=e)}function h(t){return"function"==typeof t||"object"==typeof t&&null!==t}function u(t){return"function"==typeof t}function c(t){return"object"==typeof t&&null!==t}function l(){}function p(){setTimeout(function(){for(var t=0;t<qt.length;t++){var e=qt[t],i=e.payload;i.guid=i.key+i.id,i.childGuid=i.key+i.childId,i.error&&(i.stack=i.error.stack),St.trigger(e.name,e.payload)}qt.length=0},50)}function d(t,e,i){1===qt.push({name:t,payload:{key:e._guidKey,id:e._id,eventName:t,detail:e._result,childId:i&&i._id,label:e._label,timeStamp:Ct(),error:St["instrument-with-stack"]?new Error(e._label):null}})&&p()}function f(t,e){var i=this;if(t&&"object"==typeof t&&t.constructor===i)return t;var n=new i(m,e);return _(n,t),n}function g(){return new TypeError("A promises callback cannot return that same promise.")}function m(){}function v(t){try{return t.then}catch(e){return Pt.error=e,Pt}}function y(t,e,i,n){try{t.call(e,i,n)}catch(r){return r}}function b(t,e,i){St.async(function(t){var n=!1,r=y(i,e,function(i){n||(n=!0,e!==i?_(t,i,void 0):k(t,i))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&r&&(n=!0,S(t,r))},t)}function w(t,e){e._state===Lt?k(t,e._result):e._state===Rt?(e._onError=null,S(t,e._result)):E(e,void 0,function(i){e!==i?_(t,i,void 0):k(t,i)},function(e){return S(t,e)})}function x(t,e,i){e.constructor===t.constructor&&i===L&&t.constructor.resolve===f?w(t,e):i===Pt?S(t,Pt.error):void 0===i?k(t,e):u(i)?b(t,e,i):k(t,e)}function _(t,e){t===e?k(t,e):h(e)?x(t,e,v(e)):k(t,e)}function T(t){t._onError&&t._onError(t._result),z(t)}function k(t,e){t._state===Nt&&(t._result=e,t._state=Lt,0===t._subscribers.length?St.instrument&&d("fulfilled",t):St.async(z,t))}function S(t,e){t._state===Nt&&(t._state=Rt,t._result=e,St.async(T,t))}function E(t,e,i,n){var r=t._subscribers,o=r.length;t._onError=null,r[o]=e,r[o+Lt]=i,r[o+Rt]=n,0===o&&t._state&&St.async(z,t)}function z(t){var e=t._subscribers,i=t._state;if(St.instrument&&d(i===Lt?"fulfilled":"rejected",t),0!==e.length){for(var n=void 0,r=void 0,o=t._result,s=0;s<e.length;s+=3)n=e[s],r=e[s+i],n?q(i,n,r,o):r(o);t._subscribers.length=0}}function C(){this.error=null}function A(t,e){try{return t(e)}catch(i){return jt.error=i,jt}}function q(t,e,i,n){var r=u(i),o=void 0,s=void 0,a=void 0,h=void 0;if(r){if(o=A(i,n),o===jt?(h=!0,s=o.error,o=null):a=!0,e===o)return void S(e,g())}else o=n,a=!0;e._state!==Nt||(r&&a?_(e,o):h?S(e,s):t===Lt?k(e,o):t===Rt&&S(e,o))}function N(t,e){var i=!1;try{e(function(e){i||(i=!0,_(t,e))},function(e){i||(i=!0,S(t,e))})}catch(n){S(t,n)}}function L(t,e,i){var n=arguments,r=this,o=r._state;if(o===Lt&&!t||o===Rt&&!e)return St.instrument&&d("chained",r,r),r;r._onError=null;var s=new r.constructor(m,i),a=r._result;return St.instrument&&d("chained",r,s),o?!function(){var t=n[o-1];St.async(function(){return q(o,s,t,a)})}():E(r,s,t,e),s}function R(t,e,i){return t===Lt?{state:"fulfilled",value:i}:{state:"rejected",reason:i}}function P(t,e,i,n){this._instanceConstructor=t,this.promise=new t(m,n),this._abortOnReject=i,this._validateInput(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._init(),0===this.length?k(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&k(this.promise,this._result))):S(this.promise,this._validationError())}function j(t,e){return new P(this,t,(!0),e).promise}function O(t,e){var i=this,n=new i(m,e);if(!zt(t))return S(n,new TypeError("You must pass an array to race.")),n;for(var r=0;n._state===Nt&&r<t.length;r++)E(i.resolve(t[r]),void 0,function(t){return _(n,t)},function(t){return S(n,t)});return n}function I(t,e){var i=this,n=new i(m,e);return S(n,t),n}function B(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function U(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function F(t,e){this._id=It++,this._label=e,this._state=void 0,this._result=void 0,this._subscribers=[],St.instrument&&d("created",this),m!==t&&("function"!=typeof t&&B(),this instanceof F?N(this,t):U())}function D(){this.value=void 0}function Q(t){try{return t.then}catch(e){return Bt.value=e,Bt}}function M(t,e,i){try{t.apply(e,i)}catch(n){return Bt.value=n,Bt}}function W(t,e){for(var i={},n=t.length,r=new Array(n),o=0;o<n;o++)r[o]=t[o];for(var s=0;s<e.length;s++){var a=e[s];i[a]=r[s+1]}return i}function H(t){for(var e=t.length,i=new Array(e-1),n=1;n<e;n++)i[n-1]=t[n];return i}function X(t,e){return{then:function(i,n){return t.call(e,i,n)}}}function V(t,e){var i=function(){for(var i=this,n=arguments.length,r=new Array(n+1),o=!1,s=0;s<n;++s){var a=arguments[s];if(!o){if(o=J(a),o===Ut){var h=new F(m);return S(h,Ut.value),h}o&&o!==!0&&(a=X(o,a))}r[s]=a}var u=new F(m);return r[n]=function(t,i){t?S(u,t):void 0===e?_(u,i):e===!0?_(u,H(arguments)):zt(e)?_(u,W(arguments,e)):_(u,i)},o?Z(u,r,t,i):$(u,r,t,i)};return i.__proto__=t,i}function $(t,e,i,n){var r=M(i,n,e);return r===Bt&&S(t,r.value),t}function Z(t,e,i,n){return F.all(e).then(function(e){var r=M(i,n,e);return r===Bt&&S(t,r.value),t})}function J(t){return!(!t||"object"!=typeof t)&&(t.constructor===F||Q(t))}function Y(t,e){return F.all(t,e)}function G(t,e,i){this._superConstructor(t,e,!1,i)}function K(t,e){return new G(F,t,e).promise}function tt(t,e){return F.race(t,e)}function et(t,e,i){this._superConstructor(t,e,!0,i)}function it(t,e){return new et(F,t,e).promise}function nt(t,e,i){this._superConstructor(t,e,!1,i)}function rt(t,e){return new nt(F,t,e).promise}function ot(t){throw setTimeout(function(){throw t}),t}function st(t){var e={resolve:void 0,reject:void 0};return e.promise=new F(function(t,i){e.resolve=t,e.reject=i},t),e}function at(t,e,i){return F.all(t,i).then(function(t){if(!u(e))throw new TypeError("You must pass a function as map's second argument.");for(var n=t.length,r=new Array(n),o=0;o<n;o++)r[o]=e(t[o]);return F.all(r,i)})}function ht(t,e){return F.resolve(t,e)}function ut(t,e){return F.reject(t,e)}function ct(t,e){return F.all(t,e)}function lt(t,e){return F.resolve(t,e).then(function(t){return ct(t,e)})}function pt(t,e,i){var n=zt(t)?ct(t,i):lt(t,i);return n.then(function(t){if(!u(e))throw new TypeError("You must pass a function as filter's second argument.");for(var n=t.length,r=new Array(n),o=0;o<n;o++)r[o]=e(t[o]);return ct(r,i).then(function(e){for(var i=new Array(n),r=0,o=0;o<n;o++)e[o]&&(i[r]=t[o],r++);return i.length=r,i})})}function dt(t,e){Vt[Ft]=t,Vt[Ft+1]=e,Ft+=2,2===Ft&&$t()}function ft(){var e=t.nextTick,i=t.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);return Array.isArray(i)&&"0"===i[1]&&"10"===i[2]&&(e=n),function(){return e(bt)}}function gt(){return function(){return Dt(bt)}}function mt(){var t=0,e=new Wt(bt),i=document.createTextNode("");return e.observe(i,{characterData:!0}),function(){return i.data=t=++t%2}}function vt(){var t=new MessageChannel;return t.port1.onmessage=bt,function(){return t.port2.postMessage(0)}}function yt(){return function(){return setTimeout(bt,1)}}function bt(){for(var t=0;t<Ft;t+=2){var e=Vt[t],i=Vt[t+1];e(i),Vt[t]=void 0,Vt[t+1]=void 0}Ft=0}function wt(){try{var t=i(5);return Dt=t.runOnLoop||t.runOnContext,gt()}catch(e){return yt()}}function xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _t(){St.on.apply(St,arguments)}function Tt(){St.off.apply(St,arguments)}var kt={mixin:function(t){return t.on=this.on,t.off=this.off,t.trigger=this.trigger,t._promiseCallbacks=void 0,t},on:function(t,e){if("function"!=typeof e)throw new TypeError("Callback must be a function");var i=s(this),n=void 0;n=i[t],n||(n=i[t]=[]),o(n,e)===-1&&n.push(e)},off:function(t,e){var i=s(this),n=void 0,r=void 0;return e?(n=i[t],r=o(n,e),void(r!==-1&&n.splice(r,1))):void(i[t]=[])},trigger:function(t,e,i){var n=s(this),r=void 0,o=void 0;if(r=n[t])for(var a=0;a<r.length;a++)(o=r[a])(e,i)}},St={instrument:!1};kt.mixin(St);var Et=void 0;Et=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var zt=Et,Ct=Date.now||function(){return(new Date).getTime()},At=Object.create||function(t){if(arguments.length>1)throw new Error("Second argument not supported");if("object"!=typeof t)throw new TypeError("Argument must be an object");return l.prototype=t,new l},qt=[],Nt=void 0,Lt=1,Rt=2,Pt=new C,jt=new C;P.prototype._validateInput=function(t){return zt(t)},P.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},P.prototype._init=function(){this._result=new Array(this.length)},P.prototype._enumerate=function(){for(var t=this.length,e=this.promise,i=this._input,n=0;e._state===Nt&&n<t;n++)this._eachEntry(i[n],n)},P.prototype._settleMaybeThenable=function(t,e){var i=this._instanceConstructor,n=i.resolve;if(n===f){var r=v(t);if(r===L&&t._state!==Nt)t._onError=null,this._settledAt(t._state,e,t._result);else if("function"!=typeof r)this._remaining--,this._result[e]=this._makeResult(Lt,e,t);else if(i===F){var o=new i(m);x(o,t,r),this._willSettleAt(o,e)}else this._willSettleAt(new i(function(e){return e(t)}),e)}else this._willSettleAt(n(t),e)},P.prototype._eachEntry=function(t,e){c(t)?this._settleMaybeThenable(t,e):(this._remaining--,this._result[e]=this._makeResult(Lt,e,t))},P.prototype._settledAt=function(t,e,i){var n=this.promise;n._state===Nt&&(this._remaining--,this._abortOnReject&&t===Rt?S(n,i):this._result[e]=this._makeResult(t,e,i)),0===this._remaining&&k(n,this._result)},P.prototype._makeResult=function(t,e,i){return i},P.prototype._willSettleAt=function(t,e){var i=this;E(t,void 0,function(t){return i._settledAt(Lt,e,t)},function(t){return i._settledAt(Rt,e,t)})};var Ot="rsvp_"+Ct()+"-",It=0;F.cast=f,F.all=j,F.race=O,F.resolve=f,F.reject=I,F.prototype={constructor:F,_guidKey:Ot,_onError:function(t){var e=this;St.after(function(){e._onError&&St.trigger("error",t,e._label)})},then:L,"catch":function(t,e){return this.then(void 0,t,e)},"finally":function(t,e){var i=this,n=i.constructor;return i.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})},e)}};var Bt=new D,Ut=new D;G.prototype=At(P.prototype),G.prototype._superConstructor=P,G.prototype._makeResult=R,G.prototype._validationError=function(){return new Error("allSettled must be called with an array")},et.prototype=At(P.prototype),et.prototype._superConstructor=P,et.prototype._init=function(){this._result={}},et.prototype._validateInput=function(t){return t&&"object"==typeof t},et.prototype._validationError=function(){return new Error("Promise.hash must be called with an object")},et.prototype._enumerate=function(){var t=this,e=t.promise,i=t._input,n=[];for(var r in i)e._state===Nt&&Object.prototype.hasOwnProperty.call(i,r)&&n.push({position:r,entry:i[r]});var o=n.length;t._remaining=o;for(var s=void 0,a=0;e._state===Nt&&a<o;a++)s=n[a],t._eachEntry(s.entry,s.position)},nt.prototype=At(et.prototype),nt.prototype._superConstructor=P,nt.prototype._makeResult=R,nt.prototype._validationError=function(){return new Error("hashSettled must be called with an object")};var Ft=0,Dt=void 0,Qt="undefined"!=typeof window?window:void 0,Mt=Qt||{},Wt=Mt.MutationObserver||Mt.WebKitMutationObserver,Ht="undefined"==typeof self&&"undefined"!=typeof t&&"[object process]"==={}.toString.call(t),Xt="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Vt=new Array(1e3),$t=void 0;$t=Ht?ft():Wt?mt():Xt?vt():void 0===Qt?wt():yt();var Zt=void 0;if("object"==typeof self)Zt=self;else{if("object"!=typeof r)throw new Error("no global: `self` or `global` found");Zt=r}var Jt;St.async=dt,St.after=function(t){return setTimeout(t,0)};var Yt=ht,Gt=function(t,e){return St.async(t,e)};if("undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){var Kt=window.__PROMISE_INSTRUMENTATION__;a("instrument",!0);for(var te in Kt)Kt.hasOwnProperty(te)&&_t(te,Kt[te])}var ee=(Jt={cast:Yt,Promise:F,EventTarget:kt,all:Y,allSettled:K,race:tt,hash:it,hashSettled:rt,rethrow:ot,defer:st,denodeify:V,configure:a,on:_t,off:Tt,resolve:ht,reject:ut,map:at},xt(Jt,"async",Gt),xt(Jt,"filter",pt),Jt);e["default"]=ee,e.cast=Yt,e.Promise=F,e.EventTarget=kt,e.all=Y,e.allSettled=K,e.race=tt,e.hash=it,e.hashSettled=rt,e.rethrow=ot,e.defer=st,e.denodeify=V,e.configure=a,e.on=_t,e.off=Tt,e.resolve=ht,e.reject=ut,e.map=at,e.async=Gt,e.filter=pt,Object.defineProperty(e,"__esModule",{value:!0})})}).call(e,i(3),i(4).setImmediate,function(){return this}())},function(t,e){function i(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function r(t){if(c===setTimeout)return setTimeout(t,0);if((c===i||!c)&&setTimeout)return c=setTimeout,setTimeout(t,0);try{return c(t,0)}catch(e){try{return c.call(null,t,0)}catch(e){return c.call(this,t,0)}}}function o(t){if(l===clearTimeout)return clearTimeout(t);if((l===n||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function s(){g&&d&&(g=!1,d.length?f=d.concat(f):m=-1,f.length&&a())}function a(){if(!g){var t=r(s);g=!0;for(var e=f.length;e;){for(d=f,f=[];++m<e;)d&&d[m].run();m=-1,e=f.length}d=null,g=!1,o(t)}}function h(t,e){this.fun=t,this.array=e}function u(){}var c,l,p=t.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:i}catch(t){c=i}try{l="function"==typeof clearTimeout?clearTimeout:n}catch(t){l=n}}();var d,f=[],g=!1,m=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];f.push(new h(t,e)),1!==f.length||g||r(a)},h.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=u,p.addListener=u,p.once=u,p.off=u,p.removeListener=u,p.removeAllListeners=u,p.emit=u,p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(t,e,i){(function(t,n){function r(t,e){this._id=t,this._clearFn=e}var o=i(3).nextTick,s=Function.prototype.apply,a=Array.prototype.slice,h={},u=0;e.setTimeout=function(){return new r(s.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new r(s.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var i=u++,n=!(arguments.length<2)&&a.call(arguments,1);return h[i]=!0,o(function(){h[i]&&(n?t.apply(null,n):t.call(null),e.clearImmediate(i))}),i},e.clearImmediate="function"==typeof n?n:function(t){delete h[t]}}).call(e,i(4).setImmediate,i(4).clearImmediate)},function(t,e){},function(t,e,i){/*!
|
|
* URI.js - Mutating URLs
|
|
*
|
|
* Version: 1.18.1
|
|
*
|
|
* Author: Rodney Rehm
|
|
* Web: http://medialize.github.io/URI.js/
|
|
*
|
|
* Licensed under
|
|
* MIT License http://www.opensource.org/licenses/mit-license
|
|
*
|
|
*/
|
|
!function(e,n){"use strict";t.exports=n(i(7),i(9),i(10))}(this,function(t,e,i,n){"use strict";function r(t,e){var i=arguments.length>=1,n=arguments.length>=2;if(!(this instanceof r))return i?n?new r(t,e):new r(t):new r;if(void 0===t){if(i)throw new TypeError("undefined is not a valid argument for URI");t="undefined"!=typeof location?location.href+"":""}return this.href(t),void 0!==e?this.absoluteTo(e):this}function o(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function s(t){return void 0===t?"Undefined":String(Object.prototype.toString.call(t)).slice(8,-1)}function a(t){return"Array"===s(t)}function h(t,e){var i,n,r={};if("RegExp"===s(e))r=null;else if(a(e))for(i=0,n=e.length;i<n;i++)r[e[i]]=!0;else r[e]=!0;for(i=0,n=t.length;i<n;i++){var o=r&&void 0!==r[t[i]]||!r&&e.test(t[i]);o&&(t.splice(i,1),n--,i--)}return t}function u(t,e){var i,n;if(a(e)){for(i=0,n=e.length;i<n;i++)if(!u(t,e[i]))return!1;return!0}var r=s(e);for(i=0,n=t.length;i<n;i++)if("RegExp"===r){if("string"==typeof t[i]&&t[i].match(e))return!0}else if(t[i]===e)return!0;return!1}function c(t,e){if(!a(t)||!a(e))return!1;if(t.length!==e.length)return!1;t.sort(),e.sort();for(var i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function l(t){var e=/^\/+|\/+$/g;return t.replace(e,"")}function p(t){return escape(t)}function d(t){return encodeURIComponent(t).replace(/[!'()*]/g,p).replace(/\*/g,"%2A")}function f(t){return function(e,i){return void 0===e?this._parts[t]||"":(this._parts[t]=e||null,this.build(!i),this)}}function g(t,e){return function(i,n){return void 0===i?this._parts[t]||"":(null!==i&&(i+="",i.charAt(0)===e&&(i=i.substring(1))),this._parts[t]=i,this.build(!n),this)}}var m=n&&n.URI;r.version="1.18.1";var v=r.prototype,y=Object.prototype.hasOwnProperty;r._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:r.duplicateQueryParameters,escapeQuerySpace:r.escapeQuerySpace}},r.duplicateQueryParameters=!1,r.escapeQuerySpace=!0,r.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,r.idn_expression=/[^a-z0-9\.-]/i,r.punycode_expression=/(xn--)/i,r.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,r.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,r.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,r.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},r.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},r.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,r.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},r.getDomAttribute=function(t){if(t&&t.nodeName){var e=t.nodeName.toLowerCase();if("input"!==e||"image"===t.type)return r.domAttributes[e]}},r.encode=d,r.decode=decodeURIComponent,r.iso8859=function(){r.encode=escape,r.decode=unescape},r.unicode=function(){r.encode=d,r.decode=decodeURIComponent},r.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},r.encodeQuery=function(t,e){var i=r.encode(t+"");return void 0===e&&(e=r.escapeQuerySpace),e?i.replace(/%20/g,"+"):i},r.decodeQuery=function(t,e){t+="",void 0===e&&(e=r.escapeQuerySpace);try{return r.decode(e?t.replace(/\+/g,"%20"):t)}catch(i){return t}};var b,w={encode:"encode",decode:"decode"},x=function(t,e){return function(i){try{return r[e](i+"").replace(r.characters[t][e].expression,function(i){return r.characters[t][e].map[i]})}catch(n){return i}}};for(b in w)r[b+"PathSegment"]=x("pathname",w[b]),r[b+"UrnPathSegment"]=x("urnpath",w[b]);var _=function(t,e,i){return function(n){var o;o=i?function(t){return r[e](r[i](t))}:r[e];for(var s=(n+"").split(t),a=0,h=s.length;a<h;a++)s[a]=o(s[a]);return s.join(t)}};r.decodePath=_("/","decodePathSegment"),r.decodeUrnPath=_(":","decodeUrnPathSegment"),r.recodePath=_("/","encodePathSegment","decode"),r.recodeUrnPath=_(":","encodeUrnPathSegment","decode"),r.encodeReserved=x("reserved","encode"),r.parse=function(t,e){var i;return e||(e={}),i=t.indexOf("#"),i>-1&&(e.fragment=t.substring(i+1)||null,t=t.substring(0,i)),i=t.indexOf("?"),i>-1&&(e.query=t.substring(i+1)||null,t=t.substring(0,i)),"//"===t.substring(0,2)?(e.protocol=null,t=t.substring(2),t=r.parseAuthority(t,e)):(i=t.indexOf(":"),i>-1&&(e.protocol=t.substring(0,i)||null,e.protocol&&!e.protocol.match(r.protocol_expression)?e.protocol=void 0:"//"===t.substring(i+1,i+3)?(t=t.substring(i+3),t=r.parseAuthority(t,e)):(t=t.substring(i+1),e.urn=!0))),e.path=t,e},r.parseHost=function(t,e){t=t.replace(/\\/g,"/");var i,n,r=t.indexOf("/");if(r===-1&&(r=t.length),"["===t.charAt(0))i=t.indexOf("]"),e.hostname=t.substring(1,i)||null,e.port=t.substring(i+2,r)||null,"/"===e.port&&(e.port=null);else{var o=t.indexOf(":"),s=t.indexOf("/"),a=t.indexOf(":",o+1);a!==-1&&(s===-1||a<s)?(e.hostname=t.substring(0,r)||null,e.port=null):(n=t.substring(0,r).split(":"),e.hostname=n[0]||null,e.port=n[1]||null)}return e.hostname&&"/"!==t.substring(r).charAt(0)&&(r++,t="/"+t),t.substring(r)||"/"},r.parseAuthority=function(t,e){return t=r.parseUserinfo(t,e),r.parseHost(t,e)},r.parseUserinfo=function(t,e){var i,n=t.indexOf("/"),o=t.lastIndexOf("@",n>-1?n:t.length-1);return o>-1&&(n===-1||o<n)?(i=t.substring(0,o).split(":"),e.username=i[0]?r.decode(i[0]):null,i.shift(),e.password=i[0]?r.decode(i.join(":")):null,t=t.substring(o+1)):(e.username=null,e.password=null),t},r.parseQuery=function(t,e){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var i,n,o,s={},a=t.split("&"),h=a.length,u=0;u<h;u++)i=a[u].split("="),n=r.decodeQuery(i.shift(),e),o=i.length?r.decodeQuery(i.join("="),e):null,y.call(s,n)?("string"!=typeof s[n]&&null!==s[n]||(s[n]=[s[n]]),s[n].push(o)):s[n]=o;return s},r.build=function(t){var e="";return t.protocol&&(e+=t.protocol+":"),t.urn||!e&&!t.hostname||(e+="//"),e+=r.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&"string"==typeof t.hostname&&(e+="/"),e+=t.path),"string"==typeof t.query&&t.query&&(e+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(e+="#"+t.fragment),e},r.buildHost=function(t){var e="";return t.hostname?(e+=r.ip6_expression.test(t.hostname)?"["+t.hostname+"]":t.hostname,t.port&&(e+=":"+t.port),e):""},r.buildAuthority=function(t){return r.buildUserinfo(t)+r.buildHost(t)},r.buildUserinfo=function(t){var e="";return t.username&&(e+=r.encode(t.username)),t.password&&(e+=":"+r.encode(t.password)),e&&(e+="@"),e},r.buildQuery=function(t,e,i){var n,o,s,h,u="";for(o in t)if(y.call(t,o)&&o)if(a(t[o]))for(n={},s=0,h=t[o].length;s<h;s++)void 0!==t[o][s]&&void 0===n[t[o][s]+""]&&(u+="&"+r.buildQueryParameter(o,t[o][s],i),e!==!0&&(n[t[o][s]+""]=!0));else void 0!==t[o]&&(u+="&"+r.buildQueryParameter(o,t[o],i));return u.substring(1)},r.buildQueryParameter=function(t,e,i){return r.encodeQuery(t,i)+(null!==e?"="+r.encodeQuery(e,i):"")},r.addQuery=function(t,e,i){if("object"==typeof e)for(var n in e)y.call(e,n)&&r.addQuery(t,n,e[n]);else{if("string"!=typeof e)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===t[e])return void(t[e]=i);"string"==typeof t[e]&&(t[e]=[t[e]]),a(i)||(i=[i]),t[e]=(t[e]||[]).concat(i)}},r.removeQuery=function(t,e,i){var n,o,u;if(a(e))for(n=0,o=e.length;n<o;n++)t[e[n]]=void 0;else if("RegExp"===s(e))for(u in t)e.test(u)&&(t[u]=void 0);else if("object"==typeof e)for(u in e)y.call(e,u)&&r.removeQuery(t,u,e[u]);else{if("string"!=typeof e)throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");void 0!==i?"RegExp"===s(i)?!a(t[e])&&i.test(t[e])?t[e]=void 0:t[e]=h(t[e],i):t[e]!==String(i)||a(i)&&1!==i.length?a(t[e])&&(t[e]=h(t[e],i)):t[e]=void 0:t[e]=void 0}},r.hasQuery=function(t,e,i,n){switch(s(e)){case"String":break;case"RegExp":for(var o in t)if(y.call(t,o)&&e.test(o)&&(void 0===i||r.hasQuery(t,o,i)))return!0;return!1;case"Object":for(var h in e)if(y.call(e,h)&&!r.hasQuery(t,h,e[h]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter")}switch(s(i)){case"Undefined":return e in t;case"Boolean":var l=Boolean(a(t[e])?t[e].length:t[e]);return i===l;case"Function":return!!i(t[e],e,t);case"Array":if(!a(t[e]))return!1;var p=n?u:c;return p(t[e],i);case"RegExp":return a(t[e])?!!n&&u(t[e],i):Boolean(t[e]&&t[e].match(i));case"Number":i=String(i);case"String":return a(t[e])?!!n&&u(t[e],i):t[e]===i;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},r.joinPaths=function(){for(var t=[],e=[],i=0,n=0;n<arguments.length;n++){var o=new r(arguments[n]);t.push(o);for(var s=o.segment(),a=0;a<s.length;a++)"string"==typeof s[a]&&e.push(s[a]),s[a]&&i++}if(!e.length||!i)return new r("");var h=new r("").segment(e);return""!==t[0].path()&&"/"!==t[0].path().slice(0,1)||h.path("/"+h.path()),h.normalize()},r.commonPath=function(t,e){var i,n=Math.min(t.length,e.length);for(i=0;i<n;i++)if(t.charAt(i)!==e.charAt(i)){i--;break}return i<1?t.charAt(0)===e.charAt(0)&&"/"===t.charAt(0)?"/":"":("/"===t.charAt(i)&&"/"===e.charAt(i)||(i=t.substring(0,i).lastIndexOf("/")),t.substring(0,i+1))},r.withinString=function(t,e,i){i||(i={});var n=i.start||r.findUri.start,o=i.end||r.findUri.end,s=i.trim||r.findUri.trim,a=/[a-z0-9-]=["']?$/i;for(n.lastIndex=0;;){var h=n.exec(t);if(!h)break;var u=h.index;if(i.ignoreHtml){var c=t.slice(Math.max(u-3,0),u);if(c&&a.test(c))continue}var l=u+t.slice(u).search(o),p=t.slice(u,l).replace(s,"");if(!i.ignore||!i.ignore.test(p)){l=u+p.length;var d=e(p,u,l,t);t=t.slice(0,u)+d+t.slice(l),n.lastIndex=u+d.length}}return n.lastIndex=0,t},r.ensureValidHostname=function(e){if(e.match(r.invalid_hostname_characters)){if(!t)throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(t.toASCII(e).match(r.invalid_hostname_characters))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]')}},r.noConflict=function(t){if(t){var e={URI:this.noConflict()};return n.URITemplate&&"function"==typeof n.URITemplate.noConflict&&(e.URITemplate=n.URITemplate.noConflict()),n.IPv6&&"function"==typeof n.IPv6.noConflict&&(e.IPv6=n.IPv6.noConflict()),n.SecondLevelDomains&&"function"==typeof n.SecondLevelDomains.noConflict&&(e.SecondLevelDomains=n.SecondLevelDomains.noConflict()),e}return n.URI===this&&(n.URI=m),this},v.build=function(t){return t===!0?this._deferred_build=!0:(void 0===t||this._deferred_build)&&(this._string=r.build(this._parts),this._deferred_build=!1),this},v.clone=function(){return new r(this)},v.valueOf=v.toString=function(){return this.build(!1)._string},v.protocol=f("protocol"),v.username=f("username"),v.password=f("password"),v.hostname=f("hostname"),v.port=f("port"),v.query=g("query","?"),v.fragment=g("fragment","#"),v.search=function(t,e){var i=this.query(t,e);return"string"==typeof i&&i.length?"?"+i:i},v.hash=function(t,e){var i=this.fragment(t,e);return"string"==typeof i&&i.length?"#"+i:i},v.pathname=function(t,e){if(void 0===t||t===!0){var i=this._parts.path||(this._parts.hostname?"/":"");return t?(this._parts.urn?r.decodeUrnPath:r.decodePath)(i):i}return this._parts.urn?this._parts.path=t?r.recodeUrnPath(t):"":this._parts.path=t?r.recodePath(t):"/",this.build(!e),this},v.path=v.pathname,v.href=function(t,e){var i;if(void 0===t)return this.toString();this._string="",this._parts=r._parts();var n=t instanceof r,o="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName){var s=r.getDomAttribute(t);t=t[s]||"",o=!1}if(!n&&o&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t||t instanceof String)this._parts=r.parse(String(t),this._parts);else{if(!n&&!o)throw new TypeError("invalid input");var a=n?t._parts:t;for(i in a)y.call(this._parts,i)&&(this._parts[i]=a[i])}return this.build(!e),this},v.is=function(t){var e=!1,n=!1,o=!1,s=!1,a=!1,h=!1,u=!1,c=!this._parts.urn;switch(this._parts.hostname&&(c=!1,n=r.ip4_expression.test(this._parts.hostname),o=r.ip6_expression.test(this._parts.hostname),e=n||o,s=!e,a=s&&i&&i.has(this._parts.hostname),h=s&&r.idn_expression.test(this._parts.hostname),u=s&&r.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return c;case"absolute":return!c;case"domain":case"name":return s;case"sld":return a;case"ip":return e;case"ip4":case"ipv4":case"inet4":return n;case"ip6":case"ipv6":case"inet6":return o;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return u}return null};var T=v.protocol,k=v.port,S=v.hostname;v.protocol=function(t,e){if(void 0!==t&&t&&(t=t.replace(/:(\/\/)?$/,""),!t.match(r.protocol_expression)))throw new TypeError('Protocol "'+t+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return T.call(this,t,e)},v.scheme=v.protocol,v.port=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t&&(0===t&&(t=null),t&&(t+="",":"===t.charAt(0)&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError('Port "'+t+'" contains characters other than [0-9]');return k.call(this,t,e)},v.hostname=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t){var i={},n=r.parseHost(t,i);if("/"!==n)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');t=i.hostname}return S.call(this,t,e)},v.origin=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var i=this.protocol(),n=this.authority();return n?(i?i+"://":"")+this.authority():""}var o=r(t);return this.protocol(o.protocol()).authority(o.authority()).build(!e),this},v.host=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?r.buildHost(this._parts):"";var i=r.parseHost(t,this._parts);if("/"!==i)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!e),this},v.authority=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?r.buildAuthority(this._parts):"";var i=r.parseAuthority(t,this._parts);if("/"!==i)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!e),this},v.userinfo=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var i=r.buildUserinfo(this._parts);return i?i.substring(0,i.length-1):i}return"@"!==t[t.length-1]&&(t+="@"),r.parseUserinfo(t,this._parts),this.build(!e),this},v.resource=function(t,e){var i;return void 0===t?this.path()+this.search()+this.hash():(i=r.parse(t),this._parts.path=i.path,this._parts.query=i.query,this._parts.fragment=i.fragment,this.build(!e),this)},v.subdomain=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var i=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,i)||""}var n=this._parts.hostname.length-this.domain().length,s=this._parts.hostname.substring(0,n),a=new RegExp("^"+o(s));return t&&"."!==t.charAt(t.length-1)&&(t+="."),t&&r.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(a,t),this.build(!e),this},v.domain=function(t,e){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(e=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var i=this._parts.hostname.match(/\./g);if(i&&i.length<2)return this._parts.hostname;var n=this._parts.hostname.length-this.tld(e).length-1;return n=this._parts.hostname.lastIndexOf(".",n-1)+1,this._parts.hostname.substring(n)||""}if(!t)throw new TypeError("cannot set domain empty");if(r.ensureValidHostname(t),!this._parts.hostname||this.is("IP"))this._parts.hostname=t;else{var s=new RegExp(o(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(s,t)}return this.build(!e),this},v.tld=function(t,e){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(e=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var n=this._parts.hostname.lastIndexOf("."),r=this._parts.hostname.substring(n+1);return e!==!0&&i&&i.list[r.toLowerCase()]?i.get(this._parts.hostname)||r:r}var s;if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/)){if(!i||!i.is(t))throw new TypeError('TLD "'+t+'" contains characters other than [A-Z0-9]');s=new RegExp(o(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(s,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");s=new RegExp(o(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(s,t)}return this.build(!e),this},v.directory=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var i=this._parts.path.length-this.filename().length-1,n=this._parts.path.substring(0,i)||(this._parts.hostname?"/":"");return t?r.decodePath(n):n}var s=this._parts.path.length-this.filename().length,a=this._parts.path.substring(0,s),h=new RegExp("^"+o(a));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=r.recodePath(t),this._parts.path=this._parts.path.replace(h,t),this.build(!e),this},v.filename=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var i=this._parts.path.lastIndexOf("/"),n=this._parts.path.substring(i+1);return t?r.decodePathSegment(n):n}var s=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(s=!0);var a=new RegExp(o(this.filename())+"$");return t=r.recodePath(t),this._parts.path=this._parts.path.replace(a,t),s?this.normalizePath(e):this.build(!e),this},v.suffix=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var i,n,s=this.filename(),a=s.lastIndexOf(".");return a===-1?"":(i=s.substring(a+1),n=/^[a-z0-9%]+$/i.test(i)?i:"",t?r.decodePathSegment(n):n)}"."===t.charAt(0)&&(t=t.substring(1));var h,u=this.suffix();if(u)h=t?new RegExp(o(u)+"$"):new RegExp(o("."+u)+"$");else{if(!t)return this;this._parts.path+="."+r.recodePath(t)}return h&&(t=r.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!e),this},v.segment=function(t,e,i){var n=this._parts.urn?":":"/",r=this.path(),o="/"===r.substring(0,1),s=r.split(n);if(void 0!==t&&"number"!=typeof t&&(i=e,e=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error('Bad segment "'+t+'", must be 0-based integer');if(o&&s.shift(),t<0&&(t=Math.max(s.length+t,0)),void 0===e)return void 0===t?s:s[t];if(null===t||void 0===s[t])if(a(e)){s=[];for(var h=0,u=e.length;h<u;h++)(e[h].length||s.length&&s[s.length-1].length)&&(s.length&&!s[s.length-1].length&&s.pop(),s.push(l(e[h])))}else(e||"string"==typeof e)&&(e=l(e),""===s[s.length-1]?s[s.length-1]=e:s.push(e));else e?s[t]=l(e):s.splice(t,1);return o&&s.unshift(""),this.path(s.join(n),i)},v.segmentCoded=function(t,e,i){var n,o,s;if("number"!=typeof t&&(i=e,e=t,t=void 0),void 0===e){if(n=this.segment(t,e,i),a(n))for(o=0,s=n.length;o<s;o++)n[o]=r.decode(n[o]);else n=void 0!==n?r.decode(n):void 0;return n}if(a(e))for(o=0,s=e.length;o<s;o++)e[o]=r.encode(e[o]);else e="string"==typeof e||e instanceof String?r.encode(e):e;return this.segment(t,e,i)};var E=v.query;return v.query=function(t,e){if(t===!0)return r.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var i=r.parseQuery(this._parts.query,this._parts.escapeQuerySpace),n=t.call(this,i);return this._parts.query=r.buildQuery(n||i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=r.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this):E.call(this,t,e)},v.setQuery=function(t,e,i){var n=r.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"==typeof t||t instanceof String)n[t]=void 0!==e?e:null;else{if("object"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");for(var o in t)y.call(t,o)&&(n[o]=t[o])}return this._parts.query=r.buildQuery(n,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(i=e),this.build(!i),this},v.addQuery=function(t,e,i){var n=r.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return r.addQuery(n,t,void 0===e?null:e),this._parts.query=r.buildQuery(n,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(i=e),this.build(!i),this},v.removeQuery=function(t,e,i){var n=r.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return r.removeQuery(n,t,e),this._parts.query=r.buildQuery(n,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(i=e),this.build(!i),this},v.hasQuery=function(t,e,i){var n=r.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return r.hasQuery(n,t,e,i)},v.setSearch=v.setQuery,v.addSearch=v.addQuery,v.removeSearch=v.removeQuery,v.hasSearch=v.hasQuery,v.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},v.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},v.normalizeHostname=function(i){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&e&&(this._parts.hostname=e.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!i)),this},v.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===r.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},v.normalizePath=function(t){var e=this._parts.path;if(!e)return this;if(this._parts.urn)return this._parts.path=r.recodeUrnPath(this._parts.path),this.build(!t),this;if("/"===this._parts.path)return this;e=r.recodePath(e);var i,n,o,s="";for("/"!==e.charAt(0)&&(i=!0,e="/"+e),"/.."!==e.slice(-3)&&"/."!==e.slice(-2)||(e+="/"),e=e.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),i&&(s=e.substring(1).match(/^(\.\.\/)+/)||"",s&&(s=s[0]));;){if(n=e.search(/\/\.\.(\/|$)/),n===-1)break;0!==n?(o=e.substring(0,n).lastIndexOf("/"),o===-1&&(o=n),e=e.substring(0,o)+e.substring(n+3)):e=e.substring(3)}return i&&this.is("relative")&&(e=s+e.substring(1)),this._parts.path=e,this.build(!t),this},v.normalizePathname=v.normalizePath,v.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(r.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},v.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},v.normalizeSearch=v.normalizeQuery,v.normalizeHash=v.normalizeFragment,v.iso8859=function(){var t=r.encode,e=r.decode;r.encode=escape,r.decode=decodeURIComponent;try{this.normalize()}finally{r.encode=t,r.decode=e}return this},v.unicode=function(){var t=r.encode,e=r.decode;r.encode=d,r.decode=unescape;try{this.normalize()}finally{r.encode=t,r.decode=e}return this},v.readable=function(){var e=this.clone();e.username("").password("").normalize();var i="";if(e._parts.protocol&&(i+=e._parts.protocol+"://"),e._parts.hostname&&(e.is("punycode")&&t?(i+=t.toUnicode(e._parts.hostname),e._parts.port&&(i+=":"+e._parts.port)):i+=e.host()),e._parts.hostname&&e._parts.path&&"/"!==e._parts.path.charAt(0)&&(i+="/"),i+=e.path(!0),e._parts.query){for(var n="",o=0,s=e._parts.query.split("&"),a=s.length;o<a;o++){var h=(s[o]||"").split("=");n+="&"+r.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==h[1]&&(n+="="+r.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}i+="?"+n.substring(1)}return i+=r.decodeQuery(e.hash(),!0)},v.absoluteTo=function(t){var e,i,n,o=this.clone(),s=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof r||(t=new r(t)),o._parts.protocol||(o._parts.protocol=t._parts.protocol),this._parts.hostname)return o;for(i=0;n=s[i];i++)o._parts[n]=t._parts[n];return o._parts.path?".."===o._parts.path.substring(-2)&&(o._parts.path+="/"):(o._parts.path=t._parts.path,o._parts.query||(o._parts.query=t._parts.query)),"/"!==o.path().charAt(0)&&(e=t.directory(),e=e?e:0===t.path().indexOf("/")?"/":"",o._parts.path=(e?e+"/":"")+o._parts.path,o.normalizePath()),o.build(),o},v.relativeTo=function(t){var e,i,n,o,s,a=this.clone().normalize();if(a._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new r(t).normalize(),e=a._parts,i=t._parts,o=a.path(),s=t.path(),"/"!==o.charAt(0))throw new Error("URI is already relative");if("/"!==s.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(e.protocol===i.protocol&&(e.protocol=null),e.username!==i.username||e.password!==i.password)return a.build();if(null!==e.protocol||null!==e.username||null!==e.password)return a.build();if(e.hostname!==i.hostname||e.port!==i.port)return a.build();if(e.hostname=null,e.port=null,o===s)return e.path="",a.build();if(n=r.commonPath(o,s),!n)return a.build();var h=i.path.substring(n.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return e.path=h+e.path.substring(n.length)||"./",a.build()},v.equals=function(t){var e,i,n,o=this.clone(),s=new r(t),h={},u={},l={};if(o.normalize(),s.normalize(),o.toString()===s.toString())return!0;if(e=o.query(),i=s.query(),o.query(""),s.query(""),o.toString()!==s.toString())return!1;if(e.length!==i.length)return!1;h=r.parseQuery(e,this._parts.escapeQuerySpace),u=r.parseQuery(i,this._parts.escapeQuerySpace);for(n in h)if(y.call(h,n)){if(a(h[n])){if(!c(h[n],u[n]))return!1}else if(h[n]!==u[n])return!1;l[n]=!0}for(n in u)if(y.call(u,n)&&!l[n])return!1;return!0},v.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},v.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},r})},function(t,e,i){var n;(function(t,r){!function(o){function s(t){throw new RangeError(L[t])}function a(t,e){for(var i=t.length,n=[];i--;)n[i]=e(t[i]);return n}function h(t,e){var i=t.split("@"),n="";i.length>1&&(n=i[0]+"@",t=i[1]),t=t.replace(N,".");var r=t.split("."),o=a(r,e).join(".");return n+o}function u(t){for(var e,i,n=[],r=0,o=t.length;r<o;)e=t.charCodeAt(r++),e>=55296&&e<=56319&&r<o?(i=t.charCodeAt(r++),56320==(64512&i)?n.push(((1023&e)<<10)+(1023&i)+65536):(n.push(e),r--)):n.push(e);return n}function c(t){return a(t,function(t){var e="";return t>65535&&(t-=65536,e+=j(t>>>10&1023|55296),t=56320|1023&t),e+=j(t)}).join("")}function l(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:x}function p(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function d(t,e,i){var n=0;for(t=i?P(t/S):t>>1,t+=P(t/e);t>R*T>>1;n+=x)t=P(t/R);return P(n+(R+1)*t/(t+k))}function f(t){var e,i,n,r,o,a,h,u,p,f,g=[],m=t.length,v=0,y=z,b=E;for(i=t.lastIndexOf(C),i<0&&(i=0),n=0;n<i;++n)t.charCodeAt(n)>=128&&s("not-basic"),g.push(t.charCodeAt(n));for(r=i>0?i+1:0;r<m;){for(o=v,a=1,h=x;r>=m&&s("invalid-input"),u=l(t.charCodeAt(r++)),(u>=x||u>P((w-v)/a))&&s("overflow"),v+=u*a,p=h<=b?_:h>=b+T?T:h-b,!(u<p);h+=x)f=x-p,a>P(w/f)&&s("overflow"),a*=f;e=g.length+1,b=d(v-o,e,0==o),P(v/e)>w-y&&s("overflow"),y+=P(v/e),v%=e,g.splice(v++,0,y)}return c(g)}function g(t){var e,i,n,r,o,a,h,c,l,f,g,m,v,y,b,k=[];for(t=u(t),m=t.length,e=z,i=0,o=E,a=0;a<m;++a)g=t[a],g<128&&k.push(j(g));for(n=r=k.length,r&&k.push(C);n<m;){for(h=w,a=0;a<m;++a)g=t[a],g>=e&&g<h&&(h=g);for(v=n+1,h-e>P((w-i)/v)&&s("overflow"),i+=(h-e)*v,e=h,a=0;a<m;++a)if(g=t[a],g<e&&++i>w&&s("overflow"),g==e){for(c=i,l=x;f=l<=o?_:l>=o+T?T:l-o,!(c<f);l+=x)b=c-f,y=x-f,k.push(j(p(f+b%y,0))),c=P(b/y);k.push(j(p(c,0))),o=d(i,v,n==r),i=0,++n}++i,++e}return k.join("")}function m(t){return h(t,function(t){return A.test(t)?f(t.slice(4).toLowerCase()):t})}function v(t){return h(t,function(t){return q.test(t)?"xn--"+g(t):t})}var y=("object"==typeof e&&e&&!e.nodeType&&e,"object"==typeof t&&t&&!t.nodeType&&t,"object"==typeof r&&r);y.global!==y&&y.window!==y&&y.self!==y||(o=y);var b,w=2147483647,x=36,_=1,T=26,k=38,S=700,E=72,z=128,C="-",A=/^xn--/,q=/[^\x20-\x7E]/,N=/[\x2E\u3002\uFF0E\uFF61]/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=x-_,P=Math.floor,j=String.fromCharCode;b={version:"1.3.2",ucs2:{decode:u,encode:c},decode:f,encode:g,toASCII:v,toUnicode:m},n=function(){return b}.call(e,i,e,t),!(void 0!==n&&(t.exports=n))}(this)}).call(e,i(8)(t),function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,i){/*!
|
|
* URI.js - Mutating URLs
|
|
* IPv6 Support
|
|
*
|
|
* Version: 1.18.1
|
|
*
|
|
* Author: Rodney Rehm
|
|
* Web: http://medialize.github.io/URI.js/
|
|
*
|
|
* Licensed under
|
|
* MIT License http://www.opensource.org/licenses/mit-license
|
|
*
|
|
*/
|
|
!function(e,i){"use strict";t.exports=i()}(this,function(t){"use strict";function e(t){var e=t.toLowerCase(),i=e.split(":"),n=i.length,r=8;""===i[0]&&""===i[1]&&""===i[2]?(i.shift(),i.shift()):""===i[0]&&""===i[1]?i.shift():""===i[n-1]&&""===i[n-2]&&i.pop(),n=i.length,i[n-1].indexOf(".")!==-1&&(r=7);var o;for(o=0;o<n&&""!==i[o];o++);if(o<r)for(i.splice(o,1,"0000");i.length<r;)i.splice(o,0,"0000");for(var s,a=0;a<r;a++){s=i[a].split("");for(var h=0;h<3&&("0"===s[0]&&s.length>1);h++)s.splice(0,1);i[a]=s.join("")}var u=-1,c=0,l=0,p=-1,d=!1;for(a=0;a<r;a++)d?"0"===i[a]?l+=1:(d=!1,l>c&&(u=p,c=l)):"0"===i[a]&&(d=!0,p=a,l=1);l>c&&(u=p,c=l),c>1&&i.splice(u,c,""),n=i.length;var f="";for(""===i[0]&&(f=":"),a=0;a<n&&(f+=i[a],a!==n-1);a++)f+=":";return""===i[n-1]&&(f+=":"),f}function i(){return t.IPv6===this&&(t.IPv6=n),this}var n=t&&t.IPv6;return{best:e,noConflict:i}})},function(t,e,i){/*!
|
|
* URI.js - Mutating URLs
|
|
* Second Level Domain (SLD) Support
|
|
*
|
|
* Version: 1.18.1
|
|
*
|
|
* Author: Rodney Rehm
|
|
* Web: http://medialize.github.io/URI.js/
|
|
*
|
|
* Licensed under
|
|
* MIT License http://www.opensource.org/licenses/mit-license
|
|
*
|
|
*/
|
|
!function(e,i){"use strict";t.exports=i()}(this,function(t){"use strict";var e=t&&t.SecondLevelDomains,i={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;var n=t.lastIndexOf(".",e-1);if(n<=0||n>=e-1)return!1;var r=i.list[t.slice(e+1)];return!!r&&r.indexOf(" "+t.slice(n+1,e)+" ")>=0},is:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;var n=t.lastIndexOf(".",e-1);if(n>=0)return!1;var r=i.list[t.slice(e+1)];return!!r&&r.indexOf(" "+t.slice(0,e)+" ")>=0},get:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return null;var n=t.lastIndexOf(".",e-1);if(n<=0||n>=e-1)return null;var r=i.list[t.slice(e+1)];return r?r.indexOf(" "+t.slice(n+1,e)+" ")<0?null:t.slice(n+1):null},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=e),this}};return i})},function(t,e,i){function n(t){return!(!t||1!=t.nodeType)}function r(){var t=(new Date).getTime(),e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:7&i|8).toString(16)});return e}function o(t){for(var e=-1,i=Object.keys(t),n=i.length,r=Array(n);++e<n;)r[e]=t[i[e]];return r}function s(t,e){var i,n=[],r=[],o=uri(t),s=uri(e),a=o.directory,h=s.directory,u=[];return"/"===a[0]&&(a=a.substring(1)),"/"===h[h.length-1]&&(a=a.substring(0,a.length-1)),"/"===h[0]&&(h=h.substring(1)),"/"===h[h.length-1]&&(h=h.substring(0,h.length-1)),a&&(u=a.split("/")),i=h.split("/"),i.reverse().forEach(function(t,e){".."===t?u.pop():t===u[u.length-1]?(u.pop(),r.unshift(t)):r.unshift(t)}),n=[o.origin],u.length&&(n=n.concat(u)),r&&(n=n.concat(r)),n=n.concat(s.filename),n.join("/")}function a(){return Math.max(document.documentElement.clientHeight,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight)}function h(t){return!isNaN(parseFloat(t))&&isFinite(t)}function u(t){var e=["Webkit","Moz","O","ms"],i=t[0].toUpperCase()+t.slice(1),n=e.length;if("undefined"==typeof document||"undefined"!=typeof document.body.style[t])return t;for(var r=0;r<n;r++)if("undefined"!=typeof document.body.style[e[r]+i])return e[r]+i;return t}function c(t){for(var e=1,i=arguments.length;e<i;e++){var n=arguments[e];for(var r in n)void 0===t[r]&&(t[r]=n[r])}return t}function l(t){var e=[].slice.call(arguments,1);return e.forEach(function(e){e&&Object.getOwnPropertyNames(e).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}),t}function p(t,e,i){var n=d(t,e,i);return e.splice(n,0,t),n}function d(t,e,i,n,r){var o,s=n||0,a=r||e.length,h=parseInt(s+(a-s)/2);return i||(i=function(t,e){return t>e?1:t<e?-1:(t=e)?0:void 0}),a-s<=0?h:(o=i(e[h],t),a-s===1?o>0?h:h+1:0===o?h:o===-1?d(t,e,i,h,a):d(t,e,i,s,h))}function f(t,e,i,n,r){var o,s=n||0,a=r||e.length,h=parseInt(s+(a-s)/2);return i||(i=function(t,e){return t>e?1:t<e?-1:(t=e)?0:void 0}),a-s<=0?-1:(o=i(e[h],t),a-s===1?0===o?h:-1:0===o?h:o===-1?f(t,e,i,h,a):f(t,e,i,s,h))}function g(t){var e=window.getComputedStyle(t),i=["width","paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"],n=["height","paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"],r=0,o=0;return i.forEach(function(t){r+=parseFloat(e[t])||0}),n.forEach(function(t){o+=parseFloat(e[t])||0}),{height:o,width:r}}function m(t){var e=window.getComputedStyle(t),i=["paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"],n=["paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"],r=0,o=0;return i.forEach(function(t){r+=parseFloat(e[t])||0}),n.forEach(function(t){o+=parseFloat(e[t])||0}),{height:o,width:r}}function v(){var t=window.innerWidth,e=window.innerHeight;return{top:0,left:0,right:t,bottom:e,width:t,height:e}}function y(t){var e=t.match(/[^'"]+|['"]/g);return e=e.map(function(t){return"'"===t?'"\'"':'"'===t?"'\"'":"'"+t+"'"}),"concat('',"+e.join(",")+")"}function b(t){for(var e,i=t.parentNode,n=i.childNodes,r=-1,o=0;o<n.length&&(e=n[o],e.nodeType===Node.TEXT_NODE&&r++,e!=t);o++);return r}function w(t){return["xml","opf","ncx"].indexOf(t)>-1}function x(t,e){var i=new Blob([t],{type:e});return i}function _(t,e){var i,n=window.URL||window.webkitURL||window.mozURL,r=this.createBlob(t,e);return i=n.createObjectURL(r)}function T(t,e){var i,n;if("string"==typeof t)return i=btoa(t),n="data:"+e+";base64,"+i}function k(t){return Object.prototype.toString.call(t).slice(8,-1)}function S(t,e){var n;return"undefined"==typeof DOMParser&&(DOMParser=i(13).DOMParser),n=(new DOMParser).parseFromString(t,e)}function E(t,e){var i;return"undefined"!=typeof t.querySelector?t.querySelector(e):(i=t.getElementsByTagName(e),i.length?i[0]:void 0)}function z(t,e){return"undefined"!=typeof t.querySelector?t.querySelectorAll(e):t.getElementsByTagName(e)}function C(t,e,i){var n,r;if("undefined"!=typeof t.querySelector){e+="[";for(var o in i)e+=o+"='"+i[o]+"'";return e+="]",t.querySelector(e)}if(n=t.getElementsByTagName(e),r=Array.prototype.slice.call(n,0).filter(function(t){for(var e in i)if(t.getAttribute(e)===i[e])return!0;return!1}))return r[0]}function A(t,e){var i=new FileReader;i.readAsDataURL(t),i.onloadend=function(){e(i.result)}}var q=(i(2),i(12),"undefined"!=typeof window&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame));t.exports={isElement:n,uuid:r,values:o,resolveUrl:s,indexOfSorted:f,documentHeight:a,isNumber:h,prefixed:u,defaults:c,extend:l,insert:p,locationOf:d,indexOfSorted:f,requestAnimationFrame:q,bounds:g,borders:m,windowBounds:v,cleanStringForXpath:y,indexOfTextNode:b,isXml:w,createBlob:x,createBlobUrl:_,type:k,parse:S,qs:E,qsa:z,qsp:C,blob2base64:A,createBase64Url:T}},function(t,e){"use strict";function i(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function n(t){return 3*t.length/4-i(t)}function r(t){var e,n,r,o,s,a,h=t.length;s=i(t),a=new c(3*h/4-s),r=s>0?h-4:h;var l=0;for(e=0,n=0;e<r;e+=4,n+=3)o=u[t.charCodeAt(e)]<<18|u[t.charCodeAt(e+1)]<<12|u[t.charCodeAt(e+2)]<<6|u[t.charCodeAt(e+3)],a[l++]=o>>16&255,a[l++]=o>>8&255,a[l++]=255&o;return 2===s?(o=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,a[l++]=255&o):1===s&&(o=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,a[l++]=o>>8&255,a[l++]=255&o),a}function o(t){return h[t>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}function s(t,e,i){for(var n,r=[],s=e;s<i;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],r.push(o(n));return r.join("")}function a(t){for(var e,i=t.length,n=i%3,r="",o=[],a=16383,u=0,c=i-n;u<c;u+=a)o.push(s(t,u,u+a>c?c:u+a));return 1===n?(e=t[i-1],r+=h[e>>2],r+=h[e<<4&63],r+="=="):2===n&&(e=(t[i-2]<<8)+t[i-1],r+=h[e>>10],r+=h[e>>4&63],r+=h[e<<2&63],r+="="),o.push(r),o.join("")}e.byteLength=n,e.toByteArray=r,e.fromByteArray=a;for(var h=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=l.length;p<d;++p)h[p]=l[p],u[l.charCodeAt(p)]=p;u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63},function(e,i){e.exports=t},function(t,e,i){function n(t){this.request=t,this.spineItems=[],this.spineByHref={},this.spineById={},this.hooks={},this.hooks.serialize=new o,this.hooks.content=new o,this.hooks.content.register(a.base),this.hooks.content.register(a.canonical),this.epubcfi=new r,this.loaded=!1}var r=(i(2),i(11),i(15)),o=i(16),s=i(17),a=i(19);n.prototype.load=function(t){this.items=t.spine,this.manifest=t.manifest,this.spineNodeIndex=t.spineNodeIndex,this.baseUrl=t.baseUrl||"",this.length=this.items.length,this.items.forEach(function(t,e){var i,n=this.manifest[t.idref];t.cfiBase=this.epubcfi.generateChapterComponent(this.spineNodeIndex,t.index,t.idref),n&&(t.href=n.href,t.url=this.baseUrl+t.href,n.properties.length&&t.properties.push.apply(t.properties,n.properties)),t.prev=function(){return this.get(e-1)}.bind(this),t.next=function(){return this.get(e+1)}.bind(this),i=new s(t,this.hooks),this.append(i)}.bind(this)),this.loaded=!0},n.prototype.get=function(t){var e=0;return this.epubcfi.isCfiString(t)?(cfi=new r(t),e=cfi.spinePos):!t||"number"!=typeof t&&isNaN(t)!==!1?t&&0===t.indexOf("#")?e=this.spineById[t.substring(1)]:t&&(t=t.split("#")[0],e=this.spineByHref[t]):e=t,this.spineItems[e]||null},n.prototype.append=function(t){var e=this.spineItems.length;return t.index=e,this.spineItems.push(t),this.spineByHref[t.href]=e,this.spineById[t.idref]=e,e},n.prototype.prepend=function(t){this.spineItems.unshift(t);return this.spineByHref[t.href]=0,this.spineById[t.idref]=0,this.spineItems.forEach(function(t,e){t.index=e}),0},n.prototype.insert=function(t,e){},n.prototype.remove=function(t){var e=this.spineItems.indexOf(t);if(e>-1)return delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(e,1)},n.prototype.each=function(){return this.spineItems.forEach.apply(this.spineItems,arguments)},t.exports=n},function(t,e,i){function n(t,e,i){var o;if(this.str="",this.base={},this.spinePos=0,this.range=!1,this.path={},this.start=null,this.end=null,!(this instanceof n))return new n(t,e,i);if("string"==typeof e?this.base=this.parseComponent(e):"object"==typeof e&&e.steps&&(this.base=e),o=this.checkType(t),"string"===o)return this.str=t,r.extend(this,this.parse(t));if("range"===o)return r.extend(this,this.fromRange(t,this.base,i));if("node"===o)return r.extend(this,this.fromNode(t,this.base,i));if("EpubCFI"===o&&t.path)return t;if(t)throw new TypeError("not a valid argument for EpubCFI");return this}var r=(i(6),i(11));n.prototype.checkType=function(t){return this.isCfiString(t)?"string":"object"==typeof t&&"Range"===r.type(t)?"range":"object"==typeof t&&"undefined"!=typeof t.nodeType?"node":"object"==typeof t&&t instanceof n&&"EpubCFI"},n.prototype.parse=function(t){var e,i,n,r={spinePos:-1,range:!1,base:{},path:{},start:null,end:null};return"string"!=typeof t?{spinePos:-1}:(0===t.indexOf("epubcfi(")&&")"===t[t.length-1]&&(t=t.slice(8,t.length-1)),(e=this.getChapterComponent(t))?(r.base=this.parseComponent(e),i=this.getPathComponent(t),r.path=this.parseComponent(i),n=this.getRange(t),n&&(r.range=!0,r.start=this.parseComponent(n[0]),r.end=this.parseComponent(n[1])),r.spinePos=r.base.steps[1].index,r):{spinePos:-1})},n.prototype.parseComponent=function(t){var e,i={steps:[],terminal:{offset:null,assertion:null}},n=t.split(":"),r=n[0].split("/");return n.length>1&&(e=n[1],i.terminal=this.parseTerminal(e)),""===r[0]&&r.shift(),i.steps=r.map(function(t){return this.parseStep(t)}.bind(this)),i},n.prototype.parseStep=function(t){var e,i,n,r,o;if(r=t.match(/\[(.*)\]/),r&&r[1]&&(o=r[1]),i=parseInt(t),!isNaN(i))return i%2===0?(e="element",n=i/2-1):(e="text",n=(i-1)/2),{type:e,index:n,id:o||null}},n.prototype.parseTerminal=function(t){var e,i,n=t.match(/\[(.*)\]/);return n&&n[1]?(e=parseInt(t.split("[")[0])||null,i=n[1]):e=parseInt(t)||null,{offset:e,assertion:i}},n.prototype.getChapterComponent=function(t){var e=t.split("!");return e[0]},n.prototype.getPathComponent=function(t){var e=t.split("!");if(e[1])return ranges=e[1].split(","),ranges[0]},n.prototype.getRange=function(t){var e=t.split(",");return 3===e.length&&[e[1],e[2]]},n.prototype.getCharecterOffsetComponent=function(t){var e=t.split(":");return e[1]||""},n.prototype.joinSteps=function(t){return t?t.map(function(t){var e="";return"element"===t.type&&(e+=2*(t.index+1)),"text"===t.type&&(e+=1+2*t.index),t.id&&(e+="["+t.id+"]"),e}).join("/"):""},n.prototype.segmentString=function(t){var e="/";return e+=this.joinSteps(t.steps),t.terminal&&null!=t.terminal.offset&&(e+=":"+t.terminal.offset),t.terminal&&null!=t.terminal.assertion&&(e+="["+t.terminal.assertion+"]"),e},n.prototype.toString=function(){var t="epubcfi(";return t+=this.segmentString(this.base),t+="!",t+=this.segmentString(this.path),this.start&&(t+=",",t+=this.segmentString(this.start)),this.end&&(t+=",",t+=this.segmentString(this.end)),t+=")"},n.prototype.compare=function(t,e){if("string"==typeof t&&(t=new n(t)),"string"==typeof e&&(e=new n(e)),t.spinePos>e.spinePos)return 1;if(t.spinePos<e.spinePos)return-1;for(var i=0;i<t.path.steps.length;i++){if(!e.path.steps[i])return 1;if(t.path.steps[i].index>e.path.steps[i].index)return 1;if(t.path.steps[i].index<e.path.steps[i].index)return-1}return t.path.steps.length<e.path.steps.length?1:t.path.terminal.offset>e.path.terminal.offset?1:t.path.terminal.offset<e.path.terminal.offset?-1:0},n.prototype.step=function(t){var e=t.nodeType===Node.TEXT_NODE?"text":"element";return{id:t.id,tagName:t.tagName,type:e,index:this.position(t)}},n.prototype.filteredStep=function(t,e){var i,n=this.filter(t,e);if(n)return i=n.nodeType===Node.TEXT_NODE?"text":"element",{id:n.id,tagName:n.tagName,type:i,index:this.filteredPosition(n,e)}},n.prototype.pathTo=function(t,e,i){for(var n,r={steps:[],terminal:{offset:null,assertion:null}},o=t;o&&o.parentNode&&o.parentNode.nodeType!=Node.DOCUMENT_NODE;)n=i?this.filteredStep(o,i):this.step(o),n&&r.steps.unshift(n),o=o.parentNode;return null!=e&&e>=0&&(r.terminal.offset=e,"text"!=r.steps[r.steps.length-1].type&&r.steps.push({type:"text",index:0})),r},n.prototype.equalStep=function(t,e){return!(!t||!e)&&(t.index===e.index&&t.id===e.id&&t.type===e.type)},n.prototype.fromRange=function(t,e,i){var n={range:!1,base:{},path:{},start:null,end:null},r=t.startContainer,o=t.endContainer,s=t.startOffset,a=t.endOffset,h=!1;if(i&&(h=null!=r.ownerDocument.querySelector("."+i)),"string"==typeof e?(n.base=this.parseComponent(e),n.spinePos=n.base.steps[1].index):"object"==typeof e&&(n.base=e),t.collapsed)h&&(s=this.patchOffset(r,s,i)),n.path=this.pathTo(r,s,i);else{n.range=!0,h&&(s=this.patchOffset(r,s,i)),n.start=this.pathTo(r,s,i),h&&(a=this.patchOffset(o,a,i)),n.end=this.pathTo(o,a,i),n.path={steps:[],terminal:null};var u,c=n.start.steps.length;for(u=0;u<c&&this.equalStep(n.start.steps[u],n.end.steps[u]);u++)u==c-1?n.start.terminal===n.end.terminal&&(n.path.steps.push(n.start.steps[u]),n.range=!1):n.path.steps.push(n.start.steps[u]);n.start.steps=n.start.steps.slice(n.path.steps.length),n.end.steps=n.end.steps.slice(n.path.steps.length)}return n},n.prototype.fromNode=function(t,e,i){var n={range:!1,base:{},path:{},start:null,end:null},r=!1;return i&&(r=null!=t.ownerDocument.querySelector("."+i)),"string"==typeof e?(n.base=this.parseComponent(e),n.spinePos=n.base.steps[1].index):"object"==typeof e&&(n.base=e),n.path=this.pathTo(t,null,i),n},n.prototype.filter=function(t,e){var i,n,r,o,s=!1;return t.nodeType===Node.TEXT_NODE?(s=!0,r=t.parentNode,i=t.parentNode.classList.contains(e)):(s=!1,i=t.classList.contains(e)),i&&s?(previousSibling=r.previousSibling,o=r.nextSibling,previousSibling&&previousSibling.nodeType===Node.TEXT_NODE?n=previousSibling:o&&o.nodeType===Node.TEXT_NODE&&(n=o),n?n:t):!(i&&!s)&&t},n.prototype.patchOffset=function(t,e,i){if(t.nodeType!=Node.TEXT_NODE)return void console.error("Anchor must be a text node");var n=t,r=e;for(t.parentNode.classList.contains(i)&&(n=t.parentNode);n.previousSibling;){if(n.previousSibling.nodeType===Node.ELEMENT_NODE){if(!n.previousSibling.classList.contains(i))break;r+=n.previousSibling.textContent.length}else r+=n.previousSibling.textContent.length;n=n.previousSibling}return r},n.prototype.normalizedMap=function(t,e,i){var n,r,o,s={},a=-1,h=t.length;for(n=0;n<h;n++)r=t[n].nodeType,r===Node.ELEMENT_NODE&&t[n].classList.contains(i)&&(r=Node.TEXT_NODE),n>0&&r===Node.TEXT_NODE&&o===Node.TEXT_NODE?s[n]=a:e===r&&(a+=1,s[n]=a),o=r;return s},n.prototype.position=function(t){var e,i;return t.nodeType===Node.ELEMENT_NODE?(e=t.parentNode.children,i=Array.prototype.indexOf.call(e,t)):(e=this.textNodes(t.parentNode),i=e.indexOf(t)),i},n.prototype.filteredPosition=function(t,e){var i,n,r;return t.nodeType===Node.ELEMENT_NODE?(i=t.parentNode.children,r=this.normalizedMap(i,Node.ELEMENT_NODE,e)):(i=t.parentNode.childNodes,t.parentNode.classList.contains(e)&&(t=t.parentNode,i=t.parentNode.childNodes),r=this.normalizedMap(i,Node.TEXT_NODE,e)),n=Array.prototype.indexOf.call(i,t),r[n]},n.prototype.stepsToXpath=function(t){var e=[".","*"];return t.forEach(function(t){var i=t.index+1;t.id?e.push("*[position()="+i+" and @id='"+t.id+"']"):"text"===t.type?e.push("text()["+i+"]"):e.push("*["+i+"]")}),e.join("/")},n.prototype.stepsToQuerySelector=function(t){var e=["html"];return t.forEach(function(t){var i=t.index+1;t.id?e.push("#"+t.id):"text"===t.type||e.push("*:nth-child("+i+")")}),e.join(">")},n.prototype.textNodes=function(t,e){return Array.prototype.slice.call(t.childNodes).filter(function(t){return t.nodeType===Node.TEXT_NODE||!(!e||!t.classList.contains(e))})},n.prototype.walkToNode=function(t,e,i){var n,r,o=e||document,s=o.documentElement,a=t.length;for(r=0;r<a;r++)n=t[r],"element"===n.type?s=s.children[n.index]:"text"===n.type&&(s=this.textNodes(s,i)[n.index]);return s},n.prototype.findNode=function(t,e,i){var n,r,o=e||document;return i||"undefined"==typeof o.evaluate?n=i?this.walkToNode(t,o,i):this.walkToNode(t,o):(r=this.stepsToXpath(t),n=o.evaluate(r,o,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),n},n.prototype.fixMiss=function(t,e,i,n){var r,o,s,a=this.findNode(t.slice(0,-1),i,n),h=a.childNodes,u=this.normalizedMap(h,Node.TEXT_NODE,n),c=t[t.length-1].index;for(var s in u){if(!u.hasOwnProperty(s))return;if(u[s]===c){if(r=h[s],o=r.textContent.length,!(e>o)){a=r.nodeType===Node.ELEMENT_NODE?r.childNodes[0]:r;break}e-=o}}return{container:a,offset:e}},n.prototype.toRange=function(t,e){var i,n,r,o,s,a,h,u=t||document,c=u.createRange(),l=this,p=!!e&&null!=u.querySelector("."+e);if(l.range?(i=l.start,s=l.path.steps.concat(i.steps),r=this.findNode(s,u,p?e:null),n=l.end,a=l.path.steps.concat(n.steps),o=this.findNode(a,u,p?e:null)):(i=l.path,s=l.path.steps,r=this.findNode(l.path.steps,u,p?e:null)),!r)return null;try{null!=i.terminal.offset?c.setStart(r,i.terminal.offset):c.setStart(r,0)}catch(d){h=this.fixMiss(s,i.terminal.offset,u,p?e:null),c.setStart(h.container,h.offset)}if(o)try{null!=n.terminal.offset?c.setEnd(o,n.terminal.offset):c.setEnd(o,0)}catch(d){h=this.fixMiss(a,l.end.terminal.offset,u,p?e:null),c.setEnd(h.container,h.offset)}return c},n.prototype.isCfiString=function(t){return"string"==typeof t&&0===t.indexOf("epubcfi(")&&")"===t[t.length-1]},n.prototype.generateChapterComponent=function(t,e,i){var n=parseInt(e),r=t+1,o="/"+r+"/";return o+=2*(n+1),i&&(o+="["+i+"]"),o},t.exports=n},function(t,e,i){function n(t){this.context=t||this,this.hooks=[]}var r=i(2);n.prototype.register=function(){for(var t=0;t<arguments.length;++t)if("function"==typeof arguments[t])this.hooks.push(arguments[t]);else for(var e=0;e<arguments[t].length;++e)this.hooks.push(arguments[t][e])},n.prototype.trigger=function(){var t=arguments,e=this.context,i=[];return this.hooks.forEach(function(n,r){var o=n.apply(e,t);o&&"function"==typeof o.then&&i.push(o)}),r.all(i)},n.prototype.list=function(){return this.hooks},n.prototype.clear=function(){return this.hooks=[]},t.exports=n},function(t,e,i){function n(t,e){this.idref=t.idref,this.linear=t.linear,this.properties=t.properties,this.index=t.index,this.href=t.href,this.url=t.url,this.next=t.next,this.prev=t.prev,this.cfiBase=t.cfiBase,e?this.hooks=e:(this.hooks={},this.hooks.serialize=new a(this),this.hooks.content=new a(this))}var r=i(2),o=i(6),s=(i(11),i(15)),a=i(16);n.prototype.load=function(t){var e=t||this.request||i(18),n=new r.defer,s=n.promise;return this.contents?n.resolve(this.contents):e(this.url).then(function(t){o(this.url).directory();return this.document=t,this.contents=t.documentElement,this.hooks.content.trigger(this.document,this)}.bind(this)).then(function(){n.resolve(this.contents)}.bind(this))["catch"](function(t){n.reject(t)}),s},n.prototype.base=function(t){var e,i=new r.defer,n=t.createElement("base");return console.log(window.location.origin+"/"+this.url),n.setAttribute("href",window.location.origin+"/"+this.url),t&&(e=t.querySelector("head")),e?(e.insertBefore(n,e.firstChild),i.resolve()):i.reject(new Error("No head to insert into")),i.promise},n.prototype.beforeSectionLoad=function(){},n.prototype.render=function(t){var e=new r.defer,n=e.promise;return this.output,this.load(t).then(function(t){var e;return"undefined"==typeof XMLSerializer&&(XMLSerializer=i(13).XMLSerializer),e=new XMLSerializer,this.output=e.serializeToString(t),this.output}.bind(this)).then(function(){return this.hooks.serialize.trigger(this.output,this)}.bind(this)).then(function(){e.resolve(this.output)}.bind(this))["catch"](function(t){e.reject(t)}),n},n.prototype.find=function(t){},n.prototype.reconcileLayoutSettings=function(t){var e={layout:t.layout,spread:t.spread,orientation:t.orientation};return this.properties.forEach(function(t){var i,n,r=t.replace("rendition:",""),o=r.indexOf("-");o!=-1&&(i=r.slice(0,o),n=r.slice(o+1),e[i]=n)}),e},n.prototype.cfiFromRange=function(t){return new s(t,this.cfiBase).toString()},n.prototype.cfiFromElement=function(t){return new s(t,this.cfiBase).toString()},t.exports=n},function(t,e,i){function n(t,e,i,n){function a(t){console.error(t),d.reject(t)}function h(){if(this.readyState===XMLHttpRequest.DONE)if(200===this.status||this.responseXML){var t;if(!this.response&&!this.responseXML)return d.reject({status:this.status,message:"Empty Response",stack:(new Error).stack}),d.promise;if(403===this.status)return d.reject({status:this.status,response:this.response,message:"Forbidden",stack:(new Error).stack}),d.promise;t=""!=this.responseType&&"document"!=this.responseType||!this.responseXML?s.isXml(e)?s.parse(this.response,"text/xml"):"xhtml"==e?s.parse(this.response,"application/xhtml+xml"):"html"==e||"htm"==e?s.parse(this.response,"text/html"):"json"==e?JSON.parse(this.response):"blob"==e?l?this.response:new Blob([this.response]):this.response:this.responseXML,d.resolve(t)}else d.reject({status:this.status,message:this.response,stack:(new Error).stack})}var u,c,l="undefined"!=typeof window&&window.URL,p=l?"blob":"arraybuffer",d=new r.defer,f=new XMLHttpRequest,g=XMLHttpRequest.prototype;"overrideMimeType"in g||Object.defineProperty(g,"overrideMimeType",{value:function(t){}}),i&&(f.withCredentials=!0),f.onreadystatechange=h,f.onerror=a,f.open("GET",t,!0);for(c in n)f.setRequestHeader(c,n[c]);return"json"==e&&f.setRequestHeader("Accept","application/json"),e||(u=o(t),e=u.suffix()),"blob"==e&&(f.responseType=p),s.isXml(e)&&f.overrideMimeType("text/xml"),"binary"==e&&(f.responseType="arraybuffer"),f.send(),d.promise}var r=i(2),o=i(6),s=i(11);t.exports=n},function(t,e,i){function n(t,e){var i,n;t&&(n=h.qs(t,"head"),i=h.qs(n,"base"),i||(i=t.createElement("base"),n.insertBefore(i,n.firstChild)),i.setAttribute("href",e.url))}function r(t,e){var i,n,r=e.url;t&&(i=h.qs(t,"head"),n=h.qs(i,"link[rel='canonical']"),n?n.setAttribute("href",r):(n=t.createElement("link"),n.setAttribute("rel","canonical"),n.setAttribute("href",r),i.appendChild(n)))}function o(t,e){for(var i=t.document.querySelectorAll("a[href]"),n=function(i){var n=i.getAttribute("href");if(0!==n.indexOf("mailto:")){var r=a(n),o=r.absoluteTo(t.section.url),s=o.relativeTo(this.book.baseUrl).toString();r.protocol()?i.setAttribute("target","_blank"):r.fragment()||(i.onclick=function(){return e.display(s),!1})}}.bind(this),r=0;r<i.length;r++)n(i[r])}function s(t,e,i){return e.forEach(function(e,n){e&&i[n]&&(t=t.replace(new RegExp(e,"g"),i[n]))}),t}var a=i(6),h=i(11);t.exports={base:n,canonical:r,links:o,substitute:s}},function(t,e,i){function n(t,e){this.spine=t,this.request=e,this.q=new o(this),this.epubcfi=new s,this._locations=[],this.total=0,this["break"]=150,this._current=0}var r=i(11),o=i(21),s=i(15),a=i(2);n.prototype.generate=function(t){return t&&(this["break"]=t),this.q.pause(),this.spine.each(function(t){this.q.enqueue(this.process,t)}.bind(this)),this.q.run().then(function(){return this.total=this._locations.length-1,this._currentCfi&&(this.currentLocation=this._currentCfi),this._locations}.bind(this))},n.prototype.process=function(t){return t.load(this.request).then(function(e){var i,n=e.ownerDocument,r=0;this.sprint(e,function(e){var o,s=e.length,a=0;for(0==r&&(i=n.createRange(),i.setStart(e,0)),o=this["break"]-r,o>s&&(r+=s,a=s);a<s;)r=this["break"],a+=this["break"],a>=s?r=s-(a-this["break"]):(i.setEnd(e,a),cfi=t.cfiFromRange(i),this._locations.push(cfi),r=0,a+=1,i=n.createRange(),i.setStart(e,a))}.bind(this)),i&&(i.setEnd(prev,prev.length),cfi=t.cfiFromRange(i),this._locations.push(cfi),r=0)}.bind(this))},n.prototype.sprint=function(t,e){for(var i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);node=i.nextNode();)e(node);
|
|
},n.prototype.locationFromCfi=function(t){return 0===this._locations.length?-1:r.locationOf(t,this._locations,this.epubcfi.compare)},n.prototype.precentageFromCfi=function(t){var e=this.locationFromCfi(t);return this.precentageFromLocation(e)},n.prototype.percentageFromLocation=function(t){return t&&this.total?t/this.total:0},n.prototype.cfiFromLocation=function(t){var e=-1;return"number"!=typeof t&&(t=parseInt(pg)),t>=0&&t<this._locations.length&&(e=this._locations[t]),e},n.prototype.cfiFromPercentage=function(t){var e=t>1?t/100:t,i=Math.ceil(this.total*e);return this.cfiFromLocation(i)},n.prototype.load=function(t){return this._locations=JSON.parse(t),this.total=this._locations.length-1,this._locations},n.prototype.save=function(t){return JSON.stringify(this._locations)},n.prototype.getCurrent=function(t){return this._current},n.prototype.setCurrent=function(t){var e;if("string"==typeof t)this._currentCfi=t;else{if("number"!=typeof t)return;this._current=t}0!==this._locations.length&&("string"==typeof t?(e=this.locationFromCfi(t),this._current=e):e=t,this.trigger("changed",{percentage:this.precentageFromLocation(e)}))},Object.defineProperty(n.prototype,"currentLocation",{get:function(){return this._current},set:function(t){this.setCurrent(t)}}),a.EventTarget.mixin(n.prototype),t.exports=n},function(t,e,i){function n(t){this._q=[],this.context=t,this.tick=o.requestAnimationFrame,this.running=!1,this.paused=!1}var r=i(2),o=i(11);n.prototype.enqueue=function(){var t,e,i,n=[].shift.call(arguments),o=arguments;return n?("function"==typeof n?(t=new r.defer,e=t.promise,i={task:n,args:o,deferred:t,promise:e}):i={promise:n},this._q.push(i),0!=this.paused||this.running||this.run(),i.promise):console.error("No Task Provided")},n.prototype.dequeue=function(){var t,e,i;return this._q.length?(t=this._q.shift(),(e=t.task)?(i=e.apply(this.context,t.args),i&&"function"==typeof i.then?i.then(function(){t.deferred.resolve.apply(this.context,arguments)}.bind(this)):(t.deferred.resolve.apply(this.context,i),t.promise)):t.promise?t.promise:void 0):(t=new r.defer,t.deferred.resolve(),t.promise)},n.prototype.dump=function(){for(;this._q.length;)this.dequeue()},n.prototype.run=function(){return this.running||(this.running=!0,this.defered=new r.defer),this.tick.call(window,function(){this._q.length?this.dequeue().then(function(){this.run()}.bind(this)):(this.defered.resolve(),this.running=void 0)}.bind(this)),1==this.paused&&(this.paused=!1),this.defered.promise},n.prototype.flush=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},n.prototype.clear=function(){this._q=[],this.running=!1},n.prototype.length=function(){return this._q.length},n.prototype.pause=function(){this.paused=!0},t.exports=n},function(t,e,i){function n(){}var r=i(6),o=i(11),s=i(15);n.prototype.container=function(t){var e,i,n,s;return t?(e=o.qs(t,"rootfile"))?(i=e.getAttribute("full-path"),n=r(i).directory(),s=t.xmlEncoding,{packagePath:i,basePath:n,encoding:s}):void console.error("No RootFile Found"):void console.error("Container File Not Found")},n.prototype.identifier=function(t){var e;return t?(e=o.qs(t,"metadata"),e?this.getElementText(e,"identifier"):void console.error("No Metadata Found")):void console.error("Package File Not Found")},n.prototype.packageContents=function(t){var e,i,n,r,s,a,h,u,c,l,p=this;return t?(e=o.qs(t,"metadata"))?(i=o.qs(t,"manifest"))?(n=o.qs(t,"spine"))?(r=p.manifest(i),s=p.findNavPath(i),a=p.findNcxPath(i,n),h=p.findCoverPath(t),u=Array.prototype.indexOf.call(n.parentNode.childNodes,n),c=p.spine(n,r),l=p.metadata(e),l.direction=n.getAttribute("page-progression-direction"),{metadata:l,spine:c,manifest:r,navPath:s,ncxPath:a,coverPath:h,spineNodeIndex:u}):void console.error("No Spine Found"):void console.error("No Manifest Found"):void console.error("No Metadata Found"):void console.error("Package File Not Found")},n.prototype.findNavPath=function(t){var e=o.qsp(t,"item",{properties:"nav"});return!!e&&e.getAttribute("href")},n.prototype.findNcxPath=function(t,e){var i,n=o.qsp(t,"item",{"media-type":"application/x-dtbncx+xml"});return n||(i=e.getAttribute("toc"),i&&(n=t.getElementById(i))),!!n&&n.getAttribute("href")},n.prototype.metadata=function(t){var e={},i=this;return e.title=i.getElementText(t,"title"),e.creator=i.getElementText(t,"creator"),e.description=i.getElementText(t,"description"),e.pubdate=i.getElementText(t,"date"),e.publisher=i.getElementText(t,"publisher"),e.identifier=i.getElementText(t,"identifier"),e.language=i.getElementText(t,"language"),e.rights=i.getElementText(t,"rights"),e.modified_date=i.getPropertyText(t,"dcterms:modified"),e.layout=i.getPropertyText(t,"rendition:layout"),e.orientation=i.getPropertyText(t,"rendition:orientation"),e.flow=i.getPropertyText(t,"rendition:flow"),e.viewport=i.getPropertyText(t,"rendition:viewport"),e},n.prototype.findCoverPath=function(t){var e=o.qs(t,"package"),i=e.getAttribute("version");if("2.0"===i){var n=o.qsp(t,"meta",{name:"cover"});if(n){var r=n.getAttribute("content"),s=t.getElementById(r);return!!s&&s.getAttribute("href")}return!1}var a=o.qsp(t,"item",{properties:"cover-image"});return!!a&&a.getAttribute("href")},n.prototype.getElementText=function(t,e){var i,n=t.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",e);return n&&0!==n.length?(i=n[0],i.childNodes.length?i.childNodes[0].nodeValue:""):""},n.prototype.getPropertyText=function(t,e){var i=o.qsp(t,"meta",{property:e});return i&&i.childNodes.length?i.childNodes[0].nodeValue:""},n.prototype.querySelectorText=function(t,e){var i=t.querySelector(e);return i&&i.childNodes.length?i.childNodes[0].nodeValue:""},n.prototype.manifest=function(t){var e={},i=o.qsa(t,"item"),n=Array.prototype.slice.call(i);return n.forEach(function(t){var i=t.getAttribute("id"),n=t.getAttribute("href")||"",r=t.getAttribute("media-type")||"",o=t.getAttribute("properties")||"";e[i]={href:n,type:r,properties:o.length?o.split(" "):[]}}),e},n.prototype.spine=function(t,e){var i=[],n=t.getElementsByTagName("itemref"),r=Array.prototype.slice.call(n);new s;return r.forEach(function(t,e){var n=t.getAttribute("idref"),r=t.getAttribute("properties")||"",o=r.length?r.split(" "):[],s={idref:n,linear:t.getAttribute("linear")||"",properties:o,index:e};i.push(s)}),i},n.prototype.querySelectorByType=function(t,e,i){var n;if("undefined"!=typeof t.querySelector&&(n=t.querySelector(e+'[*|type="'+i+'"]')),n&&0!==n.length)return n;n=o.qsa(t,e);for(var r=0;r<n.length;r++)if(n[r].getAttributeNS("http://www.idpf.org/2007/ops","type")===i)return n[r]},n.prototype.nav=function(t,e,i){var n,r,s,a=this.querySelectorByType(t,"nav","toc"),h=a?o.qsa(a,"li"):[],u=h.length,c={},l=[];if(!h||0===u)return l;for(n=0;n<u;++n)r=this.navItem(h[n],e,i),c[r.id]=r,r.parent?(s=c[r.parent],s.subitems.push(r)):l.push(r);return l},n.prototype.navItem=function(t,e,i){var n,r=t.getAttribute("id")||!1,s=o.qs(t,"a"),a=s.getAttribute("href")||"",h=s.textContent||"",u=[],c=t.parentNode;return c&&"navPoint"===c.nodeName&&(n=c.getAttribute("id")),{id:r,href:a,label:h,subitems:u,parent:n}},n.prototype.ncx=function(t,e,i){var n,r,s,a=o.qsa(t,"navPoint"),h=a.length,u={},c=[];if(!a||0===h)return c;for(n=0;n<h;++n)r=this.ncxItem(a[n],e,i),u[r.id]=r,r.parent?(s=u[r.parent],s.subitems.push(r)):c.push(r);return c},n.prototype.ncxItem=function(t,e,i){var n,r=t.getAttribute("id")||!1,s=o.qs(t,"content"),a=s.getAttribute("src"),h=o.qs(t,"navLabel"),u=h.textContent?h.textContent:"",c=[],l=t.parentNode;return l&&"navPoint"===l.nodeName&&(n=l.getAttribute("id")),{id:r,href:a,label:u,subitems:c,parent:n}},n.prototype.pageList=function(t,e,i){var n,r,s=this.querySelectorByType(t,"nav","page-list"),a=s?o.qsa(s,"li"):[],h=a.length,u=[];if(!a||0===h)return u;for(n=0;n<h;++n)r=this.pageListItem(a[n],e,i),u.push(r);return u},n.prototype.pageListItem=function(t,e,i){var n,r,s,a=(t.getAttribute("id")||!1,o.qs(t,"a")),h=a.getAttribute("href")||"",u=a.textContent||"",c=parseInt(u),l=h.indexOf("epubcfi");return l!=-1?(n=h.split("#"),r=n[0],s=n.length>1&&n[1],{cfi:s,href:h,packageUrl:r,page:c}):{href:h,page:c}},t.exports=n},function(t,e,i){function n(t,e){var n=this,a=new r,h=e||i(18);this["package"]=t,this.toc=[],this.tocByHref={},this.tocById={},t.navPath&&(this.navUrl=s(t.navPath).absoluteTo(t.baseUrl).toString(),this.nav={},this.nav.load=function(t){var e=new o.defer,i=e.promise;return h(n.navUrl,"xml").then(function(t){n.toc=a.nav(t),n.loaded(n.toc),e.resolve(n.toc)}),i}),t.ncxPath&&(this.ncxUrl=s(t.ncxPath).absoluteTo(t.baseUrl).toString(),this.ncx={},this.ncx.load=function(t){var e=new o.defer,i=e.promise;return h(n.ncxUrl,"xml").then(function(t){n.toc=a.toc(t),n.loaded(n.toc),e.resolve(n.toc)}),i})}var r=(i(11),i(22)),o=i(2),s=i(6);n.prototype.load=function(t){var e,n;t||i(18);return this.nav?e=this.nav.load():this.ncx?e=this.ncx.load():(n=new o.defer,n.resolve([]),e=n.promise),e},n.prototype.loaded=function(t){for(var e,i=0;i<t.length;i++)e=t[i],this.tocByHref[e.href]=i,this.tocById[e.id]=i},n.prototype.get=function(t){var e;return t?(0===t.indexOf("#")?e=this.tocById[t.substring(1)]:t in this.tocByHref&&(e=this.tocByHref[t]),this.toc[e]):this.toc},t.exports=n},function(t,e,i){function n(t,e){this.settings=s.extend(this.settings||{},{width:null,height:null,ignoreClass:"",manager:"single",view:"iframe",flow:null,layout:null,spread:null,minSpreadWidth:800,useBase64:!0}),s.extend(this.settings,e),this.viewSettings={ignoreClass:this.settings.ignoreClass},this.book=t,this.views=null,this.hooks={},this.hooks.display=new h(this),this.hooks.serialize=new h(this),this.hooks.content=new h(this),this.hooks.layout=new h(this),this.hooks.render=new h(this),this.hooks.show=new h(this),this.hooks.content.register(a.links.bind(this)),this.hooks.content.register(this.passViewEvents.bind(this)),this.epubcfi=new u,this.q=new c(this),this.q.enqueue(this.book.opened),this.q.enqueue(this.start),this.book.unarchived&&this.q.enqueue(this.replacements.bind(this))}var r=i(2),o=i(6),s=i(11),a=i(19),h=i(16),u=i(15),c=i(21),l=i(25),p=i(26);n.prototype.setManager=function(t){this.manager=t},n.prototype.requireManager=function(t){var e;return e="string"==typeof t?"undefined"!=typeof ePub?ePub.ViewManagers[t]:void 0:t},n.prototype.requireView=function(t){var e;return e="string"==typeof t?"undefined"!=typeof ePub?ePub.Views[t]:void 0:t},n.prototype.start=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.request,settings:this.settings})),this.settings.globalLayoutProperties=this.determineLayoutProperties(this.book["package"].metadata),this.flow(this.settings.globalLayoutProperties.flow),this.layout(this.settings.globalLayoutProperties),this.manager.on("added",this.afterDisplayed.bind(this)),this.manager.on("resized",this.onResized.bind(this)),this.manager.on("scroll",this.reportLocation.bind(this)),this.on("displayed",this.reportLocation.bind(this)),this.trigger("started")},n.prototype.attachTo=function(t){return this.q.enqueue(function(){this.manager.render(t,{width:this.settings.width,height:this.settings.height}),this.trigger("attached")}.bind(this))},n.prototype.display=function(t){return this.q.enqueue(this._display,t)},n.prototype._display=function(t){var e,i,n=this.epubcfi.isCfiString(t),o=new r.defer,s=o.promise;return(e=this.book.spine.get(t))?(!n&&"string"==typeof t&&t.indexOf("#")>-1&&(i=t.substring(t.indexOf("#")+1)),n&&(i=t),this.manager.display(e,i).then(function(){this.trigger("displayed",e)}.bind(this))):(o.reject(new Error("No Section Found")),s)},n.prototype.afterDisplayed=function(t){this.hooks.content.trigger(t,this),this.trigger("rendered",t.section),this.reportLocation()},n.prototype.onResized=function(t){this.location&&this.display(this.location.start),this.trigger("resized",{width:t.width,height:t.height})},n.prototype.moveTo=function(t){this.manager.moveTo(t)},n.prototype.next=function(){return this.q.enqueue(this.manager.next.bind(this.manager)).then(this.reportLocation.bind(this))},n.prototype.prev=function(){return this.q.enqueue(this.manager.prev.bind(this.manager)).then(this.reportLocation.bind(this))},n.prototype.determineLayoutProperties=function(t){var e,i=this.settings.layout||t.layout||"reflowable",n=this.settings.spread||t.spread||"auto",r=this.settings.orientation||t.orientation||"auto",o=this.settings.flow||t.flow||"auto",s=t.viewport||"",a=this.settings.minSpreadWidth||t.minSpreadWidth||800;return this.settings.width>=0&&this.settings.height>=0&&(s="width="+this.settings.width+", height="+this.settings.height),e={layout:i,spread:n,orientation:r,flow:o,viewport:s,minSpreadWidth:a}},n.prototype.flow=function(t){var e;"scrolled-doc"!==t&&"scrolled-continuous"!==t||(e="scrolled"),"auto"!==t&&"paginated"!==t||(e="paginated"),this._layout&&this._layout.flow(e),this.manager&&this.manager.updateFlow(e)},n.prototype.layout=function(t){return t&&(this._layout=new l(t),this._layout.spread(t.spread,this.settings.minSpreadWidth),this.mapping=new p(this._layout)),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this._layout},n.prototype.spread=function(t,e){this._layout.spread(t,e),this.manager.isRendered()&&this.manager.updateLayout()},n.prototype.reportLocation=function(){return this.q.enqueue(function(){var t=this.manager.currentLocation();t&&t.then&&"function"==typeof t.then?t.then(function(t){this.location=t,this.trigger("locationChanged",this.location)}.bind(this)):t&&(this.location=t,this.trigger("locationChanged",this.location))}.bind(this))},n.prototype.destroy=function(){this.q.clear(),this.manager.destroy()},n.prototype.passViewEvents=function(t){t.contents.listenedEvents.forEach(function(e){t.on(e,this.triggerViewEvent.bind(this))}.bind(this)),t.on("selected",this.triggerSelectedEvent.bind(this))},n.prototype.triggerViewEvent=function(t){this.trigger(t.type,t)},n.prototype.triggerSelectedEvent=function(t){this.trigger("selected",t)},n.prototype.replacements=function(){var t,e=this.book["package"].manifest,i=Object.keys(e).map(function(t){return e[t]}),n=i.filter(function(t){if("application/xhtml+xml"!=t.type&&"text/html"!=t.type)return!0}),s=n.filter(function(t){if("text/css"===t.type)return!0}),a=s.map(function(t){return t.href}),h=n.map(function(t){return t.href}.bind(this)),u=h.map(function(t){var e=o(t).absoluteTo(this.book.baseUrl).toString();return this.book.unarchived.createUrl(e,{base64:this.settings.useBase64})}.bind(this));return r.all(u).then(function(e){var i=[];return t=e,a.forEach(function(e){i.push(this.replaceCss(e,h,t))}.bind(this)),r.all(i)}.bind(this)).then(function(){this.book.spine.hooks.serialize.register(function(e,i){this.replaceAssets(i,h,t)}.bind(this))}.bind(this))["catch"](function(t){console.error(t)})},n.prototype.replaceCss=function(t,e,i){var n,h,u=o(t),c=u.absoluteTo(this.book.baseUrl).toString(),l=this.book.unarchived.getText(c),p=e.map(function(t){var e=o(t).absoluteTo(this.book.baseUrl),i=e.relativeTo(c).toString();return i}.bind(this));return l.then(function(o){return o=a.substitute(o,p,i),n=this.settings.useBase64?s.createBase64Url(o,"text/css"):s.createBlobUrl(o,"text/css"),h=e.indexOf(t),h>-1&&(i[h]=n),new r.Promise(function(t,n){t(e,i)})}.bind(this))},n.prototype.replaceAssets=function(t,e,i){var n=o(t.url),r=e.map(function(t){var e=o(t).absoluteTo(this.book.baseUrl),i=e.relativeTo(n).toString();return i}.bind(this));t.output=a.substitute(t.output,r,i)},n.prototype.range=function(t,e){var i=new u(t),n=this.visible().filter(function(t){if(i.spinePos===t.index)return!0});if(n.length)return n[0].range(i,e)},n.prototype.adjustImages=function(t){return t.addStylesheetRules([["img",["max-width",t.layout.spreadWidth+"px"],["max-height",t.layout.height+"px"]]]),new r.Promise(function(t,e){setTimeout(function(){t()},1)})},r.EventTarget.mixin(n.prototype),t.exports=n},function(t,e,i){function n(t){this.name=t.layout||"reflowable",this._spread="none"!==t.spread,this._minSpreadWidth=t.spread||800,this._evenSpreads=t.evenSpreads||!1,"scrolled-continuous"===t.flow||"scrolled-doc"===t.flow?this._flow="scrolled":this._flow="paginated",this.width=0,this.height=0,this.spreadWidth=0,this.delta=0,this.columnWidth=0,this.gap=0,this.divisor=1}i(11),i(2);n.prototype.flow=function(t){this._flow="paginated"===t?"paginated":"scrolled"},n.prototype.spread=function(t,e){this._spread="none"!==t,e>=0&&(this._minSpreadWidth=e)},n.prototype.calculate=function(t,e,i){var n,r,o,s=1,a=i||0,h=(Math.floor(t),t),u=Math.floor(h/8);s=this._spread&&h>=this._minSpreadWidth?2:1,"reflowable"!==this.name||"paginated"!==this._flow||i>=0||(a=u%2===0?u:u-1),"pre-paginated"===this.name&&(a=0),n=s>1?Math.floor((h-a)/s):h,"pre-paginated"===this.name&&s>1&&(h=n),r=n*s,o=(n+a)*s,this.width=h,this.height=e,this.spreadWidth=r,this.delta=o,this.columnWidth=n,this.gap=a,this.divisor=s},n.prototype.format=function(t){var e;return e="pre-paginated"===this.name?t.fit(this.columnWidth,this.height):"paginated"===this._flow?t.columns(this.width,this.height,this.columnWidth,this.gap):t.size(this.width,null)},n.prototype.count=function(t){var e=Math.ceil(t/this.spreadWidth);return{spreads:e,pages:e*this.divisor}},t.exports=n},function(t,e,i){function n(t){this.layout=t}var r=i(15);n.prototype.section=function(t){var e=this.findRanges(t),i=this.rangeListToCfiList(t.section.cfiBase,e);return i},n.prototype.page=function(t,e,i,n){var r=!(!t||!t.document)&&t.document.body;if(r)return this.rangePairToCfiPair(e,{start:this.findStart(r,i,n),end:this.findEnd(r,i,n)})},n.prototype.walk=function(t,e){for(var i,n,r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode:function(t){return t.data.trim().length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}},!1);(i=r.nextNode())&&!(n=e(i)););return n},n.prototype.findRanges=function(t){for(var e,i,n=[],r=t.contents.scrollWidth(),o=this.layout.count(r),s=this.layout.column,a=this.layout.gap,h=0;h<o.pages;h++)e=(s+a)*h,i=s*(h+1)+a*h,n.push({start:this.findStart(t.document.body,e,i),end:this.findEnd(t.document.body,e,i)});return n},n.prototype.findStart=function(t,e,i){for(var n,r,o=[t],s=t;o.length;)if(n=o.shift(),r=this.walk(n,function(t){var n,r,a,h;return t.nodeType==Node.TEXT_NODE?(h=document.createRange(),h.selectNodeContents(t),a=h.getBoundingClientRect()):a=t.getBoundingClientRect(),n=a.left,r=a.right,n>=e&&n<=i?t:r>e?t:(s=t,void o.push(t))}))return this.findTextStartRange(r,e,i);return this.findTextStartRange(s,e,i)},n.prototype.findEnd=function(t,e,i){for(var n,r,o=[t],s=t;o.length;)if(n=o.shift(),r=this.walk(n,function(t){var e,n,r,a;return t.nodeType==Node.TEXT_NODE?(a=document.createRange(),a.selectNodeContents(t),r=a.getBoundingClientRect()):r=t.getBoundingClientRect(),e=r.left,n=r.right,e>i&&s?s:n>i?t:(s=t,void o.push(t))}))return this.findTextEndRange(r,e,i);return this.findTextEndRange(s,e,i)},n.prototype.findTextStartRange=function(t,e,i){for(var n,r,o,s=this.splitTextNodeIntoRanges(t),a=0;a<s.length;a++){if(r=s[a],o=r.getBoundingClientRect(),o.left>=e)return r;n=r}return s[0]},n.prototype.findTextEndRange=function(t,e,i){for(var n,r,o,s=this.splitTextNodeIntoRanges(t),a=0;a<s.length;a++){if(r=s[a],o=r.getBoundingClientRect(),o.left>i&&n)return n;if(o.right>i)return r;n=r}return s[s.length-1]},n.prototype.splitTextNodeIntoRanges=function(t,e){var i,n=[],r=t.textContent||"",o=r.trim(),s=t.ownerDocument,a=e||" ";if(pos=o.indexOf(a),pos===-1||t.nodeType!=Node.TEXT_NODE)return i=s.createRange(),i.selectNodeContents(t),[i];for(i=s.createRange(),i.setStart(t,0),i.setEnd(t,pos),n.push(i),i=!1;pos!=-1;)pos=o.indexOf(a,pos+1),pos>0&&(i&&(i.setEnd(t,pos),n.push(i)),i=s.createRange(),i.setStart(t,pos+1));return i&&(i.setEnd(t,o.length),n.push(i)),n},n.prototype.rangePairToCfiPair=function(t,e){var i=e.start,n=e.end;return i.collapse(!0),n.collapse(!0),startCfi=new r(i,t).toString(),endCfi=new r(n,t).toString(),{start:startCfi,end:endCfi}},n.prototype.rangeListToCfiList=function(t,e){for(var i,n=[],r=0;r<e.length;r++)i=this.rangePairToCfiPair(t,e[r]),n.push(i);return n},t.exports=n},function(t,e,i){function n(){this.checkRequirements(),this.urlCache={}}var r=i(2),o=i(6),s=i(11),a=i(18),h=i(28);n.prototype.checkRequirements=function(t){try{"undefined"!=typeof JSZip?this.zip=new JSZip:(JSZip=i(29),this.zip=new JSZip)}catch(e){console.error("JSZip lib not loaded")}},n.prototype.open=function(t,e){return t instanceof ArrayBuffer||e?this.zip.loadAsync(t,{base64:e}):a(t,"binary").then(function(t){return this.zip.loadAsync(t)}.bind(this))},n.prototype.request=function(t,e){var i,n=new r.defer;return e||(uri=o(t),e=uri.suffix()),i="blob"==e?this.getBlob(t):this.getText(t),i?i.then(function(t){result=this.handleResponse(t,e),n.resolve(result)}.bind(this)):n.reject({message:"File not found in the epub: "+t,stack:(new Error).stack}),n.promise},n.prototype.handleResponse=function(t,e){var i;return i="json"==e?JSON.parse(t):s.isXml(e)?s.parse(t,"text/xml"):"xhtml"==e?s.parse(t,"application/xhtml+xml"):"html"==e||"htm"==e?s.parse(t,"text/html"):t},n.prototype.getBlob=function(t,e){var i,n=window.decodeURIComponent(t.substr(1)),r=this.zip.file(n);if(r)return i=e||h.lookup(r.name),r.async("uint8array").then(function(t){return new Blob([t],{type:i})})},n.prototype.getText=function(t,e){var i=window.decodeURIComponent(t.substr(1)),n=this.zip.file(i);if(n)return n.async("string").then(function(t){return t})},n.prototype.getBase64=function(t,e){var i,n=window.decodeURIComponent(t.substr(1)),r=this.zip.file(n);if(r)return i=e||h.lookup(r.name),r.async("base64").then(function(t){return"data:"+i+";base64,"+t})},n.prototype.createUrl=function(t,e){var i,n,o=new r.defer,s=window.URL||window.webkitURL||window.mozURL,a=e&&e.base64;return t in this.urlCache?(o.resolve(this.urlCache[t]),o.promise):(a?(n=this.getBase64(t),n&&n.then(function(e){this.urlCache[t]=e,o.resolve(e)}.bind(this))):(n=this.getBlob(t),n&&n.then(function(e){i=s.createObjectURL(e),this.urlCache[t]=i,o.resolve(i)}.bind(this))),n||o.reject({message:"File not found in the epub: "+t,stack:(new Error).stack}),o.promise)},n.prototype.revokeUrl=function(t){var e=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[t];i&&e.revokeObjectURL(i)},t.exports=n},function(t,e){function i(t){return t&&r[t.split(".").pop().toLowerCase()]||o}var n={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"}},r=function(){var t,e,i,r,o={};for(t in n)if(n.hasOwnProperty(t))for(e in n[t])if(n[t].hasOwnProperty(e))if(i=n[t][e],"string"==typeof i)o[i]=t+"/"+e;else for(r=0;r<i.length;r++)o[i[r]]=t+"/"+e;return o}(),o="text/plain";t.exports={lookup:i}},function(t,i){if("undefined"==typeof e){var n=new Error('Cannot find module "JSZip"');throw n.code="MODULE_NOT_FOUND",n}t.exports=e},function(t,e,i){function n(t,e,i){this.epubcfi=new s,this.document=t,this.documentElement=this.document.documentElement,this.content=e||this.document.body,this.window=this.document.defaultView,this.listenedEvents=["keydown","keyup","keypressed","mouseup","mousedown","click","touchend","touchstart"],this._size={width:0,height:0},this.cfiBase=i||"",this.listeners()}var r=i(2),o=i(11),s=i(15),a=i(26);n.prototype.width=function(t){var e=this.content;return t&&o.isNumber(t)&&(t+="px"),t&&(e.style.width=t),this.window.getComputedStyle(e).width},n.prototype.height=function(t){var e=this.content;return t&&o.isNumber(t)&&(t+="px"),t&&(e.style.height=t),this.window.getComputedStyle(e).height},n.prototype.contentWidth=function(t){var e=this.content||this.document.body;return t&&o.isNumber(t)&&(t+="px"),t&&(e.style.width=t),this.window.getComputedStyle(e).width},n.prototype.contentHeight=function(t){var e=this.content||this.document.body;return t&&o.isNumber(t)&&(t+="px"),t&&(e.style.height=t),this.window.getComputedStyle(e).height},n.prototype.textWidth=function(){var t,e=this.document.createRange(),i=this.content||this.document.body;return e.selectNodeContents(i),t=e.getBoundingClientRect().width},n.prototype.textHeight=function(){var t,e=this.document.createRange(),i=this.content||this.document.body;return e.selectNodeContents(i),t=e.getBoundingClientRect().height},n.prototype.scrollWidth=function(){var t=this.documentElement.scrollWidth;return t},n.prototype.scrollHeight=function(){var t=this.documentElement.scrollHeight;return t},n.prototype.overflow=function(t){return t&&(this.documentElement.style.overflow=t),this.window.getComputedStyle(this.documentElement).overflow},n.prototype.overflowX=function(t){return t&&(this.documentElement.style.overflowX=t),this.window.getComputedStyle(this.documentElement).overflowX},n.prototype.overflowY=function(t){return t&&(this.documentElement.style.overflowY=t),this.window.getComputedStyle(this.documentElement).overflowY},n.prototype.css=function(t,e){var i=this.content||this.document.body;return e&&(i.style[t]=e),this.window.getComputedStyle(i)[t]},n.prototype.viewport=function(t){var e,i,n,r,o=this.document.querySelector("meta[name='viewport']"),s="";return o&&o.hasAttribute("content")&&(content=o.getAttribute("content"),contents=content.split(/\s*,\s*/),contents[0]&&(e=contents[0].replace("width=","").trim()),contents[1]&&(i=contents[1].replace("height=","").trim()),contents[2]&&(n=contents[2].replace("initial-scale=","").trim()),contents[3]&&(r=contents[3].replace("user-scalable=","").trim())),t&&(s+="width="+(t.width||e),s+=", height="+(t.height||i),(t.scale||n)&&(s+=", initial-scale="+(t.scale||n)),(t.scalable||r)&&(s+=", user-scalable="+(t.scalable||r)),o||(o=this.document.createElement("meta"),o.setAttribute("name","viewport"),this.document.querySelector("head").appendChild(o)),o.setAttribute("content",s)),{width:parseInt(e),height:parseInt(i)}},n.prototype.expand=function(){this.trigger("expand")},n.prototype.listeners=function(){this.imageLoadListeners(),this.mediaQueryListeners(),this.addEventListeners(),this.addSelectionListeners(),this.resizeListeners()},n.prototype.removeListeners=function(){this.removeEventListeners(),this.removeSelectionListeners()},n.prototype.resizeListeners=function(){var t,e;clearTimeout(this.expanding),t=this.scrollWidth(),e=this.scrollHeight(),t==this._size.width&&e==this._size.height||(this._size={width:t,height:e},this.trigger("resize",this._size)),this.expanding=setTimeout(this.resizeListeners.bind(this),350)},n.prototype.mediaQueryListeners=function(){for(var t=this.document.styleSheets,e=function(t){t.matches&&!this._expanding&&setTimeout(this.expand.bind(this),1)}.bind(this),i=0;i<t.length;i+=1){var n=t[i].cssRules;if(!n)return;for(var r=0;r<n.length;r+=1)if(n[r].media){var o=this.window.matchMedia(n[r].media.mediaText);o.addListener(e)}}},n.prototype.observe=function(t){var e=this,i=new MutationObserver(function(t){e._expanding&&e.expand()}),n={attributes:!0,childList:!0,characterData:!0,subtree:!0};return i.observe(t,n),i},n.prototype.imageLoadListeners=function(t){for(var e,i=this.document.querySelectorAll("img"),n=0;n<i.length;n++)e=i[n],"undefined"!=typeof e.naturalWidth&&0===e.naturalWidth&&(e.onload=this.expand.bind(this))},n.prototype.fontLoadListeners=function(t){this.document&&this.document.fonts&&this.document.fonts.ready.then(function(){this.expand()}.bind(this))},n.prototype.root=function(){return this.document?this.document.documentElement:null},n.prototype.locationOf=function(t,e){var i,n={left:0,top:0};if(this.document)return this.epubcfi.isCfiString(t)?(range=new s(t).toRange(this.document,e),range&&(range.startContainer.nodeType===Node.ELEMENT_NODE?(i=range.startContainer.getBoundingClientRect(),n.left=i.left,n.top=i.top):(i=range.getBoundingClientRect(),n.left=i.left,n.top=i.top))):"string"==typeof t&&t.indexOf("#")>-1&&(id=t.substring(t.indexOf("#")+1),el=this.document.getElementById(id),el&&(i=el.getBoundingClientRect(),n.left=i.left,n.top=i.top)),n},n.prototype.addStylesheet=function(t){return new r.Promise(function(e,i){var n,r=!1;return this.document?(n=this.document.createElement("link"),n.type="text/css",n.rel="stylesheet",n.href=t,n.onload=n.onreadystatechange=function(){r||this.readyState&&"complete"!=this.readyState||(r=!0,setTimeout(function(){e(!0)},1))},void this.document.head.appendChild(n)):void e(!1)}.bind(this))},n.prototype.addStylesheetRules=function(t){var e,i;if(this.document){e=this.document.createElement("style"),this.document.head.appendChild(e),i=e.sheet;for(var n=0,r=t.length;n<r;n++){var o=1,s=t[n],a=t[n][0],h="";"[object Array]"===Object.prototype.toString.call(s[1][0])&&(s=s[1],o=0);for(var u=s.length;o<u;o++){var c=s[o];h+=c[0]+":"+c[1]+(c[2]?" !important":"")+";\n"}i.insertRule(a+"{"+h+"}",i.cssRules.length)}}},n.prototype.addScript=function(t){return new r.Promise(function(e,i){var n,r=!1;return this.document?(n=this.document.createElement("script"),n.type="text/javascript",n.async=!0,n.src=t,n.onload=n.onreadystatechange=function(){r||this.readyState&&"complete"!=this.readyState||(r=!0,setTimeout(function(){e(!0)},1))},void this.document.head.appendChild(n)):void e(!1)}.bind(this))},n.prototype.addEventListeners=function(){this.document&&this.listenedEvents.forEach(function(t){this.document.addEventListener(t,this.triggerEvent.bind(this),!1)},this)},n.prototype.removeEventListeners=function(){this.document&&this.listenedEvents.forEach(function(t){this.document.removeEventListener(t,this.triggerEvent,!1)},this)},n.prototype.triggerEvent=function(t){
|
|
this.trigger(t.type,t)},n.prototype.addSelectionListeners=function(){this.document&&this.document.addEventListener("selectionchange",this.onSelectionChange.bind(this),!1)},n.prototype.removeSelectionListeners=function(){this.document&&this.document.removeEventListener("selectionchange",this.onSelectionChange,!1)},n.prototype.onSelectionChange=function(t){this.selectionEndTimeout&&clearTimeout(this.selectionEndTimeout),this.selectionEndTimeout=setTimeout(function(){var t=this.window.getSelection();this.triggerSelectedEvent(t)}.bind(this),500)},n.prototype.triggerSelectedEvent=function(t){var e,i;t&&t.rangeCount>0&&(e=t.getRangeAt(0),e.collapsed||(i=new s(e,this.cfiBase).toString(),this.trigger("selected",i),this.trigger("selectedRange",e)))},n.prototype.range=function(t,e){var i=new s(t);return i.toRange(this.document,e)},n.prototype.map=function(t){var e=new a(t);return e.section()},n.prototype.size=function(t,e){t>=0&&this.width(t),e>=0&&this.height(e),this.css("margin","0"),this.css("boxSizing","border-box")},n.prototype.columns=function(t,e,i,n){var r=o.prefixed("columnAxis"),s=o.prefixed("columnGap"),a=o.prefixed("columnWidth"),h=o.prefixed("columnFill");this.width(t),this.height(e),this.viewport({width:t,height:e,scale:1}),this.css("overflowY","hidden"),this.css("margin","0"),this.css("boxSizing","border-box"),this.css("maxWidth","inherit"),this.css(r,"horizontal"),this.css(h,"auto"),this.css(s,n+"px"),this.css(a,i+"px")},n.prototype.scale=function(t,e,i){var t="scale("+t+")",n="";this.css("transformOrigin","top left"),(e>=0||i>=0)&&(n=" translate("+(e||0)+"px, "+(i||0)+"px )"),this.css("transform",t+n)},n.prototype.fit=function(t,e){var i=this.viewport(),n=t/i.width,r=e/i.height,o=n<r?n:r,s=(e-i.height*o)/2;this.width(t),this.height(e),this.overflow("hidden"),this.viewport({scale:1}),this.scale(o,0,s),this.css("backgroundColor","transparent")},n.prototype.mapPage=function(t,e,i){var n=new a;return n.page(this,t,e,i)},n.prototype.destroy=function(){this.observer&&this.observer.disconnect(),this.removeListeners()},r.EventTarget.mixin(n.prototype),t.exports=n},function(t,e,i){function n(t,e){this.settings=o.extend({ignoreClass:"",axis:"vertical",width:0,height:0,layout:void 0,globalLayoutProperties:{}},e||{}),this.id="epubjs-view-"+o.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.width=this.settings.width,this.height=this.settings.height,this.fixedWidth=0,this.fixedHeight=0,this.epubcfi=new s,this.layout=this.settings.layout}var r=i(2),o=i(11),s=i(15),a=i(30);n.prototype.container=function(t){var e=document.createElement("div");return e.classList.add("epub-view"),e.style.height="0px",e.style.width="0px",e.style.overflow="hidden",t&&"horizontal"==t?e.style.display="inline-block":e.style.display="block",e},n.prototype.create=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.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.appendChild(this.iframe),this.added=!0,this.elementBounds=o.bounds(this.element),"srcdoc"in this.iframe?this.supportsSrcdoc=!0:this.supportsSrcdoc=!1,this.iframe)},n.prototype.render=function(t,e){return this.create(),this.size(),this.sectionRender||(this.sectionRender=this.section.render(t)),this.sectionRender.then(function(t){return this.load(t)}.bind(this)).then(function(){}.bind(this)).then(function(){this.settings.layout.format(this.contents),this.expand(),this.addListeners(),this.trigger("rendered",this.section)}.bind(this))["catch"](function(t){this.trigger("loaderror",t)}.bind(this))},n.prototype.size=function(t,e){var i=t||this.settings.width,n=e||this.settings.height;"pre-paginated"===this.layout.name?this.lock("both",i,n):"horizontal"===this.settings.axis?this.lock("height",i,n):this.lock("width",i,n)},n.prototype.lock=function(t,e,i){var n,r=o.borders(this.element);n=this.iframe?o.borders(this.iframe):{width:0,height:0},"width"==t&&o.isNumber(e)&&(this.lockedWidth=e-r.width-n.width,this.resize(this.lockedWidth,e)),"height"==t&&o.isNumber(i)&&(this.lockedHeight=i-r.height-n.height,this.resize(e,this.lockedHeight)),"both"===t&&o.isNumber(e)&&o.isNumber(i)&&(this.lockedWidth=e-r.width-n.width,this.lockedHeight=i-r.height-n.height,this.resize(this.lockedWidth,this.lockedHeight)),this.displayed&&this.iframe&&this.expand()},n.prototype.expand=function(t){var e,i,n,r=this.lockedWidth,o=this.lockedHeight;this.iframe&&!this._expanding&&(this._expanding=!0,"horizontal"===this.settings.axis?(i=this.contents.textWidth(),i!=this._textWidth?(r=this.contentWidth(i),e=Math.ceil(r/(this.settings.layout.columnWidth+this.settings.layout.gap)),this.settings.layout.divisor>1&&"reflowable"===this.settings.layout.name&&e%2>0&&(r+=this.settings.layout.gap+this.settings.layout.columnWidth),this._textWidth=i,this._contentWidth=r):r=this._contentWidth):"vertical"===this.settings.axis&&(n=this.contents.textHeight(),n!=this._textHeight?(o=this.contentHeight(n),this._textHeight=n,this._contentHeight=o):o=this._contentHeight),(this._needsReframe||r!=this._width||o!=this._height)&&this.resize(r,o),this._expanding=!1)},n.prototype.contentWidth=function(t){var e,i;return e=this.iframe.style.width,this.iframe.style.width=(t||0)+"px",i=this.contents.scrollWidth(),this.iframe.style.width=e,i},n.prototype.contentHeight=function(t){var e,i;return e=this.iframe.style.height,this.iframe.style.height=(t||0)+"px",i=this.contents.scrollHeight(),this.iframe.style.height=e,i},n.prototype.resize=function(t,e){this.iframe&&(o.isNumber(t)&&(this.iframe.style.width=t+"px",this._width=t),o.isNumber(e)&&(this.iframe.style.height=e+"px",this._height=e),this.iframeBounds=o.bounds(this.iframe),this.reframe(this.iframeBounds.width,this.iframeBounds.height))},n.prototype.reframe=function(t,e){var i;o.isNumber(t)&&(this.element.style.width=t+"px"),o.isNumber(e)&&(this.element.style.height=e+"px"),this.prevBounds=this.elementBounds,this.elementBounds=o.bounds(this.element),i={width:this.elementBounds.width,height:this.elementBounds.height,widthDelta:this.elementBounds.width-this.prevBounds.width,heightDelta:this.elementBounds.height-this.prevBounds.height},this.onResize(this,i),this.trigger("resized",i)},n.prototype.load=function(t){var e=new r.defer,i=e.promise;if(!this.iframe)return e.reject(new Error("No Iframe Available")),i;if(this.iframe.onload=function(t){this.onLoad(t,e)}.bind(this),this.supportsSrcdoc)this.iframe.srcdoc=t;else{if(this.document=this.iframe.contentDocument,!this.document)return e.reject(new Error("No Document Available")),i;this.iframe.contentDocument.open(),this.iframe.contentDocument.write(t),this.iframe.contentDocument.close()}return i},n.prototype.onLoad=function(t,e){this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,this.contents=new a(this.document,this.document.body,this.section.cfiBase),this.rendering=!1;var i=this.document.querySelector("link[rel='canonical']");i?i.setAttribute("href",this.section.url):(i=this.document.createElement("link"),i.setAttribute("rel","canonical"),i.setAttribute("href",this.section.url),this.document.querySelector("head").appendChild(i)),this.contents.on("expand",function(){this.displayed&&this.iframe&&this.expand()}),e.resolve(this.contents)},n.prototype.setLayout=function(t){this.layout=t},n.prototype.setAxis=function(t){this.settings.axis=t},n.prototype.resizeListenters=function(){clearTimeout(this.expanding),this.expanding=setTimeout(this.expand.bind(this),350)},n.prototype.addListeners=function(){},n.prototype.removeListeners=function(t){},n.prototype.display=function(t){var e=new r.defer;return this.displayed?e.resolve(this):this.render(t).then(function(){this.trigger("displayed",this),this.onDisplayed(this),this.displayed=!0,e.resolve(this)}.bind(this)),e.promise},n.prototype.show=function(){this.element.style.visibility="visible",this.iframe&&(this.iframe.style.visibility="visible"),this.trigger("shown",this)},n.prototype.hide=function(){this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.stopExpanding=!0,this.trigger("hidden",this)},n.prototype.position=function(){return this.element.getBoundingClientRect()},n.prototype.locationOf=function(t){var e=this.iframe.getBoundingClientRect(),i=this.contents.locationOf(t,this.settings.ignoreClass);return{left:window.scrollX+e.left+i.left,top:window.scrollY+e.top+i.top}},n.prototype.onDisplayed=function(t){},n.prototype.onResize=function(t,e){},n.prototype.bounds=function(){return this.elementBounds||(this.elementBounds=o.bounds(this.element)),this.elementBounds},n.prototype.destroy=function(){this.displayed&&(this.displayed=!1,this.removeListeners(),this.stopExpanding=!0,this.element.removeChild(this.iframe),this.displayed=!1,this.iframe=null,this._textWidth=null,this._textHeight=null,this._width=null,this._height=null)},r.EventTarget.mixin(n.prototype),t.exports=n},function(t,e,i){function n(t){this.name="default",this.View=t.view,this.request=t.request,this.renditionQueue=t.queue,this.q=new a(this),this.settings=o.extend(this.settings||{},{infinite:!0,hidden:!1,width:void 0,height:void 0,axis:"vertical",ignoreClass:""}),o.extend(this.settings,t.settings||{}),this.viewSettings={ignoreClass:this.settings.ignoreClass,axis:this.settings.axis,layout:this.layout,width:0,height:0}}var r=i(2),o=i(11),s=(i(15),i(26)),a=i(21),h=i(33),u=i(34);n.prototype.render=function(t,e){this.stage=new h({width:e.width,height:e.height,overflow:this.settings.overflow,hidden:this.settings.hidden,axis:this.settings.axis}),this.stage.attachTo(t),this.container=this.stage.getContainer(),this.views=new u(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.addEventListeners(),this.layout&&this.updateLayout()},n.prototype.addEventListeners=function(){window.addEventListener("unload",function(t){this.destroy()}.bind(this))},n.prototype.destroy=function(){},n.prototype.onResized=function(t){clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){this.resize()}.bind(this),150)},n.prototype.resize=function(t,e){this.q.clear(),this._stageSize=this.stage.size(t,e),this._bounds=this.bounds(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.views.each(function(t){t.size(this._stageSize.width,this._stageSize.height)}.bind(this)),this.updateLayout(),this.trigger("resized",{width:this.stage.width,height:this.stage.height})},n.prototype.createView=function(t){return new this.View(t,this.viewSettings)},n.prototype.display=function(t,e){var i=new r.defer,n=i.promise,o=this.views.find(t);return o&&e?(offset=o.locationOf(e),this.moveTo(offset),i.resolve(),n):(this.views.hide(),this.views.clear(),this.add(t).then(function(){var e;if("pre-paginated"===this.layout.name&&this.layout.divisor>1&&(e=t.next()))return this.add(e)}.bind(this)).then(function(t){e&&(offset=t.locationOf(e),this.moveTo(offset)),this.views.show(),i.resolve()}.bind(this)),n)},n.prototype.afterDisplayed=function(t){this.trigger("added",t)},n.prototype.afterResized=function(t){this.trigger("resize",t.section)},n.prototype.moveTo=function(t){var e=0,i=0;"vertical"===this.settings.axis?i=t.top:(e=Math.floor(t.left/this.layout.delta)*this.layout.delta,e+this.layout.delta>this.container.scrollWidth&&(e=this.container.scrollWidth-this.layout.delta)),this.scrollTo(e,i)},n.prototype.add=function(t){var e=this.createView(t);return this.views.append(e),e.onDisplayed=this.afterDisplayed.bind(this),e.onResize=this.afterResized.bind(this),e.display(this.request)},n.prototype.append=function(t){var e=this.createView(t);return this.views.append(e),e.display(this.request)},n.prototype.prepend=function(t){var e=this.createView(t);return this.views.prepend(e),e.display(this.request)},n.prototype.next=function(){var t,e;if(this.views.length)return"horizontal"===this.settings.axis?(this.scrollLeft=this.container.scrollLeft,e=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,e<this.container.scrollWidth?this.scrollBy(this.layout.delta,0):e-this.layout.columnWidth===this.container.scrollWidth?this.scrollTo(this.container.scrollWidth-this.layout.delta,0):t=this.views.last().section.next()):t=this.views.last().section.next(),t?(this.views.clear(),this.append(t).then(function(){var e;if(this.layout.name&&this.layout.divisor>1&&(e=t.next()))return this.append(e)}.bind(this)).then(function(){this.views.show()}.bind(this))):void 0},n.prototype.prev=function(){var t,e;if(this.views.length)return"horizontal"===this.settings.axis?(this.scrollLeft=this.container.scrollLeft,e=this.container.scrollLeft,e>0?this.scrollBy(-this.layout.delta,0):t=this.views.first().section.prev()):t=this.views.first().section.prev(),t?(this.views.clear(),this.prepend(t).then(function(){var e;if(this.layout.name&&this.layout.divisor>1&&(e=t.prev()))return this.prepend(e)}.bind(this)).then(function(){"horizontal"===this.settings.axis&&this.scrollTo(this.container.scrollWidth-this.layout.delta,0),this.views.show()}.bind(this))):void 0},n.prototype.current=function(){var t=this.visible();return t.length?t[t.length-1]:null},n.prototype.currentLocation=function(){var t,e,i;if(this.views.length)return t=this.views.first(),e=container.left-t.position().left,i=e+this.layout.spread,this.mapping.page(t,t.section.cfiBase)},n.prototype.isVisible=function(t,e,i,n){var r=t.position(),o=n||this.bounds();return"horizontal"===this.settings.axis&&r.right>o.left-e&&r.left<o.right+i||"vertical"===this.settings.axis&&r.bottom>o.top-e&&r.top<o.bottom+i},n.prototype.visible=function(){for(var t,e,i=this.bounds(),n=this.views.displayed(),r=n.length,o=[],s=0;s<r;s++)e=n[s],t=this.isVisible(e,0,0,i),t===!0&&o.push(e);return o},n.prototype.scrollBy=function(t,e,i){i&&(this.ignore=!0),this.settings.height?(t&&(this.container.scrollLeft+=t),e&&(this.container.scrollTop+=e)):window.scrollBy(t,e),this.scrolled=!0,this.onScroll()},n.prototype.scrollTo=function(t,e,i){i&&(this.ignore=!0),this.settings.height?(this.container.scrollLeft=t,this.container.scrollTop=e):window.scrollTo(t,e),this.scrolled=!0,this.onScroll()},n.prototype.onScroll=function(){},n.prototype.bounds=function(){var t;return t=this.stage.bounds()},n.prototype.applyLayout=function(t){this.layout=t,this.updateLayout(),this.mapping=new s(this.layout)},n.prototype.updateLayout=function(){this.stage&&(this._stageSize=this.stage.size(),"vertical"===this.settings.axis?this.layout.calculate(this._stageSize.width,this._stageSize.height):(this.layout.calculate(this._stageSize.width,this._stageSize.height,this.settings.gap),this.settings.offset=this.layout.delta,this.stage.addStyleRules("iframe",[{"margin-right":this.layout.gap+"px"}])),this.viewSettings.width=this.layout.width,this.viewSettings.height=this.layout.height,this.setLayout(this.layout))},n.prototype.setLayout=function(t){this.viewSettings.layout=t,this.views&&this.views.each(function(e){e.setLayout(t)})},n.prototype.updateFlow=function(t){var e="paginated"===t?"horizontal":"vertical";this.settings.axis=e,this.viewSettings.axis=e,this.settings.overflow="paginated"===t?"hidden":"auto"},r.EventTarget.mixin(n.prototype),t.exports=n},function(t,e,i){function n(t){this.settings=t||{},this.id="epubjs-container-"+r.uuid(),this.container=this.create(this.settings),this.settings.hidden&&(this.wrapper=this.wrap(this.container))}var r=i(11);n.prototype.create=function(t){var e=t.height,i=t.width,n=t.overflow||!1,o=t.axis||"vertical";return t.height&&r.isNumber(t.height)&&(e=t.height+"px"),t.width&&r.isNumber(t.width)&&(i=t.width+"px"),container=document.createElement("div"),container.id=this.id,container.classList.add("epub-container"),container.style.wordSpacing="0",container.style.lineHeight="0",container.style.verticalAlign="top","horizontal"===o&&(container.style.whiteSpace="nowrap"),i&&(container.style.width=i),e&&(container.style.height=e),n&&(container.style.overflow=n),container},n.wrap=function(t){var e=document.createElement("div");return e.style.visibility="hidden",e.style.overflow="hidden",e.style.width="0",e.style.height="0",e.appendChild(t),e},n.prototype.getElement=function(t){var e;return r.isElement(t)?e=t:"string"==typeof t&&(e=document.getElementById(t)),e?e:void console.error("Not an Element")},n.prototype.attachTo=function(t){var e,i=this.getElement(t);if(i)return e=this.settings.hidden?this.wrapper:this.container,i.appendChild(e),this.element=i,i},n.prototype.getContainer=function(){return this.container},n.prototype.onResize=function(t){r.isNumber(this.settings.width)&&r.isNumber(this.settings.height)||window.addEventListener("resize",t,!1)},n.prototype.size=function(t,e){var i;return null===t&&(i=this.element.getBoundingClientRect(),i.width&&(t=i.width,this.container.style.width=i.width+"px")),null===e&&(i=i||this.element.getBoundingClientRect(),i.height&&(e=i.height,this.container.style.height=i.height+"px")),r.isNumber(t)||(i=this.container.getBoundingClientRect(),t=i.width),r.isNumber(e)||(i=i||this.container.getBoundingClientRect(),e=i.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},{width:t-this.containerPadding.left-this.containerPadding.right,height:e-this.containerPadding.top-this.containerPadding.bottom}},n.prototype.bounds=function(){return this.container?this.container.getBoundingClientRect():r.windowBounds()},n.prototype.getSheet=function(){var t=document.createElement("style");return t.appendChild(document.createTextNode("")),document.head.appendChild(t),t.sheet},n.prototype.addStyleRules=function(t,e){var i="#"+this.id+" ",n="";this.sheet||(this.sheet=this.getSheet()),e.forEach(function(t){for(var e in t)t.hasOwnProperty(e)&&(n+=e+":"+t[e]+";")}),this.sheet.insertRule(i+t+" {"+n+"}",0)},t.exports=n},function(t,e){function i(t){this.container=t,this._views=[],this.length=0,this.hidden=!1}i.prototype.all=function(){return this._views},i.prototype.first=function(){return this._views[0]},i.prototype.last=function(){return this._views[this._views.length-1]},i.prototype.indexOf=function(t){return this._views.indexOf(t)},i.prototype.slice=function(){return this._views.slice.apply(this._views,arguments)},i.prototype.get=function(t){return this._views[t]},i.prototype.append=function(t){return this._views.push(t),this.container&&this.container.appendChild(t.element),this.length++,t},i.prototype.prepend=function(t){return this._views.unshift(t),this.container&&this.container.insertBefore(t.element,this.container.firstChild),this.length++,t},i.prototype.insert=function(t,e){return this._views.splice(e,0,t),this.container&&(e<this.container.children.length?this.container.insertBefore(t.element,this.container.children[e]):this.container.appendChild(t.element)),this.length++,t},i.prototype.remove=function(t){var e=this._views.indexOf(t);e>-1&&this._views.splice(e,1),this.destroy(t),this.length--},i.prototype.destroy=function(t){t.off("resized"),t.displayed&&t.destroy(),this.container&&this.container.removeChild(t.element),t=null},i.prototype.each=function(){return this._views.forEach.apply(this._views,arguments)},i.prototype.clear=function(){var t,e=this.length;if(this.length){for(var i=0;i<e;i++)t=this._views[i],this.destroy(t);this._views=[],this.length=0}},i.prototype.find=function(t){for(var e,i=this.length,n=0;n<i;n++)if(e=this._views[n],e.displayed&&e.section.index==t.index)return e},i.prototype.displayed=function(){for(var t,e=[],i=this.length,n=0;n<i;n++)t=this._views[n],t.displayed&&e.push(t);return e},i.prototype.show=function(){for(var t,e=this.length,i=0;i<e;i++)t=this._views[i],t.displayed&&t.show();this.hidden=!1},i.prototype.hide=function(){for(var t,e=this.length,i=0;i<e;i++)t=this._views[i],t.displayed&&t.hide();this.hidden=!0},t.exports=i},function(t,e,i){function n(t){s.apply(this,arguments),this.name="continuous",this.settings=o.extend(this.settings||{},{infinite:!0,overflow:"auto",axis:"vertical",offset:500,offsetDelta:250,width:void 0,height:void 0}),o.extend(this.settings,t.settings||{}),"undefined"!=t.settings.gap&&0===t.settings.gap&&(this.settings.gap=t.settings.gap),this.viewSettings={ignoreClass:this.settings.ignoreClass,axis:this.settings.axis,layout:this.layout,width:0,height:0},this.scrollTop=0,this.scrollLeft=0}var r=i(2),o=i(11),s=i(32);n.prototype=Object.create(s.prototype),n.prototype.constructor=n,n.prototype.display=function(t,e){return s.prototype.display.call(this,t,e).then(function(){return this.fill()}.bind(this))},n.prototype.fill=function(t){var e=t||new r.defer;return this.check().then(function(t){t?this.fill(e):e.resolve()}.bind(this)),e.promise},n.prototype.moveTo=function(t){var e=0,i=0,n=0,r=0;return"vertical"===this.settings.axis?(i=t.top,r=t.top+this.settings.offset):(e=Math.floor(t.left/this.layout.delta)*this.layout.delta,n=e+this.settings.offset),this.check(n,r).then(function(){this.scrollBy(e,i)}.bind(this))},n.prototype.resize=function(t,e){this.q.clear(),this._stageSize=this.stage.size(t,e),this._bounds=this.bounds(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.views.each(function(t){t.size(this._stageSize.width,this._stageSize.height)}.bind(this)),this.updateLayout(),this.trigger("resized",{width:this.stage.width,height:this.stage.height})},n.prototype.onResized=function(t){clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){this.resize()}.bind(this),150)},n.prototype.afterResized=function(t){this.trigger("resize",t.section)},n.prototype.removeShownListeners=function(t){t.onDisplayed=function(){}},n.prototype.append=function(t){var e=this.createView(t);return this.views.append(e),e},n.prototype.prepend=function(t){var e=this.createView(t);return e.on("resized",this.counter.bind(this)),this.views.prepend(e),e},n.prototype.counter=function(t){"vertical"===this.settings.axis?this.scrollBy(0,t.heightDelta,!0):this.scrollBy(t.widthDelta,0,!0)},n.prototype.update=function(t){for(var e,i,n=this.bounds(),o=this.views.all(),s=o.length,a=[],h="undefined"!=typeof t?t:this.settings.offset||0,u=new r.defer,c=[],l=0;l<s;l++)i=o[l],e=this.isVisible(i,h,h,n),e===!0?(i.displayed||c.push(i.display(this.request).then(function(t){t.show()})),a.push(i)):(this.q.enqueue(i.destroy.bind(i)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.q.enqueue(this.trim.bind(this))}.bind(this),250));return c.length?r.all(c):(u.resolve(),u.promise)},n.prototype.check=function(t,e){var i,n,o,s,a=new r.defer,h=[],u="horizontal"===this.settings.axis,c=this.settings.offset||0;t&&u&&(c=t),e&&!u&&(c=e);var l=this._bounds,p=u?this.scrollLeft:this.scrollTop,d=u?l.width:l.height,f=u?this.container.scrollWidth:this.container.scrollHeight;return p+d+c>=f&&(i=this.views.last(),o=i&&i.section.next(),o&&h.push(this.append(o))),p-c<0&&(n=this.views.first(),s=n&&n.section.prev(),s&&h.push(this.prepend(s))),h.length?this.q.enqueue(function(){return this.update(c)}.bind(this)):(a.resolve(!1),a.promise)},n.prototype.trim=function(){for(var t=new r.defer,e=this.views.displayed(),i=e[0],n=e[e.length-1],o=this.views.indexOf(i),s=this.views.indexOf(n),a=this.views.slice(0,o),h=this.views.slice(s+1),u=0;u<a.length-1;u++)this.erase(a[u],a);for(var c=1;c<h.length;c++)this.erase(h[c]);return t.resolve(),t.promise},n.prototype.erase=function(t,e){var i,n;this.settings.height?(i=this.container.scrollTop,n=this.container.scrollLeft):(i=window.scrollY,n=window.scrollX);var r=t.bounds();this.views.remove(t),e&&("vertical"===this.settings.axis?this.scrollTo(0,i-r.height,!0):this.scrollTo(n-r.width,0,!0))},n.prototype.addEventListeners=function(t){window.addEventListener("unload",function(t){this.ignore=!0,this.destroy()}.bind(this)),this.addScrollListeners()},n.prototype.addScrollListeners=function(){var t;this.tick=o.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?(t=this.container,this.scrollTop=this.container.scrollTop,this.scrollLeft=this.container.scrollLeft):(t=window,this.scrollTop=window.scrollY,this.scrollLeft=window.scrollX),t.addEventListener("scroll",this.onScroll.bind(this)),this.scrolled=!1},n.prototype.onScroll=function(){this.settings.height?(scrollTop=this.container.scrollTop,scrollLeft=this.container.scrollLeft):(scrollTop=window.scrollY,scrollLeft=window.scrollX),this.scrollTop=scrollTop,this.scrollLeft=scrollLeft,this.ignore?this.ignore=!1:(0===this.scrollDeltaVert&&0===this.scrollDeltaHorz||this.scrollDeltaVert>this.settings.offsetDelta||this.scrollDeltaHorz>this.settings.offsetDelta)&&(this.q.enqueue(function(){this.check()}.bind(this)),this.scrollDeltaVert=0,this.scrollDeltaHorz=0,this.trigger("scroll",{top:scrollTop,left:scrollLeft}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.trigger("scrolled",{top:this.scrollTop,left:this.scrollLeft})}.bind(this))),this.scrollDeltaVert+=Math.abs(scrollTop-this.prevScrollTop),this.scrollDeltaHorz+=Math.abs(scrollLeft-this.prevScrollLeft),this.prevScrollTop=scrollTop,this.prevScrollLeft=scrollLeft,clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(function(){this.scrollDeltaVert=0,this.scrollDeltaHorz=0}.bind(this),150),this.scrolled=!1},n.prototype.currentLocation=function(){return"vertical"===this.settings.axis?this.location=this.scrolledLocation():this.location=this.paginatedLocation(),this.location},n.prototype.scrolledLocation=function(){var t,e,i=this.visible();this.container.getBoundingClientRect();return 1===i.length?this.mapping.page(i[0].contents,i[0].section.cfiBase):i.length>1?(t=this.mapping.page(i[0].contents,i[0].section.cfiBase),e=this.mapping.page(i[i.length-1].contents,i[i.length-1].section.cfiBase),{start:t.start,end:e.end}):void 0},n.prototype.paginatedLocation=function(){var t,e,i,n,r,o,s=this.visible(),a=this.container.getBoundingClientRect();return 1===s.length?(t=a.left-s[0].position().left,i=t+this.layout.spreadWidth,this.mapping.page(s[0].contents,s[0].section.cfiBase,t,i)):s.length>1?(t=a.left-s[0].position().left,i=t+this.layout.columnWidth,e=a.left+this.layout.spreadWidth-s[s.length-1].position().left,n=e+this.layout.columnWidth,r=this.mapping.page(s[0].contents,s[0].section.cfiBase,t,i),o=this.mapping.page(s[s.length-1].contents,s[s.length-1].section.cfiBase,e,n),{start:r.start,end:o.end}):void 0},n.prototype.updateLayout=function(){this.stage&&("vertical"===this.settings.axis?this.layout.calculate(this._stageSize.width,this._stageSize.height):(this.layout.calculate(this._stageSize.width,this._stageSize.height,this.settings.gap),this.settings.offset=this.layout.delta,this.stage.addStyleRules("iframe",[{"margin-right":this.layout.gap+"px"}])),this.viewSettings.width=this.layout.width,this.viewSettings.height=this.layout.height,this.setLayout(this.layout))},n.prototype.next=function(){"horizontal"===this.settings.axis?(this.scrollLeft=this.container.scrollLeft,this.container.scrollLeft+this.container.offsetWidth+this.layout.delta<this.container.scrollWidth?this.scrollBy(this.layout.delta,0):this.scrollTo(this.container.scrollWidth-this.layout.delta,0)):this.scrollBy(0,this.layout.height)},n.prototype.prev=function(){"horizontal"===this.settings.axis?this.scrollBy(-this.layout.delta,0):this.scrollBy(0,-this.layout.height)},n.prototype.updateFlow=function(t){var e="paginated"===t?"horizontal":"vertical";this.settings.axis=e,this.viewSettings.axis=e,this.settings.overflow="paginated"===t?"hidden":"auto","vertical"===this.settings.axis?this.settings.infinite=!0:this.settings.infinite=!1},t.exports=n}])}); |