@tindtechnologies/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
2 lines • 495 kB
JavaScript
/*! For license information please see 6982.3896e3deeb81edffeb43.js.LICENSE.txt */
(self.webpackChunkUV=self.webpackChunkUV||[]).push([[6982],{6982(t,e,n){"use strict";n.r(e),n.d(e,{uv_ebook_reader:()=>yc,uv_ebook_toc:()=>wc});var i,r=n(6233),o=(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},i(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{h(i.next(t))}catch(t){o(t)}}function a(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}h((i=i.apply(t,e||[])).next())}))},a=function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function c(t,e){return t(e={exports:{}},e.exports),e.exports}var l=function(t){return null!=t},f={object:!0,function:!0,undefined:!0},d=/^\s*class[\s{/}]/,p=Function.prototype.toString,m=function(t){return!!function(t){if("function"!=typeof t)return!1;if(!hasOwnProperty.call(t,"length"))return!1;try{if("number"!=typeof t.length)return!1;if("function"!=typeof t.call)return!1;if("function"!=typeof t.apply)return!1}catch(t){return!1}return!function(t){if(!function(t){return!!l(t)&&hasOwnProperty.call(f,typeof t)}(t))return!1;try{return!!t.constructor&&t.constructor.prototype===t}catch(t){return!1}}(t)}(t)&&!d.test(p.call(t))},g=function(t){return null!=t},v=Object.keys,y=function(){try{return!0}catch(t){return!1}}()?Object.keys:function(t){return v(g(t)?Object(t):t)},w=Math.max,b=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}()?Object.assign:function(t,e){var n,i,r,o=w(arguments.length,2);for(t=Object(function(t){if(!g(t))throw new TypeError("Cannot use null or undefined");return t}(t)),r=function(i){try{t[i]=e[i]}catch(t){n||(n=t)}},i=1;i<o;++i)y(e=arguments[i]).forEach(r);if(void 0!==n)throw n;return t},_=Array.prototype.forEach,x=Object.create,k=function(t){var e=x(null);return _.call(arguments,(function(t){g(t)&&function(t,e){var n;for(n in t)e[n]=t[n]}(Object(t),e)})),e},E="razdwatrzy",S=String.prototype.indexOf,C="function"==typeof E.contains&&!0===E.contains("dwa")&&!1===E.contains("foo")?String.prototype.contains:function(t){return S.call(this,t,arguments[1])>-1},T=c((function(t){var e=t.exports=function(t,e){var n,i,r,o,s;return arguments.length<2||"string"!=typeof t?(o=e,e=t,t=null):o=arguments[2],l(t)?(n=C.call(t,"c"),i=C.call(t,"e"),r=C.call(t,"w")):(n=r=!0,i=!1),s={value:e,configurable:n,enumerable:i,writable:r},o?b(k(o),s):s};e.gs=function(t,e,n){var i,r,o,s;return"string"!=typeof t?(o=n,n=e,e=t,t=null):o=arguments[3],l(e)?m(e)?l(n)?m(n)||(o=n,n=void 0):n=void 0:(o=e,e=n=void 0):e=void 0,l(t)?(i=C.call(t,"c"),r=C.call(t,"e")):(i=!0,r=!1),s={get:e,set:n,configurable:i,enumerable:r},o?b(k(o),s):s}})),A=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t},N=c((function(t,e){var n,i,r,o,s,a,h,u=Function.prototype.apply,c=Function.prototype.call,l=Object.create,f=Object.defineProperty,d=Object.defineProperties,p=Object.prototype.hasOwnProperty,m={configurable:!0,enumerable:!1,writable:!0};n=function(t,e){var n;return A(e),p.call(this,"__ee__")?n=this.__ee__:(n=m.value=l(null),f(this,"__ee__",m),m.value=null),n[t]?"object"==typeof n[t]?n[t].push(e):n[t]=[n[t],e]:n[t]=e,this},i=function(t,e){var i,o;return A(e),o=this,n.call(this,t,i=function(){r.call(o,t,i),u.call(e,this,arguments)}),i.__eeOnceListener__=e,this},r=function(t,e){var n,i,r,o;if(A(e),!p.call(this,"__ee__"))return this;if(!(n=this.__ee__)[t])return this;if("object"==typeof(i=n[t]))for(o=0;r=i[o];++o)r!==e&&r.__eeOnceListener__!==e||(2===i.length?n[t]=i[o?0:1]:i.splice(o,1));else i!==e&&i.__eeOnceListener__!==e||delete n[t];return this},o=function(t){var e,n,i,r,o;if(p.call(this,"__ee__")&&(r=this.__ee__[t]))if("object"==typeof r){for(n=arguments.length,o=new Array(n-1),e=1;e<n;++e)o[e-1]=arguments[e];for(r=r.slice(),e=0;i=r[e];++e)u.call(i,this,o)}else switch(arguments.length){case 1:c.call(r,this);break;case 2:c.call(r,this,arguments[1]);break;case 3:c.call(r,this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),e=1;e<n;++e)o[e-1]=arguments[e];u.call(r,this,o)}},s={on:n,once:i,off:r,emit:o},a={on:T(n),once:T(i),off:T(r),emit:T(o)},h=d({},a),t.exports=e=function(t){return null==t?l(h):d(Object(t),a)},e.methods=s})),R="undefined"!=typeof window&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),I="undefined"!=typeof URL?URL:"undefined"!=typeof window?window.URL||window.webkitURL||window.mozURL:void 0;function O(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:7&n|8).toString(16)}))}function z(t){return!(!t||1!=t.nodeType)}function D(t){return!isNaN(parseFloat(t))&&isFinite(t)}function L(t){var e=parseFloat(t);return!1!==D(t)&&("string"==typeof t&&t.indexOf(".")>-1||Math.floor(e)!==e)}function B(t){var e=["-webkit-","-webkit-","-moz-","-o-","-ms-"],n=t.toLowerCase();if("undefined"==typeof document||void 0!==document.body.style[n])return t;for(var i=0;i<5;i++)if(void 0!==document.body.style[e[i]+n])return e[i]+n;return t}function P(t){for(var e=1,n=arguments.length;e<n;e++){var i=arguments[e];for(var r in i)void 0===t[r]&&(t[r]=i[r])}return t}function j(t){return[].slice.call(arguments,1).forEach((function(e){e&&Object.getOwnPropertyNames(e).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))})),t}function U(t,e,n,i,r){var o,s=i||0,a=r||e.length,h=parseInt(s+(a-s)/2);return n||(n=function(t,e){return t>e?1:t<e?-1:t==e?0:void 0}),a-s<=0?h:(o=n(e[h],t),a-s==1?o>=0?h:h+1:0===o?h:-1===o?U(t,e,n,h,a):U(t,e,n,s,h))}function F(t,e,n,i,r){var o,s=i||0,a=r||e.length,h=parseInt(s+(a-s)/2);return n||(n=function(t,e){return t>e?1:t<e?-1:t==e?0:void 0}),a-s<=0?-1:(o=n(e[h],t),a-s==1?0===o?h:-1:0===o?h:-1===o?F(t,e,n,h,a):F(t,e,n,s,h))}function M(t){var e=window.getComputedStyle(t),n=0,i=0;return["width","paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"].forEach((function(t){n+=parseFloat(e[t])||0})),["height","paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"].forEach((function(t){i+=parseFloat(e[t])||0})),{height:i,width:n}}function W(t){var e=window.getComputedStyle(t),n=0,i=0;return["paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"].forEach((function(t){n+=parseFloat(e[t])||0})),["paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"].forEach((function(t){i+=parseFloat(e[t])||0})),{height:i,width:n}}function q(t){var e,n=t.ownerDocument;if(t.nodeType==Node.TEXT_NODE){var i=n.createRange();i.selectNodeContents(t),e=i.getBoundingClientRect()}else e=t.getBoundingClientRect();return e}function H(){var t=window.innerWidth,e=window.innerHeight;return{top:0,left:0,right:t,bottom:e,width:t,height:e}}function Z(t,e){for(var n,i=t.parentNode.childNodes,r=-1,o=0;o<i.length&&((n=i[o]).nodeType===e&&r++,n!=t);o++);return r}function Y(t){return Z(t,1)}function V(t){return["xml","opf","ncx"].indexOf(t)>-1}function X(t,e){return new Blob([t],{type:e})}function K(t,e){var n=X(t,e);return I.createObjectURL(n)}function $(t){return I.revokeObjectURL(t)}function G(t,e){if("string"==typeof t)return"data:"+e+";base64,"+btoa(encodeURIComponent(t))}function J(t){return Object.prototype.toString.call(t).slice(8,-1)}function Q(t,e,i){var r;return r="undefined"==typeof DOMParser||i?n(9788).S:DOMParser,65279===t.charCodeAt(0)&&(t=t.slice(1)),(new r).parseFromString(t,e)}function tt(t,e){var n;if(!t)throw new Error("No Element Provided");return void 0!==t.querySelector?t.querySelector(e):(n=t.getElementsByTagName(e)).length?n[0]:void 0}function et(t,e){return void 0!==t.querySelector?t.querySelectorAll(e):t.getElementsByTagName(e)}function nt(t,e,n){var i,r;if(void 0!==t.querySelector){for(var o in e+="[",n)e+=o+"~='"+n[o]+"'";return e+="]",t.querySelector(e)}if(i=t.getElementsByTagName(e),r=Array.prototype.slice.call(i,0).filter((function(t){for(var e in n)if(t.getAttribute(e)===n[e])return!0;return!1})),r)return r[0]}function it(t,e){void 0!==(t.ownerDocument||t).createTreeWalker?rt(t,e,NodeFilter.SHOW_TEXT):ot(t,(function(t){t&&3===t.nodeType&&e(t)}))}function rt(t,e,n){for(var i,r=document.createTreeWalker(t,n,null,!1);i=r.nextNode();)e(i)}function ot(t,e){if(e(t))return!0;if(t=t.firstChild)do{if(ot(t,e))return!0;t=t.nextSibling}while(t)}function st(t){return new Promise((function(e,n){var i=new FileReader;i.readAsDataURL(t),i.onloadend=function(){e(i.result)}}))}function at(){var t=this;this.resolve=null,this.reject=null,this.id=O(),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n})),Object.freeze(this)}function ht(t,e,n){var i;if(void 0!==t.querySelector&&(i=t.querySelector(e+'[*|type="'+n+'"]')),i&&0!==i.length)return i;i=et(t,e);for(var r=0;r<i.length;r++)if(i[r].getAttributeNS("http://www.idpf.org/2007/ops","type")===n||i[r].getAttribute("epub:type")===n)return i[r]}function ut(t){for(var e=[],n=t.childNodes,i=0;i<n.length;i++){var r=n[i];1===r.nodeType&&e.push(r)}return e}function ct(t){for(var e=[t];t;t=t.parentNode)e.unshift(t);return e}function lt(t,e,n){for(var i=[],r=t.childNodes,o=0;o<r.length;o++){var s=r[o];if(1===s.nodeType&&s.nodeName.toLowerCase()===e){if(n)return s;i.push(s)}}if(!n)return i}function ft(t,e){var n;if(null!==t&&""!==e)for(n=t.parentNode;1===n.nodeType;){if(n.tagName.toLowerCase()===e)return n;n=n.parentNode}}var dt=function(){function t(){this.collapsed=!1,this.commonAncestorContainer=void 0,this.endContainer=void 0,this.endOffset=void 0,this.startContainer=void 0,this.startOffset=void 0}return t.prototype.setStart=function(t,e){this.startContainer=t,this.startOffset=e,this.endContainer?this.commonAncestorContainer=this._commonAncestorContainer():this.collapse(!0),this._checkCollapsed()},t.prototype.setEnd=function(t,e){this.endContainer=t,this.endOffset=e,this.startContainer?(this.collapsed=!1,this.commonAncestorContainer=this._commonAncestorContainer()):this.collapse(!1),this._checkCollapsed()},t.prototype.collapse=function(t){this.collapsed=!0,t?(this.endContainer=this.startContainer,this.endOffset=this.startOffset,this.commonAncestorContainer=this.startContainer.parentNode):(this.startContainer=this.endContainer,this.startOffset=this.endOffset,this.commonAncestorContainer=this.endOffset.parentNode)},t.prototype.selectNode=function(t){var e=t.parentNode,n=Array.prototype.indexOf.call(e.childNodes,t);this.setStart(e,n),this.setEnd(e,n+1)},t.prototype.selectNodeContents=function(t){var e=3===t.nodeType?t.textContent.length:parent.childNodes.length;this.setStart(t,0),this.setEnd(t,e)},t.prototype._commonAncestorContainer=function(t,e){var n=ct(t||this.startContainer),i=ct(e||this.endContainer);if(n[0]==i[0])for(var r=0;r<n.length;r++)if(n[r]!=i[r])return n[r-1]},t.prototype._checkCollapsed=function(){this.startContainer===this.endContainer&&this.startOffset===this.endOffset?this.collapsed=!0:this.collapsed=!1},t.prototype.toString=function(){},t}(),pt=Object.freeze({__proto__:null,requestAnimationFrame:R,uuid:O,documentHeight:function(){return Math.max(document.documentElement.clientHeight,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight)},isElement:z,isNumber:D,isFloat:L,prefixed:B,defaults:P,extend:j,insert:function(t,e,n){var i=U(t,e,n);return e.splice(i,0,t),i},locationOf:U,indexOfSorted:F,bounds:M,borders:W,nodeBounds:q,windowBounds:H,indexOfNode:Z,indexOfTextNode:function(t){return Z(t,3)},indexOfElementNode:Y,isXml:V,createBlob:X,createBlobUrl:K,revokeBlobUrl:$,createBase64Url:G,type:J,parse:Q,qs:tt,qsa:et,qsp:nt,sprint:it,treeWalker:rt,walk:ot,blob2base64:st,defer:at,querySelectorByType:ht,findChildren:ut,parents:ct,filterChildren:lt,getParentByTagName:ft,RangeObject:dt});if(!mt)var mt={cwd:function(){return"/"}};function gt(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+t)}function vt(t,e){for(var n,i="",r=-1,o=0,s=0;s<=t.length;++s){if(s<t.length)n=t.charCodeAt(s);else{if(47===n)break;n=47}if(47===n){if(r===s-1||1===o);else if(r!==s-1&&2===o){if(i.length<2||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){for(var a=i.length-1,h=a;h>=0&&47!==i.charCodeAt(h);--h);if(h!==a){i=-1===h?"":i.slice(0,h),r=s,o=0;continue}}else if(2===i.length||1===i.length){i="",r=s,o=0;continue}e&&(i.length>0?i+="/..":i="..")}else i.length>0?i+="/"+t.slice(r+1,s):i=t.slice(r+1,s);r=s,o=0}else 46===n&&-1!==o?++o:o=-1}return i}var yt={resolve:function(){for(var t,e="",n=!1,i=arguments.length-1;i>=-1&&!n;i--){var r;i>=0?r=arguments[i]:(void 0===t&&(t=mt.cwd()),r=t),gt(r),0!==r.length&&(e=r+"/"+e,n=47===r.charCodeAt(0))}return e=vt(e,!n),n?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(t){if(gt(t),0===t.length)return".";var e=47===t.charCodeAt(0),n=47===t.charCodeAt(t.length-1);return 0!==(t=vt(t,!e)).length||e||(t="."),t.length>0&&n&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return gt(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var t,e=0;e<arguments.length;++e){var n=arguments[e];gt(n),n.length>0&&(void 0===t?t=n:t+="/"+n)}return void 0===t?".":yt.normalize(t)},relative:function(t,e){if(gt(t),gt(e),t===e)return"";if((t=yt.resolve(t))===(e=yt.resolve(e)))return"";for(var n=1;n<t.length&&47===t.charCodeAt(n);++n);for(var i=t.length,r=i-n,o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var s=e.length-o,a=r<s?r:s,h=-1,u=0;u<=a;++u){if(u===a){if(s>a){if(47===e.charCodeAt(o+u))return e.slice(o+u+1);if(0===u)return e.slice(o+u)}else r>a&&(47===t.charCodeAt(n+u)?h=u:0===u&&(h=0));break}var c=t.charCodeAt(n+u);if(c!==e.charCodeAt(o+u))break;47===c&&(h=u)}var l="";for(u=n+h+1;u<=i;++u)u!==i&&47!==t.charCodeAt(u)||(0===l.length?l+="..":l+="/..");return l.length>0?l+e.slice(o+h):(o+=h,47===e.charCodeAt(o)&&++o,e.slice(o))},_makeLong:function(t){return t},dirname:function(t){if(gt(t),0===t.length)return".";for(var e=t.charCodeAt(0),n=47===e,i=-1,r=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!r){i=o;break}}else r=!1;return-1===i?n?"/":".":n&&1===i?"//":t.slice(0,i)},basename:function(t,e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('"ext" argument must be a string');gt(t);var n,i=0,r=-1,o=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var s=e.length-1,a=-1;for(n=t.length-1;n>=0;--n){var h=t.charCodeAt(n);if(47===h){if(!o){i=n+1;break}}else-1===a&&(o=!1,a=n+1),s>=0&&(h===e.charCodeAt(s)?-1==--s&&(r=n):(s=-1,r=a))}return i===r?r=a:-1===r&&(r=t.length),t.slice(i,r)}for(n=t.length-1;n>=0;--n)if(47===t.charCodeAt(n)){if(!o){i=n+1;break}}else-1===r&&(o=!1,r=n+1);return-1===r?"":t.slice(i,r)},extname:function(t){gt(t);for(var e=-1,n=0,i=-1,r=!0,o=0,s=t.length-1;s>=0;--s){var a=t.charCodeAt(s);if(47!==a)-1===i&&(r=!1,i=s+1),46===a?-1===e?e=s:1!==o&&(o=1):-1!==e&&(o=-1);else if(!r){n=s+1;break}}return-1===e||-1===i||0===o||1===o&&e===i-1&&e===n+1?"":t.slice(e,i)},format:function(t){if(null===t||"object"!=typeof t)throw new TypeError('Parameter "pathObject" must be an object, not '+typeof t);return function(t,e){var n=e.dir||e.root,i=e.base||(e.name||"")+(e.ext||"");return n?n===e.root?n+i:n+"/"+i:i}(0,t)},parse:function(t){gt(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;var n,i=t.charCodeAt(0),r=47===i;r?(e.root="/",n=1):n=0;for(var o=-1,s=0,a=-1,h=!0,u=t.length-1,c=0;u>=n;--u)if(47!==(i=t.charCodeAt(u)))-1===a&&(h=!1,a=u+1),46===i?-1===o?o=u:1!==c&&(c=1):-1!==o&&(c=-1);else if(!h){s=u+1;break}return-1===o||-1===a||0===c||1===c&&o===a-1&&o===s+1?-1!==a&&(e.base=e.name=0===s&&r?t.slice(1,a):t.slice(s,a)):(0===s&&r?(e.name=t.slice(1,o),e.base=t.slice(1,a)):(e.name=t.slice(s,o),e.base=t.slice(s,a)),e.ext=t.slice(o,a)),s>0?e.dir=t.slice(0,s-1):r&&(e.dir="/"),e},sep:"/",delimiter:":",posix:null},wt=yt,bt=function(){function t(t){var e;t.indexOf("://")>-1&&(t=new URL(t).pathname),e=this.parse(t),this.path=t,this.isDirectory(t)?this.directory=t:this.directory=e.dir+"/",this.filename=e.base,this.extension=e.ext.slice(1)}return t.prototype.parse=function(t){return wt.parse(t)},t.prototype.isAbsolute=function(t){return wt.isAbsolute(t||this.path)},t.prototype.isDirectory=function(t){return"/"===t.charAt(t.length-1)},t.prototype.resolve=function(t){return wt.resolve(this.directory,t)},t.prototype.relative=function(t){return t&&t.indexOf("://")>-1?t:wt.relative(this.directory,t)},t.prototype.splitPath=function(t){return this.splitPathRe.exec(t).slice(1)},t.prototype.toString=function(){return this.path},t}(),_t=function(){function t(t,e){var n=t.indexOf("://")>-1,i=t;if(this.Url=void 0,this.href=t,this.protocol="",this.origin="",this.hash="",this.hash="",this.search="",this.base=e,!n&&!1!==e&&"string"!=typeof e&&window&&window.location&&(this.base=window.location.href),n||this.base)try{this.base?this.Url=new URL(t,this.base):this.Url=new URL(t),this.href=this.Url.href,this.protocol=this.Url.protocol,this.origin=this.Url.origin,this.hash=this.Url.hash,this.search=this.Url.search,i=this.Url.pathname+(this.Url.search?this.Url.search:"")}catch(t){this.Url=void 0,this.base&&(i=new bt(this.base).resolve(i))}this.Path=new bt(i),this.directory=this.Path.directory,this.filename=this.Path.filename,this.extension=this.Path.extension}return t.prototype.path=function(){return this.Path},t.prototype.resolve=function(t){var e;return t.indexOf("://")>-1?t:(e=wt.resolve(this.directory,t),this.origin+e)},t.prototype.relative=function(t){return wt.relative(t,this.directory)},t.prototype.toString=function(){return this.href},t}(),xt=function(){function t(e,n,i){var r;if(this.str="",this.base={},this.spinePos=0,this.range=!1,this.path={},this.start=null,this.end=null,!(this instanceof t))return new t(e,n,i);if("string"==typeof n?this.base=this.parseComponent(n):"object"==typeof n&&n.steps&&(this.base=n),"string"===(r=this.checkType(e)))return this.str=e,j(this,this.parse(e));if("range"===r)return j(this,this.fromRange(e,this.base,i));if("node"===r)return j(this,this.fromNode(e,this.base,i));if("EpubCFI"===r&&e.path)return e;if(e)throw new TypeError("not a valid argument for EpubCFI");return this}return t.prototype.checkType=function(e){return this.isCfiString(e)?"string":!e||"object"!=typeof e||"Range"!==J(e)&&void 0===e.startContainer?e&&"object"==typeof e&&void 0!==e.nodeType?"node":!!(e&&"object"==typeof e&&e instanceof t)&&"EpubCFI":"range"},t.prototype.parse=function(t){var e,n,i,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),n=this.getPathComponent(t),r.path=this.parseComponent(n),(i=this.getRange(t))&&(r.range=!0,r.start=this.parseComponent(i[0]),r.end=this.parseComponent(i[1])),r.spinePos=r.base.steps[1].index,r):{spinePos:-1})},t.prototype.parseComponent=function(t){var e,n={steps:[],terminal:{offset:null,assertion:null}},i=t.split(":"),r=i[0].split("/");return i.length>1&&(e=i[1],n.terminal=this.parseTerminal(e)),""===r[0]&&r.shift(),n.steps=r.map(function(t){return this.parseStep(t)}.bind(this)),n},t.prototype.parseStep=function(t){var e,n,i,r,o;if((r=t.match(/\[(.*)\]/))&&r[1]&&(o=r[1]),n=parseInt(t),!isNaN(n))return n%2==0?(e="element",i=n/2-1):(e="text",i=(n-1)/2),{type:e,index:i,id:o||null}},t.prototype.parseTerminal=function(t){var e,n,i=t.match(/\[(.*)\]/);return i&&i[1]?(e=parseInt(t.split("[")[0]),n=i[1]):e=parseInt(t),D(e)||(e=null),{offset:e,assertion:n}},t.prototype.getChapterComponent=function(t){return t.split("!")[0]},t.prototype.getPathComponent=function(t){var e=t.split("!");if(e[1])return e[1].split(",")[0]},t.prototype.getRange=function(t){var e=t.split(",");return 3===e.length&&[e[1],e[2]]},t.prototype.getCharecterOffsetComponent=function(t){return t.split(":")[1]||""},t.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("/"):""},t.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},t.prototype.toString=function(){var t="epubcfi(";return t+=this.segmentString(this.base),t+="!",t+=this.segmentString(this.path),this.range&&this.start&&(t+=",",t+=this.segmentString(this.start)),this.range&&this.end&&(t+=",",t+=this.segmentString(this.end)),t+")"},t.prototype.compare=function(e,n){var i,r,o,s;if("string"==typeof e&&(e=new t(e)),"string"==typeof n&&(n=new t(n)),e.spinePos>n.spinePos)return 1;if(e.spinePos<n.spinePos)return-1;e.range?(i=e.path.steps.concat(e.start.steps),o=e.start.terminal):(i=e.path.steps,o=e.path.terminal),n.range?(r=n.path.steps.concat(n.start.steps),s=n.start.terminal):(r=n.path.steps,s=n.path.terminal);for(var a=0;a<i.length;a++){if(!i[a])return-1;if(!r[a])return 1;if(i[a].index>r[a].index)return 1;if(i[a].index<r[a].index)return-1}return i.length<r.length?-1:o.offset>s.offset?1:o.offset<s.offset?-1:0},t.prototype.step=function(t){var e=3===t.nodeType?"text":"element";return{id:t.id,tagName:t.tagName,type:e,index:this.position(t)}},t.prototype.filteredStep=function(t,e){var n,i=this.filter(t,e);if(i)return n=3===i.nodeType?"text":"element",{id:i.id,tagName:i.tagName,type:n,index:this.filteredPosition(i,e)}},t.prototype.pathTo=function(t,e,n){for(var i,r={steps:[],terminal:{offset:null,assertion:null}},o=t;o&&o.parentNode&&9!=o.parentNode.nodeType;)(i=n?this.filteredStep(o,n):this.step(o))&&r.steps.unshift(i),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},t.prototype.equalStep=function(t,e){return!(!t||!e)&&t.index===e.index&&t.id===e.id&&t.type===e.type},t.prototype.fromRange=function(t,e,n){var i={range:!1,base:{},path:{},start:null,end:null},r=t.startContainer,o=t.endContainer,s=t.startOffset,a=t.endOffset,h=!1;if(n&&(h=null!=r.ownerDocument.querySelector("."+n)),"string"==typeof e?(i.base=this.parseComponent(e),i.spinePos=i.base.steps[1].index):"object"==typeof e&&(i.base=e),t.collapsed)h&&(s=this.patchOffset(r,s,n)),i.path=this.pathTo(r,s,n);else{i.range=!0,h&&(s=this.patchOffset(r,s,n)),i.start=this.pathTo(r,s,n),h&&(a=this.patchOffset(o,a,n)),i.end=this.pathTo(o,a,n),i.path={steps:[],terminal:null};var u,c=i.start.steps.length;for(u=0;u<c&&this.equalStep(i.start.steps[u],i.end.steps[u]);u++)u===c-1?i.start.terminal===i.end.terminal&&(i.path.steps.push(i.start.steps[u]),i.range=!1):i.path.steps.push(i.start.steps[u]);i.start.steps=i.start.steps.slice(i.path.steps.length),i.end.steps=i.end.steps.slice(i.path.steps.length)}return i},t.prototype.fromNode=function(t,e,n){var i={range:!1,base:{},path:{},start:null,end:null};return"string"==typeof e?(i.base=this.parseComponent(e),i.spinePos=i.base.steps[1].index):"object"==typeof e&&(i.base=e),i.path=this.pathTo(t,null,n),i},t.prototype.filter=function(t,e){var n,i,r,o,s,a=!1;return 3===t.nodeType?(a=!0,r=t.parentNode,n=t.parentNode.classList.contains(e)):(a=!1,n=t.classList.contains(e)),n&&a?(o=r.previousSibling,s=r.nextSibling,o&&3===o.nodeType?i=o:s&&3===s.nodeType&&(i=s),i||t):!(n&&!a)&&t},t.prototype.patchOffset=function(t,e,n){if(3!=t.nodeType)throw new Error("Anchor must be a text node");var i=t,r=e;for(t.parentNode.classList.contains(n)&&(i=t.parentNode);i.previousSibling;){if(1===i.previousSibling.nodeType){if(!i.previousSibling.classList.contains(n))break;r+=i.previousSibling.textContent.length}else r+=i.previousSibling.textContent.length;i=i.previousSibling}return r},t.prototype.normalizedMap=function(t,e,n){var i,r,o,s={},a=-1,h=t.length;for(i=0;i<h;i++)1===(r=t[i].nodeType)&&t[i].classList.contains(n)&&(r=3),i>0&&3===r&&3===o?s[i]=a:e===r&&(a+=1,s[i]=a),o=r;return s},t.prototype.position=function(t){var e,n;return 1===t.nodeType?((e=t.parentNode.children)||(e=ut(t.parentNode)),n=Array.prototype.indexOf.call(e,t)):n=(e=this.textNodes(t.parentNode)).indexOf(t),n},t.prototype.filteredPosition=function(t,e){var n,i;return 1===t.nodeType?(n=t.parentNode.children,i=this.normalizedMap(n,1,e)):(n=t.parentNode.childNodes,t.parentNode.classList.contains(e)&&(n=(t=t.parentNode).parentNode.childNodes),i=this.normalizedMap(n,3,e)),i[Array.prototype.indexOf.call(n,t)]},t.prototype.stepsToXpath=function(t){var e=[".","*"];return t.forEach((function(t){var n=t.index+1;t.id?e.push("*[position()="+n+" and @id='"+t.id+"']"):"text"===t.type?e.push("text()["+n+"]"):e.push("*["+n+"]")})),e.join("/")},t.prototype.stepsToQuerySelector=function(t){var e=["html"];return t.forEach((function(t){var n=t.index+1;t.id?e.push("#"+t.id):"text"===t.type||e.push("*:nth-child("+n+")")})),e.join(">")},t.prototype.textNodes=function(t,e){return Array.prototype.slice.call(t.childNodes).filter((function(t){return 3===t.nodeType||!(!e||!t.classList.contains(e))}))},t.prototype.walkToNode=function(t,e,n){var i,r,o=e||document,s=o.documentElement,a=t.length;for(r=0;r<a&&("element"===(i=t[r]).type?s=i.id?o.getElementById(i.id):(s.children||ut(s))[i.index]:"text"===i.type&&(s=this.textNodes(s,n)[i.index]),s);r++);return s},t.prototype.findNode=function(t,e,n){var i,r,o=e||document;return n||void 0===o.evaluate?i=n?this.walkToNode(t,o,n):this.walkToNode(t,o):(r=this.stepsToXpath(t),i=o.evaluate(r,o,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),i},t.prototype.fixMiss=function(t,e,n,i){var r,o,s=this.findNode(t.slice(0,-1),n,i),a=s.childNodes,h=this.normalizedMap(a,3,i),u=t[t.length-1].index;for(var c in h){if(!h.hasOwnProperty(c))return;if(h[c]===u){if(!(e>(o=(r=a[c]).textContent.length))){s=1===r.nodeType?r.childNodes[0]:r;break}e-=o}}return{container:s,offset:e}},t.prototype.toRange=function(t,e){var n,i,r,o,s,a,h,u,c=t||document,l=this,f=!!e&&null!=c.querySelector("."+e);if(n=void 0!==c.createRange?c.createRange():new dt,l.range?(i=l.start,a=l.path.steps.concat(i.steps),o=this.findNode(a,c,f?e:null),r=l.end,h=l.path.steps.concat(r.steps),s=this.findNode(h,c,f?e:null)):(i=l.path,a=l.path.steps,o=this.findNode(l.path.steps,c,f?e:null)),!o)return console.log("No startContainer found for",this.toString()),null;try{null!=i.terminal.offset?n.setStart(o,i.terminal.offset):n.setStart(o,0)}catch(t){u=this.fixMiss(a,i.terminal.offset,c,f?e:null),n.setStart(u.container,u.offset)}if(s)try{null!=r.terminal.offset?n.setEnd(s,r.terminal.offset):n.setEnd(s,0)}catch(t){u=this.fixMiss(h,l.end.terminal.offset,c,f?e:null),n.setEnd(u.container,u.offset)}return n},t.prototype.isCfiString=function(t){return"string"==typeof t&&0===t.indexOf("epubcfi(")&&")"===t[t.length-1]},t.prototype.generateChapterComponent=function(t,e,n){var i="/"+2*(t+1)+"/";return i+=2*(parseInt(e)+1),n&&(i+="["+n+"]"),i},t.prototype.collapse=function(t){this.range&&(this.range=!1,t?(this.path.steps=this.path.steps.concat(this.start.steps),this.path.terminal=this.start.terminal):(this.path.steps=this.path.steps.concat(this.end.steps),this.path.terminal=this.end.terminal))},t}(),kt=function(){function t(t){this.context=t||this,this.hooks=[]}return t.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])},t.prototype.deregister=function(t){for(var e=0;e<this.hooks.length;e++)if(this.hooks[e]===t){this.hooks.splice(e,1);break}},t.prototype.trigger=function(){var t=arguments,e=this.context,n=[];return this.hooks.forEach((function(i){var r=i.apply(e,t);r&&"function"==typeof r.then&&n.push(r)})),Promise.all(n)},t.prototype.list=function(){return this.hooks},t.prototype.clear=function(){return this.hooks=[]},t}();function Et(t,e){var n,i,r=e.url,o=r.indexOf("://")>-1;t&&(i=tt(t,"head"),(n=tt(i,"base"))||(n=t.createElement("base"),i.insertBefore(n,i.firstChild)),!o&&window&&window.location&&(r=window.location.origin+r),n.setAttribute("href",r))}function St(t,e){var n,i,r=e.canonical;t&&(n=tt(t,"head"),(i=tt(n,"link[rel='canonical']"))?i.setAttribute("href",r):((i=t.createElement("link")).setAttribute("rel","canonical"),i.setAttribute("href",r),n.appendChild(i)))}function Ct(t,e){var n,i,r=e.idref;t&&(n=tt(t,"head"),(i=tt(n,"link[property='dc.identifier']"))?i.setAttribute("content",r):((i=t.createElement("meta")).setAttribute("name","dc.identifier"),i.setAttribute("content",r),n.appendChild(i)))}function Tt(t,e,n){return e.forEach((function(e,i){e&&n[i]&&(t=t.replace(new RegExp(e,"g"),n[i]))})),t}var At=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,Nt=new RegExp("[\\-\\.0-9"+At.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),Rt=new RegExp("^"+At.source+Nt.source+"*(?::"+At.source+Nt.source+"*)?$");function It(){}function Ot(t,e){return e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber,e}function zt(t,e,n,i,r,o){for(var s,a=++e,h=0;;){var u=t.charAt(a);switch(u){case"=":if(1===h)s=t.slice(e,a),h=3;else{if(2!==h)throw new Error("attribute equal must after attrName");h=3}break;case"'":case'"':if(3===h||1===h){if(1===h&&(o.warning('attribute value must after "="'),s=t.slice(e,a)),e=a+1,!((a=t.indexOf(u,e))>0))throw new Error("attribute value no end '"+u+"' match");c=t.slice(e,a).replace(/&#?\w+;/g,r),n.add(s,c,e-1),h=5}else{if(4!=h)throw new Error('attribute value must after "="');c=t.slice(e,a).replace(/&#?\w+;/g,r),n.add(s,c,e),o.warning('attribute "'+s+'" missed start quot('+u+")!!"),e=a+1,h=5}break;case"/":switch(h){case 0:n.setTagName(t.slice(e,a));case 5:case 6:case 7:h=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return o.error("unexpected end of input"),0==h&&n.setTagName(t.slice(e,a)),a;case">":switch(h){case 0:n.setTagName(t.slice(e,a));case 5:case 6:case 7:break;case 4:case 1:"/"===(c=t.slice(e,a)).slice(-1)&&(n.closed=!0,c=c.slice(0,-1));case 2:2===h&&(c=s),4==h?(o.warning('attribute "'+c+'" missed quot(")!!'),n.add(s,c.replace(/&#?\w+;/g,r),e)):("http://www.w3.org/1999/xhtml"===i[""]&&c.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!'),n.add(c,c,e));break;case 3:throw new Error("attribute value missed!!")}return a;case"":u=" ";default:if(u<=" ")switch(h){case 0:n.setTagName(t.slice(e,a)),h=6;break;case 1:s=t.slice(e,a),h=2;break;case 4:var c=t.slice(e,a).replace(/&#?\w+;/g,r);o.warning('attribute "'+c+'" missed quot(")!!'),n.add(s,c,e);case 5:h=6}else switch(h){case 2:"http://www.w3.org/1999/xhtml"===i[""]&&s.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),n.add(s,s,e),e=a,h=1;break;case 5:o.warning('attribute space is required"'+s+'"!!');case 6:h=1,e=a;break;case 3:h=4,e=a;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}a++}}function Dt(t,e,n){for(var i=t.tagName,r=null,o=t.length;o--;){var s=t[o],a=s.qName,h=s.value;if((f=a.indexOf(":"))>0)var u=s.prefix=a.slice(0,f),c=a.slice(f+1),l="xmlns"===u&&c;else c=a,u=null,l="xmlns"===a&&"";s.localName=c,!1!==l&&(null==r&&(r={},Pt(n,n={})),n[l]=r[l]=h,s.uri="http://www.w3.org/2000/xmlns/",e.startPrefixMapping(l,h))}for(o=t.length;o--;)(u=(s=t[o]).prefix)&&("xml"===u&&(s.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(s.uri=n[u||""]));var f;(f=i.indexOf(":"))>0?(u=t.prefix=i.slice(0,f),c=t.localName=i.slice(f+1)):(u=null,c=t.localName=i);var d=t.uri=n[u||""];if(e.startElement(d,c,i,t),!t.closed)return t.currentNSMap=n,t.localNSMap=r,!0;if(e.endElement(d,c,i),r)for(u in r)e.endPrefixMapping(u)}function Lt(t,e,n,i,r){if(/^(?:script|textarea)$/i.test(n)){var o=t.indexOf("</"+n+">",e),s=t.substring(e+1,o);if(/[&<]/.test(s))return/^script$/i.test(n)?(r.characters(s,0,s.length),o):(s=s.replace(/&#?\w+;/g,i),r.characters(s,0,s.length),o)}return e+1}function Bt(t,e,n,i){var r=i[n];return null==r&&((r=t.lastIndexOf("</"+n+">"))<e&&(r=t.lastIndexOf("</"+n)),i[n]=r),r<e}function Pt(t,e){for(var n in t)e[n]=t[n]}function jt(t,e,n,i){if("-"===t.charAt(e+2))return"-"===t.charAt(e+3)?(r=t.indexOf("--\x3e",e+4))>e?(n.comment(t,e+4,r-e-4),r+3):(i.error("Unclosed comment"),-1):-1;if("CDATA["==t.substr(e+3,6)){var r=t.indexOf("]]>",e+9);return n.startCDATA(),n.characters(t,e+9,r-e-9),n.endCDATA(),r+3}var o=function(t,e){var n,i=[],r=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(r.lastIndex=e,r.exec(t);n=r.exec(t);)if(i.push(n),n[1])return i}(t,e),s=o.length;if(s>1&&/!doctype/i.test(o[0][0])){var a=o[1][0],h=s>3&&/^public$/i.test(o[2][0])&&o[3][0],u=s>4&&o[4][0],c=o[s-1];return n.startDTD(a,h&&h.replace(/^(['"])(.*?)\1$/,"$2"),u&&u.replace(/^(['"])(.*?)\1$/,"$2")),n.endDTD(),c.index+c[0].length}return-1}function Ut(t,e,n){var i=t.indexOf("?>",e);if(i){var r=t.substring(e,i).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return r?(n.processingInstruction(r[1],r[2]),i+2):-1}return-1}function Ft(t){}function Mt(t,e){return t.__proto__=e,t}It.prototype={parse:function(t,e,n){var i=this.domBuilder;i.startDocument(),Pt(e,e={}),function(t,e,n,i,r){function o(t){var e=t.slice(1,-1);return e in n?n[e]:"#"===e.charAt(0)?function(t){if(t>65535){var e=55296+((t-=65536)>>10),n=56320+(1023&t);return String.fromCharCode(e,n)}return String.fromCharCode(t)}(parseInt(e.substr(1).replace("x","0x"))):(r.error("entity not found:"+t),t)}function s(e){if(e>p){var n=t.substring(p,e).replace(/&#?\w+;/g,o);l&&a(p),i.characters(n,0,e-p),p=e}}function a(e,n){for(;e>=u&&(n=c.exec(t));)h=n.index,u=h+n[0].length,l.lineNumber++;l.columnNumber=e-h+1}for(var h=0,u=0,c=/.*(?:\r\n?|\n)|.*$/g,l=i.locator,f=[{currentNSMap:e}],d={},p=0;;){try{var m=t.indexOf("<",p);if(m<0){if(!t.substr(p).match(/^\s*$/)){var g=i.doc,v=g.createTextNode(t.substr(p));g.appendChild(v),i.currentElement=v}return}switch(m>p&&s(m),t.charAt(m+1)){case"/":var y=t.indexOf(">",m+3),w=t.substring(m+2,y),b=f.pop();y<0?(w=t.substring(m+2).replace(/[\s<].*/,""),r.error("end tag name: "+w+" is not complete:"+b.tagName),y=m+1+w.length):w.match(/\s</)&&(w=w.replace(/[\s<].*/,""),r.error("end tag name: "+w+" maybe not complete"),y=m+1+w.length);var _=b.localNSMap,x=b.tagName==w;if(x||b.tagName&&b.tagName.toLowerCase()==w.toLowerCase()){if(i.endElement(b.uri,b.localName,w),_)for(var k in _)i.endPrefixMapping(k);x||r.fatalError("end tag name: "+w+" is not match the current start tagName:"+b.tagName)}else f.push(b);y++;break;case"?":l&&a(m),y=Ut(t,m,i);break;case"!":l&&a(m),y=jt(t,m,i,r);break;default:l&&a(m);var E=new Ft,S=f[f.length-1].currentNSMap,C=(y=zt(t,m,E,S,o,r),E.length);if(!E.closed&&Bt(t,y,E.tagName,d)&&(E.closed=!0,n.nbsp||r.warning("unclosed xml attribute")),l&&C){for(var T=Ot(l,{}),A=0;A<C;A++){var N=E[A];a(N.offset),N.locator=Ot(l,{})}i.locator=T,Dt(E,i,S)&&f.push(E),i.locator=l}else Dt(E,i,S)&&f.push(E);"http://www.w3.org/1999/xhtml"!==E.uri||E.closed?y++:y=Lt(t,y,E.tagName,o,i)}}catch(t){r.error("element parse error: "+t),y=-1}y>p?p=y:s(Math.max(m,p)+1)}}(t,e,n,i,this.errorHandler),i.endDocument()}},Ft.prototype={setTagName:function(t){if(!Rt.test(t))throw new Error("invalid tagName:"+t);this.tagName=t},add:function(t,e,n){if(!Rt.test(t))throw new Error("invalid attribute:"+t);this[this.length++]={qName:t,value:e,offset:n}},length:0,getLocalName:function(t){return this[t].localName},getLocator:function(t){return this[t].locator},getQName:function(t){return this[t].qName},getURI:function(t){return this[t].uri},getValue:function(t){return this[t].value}},Mt({},Mt.prototype)instanceof Mt||(Mt=function(t,e){function n(){}for(e in n.prototype=e,n=new n,t)n[e]=t[e];return n});var Wt=It;function qt(t,e){for(var n in t)e[n]=t[n]}function Ht(t,e){var n=t.prototype;if(Object.create){var i=Object.create(e.prototype);n.__proto__=i}if(!(n instanceof e)){function r(){}r.prototype=e.prototype,qt(n,r=new r),t.prototype=n=r}n.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),n.constructor=t)}var Zt={},Yt=Zt.ELEMENT_NODE=1,Vt=Zt.ATTRIBUTE_NODE=2,Xt=Zt.TEXT_NODE=3,Kt=Zt.CDATA_SECTION_NODE=4,$t=Zt.ENTITY_REFERENCE_NODE=5,Gt=Zt.ENTITY_NODE=6,Jt=Zt.PROCESSING_INSTRUCTION_NODE=7,Qt=Zt.COMMENT_NODE=8,te=Zt.DOCUMENT_NODE=9,ee=Zt.DOCUMENT_TYPE_NODE=10,ne=Zt.DOCUMENT_FRAGMENT_NODE=11,ie=Zt.NOTATION_NODE=12,re={},oe={},se=(re.INDEX_SIZE_ERR=(oe[1]="Index size error",1),re.DOMSTRING_SIZE_ERR=(oe[2]="DOMString size error",2),re.HIERARCHY_REQUEST_ERR=(oe[3]="Hierarchy request error",3)),ae=(re.WRONG_DOCUMENT_ERR=(oe[4]="Wrong document",4),re.INVALID_CHARACTER_ERR=(oe[5]="Invalid character",5),re.NO_DATA_ALLOWED_ERR=(oe[6]="No data allowed",6),re.NO_MODIFICATION_ALLOWED_ERR=(oe[7]="No modification allowed",7),re.NOT_FOUND_ERR=(oe[8]="Not found",8)),he=(re.NOT_SUPPORTED_ERR=(oe[9]="Not supported",9),re.INUSE_ATTRIBUTE_ERR=(oe[10]="Attribute in use",10));function ue(t,e){if(e instanceof Error)var n=e;else n=this,Error.call(this,oe[t]),this.message=oe[t],Error.captureStackTrace&&Error.captureStackTrace(this,ue);return n.code=t,e&&(this.message=this.message+": "+e),n}function ce(){}function le(t,e){this._node=t,this._refresh=e,fe(this)}function fe(t){var e=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=e){var n=t._refresh(t._node);He(t,"length",n.length),qt(n,t),t._inc=e}}function de(){}function pe(t,e){for(var n=t.length;n--;)if(t[n]===e)return n}function me(t,e,n,i){if(i?e[pe(e,i)]=n:e[e.length++]=n,t){n.ownerElement=t;var r=t.ownerDocument;r&&(i&&xe(r,t,i),function(t,e,n){t&&t._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&(e._nsMap[n.prefix?n.localName:""]=n.value)}(r,t,n))}}function ge(t,e,n){var i=pe(e,n);if(!(i>=0))throw ue(ae,new Error(t.tagName+"@"+n));for(var r=e.length-1;i<r;)e[i]=e[++i];if(e.length=r,t){var o=t.ownerDocument;o&&(xe(o,t,n),n.ownerElement=null)}}function ve(t){if(this._features={},t)for(var e in t)this._features=t[e]}function ye(){}function we(t){return("<"==t?"<":">"==t&&">")||"&"==t&&"&"||'"'==t&&"""||"&#"+t.charCodeAt()+";"}function be(t,e){if(e(t))return!0;if(t=t.firstChild)do{if(be(t,e))return!0}while(t=t.nextSibling)}function _e(){}function xe(t,e,n,i){t&&t._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete e._nsMap[n.prefix?n.localName:""]}function ke(t,e,n){if(t&&t._inc){t._inc++;var i=e.childNodes;if(n)i[i.length++]=n;else{for(var r=e.firstChild,o=0;r;)i[o++]=r,r=r.nextSibling;i.length=o}}}function Ee(t,e){var n=e.previousSibling,i=e.nextSibling;return n?n.nextSibling=i:t.firstChild=i,i?i.previousSibling=n:t.lastChild=n,ke(t.ownerDocument,t),e}function Se(t,e,n){var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===ne){var r=e.firstChild;if(null==r)return e;var o=e.lastChild}else r=o=e;var s=n?n.previousSibling:t.lastChild;r.previousSibling=s,o.nextSibling=n,s?s.nextSibling=r:t.firstChild=r,null==n?t.lastChild=o:n.previousSibling=o;do{r.parentNode=t}while(r!==o&&(r=r.nextSibling));return ke(t.ownerDocument||t,t),e.nodeType==ne&&(e.firstChild=e.lastChild=null),e}function Ce(){this._nsMap={}}function Te(){}function Ae(){}function Ne(){}function Re(){}function Ie(){}function Oe(){}function ze(){}function De(){}function Le(){}function Be(){}function Pe(){}function je(){}function Ue(t,e){var n=[],i=9==this.nodeType?this.documentElement:this,r=i.prefix,o=i.namespaceURI;if(o&&null==r&&null==(r=i.lookupPrefix(o)))var s=[{namespace:o,prefix:null}];return Me(this,n,t,e,s),n.join("")}function Fe(t,e,n){var i=t.prefix||"",r=t.namespaceURI;if(!i&&!r)return!1;if("xml"===i&&"http://www.w3.org/XML/1998/namespace"===r||"http://www.w3.org/2000/xmlns/"==r)return!1;for(var o=n.length;o--;){var s=n[o];if(s.prefix==i)return s.namespace!=r}return!0}function Me(t,e,n,i,r){if(i){if(!(t=i(t)))return;if("string"==typeof t)return void e.push(t)}switch(t.nodeType){case Yt:r||(r=[]);var o=t.attributes,s=o.length,a=t.firstChild,h=t.tagName;n="http://www.w3.org/1999/xhtml"===t.namespaceURI||n,e.push("<",h);for(var u=0;u<s;u++)"xmlns"==(c=o.item(u)).prefix?r.push({prefix:c.localName,namespace:c.value}):"xmlns"==c.nodeName&&r.push({prefix:"",namespace:c.value});for(u=0;u<s;u++){var c;if(Fe(c=o.item(u),0,r)){var l=c.prefix||"",f=c.namespaceURI,d=l?" xmlns:"+l:" xmlns";e.push(d,'="',f,'"'),r.push({prefix:l,namespace:f})}Me(c,e,n,i,r)}if(Fe(t,0,r)&&(l=t.prefix||"",f=t.namespaceURI,d=l?" xmlns:"+l:" xmlns",e.push(d,'="',f,'"'),r.push({prefix:l,namespace:f})),a||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(h)){if(e.push(">"),n&&/^script$/i.test(h))for(;a;)a.data?e.push(a.data):Me(a,e,n,i,r),a=a.nextSibling;else for(;a;)Me(a,e,n,i,r),a=a.nextSibling;e.push("</",h,">")}else e.push("/>");return;case te:case ne:for(a=t.firstChild;a;)Me(a,e,n,i,r),a=a.nextSibling;return;case Vt:return e.push(" ",t.name,'="',t.value.replace(/[<&"]/g,we),'"');case Xt:return e.push(t.data.replace(/[<&]/g,we));case Kt:return e.push("<![CDATA[",t.data,"]]>");case Qt:return e.push("\x3c!--",t.data,"--\x3e");case ee:var p=t.publicId,m=t.systemId;if(e.push("<!DOCTYPE ",t.name),p)e.push(' PUBLIC "',p),m&&"."!=m&&e.push('" "',m),e.push('">');else if(m&&"."!=m)e.push(' SYSTEM "',m,'">');else{var g=t.internalSubset;g&&e.push(" [",g,"]"),e.push(">")}return;case Jt:return e.push("<?",t.target," ",t.data,"?>");case $t:return e.push("&",t.nodeName,";");default:e.push("??",t.nodeName)}}function We(t,e,n){var i;switch(e.nodeType){case Yt:(i=e.cloneNode(!1)).ownerDocument=t;case ne:break;case Vt:n=!0}if(i||(i=e.cloneNode(!1)),i.ownerDocument=t,i.parentNode=null,n)for(var r=e.firstChild;r;)i.appendChild(We(t,r,n)),r=r.nextSibling;return i}function qe(t,e,n){var i=new e.constructor;for(var r in e){var o=e[r];"object"!=typeof o&&o!=i[r]&&(i[r]=o)}switch(e.childNodes&&(i.childNodes=new ce),i.ownerDocument=t,i.nodeType){case Yt:var s=e.attributes,a=i.attributes=new de,h=s.length;a._ownerElement=i;for(var u=0;u<h;u++)i.setAttributeNode(qe(t,s.item(u),!0));break;case Vt:n=!0}if(n)for(var c=e.firstChild;c;)i.appendChild(qe(t,c,n)),c=c.nextSibling;return i}function He(t,e,n){t[e]=n}re.INVALID_STATE_ERR=(oe[11]="Invalid state",11),re.SYNTAX_ERR=(oe[12]="Syntax error",12),re.INVALID_MODIFICATION_ERR=(oe[13]="Invalid modification",13),re.NAMESPACE_ERR=(oe[14]="Invalid namespace",14),re.INVALID_ACCESS_ERR=(oe[15]="Invalid access",15),ue.prototype=Error.prototype,qt(re,ue),ce.prototype={length:0,item:function(t){return this[t]||null},toString:function(t,e){for(var n=[],i=0;i<this.length;i++)Me(this[i],n,t,e);return n.join("")}},le.prototype.item=function(t){return fe(this),this[t]},Ht(le,ce),de.prototype={length:0,item:ce.prototype.item,getNamedItem:function(t){for(var e=this.length;e--;){var n=this[e];if(n.nodeName==t)return n}},setNamedItem:function(t){var e=t.ownerElement;if(e&&e!=this._ownerElement)throw new ue(he);var n=this.getNamedItem(t.nodeName);return me(this._ownerElement,this,t,n),n},setNamedItemNS:function(t){var e,n=t.ownerElement;if(n&&n!=this._ownerElement)throw new ue(he);return e=this.getNamedItemNS(t.namespaceURI,t.localName),me(this._ownerElement,this,t,e),e},removeNamedItem:function(t){var e=this.getNamedItem(t);return ge(this._ownerElement,this,e),e},removeNamedItemNS:function(t,e){var n=this.getNamedItemNS(t,e);return ge(this._ownerElement,this,n),n},getNamedItemNS:function(t,e){for(var n=this.length;n--;){var i=this[n];if(i.localName==e&&i.namespaceURI==t)return i}return null}},ve.prototype={hasFeature:function(t,e){var n=this._features[t.toLowerCase()];return!(!n||e&&!(e in n))},createDocument:function(t,e,n){var i=new _e;if(i.implementation=this,i.childNodes=new ce,i.doctype=n,n&&i.appendChild(n),e){var r=i.createElementNS(t,e);i.appendChild(r)}return i},createDocumentType:function(t,e,n){var i=new Oe;return i.name=t,i.nodeName=t,i.publicId=e,i.systemId=n,i}},ye.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(t,e){return Se(this,t,e)},replaceChild:function(t,e){this.insertBefore(t,e),e&&this.removeChild(e)},removeChild:function(t){return Ee(this,t)},appendChild:function(t){return this.insertBefore(t,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(t){return qe(this.ownerDocument||this,this,t)},normalize:function(){for(var t=this.firstChild;t;){var e=t.nextSibling;e&&e.nodeType==Xt&&t.nodeType==Xt?(this.removeChild(e),t.appendData(e.data)):(t.normalize(),t=e)}},isSupported:function(t,e){return this.ownerDocument.implementation.hasFeature(t,e)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(t){for(var e=this;e;){var n=e._nsMap;if(n)for(var i in n)if(n[i]==t)return i;e=e.nodeType==Vt?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(t){for(var e=this;e;){var n=e._nsMap;if(n&&t in n)return n[t];e=e.nodeType==Vt?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(t){return null==this.lookupPrefix(t)}},qt(Zt,ye),qt(Zt,ye.prototype),_e.prototype={nodeName:"#document",nodeType:te,doctype:null,documentElement:null,_inc:1,insertBefore:function(t,e){if(t.nodeType==ne){for(var n=t.firstChild;n;){var i=n.nextSibling;this.insertBefore(n,e),n=i}return t}return null==this.documentElement&&t.nodeType==Yt&&(this.documentElement=t),Se(this,t,e),t.ownerDocument=this,t},removeChild:function(t){return this.documentElement==t&&(this.documentElement=null),Ee(this,t)},importNode:function(t,e){return We(this,t,e)},getElementById:function(t){var e=null;return be(this.documentElement,(function(n){if(n.nodeType==Yt&&n.getAttribute("id")==t)return e=n,!0})),e},createElement:function(t){var e=new Ce;return e.ownerDocument=this,e.nodeName=t,e.tagName=t,e.childNodes=new ce,(e.attributes=new de)._ownerElement=e,e},createDocumentFragment:function(){var t=new Be;return t.ownerDocument=this,t.childNodes=new ce,t},createTextNode:function(t){var e=new Ne;return e.ownerDocument=this,e.appendData(t),e},createComment:function(t){var e=new Re;return e.ownerDocument=this,e.appendData(t),e},createCDATASection:function(t){var e=new Ie;return e.ownerDocument=this,e.appendData(t),e},createProcessingInstruction:function(t,e){var n=new Pe;return n.ownerDocument=this,n.tagName=n.target=t,n.nodeValue=n.data=e,n},createAttribute:function(t){var e=new Te;return e.ownerDocument=this,e.name=t,e.nodeName=t,e.localName=t,e.specified=!0,e},createEntityReference:function(t){var e=new Le;return e.ownerDocument=this,e.nodeName=t,e},createElementNS:function(t,e){var n=new Ce,i=e.split(":"),r=n.attributes=new de;return n.childNodes=new ce,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=t,2==i.length?(n.prefix=i[0],n.localName=i[1]):n.localName=e,r._ownerElement=n,n},createAttributeNS:function(t,e){var n=new Te,i=e.split(":");return n.ownerDocument=this,n.nodeName=e,n.name=e,n.namespaceURI=t,n.specified=!0,2==i.length?(n.prefix=i[0],n.localName=i[1]):n.localName=e,n}},Ht(_e,ye),Ce.prototype={nodeType:Yt,hasAttribute:function(t){return null!=this.getAttributeNode(t)},getAttribute:function(t){var e=this.getAttributeNode(t);return e&&e.value||""},getAttributeNode:function(t){return this.attributes.getNamedItem(t)},setAttribute:function(t,e){var n=this.ownerDocument.createAttribute(t);n.value=n.nodeValue=""+e,this.setAttributeNode(n)},removeAttribute:function(t){var e=this.getAttributeNode(t);e&&this.removeAttributeNode(e)},appendChild:function(t){return t.nodeType===ne?this.insertBefore(t,null):function(t,e){var n=e.parentNode;if(n){var i=t.lastChild;n.removeChild(e),i=t.lastChild}return i=t.lastChild,e.parentNode=t,e.previousSibling=i,e.nextSibling=null,i?i.nextSibling=e:t.firstChild=e,t.lastChild=e,ke(t.ownerDocument,t,e),e}(this,t)},setAttributeNode:function(t){return this.attributes.setNamedItem(t)},setAttributeNodeNS:function(t){return this.attributes.setNamedItemNS(t)},removeAttributeNode:function(t){return this.attributes.removeNamedItem(t.nodeName)},removeAttributeNS:function(t,e){var n=this.getAttributeNodeNS(t,e);n&&this.removeAttributeNode(n)},hasAttributeNS:function(t,e){return null!=this.getAttributeNodeNS(t,e)},getAttributeNS:function(t,e){var n=this.getAttributeNodeNS(t,e);return n&&n.va