unvendor: Delete replaced libraries

c7412787490f65f796b49f05b0f00ffafb2d1dc6

Cohee <18619528+Cohee1207@users.noreply.github.com>

7 files changed, +0 -9997Ignore whitespace
public/lib/epub.min.js+0 -1
@@ -1 +0,0 @@
1!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("xmldom"),require("JSZip")):"function"==typeof define&&define.amd?define(["xmldom","JSZip"],e):"object"==typeof exports?exports.ePub=e(require("xmldom"),require("JSZip")):t.ePub=e(t.xmldom,t.JSZip)}(window,(function(t,e){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s=86)}([function(t,e,i){"use strict";i.r(e),i.d(e,"requestAnimationFrame",(function(){return r})),i.d(e,"uuid",(function(){return o})),i.d(e,"documentHeight",(function(){return a})),i.d(e,"isElement",(function(){return h})),i.d(e,"isNumber",(function(){return l})),i.d(e,"isFloat",(function(){return c})),i.d(e,"prefixed",(function(){return u})),i.d(e,"defaults",(function(){return d})),i.d(e,"extend",(function(){return f})),i.d(e,"insert",(function(){return p})),i.d(e,"locationOf",(function(){return g})),i.d(e,"indexOfSorted",(function(){return v})),i.d(e,"bounds",(function(){return m})),i.d(e,"borders",(function(){return y})),i.d(e,"nodeBounds",(function(){return b})),i.d(e,"windowBounds",(function(){return w})),i.d(e,"indexOfNode",(function(){return x})),i.d(e,"indexOfTextNode",(function(){return E})),i.d(e,"indexOfElementNode",(function(){return S})),i.d(e,"isXml",(function(){return _})),i.d(e,"createBlob",(function(){return O})),i.d(e,"createBlobUrl",(function(){return C})),i.d(e,"revokeBlobUrl",(function(){return T})),i.d(e,"createBase64Url",(function(){return k})),i.d(e,"type",(function(){return R})),i.d(e,"parse",(function(){return L})),i.d(e,"qs",(function(){return I})),i.d(e,"qsa",(function(){return j})),i.d(e,"qsp",(function(){return N})),i.d(e,"sprint",(function(){return A})),i.d(e,"treeWalker",(function(){return P})),i.d(e,"walk",(function(){return D})),i.d(e,"blob2base64",(function(){return z})),i.d(e,"defer",(function(){return B})),i.d(e,"querySelectorByType",(function(){return q})),i.d(e,"findChildren",(function(){return M})),i.d(e,"parents",(function(){return U})),i.d(e,"filterChildren",(function(){return F})),i.d(e,"getParentByTagName",(function(){return W})),i.d(e,"RangeObject",(function(){return H}));i(24),i(14),i(20);var n=i(38);const r="undefined"!=typeof window&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),s="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 i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:7&i|8).toString(16)}))}function a(){return Math.max(document.documentElement.clientHeight,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight)}function h(t){return!(!t||1!=t.nodeType)}function l(t){return!isNaN(parseFloat(t))&&isFinite(t)}function c(t){let e=parseFloat(t);return!1!==l(t)&&("string"==typeof t&&t.indexOf(".")>-1||Math.floor(e)!==e)}function u(t){var e=["-webkit-","-webkit-","-moz-","-o-","-ms-"],i=t.toLowerCase(),n=["Webkit","webkit","Moz","O","ms"].length;if("undefined"==typeof document||void 0!==document.body.style[i])return t;for(var r=0;r<n;r++)if(void 0!==document.body.style[e[r]+i])return e[r]+i;return t}function d(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 f(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=g(t,e,i);return e.splice(n,0,t),n}function g(t,e,i,n,r){var s,o=n||0,a=r||e.length,h=parseInt(o+(a-o)/2);return i||(i=function(t,e){return t>e?1:t<e?-1:t==e?0:void 0}),a-o<=0?h:(s=i(e[h],t),a-o==1?s>=0?h:h+1:0===s?h:-1===s?g(t,e,i,h,a):g(t,e,i,o,h))}function v(t,e,i,n,r){var s,o=n||0,a=r||e.length,h=parseInt(o+(a-o)/2);return i||(i=function(t,e){return t>e?1:t<e?-1:t==e?0:void 0}),a-o<=0?-1:(s=i(e[h],t),a-o==1?0===s?h:-1:0===s?h:-1===s?v(t,e,i,h,a):v(t,e,i,o,h))}function m(t){var e=window.getComputedStyle(t),i=0,n=0;return["width","paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"].forEach((function(t){i+=parseFloat(e[t])||0})),["height","paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"].forEach((function(t){n+=parseFloat(e[t])||0})),{height:n,width:i}}function y(t){var e=window.getComputedStyle(t),i=0,n=0;return["paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"].forEach((function(t){i+=parseFloat(e[t])||0})),["paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"].forEach((function(t){n+=parseFloat(e[t])||0})),{height:n,width:i}}function b(t){let e,i=t.ownerDocument;if(t.nodeType==Node.TEXT_NODE){let n=i.createRange();n.selectNodeContents(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();return e}function w(){var t=window.innerWidth,e=window.innerHeight;return{top:0,left:0,right:t,bottom:e,width:t,height:e}}function x(t,e){for(var i,n=t.parentNode.childNodes,r=-1,s=0;s<n.length&&((i=n[s]).nodeType===e&&r++,i!=t);s++);return r}function E(t){return x(t,3)}function S(t){return x(t,1)}function _(t){return["xml","opf","ncx"].indexOf(t)>-1}function O(t,e){return new Blob([t],{type:e})}function C(t,e){var i=O(t,e);return s.createObjectURL(i)}function T(t){return s.revokeObjectURL(t)}function k(t,e){if("string"==typeof t)return"data:"+e+";base64,"+btoa(encodeURIComponent(t))}function R(t){return Object.prototype.toString.call(t).slice(8,-1)}function L(t,e,i){var r;return r="undefined"==typeof DOMParser||i?n.DOMParser:DOMParser,65279===t.charCodeAt(0)&&(t=t.slice(1)),(new r).parseFromString(t,e)}function I(t,e){var i;if(!t)throw new Error("No Element Provided");return void 0!==t.querySelector?t.querySelector(e):(i=t.getElementsByTagName(e)).length?i[0]:void 0}function j(t,e){return void 0!==t.querySelector?t.querySelectorAll(e):t.getElementsByTagName(e)}function N(t,e,i){var n,r;if(void 0!==t.querySelector){for(var s in e+="[",i)e+=s+"~='"+i[s]+"'";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){void 0!==(t.ownerDocument||t).createTreeWalker?P(t,e,NodeFilter.SHOW_TEXT):D(t,(function(t){t&&3===t.nodeType&&e(t)}))}function P(t,e,i){var n=document.createTreeWalker(t,i,null,!1);let r;for(;r=n.nextNode();)e(r)}function D(t,e){if(e(t))return!0;if(t=t.firstChild)do{if(D(t,e))return!0;t=t.nextSibling}while(t)}function z(t){return new Promise((function(e,i){var n=new FileReader;n.readAsDataURL(t),n.onloadend=function(){e(n.result)}}))}function B(){this.resolve=null,this.reject=null,this.id=o(),this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e}),Object.freeze(this)}function q(t,e,i){var n;if(void 0!==t.querySelector&&(n=t.querySelector(`${e}[*|type="${i}"]`)),n&&0!==n.length)return n;n=j(t,e);for(var r=0;r<n.length;r++)if(n[r].getAttributeNS("http://www.idpf.org/2007/ops","type")===i||n[r].getAttribute("epub:type")===i)return n[r]}function M(t){for(var e=[],i=t.childNodes,n=0;n<i.length;n++){let t=i[n];1===t.nodeType&&e.push(t)}return e}function U(t){for(var e=[t];t;t=t.parentNode)e.unshift(t);return e}function F(t,e,i){for(var n=[],r=t.childNodes,s=0;s<r.length;s++){let t=r[s];if(1===t.nodeType&&t.nodeName.toLowerCase()===e){if(i)return t;n.push(t)}}if(!i)return n}function W(t,e){let i;if(null!==t&&""!==e)for(i=t.parentNode;1===i.nodeType;){if(i.tagName.toLowerCase()===e)return i;i=i.parentNode}}class H{constructor(){this.collapsed=!1,this.commonAncestorContainer=void 0,this.endContainer=void 0,this.endOffset=void 0,this.startContainer=void 0,this.startOffset=void 0}setStart(t,e){this.startContainer=t,this.startOffset=e,this.endContainer?this.commonAncestorContainer=this._commonAncestorContainer():this.collapse(!0),this._checkCollapsed()}setEnd(t,e){this.endContainer=t,this.endOffset=e,this.startContainer?(this.collapsed=!1,this.commonAncestorContainer=this._commonAncestorContainer()):this.collapse(!1),this._checkCollapsed()}collapse(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)}selectNode(t){let e=t.parentNode,i=Array.prototype.indexOf.call(e.childNodes,t);this.setStart(e,i),this.setEnd(e,i+1)}selectNodeContents(t){t.childNodes[t.childNodes-1];let e=3===t.nodeType?t.textContent.length:parent.childNodes.length;this.setStart(t,0),this.setEnd(t,e)}_commonAncestorContainer(t,e){var i=U(t||this.startContainer),n=U(e||this.endContainer);if(i[0]==n[0])for(var r=0;r<i.length;r++)if(i[r]!=n[r])return i[r-1]}_checkCollapsed(){this.startContainer===this.endContainer&&this.startOffset===this.endOffset?this.collapsed=!0:this.collapsed=!1}toString(){}}},function(t,e,i){"use strict";i.d(e,"b",(function(){return n})),i.d(e,"a",(function(){return r})),i.d(e,"c",(function(){return s}));const n="0.3",r=["keydown","keyup","keypressed","mouseup","mousedown","click","touchend","touchstart","touchmove"],s={BOOK:{OPEN_FAILED:"openFailed"},CONTENTS:{EXPAND:"expand",RESIZE:"resize",SELECTED:"selected",SELECTED_RANGE:"selectedRange",LINK_CLICKED:"linkClicked"},LOCATIONS:{CHANGED:"changed"},MANAGERS:{RESIZE:"resize",RESIZED:"resized",ORIENTATION_CHANGE:"orientationchange",ADDED:"added",SCROLL:"scroll",SCROLLED:"scrolled",REMOVED:"removed"},VIEWS:{AXIS:"axis",WRITING_MODE:"writingMode",LOAD_ERROR:"loaderror",RENDERED:"rendered",RESIZED:"resized",DISPLAYED:"displayed",SHOWN:"shown",HIDDEN:"hidden",MARK_CLICKED:"markClicked"},RENDITION:{STARTED:"started",ATTACHED:"attached",DISPLAYED:"displayed",DISPLAY_ERROR:"displayerror",RENDERED:"rendered",REMOVED:"removed",RESIZED:"resized",ORIENTATION_CHANGE:"orientationchange",LOCATION_CHANGED:"locationChanged",RELOCATED:"relocated",MARK_CLICKED:"markClicked",SELECTED:"selected",LAYOUT:"layout"},LAYOUT:{UPDATED:"updated"},ANNOTATION:{ATTACH:"attach",DETACH:"detach"}}},function(t,e,i){"use strict";var n=i(0);class r{constructor(t,e,i){var s;if(this.str="",this.base={},this.spinePos=0,this.range=!1,this.path={},this.start=null,this.end=null,!(this instanceof r))return new r(t,e,i);if("string"==typeof e?this.base=this.parseComponent(e):"object"==typeof e&&e.steps&&(this.base=e),"string"===(s=this.checkType(t)))return this.str=t,Object(n.extend)(this,this.parse(t));if("range"===s)return Object(n.extend)(this,this.fromRange(t,this.base,i));if("node"===s)return Object(n.extend)(this,this.fromNode(t,this.base,i));if("EpubCFI"===s&&t.path)return t;if(t)throw new TypeError("not a valid argument for EpubCFI");return this}checkType(t){return this.isCfiString(t)?"string":!t||"object"!=typeof t||"Range"!==Object(n.type)(t)&&void 0===t.startContainer?t&&"object"==typeof t&&void 0!==t.nodeType?"node":!!(t&&"object"==typeof t&&t instanceof r)&&"EpubCFI":"range"}parse(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))&&(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})}parseComponent(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}parseStep(t){var e,i,n,r,s;if((r=t.match(/\[(.*)\]/))&&r[1]&&(s=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:s||null}}parseTerminal(t){var e,i,r=t.match(/\[(.*)\]/);return r&&r[1]?(e=parseInt(t.split("[")[0]),i=r[1]):e=parseInt(t),Object(n.isNumber)(e)||(e=null),{offset:e,assertion:i}}getChapterComponent(t){return t.split("!")[0]}getPathComponent(t){var e=t.split("!");if(e[1]){return e[1].split(",")[0]}}getRange(t){var e=t.split(",");return 3===e.length&&[e[1],e[2]]}getCharecterOffsetComponent(t){return t.split(":")[1]||""}joinSteps(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("/"):""}segmentString(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}toString(){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+=")"}compare(t,e){var i,n,s,o;if("string"==typeof t&&(t=new r(t)),"string"==typeof e&&(e=new r(e)),t.spinePos>e.spinePos)return 1;if(t.spinePos<e.spinePos)return-1;t.range?(i=t.path.steps.concat(t.start.steps),s=t.start.terminal):(i=t.path.steps,s=t.path.terminal),e.range?(n=e.path.steps.concat(e.start.steps),o=e.start.terminal):(n=e.path.steps,o=e.path.terminal);for(var a=0;a<i.length;a++){if(!i[a])return-1;if(!n[a])return 1;if(i[a].index>n[a].index)return 1;if(i[a].index<n[a].index)return-1}return i.length<n.length?-1:s.offset>o.offset?1:s.offset<o.offset?-1:0}step(t){var e=3===t.nodeType?"text":"element";return{id:t.id,tagName:t.tagName,type:e,index:this.position(t)}}filteredStep(t,e){var i,n=this.filter(t,e);if(n)return i=3===n.nodeType?"text":"element",{id:n.id,tagName:n.tagName,type:i,index:this.filteredPosition(n,e)}}pathTo(t,e,i){for(var n,r={steps:[],terminal:{offset:null,assertion:null}},s=t;s&&s.parentNode&&9!=s.parentNode.nodeType;)(n=i?this.filteredStep(s,i):this.step(s))&&r.steps.unshift(n),s=s.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}equalStep(t,e){return!(!t||!e)&&(t.index===e.index&&t.id===e.id&&t.type===e.type)}fromRange(t,e,i){var n={range:!1,base:{},path:{},start:null,end:null},r=t.startContainer,s=t.endContainer,o=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&&(o=this.patchOffset(r,o,i)),n.path=this.pathTo(r,o,i);else{n.range=!0,h&&(o=this.patchOffset(r,o,i)),n.start=this.pathTo(r,o,i),h&&(a=this.patchOffset(s,a,i)),n.end=this.pathTo(s,a,i),n.path={steps:[],terminal:null};var l,c=n.start.steps.length;for(l=0;l<c&&this.equalStep(n.start.steps[l],n.end.steps[l]);l++)l===c-1?n.start.terminal===n.end.terminal&&(n.path.steps.push(n.start.steps[l]),n.range=!1):n.path.steps.push(n.start.steps[l]);n.start.steps=n.start.steps.slice(n.path.steps.length),n.end.steps=n.end.steps.slice(n.path.steps.length)}return n}fromNode(t,e,i){var n={range:!1,base:{},path:{},start:null,end:null};return"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}filter(t,e){var i,n,r,s,o,a=!1;return 3===t.nodeType?(a=!0,r=t.parentNode,i=t.parentNode.classList.contains(e)):(a=!1,i=t.classList.contains(e)),i&&a?(s=r.previousSibling,o=r.nextSibling,s&&3===s.nodeType?n=s:o&&3===o.nodeType&&(n=o),n||t):!(i&&!a)&&t}patchOffset(t,e,i){if(3!=t.nodeType)throw new Error("Anchor must be a text node");var n=t,r=e;for(t.parentNode.classList.contains(i)&&(n=t.parentNode);n.previousSibling;){if(1===n.previousSibling.nodeType){if(!n.previousSibling.classList.contains(i))break;r+=n.previousSibling.textContent.length}else r+=n.previousSibling.textContent.length;n=n.previousSibling}return r}normalizedMap(t,e,i){var n,r,s,o={},a=-1,h=t.length;for(n=0;n<h;n++)1===(r=t[n].nodeType)&&t[n].classList.contains(i)&&(r=3),n>0&&3===r&&3===s?o[n]=a:e===r&&(a+=1,o[n]=a),s=r;return o}position(t){var e,i;return 1===t.nodeType?((e=t.parentNode.children)||(e=Object(n.findChildren)(t.parentNode)),i=Array.prototype.indexOf.call(e,t)):i=(e=this.textNodes(t.parentNode)).indexOf(t),i}filteredPosition(t,e){var i,n;return 1===t.nodeType?(i=t.parentNode.children,n=this.normalizedMap(i,1,e)):(i=t.parentNode.childNodes,t.parentNode.classList.contains(e)&&(i=(t=t.parentNode).parentNode.childNodes),n=this.normalizedMap(i,3,e)),n[Array.prototype.indexOf.call(i,t)]}stepsToXpath(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("/")}stepsToQuerySelector(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(">")}textNodes(t,e){return Array.prototype.slice.call(t.childNodes).filter((function(t){return 3===t.nodeType||!(!e||!t.classList.contains(e))}))}walkToNode(t,e,i){var r,s,o=e||document,a=o.documentElement,h=t.length;for(s=0;s<h&&("element"===(r=t[s]).type?a=r.id?o.getElementById(r.id):(a.children||Object(n.findChildren)(a))[r.index]:"text"===r.type&&(a=this.textNodes(a,i)[r.index]),a);s++);return a}findNode(t,e,i){var n,r,s=e||document;return i||void 0===s.evaluate?n=i?this.walkToNode(t,s,i):this.walkToNode(t,s):(r=this.stepsToXpath(t),n=s.evaluate(r,s,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),n}fixMiss(t,e,i,n){var r,s,o=this.findNode(t.slice(0,-1),i,n),a=o.childNodes,h=this.normalizedMap(a,3,n),l=t[t.length-1].index;for(let t in h){if(!h.hasOwnProperty(t))return;if(h[t]===l){if(!(e>(s=(r=a[t]).textContent.length))){o=1===r.nodeType?r.childNodes[0]:r;break}e-=s}}return{container:o,offset:e}}toRange(t,e){var i,r,s,o,a,h,l,c,u=t||document,d=!!e&&null!=u.querySelector("."+e);if(i=void 0!==u.createRange?u.createRange():new n.RangeObject,this.range?(r=this.start,h=this.path.steps.concat(r.steps),o=this.findNode(h,u,d?e:null),s=this.end,l=this.path.steps.concat(s.steps),a=this.findNode(l,u,d?e:null)):(r=this.path,h=this.path.steps,o=this.findNode(this.path.steps,u,d?e:null)),!o)return console.log("No startContainer found for",this.toString()),null;try{null!=r.terminal.offset?i.setStart(o,r.terminal.offset):i.setStart(o,0)}catch(t){c=this.fixMiss(h,r.terminal.offset,u,d?e:null),i.setStart(c.container,c.offset)}if(a)try{null!=s.terminal.offset?i.setEnd(a,s.terminal.offset):i.setEnd(a,0)}catch(t){c=this.fixMiss(l,this.end.terminal.offset,u,d?e:null),i.setEnd(c.container,c.offset)}return i}isCfiString(t){return"string"==typeof t&&0===t.indexOf("epubcfi(")&&")"===t[t.length-1]}generateChapterComponent(t,e,i){var n="/"+2*(t+1)+"/";return n+=2*(parseInt(e)+1),i&&(n+="["+i+"]"),n}collapse(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))}}e.a=r},function(t,e,i){"use strict";var n,r,s,o,a,h,l,c=i(108),u=i(122),d=Function.prototype.apply,f=Function.prototype.call,p=Object.create,g=Object.defineProperty,v=Object.defineProperties,m=Object.prototype.hasOwnProperty,y={configurable:!0,enumerable:!1,writable:!0};r=function(t,e){var i,r;return u(e),r=this,n.call(this,t,i=function(){s.call(r,t,i),d.call(e,this,arguments)}),i.__eeOnceListener__=e,this},a={on:n=function(t,e){var i;return u(e),m.call(this,"__ee__")?i=this.__ee__:(i=y.value=p(null),g(this,"__ee__",y),y.value=null),i[t]?"object"==typeof i[t]?i[t].push(e):i[t]=[i[t],e]:i[t]=e,this},once:r,off:s=function(t,e){var i,n,r,s;if(u(e),!m.call(this,"__ee__"))return this;if(!(i=this.__ee__)[t])return this;if("object"==typeof(n=i[t]))for(s=0;r=n[s];++s)r!==e&&r.__eeOnceListener__!==e||(2===n.length?i[t]=n[s?0:1]:n.splice(s,1));else n!==e&&n.__eeOnceListener__!==e||delete i[t];return this},emit:o=function(t){var e,i,n,r,s;if(m.call(this,"__ee__")&&(r=this.__ee__[t]))if("object"==typeof r){for(i=arguments.length,s=new Array(i-1),e=1;e<i;++e)s[e-1]=arguments[e];for(r=r.slice(),e=0;n=r[e];++e)d.call(n,this,s)}else switch(arguments.length){case 1:f.call(r,this);break;case 2:f.call(r,this,arguments[1]);break;case 3:f.call(r,this,arguments[1],arguments[2]);break;default:for(i=arguments.length,s=new Array(i-1),e=1;e<i;++e)s[e-1]=arguments[e];d.call(r,this,s)}}},h={on:c(n),once:c(r),off:c(s),emit:c(o)},l=v({},h),t.exports=e=function(t){return null==t?p(l):v(Object(t),h)},e.methods=a},function(t,e,i){"use strict";i(14),i(20);var n=i(9),r=i.n(n);e.a=class{constructor(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)}parse(t){return r.a.parse(t)}isAbsolute(t){return r.a.isAbsolute(t||this.path)}isDirectory(t){return"/"===t.charAt(t.length-1)}resolve(t){return r.a.resolve(this.directory,t)}relative(t){return t&&t.indexOf("://")>-1?t:r.a.relative(this.directory,t)}splitPath(t){return this.splitPathRe.exec(t).slice(1)}toString(){return this.path}}},function(t,e,i){"use strict";i(14),i(20);var n=i(4),r=i(9),s=i.n(r);e.a=class{constructor(t,e){var i=t.indexOf("://")>-1,r=t;if(this.Url=void 0,this.href=t,this.protocol="",this.origin="",this.hash="",this.hash="",this.search="",this.base=e,!i&&!1!==e&&"string"!=typeof e&&window&&window.location&&(this.base=window.location.href),i||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,r=this.Url.pathname+(this.Url.search?this.Url.search:"")}catch(t){this.Url=void 0,this.base&&(r=new n.a(this.base).resolve(r))}this.Path=new n.a(r),this.directory=this.Path.directory,this.filename=this.Path.filename,this.extension=this.Path.extension}path(){return this.Path}resolve(t){var e;return t.indexOf("://")>-1?t:(e=s.a.resolve(this.directory,t),this.origin+e)}relative(t){return s.a.relative(t,this.directory)}toString(){return this.href}}},function(t,e,i){"use strict";i(14);e.a=class{constructor(t){this.context=t||this,this.hooks=[]}register(){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])}deregister(t){let e;for(let i=0;i<this.hooks.length;i++)if(e=this.hooks[i],e===t){this.hooks.splice(i,1);break}}trigger(){var t=arguments,e=this.context,i=[];return this.hooks.forEach((function(n){var r=n.apply(e,t);r&&"function"==typeof r.then&&i.push(r)})),Promise.all(i)}list(){return this.hooks}clear(){return this.hooks=[]}}},function(t,e,i){(function(e){var i=function(t){return t&&t.Math==Math&&t};t.exports=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof e&&e)||Function("return this")()}).call(this,i(30))},function(t,e,i){var n=i(7),r=i(66),s=i(10),o=i(67),a=i(70),h=i(99),l=r("wks"),c=n.Symbol,u=h?c:c&&c.withoutSetter||o;t.exports=function(t){return s(l,t)||(a&&s(c,t)?l[t]=c[t]:l[t]=u("Symbol."+t)),l[t]}},function(t,e,i){"use strict";if(!n)var n={cwd:function(){return"/"}};function r(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+t)}function s(t,e){for(var i,n="",r=-1,s=0,o=0;o<=t.length;++o){if(o<t.length)i=t.charCodeAt(o);else{if(47===i)break;i=47}if(47===i){if(r===o-1||1===s);else if(r!==o-1&&2===s){if(n.length<2||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){for(var a=n.length-1,h=a;h>=0&&47!==n.charCodeAt(h);--h);if(h!==a){n=-1===h?"":n.slice(0,h),r=o,s=0;continue}}else if(2===n.length||1===n.length){n="",r=o,s=0;continue}e&&(n.length>0?n+="/..":n="..")}else n.length>0?n+="/"+t.slice(r+1,o):n=t.slice(r+1,o);r=o,s=0}else 46===i&&-1!==s?++s:s=-1}return n}var o={resolve:function(){for(var t,e="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var a;o>=0?a=arguments[o]:(void 0===t&&(t=n.cwd()),a=t),r(a),0!==a.length&&(e=a+"/"+e,i=47===a.charCodeAt(0))}return e=s(e,!i),i?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(t){if(r(t),0===t.length)return".";var e=47===t.charCodeAt(0),i=47===t.charCodeAt(t.length-1);return 0!==(t=s(t,!e)).length||e||(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return r(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 i=arguments[e];r(i),i.length>0&&(void 0===t?t=i:t+="/"+i)}return void 0===t?".":o.normalize(t)},relative:function(t,e){if(r(t),r(e),t===e)return"";if((t=o.resolve(t))===(e=o.resolve(e)))return"";for(var i=1;i<t.length&&47===t.charCodeAt(i);++i);for(var n=t.length,s=n-i,a=1;a<e.length&&47===e.charCodeAt(a);++a);for(var h=e.length-a,l=s<h?s:h,c=-1,u=0;u<=l;++u){if(u===l){if(h>l){if(47===e.charCodeAt(a+u))return e.slice(a+u+1);if(0===u)return e.slice(a+u)}else s>l&&(47===t.charCodeAt(i+u)?c=u:0===u&&(c=0));break}var d=t.charCodeAt(i+u);if(d!==e.charCodeAt(a+u))break;47===d&&(c=u)}var f="";for(u=i+c+1;u<=n;++u)u!==n&&47!==t.charCodeAt(u)||(0===f.length?f+="..":f+="/..");return f.length>0?f+e.slice(a+c):(a+=c,47===e.charCodeAt(a)&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(r(t),0===t.length)return".";for(var e=t.charCodeAt(0),i=47===e,n=-1,s=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!s){n=o;break}}else s=!1;return-1===n?i?"/":".":i&&1===n?"//":t.slice(0,n)},basename:function(t,e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('"ext" argument must be a string');r(t);var i,n=0,s=-1,o=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var a=e.length-1,h=-1;for(i=t.length-1;i>=0;--i){var l=t.charCodeAt(i);if(47===l){if(!o){n=i+1;break}}else-1===h&&(o=!1,h=i+1),a>=0&&(l===e.charCodeAt(a)?-1==--a&&(s=i):(a=-1,s=h))}return n===s?s=h:-1===s&&(s=t.length),t.slice(n,s)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!o){n=i+1;break}}else-1===s&&(o=!1,s=i+1);return-1===s?"":t.slice(n,s)},extname:function(t){r(t);for(var e=-1,i=0,n=-1,s=!0,o=0,a=t.length-1;a>=0;--a){var h=t.charCodeAt(a);if(47!==h)-1===n&&(s=!1,n=a+1),46===h?-1===e?e=a:1!==o&&(o=1):-1!==e&&(o=-1);else if(!s){i=a+1;break}}return-1===e||-1===n||0===o||1===o&&e===n-1&&e===i+1?"":t.slice(e,n)},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 i=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return i?i===e.root?i+n:i+t+n:n}("/",t)},parse:function(t){r(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;var i,n=t.charCodeAt(0),s=47===n;s?(e.root="/",i=1):i=0;for(var o=-1,a=0,h=-1,l=!0,c=t.length-1,u=0;c>=i;--c)if(47!==(n=t.charCodeAt(c)))-1===h&&(l=!1,h=c+1),46===n?-1===o?o=c:1!==u&&(u=1):-1!==o&&(u=-1);else if(!l){a=c+1;break}return-1===o||-1===h||0===u||1===u&&o===h-1&&o===a+1?-1!==h&&(e.base=e.name=0===a&&s?t.slice(1,h):t.slice(a,h)):(0===a&&s?(e.name=t.slice(1,o),e.base=t.slice(1,h)):(e.name=t.slice(a,o),e.base=t.slice(a,h)),e.ext=t.slice(o,h)),a>0?e.dir=t.slice(0,a-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",posix:null};t.exports=o},function(t,e){var i={}.hasOwnProperty;t.exports=function(t,e){return i.call(t,e)}},function(t,e,i){"use strict";i.d(e,"a",(function(){return s})),i.d(e,"b",(function(){return o})),i.d(e,"d",(function(){return a})),i.d(e,"c",(function(){return h})),i.d(e,"e",(function(){return l}));i(24);var n=i(0),r=i(5);i(4);function s(t,e){var i,r,s=e.url,o=s.indexOf("://")>-1;t&&(r=Object(n.qs)(t,"head"),(i=Object(n.qs)(r,"base"))||(i=t.createElement("base"),r.insertBefore(i,r.firstChild)),!o&&window&&window.location&&(s=window.location.origin+s),i.setAttribute("href",s))}function o(t,e){var i,r,s=e.canonical;t&&(i=Object(n.qs)(t,"head"),(r=Object(n.qs)(i,"link[rel='canonical']"))?r.setAttribute("href",s):((r=t.createElement("link")).setAttribute("rel","canonical"),r.setAttribute("href",s),i.appendChild(r)))}function a(t,e){var i,r,s=e.idref;t&&(i=Object(n.qs)(t,"head"),(r=Object(n.qs)(i,"link[property='dc.identifier']"))?r.setAttribute("content",s):((r=t.createElement("meta")).setAttribute("name","dc.identifier"),r.setAttribute("content",s),i.appendChild(r)))}function h(t,e){var i=t.querySelectorAll("a[href]");if(i.length)for(var s=Object(n.qs)(t.ownerDocument,"base"),o=s?s.getAttribute("href"):void 0,a=function(t){var i=t.getAttribute("href");if(0!==i.indexOf("mailto:"))if(i.indexOf("://")>-1)t.setAttribute("target","_blank");else{var n;try{n=new r.a(i,o)}catch(t){}t.onclick=function(){return n&&n.hash?e(n.Path.path+n.hash):e(n?n.Path.path:i),!1}}}.bind(this),h=0;h<i.length;h++)a(i[h])}function l(t,e,i){return e.forEach((function(e,n){e&&i[n]&&(e=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),t=t.replace(new RegExp(e,"g"),i[n]))})),t}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,i){var n=i(17);t.exports=function(t){if(!n(t))throw TypeError(String(t)+" is not an object");return t}},function(t,e,i){var n=i(7),r=i(102),s=i(71),o=i(15),a=i(8),h=a("iterator"),l=a("toStringTag"),c=s.values;for(var u in r){var d=n[u],f=d&&d.prototype;if(f){if(f[h]!==c)try{o(f,h,c)}catch(t){f[h]=c}if(f[l]||o(f,l,u),r[u])for(var p in s)if(f[p]!==s[p])try{o(f,p,s[p])}catch(t){f[p]=s[p]}}}},function(t,e,i){var n=i(16),r=i(18),s=i(25);t.exports=n?function(t,e,i){return r.f(t,e,s(1,i))}:function(t,e,i){return t[e]=i,t}},function(t,e,i){var n=i(12);t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,i){var n=i(16),r=i(62),s=i(13),o=i(41),a=Object.defineProperty;e.f=n?a:function(t,e,i){if(s(t),e=o(e,!0),s(i),r)try{return a(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},function(t,e,i){var n=i(7),r=i(15),s=i(10),o=i(42),a=i(64),h=i(26),l=h.get,c=h.enforce,u=String(String).split("String");(t.exports=function(t,e,i,a){var h=!!a&&!!a.unsafe,l=!!a&&!!a.enumerable,d=!!a&&!!a.noTargetGet;"function"==typeof i&&("string"!=typeof e||s(i,"name")||r(i,"name",e),c(i).source=u.join("string"==typeof e?e:"")),t!==n?(h?!d&&t[e]&&(l=!0):delete t[e],l?t[e]=i:r(t,e,i)):l?t[e]=i:o(e,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&l(this).source||a(this)}))},function(t,e,i){"use strict";i(123);var n,r=i(31),s=i(16),o=i(78),a=i(7),h=i(72),l=i(19),c=i(79),u=i(10),d=i(124),f=i(125),p=i(49).codeAt,g=i(131),v=i(37),m=i(132),y=i(26),b=a.URL,w=m.URLSearchParams,x=m.getState,E=y.set,S=y.getterFor("URL"),_=Math.floor,O=Math.pow,C=/[A-Za-z]/,T=/[\d+-.A-Za-z]/,k=/\d/,R=/^(0x|0X)/,L=/^[0-7]+$/,I=/^\d+$/,j=/^[\dA-Fa-f]+$/,N=/[\u0000\u0009\u000A\u000D #%/:?@[\\]]/,A=/[\u0000\u0009\u000A\u000D #/:?@[\\]]/,P=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,D=/[\u0009\u000A\u000D]/g,z=function(t,e){var i,n,r;if("["==e.charAt(0)){if("]"!=e.charAt(e.length-1))return"Invalid host";if(!(i=q(e.slice(1,-1))))return"Invalid host";t.host=i}else if(G(t)){if(e=g(e),N.test(e))return"Invalid host";if(null===(i=B(e)))return"Invalid host";t.host=i}else{if(A.test(e))return"Invalid host";for(i="",n=f(e),r=0;r<n.length;r++)i+=V(n[r],U);t.host=i}},B=function(t){var e,i,n,r,s,o,a,h=t.split(".");if(h.length&&""==h[h.length-1]&&h.pop(),(e=h.length)>4)return t;for(i=[],n=0;n<e;n++){if(""==(r=h[n]))return t;if(s=10,r.length>1&&"0"==r.charAt(0)&&(s=R.test(r)?16:8,r=r.slice(8==s?1:2)),""===r)o=0;else{if(!(10==s?I:8==s?L:j).test(r))return t;o=parseInt(r,s)}i.push(o)}for(n=0;n<e;n++)if(o=i[n],n==e-1){if(o>=O(256,5-e))return null}else if(o>255)return null;for(a=i.pop(),n=0;n<i.length;n++)a+=i[n]*O(256,3-n);return a},q=function(t){var e,i,n,r,s,o,a,h=[0,0,0,0,0,0,0,0],l=0,c=null,u=0,d=function(){return t.charAt(u)};if(":"==d()){if(":"!=t.charAt(1))return;u+=2,c=++l}for(;d();){if(8==l)return;if(":"!=d()){for(e=i=0;i<4&&j.test(d());)e=16*e+parseInt(d(),16),u++,i++;if("."==d()){if(0==i)return;if(u-=i,l>6)return;for(n=0;d();){if(r=null,n>0){if(!("."==d()&&n<4))return;u++}if(!k.test(d()))return;for(;k.test(d());){if(s=parseInt(d(),10),null===r)r=s;else{if(0==r)return;r=10*r+s}if(r>255)return;u++}h[l]=256*h[l]+r,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==d()){if(u++,!d())return}else if(d())return;h[l++]=e}else{if(null!==c)return;u++,c=++l}}if(null!==c)for(o=l-c,l=7;0!=l&&o>0;)a=h[l],h[l--]=h[c+o-1],h[c+--o]=a;else if(8!=l)return;return h},M=function(t){var e,i,n,r;if("number"==typeof t){for(e=[],i=0;i<4;i++)e.unshift(t%256),t=_(t/256);return e.join(".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,i=1,n=null,r=0,s=0;s<8;s++)0!==t[s]?(r>i&&(e=n,i=r),n=null,r=0):(null===n&&(n=s),++r);return r>i&&(e=n,i=r),e}(t),i=0;i<8;i++)r&&0===t[i]||(r&&(r=!1),n===i?(e+=i?":":"::",r=!0):(e+=t[i].toString(16),i<7&&(e+=":")));return"["+e+"]"}return t},U={},F=d({},U,{" ":1,'"':1,"<":1,">":1,"`":1}),W=d({},F,{"#":1,"?":1,"{":1,"}":1}),H=d({},W,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),V=function(t,e){var i=p(t,0);return i>32&&i<127&&!u(e,t)?t:encodeURIComponent(t)},X={ftp:21,file:null,http:80,https:443,ws:80,wss:443},G=function(t){return u(X,t.scheme)},Y=function(t){return""!=t.username||""!=t.password},$=function(t){return!t.host||t.cannotBeABaseURL||"file"==t.scheme},K=function(t,e){var i;return 2==t.length&&C.test(t.charAt(0))&&(":"==(i=t.charAt(1))||!e&&"|"==i)},Z=function(t){var e;return t.length>1&&K(t.slice(0,2))&&(2==t.length||"/"===(e=t.charAt(2))||"\\"===e||"?"===e||"#"===e)},J=function(t){var e=t.path,i=e.length;!i||"file"==t.scheme&&1==i&&K(e[0],!0)||e.pop()},Q=function(t){return"."===t||"%2e"===t.toLowerCase()},tt={},et={},it={},nt={},rt={},st={},ot={},at={},ht={},lt={},ct={},ut={},dt={},ft={},pt={},gt={},vt={},mt={},yt={},bt={},wt={},xt=function(t,e,i,r){var s,o,a,h,l,c=i||tt,d=0,p="",g=!1,v=!1,m=!1;for(i||(t.scheme="",t.username="",t.password="",t.host=null,t.port=null,t.path=[],t.query=null,t.fragment=null,t.cannotBeABaseURL=!1,e=e.replace(P,"")),e=e.replace(D,""),s=f(e);d<=s.length;){switch(o=s[d],c){case tt:if(!o||!C.test(o)){if(i)return"Invalid scheme";c=it;continue}p+=o.toLowerCase(),c=et;break;case et:if(o&&(T.test(o)||"+"==o||"-"==o||"."==o))p+=o.toLowerCase();else{if(":"!=o){if(i)return"Invalid scheme";p="",c=it,d=0;continue}if(i&&(G(t)!=u(X,p)||"file"==p&&(Y(t)||null!==t.port)||"file"==t.scheme&&!t.host))return;if(t.scheme=p,i)return void(G(t)&&X[t.scheme]==t.port&&(t.port=null));p="","file"==t.scheme?c=ft:G(t)&&r&&r.scheme==t.scheme?c=nt:G(t)?c=at:"/"==s[d+1]?(c=rt,d++):(t.cannotBeABaseURL=!0,t.path.push(""),c=yt)}break;case it:if(!r||r.cannotBeABaseURL&&"#"!=o)return"Invalid scheme";if(r.cannotBeABaseURL&&"#"==o){t.scheme=r.scheme,t.path=r.path.slice(),t.query=r.query,t.fragment="",t.cannotBeABaseURL=!0,c=wt;break}c="file"==r.scheme?ft:st;continue;case nt:if("/"!=o||"/"!=s[d+1]){c=st;continue}c=ht,d++;break;case rt:if("/"==o){c=lt;break}c=mt;continue;case st:if(t.scheme=r.scheme,o==n)t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.query=r.query;else if("/"==o||"\\"==o&&G(t))c=ot;else if("?"==o)t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.query="",c=bt;else{if("#"!=o){t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.path.pop(),c=mt;continue}t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.query=r.query,t.fragment="",c=wt}break;case ot:if(!G(t)||"/"!=o&&"\\"!=o){if("/"!=o){t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,c=mt;continue}c=lt}else c=ht;break;case at:if(c=ht,"/"!=o||"/"!=p.charAt(d+1))continue;d++;break;case ht:if("/"!=o&&"\\"!=o){c=lt;continue}break;case lt:if("@"==o){g&&(p="%40"+p),g=!0,a=f(p);for(var y=0;y<a.length;y++){var b=a[y];if(":"!=b||m){var w=V(b,H);m?t.password+=w:t.username+=w}else m=!0}p=""}else if(o==n||"/"==o||"?"==o||"#"==o||"\\"==o&&G(t)){if(g&&""==p)return"Invalid authority";d-=f(p).length+1,p="",c=ct}else p+=o;break;case ct:case ut:if(i&&"file"==t.scheme){c=gt;continue}if(":"!=o||v){if(o==n||"/"==o||"?"==o||"#"==o||"\\"==o&&G(t)){if(G(t)&&""==p)return"Invalid host";if(i&&""==p&&(Y(t)||null!==t.port))return;if(h=z(t,p))return h;if(p="",c=vt,i)return;continue}"["==o?v=!0:"]"==o&&(v=!1),p+=o}else{if(""==p)return"Invalid host";if(h=z(t,p))return h;if(p="",c=dt,i==ut)return}break;case dt:if(!k.test(o)){if(o==n||"/"==o||"?"==o||"#"==o||"\\"==o&&G(t)||i){if(""!=p){var x=parseInt(p,10);if(x>65535)return"Invalid port";t.port=G(t)&&x===X[t.scheme]?null:x,p=""}if(i)return;c=vt;continue}return"Invalid port"}p+=o;break;case ft:if(t.scheme="file","/"==o||"\\"==o)c=pt;else{if(!r||"file"!=r.scheme){c=mt;continue}if(o==n)t.host=r.host,t.path=r.path.slice(),t.query=r.query;else if("?"==o)t.host=r.host,t.path=r.path.slice(),t.query="",c=bt;else{if("#"!=o){Z(s.slice(d).join(""))||(t.host=r.host,t.path=r.path.slice(),J(t)),c=mt;continue}t.host=r.host,t.path=r.path.slice(),t.query=r.query,t.fragment="",c=wt}}break;case pt:if("/"==o||"\\"==o){c=gt;break}r&&"file"==r.scheme&&!Z(s.slice(d).join(""))&&(K(r.path[0],!0)?t.path.push(r.path[0]):t.host=r.host),c=mt;continue;case gt:if(o==n||"/"==o||"\\"==o||"?"==o||"#"==o){if(!i&&K(p))c=mt;else if(""==p){if(t.host="",i)return;c=vt}else{if(h=z(t,p))return h;if("localhost"==t.host&&(t.host=""),i)return;p="",c=vt}continue}p+=o;break;case vt:if(G(t)){if(c=mt,"/"!=o&&"\\"!=o)continue}else if(i||"?"!=o)if(i||"#"!=o){if(o!=n&&(c=mt,"/"!=o))continue}else t.fragment="",c=wt;else t.query="",c=bt;break;case mt:if(o==n||"/"==o||"\\"==o&&G(t)||!i&&("?"==o||"#"==o)){if(".."===(l=(l=p).toLowerCase())||"%2e."===l||".%2e"===l||"%2e%2e"===l?(J(t),"/"==o||"\\"==o&&G(t)||t.path.push("")):Q(p)?"/"==o||"\\"==o&&G(t)||t.path.push(""):("file"==t.scheme&&!t.path.length&&K(p)&&(t.host&&(t.host=""),p=p.charAt(0)+":"),t.path.push(p)),p="","file"==t.scheme&&(o==n||"?"==o||"#"==o))for(;t.path.length>1&&""===t.path[0];)t.path.shift();"?"==o?(t.query="",c=bt):"#"==o&&(t.fragment="",c=wt)}else p+=V(o,W);break;case yt:"?"==o?(t.query="",c=bt):"#"==o?(t.fragment="",c=wt):o!=n&&(t.path[0]+=V(o,U));break;case bt:i||"#"!=o?o!=n&&("'"==o&&G(t)?t.query+="%27":t.query+="#"==o?"%23":V(o,U)):(t.fragment="",c=wt);break;case wt:o!=n&&(t.fragment+=V(o,F))}d++}},Et=function(t){var e,i,n=c(this,Et,"URL"),r=arguments.length>1?arguments[1]:void 0,o=String(t),a=E(n,{type:"URL"});if(void 0!==r)if(r instanceof Et)e=S(r);else if(i=xt(e={},String(r)))throw TypeError(i);if(i=xt(a,o,null,e))throw TypeError(i);var h=a.searchParams=new w,l=x(h);l.updateSearchParams(a.query),l.updateURL=function(){a.query=String(h)||null},s||(n.href=_t.call(n),n.origin=Ot.call(n),n.protocol=Ct.call(n),n.username=Tt.call(n),n.password=kt.call(n),n.host=Rt.call(n),n.hostname=Lt.call(n),n.port=It.call(n),n.pathname=jt.call(n),n.search=Nt.call(n),n.searchParams=At.call(n),n.hash=Pt.call(n))},St=Et.prototype,_t=function(){var t=S(this),e=t.scheme,i=t.username,n=t.password,r=t.host,s=t.port,o=t.path,a=t.query,h=t.fragment,l=e+":";return null!==r?(l+="//",Y(t)&&(l+=i+(n?":"+n:"")+"@"),l+=M(r),null!==s&&(l+=":"+s)):"file"==e&&(l+="//"),l+=t.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==a&&(l+="?"+a),null!==h&&(l+="#"+h),l},Ot=function(){var t=S(this),e=t.scheme,i=t.port;if("blob"==e)try{return new URL(e.path[0]).origin}catch(t){return"null"}return"file"!=e&&G(t)?e+"://"+M(t.host)+(null!==i?":"+i:""):"null"},Ct=function(){return S(this).scheme+":"},Tt=function(){return S(this).username},kt=function(){return S(this).password},Rt=function(){var t=S(this),e=t.host,i=t.port;return null===e?"":null===i?M(e):M(e)+":"+i},Lt=function(){var t=S(this).host;return null===t?"":M(t)},It=function(){var t=S(this).port;return null===t?"":String(t)},jt=function(){var t=S(this),e=t.path;return t.cannotBeABaseURL?e[0]:e.length?"/"+e.join("/"):""},Nt=function(){var t=S(this).query;return t?"?"+t:""},At=function(){return S(this).searchParams},Pt=function(){var t=S(this).fragment;return t?"#"+t:""},Dt=function(t,e){return{get:t,set:e,configurable:!0,enumerable:!0}};if(s&&h(St,{href:Dt(_t,(function(t){var e=S(this),i=String(t),n=xt(e,i);if(n)throw TypeError(n);x(e.searchParams).updateSearchParams(e.query)})),origin:Dt(Ot),protocol:Dt(Ct,(function(t){var e=S(this);xt(e,String(t)+":",tt)})),username:Dt(Tt,(function(t){var e=S(this),i=f(String(t));if(!$(e)){e.username="";for(var n=0;n<i.length;n++)e.username+=V(i[n],H)}})),password:Dt(kt,(function(t){var e=S(this),i=f(String(t));if(!$(e)){e.password="";for(var n=0;n<i.length;n++)e.password+=V(i[n],H)}})),host:Dt(Rt,(function(t){var e=S(this);e.cannotBeABaseURL||xt(e,String(t),ct)})),hostname:Dt(Lt,(function(t){var e=S(this);e.cannotBeABaseURL||xt(e,String(t),ut)})),port:Dt(It,(function(t){var e=S(this);$(e)||(""==(t=String(t))?e.port=null:xt(e,t,dt))})),pathname:Dt(jt,(function(t){var e=S(this);e.cannotBeABaseURL||(e.path=[],xt(e,t+"",vt))})),search:Dt(Nt,(function(t){var e=S(this);""==(t=String(t))?e.query=null:("?"==t.charAt(0)&&(t=t.slice(1)),e.query="",xt(e,t,bt)),x(e.searchParams).updateSearchParams(e.query)})),searchParams:Dt(At),hash:Dt(Pt,(function(t){var e=S(this);""!=(t=String(t))?("#"==t.charAt(0)&&(t=t.slice(1)),e.fragment="",xt(e,t,wt)):e.fragment=null}))}),l(St,"toJSON",(function(){return _t.call(this)}),{enumerable:!0}),l(St,"toString",(function(){return _t.call(this)}),{enumerable:!0}),b){var zt=b.createObjectURL,Bt=b.revokeObjectURL;zt&&l(Et,"createObjectURL",(function(t){return zt.apply(b,arguments)})),Bt&&l(Et,"revokeObjectURL",(function(t){return Bt.apply(b,arguments)}))}v(Et,"URL"),r({global:!0,forced:!o,sham:!s},{URL:Et})},function(t,e,i){"use strict";var n=i(0);e.a=class{constructor(t){this._q=[],this.context=t,this.tick=n.requestAnimationFrame,this.running=!1,this.paused=!1}enqueue(){var t,e,i=[].shift.call(arguments),r=arguments;if(!i)throw new Error("No Task Provided");return e="function"==typeof i?{task:i,args:r,deferred:t=new n.defer,promise:t.promise}:{promise:i},this._q.push(e),0!=this.paused||this.running||this.run(),e.promise}dequeue(){var t,e,i;return!this._q.length||this.paused?((t=new n.defer).deferred.resolve(),t.promise):(e=(t=this._q.shift()).task)?(i=e.apply(this.context,t.args))&&"function"==typeof i.then?i.then(function(){t.deferred.resolve.apply(this.context,arguments)}.bind(this),function(){t.deferred.reject.apply(this.context,arguments)}.bind(this)):(t.deferred.resolve.apply(this.context,i),t.promise):t.promise?t.promise:void 0}dump(){for(;this._q.length;)this.dequeue()}run(){return this.running||(this.running=!0,this.defered=new n.defer),this.tick.call(window,()=>{this._q.length?this.dequeue().then(function(){this.run()}.bind(this)):(this.defered.resolve(),this.running=void 0)}),1==this.paused&&(this.paused=!1),this.defered.promise}flush(){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}clear(){this._q=[]}length(){return this._q.length}pause(){this.paused=!0}stop(){this._q=[],this.running=!1,this.paused=!0}}},function(t,e,i){"use strict";var n=i(3),r=i.n(n),s=i(0);function o(){var t="reverse",e=function(){var t=document.createElement("div");t.dir="rtl",t.style.position="fixed",t.style.width="1px",t.style.height="1px",t.style.top="0px",t.style.left="0px",t.style.overflow="hidden";var e=document.createElement("div");e.style.width="2px";var i=document.createElement("span");i.style.width="1px",i.style.display="inline-block";var n=document.createElement("span");return n.style.width="1px",n.style.display="inline-block",e.appendChild(i),e.appendChild(n),t.appendChild(e),t}();return document.body.appendChild(e),e.scrollLeft>0?t="default":"undefined"!=typeof Element&&Element.prototype.scrollIntoView?(e.children[0].children[1].scrollIntoView(),e.scrollLeft<0&&(t="negative")):(e.scrollLeft=1,0===e.scrollLeft&&(t="negative")),document.body.removeChild(e),t}var a=i(23),h=i(21),l=i(84),c=i.n(l);var u=class{constructor(t){this.settings=t||{},this.id="epubjs-container-"+Object(s.uuid)(),this.container=this.create(this.settings),this.settings.hidden&&(this.wrapper=this.wrap(this.container))}create(t){let e=t.height,i=t.width,n=t.overflow||!1,r=t.axis||"vertical",o=t.direction;Object(s.extend)(this.settings,t),t.height&&Object(s.isNumber)(t.height)&&(e=t.height+"px"),t.width&&Object(s.isNumber)(t.width)&&(i=t.width+"px");let a=document.createElement("div");return a.id=this.id,a.classList.add("epub-container"),a.style.wordSpacing="0",a.style.lineHeight="0",a.style.verticalAlign="top",a.style.position="relative","horizontal"===r&&(a.style.display="flex",a.style.flexDirection="row",a.style.flexWrap="nowrap"),i&&(a.style.width=i),e&&(a.style.height=e),n&&("scroll"===n&&"vertical"===r?(a.style["overflow-y"]=n,a.style["overflow-x"]="hidden"):"scroll"===n&&"horizontal"===r?(a.style["overflow-y"]="hidden",a.style["overflow-x"]=n):a.style.overflow=n),o&&(a.dir=o,a.style.direction=o),o&&this.settings.fullsize&&(document.body.style.direction=o),a}wrap(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}getElement(t){var e;if(Object(s.isElement)(t)?e=t:"string"==typeof t&&(e=document.getElementById(t)),!e)throw new Error("Not an Element");return e}attachTo(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}getContainer(){return this.container}onResize(t){Object(s.isNumber)(this.settings.width)&&Object(s.isNumber)(this.settings.height)||(this.resizeFunc=c()(t,50),window.addEventListener("resize",this.resizeFunc,!1))}onOrientationChange(t){this.orientationChangeFunc=t,window.addEventListener("orientationchange",this.orientationChangeFunc,!1)}size(t,e){var i;let n=t||this.settings.width,r=e||this.settings.height;null===t?(i=this.element.getBoundingClientRect()).width&&(t=Math.floor(i.width),this.container.style.width=t+"px"):Object(s.isNumber)(t)?this.container.style.width=t+"px":this.container.style.width=t,null===e?(i=i||this.element.getBoundingClientRect()).height&&(e=i.height,this.container.style.height=e+"px"):Object(s.isNumber)(e)?this.container.style.height=e+"px":this.container.style.height=e,Object(s.isNumber)(t)||(t=this.container.clientWidth),Object(s.isNumber)(e)||(e=this.container.clientHeight),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};let o=Object(s.windowBounds)(),a=window.getComputedStyle(document.body),h=parseFloat(a["padding-left"])||0,l=parseFloat(a["padding-right"])||0,c=parseFloat(a["padding-top"])||0,u=parseFloat(a["padding-bottom"])||0;return n||(t=o.width-h-l),(this.settings.fullsize&&!r||!r)&&(e=o.height-c-u),{width:t-this.containerPadding.left-this.containerPadding.right,height:e-this.containerPadding.top-this.containerPadding.bottom}}bounds(){let t;return"visible"!==this.container.style.overflow&&(t=this.container&&this.container.getBoundingClientRect()),t&&t.width&&t.height?t:Object(s.windowBounds)()}getSheet(){var t=document.createElement("style");return t.appendChild(document.createTextNode("")),document.head.appendChild(t),t.sheet}addStyleRules(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)}axis(t){"horizontal"===t?(this.container.style.display="flex",this.container.style.flexDirection="row",this.container.style.flexWrap="nowrap"):this.container.style.display="block",this.settings.axis=t}direction(t){this.container&&(this.container.dir=t,this.container.style.direction=t),this.settings.fullsize&&(document.body.style.direction=t),this.settings.dir=t}overflow(t){this.container&&("scroll"===t&&"vertical"===this.settings.axis?(this.container.style["overflow-y"]=t,this.container.style["overflow-x"]="hidden"):"scroll"===t&&"horizontal"===this.settings.axis?(this.container.style["overflow-y"]="hidden",this.container.style["overflow-x"]=t):this.container.style.overflow=t),this.settings.overflow=t}destroy(){this.element&&(this.settings.hidden?this.wrapper:this.container,this.element.contains(this.container)&&this.element.removeChild(this.container),window.removeEventListener("resize",this.resizeFunc),window.removeEventListener("orientationChange",this.orientationChangeFunc))}};var d=class{constructor(t){this.container=t,this._views=[],this.length=0,this.hidden=!1}all(){return this._views}first(){return this._views[0]}last(){return this._views[this._views.length-1]}indexOf(t){return this._views.indexOf(t)}slice(){return this._views.slice.apply(this._views,arguments)}get(t){return this._views[t]}append(t){return this._views.push(t),this.container&&this.container.appendChild(t.element),this.length++,t}prepend(t){return this._views.unshift(t),this.container&&this.container.insertBefore(t.element,this.container.firstChild),this.length++,t}insert(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}remove(t){var e=this._views.indexOf(t);e>-1&&this._views.splice(e,1),this.destroy(t),this.length--}destroy(t){t.displayed&&t.destroy(),this.container&&this.container.removeChild(t.element),t=null}forEach(){return this._views.forEach.apply(this._views,arguments)}clear(){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}}find(t){for(var e,i=this.length,n=0;n<i;n++)if((e=this._views[n]).displayed&&e.section.index==t.index)return e}displayed(){for(var t,e=[],i=this.length,n=0;n<i;n++)(t=this._views[n]).displayed&&e.push(t);return e}show(){for(var t,e=this.length,i=0;i<e;i++)(t=this._views[i]).displayed&&t.show();this.hidden=!1}hide(){for(var t,e=this.length,i=0;i<e;i++)(t=this._views[i]).displayed&&t.hide();this.hidden=!0}},f=i(1);class p{constructor(t){this.name="default",this.optsSettings=t.settings,this.View=t.view,this.request=t.request,this.renditionQueue=t.queue,this.q=new h.a(this),this.settings=Object(s.extend)(this.settings||{},{infinite:!0,hidden:!1,width:void 0,height:void 0,axis:void 0,writingMode:void 0,flow:"scrolled",ignoreClass:"",fullsize:void 0}),Object(s.extend)(this.settings,t.settings||{}),this.viewSettings={ignoreClass:this.settings.ignoreClass,axis:this.settings.axis,flow:this.settings.flow,layout:this.layout,method:this.settings.method,width:0,height:0,forceEvenPages:!0},this.rendered=!1}render(t,e){let i=t.tagName;void 0!==this.settings.fullsize||!i||"body"!=i.toLowerCase()&&"html"!=i.toLowerCase()||(this.settings.fullsize=!0),this.settings.fullsize&&(this.settings.overflow="visible",this.overflow=this.settings.overflow),this.settings.size=e,this.settings.rtlScrollType=o(),this.stage=new u({width:e.width,height:e.height,overflow:this.overflow,hidden:this.settings.hidden,axis:this.settings.axis,fullsize:this.settings.fullsize,direction:this.settings.direction}),this.stage.attachTo(t),this.container=this.stage.getContainer(),this.views=new d(this.container),this._bounds=this.bounds(),this._stageSize=this.stage.size(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.stage.onResize(this.onResized.bind(this)),this.stage.onOrientationChange(this.onOrientationChange.bind(this)),this.addEventListeners(),this.layout&&this.updateLayout(),this.rendered=!0}addEventListeners(){var t;window.addEventListener("unload",function(t){this.destroy()}.bind(this)),t=this.settings.fullsize?window:this.container,this._onScroll=this.onScroll.bind(this),t.addEventListener("scroll",this._onScroll)}removeEventListeners(){(this.settings.fullsize?window:this.container).removeEventListener("scroll",this._onScroll),this._onScroll=void 0}destroy(){clearTimeout(this.orientationTimeout),clearTimeout(this.resizeTimeout),clearTimeout(this.afterScrolled),this.clear(),this.removeEventListeners(),this.stage.destroy(),this.rendered=!1}onOrientationChange(t){let{orientation:e}=window;this.optsSettings.resizeOnOrientationChange&&this.resize(),clearTimeout(this.orientationTimeout),this.orientationTimeout=setTimeout(function(){this.orientationTimeout=void 0,this.optsSettings.resizeOnOrientationChange&&this.resize(),this.emit(f.c.MANAGERS.ORIENTATION_CHANGE,e)}.bind(this),500)}onResized(t){this.resize()}resize(t,e,i){let n=this.stage.size(t,e);this.winBounds=Object(s.windowBounds)(),this.orientationTimeout&&this.winBounds.width===this.winBounds.height?this._stageSize=void 0:this._stageSize&&this._stageSize.width===n.width&&this._stageSize.height===n.height||(this._stageSize=n,this._bounds=this.bounds(),this.clear(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.updateLayout(),this.emit(f.c.MANAGERS.RESIZED,{width:this._stageSize.width,height:this._stageSize.height},i))}createView(t,e){return new this.View(t,Object(s.extend)(this.viewSettings,{forceRight:e}))}handleNextPrePaginated(t,e,i){let n;if("pre-paginated"===this.layout.name&&this.layout.divisor>1){if(t||0===e.index)return;if(n=e.next(),n&&!n.properties.includes("page-spread-left"))return i.call(this,n)}}display(t,e){var i=new s.defer,n=i.promise;(e===t.href||Object(s.isNumber)(e))&&(e=void 0);var r=this.views.find(t);if(r&&t&&"pre-paginated"!==this.layout.name){let t=r.offset();if("ltr"===this.settings.direction)this.scrollTo(t.left,t.top,!0);else{let e=r.width();this.scrollTo(t.left+e,t.top,!0)}if(e){let t=r.locationOf(e);this.moveTo(t)}return i.resolve(),n}this.clear();let o=!1;return"pre-paginated"===this.layout.name&&2===this.layout.divisor&&t.properties.includes("page-spread-right")&&(o=!0),this.add(t,o).then(function(t){if(e){let i=t.locationOf(e);this.moveTo(i)}}.bind(this),t=>{i.reject(t)}).then(function(){return this.handleNextPrePaginated(o,t,this.add)}.bind(this)).then(function(){this.views.show(),i.resolve()}.bind(this)),n}afterDisplayed(t){this.emit(f.c.MANAGERS.ADDED,t)}afterResized(t){this.emit(f.c.MANAGERS.RESIZE,t.section)}moveTo(t){var e=0,i=0;this.isPaginated?(e=Math.floor(t.left/this.layout.delta)*this.layout.delta)+this.layout.delta>this.container.scrollWidth&&(e=this.container.scrollWidth-this.layout.delta):i=t.top,this.scrollTo(e,i,!0)}add(t,e){var i=this.createView(t,e);return this.views.append(i),i.onDisplayed=this.afterDisplayed.bind(this),i.onResize=this.afterResized.bind(this),i.on(f.c.VIEWS.AXIS,t=>{this.updateAxis(t)}),i.on(f.c.VIEWS.WRITING_MODE,t=>{this.updateWritingMode(t)}),i.display(this.request)}append(t,e){var i=this.createView(t,e);return this.views.append(i),i.onDisplayed=this.afterDisplayed.bind(this),i.onResize=this.afterResized.bind(this),i.on(f.c.VIEWS.AXIS,t=>{this.updateAxis(t)}),i.on(f.c.VIEWS.WRITING_MODE,t=>{this.updateWritingMode(t)}),i.display(this.request)}prepend(t,e){var i=this.createView(t,e);return i.on(f.c.VIEWS.RESIZED,t=>{this.counter(t)}),this.views.prepend(i),i.onDisplayed=this.afterDisplayed.bind(this),i.onResize=this.afterResized.bind(this),i.on(f.c.VIEWS.AXIS,t=>{this.updateAxis(t)}),i.on(f.c.VIEWS.WRITING_MODE,t=>{this.updateWritingMode(t)}),i.display(this.request)}counter(t){"vertical"===this.settings.axis?this.scrollBy(0,t.heightDelta,!0):this.scrollBy(t.widthDelta,0,!0)}next(){var t;let e=this.settings.direction;if(this.views.length){if(!this.isPaginated||"horizontal"!==this.settings.axis||e&&"ltr"!==e)if(this.isPaginated&&"horizontal"===this.settings.axis&&"rtl"===e)this.scrollLeft=this.container.scrollLeft,"default"===this.settings.rtlScrollType?this.container.scrollLeft>0?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next():this.container.scrollLeft+-1*this.layout.delta>-1*this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next();else if(this.isPaginated&&"vertical"===this.settings.axis){this.scrollTop=this.container.scrollTop,this.container.scrollTop+this.container.offsetHeight<this.container.scrollHeight?this.scrollBy(0,this.layout.height,!0):t=this.views.last().section.next()}else t=this.views.last().section.next();else this.scrollLeft=this.container.scrollLeft,this.container.scrollLeft+this.container.offsetWidth+this.layout.delta<=this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next();if(t){this.clear();let e=!1;return"pre-paginated"===this.layout.name&&2===this.layout.divisor&&t.properties.includes("page-spread-right")&&(e=!0),this.append(t,e).then(function(){return this.handleNextPrePaginated(e,t,this.append)}.bind(this),t=>t).then(function(){this.isPaginated||"horizontal"!==this.settings.axis||"rtl"!==this.settings.direction||"default"!==this.settings.rtlScrollType||this.scrollTo(this.container.scrollWidth,0,!0),this.views.show()}.bind(this))}}}prev(){var t;let e=this.settings.direction;if(this.views.length){if(!this.isPaginated||"horizontal"!==this.settings.axis||e&&"ltr"!==e)if(this.isPaginated&&"horizontal"===this.settings.axis&&"rtl"===e)this.scrollLeft=this.container.scrollLeft,"default"===this.settings.rtlScrollType?this.container.scrollLeft+this.container.offsetWidth<this.container.scrollWidth?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev():this.container.scrollLeft<0?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev();else if(this.isPaginated&&"vertical"===this.settings.axis){this.scrollTop=this.container.scrollTop,this.container.scrollTop>0?this.scrollBy(0,-this.layout.height,!0):t=this.views.first().section.prev()}else t=this.views.first().section.prev();else this.scrollLeft=this.container.scrollLeft,this.container.scrollLeft>0?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev();if(t){this.clear();let e=!1;return"pre-paginated"===this.layout.name&&2===this.layout.divisor&&"object"!=typeof t.prev()&&(e=!0),this.prepend(t,e).then(function(){var e;if("pre-paginated"===this.layout.name&&this.layout.divisor>1&&(e=t.prev()))return this.prepend(e)}.bind(this),t=>t).then(function(){this.isPaginated&&"horizontal"===this.settings.axis&&("rtl"===this.settings.direction?"default"===this.settings.rtlScrollType?this.scrollTo(0,0,!0):this.scrollTo(-1*this.container.scrollWidth+this.layout.delta,0,!0):this.scrollTo(this.container.scrollWidth-this.layout.delta,0,!0)),this.views.show()}.bind(this))}}}current(){var t=this.visible();return t.length?t[t.length-1]:null}clear(){this.views&&(this.views.hide(),this.scrollTo(0,0,!0),this.views.clear())}currentLocation(){return this.isPaginated&&"horizontal"===this.settings.axis?this.location=this.paginatedLocation():this.location=this.scrolledLocation(),this.location}scrolledLocation(){let t=this.visible(),e=this.container.getBoundingClientRect(),i=e.height<window.innerHeight?e.height:window.innerHeight,n=e.width<window.innerWidth?e.width:window.innerWidth,r="vertical"===this.settings.axis,s=(this.settings.direction,0);return this.settings.fullsize&&(s=r?window.scrollY:window.scrollX),t.map(t=>{let o,a,h,l,{index:c,href:u}=t.section,d=t.position(),f=t.width(),p=t.height();r?(o=s+e.top-d.top+0,a=o+i-0,l=this.layout.count(p,i).pages,h=i):(o=s+e.left-d.left+0,a=o+n-0,l=this.layout.count(f,n).pages,h=n);let g=Math.ceil(o/h),v=[],m=Math.ceil(a/h);if("rtl"===this.settings.direction&&!r){let t=g;g=l-m,m=l-t}v=[];for(var y=g;y<=m;y++){let t=y+1;v.push(t)}return{index:c,href:u,pages:v,totalPages:l,mapping:this.mapping.page(t.contents,t.section.cfiBase,o,a)}})}paginatedLocation(){let t=this.visible(),e=this.container.getBoundingClientRect(),i=0,n=0;return this.settings.fullsize&&(i=window.scrollX),t.map(t=>{let r,s,o,a,{index:h,href:l}=t.section,c=t.position(),u=t.width();"rtl"===this.settings.direction?(r=e.right-i,a=Math.min(Math.abs(r-c.left),this.layout.width)-n,o=c.width-(c.right-r)-n,s=o-a):(r=e.left+i,a=Math.min(c.right-r,this.layout.width)-n,s=r-c.left+n,o=s+a),n+=a;let d=this.mapping.page(t.contents,t.section.cfiBase,s,o),f=this.layout.count(u).pages,p=Math.floor(s/this.layout.pageWidth),g=[],v=Math.floor(o/this.layout.pageWidth);if(p<0&&(p=0,v+=1),"rtl"===this.settings.direction){let t=p;p=f-v,v=f-t}for(var m=p+1;m<=v;m++){let t=m;g.push(t)}return{index:h,href:l,pages:g,totalPages:f,mapping:d}})}isVisible(t,e,i,n){var r=t.position(),s=n||this.bounds();return"horizontal"===this.settings.axis&&r.right>s.left-e&&r.left<s.right+i||"vertical"===this.settings.axis&&r.bottom>s.top-e&&r.top<s.bottom+i}visible(){for(var t,e=this.bounds(),i=this.views.displayed(),n=i.length,r=[],s=0;s<n;s++)t=i[s],!0===this.isVisible(t,0,0,e)&&r.push(t);return r}scrollBy(t,e,i){let n="rtl"===this.settings.direction?-1:1;i&&(this.ignore=!0),this.settings.fullsize?window.scrollBy(t*n,e*n):(t&&(this.container.scrollLeft+=t*n),e&&(this.container.scrollTop+=e)),this.scrolled=!0}scrollTo(t,e,i){i&&(this.ignore=!0),this.settings.fullsize?window.scrollTo(t,e):(this.container.scrollLeft=t,this.container.scrollTop=e),this.scrolled=!0}onScroll(){let t,e;this.settings.fullsize?(t=window.scrollY,e=window.scrollX):(t=this.container.scrollTop,e=this.container.scrollLeft),this.scrollTop=t,this.scrollLeft=e,this.ignore?this.ignore=!1:(this.emit(f.c.MANAGERS.SCROLL,{top:t,left:e}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.emit(f.c.MANAGERS.SCROLLED,{top:this.scrollTop,left:this.scrollLeft})}.bind(this),20))}bounds(){return this.stage.bounds()}applyLayout(t){this.layout=t,this.updateLayout(),this.views&&this.views.length>0&&"pre-paginated"===this.layout.name&&this.display(this.views.first().section)}updateLayout(){this.stage&&(this._stageSize=this.stage.size(),this.isPaginated?(this.layout.calculate(this._stageSize.width,this._stageSize.height,this.settings.gap),this.settings.offset=this.layout.delta/this.layout.divisor):this.layout.calculate(this._stageSize.width,this._stageSize.height),this.viewSettings.width=this.layout.width,this.viewSettings.height=this.layout.height,this.setLayout(this.layout))}setLayout(t){this.viewSettings.layout=t,this.mapping=new a.a(t.props,this.settings.direction,this.settings.axis),this.views&&this.views.forEach((function(e){e&&e.setLayout(t)}))}updateWritingMode(t){this.writingMode=t}updateAxis(t,e){(e||t!==this.settings.axis)&&(this.settings.axis=t,this.stage&&this.stage.axis(t),this.viewSettings.axis=t,this.mapping&&(this.mapping=new a.a(this.layout.props,this.settings.direction,this.settings.axis)),this.layout&&("vertical"===t?this.layout.spread("none"):this.layout.spread(this.layout.settings.spread)))}updateFlow(t,e="auto"){let i="paginated"===t||"auto"===t;this.isPaginated=i,"scrolled-doc"===t||"scrolled-continuous"===t||"scrolled"===t?this.updateAxis("vertical"):this.updateAxis("horizontal"),this.viewSettings.flow=t,this.settings.overflow?this.overflow=this.settings.overflow:this.overflow=i?"hidden":e,this.stage&&this.stage.overflow(this.overflow),this.updateLayout()}getContents(){var t=[];return this.views?(this.views.forEach((function(e){const i=e&&e.contents;i&&t.push(i)})),t):t}direction(t="ltr"){this.settings.direction=t,this.stage&&this.stage.direction(t),this.viewSettings.direction=t,this.updateLayout()}isRendered(){return this.rendered}}r()(p.prototype);e.a=p},function(t,e,i){"use strict";var n=i(2),r=i(0);e.a=class{constructor(t,e,i,n=!1){this.layout=t,this.horizontal="horizontal"===i,this.direction=e||"ltr",this._dev=n}section(t){var e=this.findRanges(t);return this.rangeListToCfiList(t.section.cfiBase,e)}page(t,e,i,r){var s,o=!(!t||!t.document)&&t.document.body;if(o){if(s=this.rangePairToCfiPair(e,{start:this.findStart(o,i,r),end:this.findEnd(o,i,r)}),!0===this._dev){let e=t.document,i=new n.a(s.start).toRange(e),r=new n.a(s.end).toRange(e),o=e.defaultView.getSelection(),a=e.createRange();o.removeAllRanges(),a.setStart(i.startContainer,i.startOffset),a.setEnd(r.endContainer,r.endOffset),o.addRange(a)}return s}}walk(t,e){if(!t||t.nodeType!==Node.TEXT_NODE){var i=function(t){return t.data.trim().length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},n=i;n.acceptNode=i;for(var r,s,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,n,!1);(r=o.nextNode())&&!(s=e(r)););return s}}findRanges(t){for(var e,i,n=[],r=t.contents.scrollWidth(),s=Math.ceil(r/this.layout.spreadWidth)*this.layout.divisor,o=this.layout.columnWidth,a=this.layout.gap,h=0;h<s.pages;h++)e=(o+a)*h,i=o*(h+1)+a*h,n.push({start:this.findStart(t.document.body,e,i),end:this.findEnd(t.document.body,e,i)});return n}findStart(t,e,i){for(var n,s,o=[t],a=t;o.length;)if(n=o.shift(),s=this.walk(n,t=>{var n,s,h,l,c;if(c=Object(r.nodeBounds)(t),this.horizontal&&"ltr"===this.direction){if(n=this.horizontal?c.left:c.top,s=this.horizontal?c.right:c.bottom,n>=e&&n<=i)return t;if(s>e)return t;a=t,o.push(t)}else if(this.horizontal&&"rtl"===this.direction){if(n=c.left,(s=c.right)<=i&&s>=e)return t;if(n<i)return t;a=t,o.push(t)}else{if(h=c.top,l=c.bottom,h>=e&&h<=i)return t;if(l>e)return t;a=t,o.push(t)}}))return this.findTextStartRange(s,e,i);return this.findTextStartRange(a,e,i)}findEnd(t,e,i){for(var n,s,o=[t],a=t;o.length;)if(n=o.shift(),s=this.walk(n,t=>{var n,s,h,l,c;if(c=Object(r.nodeBounds)(t),this.horizontal&&"ltr"===this.direction){if(n=Math.round(c.left),s=Math.round(c.right),n>i&&a)return a;if(s>i)return t;a=t,o.push(t)}else if(this.horizontal&&"rtl"===this.direction){if(n=Math.round(this.horizontal?c.left:c.top),(s=Math.round(this.horizontal?c.right:c.bottom))<e&&a)return a;if(n<e)return t;a=t,o.push(t)}else{if(h=Math.round(c.top),l=Math.round(c.bottom),h>i&&a)return a;if(l>i)return t;a=t,o.push(t)}}))return this.findTextEndRange(s,e,i);return this.findTextEndRange(a,e,i)}findTextStartRange(t,e,i){for(var n,r,s=this.splitTextNodeIntoRanges(t),o=0;o<s.length;o++)if(r=(n=s[o]).getBoundingClientRect(),this.horizontal&&"ltr"===this.direction){if(r.left>=e)return n}else if(this.horizontal&&"rtl"===this.direction){if(r.right<=i)return n}else if(r.top>=e)return n;return s[0]}findTextEndRange(t,e,i){for(var n,r,s,o,a,h,l,c=this.splitTextNodeIntoRanges(t),u=0;u<c.length;u++){if(s=(r=c[u]).getBoundingClientRect(),this.horizontal&&"ltr"===this.direction){if(o=s.left,a=s.right,o>i&&n)return n;if(a>i)return r}else if(this.horizontal&&"rtl"===this.direction){if(o=s.left,(a=s.right)<e&&n)return n;if(o<e)return r}else{if(h=s.top,l=s.bottom,h>i&&n)return n;if(l>i)return r}n=r}return c[c.length-1]}splitTextNodeIntoRanges(t,e){var i,n=[],r=(t.textContent||"").trim(),s=t.ownerDocument,o=e||" ",a=r.indexOf(o);if(-1===a||t.nodeType!=Node.TEXT_NODE)return(i=s.createRange()).selectNodeContents(t),[i];for((i=s.createRange()).setStart(t,0),i.setEnd(t,a),n.push(i),i=!1;-1!=a;)(a=r.indexOf(o,a+1))>0&&(i&&(i.setEnd(t,a),n.push(i)),(i=s.createRange()).setStart(t,a+1));return i&&(i.setEnd(t,r.length),n.push(i)),n}rangePairToCfiPair(t,e){var i=e.start,r=e.end;return i.collapse(!0),r.collapse(!1),{start:new n.a(i,t).toString(),end:new n.a(r,t).toString()}}rangeListToCfiList(t,e){for(var i,n=[],r=0;r<e.length;r++)i=this.rangePairToCfiPair(t,e[r]),n.push(i);return n}axis(t){return t&&(this.horizontal="horizontal"===t),this.horizontal}}},function(t,e,i){"use strict";var n=i(87),r=i(13),s=i(36),o=i(46),a=i(35),h=i(33),l=i(100),c=i(101),u=Math.max,d=Math.min,f=Math.floor,p=/\$([$&'`]|\d\d?|<[^>]*>)/g,g=/\$([$&'`]|\d\d?)/g;n("replace",2,(function(t,e,i,n){var v=n.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,m=n.REPLACE_KEEPS_$0,y=v?"$":"$0";return[function(i,n){var r=h(this),s=null==i?void 0:i[t];return void 0!==s?s.call(i,r,n):e.call(String(r),i,n)},function(t,n){if(!v&&m||"string"==typeof n&&-1===n.indexOf(y)){var s=i(e,t,this,n);if(s.done)return s.value}var h=r(t),f=String(this),p="function"==typeof n;p||(n=String(n));var g=h.global;if(g){var w=h.unicode;h.lastIndex=0}for(var x=[];;){var E=c(h,f);if(null===E)break;if(x.push(E),!g)break;""===String(E[0])&&(h.lastIndex=l(f,o(h.lastIndex),w))}for(var S,_="",O=0,C=0;C<x.length;C++){E=x[C];for(var T=String(E[0]),k=u(d(a(E.index),f.length),0),R=[],L=1;L<E.length;L++)R.push(void 0===(S=E[L])?S:String(S));var I=E.groups;if(p){var j=[T].concat(R,k,f);void 0!==I&&j.push(I);var N=String(n.apply(void 0,j))}else N=b(T,f,k,R,I,n);k>=O&&(_+=f.slice(O,k)+N,O=k+T.length)}return _+f.slice(O)}];function b(t,i,n,r,o,a){var h=n+t.length,l=r.length,c=g;return void 0!==o&&(o=s(o),c=p),e.call(a,c,(function(e,s){var a;switch(s.charAt(0)){case"$":return"$";case"&":return t;case"`":return i.slice(0,n);case"'":return i.slice(h);case"<":a=o[s.slice(1,-1)];break;default:var c=+s;if(0===c)return e;if(c>l){var u=f(c/10);return 0===u?e:u<=l?void 0===r[u-1]?s.charAt(1):r[u-1]+s.charAt(1):e}a=r[c-1]}return void 0===a?"":a}))}}))},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,i){var n,r,s,o=i(89),a=i(7),h=i(17),l=i(15),c=i(10),u=i(43),d=i(44),f=a.WeakMap;if(o){var p=new f,g=p.get,v=p.has,m=p.set;n=function(t,e){return m.call(p,t,e),e},r=function(t){return g.call(p,t)||{}},s=function(t){return v.call(p,t)}}else{var y=u("state");d[y]=!0,n=function(t,e){return l(t,y,e),e},r=function(t){return c(t,y)?t[y]:{}},s=function(t){return c(t,y)}}t.exports={set:n,get:r,has:s,enforce:function(t){return s(t)?r(t):n(t,{})},getterFor:function(t){return function(e){var i;if(!h(e)||(i=r(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return i}}}},function(t,e){t.exports={}},function(t,e,i){"use strict";var n=i(3),r=i.n(n),s=i(0),o=i(2),a=i(23),h=i(11),l=i(1);const c="undefined"!=typeof navigator,u=c&&/Chrome/.test(navigator.userAgent),d=c&&!u&&/AppleWebKit/.test(navigator.userAgent);class f{constructor(t,e,i,n){this.epubcfi=new o.a,this.document=t,this.documentElement=this.document.documentElement,this.content=e||this.document.body,this.window=this.document.defaultView,this._size={width:0,height:0},this.sectionIndex=n||0,this.cfiBase=i||"",this.epubReadingSystem("epub.js",l.b),this.called=0,this.active=!0,this.listeners()}static get listenedEvents(){return l.a}width(t){var e=this.content;return t&&Object(s.isNumber)(t)&&(t+="px"),t&&(e.style.width=t),parseInt(this.window.getComputedStyle(e).width)}height(t){var e=this.content;return t&&Object(s.isNumber)(t)&&(t+="px"),t&&(e.style.height=t),parseInt(this.window.getComputedStyle(e).height)}contentWidth(t){var e=this.content||this.document.body;return t&&Object(s.isNumber)(t)&&(t+="px"),t&&(e.style.width=t),parseInt(this.window.getComputedStyle(e).width)}contentHeight(t){var e=this.content||this.document.body;return t&&Object(s.isNumber)(t)&&(t+="px"),t&&(e.style.height=t),parseInt(this.window.getComputedStyle(e).height)}textWidth(){let t,e,i=this.document.createRange(),n=this.content||this.document.body,r=Object(s.borders)(n);return i.selectNodeContents(n),t=i.getBoundingClientRect(),e=t.width,r&&r.width&&(e+=r.width),Math.round(e)}textHeight(){let t,e,i=this.document.createRange(),n=this.content||this.document.body;return i.selectNodeContents(n),t=i.getBoundingClientRect(),e=t.bottom,Math.round(e)}scrollWidth(){return this.documentElement.scrollWidth}scrollHeight(){return this.documentElement.scrollHeight}overflow(t){return t&&(this.documentElement.style.overflow=t),this.window.getComputedStyle(this.documentElement).overflow}overflowX(t){return t&&(this.documentElement.style.overflowX=t),this.window.getComputedStyle(this.documentElement).overflowX}overflowY(t){return t&&(this.documentElement.style.overflowY=t),this.window.getComputedStyle(this.documentElement).overflowY}css(t,e,i){var n=this.content||this.document.body;return e?n.style.setProperty(t,e,i?"important":""):n.style.removeProperty(t),this.window.getComputedStyle(n)[t]}viewport(t){var e,i=this.document.querySelector("meta[name='viewport']"),n={width:void 0,height:void 0,scale:void 0,minimum:void 0,maximum:void 0,scalable:void 0},r=[];if(i&&i.hasAttribute("content")){let t=i.getAttribute("content"),e=t.match(/width\s*=\s*([^,]*)/),r=t.match(/height\s*=\s*([^,]*)/),s=t.match(/initial-scale\s*=\s*([^,]*)/),o=t.match(/minimum-scale\s*=\s*([^,]*)/),a=t.match(/maximum-scale\s*=\s*([^,]*)/),h=t.match(/user-scalable\s*=\s*([^,]*)/);e&&e.length&&void 0!==e[1]&&(n.width=e[1]),r&&r.length&&void 0!==r[1]&&(n.height=r[1]),s&&s.length&&void 0!==s[1]&&(n.scale=s[1]),o&&o.length&&void 0!==o[1]&&(n.minimum=o[1]),a&&a.length&&void 0!==a[1]&&(n.maximum=a[1]),h&&h.length&&void 0!==h[1]&&(n.scalable=h[1])}return e=Object(s.defaults)(t||{},n),t&&(e.width&&r.push("width="+e.width),e.height&&r.push("height="+e.height),e.scale&&r.push("initial-scale="+e.scale),"no"===e.scalable?(r.push("minimum-scale="+e.scale),r.push("maximum-scale="+e.scale),r.push("user-scalable="+e.scalable)):(e.scalable&&r.push("user-scalable="+e.scalable),e.minimum&&r.push("minimum-scale="+e.minimum),e.maximum&&r.push("minimum-scale="+e.maximum)),i||((i=this.document.createElement("meta")).setAttribute("name","viewport"),this.document.querySelector("head").appendChild(i)),i.setAttribute("content",r.join(", ")),this.window.scrollTo(0,0)),e}expand(){this.emit(l.c.CONTENTS.EXPAND)}listeners(){this.imageLoadListeners(),this.mediaQueryListeners(),this.addEventListeners(),this.addSelectionListeners(),"undefined"==typeof ResizeObserver?(this.resizeListeners(),this.visibilityListeners()):this.resizeObservers(),this.linksHandler()}removeListeners(){this.removeEventListeners(),this.removeSelectionListeners(),this.observer&&this.observer.disconnect(),clearTimeout(this.expanding)}resizeCheck(){let t=this.textWidth(),e=this.textHeight();t==this._size.width&&e==this._size.height||(this._size={width:t,height:e},this.onResize&&this.onResize(this._size),this.emit(l.c.CONTENTS.RESIZE,this._size))}resizeListeners(){clearTimeout(this.expanding),requestAnimationFrame(this.resizeCheck.bind(this)),this.expanding=setTimeout(this.resizeListeners.bind(this),350)}visibilityListeners(){document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&!1===this.active?(this.active=!0,this.resizeListeners()):(this.active=!1,clearTimeout(this.expanding))})}transitionListeners(){let t=this.content;t.style.transitionProperty="font, font-size, font-size-adjust, font-stretch, font-variation-settings, font-weight, width, height",t.style.transitionDuration="0.001ms",t.style.transitionTimingFunction="linear",t.style.transitionDelay="0",this._resizeCheck=this.resizeCheck.bind(this),this.document.addEventListener("transitionend",this._resizeCheck)}mediaQueryListeners(){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;try{n=t[i].cssRules}catch(t){return}if(!n)return;for(var r=0;r<n.length;r+=1){if(n[r].media)this.window.matchMedia(n[r].media.mediaText).addListener(e)}}}resizeObservers(){this.observer=new ResizeObserver(t=>{requestAnimationFrame(this.resizeCheck.bind(this))}),this.observer.observe(this.document.documentElement)}mutationObservers(){this.observer=new MutationObserver(t=>{this.resizeCheck()});this.observer.observe(this.document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}imageLoadListeners(){for(var t,e=this.document.querySelectorAll("img"),i=0;i<e.length;i++)void 0!==(t=e[i]).naturalWidth&&0===t.naturalWidth&&(t.onload=this.expand.bind(this))}fontLoadListeners(){this.document&&this.document.fonts&&this.document.fonts.ready.then(function(){this.resizeCheck()}.bind(this))}root(){return this.document?this.document.documentElement:null}locationOf(t,e){var i,n={left:0,top:0};if(!this.document)return n;if(this.epubcfi.isCfiString(t)){let r=new o.a(t).toRange(this.document,e);if(r){try{if(!r.endContainer||r.startContainer==r.endContainer&&r.startOffset==r.endOffset){let t=r.startContainer.textContent.indexOf(" ",r.startOffset);-1==t&&(t=r.startContainer.textContent.length),r.setEnd(r.startContainer,t)}}catch(t){console.error("setting end offset to start container length failed",t)}if(r.startContainer.nodeType===Node.ELEMENT_NODE)i=r.startContainer.getBoundingClientRect(),n.left=i.left,n.top=i.top;else if(d){let t=r.startContainer,e=new Range;try{1===t.nodeType?i=t.getBoundingClientRect():r.startOffset+2<t.length?(e.setStart(t,r.startOffset),e.setEnd(t,r.startOffset+2),i=e.getBoundingClientRect()):r.startOffset-2>0?(e.setStart(t,r.startOffset-2),e.setEnd(t,r.startOffset),i=e.getBoundingClientRect()):i=t.parentNode.getBoundingClientRect()}catch(t){console.error(t,t.stack)}}else i=r.getBoundingClientRect()}}else if("string"==typeof t&&t.indexOf("#")>-1){let e=t.substring(t.indexOf("#")+1),n=this.document.getElementById(e);if(n)if(d){let t=new Range;t.selectNode(n),i=t.getBoundingClientRect()}else i=n.getBoundingClientRect()}return i&&(n.left=i.left,n.top=i.top),n}addStylesheet(t){return new Promise(function(e,i){var n,r=!1;this.document?(n=this.document.querySelector("link[href='"+t+"']"))?e(!0):((n=this.document.createElement("link")).type="text/css",n.rel="stylesheet",n.href=t,n.onload=n.onreadystatechange=function(){r||this.readyState&&"complete"!=this.readyState||(r=!0,setTimeout(()=>{e(!0)},1))},this.document.head.appendChild(n)):e(!1)}.bind(this))}_getStylesheetNode(t){var e;return t="epubjs-inserted-css-"+(t||""),!!this.document&&((e=this.document.getElementById(t))||((e=this.document.createElement("style")).id=t,this.document.head.appendChild(e)),e)}addStylesheetCss(t,e){return!(!this.document||!t)&&(this._getStylesheetNode(e).innerHTML=t,!0)}addStylesheetRules(t,e){var i;if(this.document&&t&&0!==t.length)if(i=this._getStylesheetNode(e).sheet,"[object Array]"===Object.prototype.toString.call(t))for(var n=0,r=t.length;n<r;n++){var s=1,o=t[n],a=t[n][0],h="";"[object Array]"===Object.prototype.toString.call(o[1][0])&&(o=o[1],s=0);for(var l=o.length;s<l;s++){var c=o[s];h+=c[0]+":"+c[1]+(c[2]?" !important":"")+";\n"}i.insertRule(a+"{"+h+"}",i.cssRules.length)}else{Object.keys(t).forEach(e=>{const n=t[e];if(Array.isArray(n))n.forEach(t=>{const n=Object.keys(t).map(e=>`${e}:${t[e]}`).join(";");i.insertRule(`${e}{${n}}`,i.cssRules.length)});else{const t=Object.keys(n).map(t=>`${t}:${n[t]}`).join(";");i.insertRule(`${e}{${t}}`,i.cssRules.length)}})}}addScript(t){return new Promise(function(e,i){var n,r=!1;this.document?((n=this.document.createElement("script")).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))},this.document.head.appendChild(n)):e(!1)}.bind(this))}addClass(t){var e;this.document&&(e=this.content||this.document.body)&&e.classList.add(t)}removeClass(t){var e;this.document&&(e=this.content||this.document.body)&&e.classList.remove(t)}addEventListeners(){this.document&&(this._triggerEvent=this.triggerEvent.bind(this),l.a.forEach((function(t){this.document.addEventListener(t,this._triggerEvent,{passive:!0})}),this))}removeEventListeners(){this.document&&(l.a.forEach((function(t){this.document.removeEventListener(t,this._triggerEvent,{passive:!0})}),this),this._triggerEvent=void 0)}triggerEvent(t){this.emit(t.type,t)}addSelectionListeners(){this.document&&(this._onSelectionChange=this.onSelectionChange.bind(this),this.document.addEventListener("selectionchange",this._onSelectionChange,{passive:!0}))}removeSelectionListeners(){this.document&&(this.document.removeEventListener("selectionchange",this._onSelectionChange,{passive:!0}),this._onSelectionChange=void 0)}onSelectionChange(t){this.selectionEndTimeout&&clearTimeout(this.selectionEndTimeout),this.selectionEndTimeout=setTimeout(function(){var t=this.window.getSelection();this.triggerSelectedEvent(t)}.bind(this),250)}triggerSelectedEvent(t){var e,i;t&&t.rangeCount>0&&((e=t.getRangeAt(0)).collapsed||(i=new o.a(e,this.cfiBase).toString(),this.emit(l.c.CONTENTS.SELECTED,i),this.emit(l.c.CONTENTS.SELECTED_RANGE,e)))}range(t,e){return new o.a(t).toRange(this.document,e)}cfiFromRange(t,e){return new o.a(t,this.cfiBase,e).toString()}cfiFromNode(t,e){return new o.a(t,this.cfiBase,e).toString()}map(t){return new a.a(t).section()}size(t,e){var i={scale:1,scalable:"no"};this.layoutStyle("scrolling"),t>=0&&(this.width(t),i.width=t,this.css("padding","0 "+t/12+"px")),e>=0&&(this.height(e),i.height=e),this.css("margin","0"),this.css("box-sizing","border-box"),this.viewport(i)}columns(t,e,i,n,r){let o=Object(s.prefixed)("column-axis"),a=Object(s.prefixed)("column-gap"),h=Object(s.prefixed)("column-width"),l=Object(s.prefixed)("column-fill"),c=0===this.writingMode().indexOf("vertical")?"vertical":"horizontal";this.layoutStyle("paginated"),"rtl"===r&&"horizontal"===c&&this.direction(r),this.width(t),this.height(e),this.viewport({width:t,height:e,scale:1,scalable:"no"}),this.css("overflow-y","hidden"),this.css("margin","0",!0),"vertical"===c?(this.css("padding-top",n/2+"px",!0),this.css("padding-bottom",n/2+"px",!0),this.css("padding-left","20px"),this.css("padding-right","20px"),this.css(o,"vertical")):(this.css("padding-top","20px"),this.css("padding-bottom","20px"),this.css("padding-left",n/2+"px",!0),this.css("padding-right",n/2+"px",!0),this.css(o,"horizontal")),this.css("box-sizing","border-box"),this.css("max-width","inherit"),this.css(l,"auto"),this.css(a,n+"px"),this.css(h,i+"px"),this.css("-webkit-line-box-contain","block glyphs replaced")}scaler(t,e,i){var n="scale("+t+")",r="";this.css("transform-origin","top left"),(e>=0||i>=0)&&(r=" translate("+(e||0)+"px, "+(i||0)+"px )"),this.css("transform",n+r)}fit(t,e,i){var n=this.viewport(),r=parseInt(n.width),s=parseInt(n.height),o=t/r,a=e/s,h=o<a?o:a;if(this.layoutStyle("paginated"),this.width(r),this.height(s),this.overflow("hidden"),this.scaler(h,0,0),this.css("background-size",r*h+"px "+s*h+"px"),this.css("background-color","transparent"),i&&i.properties.includes("page-spread-left")){var l=t-r*h;this.css("margin-left",l+"px")}}direction(t){this.documentElement&&(this.documentElement.style.direction=t)}mapPage(t,e,i,n,r){return new a.a(e,r).page(this,t,i,n)}linksHandler(){Object(h.c)(this.content,t=>{this.emit(l.c.CONTENTS.LINK_CLICKED,t)})}writingMode(t){let e=Object(s.prefixed)("writing-mode");return t&&this.documentElement&&(this.documentElement.style[e]=t),this.window.getComputedStyle(this.documentElement)[e]||""}layoutStyle(t){return t&&(this._layoutStyle=t,navigator.epubReadingSystem.layoutStyle=this._layoutStyle),this._layoutStyle||"paginated"}epubReadingSystem(t,e){return navigator.epubReadingSystem={name:t,version:e,layoutStyle:this.layoutStyle(),hasFeature:function(t){switch(t){case"dom-manipulation":case"layout-changes":case"touch-events":case"mouse-events":case"keyboard-events":return!0;case"spine-scripting":default:return!1}}},navigator.epubReadingSystem}destroy(){this.removeListeners()}}r()(f.prototype),e.a=f},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Underline=e.Highlight=e.Mark=e.Pane=void 0;var n=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),r=o(i(135)),s=o(i(136));function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.Pane=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.body;l(this,t),this.target=e,this.element=r.default.createElement("svg"),this.marks=[],this.element.style.position="absolute",this.element.setAttribute("pointer-events","none"),s.default.proxyMouse(this.target,this.marks),this.container=i,this.container.appendChild(this.element),this.render()}return n(t,[{key:"addMark",value:function(t){var e=r.default.createElement("g");return this.element.appendChild(e),t.bind(e,this.container),this.marks.push(t),t.render(),t}},{key:"removeMark",value:function(t){var e=this.marks.indexOf(t);if(-1!==e){var i=t.unbind();this.element.removeChild(i),this.marks.splice(e,1)}}},{key:"render",value:function(){var t,e,i,n;!function(t,e){t.style.setProperty("top",e.top+"px","important"),t.style.setProperty("left",e.left+"px","important"),t.style.setProperty("height",e.height+"px","important"),t.style.setProperty("width",e.width+"px","important")}(this.element,(t=this.target,e=this.container,i=e.getBoundingClientRect(),n=t.getBoundingClientRect(),{top:n.top-i.top,left:n.left-i.left,height:t.scrollHeight,width:t.scrollWidth}));var r=!0,s=!1,o=void 0;try{for(var a,h=this.marks[Symbol.iterator]();!(r=(a=h.next()).done);r=!0){a.value.render()}}catch(t){s=!0,o=t}finally{try{!r&&h.return&&h.return()}finally{if(s)throw o}}}}]),t}();var c=e.Mark=function(){function t(){l(this,t),this.element=null}return n(t,[{key:"bind",value:function(t,e){this.element=t,this.container=e}},{key:"unbind",value:function(){var t=this.element;return this.element=null,t}},{key:"render",value:function(){}},{key:"dispatchEvent",value:function(t){this.element&&this.element.dispatchEvent(t)}},{key:"getBoundingClientRect",value:function(){return this.element.getBoundingClientRect()}},{key:"getClientRects",value:function(){for(var t=[],e=this.element.firstChild;e;)t.push(e.getBoundingClientRect()),e=e.nextSibling;return t}},{key:"filteredRanges",value:function(){var t=Array.from(this.range.getClientRects());return t.filter((function(e){for(var i=0;i<t.length;i++){if(t[i]===e)return!0;if(n=t[i],(r=e).right<=n.right&&r.left>=n.left&&r.top>=n.top&&r.bottom<=n.bottom)return!1}var n,r;return!0}))}}]),t}(),u=e.Highlight=function(t){function e(t,i,n,r){l(this,e);var s=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return s.range=t,s.className=i,s.data=n||{},s.attributes=r||{},s}return h(e,t),n(e,[{key:"bind",value:function(t,i){for(var n in function t(e,i,n){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,i);if(void 0===r){var s=Object.getPrototypeOf(e);return null===s?void 0:t(s,i,n)}if("value"in r)return r.value;var o=r.get;return void 0!==o?o.call(n):void 0}(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"bind",this).call(this,t,i),this.data)this.data.hasOwnProperty(n)&&(this.element.dataset[n]=this.data[n]);for(var n in this.attributes)this.attributes.hasOwnProperty(n)&&this.element.setAttribute(n,this.attributes[n]);this.className&&this.element.classList.add(this.className)}},{key:"render",value:function(){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(var t=this.element.ownerDocument.createDocumentFragment(),e=this.filteredRanges(),i=this.element.getBoundingClientRect(),n=this.container.getBoundingClientRect(),s=0,o=e.length;s<o;s++){var a=e[s],h=r.default.createElement("rect");h.setAttribute("x",a.left-i.left+n.left),h.setAttribute("y",a.top-i.top+n.top),h.setAttribute("height",a.height),h.setAttribute("width",a.width),t.appendChild(h)}this.element.appendChild(t)}}]),e}(c);e.Underline=function(t){function e(t,i,n,r){return l(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i,n,r))}return h(e,t),n(e,[{key:"render",value:function(){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(var t=this.element.ownerDocument.createDocumentFragment(),e=this.filteredRanges(),i=this.element.getBoundingClientRect(),n=this.container.getBoundingClientRect(),s=0,o=e.length;s<o;s++){var a=e[s],h=r.default.createElement("rect");h.setAttribute("x",a.left-i.left+n.left),h.setAttribute("y",a.top-i.top+n.top),h.setAttribute("height",a.height),h.setAttribute("width",a.width),h.setAttribute("fill","none");var l=r.default.createElement("line");l.setAttribute("x1",a.left-i.left+n.left),l.setAttribute("x2",a.left-i.left+n.left+a.width),l.setAttribute("y1",a.top-i.top+n.top+a.height-1),l.setAttribute("y2",a.top-i.top+n.top+a.height-1),l.setAttribute("stroke-width",1),l.setAttribute("stroke","black"),l.setAttribute("stroke-linecap","square"),t.appendChild(h),t.appendChild(l)}this.element.appendChild(t)}}]),e}(u)},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){var n=i(7),r=i(59).f,s=i(15),o=i(19),a=i(42),h=i(90),l=i(96);t.exports=function(t,e){var i,c,u,d,f,p=t.target,g=t.global,v=t.stat;if(i=g?n:v?n[p]||a(p,{}):(n[p]||{}).prototype)for(c in e){if(d=e[c],u=t.noTargetGet?(f=r(i,c))&&f.value:i[c],!l(g?c:p+(v?".":"#")+c,t.forced)&&void 0!==u){if(typeof d==typeof u)continue;h(d,u)}(t.sham||u&&u.sham)&&s(d,"sham",!0),o(i,c,d,t)}}},function(t,e,i){var n=i(61),r=i(33);t.exports=function(t){return n(r(t))}},function(t,e){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,e){t.exports=!1},function(t,e){var i=Math.ceil,n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:i)(t)}},function(t,e,i){var n=i(33);t.exports=function(t){return Object(n(t))}},function(t,e,i){var n=i(18).f,r=i(10),s=i(8)("toStringTag");t.exports=function(t,e,i){t&&!r(t=i?t:t.prototype,s)&&n(t,s,{configurable:!0,value:e})}},function(e,i){e.exports=t},function(t,e,i){"use strict";var n=i(3),r=i.n(n),s=i(0),o=i(6),a=i(2),h=i(21),l=i(1);class c{constructor(t){this.settings=t,this.name=t.layout||"reflowable",this._spread="none"!==t.spread,this._minSpreadWidth=t.minSpreadWidth||800,this._evenSpreads=t.evenSpreads||!1,"scrolled"===t.flow||"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,this.props={name:this.name,spread:this._spread,flow:this._flow,width:0,height:0,spreadWidth:0,delta:0,columnWidth:0,gap:0,divisor:1}}flow(t){return void 0!==t&&(this._flow="scrolled"===t||"scrolled-continuous"===t||"scrolled-doc"===t?"scrolled":"paginated",this.update({flow:this._flow})),this._flow}spread(t,e){return t&&(this._spread="none"!==t,this.update({spread:this._spread})),e>=0&&(this._minSpreadWidth=e),this._spread}calculate(t,e,i){var n,r,s,o,a=1,h=i||0,l=t,c=e,u=Math.floor(l/12);a=this._spread&&l>=this._minSpreadWidth?2:1,"reflowable"!==this.name||"paginated"!==this._flow||i>=0||(h=u%2==0?u:u-1),"pre-paginated"===this.name&&(h=0),a>1?s=(n=l/a-h)+h:(n=l,s=l),"pre-paginated"===this.name&&a>1&&(l=n),r=n*a+h,o=l,this.width=l,this.height=c,this.spreadWidth=r,this.pageWidth=s,this.delta=o,this.columnWidth=n,this.gap=h,this.divisor=a,this.update({width:l,height:c,spreadWidth:r,pageWidth:s,delta:o,columnWidth:n,gap:h,divisor:a})}format(t,e,i){return"pre-paginated"===this.name?t.fit(this.columnWidth,this.height,e):"paginated"===this._flow?t.columns(this.width,this.height,this.columnWidth,this.gap,this.settings.direction):i&&"horizontal"===i?t.size(null,this.height):t.size(this.width,null)}count(t,e){let i,n;return"pre-paginated"===this.name?(i=1,n=1):"paginated"===this._flow?(e=e||this.delta,i=Math.ceil(t/e),n=i*this.divisor):(e=e||this.height,i=Math.ceil(t/e),n=i),{spreads:i,pages:n}}update(t){if(Object.keys(t).forEach(e=>{this.props[e]===t[e]&&delete t[e]}),Object.keys(t).length>0){let e=Object(s.extend)(this.props,t);this.emit(l.c.LAYOUT.UPDATED,e,t)}}}r()(c.prototype);var u=c,d=i(5);var f=class{constructor(t){this.rendition=t,this._themes={default:{rules:{},url:"",serialized:""}},this._overrides={},this._current="default",this._injected=[],this.rendition.hooks.content.register(this.inject.bind(this)),this.rendition.hooks.content.register(this.overrides.bind(this))}register(){if(0!==arguments.length)return 1===arguments.length&&"object"==typeof arguments[0]?this.registerThemes(arguments[0]):1===arguments.length&&"string"==typeof arguments[0]?this.default(arguments[0]):2===arguments.length&&"string"==typeof arguments[1]?this.registerUrl(arguments[0],arguments[1]):2===arguments.length&&"object"==typeof arguments[1]?this.registerRules(arguments[0],arguments[1]):void 0}default(t){if(t)return"string"==typeof t?this.registerUrl("default",t):"object"==typeof t?this.registerRules("default",t):void 0}registerThemes(t){for(var e in t)t.hasOwnProperty(e)&&("string"==typeof t[e]?this.registerUrl(e,t[e]):this.registerRules(e,t[e]))}registerCss(t,e){this._themes[t]={serialized:e},(this._injected[t]||"default"==t)&&this.update(t)}registerUrl(t,e){var i=new d.a(e);this._themes[t]={url:i.toString()},(this._injected[t]||"default"==t)&&this.update(t)}registerRules(t,e){this._themes[t]={rules:e},(this._injected[t]||"default"==t)&&this.update(t)}select(t){var e=this._current;this._current=t,this.update(t),this.rendition.getContents().forEach(i=>{i.removeClass(e),i.addClass(t)})}update(t){this.rendition.getContents().forEach(e=>{this.add(t,e)})}inject(t){var e,i=[],n=this._themes;for(var r in n)!n.hasOwnProperty(r)||r!==this._current&&"default"!==r||(((e=n[r]).rules&&Object.keys(e.rules).length>0||e.url&&-1===i.indexOf(e.url))&&this.add(r,t),this._injected.push(r));"default"!=this._current&&t.addClass(this._current)}add(t,e){var i=this._themes[t];i&&e&&(i.url?e.addStylesheet(i.url):i.serialized?(e.addStylesheetCss(i.serialized,t),i.injected=!0):i.rules&&(e.addStylesheetRules(i.rules,t),i.injected=!0))}override(t,e,i){var n=this.rendition.getContents();this._overrides[t]={value:e,priority:!0===i},n.forEach(e=>{e.css(t,this._overrides[t].value,this._overrides[t].priority)})}removeOverride(t){var e=this.rendition.getContents();delete this._overrides[t],e.forEach(e=>{e.css(t)})}overrides(t){var e=this._overrides;for(var i in e)e.hasOwnProperty(i)&&t.css(i,e[i].value,e[i].priority)}fontSize(t){this.override("font-size",t)}font(t){this.override("font-family",t,!0)}destroy(){this.rendition=void 0,this._themes=void 0,this._overrides=void 0,this._current=void 0,this._injected=void 0}};i(28);class p{constructor({type:t,cfiRange:e,data:i,sectionIndex:n,cb:r,className:s,styles:o}){this.type=t,this.cfiRange=e,this.data=i,this.sectionIndex=n,this.mark=void 0,this.cb=r,this.className=s,this.styles=o}update(t){this.data=t}attach(t){let e,{cfiRange:i,data:n,type:r,mark:s,cb:o,className:a,styles:h}=this;return"highlight"===r?e=t.highlight(i,n,o,a,h):"underline"===r?e=t.underline(i,n,o,a,h):"mark"===r&&(e=t.mark(i,n,o)),this.mark=e,this.emit(l.c.ANNOTATION.ATTACH,e),e}detach(t){let e,{cfiRange:i,type:n}=this;return t&&("highlight"===n?e=t.unhighlight(i):"underline"===n?e=t.ununderline(i):"mark"===n&&(e=t.unmark(i))),this.mark=void 0,this.emit(l.c.ANNOTATION.DETACH,e),e}text(){}}r()(p.prototype);var g=class{constructor(t){this.rendition=t,this.highlights=[],this.underlines=[],this.marks=[],this._annotations={},this._annotationsBySectionIndex={},this.rendition.hooks.render.register(this.inject.bind(this)),this.rendition.hooks.unloaded.register(this.clear.bind(this))}add(t,e,i,n,r,s){let o=encodeURI(e+t),h=new a.a(e).spinePos,l=new p({type:t,cfiRange:e,data:i,sectionIndex:h,cb:n,className:r,styles:s});return this._annotations[o]=l,h in this._annotationsBySectionIndex?this._annotationsBySectionIndex[h].push(o):this._annotationsBySectionIndex[h]=[o],this.rendition.views().forEach(t=>{l.sectionIndex===t.index&&l.attach(t)}),l}remove(t,e){let i=encodeURI(t+e);if(i in this._annotations){let t=this._annotations[i];if(e&&t.type!==e)return;this.rendition.views().forEach(e=>{this._removeFromAnnotationBySectionIndex(t.sectionIndex,i),t.sectionIndex===e.index&&t.detach(e)}),delete this._annotations[i]}}_removeFromAnnotationBySectionIndex(t,e){this._annotationsBySectionIndex[t]=this._annotationsAt(t).filter(t=>t!==e)}_annotationsAt(t){return this._annotationsBySectionIndex[t]}highlight(t,e,i,n,r){return this.add("highlight",t,e,i,n,r)}underline(t,e,i,n,r){return this.add("underline",t,e,i,n,r)}mark(t,e,i){return this.add("mark",t,e,i)}each(){return this._annotations.forEach.apply(this._annotations,arguments)}inject(t){let e=t.index;if(e in this._annotationsBySectionIndex){this._annotationsBySectionIndex[e].forEach(e=>{this._annotations[e].attach(t)})}}clear(t){let e=t.index;if(e in this._annotationsBySectionIndex){this._annotationsBySectionIndex[e].forEach(e=>{this._annotations[e].detach(t)})}}show(){}hide(){}},v=i(54),m=i(22),y=i(56);class b{constructor(t,e){this.settings=Object(s.extend)(this.settings||{},{width:null,height:null,ignoreClass:"",manager:"default",view:"iframe",flow:null,layout:null,spread:null,minSpreadWidth:800,stylesheet:null,resizeOnOrientationChange:!0,script:null,snap:!1,defaultDirection:"ltr"}),Object(s.extend)(this.settings,e),"object"==typeof this.settings.manager&&(this.manager=this.settings.manager),this.book=t,this.hooks={},this.hooks.display=new o.a(this),this.hooks.serialize=new o.a(this),this.hooks.content=new o.a(this),this.hooks.unloaded=new o.a(this),this.hooks.layout=new o.a(this),this.hooks.render=new o.a(this),this.hooks.show=new o.a(this),this.hooks.content.register(this.handleLinks.bind(this)),this.hooks.content.register(this.passEvents.bind(this)),this.hooks.content.register(this.adjustImages.bind(this)),this.book.spine.hooks.content.register(this.injectIdentifier.bind(this)),this.settings.stylesheet&&this.book.spine.hooks.content.register(this.injectStylesheet.bind(this)),this.settings.script&&this.book.spine.hooks.content.register(this.injectScript.bind(this)),this.themes=new f(this),this.annotations=new g(this),this.epubcfi=new a.a,this.q=new h.a(this),this.location=void 0,this.q.enqueue(this.book.opened),this.starting=new s.defer,this.started=this.starting.promise,this.q.enqueue(this.start)}setManager(t){this.manager=t}requireManager(t){return"string"==typeof t&&"default"===t?m.a:"string"==typeof t&&"continuous"===t?y.a:t}requireView(t){return"string"==typeof t&&"iframe"===t?v.a:t}start(){switch(this.settings.layout||"pre-paginated"!==this.book.package.metadata.layout&&"true"!==this.book.displayOptions.fixedLayout||(this.settings.layout="pre-paginated"),this.book.package.metadata.spread){case"none":this.settings.spread="none";break;case"both":this.settings.spread=!0}this.manager||(this.ViewManager=this.requireManager(this.settings.manager),this.View=this.requireView(this.settings.view),this.manager=new this.ViewManager({view:this.View,queue:this.q,request:this.book.load.bind(this.book),settings:this.settings})),this.direction(this.book.package.metadata.direction||this.settings.defaultDirection),this.settings.globalLayoutProperties=this.determineLayoutProperties(this.book.package.metadata),this.flow(this.settings.globalLayoutProperties.flow),this.layout(this.settings.globalLayoutProperties),this.manager.on(l.c.MANAGERS.ADDED,this.afterDisplayed.bind(this)),this.manager.on(l.c.MANAGERS.REMOVED,this.afterRemoved.bind(this)),this.manager.on(l.c.MANAGERS.RESIZED,this.onResized.bind(this)),this.manager.on(l.c.MANAGERS.ORIENTATION_CHANGE,this.onOrientationChange.bind(this)),this.manager.on(l.c.MANAGERS.SCROLLED,this.reportLocation.bind(this)),this.emit(l.c.RENDITION.STARTED),this.starting.resolve()}attachTo(t){return this.q.enqueue(function(){this.manager.render(t,{width:this.settings.width,height:this.settings.height}),this.emit(l.c.RENDITION.ATTACHED)}.bind(this))}display(t){return this.displaying&&this.displaying.resolve(),this.q.enqueue(this._display,t)}_display(t){if(this.book){this.epubcfi.isCfiString(t);var e,i=new s.defer,n=i.promise;return this.displaying=i,this.book.locations.length()&&Object(s.isFloat)(t)&&(t=this.book.locations.cfiFromPercentage(parseFloat(t))),(e=this.book.spine.get(t))?(this.manager.display(e,t).then(()=>{i.resolve(e),this.displaying=void 0,this.emit(l.c.RENDITION.DISPLAYED,e),this.reportLocation()},t=>{this.emit(l.c.RENDITION.DISPLAY_ERROR,t)}),n):(i.reject(new Error("No Section Found")),n)}}afterDisplayed(t){t.on(l.c.VIEWS.MARK_CLICKED,(e,i)=>this.triggerMarkEvent(e,i,t.contents)),this.hooks.render.trigger(t,this).then(()=>{t.contents?this.hooks.content.trigger(t.contents,this).then(()=>{this.emit(l.c.RENDITION.RENDERED,t.section,t)}):this.emit(l.c.RENDITION.RENDERED,t.section,t)})}afterRemoved(t){this.hooks.unloaded.trigger(t,this).then(()=>{this.emit(l.c.RENDITION.REMOVED,t.section,t)})}onResized(t,e){this.emit(l.c.RENDITION.RESIZED,{width:t.width,height:t.height},e),this.location&&this.location.start&&this.display(e||this.location.start.cfi)}onOrientationChange(t){this.emit(l.c.RENDITION.ORIENTATION_CHANGE,t)}moveTo(t){this.manager.moveTo(t)}resize(t,e,i){t&&(this.settings.width=t),e&&(this.settings.height=e),this.manager.resize(t,e,i)}clear(){this.manager.clear()}next(){return this.q.enqueue(this.manager.next.bind(this.manager)).then(this.reportLocation.bind(this))}prev(){return this.q.enqueue(this.manager.prev.bind(this.manager)).then(this.reportLocation.bind(this))}determineLayoutProperties(t){var e=this.settings.layout||t.layout||"reflowable",i=this.settings.spread||t.spread||"auto",n=this.settings.orientation||t.orientation||"auto",r=this.settings.flow||t.flow||"auto",s=t.viewport||"",o=this.settings.minSpreadWidth||t.minSpreadWidth||800,a=this.settings.direction||t.direction||"ltr";return(0===this.settings.width||this.settings.width>0)&&(0===this.settings.height||this.settings.height),{layout:e,spread:i,orientation:n,flow:r,viewport:s,minSpreadWidth:o,direction:a}}flow(t){var e=t;"scrolled"!==t&&"scrolled-doc"!==t&&"scrolled-continuous"!==t||(e="scrolled"),"auto"!==t&&"paginated"!==t||(e="paginated"),this.settings.flow=t,this._layout&&this._layout.flow(e),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this.manager&&this.manager.updateFlow(e),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}layout(t){return t&&(this._layout=new u(t),this._layout.spread(t.spread,this.settings.minSpreadWidth),this._layout.on(l.c.LAYOUT.UPDATED,(t,e)=>{this.emit(l.c.RENDITION.LAYOUT,t,e)})),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this._layout}spread(t,e){this.settings.spread=t,e&&(this.settings.minSpreadWidth=e),this._layout&&this._layout.spread(t,e),this.manager&&this.manager.isRendered()&&this.manager.updateLayout()}direction(t){this.settings.direction=t||"ltr",this.manager&&this.manager.direction(this.settings.direction),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}reportLocation(){return this.q.enqueue(function(){requestAnimationFrame(function(){var t=this.manager.currentLocation();if(t&&t.then&&"function"==typeof t.then)t.then(function(t){let e=this.located(t);e&&e.start&&e.end&&(this.location=e,this.emit(l.c.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(l.c.RENDITION.RELOCATED,this.location))}.bind(this));else if(t){let e=this.located(t);if(!e||!e.start||!e.end)return;this.location=e,this.emit(l.c.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(l.c.RENDITION.RELOCATED,this.location)}}.bind(this))}.bind(this))}currentLocation(){var t=this.manager.currentLocation();if(t&&t.then&&"function"==typeof t.then)t.then(function(t){return this.located(t)}.bind(this));else if(t){return this.located(t)}}located(t){if(!t.length)return{};let e=t[0],i=t[t.length-1],n={start:{index:e.index,href:e.href,cfi:e.mapping.start,displayed:{page:e.pages[0]||1,total:e.totalPages}},end:{index:i.index,href:i.href,cfi:i.mapping.end,displayed:{page:i.pages[i.pages.length-1]||1,total:i.totalPages}}},r=this.book.locations.locationFromCfi(e.mapping.start),s=this.book.locations.locationFromCfi(i.mapping.end);null!=r&&(n.start.location=r,n.start.percentage=this.book.locations.percentageFromLocation(r)),null!=s&&(n.end.location=s,n.end.percentage=this.book.locations.percentageFromLocation(s));let o=this.book.pageList.pageFromCfi(e.mapping.start),a=this.book.pageList.pageFromCfi(i.mapping.end);return-1!=o&&(n.start.page=o),-1!=a&&(n.end.page=a),i.index===this.book.spine.last().index&&n.end.displayed.page>=n.end.displayed.total&&(n.atEnd=!0),e.index===this.book.spine.first().index&&1===n.start.displayed.page&&(n.atStart=!0),n}destroy(){this.manager&&this.manager.destroy(),this.book=void 0}passEvents(t){l.a.forEach(e=>{t.on(e,e=>this.triggerViewEvent(e,t))}),t.on(l.c.CONTENTS.SELECTED,e=>this.triggerSelectedEvent(e,t))}triggerViewEvent(t,e){this.emit(t.type,t,e)}triggerSelectedEvent(t,e){this.emit(l.c.RENDITION.SELECTED,t,e)}triggerMarkEvent(t,e,i){this.emit(l.c.RENDITION.MARK_CLICKED,t,e,i)}getRange(t,e){var i=new a.a(t),n=this.manager.visible().filter((function(t){if(i.spinePos===t.index)return!0}));if(n.length)return n[0].contents.range(i,e)}adjustImages(t){if("pre-paginated"===this._layout.name)return new Promise((function(t){t()}));let e=t.window.getComputedStyle(t.content,null),i=.95*(t.content.offsetHeight-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom))),n=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.addStylesheetRules({img:{"max-width":(this._layout.columnWidth?this._layout.columnWidth-n+"px":"100%")+"!important","max-height":i+"px!important","object-fit":"contain","page-break-inside":"avoid","break-inside":"avoid","box-sizing":"border-box"},svg:{"max-width":(this._layout.columnWidth?this._layout.columnWidth-n+"px":"100%")+"!important","max-height":i+"px!important","page-break-inside":"avoid","break-inside":"avoid"}}),new Promise((function(t,e){setTimeout((function(){t()}),1)}))}getContents(){return this.manager?this.manager.getContents():[]}views(){return(this.manager?this.manager.views:void 0)||[]}handleLinks(t){t&&t.on(l.c.CONTENTS.LINK_CLICKED,t=>{let e=this.book.path.relative(t);this.display(e)})}injectStylesheet(t,e){let i=t.createElement("link");i.setAttribute("type","text/css"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",this.settings.stylesheet),t.getElementsByTagName("head")[0].appendChild(i)}injectScript(t,e){let i=t.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("src",this.settings.script),i.textContent=" ",t.getElementsByTagName("head")[0].appendChild(i)}injectIdentifier(t,e){let i=this.book.packaging.metadata.identifier,n=t.createElement("meta");n.setAttribute("name","dc.relation.ispartof"),i&&n.setAttribute("content",i),t.getElementsByTagName("head")[0].appendChild(n)}}r()(b.prototype);e.a=b},function(t,e){var i={}.toString;t.exports=function(t){return i.call(t).slice(8,-1)}},function(t,e,i){var n=i(17);t.exports=function(t,e){if(!n(t))return t;var i,r;if(e&&"function"==typeof(i=t.toString)&&!n(r=i.call(t)))return r;if("function"==typeof(i=t.valueOf)&&!n(r=i.call(t)))return r;if(!e&&"function"==typeof(i=t.toString)&&!n(r=i.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},function(t,e,i){var n=i(7),r=i(15);t.exports=function(t,e){try{r(n,t,e)}catch(i){n[t]=e}return e}},function(t,e,i){var n=i(66),r=i(67),s=n("keys");t.exports=function(t){return s[t]||(s[t]=r(t))}},function(t,e){t.exports={}},function(t,e,i){var n=i(92),r=i(7),s=function(t){return"function"==typeof t?t:void 0};t.exports=function(t,e){return arguments.length<2?s(n[t])||s(r[t]):n[t]&&n[t][e]||r[t]&&r[t][e]}},function(t,e,i){var n=i(35),r=Math.min;t.exports=function(t){return t>0?r(n(t),9007199254740991):0}},function(t,e){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(t,e,i){"use strict";var n,r,s=i(97),o=i(98),a=RegExp.prototype.exec,h=String.prototype.replace,l=a,c=(n=/a/,r=/b*/g,a.call(n,"a"),a.call(r,"a"),0!==n.lastIndex||0!==r.lastIndex),u=o.UNSUPPORTED_Y||o.BROKEN_CARET,d=void 0!==/()??/.exec("")[1];(c||d||u)&&(l=function(t){var e,i,n,r,o=this,l=u&&o.sticky,f=s.call(o),p=o.source,g=0,v=t;return l&&(-1===(f=f.replace("y","")).indexOf("g")&&(f+="g"),v=String(t).slice(o.lastIndex),o.lastIndex>0&&(!o.multiline||o.multiline&&"\n"!==t[o.lastIndex-1])&&(p="(?: "+p+")",v=" "+v,g++),i=new RegExp("^(?:"+p+")",f)),d&&(i=new RegExp("^"+p+"$(?!\\s)",f)),c&&(e=o.lastIndex),n=a.call(l?i:o,v),l?n?(n.input=n.input.slice(g),n[0]=n[0].slice(g),n.index=o.lastIndex,o.lastIndex+=n[0].length):o.lastIndex=0:c&&n&&(o.lastIndex=o.global?n.index+n[0].length:e),d&&n&&n.length>1&&h.call(n[0],i,(function(){for(r=1;r<arguments.length-2;r++)void 0===arguments[r]&&(n[r]=void 0)})),n}),t.exports=l},function(t,e,i){var n=i(35),r=i(33),s=function(t){return function(e,i){var s,o,a=String(r(e)),h=n(i),l=a.length;return h<0||h>=l?t?"":void 0:(s=a.charCodeAt(h))<55296||s>56319||h+1===l||(o=a.charCodeAt(h+1))<56320||o>57343?t?a.charAt(h):s:t?a.slice(h,h+2):o-56320+(s-55296<<10)+65536}};t.exports={codeAt:s(!1),charAt:s(!0)}},function(t,e,i){var n,r=i(13),s=i(72),o=i(47),a=i(44),h=i(104),l=i(63),c=i(43),u=c("IE_PROTO"),d=function(){},f=function(t){return"<script>"+t+"<\/script>"},p=function(){try{n=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;p=n?function(t){t.write(f("")),t.close();var e=t.parentWindow.Object;return t=null,e}(n):((e=l("iframe")).style.display="none",h.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(f("document.F=Object")),t.close(),t.F);for(var i=o.length;i--;)delete p.prototype[o[i]];return p()};a[u]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(d.prototype=r(t),i=new d,d.prototype=null,i[u]=t):i=p(),void 0===e?i:s(i,e)}},function(t,e,i){"use strict";var n=i(115)();t.exports=function(t){return t!==n&&null!==t}},function(t,e,i){var n=i(81),r=i(27),s=i(8)("iterator");t.exports=function(t){if(null!=t)return t[s]||t["@@iterator"]||r[n(t)]}},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,i){"use strict";var n=i(3),r=i.n(n),s=i(0),o=i(2),a=i(28),h=i(1),l=i(29);class c{constructor(t,e){this.settings=Object(s.extend)({ignoreClass:"",axis:void 0,direction:void 0,width:0,height:0,layout:void 0,globalLayoutProperties:{},method:void 0,forceRight:!1},e||{}),this.id="epubjs-view-"+Object(s.uuid)(),this.section=t,this.index=t.index,this.element=this.container(this.settings.axis),this.added=!1,this.displayed=!1,this.rendered=!1,this.fixedWidth=0,this.fixedHeight=0,this.epubcfi=new o.a,this.layout=this.settings.layout,this.pane=void 0,this.highlights={},this.underlines={},this.marks={}}container(t){var e=document.createElement("div");return e.classList.add("epub-view"),e.style.height="0px",e.style.width="0px",e.style.overflow="hidden",e.style.position="relative",e.style.display="block",e.style.flex=t&&"horizontal"==t?"none":"initial",e}create(){return this.iframe||(this.element||(this.element=this.createContainer()),this.iframe=document.createElement("iframe"),this.iframe.id=this.id,this.iframe.scrolling="no",this.iframe.style.overflow="hidden",this.iframe.seamless="seamless",this.iframe.style.border="none",this.iframe.setAttribute("enable-annotation","true"),this.resizing=!0,this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.iframe.style.width="0",this.iframe.style.height="0",this._width=0,this._height=0,this.element.setAttribute("ref",this.index),this.added=!0,this.elementBounds=Object(s.bounds)(this.element),"srcdoc"in this.iframe?this.supportsSrcdoc=!0:this.supportsSrcdoc=!1,this.settings.method||(this.settings.method=this.supportsSrcdoc?"srcdoc":"write")),this.iframe}render(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(){let t,e=this.contents.writingMode();return t="scrolled"===this.settings.flow?0===e.indexOf("vertical")?"horizontal":"vertical":0===e.indexOf("vertical")?"vertical":"horizontal",0===e.indexOf("vertical")&&"paginated"===this.settings.flow&&(this.layout.delta=this.layout.height),this.setAxis(t),this.emit(h.c.VIEWS.AXIS,t),this.setWritingMode(e),this.emit(h.c.VIEWS.WRITING_MODE,e),this.layout.format(this.contents,this.section,this.axis),this.addListeners(),new Promise((t,e)=>{this.expand(),this.settings.forceRight&&(this.element.style.marginLeft=this.width()+"px"),t()})}.bind(this),function(t){return this.emit(h.c.VIEWS.LOAD_ERROR,t),new Promise((e,i)=>{i(t)})}.bind(this)).then(function(){this.emit(h.c.VIEWS.RENDERED,this.section)}.bind(this))}reset(){this.iframe&&(this.iframe.style.width="0",this.iframe.style.height="0",this._width=0,this._height=0,this._textWidth=void 0,this._contentWidth=void 0,this._textHeight=void 0,this._contentHeight=void 0),this._needsReframe=!0}size(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),this.settings.width=i,this.settings.height=n}lock(t,e,i){var n,r=Object(s.borders)(this.element);n=this.iframe?Object(s.borders)(this.iframe):{width:0,height:0},"width"==t&&Object(s.isNumber)(e)&&(this.lockedWidth=e-r.width-n.width),"height"==t&&Object(s.isNumber)(i)&&(this.lockedHeight=i-r.height-n.height),"both"===t&&Object(s.isNumber)(e)&&Object(s.isNumber)(i)&&(this.lockedWidth=e-r.width-n.width,this.lockedHeight=i-r.height-n.height),this.displayed&&this.iframe&&this.expand()}expand(t){var e,i=this.lockedWidth,n=this.lockedHeight;this.iframe&&!this._expanding&&(this._expanding=!0,"pre-paginated"===this.layout.name?(i=this.layout.columnWidth,n=this.layout.height):"horizontal"===this.settings.axis?((i=this.contents.textWidth())%this.layout.pageWidth>0&&(i=Math.ceil(i/this.layout.pageWidth)*this.layout.pageWidth),this.settings.forceEvenPages&&(e=i/this.layout.pageWidth,this.layout.divisor>1&&"reflowable"===this.layout.name&&e%2>0&&(i+=this.layout.pageWidth))):"vertical"===this.settings.axis&&(n=this.contents.textHeight(),"paginated"===this.settings.flow&&n%this.layout.height>0&&(n=Math.ceil(n/this.layout.height)*this.layout.height)),(this._needsReframe||i!=this._width||n!=this._height)&&this.reframe(i,n),this._expanding=!1)}reframe(t,e){var i;Object(s.isNumber)(t)&&(this.element.style.width=t+"px",this.iframe.style.width=t+"px",this._width=t),Object(s.isNumber)(e)&&(this.element.style.height=e+"px",this.iframe.style.height=e+"px",this._height=e),i={width:t,height:e,widthDelta:this.prevBounds?t-this.prevBounds.width:t,heightDelta:this.prevBounds?e-this.prevBounds.height:e},this.pane&&this.pane.render(),requestAnimationFrame(()=>{let t;for(let e in this.marks)this.marks.hasOwnProperty(e)&&(t=this.marks[e],this.placeMark(t.element,t.range))}),this.onResize(this,i),this.emit(h.c.VIEWS.RESIZED,i),this.prevBounds=i,this.elementBounds=Object(s.bounds)(this.element)}load(t){var e=new s.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),"blobUrl"===this.settings.method)this.blobUrl=Object(s.createBlobUrl)(t,"application/xhtml+xml"),this.iframe.src=this.blobUrl,this.element.appendChild(this.iframe);else if("srcdoc"===this.settings.method)this.iframe.srcdoc=t,this.element.appendChild(this.iframe);else{if(this.element.appendChild(this.iframe),this.document=this.iframe.contentDocument,!this.document)return e.reject(new Error("No Document Available")),i;if(this.iframe.contentDocument.open(),window.MSApp&&MSApp.execUnsafeLocalFunction){var n=this;MSApp.execUnsafeLocalFunction((function(){n.iframe.contentDocument.write(t)}))}else this.iframe.contentDocument.write(t);this.iframe.contentDocument.close()}return i}onLoad(t,e){this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,this.contents=new a.a(this.document,this.document.body,this.section.cfiBase,this.section.index),this.rendering=!1;var i=this.document.querySelector("link[rel='canonical']");i?i.setAttribute("href",this.section.canonical):((i=this.document.createElement("link")).setAttribute("rel","canonical"),i.setAttribute("href",this.section.canonical),this.document.querySelector("head").appendChild(i)),this.contents.on(h.c.CONTENTS.EXPAND,()=>{this.displayed&&this.iframe&&(this.expand(),this.contents&&this.layout.format(this.contents))}),this.contents.on(h.c.CONTENTS.RESIZE,t=>{this.displayed&&this.iframe&&(this.expand(),this.contents&&this.layout.format(this.contents))}),e.resolve(this.contents)}setLayout(t){this.layout=t,this.contents&&(this.layout.format(this.contents),this.expand())}setAxis(t){this.settings.axis=t,this.element.style.flex="horizontal"==t?"none":"initial",this.size()}setWritingMode(t){this.writingMode=t}addListeners(){}removeListeners(t){}display(t){var e=new s.defer;return this.displayed?e.resolve(this):this.render(t).then(function(){this.emit(h.c.VIEWS.DISPLAYED,this),this.onDisplayed(this),this.displayed=!0,e.resolve(this)}.bind(this),(function(t){e.reject(t,this)})),e.promise}show(){this.element.style.visibility="visible",this.iframe&&(this.iframe.style.visibility="visible",this.iframe.style.transform="translateZ(0)",this.iframe.offsetWidth,this.iframe.style.transform=null),this.emit(h.c.VIEWS.SHOWN,this)}hide(){this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.stopExpanding=!0,this.emit(h.c.VIEWS.HIDDEN,this)}offset(){return{top:this.element.offsetTop,left:this.element.offsetLeft}}width(){return this._width}height(){return this._height}position(){return this.element.getBoundingClientRect()}locationOf(t){this.iframe.getBoundingClientRect();var e=this.contents.locationOf(t,this.settings.ignoreClass);return{left:e.left,top:e.top}}onDisplayed(t){}onResize(t,e){}bounds(t){return!t&&this.elementBounds||(this.elementBounds=Object(s.bounds)(this.element)),this.elementBounds}highlight(t,e={},i,n="epubjs-hl",r={}){if(!this.contents)return;const s=Object.assign({fill:"yellow","fill-opacity":"0.3","mix-blend-mode":"multiply"},r);let o=this.contents.range(t),a=()=>{this.emit(h.c.VIEWS.MARK_CLICKED,t,e)};e.epubcfi=t,this.pane||(this.pane=new l.Pane(this.iframe,this.element));let c=new l.Highlight(o,n,e,s),u=this.pane.addMark(c);return this.highlights[t]={mark:u,element:u.element,listeners:[a,i]},u.element.setAttribute("ref",n),u.element.addEventListener("click",a),u.element.addEventListener("touchstart",a),i&&(u.element.addEventListener("click",i),u.element.addEventListener("touchstart",i)),u}underline(t,e={},i,n="epubjs-ul",r={}){if(!this.contents)return;const s=Object.assign({stroke:"black","stroke-opacity":"0.3","mix-blend-mode":"multiply"},r);let o=this.contents.range(t),a=()=>{this.emit(h.c.VIEWS.MARK_CLICKED,t,e)};e.epubcfi=t,this.pane||(this.pane=new l.Pane(this.iframe,this.element));let c=new l.Underline(o,n,e,s),u=this.pane.addMark(c);return this.underlines[t]={mark:u,element:u.element,listeners:[a,i]},u.element.setAttribute("ref",n),u.element.addEventListener("click",a),u.element.addEventListener("touchstart",a),i&&(u.element.addEventListener("click",i),u.element.addEventListener("touchstart",i)),u}mark(t,e={},i){if(!this.contents)return;if(t in this.marks){return this.marks[t]}let n=this.contents.range(t);if(!n)return;let r=n.commonAncestorContainer,s=1===r.nodeType?r:r.parentNode,o=i=>{this.emit(h.c.VIEWS.MARK_CLICKED,t,e)};n.collapsed&&1===r.nodeType?(n=new Range,n.selectNodeContents(r)):n.collapsed&&(n=new Range,n.selectNodeContents(s));let a=this.document.createElement("a");return a.setAttribute("ref","epubjs-mk"),a.style.position="absolute",a.dataset.epubcfi=t,e&&Object.keys(e).forEach(t=>{a.dataset[t]=e[t]}),i&&(a.addEventListener("click",i),a.addEventListener("touchstart",i)),a.addEventListener("click",o),a.addEventListener("touchstart",o),this.placeMark(a,n),this.element.appendChild(a),this.marks[t]={element:a,range:n,listeners:[o,i]},s}placeMark(t,e){let i,n,r;if("pre-paginated"===this.layout.name||"horizontal"!==this.settings.axis){let t=e.getBoundingClientRect();i=t.top,n=t.right}else{let t,o=e.getClientRects();for(var s=0;s!=o.length;s++)t=o[s],(!r||t.left<r)&&(r=t.left,n=Math.ceil(r/this.layout.props.pageWidth)*this.layout.props.pageWidth-this.layout.gap/2,i=t.top)}t.style.top=i+"px",t.style.left=n+"px"}unhighlight(t){let e;t in this.highlights&&(e=this.highlights[t],this.pane.removeMark(e.mark),e.listeners.forEach(t=>{t&&(e.element.removeEventListener("click",t),e.element.removeEventListener("touchstart",t))}),delete this.highlights[t])}ununderline(t){let e;t in this.underlines&&(e=this.underlines[t],this.pane.removeMark(e.mark),e.listeners.forEach(t=>{t&&(e.element.removeEventListener("click",t),e.element.removeEventListener("touchstart",t))}),delete this.underlines[t])}unmark(t){let e;t in this.marks&&(e=this.marks[t],this.element.removeChild(e.element),e.listeners.forEach(t=>{t&&(e.element.removeEventListener("click",t),e.element.removeEventListener("touchstart",t))}),delete this.marks[t])}destroy(){for(let t in this.highlights)this.unhighlight(t);for(let t in this.underlines)this.ununderline(t);for(let t in this.marks)this.unmark(t);this.blobUrl&&Object(s.revokeBlobUrl)(this.blobUrl),this.displayed&&(this.displayed=!1,this.removeListeners(),this.contents.destroy(),this.stopExpanding=!0,this.element.removeChild(this.iframe),this.iframe=void 0,this.contents=void 0,this._textWidth=null,this._textHeight=null,this._width=null,this._height=null)}}r()(c.prototype),e.a=c},function(t,e,i){var n=i(53),r=i(137),s=i(139),o=Math.max,a=Math.min;t.exports=function(t,e,i){var h,l,c,u,d,f,p=0,g=!1,v=!1,m=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var i=h,n=l;return h=l=void 0,p=e,u=t.apply(n,i)}function b(t){return p=t,d=setTimeout(x,e),g?y(t):u}function w(t){var i=t-f;return void 0===f||i>=e||i<0||v&&t-p>=c}function x(){var t=r();if(w(t))return E(t);d=setTimeout(x,function(t){var i=e-(t-f);return v?a(i,c-(t-p)):i}(t))}function E(t){return d=void 0,m&&h?y(t):(h=l=void 0,u)}function S(){var t=r(),i=w(t);if(h=arguments,l=this,f=t,i){if(void 0===d)return b(f);if(v)return clearTimeout(d),d=setTimeout(x,e),y(f)}return void 0===d&&(d=setTimeout(x,e)),u}return e=s(e)||0,n(i)&&(g=!!i.leading,c=(v="maxWait"in i)?o(s(i.maxWait)||0,e):c,m="trailing"in i?!!i.trailing:m),S.cancel=function(){void 0!==d&&clearTimeout(d),p=0,h=f=l=d=void 0},S.flush=function(){return void 0===d?u:E(r())},S}},function(t,e,i){"use strict";i(14);var n=i(0),r=i(22),s=i(1),o=i(3),a=i.n(o);const h=Math.PI/2,l={easeOutSine:function(t){return Math.sin(t*h)},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},easeInCubic:function(t){return Math.pow(t,3)}};class c{constructor(t,e){this.settings=Object(n.extend)({duration:80,minVelocity:.2,minDistance:10,easing:l.easeInCubic},e||{}),this.supportsTouch=this.supportsTouch(),this.supportsTouch&&this.setup(t)}setup(t){this.manager=t,this.layout=this.manager.layout,this.fullsize=this.manager.settings.fullsize,this.fullsize?(this.element=this.manager.stage.element,this.scroller=window,this.disableScroll()):(this.element=this.manager.stage.container,this.scroller=this.element,this.element.style.WebkitOverflowScrolling="touch"),this.manager.settings.offset=this.layout.width,this.manager.settings.afterScrolledTimeout=2*this.settings.duration,this.isVertical="vertical"===this.manager.settings.axis,this.manager.isPaginated&&!this.isVertical&&(this.touchCanceler=!1,this.resizeCanceler=!1,this.snapping=!1,this.scrollLeft,this.scrollTop,this.startTouchX=void 0,this.startTouchY=void 0,this.startTime=void 0,this.endTouchX=void 0,this.endTouchY=void 0,this.endTime=void 0,this.addListeners())}supportsTouch(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}disableScroll(){this.element.style.overflow="hidden"}enableScroll(){this.element.style.overflow=""}addListeners(){this._onResize=this.onResize.bind(this),window.addEventListener("resize",this._onResize),this._onScroll=this.onScroll.bind(this),this.scroller.addEventListener("scroll",this._onScroll),this._onTouchStart=this.onTouchStart.bind(this),this.scroller.addEventListener("touchstart",this._onTouchStart,{passive:!0}),this.on("touchstart",this._onTouchStart),this._onTouchMove=this.onTouchMove.bind(this),this.scroller.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.on("touchmove",this._onTouchMove),this._onTouchEnd=this.onTouchEnd.bind(this),this.scroller.addEventListener("touchend",this._onTouchEnd,{passive:!0}),this.on("touchend",this._onTouchEnd),this._afterDisplayed=this.afterDisplayed.bind(this),this.manager.on(s.c.MANAGERS.ADDED,this._afterDisplayed)}removeListeners(){window.removeEventListener("resize",this._onResize),this._onResize=void 0,this.scroller.removeEventListener("scroll",this._onScroll),this._onScroll=void 0,this.scroller.removeEventListener("touchstart",this._onTouchStart,{passive:!0}),this.off("touchstart",this._onTouchStart),this._onTouchStart=void 0,this.scroller.removeEventListener("touchmove",this._onTouchMove,{passive:!0}),this.off("touchmove",this._onTouchMove),this._onTouchMove=void 0,this.scroller.removeEventListener("touchend",this._onTouchEnd,{passive:!0}),this.off("touchend",this._onTouchEnd),this._onTouchEnd=void 0,this.manager.off(s.c.MANAGERS.ADDED,this._afterDisplayed),this._afterDisplayed=void 0}afterDisplayed(t){let e=t.contents;["touchstart","touchmove","touchend"].forEach(t=>{e.on(t,t=>this.triggerViewEvent(t,e))})}triggerViewEvent(t,e){this.emit(t.type,t,e)}onScroll(t){this.scrollLeft=this.fullsize?window.scrollX:this.scroller.scrollLeft,this.scrollTop=this.fullsize?window.scrollY:this.scroller.scrollTop}onResize(t){this.resizeCanceler=!0}onTouchStart(t){let{screenX:e,screenY:i}=t.touches[0];this.fullsize&&this.enableScroll(),this.touchCanceler=!0,this.startTouchX||(this.startTouchX=e,this.startTouchY=i,this.startTime=this.now()),this.endTouchX=e,this.endTouchY=i,this.endTime=this.now()}onTouchMove(t){let{screenX:e,screenY:i}=t.touches[0],n=Math.abs(i-this.endTouchY);this.touchCanceler=!0,!this.fullsize&&n<10&&(this.element.scrollLeft-=e-this.endTouchX),this.endTouchX=e,this.endTouchY=i,this.endTime=this.now()}onTouchEnd(t){this.fullsize&&this.disableScroll(),this.touchCanceler=!1;let e=this.wasSwiped();0!==e?this.snap(e):this.snap(),this.startTouchX=void 0,this.startTouchY=void 0,this.startTime=void 0,this.endTouchX=void 0,this.endTouchY=void 0,this.endTime=void 0}wasSwiped(){let t=this.layout.pageWidth*this.layout.divisor,e=this.endTouchX-this.startTouchX,i=Math.abs(e),n=e/(this.endTime-this.startTime),r=this.settings.minVelocity;return i<=this.settings.minDistance||i>=t?0:n>r?-1:n<-r?1:void 0}needsSnap(){return this.scrollLeft%(this.layout.pageWidth*this.layout.divisor)!=0}snap(t=0){let e=this.scrollLeft,i=this.layout.pageWidth*this.layout.divisor,n=Math.round(e/i)*i;return t&&(n+=t*i),this.smoothScrollTo(n)}smoothScrollTo(t){const e=new n.defer,i=this.scrollLeft,r=this.now(),s=this.settings.duration,o=this.settings.easing;return this.snapping=!0,function n(){const a=this.now(),h=Math.min(1,(a-r)/s);if(o(h),this.touchCanceler||this.resizeCanceler)return this.resizeCanceler=!1,this.snapping=!1,void e.resolve();h<1?(window.requestAnimationFrame(n.bind(this)),this.scrollTo(i+(t-i)*h,0)):(this.scrollTo(t,0),this.snapping=!1,e.resolve())}.call(this),e.promise}scrollTo(t=0,e=0){this.fullsize?window.scroll(t,e):(this.scroller.scrollLeft=t,this.scroller.scrollTop=e)}now(){return"now"in window.performance?performance.now():(new Date).getTime()}destroy(){this.scroller&&(this.fullsize&&this.enableScroll(),this.removeListeners(),this.scroller=void 0)}}a()(c.prototype);var u=c,d=i(55),f=i.n(d);class p extends r.a{constructor(t){super(t),this.name="continuous",this.settings=Object(n.extend)(this.settings||{},{infinite:!0,overflow:void 0,axis:void 0,writingMode:void 0,flow:"scrolled",offset:500,offsetDelta:250,width:void 0,height:void 0,snap:!1,afterScrolledTimeout:10}),Object(n.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,flow:this.settings.flow,layout:this.layout,width:0,height:0,forceEvenPages:!1},this.scrollTop=0,this.scrollLeft=0}display(t,e){return r.a.prototype.display.call(this,t,e).then(function(){return this.fill()}.bind(this))}fill(t){var e=t||new n.defer;return this.q.enqueue(()=>this.check()).then(t=>{t?this.fill(e):e.resolve()}),e.promise}moveTo(t){var e=0,i=0;this.isPaginated?(e=Math.floor(t.left/this.layout.delta)*this.layout.delta,this.settings.offsetDelta):(i=t.top,t.top,this.settings.offsetDelta),(e>0||i>0)&&this.scrollBy(e,i,!0)}afterResized(t){this.emit(s.c.MANAGERS.RESIZE,t.section)}removeShownListeners(t){t.onDisplayed=function(){}}add(t){var e=this.createView(t);return this.views.append(e),e.on(s.c.VIEWS.RESIZED,t=>{e.expanded=!0}),e.on(s.c.VIEWS.AXIS,t=>{this.updateAxis(t)}),e.on(s.c.VIEWS.WRITING_MODE,t=>{this.updateWritingMode(t)}),e.onDisplayed=this.afterDisplayed.bind(this),e.onResize=this.afterResized.bind(this),e.display(this.request)}append(t){var e=this.createView(t);return e.on(s.c.VIEWS.RESIZED,t=>{e.expanded=!0}),e.on(s.c.VIEWS.AXIS,t=>{this.updateAxis(t)}),e.on(s.c.VIEWS.WRITING_MODE,t=>{this.updateWritingMode(t)}),this.views.append(e),e.onDisplayed=this.afterDisplayed.bind(this),e}prepend(t){var e=this.createView(t);return e.on(s.c.VIEWS.RESIZED,t=>{this.counter(t),e.expanded=!0}),e.on(s.c.VIEWS.AXIS,t=>{this.updateAxis(t)}),e.on(s.c.VIEWS.WRITING_MODE,t=>{this.updateWritingMode(t)}),this.views.prepend(e),e.onDisplayed=this.afterDisplayed.bind(this),e}counter(t){"vertical"===this.settings.axis?this.scrollBy(0,t.heightDelta,!0):this.scrollBy(t.widthDelta,0,!0)}update(t){for(var e,i=this.bounds(),r=this.views.all(),s=r.length,o=[],a=void 0!==t?t:this.settings.offset||0,h=new n.defer,l=[],c=0;c<s;c++)if(e=r[c],!0===this.isVisible(e,a,a,i)){if(e.displayed)e.show();else{let t=e.display(this.request).then((function(t){t.show()}),t=>{e.hide()});l.push(t)}o.push(e)}else this.q.enqueue(e.destroy.bind(e)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.q.enqueue(this.trim.bind(this))}.bind(this),250);return l.length?Promise.all(l).catch(t=>{h.reject(t)}):(h.resolve(),h.promise)}check(t,e){var i=new n.defer,r=[],s="horizontal"===this.settings.axis,o=this.settings.offset||0;t&&s&&(o=t),e&&!s&&(o=e);var a=this._bounds;let h=s?this.scrollLeft:this.scrollTop,l=s?Math.floor(a.width):a.height,c=s?this.container.scrollWidth:this.container.scrollHeight,u=this.writingMode&&0===this.writingMode.indexOf("vertical")?"vertical":"horizontal",d=this.settings.rtlScrollType,f="rtl"===this.settings.direction;this.settings.fullsize?(s&&f&&"negative"===d||!s&&f&&"default"===d)&&(h*=-1):(f&&"default"===d&&"horizontal"===u&&(h=c-l-h),f&&"negative"===d&&"horizontal"===u&&(h*=-1));let p=()=>{let t=this.views.first(),e=t&&t.section.prev();e&&r.push(this.prepend(e))},g=h-o;h+l+o>=c&&(()=>{let t=this.views.last(),e=t&&t.section.next();e&&r.push(this.append(e))})(),g<0&&p();let v=r.map(t=>t.display(this.request));return r.length?Promise.all(v).then(()=>this.check()).then(()=>this.update(o),t=>t):(this.q.enqueue(function(){this.update()}.bind(this)),i.resolve(!1),i.promise)}trim(){for(var t=new n.defer,e=this.views.displayed(),i=e[0],r=e[e.length-1],s=this.views.indexOf(i),o=this.views.indexOf(r),a=this.views.slice(0,s),h=this.views.slice(o+1),l=0;l<a.length-1;l++)this.erase(a[l],a);for(var c=1;c<h.length;c++)this.erase(h[c]);return t.resolve(),t.promise}erase(t,e){var i,n;this.settings.fullsize?(i=window.scrollY,n=window.scrollX):(i=this.container.scrollTop,n=this.container.scrollLeft);var r=t.bounds();this.views.remove(t),e&&("vertical"===this.settings.axis?this.scrollTo(0,i-r.height,!0):"rtl"===this.settings.direction?this.settings.fullsize?this.scrollTo(n+Math.floor(r.width),0,!0):this.scrollTo(n,0,!0):this.scrollTo(n-Math.floor(r.width),0,!0))}addEventListeners(t){window.addEventListener("unload",function(t){this.ignore=!0,this.destroy()}.bind(this)),this.addScrollListeners(),this.isPaginated&&this.settings.snap&&(this.snapper=new u(this,this.settings.snap&&"object"==typeof this.settings.snap&&this.settings.snap))}addScrollListeners(){var t;this.tick=n.requestAnimationFrame;let e="rtl"===this.settings.direction&&"default"===this.settings.rtlScrollType?-1:1;this.scrollDeltaVert=0,this.scrollDeltaHorz=0,this.settings.fullsize?(t=window,this.scrollTop=window.scrollY*e,this.scrollLeft=window.scrollX*e):(t=this.container,this.scrollTop=this.container.scrollTop,this.scrollLeft=this.container.scrollLeft),this._onScroll=this.onScroll.bind(this),t.addEventListener("scroll",this._onScroll),this._scrolled=f()(this.scrolled.bind(this),30),this.didScroll=!1}removeEventListeners(){(this.settings.fullsize?window:this.container).removeEventListener("scroll",this._onScroll),this._onScroll=void 0}onScroll(){let t,e,i="rtl"===this.settings.direction&&"default"===this.settings.rtlScrollType?-1:1;this.settings.fullsize?(t=window.scrollY*i,e=window.scrollX*i):(t=this.container.scrollTop,e=this.container.scrollLeft),this.scrollTop=t,this.scrollLeft=e,this.ignore?this.ignore=!1:this._scrolled(),this.scrollDeltaVert+=Math.abs(t-this.prevScrollTop),this.scrollDeltaHorz+=Math.abs(e-this.prevScrollLeft),this.prevScrollTop=t,this.prevScrollLeft=e,clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(function(){this.scrollDeltaVert=0,this.scrollDeltaHorz=0}.bind(this),150),clearTimeout(this.afterScrolled),this.didScroll=!1}scrolled(){this.q.enqueue(function(){return this.check()}.bind(this)),this.emit(s.c.MANAGERS.SCROLL,{top:this.scrollTop,left:this.scrollLeft}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.snapper&&this.snapper.supportsTouch&&this.snapper.needsSnap()||this.emit(s.c.MANAGERS.SCROLLED,{top:this.scrollTop,left:this.scrollLeft})}.bind(this),this.settings.afterScrolledTimeout)}next(){let t="pre-paginated"===this.layout.props.name&&this.layout.props.spread?2*this.layout.props.delta:this.layout.props.delta;this.views.length&&(this.isPaginated&&"horizontal"===this.settings.axis?this.scrollBy(t,0,!0):this.scrollBy(0,this.layout.height,!0),this.q.enqueue(function(){return this.check()}.bind(this)))}prev(){let t="pre-paginated"===this.layout.props.name&&this.layout.props.spread?2*this.layout.props.delta:this.layout.props.delta;this.views.length&&(this.isPaginated&&"horizontal"===this.settings.axis?this.scrollBy(-t,0,!0):this.scrollBy(0,-this.layout.height,!0),this.q.enqueue(function(){return this.check()}.bind(this)))}updateFlow(t){this.rendered&&this.snapper&&(this.snapper.destroy(),this.snapper=void 0),super.updateFlow(t,"scroll"),this.rendered&&this.isPaginated&&this.settings.snap&&(this.snapper=new u(this,this.settings.snap&&"object"==typeof this.settings.snap&&this.settings.snap))}destroy(){super.destroy(),this.snapper&&this.snapper.destroy()}}e.a=p},function(t,e,i){(function(e){t.exports=function t(e,i,n){function r(o,a){if(!i[o]){if(!e[o]){if(s)return s(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var l=i[o]={exports:{}};e[o][0].call(l.exports,(function(t){var i=e[o][1][t];return r(i||t)}),l,l.exports,t,e,i,n)}return i[o].exports}for(var s=!1,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,i,n){(function(t){"use strict";var e,n,r=t.MutationObserver||t.WebKitMutationObserver;if(r){var s=0,o=new r(c),a=t.document.createTextNode("");o.observe(a,{characterData:!0}),e=function(){a.data=s=++s%2}}else if(t.setImmediate||void 0===t.MessageChannel)e="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){c(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(c,0)};else{var h=new t.MessageChannel;h.port1.onmessage=c,e=function(){h.port2.postMessage(0)}}var l=[];function c(){var t,e;n=!0;for(var i=l.length;i;){for(e=l,l=[],t=-1;++t<i;)e[t]();i=l.length}n=!1}i.exports=function(t){1!==l.push(t)||n||e()}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,i){"use strict";var n=t(1);function r(){}var s={},o=["REJECTED"],a=["FULFILLED"],h=["PENDING"];function l(t){if("function"!=typeof t)throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,t!==r&&f(this,t)}function c(t,e,i){this.promise=t,"function"==typeof e&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),"function"==typeof i&&(this.onRejected=i,this.callRejected=this.otherCallRejected)}function u(t,e,i){n((function(){var n;try{n=e(i)}catch(e){return s.reject(t,e)}n===t?s.reject(t,new TypeError("Cannot resolve promise with itself")):s.resolve(t,n)}))}function d(t){var e=t&&t.then;if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof e)return function(){e.apply(t,arguments)}}function f(t,e){var i=!1;function n(e){i||(i=!0,s.reject(t,e))}function r(e){i||(i=!0,s.resolve(t,e))}var o=p((function(){e(r,n)}));"error"===o.status&&n(o.value)}function p(t,e){var i={};try{i.value=t(e),i.status="success"}catch(t){i.status="error",i.value=t}return i}e.exports=l,l.prototype.catch=function(t){return this.then(null,t)},l.prototype.then=function(t,e){if("function"!=typeof t&&this.state===a||"function"!=typeof e&&this.state===o)return this;var i=new this.constructor(r);return this.state!==h?u(i,this.state===a?t:e,this.outcome):this.queue.push(new c(i,t,e)),i},c.prototype.callFulfilled=function(t){s.resolve(this.promise,t)},c.prototype.otherCallFulfilled=function(t){u(this.promise,this.onFulfilled,t)},c.prototype.callRejected=function(t){s.reject(this.promise,t)},c.prototype.otherCallRejected=function(t){u(this.promise,this.onRejected,t)},s.resolve=function(t,e){var i=p(d,e);if("error"===i.status)return s.reject(t,i.value);var n=i.value;if(n)f(t,n);else{t.state=a,t.outcome=e;for(var r=-1,o=t.queue.length;++r<o;)t.queue[r].callFulfilled(e)}return t},s.reject=function(t,e){t.state=o,t.outcome=e;for(var i=-1,n=t.queue.length;++i<n;)t.queue[i].callRejected(e);return t},l.resolve=function(t){return t instanceof this?t:s.resolve(new this(r),t)},l.reject=function(t){var e=new this(r);return s.reject(e,t)},l.all=function(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var i=t.length,n=!1;if(!i)return this.resolve([]);for(var o=new Array(i),a=0,h=-1,l=new this(r);++h<i;)c(t[h],h);return l;function c(t,r){e.resolve(t).then((function(t){o[r]=t,++a!==i||n||(n=!0,s.resolve(l,o))}),(function(t){n||(n=!0,s.reject(l,t))}))}},l.race=function(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var i=t.length,n=!1;if(!i)return this.resolve([]);for(var o,a=-1,h=new this(r);++a<i;)o=t[a],e.resolve(o).then((function(t){n||(n=!0,s.resolve(h,t))}),(function(t){n||(n=!0,s.reject(h,t))}));return h}},{1:1}],3:[function(t,i,n){(function(e){"use strict";"function"!=typeof e.Promise&&(e.Promise=t(2))}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(t,e,i){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(t){return}}();function s(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(r){if("TypeError"!==r.name)throw r;for(var i=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<t.length;n+=1)i.append(t[n]);return i.getBlob(e.type)}}"undefined"==typeof Promise&&t(3);var o=Promise;function a(t,e){e&&t.then((function(t){e(null,t)}),(function(t){e(t)}))}function h(t,e,i){"function"==typeof e&&t.then(e),"function"==typeof i&&t.catch(i)}function l(t){return"string"!=typeof t&&(console.warn(t+" used as a key, but it is not a string."),t=String(t)),t}function c(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var u=void 0,d={},f=Object.prototype.toString;function p(t){return"boolean"==typeof u?o.resolve(u):function(t){return new o((function(e){var i=t.transaction("local-forage-detect-blob-support","readwrite"),n=s([""]);i.objectStore("local-forage-detect-blob-support").put(n,"key"),i.onabort=function(t){t.preventDefault(),t.stopPropagation(),e(!1)},i.oncomplete=function(){var t=navigator.userAgent.match(/Chrome\/(\d+)/),i=navigator.userAgent.match(/Edge\//);e(i||!t||parseInt(t[1],10)>=43)}})).catch((function(){return!1}))}(t).then((function(t){return u=t}))}function g(t){var e=d[t.name],i={};i.promise=new o((function(t,e){i.resolve=t,i.reject=e})),e.deferredOperations.push(i),e.dbReady?e.dbReady=e.dbReady.then((function(){return i.promise})):e.dbReady=i.promise}function v(t){var e=d[t.name].deferredOperations.pop();if(e)return e.resolve(),e.promise}function m(t,e){var i=d[t.name].deferredOperations.pop();if(i)return i.reject(e),i.promise}function y(t,e){return new o((function(i,n){if(d[t.name]=d[t.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},t.db){if(!e)return i(t.db);g(t),t.db.close()}var s=[t.name];e&&s.push(t.version);var o=r.open.apply(r,s);e&&(o.onupgradeneeded=function(e){var i=o.result;try{i.createObjectStore(t.storeName),e.oldVersion<=1&&i.createObjectStore("local-forage-detect-blob-support")}catch(i){if("ConstraintError"!==i.name)throw i;console.warn('The database "'+t.name+'" has been upgraded from version '+e.oldVersion+" to version "+e.newVersion+', but the storage "'+t.storeName+'" already exists.')}}),o.onerror=function(t){t.preventDefault(),n(o.error)},o.onsuccess=function(){i(o.result),v(t)}}))}function b(t){return y(t,!1)}function w(t){return y(t,!0)}function x(t,e){if(!t.db)return!0;var i=!t.db.objectStoreNames.contains(t.storeName),n=t.version<t.db.version,r=t.version>t.db.version;if(n&&(t.version!==e&&console.warn('The database "'+t.name+"\" can't be downgraded from version "+t.db.version+" to version "+t.version+"."),t.version=t.db.version),r||i){if(i){var s=t.db.version+1;s>t.version&&(t.version=s)}return!0}return!1}function E(t){return s([function(t){for(var e=t.length,i=new ArrayBuffer(e),n=new Uint8Array(i),r=0;r<e;r++)n[r]=t.charCodeAt(r);return i}(atob(t.data))],{type:t.type})}function S(t){return t&&t.__local_forage_encoded_blob}function _(t){var e=this,i=e._initReady().then((function(){var t=d[e._dbInfo.name];if(t&&t.dbReady)return t.dbReady}));return h(i,t,t),i}function O(t,e,i,n){void 0===n&&(n=1);try{var r=t.db.transaction(t.storeName,e);i(null,r)}catch(r){if(n>0&&(!t.db||"InvalidStateError"===r.name||"NotFoundError"===r.name))return o.resolve().then((function(){if(!t.db||"NotFoundError"===r.name&&!t.db.objectStoreNames.contains(t.storeName)&&t.version<=t.db.version)return t.db&&(t.version=t.db.version+1),w(t)})).then((function(){return function(t){g(t);for(var e=d[t.name],i=e.forages,n=0;n<i.length;n++){var r=i[n];r._dbInfo.db&&(r._dbInfo.db.close(),r._dbInfo.db=null)}return t.db=null,b(t).then((function(e){return t.db=e,x(t)?w(t):e})).then((function(n){t.db=e.db=n;for(var r=0;r<i.length;r++)i[r]._dbInfo.db=n})).catch((function(e){throw m(t,e),e}))}(t).then((function(){O(t,e,i,n-1)}))})).catch(i);i(r)}}var C={_driver:"asyncStorage",_initStorage:function(t){var e=this,i={db:null};if(t)for(var n in t)i[n]=t[n];var r=d[i.name];r||(r={forages:[],db:null,dbReady:null,deferredOperations:[]},d[i.name]=r),r.forages.push(e),e._initReady||(e._initReady=e.ready,e.ready=_);var s=[];function a(){return o.resolve()}for(var h=0;h<r.forages.length;h++){var l=r.forages[h];l!==e&&s.push(l._initReady().catch(a))}var c=r.forages.slice(0);return o.all(s).then((function(){return i.db=r.db,b(i)})).then((function(t){return i.db=t,x(i,e._defaultConfig.version)?w(i):t})).then((function(t){i.db=r.db=t,e._dbInfo=i;for(var n=0;n<c.length;n++){var s=c[n];s!==e&&(s._dbInfo.db=i.db,s._dbInfo.version=i.version)}}))},_support:function(){try{if(!r)return!1;var t="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),e="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!t||e)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(t){return!1}}(),iterate:function(t,e){var i=this,n=new o((function(e,n){i.ready().then((function(){O(i._dbInfo,"readonly",(function(r,s){if(r)return n(r);try{var o=s.objectStore(i._dbInfo.storeName).openCursor(),a=1;o.onsuccess=function(){var i=o.result;if(i){var n=i.value;S(n)&&(n=E(n));var r=t(n,i.key,a++);void 0!==r?e(r):i.continue()}else e()},o.onerror=function(){n(o.error)}}catch(t){n(t)}}))})).catch(n)}));return a(n,e),n},getItem:function(t,e){var i=this;t=l(t);var n=new o((function(e,n){i.ready().then((function(){O(i._dbInfo,"readonly",(function(r,s){if(r)return n(r);try{var o=s.objectStore(i._dbInfo.storeName).get(t);o.onsuccess=function(){var t=o.result;void 0===t&&(t=null),S(t)&&(t=E(t)),e(t)},o.onerror=function(){n(o.error)}}catch(t){n(t)}}))})).catch(n)}));return a(n,e),n},setItem:function(t,e,i){var n=this;t=l(t);var r=new o((function(i,r){var s;n.ready().then((function(){return s=n._dbInfo,"[object Blob]"===f.call(e)?p(s.db).then((function(t){return t?e:(i=e,new o((function(t,e){var n=new FileReader;n.onerror=e,n.onloadend=function(e){var n=btoa(e.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:i.type})},n.readAsBinaryString(i)})));var i})):e})).then((function(e){O(n._dbInfo,"readwrite",(function(s,o){if(s)return r(s);try{var a=o.objectStore(n._dbInfo.storeName);null===e&&(e=void 0);var h=a.put(e,t);o.oncomplete=function(){void 0===e&&(e=null),i(e)},o.onabort=o.onerror=function(){var t=h.error?h.error:h.transaction.error;r(t)}}catch(t){r(t)}}))})).catch(r)}));return a(r,i),r},removeItem:function(t,e){var i=this;t=l(t);var n=new o((function(e,n){i.ready().then((function(){O(i._dbInfo,"readwrite",(function(r,s){if(r)return n(r);try{var o=s.objectStore(i._dbInfo.storeName).delete(t);s.oncomplete=function(){e()},s.onerror=function(){n(o.error)},s.onabort=function(){var t=o.error?o.error:o.transaction.error;n(t)}}catch(t){n(t)}}))})).catch(n)}));return a(n,e),n},clear:function(t){var e=this,i=new o((function(t,i){e.ready().then((function(){O(e._dbInfo,"readwrite",(function(n,r){if(n)return i(n);try{var s=r.objectStore(e._dbInfo.storeName).clear();r.oncomplete=function(){t()},r.onabort=r.onerror=function(){var t=s.error?s.error:s.transaction.error;i(t)}}catch(t){i(t)}}))})).catch(i)}));return a(i,t),i},length:function(t){var e=this,i=new o((function(t,i){e.ready().then((function(){O(e._dbInfo,"readonly",(function(n,r){if(n)return i(n);try{var s=r.objectStore(e._dbInfo.storeName).count();s.onsuccess=function(){t(s.result)},s.onerror=function(){i(s.error)}}catch(t){i(t)}}))})).catch(i)}));return a(i,t),i},key:function(t,e){var i=this,n=new o((function(e,n){t<0?e(null):i.ready().then((function(){O(i._dbInfo,"readonly",(function(r,s){if(r)return n(r);try{var o=s.objectStore(i._dbInfo.storeName),a=!1,h=o.openCursor();h.onsuccess=function(){var i=h.result;i?0===t||a?e(i.key):(a=!0,i.advance(t)):e(null)},h.onerror=function(){n(h.error)}}catch(t){n(t)}}))})).catch(n)}));return a(n,e),n},keys:function(t){var e=this,i=new o((function(t,i){e.ready().then((function(){O(e._dbInfo,"readonly",(function(n,r){if(n)return i(n);try{var s=r.objectStore(e._dbInfo.storeName).openCursor(),o=[];s.onsuccess=function(){var e=s.result;e?(o.push(e.key),e.continue()):t(o)},s.onerror=function(){i(s.error)}}catch(t){i(t)}}))})).catch(i)}));return a(i,t),i},dropInstance:function(t,e){e=c.apply(this,arguments);var i=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||i.name,t.storeName=t.storeName||i.storeName);var n,s=this;if(t.name){var h=t.name===i.name&&s._dbInfo.db,l=h?o.resolve(s._dbInfo.db):b(t).then((function(e){var i=d[t.name],n=i.forages;i.db=e;for(var r=0;r<n.length;r++)n[r]._dbInfo.db=e;return e}));n=t.storeName?l.then((function(e){if(e.objectStoreNames.contains(t.storeName)){var i=e.version+1;g(t);var n=d[t.name],s=n.forages;e.close();for(var a=0;a<s.length;a++){var h=s[a];h._dbInfo.db=null,h._dbInfo.version=i}return new o((function(e,n){var s=r.open(t.name,i);s.onerror=function(t){s.result.close(),n(t)},s.onupgradeneeded=function(){s.result.deleteObjectStore(t.storeName)},s.onsuccess=function(){var t=s.result;t.close(),e(t)}})).then((function(t){n.db=t;for(var e=0;e<s.length;e++){var i=s[e];i._dbInfo.db=t,v(i._dbInfo)}})).catch((function(e){throw(m(t,e)||o.resolve()).catch((function(){})),e}))}})):l.then((function(e){g(t);var i=d[t.name],n=i.forages;e.close();for(var s=0;s<n.length;s++)n[s]._dbInfo.db=null;return new o((function(e,i){var n=r.deleteDatabase(t.name);n.onerror=n.onblocked=function(t){var e=n.result;e&&e.close(),i(t)},n.onsuccess=function(){var t=n.result;t&&t.close(),e(t)}})).then((function(t){i.db=t;for(var e=0;e<n.length;e++)v(n[e]._dbInfo)})).catch((function(e){throw(m(t,e)||o.resolve()).catch((function(){})),e}))}))}else n=o.reject("Invalid arguments");return a(n,e),n}},T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=/^~~local_forage_type~([^~]+)~/,R="__lfsc__:".length,L=R+"arbf".length,I=Object.prototype.toString;function j(t){var e,i,n,r,s,o=.75*t.length,a=t.length,h=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);var l=new ArrayBuffer(o),c=new Uint8Array(l);for(e=0;e<a;e+=4)i=T.indexOf(t[e]),n=T.indexOf(t[e+1]),r=T.indexOf(t[e+2]),s=T.indexOf(t[e+3]),c[h++]=i<<2|n>>4,c[h++]=(15&n)<<4|r>>2,c[h++]=(3&r)<<6|63&s;return l}function N(t){var e,i=new Uint8Array(t),n="";for(e=0;e<i.length;e+=3)n+=T[i[e]>>2],n+=T[(3&i[e])<<4|i[e+1]>>4],n+=T[(15&i[e+1])<<2|i[e+2]>>6],n+=T[63&i[e+2]];return i.length%3==2?n=n.substring(0,n.length-1)+"=":i.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var A={serialize:function(t,e){var i="";if(t&&(i=I.call(t)),t&&("[object ArrayBuffer]"===i||t.buffer&&"[object ArrayBuffer]"===I.call(t.buffer))){var n,r="__lfsc__:";t instanceof ArrayBuffer?(n=t,r+="arbf"):(n=t.buffer,"[object Int8Array]"===i?r+="si08":"[object Uint8Array]"===i?r+="ui08":"[object Uint8ClampedArray]"===i?r+="uic8":"[object Int16Array]"===i?r+="si16":"[object Uint16Array]"===i?r+="ur16":"[object Int32Array]"===i?r+="si32":"[object Uint32Array]"===i?r+="ui32":"[object Float32Array]"===i?r+="fl32":"[object Float64Array]"===i?r+="fl64":e(new Error("Failed to get type for BinaryArray"))),e(r+N(n))}else if("[object Blob]"===i){var s=new FileReader;s.onload=function(){var i="~~local_forage_type~"+t.type+"~"+N(this.result);e("__lfsc__:blob"+i)},s.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(i){console.error("Couldn't convert value into a JSON string: ",t),e(null,i)}},deserialize:function(t){if("__lfsc__:"!==t.substring(0,R))return JSON.parse(t);var e,i=t.substring(L),n=t.substring(R,L);if("blob"===n&&k.test(i)){var r=i.match(k);e=r[1],i=i.substring(r[0].length)}var o=j(i);switch(n){case"arbf":return o;case"blob":return s([o],{type:e});case"si08":return new Int8Array(o);case"ui08":return new Uint8Array(o);case"uic8":return new Uint8ClampedArray(o);case"si16":return new Int16Array(o);case"ur16":return new Uint16Array(o);case"si32":return new Int32Array(o);case"ui32":return new Uint32Array(o);case"fl32":return new Float32Array(o);case"fl64":return new Float64Array(o);default:throw new Error("Unkown type: "+n)}},stringToBuffer:j,bufferToString:N};function P(t,e,i,n){t.executeSql("CREATE TABLE IF NOT EXISTS "+e.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],i,n)}function D(t,e,i,n,r,s){t.executeSql(i,n,r,(function(t,o){o.code===o.SYNTAX_ERR?t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[e.storeName],(function(t,a){a.rows.length?s(t,o):P(t,e,(function(){t.executeSql(i,n,r,s)}),s)}),s):s(t,o)}),s)}function z(t,e,i,n){var r=this;t=l(t);var s=new o((function(s,o){r.ready().then((function(){void 0===e&&(e=null);var a=e,h=r._dbInfo;h.serializer.serialize(e,(function(e,l){l?o(l):h.db.transaction((function(i){D(i,h,"INSERT OR REPLACE INTO "+h.storeName+" (key, value) VALUES (?, ?)",[t,e],(function(){s(a)}),(function(t,e){o(e)}))}),(function(e){if(e.code===e.QUOTA_ERR){if(n>0)return void s(z.apply(r,[t,a,i,n-1]));o(e)}}))}))})).catch(o)}));return a(s,i),s}function B(t){return new o((function(e,i){t.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(i,n){for(var r=[],s=0;s<n.rows.length;s++)r.push(n.rows.item(s).name);e({db:t,storeNames:r})}),(function(t,e){i(e)}))}),(function(t){i(t)}))}))}var q={_driver:"webSQLStorage",_initStorage:function(t){var e=this,i={db:null};if(t)for(var n in t)i[n]="string"!=typeof t[n]?t[n].toString():t[n];var r=new o((function(t,n){try{i.db=openDatabase(i.name,String(i.version),i.description,i.size)}catch(t){return n(t)}i.db.transaction((function(r){P(r,i,(function(){e._dbInfo=i,t()}),(function(t,e){n(e)}))}),n)}));return i.serializer=A,r},_support:"function"==typeof openDatabase,iterate:function(t,e){var i=this,n=new o((function(e,n){i.ready().then((function(){var r=i._dbInfo;r.db.transaction((function(i){D(i,r,"SELECT * FROM "+r.storeName,[],(function(i,n){for(var s=n.rows,o=s.length,a=0;a<o;a++){var h=s.item(a),l=h.value;if(l&&(l=r.serializer.deserialize(l)),void 0!==(l=t(l,h.key,a+1)))return void e(l)}e()}),(function(t,e){n(e)}))}))})).catch(n)}));return a(n,e),n},getItem:function(t,e){var i=this;t=l(t);var n=new o((function(e,n){i.ready().then((function(){var r=i._dbInfo;r.db.transaction((function(i){D(i,r,"SELECT * FROM "+r.storeName+" WHERE key = ? LIMIT 1",[t],(function(t,i){var n=i.rows.length?i.rows.item(0).value:null;n&&(n=r.serializer.deserialize(n)),e(n)}),(function(t,e){n(e)}))}))})).catch(n)}));return a(n,e),n},setItem:function(t,e,i){return z.apply(this,[t,e,i,1])},removeItem:function(t,e){var i=this;t=l(t);var n=new o((function(e,n){i.ready().then((function(){var r=i._dbInfo;r.db.transaction((function(i){D(i,r,"DELETE FROM "+r.storeName+" WHERE key = ?",[t],(function(){e()}),(function(t,e){n(e)}))}))})).catch(n)}));return a(n,e),n},clear:function(t){var e=this,i=new o((function(t,i){e.ready().then((function(){var n=e._dbInfo;n.db.transaction((function(e){D(e,n,"DELETE FROM "+n.storeName,[],(function(){t()}),(function(t,e){i(e)}))}))})).catch(i)}));return a(i,t),i},length:function(t){var e=this,i=new o((function(t,i){e.ready().then((function(){var n=e._dbInfo;n.db.transaction((function(e){D(e,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(e,i){var n=i.rows.item(0).c;t(n)}),(function(t,e){i(e)}))}))})).catch(i)}));return a(i,t),i},key:function(t,e){var i=this,n=new o((function(e,n){i.ready().then((function(){var r=i._dbInfo;r.db.transaction((function(i){D(i,r,"SELECT key FROM "+r.storeName+" WHERE id = ? LIMIT 1",[t+1],(function(t,i){var n=i.rows.length?i.rows.item(0).key:null;e(n)}),(function(t,e){n(e)}))}))})).catch(n)}));return a(n,e),n},keys:function(t){var e=this,i=new o((function(t,i){e.ready().then((function(){var n=e._dbInfo;n.db.transaction((function(e){D(e,n,"SELECT key FROM "+n.storeName,[],(function(e,i){for(var n=[],r=0;r<i.rows.length;r++)n.push(i.rows.item(r).key);t(n)}),(function(t,e){i(e)}))}))})).catch(i)}));return a(i,t),i},dropInstance:function(t,e){e=c.apply(this,arguments);var i=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||i.name,t.storeName=t.storeName||i.storeName);var n,r=this;return a(n=t.name?new o((function(e){var n;n=t.name===i.name?r._dbInfo.db:openDatabase(t.name,"","",0),t.storeName?e({db:n,storeNames:[t.storeName]}):e(B(n))})).then((function(t){return new o((function(e,i){t.db.transaction((function(n){function r(t){return new o((function(e,i){n.executeSql("DROP TABLE IF EXISTS "+t,[],(function(){e()}),(function(t,e){i(e)}))}))}for(var s=[],a=0,h=t.storeNames.length;a<h;a++)s.push(r(t.storeNames[a]));o.all(s).then((function(){e()})).catch((function(t){i(t)}))}),(function(t){i(t)}))}))})):o.reject("Invalid arguments"),e),n}};function M(t,e){var i=t.name+"/";return t.storeName!==e.storeName&&(i+=t.storeName+"/"),i}function U(){return!function(){try{return localStorage.setItem("_localforage_support_test",!0),localStorage.removeItem("_localforage_support_test"),!1}catch(t){return!0}}()||localStorage.length>0}var F={_driver:"localStorageWrapper",_initStorage:function(t){var e={};if(t)for(var i in t)e[i]=t[i];return e.keyPrefix=M(t,this._defaultConfig),U()?(this._dbInfo=e,e.serializer=A,o.resolve()):o.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}(),iterate:function(t,e){var i=this,n=i.ready().then((function(){for(var e=i._dbInfo,n=e.keyPrefix,r=n.length,s=localStorage.length,o=1,a=0;a<s;a++){var h=localStorage.key(a);if(0===h.indexOf(n)){var l=localStorage.getItem(h);if(l&&(l=e.serializer.deserialize(l)),void 0!==(l=t(l,h.substring(r),o++)))return l}}}));return a(n,e),n},getItem:function(t,e){var i=this;t=l(t);var n=i.ready().then((function(){var e=i._dbInfo,n=localStorage.getItem(e.keyPrefix+t);return n&&(n=e.serializer.deserialize(n)),n}));return a(n,e),n},setItem:function(t,e,i){var n=this;t=l(t);var r=n.ready().then((function(){void 0===e&&(e=null);var i=e;return new o((function(r,s){var o=n._dbInfo;o.serializer.serialize(e,(function(e,n){if(n)s(n);else try{localStorage.setItem(o.keyPrefix+t,e),r(i)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||s(t),s(t)}}))}))}));return a(r,i),r},removeItem:function(t,e){var i=this;t=l(t);var n=i.ready().then((function(){var e=i._dbInfo;localStorage.removeItem(e.keyPrefix+t)}));return a(n,e),n},clear:function(t){var e=this,i=e.ready().then((function(){for(var t=e._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);0===n.indexOf(t)&&localStorage.removeItem(n)}}));return a(i,t),i},length:function(t){var e=this.keys().then((function(t){return t.length}));return a(e,t),e},key:function(t,e){var i=this,n=i.ready().then((function(){var e,n=i._dbInfo;try{e=localStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(n.keyPrefix.length)),e}));return a(n,e),n},keys:function(t){var e=this,i=e.ready().then((function(){for(var t=e._dbInfo,i=localStorage.length,n=[],r=0;r<i;r++){var s=localStorage.key(r);0===s.indexOf(t.keyPrefix)&&n.push(s.substring(t.keyPrefix.length))}return n}));return a(i,t),i},dropInstance:function(t,e){if(e=c.apply(this,arguments),!(t="function"!=typeof t&&t||{}).name){var i=this.config();t.name=t.name||i.name,t.storeName=t.storeName||i.storeName}var n,r=this;return a(n=t.name?new o((function(e){t.storeName?e(M(t,r._defaultConfig)):e(t.name+"/")})).then((function(t){for(var e=localStorage.length-1;e>=0;e--){var i=localStorage.key(e);0===i.indexOf(t)&&localStorage.removeItem(i)}})):o.reject("Invalid arguments"),e),n}},W=function(t,e){for(var i,n,r=t.length,s=0;s<r;){if((i=t[s])===(n=e)||"number"==typeof i&&"number"==typeof n&&isNaN(i)&&isNaN(n))return!0;s++}return!1},H=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},V={},X={},G={INDEXEDDB:C,WEBSQL:q,LOCALSTORAGE:F},Y=[G.INDEXEDDB._driver,G.WEBSQL._driver,G.LOCALSTORAGE._driver],$=["dropInstance"],K=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat($),Z={description:"",driver:Y.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function J(t,e){t[e]=function(){var i=arguments;return t.ready().then((function(){return t[e].apply(t,i)}))}}function Q(){for(var t=1;t<arguments.length;t++){var e=arguments[t];if(e)for(var i in e)e.hasOwnProperty(i)&&(H(e[i])?arguments[0][i]=e[i].slice():arguments[0][i]=e[i])}return arguments[0]}var tt=new(function(){function t(e){for(var i in function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),G)if(G.hasOwnProperty(i)){var n=G[i],r=n._driver;this[i]=r,V[r]||this.defineDriver(n)}this._defaultConfig=Q({},Z),this._config=Q({},this._defaultConfig,e),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return t.prototype.config=function(t){if("object"===(void 0===t?"undefined":n(t))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var e in t){if("storeName"===e&&(t[e]=t[e].replace(/\W/g,"_")),"version"===e&&"number"!=typeof t[e])return new Error("Database version must be a number.");this._config[e]=t[e]}return!("driver"in t)||!t.driver||this.setDriver(this._config.driver)}return"string"==typeof t?this._config[t]:this._config},t.prototype.defineDriver=function(t,e,i){var n=new o((function(e,i){try{var n=t._driver,r=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver)return void i(r);for(var s=K.concat("_initStorage"),h=0,l=s.length;h<l;h++){var c=s[h];if((!W($,c)||t[c])&&"function"!=typeof t[c])return void i(r)}!function(){for(var e=function(t){return function(){var e=new Error("Method "+t+" is not implemented by the current driver"),i=o.reject(e);return a(i,arguments[arguments.length-1]),i}},i=0,n=$.length;i<n;i++){var r=$[i];t[r]||(t[r]=e(r))}}();var u=function(i){V[n]&&console.info("Redefining LocalForage driver: "+n),V[n]=t,X[n]=i,e()};"_support"in t?t._support&&"function"==typeof t._support?t._support().then(u,i):u(!!t._support):u(!0)}catch(t){i(t)}}));return h(n,e,i),n},t.prototype.driver=function(){return this._driver||null},t.prototype.getDriver=function(t,e,i){var n=V[t]?o.resolve(V[t]):o.reject(new Error("Driver not found."));return h(n,e,i),n},t.prototype.getSerializer=function(t){var e=o.resolve(A);return h(e,t),e},t.prototype.ready=function(t){var e=this,i=e._driverSet.then((function(){return null===e._ready&&(e._ready=e._initDriver()),e._ready}));return h(i,t,t),i},t.prototype.setDriver=function(t,e,i){var n=this;H(t)||(t=[t]);var r=this._getSupportedDrivers(t);function s(){n._config.driver=n.driver()}function a(t){return n._extend(t),s(),n._ready=n._initStorage(n._config),n._ready}var l=null!==this._driverSet?this._driverSet.catch((function(){return o.resolve()})):o.resolve();return this._driverSet=l.then((function(){var t=r[0];return n._dbInfo=null,n._ready=null,n.getDriver(t).then((function(t){n._driver=t._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(t){return function(){var e=0;return function i(){for(;e<t.length;){var r=t[e];return e++,n._dbInfo=null,n._ready=null,n.getDriver(r).then(a).catch(i)}s();var h=new Error("No available storage method found.");return n._driverSet=o.reject(h),n._driverSet}()}}(r)}))})).catch((function(){s();var t=new Error("No available storage method found.");return n._driverSet=o.reject(t),n._driverSet})),h(this._driverSet,e,i),this._driverSet},t.prototype.supports=function(t){return!!X[t]},t.prototype._extend=function(t){Q(this,t)},t.prototype._getSupportedDrivers=function(t){for(var e=[],i=0,n=t.length;i<n;i++){var r=t[i];this.supports(r)&&e.push(r)}return e},t.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,e=K.length;t<e;t++)J(this,K[t])},t.prototype.createInstance=function(e){return new t(e)},t}());e.exports=tt},{3:3}]},{},[4])(4)}).call(this,i(30))},function(t,e,i){"use strict";i(24),i(14);var n=i(3),r=i.n(n),s=i(0),o=i(5),a=i(4),h=i(2),l=i(6),c=i(11);i(20);var u=function(t,e,i,n){var r,o="undefined"!=typeof window&&window.URL,h=o?"blob":"arraybuffer",l=new s.defer,c=new XMLHttpRequest,u=XMLHttpRequest.prototype;for(r in"overrideMimeType"in u||Object.defineProperty(u,"overrideMimeType",{value:function(){}}),i&&(c.withCredentials=!0),c.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE){var t=!1;if(""!==this.responseType&&"document"!==this.responseType||(t=this.responseXML),200===this.status||0===this.status||t){var i;if(!this.response&&!t)return l.reject({status:this.status,message:"Empty Response",stack:(new Error).stack}),l.promise;if(403===this.status)return l.reject({status:this.status,response:this.response,message:"Forbidden",stack:(new Error).stack}),l.promise;i=t?this.responseXML:Object(s.isXml)(e)?Object(s.parse)(this.response,"text/xml"):"xhtml"==e?Object(s.parse)(this.response,"application/xhtml+xml"):"html"==e||"htm"==e?Object(s.parse)(this.response,"text/html"):"json"==e?JSON.parse(this.response):"blob"==e?o?this.response:new Blob([this.response]):this.response,l.resolve(i)}else l.reject({status:this.status,message:this.response,stack:(new Error).stack})}},c.onerror=function(t){l.reject(t)},c.open("GET",t,!0),n)c.setRequestHeader(r,n[r]);return"json"==e&&c.setRequestHeader("Accept","application/json"),e||(e=new a.a(t).extension),"blob"==e&&(c.responseType=h),Object(s.isXml)(e)&&c.overrideMimeType("text/xml"),"binary"==e&&(c.responseType="arraybuffer"),c.send(),l.promise},d=i(38);var f=class{constructor(t,e){this.idref=t.idref,this.linear="yes"===t.linear,this.properties=t.properties,this.index=t.index,this.href=t.href,this.url=t.url,this.canonical=t.canonical,this.next=t.next,this.prev=t.prev,this.cfiBase=t.cfiBase,e?this.hooks=e:(this.hooks={},this.hooks.serialize=new l.a(this),this.hooks.content=new l.a(this)),this.document=void 0,this.contents=void 0,this.output=void 0}load(t){var e=t||this.request||u,i=new s.defer,n=i.promise;return this.contents?i.resolve(this.contents):e(this.url).then(function(t){return this.document=t,this.contents=t.documentElement,this.hooks.content.trigger(this.document,this)}.bind(this)).then(function(){i.resolve(this.contents)}.bind(this)).catch((function(t){i.reject(t)})),n}base(){return Object(c.a)(this.document,this)}render(t){var e=new s.defer,i=e.promise;return this.output,this.load(t).then(function(t){var e=("undefined"!=typeof navigator&&navigator.userAgent||"").indexOf("Trident")>=0,i=new("undefined"==typeof XMLSerializer||e?d.XMLDOMParser:XMLSerializer);return this.output=i.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)})),i}find(t){var e=this,i=[],n=t.toLowerCase();return Object(s.sprint)(e.document,(function(t){!function(t){for(var r,s,o,a=t.textContent.toLowerCase(),h=e.document.createRange(),l=-1;-1!=s;)-1!=(s=a.indexOf(n,l+1))&&((h=e.document.createRange()).setStart(t,s),h.setEnd(t,s+n.length),r=e.cfiFromRange(h),o=t.textContent.length<150?t.textContent:"..."+(o=t.textContent.substring(s-75,s+75))+"...",i.push({cfi:r,excerpt:o})),l=s}(t)})),i}search(t,e=5){if(void 0===document.createTreeWalker)return this.find(t);let i=[];const n=this,r=t.toLowerCase(),s=function(t){const e=t.reduce((t,e)=>t+e.textContent,"").toLowerCase().indexOf(r);if(-1!=e){const s=0,o=e+r.length;let a=0,h=0;if(e<t[s].length){let r;for(;a<t.length-1&&(h+=t[a].length,!(o<=h));)a+=1;let l=t[s],c=t[a],u=n.document.createRange();u.setStart(l,e);let d=t.slice(0,a).reduce((t,e)=>t+e.textContent.length,0);u.setEnd(c,d>o?o:o-d),r=n.cfiFromRange(u);let f=t.slice(0,a+1).reduce((t,e)=>t+e.textContent,"");f.length>150&&(f=f.substring(e-75,e+75),f="..."+f+"..."),i.push({cfi:r,excerpt:f})}}},o=document.createTreeWalker(n.document,NodeFilter.SHOW_TEXT,null,!1);let a,h=[];for(;a=o.nextNode();)h.push(a),h.length==e&&(s(h.slice(0,e)),h=h.slice(1,e));return h.length>0&&s(h),i}reconcileLayoutSettings(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:",""),s=r.indexOf("-");-1!=s&&(i=r.slice(0,s),n=r.slice(s+1),e[i]=n)})),e}cfiFromRange(t){return new h.a(t,this.cfiBase).toString()}cfiFromElement(t){return new h.a(t,this.cfiBase).toString()}unload(){this.document=void 0,this.contents=void 0,this.output=void 0}destroy(){this.unload(),this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.idref=void 0,this.linear=void 0,this.properties=void 0,this.index=void 0,this.href=void 0,this.url=void 0,this.next=void 0,this.prev=void 0,this.cfiBase=void 0}};var p=class{constructor(){this.spineItems=[],this.spineByHref={},this.spineById={},this.hooks={},this.hooks.serialize=new l.a,this.hooks.content=new l.a,this.hooks.content.register(c.a),this.hooks.content.register(c.b),this.hooks.content.register(c.d),this.epubcfi=new h.a,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}unpack(t,e,i){this.items=t.spine,this.manifest=t.manifest,this.spineNodeIndex=t.spineNodeIndex,this.baseUrl=t.baseUrl||t.basePath||"",this.length=this.items.length,this.items.forEach((t,n)=>{var r,s=this.manifest[t.idref];t.index=n,t.cfiBase=this.epubcfi.generateChapterComponent(this.spineNodeIndex,t.index,t.idref),t.href&&(t.url=e(t.href,!0),t.canonical=i(t.href)),s&&(t.href=s.href,t.url=e(t.href,!0),t.canonical=i(t.href),s.properties.length&&t.properties.push.apply(t.properties,s.properties)),"yes"===t.linear?(t.prev=function(){let e=t.index;for(;e>0;){let t=this.get(e-1);if(t&&t.linear)return t;e-=1}}.bind(this),t.next=function(){let e=t.index;for(;e<this.spineItems.length-1;){let t=this.get(e+1);if(t&&t.linear)return t;e+=1}}.bind(this)):(t.prev=function(){},t.next=function(){}),r=new f(t,this.hooks),this.append(r)}),this.loaded=!0}get(t){var e=0;if(void 0===t)for(;e<this.spineItems.length;){let t=this.spineItems[e];if(t&&t.linear)break;e+=1}else if(this.epubcfi.isCfiString(t)){e=new h.a(t).spinePos}else"number"==typeof t||!1===isNaN(t)?e=t:"string"==typeof t&&0===t.indexOf("#")?e=this.spineById[t.substring(1)]:"string"==typeof t&&(t=t.split("#")[0],e=this.spineByHref[t]||this.spineByHref[encodeURI(t)]);return this.spineItems[e]||null}append(t){var e=this.spineItems.length;return t.index=e,this.spineItems.push(t),this.spineByHref[decodeURI(t.href)]=e,this.spineByHref[encodeURI(t.href)]=e,this.spineByHref[t.href]=e,this.spineById[t.idref]=e,e}prepend(t){return this.spineByHref[t.href]=0,this.spineById[t.idref]=0,this.spineItems.forEach((function(t,e){t.index=e})),0}remove(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)}each(){return this.spineItems.forEach.apply(this.spineItems,arguments)}first(){let t=0;do{let e=this.get(t);if(e&&e.linear)return e;t+=1}while(t<this.spineItems.length)}last(){let t=this.spineItems.length-1;do{let e=this.get(t);if(e&&e.linear)return e;t-=1}while(t>=0)}destroy(){this.each(t=>t.destroy()),this.spineItems=void 0,this.spineByHref=void 0,this.spineById=void 0,this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.epubcfi=void 0,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}},g=i(21),v=i(1);class m{constructor(t,e,i){this.spine=t,this.request=e,this.pause=i||100,this.q=new g.a(this),this.epubcfi=new h.a,this._locations=[],this._locationsWords=[],this.total=0,this.break=150,this._current=0,this._wordCounter=0,this.currentLocation="",this._currentCfi="",this.processingTimeout=void 0}generate(t){return t&&(this.break=t),this.q.pause(),this.spine.each(function(t){t.linear&&this.q.enqueue(this.process.bind(this),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))}createRange(){return{startContainer:void 0,startOffset:void 0,endContainer:void 0,endOffset:void 0}}process(t){return t.load(this.request).then(function(e){var i=new s.defer,n=this.parse(e,t.cfiBase);return this._locations=this._locations.concat(n),t.unload(),this.processingTimeout=setTimeout(()=>i.resolve(n),this.pause),i.promise}.bind(this))}parse(t,e,i){var n,r,o=[],a=t.ownerDocument,l=Object(s.qs)(a,"body"),c=0,u=i||this.break;if(Object(s.sprint)(l,function(t){var i,s=t.length,a=0;if(0===t.textContent.trim().length)return!1;for(0==c&&((n=this.createRange()).startContainer=t,n.startOffset=0),(i=u-c)>s&&(c+=s,a=s);a<s;)if(i=u-c,0===c&&(a+=1,(n=this.createRange()).startContainer=t,n.startOffset=a),a+i>=s)c+=s-a,a=s;else{a+=i,n.endContainer=t,n.endOffset=a;let r=new h.a(n,e).toString();o.push(r),c=0}r=t}.bind(this)),n&&n.startContainer&&r){n.endContainer=r,n.endOffset=r.length;let t=new h.a(n,e).toString();o.push(t),c=0}return o}generateFromWords(t,e,i){var n=t?new h.a(t):void 0;return this.q.pause(),this._locationsWords=[],this._wordCounter=0,this.spine.each(function(t){t.linear&&(n?t.index>=n.spinePos&&this.q.enqueue(this.processWords.bind(this),t,e,n,i):this.q.enqueue(this.processWords.bind(this),t,e,n,i))}.bind(this)),this.q.run().then(function(){return this._currentCfi&&(this.currentLocation=this._currentCfi),this._locationsWords}.bind(this))}processWords(t,e,i,n){return n&&this._locationsWords.length>=n?Promise.resolve():t.load(this.request).then(function(r){var o=new s.defer,a=this.parseWords(r,t,e,i),h=n-this._locationsWords.length;return this._locationsWords=this._locationsWords.concat(a.length>=n?a.slice(0,h):a),t.unload(),this.processingTimeout=setTimeout(()=>o.resolve(a),this.pause),o.promise}.bind(this))}countWords(t){return(t=(t=(t=t.replace(/(^\s*)|(\s*$)/gi,"")).replace(/[ ]{2,}/gi," ")).replace(/\n /,"\n")).split(" ").length}parseWords(t,e,i,n){var r,o=e.cfiBase,a=[],l=t.ownerDocument,c=Object(s.qs)(l,"body"),u=i,d=!n||n.spinePos!==e.index;n&&e.index===n.spinePos&&(r=n.findNode(n.range?n.path.steps.concat(n.start.steps):n.path.steps,t.ownerDocument));return Object(s.sprint)(c,function(t){if(!d){if(t!==r)return!1;d=!0}if(t.textContent.length<10&&0===t.textContent.trim().length)return!1;var e,i=this.countWords(t.textContent),n=0;if(0===i)return!1;for((e=u-this._wordCounter)>i&&(this._wordCounter+=i,n=i);n<i;)if(n+(e=u-this._wordCounter)>=i)this._wordCounter+=i-n,n=i;else{n+=e;let i=new h.a(t,o);a.push({cfi:i.toString(),wordCount:this._wordCounter}),this._wordCounter=0}t}.bind(this)),a}locationFromCfi(t){let e;return h.a.prototype.isCfiString(t)&&(t=new h.a(t)),0===this._locations.length?-1:(e=Object(s.locationOf)(t,this._locations,this.epubcfi.compare),e>this.total?this.total:e)}percentageFromCfi(t){if(0===this._locations.length)return null;var e=this.locationFromCfi(t);return this.percentageFromLocation(e)}percentageFromLocation(t){return t&&this.total?t/this.total:0}cfiFromLocation(t){var e=-1;return"number"!=typeof t&&(t=parseInt(t)),t>=0&&t<this._locations.length&&(e=this._locations[t]),e}cfiFromPercentage(t){let e;if(t>1&&console.warn("Normalize cfiFromPercentage value to between 0 - 1"),t>=1){let t=new h.a(this._locations[this.total]);return t.collapse(),t.toString()}return e=Math.ceil(this.total*t),this.cfiFromLocation(e)}load(t){return this._locations="string"==typeof t?JSON.parse(t):t,this.total=this._locations.length-1,this._locations}save(){return JSON.stringify(this._locations)}getCurrent(){return this._current}setCurrent(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.emit(v.c.LOCATIONS.CHANGED,{percentage:this.percentageFromLocation(e)}))}get currentLocation(){return this._current}set currentLocation(t){this.setCurrent(t)}length(){return this._locations.length}destroy(){this.spine=void 0,this.request=void 0,this.pause=void 0,this.q.stop(),this.q=void 0,this.epubcfi=void 0,this._locations=void 0,this.total=void 0,this.break=void 0,this._current=void 0,this.currentLocation=void 0,this._currentCfi=void 0,clearTimeout(this.processingTimeout)}}r()(m.prototype);var y=m,b=i(9),w=i.n(b);var x=class{constructor(t){this.packagePath="",this.directory="",this.encoding="",t&&this.parse(t)}parse(t){var e;if(!t)throw new Error("Container File Not Found");if(!(e=Object(s.qs)(t,"rootfile")))throw new Error("No RootFile Found");this.packagePath=e.getAttribute("full-path"),this.directory=w.a.dirname(this.packagePath),this.encoding=t.xmlEncoding}destroy(){this.packagePath=void 0,this.directory=void 0,this.encoding=void 0}};var E=class{constructor(t){this.manifest={},this.navPath="",this.ncxPath="",this.coverPath="",this.spineNodeIndex=0,this.spine=[],this.metadata={},t&&this.parse(t)}parse(t){var e,i,n;if(!t)throw new Error("Package File Not Found");if(!(e=Object(s.qs)(t,"metadata")))throw new Error("No Metadata Found");if(!(i=Object(s.qs)(t,"manifest")))throw new Error("No Manifest Found");if(!(n=Object(s.qs)(t,"spine")))throw new Error("No Spine Found");return this.manifest=this.parseManifest(i),this.navPath=this.findNavPath(i),this.ncxPath=this.findNcxPath(i,n),this.coverPath=this.findCoverPath(t),this.spineNodeIndex=Object(s.indexOfElementNode)(n),this.spine=this.parseSpine(n,this.manifest),this.uniqueIdentifier=this.findUniqueIdentifier(t),this.metadata=this.parseMetadata(e),this.metadata.direction=n.getAttribute("page-progression-direction"),{metadata:this.metadata,spine:this.spine,manifest:this.manifest,navPath:this.navPath,ncxPath:this.ncxPath,coverPath:this.coverPath,spineNodeIndex:this.spineNodeIndex}}parseMetadata(t){var e={};return e.title=this.getElementText(t,"title"),e.creator=this.getElementText(t,"creator"),e.description=this.getElementText(t,"description"),e.pubdate=this.getElementText(t,"date"),e.publisher=this.getElementText(t,"publisher"),e.identifier=this.getElementText(t,"identifier"),e.language=this.getElementText(t,"language"),e.rights=this.getElementText(t,"rights"),e.modified_date=this.getPropertyText(t,"dcterms:modified"),e.layout=this.getPropertyText(t,"rendition:layout"),e.orientation=this.getPropertyText(t,"rendition:orientation"),e.flow=this.getPropertyText(t,"rendition:flow"),e.viewport=this.getPropertyText(t,"rendition:viewport"),e.media_active_class=this.getPropertyText(t,"media:active-class"),e.spread=this.getPropertyText(t,"rendition:spread"),e}parseManifest(t){var e={},i=Object(s.qsa)(t,"item");return Array.prototype.slice.call(i).forEach((function(t){var i=t.getAttribute("id"),n=t.getAttribute("href")||"",r=t.getAttribute("media-type")||"",s=t.getAttribute("media-overlay")||"",o=t.getAttribute("properties")||"";e[i]={href:n,type:r,overlay:s,properties:o.length?o.split(" "):[]}})),e}parseSpine(t,e){var i=[],n=Object(s.qsa)(t,"itemref");return Array.prototype.slice.call(n).forEach((function(t,e){var n=t.getAttribute("idref"),r=t.getAttribute("properties")||"",s=r.length?r.split(" "):[],o={idref:n,linear:t.getAttribute("linear")||"yes",properties:s,index:e};i.push(o)})),i}findUniqueIdentifier(t){var e=t.documentElement.getAttribute("unique-identifier");if(!e)return"";var i=t.getElementById(e);return i&&"identifier"===i.localName&&"http://purl.org/dc/elements/1.1/"===i.namespaceURI&&i.childNodes.length>0?i.childNodes[0].nodeValue.trim():""}findNavPath(t){var e=Object(s.qsp)(t,"item",{properties:"nav"});return!!e&&e.getAttribute("href")}findNcxPath(t,e){var i,n=Object(s.qsp)(t,"item",{"media-type":"application/x-dtbncx+xml"});return n||(i=e.getAttribute("toc"))&&(n=t.querySelector("#"+i)),!!n&&n.getAttribute("href")}findCoverPath(t){Object(s.qs)(t,"package").getAttribute("version");var e=Object(s.qsp)(t,"item",{properties:"cover-image"});if(e)return e.getAttribute("href");var i=Object(s.qsp)(t,"meta",{name:"cover"});if(i){var n=i.getAttribute("content"),r=t.getElementById(n);return r?r.getAttribute("href"):""}return!1}getElementText(t,e){var i,n=t.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",e);return n&&0!==n.length&&(i=n[0]).childNodes.length?i.childNodes[0].nodeValue:""}getPropertyText(t,e){var i=Object(s.qsp)(t,"meta",{property:e});return i&&i.childNodes.length?i.childNodes[0].nodeValue:""}load(t){this.metadata=t.metadata;let e=t.readingOrder||t.spine;return this.spine=e.map((t,e)=>(t.index=e,t.linear=t.linear||"yes",t)),t.resources.forEach((t,e)=>{this.manifest[e]=t,t.rel&&"cover"===t.rel[0]&&(this.coverPath=t.href)}),this.spineNodeIndex=0,this.toc=t.toc.map((t,e)=>(t.label=t.title,t)),{metadata:this.metadata,spine:this.spine,manifest:this.manifest,navPath:this.navPath,ncxPath:this.ncxPath,coverPath:this.coverPath,spineNodeIndex:this.spineNodeIndex,toc:this.toc}}destroy(){this.manifest=void 0,this.navPath=void 0,this.ncxPath=void 0,this.coverPath=void 0,this.spineNodeIndex=void 0,this.spine=void 0,this.metadata=void 0}};var S=class{constructor(t){this.toc=[],this.tocByHref={},this.tocById={},this.landmarks=[],this.landmarksByType={},this.length=0,t&&this.parse(t)}parse(t){let e,i,n=t.nodeType;n&&(e=Object(s.qs)(t,"html"),i=Object(s.qs)(t,"ncx")),n?e?(this.toc=this.parseNav(t),this.landmarks=this.parseLandmarks(t)):i&&(this.toc=this.parseNcx(t)):this.toc=this.load(t),this.length=0,this.unpack(this.toc)}unpack(t){for(var e,i=0;i<t.length;i++)(e=t[i]).href&&(this.tocByHref[e.href]=i),e.id&&(this.tocById[e.id]=i),this.length++,e.subitems.length&&this.unpack(e.subitems)}get(t){var e;return t?(0===t.indexOf("#")?e=this.tocById[t.substring(1)]:t in this.tocByHref&&(e=this.tocByHref[t]),this.getByIndex(t,e,this.toc)):this.toc}getByIndex(t,e,i){if(0===i.length)return;const n=i[e];if(!n||t!==n.id&&t!==n.href){let n;for(let r=0;r<i.length&&(n=this.getByIndex(t,e,i[r].subitems),!n);++r);return n}return n}landmark(t){var e;return t?(e=this.landmarksByType[t],this.landmarks[e]):this.landmarks}parseNav(t){var e,i,n=Object(s.querySelectorByType)(t,"nav","toc"),r=n?Object(s.qsa)(n,"li"):[],o=r.length,a={},h=[];if(!r||0===o)return h;for(e=0;e<o;++e)(i=this.navItem(r[e]))&&(a[i.id]=i,i.parent?a[i.parent].subitems.push(i):h.push(i));return h}navItem(t){let e=t.getAttribute("id")||void 0,i=Object(s.filterChildren)(t,"a",!0);if(!i)return;let n=i.getAttribute("href")||"";e||(e=n);let r,o=i.textContent||"",a=Object(s.getParentByTagName)(t,"li");if(a&&(r=a.getAttribute("id"),!r)){const t=Object(s.filterChildren)(a,"a",!0);r=t&&t.getAttribute("href")}for(;!r&&a;)if(a=Object(s.getParentByTagName)(a,"li"),a&&(r=a.getAttribute("id"),!r)){const t=Object(s.filterChildren)(a,"a",!0);r=t&&t.getAttribute("href")}return{id:e,href:n,label:o,subitems:[],parent:r}}parseLandmarks(t){var e,i,n=Object(s.querySelectorByType)(t,"nav","landmarks"),r=n?Object(s.qsa)(n,"li"):[],o=r.length,a=[];if(!r||0===o)return a;for(e=0;e<o;++e)(i=this.landmarkItem(r[e]))&&(a.push(i),this.landmarksByType[i.type]=e);return a}landmarkItem(t){let e=Object(s.filterChildren)(t,"a",!0);if(!e)return;let i=e.getAttributeNS("http://www.idpf.org/2007/ops","type")||void 0;return{href:e.getAttribute("href")||"",label:e.textContent||"",type:i}}parseNcx(t){var e,i,n=Object(s.qsa)(t,"navPoint"),r=n.length,o={},a=[];if(!n||0===r)return a;for(e=0;e<r;++e)o[(i=this.ncxItem(n[e])).id]=i,i.parent?o[i.parent].subitems.push(i):a.push(i);return a}ncxItem(t){var e,i=t.getAttribute("id")||!1,n=Object(s.qs)(t,"content").getAttribute("src"),r=Object(s.qs)(t,"navLabel"),o=r.textContent?r.textContent:"",a=t.parentNode;return!a||"navPoint"!==a.nodeName&&"navPoint"!==a.nodeName.split(":").slice(-1)[0]||(e=a.getAttribute("id")),{id:i,href:n,label:o,subitems:[],parent:e}}load(t){return t.map(t=>(t.label=t.title,t.subitems=t.children?this.load(t.children):[],t))}forEach(t){return this.toc.forEach(t)}},_={application:{ecmascript:["es","ecma"],javascript:"js",ogg:"ogx",pdf:"pdf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],"rdf+xml":"rdf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd","opf","ncx"],zip:"zip","x-httpd-eruby":"rhtml","x-latex":"latex","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-object":"o","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","epub+zip":"epub","font-tdpfr":"pfr","inkml+xml":["ink","inkml"],json:"json","jsonml+json":"jsonml","mathml+xml":"mathml","metalink+xml":"metalink",mp4:"mp4s","omdoc+xml":"omdoc",oxps:"oxps","vnd.amazon.ebook":"azw",widget:"wgt","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-mobipocket-ebook":["prc","mobi"],"x-mspublisher":"pub","x-nzb":"nzb","x-tgif":"obj","xaml+xml":"xaml","xml-dtd":"dtd","xproc+xml":"xpl","xslt+xml":"xslt","internet-property-stream":"acx","x-compress":"z","x-compressed":"tgz","x-gzip":"gz"},audio:{flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"x-aiff":["aif","aiff","aifc"],"x-ms-wma":"wma","x-wav":"wav",adpcm:"adp",mp4:"mp4a",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"x-icon":"ico",bmp:"bmp",webp:"webp","x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod"},text:{"cache-manifest":["manifest","appcache"],css:"css",csv:"csv",html:["html","htm","shtml","stm"],mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx","tab-separated-values":"tsv","x-bibtex":"bib"},video:{mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"}},O=function(){var t,e,i,n,r={};for(t in _)if(_.hasOwnProperty(t))for(e in _[t])if(_[t].hasOwnProperty(e))if("string"==typeof(i=_[t][e]))r[i]=t+"/"+e;else for(n=0;n<i.length;n++)r[i[n]]=t+"/"+e;return r}();var C={lookup:function(t){return t&&O[t.split(".").pop().toLowerCase()]||"text/plain"}};var T=class{constructor(t,e){this.settings={replacements:e&&e.replacements||"base64",archive:e&&e.archive,resolver:e&&e.resolver,request:e&&e.request},this.process(t)}process(t){this.manifest=t,this.resources=Object.keys(t).map((function(e){return t[e]})),this.replacementUrls=[],this.html=[],this.assets=[],this.css=[],this.urls=[],this.cssUrls=[],this.split(),this.splitUrls()}split(){this.html=this.resources.filter((function(t){if("application/xhtml+xml"===t.type||"text/html"===t.type)return!0})),this.assets=this.resources.filter((function(t){if("application/xhtml+xml"!==t.type&&"text/html"!==t.type)return!0})),this.css=this.resources.filter((function(t){if("text/css"===t.type)return!0}))}splitUrls(){this.urls=this.assets.map(function(t){return t.href}.bind(this)),this.cssUrls=this.css.map((function(t){return t.href}))}createUrl(t){var e=new o.a(t),i=C.lookup(e.filename);return this.settings.archive?this.settings.archive.createUrl(t,{base64:"base64"===this.settings.replacements}):"base64"===this.settings.replacements?this.settings.request(t,"blob").then(t=>Object(s.blob2base64)(t)).then(t=>Object(s.createBase64Url)(t,i)):this.settings.request(t,"blob").then(t=>Object(s.createBlobUrl)(t,i))}replacements(){if("none"===this.settings.replacements)return new Promise(function(t){t(this.urls)}.bind(this));var t=this.urls.map(t=>{var e=this.settings.resolver(t);return this.createUrl(e).catch(t=>(console.error(t),null))});return Promise.all(t).then(t=>(this.replacementUrls=t.filter(t=>"string"==typeof t),t))}replaceCss(t,e){var i=[];return t=t||this.settings.archive,e=e||this.settings.resolver,this.cssUrls.forEach(function(n){var r=this.createCssFile(n,t,e).then(function(t){var e=this.urls.indexOf(n);e>-1&&(this.replacementUrls[e]=t)}.bind(this));i.push(r)}.bind(this)),Promise.all(i)}createCssFile(t){if(w.a.isAbsolute(t))return new Promise((function(t){t()}));var e,i=this.settings.resolver(t);e=this.settings.archive?this.settings.archive.getText(i):this.settings.request(i,"text");var n=this.urls.map(t=>{var e=this.settings.resolver(t);return new a.a(i).relative(e)});return e?e.then(t=>(t=Object(c.e)(t,n,this.replacementUrls),"base64"===this.settings.replacements?Object(s.createBase64Url)(t,"text/css"):Object(s.createBlobUrl)(t,"text/css")),t=>new Promise((function(t){t()}))):new Promise((function(t){t()}))}relativeTo(t,e){return e=e||this.settings.resolver,this.urls.map(function(i){var n=e(i);return new a.a(t).relative(n)}.bind(this))}get(t){var e=this.urls.indexOf(t);if(-1!==e)return this.replacementUrls.length?new Promise(function(t,i){t(this.replacementUrls[e])}.bind(this)):this.createUrl(t)}substitute(t,e){var i;return i=e?this.relativeTo(e):this.urls,Object(c.e)(t,i,this.replacementUrls)}destroy(){this.settings=void 0,this.manifest=void 0,this.resources=void 0,this.replacementUrls=void 0,this.html=void 0,this.assets=void 0,this.css=void 0,this.urls=void 0,this.cssUrls=void 0}};var k=class{constructor(t){this.pages=[],this.locations=[],this.epubcfi=new h.a,this.firstPage=0,this.lastPage=0,this.totalPages=0,this.toc=void 0,this.ncx=void 0,t&&(this.pageList=this.parse(t)),this.pageList&&this.pageList.length&&this.process(this.pageList)}parse(t){var e=Object(s.qs)(t,"html"),i=Object(s.qs)(t,"ncx");return e?this.parseNav(t):i?this.parseNcx(t):void 0}parseNav(t){var e,i,n=Object(s.querySelectorByType)(t,"nav","page-list"),r=n?Object(s.qsa)(n,"li"):[],o=r.length,a=[];if(!r||0===o)return a;for(e=0;e<o;++e)i=this.item(r[e]),a.push(i);return a}parseNcx(t){var e,i,n,r,o=[],a=0;if(!(i=Object(s.qs)(t,"pageList")))return o;if(r=(n=Object(s.qsa)(i,"pageTarget")).length,!n||0===n.length)return o;for(a=0;a<r;++a)e=this.ncxItem(n[a]),o.push(e);return o}ncxItem(t){var e=Object(s.qs)(t,"navLabel"),i=Object(s.qs)(e,"text").textContent;return{href:Object(s.qs)(t,"content").getAttribute("src"),page:parseInt(i,10)}}item(t){var e,i,n=Object(s.qs)(t,"a"),r=n.getAttribute("href")||"",o=n.textContent||"",a=parseInt(o);return-1!=r.indexOf("epubcfi")?(i=(e=r.split("#"))[0],{cfi:e.length>1&&e[1],href:r,packageUrl:i,page:a}):{href:r,page:a}}process(t){t.forEach((function(t){this.pages.push(t.page),t.cfi&&this.locations.push(t.cfi)}),this),this.firstPage=parseInt(this.pages[0]),this.lastPage=parseInt(this.pages[this.pages.length-1]),this.totalPages=this.lastPage-this.firstPage}pageFromCfi(t){var e=-1;if(0===this.locations.length)return-1;var i=Object(s.indexOfSorted)(t,this.locations,this.epubcfi.compare);return-1!=i?e=this.pages[i]:void 0!==(e=(i=Object(s.locationOf)(t,this.locations,this.epubcfi.compare))-1>=0?this.pages[i-1]:this.pages[0])||(e=-1),e}cfiFromPage(t){var e=-1;"number"!=typeof t&&(t=parseInt(t));var i=this.pages.indexOf(t);return-1!=i&&(e=this.locations[i]),e}pageFromPercentage(t){return Math.round(this.totalPages*t)}percentageFromPage(t){var e=(t-this.firstPage)/this.totalPages;return Math.round(1e3*e)/1e3}percentageFromCfi(t){var e=this.pageFromCfi(t);return this.percentageFromPage(e)}destroy(){this.pages=void 0,this.locations=void 0,this.epubcfi=void 0,this.pageList=void 0,this.toc=void 0,this.ncx=void 0}},R=i(39),L=i(85),I=i.n(L);var j=class{constructor(){this.zip=void 0,this.urlCache={},this.checkRequirements()}checkRequirements(){try{this.zip=new I.a}catch(t){throw new Error("JSZip lib not loaded")}}open(t,e){return this.zip.loadAsync(t,{base64:e})}openUrl(t,e){return u(t,"binary").then(function(t){return this.zip.loadAsync(t,{base64:e})}.bind(this))}request(t,e){var i,n=new s.defer,r=new a.a(t);return e||(e=r.extension),(i="blob"==e?this.getBlob(t):this.getText(t))?i.then(function(t){let i=this.handleResponse(t,e);n.resolve(i)}.bind(this)):n.reject({message:"File not found in the epub: "+t,stack:(new Error).stack}),n.promise}handleResponse(t,e){return"json"==e?JSON.parse(t):Object(s.isXml)(e)?Object(s.parse)(t,"text/xml"):"xhtml"==e?Object(s.parse)(t,"application/xhtml+xml"):"html"==e||"htm"==e?Object(s.parse)(t,"text/html"):t}getBlob(t,e){var i=window.decodeURIComponent(t.substr(1)),n=this.zip.file(i);if(n)return e=e||C.lookup(n.name),n.async("uint8array").then((function(t){return new Blob([t],{type:e})}))}getText(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}))}getBase64(t,e){var i=window.decodeURIComponent(t.substr(1)),n=this.zip.file(i);if(n)return e=e||C.lookup(n.name),n.async("base64").then((function(t){return"data:"+e+";base64,"+t}))}createUrl(t,e){var i,n,r=new s.defer,o=window.URL||window.webkitURL||window.mozURL,a=e&&e.base64;return t in this.urlCache?(r.resolve(this.urlCache[t]),r.promise):(a?(n=this.getBase64(t))&&n.then(function(e){this.urlCache[t]=e,r.resolve(e)}.bind(this)):(n=this.getBlob(t))&&n.then(function(e){i=o.createObjectURL(e),this.urlCache[t]=i,r.resolve(i)}.bind(this)),n||r.reject({message:"File not found in the epub: "+t,stack:(new Error).stack}),r.promise)}revokeUrl(t){var e=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[t];i&&e.revokeObjectURL(i)}destroy(){var t=window.URL||window.webkitURL||window.mozURL;for(let e in this.urlCache)t.revokeObjectURL(e);this.zip=void 0,this.urlCache={}}},N=i(57),A=i.n(N);class P{constructor(t,e,i){this.urlCache={},this.storage=void 0,this.name=t,this.requester=e||u,this.resolver=i,this.online=!0,this.checkRequirements(),this.addListeners()}checkRequirements(){try{let t;void 0===A.a&&(t=A.a),this.storage=t.createInstance({name:this.name})}catch(t){throw new Error("localForage lib not loaded")}}addListeners(){this._status=this.status.bind(this),window.addEventListener("online",this._status),window.addEventListener("offline",this._status)}removeListeners(){window.removeEventListener("online",this._status),window.removeEventListener("offline",this._status),this._status=void 0}status(t){let e=navigator.onLine;this.online=e,e?this.emit("online",this):this.emit("offline",this)}add(t,e){let i=t.resources.map(t=>{let{href:i}=t,n=this.resolver(i),r=window.encodeURIComponent(n);return this.storage.getItem(r).then(t=>!t||e?this.requester(n,"binary").then(t=>this.storage.setItem(r,t)):t)});return Promise.all(i)}put(t,e,i){let n=window.encodeURIComponent(t);return this.storage.getItem(n).then(r=>r||this.requester(t,"binary",e,i).then(t=>this.storage.setItem(n,t)))}request(t,e,i,n){return this.online?this.requester(t,e,i,n).then(e=>(this.put(t),e)):this.retrieve(t,e)}retrieve(t,e){new s.defer;var i=new a.a(t);return e||(e=i.extension),("blob"==e?this.getBlob(t):this.getText(t)).then(i=>{var n,r=new s.defer;return i?(n=this.handleResponse(i,e),r.resolve(n)):r.reject({message:"File not found in storage: "+t,stack:(new Error).stack}),r.promise})}handleResponse(t,e){return"json"==e?JSON.parse(t):Object(s.isXml)(e)?Object(s.parse)(t,"text/xml"):"xhtml"==e?Object(s.parse)(t,"application/xhtml+xml"):"html"==e||"htm"==e?Object(s.parse)(t,"text/html"):t}getBlob(t,e){let i=window.encodeURIComponent(t);return this.storage.getItem(i).then((function(i){if(i)return e=e||C.lookup(t),new Blob([i],{type:e})}))}getText(t,e){let i=window.encodeURIComponent(t);return e=e||C.lookup(t),this.storage.getItem(i).then((function(t){var i,n=new s.defer,r=new FileReader;if(t)return i=new Blob([t],{type:e}),r.addEventListener("loadend",()=>{n.resolve(r.result)}),r.readAsText(i,e),n.promise}))}getBase64(t,e){let i=window.encodeURIComponent(t);return e=e||C.lookup(t),this.storage.getItem(i).then(t=>{var i,n=new s.defer,r=new FileReader;if(t)return i=new Blob([t],{type:e}),r.addEventListener("loadend",()=>{n.resolve(r.result)}),r.readAsDataURL(i,e),n.promise})}createUrl(t,e){var i,n,r=new s.defer,o=window.URL||window.webkitURL||window.mozURL,a=e&&e.base64;return t in this.urlCache?(r.resolve(this.urlCache[t]),r.promise):(a?(n=this.getBase64(t))&&n.then(function(e){this.urlCache[t]=e,r.resolve(e)}.bind(this)):(n=this.getBlob(t))&&n.then(function(e){i=o.createObjectURL(e),this.urlCache[t]=i,r.resolve(i)}.bind(this)),n||r.reject({message:"File not found in storage: "+t,stack:(new Error).stack}),r.promise)}revokeUrl(t){var e=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[t];i&&e.revokeObjectURL(i)}destroy(){var t=window.URL||window.webkitURL||window.mozURL;for(let e in this.urlCache)t.revokeObjectURL(e);this.urlCache={},this.removeListeners()}}r()(P.prototype);var D=P;var z=class{constructor(t){this.interactive="",this.fixedLayout="",this.openToSpread="",this.orientationLock="",t&&this.parse(t)}parse(t){if(!t)return this;const e=Object(s.qs)(t,"display_options");if(!e)return this;return Object(s.qsa)(e,"option").forEach(t=>{let e="";switch(t.childNodes.length&&(e=t.childNodes[0].nodeValue),t.attributes.name.value){case"interactive":this.interactive=e;break;case"fixed-layout":this.fixedLayout=e;break;case"open-to-spread":this.openToSpread=e;break;case"orientation-lock":this.orientationLock=e}}),this}destroy(){this.interactive=void 0,this.fixedLayout=void 0,this.openToSpread=void 0,this.orientationLock=void 0}};const B="binary",q="base64",M="epub",U="opf",F="json",W="directory";class H{constructor(t,e){void 0===e&&"string"!=typeof t&&t instanceof Blob==!1&&t instanceof ArrayBuffer==!1&&(e=t,t=void 0),this.settings=Object(s.extend)(this.settings||{},{requestMethod:void 0,requestCredentials:void 0,requestHeaders:void 0,encoding:void 0,replacements:void 0,canonical:void 0,openAs:void 0,store:void 0}),Object(s.extend)(this.settings,e),this.opening=new s.defer,this.opened=this.opening.promise,this.isOpen=!1,this.loading={manifest:new s.defer,spine:new s.defer,metadata:new s.defer,cover:new s.defer,navigation:new s.defer,pageList:new s.defer,resources:new s.defer,displayOptions:new s.defer},this.loaded={manifest:this.loading.manifest.promise,spine:this.loading.spine.promise,metadata:this.loading.metadata.promise,cover:this.loading.cover.promise,navigation:this.loading.navigation.promise,pageList:this.loading.pageList.promise,resources:this.loading.resources.promise,displayOptions:this.loading.displayOptions.promise},this.ready=Promise.all([this.loaded.manifest,this.loaded.spine,this.loaded.metadata,this.loaded.cover,this.loaded.navigation,this.loaded.resources,this.loaded.displayOptions]),this.isRendered=!1,this.request=this.settings.requestMethod||u,this.spine=new p,this.locations=new y(this.spine,this.load.bind(this)),this.navigation=void 0,this.pageList=void 0,this.url=void 0,this.path=void 0,this.archived=!1,this.archive=void 0,this.storage=void 0,this.resources=void 0,this.rendition=void 0,this.container=void 0,this.packaging=void 0,this.displayOptions=void 0,this.settings.store&&this.store(this.settings.store),t&&this.open(t,this.settings.openAs).catch(e=>{var i=new Error("Cannot load book at "+t);this.emit(v.c.BOOK.OPEN_FAILED,i)})}open(t,e){var i,n=e||this.determineType(t);return n===B?(this.archived=!0,this.url=new o.a("/",""),i=this.openEpub(t)):n===q?(this.archived=!0,this.url=new o.a("/",""),i=this.openEpub(t,n)):n===M?(this.archived=!0,this.url=new o.a("/",""),i=this.request(t,"binary",this.settings.requestCredentials,this.settings.requestHeaders).then(this.openEpub.bind(this))):n==U?(this.url=new o.a(t),i=this.openPackaging(this.url.Path.toString())):n==F?(this.url=new o.a(t),i=this.openManifest(this.url.Path.toString())):(this.url=new o.a(t),i=this.openContainer("META-INF/container.xml").then(this.openPackaging.bind(this))),i}openEpub(t,e){return this.unarchive(t,e||this.settings.encoding).then(()=>this.openContainer("META-INF/container.xml")).then(t=>this.openPackaging(t))}openContainer(t){return this.load(t).then(t=>(this.container=new x(t),this.resolve(this.container.packagePath)))}openPackaging(t){return this.path=new a.a(t),this.load(t).then(t=>(this.packaging=new E(t),this.unpack(this.packaging)))}openManifest(t){return this.path=new a.a(t),this.load(t).then(t=>(this.packaging=new E,this.packaging.load(t),this.unpack(this.packaging)))}load(t){var e=this.resolve(t);return this.archived?this.archive.request(e):this.request(e,null,this.settings.requestCredentials,this.settings.requestHeaders)}resolve(t,e){if(t){var i=t;return t.indexOf("://")>-1?t:(this.path&&(i=this.path.resolve(t)),0!=e&&this.url&&(i=this.url.resolve(i)),i)}}canonical(t){return t?this.settings.canonical?this.settings.canonical(t):this.resolve(t,!0):""}determineType(t){var e;return"base64"===this.settings.encoding?q:"string"!=typeof t?B:((e=new o.a(t).path().extension)&&(e=e.replace(/\?.*$/,"")),e?"epub"===e?M:"opf"===e?U:"json"===e?F:void 0:W)}unpack(t){this.package=t,""===this.packaging.metadata.layout?this.load(this.url.resolve("META-INF/com.apple.ibooks.display-options.xml")).then(t=>{this.displayOptions=new z(t),this.loading.displayOptions.resolve(this.displayOptions)}).catch(t=>{this.displayOptions=new z,this.loading.displayOptions.resolve(this.displayOptions)}):(this.displayOptions=new z,this.loading.displayOptions.resolve(this.displayOptions)),this.spine.unpack(this.packaging,this.resolve.bind(this),this.canonical.bind(this)),this.resources=new T(this.packaging.manifest,{archive:this.archive,resolver:this.resolve.bind(this),request:this.request.bind(this),replacements:this.settings.replacements||(this.archived?"blobUrl":"base64")}),this.loadNavigation(this.packaging).then(()=>{this.loading.navigation.resolve(this.navigation)}),this.packaging.coverPath&&(this.cover=this.resolve(this.packaging.coverPath)),this.loading.manifest.resolve(this.packaging.manifest),this.loading.metadata.resolve(this.packaging.metadata),this.loading.spine.resolve(this.spine),this.loading.cover.resolve(this.cover),this.loading.resources.resolve(this.resources),this.loading.pageList.resolve(this.pageList),this.isOpen=!0,this.archived||this.settings.replacements&&"none"!=this.settings.replacements?this.replacements().then(()=>{this.loaded.displayOptions.then(()=>{this.opening.resolve(this)})}).catch(t=>{console.error(t)}):this.loaded.displayOptions.then(()=>{this.opening.resolve(this)})}loadNavigation(t){let e=t.navPath||t.ncxPath,i=t.toc;return i?new Promise((e,n)=>{this.navigation=new S(i),t.pageList&&(this.pageList=new k(t.pageList)),e(this.navigation)}):e?this.load(e,"xml").then(t=>(this.navigation=new S(t),this.pageList=new k(t),this.navigation)):new Promise((t,e)=>{this.navigation=new S,this.pageList=new k,t(this.navigation)})}section(t){return this.spine.get(t)}renderTo(t,e){return this.rendition=new R.a(this,e),this.rendition.attachTo(t),this.rendition}setRequestCredentials(t){this.settings.requestCredentials=t}setRequestHeaders(t){this.settings.requestHeaders=t}unarchive(t,e){return this.archive=new j,this.archive.open(t,e)}store(t){let e=this.settings.replacements&&"none"!==this.settings.replacements,i=this.url,n=this.settings.requestMethod||u.bind(this);return this.storage=new D(t,n,this.resolve.bind(this)),this.request=this.storage.request.bind(this.storage),this.opened.then(()=>{this.archived&&(this.storage.requester=this.archive.request.bind(this.archive));let t=(t,e)=>{e.output=this.resources.substitute(t,e.url)};this.resources.settings.replacements=e||"blobUrl",this.resources.replacements().then(()=>this.resources.replaceCss()),this.storage.on("offline",()=>{this.url=new o.a("/",""),this.spine.hooks.serialize.register(t)}),this.storage.on("online",()=>{this.url=i,this.spine.hooks.serialize.deregister(t)})}),this.storage}coverUrl(){return this.loaded.cover.then(()=>this.cover?this.archived?this.archive.createUrl(this.cover):this.cover:null)}replacements(){return this.spine.hooks.serialize.register((t,e)=>{e.output=this.resources.substitute(t,e.url)}),this.resources.replacements().then(()=>this.resources.replaceCss())}getRange(t){var e=new h.a(t),i=this.spine.get(e.spinePos),n=this.load.bind(this);return i?i.load(n).then((function(t){return e.toRange(i.document)})):new Promise((t,e)=>{e("CFI could not be found")})}key(t){var e=t||this.packaging.metadata.identifier||this.url.filename;return`epubjs:${v.b}:${e}`}destroy(){this.opened=void 0,this.loading=void 0,this.loaded=void 0,this.ready=void 0,this.isOpen=!1,this.isRendered=!1,this.spine&&this.spine.destroy(),this.locations&&this.locations.destroy(),this.pageList&&this.pageList.destroy(),this.archive&&this.archive.destroy(),this.resources&&this.resources.destroy(),this.container&&this.container.destroy(),this.packaging&&this.packaging.destroy(),this.rendition&&this.rendition.destroy(),this.displayOptions&&this.displayOptions.destroy(),this.spine=void 0,this.locations=void 0,this.pageList=void 0,this.archive=void 0,this.resources=void 0,this.container=void 0,this.packaging=void 0,this.rendition=void 0,this.navigation=void 0,this.url=void 0,this.path=void 0,this.archived=!1}}r()(H.prototype);e.a=H},function(t,e,i){var n=i(16),r=i(60),s=i(25),o=i(32),a=i(41),h=i(10),l=i(62),c=Object.getOwnPropertyDescriptor;e.f=n?c:function(t,e){if(t=o(t),e=a(e,!0),l)try{return c(t,e)}catch(t){}if(h(t,e))return s(!r.f.call(t,e),t[e])}},function(t,e,i){"use strict";var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor,s=r&&!n.call({1:2},1);e.f=s?function(t){var e=r(this,t);return!!e&&e.enumerable}:n},function(t,e,i){var n=i(12),r=i(40),s="".split;t.exports=n((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==r(t)?s.call(t,""):Object(t)}:Object},function(t,e,i){var n=i(16),r=i(12),s=i(63);t.exports=!n&&!r((function(){return 7!=Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a}))},function(t,e,i){var n=i(7),r=i(17),s=n.document,o=r(s)&&r(s.createElement);t.exports=function(t){return o?s.createElement(t):{}}},function(t,e,i){var n=i(65),r=Function.toString;"function"!=typeof n.inspectSource&&(n.inspectSource=function(t){return r.call(t)}),t.exports=n.inspectSource},function(t,e,i){var n=i(7),r=i(42),s=n["__core-js_shared__"]||r("__core-js_shared__",{});t.exports=s},function(t,e,i){var n=i(34),r=i(65);(t.exports=function(t,e){return r[t]||(r[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:n?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})},function(t,e){var i=0,n=Math.random();t.exports=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++i+n).toString(36)}},function(t,e,i){var n=i(10),r=i(32),s=i(94).indexOf,o=i(44);t.exports=function(t,e){var i,a=r(t),h=0,l=[];for(i in a)!n(o,i)&&n(a,i)&&l.push(i);for(;e.length>h;)n(a,i=e[h++])&&(~s(l,i)||l.push(i));return l}},function(t,e){e.f=Object.getOwnPropertySymbols},function(t,e,i){var n=i(12);t.exports=!!Object.getOwnPropertySymbols&&!n((function(){return!String(Symbol())}))},function(t,e,i){"use strict";var n=i(32),r=i(103),s=i(27),o=i(26),a=i(74),h=o.set,l=o.getterFor("Array Iterator");t.exports=a(Array,"Array",(function(t,e){h(this,{type:"Array Iterator",target:n(t),index:0,kind:e})}),(function(){var t=l(this),e=t.target,i=t.kind,n=t.index++;return!e||n>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==i?{value:n,done:!1}:"values"==i?{value:e[n],done:!1}:{value:[n,e[n]],done:!1}}),"values"),s.Arguments=s.Array,r("keys"),r("values"),r("entries")},function(t,e,i){var n=i(16),r=i(18),s=i(13),o=i(73);t.exports=n?Object.defineProperties:function(t,e){s(t);for(var i,n=o(e),a=n.length,h=0;a>h;)r.f(t,i=n[h++],e[i]);return t}},function(t,e,i){var n=i(68),r=i(47);t.exports=Object.keys||function(t){return n(t,r)}},function(t,e,i){"use strict";var n=i(31),r=i(75),s=i(77),o=i(106),a=i(37),h=i(15),l=i(19),c=i(8),u=i(34),d=i(27),f=i(76),p=f.IteratorPrototype,g=f.BUGGY_SAFARI_ITERATORS,v=c("iterator"),m=function(){return this};t.exports=function(t,e,i,c,f,y,b){r(i,e,c);var w,x,E,S=function(t){if(t===f&&k)return k;if(!g&&t in C)return C[t];switch(t){case"keys":case"values":case"entries":return function(){return new i(this,t)}}return function(){return new i(this)}},_=e+" Iterator",O=!1,C=t.prototype,T=C[v]||C["@@iterator"]||f&&C[f],k=!g&&T||S(f),R="Array"==e&&C.entries||T;if(R&&(w=s(R.call(new t)),p!==Object.prototype&&w.next&&(u||s(w)===p||(o?o(w,p):"function"!=typeof w[v]&&h(w,v,m)),a(w,_,!0,!0),u&&(d[_]=m))),"values"==f&&T&&"values"!==T.name&&(O=!0,k=function(){return T.call(this)}),u&&!b||C[v]===k||h(C,v,k),d[e]=k,f)if(x={values:S("values"),keys:y?k:S("keys"),entries:S("entries")},b)for(E in x)(g||O||!(E in C))&&l(C,E,x[E]);else n({target:e,proto:!0,forced:g||O},x);return x}},function(t,e,i){"use strict";var n=i(76).IteratorPrototype,r=i(50),s=i(25),o=i(37),a=i(27),h=function(){return this};t.exports=function(t,e,i){var l=e+" Iterator";return t.prototype=r(n,{next:s(1,i)}),o(t,l,!1,!0),a[l]=h,t}},function(t,e,i){"use strict";var n,r,s,o=i(77),a=i(15),h=i(10),l=i(8),c=i(34),u=l("iterator"),d=!1;[].keys&&("next"in(s=[].keys())?(r=o(o(s)))!==Object.prototype&&(n=r):d=!0),null==n&&(n={}),c||h(n,u)||a(n,u,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:d}},function(t,e,i){var n=i(10),r=i(36),s=i(43),o=i(105),a=s("IE_PROTO"),h=Object.prototype;t.exports=o?Object.getPrototypeOf:function(t){return t=r(t),n(t,a)?t[a]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?h:null}},function(t,e,i){var n=i(12),r=i(8),s=i(34),o=r("iterator");t.exports=!n((function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,i="";return t.pathname="c%20d",e.forEach((function(t,n){e.delete("b"),i+=n+t})),s&&!t.toJSON||!e.sort||"http://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[o]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==i||"x"!==new URL("http://x",void 0).host}))},function(t,e){t.exports=function(t,e,i){if(!(t instanceof e))throw TypeError("Incorrect "+(i?i+" ":"")+"invocation");return t}},function(t,e,i){var n=i(126);t.exports=function(t,e,i){if(n(t),void 0===e)return t;switch(i){case 0:return function(){return t.call(e)};case 1:return function(i){return t.call(e,i)};case 2:return function(i,n){return t.call(e,i,n)};case 3:return function(i,n,r){return t.call(e,i,n,r)}}return function(){return t.apply(e,arguments)}}},function(t,e,i){var n=i(130),r=i(40),s=i(8)("toStringTag"),o="Arguments"==r(function(){return arguments}());t.exports=n?r:function(t){var e,i,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),s))?i:o?r(e):"Object"==(n=r(e))&&"function"==typeof e.callee?"Arguments":n}},function(t,e,i){var n=i(138),r="object"==typeof self&&self&&self.Object===Object&&self,s=n||r||Function("return this")();t.exports=s},function(t,e,i){var n=i(82).Symbol;t.exports=n},function(t,e,i){var n=i(55),r=i(53);t.exports=function(t,e,i){var s=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return r(i)&&(s="leading"in i?!!i.leading:s,o="trailing"in i?!!i.trailing:o),n(t,e,{leading:s,maxWait:e,trailing:o})}},function(t,i){t.exports=e},function(t,e,i){"use strict";i.r(e),function(t){var n=i(58),r=i(39),s=i(2),o=i(28),a=i(0),h=i(1);i(54),i(22),i(56);function l(t,e){return new n.a(t,e)}l.VERSION=h.b,void 0!==t&&(t.EPUBJS_VERSION=h.b),l.Book=n.a,l.Rendition=r.a,l.Contents=o.a,l.CFI=s.a,l.utils=a,e.default=l}.call(this,i(30))},function(t,e,i){"use strict";i(88);var n=i(19),r=i(12),s=i(8),o=i(48),a=i(15),h=s("species"),l=!r((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")})),c="$0"==="a".replace(/./,"$0"),u=s("replace"),d=!!/./[u]&&""===/./[u]("a","$0"),f=!r((function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var i="ab".split(t);return 2!==i.length||"a"!==i[0]||"b"!==i[1]}));t.exports=function(t,e,i,u){var p=s(t),g=!r((function(){var e={};return e[p]=function(){return 7},7!=""[t](e)})),v=g&&!r((function(){var e=!1,i=/a/;return"split"===t&&((i={}).constructor={},i.constructor[h]=function(){return i},i.flags="",i[p]=/./[p]),i.exec=function(){return e=!0,null},i[p](""),!e}));if(!g||!v||"replace"===t&&(!l||!c||d)||"split"===t&&!f){var m=/./[p],y=i(p,""[t],(function(t,e,i,n,r){return e.exec===o?g&&!r?{done:!0,value:m.call(e,i,n)}:{done:!0,value:t.call(i,e,n)}:{done:!1}}),{REPLACE_KEEPS_$0:c,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:d}),b=y[0],w=y[1];n(String.prototype,t,b),n(RegExp.prototype,p,2==e?function(t,e){return w.call(t,this,e)}:function(t){return w.call(t,this)})}u&&a(RegExp.prototype[p],"sham",!0)}},function(t,e,i){"use strict";var n=i(31),r=i(48);n({target:"RegExp",proto:!0,forced:/./.exec!==r},{exec:r})},function(t,e,i){var n=i(7),r=i(64),s=n.WeakMap;t.exports="function"==typeof s&&/native code/.test(r(s))},function(t,e,i){var n=i(10),r=i(91),s=i(59),o=i(18);t.exports=function(t,e){for(var i=r(e),a=o.f,h=s.f,l=0;l<i.length;l++){var c=i[l];n(t,c)||a(t,c,h(e,c))}}},function(t,e,i){var n=i(45),r=i(93),s=i(69),o=i(13);t.exports=n("Reflect","ownKeys")||function(t){var e=r.f(o(t)),i=s.f;return i?e.concat(i(t)):e}},function(t,e,i){var n=i(7);t.exports=n},function(t,e,i){var n=i(68),r=i(47).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return n(t,r)}},function(t,e,i){var n=i(32),r=i(46),s=i(95),o=function(t){return function(e,i,o){var a,h=n(e),l=r(h.length),c=s(o,l);if(t&&i!=i){for(;l>c;)if((a=h[c++])!=a)return!0}else for(;l>c;c++)if((t||c in h)&&h[c]===i)return t||c||0;return!t&&-1}};t.exports={includes:o(!0),indexOf:o(!1)}},function(t,e,i){var n=i(35),r=Math.max,s=Math.min;t.exports=function(t,e){var i=n(t);return i<0?r(i+e,0):s(i,e)}},function(t,e,i){var n=i(12),r=/#|\.prototype\./,s=function(t,e){var i=a[o(t)];return i==l||i!=h&&("function"==typeof e?n(e):!!e)},o=s.normalize=function(t){return String(t).replace(r,".").toLowerCase()},a=s.data={},h=s.NATIVE="N",l=s.POLYFILL="P";t.exports=s},function(t,e,i){"use strict";var n=i(13);t.exports=function(){var t=n(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},function(t,e,i){"use strict";var n=i(12);function r(t,e){return RegExp(t,e)}e.UNSUPPORTED_Y=n((function(){var t=r("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),e.BROKEN_CARET=n((function(){var t=r("^r","gy");return t.lastIndex=2,null!=t.exec("str")}))},function(t,e,i){var n=i(70);t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},function(t,e,i){"use strict";var n=i(49).charAt;t.exports=function(t,e,i){return e+(i?n(t,e).length:1)}},function(t,e,i){var n=i(40),r=i(48);t.exports=function(t,e){var i=t.exec;if("function"==typeof i){var s=i.call(t,e);if("object"!=typeof s)throw TypeError("RegExp exec method returned something other than an Object or null");return s}if("RegExp"!==n(t))throw TypeError("RegExp#exec called on incompatible receiver");return r.call(t,e)}},function(t,e){t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},function(t,e,i){var n=i(8),r=i(50),s=i(18),o=n("unscopables"),a=Array.prototype;null==a[o]&&s.f(a,o,{configurable:!0,value:r(null)}),t.exports=function(t){a[o][t]=!0}},function(t,e,i){var n=i(45);t.exports=n("document","documentElement")},function(t,e,i){var n=i(12);t.exports=!n((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},function(t,e,i){var n=i(13),r=i(107);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,i={};try{(t=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(i,[]),e=i instanceof Array}catch(t){}return function(i,s){return n(i),r(s),e?t.call(i,s):i.__proto__=s,i}}():void 0)},function(t,e,i){var n=i(17);t.exports=function(t){if(!n(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype");return t}},function(t,e,i){"use strict";var n=i(109),r=i(117),s=i(118),o=i(119);(t.exports=function(t,e){var i,s,a,h,l;return arguments.length<2||"string"!=typeof t?(h=e,e=t,t=null):h=arguments[2],null==t?(i=a=!0,s=!1):(i=o.call(t,"c"),s=o.call(t,"e"),a=o.call(t,"w")),l={value:e,configurable:i,enumerable:s,writable:a},h?n(r(h),l):l}).gs=function(t,e,i){var a,h,l,c;return"string"!=typeof t?(l=i,i=e,e=t,t=null):l=arguments[3],null==e?e=void 0:s(e)?null==i?i=void 0:s(i)||(l=i,i=void 0):(l=e,e=i=void 0),null==t?(a=!0,h=!1):(a=o.call(t,"c"),h=o.call(t,"e")),c={get:e,set:i,configurable:a,enumerable:h},l?n(r(l),c):c}},function(t,e,i){"use strict";t.exports=i(110)()?Object.assign:i(111)},function(t,e,i){"use strict";t.exports=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")}},function(t,e,i){"use strict";var n=i(112),r=i(116),s=Math.max;t.exports=function(t,e){var i,o,a,h=s(arguments.length,2);for(t=Object(r(t)),a=function(n){try{t[n]=e[n]}catch(t){i||(i=t)}},o=1;o<h;++o)n(e=arguments[o]).forEach(a);if(void 0!==i)throw i;return t}},function(t,e,i){"use strict";t.exports=i(113)()?Object.keys:i(114)},function(t,e,i){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},function(t,e,i){"use strict";var n=i(51),r=Object.keys;t.exports=function(t){return r(n(t)?Object(t):t)}},function(t,e,i){"use strict";t.exports=function(){}},function(t,e,i){"use strict";var n=i(51);t.exports=function(t){if(!n(t))throw new TypeError("Cannot use null or undefined");return t}},function(t,e,i){"use strict";var n=i(51),r=Array.prototype.forEach,s=Object.create,o=function(t,e){var i;for(i in t)e[i]=t[i]};t.exports=function(t){var e=s(null);return r.call(arguments,(function(t){n(t)&&o(Object(t),e)})),e}},function(t,e,i){"use strict";t.exports=function(t){return"function"==typeof t}},function(t,e,i){"use strict";t.exports=i(120)()?String.prototype.contains:i(121)},function(t,e,i){"use strict";var n="razdwatrzy";t.exports=function(){return"function"==typeof n.contains&&(!0===n.contains("dwa")&&!1===n.contains("foo"))}},function(t,e,i){"use strict";var n=String.prototype.indexOf;t.exports=function(t){return n.call(this,t,arguments[1])>-1}},function(t,e,i){"use strict";t.exports=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t}},function(t,e,i){"use strict";var n=i(49).charAt,r=i(26),s=i(74),o=r.set,a=r.getterFor("String Iterator");s(String,"String",(function(t){o(this,{type:"String Iterator",string:String(t),index:0})}),(function(){var t,e=a(this),i=e.string,r=e.index;return r>=i.length?{value:void 0,done:!0}:(t=n(i,r),e.index+=t.length,{value:t,done:!1})}))},function(t,e,i){"use strict";var n=i(16),r=i(12),s=i(73),o=i(69),a=i(60),h=i(36),l=i(61),c=Object.assign,u=Object.defineProperty;t.exports=!c||r((function(){if(n&&1!==c({b:1},c(u({},"a",{enumerable:!0,get:function(){u(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},i=Symbol();return t[i]=7,"abcdefghijklmnopqrst".split("").forEach((function(t){e[t]=t})),7!=c({},t)[i]||"abcdefghijklmnopqrst"!=s(c({},e)).join("")}))?function(t,e){for(var i=h(t),r=arguments.length,c=1,u=o.f,d=a.f;r>c;)for(var f,p=l(arguments[c++]),g=u?s(p).concat(u(p)):s(p),v=g.length,m=0;v>m;)f=g[m++],n&&!d.call(p,f)||(i[f]=p[f]);return i}:c},function(t,e,i){"use strict";var n=i(80),r=i(36),s=i(127),o=i(128),a=i(46),h=i(129),l=i(52);t.exports=function(t){var e,i,c,u,d,f,p=r(t),g="function"==typeof this?this:Array,v=arguments.length,m=v>1?arguments[1]:void 0,y=void 0!==m,b=l(p),w=0;if(y&&(m=n(m,v>2?arguments[2]:void 0,2)),null==b||g==Array&&o(b))for(i=new g(e=a(p.length));e>w;w++)f=y?m(p[w],w):p[w],h(i,w,f);else for(d=(u=b.call(p)).next,i=new g;!(c=d.call(u)).done;w++)f=y?s(u,m,[c.value,w],!0):c.value,h(i,w,f);return i.length=w,i}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}},function(t,e,i){var n=i(13);t.exports=function(t,e,i,r){try{return r?e(n(i)[0],i[1]):e(i)}catch(e){var s=t.return;throw void 0!==s&&n(s.call(t)),e}}},function(t,e,i){var n=i(8),r=i(27),s=n("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||o[s]===t)}},function(t,e,i){"use strict";var n=i(41),r=i(18),s=i(25);t.exports=function(t,e,i){var o=n(e);o in t?r.f(t,o,s(0,i)):t[o]=i}},function(t,e,i){var n={};n[i(8)("toStringTag")]="z",t.exports="[object z]"===String(n)},function(t,e,i){"use strict";var n=/[^\0-\u007E]/,r=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",o=Math.floor,a=String.fromCharCode,h=function(t){return t+22+75*(t<26)},l=function(t,e,i){var n=0;for(t=i?o(t/700):t>>1,t+=o(t/e);t>455;n+=36)t=o(t/35);return o(n+36*t/(t+38))},c=function(t){var e,i,n=[],r=(t=function(t){for(var e=[],i=0,n=t.length;i<n;){var r=t.charCodeAt(i++);if(r>=55296&&r<=56319&&i<n){var s=t.charCodeAt(i++);56320==(64512&s)?e.push(((1023&r)<<10)+(1023&s)+65536):(e.push(r),i--)}else e.push(r)}return e}(t)).length,c=128,u=0,d=72;for(e=0;e<t.length;e++)(i=t[e])<128&&n.push(a(i));var f=n.length,p=f;for(f&&n.push("-");p<r;){var g=2147483647;for(e=0;e<t.length;e++)(i=t[e])>=c&&i<g&&(g=i);var v=p+1;if(g-c>o((2147483647-u)/v))throw RangeError(s);for(u+=(g-c)*v,c=g,e=0;e<t.length;e++){if((i=t[e])<c&&++u>2147483647)throw RangeError(s);if(i==c){for(var m=u,y=36;;y+=36){var b=y<=d?1:y>=d+26?26:y-d;if(m<b)break;var w=m-b,x=36-b;n.push(a(h(b+w%x))),m=o(w/x)}n.push(a(h(m))),d=l(u,v,p==f),u=0,++p}}++u,++c}return n.join("")};t.exports=function(t){var e,i,s=[],o=t.toLowerCase().replace(r,".").split(".");for(e=0;e<o.length;e++)i=o[e],s.push(n.test(i)?"xn--"+c(i):i);return s.join(".")}},function(t,e,i){"use strict";i(71);var n=i(31),r=i(45),s=i(78),o=i(19),a=i(133),h=i(37),l=i(75),c=i(26),u=i(79),d=i(10),f=i(80),p=i(81),g=i(13),v=i(17),m=i(50),y=i(25),b=i(134),w=i(52),x=i(8),E=r("fetch"),S=r("Headers"),_=x("iterator"),O=c.set,C=c.getterFor("URLSearchParams"),T=c.getterFor("URLSearchParamsIterator"),k=/\+/g,R=Array(4),L=function(t){return R[t-1]||(R[t-1]=RegExp("((?:%[\\da-f]{2}){"+t+"})","gi"))},I=function(t){try{return decodeURIComponent(t)}catch(e){return t}},j=function(t){var e=t.replace(k," "),i=4;try{return decodeURIComponent(e)}catch(t){for(;i;)e=e.replace(L(i--),I);return e}},N=/[!'()~]|%20/g,A={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},P=function(t){return A[t]},D=function(t){return encodeURIComponent(t).replace(N,P)},z=function(t,e){if(e)for(var i,n,r=e.split("&"),s=0;s<r.length;)(i=r[s++]).length&&(n=i.split("="),t.push({key:j(n.shift()),value:j(n.join("="))}))},B=function(t){this.entries.length=0,z(this.entries,t)},q=function(t,e){if(t<e)throw TypeError("Not enough arguments")},M=l((function(t,e){O(this,{type:"URLSearchParamsIterator",iterator:b(C(t).entries),kind:e})}),"Iterator",(function(){var t=T(this),e=t.kind,i=t.iterator.next(),n=i.value;return i.done||(i.value="keys"===e?n.key:"values"===e?n.value:[n.key,n.value]),i})),U=function(){u(this,U,"URLSearchParams");var t,e,i,n,r,s,o,a,h,l=arguments.length>0?arguments[0]:void 0,c=this,f=[];if(O(c,{type:"URLSearchParams",entries:f,updateURL:function(){},updateSearchParams:B}),void 0!==l)if(v(l))if("function"==typeof(t=w(l)))for(i=(e=t.call(l)).next;!(n=i.call(e)).done;){if((o=(s=(r=b(g(n.value))).next).call(r)).done||(a=s.call(r)).done||!s.call(r).done)throw TypeError("Expected sequence with length 2");f.push({key:o.value+"",value:a.value+""})}else for(h in l)d(l,h)&&f.push({key:h,value:l[h]+""});else z(f,"string"==typeof l?"?"===l.charAt(0)?l.slice(1):l:l+"")},F=U.prototype;a(F,{append:function(t,e){q(arguments.length,2);var i=C(this);i.entries.push({key:t+"",value:e+""}),i.updateURL()},delete:function(t){q(arguments.length,1);for(var e=C(this),i=e.entries,n=t+"",r=0;r<i.length;)i[r].key===n?i.splice(r,1):r++;e.updateURL()},get:function(t){q(arguments.length,1);for(var e=C(this).entries,i=t+"",n=0;n<e.length;n++)if(e[n].key===i)return e[n].value;return null},getAll:function(t){q(arguments.length,1);for(var e=C(this).entries,i=t+"",n=[],r=0;r<e.length;r++)e[r].key===i&&n.push(e[r].value);return n},has:function(t){q(arguments.length,1);for(var e=C(this).entries,i=t+"",n=0;n<e.length;)if(e[n++].key===i)return!0;return!1},set:function(t,e){q(arguments.length,1);for(var i,n=C(this),r=n.entries,s=!1,o=t+"",a=e+"",h=0;h<r.length;h++)(i=r[h]).key===o&&(s?r.splice(h--,1):(s=!0,i.value=a));s||r.push({key:o,value:a}),n.updateURL()},sort:function(){var t,e,i,n=C(this),r=n.entries,s=r.slice();for(r.length=0,i=0;i<s.length;i++){for(t=s[i],e=0;e<i;e++)if(r[e].key>t.key){r.splice(e,0,t);break}e===i&&r.push(t)}n.updateURL()},forEach:function(t){for(var e,i=C(this).entries,n=f(t,arguments.length>1?arguments[1]:void 0,3),r=0;r<i.length;)n((e=i[r++]).value,e.key,this)},keys:function(){return new M(this,"keys")},values:function(){return new M(this,"values")},entries:function(){return new M(this,"entries")}},{enumerable:!0}),o(F,_,F.entries),o(F,"toString",(function(){for(var t,e=C(this).entries,i=[],n=0;n<e.length;)t=e[n++],i.push(D(t.key)+"="+D(t.value));return i.join("&")}),{enumerable:!0}),h(U,"URLSearchParams"),n({global:!0,forced:!s},{URLSearchParams:U}),s||"function"!=typeof E||"function"!=typeof S||n({global:!0,enumerable:!0,forced:!0},{fetch:function(t){var e,i,n,r=[t];return arguments.length>1&&(v(e=arguments[1])&&(i=e.body,"URLSearchParams"===p(i)&&((n=e.headers?new S(e.headers):new S).has("content-type")||n.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),e=m(e,{body:y(0,String(i)),headers:y(0,n)}))),r.push(e)),E.apply(this,r)}}),t.exports={URLSearchParams:U,getState:C}},function(t,e,i){var n=i(19);t.exports=function(t,e,i){for(var r in e)n(t,r,e[r],i);return t}},function(t,e,i){var n=i(13),r=i(52);t.exports=function(t){var e=r(t);if("function"!=typeof e)throw TypeError(String(t)+" is not iterable");return n(e.call(t))}},function(t,e,i){"use strict";function n(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}Object.defineProperty(e,"__esModule",{value:!0}),e.createElement=n,e.default={createElement:n}},function(t,e,i){"use strict";function n(t,e){function i(i){for(var n=e.length-1;n>=0;n--){var o=e[n],a=i.clientX,h=i.clientY;if(i.touches&&i.touches.length&&(a=i.touches[0].clientX,h=i.touches[0].clientY),s(o,t,a,h)){o.dispatchEvent(r(i));break}}}if("iframe"===t.nodeName||"IFRAME"===t.nodeName)try{this.target=t.contentDocument}catch(e){this.target=t}else this.target=t;for(var n=["mouseup","mousedown","click","touchstart"],o=0;o<n.length;o++){var a=n[o];this.target.addEventListener(a,(function(t){return i(t)}),!1)}}function r(t){var e=Object.assign({},t,{bubbles:!1});try{return new MouseEvent(t.type,e)}catch(n){var i=document.createEvent("MouseEvents");return i.initMouseEvent(t.type,!1,e.cancelable,e.view,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget),i}}function s(t,e,i,n){var r=e.getBoundingClientRect();function s(t,e,i){var n=t.top-r.top,s=t.left-r.left,o=n+t.height,a=s+t.width;return n<=i&&s<=e&&o>i&&a>e}if(!s(t.getBoundingClientRect(),i,n))return!1;for(var o=t.getClientRects(),a=0,h=o.length;a<h;a++)if(s(o[a],i,n))return!0;return!1}Object.defineProperty(e,"__esModule",{value:!0}),e.proxyMouse=n,e.clone=r,e.default={proxyMouse:n}},function(t,e,i){var n=i(82);t.exports=function(){return n.Date.now()}},function(t,e,i){(function(e){var i="object"==typeof e&&e&&e.Object===Object&&e;t.exports=i}).call(this,i(30))},function(t,e,i){var n=i(53),r=i(140),s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,h=/^0o[0-7]+$/i,l=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(r(t))return NaN;if(n(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=n(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(s,"");var i=a.test(t);return i||h.test(t)?l(t.slice(2),i?2:8):o.test(t)?NaN:+t}},function(t,e,i){var n=i(141),r=i(144);t.exports=function(t){return"symbol"==typeof t||r(t)&&"[object Symbol]"==n(t)}},function(t,e,i){var n=i(83),r=i(142),s=i(143),o=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":o&&o in Object(t)?r(t):s(t)}},function(t,e,i){var n=i(83),r=Object.prototype,s=r.hasOwnProperty,o=r.toString,a=n?n.toStringTag:void 0;t.exports=function(t){var e=s.call(t,a),i=t[a];try{t[a]=void 0;var n=!0}catch(t){}var r=o.call(t);return n&&(e?t[a]=i:delete t[a]),r}},function(t,e){var i=Object.prototype.toString;t.exports=function(t){return i.call(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}}]).default}));
1 \ No newline at end of file \ No newline at end of file
public/lib/jszip.min.js+0 -13
@@ -1,13 +0,0 @@
1/*!
2
3JSZip v3.10.1 - A JavaScript class for generating and reading zip files
4<http://stuartk.com/jszip>
5
6(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
7Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
8
9JSZip uses the library pako released under the MIT license :
10https://github.com/nodeca/pako/blob/main/LICENSE
11*/
12
13!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=e()}}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(l)return l(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h)}return o[r].exports}for(var l="function"==typeof require&&require,e=0;e<h.length;e++)u(h[e]);return u}({1:[function(e,t,r){"use strict";var d=e("./utils"),c=e("./support"),p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,n,i,s,a,o,h=[],u=0,l=e.length,f=l,c="string"!==d.getTypeOf(e);u<e.length;)f=l-u,n=c?(t=e[u++],r=u<l?e[u++]:0,u<l?e[u++]:0):(t=e.charCodeAt(u++),r=u<l?e.charCodeAt(u++):0,u<l?e.charCodeAt(u++):0),i=t>>2,s=(3&t)<<4|r>>4,a=1<f?(15&r)<<2|n>>6:64,o=2<f?63&n:64,h.push(p.charAt(i)+p.charAt(s)+p.charAt(a)+p.charAt(o));return h.join("")},r.decode=function(e){var t,r,n,i,s,a,o=0,h=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var l,f=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===p.charAt(64)&&f--,e.charAt(e.length-2)===p.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(l=c.uint8array?new Uint8Array(0|f):new Array(0|f);o<e.length;)t=p.indexOf(e.charAt(o++))<<2|(i=p.indexOf(e.charAt(o++)))>>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function h(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new h("Deflate",e)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function A(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),c=I.transformTo("string",O.utf8encode(h.name)),d=h.comment,p=I.transformTo("string",s(d)),m=I.transformTo("string",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(n,4)+f+b+p}}var I=e("../utils"),i=e("../stream/GenericWorker"),O=e("../utf8"),B=e("../crc32"),R=e("../signature");function s(e,t,r,n){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,n=function(e,t,r,n,i){var s=I.transformTo("string",i(n));return R.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(e,2)+A(e,2)+A(t,4)+A(r,4)+A(s.length,2)+s}(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})},s.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},s.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},s.prototype.error=function(e){var t=this._sources;if(!i.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(e){}return!0},s.prototype.lock=function(){i.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=s},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,r){"use strict";var u=e("../compressions"),n=e("./ZipFileWorker");r.generateWorker=function(e,a,t){var o=new n(a.streamFiles,t,a.platform,a.encodeFileName),h=0;try{e.forEach(function(e,t){h++;var r=function(e,t){var r=e||t,n=u[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(t.options.compression,a.compression),n=t.options.compressionOptions||a.compressionOptions||{},i=t.dir,s=t.date;t._compressWorker(r,n).withStreamInfo("file",{name:e,dir:i,date:s,comment:t.comment||"",unixPermissions:t.unixPermissions,dosPermissions:t.dosPermissions}).pipe(o)}),o.entriesCount=h}catch(e){o.error(e)}return o}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){"use strict";function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new n;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.1",n.loadAsync=function(e,t){return(new n).loadAsync(e,t)},n.external=e("./external"),t.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){"use strict";var u=e("./utils"),i=e("./external"),n=e("./utf8"),s=e("./zipEntries"),a=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function f(n){return new i.Promise(function(e,t){var r=n.decompressed.getContentWorker().pipe(new a);r.on("error",function(e){t(e)}).on("end",function(){r.streamInfo.crc32!==n.decompressed.crc32?t(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}t.exports=function(e,o){var h=this;return o=u.extend(o||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),l.isNode&&l.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):u.prepareContent("the loaded zip file",e,!0,o.optimizedBinaryString,o.base64).then(function(e){var t=new s(o);return t.load(e),t}).then(function(e){var t=[i.Promise.resolve(e)],r=e.files;if(o.checkCRC32)for(var n=0;n<r.length;n++)t.push(f(r[n]));return i.Promise.all(t)}).then(function(e){for(var t=e.shift(),r=t.files,n=0;n<r.length;n++){var i=r[n],s=i.fileNameStr,a=u.resolve(i.fileNameStr);h.file(a,i.decompressed,{binary:!0,optimizedBinaryString:!0,date:i.date,dir:i.dir,comment:i.fileCommentStr.length?i.fileCommentStr:null,unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions,createFolders:o.createFolders}),i.dir||(h.file(a).unsafeOriginalName=s)}return t.zipComment.length&&(h.comment=t.zipComment),h})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../stream/GenericWorker");function s(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}n.inherits(s,i),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){"use strict";var i=e("readable-stream").Readable;function n(e,t,r){i.call(this,t),this._helper=e;var n=this;e.on("data",function(e,t){n.push(e)||n._helper.pause(),r&&r(t)}).on("error",function(e){n.emit("error",e)}).on("end",function(){n.push(null)})}e("../utils").inherits(n,i),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){"use strict";t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,r){"use strict";function s(e,t,r){var n,i=u.getTypeOf(t),s=u.extend(r||{},f);s.date=s.date||new Date,null!==s.compression&&(s.compression=s.compression.toUpperCase()),"string"==typeof s.unixPermissions&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&16384&s.unixPermissions&&(s.dir=!0),s.dosPermissions&&16&s.dosPermissions&&(s.dir=!0),s.dir&&(e=g(e)),s.createFolders&&(n=_(e))&&b.call(this,n,!0);var a="string"===i&&!1===s.binary&&!1===s.base64;r&&void 0!==r.binary||(s.binary=!a),(t instanceof c&&0===t.uncompressedSize||s.dir||!t||0===t.length)&&(s.base64=!1,s.binary=!0,t="",s.compression="STORE",i="string");var o=null;o=t instanceof c||t instanceof l?t:p.isNode&&p.isStream(t)?new m(e,t):u.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var h=new d(e,o,s);this.files[e]=h}var i=e("./utf8"),u=e("./utils"),l=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),f=e("./defaults"),c=e("./compressedObject"),d=e("./zipObject"),o=e("./generate"),p=e("./nodejsUtils"),m=e("./nodejs/NodejsStreamInputAdapter"),_=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},b=function(e,t){return t=void 0!==t?t:f.createFolders,e=g(e),this.files[e]||s.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function h(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var n={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n)},filter:function(r){var n=[];return this.forEach(function(e,t){r(e,t)&&n.push(t)}),n},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,s.call(this,e,t,r),this;if(h(e)){var n=e;return this.filter(function(e,t){return!t.dir&&n.test(e)})}var i=this.files[this.root+e];return i&&!i.dir?i:null},folder:function(r){if(!r)return this;if(h(r))return this.filter(function(e,t){return t.dir&&r.test(e)});var e=this.root+r,t=b.call(this,e),n=this.clone();return n.root=t.name,n},remove:function(r){r=this.root+r;var e=this.files[r];if(e||("/"!==r.slice(-1)&&(r+="/"),e=this.files[r]),e&&!e.dir)delete this.files[r];else for(var t=this.filter(function(e,t){return t.name.slice(0,r.length)===r}),n=0;n<t.length;n++)delete this.files[t[n].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=u.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");u.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=o.generateWorker(this,r,n)}catch(e){(t=new l("error")).error(e)}return new a(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=n},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,r){"use strict";t.exports=e("stream")},{stream:void 0}],17:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===r&&this.data[s+2]===n&&this.data[s+3]===i)return s-this.zero;return-1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&r===s[1]&&n===s[2]&&i===s[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){"use strict";var n=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new h(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var h=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),u=e("../base64"),n=e("../support"),a=e("../external"),o=null;if(n.nodestream)try{o=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on("data",function(e,t){n.push(e),o&&o(t)}).on("error",function(e){n=[],r(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return h.newBlob(h.transformTo("arraybuffer",t),r);case"base64":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r<t.length;r++)s+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(s),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(i,n),a);t(e)}catch(e){r(e)}n=[]}).resume()})}function f(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=t,this._mimeType=r,h.checkSupport(n),this._worker=e.pipe(new i(n)),e.lock()}catch(e){this._worker=new s("error"),this._worker.error(e)}}f.prototype={accumulate:function(e){return l(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,function(e){t.call(r,e.data,e.meta)}):this._worker.on(e,function(){h.delay(t,arguments,r)}),this},resume:function(){return h.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(h.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new o(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,r){"use strict";if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer="undefined"!=typeof Buffer,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var n=new ArrayBuffer(0);try{r.blob=0===new Blob([n],{type:"application/zip"}).size}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(n),r.blob=0===i.getBlob("application/zip").size}catch(e){r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch(e){r.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,s){"use strict";for(var o=e("./utils"),h=e("./support"),r=e("./nodejsUtils"),n=e("./stream/GenericWorker"),u=new Array(256),i=0;i<256;i++)u[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;u[254]=u[254]=1;function a(){n.call(this,"utf-8 decode"),this.leftOver=null}function l(){n.call(this,"utf-8 encode")}s.utf8encode=function(e){return h.nodebuffer?r.newBufferFrom(e,"utf-8"):function(e){var t,r,n,i,s,a=e.length,o=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=h.uint8array?new Uint8Array(o):new Array(o),i=s=0;s<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t<s;)if((n=e[t++])<128)a[r++]=n;else if(4<(i=u[n]))a[r++]=65533,t+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&t<s;)n=n<<6|63&e[t++],i--;1<i?a[r++]=65533:n<65536?a[r++]=n:(n-=65536,a[r++]=55296|n>>10&1023,a[r++]=56320|1023&n)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?"uint8array":"array",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){"use strict";var o=e("./support"),h=e("./base64"),r=e("./nodejsUtils"),u=e("./external");function n(e){return e}function l(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e("setimmediate"),a.newBlob=function(t,r){a.checkSupport("blob");try{return new Blob([t],{type:r})}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(r)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var i={stringifyByChunk:function(e,t,r){var n=[],i=0,s=e.length;if(s<=r)return String.fromCharCode.apply(null,e);for(;i<s;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,s)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,s)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return o.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return o.nodebuffer&&1===String.fromCharCode.apply(null,r.allocBuffer(1)).length}catch(e){return!1}}()}};function s(e){var t=65536,r=a.getTypeOf(e),n=!0;if("uint8array"===r?n=i.applyCanBeUsed.uint8array:"nodebuffer"===r&&(n=i.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return i.stringifyByChunk(e,r,t)}catch(e){t=Math.floor(t/2)}return i.stringifyByChar(e)}function f(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}a.applyFromCharCode=s;var c={};c.string={string:n,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return c.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,r.allocBuffer(e.length))}},c.array={string:s,array:n,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(e)}},c.arraybuffer={string:function(e){return s(new Uint8Array(e))},array:function(e){return f(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:n,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(new Uint8Array(e))}},c.uint8array={string:s,array:function(e){return f(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:n,nodebuffer:function(e){return r.newBufferFrom(e)}},c.nodebuffer={string:s,array:function(e){return f(e,new Array(e.length))},arraybuffer:function(e){return c.nodebuffer.uint8array(e).buffer},uint8array:function(e){return f(e,new Uint8Array(e.length))},nodebuffer:n},a.transformTo=function(e,t){if(t=t||"",!e)return t;a.checkSupport(e);var r=a.getTypeOf(t);return c[r][e](t)},a.resolve=function(e){for(var t=e.split("/"),r=[],n=0;n<t.length;n++){var i=t[n];"."===i||""===i&&0!==n&&n!==t.length-1||(".."===i?r.pop():r.push(i))}return r.join("/")},a.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":o.nodebuffer&&r.isBuffer(e)?"nodebuffer":o.uint8array&&e instanceof Uint8Array?"uint8array":o.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(e){if(!o[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},a.delay=function(e,t,r){setImmediate(function(){e.apply(r||null,t||[])})},a.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r},a.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},a.prepareContent=function(r,e,n,i,s){return u.Promise.resolve(e).then(function(n){return o.blob&&(n instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(n)))&&"undefined"!=typeof FileReader?new u.Promise(function(t,r){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.onerror=function(e){r(e.target.error)},e.readAsArrayBuffer(n)}):n}).then(function(e){var t=a.getTypeOf(e);return t?("arraybuffer"===t?e=a.transformTo("uint8array",e):"string"===t&&(s?e=h.decode(e):n&&!0!==i&&(e=function(e){return l(e,o.uint8array?new Uint8Array(e.length):new Array(e.length))}(e))),e):u.Promise.reject(new Error("Can't read the data of '"+r+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),i=e("./utils"),s=e("./signature"),a=e("./zipEntry"),o=e("./support");function h(e){this.files=[],this.loadOptions=e}h.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=o.uint8array?"uint8array":"array",r=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw!this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(0<n)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=n(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),s=e("./utils"),i=e("./compressedObject"),a=e("./crc32"),o=e("./utf8"),h=e("./compressions"),u=e("./support");function l(e,t){this.options=e,this.loadOptions=t}l.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in h)if(Object.prototype.hasOwnProperty.call(h,t)&&h[t].magic===e)return h[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i)},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=o.utf8decode(this.fileName),this.fileCommentStr=o.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var r=s.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=s.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:a(this.fileName)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:a(this.fileComment)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null}},t.exports=l},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,r){"use strict";function n(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var s=e("./stream/StreamHelper"),i=e("./stream/DataWorker"),a=e("./utf8"),o=e("./compressedObject"),h=e("./stream/GenericWorker");n.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(t=t.pipe(new a.Utf8EncodeWorker)),!i&&n&&(t=t.pipe(new a.Utf8DecodeWorker))}catch(e){(t=new h("error")).error(e)}return new s(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof o&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new a.Utf8EncodeWorker)),o.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof o?this._data.getContentWorker():this._data instanceof h?this._data:new i(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],l=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)n.prototype[u[f]]=l;t.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,l,t){(function(t){"use strict";var r,n,e=t.MutationObserver||t.WebKitMutationObserver;if(e){var i=0,s=new e(u),a=t.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=i=++i%2}}else if(t.setImmediate||void 0===t.MessageChannel)r="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var o=new t.MessageChannel;o.port1.onmessage=u,r=function(){o.port2.postMessage(0)}}var h=[];function u(){var e,t;n=!0;for(var r=h.length;r;){for(t=h,h=[],e=-1;++e<r;)t[e]();r=h.length}n=!1}l.exports=function(e){1!==h.push(e)||n||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,r){"use strict";var i=e("immediate");function u(){}var l={},s=["REJECTED"],a=["FULFILLED"],n=["PENDING"];function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=n,this.queue=[],this.outcome=void 0,e!==u&&d(this,e)}function h(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function f(t,r,n){i(function(){var e;try{e=r(n)}catch(e){return l.reject(t,e)}e===t?l.reject(t,new TypeError("Cannot resolve promise with itself")):l.resolve(t,e)})}function c(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(t,e){var r=!1;function n(e){r||(r=!0,l.reject(t,e))}function i(e){r||(r=!0,l.resolve(t,e))}var s=p(function(){e(i,n)});"error"===s.status&&n(s.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}(t.exports=o).prototype.finally=function(t){if("function"!=typeof t)return this;var r=this.constructor;return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})},o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(u);this.state!==n?f(r,this.state===a?e:t,this.outcome):this.queue.push(new h(r,e,t));return r},h.prototype.callFulfilled=function(e){l.resolve(this.promise,e)},h.prototype.otherCallFulfilled=function(e){f(this.promise,this.onFulfilled,e)},h.prototype.callRejected=function(e){l.reject(this.promise,e)},h.prototype.otherCallRejected=function(e){f(this.promise,this.onRejected,e)},l.resolve=function(e,t){var r=p(c,t);if("error"===r.status)return l.reject(e,r.value);var n=r.value;if(n)d(e,n);else{e.state=a,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t)}return e},l.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},o.resolve=function(e){if(e instanceof this)return e;return l.resolve(new this(u),e)},o.reject=function(e){var t=new this(u);return l.reject(t,e)},o.all=function(e){var r=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);var s=new Array(n),a=0,t=-1,o=new this(u);for(;++t<n;)h(e[t],t);return o;function h(e,t){r.resolve(e).then(function(e){s[t]=e,++a!==n||i||(i=!0,l.resolve(o,s))},function(e){i||(i=!0,l.reject(o,e))})}},o.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);var i=-1,s=new this(u);for(;++i<r;)a=e[i],t.resolve(a).then(function(e){n||(n=!0,l.resolve(s,e))},function(e){n||(n=!0,l.reject(s,e))});var a;return s}},{immediate:36}],38:[function(e,t,r){"use strict";var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){"use strict";var a=e("./zlib/deflate"),o=e("./utils/common"),h=e("./utils/strings"),i=e("./zlib/messages"),s=e("./zlib/zstream"),u=Object.prototype.toString,l=0,f=-1,c=0,d=8;function p(e){if(!(this instanceof p))return new p(e);this.options=o.assign({level:f,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:c,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=a.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==l)throw new Error(i[r]);if(t.header&&a.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?h.string2buf(t.dictionary):"[object ArrayBuffer]"===u.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=a.deflateSetDictionary(this.strm,n))!==l)throw new Error(i[r]);this._dict_set=!0}}function n(e,t){var r=new p(t);if(r.push(e,!0),r.err)throw r.msg||i[r.err];return r.result}p.prototype.push=function(e,t){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=h.string2buf(e):"[object ArrayBuffer]"===u.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new o.Buf8(s),i.next_out=0,i.avail_out=s),1!==(r=a.deflate(i,n))&&r!==l)return this.onEnd(r),!(this.ended=!0);0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(h.buf2binstring(o.shrinkBuf(i.output,i.next_out))):this.onData(o.shrinkBuf(i.output,i.next_out)))}while((0<i.avail_in||0===i.avail_out)&&1!==r);return 4===n?(r=a.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===l):2!==n||(this.onEnd(l),!(i.avail_out=0))},p.prototype.onData=function(e){this.chunks.push(e)},p.prototype.onEnd=function(e){e===l&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=p,r.deflate=n,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,n(e,t)},r.gzip=function(e,t){return(t=t||{}).gzip=!0,n(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,r){"use strict";var c=e("./zlib/inflate"),d=e("./utils/common"),p=e("./utils/strings"),m=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),s=e("./zlib/gzheader"),_=Object.prototype.toString;function a(e){if(!(this instanceof a))return new a(e);this.options=d.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;var r=c.inflateInit2(this.strm,t.windowBits);if(r!==m.Z_OK)throw new Error(n[r]);this.header=new s,c.inflateGetHeader(this.strm,this.header)}function o(e,t){var r=new a(t);if(r.push(e,!0),r.err)throw r.msg||n[r.err];return r.result}a.prototype.push=function(e,t){var r,n,i,s,a,o,h=this.strm,u=this.options.chunkSize,l=this.options.dictionary,f=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?m.Z_FINISH:m.Z_NO_FLUSH,"string"==typeof e?h.input=p.binstring2buf(e):"[object ArrayBuffer]"===_.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new d.Buf8(u),h.next_out=0,h.avail_out=u),(r=c.inflate(h,m.Z_NO_FLUSH))===m.Z_NEED_DICT&&l&&(o="string"==typeof l?p.string2buf(l):"[object ArrayBuffer]"===_.call(l)?new Uint8Array(l):l,r=c.inflateSetDictionary(this.strm,o)),r===m.Z_BUF_ERROR&&!0===f&&(r=m.Z_OK,f=!1),r!==m.Z_STREAM_END&&r!==m.Z_OK)return this.onEnd(r),!(this.ended=!0);h.next_out&&(0!==h.avail_out&&r!==m.Z_STREAM_END&&(0!==h.avail_in||n!==m.Z_FINISH&&n!==m.Z_SYNC_FLUSH)||("string"===this.options.to?(i=p.utf8border(h.output,h.next_out),s=h.next_out-i,a=p.buf2string(h.output,i),h.next_out=s,h.avail_out=u-s,s&&d.arraySet(h.output,h.output,i,s,0),this.onData(a)):this.onData(d.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(f=!0)}while((0<h.avail_in||0===h.avail_out)&&r!==m.Z_STREAM_END);return r===m.Z_STREAM_END&&(n=m.Z_FINISH),n===m.Z_FINISH?(r=c.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===m.Z_OK):n!==m.Z_SYNC_FLUSH||(this.onEnd(m.Z_OK),!(h.avail_out=0))},a.prototype.onData=function(e){this.chunks.push(e)},a.prototype.onEnd=function(e){e===m.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=d.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=a,r.inflate=o,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,o(e,t)},r.ungzip=o},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){var t,r,n,i,s,a;for(t=n=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),t=i=0,r=e.length;t<r;t++)s=e[t],a.set(s,i),i+=s.length;return a}},s={arraySet:function(e,t,r,n,i){for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,s))},r.setTyped(n)},{}],42:[function(e,t,r){"use strict";var h=e("./common"),i=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var u=new h.Buf8(256),n=0;n<256;n++)u[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function l(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&i))return String.fromCharCode.apply(null,h.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}u[254]=u[254]=1,r.string2buf=function(e){var t,r,n,i,s,a=e.length,o=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new h.Buf8(o),i=s=0;s<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,n,i,s,a=t||e.length,o=new Array(2*a);for(r=n=0;r<a;)if((i=e[r++])<128)o[n++]=i;else if(4<(s=u[i]))o[n++]=65533,r+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&r<a;)i=i<<6|63&e[r++],s--;1<s?o[n++]=65533:i<65536?o[n++]=i:(i-=65536,o[n++]=55296|i>>10&1023,o[n++]=56320|1023&i)}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3<r?2e3:r;s=s+(i=i+t[n++]|0)|0,--a;);i%=65521,s%=65521}return i|s<<16|0}},{}],44:[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,r){"use strict";var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,r){"use strict";var h,c=e("../utils/common"),u=e("./trees"),d=e("./adler32"),p=e("./crc32"),n=e("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return(e<<1)-(4<e?9:0)}function D(e){for(var t=e.length;0<=--t;)e[t]=0}function F(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&s<c);if(n=S-(c-s),s=c-S,a<n){if(e.match_start=t,o<=(a=n))break;d=u[s+a-1],p=u[s+a]}}}while((t=f[t&l])>h&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u<l&&(l=u),r=0===l?0:(a.avail_in-=l,c.arraySet(o,a.input,a.next_in,l,h),1===a.state.wrap?a.adler=d(a.adler,o,l,h):2===a.state.wrap&&(a.adler=p(a.adler,o,l,h)),a.next_in+=l,a.total_in+=l,l),e.lookahead+=r,e.lookahead+e.insert>=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+x-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<x)););}while(e.lookahead<z&&0!==e.strm.avail_in)}function Z(e,t){for(var r,n;;){if(e.lookahead<z){if(j(e),e.lookahead<z&&t===l)return A;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-z&&(e.match_length=L(e,r)),e.match_length>=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=e.strstart<x-1?e.strstart:x-1,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}function W(e,t){for(var r,n,i;;){if(e.lookahead<z){if(j(e),e.lookahead<z&&t===l)return A;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=x-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-z&&(e.match_length=L(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===x&&4096<e.strstart-e.match_start)&&(e.match_length=x-1)),e.prev_length>=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=x-1,e.strstart++,n&&(N(e,!1),0===e.strm.avail_out))return A}else if(e.match_available){if((n=u._tr_tally(e,0,e.window[e.strstart-1]))&&N(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return A}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=u._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<x-1?e.strstart:x-1,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}function M(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function H(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new c.Buf16(2*w),this.dyn_dtree=new c.Buf16(2*(2*a+1)),this.bl_tree=new c.Buf16(2*(2*o+1)),D(this.dyn_ltree),D(this.dyn_dtree),D(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new c.Buf16(k+1),this.heap=new c.Buf16(2*s+1),D(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new c.Buf16(2*s+1),D(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function G(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=i,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?C:E,e.adler=2===t.wrap?0:1,t.last_flush=l,u._tr_init(t),m):R(e,_)}function K(e){var t=G(e);return t===m&&function(e){e.window_size=2*e.w_size,D(e.head),e.max_lazy_match=h[e.level].max_lazy,e.good_match=h[e.level].good_length,e.nice_match=h[e.level].nice_length,e.max_chain_length=h[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=x-1,e.match_available=0,e.ins_h=0}(e.state),t}function Y(e,t,r,n,i,s){if(!e)return _;var a=1;if(t===g&&(t=6),n<0?(a=0,n=-n):15<n&&(a=2,n-=16),i<1||y<i||r!==v||n<8||15<n||t<0||9<t||s<0||b<s)return R(e,_);8===n&&(n=9);var o=new H;return(e.state=o).strm=e,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+x-1)/x),o.window=new c.Buf8(2*o.w_size),o.head=new c.Buf16(o.hash_size),o.prev=new c.Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new c.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=s,o.method=r,K(e)}h=[new M(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5<t||t<0)return e?R(e,_):_;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&t!==f)return R(e,0===e.avail_out?-5:_);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===C)if(2===n.wrap)e.adler=0,U(n,31),U(n,139),U(n,8),n.gzhead?(U(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),U(n,255&n.gzhead.time),U(n,n.gzhead.time>>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else{var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,U(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,U(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0<e.strstart&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){s=e.strstart+S;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<s);e.match_length=S-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?m:1)},r.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==C&&69!==t&&73!==t&&91!==t&&103!==t&&t!==E&&666!==t?R(e,_):(e.state=null,t===E?R(e,-3):m):_},r.deflateSetDictionary=function(e,t){var r,n,i,s,a,o,h,u,l=t.length;if(!e||!e.state)return _;if(2===(s=(r=e.state).wrap)||1===s&&r.status!==C||r.lookahead)return _;for(1===s&&(e.adler=d(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+x-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,--i;);r.strstart=n,r.lookahead=x-1,j(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=x-1,r.match_available=0,e.next_in=o,e.input=h,e.avail_in=a,r.wrap=s,m},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,r){"use strict";t.exports=function(e,t){var r,n,i,s,a,o,h,u,l,f,c,d,p,m,_,g,b,v,y,w,k,x,S,z,C;r=e.state,n=e.next_in,z=e.input,i=n+(e.avail_in-5),s=e.next_out,C=e.output,a=s-(t-e.avail_out),o=s+(e.avail_out-257),h=r.dmax,u=r.wsize,l=r.whave,f=r.wnext,c=r.window,d=r.hold,p=r.bits,m=r.lencode,_=r.distcode,g=(1<<r.lenbits)-1,b=(1<<r.distbits)-1;e:do{p<15&&(d+=z[n++]<<p,p+=8,d+=z[n++]<<p,p+=8),v=m[d&g];t:for(;;){if(d>>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<<y)-1)];continue t}if(32&y){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}w=65535&v,(y&=15)&&(p<y&&(d+=z[n++]<<p,p+=8),w+=d&(1<<y)-1,d>>>=y,p-=y),p<15&&(d+=z[n++]<<p,p+=8,d+=z[n++]<<p,p+=8),v=_[d&b];r:for(;;){if(d>>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<<y)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&v,p<(y&=15)&&(d+=z[n++]<<p,(p+=8)<y&&(d+=z[n++]<<p,p+=8)),h<(k+=d&(1<<y)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=y,p-=y,(y=s-a)<k){if(l<(y=k-y)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=c,(x=0)===f){if(x+=u-y,y<w){for(w-=y;C[s++]=c[x++],--y;);x=s-k,S=C}}else if(f<y){if(x+=u+f-y,(y-=f)<w){for(w-=y;C[s++]=c[x++],--y;);if(x=0,f<w){for(w-=y=f;C[s++]=c[x++],--y;);x=s-k,S=C}}}else if(x+=f-y,y<w){for(w-=y;C[s++]=c[x++],--y;);x=s-k,S=C}for(;2<w;)C[s++]=S[x++],C[s++]=S[x++],C[s++]=S[x++],w-=3;w&&(C[s++]=S[x++],1<w&&(C[s++]=S[x++]))}else{for(x=s-k;C[s++]=C[x++],C[s++]=C[x++],C[s++]=C[x++],2<(w-=3););w&&(C[s++]=C[x++],1<w&&(C[s++]=C[x++]))}break}}break}}while(n<i&&s<o);n-=w=p>>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=s<o?o-s+257:257-(s-o),r.hold=d,r.bits=p}},{}],49:[function(e,t,r){"use strict";var I=e("../utils/common"),O=e("./adler32"),B=e("./crc32"),R=e("./inffast"),T=e("./inftrees"),D=1,F=2,N=0,U=-2,P=1,n=852,i=592;function L(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?U:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,o(e))):U}function u(e,t){var r,n;return e?(n=new s,(e.state=n).window=null,(r=h(e,t))!==N&&(e.state=null),r):U}var l,f,c=!0;function j(e){if(c){var t;for(l=new I.Buf32(512),f=new I.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(T(D,e.lens,0,288,l,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;T(F,e.lens,0,32,f,0,e.work,{bits:5}),c=!1}e.lencode=l,e.lenbits=9,e.distcode=f,e.distbits=5}function Z(e,t,r,n){var i,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new I.Buf8(s.wsize)),n>=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0}r.inflateReset=o,r.inflateReset2=h,r.inflateResetKeep=a,r.inflateInit=function(e){return u(e,15)},r.inflateInit2=u,r.inflate=function(e,t){var r,n,i,s,a,o,h,u,l,f,c,d,p,m,_,g,b,v,y,w,k,x,S,z,C=0,E=new I.Buf8(4),A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return U;12===(r=e.state).mode&&(r.mode=13),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,f=o,c=h,x=N;e:for(;;)switch(r.mode){case P:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(2&r.wrap&&35615===u){E[r.check=0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:12,l=u=0;break;case 2:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d<o;);if(512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k)),k&&d<o;);if(512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}l=u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}e.adler=r.check=L(u),l=u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o<d&&(d=o),h<d&&(d=h),0===d)break e;I.arraySet(i,n,s,d,a),o-=d,s+=d,h-=d,a+=d,r.length-=d;break}r.mode=12;break;case 17:for(;l<14;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.lens[A[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(b<16)u>>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u>>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}l-=_,k=0,d=3+(7&(u>>>=_)),u>>>=3,l-=3}else{for(z=_+7;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}l-=_,k=0,d=11+(127&(u>>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(g&&0==(240&g)){for(v=_,y=g,w=b;g=(C=r.lencode[w+((u&(1<<v+y)-1)>>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<<r.distbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(0==(240&g)){for(v=_,y=g,w=b;g=(C=r.distcode[w+((u&(1<<v+y)-1)>>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(h<d&&(d=h),h-=d,r.length-=d;i[a++]=m[p++],--d;);0===r.length&&(r.mode=21);break;case 26:if(0===h)break e;i[a++]=r.length,h--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===o)break e;o--,u|=n[s++]<<l,l+=8}if(c-=h,e.total_out+=c,r.total+=c,c&&(e.adler=r.check=r.flags?B(r.check,i,c,a-c):O(r.check,i,c,a-c)),c=h,(r.flags?u:L(u))!==r.check){e.msg="incorrect data check",r.mode=30;break}l=u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}l=u=0}r.mode=29;case 29:x=1;break e;case 30:x=-3;break e;case 31:return-4;case 32:default:return U}return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,(r.wsize||c!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&Z(e,e.output,e.next_out,c-e.avail_out)?(r.mode=31,-4):(f-=e.avail_in,c-=e.avail_out,e.total_in+=f,e.total_out+=c,r.total+=c,r.wrap&&c&&(e.adler=r.check=r.flags?B(r.check,i,c,e.next_out-c):O(r.check,i,c,e.next_out-c)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==f&&0===c||4===t)&&x===N&&(x=-5),x)},r.inflateEnd=function(e){if(!e||!e.state)return U;var t=e.state;return t.window&&(t.window=null),e.state=null,N},r.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?U:((r.head=t).done=!1,N):U},r.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?U:11===r.mode&&O(1,t,n,0)!==r.check?-3:Z(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,N):U},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){"use strict";var D=e("../utils/common"),F=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],N=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],U=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],P=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,r,n,i,s,a,o){var h,u,l,f,c,d,p,m,_,g=o.bits,b=0,v=0,y=0,w=0,k=0,x=0,S=0,z=0,C=0,E=0,A=null,I=0,O=new D.Buf16(16),B=new D.Buf16(16),R=null,T=0;for(b=0;b<=15;b++)O[b]=0;for(v=0;v<n;v++)O[t[r+v]]++;for(k=g,w=15;1<=w&&0===O[w];w--);if(w<k&&(k=w),0===w)return i[s++]=20971520,i[s++]=20971520,o.bits=1,0;for(y=1;y<w&&0===O[y];y++);for(k<y&&(k=y),b=z=1;b<=15;b++)if(z<<=1,(z-=O[b])<0)return-1;if(0<z&&(0===e||1!==w))return-1;for(B[1]=0,b=1;b<15;b++)B[b+1]=B[b]+O[b];for(v=0;v<n;v++)0!==t[r+v]&&(a[B[t[r+v]]++]=v);if(d=0===e?(A=R=a,19):1===e?(A=F,I-=257,R=N,T-=257,256):(A=U,R=P,-1),b=y,c=s,S=v=E=0,l=-1,f=(C=1<<(x=k))-1,1===e&&852<C||2===e&&592<C)return 1;for(;;){for(p=b-S,_=a[v]<d?(m=0,a[v]):a[v]>d?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<<b-S,y=u=1<<x;i[c+(E>>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<<b-1;E&h;)h>>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k<b&&(E&f)!==l){for(0===S&&(S=k),c+=y,z=1<<(x=b-S);x+S<w&&!((z-=O[x+S])<=0);)x++,z<<=1;if(C+=1<<x,1===e&&852<C||2===e&&592<C)return 1;i[l=E&f]=k<<24|x<<16|c-s|0}}return 0!==E&&(i[c+E]=b-S<<24|64<<16|0),o.bits=k,0}},{"../utils/common":41}],51:[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,r){"use strict";var i=e("../utils/common"),o=0,h=1;function n(e){for(var t=e.length;0<=--t;)e[t]=0}var s=0,a=29,u=256,l=u+1+a,f=30,c=19,_=2*l+1,g=15,d=16,p=7,m=256,b=16,v=17,y=18,w=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(l+2));n(z);var C=new Array(2*f);n(C);var E=new Array(512);n(E);var A=new Array(256);n(A);var I=new Array(a);n(I);var O,B,R,T=new Array(f);function D(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function F(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function N(e){return e<256?E[e]:E[256+(e>>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<<e.bi_valid&65535,U(e,e.bi_buf),e.bi_buf=t>>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function L(e,t,r){P(e,r[2*t],r[2*t+1])}function j(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t<l;t++)e.dyn_ltree[2*t]=0;for(t=0;t<f;t++)e.dyn_dtree[2*t]=0;for(t=0;t<c;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*m]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function M(e){8<e.bi_valid?U(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function H(e,t,r,n){var i=2*t,s=2*r;return e[i]<e[s]||e[i]===e[s]&&n[t]<=n[r]}function G(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&H(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!H(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function K(e,t,r){var n,i,s,a,o=0;if(0!==e.last_lit)for(;n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?L(e,i,t):(L(e,(s=A[i])+u+1,t),0!==(a=w[s])&&P(e,i-=I[s],a),L(e,s=N(--n),r),0!==(a=k[s])&&P(e,n-=T[s],a)),o<e.last_lit;);L(e,m,t)}function Y(e,t){var r,n,i,s=t.dyn_tree,a=t.stat_desc.static_tree,o=t.stat_desc.has_stree,h=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=_,r=0;r<h;r++)0!==s[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):s[2*r+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u<n||(e.bl_count[s]++,a=0,d<=n&&(a=c[n-d]),o=h[2*n],e.opt_len+=o*(s+a),f&&(e.static_len+=o*(l[2*n+1]+a)));if(0!==m){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,m-=2}while(0<m);for(s=p;0!==s;s--)for(n=e.bl_count[s];0!==n;)u<(i=e.heap[--r])||(h[2*i+1]!==s&&(e.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(e,t),Z(s,u,e.bl_count)}function X(e,t,r){var n,i,s=-1,a=t[1],o=0,h=7,u=4;for(0===a&&(h=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++o<h&&i===a||(o<u?e.bl_tree[2*i]+=o:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[2*b]++):o<=10?e.bl_tree[2*v]++:e.bl_tree[2*y]++,s=i,u=(o=0)===a?(h=138,3):i===a?(h=6,3):(h=7,4))}function V(e,t,r){var n,i,s=-1,a=t[1],o=0,h=7,u=4;for(0===a&&(h=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++o<h&&i===a)){if(o<u)for(;L(e,i,e.bl_tree),0!=--o;);else 0!==i?(i!==s&&(L(e,i,e.bl_tree),o--),L(e,b,e.bl_tree),P(e,o-3,2)):o<=10?(L(e,v,e.bl_tree),P(e,o-3,3)):(L(e,y,e.bl_tree),P(e,o-11,7));s=i,u=(o=0)===a?(h=138,3):i===a?(h=6,3):(h=7,4)}}n(T);var q=!1;function J(e,t,r,n){P(e,(s<<1)+(n?1:0),3),function(e,t,r,n){M(e),n&&(U(e,r),U(e,~r)),i.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}r._tr_init=function(e){q||(function(){var e,t,r,n,i,s=new Array(g+1);for(n=r=0;n<a-1;n++)for(I[n]=r,e=0;e<1<<w[n];e++)A[r++]=n;for(A[r-1]=n,n=i=0;n<16;n++)for(T[n]=i,e=0;e<1<<k[n];e++)E[i++]=n;for(i>>=7;n<f;n++)for(T[n]=i<<7,e=0;e<1<<k[n]-7;e++)E[256+i++]=n;for(t=0;t<=g;t++)s[t]=0;for(e=0;e<=143;)z[2*e+1]=8,e++,s[8]++;for(;e<=255;)z[2*e+1]=9,e++,s[9]++;for(;e<=279;)z[2*e+1]=7,e++,s[7]++;for(;e<=287;)z[2*e+1]=8,e++,s[8]++;for(Z(z,l+1,s),e=0;e<f;e++)C[2*e+1]=5,C[2*e]=j(e,5);O=new D(z,w,u+1,l,g),B=new D(C,k,0,f,g),R=new D(new Array(0),x,0,c,p)}(),q=!0),e.l_desc=new F(e.dyn_ltree,O),e.d_desc=new F(e.dyn_dtree,B),e.bl_desc=new F(e.bl_tree,R),e.bi_buf=0,e.bi_valid=0,W(e)},r._tr_stored_block=J,r._tr_flush_block=function(e,t,r,n){var i,s,a=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t<u;t++)if(0!==e.dyn_ltree[2*t])return h;return o}(e)),Y(e,e.l_desc),Y(e,e.d_desc),a=function(e){var t;for(X(e,e.dyn_ltree,e.l_desc.max_code),X(e,e.dyn_dtree,e.d_desc.max_code),Y(e,e.bl_desc),t=c-1;3<=t&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i<n;i++)P(e,e.bl_tree[2*S[i]+1],3);V(e,e.dyn_ltree,t-1),V(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),K(e,e.dyn_ltree,e.dyn_dtree)),W(e),n&&M(e)},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){"use strict";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i="[object process]"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}}()?(a="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",d,!1):r.attachEvent("onmessage",d),function(e){r.postMessage(a+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var n={callback:e,args:t};return h[o]=n,i(o),o++},e.clearImmediate=f}function f(e){delete h[e]}function c(e){if(u)setTimeout(c,0,e);else{var t=h[e];if(t){u=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}(t)}finally{f(e),u=!1}}}}function d(e){e.source===r&&"string"==typeof e.data&&0===e.data.indexOf(a)&&c(+e.data.slice(a.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)});
13 \ No newline at end of file \ No newline at end of file
public/lib/localforage.min.js+0 -7
@@ -1,7 +0,0 @@
1/*!
2 localForage -- Offline Storage, Improved
3 Version 1.10.0
4 https://localforage.github.io/localForage
5 (c) 2013-2017 Mozilla, Apache License 2.0
6*/
7!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.localforage=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){"use strict";function c(){k=!0;for(var a,b,c=l.length;c;){for(b=l,l=[],a=-1;++a<c;)b[a]();c=l.length}k=!1}function d(a){1!==l.push(a)||k||e()}var e,f=a.MutationObserver||a.WebKitMutationObserver;if(f){var g=0,h=new f(c),i=a.document.createTextNode("");h.observe(i,{characterData:!0}),e=function(){i.data=g=++g%2}}else if(a.setImmediate||void 0===a.MessageChannel)e="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){c(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(c,0)};else{var j=new a.MessageChannel;j.port1.onmessage=c,e=function(){j.port2.postMessage(0)}}var k,l=[];b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){"use strict";function d(){}function e(a){if("function"!=typeof a)throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,a!==d&&i(this,a)}function f(a,b,c){this.promise=a,"function"==typeof b&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),"function"==typeof c&&(this.onRejected=c,this.callRejected=this.otherCallRejected)}function g(a,b,c){o(function(){var d;try{d=b(c)}catch(b){return p.reject(a,b)}d===a?p.reject(a,new TypeError("Cannot resolve promise with itself")):p.resolve(a,d)})}function h(a){var b=a&&a.then;if(a&&("object"==typeof a||"function"==typeof a)&&"function"==typeof b)return function(){b.apply(a,arguments)}}function i(a,b){function c(b){f||(f=!0,p.reject(a,b))}function d(b){f||(f=!0,p.resolve(a,b))}function e(){b(d,c)}var f=!1,g=j(e);"error"===g.status&&c(g.value)}function j(a,b){var c={};try{c.value=a(b),c.status="success"}catch(a){c.status="error",c.value=a}return c}function k(a){return a instanceof this?a:p.resolve(new this(d),a)}function l(a){var b=new this(d);return p.reject(b,a)}function m(a){function b(a,b){function d(a){g[b]=a,++h!==e||f||(f=!0,p.resolve(j,g))}c.resolve(a).then(d,function(a){f||(f=!0,p.reject(j,a))})}var c=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=new Array(e),h=0,i=-1,j=new this(d);++i<e;)b(a[i],i);return j}function n(a){function b(a){c.resolve(a).then(function(a){f||(f=!0,p.resolve(h,a))},function(a){f||(f=!0,p.reject(h,a))})}var c=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=-1,h=new this(d);++g<e;)b(a[g]);return h}var o=a(1),p={},q=["REJECTED"],r=["FULFILLED"],s=["PENDING"];b.exports=e,e.prototype.catch=function(a){return this.then(null,a)},e.prototype.then=function(a,b){if("function"!=typeof a&&this.state===r||"function"!=typeof b&&this.state===q)return this;var c=new this.constructor(d);if(this.state!==s){g(c,this.state===r?a:b,this.outcome)}else this.queue.push(new f(c,a,b));return c},f.prototype.callFulfilled=function(a){p.resolve(this.promise,a)},f.prototype.otherCallFulfilled=function(a){g(this.promise,this.onFulfilled,a)},f.prototype.callRejected=function(a){p.reject(this.promise,a)},f.prototype.otherCallRejected=function(a){g(this.promise,this.onRejected,a)},p.resolve=function(a,b){var c=j(h,b);if("error"===c.status)return p.reject(a,c.value);var d=c.value;if(d)i(a,d);else{a.state=r,a.outcome=b;for(var e=-1,f=a.queue.length;++e<f;)a.queue[e].callFulfilled(b)}return a},p.reject=function(a,b){a.state=q,a.outcome=b;for(var c=-1,d=a.queue.length;++c<d;)a.queue[c].callRejected(b);return a},e.resolve=k,e.reject=l,e.all=m,e.race=n},{1:1}],3:[function(a,b,c){(function(b){"use strict";"function"!=typeof b.Promise&&(b.Promise=a(2))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(a){return}}function f(){try{if(!ua||!ua.open)return!1;var a="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),b="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!a||b)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(a){return!1}}function g(a,b){a=a||[],b=b||{};try{return new Blob(a,b)}catch(f){if("TypeError"!==f.name)throw f;for(var c="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,d=new c,e=0;e<a.length;e+=1)d.append(a[e]);return d.getBlob(b.type)}}function h(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}function i(a,b,c){"function"==typeof b&&a.then(b),"function"==typeof c&&a.catch(c)}function j(a){return"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}function k(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function l(a){for(var b=a.length,c=new ArrayBuffer(b),d=new Uint8Array(c),e=0;e<b;e++)d[e]=a.charCodeAt(e);return c}function m(a){return new va(function(b){var c=a.transaction(wa,Ba),d=g([""]);c.objectStore(wa).put(d,"key"),c.onabort=function(a){a.preventDefault(),a.stopPropagation(),b(!1)},c.oncomplete=function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);b(c||!a||parseInt(a[1],10)>=43)}}).catch(function(){return!1})}function n(a){return"boolean"==typeof xa?va.resolve(xa):m(a).then(function(a){return xa=a})}function o(a){var b=ya[a.name],c={};c.promise=new va(function(a,b){c.resolve=a,c.reject=b}),b.deferredOperations.push(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady=c.promise}function p(a){var b=ya[a.name],c=b.deferredOperations.pop();if(c)return c.resolve(),c.promise}function q(a,b){var c=ya[a.name],d=c.deferredOperations.pop();if(d)return d.reject(b),d.promise}function r(a,b){return new va(function(c,d){if(ya[a.name]=ya[a.name]||B(),a.db){if(!b)return c(a.db);o(a),a.db.close()}var e=[a.name];b&&e.push(a.version);var f=ua.open.apply(ua,e);b&&(f.onupgradeneeded=function(b){var c=f.result;try{c.createObjectStore(a.storeName),b.oldVersion<=1&&c.createObjectStore(wa)}catch(c){if("ConstraintError"!==c.name)throw c;console.warn('The database "'+a.name+'" has been upgraded from version '+b.oldVersion+" to version "+b.newVersion+', but the storage "'+a.storeName+'" already exists.')}}),f.onerror=function(a){a.preventDefault(),d(f.error)},f.onsuccess=function(){var b=f.result;b.onversionchange=function(a){a.target.close()},c(b),p(a)}})}function s(a){return r(a,!1)}function t(a){return r(a,!0)}function u(a,b){if(!a.db)return!0;var c=!a.db.objectStoreNames.contains(a.storeName),d=a.version<a.db.version,e=a.version>a.db.version;if(d&&(a.version!==b&&console.warn('The database "'+a.name+"\" can't be downgraded from version "+a.db.version+" to version "+a.version+"."),a.version=a.db.version),e||c){if(c){var f=a.db.version+1;f>a.version&&(a.version=f)}return!0}return!1}function v(a){return new va(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function w(a){return g([l(atob(a.data))],{type:a.type})}function x(a){return a&&a.__local_forage_encoded_blob}function y(a){var b=this,c=b._initReady().then(function(){var a=ya[b._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return i(c,a,a),c}function z(a){o(a);for(var b=ya[a.name],c=b.forages,d=0;d<c.length;d++){var e=c[d];e._dbInfo.db&&(e._dbInfo.db.close(),e._dbInfo.db=null)}return a.db=null,s(a).then(function(b){return a.db=b,u(a)?t(a):b}).then(function(d){a.db=b.db=d;for(var e=0;e<c.length;e++)c[e]._dbInfo.db=d}).catch(function(b){throw q(a,b),b})}function A(a,b,c,d){void 0===d&&(d=1);try{var e=a.db.transaction(a.storeName,b);c(null,e)}catch(e){if(d>0&&(!a.db||"InvalidStateError"===e.name||"NotFoundError"===e.name))return va.resolve().then(function(){if(!a.db||"NotFoundError"===e.name&&!a.db.objectStoreNames.contains(a.storeName)&&a.version<=a.db.version)return a.db&&(a.version=a.db.version+1),t(a)}).then(function(){return z(a).then(function(){A(a,b,c,d-1)})}).catch(c);c(e)}}function B(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function C(a){function b(){return va.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];var f=ya[d.name];f||(f=B(),ya[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=y);for(var g=[],h=0;h<f.forages.length;h++){var i=f.forages[h];i!==c&&g.push(i._initReady().catch(b))}var j=f.forages.slice(0);return va.all(g).then(function(){return d.db=f.db,s(d)}).then(function(a){return d.db=a,u(d,c._defaultConfig.version)?t(d):a}).then(function(a){d.db=f.db=a,c._dbInfo=d;for(var b=0;b<j.length;b++){var e=j[b];e!==c&&(e._dbInfo.db=d.db,e._dbInfo.version=d.version)}})}function D(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){A(c._dbInfo,Aa,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.get(a);h.onsuccess=function(){var a=h.result;void 0===a&&(a=null),x(a)&&(a=w(a)),b(a)},h.onerror=function(){d(h.error)}}catch(a){d(a)}})}).catch(d)});return h(d,b),d}function E(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){A(c._dbInfo,Aa,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.openCursor(),i=1;h.onsuccess=function(){var c=h.result;if(c){var d=c.value;x(d)&&(d=w(d));var e=a(d,c.key,i++);void 0!==e?b(e):c.continue()}else b()},h.onerror=function(){d(h.error)}}catch(a){d(a)}})}).catch(d)});return h(d,b),d}function F(a,b,c){var d=this;a=j(a);var e=new va(function(c,e){var f;d.ready().then(function(){return f=d._dbInfo,"[object Blob]"===za.call(b)?n(f.db).then(function(a){return a?b:v(b)}):b}).then(function(b){A(d._dbInfo,Ba,function(f,g){if(f)return e(f);try{var h=g.objectStore(d._dbInfo.storeName);null===b&&(b=void 0);var i=h.put(b,a);g.oncomplete=function(){void 0===b&&(b=null),c(b)},g.onabort=g.onerror=function(){var a=i.error?i.error:i.transaction.error;e(a)}}catch(a){e(a)}})}).catch(e)});return h(e,c),e}function G(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){A(c._dbInfo,Ba,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.delete(a);f.oncomplete=function(){b()},f.onerror=function(){d(h.error)},f.onabort=function(){var a=h.error?h.error:h.transaction.error;d(a)}}catch(a){d(a)}})}).catch(d)});return h(d,b),d}function H(a){var b=this,c=new va(function(a,c){b.ready().then(function(){A(b._dbInfo,Ba,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.clear();e.oncomplete=function(){a()},e.onabort=e.onerror=function(){var a=g.error?g.error:g.transaction.error;c(a)}}catch(a){c(a)}})}).catch(c)});return h(c,a),c}function I(a){var b=this,c=new va(function(a,c){b.ready().then(function(){A(b._dbInfo,Aa,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.count();g.onsuccess=function(){a(g.result)},g.onerror=function(){c(g.error)}}catch(a){c(a)}})}).catch(c)});return h(c,a),c}function J(a,b){var c=this,d=new va(function(b,d){if(a<0)return void b(null);c.ready().then(function(){A(c._dbInfo,Aa,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=!1,i=g.openKeyCursor();i.onsuccess=function(){var c=i.result;if(!c)return void b(null);0===a?b(c.key):h?b(c.key):(h=!0,c.advance(a))},i.onerror=function(){d(i.error)}}catch(a){d(a)}})}).catch(d)});return h(d,b),d}function K(a){var b=this,c=new va(function(a,c){b.ready().then(function(){A(b._dbInfo,Aa,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.openKeyCursor(),h=[];g.onsuccess=function(){var b=g.result;if(!b)return void a(h);h.push(b.key),b.continue()},g.onerror=function(){c(g.error)}}catch(a){c(a)}})}).catch(c)});return h(c,a),c}function L(a,b){b=k.apply(this,arguments);var c=this.config();a="function"!=typeof a&&a||{},a.name||(a.name=a.name||c.name,a.storeName=a.storeName||c.storeName);var d,e=this;if(a.name){var f=a.name===c.name&&e._dbInfo.db,g=f?va.resolve(e._dbInfo.db):s(a).then(function(b){var c=ya[a.name],d=c.forages;c.db=b;for(var e=0;e<d.length;e++)d[e]._dbInfo.db=b;return b});d=a.storeName?g.then(function(b){if(b.objectStoreNames.contains(a.storeName)){var c=b.version+1;o(a);var d=ya[a.name],e=d.forages;b.close();for(var f=0;f<e.length;f++){var g=e[f];g._dbInfo.db=null,g._dbInfo.version=c}return new va(function(b,d){var e=ua.open(a.name,c);e.onerror=function(a){e.result.close(),d(a)},e.onupgradeneeded=function(){e.result.deleteObjectStore(a.storeName)},e.onsuccess=function(){var a=e.result;a.close(),b(a)}}).then(function(a){d.db=a;for(var b=0;b<e.length;b++){var c=e[b];c._dbInfo.db=a,p(c._dbInfo)}}).catch(function(b){throw(q(a,b)||va.resolve()).catch(function(){}),b})}}):g.then(function(b){o(a);var c=ya[a.name],d=c.forages;b.close();for(var e=0;e<d.length;e++){d[e]._dbInfo.db=null}return new va(function(b,c){var d=ua.deleteDatabase(a.name);d.onerror=function(){var a=d.result;a&&a.close(),c(d.error)},d.onblocked=function(){console.warn('dropInstance blocked for database "'+a.name+'" until all open connections are closed')},d.onsuccess=function(){var a=d.result;a&&a.close(),b(a)}}).then(function(a){c.db=a;for(var b=0;b<d.length;b++)p(d[b]._dbInfo)}).catch(function(b){throw(q(a,b)||va.resolve()).catch(function(){}),b})})}else d=va.reject("Invalid arguments");return h(d,b),d}function M(){return"function"==typeof openDatabase}function N(a){var b,c,d,e,f,g=.75*a.length,h=a.length,i=0;"="===a[a.length-1]&&(g--,"="===a[a.length-2]&&g--);var j=new ArrayBuffer(g),k=new Uint8Array(j);for(b=0;b<h;b+=4)c=Da.indexOf(a[b]),d=Da.indexOf(a[b+1]),e=Da.indexOf(a[b+2]),f=Da.indexOf(a[b+3]),k[i++]=c<<2|d>>4,k[i++]=(15&d)<<4|e>>2,k[i++]=(3&e)<<6|63&f;return j}function O(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+=Da[c[b]>>2],d+=Da[(3&c[b])<<4|c[b+1]>>4],d+=Da[(15&c[b+1])<<2|c[b+2]>>6],d+=Da[63&c[b+2]];return c.length%3==2?d=d.substring(0,d.length-1)+"=":c.length%3==1&&(d=d.substring(0,d.length-2)+"=="),d}function P(a,b){var c="";if(a&&(c=Ua.call(a)),a&&("[object ArrayBuffer]"===c||a.buffer&&"[object ArrayBuffer]"===Ua.call(a.buffer))){var d,e=Ga;a instanceof ArrayBuffer?(d=a,e+=Ia):(d=a.buffer,"[object Int8Array]"===c?e+=Ka:"[object Uint8Array]"===c?e+=La:"[object Uint8ClampedArray]"===c?e+=Ma:"[object Int16Array]"===c?e+=Na:"[object Uint16Array]"===c?e+=Pa:"[object Int32Array]"===c?e+=Oa:"[object Uint32Array]"===c?e+=Qa:"[object Float32Array]"===c?e+=Ra:"[object Float64Array]"===c?e+=Sa:b(new Error("Failed to get type for BinaryArray"))),b(e+O(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var c=Ea+a.type+"~"+O(this.result);b(Ga+Ja+c)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(c){console.error("Couldn't convert value into a JSON string: ",a),b(null,c)}}function Q(a){if(a.substring(0,Ha)!==Ga)return JSON.parse(a);var b,c=a.substring(Ta),d=a.substring(Ha,Ta);if(d===Ja&&Fa.test(c)){var e=c.match(Fa);b=e[1],c=c.substring(e[0].length)}var f=N(c);switch(d){case Ia:return f;case Ja:return g([f],{type:b});case Ka:return new Int8Array(f);case La:return new Uint8Array(f);case Ma:return new Uint8ClampedArray(f);case Na:return new Int16Array(f);case Pa:return new Uint16Array(f);case Oa:return new Int32Array(f);case Qa:return new Uint32Array(f);case Ra:return new Float32Array(f);case Sa:return new Float64Array(f);default:throw new Error("Unkown type: "+d)}}function R(a,b,c,d){a.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],c,d)}function S(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="string"!=typeof a[d]?a[d].toString():a[d];var e=new va(function(a,d){try{c.db=openDatabase(c.name,String(c.version),c.description,c.size)}catch(a){return d(a)}c.db.transaction(function(e){R(e,c,function(){b._dbInfo=c,a()},function(a,b){d(b)})},d)});return c.serializer=Va,e}function T(a,b,c,d,e,f){a.executeSql(c,d,e,function(a,g){g.code===g.SYNTAX_ERR?a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function(a,h){h.rows.length?f(a,g):R(a,b,function(){a.executeSql(c,d,e,f)},f)},f):f(a,g)},f)}function U(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),b(d)},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function V(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT * FROM "+e.storeName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;h<g;h++){var i=f.item(h),j=i.value;if(j&&(j=e.serializer.deserialize(j)),void 0!==(j=a(j,i.key,h+1)))return void b(j)}b()},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function W(a,b,c,d){var e=this;a=j(a);var f=new va(function(f,g){e.ready().then(function(){void 0===b&&(b=null);var h=b,i=e._dbInfo;i.serializer.serialize(b,function(b,j){j?g(j):i.db.transaction(function(c){T(c,i,"INSERT OR REPLACE INTO "+i.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){f(h)},function(a,b){g(b)})},function(b){if(b.code===b.QUOTA_ERR){if(d>0)return void f(W.apply(e,[a,h,c,d-1]));g(b)}})})}).catch(g)});return h(f,c),f}function X(a,b,c){return W.apply(this,[a,b,c,1])}function Y(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"DELETE FROM "+e.storeName+" WHERE key = ?",[a],function(){b()},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function Z(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})}).catch(c)});return h(c,a),c}function $(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})}).catch(c)});return h(c,a),c}function _(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})}).catch(d)});return h(d,b),d}function aa(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;e<c.rows.length;e++)d.push(c.rows.item(e).key);a(d)},function(a,b){c(b)})})}).catch(c)});return h(c,a),c}function ba(a){return new va(function(b,c){a.transaction(function(d){d.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(c,d){for(var e=[],f=0;f<d.rows.length;f++)e.push(d.rows.item(f).name);b({db:a,storeNames:e})},function(a,b){c(b)})},function(a){c(a)})})}function ca(a,b){b=k.apply(this,arguments);var c=this.config();a="function"!=typeof a&&a||{},a.name||(a.name=a.name||c.name,a.storeName=a.storeName||c.storeName);var d,e=this;return d=a.name?new va(function(b){var d;d=a.name===c.name?e._dbInfo.db:openDatabase(a.name,"","",0),b(a.storeName?{db:d,storeNames:[a.storeName]}:ba(d))}).then(function(a){return new va(function(b,c){a.db.transaction(function(d){function e(a){return new va(function(b,c){d.executeSql("DROP TABLE IF EXISTS "+a,[],function(){b()},function(a,b){c(b)})})}for(var f=[],g=0,h=a.storeNames.length;g<h;g++)f.push(e(a.storeNames[g]));va.all(f).then(function(){b()}).catch(function(a){c(a)})},function(a){c(a)})})}):va.reject("Invalid arguments"),h(d,b),d}function da(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(a){return!1}}function ea(a,b){var c=a.name+"/";return a.storeName!==b.storeName&&(c+=a.storeName+"/"),c}function fa(){var a="_localforage_support_test";try{return localStorage.setItem(a,!0),localStorage.removeItem(a),!1}catch(a){return!0}}function ga(){return!fa()||localStorage.length>0}function ha(a){var b=this,c={};if(a)for(var d in a)c[d]=a[d];return c.keyPrefix=ea(a,b._defaultConfig),ga()?(b._dbInfo=c,c.serializer=Va,va.resolve()):va.reject()}function ia(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c=localStorage.length-1;c>=0;c--){var d=localStorage.key(c);0===d.indexOf(a)&&localStorage.removeItem(d)}});return h(c,a),c}function ja(a,b){var c=this;a=j(a);var d=c.ready().then(function(){var b=c._dbInfo,d=localStorage.getItem(b.keyPrefix+a);return d&&(d=b.serializer.deserialize(d)),d});return h(d,b),d}function ka(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.length,f=localStorage.length,g=1,h=0;h<f;h++){var i=localStorage.key(h);if(0===i.indexOf(d)){var j=localStorage.getItem(i);if(j&&(j=b.serializer.deserialize(j)),void 0!==(j=a(j,i.substring(e),g++)))return j}}});return h(d,b),d}function la(a,b){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=localStorage.key(a)}catch(a){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return h(d,b),d}function ma(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo,c=localStorage.length,d=[],e=0;e<c;e++){var f=localStorage.key(e);0===f.indexOf(a.keyPrefix)&&d.push(f.substring(a.keyPrefix.length))}return d});return h(c,a),c}function na(a){var b=this,c=b.keys().then(function(a){return a.length});return h(c,a),c}function oa(a,b){var c=this;a=j(a);var d=c.ready().then(function(){var b=c._dbInfo;localStorage.removeItem(b.keyPrefix+a)});return h(d,b),d}function pa(a,b,c){var d=this;a=j(a);var e=d.ready().then(function(){void 0===b&&(b=null);var c=b;return new va(function(e,f){var g=d._dbInfo;g.serializer.serialize(b,function(b,d){if(d)f(d);else try{localStorage.setItem(g.keyPrefix+a,b),e(c)}catch(a){"QuotaExceededError"!==a.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==a.name||f(a),f(a)}})})});return h(e,c),e}function qa(a,b){if(b=k.apply(this,arguments),a="function"!=typeof a&&a||{},!a.name){var c=this.config();a.name=a.name||c.name,a.storeName=a.storeName||c.storeName}var d,e=this;return d=a.name?new va(function(b){b(a.storeName?ea(a,e._defaultConfig):a.name+"/")}).then(function(a){for(var b=localStorage.length-1;b>=0;b--){var c=localStorage.key(b);0===c.indexOf(a)&&localStorage.removeItem(c)}}):va.reject("Invalid arguments"),h(d,b),d}function ra(a,b){a[b]=function(){var c=arguments;return a.ready().then(function(){return a[b].apply(a,c)})}}function sa(){for(var a=1;a<arguments.length;a++){var b=arguments[a];if(b)for(var c in b)b.hasOwnProperty(c)&&($a(b[c])?arguments[0][c]=b[c].slice():arguments[0][c]=b[c])}return arguments[0]}var ta="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ua=e();"undefined"==typeof Promise&&a(3);var va=Promise,wa="local-forage-detect-blob-support",xa=void 0,ya={},za=Object.prototype.toString,Aa="readonly",Ba="readwrite",Ca={_driver:"asyncStorage",_initStorage:C,_support:f(),iterate:E,getItem:D,setItem:F,removeItem:G,clear:H,length:I,key:J,keys:K,dropInstance:L},Da="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ea="~~local_forage_type~",Fa=/^~~local_forage_type~([^~]+)~/,Ga="__lfsc__:",Ha=Ga.length,Ia="arbf",Ja="blob",Ka="si08",La="ui08",Ma="uic8",Na="si16",Oa="si32",Pa="ur16",Qa="ui32",Ra="fl32",Sa="fl64",Ta=Ha+Ia.length,Ua=Object.prototype.toString,Va={serialize:P,deserialize:Q,stringToBuffer:N,bufferToString:O},Wa={_driver:"webSQLStorage",_initStorage:S,_support:M(),iterate:V,getItem:U,setItem:X,removeItem:Y,clear:Z,length:$,key:_,keys:aa,dropInstance:ca},Xa={_driver:"localStorageWrapper",_initStorage:ha,_support:da(),iterate:ka,getItem:ja,setItem:pa,removeItem:oa,clear:ia,length:na,key:la,keys:ma,dropInstance:qa},Ya=function(a,b){return a===b||"number"==typeof a&&"number"==typeof b&&isNaN(a)&&isNaN(b)},Za=function(a,b){for(var c=a.length,d=0;d<c;){if(Ya(a[d],b))return!0;d++}return!1},$a=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},_a={},ab={},bb={INDEXEDDB:Ca,WEBSQL:Wa,LOCALSTORAGE:Xa},cb=[bb.INDEXEDDB._driver,bb.WEBSQL._driver,bb.LOCALSTORAGE._driver],db=["dropInstance"],eb=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(db),fb={description:"",driver:cb.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},gb=function(){function a(b){d(this,a);for(var c in bb)if(bb.hasOwnProperty(c)){var e=bb[c],f=e._driver;this[c]=f,_a[f]||this.defineDriver(e)}this._defaultConfig=sa({},fb),this._config=sa({},this._defaultConfig,b),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return a.prototype.config=function(a){if("object"===(void 0===a?"undefined":ta(a))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in a){if("storeName"===b&&(a[b]=a[b].replace(/\W/g,"_")),"version"===b&&"number"!=typeof a[b])return new Error("Database version must be a number.");this._config[b]=a[b]}return!("driver"in a&&a.driver)||this.setDriver(this._config.driver)}return"string"==typeof a?this._config[a]:this._config},a.prototype.defineDriver=function(a,b,c){var d=new va(function(b,c){try{var d=a._driver,e=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!a._driver)return void c(e);for(var f=eb.concat("_initStorage"),g=0,i=f.length;g<i;g++){var j=f[g];if((!Za(db,j)||a[j])&&"function"!=typeof a[j])return void c(e)}(function(){for(var b=function(a){return function(){var b=new Error("Method "+a+" is not implemented by the current driver"),c=va.reject(b);return h(c,arguments[arguments.length-1]),c}},c=0,d=db.length;c<d;c++){var e=db[c];a[e]||(a[e]=b(e))}})();var k=function(c){_a[d]&&console.info("Redefining LocalForage driver: "+d),_a[d]=a,ab[d]=c,b()};"_support"in a?a._support&&"function"==typeof a._support?a._support().then(k,c):k(!!a._support):k(!0)}catch(a){c(a)}});return i(d,b,c),d},a.prototype.driver=function(){return this._driver||null},a.prototype.getDriver=function(a,b,c){var d=_a[a]?va.resolve(_a[a]):va.reject(new Error("Driver not found."));return i(d,b,c),d},a.prototype.getSerializer=function(a){var b=va.resolve(Va);return i(b,a),b},a.prototype.ready=function(a){var b=this,c=b._driverSet.then(function(){return null===b._ready&&(b._ready=b._initDriver()),b._ready});return i(c,a,a),c},a.prototype.setDriver=function(a,b,c){function d(){g._config.driver=g.driver()}function e(a){return g._extend(a),d(),g._ready=g._initStorage(g._config),g._ready}function f(a){return function(){function b(){for(;c<a.length;){var f=a[c];return c++,g._dbInfo=null,g._ready=null,g.getDriver(f).then(e).catch(b)}d();var h=new Error("No available storage method found.");return g._driverSet=va.reject(h),g._driverSet}var c=0;return b()}}var g=this;$a(a)||(a=[a]);var h=this._getSupportedDrivers(a),j=null!==this._driverSet?this._driverSet.catch(function(){return va.resolve()}):va.resolve();return this._driverSet=j.then(function(){var a=h[0];return g._dbInfo=null,g._ready=null,g.getDriver(a).then(function(a){g._driver=a._driver,d(),g._wrapLibraryMethodsWithReady(),g._initDriver=f(h)})}).catch(function(){d();var a=new Error("No available storage method found.");return g._driverSet=va.reject(a),g._driverSet}),i(this._driverSet,b,c),this._driverSet},a.prototype.supports=function(a){return!!ab[a]},a.prototype._extend=function(a){sa(this,a)},a.prototype._getSupportedDrivers=function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];this.supports(e)&&b.push(e)}return b},a.prototype._wrapLibraryMethodsWithReady=function(){for(var a=0,b=eb.length;a<b;a++)ra(this,eb[a])},a.prototype.createInstance=function(b){return new a(b)},a}(),hb=new gb;b.exports=hb},{3:3}]},{},[4])(4)});
7 \ No newline at end of file \ No newline at end of file
public/lib/pdf.mjs+0 -9976
@@ -1,17398 +0,0 @@
1/**
2 * @licstart The following is the entire license notice for the
3 * JavaScript code in this page
4 *
5 * Copyright 2023 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * JavaScript code in this page
21 */
22
23/******/ var __webpack_modules__ = ({
24
25/***/ 640:
26/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
27
28
29// EXPORTS
30__webpack_require__.d(__webpack_exports__, {
31 AnnotationLayer: () => (/* binding */ AnnotationLayer),
32 FreeTextAnnotationElement: () => (/* binding */ FreeTextAnnotationElement),
33 InkAnnotationElement: () => (/* binding */ InkAnnotationElement),
34 StampAnnotationElement: () => (/* binding */ StampAnnotationElement)
35});
36
37// EXTERNAL MODULE: ./src/shared/util.js
38var util = __webpack_require__(266);
39// EXTERNAL MODULE: ./src/display/display_utils.js
40var display_utils = __webpack_require__(473);
41// EXTERNAL MODULE: ./src/display/annotation_storage.js
42var annotation_storage = __webpack_require__(780);
43;// CONCATENATED MODULE: ./src/shared/scripting_utils.js
44function makeColorComp(n) {
45 return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
46}
47function scaleAndClamp(x) {
48 return Math.max(0, Math.min(255, 255 * x));
49}
50class ColorConverters {
51 static CMYK_G([c, y, m, k]) {
52 return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
53 }
54 static G_CMYK([g]) {
55 return ["CMYK", 0, 0, 0, 1 - g];
56 }
57 static G_RGB([g]) {
58 return ["RGB", g, g, g];
59 }
60 static G_rgb([g]) {
61 g = scaleAndClamp(g);
62 return [g, g, g];
63 }
64 static G_HTML([g]) {
65 const G = makeColorComp(g);
66 return `#${G}${G}${G}`;
67 }
68 static RGB_G([r, g, b]) {
69 return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
70 }
71 static RGB_rgb(color) {
72 return color.map(scaleAndClamp);
73 }
74 static RGB_HTML(color) {
75 return `#${color.map(makeColorComp).join("")}`;
76 }
77 static T_HTML() {
78 return "#00000000";
79 }
80 static T_rgb() {
81 return [null];
82 }
83 static CMYK_RGB([c, y, m, k]) {
84 return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
85 }
86 static CMYK_rgb([c, y, m, k]) {
87 return [scaleAndClamp(1 - Math.min(1, c + k)), scaleAndClamp(1 - Math.min(1, m + k)), scaleAndClamp(1 - Math.min(1, y + k))];
88 }
89 static CMYK_HTML(components) {
90 const rgb = this.CMYK_RGB(components).slice(1);
91 return this.RGB_HTML(rgb);
92 }
93 static RGB_CMYK([r, g, b]) {
94 const c = 1 - r;
95 const m = 1 - g;
96 const y = 1 - b;
97 const k = Math.min(c, m, y);
98 return ["CMYK", c, m, y, k];
99 }
100}
101
102// EXTERNAL MODULE: ./src/display/xfa_layer.js
103var xfa_layer = __webpack_require__(160);
104;// CONCATENATED MODULE: ./src/display/annotation_layer.js
105
106
107
108
109
110const DEFAULT_TAB_INDEX = 1000;
111const DEFAULT_FONT_SIZE = 9;
112const GetElementsByNameSet = new WeakSet();
113function getRectDims(rect) {
114 return {
115 width: rect[2] - rect[0],
116 height: rect[3] - rect[1]
117 };
118}
119class AnnotationElementFactory {
120 static create(parameters) {
121 const subtype = parameters.data.annotationType;
122 switch (subtype) {
123 case util.AnnotationType.LINK:
124 return new LinkAnnotationElement(parameters);
125 case util.AnnotationType.TEXT:
126 return new TextAnnotationElement(parameters);
127 case util.AnnotationType.WIDGET:
128 const fieldType = parameters.data.fieldType;
129 switch (fieldType) {
130 case "Tx":
131 return new TextWidgetAnnotationElement(parameters);
132 case "Btn":
133 if (parameters.data.radioButton) {
134 return new RadioButtonWidgetAnnotationElement(parameters);
135 } else if (parameters.data.checkBox) {
136 return new CheckboxWidgetAnnotationElement(parameters);
137 }
138 return new PushButtonWidgetAnnotationElement(parameters);
139 case "Ch":
140 return new ChoiceWidgetAnnotationElement(parameters);
141 case "Sig":
142 return new SignatureWidgetAnnotationElement(parameters);
143 }
144 return new WidgetAnnotationElement(parameters);
145 case util.AnnotationType.POPUP:
146 return new PopupAnnotationElement(parameters);
147 case util.AnnotationType.FREETEXT:
148 return new FreeTextAnnotationElement(parameters);
149 case util.AnnotationType.LINE:
150 return new LineAnnotationElement(parameters);
151 case util.AnnotationType.SQUARE:
152 return new SquareAnnotationElement(parameters);
153 case util.AnnotationType.CIRCLE:
154 return new CircleAnnotationElement(parameters);
155 case util.AnnotationType.POLYLINE:
156 return new PolylineAnnotationElement(parameters);
157 case util.AnnotationType.CARET:
158 return new CaretAnnotationElement(parameters);
159 case util.AnnotationType.INK:
160 return new InkAnnotationElement(parameters);
161 case util.AnnotationType.POLYGON:
162 return new PolygonAnnotationElement(parameters);
163 case util.AnnotationType.HIGHLIGHT:
164 return new HighlightAnnotationElement(parameters);
165 case util.AnnotationType.UNDERLINE:
166 return new UnderlineAnnotationElement(parameters);
167 case util.AnnotationType.SQUIGGLY:
168 return new SquigglyAnnotationElement(parameters);
169 case util.AnnotationType.STRIKEOUT:
170 return new StrikeOutAnnotationElement(parameters);
171 case util.AnnotationType.STAMP:
172 return new StampAnnotationElement(parameters);
173 case util.AnnotationType.FILEATTACHMENT:
174 return new FileAttachmentAnnotationElement(parameters);
175 default:
176 return new AnnotationElement(parameters);
177 }
178 }
179}
180class AnnotationElement {
181 #hasBorder = false;
182 constructor(parameters, {
183 isRenderable = false,
184 ignoreBorder = false,
185 createQuadrilaterals = false
186 } = {}) {
187 this.isRenderable = isRenderable;
188 this.data = parameters.data;
189 this.layer = parameters.layer;
190 this.linkService = parameters.linkService;
191 this.downloadManager = parameters.downloadManager;
192 this.imageResourcesPath = parameters.imageResourcesPath;
193 this.renderForms = parameters.renderForms;
194 this.svgFactory = parameters.svgFactory;
195 this.annotationStorage = parameters.annotationStorage;
196 this.enableScripting = parameters.enableScripting;
197 this.hasJSActions = parameters.hasJSActions;
198 this._fieldObjects = parameters.fieldObjects;
199 this.parent = parameters.parent;
200 if (isRenderable) {
201 this.container = this._createContainer(ignoreBorder);
202 }
203 if (createQuadrilaterals) {
204 this._createQuadrilaterals();
205 }
206 }
207 static _hasPopupData({
208 titleObj,
209 contentsObj,
210 richText
211 }) {
212 return !!(titleObj?.str || contentsObj?.str || richText?.str);
213 }
214 get hasPopupData() {
215 return AnnotationElement._hasPopupData(this.data);
216 }
217 _createContainer(ignoreBorder) {
218 const {
219 data,
220 parent: {
221 page,
222 viewport
223 }
224 } = this;
225 const container = document.createElement("section");
226 container.setAttribute("data-annotation-id", data.id);
227 if (!(this instanceof WidgetAnnotationElement)) {
228 container.tabIndex = DEFAULT_TAB_INDEX;
229 }
230 container.style.zIndex = this.parent.zIndex++;
231 if (this.data.popupRef) {
232 container.setAttribute("aria-haspopup", "dialog");
233 }
234 if (data.noRotate) {
235 container.classList.add("norotate");
236 }
237 const {
238 pageWidth,
239 pageHeight,
240 pageX,
241 pageY
242 } = viewport.rawDims;
243 if (!data.rect || this instanceof PopupAnnotationElement) {
244 const {
245 rotation
246 } = data;
247 if (!data.hasOwnCanvas && rotation !== 0) {
248 this.setRotation(rotation, container);
249 }
250 return container;
251 }
252 const {
253 width,
254 height
255 } = getRectDims(data.rect);
256 const rect = util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
257 if (!ignoreBorder && data.borderStyle.width > 0) {
258 container.style.borderWidth = `${data.borderStyle.width}px`;
259 const horizontalRadius = data.borderStyle.horizontalCornerRadius;
260 const verticalRadius = data.borderStyle.verticalCornerRadius;
261 if (horizontalRadius > 0 || verticalRadius > 0) {
262 const radius = `calc(${horizontalRadius}px * var(--scale-factor)) / calc(${verticalRadius}px * var(--scale-factor))`;
263 container.style.borderRadius = radius;
264 } else if (this instanceof RadioButtonWidgetAnnotationElement) {
265 const radius = `calc(${width}px * var(--scale-factor)) / calc(${height}px * var(--scale-factor))`;
266 container.style.borderRadius = radius;
267 }
268 switch (data.borderStyle.style) {
269 case util.AnnotationBorderStyleType.SOLID:
270 container.style.borderStyle = "solid";
271 break;
272 case util.AnnotationBorderStyleType.DASHED:
273 container.style.borderStyle = "dashed";
274 break;
275 case util.AnnotationBorderStyleType.BEVELED:
276 (0,util.warn)("Unimplemented border style: beveled");
277 break;
278 case util.AnnotationBorderStyleType.INSET:
279 (0,util.warn)("Unimplemented border style: inset");
280 break;
281 case util.AnnotationBorderStyleType.UNDERLINE:
282 container.style.borderBottomStyle = "solid";
283 break;
284 default:
285 break;
286 }
287 const borderColor = data.borderColor || null;
288 if (borderColor) {
289 this.#hasBorder = true;
290 container.style.borderColor = util.Util.makeHexColor(borderColor[0] | 0, borderColor[1] | 0, borderColor[2] | 0);
291 } else {
292 container.style.borderWidth = 0;
293 }
294 }
295 container.style.left = `${100 * (rect[0] - pageX) / pageWidth}%`;
296 container.style.top = `${100 * (rect[1] - pageY) / pageHeight}%`;
297 const {
298 rotation
299 } = data;
300 if (data.hasOwnCanvas || rotation === 0) {
301 container.style.width = `${100 * width / pageWidth}%`;
302 container.style.height = `${100 * height / pageHeight}%`;
303 } else {
304 this.setRotation(rotation, container);
305 }
306 return container;
307 }
308 setRotation(angle, container = this.container) {
309 if (!this.data.rect) {
310 return;
311 }
312 const {
313 pageWidth,
314 pageHeight
315 } = this.parent.viewport.rawDims;
316 const {
317 width,
318 height
319 } = getRectDims(this.data.rect);
320 let elementWidth, elementHeight;
321 if (angle % 180 === 0) {
322 elementWidth = 100 * width / pageWidth;
323 elementHeight = 100 * height / pageHeight;
324 } else {
325 elementWidth = 100 * height / pageWidth;
326 elementHeight = 100 * width / pageHeight;
327 }
328 container.style.width = `${elementWidth}%`;
329 container.style.height = `${elementHeight}%`;
330 container.setAttribute("data-main-rotation", (360 - angle) % 360);
331 }
332 get _commonActions() {
333 const setColor = (jsName, styleName, event) => {
334 const color = event.detail[jsName];
335 const colorType = color[0];
336 const colorArray = color.slice(1);
337 event.target.style[styleName] = ColorConverters[`${colorType}_HTML`](colorArray);
338 this.annotationStorage.setValue(this.data.id, {
339 [styleName]: ColorConverters[`${colorType}_rgb`](colorArray)
340 });
341 };
342 return (0,util.shadow)(this, "_commonActions", {
343 display: event => {
344 const {
345 display
346 } = event.detail;
347 const hidden = display % 2 === 1;
348 this.container.style.visibility = hidden ? "hidden" : "visible";
349 this.annotationStorage.setValue(this.data.id, {
350 noView: hidden,
351 noPrint: display === 1 || display === 2
352 });
353 },
354 print: event => {
355 this.annotationStorage.setValue(this.data.id, {
356 noPrint: !event.detail.print
357 });
358 },
359 hidden: event => {
360 const {
361 hidden
362 } = event.detail;
363 this.container.style.visibility = hidden ? "hidden" : "visible";
364 this.annotationStorage.setValue(this.data.id, {
365 noPrint: hidden,
366 noView: hidden
367 });
368 },
369 focus: event => {
370 setTimeout(() => event.target.focus({
371 preventScroll: false
372 }), 0);
373 },
374 userName: event => {
375 event.target.title = event.detail.userName;
376 },
377 readonly: event => {
378 event.target.disabled = event.detail.readonly;
379 },
380 required: event => {
381 this._setRequired(event.target, event.detail.required);
382 },
383 bgColor: event => {
384 setColor("bgColor", "backgroundColor", event);
385 },
386 fillColor: event => {
387 setColor("fillColor", "backgroundColor", event);
388 },
389 fgColor: event => {
390 setColor("fgColor", "color", event);
391 },
392 textColor: event => {
393 setColor("textColor", "color", event);
394 },
395 borderColor: event => {
396 setColor("borderColor", "borderColor", event);
397 },
398 strokeColor: event => {
399 setColor("strokeColor", "borderColor", event);
400 },
401 rotation: event => {
402 const angle = event.detail.rotation;
403 this.setRotation(angle);
404 this.annotationStorage.setValue(this.data.id, {
405 rotation: angle
406 });
407 }
408 });
409 }
410 _dispatchEventFromSandbox(actions, jsEvent) {
411 const commonActions = this._commonActions;
412 for (const name of Object.keys(jsEvent.detail)) {
413 const action = actions[name] || commonActions[name];
414 action?.(jsEvent);
415 }
416 }
417 _setDefaultPropertiesFromJS(element) {
418 if (!this.enableScripting) {
419 return;
420 }
421 const storedData = this.annotationStorage.getRawValue(this.data.id);
422 if (!storedData) {
423 return;
424 }
425 const commonActions = this._commonActions;
426 for (const [actionName, detail] of Object.entries(storedData)) {
427 const action = commonActions[actionName];
428 if (action) {
429 const eventProxy = {
430 detail: {
431 [actionName]: detail
432 },
433 target: element
434 };
435 action(eventProxy);
436 delete storedData[actionName];
437 }
438 }
439 }
440 _createQuadrilaterals() {
441 if (!this.container) {
442 return;
443 }
444 const {
445 quadPoints
446 } = this.data;
447 if (!quadPoints) {
448 return;
449 }
450 const [rectBlX, rectBlY, rectTrX, rectTrY] = this.data.rect;
451 if (quadPoints.length === 1) {
452 const [, {
453 x: trX,
454 y: trY
455 }, {
456 x: blX,
457 y: blY
458 }] = quadPoints[0];
459 if (rectTrX === trX && rectTrY === trY && rectBlX === blX && rectBlY === blY) {
460 return;
461 }
462 }
463 const {
464 style
465 } = this.container;
466 let svgBuffer;
467 if (this.#hasBorder) {
468 const {
469 borderColor,
470 borderWidth
471 } = style;
472 style.borderWidth = 0;
473 svgBuffer = ["url('data:image/svg+xml;utf8,", `<svg xmlns="http://www.w3.org/2000/svg"`, ` preserveAspectRatio="none" viewBox="0 0 1 1">`, `<g fill="transparent" stroke="${borderColor}" stroke-width="${borderWidth}">`];
474 this.container.classList.add("hasBorder");
475 }
476 const width = rectTrX - rectBlX;
477 const height = rectTrY - rectBlY;
478 const {
479 svgFactory
480 } = this;
481 const svg = svgFactory.createElement("svg");
482 svg.classList.add("quadrilateralsContainer");
483 svg.setAttribute("width", 0);
484 svg.setAttribute("height", 0);
485 const defs = svgFactory.createElement("defs");
486 svg.append(defs);
487 const clipPath = svgFactory.createElement("clipPath");
488 const id = `clippath_${this.data.id}`;
489 clipPath.setAttribute("id", id);
490 clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
491 defs.append(clipPath);
492 for (const [, {
493 x: trX,
494 y: trY
495 }, {
496 x: blX,
497 y: blY
498 }] of quadPoints) {
499 const rect = svgFactory.createElement("rect");
500 const x = (blX - rectBlX) / width;
501 const y = (rectTrY - trY) / height;
502 const rectWidth = (trX - blX) / width;
503 const rectHeight = (trY - blY) / height;
504 rect.setAttribute("x", x);
505 rect.setAttribute("y", y);
506 rect.setAttribute("width", rectWidth);
507 rect.setAttribute("height", rectHeight);
508 clipPath.append(rect);
509 svgBuffer?.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${y}" width="${rectWidth}" height="${rectHeight}"/>`);
510 }
511 if (this.#hasBorder) {
512 svgBuffer.push(`</g></svg>')`);
513 style.backgroundImage = svgBuffer.join("");
514 }
515 this.container.append(svg);
516 this.container.style.clipPath = `url(#${id})`;
517 }
518 _createPopup() {
519 const {
520 container,
521 data
522 } = this;
523 container.setAttribute("aria-haspopup", "dialog");
524 const popup = new PopupAnnotationElement({
525 data: {
526 color: data.color,
527 titleObj: data.titleObj,
528 modificationDate: data.modificationDate,
529 contentsObj: data.contentsObj,
530 richText: data.richText,
531 parentRect: data.rect,
532 borderStyle: 0,
533 id: `popup_${data.id}`,
534 rotation: data.rotation
535 },
536 parent: this.parent,
537 elements: [this]
538 });
539 this.parent.div.append(popup.render());
540 }
541 render() {
542 (0,util.unreachable)("Abstract method `AnnotationElement.render` called");
543 }
544 _getElementsByName(name, skipId = null) {
545 const fields = [];
546 if (this._fieldObjects) {
547 const fieldObj = this._fieldObjects[name];
548 if (fieldObj) {
549 for (const {
550 page,
551 id,
552 exportValues
553 } of fieldObj) {
554 if (page === -1) {
555 continue;
556 }
557 if (id === skipId) {
558 continue;
559 }
560 const exportValue = typeof exportValues === "string" ? exportValues : null;
561 const domElement = document.querySelector(`[data-element-id="${id}"]`);
562 if (domElement && !GetElementsByNameSet.has(domElement)) {
563 (0,util.warn)(`_getElementsByName - element not allowed: ${id}`);
564 continue;
565 }
566 fields.push({
567 id,
568 exportValue,
569 domElement
570 });
571 }
572 }
573 return fields;
574 }
575 for (const domElement of document.getElementsByName(name)) {
576 const {
577 exportValue
578 } = domElement;
579 const id = domElement.getAttribute("data-element-id");
580 if (id === skipId) {
581 continue;
582 }
583 if (!GetElementsByNameSet.has(domElement)) {
584 continue;
585 }
586 fields.push({
587 id,
588 exportValue,
589 domElement
590 });
591 }
592 return fields;
593 }
594 show() {
595 if (this.container) {
596 this.container.hidden = false;
597 }
598 this.popup?.maybeShow();
599 }
600 hide() {
601 if (this.container) {
602 this.container.hidden = true;
603 }
604 this.popup?.forceHide();
605 }
606 getElementsToTriggerPopup() {
607 return this.container;
608 }
609 addHighlightArea() {
610 const triggers = this.getElementsToTriggerPopup();
611 if (Array.isArray(triggers)) {
612 for (const element of triggers) {
613 element.classList.add("highlightArea");
614 }
615 } else {
616 triggers.classList.add("highlightArea");
617 }
618 }
619 get _isEditable() {
620 return false;
621 }
622 _editOnDoubleClick() {
623 if (!this._isEditable) {
624 return;
625 }
626 const {
627 annotationEditorType: mode,
628 data: {
629 id: editId
630 }
631 } = this;
632 this.container.addEventListener("dblclick", () => {
633 this.linkService.eventBus?.dispatch("switchannotationeditormode", {
634 source: this,
635 mode,
636 editId
637 });
638 });
639 }
640}
641class LinkAnnotationElement extends AnnotationElement {
642 constructor(parameters, options = null) {
643 super(parameters, {
644 isRenderable: true,
645 ignoreBorder: !!options?.ignoreBorder,
646 createQuadrilaterals: true
647 });
648 this.isTooltipOnly = parameters.data.isTooltipOnly;
649 }
650 render() {
651 const {
652 data,
653 linkService
654 } = this;
655 const link = document.createElement("a");
656 link.setAttribute("data-element-id", data.id);
657 let isBound = false;
658 if (data.url) {
659 linkService.addLinkAttributes(link, data.url, data.newWindow);
660 isBound = true;
661 } else if (data.action) {
662 this._bindNamedAction(link, data.action);
663 isBound = true;
664 } else if (data.attachment) {
665 this.#bindAttachment(link, data.attachment, data.attachmentDest);
666 isBound = true;
667 } else if (data.setOCGState) {
668 this.#bindSetOCGState(link, data.setOCGState);
669 isBound = true;
670 } else if (data.dest) {
671 this._bindLink(link, data.dest);
672 isBound = true;
673 } else {
674 if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
675 this._bindJSAction(link, data);
676 isBound = true;
677 }
678 if (data.resetForm) {
679 this._bindResetFormAction(link, data.resetForm);
680 isBound = true;
681 } else if (this.isTooltipOnly && !isBound) {
682 this._bindLink(link, "");
683 isBound = true;
684 }
685 }
686 this.container.classList.add("linkAnnotation");
687 if (isBound) {
688 this.container.append(link);
689 }
690 return this.container;
691 }
692 #setInternalLink() {
693 this.container.setAttribute("data-internal-link", "");
694 }
695 _bindLink(link, destination) {
696 link.href = this.linkService.getDestinationHash(destination);
697 link.onclick = () => {
698 if (destination) {
699 this.linkService.goToDestination(destination);
700 }
701 return false;
702 };
703 if (destination || destination === "") {
704 this.#setInternalLink();
705 }
706 }
707 _bindNamedAction(link, action) {
708 link.href = this.linkService.getAnchorUrl("");
709 link.onclick = () => {
710 this.linkService.executeNamedAction(action);
711 return false;
712 };
713 this.#setInternalLink();
714 }
715 #bindAttachment(link, attachment, dest = null) {
716 link.href = this.linkService.getAnchorUrl("");
717 link.onclick = () => {
718 this.downloadManager?.openOrDownloadData(attachment.content, attachment.filename, dest);
719 return false;
720 };
721 this.#setInternalLink();
722 }
723 #bindSetOCGState(link, action) {
724 link.href = this.linkService.getAnchorUrl("");
725 link.onclick = () => {
726 this.linkService.executeSetOCGState(action);
727 return false;
728 };
729 this.#setInternalLink();
730 }
731 _bindJSAction(link, data) {
732 link.href = this.linkService.getAnchorUrl("");
733 const map = new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]);
734 for (const name of Object.keys(data.actions)) {
735 const jsName = map.get(name);
736 if (!jsName) {
737 continue;
738 }
739 link[jsName] = () => {
740 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
741 source: this,
742 detail: {
743 id: data.id,
744 name
745 }
746 });
747 return false;
748 };
749 }
750 if (!link.onclick) {
751 link.onclick = () => false;
752 }
753 this.#setInternalLink();
754 }
755 _bindResetFormAction(link, resetForm) {
756 const otherClickAction = link.onclick;
757 if (!otherClickAction) {
758 link.href = this.linkService.getAnchorUrl("");
759 }
760 this.#setInternalLink();
761 if (!this._fieldObjects) {
762 (0,util.warn)(`_bindResetFormAction - "resetForm" action not supported, ` + "ensure that the `fieldObjects` parameter is provided.");
763 if (!otherClickAction) {
764 link.onclick = () => false;
765 }
766 return;
767 }
768 link.onclick = () => {
769 otherClickAction?.();
770 const {
771 fields: resetFormFields,
772 refs: resetFormRefs,
773 include
774 } = resetForm;
775 const allFields = [];
776 if (resetFormFields.length !== 0 || resetFormRefs.length !== 0) {
777 const fieldIds = new Set(resetFormRefs);
778 for (const fieldName of resetFormFields) {
779 const fields = this._fieldObjects[fieldName] || [];
780 for (const {
781 id
782 } of fields) {
783 fieldIds.add(id);
784 }
785 }
786 for (const fields of Object.values(this._fieldObjects)) {
787 for (const field of fields) {
788 if (fieldIds.has(field.id) === include) {
789 allFields.push(field);
790 }
791 }
792 }
793 } else {
794 for (const fields of Object.values(this._fieldObjects)) {
795 allFields.push(...fields);
796 }
797 }
798 const storage = this.annotationStorage;
799 const allIds = [];
800 for (const field of allFields) {
801 const {
802 id
803 } = field;
804 allIds.push(id);
805 switch (field.type) {
806 case "text":
807 {
808 const value = field.defaultValue || "";
809 storage.setValue(id, {
810 value
811 });
812 break;
813 }
814 case "checkbox":
815 case "radiobutton":
816 {
817 const value = field.defaultValue === field.exportValues;
818 storage.setValue(id, {
819 value
820 });
821 break;
822 }
823 case "combobox":
824 case "listbox":
825 {
826 const value = field.defaultValue || "";
827 storage.setValue(id, {
828 value
829 });
830 break;
831 }
832 default:
833 continue;
834 }
835 const domElement = document.querySelector(`[data-element-id="${id}"]`);
836 if (!domElement) {
837 continue;
838 } else if (!GetElementsByNameSet.has(domElement)) {
839 (0,util.warn)(`_bindResetFormAction - element not allowed: ${id}`);
840 continue;
841 }
842 domElement.dispatchEvent(new Event("resetform"));
843 }
844 if (this.enableScripting) {
845 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
846 source: this,
847 detail: {
848 id: "app",
849 ids: allIds,
850 name: "ResetForm"
851 }
852 });
853 }
854 return false;
855 };
856 }
857}
858class TextAnnotationElement extends AnnotationElement {
859 constructor(parameters) {
860 super(parameters, {
861 isRenderable: true
862 });
863 }
864 render() {
865 this.container.classList.add("textAnnotation");
866 const image = document.createElement("img");
867 image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
868 image.setAttribute("data-l10n-id", "pdfjs-text-annotation-type");
869 image.setAttribute("data-l10n-args", JSON.stringify({
870 type: this.data.name
871 }));
872 if (!this.data.popupRef && this.hasPopupData) {
873 this._createPopup();
874 }
875 this.container.append(image);
876 return this.container;
877 }
878}
879class WidgetAnnotationElement extends AnnotationElement {
880 render() {
881 if (this.data.alternativeText) {
882 this.container.title = this.data.alternativeText;
883 }
884 return this.container;
885 }
886 showElementAndHideCanvas(element) {
887 if (this.data.hasOwnCanvas) {
888 if (element.previousSibling?.nodeName === "CANVAS") {
889 element.previousSibling.hidden = true;
890 }
891 element.hidden = false;
892 }
893 }
894 _getKeyModifier(event) {
895 return util.FeatureTest.platform.isMac ? event.metaKey : event.ctrlKey;
896 }
897 _setEventListener(element, elementData, baseName, eventName, valueGetter) {
898 if (baseName.includes("mouse")) {
899 element.addEventListener(baseName, event => {
900 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
901 source: this,
902 detail: {
903 id: this.data.id,
904 name: eventName,
905 value: valueGetter(event),
906 shift: event.shiftKey,
907 modifier: this._getKeyModifier(event)
908 }
909 });
910 });
911 } else {
912 element.addEventListener(baseName, event => {
913 if (baseName === "blur") {
914 if (!elementData.focused || !event.relatedTarget) {
915 return;
916 }
917 elementData.focused = false;
918 } else if (baseName === "focus") {
919 if (elementData.focused) {
920 return;
921 }
922 elementData.focused = true;
923 }
924 if (!valueGetter) {
925 return;
926 }
927 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
928 source: this,
929 detail: {
930 id: this.data.id,
931 name: eventName,
932 value: valueGetter(event)
933 }
934 });
935 });
936 }
937 }
938 _setEventListeners(element, elementData, names, getter) {
939 for (const [baseName, eventName] of names) {
940 if (eventName === "Action" || this.data.actions?.[eventName]) {
941 if (eventName === "Focus" || eventName === "Blur") {
942 elementData ||= {
943 focused: false
944 };
945 }
946 this._setEventListener(element, elementData, baseName, eventName, getter);
947 if (eventName === "Focus" && !this.data.actions?.Blur) {
948 this._setEventListener(element, elementData, "blur", "Blur", null);
949 } else if (eventName === "Blur" && !this.data.actions?.Focus) {
950 this._setEventListener(element, elementData, "focus", "Focus", null);
951 }
952 }
953 }
954 }
955 _setBackgroundColor(element) {
956 const color = this.data.backgroundColor || null;
957 element.style.backgroundColor = color === null ? "transparent" : util.Util.makeHexColor(color[0], color[1], color[2]);
958 }
959 _setTextStyle(element) {
960 const TEXT_ALIGNMENT = ["left", "center", "right"];
961 const {
962 fontColor
963 } = this.data.defaultAppearanceData;
964 const fontSize = this.data.defaultAppearanceData.fontSize || DEFAULT_FONT_SIZE;
965 const style = element.style;
966 let computedFontSize;
967 const BORDER_SIZE = 2;
968 const roundToOneDecimal = x => Math.round(10 * x) / 10;
969 if (this.data.multiLine) {
970 const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
971 const numberOfLines = Math.round(height / (util.LINE_FACTOR * fontSize)) || 1;
972 const lineHeight = height / numberOfLines;
973 computedFontSize = Math.min(fontSize, roundToOneDecimal(lineHeight / util.LINE_FACTOR));
974 } else {
975 const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
976 computedFontSize = Math.min(fontSize, roundToOneDecimal(height / util.LINE_FACTOR));
977 }
978 style.fontSize = `calc(${computedFontSize}px * var(--scale-factor))`;
979 style.color = util.Util.makeHexColor(fontColor[0], fontColor[1], fontColor[2]);
980 if (this.data.textAlignment !== null) {
981 style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
982 }
983 }
984 _setRequired(element, isRequired) {
985 if (isRequired) {
986 element.setAttribute("required", true);
987 } else {
988 element.removeAttribute("required");
989 }
990 element.setAttribute("aria-required", isRequired);
991 }
992}
993class TextWidgetAnnotationElement extends WidgetAnnotationElement {
994 constructor(parameters) {
995 const isRenderable = parameters.renderForms || parameters.data.hasOwnCanvas || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
996 super(parameters, {
997 isRenderable
998 });
999 }
1000 setPropertyOnSiblings(base, key, value, keyInStorage) {
1001 const storage = this.annotationStorage;
1002 for (const element of this._getElementsByName(base.name, base.id)) {
1003 if (element.domElement) {
1004 element.domElement[key] = value;
1005 }
1006 storage.setValue(element.id, {
1007 [keyInStorage]: value
1008 });
1009 }
1010 }
1011 render() {
1012 const storage = this.annotationStorage;
1013 const id = this.data.id;
1014 this.container.classList.add("textWidgetAnnotation");
1015 let element = null;
1016 if (this.renderForms) {
1017 const storedData = storage.getValue(id, {
1018 value: this.data.fieldValue
1019 });
1020 let textContent = storedData.value || "";
1021 const maxLen = storage.getValue(id, {
1022 charLimit: this.data.maxLen
1023 }).charLimit;
1024 if (maxLen && textContent.length > maxLen) {
1025 textContent = textContent.slice(0, maxLen);
1026 }
1027 let fieldFormattedValues = storedData.formattedValue || this.data.textContent?.join("\n") || null;
1028 if (fieldFormattedValues && this.data.comb) {
1029 fieldFormattedValues = fieldFormattedValues.replaceAll(/\s+/g, "");
1030 }
1031 const elementData = {
1032 userValue: textContent,
1033 formattedValue: fieldFormattedValues,
1034 lastCommittedValue: null,
1035 commitKey: 1,
1036 focused: false
1037 };
1038 if (this.data.multiLine) {
1039 element = document.createElement("textarea");
1040 element.textContent = fieldFormattedValues ?? textContent;
1041 if (this.data.doNotScroll) {
1042 element.style.overflowY = "hidden";
1043 }
1044 } else {
1045 element = document.createElement("input");
1046 element.type = "text";
1047 element.setAttribute("value", fieldFormattedValues ?? textContent);
1048 if (this.data.doNotScroll) {
1049 element.style.overflowX = "hidden";
1050 }
1051 }
1052 if (this.data.hasOwnCanvas) {
1053 element.hidden = true;
1054 }
1055 GetElementsByNameSet.add(element);
1056 element.setAttribute("data-element-id", id);
1057 element.disabled = this.data.readOnly;
1058 element.name = this.data.fieldName;
1059 element.tabIndex = DEFAULT_TAB_INDEX;
1060 this._setRequired(element, this.data.required);
1061 if (maxLen) {
1062 element.maxLength = maxLen;
1063 }
1064 element.addEventListener("input", event => {
1065 storage.setValue(id, {
1066 value: event.target.value
1067 });
1068 this.setPropertyOnSiblings(element, "value", event.target.value, "value");
1069 elementData.formattedValue = null;
1070 });
1071 element.addEventListener("resetform", event => {
1072 const defaultValue = this.data.defaultFieldValue ?? "";
1073 element.value = elementData.userValue = defaultValue;
1074 elementData.formattedValue = null;
1075 });
1076 let blurListener = event => {
1077 const {
1078 formattedValue
1079 } = elementData;
1080 if (formattedValue !== null && formattedValue !== undefined) {
1081 event.target.value = formattedValue;
1082 }
1083 event.target.scrollLeft = 0;
1084 };
1085 if (this.enableScripting && this.hasJSActions) {
1086 element.addEventListener("focus", event => {
1087 if (elementData.focused) {
1088 return;
1089 }
1090 const {
1091 target
1092 } = event;
1093 if (elementData.userValue) {
1094 target.value = elementData.userValue;
1095 }
1096 elementData.lastCommittedValue = target.value;
1097 elementData.commitKey = 1;
1098 if (!this.data.actions?.Focus) {
1099 elementData.focused = true;
1100 }
1101 });
1102 element.addEventListener("updatefromsandbox", jsEvent => {
1103 this.showElementAndHideCanvas(jsEvent.target);
1104 const actions = {
1105 value(event) {
1106 elementData.userValue = event.detail.value ?? "";
1107 storage.setValue(id, {
1108 value: elementData.userValue.toString()
1109 });
1110 event.target.value = elementData.userValue;
1111 },
1112 formattedValue(event) {
1113 const {
1114 formattedValue
1115 } = event.detail;
1116 elementData.formattedValue = formattedValue;
1117 if (formattedValue !== null && formattedValue !== undefined && event.target !== document.activeElement) {
1118 event.target.value = formattedValue;
1119 }
1120 storage.setValue(id, {
1121 formattedValue
1122 });
1123 },
1124 selRange(event) {
1125 event.target.setSelectionRange(...event.detail.selRange);
1126 },
1127 charLimit: event => {
1128 const {
1129 charLimit
1130 } = event.detail;
1131 const {
1132 target
1133 } = event;
1134 if (charLimit === 0) {
1135 target.removeAttribute("maxLength");
1136 return;
1137 }
1138 target.setAttribute("maxLength", charLimit);
1139 let value = elementData.userValue;
1140 if (!value || value.length <= charLimit) {
1141 return;
1142 }
1143 value = value.slice(0, charLimit);
1144 target.value = elementData.userValue = value;
1145 storage.setValue(id, {
1146 value
1147 });
1148 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
1149 source: this,
1150 detail: {
1151 id,
1152 name: "Keystroke",
1153 value,
1154 willCommit: true,
1155 commitKey: 1,
1156 selStart: target.selectionStart,
1157 selEnd: target.selectionEnd
1158 }
1159 });
1160 }
1161 };
1162 this._dispatchEventFromSandbox(actions, jsEvent);
1163 });
1164 element.addEventListener("keydown", event => {
1165 elementData.commitKey = 1;
1166 let commitKey = -1;
1167 if (event.key === "Escape") {
1168 commitKey = 0;
1169 } else if (event.key === "Enter" && !this.data.multiLine) {
1170 commitKey = 2;
1171 } else if (event.key === "Tab") {
1172 elementData.commitKey = 3;
1173 }
1174 if (commitKey === -1) {
1175 return;
1176 }
1177 const {
1178 value
1179 } = event.target;
1180 if (elementData.lastCommittedValue === value) {
1181 return;
1182 }
1183 elementData.lastCommittedValue = value;
1184 elementData.userValue = value;
1185 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
1186 source: this,
1187 detail: {
1188 id,
1189 name: "Keystroke",
1190 value,
1191 willCommit: true,
1192 commitKey,
1193 selStart: event.target.selectionStart,
1194 selEnd: event.target.selectionEnd
1195 }
1196 });
1197 });
1198 const _blurListener = blurListener;
1199 blurListener = null;
1200 element.addEventListener("blur", event => {
1201 if (!elementData.focused || !event.relatedTarget) {
1202 return;
1203 }
1204 if (!this.data.actions?.Blur) {
1205 elementData.focused = false;
1206 }
1207 const {
1208 value
1209 } = event.target;
1210 elementData.userValue = value;
1211 if (elementData.lastCommittedValue !== value) {
1212 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
1213 source: this,
1214 detail: {
1215 id,
1216 name: "Keystroke",
1217 value,
1218 willCommit: true,
1219 commitKey: elementData.commitKey,
1220 selStart: event.target.selectionStart,
1221 selEnd: event.target.selectionEnd
1222 }
1223 });
1224 }
1225 _blurListener(event);
1226 });
1227 if (this.data.actions?.Keystroke) {
1228 element.addEventListener("beforeinput", event => {
1229 elementData.lastCommittedValue = null;
1230 const {
1231 data,
1232 target
1233 } = event;
1234 const {
1235 value,
1236 selectionStart,
1237 selectionEnd
1238 } = target;
1239 let selStart = selectionStart,
1240 selEnd = selectionEnd;
1241 switch (event.inputType) {
1242 case "deleteWordBackward":
1243 {
1244 const match = value.substring(0, selectionStart).match(/\w*[^\w]*$/);
1245 if (match) {
1246 selStart -= match[0].length;
1247 }
1248 break;
1249 }
1250 case "deleteWordForward":
1251 {
1252 const match = value.substring(selectionStart).match(/^[^\w]*\w*/);
1253 if (match) {
1254 selEnd += match[0].length;
1255 }
1256 break;
1257 }
1258 case "deleteContentBackward":
1259 if (selectionStart === selectionEnd) {
1260 selStart -= 1;
1261 }
1262 break;
1263 case "deleteContentForward":
1264 if (selectionStart === selectionEnd) {
1265 selEnd += 1;
1266 }
1267 break;
1268 }
1269 event.preventDefault();
1270 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
1271 source: this,
1272 detail: {
1273 id,
1274 name: "Keystroke",
1275 value,
1276 change: data || "",
1277 willCommit: false,
1278 selStart,
1279 selEnd
1280 }
1281 });
1282 });
1283 }
1284 this._setEventListeners(element, elementData, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.value);
1285 }
1286 if (blurListener) {
1287 element.addEventListener("blur", blurListener);
1288 }
1289 if (this.data.comb) {
1290 const fieldWidth = this.data.rect[2] - this.data.rect[0];
1291 const combWidth = fieldWidth / maxLen;
1292 element.classList.add("comb");
1293 element.style.letterSpacing = `calc(${combWidth}px * var(--scale-factor) - 1ch)`;
1294 }
1295 } else {
1296 element = document.createElement("div");
1297 element.textContent = this.data.fieldValue;
1298 element.style.verticalAlign = "middle";
1299 element.style.display = "table-cell";
1300 if (this.data.hasOwnCanvas) {
1301 element.hidden = true;
1302 }
1303 }
1304 this._setTextStyle(element);
1305 this._setBackgroundColor(element);
1306 this._setDefaultPropertiesFromJS(element);
1307 this.container.append(element);
1308 return this.container;
1309 }
1310}
1311class SignatureWidgetAnnotationElement extends WidgetAnnotationElement {
1312 constructor(parameters) {
1313 super(parameters, {
1314 isRenderable: !!parameters.data.hasOwnCanvas
1315 });
1316 }
1317}
1318class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
1319 constructor(parameters) {
1320 super(parameters, {
1321 isRenderable: parameters.renderForms
1322 });
1323 }
1324 render() {
1325 const storage = this.annotationStorage;
1326 const data = this.data;
1327 const id = data.id;
1328 let value = storage.getValue(id, {
1329 value: data.exportValue === data.fieldValue
1330 }).value;
1331 if (typeof value === "string") {
1332 value = value !== "Off";
1333 storage.setValue(id, {
1334 value
1335 });
1336 }
1337 this.container.classList.add("buttonWidgetAnnotation", "checkBox");
1338 const element = document.createElement("input");
1339 GetElementsByNameSet.add(element);
1340 element.setAttribute("data-element-id", id);
1341 element.disabled = data.readOnly;
1342 this._setRequired(element, this.data.required);
1343 element.type = "checkbox";
1344 element.name = data.fieldName;
1345 if (value) {
1346 element.setAttribute("checked", true);
1347 }
1348 element.setAttribute("exportValue", data.exportValue);
1349 element.tabIndex = DEFAULT_TAB_INDEX;
1350 element.addEventListener("change", event => {
1351 const {
1352 name,
1353 checked
1354 } = event.target;
1355 for (const checkbox of this._getElementsByName(name, id)) {
1356 const curChecked = checked && checkbox.exportValue === data.exportValue;
1357 if (checkbox.domElement) {
1358 checkbox.domElement.checked = curChecked;
1359 }
1360 storage.setValue(checkbox.id, {
1361 value: curChecked
1362 });
1363 }
1364 storage.setValue(id, {
1365 value: checked
1366 });
1367 });
1368 element.addEventListener("resetform", event => {
1369 const defaultValue = data.defaultFieldValue || "Off";
1370 event.target.checked = defaultValue === data.exportValue;
1371 });
1372 if (this.enableScripting && this.hasJSActions) {
1373 element.addEventListener("updatefromsandbox", jsEvent => {
1374 const actions = {
1375 value(event) {
1376 event.target.checked = event.detail.value !== "Off";
1377 storage.setValue(id, {
1378 value: event.target.checked
1379 });
1380 }
1381 };
1382 this._dispatchEventFromSandbox(actions, jsEvent);
1383 });
1384 this._setEventListeners(element, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
1385 }
1386 this._setBackgroundColor(element);
1387 this._setDefaultPropertiesFromJS(element);
1388 this.container.append(element);
1389 return this.container;
1390 }
1391}
1392class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
1393 constructor(parameters) {
1394 super(parameters, {
1395 isRenderable: parameters.renderForms
1396 });
1397 }
1398 render() {
1399 this.container.classList.add("buttonWidgetAnnotation", "radioButton");
1400 const storage = this.annotationStorage;
1401 const data = this.data;
1402 const id = data.id;
1403 let value = storage.getValue(id, {
1404 value: data.fieldValue === data.buttonValue
1405 }).value;
1406 if (typeof value === "string") {
1407 value = value !== data.buttonValue;
1408 storage.setValue(id, {
1409 value
1410 });
1411 }
1412 if (value) {
1413 for (const radio of this._getElementsByName(data.fieldName, id)) {
1414 storage.setValue(radio.id, {
1415 value: false
1416 });
1417 }
1418 }
1419 const element = document.createElement("input");
1420 GetElementsByNameSet.add(element);
1421 element.setAttribute("data-element-id", id);
1422 element.disabled = data.readOnly;
1423 this._setRequired(element, this.data.required);
1424 element.type = "radio";
1425 element.name = data.fieldName;
1426 if (value) {
1427 element.setAttribute("checked", true);
1428 }
1429 element.tabIndex = DEFAULT_TAB_INDEX;
1430 element.addEventListener("change", event => {
1431 const {
1432 name,
1433 checked
1434 } = event.target;
1435 for (const radio of this._getElementsByName(name, id)) {
1436 storage.setValue(radio.id, {
1437 value: false
1438 });
1439 }
1440 storage.setValue(id, {
1441 value: checked
1442 });
1443 });
1444 element.addEventListener("resetform", event => {
1445 const defaultValue = data.defaultFieldValue;
1446 event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
1447 });
1448 if (this.enableScripting && this.hasJSActions) {
1449 const pdfButtonValue = data.buttonValue;
1450 element.addEventListener("updatefromsandbox", jsEvent => {
1451 const actions = {
1452 value: event => {
1453 const checked = pdfButtonValue === event.detail.value;
1454 for (const radio of this._getElementsByName(event.target.name)) {
1455 const curChecked = checked && radio.id === id;
1456 if (radio.domElement) {
1457 radio.domElement.checked = curChecked;
1458 }
1459 storage.setValue(radio.id, {
1460 value: curChecked
1461 });
1462 }
1463 }
1464 };
1465 this._dispatchEventFromSandbox(actions, jsEvent);
1466 });
1467 this._setEventListeners(element, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
1468 }
1469 this._setBackgroundColor(element);
1470 this._setDefaultPropertiesFromJS(element);
1471 this.container.append(element);
1472 return this.container;
1473 }
1474}
1475class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
1476 constructor(parameters) {
1477 super(parameters, {
1478 ignoreBorder: parameters.data.hasAppearance
1479 });
1480 }
1481 render() {
1482 const container = super.render();
1483 container.classList.add("buttonWidgetAnnotation", "pushButton");
1484 if (this.data.alternativeText) {
1485 container.title = this.data.alternativeText;
1486 }
1487 const linkElement = container.lastChild;
1488 if (this.enableScripting && this.hasJSActions && linkElement) {
1489 this._setDefaultPropertiesFromJS(linkElement);
1490 linkElement.addEventListener("updatefromsandbox", jsEvent => {
1491 this._dispatchEventFromSandbox({}, jsEvent);
1492 });
1493 }
1494 return container;
1495 }
1496}
1497class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
1498 constructor(parameters) {
1499 super(parameters, {
1500 isRenderable: parameters.renderForms
1501 });
1502 }
1503 render() {
1504 this.container.classList.add("choiceWidgetAnnotation");
1505 const storage = this.annotationStorage;
1506 const id = this.data.id;
1507 const storedData = storage.getValue(id, {
1508 value: this.data.fieldValue
1509 });
1510 const selectElement = document.createElement("select");
1511 GetElementsByNameSet.add(selectElement);
1512 selectElement.setAttribute("data-element-id", id);
1513 selectElement.disabled = this.data.readOnly;
1514 this._setRequired(selectElement, this.data.required);
1515 selectElement.name = this.data.fieldName;
1516 selectElement.tabIndex = DEFAULT_TAB_INDEX;
1517 let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;
1518 if (!this.data.combo) {
1519 selectElement.size = this.data.options.length;
1520 if (this.data.multiSelect) {
1521 selectElement.multiple = true;
1522 }
1523 }
1524 selectElement.addEventListener("resetform", event => {
1525 const defaultValue = this.data.defaultFieldValue;
1526 for (const option of selectElement.options) {
1527 option.selected = option.value === defaultValue;
1528 }
1529 });
1530 for (const option of this.data.options) {
1531 const optionElement = document.createElement("option");
1532 optionElement.textContent = option.displayValue;
1533 optionElement.value = option.exportValue;
1534 if (storedData.value.includes(option.exportValue)) {
1535 optionElement.setAttribute("selected", true);
1536 addAnEmptyEntry = false;
1537 }
1538 selectElement.append(optionElement);
1539 }
1540 let removeEmptyEntry = null;
1541 if (addAnEmptyEntry) {
1542 const noneOptionElement = document.createElement("option");
1543 noneOptionElement.value = " ";
1544 noneOptionElement.setAttribute("hidden", true);
1545 noneOptionElement.setAttribute("selected", true);
1546 selectElement.prepend(noneOptionElement);
1547 removeEmptyEntry = () => {
1548 noneOptionElement.remove();
1549 selectElement.removeEventListener("input", removeEmptyEntry);
1550 removeEmptyEntry = null;
1551 };
1552 selectElement.addEventListener("input", removeEmptyEntry);
1553 }
1554 const getValue = isExport => {
1555 const name = isExport ? "value" : "textContent";
1556 const {
1557 options,
1558 multiple
1559 } = selectElement;
1560 if (!multiple) {
1561 return options.selectedIndex === -1 ? null : options[options.selectedIndex][name];
1562 }
1563 return Array.prototype.filter.call(options, option => option.selected).map(option => option[name]);
1564 };
1565 let selectedValues = getValue(false);
1566 const getItems = event => {
1567 const options = event.target.options;
1568 return Array.prototype.map.call(options, option => {
1569 return {
1570 displayValue: option.textContent,
1571 exportValue: option.value
1572 };
1573 });
1574 };
1575 if (this.enableScripting && this.hasJSActions) {
1576 selectElement.addEventListener("updatefromsandbox", jsEvent => {
1577 const actions = {
1578 value(event) {
1579 removeEmptyEntry?.();
1580 const value = event.detail.value;
1581 const values = new Set(Array.isArray(value) ? value : [value]);
1582 for (const option of selectElement.options) {
1583 option.selected = values.has(option.value);
1584 }
1585 storage.setValue(id, {
1586 value: getValue(true)
1587 });
1588 selectedValues = getValue(false);
1589 },
1590 multipleSelection(event) {
1591 selectElement.multiple = true;
1592 },
1593 remove(event) {
1594 const options = selectElement.options;
1595 const index = event.detail.remove;
1596 options[index].selected = false;
1597 selectElement.remove(index);
1598 if (options.length > 0) {
1599 const i = Array.prototype.findIndex.call(options, option => option.selected);
1600 if (i === -1) {
1601 options[0].selected = true;
1602 }
1603 }
1604 storage.setValue(id, {
1605 value: getValue(true),
1606 items: getItems(event)
1607 });
1608 selectedValues = getValue(false);
1609 },
1610 clear(event) {
1611 while (selectElement.length !== 0) {
1612 selectElement.remove(0);
1613 }
1614 storage.setValue(id, {
1615 value: null,
1616 items: []
1617 });
1618 selectedValues = getValue(false);
1619 },
1620 insert(event) {
1621 const {
1622 index,
1623 displayValue,
1624 exportValue
1625 } = event.detail.insert;
1626 const selectChild = selectElement.children[index];
1627 const optionElement = document.createElement("option");
1628 optionElement.textContent = displayValue;
1629 optionElement.value = exportValue;
1630 if (selectChild) {
1631 selectChild.before(optionElement);
1632 } else {
1633 selectElement.append(optionElement);
1634 }
1635 storage.setValue(id, {
1636 value: getValue(true),
1637 items: getItems(event)
1638 });
1639 selectedValues = getValue(false);
1640 },
1641 items(event) {
1642 const {
1643 items
1644 } = event.detail;
1645 while (selectElement.length !== 0) {
1646 selectElement.remove(0);
1647 }
1648 for (const item of items) {
1649 const {
1650 displayValue,
1651 exportValue
1652 } = item;
1653 const optionElement = document.createElement("option");
1654 optionElement.textContent = displayValue;
1655 optionElement.value = exportValue;
1656 selectElement.append(optionElement);
1657 }
1658 if (selectElement.options.length > 0) {
1659 selectElement.options[0].selected = true;
1660 }
1661 storage.setValue(id, {
1662 value: getValue(true),
1663 items: getItems(event)
1664 });
1665 selectedValues = getValue(false);
1666 },
1667 indices(event) {
1668 const indices = new Set(event.detail.indices);
1669 for (const option of event.target.options) {
1670 option.selected = indices.has(option.index);
1671 }
1672 storage.setValue(id, {
1673 value: getValue(true)
1674 });
1675 selectedValues = getValue(false);
1676 },
1677 editable(event) {
1678 event.target.disabled = !event.detail.editable;
1679 }
1680 };
1681 this._dispatchEventFromSandbox(actions, jsEvent);
1682 });
1683 selectElement.addEventListener("input", event => {
1684 const exportValue = getValue(true);
1685 storage.setValue(id, {
1686 value: exportValue
1687 });
1688 event.preventDefault();
1689 this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
1690 source: this,
1691 detail: {
1692 id,
1693 name: "Keystroke",
1694 value: selectedValues,
1695 changeEx: exportValue,
1696 willCommit: false,
1697 commitKey: 1,
1698 keyDown: false
1699 }
1700 });
1701 });
1702 this._setEventListeners(selectElement, null, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"], ["input", "Validate"]], event => event.target.value);
1703 } else {
1704 selectElement.addEventListener("input", function (event) {
1705 storage.setValue(id, {
1706 value: getValue(true)
1707 });
1708 });
1709 }
1710 if (this.data.combo) {
1711 this._setTextStyle(selectElement);
1712 } else {}
1713 this._setBackgroundColor(selectElement);
1714 this._setDefaultPropertiesFromJS(selectElement);
1715 this.container.append(selectElement);
1716 return this.container;
1717 }
1718}
1719class PopupAnnotationElement extends AnnotationElement {
1720 constructor(parameters) {
1721 const {
1722 data,
1723 elements
1724 } = parameters;
1725 super(parameters, {
1726 isRenderable: AnnotationElement._hasPopupData(data)
1727 });
1728 this.elements = elements;
1729 }
1730 render() {
1731 this.container.classList.add("popupAnnotation");
1732 const popup = new PopupElement({
1733 container: this.container,
1734 color: this.data.color,
1735 titleObj: this.data.titleObj,
1736 modificationDate: this.data.modificationDate,
1737 contentsObj: this.data.contentsObj,
1738 richText: this.data.richText,
1739 rect: this.data.rect,
1740 parentRect: this.data.parentRect || null,
1741 parent: this.parent,
1742 elements: this.elements,
1743 open: this.data.open
1744 });
1745 const elementIds = [];
1746 for (const element of this.elements) {
1747 element.popup = popup;
1748 elementIds.push(element.data.id);
1749 element.addHighlightArea();
1750 }
1751 this.container.setAttribute("aria-controls", elementIds.map(id => `${util.AnnotationPrefix}${id}`).join(","));
1752 return this.container;
1753 }
1754}
1755class PopupElement {
1756 #boundKeyDown = this.#keyDown.bind(this);
1757 #boundHide = this.#hide.bind(this);
1758 #boundShow = this.#show.bind(this);
1759 #boundToggle = this.#toggle.bind(this);
1760 #color = null;
1761 #container = null;
1762 #contentsObj = null;
1763 #dateObj = null;
1764 #elements = null;
1765 #parent = null;
1766 #parentRect = null;
1767 #pinned = false;
1768 #popup = null;
1769 #rect = null;
1770 #richText = null;
1771 #titleObj = null;
1772 #wasVisible = false;
1773 constructor({
1774 container,
1775 color,
1776 elements,
1777 titleObj,
1778 modificationDate,
1779 contentsObj,
1780 richText,
1781 parent,
1782 rect,
1783 parentRect,
1784 open
1785 }) {
1786 this.#container = container;
1787 this.#titleObj = titleObj;
1788 this.#contentsObj = contentsObj;
1789 this.#richText = richText;
1790 this.#parent = parent;
1791 this.#color = color;
1792 this.#rect = rect;
1793 this.#parentRect = parentRect;
1794 this.#elements = elements;
1795 this.#dateObj = display_utils.PDFDateString.toDateObject(modificationDate);
1796 this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
1797 for (const element of this.trigger) {
1798 element.addEventListener("click", this.#boundToggle);
1799 element.addEventListener("mouseenter", this.#boundShow);
1800 element.addEventListener("mouseleave", this.#boundHide);
1801 element.classList.add("popupTriggerArea");
1802 }
1803 for (const element of elements) {
1804 element.container?.addEventListener("keydown", this.#boundKeyDown);
1805 }
1806 this.#container.hidden = true;
1807 if (open) {
1808 this.#toggle();
1809 }
1810 }
1811 render() {
1812 if (this.#popup) {
1813 return;
1814 }
1815 const {
1816 page: {
1817 view
1818 },
1819 viewport: {
1820 rawDims: {
1821 pageWidth,
1822 pageHeight,
1823 pageX,
1824 pageY
1825 }
1826 }
1827 } = this.#parent;
1828 const popup = this.#popup = document.createElement("div");
1829 popup.className = "popup";
1830 if (this.#color) {
1831 const baseColor = popup.style.outlineColor = util.Util.makeHexColor(...this.#color);
1832 if (CSS.supports("background-color", "color-mix(in srgb, red 30%, white)")) {
1833 popup.style.backgroundColor = `color-mix(in srgb, ${baseColor} 30%, white)`;
1834 } else {
1835 const BACKGROUND_ENLIGHT = 0.7;
1836 popup.style.backgroundColor = util.Util.makeHexColor(...this.#color.map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
1837 }
1838 }
1839 const header = document.createElement("span");
1840 header.className = "header";
1841 const title = document.createElement("h1");
1842 header.append(title);
1843 ({
1844 dir: title.dir,
1845 str: title.textContent
1846 } = this.#titleObj);
1847 popup.append(header);
1848 if (this.#dateObj) {
1849 const modificationDate = document.createElement("span");
1850 modificationDate.classList.add("popupDate");
1851 modificationDate.setAttribute("data-l10n-id", "pdfjs-annotation-date-string");
1852 modificationDate.setAttribute("data-l10n-args", JSON.stringify({
1853 date: this.#dateObj.toLocaleDateString(),
1854 time: this.#dateObj.toLocaleTimeString()
1855 }));
1856 header.append(modificationDate);
1857 }
1858 const contentsObj = this.#contentsObj;
1859 const richText = this.#richText;
1860 if (richText?.str && (!contentsObj?.str || contentsObj.str === richText.str)) {
1861 xfa_layer.XfaLayer.render({
1862 xfaHtml: richText.html,
1863 intent: "richText",
1864 div: popup
1865 });
1866 popup.lastChild.classList.add("richText", "popupContent");
1867 } else {
1868 const contents = this._formatContents(contentsObj);
1869 popup.append(contents);
1870 }
1871 let useParentRect = !!this.#parentRect;
1872 let rect = useParentRect ? this.#parentRect : this.#rect;
1873 for (const element of this.#elements) {
1874 if (!rect || util.Util.intersect(element.data.rect, rect) !== null) {
1875 rect = element.data.rect;
1876 useParentRect = true;
1877 break;
1878 }
1879 }
1880 const normalizedRect = util.Util.normalizeRect([rect[0], view[3] - rect[1] + view[1], rect[2], view[3] - rect[3] + view[1]]);
1881 const HORIZONTAL_SPACE_AFTER_ANNOTATION = 5;
1882 const parentWidth = useParentRect ? rect[2] - rect[0] + HORIZONTAL_SPACE_AFTER_ANNOTATION : 0;
1883 const popupLeft = normalizedRect[0] + parentWidth;
1884 const popupTop = normalizedRect[1];
1885 const {
1886 style
1887 } = this.#container;
1888 style.left = `${100 * (popupLeft - pageX) / pageWidth}%`;
1889 style.top = `${100 * (popupTop - pageY) / pageHeight}%`;
1890 this.#container.append(popup);
1891 }
1892 _formatContents({
1893 str,
1894 dir
1895 }) {
1896 const p = document.createElement("p");
1897 p.classList.add("popupContent");
1898 p.dir = dir;
1899 const lines = str.split(/(?:\r\n?|\n)/);
1900 for (let i = 0, ii = lines.length; i < ii; ++i) {
1901 const line = lines[i];
1902 p.append(document.createTextNode(line));
1903 if (i < ii - 1) {
1904 p.append(document.createElement("br"));
1905 }
1906 }
1907 return p;
1908 }
1909 #keyDown(event) {
1910 if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
1911 return;
1912 }
1913 if (event.key === "Enter" || event.key === "Escape" && this.#pinned) {
1914 this.#toggle();
1915 }
1916 }
1917 #toggle() {
1918 this.#pinned = !this.#pinned;
1919 if (this.#pinned) {
1920 this.#show();
1921 this.#container.addEventListener("click", this.#boundToggle);
1922 this.#container.addEventListener("keydown", this.#boundKeyDown);
1923 } else {
1924 this.#hide();
1925 this.#container.removeEventListener("click", this.#boundToggle);
1926 this.#container.removeEventListener("keydown", this.#boundKeyDown);
1927 }
1928 }
1929 #show() {
1930 if (!this.#popup) {
1931 this.render();
1932 }
1933 if (!this.isVisible) {
1934 this.#container.hidden = false;
1935 this.#container.style.zIndex = parseInt(this.#container.style.zIndex) + 1000;
1936 } else if (this.#pinned) {
1937 this.#container.classList.add("focused");
1938 }
1939 }
1940 #hide() {
1941 this.#container.classList.remove("focused");
1942 if (this.#pinned || !this.isVisible) {
1943 return;
1944 }
1945 this.#container.hidden = true;
1946 this.#container.style.zIndex = parseInt(this.#container.style.zIndex) - 1000;
1947 }
1948 forceHide() {
1949 this.#wasVisible = this.isVisible;
1950 if (!this.#wasVisible) {
1951 return;
1952 }
1953 this.#container.hidden = true;
1954 }
1955 maybeShow() {
1956 if (!this.#wasVisible) {
1957 return;
1958 }
1959 this.#wasVisible = false;
1960 this.#container.hidden = false;
1961 }
1962 get isVisible() {
1963 return this.#container.hidden === false;
1964 }
1965}
1966class FreeTextAnnotationElement extends AnnotationElement {
1967 constructor(parameters) {
1968 super(parameters, {
1969 isRenderable: true,
1970 ignoreBorder: true
1971 });
1972 this.textContent = parameters.data.textContent;
1973 this.textPosition = parameters.data.textPosition;
1974 this.annotationEditorType = util.AnnotationEditorType.FREETEXT;
1975 }
1976 render() {
1977 this.container.classList.add("freeTextAnnotation");
1978 if (this.textContent) {
1979 const content = document.createElement("div");
1980 content.classList.add("annotationTextContent");
1981 content.setAttribute("role", "comment");
1982 for (const line of this.textContent) {
1983 const lineSpan = document.createElement("span");
1984 lineSpan.textContent = line;
1985 content.append(lineSpan);
1986 }
1987 this.container.append(content);
1988 }
1989 if (!this.data.popupRef && this.hasPopupData) {
1990 this._createPopup();
1991 }
1992 this._editOnDoubleClick();
1993 return this.container;
1994 }
1995 get _isEditable() {
1996 return this.data.hasOwnCanvas;
1997 }
1998}
1999class LineAnnotationElement extends AnnotationElement {
2000 #line = null;
2001 constructor(parameters) {
2002 super(parameters, {
2003 isRenderable: true,
2004 ignoreBorder: true
2005 });
2006 }
2007 render() {
2008 this.container.classList.add("lineAnnotation");
2009 const data = this.data;
2010 const {
2011 width,
2012 height
2013 } = getRectDims(data.rect);
2014 const svg = this.svgFactory.create(width, height, true);
2015 const line = this.#line = this.svgFactory.createElement("svg:line");
2016 line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
2017 line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
2018 line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
2019 line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
2020 line.setAttribute("stroke-width", data.borderStyle.width || 1);
2021 line.setAttribute("stroke", "transparent");
2022 line.setAttribute("fill", "transparent");
2023 svg.append(line);
2024 this.container.append(svg);
2025 if (!data.popupRef && this.hasPopupData) {
2026 this._createPopup();
2027 }
2028 return this.container;
2029 }
2030 getElementsToTriggerPopup() {
2031 return this.#line;
2032 }
2033 addHighlightArea() {
2034 this.container.classList.add("highlightArea");
2035 }
2036}
2037class SquareAnnotationElement extends AnnotationElement {
2038 #square = null;
2039 constructor(parameters) {
2040 super(parameters, {
2041 isRenderable: true,
2042 ignoreBorder: true
2043 });
2044 }
2045 render() {
2046 this.container.classList.add("squareAnnotation");
2047 const data = this.data;
2048 const {
2049 width,
2050 height
2051 } = getRectDims(data.rect);
2052 const svg = this.svgFactory.create(width, height, true);
2053 const borderWidth = data.borderStyle.width;
2054 const square = this.#square = this.svgFactory.createElement("svg:rect");
2055 square.setAttribute("x", borderWidth / 2);
2056 square.setAttribute("y", borderWidth / 2);
2057 square.setAttribute("width", width - borderWidth);
2058 square.setAttribute("height", height - borderWidth);
2059 square.setAttribute("stroke-width", borderWidth || 1);
2060 square.setAttribute("stroke", "transparent");
2061 square.setAttribute("fill", "transparent");
2062 svg.append(square);
2063 this.container.append(svg);
2064 if (!data.popupRef && this.hasPopupData) {
2065 this._createPopup();
2066 }
2067 return this.container;
2068 }
2069 getElementsToTriggerPopup() {
2070 return this.#square;
2071 }
2072 addHighlightArea() {
2073 this.container.classList.add("highlightArea");
2074 }
2075}
2076class CircleAnnotationElement extends AnnotationElement {
2077 #circle = null;
2078 constructor(parameters) {
2079 super(parameters, {
2080 isRenderable: true,
2081 ignoreBorder: true
2082 });
2083 }
2084 render() {
2085 this.container.classList.add("circleAnnotation");
2086 const data = this.data;
2087 const {
2088 width,
2089 height
2090 } = getRectDims(data.rect);
2091 const svg = this.svgFactory.create(width, height, true);
2092 const borderWidth = data.borderStyle.width;
2093 const circle = this.#circle = this.svgFactory.createElement("svg:ellipse");
2094 circle.setAttribute("cx", width / 2);
2095 circle.setAttribute("cy", height / 2);
2096 circle.setAttribute("rx", width / 2 - borderWidth / 2);
2097 circle.setAttribute("ry", height / 2 - borderWidth / 2);
2098 circle.setAttribute("stroke-width", borderWidth || 1);
2099 circle.setAttribute("stroke", "transparent");
2100 circle.setAttribute("fill", "transparent");
2101 svg.append(circle);
2102 this.container.append(svg);
2103 if (!data.popupRef && this.hasPopupData) {
2104 this._createPopup();
2105 }
2106 return this.container;
2107 }
2108 getElementsToTriggerPopup() {
2109 return this.#circle;
2110 }
2111 addHighlightArea() {
2112 this.container.classList.add("highlightArea");
2113 }
2114}
2115class PolylineAnnotationElement extends AnnotationElement {
2116 #polyline = null;
2117 constructor(parameters) {
2118 super(parameters, {
2119 isRenderable: true,
2120 ignoreBorder: true
2121 });
2122 this.containerClassName = "polylineAnnotation";
2123 this.svgElementName = "svg:polyline";
2124 }
2125 render() {
2126 this.container.classList.add(this.containerClassName);
2127 const data = this.data;
2128 const {
2129 width,
2130 height
2131 } = getRectDims(data.rect);
2132 const svg = this.svgFactory.create(width, height, true);
2133 let points = [];
2134 for (const coordinate of data.vertices) {
2135 const x = coordinate.x - data.rect[0];
2136 const y = data.rect[3] - coordinate.y;
2137 points.push(x + "," + y);
2138 }
2139 points = points.join(" ");
2140 const polyline = this.#polyline = this.svgFactory.createElement(this.svgElementName);
2141 polyline.setAttribute("points", points);
2142 polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
2143 polyline.setAttribute("stroke", "transparent");
2144 polyline.setAttribute("fill", "transparent");
2145 svg.append(polyline);
2146 this.container.append(svg);
2147 if (!data.popupRef && this.hasPopupData) {
2148 this._createPopup();
2149 }
2150 return this.container;
2151 }
2152 getElementsToTriggerPopup() {
2153 return this.#polyline;
2154 }
2155 addHighlightArea() {
2156 this.container.classList.add("highlightArea");
2157 }
2158}
2159class PolygonAnnotationElement extends PolylineAnnotationElement {
2160 constructor(parameters) {
2161 super(parameters);
2162 this.containerClassName = "polygonAnnotation";
2163 this.svgElementName = "svg:polygon";
2164 }
2165}
2166class CaretAnnotationElement extends AnnotationElement {
2167 constructor(parameters) {
2168 super(parameters, {
2169 isRenderable: true,
2170 ignoreBorder: true
2171 });
2172 }
2173 render() {
2174 this.container.classList.add("caretAnnotation");
2175 if (!this.data.popupRef && this.hasPopupData) {
2176 this._createPopup();
2177 }
2178 return this.container;
2179 }
2180}
2181class InkAnnotationElement extends AnnotationElement {
2182 #polylines = [];
2183 constructor(parameters) {
2184 super(parameters, {
2185 isRenderable: true,
2186 ignoreBorder: true
2187 });
2188 this.containerClassName = "inkAnnotation";
2189 this.svgElementName = "svg:polyline";
2190 this.annotationEditorType = util.AnnotationEditorType.INK;
2191 }
2192 render() {
2193 this.container.classList.add(this.containerClassName);
2194 const data = this.data;
2195 const {
2196 width,
2197 height
2198 } = getRectDims(data.rect);
2199 const svg = this.svgFactory.create(width, height, true);
2200 for (const inkList of data.inkLists) {
2201 let points = [];
2202 for (const coordinate of inkList) {
2203 const x = coordinate.x - data.rect[0];
2204 const y = data.rect[3] - coordinate.y;
2205 points.push(`${x},${y}`);
2206 }
2207 points = points.join(" ");
2208 const polyline = this.svgFactory.createElement(this.svgElementName);
2209 this.#polylines.push(polyline);
2210 polyline.setAttribute("points", points);
2211 polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
2212 polyline.setAttribute("stroke", "transparent");
2213 polyline.setAttribute("fill", "transparent");
2214 if (!data.popupRef && this.hasPopupData) {
2215 this._createPopup();
2216 }
2217 svg.append(polyline);
2218 }
2219 this.container.append(svg);
2220 return this.container;
2221 }
2222 getElementsToTriggerPopup() {
2223 return this.#polylines;
2224 }
2225 addHighlightArea() {
2226 this.container.classList.add("highlightArea");
2227 }
2228}
2229class HighlightAnnotationElement extends AnnotationElement {
2230 constructor(parameters) {
2231 super(parameters, {
2232 isRenderable: true,
2233 ignoreBorder: true,
2234 createQuadrilaterals: true
2235 });
2236 }
2237 render() {
2238 if (!this.data.popupRef && this.hasPopupData) {
2239 this._createPopup();
2240 }
2241 this.container.classList.add("highlightAnnotation");
2242 return this.container;
2243 }
2244}
2245class UnderlineAnnotationElement extends AnnotationElement {
2246 constructor(parameters) {
2247 super(parameters, {
2248 isRenderable: true,
2249 ignoreBorder: true,
2250 createQuadrilaterals: true
2251 });
2252 }
2253 render() {
2254 if (!this.data.popupRef && this.hasPopupData) {
2255 this._createPopup();
2256 }
2257 this.container.classList.add("underlineAnnotation");
2258 return this.container;
2259 }
2260}
2261class SquigglyAnnotationElement extends AnnotationElement {
2262 constructor(parameters) {
2263 super(parameters, {
2264 isRenderable: true,
2265 ignoreBorder: true,
2266 createQuadrilaterals: true
2267 });
2268 }
2269 render() {
2270 if (!this.data.popupRef && this.hasPopupData) {
2271 this._createPopup();
2272 }
2273 this.container.classList.add("squigglyAnnotation");
2274 return this.container;
2275 }
2276}
2277class StrikeOutAnnotationElement extends AnnotationElement {
2278 constructor(parameters) {
2279 super(parameters, {
2280 isRenderable: true,
2281 ignoreBorder: true,
2282 createQuadrilaterals: true
2283 });
2284 }
2285 render() {
2286 if (!this.data.popupRef && this.hasPopupData) {
2287 this._createPopup();
2288 }
2289 this.container.classList.add("strikeoutAnnotation");
2290 return this.container;
2291 }
2292}
2293class StampAnnotationElement extends AnnotationElement {
2294 constructor(parameters) {
2295 super(parameters, {
2296 isRenderable: true,
2297 ignoreBorder: true
2298 });
2299 }
2300 render() {
2301 this.container.classList.add("stampAnnotation");
2302 if (!this.data.popupRef && this.hasPopupData) {
2303 this._createPopup();
2304 }
2305 return this.container;
2306 }
2307}
2308class FileAttachmentAnnotationElement extends AnnotationElement {
2309 #trigger = null;
2310 constructor(parameters) {
2311 super(parameters, {
2312 isRenderable: true
2313 });
2314 const {
2315 filename,
2316 content
2317 } = this.data.file;
2318 this.filename = (0,display_utils.getFilenameFromUrl)(filename, true);
2319 this.content = content;
2320 this.linkService.eventBus?.dispatch("fileattachmentannotation", {
2321 source: this,
2322 filename,
2323 content
2324 });
2325 }
2326 render() {
2327 this.container.classList.add("fileAttachmentAnnotation");
2328 const {
2329 container,
2330 data
2331 } = this;
2332 let trigger;
2333 if (data.hasAppearance || data.fillAlpha === 0) {
2334 trigger = document.createElement("div");
2335 } else {
2336 trigger = document.createElement("img");
2337 trigger.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(data.name) ? "paperclip" : "pushpin"}.svg`;
2338 if (data.fillAlpha && data.fillAlpha < 1) {
2339 trigger.style = `filter: opacity(${Math.round(data.fillAlpha * 100)}%);`;
2340 }
2341 }
2342 trigger.addEventListener("dblclick", this.#download.bind(this));
2343 this.#trigger = trigger;
2344 const {
2345 isMac
2346 } = util.FeatureTest.platform;
2347 container.addEventListener("keydown", evt => {
2348 if (evt.key === "Enter" && (isMac ? evt.metaKey : evt.ctrlKey)) {
2349 this.#download();
2350 }
2351 });
2352 if (!data.popupRef && this.hasPopupData) {
2353 this._createPopup();
2354 } else {
2355 trigger.classList.add("popupTriggerArea");
2356 }
2357 container.append(trigger);
2358 return container;
2359 }
2360 getElementsToTriggerPopup() {
2361 return this.#trigger;
2362 }
2363 addHighlightArea() {
2364 this.container.classList.add("highlightArea");
2365 }
2366 #download() {
2367 this.downloadManager?.openOrDownloadData(this.content, this.filename);
2368 }
2369}
2370class AnnotationLayer {
2371 #accessibilityManager = null;
2372 #annotationCanvasMap = null;
2373 #editableAnnotations = new Map();
2374 constructor({
2375 div,
2376 accessibilityManager,
2377 annotationCanvasMap,
2378 page,
2379 viewport
2380 }) {
2381 this.div = div;
2382 this.#accessibilityManager = accessibilityManager;
2383 this.#annotationCanvasMap = annotationCanvasMap;
2384 this.page = page;
2385 this.viewport = viewport;
2386 this.zIndex = 0;
2387 }
2388 #appendElement(element, id) {
2389 const contentElement = element.firstChild || element;
2390 contentElement.id = `${util.AnnotationPrefix}${id}`;
2391 this.div.append(element);
2392 this.#accessibilityManager?.moveElementInDOM(this.div, element, contentElement, false);
2393 }
2394 async render(params) {
2395 const {
2396 annotations
2397 } = params;
2398 const layer = this.div;
2399 (0,display_utils.setLayerDimensions)(layer, this.viewport);
2400 const popupToElements = new Map();
2401 const elementParams = {
2402 data: null,
2403 layer,
2404 linkService: params.linkService,
2405 downloadManager: params.downloadManager,
2406 imageResourcesPath: params.imageResourcesPath || "",
2407 renderForms: params.renderForms !== false,
2408 svgFactory: new display_utils.DOMSVGFactory(),
2409 annotationStorage: params.annotationStorage || new annotation_storage.AnnotationStorage(),
2410 enableScripting: params.enableScripting === true,
2411 hasJSActions: params.hasJSActions,
2412 fieldObjects: params.fieldObjects,
2413 parent: this,
2414 elements: null
2415 };
2416 for (const data of annotations) {
2417 if (data.noHTML) {
2418 continue;
2419 }
2420 const isPopupAnnotation = data.annotationType === util.AnnotationType.POPUP;
2421 if (!isPopupAnnotation) {
2422 const {
2423 width,
2424 height
2425 } = getRectDims(data.rect);
2426 if (width <= 0 || height <= 0) {
2427 continue;
2428 }
2429 } else {
2430 const elements = popupToElements.get(data.id);
2431 if (!elements) {
2432 continue;
2433 }
2434 elementParams.elements = elements;
2435 }
2436 elementParams.data = data;
2437 const element = AnnotationElementFactory.create(elementParams);
2438 if (!element.isRenderable) {
2439 continue;
2440 }
2441 if (!isPopupAnnotation && data.popupRef) {
2442 const elements = popupToElements.get(data.popupRef);
2443 if (!elements) {
2444 popupToElements.set(data.popupRef, [element]);
2445 } else {
2446 elements.push(element);
2447 }
2448 }
2449 if (element.annotationEditorType > 0) {
2450 this.#editableAnnotations.set(element.data.id, element);
2451 }
2452 const rendered = element.render();
2453 if (data.hidden) {
2454 rendered.style.visibility = "hidden";
2455 }
2456 this.#appendElement(rendered, data.id);
2457 }
2458 this.#setAnnotationCanvasMap();
2459 }
2460 update({
2461 viewport
2462 }) {
2463 const layer = this.div;
2464 this.viewport = viewport;
2465 (0,display_utils.setLayerDimensions)(layer, {
2466 rotation: viewport.rotation
2467 });
2468 this.#setAnnotationCanvasMap();
2469 layer.hidden = false;
2470 }
2471 #setAnnotationCanvasMap() {
2472 if (!this.#annotationCanvasMap) {
2473 return;
2474 }
2475 const layer = this.div;
2476 for (const [id, canvas] of this.#annotationCanvasMap) {
2477 const element = layer.querySelector(`[data-annotation-id="${id}"]`);
2478 if (!element) {
2479 continue;
2480 }
2481 const {
2482 firstChild
2483 } = element;
2484 if (!firstChild) {
2485 element.append(canvas);
2486 } else if (firstChild.nodeName === "CANVAS") {
2487 firstChild.replaceWith(canvas);
2488 } else {
2489 firstChild.before(canvas);
2490 }
2491 }
2492 this.#annotationCanvasMap.clear();
2493 }
2494 getEditableAnnotations() {
2495 return Array.from(this.#editableAnnotations.values());
2496 }
2497 getEditableAnnotation(id) {
2498 return this.#editableAnnotations.get(id);
2499 }
2500}
2501
2502
2503/***/ }),
2504
2505/***/ 780:
2506/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
2507
2508/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2509/* harmony export */ AnnotationStorage: () => (/* binding */ AnnotationStorage),
2510/* harmony export */ PrintAnnotationStorage: () => (/* binding */ PrintAnnotationStorage),
2511/* harmony export */ SerializableEmpty: () => (/* binding */ SerializableEmpty)
2512/* harmony export */ });
2513/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(266);
2514/* harmony import */ var _editor_editor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(796);
2515/* harmony import */ var _shared_murmurhash3_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(825);
2516
2517
2518
2519const SerializableEmpty = Object.freeze({
2520 map: null,
2521 hash: "",
2522 transfer: undefined
2523});
2524class AnnotationStorage {
2525 #modified = false;
2526 #storage = new Map();
2527 constructor() {
2528 this.onSetModified = null;
2529 this.onResetModified = null;
2530 this.onAnnotationEditor = null;
2531 }
2532 getValue(key, defaultValue) {
2533 const value = this.#storage.get(key);
2534 if (value === undefined) {
2535 return defaultValue;
2536 }
2537 return Object.assign(defaultValue, value);
2538 }
2539 getRawValue(key) {
2540 return this.#storage.get(key);
2541 }
2542 remove(key) {
2543 this.#storage.delete(key);
2544 if (this.#storage.size === 0) {
2545 this.resetModified();
2546 }
2547 if (typeof this.onAnnotationEditor === "function") {
2548 for (const value of this.#storage.values()) {
2549 if (value instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditor) {
2550 return;
2551 }
2552 }
2553 this.onAnnotationEditor(null);
2554 }
2555 }
2556 setValue(key, value) {
2557 const obj = this.#storage.get(key);
2558 let modified = false;
2559 if (obj !== undefined) {
2560 for (const [entry, val] of Object.entries(value)) {
2561 if (obj[entry] !== val) {
2562 modified = true;
2563 obj[entry] = val;
2564 }
2565 }
2566 } else {
2567 modified = true;
2568 this.#storage.set(key, value);
2569 }
2570 if (modified) {
2571 this.#setModified();
2572 }
2573 if (value instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditor && typeof this.onAnnotationEditor === "function") {
2574 this.onAnnotationEditor(value.constructor._type);
2575 }
2576 }
2577 has(key) {
2578 return this.#storage.has(key);
2579 }
2580 getAll() {
2581 return this.#storage.size > 0 ? (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.objectFromMap)(this.#storage) : null;
2582 }
2583 setAll(obj) {
2584 for (const [key, val] of Object.entries(obj)) {
2585 this.setValue(key, val);
2586 }
2587 }
2588 get size() {
2589 return this.#storage.size;
2590 }
2591 #setModified() {
2592 if (!this.#modified) {
2593 this.#modified = true;
2594 if (typeof this.onSetModified === "function") {
2595 this.onSetModified();
2596 }
2597 }
2598 }
2599 resetModified() {
2600 if (this.#modified) {
2601 this.#modified = false;
2602 if (typeof this.onResetModified === "function") {
2603 this.onResetModified();
2604 }
2605 }
2606 }
2607 get print() {
2608 return new PrintAnnotationStorage(this);
2609 }
2610 get serializable() {
2611 if (this.#storage.size === 0) {
2612 return SerializableEmpty;
2613 }
2614 const map = new Map(),
2615 hash = new _shared_murmurhash3_js__WEBPACK_IMPORTED_MODULE_2__.MurmurHash3_64(),
2616 transfer = [];
2617 const context = Object.create(null);
2618 let hasBitmap = false;
2619 for (const [key, val] of this.#storage) {
2620 const serialized = val instanceof _editor_editor_js__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditor ? val.serialize(false, context) : val;
2621 if (serialized) {
2622 map.set(key, serialized);
2623 hash.update(`${key}:${JSON.stringify(serialized)}`);
2624 hasBitmap ||= !!serialized.bitmap;
2625 }
2626 }
2627 if (hasBitmap) {
2628 for (const value of map.values()) {
2629 if (value.bitmap) {
2630 transfer.push(value.bitmap);
2631 }
2632 }
2633 }
2634 return map.size > 0 ? {
2635 map,
2636 hash: hash.hexdigest(),
2637 transfer
2638 } : SerializableEmpty;
2639 }
2640}
2641class PrintAnnotationStorage extends AnnotationStorage {
2642 #serializable;
2643 constructor(parent) {
2644 super();
2645 const {
2646 map,
2647 hash,
2648 transfer
2649 } = parent.serializable;
2650 const clone = structuredClone(map, transfer ? {
2651 transfer
2652 } : null);
2653 this.#serializable = {
2654 map: clone,
2655 hash,
2656 transfer
2657 };
2658 }
2659 get print() {
2660 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Should not call PrintAnnotationStorage.print");
2661 }
2662 get serializable() {
2663 return this.#serializable;
2664 }
2665}
2666
2667
2668/***/ }),
2669
2670/***/ 406:
2671/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
2672
2673__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2674/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2675/* harmony export */ PDFDataRangeTransport: () => (/* binding */ PDFDataRangeTransport),
2676/* harmony export */ PDFWorker: () => (/* binding */ PDFWorker),
2677/* harmony export */ build: () => (/* binding */ build),
2678/* harmony export */ getDocument: () => (/* binding */ getDocument),
2679/* harmony export */ version: () => (/* binding */ version)
2680/* harmony export */ });
2681/* unused harmony exports DefaultCanvasFactory, DefaultCMapReaderFactory, DefaultFilterFactory, DefaultStandardFontDataFactory, LoopbackPort, PDFDocumentLoadingTask, PDFDocumentProxy, PDFPageProxy, PDFWorkerUtil, RenderTask */
2682/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(266);
2683/* harmony import */ var _annotation_storage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(780);
2684/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(473);
2685/* harmony import */ var _font_loader_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(742);
2686/* harmony import */ var display_node_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(738);
2687/* harmony import */ var _canvas_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(250);
2688/* harmony import */ var _worker_options_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(368);
2689/* harmony import */ var _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(694);
2690/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(472);
2691/* harmony import */ var _optional_content_config_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(890);
2692/* harmony import */ var _transport_stream_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(92);
2693/* harmony import */ var display_fetch_stream__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(171);
2694/* harmony import */ var display_network__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(474);
2695/* harmony import */ var display_node_stream__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(498);
2696/* harmony import */ var _xfa_text_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(521);
2697var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([display_node_utils__WEBPACK_IMPORTED_MODULE_4__, display_node_stream__WEBPACK_IMPORTED_MODULE_13__]);
2698([display_node_utils__WEBPACK_IMPORTED_MODULE_4__, display_node_stream__WEBPACK_IMPORTED_MODULE_13__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714const DEFAULT_RANGE_CHUNK_SIZE = 65536;
2715const RENDERING_CANCELLED_TIMEOUT = 100;
2716const DELAYED_CLEANUP_TIMEOUT = 5000;
2717const DefaultCanvasFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_4__.NodeCanvasFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMCanvasFactory;
2718const DefaultCMapReaderFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_4__.NodeCMapReaderFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMCMapReaderFactory;
2719const DefaultFilterFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_4__.NodeFilterFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMFilterFactory;
2720const DefaultStandardFontDataFactory = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS ? display_node_utils__WEBPACK_IMPORTED_MODULE_4__.NodeStandardFontDataFactory : _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMStandardFontDataFactory;
2721function getDocument(src) {
2722 if (typeof src === "string" || src instanceof URL) {
2723 src = {
2724 url: src
2725 };
2726 } else if ((0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isArrayBuffer)(src)) {
2727 src = {
2728 data: src
2729 };
2730 }
2731 if (typeof src !== "object") {
2732 throw new Error("Invalid parameter in getDocument, need parameter object.");
2733 }
2734 if (!src.url && !src.data && !src.range) {
2735 throw new Error("Invalid parameter object: need either .data, .range or .url");
2736 }
2737 const task = new PDFDocumentLoadingTask();
2738 const {
2739 docId
2740 } = task;
2741 const url = src.url ? getUrlProp(src.url) : null;
2742 const data = src.data ? getDataProp(src.data) : null;
2743 const httpHeaders = src.httpHeaders || null;
2744 const withCredentials = src.withCredentials === true;
2745 const password = src.password ?? null;
2746 const rangeTransport = src.range instanceof PDFDataRangeTransport ? src.range : null;
2747 const rangeChunkSize = Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0 ? src.rangeChunkSize : DEFAULT_RANGE_CHUNK_SIZE;
2748 let worker = src.worker instanceof PDFWorker ? src.worker : null;
2749 const verbosity = src.verbosity;
2750 const docBaseUrl = typeof src.docBaseUrl === "string" && !(0,_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.isDataScheme)(src.docBaseUrl) ? src.docBaseUrl : null;
2751 const cMapUrl = typeof src.cMapUrl === "string" ? src.cMapUrl : null;
2752 const cMapPacked = src.cMapPacked !== false;
2753 const CMapReaderFactory = src.CMapReaderFactory || DefaultCMapReaderFactory;
2754 const standardFontDataUrl = typeof src.standardFontDataUrl === "string" ? src.standardFontDataUrl : null;
2755 const StandardFontDataFactory = src.StandardFontDataFactory || DefaultStandardFontDataFactory;
2756 const ignoreErrors = src.stopAtErrors !== true;
2757 const maxImageSize = Number.isInteger(src.maxImageSize) && src.maxImageSize > -1 ? src.maxImageSize : -1;
2758 const isEvalSupported = src.isEvalSupported !== false;
2759 const isOffscreenCanvasSupported = typeof src.isOffscreenCanvasSupported === "boolean" ? src.isOffscreenCanvasSupported : !_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS;
2760 const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes) ? src.canvasMaxAreaInBytes : -1;
2761 const disableFontFace = typeof src.disableFontFace === "boolean" ? src.disableFontFace : _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS;
2762 const fontExtraProperties = src.fontExtraProperties === true;
2763 const enableXfa = src.enableXfa === true;
2764 const ownerDocument = src.ownerDocument || globalThis.document;
2765 const disableRange = src.disableRange === true;
2766 const disableStream = src.disableStream === true;
2767 const disableAutoFetch = src.disableAutoFetch === true;
2768 const pdfBug = src.pdfBug === true;
2769 const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
2770 const useSystemFonts = typeof src.useSystemFonts === "boolean" ? src.useSystemFonts : !_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS && !disableFontFace;
2771 const useWorkerFetch = typeof src.useWorkerFetch === "boolean" ? src.useWorkerFetch : CMapReaderFactory === _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMCMapReaderFactory && StandardFontDataFactory === _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.DOMStandardFontDataFactory && cMapUrl && standardFontDataUrl && (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.isValidFetchUrl)(cMapUrl, document.baseURI) && (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.isValidFetchUrl)(standardFontDataUrl, document.baseURI);
2772 const canvasFactory = src.canvasFactory || new DefaultCanvasFactory({
2773 ownerDocument
2774 });
2775 const filterFactory = src.filterFactory || new DefaultFilterFactory({
2776 docId,
2777 ownerDocument
2778 });
2779 const styleElement = null;
2780 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.setVerbosityLevel)(verbosity);
2781 const transportFactory = {
2782 canvasFactory,
2783 filterFactory
2784 };
2785 if (!useWorkerFetch) {
2786 transportFactory.cMapReaderFactory = new CMapReaderFactory({
2787 baseUrl: cMapUrl,
2788 isCompressed: cMapPacked
2789 });
2790 transportFactory.standardFontDataFactory = new StandardFontDataFactory({
2791 baseUrl: standardFontDataUrl
2792 });
2793 }
2794 if (!worker) {
2795 const workerParams = {
2796 verbosity,
2797 port: _worker_options_js__WEBPACK_IMPORTED_MODULE_6__.GlobalWorkerOptions.workerPort
2798 };
2799 worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
2800 task._worker = worker;
2801 }
2802 const fetchDocParams = {
2803 docId,
2804 apiVersion: '4.0.269',
2805 data,
2806 password,
2807 disableAutoFetch,
2808 rangeChunkSize,
2809 length,
2810 docBaseUrl,
2811 enableXfa,
2812 evaluatorOptions: {
2813 maxImageSize,
2814 disableFontFace,
2815 ignoreErrors,
2816 isEvalSupported,
2817 isOffscreenCanvasSupported,
2818 canvasMaxAreaInBytes,
2819 fontExtraProperties,
2820 useSystemFonts,
2821 cMapUrl: useWorkerFetch ? cMapUrl : null,
2822 standardFontDataUrl: useWorkerFetch ? standardFontDataUrl : null
2823 }
2824 };
2825 const transportParams = {
2826 ignoreErrors,
2827 isEvalSupported,
2828 disableFontFace,
2829 fontExtraProperties,
2830 enableXfa,
2831 ownerDocument,
2832 disableAutoFetch,
2833 pdfBug,
2834 styleElement
2835 };
2836 worker.promise.then(function () {
2837 if (task.destroyed) {
2838 throw new Error("Loading aborted");
2839 }
2840 const workerIdPromise = _fetchDocument(worker, fetchDocParams);
2841 const networkStreamPromise = new Promise(function (resolve) {
2842 let networkStream;
2843 if (rangeTransport) {
2844 networkStream = new _transport_stream_js__WEBPACK_IMPORTED_MODULE_10__.PDFDataTransportStream({
2845 length,
2846 initialData: rangeTransport.initialData,
2847 progressiveDone: rangeTransport.progressiveDone,
2848 contentDispositionFilename: rangeTransport.contentDispositionFilename,
2849 disableRange,
2850 disableStream
2851 }, rangeTransport);
2852 } else if (!data) {
2853 const createPDFNetworkStream = params => {
2854 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS) {
2855 return new display_node_stream__WEBPACK_IMPORTED_MODULE_13__.PDFNodeStream(params);
2856 }
2857 return (0,_display_utils_js__WEBPACK_IMPORTED_MODULE_2__.isValidFetchUrl)(params.url) ? new display_fetch_stream__WEBPACK_IMPORTED_MODULE_11__.PDFFetchStream(params) : new display_network__WEBPACK_IMPORTED_MODULE_12__.PDFNetworkStream(params);
2858 };
2859 networkStream = createPDFNetworkStream({
2860 url,
2861 length,
2862 httpHeaders,
2863 withCredentials,
2864 rangeChunkSize,
2865 disableRange,
2866 disableStream
2867 });
2868 }
2869 resolve(networkStream);
2870 });
2871 return Promise.all([workerIdPromise, networkStreamPromise]).then(function ([workerId, networkStream]) {
2872 if (task.destroyed) {
2873 throw new Error("Loading aborted");
2874 }
2875 const messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_7__.MessageHandler(docId, workerId, worker.port);
2876 const transport = new WorkerTransport(messageHandler, task, networkStream, transportParams, transportFactory);
2877 task._transport = transport;
2878 messageHandler.send("Ready", null);
2879 });
2880 }).catch(task._capability.reject);
2881 return task;
2882}
2883async function _fetchDocument(worker, source) {
2884 if (worker.destroyed) {
2885 throw new Error("Worker was destroyed");
2886 }
2887 const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", source, source.data ? [source.data.buffer] : null);
2888 if (worker.destroyed) {
2889 throw new Error("Worker was destroyed");
2890 }
2891 return workerId;
2892}
2893function getUrlProp(val) {
2894 if (val instanceof URL) {
2895 return val.href;
2896 }
2897 try {
2898 return new URL(val, window.location).href;
2899 } catch {
2900 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS && typeof val === "string") {
2901 return val;
2902 }
2903 }
2904 throw new Error("Invalid PDF url data: " + "either string or URL-object is expected in the url property.");
2905}
2906function getDataProp(val) {
2907 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS && typeof Buffer !== "undefined" && val instanceof Buffer) {
2908 throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");
2909 }
2910 if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
2911 return val;
2912 }
2913 if (typeof val === "string") {
2914 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.stringToBytes)(val);
2915 }
2916 if (typeof val === "object" && !isNaN(val?.length) || (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isArrayBuffer)(val)) {
2917 return new Uint8Array(val);
2918 }
2919 throw new Error("Invalid PDF binary data: either TypedArray, " + "string, or array-like object is expected in the data property.");
2920}
2921class PDFDocumentLoadingTask {
2922 static #docId = 0;
2923 constructor() {
2924 this._capability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
2925 this._transport = null;
2926 this._worker = null;
2927 this.docId = `d${PDFDocumentLoadingTask.#docId++}`;
2928 this.destroyed = false;
2929 this.onPassword = null;
2930 this.onProgress = null;
2931 }
2932 get promise() {
2933 return this._capability.promise;
2934 }
2935 async destroy() {
2936 this.destroyed = true;
2937 try {
2938 if (this._worker?.port) {
2939 this._worker._pendingDestroy = true;
2940 }
2941 await this._transport?.destroy();
2942 } catch (ex) {
2943 if (this._worker?.port) {
2944 delete this._worker._pendingDestroy;
2945 }
2946 throw ex;
2947 }
2948 this._transport = null;
2949 if (this._worker) {
2950 this._worker.destroy();
2951 this._worker = null;
2952 }
2953 }
2954}
2955class PDFDataRangeTransport {
2956 constructor(length, initialData, progressiveDone = false, contentDispositionFilename = null) {
2957 this.length = length;
2958 this.initialData = initialData;
2959 this.progressiveDone = progressiveDone;
2960 this.contentDispositionFilename = contentDispositionFilename;
2961 this._rangeListeners = [];
2962 this._progressListeners = [];
2963 this._progressiveReadListeners = [];
2964 this._progressiveDoneListeners = [];
2965 this._readyCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
2966 }
2967 addRangeListener(listener) {
2968 this._rangeListeners.push(listener);
2969 }
2970 addProgressListener(listener) {
2971 this._progressListeners.push(listener);
2972 }
2973 addProgressiveReadListener(listener) {
2974 this._progressiveReadListeners.push(listener);
2975 }
2976 addProgressiveDoneListener(listener) {
2977 this._progressiveDoneListeners.push(listener);
2978 }
2979 onDataRange(begin, chunk) {
2980 for (const listener of this._rangeListeners) {
2981 listener(begin, chunk);
2982 }
2983 }
2984 onDataProgress(loaded, total) {
2985 this._readyCapability.promise.then(() => {
2986 for (const listener of this._progressListeners) {
2987 listener(loaded, total);
2988 }
2989 });
2990 }
2991 onDataProgressiveRead(chunk) {
2992 this._readyCapability.promise.then(() => {
2993 for (const listener of this._progressiveReadListeners) {
2994 listener(chunk);
2995 }
2996 });
2997 }
2998 onDataProgressiveDone() {
2999 this._readyCapability.promise.then(() => {
3000 for (const listener of this._progressiveDoneListeners) {
3001 listener();
3002 }
3003 });
3004 }
3005 transportReady() {
3006 this._readyCapability.resolve();
3007 }
3008 requestDataRange(begin, end) {
3009 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
3010 }
3011 abort() {}
3012}
3013class PDFDocumentProxy {
3014 constructor(pdfInfo, transport) {
3015 this._pdfInfo = pdfInfo;
3016 this._transport = transport;
3017 }
3018 get annotationStorage() {
3019 return this._transport.annotationStorage;
3020 }
3021 get filterFactory() {
3022 return this._transport.filterFactory;
3023 }
3024 get numPages() {
3025 return this._pdfInfo.numPages;
3026 }
3027 get fingerprints() {
3028 return this._pdfInfo.fingerprints;
3029 }
3030 get isPureXfa() {
3031 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
3032 }
3033 get allXfaHtml() {
3034 return this._transport._htmlForXfa;
3035 }
3036 getPage(pageNumber) {
3037 return this._transport.getPage(pageNumber);
3038 }
3039 getPageIndex(ref) {
3040 return this._transport.getPageIndex(ref);
3041 }
3042 getDestinations() {
3043 return this._transport.getDestinations();
3044 }
3045 getDestination(id) {
3046 return this._transport.getDestination(id);
3047 }
3048 getPageLabels() {
3049 return this._transport.getPageLabels();
3050 }
3051 getPageLayout() {
3052 return this._transport.getPageLayout();
3053 }
3054 getPageMode() {
3055 return this._transport.getPageMode();
3056 }
3057 getViewerPreferences() {
3058 return this._transport.getViewerPreferences();
3059 }
3060 getOpenAction() {
3061 return this._transport.getOpenAction();
3062 }
3063 getAttachments() {
3064 return this._transport.getAttachments();
3065 }
3066 getJSActions() {
3067 return this._transport.getDocJSActions();
3068 }
3069 getOutline() {
3070 return this._transport.getOutline();
3071 }
3072 getOptionalContentConfig() {
3073 return this._transport.getOptionalContentConfig();
3074 }
3075 getPermissions() {
3076 return this._transport.getPermissions();
3077 }
3078 getMetadata() {
3079 return this._transport.getMetadata();
3080 }
3081 getMarkInfo() {
3082 return this._transport.getMarkInfo();
3083 }
3084 getData() {
3085 return this._transport.getData();
3086 }
3087 saveDocument() {
3088 return this._transport.saveDocument();
3089 }
3090 getDownloadInfo() {
3091 return this._transport.downloadInfoCapability.promise;
3092 }
3093 cleanup(keepLoadedFonts = false) {
3094 return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
3095 }
3096 destroy() {
3097 return this.loadingTask.destroy();
3098 }
3099 get loadingParams() {
3100 return this._transport.loadingParams;
3101 }
3102 get loadingTask() {
3103 return this._transport.loadingTask;
3104 }
3105 getFieldObjects() {
3106 return this._transport.getFieldObjects();
3107 }
3108 hasJSActions() {
3109 return this._transport.hasJSActions();
3110 }
3111 getCalculationOrderIds() {
3112 return this._transport.getCalculationOrderIds();
3113 }
3114}
3115class PDFPageProxy {
3116 #delayedCleanupTimeout = null;
3117 #pendingCleanup = false;
3118 constructor(pageIndex, pageInfo, transport, pdfBug = false) {
3119 this._pageIndex = pageIndex;
3120 this._pageInfo = pageInfo;
3121 this._transport = transport;
3122 this._stats = pdfBug ? new _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.StatTimer() : null;
3123 this._pdfBug = pdfBug;
3124 this.commonObjs = transport.commonObjs;
3125 this.objs = new PDFObjects();
3126 this._maybeCleanupAfterRender = false;
3127 this._intentStates = new Map();
3128 this.destroyed = false;
3129 }
3130 get pageNumber() {
3131 return this._pageIndex + 1;
3132 }
3133 get rotate() {
3134 return this._pageInfo.rotate;
3135 }
3136 get ref() {
3137 return this._pageInfo.ref;
3138 }
3139 get userUnit() {
3140 return this._pageInfo.userUnit;
3141 }
3142 get view() {
3143 return this._pageInfo.view;
3144 }
3145 getViewport({
3146 scale,
3147 rotation = this.rotate,
3148 offsetX = 0,
3149 offsetY = 0,
3150 dontFlip = false
3151 } = {}) {
3152 return new _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.PageViewport({
3153 viewBox: this.view,
3154 scale,
3155 rotation,
3156 offsetX,
3157 offsetY,
3158 dontFlip
3159 });
3160 }
3161 getAnnotations({
3162 intent = "display"
3163 } = {}) {
3164 const intentArgs = this._transport.getRenderingIntent(intent);
3165 return this._transport.getAnnotations(this._pageIndex, intentArgs.renderingIntent);
3166 }
3167 getJSActions() {
3168 return this._transport.getPageJSActions(this._pageIndex);
3169 }
3170 get filterFactory() {
3171 return this._transport.filterFactory;
3172 }
3173 get isPureXfa() {
3174 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
3175 }
3176 async getXfa() {
3177 return this._transport._htmlForXfa?.children[this._pageIndex] || null;
3178 }
3179 render({
3180 canvasContext,
3181 viewport,
3182 intent = "display",
3183 annotationMode = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE,
3184 transform = null,
3185 background = null,
3186 optionalContentConfigPromise = null,
3187 annotationCanvasMap = null,
3188 pageColors = null,
3189 printAnnotationStorage = null
3190 }) {
3191 this._stats?.time("Overall");
3192 const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage);
3193 this.#pendingCleanup = false;
3194 this.#abortDelayedCleanup();
3195 if (!optionalContentConfigPromise) {
3196 optionalContentConfigPromise = this._transport.getOptionalContentConfig();
3197 }
3198 let intentState = this._intentStates.get(intentArgs.cacheKey);
3199 if (!intentState) {
3200 intentState = Object.create(null);
3201 this._intentStates.set(intentArgs.cacheKey, intentState);
3202 }
3203 if (intentState.streamReaderCancelTimeout) {
3204 clearTimeout(intentState.streamReaderCancelTimeout);
3205 intentState.streamReaderCancelTimeout = null;
3206 }
3207 const intentPrint = !!(intentArgs.renderingIntent & _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.PRINT);
3208 if (!intentState.displayReadyCapability) {
3209 intentState.displayReadyCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
3210 intentState.operatorList = {
3211 fnArray: [],
3212 argsArray: [],
3213 lastChunk: false,
3214 separateAnnots: null
3215 };
3216 this._stats?.time("Page Request");
3217 this._pumpOperatorList(intentArgs);
3218 }
3219 const complete = error => {
3220 intentState.renderTasks.delete(internalRenderTask);
3221 if (this._maybeCleanupAfterRender || intentPrint) {
3222 this.#pendingCleanup = true;
3223 }
3224 this.#tryCleanup(!intentPrint);
3225 if (error) {
3226 internalRenderTask.capability.reject(error);
3227 this._abortOperatorList({
3228 intentState,
3229 reason: error instanceof Error ? error : new Error(error)
3230 });
3231 } else {
3232 internalRenderTask.capability.resolve();
3233 }
3234 this._stats?.timeEnd("Rendering");
3235 this._stats?.timeEnd("Overall");
3236 };
3237 const internalRenderTask = new InternalRenderTask({
3238 callback: complete,
3239 params: {
3240 canvasContext,
3241 viewport,
3242 transform,
3243 background
3244 },
3245 objs: this.objs,
3246 commonObjs: this.commonObjs,
3247 annotationCanvasMap,
3248 operatorList: intentState.operatorList,
3249 pageIndex: this._pageIndex,
3250 canvasFactory: this._transport.canvasFactory,
3251 filterFactory: this._transport.filterFactory,
3252 useRequestAnimationFrame: !intentPrint,
3253 pdfBug: this._pdfBug,
3254 pageColors
3255 });
3256 (intentState.renderTasks ||= new Set()).add(internalRenderTask);
3257 const renderTask = internalRenderTask.task;
3258 Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {
3259 if (this.destroyed) {
3260 complete();
3261 return;
3262 }
3263 this._stats?.time("Rendering");
3264 internalRenderTask.initializeGraphics({
3265 transparency,
3266 optionalContentConfig
3267 });
3268 internalRenderTask.operatorListChanged();
3269 }).catch(complete);
3270 return renderTask;
3271 }
3272 getOperatorList({
3273 intent = "display",
3274 annotationMode = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE,
3275 printAnnotationStorage = null
3276 } = {}) {
3277 function operatorListChanged() {
3278 if (intentState.operatorList.lastChunk) {
3279 intentState.opListReadCapability.resolve(intentState.operatorList);
3280 intentState.renderTasks.delete(opListTask);
3281 }
3282 }
3283 const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage, true);
3284 let intentState = this._intentStates.get(intentArgs.cacheKey);
3285 if (!intentState) {
3286 intentState = Object.create(null);
3287 this._intentStates.set(intentArgs.cacheKey, intentState);
3288 }
3289 let opListTask;
3290 if (!intentState.opListReadCapability) {
3291 opListTask = Object.create(null);
3292 opListTask.operatorListChanged = operatorListChanged;
3293 intentState.opListReadCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
3294 (intentState.renderTasks ||= new Set()).add(opListTask);
3295 intentState.operatorList = {
3296 fnArray: [],
3297 argsArray: [],
3298 lastChunk: false,
3299 separateAnnots: null
3300 };
3301 this._stats?.time("Page Request");
3302 this._pumpOperatorList(intentArgs);
3303 }
3304 return intentState.opListReadCapability.promise;
3305 }
3306 streamTextContent({
3307 includeMarkedContent = false,
3308 disableNormalization = false
3309 } = {}) {
3310 const TEXT_CONTENT_CHUNK_SIZE = 100;
3311 return this._transport.messageHandler.sendWithStream("GetTextContent", {
3312 pageIndex: this._pageIndex,
3313 includeMarkedContent: includeMarkedContent === true,
3314 disableNormalization: disableNormalization === true
3315 }, {
3316 highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
3317 size(textContent) {
3318 return textContent.items.length;
3319 }
3320 });
3321 }
3322 getTextContent(params = {}) {
3323 if (this._transport._htmlForXfa) {
3324 return this.getXfa().then(xfa => {
3325 return _xfa_text_js__WEBPACK_IMPORTED_MODULE_14__.XfaText.textContent(xfa);
3326 });
3327 }
3328 const readableStream = this.streamTextContent(params);
3329 return new Promise(function (resolve, reject) {
3330 function pump() {
3331 reader.read().then(function ({
3332 value,
3333 done
3334 }) {
3335 if (done) {
3336 resolve(textContent);
3337 return;
3338 }
3339 Object.assign(textContent.styles, value.styles);
3340 textContent.items.push(...value.items);
3341 pump();
3342 }, reject);
3343 }
3344 const reader = readableStream.getReader();
3345 const textContent = {
3346 items: [],
3347 styles: Object.create(null)
3348 };
3349 pump();
3350 });
3351 }
3352 getStructTree() {
3353 return this._transport.getStructTree(this._pageIndex);
3354 }
3355 _destroy() {
3356 this.destroyed = true;
3357 const waitOn = [];
3358 for (const intentState of this._intentStates.values()) {
3359 this._abortOperatorList({
3360 intentState,
3361 reason: new Error("Page was destroyed."),
3362 force: true
3363 });
3364 if (intentState.opListReadCapability) {
3365 continue;
3366 }
3367 for (const internalRenderTask of intentState.renderTasks) {
3368 waitOn.push(internalRenderTask.completed);
3369 internalRenderTask.cancel();
3370 }
3371 }
3372 this.objs.clear();
3373 this.#pendingCleanup = false;
3374 this.#abortDelayedCleanup();
3375 return Promise.all(waitOn);
3376 }
3377 cleanup(resetStats = false) {
3378 this.#pendingCleanup = true;
3379 const success = this.#tryCleanup(false);
3380 if (resetStats && success) {
3381 this._stats &&= new _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.StatTimer();
3382 }
3383 return success;
3384 }
3385 #tryCleanup(delayed = false) {
3386 this.#abortDelayedCleanup();
3387 if (!this.#pendingCleanup || this.destroyed) {
3388 return false;
3389 }
3390 if (delayed) {
3391 this.#delayedCleanupTimeout = setTimeout(() => {
3392 this.#delayedCleanupTimeout = null;
3393 this.#tryCleanup(false);
3394 }, DELAYED_CLEANUP_TIMEOUT);
3395 return false;
3396 }
3397 for (const {
3398 renderTasks,
3399 operatorList
3400 } of this._intentStates.values()) {
3401 if (renderTasks.size > 0 || !operatorList.lastChunk) {
3402 return false;
3403 }
3404 }
3405 this._intentStates.clear();
3406 this.objs.clear();
3407 this.#pendingCleanup = false;
3408 return true;
3409 }
3410 #abortDelayedCleanup() {
3411 if (this.#delayedCleanupTimeout) {
3412 clearTimeout(this.#delayedCleanupTimeout);
3413 this.#delayedCleanupTimeout = null;
3414 }
3415 }
3416 _startRenderPage(transparency, cacheKey) {
3417 const intentState = this._intentStates.get(cacheKey);
3418 if (!intentState) {
3419 return;
3420 }
3421 this._stats?.timeEnd("Page Request");
3422 intentState.displayReadyCapability?.resolve(transparency);
3423 }
3424 _renderPageChunk(operatorListChunk, intentState) {
3425 for (let i = 0, ii = operatorListChunk.length; i < ii; i++) {
3426 intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
3427 intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
3428 }
3429 intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
3430 intentState.operatorList.separateAnnots = operatorListChunk.separateAnnots;
3431 for (const internalRenderTask of intentState.renderTasks) {
3432 internalRenderTask.operatorListChanged();
3433 }
3434 if (operatorListChunk.lastChunk) {
3435 this.#tryCleanup(true);
3436 }
3437 }
3438 _pumpOperatorList({
3439 renderingIntent,
3440 cacheKey,
3441 annotationStorageSerializable
3442 }) {
3443 const {
3444 map,
3445 transfer
3446 } = annotationStorageSerializable;
3447 const readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", {
3448 pageIndex: this._pageIndex,
3449 intent: renderingIntent,
3450 cacheKey,
3451 annotationStorage: map
3452 }, transfer);
3453 const reader = readableStream.getReader();
3454 const intentState = this._intentStates.get(cacheKey);
3455 intentState.streamReader = reader;
3456 const pump = () => {
3457 reader.read().then(({
3458 value,
3459 done
3460 }) => {
3461 if (done) {
3462 intentState.streamReader = null;
3463 return;
3464 }
3465 if (this._transport.destroyed) {
3466 return;
3467 }
3468 this._renderPageChunk(value, intentState);
3469 pump();
3470 }, reason => {
3471 intentState.streamReader = null;
3472 if (this._transport.destroyed) {
3473 return;
3474 }
3475 if (intentState.operatorList) {
3476 intentState.operatorList.lastChunk = true;
3477 for (const internalRenderTask of intentState.renderTasks) {
3478 internalRenderTask.operatorListChanged();
3479 }
3480 this.#tryCleanup(true);
3481 }
3482 if (intentState.displayReadyCapability) {
3483 intentState.displayReadyCapability.reject(reason);
3484 } else if (intentState.opListReadCapability) {
3485 intentState.opListReadCapability.reject(reason);
3486 } else {
3487 throw reason;
3488 }
3489 });
3490 };
3491 pump();
3492 }
3493 _abortOperatorList({
3494 intentState,
3495 reason,
3496 force = false
3497 }) {
3498 if (!intentState.streamReader) {
3499 return;
3500 }
3501 if (intentState.streamReaderCancelTimeout) {
3502 clearTimeout(intentState.streamReaderCancelTimeout);
3503 intentState.streamReaderCancelTimeout = null;
3504 }
3505 if (!force) {
3506 if (intentState.renderTasks.size > 0) {
3507 return;
3508 }
3509 if (reason instanceof _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.RenderingCancelledException) {
3510 let delay = RENDERING_CANCELLED_TIMEOUT;
3511 if (reason.extraDelay > 0 && reason.extraDelay < 1000) {
3512 delay += reason.extraDelay;
3513 }
3514 intentState.streamReaderCancelTimeout = setTimeout(() => {
3515 intentState.streamReaderCancelTimeout = null;
3516 this._abortOperatorList({
3517 intentState,
3518 reason,
3519 force: true
3520 });
3521 }, delay);
3522 return;
3523 }
3524 }
3525 intentState.streamReader.cancel(new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AbortException(reason.message)).catch(() => {});
3526 intentState.streamReader = null;
3527 if (this._transport.destroyed) {
3528 return;
3529 }
3530 for (const [curCacheKey, curIntentState] of this._intentStates) {
3531 if (curIntentState === intentState) {
3532 this._intentStates.delete(curCacheKey);
3533 break;
3534 }
3535 }
3536 this.cleanup();
3537 }
3538 get stats() {
3539 return this._stats;
3540 }
3541}
3542class LoopbackPort {
3543 #listeners = new Set();
3544 #deferred = Promise.resolve();
3545 postMessage(obj, transfer) {
3546 const event = {
3547 data: structuredClone(obj, transfer ? {
3548 transfer
3549 } : null)
3550 };
3551 this.#deferred.then(() => {
3552 for (const listener of this.#listeners) {
3553 listener.call(this, event);
3554 }
3555 });
3556 }
3557 addEventListener(name, listener) {
3558 this.#listeners.add(listener);
3559 }
3560 removeEventListener(name, listener) {
3561 this.#listeners.delete(listener);
3562 }
3563 terminate() {
3564 this.#listeners.clear();
3565 }
3566}
3567const PDFWorkerUtil = {
3568 isWorkerDisabled: false,
3569 fakeWorkerId: 0
3570};
3571{
3572 if (_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.isNodeJS) {
3573 PDFWorkerUtil.isWorkerDisabled = true;
3574 _worker_options_js__WEBPACK_IMPORTED_MODULE_6__.GlobalWorkerOptions.workerSrc ||= "./pdf.worker.mjs";
3575 }
3576 PDFWorkerUtil.isSameOrigin = function (baseUrl, otherUrl) {
3577 let base;
3578 try {
3579 base = new URL(baseUrl);
3580 if (!base.origin || base.origin === "null") {
3581 return false;
3582 }
3583 } catch {
3584 return false;
3585 }
3586 const other = new URL(otherUrl, base);
3587 return base.origin === other.origin;
3588 };
3589 PDFWorkerUtil.createCDNWrapper = function (url) {
3590 const wrapper = `await import("${url}");`;
3591 return URL.createObjectURL(new Blob([wrapper], {
3592 type: "text/javascript"
3593 }));
3594 };
3595}
3596class PDFWorker {
3597 static #workerPorts;
3598 constructor({
3599 name = null,
3600 port = null,
3601 verbosity = (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.getVerbosityLevel)()
3602 } = {}) {
3603 this.name = name;
3604 this.destroyed = false;
3605 this.verbosity = verbosity;
3606 this._readyCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
3607 this._port = null;
3608 this._webWorker = null;
3609 this._messageHandler = null;
3610 if (port) {
3611 if (PDFWorker.#workerPorts?.has(port)) {
3612 throw new Error("Cannot use more than one PDFWorker per port.");
3613 }
3614 (PDFWorker.#workerPorts ||= new WeakMap()).set(port, this);
3615 this._initializeFromPort(port);
3616 return;
3617 }
3618 this._initialize();
3619 }
3620 get promise() {
3621 return this._readyCapability.promise;
3622 }
3623 get port() {
3624 return this._port;
3625 }
3626 get messageHandler() {
3627 return this._messageHandler;
3628 }
3629 _initializeFromPort(port) {
3630 this._port = port;
3631 this._messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_7__.MessageHandler("main", "worker", port);
3632 this._messageHandler.on("ready", function () {});
3633 this._readyCapability.resolve();
3634 this._messageHandler.send("configure", {
3635 verbosity: this.verbosity
3636 });
3637 }
3638 _initialize() {
3639 if (!PDFWorkerUtil.isWorkerDisabled && !PDFWorker.#mainThreadWorkerMessageHandler) {
3640 let {
3641 workerSrc
3642 } = PDFWorker;
3643 try {
3644 if (!PDFWorkerUtil.isSameOrigin(window.location.href, workerSrc)) {
3645 workerSrc = PDFWorkerUtil.createCDNWrapper(new URL(workerSrc, window.location).href);
3646 }
3647 const worker = new Worker(workerSrc, {
3648 type: "module"
3649 });
3650 const messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_7__.MessageHandler("main", "worker", worker);
3651 const terminateEarly = () => {
3652 worker.removeEventListener("error", onWorkerError);
3653 messageHandler.destroy();
3654 worker.terminate();
3655 if (this.destroyed) {
3656 this._readyCapability.reject(new Error("Worker was destroyed"));
3657 } else {
3658 this._setupFakeWorker();
3659 }
3660 };
3661 const onWorkerError = () => {
3662 if (!this._webWorker) {
3663 terminateEarly();
3664 }
3665 };
3666 worker.addEventListener("error", onWorkerError);
3667 messageHandler.on("test", data => {
3668 worker.removeEventListener("error", onWorkerError);
3669 if (this.destroyed) {
3670 terminateEarly();
3671 return;
3672 }
3673 if (data) {
3674 this._messageHandler = messageHandler;
3675 this._port = worker;
3676 this._webWorker = worker;
3677 this._readyCapability.resolve();
3678 messageHandler.send("configure", {
3679 verbosity: this.verbosity
3680 });
3681 } else {
3682 this._setupFakeWorker();
3683 messageHandler.destroy();
3684 worker.terminate();
3685 }
3686 });
3687 messageHandler.on("ready", data => {
3688 worker.removeEventListener("error", onWorkerError);
3689 if (this.destroyed) {
3690 terminateEarly();
3691 return;
3692 }
3693 try {
3694 sendTest();
3695 } catch {
3696 this._setupFakeWorker();
3697 }
3698 });
3699 const sendTest = () => {
3700 const testObj = new Uint8Array();
3701 messageHandler.send("test", testObj, [testObj.buffer]);
3702 };
3703 sendTest();
3704 return;
3705 } catch {
3706 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.info)("The worker has been disabled.");
3707 }
3708 }
3709 this._setupFakeWorker();
3710 }
3711 _setupFakeWorker() {
3712 if (!PDFWorkerUtil.isWorkerDisabled) {
3713 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)("Setting up fake worker.");
3714 PDFWorkerUtil.isWorkerDisabled = true;
3715 }
3716 PDFWorker._setupFakeWorkerGlobal.then(WorkerMessageHandler => {
3717 if (this.destroyed) {
3718 this._readyCapability.reject(new Error("Worker was destroyed"));
3719 return;
3720 }
3721 const port = new LoopbackPort();
3722 this._port = port;
3723 const id = `fake${PDFWorkerUtil.fakeWorkerId++}`;
3724 const workerHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_7__.MessageHandler(id + "_worker", id, port);
3725 WorkerMessageHandler.setup(workerHandler, port);
3726 const messageHandler = new _shared_message_handler_js__WEBPACK_IMPORTED_MODULE_7__.MessageHandler(id, id + "_worker", port);
3727 this._messageHandler = messageHandler;
3728 this._readyCapability.resolve();
3729 messageHandler.send("configure", {
3730 verbosity: this.verbosity
3731 });
3732 }).catch(reason => {
3733 this._readyCapability.reject(new Error(`Setting up fake worker failed: "${reason.message}".`));
3734 });
3735 }
3736 destroy() {
3737 this.destroyed = true;
3738 if (this._webWorker) {
3739 this._webWorker.terminate();
3740 this._webWorker = null;
3741 }
3742 PDFWorker.#workerPorts?.delete(this._port);
3743 this._port = null;
3744 if (this._messageHandler) {
3745 this._messageHandler.destroy();
3746 this._messageHandler = null;
3747 }
3748 }
3749 static fromPort(params) {
3750 if (!params?.port) {
3751 throw new Error("PDFWorker.fromPort - invalid method signature.");
3752 }
3753 const cachedPort = this.#workerPorts?.get(params.port);
3754 if (cachedPort) {
3755 if (cachedPort._pendingDestroy) {
3756 throw new Error("PDFWorker.fromPort - the worker is being destroyed.\n" + "Please remember to await `PDFDocumentLoadingTask.destroy()`-calls.");
3757 }
3758 return cachedPort;
3759 }
3760 return new PDFWorker(params);
3761 }
3762 static get workerSrc() {
3763 if (_worker_options_js__WEBPACK_IMPORTED_MODULE_6__.GlobalWorkerOptions.workerSrc) {
3764 return _worker_options_js__WEBPACK_IMPORTED_MODULE_6__.GlobalWorkerOptions.workerSrc;
3765 }
3766 throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
3767 }
3768 static get #mainThreadWorkerMessageHandler() {
3769 try {
3770 return globalThis.pdfjsWorker?.WorkerMessageHandler || null;
3771 } catch {
3772 return null;
3773 }
3774 }
3775 static get _setupFakeWorkerGlobal() {
3776 const loader = async () => {
3777 if (this.#mainThreadWorkerMessageHandler) {
3778 return this.#mainThreadWorkerMessageHandler;
3779 }
3780 const worker = await import(/* webpackIgnore: true */ this.workerSrc);
3781 return worker.WorkerMessageHandler;
3782 };
3783 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_setupFakeWorkerGlobal", loader());
3784 }
3785}
3786class WorkerTransport {
3787 #methodPromises = new Map();
3788 #pageCache = new Map();
3789 #pagePromises = new Map();
3790 #passwordCapability = null;
3791 constructor(messageHandler, loadingTask, networkStream, params, factory) {
3792 this.messageHandler = messageHandler;
3793 this.loadingTask = loadingTask;
3794 this.commonObjs = new PDFObjects();
3795 this.fontLoader = new _font_loader_js__WEBPACK_IMPORTED_MODULE_3__.FontLoader({
3796 ownerDocument: params.ownerDocument,
3797 styleElement: params.styleElement
3798 });
3799 this._params = params;
3800 this.canvasFactory = factory.canvasFactory;
3801 this.filterFactory = factory.filterFactory;
3802 this.cMapReaderFactory = factory.cMapReaderFactory;
3803 this.standardFontDataFactory = factory.standardFontDataFactory;
3804 this.destroyed = false;
3805 this.destroyCapability = null;
3806 this._networkStream = networkStream;
3807 this._fullReader = null;
3808 this._lastProgress = null;
3809 this.downloadInfoCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
3810 this.setupMessageHandler();
3811 }
3812 #cacheSimpleMethod(name, data = null) {
3813 const cachedPromise = this.#methodPromises.get(name);
3814 if (cachedPromise) {
3815 return cachedPromise;
3816 }
3817 const promise = this.messageHandler.sendWithPromise(name, data);
3818 this.#methodPromises.set(name, promise);
3819 return promise;
3820 }
3821 get annotationStorage() {
3822 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "annotationStorage", new _annotation_storage_js__WEBPACK_IMPORTED_MODULE_1__.AnnotationStorage());
3823 }
3824 getRenderingIntent(intent, annotationMode = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE, printAnnotationStorage = null, isOpList = false) {
3825 let renderingIntent = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.DISPLAY;
3826 let annotationStorageSerializable = _annotation_storage_js__WEBPACK_IMPORTED_MODULE_1__.SerializableEmpty;
3827 switch (intent) {
3828 case "any":
3829 renderingIntent = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.ANY;
3830 break;
3831 case "display":
3832 break;
3833 case "print":
3834 renderingIntent = _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.PRINT;
3835 break;
3836 default:
3837 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`getRenderingIntent - invalid intent: ${intent}`);
3838 }
3839 switch (annotationMode) {
3840 case _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.DISABLE:
3841 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.ANNOTATIONS_DISABLE;
3842 break;
3843 case _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE:
3844 break;
3845 case _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS:
3846 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.ANNOTATIONS_FORMS;
3847 break;
3848 case _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_STORAGE:
3849 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.ANNOTATIONS_STORAGE;
3850 const annotationStorage = renderingIntent & _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.PRINT && printAnnotationStorage instanceof _annotation_storage_js__WEBPACK_IMPORTED_MODULE_1__.PrintAnnotationStorage ? printAnnotationStorage : this.annotationStorage;
3851 annotationStorageSerializable = annotationStorage.serializable;
3852 break;
3853 default:
3854 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
3855 }
3856 if (isOpList) {
3857 renderingIntent += _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.RenderingIntentFlag.OPLIST;
3858 }
3859 return {
3860 renderingIntent,
3861 cacheKey: `${renderingIntent}_${annotationStorageSerializable.hash}`,
3862 annotationStorageSerializable
3863 };
3864 }
3865 destroy() {
3866 if (this.destroyCapability) {
3867 return this.destroyCapability.promise;
3868 }
3869 this.destroyed = true;
3870 this.destroyCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
3871 this.#passwordCapability?.reject(new Error("Worker was destroyed during onPassword callback"));
3872 const waitOn = [];
3873 for (const page of this.#pageCache.values()) {
3874 waitOn.push(page._destroy());
3875 }
3876 this.#pageCache.clear();
3877 this.#pagePromises.clear();
3878 if (this.hasOwnProperty("annotationStorage")) {
3879 this.annotationStorage.resetModified();
3880 }
3881 const terminated = this.messageHandler.sendWithPromise("Terminate", null);
3882 waitOn.push(terminated);
3883 Promise.all(waitOn).then(() => {
3884 this.commonObjs.clear();
3885 this.fontLoader.clear();
3886 this.#methodPromises.clear();
3887 this.filterFactory.destroy();
3888 this._networkStream?.cancelAllRequests(new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.AbortException("Worker was terminated."));
3889 if (this.messageHandler) {
3890 this.messageHandler.destroy();
3891 this.messageHandler = null;
3892 }
3893 this.destroyCapability.resolve();
3894 }, this.destroyCapability.reject);
3895 return this.destroyCapability.promise;
3896 }
3897 setupMessageHandler() {
3898 const {
3899 messageHandler,
3900 loadingTask
3901 } = this;
3902 messageHandler.on("GetReader", (data, sink) => {
3903 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.assert)(this._networkStream, "GetReader - no `IPDFStream` instance available.");
3904 this._fullReader = this._networkStream.getFullReader();
3905 this._fullReader.onProgress = evt => {
3906 this._lastProgress = {
3907 loaded: evt.loaded,
3908 total: evt.total
3909 };
3910 };
3911 sink.onPull = () => {
3912 this._fullReader.read().then(function ({
3913 value,
3914 done
3915 }) {
3916 if (done) {
3917 sink.close();
3918 return;
3919 }
3920 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.assert)(value instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer.");
3921 sink.enqueue(new Uint8Array(value), 1, [value]);
3922 }).catch(reason => {
3923 sink.error(reason);
3924 });
3925 };
3926 sink.onCancel = reason => {
3927 this._fullReader.cancel(reason);
3928 sink.ready.catch(readyReason => {
3929 if (this.destroyed) {
3930 return;
3931 }
3932 throw readyReason;
3933 });
3934 };
3935 });
3936 messageHandler.on("ReaderHeadersReady", data => {
3937 const headersCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
3938 const fullReader = this._fullReader;
3939 fullReader.headersReady.then(() => {
3940 if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
3941 if (this._lastProgress) {
3942 loadingTask.onProgress?.(this._lastProgress);
3943 }
3944 fullReader.onProgress = evt => {
3945 loadingTask.onProgress?.({
3946 loaded: evt.loaded,
3947 total: evt.total
3948 });
3949 };
3950 }
3951 headersCapability.resolve({
3952 isStreamingSupported: fullReader.isStreamingSupported,
3953 isRangeSupported: fullReader.isRangeSupported,
3954 contentLength: fullReader.contentLength
3955 });
3956 }, headersCapability.reject);
3957 return headersCapability.promise;
3958 });
3959 messageHandler.on("GetRangeReader", (data, sink) => {
3960 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.assert)(this._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
3961 const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
3962 if (!rangeReader) {
3963 sink.close();
3964 return;
3965 }
3966 sink.onPull = () => {
3967 rangeReader.read().then(function ({
3968 value,
3969 done
3970 }) {
3971 if (done) {
3972 sink.close();
3973 return;
3974 }
3975 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.assert)(value instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer.");
3976 sink.enqueue(new Uint8Array(value), 1, [value]);
3977 }).catch(reason => {
3978 sink.error(reason);
3979 });
3980 };
3981 sink.onCancel = reason => {
3982 rangeReader.cancel(reason);
3983 sink.ready.catch(readyReason => {
3984 if (this.destroyed) {
3985 return;
3986 }
3987 throw readyReason;
3988 });
3989 };
3990 });
3991 messageHandler.on("GetDoc", ({
3992 pdfInfo
3993 }) => {
3994 this._numPages = pdfInfo.numPages;
3995 this._htmlForXfa = pdfInfo.htmlForXfa;
3996 delete pdfInfo.htmlForXfa;
3997 loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
3998 });
3999 messageHandler.on("DocException", function (ex) {
4000 let reason;
4001 switch (ex.name) {
4002 case "PasswordException":
4003 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PasswordException(ex.message, ex.code);
4004 break;
4005 case "InvalidPDFException":
4006 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.InvalidPDFException(ex.message);
4007 break;
4008 case "MissingPDFException":
4009 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.MissingPDFException(ex.message);
4010 break;
4011 case "UnexpectedResponseException":
4012 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.UnexpectedResponseException(ex.message, ex.status);
4013 break;
4014 case "UnknownErrorException":
4015 reason = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.UnknownErrorException(ex.message, ex.details);
4016 break;
4017 default:
4018 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("DocException - expected a valid Error.");
4019 }
4020 loadingTask._capability.reject(reason);
4021 });
4022 messageHandler.on("PasswordRequest", exception => {
4023 this.#passwordCapability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
4024 if (loadingTask.onPassword) {
4025 const updatePassword = password => {
4026 if (password instanceof Error) {
4027 this.#passwordCapability.reject(password);
4028 } else {
4029 this.#passwordCapability.resolve({
4030 password
4031 });
4032 }
4033 };
4034 try {
4035 loadingTask.onPassword(updatePassword, exception.code);
4036 } catch (ex) {
4037 this.#passwordCapability.reject(ex);
4038 }
4039 } else {
4040 this.#passwordCapability.reject(new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PasswordException(exception.message, exception.code));
4041 }
4042 return this.#passwordCapability.promise;
4043 });
4044 messageHandler.on("DataLoaded", data => {
4045 loadingTask.onProgress?.({
4046 loaded: data.length,
4047 total: data.length
4048 });
4049 this.downloadInfoCapability.resolve(data);
4050 });
4051 messageHandler.on("StartRenderPage", data => {
4052 if (this.destroyed) {
4053 return;
4054 }
4055 const page = this.#pageCache.get(data.pageIndex);
4056 page._startRenderPage(data.transparency, data.cacheKey);
4057 });
4058 messageHandler.on("commonobj", ([id, type, exportedData]) => {
4059 if (this.destroyed) {
4060 return;
4061 }
4062 if (this.commonObjs.has(id)) {
4063 return;
4064 }
4065 switch (type) {
4066 case "Font":
4067 const params = this._params;
4068 if ("error" in exportedData) {
4069 const exportedError = exportedData.error;
4070 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)(`Error during font loading: ${exportedError}`);
4071 this.commonObjs.resolve(id, exportedError);
4072 break;
4073 }
4074 const inspectFont = params.pdfBug && globalThis.FontInspector?.enabled ? (font, url) => globalThis.FontInspector.fontAdded(font, url) : null;
4075 const font = new _font_loader_js__WEBPACK_IMPORTED_MODULE_3__.FontFaceObject(exportedData, {
4076 isEvalSupported: params.isEvalSupported,
4077 disableFontFace: params.disableFontFace,
4078 ignoreErrors: params.ignoreErrors,
4079 inspectFont
4080 });
4081 this.fontLoader.bind(font).catch(reason => {
4082 return messageHandler.sendWithPromise("FontFallback", {
4083 id
4084 });
4085 }).finally(() => {
4086 if (!params.fontExtraProperties && font.data) {
4087 font.data = null;
4088 }
4089 this.commonObjs.resolve(id, font);
4090 });
4091 break;
4092 case "FontPath":
4093 case "Image":
4094 case "Pattern":
4095 this.commonObjs.resolve(id, exportedData);
4096 break;
4097 default:
4098 throw new Error(`Got unknown common object type ${type}`);
4099 }
4100 });
4101 messageHandler.on("obj", ([id, pageIndex, type, imageData]) => {
4102 if (this.destroyed) {
4103 return;
4104 }
4105 const pageProxy = this.#pageCache.get(pageIndex);
4106 if (pageProxy.objs.has(id)) {
4107 return;
4108 }
4109 if (pageProxy._intentStates.size === 0) {
4110 imageData?.bitmap?.close();
4111 return;
4112 }
4113 switch (type) {
4114 case "Image":
4115 pageProxy.objs.resolve(id, imageData);
4116 if (imageData) {
4117 let length;
4118 if (imageData.bitmap) {
4119 const {
4120 width,
4121 height
4122 } = imageData;
4123 length = width * height * 4;
4124 } else {
4125 length = imageData.data?.length || 0;
4126 }
4127 if (length > _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.MAX_IMAGE_SIZE_TO_CACHE) {
4128 pageProxy._maybeCleanupAfterRender = true;
4129 }
4130 }
4131 break;
4132 case "Pattern":
4133 pageProxy.objs.resolve(id, imageData);
4134 break;
4135 default:
4136 throw new Error(`Got unknown object type ${type}`);
4137 }
4138 });
4139 messageHandler.on("DocProgress", data => {
4140 if (this.destroyed) {
4141 return;
4142 }
4143 loadingTask.onProgress?.({
4144 loaded: data.loaded,
4145 total: data.total
4146 });
4147 });
4148 messageHandler.on("FetchBuiltInCMap", data => {
4149 if (this.destroyed) {
4150 return Promise.reject(new Error("Worker was destroyed."));
4151 }
4152 if (!this.cMapReaderFactory) {
4153 return Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."));
4154 }
4155 return this.cMapReaderFactory.fetch(data);
4156 });
4157 messageHandler.on("FetchStandardFontData", data => {
4158 if (this.destroyed) {
4159 return Promise.reject(new Error("Worker was destroyed."));
4160 }
4161 if (!this.standardFontDataFactory) {
4162 return Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."));
4163 }
4164 return this.standardFontDataFactory.fetch(data);
4165 });
4166 }
4167 getData() {
4168 return this.messageHandler.sendWithPromise("GetData", null);
4169 }
4170 saveDocument() {
4171 if (this.annotationStorage.size <= 0) {
4172 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.warn)("saveDocument called while `annotationStorage` is empty, " + "please use the getData-method instead.");
4173 }
4174 const {
4175 map,
4176 transfer
4177 } = this.annotationStorage.serializable;
4178 return this.messageHandler.sendWithPromise("SaveDocument", {
4179 isPureXfa: !!this._htmlForXfa,
4180 numPages: this._numPages,
4181 annotationStorage: map,
4182 filename: this._fullReader?.filename ?? null
4183 }, transfer).finally(() => {
4184 this.annotationStorage.resetModified();
4185 });
4186 }
4187 getPage(pageNumber) {
4188 if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
4189 return Promise.reject(new Error("Invalid page request."));
4190 }
4191 const pageIndex = pageNumber - 1,
4192 cachedPromise = this.#pagePromises.get(pageIndex);
4193 if (cachedPromise) {
4194 return cachedPromise;
4195 }
4196 const promise = this.messageHandler.sendWithPromise("GetPage", {
4197 pageIndex
4198 }).then(pageInfo => {
4199 if (this.destroyed) {
4200 throw new Error("Transport destroyed");
4201 }
4202 const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
4203 this.#pageCache.set(pageIndex, page);
4204 return page;
4205 });
4206 this.#pagePromises.set(pageIndex, promise);
4207 return promise;
4208 }
4209 getPageIndex(ref) {
4210 if (typeof ref !== "object" || ref === null || !Number.isInteger(ref.num) || ref.num < 0 || !Number.isInteger(ref.gen) || ref.gen < 0) {
4211 return Promise.reject(new Error("Invalid pageIndex request."));
4212 }
4213 return this.messageHandler.sendWithPromise("GetPageIndex", {
4214 num: ref.num,
4215 gen: ref.gen
4216 });
4217 }
4218 getAnnotations(pageIndex, intent) {
4219 return this.messageHandler.sendWithPromise("GetAnnotations", {
4220 pageIndex,
4221 intent
4222 });
4223 }
4224 getFieldObjects() {
4225 return this.#cacheSimpleMethod("GetFieldObjects");
4226 }
4227 hasJSActions() {
4228 return this.#cacheSimpleMethod("HasJSActions");
4229 }
4230 getCalculationOrderIds() {
4231 return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
4232 }
4233 getDestinations() {
4234 return this.messageHandler.sendWithPromise("GetDestinations", null);
4235 }
4236 getDestination(id) {
4237 if (typeof id !== "string") {
4238 return Promise.reject(new Error("Invalid destination request."));
4239 }
4240 return this.messageHandler.sendWithPromise("GetDestination", {
4241 id
4242 });
4243 }
4244 getPageLabels() {
4245 return this.messageHandler.sendWithPromise("GetPageLabels", null);
4246 }
4247 getPageLayout() {
4248 return this.messageHandler.sendWithPromise("GetPageLayout", null);
4249 }
4250 getPageMode() {
4251 return this.messageHandler.sendWithPromise("GetPageMode", null);
4252 }
4253 getViewerPreferences() {
4254 return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
4255 }
4256 getOpenAction() {
4257 return this.messageHandler.sendWithPromise("GetOpenAction", null);
4258 }
4259 getAttachments() {
4260 return this.messageHandler.sendWithPromise("GetAttachments", null);
4261 }
4262 getDocJSActions() {
4263 return this.#cacheSimpleMethod("GetDocJSActions");
4264 }
4265 getPageJSActions(pageIndex) {
4266 return this.messageHandler.sendWithPromise("GetPageJSActions", {
4267 pageIndex
4268 });
4269 }
4270 getStructTree(pageIndex) {
4271 return this.messageHandler.sendWithPromise("GetStructTree", {
4272 pageIndex
4273 });
4274 }
4275 getOutline() {
4276 return this.messageHandler.sendWithPromise("GetOutline", null);
4277 }
4278 getOptionalContentConfig() {
4279 return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then(results => {
4280 return new _optional_content_config_js__WEBPACK_IMPORTED_MODULE_9__.OptionalContentConfig(results);
4281 });
4282 }
4283 getPermissions() {
4284 return this.messageHandler.sendWithPromise("GetPermissions", null);
4285 }
4286 getMetadata() {
4287 const name = "GetMetadata",
4288 cachedPromise = this.#methodPromises.get(name);
4289 if (cachedPromise) {
4290 return cachedPromise;
4291 }
4292 const promise = this.messageHandler.sendWithPromise(name, null).then(results => {
4293 return {
4294 info: results[0],
4295 metadata: results[1] ? new _metadata_js__WEBPACK_IMPORTED_MODULE_8__.Metadata(results[1]) : null,
4296 contentDispositionFilename: this._fullReader?.filename ?? null,
4297 contentLength: this._fullReader?.contentLength ?? null
4298 };
4299 });
4300 this.#methodPromises.set(name, promise);
4301 return promise;
4302 }
4303 getMarkInfo() {
4304 return this.messageHandler.sendWithPromise("GetMarkInfo", null);
4305 }
4306 async startCleanup(keepLoadedFonts = false) {
4307 if (this.destroyed) {
4308 return;
4309 }
4310 await this.messageHandler.sendWithPromise("Cleanup", null);
4311 for (const page of this.#pageCache.values()) {
4312 const cleanupSuccessful = page.cleanup();
4313 if (!cleanupSuccessful) {
4314 throw new Error(`startCleanup: Page ${page.pageNumber} is currently rendering.`);
4315 }
4316 }
4317 this.commonObjs.clear();
4318 if (!keepLoadedFonts) {
4319 this.fontLoader.clear();
4320 }
4321 this.#methodPromises.clear();
4322 this.filterFactory.destroy(true);
4323 }
4324 get loadingParams() {
4325 const {
4326 disableAutoFetch,
4327 enableXfa
4328 } = this._params;
4329 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "loadingParams", {
4330 disableAutoFetch,
4331 enableXfa
4332 });
4333 }
4334}
4335class PDFObjects {
4336 #objs = Object.create(null);
4337 #ensureObj(objId) {
4338 return this.#objs[objId] ||= {
4339 capability: new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability(),
4340 data: null
4341 };
4342 }
4343 get(objId, callback = null) {
4344 if (callback) {
4345 const obj = this.#ensureObj(objId);
4346 obj.capability.promise.then(() => callback(obj.data));
4347 return null;
4348 }
4349 const obj = this.#objs[objId];
4350 if (!obj?.capability.settled) {
4351 throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
4352 }
4353 return obj.data;
4354 }
4355 has(objId) {
4356 const obj = this.#objs[objId];
4357 return obj?.capability.settled || false;
4358 }
4359 resolve(objId, data = null) {
4360 const obj = this.#ensureObj(objId);
4361 obj.data = data;
4362 obj.capability.resolve();
4363 }
4364 clear() {
4365 for (const objId in this.#objs) {
4366 const {
4367 data
4368 } = this.#objs[objId];
4369 data?.bitmap?.close();
4370 }
4371 this.#objs = Object.create(null);
4372 }
4373}
4374class RenderTask {
4375 #internalRenderTask = null;
4376 constructor(internalRenderTask) {
4377 this.#internalRenderTask = internalRenderTask;
4378 this.onContinue = null;
4379 }
4380 get promise() {
4381 return this.#internalRenderTask.capability.promise;
4382 }
4383 cancel(extraDelay = 0) {
4384 this.#internalRenderTask.cancel(null, extraDelay);
4385 }
4386 get separateAnnots() {
4387 const {
4388 separateAnnots
4389 } = this.#internalRenderTask.operatorList;
4390 if (!separateAnnots) {
4391 return false;
4392 }
4393 const {
4394 annotationCanvasMap
4395 } = this.#internalRenderTask;
4396 return separateAnnots.form || separateAnnots.canvas && annotationCanvasMap?.size > 0;
4397 }
4398}
4399class InternalRenderTask {
4400 static #canvasInUse = new WeakSet();
4401 constructor({
4402 callback,
4403 params,
4404 objs,
4405 commonObjs,
4406 annotationCanvasMap,
4407 operatorList,
4408 pageIndex,
4409 canvasFactory,
4410 filterFactory,
4411 useRequestAnimationFrame = false,
4412 pdfBug = false,
4413 pageColors = null
4414 }) {
4415 this.callback = callback;
4416 this.params = params;
4417 this.objs = objs;
4418 this.commonObjs = commonObjs;
4419 this.annotationCanvasMap = annotationCanvasMap;
4420 this.operatorListIdx = null;
4421 this.operatorList = operatorList;
4422 this._pageIndex = pageIndex;
4423 this.canvasFactory = canvasFactory;
4424 this.filterFactory = filterFactory;
4425 this._pdfBug = pdfBug;
4426 this.pageColors = pageColors;
4427 this.running = false;
4428 this.graphicsReadyCallback = null;
4429 this.graphicsReady = false;
4430 this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
4431 this.cancelled = false;
4432 this.capability = new _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
4433 this.task = new RenderTask(this);
4434 this._cancelBound = this.cancel.bind(this);
4435 this._continueBound = this._continue.bind(this);
4436 this._scheduleNextBound = this._scheduleNext.bind(this);
4437 this._nextBound = this._next.bind(this);
4438 this._canvas = params.canvasContext.canvas;
4439 }
4440 get completed() {
4441 return this.capability.promise.catch(function () {});
4442 }
4443 initializeGraphics({
4444 transparency = false,
4445 optionalContentConfig
4446 }) {
4447 if (this.cancelled) {
4448 return;
4449 }
4450 if (this._canvas) {
4451 if (InternalRenderTask.#canvasInUse.has(this._canvas)) {
4452 throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
4453 }
4454 InternalRenderTask.#canvasInUse.add(this._canvas);
4455 }
4456 if (this._pdfBug && globalThis.StepperManager?.enabled) {
4457 this.stepper = globalThis.StepperManager.create(this._pageIndex);
4458 this.stepper.init(this.operatorList);
4459 this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
4460 }
4461 const {
4462 canvasContext,
4463 viewport,
4464 transform,
4465 background
4466 } = this.params;
4467 this.gfx = new _canvas_js__WEBPACK_IMPORTED_MODULE_5__.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
4468 optionalContentConfig
4469 }, this.annotationCanvasMap, this.pageColors);
4470 this.gfx.beginDrawing({
4471 transform,
4472 viewport,
4473 transparency,
4474 background
4475 });
4476 this.operatorListIdx = 0;
4477 this.graphicsReady = true;
4478 this.graphicsReadyCallback?.();
4479 }
4480 cancel(error = null, extraDelay = 0) {
4481 this.running = false;
4482 this.cancelled = true;
4483 this.gfx?.endDrawing();
4484 InternalRenderTask.#canvasInUse.delete(this._canvas);
4485 this.callback(error || new _display_utils_js__WEBPACK_IMPORTED_MODULE_2__.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, extraDelay));
4486 }
4487 operatorListChanged() {
4488 if (!this.graphicsReady) {
4489 this.graphicsReadyCallback ||= this._continueBound;
4490 return;
4491 }
4492 this.stepper?.updateOperatorList(this.operatorList);
4493 if (this.running) {
4494 return;
4495 }
4496 this._continue();
4497 }
4498 _continue() {
4499 this.running = true;
4500 if (this.cancelled) {
4501 return;
4502 }
4503 if (this.task.onContinue) {
4504 this.task.onContinue(this._scheduleNextBound);
4505 } else {
4506 this._scheduleNext();
4507 }
4508 }
4509 _scheduleNext() {
4510 if (this._useRequestAnimationFrame) {
4511 window.requestAnimationFrame(() => {
4512 this._nextBound().catch(this._cancelBound);
4513 });
4514 } else {
4515 Promise.resolve().then(this._nextBound).catch(this._cancelBound);
4516 }
4517 }
4518 async _next() {
4519 if (this.cancelled) {
4520 return;
4521 }
4522 this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
4523 if (this.operatorListIdx === this.operatorList.argsArray.length) {
4524 this.running = false;
4525 if (this.operatorList.lastChunk) {
4526 this.gfx.endDrawing();
4527 InternalRenderTask.#canvasInUse.delete(this._canvas);
4528 this.callback();
4529 }
4530 }
4531 }
4532}
4533const version = '4.0.269';
4534const build = 'f4b396f6c';
4535
4536__webpack_async_result__();
4537} catch(e) { __webpack_async_result__(e); } });
4538
4539/***/ }),
4540
4541/***/ 822:
4542/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
4543
4544/* harmony export */ __webpack_require__.d(__webpack_exports__, {
4545/* harmony export */ BaseCMapReaderFactory: () => (/* binding */ BaseCMapReaderFactory),
4546/* harmony export */ BaseCanvasFactory: () => (/* binding */ BaseCanvasFactory),
4547/* harmony export */ BaseFilterFactory: () => (/* binding */ BaseFilterFactory),
4548/* harmony export */ BaseSVGFactory: () => (/* binding */ BaseSVGFactory),
4549/* harmony export */ BaseStandardFontDataFactory: () => (/* binding */ BaseStandardFontDataFactory)
4550/* harmony export */ });
4551/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(266);
4552
4553class BaseFilterFactory {
4554 constructor() {
4555 if (this.constructor === BaseFilterFactory) {
4556 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseFilterFactory.");
4557 }
4558 }
4559 addFilter(maps) {
4560 return "none";
4561 }
4562 addHCMFilter(fgColor, bgColor) {
4563 return "none";
4564 }
4565 addHighlightHCMFilter(fgColor, bgColor, newFgColor, newBgColor) {
4566 return "none";
4567 }
4568 destroy(keepHCM = false) {}
4569}
4570class BaseCanvasFactory {
4571 constructor() {
4572 if (this.constructor === BaseCanvasFactory) {
4573 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseCanvasFactory.");
4574 }
4575 }
4576 create(width, height) {
4577 if (width <= 0 || height <= 0) {
4578 throw new Error("Invalid canvas size");
4579 }
4580 const canvas = this._createCanvas(width, height);
4581 return {
4582 canvas,
4583 context: canvas.getContext("2d")
4584 };
4585 }
4586 reset(canvasAndContext, width, height) {
4587 if (!canvasAndContext.canvas) {
4588 throw new Error("Canvas is not specified");
4589 }
4590 if (width <= 0 || height <= 0) {
4591 throw new Error("Invalid canvas size");
4592 }
4593 canvasAndContext.canvas.width = width;
4594 canvasAndContext.canvas.height = height;
4595 }
4596 destroy(canvasAndContext) {
4597 if (!canvasAndContext.canvas) {
4598 throw new Error("Canvas is not specified");
4599 }
4600 canvasAndContext.canvas.width = 0;
4601 canvasAndContext.canvas.height = 0;
4602 canvasAndContext.canvas = null;
4603 canvasAndContext.context = null;
4604 }
4605 _createCanvas(width, height) {
4606 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_createCanvas` called.");
4607 }
4608}
4609class BaseCMapReaderFactory {
4610 constructor({
4611 baseUrl = null,
4612 isCompressed = true
4613 }) {
4614 if (this.constructor === BaseCMapReaderFactory) {
4615 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseCMapReaderFactory.");
4616 }
4617 this.baseUrl = baseUrl;
4618 this.isCompressed = isCompressed;
4619 }
4620 async fetch({
4621 name
4622 }) {
4623 if (!this.baseUrl) {
4624 throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
4625 }
4626 if (!name) {
4627 throw new Error("CMap name must be specified.");
4628 }
4629 const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
4630 const compressionType = this.isCompressed ? _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.CMapCompressionType.BINARY : _shared_util_js__WEBPACK_IMPORTED_MODULE_0__.CMapCompressionType.NONE;
4631 return this._fetchData(url, compressionType).catch(reason => {
4632 throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
4633 });
4634 }
4635 _fetchData(url, compressionType) {
4636 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_fetchData` called.");
4637 }
4638}
4639class BaseStandardFontDataFactory {
4640 constructor({
4641 baseUrl = null
4642 }) {
4643 if (this.constructor === BaseStandardFontDataFactory) {
4644 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseStandardFontDataFactory.");
4645 }
4646 this.baseUrl = baseUrl;
4647 }
4648 async fetch({
4649 filename
4650 }) {
4651 if (!this.baseUrl) {
4652 throw new Error('The standard font "baseUrl" parameter must be specified, ensure that ' + 'the "standardFontDataUrl" API parameter is provided.');
4653 }
4654 if (!filename) {
4655 throw new Error("Font filename must be specified.");
4656 }
4657 const url = `${this.baseUrl}${filename}`;
4658 return this._fetchData(url).catch(reason => {
4659 throw new Error(`Unable to load font data at: ${url}`);
4660 });
4661 }
4662 _fetchData(url) {
4663 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_fetchData` called.");
4664 }
4665}
4666class BaseSVGFactory {
4667 constructor() {
4668 if (this.constructor === BaseSVGFactory) {
4669 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Cannot initialize BaseSVGFactory.");
4670 }
4671 }
4672 create(width, height, skipDimensions = false) {
4673 if (width <= 0 || height <= 0) {
4674 throw new Error("Invalid SVG dimensions");
4675 }
4676 const svg = this._createSVG("svg:svg");
4677 svg.setAttribute("version", "1.1");
4678 if (!skipDimensions) {
4679 svg.setAttribute("width", `${width}px`);
4680 svg.setAttribute("height", `${height}px`);
4681 }
4682 svg.setAttribute("preserveAspectRatio", "none");
4683 svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
4684 return svg;
4685 }
4686 createElement(type) {
4687 if (typeof type !== "string") {
4688 throw new Error("Invalid SVG element type");
4689 }
4690 return this._createSVG(type);
4691 }
4692 _createSVG(type) {
4693 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_0__.unreachable)("Abstract method `_createSVG` called.");
4694 }
4695}
4696
4697
4698/***/ }),
4699
4700/***/ 250:
4701/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
4702
4703
4704// EXPORTS
4705__webpack_require__.d(__webpack_exports__, {
4706 CanvasGraphics: () => (/* binding */ CanvasGraphics)
4707});
4708
4709// EXTERNAL MODULE: ./src/shared/util.js
4710var util = __webpack_require__(266);
4711// EXTERNAL MODULE: ./src/display/display_utils.js
4712var display_utils = __webpack_require__(473);
4713;// CONCATENATED MODULE: ./src/display/pattern_helper.js
4714
4715
4716const PathType = {
4717 FILL: "Fill",
4718 STROKE: "Stroke",
4719 SHADING: "Shading"
4720};
4721function applyBoundingBox(ctx, bbox) {
4722 if (!bbox) {
4723 return;
4724 }
4725 const width = bbox[2] - bbox[0];
4726 const height = bbox[3] - bbox[1];
4727 const region = new Path2D();
4728 region.rect(bbox[0], bbox[1], width, height);
4729 ctx.clip(region);
4730}
4731class BaseShadingPattern {
4732 constructor() {
4733 if (this.constructor === BaseShadingPattern) {
4734 (0,util.unreachable)("Cannot initialize BaseShadingPattern.");
4735 }
4736 }
4737 getPattern() {
4738 (0,util.unreachable)("Abstract method `getPattern` called.");
4739 }
4740}
4741class RadialAxialShadingPattern extends BaseShadingPattern {
4742 constructor(IR) {
4743 super();
4744 this._type = IR[1];
4745 this._bbox = IR[2];
4746 this._colorStops = IR[3];
4747 this._p0 = IR[4];
4748 this._p1 = IR[5];
4749 this._r0 = IR[6];
4750 this._r1 = IR[7];
4751 this.matrix = null;
4752 }
4753 _createGradient(ctx) {
4754 let grad;
4755 if (this._type === "axial") {
4756 grad = ctx.createLinearGradient(this._p0[0], this._p0[1], this._p1[0], this._p1[1]);
4757 } else if (this._type === "radial") {
4758 grad = ctx.createRadialGradient(this._p0[0], this._p0[1], this._r0, this._p1[0], this._p1[1], this._r1);
4759 }
4760 for (const colorStop of this._colorStops) {
4761 grad.addColorStop(colorStop[0], colorStop[1]);
4762 }
4763 return grad;
4764 }
4765 getPattern(ctx, owner, inverse, pathType) {
4766 let pattern;
4767 if (pathType === PathType.STROKE || pathType === PathType.FILL) {
4768 const ownerBBox = owner.current.getClippedPathBoundingBox(pathType, (0,display_utils.getCurrentTransform)(ctx)) || [0, 0, 0, 0];
4769 const width = Math.ceil(ownerBBox[2] - ownerBBox[0]) || 1;
4770 const height = Math.ceil(ownerBBox[3] - ownerBBox[1]) || 1;
4771 const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", width, height, true);
4772 const tmpCtx = tmpCanvas.context;
4773 tmpCtx.clearRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
4774 tmpCtx.beginPath();
4775 tmpCtx.rect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
4776 tmpCtx.translate(-ownerBBox[0], -ownerBBox[1]);
4777 inverse = util.Util.transform(inverse, [1, 0, 0, 1, ownerBBox[0], ownerBBox[1]]);
4778 tmpCtx.transform(...owner.baseTransform);
4779 if (this.matrix) {
4780 tmpCtx.transform(...this.matrix);
4781 }
4782 applyBoundingBox(tmpCtx, this._bbox);
4783 tmpCtx.fillStyle = this._createGradient(tmpCtx);
4784 tmpCtx.fill();
4785 pattern = ctx.createPattern(tmpCanvas.canvas, "no-repeat");
4786 const domMatrix = new DOMMatrix(inverse);
4787 pattern.setTransform(domMatrix);
4788 } else {
4789 applyBoundingBox(ctx, this._bbox);
4790 pattern = this._createGradient(ctx);
4791 }
4792 return pattern;
4793 }
4794}
4795function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
4796 const coords = context.coords,
4797 colors = context.colors;
4798 const bytes = data.data,
4799 rowSize = data.width * 4;
4800 let tmp;
4801 if (coords[p1 + 1] > coords[p2 + 1]) {
4802 tmp = p1;
4803 p1 = p2;
4804 p2 = tmp;
4805 tmp = c1;
4806 c1 = c2;
4807 c2 = tmp;
4808 }
4809 if (coords[p2 + 1] > coords[p3 + 1]) {
4810 tmp = p2;
4811 p2 = p3;
4812 p3 = tmp;
4813 tmp = c2;
4814 c2 = c3;
4815 c3 = tmp;
4816 }
4817 if (coords[p1 + 1] > coords[p2 + 1]) {
4818 tmp = p1;
4819 p1 = p2;
4820 p2 = tmp;
4821 tmp = c1;
4822 c1 = c2;
4823 c2 = tmp;
4824 }
4825 const x1 = (coords[p1] + context.offsetX) * context.scaleX;
4826 const y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
4827 const x2 = (coords[p2] + context.offsetX) * context.scaleX;
4828 const y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
4829 const x3 = (coords[p3] + context.offsetX) * context.scaleX;
4830 const y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
4831 if (y1 >= y3) {
4832 return;
4833 }
4834 const c1r = colors[c1],
4835 c1g = colors[c1 + 1],
4836 c1b = colors[c1 + 2];
4837 const c2r = colors[c2],
4838 c2g = colors[c2 + 1],
4839 c2b = colors[c2 + 2];
4840 const c3r = colors[c3],
4841 c3g = colors[c3 + 1],
4842 c3b = colors[c3 + 2];
4843 const minY = Math.round(y1),
4844 maxY = Math.round(y3);
4845 let xa, car, cag, cab;
4846 let xb, cbr, cbg, cbb;
4847 for (let y = minY; y <= maxY; y++) {
4848 if (y < y2) {
4849 const k = y < y1 ? 0 : (y1 - y) / (y1 - y2);
4850 xa = x1 - (x1 - x2) * k;
4851 car = c1r - (c1r - c2r) * k;
4852 cag = c1g - (c1g - c2g) * k;
4853 cab = c1b - (c1b - c2b) * k;
4854 } else {
4855 let k;
4856 if (y > y3) {
4857 k = 1;
4858 } else if (y2 === y3) {
4859 k = 0;
4860 } else {
4861 k = (y2 - y) / (y2 - y3);
4862 }
4863 xa = x2 - (x2 - x3) * k;
4864 car = c2r - (c2r - c3r) * k;
4865 cag = c2g - (c2g - c3g) * k;
4866 cab = c2b - (c2b - c3b) * k;
4867 }
4868 let k;
4869 if (y < y1) {
4870 k = 0;
4871 } else if (y > y3) {
4872 k = 1;
4873 } else {
4874 k = (y1 - y) / (y1 - y3);
4875 }
4876 xb = x1 - (x1 - x3) * k;
4877 cbr = c1r - (c1r - c3r) * k;
4878 cbg = c1g - (c1g - c3g) * k;
4879 cbb = c1b - (c1b - c3b) * k;
4880 const x1_ = Math.round(Math.min(xa, xb));
4881 const x2_ = Math.round(Math.max(xa, xb));
4882 let j = rowSize * y + x1_ * 4;
4883 for (let x = x1_; x <= x2_; x++) {
4884 k = (xa - x) / (xa - xb);
4885 if (k < 0) {
4886 k = 0;
4887 } else if (k > 1) {
4888 k = 1;
4889 }
4890 bytes[j++] = car - (car - cbr) * k | 0;
4891 bytes[j++] = cag - (cag - cbg) * k | 0;
4892 bytes[j++] = cab - (cab - cbb) * k | 0;
4893 bytes[j++] = 255;
4894 }
4895 }
4896}
4897function drawFigure(data, figure, context) {
4898 const ps = figure.coords;
4899 const cs = figure.colors;
4900 let i, ii;
4901 switch (figure.type) {
4902 case "lattice":
4903 const verticesPerRow = figure.verticesPerRow;
4904 const rows = Math.floor(ps.length / verticesPerRow) - 1;
4905 const cols = verticesPerRow - 1;
4906 for (i = 0; i < rows; i++) {
4907 let q = i * verticesPerRow;
4908 for (let j = 0; j < cols; j++, q++) {
4909 drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
4910 drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
4911 }
4912 }
4913 break;
4914 case "triangles":
4915 for (i = 0, ii = ps.length; i < ii; i += 3) {
4916 drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
4917 }
4918 break;
4919 default:
4920 throw new Error("illegal figure");
4921 }
4922}
4923class MeshShadingPattern extends BaseShadingPattern {
4924 constructor(IR) {
4925 super();
4926 this._coords = IR[2];
4927 this._colors = IR[3];
4928 this._figures = IR[4];
4929 this._bounds = IR[5];
4930 this._bbox = IR[7];
4931 this._background = IR[8];
4932 this.matrix = null;
4933 }
4934 _createMeshCanvas(combinedScale, backgroundColor, cachedCanvases) {
4935 const EXPECTED_SCALE = 1.1;
4936 const MAX_PATTERN_SIZE = 3000;
4937 const BORDER_SIZE = 2;
4938 const offsetX = Math.floor(this._bounds[0]);
4939 const offsetY = Math.floor(this._bounds[1]);
4940 const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
4941 const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
4942 const width = Math.min(Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
4943 const height = Math.min(Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
4944 const scaleX = boundsWidth / width;
4945 const scaleY = boundsHeight / height;
4946 const context = {
4947 coords: this._coords,
4948 colors: this._colors,
4949 offsetX: -offsetX,
4950 offsetY: -offsetY,
4951 scaleX: 1 / scaleX,
4952 scaleY: 1 / scaleY
4953 };
4954 const paddedWidth = width + BORDER_SIZE * 2;
4955 const paddedHeight = height + BORDER_SIZE * 2;
4956 const tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
4957 const tmpCtx = tmpCanvas.context;
4958 const data = tmpCtx.createImageData(width, height);
4959 if (backgroundColor) {
4960 const bytes = data.data;
4961 for (let i = 0, ii = bytes.length; i < ii; i += 4) {
4962 bytes[i] = backgroundColor[0];
4963 bytes[i + 1] = backgroundColor[1];
4964 bytes[i + 2] = backgroundColor[2];
4965 bytes[i + 3] = 255;
4966 }
4967 }
4968 for (const figure of this._figures) {
4969 drawFigure(data, figure, context);
4970 }
4971 tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
4972 const canvas = tmpCanvas.canvas;
4973 return {
4974 canvas,
4975 offsetX: offsetX - BORDER_SIZE * scaleX,
4976 offsetY: offsetY - BORDER_SIZE * scaleY,
4977 scaleX,
4978 scaleY
4979 };
4980 }
4981 getPattern(ctx, owner, inverse, pathType) {
4982 applyBoundingBox(ctx, this._bbox);
4983 let scale;
4984 if (pathType === PathType.SHADING) {
4985 scale = util.Util.singularValueDecompose2dScale((0,display_utils.getCurrentTransform)(ctx));
4986 } else {
4987 scale = util.Util.singularValueDecompose2dScale(owner.baseTransform);
4988 if (this.matrix) {
4989 const matrixScale = util.Util.singularValueDecompose2dScale(this.matrix);
4990 scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
4991 }
4992 }
4993 const temporaryPatternCanvas = this._createMeshCanvas(scale, pathType === PathType.SHADING ? null : this._background, owner.cachedCanvases);
4994 if (pathType !== PathType.SHADING) {
4995 ctx.setTransform(...owner.baseTransform);
4996 if (this.matrix) {
4997 ctx.transform(...this.matrix);
4998 }
4999 }
5000 ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
5001 ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
5002 return ctx.createPattern(temporaryPatternCanvas.canvas, "no-repeat");
5003 }
5004}
5005class DummyShadingPattern extends BaseShadingPattern {
5006 getPattern() {
5007 return "hotpink";
5008 }
5009}
5010function getShadingPattern(IR) {
5011 switch (IR[0]) {
5012 case "RadialAxial":
5013 return new RadialAxialShadingPattern(IR);
5014 case "Mesh":
5015 return new MeshShadingPattern(IR);
5016 case "Dummy":
5017 return new DummyShadingPattern();
5018 }
5019 throw new Error(`Unknown IR type: ${IR[0]}`);
5020}
5021const PaintType = {
5022 COLORED: 1,
5023 UNCOLORED: 2
5024};
5025class TilingPattern {
5026 static MAX_PATTERN_SIZE = 3000;
5027 constructor(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
5028 this.operatorList = IR[2];
5029 this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
5030 this.bbox = IR[4];
5031 this.xstep = IR[5];
5032 this.ystep = IR[6];
5033 this.paintType = IR[7];
5034 this.tilingType = IR[8];
5035 this.color = color;
5036 this.ctx = ctx;
5037 this.canvasGraphicsFactory = canvasGraphicsFactory;
5038 this.baseTransform = baseTransform;
5039 }
5040 createPatternCanvas(owner) {
5041 const operatorList = this.operatorList;
5042 const bbox = this.bbox;
5043 const xstep = this.xstep;
5044 const ystep = this.ystep;
5045 const paintType = this.paintType;
5046 const tilingType = this.tilingType;
5047 const color = this.color;
5048 const canvasGraphicsFactory = this.canvasGraphicsFactory;
5049 (0,util.info)("TilingType: " + tilingType);
5050 const x0 = bbox[0],
5051 y0 = bbox[1],
5052 x1 = bbox[2],
5053 y1 = bbox[3];
5054 const matrixScale = util.Util.singularValueDecompose2dScale(this.matrix);
5055 const curMatrixScale = util.Util.singularValueDecompose2dScale(this.baseTransform);
5056 const combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
5057 const dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
5058 const dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
5059 const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", dimx.size, dimy.size, true);
5060 const tmpCtx = tmpCanvas.context;
5061 const graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
5062 graphics.groupLevel = owner.groupLevel;
5063 this.setFillAndStrokeStyleToContext(graphics, paintType, color);
5064 let adjustedX0 = x0;
5065 let adjustedY0 = y0;
5066 let adjustedX1 = x1;
5067 let adjustedY1 = y1;
5068 if (x0 < 0) {
5069 adjustedX0 = 0;
5070 adjustedX1 += Math.abs(x0);
5071 }
5072 if (y0 < 0) {
5073 adjustedY0 = 0;
5074 adjustedY1 += Math.abs(y0);
5075 }
5076 tmpCtx.translate(-(dimx.scale * adjustedX0), -(dimy.scale * adjustedY0));
5077 graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
5078 tmpCtx.save();
5079 this.clipBbox(graphics, adjustedX0, adjustedY0, adjustedX1, adjustedY1);
5080 graphics.baseTransform = (0,display_utils.getCurrentTransform)(graphics.ctx);
5081 graphics.executeOperatorList(operatorList);
5082 graphics.endDrawing();
5083 return {
5084 canvas: tmpCanvas.canvas,
5085 scaleX: dimx.scale,
5086 scaleY: dimy.scale,
5087 offsetX: adjustedX0,
5088 offsetY: adjustedY0
5089 };
5090 }
5091 getSizeAndScale(step, realOutputSize, scale) {
5092 step = Math.abs(step);
5093 const maxSize = Math.max(TilingPattern.MAX_PATTERN_SIZE, realOutputSize);
5094 let size = Math.ceil(step * scale);
5095 if (size >= maxSize) {
5096 size = maxSize;
5097 } else {
5098 scale = size / step;
5099 }
5100 return {
5101 scale,
5102 size
5103 };
5104 }
5105 clipBbox(graphics, x0, y0, x1, y1) {
5106 const bboxWidth = x1 - x0;
5107 const bboxHeight = y1 - y0;
5108 graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
5109 graphics.current.updateRectMinMax((0,display_utils.getCurrentTransform)(graphics.ctx), [x0, y0, x1, y1]);
5110 graphics.clip();
5111 graphics.endPath();
5112 }
5113 setFillAndStrokeStyleToContext(graphics, paintType, color) {
5114 const context = graphics.ctx,
5115 current = graphics.current;
5116 switch (paintType) {
5117 case PaintType.COLORED:
5118 const ctx = this.ctx;
5119 context.fillStyle = ctx.fillStyle;
5120 context.strokeStyle = ctx.strokeStyle;
5121 current.fillColor = ctx.fillStyle;
5122 current.strokeColor = ctx.strokeStyle;
5123 break;
5124 case PaintType.UNCOLORED:
5125 const cssColor = util.Util.makeHexColor(color[0], color[1], color[2]);
5126 context.fillStyle = cssColor;
5127 context.strokeStyle = cssColor;
5128 current.fillColor = cssColor;
5129 current.strokeColor = cssColor;
5130 break;
5131 default:
5132 throw new util.FormatError(`Unsupported paint type: ${paintType}`);
5133 }
5134 }
5135 getPattern(ctx, owner, inverse, pathType) {
5136 let matrix = inverse;
5137 if (pathType !== PathType.SHADING) {
5138 matrix = util.Util.transform(matrix, owner.baseTransform);
5139 if (this.matrix) {
5140 matrix = util.Util.transform(matrix, this.matrix);
5141 }
5142 }
5143 const temporaryPatternCanvas = this.createPatternCanvas(owner);
5144 let domMatrix = new DOMMatrix(matrix);
5145 domMatrix = domMatrix.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
5146 domMatrix = domMatrix.scale(1 / temporaryPatternCanvas.scaleX, 1 / temporaryPatternCanvas.scaleY);
5147 const pattern = ctx.createPattern(temporaryPatternCanvas.canvas, "repeat");
5148 pattern.setTransform(domMatrix);
5149 return pattern;
5150 }
5151}
5152
5153;// CONCATENATED MODULE: ./src/shared/image_utils.js
5154
5155function convertToRGBA(params) {
5156 switch (params.kind) {
5157 case ImageKind.GRAYSCALE_1BPP:
5158 return convertBlackAndWhiteToRGBA(params);
5159 case ImageKind.RGB_24BPP:
5160 return convertRGBToRGBA(params);
5161 }
5162 return null;
5163}
5164function convertBlackAndWhiteToRGBA({
5165 src,
5166 srcPos = 0,
5167 dest,
5168 width,
5169 height,
5170 nonBlackColor = 0xffffffff,
5171 inverseDecode = false
5172}) {
5173 const black = util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
5174 const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
5175 const widthInSource = width >> 3;
5176 const widthRemainder = width & 7;
5177 const srcLength = src.length;
5178 dest = new Uint32Array(dest.buffer);
5179 let destPos = 0;
5180 for (let i = 0; i < height; i++) {
5181 for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
5182 const elem = srcPos < srcLength ? src[srcPos] : 255;
5183 dest[destPos++] = elem & 0b10000000 ? oneMapping : zeroMapping;
5184 dest[destPos++] = elem & 0b1000000 ? oneMapping : zeroMapping;
5185 dest[destPos++] = elem & 0b100000 ? oneMapping : zeroMapping;
5186 dest[destPos++] = elem & 0b10000 ? oneMapping : zeroMapping;
5187 dest[destPos++] = elem & 0b1000 ? oneMapping : zeroMapping;
5188 dest[destPos++] = elem & 0b100 ? oneMapping : zeroMapping;
5189 dest[destPos++] = elem & 0b10 ? oneMapping : zeroMapping;
5190 dest[destPos++] = elem & 0b1 ? oneMapping : zeroMapping;
5191 }
5192 if (widthRemainder === 0) {
5193 continue;
5194 }
5195 const elem = srcPos < srcLength ? src[srcPos++] : 255;
5196 for (let j = 0; j < widthRemainder; j++) {
5197 dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
5198 }
5199 }
5200 return {
5201 srcPos,
5202 destPos
5203 };
5204}
5205function convertRGBToRGBA({
5206 src,
5207 srcPos = 0,
5208 dest,
5209 destPos = 0,
5210 width,
5211 height
5212}) {
5213 let i = 0;
5214 const len32 = src.length >> 2;
5215 const src32 = new Uint32Array(src.buffer, srcPos, len32);
5216 if (FeatureTest.isLittleEndian) {
5217 for (; i < len32 - 2; i += 3, destPos += 4) {
5218 const s1 = src32[i];
5219 const s2 = src32[i + 1];
5220 const s3 = src32[i + 2];
5221 dest[destPos] = s1 | 0xff000000;
5222 dest[destPos + 1] = s1 >>> 24 | s2 << 8 | 0xff000000;
5223 dest[destPos + 2] = s2 >>> 16 | s3 << 16 | 0xff000000;
5224 dest[destPos + 3] = s3 >>> 8 | 0xff000000;
5225 }
5226 for (let j = i * 4, jj = src.length; j < jj; j += 3) {
5227 dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | 0xff000000;
5228 }
5229 } else {
5230 for (; i < len32 - 2; i += 3, destPos += 4) {
5231 const s1 = src32[i];
5232 const s2 = src32[i + 1];
5233 const s3 = src32[i + 2];
5234 dest[destPos] = s1 | 0xff;
5235 dest[destPos + 1] = s1 << 24 | s2 >>> 8 | 0xff;
5236 dest[destPos + 2] = s2 << 16 | s3 >>> 16 | 0xff;
5237 dest[destPos + 3] = s3 << 8 | 0xff;
5238 }
5239 for (let j = i * 4, jj = src.length; j < jj; j += 3) {
5240 dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | 0xff;
5241 }
5242 }
5243 return {
5244 srcPos,
5245 destPos
5246 };
5247}
5248function grayToRGBA(src, dest) {
5249 if (FeatureTest.isLittleEndian) {
5250 for (let i = 0, ii = src.length; i < ii; i++) {
5251 dest[i] = src[i] * 0x10101 | 0xff000000;
5252 }
5253 } else {
5254 for (let i = 0, ii = src.length; i < ii; i++) {
5255 dest[i] = src[i] * 0x1010100 | 0x000000ff;
5256 }
5257 }
5258}
5259
5260;// CONCATENATED MODULE: ./src/display/canvas.js
5261
5262
5263
5264
5265const MIN_FONT_SIZE = 16;
5266const MAX_FONT_SIZE = 100;
5267const MAX_GROUP_SIZE = 4096;
5268const EXECUTION_TIME = 15;
5269const EXECUTION_STEPS = 10;
5270const MAX_SIZE_TO_COMPILE = 1000;
5271const FULL_CHUNK_HEIGHT = 16;
5272function mirrorContextOperations(ctx, destCtx) {
5273 if (ctx._removeMirroring) {
5274 throw new Error("Context is already forwarding operations.");
5275 }
5276 ctx.__originalSave = ctx.save;
5277 ctx.__originalRestore = ctx.restore;
5278 ctx.__originalRotate = ctx.rotate;
5279 ctx.__originalScale = ctx.scale;
5280 ctx.__originalTranslate = ctx.translate;
5281 ctx.__originalTransform = ctx.transform;
5282 ctx.__originalSetTransform = ctx.setTransform;
5283 ctx.__originalResetTransform = ctx.resetTransform;
5284 ctx.__originalClip = ctx.clip;
5285 ctx.__originalMoveTo = ctx.moveTo;
5286 ctx.__originalLineTo = ctx.lineTo;
5287 ctx.__originalBezierCurveTo = ctx.bezierCurveTo;
5288 ctx.__originalRect = ctx.rect;
5289 ctx.__originalClosePath = ctx.closePath;
5290 ctx.__originalBeginPath = ctx.beginPath;
5291 ctx._removeMirroring = () => {
5292 ctx.save = ctx.__originalSave;
5293 ctx.restore = ctx.__originalRestore;
5294 ctx.rotate = ctx.__originalRotate;
5295 ctx.scale = ctx.__originalScale;
5296 ctx.translate = ctx.__originalTranslate;
5297 ctx.transform = ctx.__originalTransform;
5298 ctx.setTransform = ctx.__originalSetTransform;
5299 ctx.resetTransform = ctx.__originalResetTransform;
5300 ctx.clip = ctx.__originalClip;
5301 ctx.moveTo = ctx.__originalMoveTo;
5302 ctx.lineTo = ctx.__originalLineTo;
5303 ctx.bezierCurveTo = ctx.__originalBezierCurveTo;
5304 ctx.rect = ctx.__originalRect;
5305 ctx.closePath = ctx.__originalClosePath;
5306 ctx.beginPath = ctx.__originalBeginPath;
5307 delete ctx._removeMirroring;
5308 };
5309 ctx.save = function ctxSave() {
5310 destCtx.save();
5311 this.__originalSave();
5312 };
5313 ctx.restore = function ctxRestore() {
5314 destCtx.restore();
5315 this.__originalRestore();
5316 };
5317 ctx.translate = function ctxTranslate(x, y) {
5318 destCtx.translate(x, y);
5319 this.__originalTranslate(x, y);
5320 };
5321 ctx.scale = function ctxScale(x, y) {
5322 destCtx.scale(x, y);
5323 this.__originalScale(x, y);
5324 };
5325 ctx.transform = function ctxTransform(a, b, c, d, e, f) {
5326 destCtx.transform(a, b, c, d, e, f);
5327 this.__originalTransform(a, b, c, d, e, f);
5328 };
5329 ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
5330 destCtx.setTransform(a, b, c, d, e, f);
5331 this.__originalSetTransform(a, b, c, d, e, f);
5332 };
5333 ctx.resetTransform = function ctxResetTransform() {
5334 destCtx.resetTransform();
5335 this.__originalResetTransform();
5336 };
5337 ctx.rotate = function ctxRotate(angle) {
5338 destCtx.rotate(angle);
5339 this.__originalRotate(angle);
5340 };
5341 ctx.clip = function ctxRotate(rule) {
5342 destCtx.clip(rule);
5343 this.__originalClip(rule);
5344 };
5345 ctx.moveTo = function (x, y) {
5346 destCtx.moveTo(x, y);
5347 this.__originalMoveTo(x, y);
5348 };
5349 ctx.lineTo = function (x, y) {
5350 destCtx.lineTo(x, y);
5351 this.__originalLineTo(x, y);
5352 };
5353 ctx.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
5354 destCtx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
5355 this.__originalBezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
5356 };
5357 ctx.rect = function (x, y, width, height) {
5358 destCtx.rect(x, y, width, height);
5359 this.__originalRect(x, y, width, height);
5360 };
5361 ctx.closePath = function () {
5362 destCtx.closePath();
5363 this.__originalClosePath();
5364 };
5365 ctx.beginPath = function () {
5366 destCtx.beginPath();
5367 this.__originalBeginPath();
5368 };
5369}
5370class CachedCanvases {
5371 constructor(canvasFactory) {
5372 this.canvasFactory = canvasFactory;
5373 this.cache = Object.create(null);
5374 }
5375 getCanvas(id, width, height) {
5376 let canvasEntry;
5377 if (this.cache[id] !== undefined) {
5378 canvasEntry = this.cache[id];
5379 this.canvasFactory.reset(canvasEntry, width, height);
5380 } else {
5381 canvasEntry = this.canvasFactory.create(width, height);
5382 this.cache[id] = canvasEntry;
5383 }
5384 return canvasEntry;
5385 }
5386 delete(id) {
5387 delete this.cache[id];
5388 }
5389 clear() {
5390 for (const id in this.cache) {
5391 const canvasEntry = this.cache[id];
5392 this.canvasFactory.destroy(canvasEntry);
5393 delete this.cache[id];
5394 }
5395 }
5396}
5397function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
5398 const [a, b, c, d, tx, ty] = (0,display_utils.getCurrentTransform)(ctx);
5399 if (b === 0 && c === 0) {
5400 const tlX = destX * a + tx;
5401 const rTlX = Math.round(tlX);
5402 const tlY = destY * d + ty;
5403 const rTlY = Math.round(tlY);
5404 const brX = (destX + destW) * a + tx;
5405 const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
5406 const brY = (destY + destH) * d + ty;
5407 const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
5408 ctx.setTransform(Math.sign(a), 0, 0, Math.sign(d), rTlX, rTlY);
5409 ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rWidth, rHeight);
5410 ctx.setTransform(a, b, c, d, tx, ty);
5411 return [rWidth, rHeight];
5412 }
5413 if (a === 0 && d === 0) {
5414 const tlX = destY * c + tx;
5415 const rTlX = Math.round(tlX);
5416 const tlY = destX * b + ty;
5417 const rTlY = Math.round(tlY);
5418 const brX = (destY + destH) * c + tx;
5419 const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
5420 const brY = (destX + destW) * b + ty;
5421 const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
5422 ctx.setTransform(0, Math.sign(b), Math.sign(c), 0, rTlX, rTlY);
5423 ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rHeight, rWidth);
5424 ctx.setTransform(a, b, c, d, tx, ty);
5425 return [rHeight, rWidth];
5426 }
5427 ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
5428 const scaleX = Math.hypot(a, b);
5429 const scaleY = Math.hypot(c, d);
5430 return [scaleX * destW, scaleY * destH];
5431}
5432function compileType3Glyph(imgData) {
5433 const {
5434 width,
5435 height
5436 } = imgData;
5437 if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
5438 return null;
5439 }
5440 const POINT_TO_PROCESS_LIMIT = 1000;
5441 const POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
5442 const width1 = width + 1;
5443 let points = new Uint8Array(width1 * (height + 1));
5444 let i, j, j0;
5445 const lineSize = width + 7 & ~7;
5446 let data = new Uint8Array(lineSize * height),
5447 pos = 0;
5448 for (const elem of imgData.data) {
5449 let mask = 128;
5450 while (mask > 0) {
5451 data[pos++] = elem & mask ? 0 : 255;
5452 mask >>= 1;
5453 }
5454 }
5455 let count = 0;
5456 pos = 0;
5457 if (data[pos] !== 0) {
5458 points[0] = 1;
5459 ++count;
5460 }
5461 for (j = 1; j < width; j++) {
5462 if (data[pos] !== data[pos + 1]) {
5463 points[j] = data[pos] ? 2 : 1;
5464 ++count;
5465 }
5466 pos++;
5467 }
5468 if (data[pos] !== 0) {
5469 points[j] = 2;
5470 ++count;
5471 }
5472 for (i = 1; i < height; i++) {
5473 pos = i * lineSize;
5474 j0 = i * width1;
5475 if (data[pos - lineSize] !== data[pos]) {
5476 points[j0] = data[pos] ? 1 : 8;
5477 ++count;
5478 }
5479 let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
5480 for (j = 1; j < width; j++) {
5481 sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
5482 if (POINT_TYPES[sum]) {
5483 points[j0 + j] = POINT_TYPES[sum];
5484 ++count;
5485 }
5486 pos++;
5487 }
5488 if (data[pos - lineSize] !== data[pos]) {
5489 points[j0 + j] = data[pos] ? 2 : 4;
5490 ++count;
5491 }
5492 if (count > POINT_TO_PROCESS_LIMIT) {
5493 return null;
5494 }
5495 }
5496 pos = lineSize * (height - 1);
5497 j0 = i * width1;
5498 if (data[pos] !== 0) {
5499 points[j0] = 8;
5500 ++count;
5501 }
5502 for (j = 1; j < width; j++) {
5503 if (data[pos] !== data[pos + 1]) {
5504 points[j0 + j] = data[pos] ? 4 : 8;
5505 ++count;
5506 }
5507 pos++;
5508 }
5509 if (data[pos] !== 0) {
5510 points[j0 + j] = 4;
5511 ++count;
5512 }
5513 if (count > POINT_TO_PROCESS_LIMIT) {
5514 return null;
5515 }
5516 const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
5517 const path = new Path2D();
5518 for (i = 0; count && i <= height; i++) {
5519 let p = i * width1;
5520 const end = p + width;
5521 while (p < end && !points[p]) {
5522 p++;
5523 }
5524 if (p === end) {
5525 continue;
5526 }
5527 path.moveTo(p % width1, i);
5528 const p0 = p;
5529 let type = points[p];
5530 do {
5531 const step = steps[type];
5532 do {
5533 p += step;
5534 } while (!points[p]);
5535 const pp = points[p];
5536 if (pp !== 5 && pp !== 10) {
5537 type = pp;
5538 points[p] = 0;
5539 } else {
5540 type = pp & 0x33 * type >> 4;
5541 points[p] &= type >> 2 | type << 2;
5542 }
5543 path.lineTo(p % width1, p / width1 | 0);
5544 if (!points[p]) {
5545 --count;
5546 }
5547 } while (p0 !== p);
5548 --i;
5549 }
5550 data = null;
5551 points = null;
5552 const drawOutline = function (c) {
5553 c.save();
5554 c.scale(1 / width, -1 / height);
5555 c.translate(0, -height);
5556 c.fill(path);
5557 c.beginPath();
5558 c.restore();
5559 };
5560 return drawOutline;
5561}
5562class CanvasExtraState {
5563 constructor(width, height) {
5564 this.alphaIsShape = false;
5565 this.fontSize = 0;
5566 this.fontSizeScale = 1;
5567 this.textMatrix = util.IDENTITY_MATRIX;
5568 this.textMatrixScale = 1;
5569 this.fontMatrix = util.FONT_IDENTITY_MATRIX;
5570 this.leading = 0;
5571 this.x = 0;
5572 this.y = 0;
5573 this.lineX = 0;
5574 this.lineY = 0;
5575 this.charSpacing = 0;
5576 this.wordSpacing = 0;
5577 this.textHScale = 1;
5578 this.textRenderingMode = util.TextRenderingMode.FILL;
5579 this.textRise = 0;
5580 this.fillColor = "#000000";
5581 this.strokeColor = "#000000";
5582 this.patternFill = false;
5583 this.fillAlpha = 1;
5584 this.strokeAlpha = 1;
5585 this.lineWidth = 1;
5586 this.activeSMask = null;
5587 this.transferMaps = "none";
5588 this.startNewPathAndClipBox([0, 0, width, height]);
5589 }
5590 clone() {
5591 const clone = Object.create(this);
5592 clone.clipBox = this.clipBox.slice();
5593 return clone;
5594 }
5595 setCurrentPoint(x, y) {
5596 this.x = x;
5597 this.y = y;
5598 }
5599 updatePathMinMax(transform, x, y) {
5600 [x, y] = util.Util.applyTransform([x, y], transform);
5601 this.minX = Math.min(this.minX, x);
5602 this.minY = Math.min(this.minY, y);
5603 this.maxX = Math.max(this.maxX, x);
5604 this.maxY = Math.max(this.maxY, y);
5605 }
5606 updateRectMinMax(transform, rect) {
5607 const p1 = util.Util.applyTransform(rect, transform);
5608 const p2 = util.Util.applyTransform(rect.slice(2), transform);
5609 const p3 = util.Util.applyTransform([rect[0], rect[3]], transform);
5610 const p4 = util.Util.applyTransform([rect[2], rect[1]], transform);
5611 this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
5612 this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
5613 this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
5614 this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]);
5615 }
5616 updateScalingPathMinMax(transform, minMax) {
5617 util.Util.scaleMinMax(transform, minMax);
5618 this.minX = Math.min(this.minX, minMax[0]);
5619 this.maxX = Math.max(this.maxX, minMax[1]);
5620 this.minY = Math.min(this.minY, minMax[2]);
5621 this.maxY = Math.max(this.maxY, minMax[3]);
5622 }
5623 updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
5624 const box = util.Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3);
5625 if (minMax) {
5626 minMax[0] = Math.min(minMax[0], box[0], box[2]);
5627 minMax[1] = Math.max(minMax[1], box[0], box[2]);
5628 minMax[2] = Math.min(minMax[2], box[1], box[3]);
5629 minMax[3] = Math.max(minMax[3], box[1], box[3]);
5630 return;
5631 }
5632 this.updateRectMinMax(transform, box);
5633 }
5634 getPathBoundingBox(pathType = PathType.FILL, transform = null) {
5635 const box = [this.minX, this.minY, this.maxX, this.maxY];
5636 if (pathType === PathType.STROKE) {
5637 if (!transform) {
5638 (0,util.unreachable)("Stroke bounding box must include transform.");
5639 }
5640 const scale = util.Util.singularValueDecompose2dScale(transform);
5641 const xStrokePad = scale[0] * this.lineWidth / 2;
5642 const yStrokePad = scale[1] * this.lineWidth / 2;
5643 box[0] -= xStrokePad;
5644 box[1] -= yStrokePad;
5645 box[2] += xStrokePad;
5646 box[3] += yStrokePad;
5647 }
5648 return box;
5649 }
5650 updateClipFromPath() {
5651 const intersect = util.Util.intersect(this.clipBox, this.getPathBoundingBox());
5652 this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
5653 }
5654 isEmptyClip() {
5655 return this.minX === Infinity;
5656 }
5657 startNewPathAndClipBox(box) {
5658 this.clipBox = box;
5659 this.minX = Infinity;
5660 this.minY = Infinity;
5661 this.maxX = 0;
5662 this.maxY = 0;
5663 }
5664 getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) {
5665 return util.Util.intersect(this.clipBox, this.getPathBoundingBox(pathType, transform));
5666 }
5667}
5668function putBinaryImageData(ctx, imgData) {
5669 if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
5670 ctx.putImageData(imgData, 0, 0);
5671 return;
5672 }
5673 const height = imgData.height,
5674 width = imgData.width;
5675 const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
5676 const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
5677 const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
5678 const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
5679 let srcPos = 0,
5680 destPos;
5681 const src = imgData.data;
5682 const dest = chunkImgData.data;
5683 let i, j, thisChunkHeight, elemsInThisChunk;
5684 if (imgData.kind === util.ImageKind.GRAYSCALE_1BPP) {
5685 const srcLength = src.byteLength;
5686 const dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
5687 const dest32DataLength = dest32.length;
5688 const fullSrcDiff = width + 7 >> 3;
5689 const white = 0xffffffff;
5690 const black = util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
5691 for (i = 0; i < totalChunks; i++) {
5692 thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
5693 destPos = 0;
5694 for (j = 0; j < thisChunkHeight; j++) {
5695 const srcDiff = srcLength - srcPos;
5696 let k = 0;
5697 const kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
5698 const kEndUnrolled = kEnd & ~7;
5699 let mask = 0;
5700 let srcByte = 0;
5701 for (; k < kEndUnrolled; k += 8) {
5702 srcByte = src[srcPos++];
5703 dest32[destPos++] = srcByte & 128 ? white : black;
5704 dest32[destPos++] = srcByte & 64 ? white : black;
5705 dest32[destPos++] = srcByte & 32 ? white : black;
5706 dest32[destPos++] = srcByte & 16 ? white : black;
5707 dest32[destPos++] = srcByte & 8 ? white : black;
5708 dest32[destPos++] = srcByte & 4 ? white : black;
5709 dest32[destPos++] = srcByte & 2 ? white : black;
5710 dest32[destPos++] = srcByte & 1 ? white : black;
5711 }
5712 for (; k < kEnd; k++) {
5713 if (mask === 0) {
5714 srcByte = src[srcPos++];
5715 mask = 128;
5716 }
5717 dest32[destPos++] = srcByte & mask ? white : black;
5718 mask >>= 1;
5719 }
5720 }
5721 while (destPos < dest32DataLength) {
5722 dest32[destPos++] = 0;
5723 }
5724 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
5725 }
5726 } else if (imgData.kind === util.ImageKind.RGBA_32BPP) {
5727 j = 0;
5728 elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
5729 for (i = 0; i < fullChunks; i++) {
5730 dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
5731 srcPos += elemsInThisChunk;
5732 ctx.putImageData(chunkImgData, 0, j);
5733 j += FULL_CHUNK_HEIGHT;
5734 }
5735 if (i < totalChunks) {
5736 elemsInThisChunk = width * partialChunkHeight * 4;
5737 dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
5738 ctx.putImageData(chunkImgData, 0, j);
5739 }
5740 } else if (imgData.kind === util.ImageKind.RGB_24BPP) {
5741 thisChunkHeight = FULL_CHUNK_HEIGHT;
5742 elemsInThisChunk = width * thisChunkHeight;
5743 for (i = 0; i < totalChunks; i++) {
5744 if (i >= fullChunks) {
5745 thisChunkHeight = partialChunkHeight;
5746 elemsInThisChunk = width * thisChunkHeight;
5747 }
5748 destPos = 0;
5749 for (j = elemsInThisChunk; j--;) {
5750 dest[destPos++] = src[srcPos++];
5751 dest[destPos++] = src[srcPos++];
5752 dest[destPos++] = src[srcPos++];
5753 dest[destPos++] = 255;
5754 }
5755 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
5756 }
5757 } else {
5758 throw new Error(`bad image kind: ${imgData.kind}`);
5759 }
5760}
5761function putBinaryImageMask(ctx, imgData) {
5762 if (imgData.bitmap) {
5763 ctx.drawImage(imgData.bitmap, 0, 0);
5764 return;
5765 }
5766 const height = imgData.height,
5767 width = imgData.width;
5768 const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
5769 const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
5770 const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
5771 const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
5772 let srcPos = 0;
5773 const src = imgData.data;
5774 const dest = chunkImgData.data;
5775 for (let i = 0; i < totalChunks; i++) {
5776 const thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
5777 ({
5778 srcPos
5779 } = convertBlackAndWhiteToRGBA({
5780 src,
5781 srcPos,
5782 dest,
5783 width,
5784 height: thisChunkHeight,
5785 nonBlackColor: 0
5786 }));
5787 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
5788 }
5789}
5790function copyCtxState(sourceCtx, destCtx) {
5791 const properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font", "filter"];
5792 for (const property of properties) {
5793 if (sourceCtx[property] !== undefined) {
5794 destCtx[property] = sourceCtx[property];
5795 }
5796 }
5797 if (sourceCtx.setLineDash !== undefined) {
5798 destCtx.setLineDash(sourceCtx.getLineDash());
5799 destCtx.lineDashOffset = sourceCtx.lineDashOffset;
5800 }
5801}
5802function resetCtxToDefault(ctx) {
5803 ctx.strokeStyle = ctx.fillStyle = "#000000";
5804 ctx.fillRule = "nonzero";
5805 ctx.globalAlpha = 1;
5806 ctx.lineWidth = 1;
5807 ctx.lineCap = "butt";
5808 ctx.lineJoin = "miter";
5809 ctx.miterLimit = 10;
5810 ctx.globalCompositeOperation = "source-over";
5811 ctx.font = "10px sans-serif";
5812 if (ctx.setLineDash !== undefined) {
5813 ctx.setLineDash([]);
5814 ctx.lineDashOffset = 0;
5815 }
5816 if (!util.isNodeJS) {
5817 const {
5818 filter
5819 } = ctx;
5820 if (filter !== "none" && filter !== "") {
5821 ctx.filter = "none";
5822 }
5823 }
5824}
5825function composeSMaskBackdrop(bytes, r0, g0, b0) {
5826 const length = bytes.length;
5827 for (let i = 3; i < length; i += 4) {
5828 const alpha = bytes[i];
5829 if (alpha === 0) {
5830 bytes[i - 3] = r0;
5831 bytes[i - 2] = g0;
5832 bytes[i - 1] = b0;
5833 } else if (alpha < 255) {
5834 const alpha_ = 255 - alpha;
5835 bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
5836 bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
5837 bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
5838 }
5839 }
5840}
5841function composeSMaskAlpha(maskData, layerData, transferMap) {
5842 const length = maskData.length;
5843 const scale = 1 / 255;
5844 for (let i = 3; i < length; i += 4) {
5845 const alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
5846 layerData[i] = layerData[i] * alpha * scale | 0;
5847 }
5848}
5849function composeSMaskLuminosity(maskData, layerData, transferMap) {
5850 const length = maskData.length;
5851 for (let i = 3; i < length; i += 4) {
5852 const y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
5853 layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
5854 }
5855}
5856function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap, layerOffsetX, layerOffsetY, maskOffsetX, maskOffsetY) {
5857 const hasBackdrop = !!backdrop;
5858 const r0 = hasBackdrop ? backdrop[0] : 0;
5859 const g0 = hasBackdrop ? backdrop[1] : 0;
5860 const b0 = hasBackdrop ? backdrop[2] : 0;
5861 const composeFn = subtype === "Luminosity" ? composeSMaskLuminosity : composeSMaskAlpha;
5862 const PIXELS_TO_PROCESS = 1048576;
5863 const chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
5864 for (let row = 0; row < height; row += chunkSize) {
5865 const chunkHeight = Math.min(chunkSize, height - row);
5866 const maskData = maskCtx.getImageData(layerOffsetX - maskOffsetX, row + (layerOffsetY - maskOffsetY), width, chunkHeight);
5867 const layerData = layerCtx.getImageData(layerOffsetX, row + layerOffsetY, width, chunkHeight);
5868 if (hasBackdrop) {
5869 composeSMaskBackdrop(maskData.data, r0, g0, b0);
5870 }
5871 composeFn(maskData.data, layerData.data, transferMap);
5872 layerCtx.putImageData(layerData, layerOffsetX, row + layerOffsetY);
5873 }
5874}
5875function composeSMask(ctx, smask, layerCtx, layerBox) {
5876 const layerOffsetX = layerBox[0];
5877 const layerOffsetY = layerBox[1];
5878 const layerWidth = layerBox[2] - layerOffsetX;
5879 const layerHeight = layerBox[3] - layerOffsetY;
5880 if (layerWidth === 0 || layerHeight === 0) {
5881 return;
5882 }
5883 genericComposeSMask(smask.context, layerCtx, layerWidth, layerHeight, smask.subtype, smask.backdrop, smask.transferMap, layerOffsetX, layerOffsetY, smask.offsetX, smask.offsetY);
5884 ctx.save();
5885 ctx.globalAlpha = 1;
5886 ctx.globalCompositeOperation = "source-over";
5887 ctx.setTransform(1, 0, 0, 1, 0, 0);
5888 ctx.drawImage(layerCtx.canvas, 0, 0);
5889 ctx.restore();
5890}
5891function getImageSmoothingEnabled(transform, interpolate) {
5892 const scale = util.Util.singularValueDecompose2dScale(transform);
5893 scale[0] = Math.fround(scale[0]);
5894 scale[1] = Math.fround(scale[1]);
5895 const actualScale = Math.fround((globalThis.devicePixelRatio || 1) * display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
5896 if (interpolate !== undefined) {
5897 return interpolate;
5898 } else if (scale[0] <= actualScale || scale[1] <= actualScale) {
5899 return true;
5900 }
5901 return false;
5902}
5903const LINE_CAP_STYLES = ["butt", "round", "square"];
5904const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
5905const NORMAL_CLIP = {};
5906const EO_CLIP = {};
5907class CanvasGraphics {
5908 constructor(canvasCtx, commonObjs, objs, canvasFactory, filterFactory, {
5909 optionalContentConfig,
5910 markedContentStack = null
5911 }, annotationCanvasMap, pageColors) {
5912 this.ctx = canvasCtx;
5913 this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
5914 this.stateStack = [];
5915 this.pendingClip = null;
5916 this.pendingEOFill = false;
5917 this.res = null;
5918 this.xobjs = null;
5919 this.commonObjs = commonObjs;
5920 this.objs = objs;
5921 this.canvasFactory = canvasFactory;
5922 this.filterFactory = filterFactory;
5923 this.groupStack = [];
5924 this.processingType3 = null;
5925 this.baseTransform = null;
5926 this.baseTransformStack = [];
5927 this.groupLevel = 0;
5928 this.smaskStack = [];
5929 this.smaskCounter = 0;
5930 this.tempSMask = null;
5931 this.suspendedCtx = null;
5932 this.contentVisible = true;
5933 this.markedContentStack = markedContentStack || [];
5934 this.optionalContentConfig = optionalContentConfig;
5935 this.cachedCanvases = new CachedCanvases(this.canvasFactory);
5936 this.cachedPatterns = new Map();
5937 this.annotationCanvasMap = annotationCanvasMap;
5938 this.viewportScale = 1;
5939 this.outputScaleX = 1;
5940 this.outputScaleY = 1;
5941 this.pageColors = pageColors;
5942 this._cachedScaleForStroking = [-1, 0];
5943 this._cachedGetSinglePixelWidth = null;
5944 this._cachedBitmapsMap = new Map();
5945 }
5946 getObject(data, fallback = null) {
5947 if (typeof data === "string") {
5948 return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
5949 }
5950 return fallback;
5951 }
5952 beginDrawing({
5953 transform,
5954 viewport,
5955 transparency = false,
5956 background = null
5957 }) {
5958 const width = this.ctx.canvas.width;
5959 const height = this.ctx.canvas.height;
5960 const savedFillStyle = this.ctx.fillStyle;
5961 this.ctx.fillStyle = background || "#ffffff";
5962 this.ctx.fillRect(0, 0, width, height);
5963 this.ctx.fillStyle = savedFillStyle;
5964 if (transparency) {
5965 const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height);
5966 this.compositeCtx = this.ctx;
5967 this.transparentCanvas = transparentCanvas.canvas;
5968 this.ctx = transparentCanvas.context;
5969 this.ctx.save();
5970 this.ctx.transform(...(0,display_utils.getCurrentTransform)(this.compositeCtx));
5971 }
5972 this.ctx.save();
5973 resetCtxToDefault(this.ctx);
5974 if (transform) {
5975 this.ctx.transform(...transform);
5976 this.outputScaleX = transform[0];
5977 this.outputScaleY = transform[0];
5978 }
5979 this.ctx.transform(...viewport.transform);
5980 this.viewportScale = viewport.scale;
5981 this.baseTransform = (0,display_utils.getCurrentTransform)(this.ctx);
5982 }
5983 executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
5984 const argsArray = operatorList.argsArray;
5985 const fnArray = operatorList.fnArray;
5986 let i = executionStartIdx || 0;
5987 const argsArrayLen = argsArray.length;
5988 if (argsArrayLen === i) {
5989 return i;
5990 }
5991 const chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
5992 const endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
5993 let steps = 0;
5994 const commonObjs = this.commonObjs;
5995 const objs = this.objs;
5996 let fnId;
5997 while (true) {
5998 if (stepper !== undefined && i === stepper.nextBreakPoint) {
5999 stepper.breakIt(i, continueCallback);
6000 return i;
6001 }
6002 fnId = fnArray[i];
6003 if (fnId !== util.OPS.dependency) {
6004 this[fnId].apply(this, argsArray[i]);
6005 } else {
6006 for (const depObjId of argsArray[i]) {
6007 const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
6008 if (!objsPool.has(depObjId)) {
6009 objsPool.get(depObjId, continueCallback);
6010 return i;
6011 }
6012 }
6013 }
6014 i++;
6015 if (i === argsArrayLen) {
6016 return i;
6017 }
6018 if (chunkOperations && ++steps > EXECUTION_STEPS) {
6019 if (Date.now() > endTime) {
6020 continueCallback();
6021 return i;
6022 }
6023 steps = 0;
6024 }
6025 }
6026 }
6027 #restoreInitialState() {
6028 while (this.stateStack.length || this.inSMaskMode) {
6029 this.restore();
6030 }
6031 this.ctx.restore();
6032 if (this.transparentCanvas) {
6033 this.ctx = this.compositeCtx;
6034 this.ctx.save();
6035 this.ctx.setTransform(1, 0, 0, 1, 0, 0);
6036 this.ctx.drawImage(this.transparentCanvas, 0, 0);
6037 this.ctx.restore();
6038 this.transparentCanvas = null;
6039 }
6040 }
6041 endDrawing() {
6042 this.#restoreInitialState();
6043 this.cachedCanvases.clear();
6044 this.cachedPatterns.clear();
6045 for (const cache of this._cachedBitmapsMap.values()) {
6046 for (const canvas of cache.values()) {
6047 if (typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement) {
6048 canvas.width = canvas.height = 0;
6049 }
6050 }
6051 cache.clear();
6052 }
6053 this._cachedBitmapsMap.clear();
6054 this.#drawFilter();
6055 }
6056 #drawFilter() {
6057 if (this.pageColors) {
6058 const hcmFilterId = this.filterFactory.addHCMFilter(this.pageColors.foreground, this.pageColors.background);
6059 if (hcmFilterId !== "none") {
6060 const savedFilter = this.ctx.filter;
6061 this.ctx.filter = hcmFilterId;
6062 this.ctx.drawImage(this.ctx.canvas, 0, 0);
6063 this.ctx.filter = savedFilter;
6064 }
6065 }
6066 }
6067 _scaleImage(img, inverseTransform) {
6068 const width = img.width;
6069 const height = img.height;
6070 let widthScale = Math.max(Math.hypot(inverseTransform[0], inverseTransform[1]), 1);
6071 let heightScale = Math.max(Math.hypot(inverseTransform[2], inverseTransform[3]), 1);
6072 let paintWidth = width,
6073 paintHeight = height;
6074 let tmpCanvasId = "prescale1";
6075 let tmpCanvas, tmpCtx;
6076 while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
6077 let newWidth = paintWidth,
6078 newHeight = paintHeight;
6079 if (widthScale > 2 && paintWidth > 1) {
6080 newWidth = paintWidth >= 16384 ? Math.floor(paintWidth / 2) - 1 || 1 : Math.ceil(paintWidth / 2);
6081 widthScale /= paintWidth / newWidth;
6082 }
6083 if (heightScale > 2 && paintHeight > 1) {
6084 newHeight = paintHeight >= 16384 ? Math.floor(paintHeight / 2) - 1 || 1 : Math.ceil(paintHeight) / 2;
6085 heightScale /= paintHeight / newHeight;
6086 }
6087 tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
6088 tmpCtx = tmpCanvas.context;
6089 tmpCtx.clearRect(0, 0, newWidth, newHeight);
6090 tmpCtx.drawImage(img, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
6091 img = tmpCanvas.canvas;
6092 paintWidth = newWidth;
6093 paintHeight = newHeight;
6094 tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
6095 }
6096 return {
6097 img,
6098 paintWidth,
6099 paintHeight
6100 };
6101 }
6102 _createMaskCanvas(img) {
6103 const ctx = this.ctx;
6104 const {
6105 width,
6106 height
6107 } = img;
6108 const fillColor = this.current.fillColor;
6109 const isPatternFill = this.current.patternFill;
6110 const currentTransform = (0,display_utils.getCurrentTransform)(ctx);
6111 let cache, cacheKey, scaled, maskCanvas;
6112 if ((img.bitmap || img.data) && img.count > 1) {
6113 const mainKey = img.bitmap || img.data.buffer;
6114 cacheKey = JSON.stringify(isPatternFill ? currentTransform : [currentTransform.slice(0, 4), fillColor]);
6115 cache = this._cachedBitmapsMap.get(mainKey);
6116 if (!cache) {
6117 cache = new Map();
6118 this._cachedBitmapsMap.set(mainKey, cache);
6119 }
6120 const cachedImage = cache.get(cacheKey);
6121 if (cachedImage && !isPatternFill) {
6122 const offsetX = Math.round(Math.min(currentTransform[0], currentTransform[2]) + currentTransform[4]);
6123 const offsetY = Math.round(Math.min(currentTransform[1], currentTransform[3]) + currentTransform[5]);
6124 return {
6125 canvas: cachedImage,
6126 offsetX,
6127 offsetY
6128 };
6129 }
6130 scaled = cachedImage;
6131 }
6132 if (!scaled) {
6133 maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
6134 putBinaryImageMask(maskCanvas.context, img);
6135 }
6136 let maskToCanvas = util.Util.transform(currentTransform, [1 / width, 0, 0, -1 / height, 0, 0]);
6137 maskToCanvas = util.Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
6138 const [minX, minY, maxX, maxY] = util.Util.getAxialAlignedBoundingBox([0, 0, width, height], maskToCanvas);
6139 const drawnWidth = Math.round(maxX - minX) || 1;
6140 const drawnHeight = Math.round(maxY - minY) || 1;
6141 const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight);
6142 const fillCtx = fillCanvas.context;
6143 const offsetX = minX;
6144 const offsetY = minY;
6145 fillCtx.translate(-offsetX, -offsetY);
6146 fillCtx.transform(...maskToCanvas);
6147 if (!scaled) {
6148 scaled = this._scaleImage(maskCanvas.canvas, (0,display_utils.getCurrentTransformInverse)(fillCtx));
6149 scaled = scaled.img;
6150 if (cache && isPatternFill) {
6151 cache.set(cacheKey, scaled);
6152 }
6153 }
6154 fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled((0,display_utils.getCurrentTransform)(fillCtx), img.interpolate);
6155 drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
6156 fillCtx.globalCompositeOperation = "source-in";
6157 const inverse = util.Util.transform((0,display_utils.getCurrentTransformInverse)(fillCtx), [1, 0, 0, 1, -offsetX, -offsetY]);
6158 fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, PathType.FILL) : fillColor;
6159 fillCtx.fillRect(0, 0, width, height);
6160 if (cache && !isPatternFill) {
6161 this.cachedCanvases.delete("fillCanvas");
6162 cache.set(cacheKey, fillCanvas.canvas);
6163 }
6164 return {
6165 canvas: fillCanvas.canvas,
6166 offsetX: Math.round(offsetX),
6167 offsetY: Math.round(offsetY)
6168 };
6169 }
6170 setLineWidth(width) {
6171 if (width !== this.current.lineWidth) {
6172 this._cachedScaleForStroking[0] = -1;
6173 }
6174 this.current.lineWidth = width;
6175 this.ctx.lineWidth = width;
6176 }
6177 setLineCap(style) {
6178 this.ctx.lineCap = LINE_CAP_STYLES[style];
6179 }
6180 setLineJoin(style) {
6181 this.ctx.lineJoin = LINE_JOIN_STYLES[style];
6182 }
6183 setMiterLimit(limit) {
6184 this.ctx.miterLimit = limit;
6185 }
6186 setDash(dashArray, dashPhase) {
6187 const ctx = this.ctx;
6188 if (ctx.setLineDash !== undefined) {
6189 ctx.setLineDash(dashArray);
6190 ctx.lineDashOffset = dashPhase;
6191 }
6192 }
6193 setRenderingIntent(intent) {}
6194 setFlatness(flatness) {}
6195 setGState(states) {
6196 for (const [key, value] of states) {
6197 switch (key) {
6198 case "LW":
6199 this.setLineWidth(value);
6200 break;
6201 case "LC":
6202 this.setLineCap(value);
6203 break;
6204 case "LJ":
6205 this.setLineJoin(value);
6206 break;
6207 case "ML":
6208 this.setMiterLimit(value);
6209 break;
6210 case "D":
6211 this.setDash(value[0], value[1]);
6212 break;
6213 case "RI":
6214 this.setRenderingIntent(value);
6215 break;
6216 case "FL":
6217 this.setFlatness(value);
6218 break;
6219 case "Font":
6220 this.setFont(value[0], value[1]);
6221 break;
6222 case "CA":
6223 this.current.strokeAlpha = value;
6224 break;
6225 case "ca":
6226 this.current.fillAlpha = value;
6227 this.ctx.globalAlpha = value;
6228 break;
6229 case "BM":
6230 this.ctx.globalCompositeOperation = value;
6231 break;
6232 case "SMask":
6233 this.current.activeSMask = value ? this.tempSMask : null;
6234 this.tempSMask = null;
6235 this.checkSMaskState();
6236 break;
6237 case "TR":
6238 this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(value);
6239 break;
6240 }
6241 }
6242 }
6243 get inSMaskMode() {
6244 return !!this.suspendedCtx;
6245 }
6246 checkSMaskState() {
6247 const inSMaskMode = this.inSMaskMode;
6248 if (this.current.activeSMask && !inSMaskMode) {
6249 this.beginSMaskMode();
6250 } else if (!this.current.activeSMask && inSMaskMode) {
6251 this.endSMaskMode();
6252 }
6253 }
6254 beginSMaskMode() {
6255 if (this.inSMaskMode) {
6256 throw new Error("beginSMaskMode called while already in smask mode");
6257 }
6258 const drawnWidth = this.ctx.canvas.width;
6259 const drawnHeight = this.ctx.canvas.height;
6260 const cacheId = "smaskGroupAt" + this.groupLevel;
6261 const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
6262 this.suspendedCtx = this.ctx;
6263 this.ctx = scratchCanvas.context;
6264 const ctx = this.ctx;
6265 ctx.setTransform(...(0,display_utils.getCurrentTransform)(this.suspendedCtx));
6266 copyCtxState(this.suspendedCtx, ctx);
6267 mirrorContextOperations(ctx, this.suspendedCtx);
6268 this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
6269 }
6270 endSMaskMode() {
6271 if (!this.inSMaskMode) {
6272 throw new Error("endSMaskMode called while not in smask mode");
6273 }
6274 this.ctx._removeMirroring();
6275 copyCtxState(this.ctx, this.suspendedCtx);
6276 this.ctx = this.suspendedCtx;
6277 this.suspendedCtx = null;
6278 }
6279 compose(dirtyBox) {
6280 if (!this.current.activeSMask) {
6281 return;
6282 }
6283 if (!dirtyBox) {
6284 dirtyBox = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height];
6285 } else {
6286 dirtyBox[0] = Math.floor(dirtyBox[0]);
6287 dirtyBox[1] = Math.floor(dirtyBox[1]);
6288 dirtyBox[2] = Math.ceil(dirtyBox[2]);
6289 dirtyBox[3] = Math.ceil(dirtyBox[3]);
6290 }
6291 const smask = this.current.activeSMask;
6292 const suspendedCtx = this.suspendedCtx;
6293 composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);
6294 this.ctx.save();
6295 this.ctx.setTransform(1, 0, 0, 1, 0, 0);
6296 this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
6297 this.ctx.restore();
6298 }
6299 save() {
6300 if (this.inSMaskMode) {
6301 copyCtxState(this.ctx, this.suspendedCtx);
6302 this.suspendedCtx.save();
6303 } else {
6304 this.ctx.save();
6305 }
6306 const old = this.current;
6307 this.stateStack.push(old);
6308 this.current = old.clone();
6309 }
6310 restore() {
6311 if (this.stateStack.length === 0 && this.inSMaskMode) {
6312 this.endSMaskMode();
6313 }
6314 if (this.stateStack.length !== 0) {
6315 this.current = this.stateStack.pop();
6316 if (this.inSMaskMode) {
6317 this.suspendedCtx.restore();
6318 copyCtxState(this.suspendedCtx, this.ctx);
6319 } else {
6320 this.ctx.restore();
6321 }
6322 this.checkSMaskState();
6323 this.pendingClip = null;
6324 this._cachedScaleForStroking[0] = -1;
6325 this._cachedGetSinglePixelWidth = null;
6326 }
6327 }
6328 transform(a, b, c, d, e, f) {
6329 this.ctx.transform(a, b, c, d, e, f);
6330 this._cachedScaleForStroking[0] = -1;
6331 this._cachedGetSinglePixelWidth = null;
6332 }
6333 constructPath(ops, args, minMax) {
6334 const ctx = this.ctx;
6335 const current = this.current;
6336 let x = current.x,
6337 y = current.y;
6338 let startX, startY;
6339 const currentTransform = (0,display_utils.getCurrentTransform)(ctx);
6340 const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
6341 const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
6342 for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
6343 switch (ops[i] | 0) {
6344 case util.OPS.rectangle:
6345 x = args[j++];
6346 y = args[j++];
6347 const width = args[j++];
6348 const height = args[j++];
6349 const xw = x + width;
6350 const yh = y + height;
6351 ctx.moveTo(x, y);
6352 if (width === 0 || height === 0) {
6353 ctx.lineTo(xw, yh);
6354 } else {
6355 ctx.lineTo(xw, y);
6356 ctx.lineTo(xw, yh);
6357 ctx.lineTo(x, yh);
6358 }
6359 if (!isScalingMatrix) {
6360 current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
6361 }
6362 ctx.closePath();
6363 break;
6364 case util.OPS.moveTo:
6365 x = args[j++];
6366 y = args[j++];
6367 ctx.moveTo(x, y);
6368 if (!isScalingMatrix) {
6369 current.updatePathMinMax(currentTransform, x, y);
6370 }
6371 break;
6372 case util.OPS.lineTo:
6373 x = args[j++];
6374 y = args[j++];
6375 ctx.lineTo(x, y);
6376 if (!isScalingMatrix) {
6377 current.updatePathMinMax(currentTransform, x, y);
6378 }
6379 break;
6380 case util.OPS.curveTo:
6381 startX = x;
6382 startY = y;
6383 x = args[j + 4];
6384 y = args[j + 5];
6385 ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
6386 current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], args[j + 2], args[j + 3], x, y, minMaxForBezier);
6387 j += 6;
6388 break;
6389 case util.OPS.curveTo2:
6390 startX = x;
6391 startY = y;
6392 ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
6393 current.updateCurvePathMinMax(currentTransform, startX, startY, x, y, args[j], args[j + 1], args[j + 2], args[j + 3], minMaxForBezier);
6394 x = args[j + 2];
6395 y = args[j + 3];
6396 j += 4;
6397 break;
6398 case util.OPS.curveTo3:
6399 startX = x;
6400 startY = y;
6401 x = args[j + 2];
6402 y = args[j + 3];
6403 ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
6404 current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], x, y, x, y, minMaxForBezier);
6405 j += 4;
6406 break;
6407 case util.OPS.closePath:
6408 ctx.closePath();
6409 break;
6410 }
6411 }
6412 if (isScalingMatrix) {
6413 current.updateScalingPathMinMax(currentTransform, minMaxForBezier);
6414 }
6415 current.setCurrentPoint(x, y);
6416 }
6417 closePath() {
6418 this.ctx.closePath();
6419 }
6420 stroke(consumePath = true) {
6421 const ctx = this.ctx;
6422 const strokeColor = this.current.strokeColor;
6423 ctx.globalAlpha = this.current.strokeAlpha;
6424 if (this.contentVisible) {
6425 if (typeof strokeColor === "object" && strokeColor?.getPattern) {
6426 ctx.save();
6427 ctx.strokeStyle = strokeColor.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.STROKE);
6428 this.rescaleAndStroke(false);
6429 ctx.restore();
6430 } else {
6431 this.rescaleAndStroke(true);
6432 }
6433 }
6434 if (consumePath) {
6435 this.consumePath(this.current.getClippedPathBoundingBox());
6436 }
6437 ctx.globalAlpha = this.current.fillAlpha;
6438 }
6439 closeStroke() {
6440 this.closePath();
6441 this.stroke();
6442 }
6443 fill(consumePath = true) {
6444 const ctx = this.ctx;
6445 const fillColor = this.current.fillColor;
6446 const isPatternFill = this.current.patternFill;
6447 let needRestore = false;
6448 if (isPatternFill) {
6449 ctx.save();
6450 ctx.fillStyle = fillColor.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.FILL);
6451 needRestore = true;
6452 }
6453 const intersect = this.current.getClippedPathBoundingBox();
6454 if (this.contentVisible && intersect !== null) {
6455 if (this.pendingEOFill) {
6456 ctx.fill("evenodd");
6457 this.pendingEOFill = false;
6458 } else {
6459 ctx.fill();
6460 }
6461 }
6462 if (needRestore) {
6463 ctx.restore();
6464 }
6465 if (consumePath) {
6466 this.consumePath(intersect);
6467 }
6468 }
6469 eoFill() {
6470 this.pendingEOFill = true;
6471 this.fill();
6472 }
6473 fillStroke() {
6474 this.fill(false);
6475 this.stroke(false);
6476 this.consumePath();
6477 }
6478 eoFillStroke() {
6479 this.pendingEOFill = true;
6480 this.fillStroke();
6481 }
6482 closeFillStroke() {
6483 this.closePath();
6484 this.fillStroke();
6485 }
6486 closeEOFillStroke() {
6487 this.pendingEOFill = true;
6488 this.closePath();
6489 this.fillStroke();
6490 }
6491 endPath() {
6492 this.consumePath();
6493 }
6494 clip() {
6495 this.pendingClip = NORMAL_CLIP;
6496 }
6497 eoClip() {
6498 this.pendingClip = EO_CLIP;
6499 }
6500 beginText() {
6501 this.current.textMatrix = util.IDENTITY_MATRIX;
6502 this.current.textMatrixScale = 1;
6503 this.current.x = this.current.lineX = 0;
6504 this.current.y = this.current.lineY = 0;
6505 }
6506 endText() {
6507 const paths = this.pendingTextPaths;
6508 const ctx = this.ctx;
6509 if (paths === undefined) {
6510 ctx.beginPath();
6511 return;
6512 }
6513 ctx.save();
6514 ctx.beginPath();
6515 for (const path of paths) {
6516 ctx.setTransform(...path.transform);
6517 ctx.translate(path.x, path.y);
6518 path.addToPath(ctx, path.fontSize);
6519 }
6520 ctx.restore();
6521 ctx.clip();
6522 ctx.beginPath();
6523 delete this.pendingTextPaths;
6524 }
6525 setCharSpacing(spacing) {
6526 this.current.charSpacing = spacing;
6527 }
6528 setWordSpacing(spacing) {
6529 this.current.wordSpacing = spacing;
6530 }
6531 setHScale(scale) {
6532 this.current.textHScale = scale / 100;
6533 }
6534 setLeading(leading) {
6535 this.current.leading = -leading;
6536 }
6537 setFont(fontRefName, size) {
6538 const fontObj = this.commonObjs.get(fontRefName);
6539 const current = this.current;
6540 if (!fontObj) {
6541 throw new Error(`Can't find font for ${fontRefName}`);
6542 }
6543 current.fontMatrix = fontObj.fontMatrix || util.FONT_IDENTITY_MATRIX;
6544 if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
6545 (0,util.warn)("Invalid font matrix for font " + fontRefName);
6546 }
6547 if (size < 0) {
6548 size = -size;
6549 current.fontDirection = -1;
6550 } else {
6551 current.fontDirection = 1;
6552 }
6553 this.current.font = fontObj;
6554 this.current.fontSize = size;
6555 if (fontObj.isType3Font) {
6556 return;
6557 }
6558 const name = fontObj.loadedName || "sans-serif";
6559 const typeface = fontObj.systemFontInfo?.css || `"${name}", ${fontObj.fallbackName}`;
6560 let bold = "normal";
6561 if (fontObj.black) {
6562 bold = "900";
6563 } else if (fontObj.bold) {
6564 bold = "bold";
6565 }
6566 const italic = fontObj.italic ? "italic" : "normal";
6567 let browserFontSize = size;
6568 if (size < MIN_FONT_SIZE) {
6569 browserFontSize = MIN_FONT_SIZE;
6570 } else if (size > MAX_FONT_SIZE) {
6571 browserFontSize = MAX_FONT_SIZE;
6572 }
6573 this.current.fontSizeScale = size / browserFontSize;
6574 this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
6575 }
6576 setTextRenderingMode(mode) {
6577 this.current.textRenderingMode = mode;
6578 }
6579 setTextRise(rise) {
6580 this.current.textRise = rise;
6581 }
6582 moveText(x, y) {
6583 this.current.x = this.current.lineX += x;
6584 this.current.y = this.current.lineY += y;
6585 }
6586 setLeadingMoveText(x, y) {
6587 this.setLeading(-y);
6588 this.moveText(x, y);
6589 }
6590 setTextMatrix(a, b, c, d, e, f) {
6591 this.current.textMatrix = [a, b, c, d, e, f];
6592 this.current.textMatrixScale = Math.hypot(a, b);
6593 this.current.x = this.current.lineX = 0;
6594 this.current.y = this.current.lineY = 0;
6595 }
6596 nextLine() {
6597 this.moveText(0, this.current.leading);
6598 }
6599 paintChar(character, x, y, patternTransform) {
6600 const ctx = this.ctx;
6601 const current = this.current;
6602 const font = current.font;
6603 const textRenderingMode = current.textRenderingMode;
6604 const fontSize = current.fontSize / current.fontSizeScale;
6605 const fillStrokeMode = textRenderingMode & util.TextRenderingMode.FILL_STROKE_MASK;
6606 const isAddToPathSet = !!(textRenderingMode & util.TextRenderingMode.ADD_TO_PATH_FLAG);
6607 const patternFill = current.patternFill && !font.missingFile;
6608 let addToPath;
6609 if (font.disableFontFace || isAddToPathSet || patternFill) {
6610 addToPath = font.getPathGenerator(this.commonObjs, character);
6611 }
6612 if (font.disableFontFace || patternFill) {
6613 ctx.save();
6614 ctx.translate(x, y);
6615 ctx.beginPath();
6616 addToPath(ctx, fontSize);
6617 if (patternTransform) {
6618 ctx.setTransform(...patternTransform);
6619 }
6620 if (fillStrokeMode === util.TextRenderingMode.FILL || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
6621 ctx.fill();
6622 }
6623 if (fillStrokeMode === util.TextRenderingMode.STROKE || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
6624 ctx.stroke();
6625 }
6626 ctx.restore();
6627 } else {
6628 if (fillStrokeMode === util.TextRenderingMode.FILL || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
6629 ctx.fillText(character, x, y);
6630 }
6631 if (fillStrokeMode === util.TextRenderingMode.STROKE || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
6632 ctx.strokeText(character, x, y);
6633 }
6634 }
6635 if (isAddToPathSet) {
6636 const paths = this.pendingTextPaths ||= [];
6637 paths.push({
6638 transform: (0,display_utils.getCurrentTransform)(ctx),
6639 x,
6640 y,
6641 fontSize,
6642 addToPath
6643 });
6644 }
6645 }
6646 get isFontSubpixelAAEnabled() {
6647 const {
6648 context: ctx
6649 } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
6650 ctx.scale(1.5, 1);
6651 ctx.fillText("I", 0, 10);
6652 const data = ctx.getImageData(0, 0, 10, 10).data;
6653 let enabled = false;
6654 for (let i = 3; i < data.length; i += 4) {
6655 if (data[i] > 0 && data[i] < 255) {
6656 enabled = true;
6657 break;
6658 }
6659 }
6660 return (0,util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
6661 }
6662 showText(glyphs) {
6663 const current = this.current;
6664 const font = current.font;
6665 if (font.isType3Font) {
6666 return this.showType3Text(glyphs);
6667 }
6668 const fontSize = current.fontSize;
6669 if (fontSize === 0) {
6670 return undefined;
6671 }
6672 const ctx = this.ctx;
6673 const fontSizeScale = current.fontSizeScale;
6674 const charSpacing = current.charSpacing;
6675 const wordSpacing = current.wordSpacing;
6676 const fontDirection = current.fontDirection;
6677 const textHScale = current.textHScale * fontDirection;
6678 const glyphsLength = glyphs.length;
6679 const vertical = font.vertical;
6680 const spacingDir = vertical ? 1 : -1;
6681 const defaultVMetrics = font.defaultVMetrics;
6682 const widthAdvanceScale = fontSize * current.fontMatrix[0];
6683 const simpleFillText = current.textRenderingMode === util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
6684 ctx.save();
6685 ctx.transform(...current.textMatrix);
6686 ctx.translate(current.x, current.y + current.textRise);
6687 if (fontDirection > 0) {
6688 ctx.scale(textHScale, -1);
6689 } else {
6690 ctx.scale(textHScale, 1);
6691 }
6692 let patternTransform;
6693 if (current.patternFill) {
6694 ctx.save();
6695 const pattern = current.fillColor.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.FILL);
6696 patternTransform = (0,display_utils.getCurrentTransform)(ctx);
6697 ctx.restore();
6698 ctx.fillStyle = pattern;
6699 }
6700 let lineWidth = current.lineWidth;
6701 const scale = current.textMatrixScale;
6702 if (scale === 0 || lineWidth === 0) {
6703 const fillStrokeMode = current.textRenderingMode & util.TextRenderingMode.FILL_STROKE_MASK;
6704 if (fillStrokeMode === util.TextRenderingMode.STROKE || fillStrokeMode === util.TextRenderingMode.FILL_STROKE) {
6705 lineWidth = this.getSinglePixelWidth();
6706 }
6707 } else {
6708 lineWidth /= scale;
6709 }
6710 if (fontSizeScale !== 1.0) {
6711 ctx.scale(fontSizeScale, fontSizeScale);
6712 lineWidth /= fontSizeScale;
6713 }
6714 ctx.lineWidth = lineWidth;
6715 if (font.isInvalidPDFjsFont) {
6716 const chars = [];
6717 let width = 0;
6718 for (const glyph of glyphs) {
6719 chars.push(glyph.unicode);
6720 width += glyph.width;
6721 }
6722 ctx.fillText(chars.join(""), 0, 0);
6723 current.x += width * widthAdvanceScale * textHScale;
6724 ctx.restore();
6725 this.compose();
6726 return undefined;
6727 }
6728 let x = 0,
6729 i;
6730 for (i = 0; i < glyphsLength; ++i) {
6731 const glyph = glyphs[i];
6732 if (typeof glyph === "number") {
6733 x += spacingDir * glyph * fontSize / 1000;
6734 continue;
6735 }
6736 let restoreNeeded = false;
6737 const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
6738 const character = glyph.fontChar;
6739 const accent = glyph.accent;
6740 let scaledX, scaledY;
6741 let width = glyph.width;
6742 if (vertical) {
6743 const vmetric = glyph.vmetric || defaultVMetrics;
6744 const vx = -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;
6745 const vy = vmetric[2] * widthAdvanceScale;
6746 width = vmetric ? -vmetric[0] : width;
6747 scaledX = vx / fontSizeScale;
6748 scaledY = (x + vy) / fontSizeScale;
6749 } else {
6750 scaledX = x / fontSizeScale;
6751 scaledY = 0;
6752 }
6753 if (font.remeasure && width > 0) {
6754 const measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
6755 if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
6756 const characterScaleX = width / measuredWidth;
6757 restoreNeeded = true;
6758 ctx.save();
6759 ctx.scale(characterScaleX, 1);
6760 scaledX /= characterScaleX;
6761 } else if (width !== measuredWidth) {
6762 scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
6763 }
6764 }
6765 if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
6766 if (simpleFillText && !accent) {
6767 ctx.fillText(character, scaledX, scaledY);
6768 } else {
6769 this.paintChar(character, scaledX, scaledY, patternTransform);
6770 if (accent) {
6771 const scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
6772 const scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
6773 this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
6774 }
6775 }
6776 }
6777 const charWidth = vertical ? width * widthAdvanceScale - spacing * fontDirection : width * widthAdvanceScale + spacing * fontDirection;
6778 x += charWidth;
6779 if (restoreNeeded) {
6780 ctx.restore();
6781 }
6782 }
6783 if (vertical) {
6784 current.y -= x;
6785 } else {
6786 current.x += x * textHScale;
6787 }
6788 ctx.restore();
6789 this.compose();
6790 return undefined;
6791 }
6792 showType3Text(glyphs) {
6793 const ctx = this.ctx;
6794 const current = this.current;
6795 const font = current.font;
6796 const fontSize = current.fontSize;
6797 const fontDirection = current.fontDirection;
6798 const spacingDir = font.vertical ? 1 : -1;
6799 const charSpacing = current.charSpacing;
6800 const wordSpacing = current.wordSpacing;
6801 const textHScale = current.textHScale * fontDirection;
6802 const fontMatrix = current.fontMatrix || util.FONT_IDENTITY_MATRIX;
6803 const glyphsLength = glyphs.length;
6804 const isTextInvisible = current.textRenderingMode === util.TextRenderingMode.INVISIBLE;
6805 let i, glyph, width, spacingLength;
6806 if (isTextInvisible || fontSize === 0) {
6807 return;
6808 }
6809 this._cachedScaleForStroking[0] = -1;
6810 this._cachedGetSinglePixelWidth = null;
6811 ctx.save();
6812 ctx.transform(...current.textMatrix);
6813 ctx.translate(current.x, current.y);
6814 ctx.scale(textHScale, fontDirection);
6815 for (i = 0; i < glyphsLength; ++i) {
6816 glyph = glyphs[i];
6817 if (typeof glyph === "number") {
6818 spacingLength = spacingDir * glyph * fontSize / 1000;
6819 this.ctx.translate(spacingLength, 0);
6820 current.x += spacingLength * textHScale;
6821 continue;
6822 }
6823 const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
6824 const operatorList = font.charProcOperatorList[glyph.operatorListId];
6825 if (!operatorList) {
6826 (0,util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
6827 continue;
6828 }
6829 if (this.contentVisible) {
6830 this.processingType3 = glyph;
6831 this.save();
6832 ctx.scale(fontSize, fontSize);
6833 ctx.transform(...fontMatrix);
6834 this.executeOperatorList(operatorList);
6835 this.restore();
6836 }
6837 const transformed = util.Util.applyTransform([glyph.width, 0], fontMatrix);
6838 width = transformed[0] * fontSize + spacing;
6839 ctx.translate(width, 0);
6840 current.x += width * textHScale;
6841 }
6842 ctx.restore();
6843 this.processingType3 = null;
6844 }
6845 setCharWidth(xWidth, yWidth) {}
6846 setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
6847 this.ctx.rect(llx, lly, urx - llx, ury - lly);
6848 this.ctx.clip();
6849 this.endPath();
6850 }
6851 getColorN_Pattern(IR) {
6852 let pattern;
6853 if (IR[0] === "TilingPattern") {
6854 const color = IR[1];
6855 const baseTransform = this.baseTransform || (0,display_utils.getCurrentTransform)(this.ctx);
6856 const canvasGraphicsFactory = {
6857 createCanvasGraphics: ctx => {
6858 return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
6859 optionalContentConfig: this.optionalContentConfig,
6860 markedContentStack: this.markedContentStack
6861 });
6862 }
6863 };
6864 pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
6865 } else {
6866 pattern = this._getPattern(IR[1], IR[2]);
6867 }
6868 return pattern;
6869 }
6870 setStrokeColorN() {
6871 this.current.strokeColor = this.getColorN_Pattern(arguments);
6872 }
6873 setFillColorN() {
6874 this.current.fillColor = this.getColorN_Pattern(arguments);
6875 this.current.patternFill = true;
6876 }
6877 setStrokeRGBColor(r, g, b) {
6878 const color = util.Util.makeHexColor(r, g, b);
6879 this.ctx.strokeStyle = color;
6880 this.current.strokeColor = color;
6881 }
6882 setFillRGBColor(r, g, b) {
6883 const color = util.Util.makeHexColor(r, g, b);
6884 this.ctx.fillStyle = color;
6885 this.current.fillColor = color;
6886 this.current.patternFill = false;
6887 }
6888 _getPattern(objId, matrix = null) {
6889 let pattern;
6890 if (this.cachedPatterns.has(objId)) {
6891 pattern = this.cachedPatterns.get(objId);
6892 } else {
6893 pattern = getShadingPattern(this.getObject(objId));
6894 this.cachedPatterns.set(objId, pattern);
6895 }
6896 if (matrix) {
6897 pattern.matrix = matrix;
6898 }
6899 return pattern;
6900 }
6901 shadingFill(objId) {
6902 if (!this.contentVisible) {
6903 return;
6904 }
6905 const ctx = this.ctx;
6906 this.save();
6907 const pattern = this._getPattern(objId);
6908 ctx.fillStyle = pattern.getPattern(ctx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.SHADING);
6909 const inv = (0,display_utils.getCurrentTransformInverse)(ctx);
6910 if (inv) {
6911 const {
6912 width,
6913 height
6914 } = ctx.canvas;
6915 const [x0, y0, x1, y1] = util.Util.getAxialAlignedBoundingBox([0, 0, width, height], inv);
6916 this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
6917 } else {
6918 this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
6919 }
6920 this.compose(this.current.getClippedPathBoundingBox());
6921 this.restore();
6922 }
6923 beginInlineImage() {
6924 (0,util.unreachable)("Should not call beginInlineImage");
6925 }
6926 beginImageData() {
6927 (0,util.unreachable)("Should not call beginImageData");
6928 }
6929 paintFormXObjectBegin(matrix, bbox) {
6930 if (!this.contentVisible) {
6931 return;
6932 }
6933 this.save();
6934 this.baseTransformStack.push(this.baseTransform);
6935 if (Array.isArray(matrix) && matrix.length === 6) {
6936 this.transform(...matrix);
6937 }
6938 this.baseTransform = (0,display_utils.getCurrentTransform)(this.ctx);
6939 if (bbox) {
6940 const width = bbox[2] - bbox[0];
6941 const height = bbox[3] - bbox[1];
6942 this.ctx.rect(bbox[0], bbox[1], width, height);
6943 this.current.updateRectMinMax((0,display_utils.getCurrentTransform)(this.ctx), bbox);
6944 this.clip();
6945 this.endPath();
6946 }
6947 }
6948 paintFormXObjectEnd() {
6949 if (!this.contentVisible) {
6950 return;
6951 }
6952 this.restore();
6953 this.baseTransform = this.baseTransformStack.pop();
6954 }
6955 beginGroup(group) {
6956 if (!this.contentVisible) {
6957 return;
6958 }
6959 this.save();
6960 if (this.inSMaskMode) {
6961 this.endSMaskMode();
6962 this.current.activeSMask = null;
6963 }
6964 const currentCtx = this.ctx;
6965 if (!group.isolated) {
6966 (0,util.info)("TODO: Support non-isolated groups.");
6967 }
6968 if (group.knockout) {
6969 (0,util.warn)("Knockout groups not supported.");
6970 }
6971 const currentTransform = (0,display_utils.getCurrentTransform)(currentCtx);
6972 if (group.matrix) {
6973 currentCtx.transform(...group.matrix);
6974 }
6975 if (!group.bbox) {
6976 throw new Error("Bounding box is required.");
6977 }
6978 let bounds = util.Util.getAxialAlignedBoundingBox(group.bbox, (0,display_utils.getCurrentTransform)(currentCtx));
6979 const canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
6980 bounds = util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
6981 const offsetX = Math.floor(bounds[0]);
6982 const offsetY = Math.floor(bounds[1]);
6983 let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
6984 let drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
6985 let scaleX = 1,
6986 scaleY = 1;
6987 if (drawnWidth > MAX_GROUP_SIZE) {
6988 scaleX = drawnWidth / MAX_GROUP_SIZE;
6989 drawnWidth = MAX_GROUP_SIZE;
6990 }
6991 if (drawnHeight > MAX_GROUP_SIZE) {
6992 scaleY = drawnHeight / MAX_GROUP_SIZE;
6993 drawnHeight = MAX_GROUP_SIZE;
6994 }
6995 this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
6996 let cacheId = "groupAt" + this.groupLevel;
6997 if (group.smask) {
6998 cacheId += "_smask_" + this.smaskCounter++ % 2;
6999 }
7000 const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
7001 const groupCtx = scratchCanvas.context;
7002 groupCtx.scale(1 / scaleX, 1 / scaleY);
7003 groupCtx.translate(-offsetX, -offsetY);
7004 groupCtx.transform(...currentTransform);
7005 if (group.smask) {
7006 this.smaskStack.push({
7007 canvas: scratchCanvas.canvas,
7008 context: groupCtx,
7009 offsetX,
7010 offsetY,
7011 scaleX,
7012 scaleY,
7013 subtype: group.smask.subtype,
7014 backdrop: group.smask.backdrop,
7015 transferMap: group.smask.transferMap || null,
7016 startTransformInverse: null
7017 });
7018 } else {
7019 currentCtx.setTransform(1, 0, 0, 1, 0, 0);
7020 currentCtx.translate(offsetX, offsetY);
7021 currentCtx.scale(scaleX, scaleY);
7022 currentCtx.save();
7023 }
7024 copyCtxState(currentCtx, groupCtx);
7025 this.ctx = groupCtx;
7026 this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
7027 this.groupStack.push(currentCtx);
7028 this.groupLevel++;
7029 }
7030 endGroup(group) {
7031 if (!this.contentVisible) {
7032 return;
7033 }
7034 this.groupLevel--;
7035 const groupCtx = this.ctx;
7036 const ctx = this.groupStack.pop();
7037 this.ctx = ctx;
7038 this.ctx.imageSmoothingEnabled = false;
7039 if (group.smask) {
7040 this.tempSMask = this.smaskStack.pop();
7041 this.restore();
7042 } else {
7043 this.ctx.restore();
7044 const currentMtx = (0,display_utils.getCurrentTransform)(this.ctx);
7045 this.restore();
7046 this.ctx.save();
7047 this.ctx.setTransform(...currentMtx);
7048 const dirtyBox = util.Util.getAxialAlignedBoundingBox([0, 0, groupCtx.canvas.width, groupCtx.canvas.height], currentMtx);
7049 this.ctx.drawImage(groupCtx.canvas, 0, 0);
7050 this.ctx.restore();
7051 this.compose(dirtyBox);
7052 }
7053 }
7054 beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
7055 this.#restoreInitialState();
7056 resetCtxToDefault(this.ctx);
7057 this.ctx.save();
7058 this.save();
7059 if (this.baseTransform) {
7060 this.ctx.setTransform(...this.baseTransform);
7061 }
7062 if (Array.isArray(rect) && rect.length === 4) {
7063 const width = rect[2] - rect[0];
7064 const height = rect[3] - rect[1];
7065 if (hasOwnCanvas && this.annotationCanvasMap) {
7066 transform = transform.slice();
7067 transform[4] -= rect[0];
7068 transform[5] -= rect[1];
7069 rect = rect.slice();
7070 rect[0] = rect[1] = 0;
7071 rect[2] = width;
7072 rect[3] = height;
7073 const [scaleX, scaleY] = util.Util.singularValueDecompose2dScale((0,display_utils.getCurrentTransform)(this.ctx));
7074 const {
7075 viewportScale
7076 } = this;
7077 const canvasWidth = Math.ceil(width * this.outputScaleX * viewportScale);
7078 const canvasHeight = Math.ceil(height * this.outputScaleY * viewportScale);
7079 this.annotationCanvas = this.canvasFactory.create(canvasWidth, canvasHeight);
7080 const {
7081 canvas,
7082 context
7083 } = this.annotationCanvas;
7084 this.annotationCanvasMap.set(id, canvas);
7085 this.annotationCanvas.savedCtx = this.ctx;
7086 this.ctx = context;
7087 this.ctx.save();
7088 this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
7089 resetCtxToDefault(this.ctx);
7090 } else {
7091 resetCtxToDefault(this.ctx);
7092 this.ctx.rect(rect[0], rect[1], width, height);
7093 this.ctx.clip();
7094 this.endPath();
7095 }
7096 }
7097 this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
7098 this.transform(...transform);
7099 this.transform(...matrix);
7100 }
7101 endAnnotation() {
7102 if (this.annotationCanvas) {
7103 this.ctx.restore();
7104 this.#drawFilter();
7105 this.ctx = this.annotationCanvas.savedCtx;
7106 delete this.annotationCanvas.savedCtx;
7107 delete this.annotationCanvas;
7108 }
7109 }
7110 paintImageMaskXObject(img) {
7111 if (!this.contentVisible) {
7112 return;
7113 }
7114 const count = img.count;
7115 img = this.getObject(img.data, img);
7116 img.count = count;
7117 const ctx = this.ctx;
7118 const glyph = this.processingType3;
7119 if (glyph) {
7120 if (glyph.compiled === undefined) {
7121 glyph.compiled = compileType3Glyph(img);
7122 }
7123 if (glyph.compiled) {
7124 glyph.compiled(ctx);
7125 return;
7126 }
7127 }
7128 const mask = this._createMaskCanvas(img);
7129 const maskCanvas = mask.canvas;
7130 ctx.save();
7131 ctx.setTransform(1, 0, 0, 1, 0, 0);
7132 ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);
7133 ctx.restore();
7134 this.compose();
7135 }
7136 paintImageMaskXObjectRepeat(img, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
7137 if (!this.contentVisible) {
7138 return;
7139 }
7140 img = this.getObject(img.data, img);
7141 const ctx = this.ctx;
7142 ctx.save();
7143 const currentTransform = (0,display_utils.getCurrentTransform)(ctx);
7144 ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
7145 const mask = this._createMaskCanvas(img);
7146 ctx.setTransform(1, 0, 0, 1, mask.offsetX - currentTransform[4], mask.offsetY - currentTransform[5]);
7147 for (let i = 0, ii = positions.length; i < ii; i += 2) {
7148 const trans = util.Util.transform(currentTransform, [scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]]);
7149 const [x, y] = util.Util.applyTransform([0, 0], trans);
7150 ctx.drawImage(mask.canvas, x, y);
7151 }
7152 ctx.restore();
7153 this.compose();
7154 }
7155 paintImageMaskXObjectGroup(images) {
7156 if (!this.contentVisible) {
7157 return;
7158 }
7159 const ctx = this.ctx;
7160 const fillColor = this.current.fillColor;
7161 const isPatternFill = this.current.patternFill;
7162 for (const image of images) {
7163 const {
7164 data,
7165 width,
7166 height,
7167 transform
7168 } = image;
7169 const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
7170 const maskCtx = maskCanvas.context;
7171 maskCtx.save();
7172 const img = this.getObject(data, image);
7173 putBinaryImageMask(maskCtx, img);
7174 maskCtx.globalCompositeOperation = "source-in";
7175 maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, (0,display_utils.getCurrentTransformInverse)(ctx), PathType.FILL) : fillColor;
7176 maskCtx.fillRect(0, 0, width, height);
7177 maskCtx.restore();
7178 ctx.save();
7179 ctx.transform(...transform);
7180 ctx.scale(1, -1);
7181 drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
7182 ctx.restore();
7183 }
7184 this.compose();
7185 }
7186 paintImageXObject(objId) {
7187 if (!this.contentVisible) {
7188 return;
7189 }
7190 const imgData = this.getObject(objId);
7191 if (!imgData) {
7192 (0,util.warn)("Dependent image isn't ready yet");
7193 return;
7194 }
7195 this.paintInlineImageXObject(imgData);
7196 }
7197 paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
7198 if (!this.contentVisible) {
7199 return;
7200 }
7201 const imgData = this.getObject(objId);
7202 if (!imgData) {
7203 (0,util.warn)("Dependent image isn't ready yet");
7204 return;
7205 }
7206 const width = imgData.width;
7207 const height = imgData.height;
7208 const map = [];
7209 for (let i = 0, ii = positions.length; i < ii; i += 2) {
7210 map.push({
7211 transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
7212 x: 0,
7213 y: 0,
7214 w: width,
7215 h: height
7216 });
7217 }
7218 this.paintInlineImageXObjectGroup(imgData, map);
7219 }
7220 applyTransferMapsToCanvas(ctx) {
7221 if (this.current.transferMaps !== "none") {
7222 ctx.filter = this.current.transferMaps;
7223 ctx.drawImage(ctx.canvas, 0, 0);
7224 ctx.filter = "none";
7225 }
7226 return ctx.canvas;
7227 }
7228 applyTransferMapsToBitmap(imgData) {
7229 if (this.current.transferMaps === "none") {
7230 return imgData.bitmap;
7231 }
7232 const {
7233 bitmap,
7234 width,
7235 height
7236 } = imgData;
7237 const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
7238 const tmpCtx = tmpCanvas.context;
7239 tmpCtx.filter = this.current.transferMaps;
7240 tmpCtx.drawImage(bitmap, 0, 0);
7241 tmpCtx.filter = "none";
7242 return tmpCanvas.canvas;
7243 }
7244 paintInlineImageXObject(imgData) {
7245 if (!this.contentVisible) {
7246 return;
7247 }
7248 const width = imgData.width;
7249 const height = imgData.height;
7250 const ctx = this.ctx;
7251 this.save();
7252 if (!util.isNodeJS) {
7253 const {
7254 filter
7255 } = ctx;
7256 if (filter !== "none" && filter !== "") {
7257 ctx.filter = "none";
7258 }
7259 }
7260 ctx.scale(1 / width, -1 / height);
7261 let imgToPaint;
7262 if (imgData.bitmap) {
7263 imgToPaint = this.applyTransferMapsToBitmap(imgData);
7264 } else if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
7265 imgToPaint = imgData;
7266 } else {
7267 const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
7268 const tmpCtx = tmpCanvas.context;
7269 putBinaryImageData(tmpCtx, imgData);
7270 imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
7271 }
7272 const scaled = this._scaleImage(imgToPaint, (0,display_utils.getCurrentTransformInverse)(ctx));
7273 ctx.imageSmoothingEnabled = getImageSmoothingEnabled((0,display_utils.getCurrentTransform)(ctx), imgData.interpolate);
7274 drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
7275 this.compose();
7276 this.restore();
7277 }
7278 paintInlineImageXObjectGroup(imgData, map) {
7279 if (!this.contentVisible) {
7280 return;
7281 }
7282 const ctx = this.ctx;
7283 let imgToPaint;
7284 if (imgData.bitmap) {
7285 imgToPaint = imgData.bitmap;
7286 } else {
7287 const w = imgData.width;
7288 const h = imgData.height;
7289 const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
7290 const tmpCtx = tmpCanvas.context;
7291 putBinaryImageData(tmpCtx, imgData);
7292 imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
7293 }
7294 for (const entry of map) {
7295 ctx.save();
7296 ctx.transform(...entry.transform);
7297 ctx.scale(1, -1);
7298 drawImageAtIntegerCoords(ctx, imgToPaint, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
7299 ctx.restore();
7300 }
7301 this.compose();
7302 }
7303 paintSolidColorImageMask() {
7304 if (!this.contentVisible) {
7305 return;
7306 }
7307 this.ctx.fillRect(0, 0, 1, 1);
7308 this.compose();
7309 }
7310 markPoint(tag) {}
7311 markPointProps(tag, properties) {}
7312 beginMarkedContent(tag) {
7313 this.markedContentStack.push({
7314 visible: true
7315 });
7316 }
7317 beginMarkedContentProps(tag, properties) {
7318 if (tag === "OC") {
7319 this.markedContentStack.push({
7320 visible: this.optionalContentConfig.isVisible(properties)
7321 });
7322 } else {
7323 this.markedContentStack.push({
7324 visible: true
7325 });
7326 }
7327 this.contentVisible = this.isContentVisible();
7328 }
7329 endMarkedContent() {
7330 this.markedContentStack.pop();
7331 this.contentVisible = this.isContentVisible();
7332 }
7333 beginCompat() {}
7334 endCompat() {}
7335 consumePath(clipBox) {
7336 const isEmpty = this.current.isEmptyClip();
7337 if (this.pendingClip) {
7338 this.current.updateClipFromPath();
7339 }
7340 if (!this.pendingClip) {
7341 this.compose(clipBox);
7342 }
7343 const ctx = this.ctx;
7344 if (this.pendingClip) {
7345 if (!isEmpty) {
7346 if (this.pendingClip === EO_CLIP) {
7347 ctx.clip("evenodd");
7348 } else {
7349 ctx.clip();
7350 }
7351 }
7352 this.pendingClip = null;
7353 }
7354 this.current.startNewPathAndClipBox(this.current.clipBox);
7355 ctx.beginPath();
7356 }
7357 getSinglePixelWidth() {
7358 if (!this._cachedGetSinglePixelWidth) {
7359 const m = (0,display_utils.getCurrentTransform)(this.ctx);
7360 if (m[1] === 0 && m[2] === 0) {
7361 this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
7362 } else {
7363 const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
7364 const normX = Math.hypot(m[0], m[2]);
7365 const normY = Math.hypot(m[1], m[3]);
7366 this._cachedGetSinglePixelWidth = Math.max(normX, normY) / absDet;
7367 }
7368 }
7369 return this._cachedGetSinglePixelWidth;
7370 }
7371 getScaleForStroking() {
7372 if (this._cachedScaleForStroking[0] === -1) {
7373 const {
7374 lineWidth
7375 } = this.current;
7376 const {
7377 a,
7378 b,
7379 c,
7380 d
7381 } = this.ctx.getTransform();
7382 let scaleX, scaleY;
7383 if (b === 0 && c === 0) {
7384 const normX = Math.abs(a);
7385 const normY = Math.abs(d);
7386 if (normX === normY) {
7387 if (lineWidth === 0) {
7388 scaleX = scaleY = 1 / normX;
7389 } else {
7390 const scaledLineWidth = normX * lineWidth;
7391 scaleX = scaleY = scaledLineWidth < 1 ? 1 / scaledLineWidth : 1;
7392 }
7393 } else if (lineWidth === 0) {
7394 scaleX = 1 / normX;
7395 scaleY = 1 / normY;
7396 } else {
7397 const scaledXLineWidth = normX * lineWidth;
7398 const scaledYLineWidth = normY * lineWidth;
7399 scaleX = scaledXLineWidth < 1 ? 1 / scaledXLineWidth : 1;
7400 scaleY = scaledYLineWidth < 1 ? 1 / scaledYLineWidth : 1;
7401 }
7402 } else {
7403 const absDet = Math.abs(a * d - b * c);
7404 const normX = Math.hypot(a, b);
7405 const normY = Math.hypot(c, d);
7406 if (lineWidth === 0) {
7407 scaleX = normY / absDet;
7408 scaleY = normX / absDet;
7409 } else {
7410 const baseArea = lineWidth * absDet;
7411 scaleX = normY > baseArea ? normY / baseArea : 1;
7412 scaleY = normX > baseArea ? normX / baseArea : 1;
7413 }
7414 }
7415 this._cachedScaleForStroking[0] = scaleX;
7416 this._cachedScaleForStroking[1] = scaleY;
7417 }
7418 return this._cachedScaleForStroking;
7419 }
7420 rescaleAndStroke(saveRestore) {
7421 const {
7422 ctx
7423 } = this;
7424 const {
7425 lineWidth
7426 } = this.current;
7427 const [scaleX, scaleY] = this.getScaleForStroking();
7428 ctx.lineWidth = lineWidth || 1;
7429 if (scaleX === 1 && scaleY === 1) {
7430 ctx.stroke();
7431 return;
7432 }
7433 const dashes = ctx.getLineDash();
7434 if (saveRestore) {
7435 ctx.save();
7436 }
7437 ctx.scale(scaleX, scaleY);
7438 if (dashes.length > 0) {
7439 const scale = Math.max(scaleX, scaleY);
7440 ctx.setLineDash(dashes.map(x => x / scale));
7441 ctx.lineDashOffset /= scale;
7442 }
7443 ctx.stroke();
7444 if (saveRestore) {
7445 ctx.restore();
7446 }
7447 }
7448 isContentVisible() {
7449 for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
7450 if (!this.markedContentStack[i].visible) {
7451 return false;
7452 }
7453 }
7454 return true;
7455 }
7456}
7457for (const op in util.OPS) {
7458 if (CanvasGraphics.prototype[op] !== undefined) {
7459 CanvasGraphics.prototype[util.OPS[op]] = CanvasGraphics.prototype[op];
7460 }
7461}
7462
7463
7464/***/ }),
7465
7466/***/ 473:
7467/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7468
7469/* harmony export */ __webpack_require__.d(__webpack_exports__, {
7470/* harmony export */ DOMCMapReaderFactory: () => (/* binding */ DOMCMapReaderFactory),
7471/* harmony export */ DOMCanvasFactory: () => (/* binding */ DOMCanvasFactory),
7472/* harmony export */ DOMFilterFactory: () => (/* binding */ DOMFilterFactory),
7473/* harmony export */ DOMSVGFactory: () => (/* binding */ DOMSVGFactory),
7474/* harmony export */ DOMStandardFontDataFactory: () => (/* binding */ DOMStandardFontDataFactory),
7475/* harmony export */ PDFDateString: () => (/* binding */ PDFDateString),
7476/* harmony export */ PageViewport: () => (/* binding */ PageViewport),
7477/* harmony export */ PixelsPerInch: () => (/* binding */ PixelsPerInch),
7478/* harmony export */ RenderingCancelledException: () => (/* binding */ RenderingCancelledException),
7479/* harmony export */ StatTimer: () => (/* binding */ StatTimer),
7480/* harmony export */ fetchData: () => (/* binding */ fetchData),
7481/* harmony export */ getColorValues: () => (/* binding */ getColorValues),
7482/* harmony export */ getCurrentTransform: () => (/* binding */ getCurrentTransform),
7483/* harmony export */ getCurrentTransformInverse: () => (/* binding */ getCurrentTransformInverse),
7484/* harmony export */ getFilenameFromUrl: () => (/* binding */ getFilenameFromUrl),
7485/* harmony export */ getPdfFilenameFromUrl: () => (/* binding */ getPdfFilenameFromUrl),
7486/* harmony export */ getRGB: () => (/* binding */ getRGB),
7487/* harmony export */ getXfaPageViewport: () => (/* binding */ getXfaPageViewport),
7488/* harmony export */ isDataScheme: () => (/* binding */ isDataScheme),
7489/* harmony export */ isPdfFile: () => (/* binding */ isPdfFile),
7490/* harmony export */ isValidFetchUrl: () => (/* binding */ isValidFetchUrl),
7491/* harmony export */ noContextMenu: () => (/* binding */ noContextMenu),
7492/* harmony export */ setLayerDimensions: () => (/* binding */ setLayerDimensions)
7493/* harmony export */ });
7494/* unused harmony export deprecated */
7495/* harmony import */ var _base_factory_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(822);
7496/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(266);
7497
7498
7499const SVG_NS = "http://www.w3.org/2000/svg";
7500class PixelsPerInch {
7501 static CSS = 96.0;
7502 static PDF = 72.0;
7503 static PDF_TO_CSS_UNITS = this.CSS / this.PDF;
7504}
7505class DOMFilterFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_0__.BaseFilterFactory {
7506 #_cache;
7507 #_defs;
7508 #docId;
7509 #document;
7510 #hcmFilter;
7511 #hcmKey;
7512 #hcmUrl;
7513 #hcmHighlightFilter;
7514 #hcmHighlightKey;
7515 #hcmHighlightUrl;
7516 #id = 0;
7517 constructor({
7518 docId,
7519 ownerDocument = globalThis.document
7520 } = {}) {
7521 super();
7522 this.#docId = docId;
7523 this.#document = ownerDocument;
7524 }
7525 get #cache() {
7526 return this.#_cache ||= new Map();
7527 }
7528 get #defs() {
7529 if (!this.#_defs) {
7530 const div = this.#document.createElement("div");
7531 const {
7532 style
7533 } = div;
7534 style.visibility = "hidden";
7535 style.contain = "strict";
7536 style.width = style.height = 0;
7537 style.position = "absolute";
7538 style.top = style.left = 0;
7539 style.zIndex = -1;
7540 const svg = this.#document.createElementNS(SVG_NS, "svg");
7541 svg.setAttribute("width", 0);
7542 svg.setAttribute("height", 0);
7543 this.#_defs = this.#document.createElementNS(SVG_NS, "defs");
7544 div.append(svg);
7545 svg.append(this.#_defs);
7546 this.#document.body.append(div);
7547 }
7548 return this.#_defs;
7549 }
7550 addFilter(maps) {
7551 if (!maps) {
7552 return "none";
7553 }
7554 let value = this.#cache.get(maps);
7555 if (value) {
7556 return value;
7557 }
7558 let tableR, tableG, tableB, key;
7559 if (maps.length === 1) {
7560 const mapR = maps[0];
7561 const buffer = new Array(256);
7562 for (let i = 0; i < 256; i++) {
7563 buffer[i] = mapR[i] / 255;
7564 }
7565 key = tableR = tableG = tableB = buffer.join(",");
7566 } else {
7567 const [mapR, mapG, mapB] = maps;
7568 const bufferR = new Array(256);
7569 const bufferG = new Array(256);
7570 const bufferB = new Array(256);
7571 for (let i = 0; i < 256; i++) {
7572 bufferR[i] = mapR[i] / 255;
7573 bufferG[i] = mapG[i] / 255;
7574 bufferB[i] = mapB[i] / 255;
7575 }
7576 tableR = bufferR.join(",");
7577 tableG = bufferG.join(",");
7578 tableB = bufferB.join(",");
7579 key = `${tableR}${tableG}${tableB}`;
7580 }
7581 value = this.#cache.get(key);
7582 if (value) {
7583 this.#cache.set(maps, value);
7584 return value;
7585 }
7586 const id = `g_${this.#docId}_transfer_map_${this.#id++}`;
7587 const url = `url(#${id})`;
7588 this.#cache.set(maps, url);
7589 this.#cache.set(key, url);
7590 const filter = this.#createFilter(id);
7591 this.#addTransferMapConversion(tableR, tableG, tableB, filter);
7592 return url;
7593 }
7594 addHCMFilter(fgColor, bgColor) {
7595 const key = `${fgColor}-${bgColor}`;
7596 if (this.#hcmKey === key) {
7597 return this.#hcmUrl;
7598 }
7599 this.#hcmKey = key;
7600 this.#hcmUrl = "none";
7601 this.#hcmFilter?.remove();
7602 if (!fgColor || !bgColor) {
7603 return this.#hcmUrl;
7604 }
7605 const fgRGB = this.#getRGB(fgColor);
7606 fgColor = _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.Util.makeHexColor(...fgRGB);
7607 const bgRGB = this.#getRGB(bgColor);
7608 bgColor = _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.Util.makeHexColor(...bgRGB);
7609 this.#defs.style.color = "";
7610 if (fgColor === "#000000" && bgColor === "#ffffff" || fgColor === bgColor) {
7611 return this.#hcmUrl;
7612 }
7613 const map = new Array(256);
7614 for (let i = 0; i <= 255; i++) {
7615 const x = i / 255;
7616 map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
7617 }
7618 const table = map.join(",");
7619 const id = `g_${this.#docId}_hcm_filter`;
7620 const filter = this.#hcmHighlightFilter = this.#createFilter(id);
7621 this.#addTransferMapConversion(table, table, table, filter);
7622 this.#addGrayConversion(filter);
7623 const getSteps = (c, n) => {
7624 const start = fgRGB[c] / 255;
7625 const end = bgRGB[c] / 255;
7626 const arr = new Array(n + 1);
7627 for (let i = 0; i <= n; i++) {
7628 arr[i] = start + i / n * (end - start);
7629 }
7630 return arr.join(",");
7631 };
7632 this.#addTransferMapConversion(getSteps(0, 5), getSteps(1, 5), getSteps(2, 5), filter);
7633 this.#hcmUrl = `url(#${id})`;
7634 return this.#hcmUrl;
7635 }
7636 addHighlightHCMFilter(fgColor, bgColor, newFgColor, newBgColor) {
7637 const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
7638 if (this.#hcmHighlightKey === key) {
7639 return this.#hcmHighlightUrl;
7640 }
7641 this.#hcmHighlightKey = key;
7642 this.#hcmHighlightUrl = "none";
7643 this.#hcmHighlightFilter?.remove();
7644 if (!fgColor || !bgColor) {
7645 return this.#hcmHighlightUrl;
7646 }
7647 const [fgRGB, bgRGB] = [fgColor, bgColor].map(this.#getRGB.bind(this));
7648 let fgGray = Math.round(0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]);
7649 let bgGray = Math.round(0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]);
7650 let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(this.#getRGB.bind(this));
7651 if (bgGray < fgGray) {
7652 [fgGray, bgGray, newFgRGB, newBgRGB] = [bgGray, fgGray, newBgRGB, newFgRGB];
7653 }
7654 this.#defs.style.color = "";
7655 const getSteps = (fg, bg, n) => {
7656 const arr = new Array(256);
7657 const step = (bgGray - fgGray) / n;
7658 const newStart = fg / 255;
7659 const newStep = (bg - fg) / (255 * n);
7660 let prev = 0;
7661 for (let i = 0; i <= n; i++) {
7662 const k = Math.round(fgGray + i * step);
7663 const value = newStart + i * newStep;
7664 for (let j = prev; j <= k; j++) {
7665 arr[j] = value;
7666 }
7667 prev = k + 1;
7668 }
7669 for (let i = prev; i < 256; i++) {
7670 arr[i] = arr[prev - 1];
7671 }
7672 return arr.join(",");
7673 };
7674 const id = `g_${this.#docId}_hcm_highlight_filter`;
7675 const filter = this.#hcmHighlightFilter = this.#createFilter(id);
7676 this.#addGrayConversion(filter);
7677 this.#addTransferMapConversion(getSteps(newFgRGB[0], newBgRGB[0], 5), getSteps(newFgRGB[1], newBgRGB[1], 5), getSteps(newFgRGB[2], newBgRGB[2], 5), filter);
7678 this.#hcmHighlightUrl = `url(#${id})`;
7679 return this.#hcmHighlightUrl;
7680 }
7681 destroy(keepHCM = false) {
7682 if (keepHCM && (this.#hcmUrl || this.#hcmHighlightUrl)) {
7683 return;
7684 }
7685 if (this.#_defs) {
7686 this.#_defs.parentNode.parentNode.remove();
7687 this.#_defs = null;
7688 }
7689 if (this.#_cache) {
7690 this.#_cache.clear();
7691 this.#_cache = null;
7692 }
7693 this.#id = 0;
7694 }
7695 #addGrayConversion(filter) {
7696 const feColorMatrix = this.#document.createElementNS(SVG_NS, "feColorMatrix");
7697 feColorMatrix.setAttribute("type", "matrix");
7698 feColorMatrix.setAttribute("values", "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0");
7699 filter.append(feColorMatrix);
7700 }
7701 #createFilter(id) {
7702 const filter = this.#document.createElementNS(SVG_NS, "filter");
7703 filter.setAttribute("color-interpolation-filters", "sRGB");
7704 filter.setAttribute("id", id);
7705 this.#defs.append(filter);
7706 return filter;
7707 }
7708 #appendFeFunc(feComponentTransfer, func, table) {
7709 const feFunc = this.#document.createElementNS(SVG_NS, func);
7710 feFunc.setAttribute("type", "discrete");
7711 feFunc.setAttribute("tableValues", table);
7712 feComponentTransfer.append(feFunc);
7713 }
7714 #addTransferMapConversion(rTable, gTable, bTable, filter) {
7715 const feComponentTransfer = this.#document.createElementNS(SVG_NS, "feComponentTransfer");
7716 filter.append(feComponentTransfer);
7717 this.#appendFeFunc(feComponentTransfer, "feFuncR", rTable);
7718 this.#appendFeFunc(feComponentTransfer, "feFuncG", gTable);
7719 this.#appendFeFunc(feComponentTransfer, "feFuncB", bTable);
7720 }
7721 #getRGB(color) {
7722 this.#defs.style.color = color;
7723 return getRGB(getComputedStyle(this.#defs).getPropertyValue("color"));
7724 }
7725}
7726class DOMCanvasFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_0__.BaseCanvasFactory {
7727 constructor({
7728 ownerDocument = globalThis.document
7729 } = {}) {
7730 super();
7731 this._document = ownerDocument;
7732 }
7733 _createCanvas(width, height) {
7734 const canvas = this._document.createElement("canvas");
7735 canvas.width = width;
7736 canvas.height = height;
7737 return canvas;
7738 }
7739}
7740async function fetchData(url, type = "text") {
7741 if (isValidFetchUrl(url, document.baseURI)) {
7742 const response = await fetch(url);
7743 if (!response.ok) {
7744 throw new Error(response.statusText);
7745 }
7746 switch (type) {
7747 case "arraybuffer":
7748 return response.arrayBuffer();
7749 case "blob":
7750 return response.blob();
7751 case "json":
7752 return response.json();
7753 }
7754 return response.text();
7755 }
7756 return new Promise((resolve, reject) => {
7757 const request = new XMLHttpRequest();
7758 request.open("GET", url, true);
7759 request.responseType = type;
7760 request.onreadystatechange = () => {
7761 if (request.readyState !== XMLHttpRequest.DONE) {
7762 return;
7763 }
7764 if (request.status === 200 || request.status === 0) {
7765 let data;
7766 switch (type) {
7767 case "arraybuffer":
7768 case "blob":
7769 case "json":
7770 data = request.response;
7771 break;
7772 default:
7773 data = request.responseText;
7774 break;
7775 }
7776 if (data) {
7777 resolve(data);
7778 return;
7779 }
7780 }
7781 reject(new Error(request.statusText));
7782 };
7783 request.send(null);
7784 });
7785}
7786class DOMCMapReaderFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_0__.BaseCMapReaderFactory {
7787 _fetchData(url, compressionType) {
7788 return fetchData(url, this.isCompressed ? "arraybuffer" : "text").then(data => {
7789 return {
7790 cMapData: data instanceof ArrayBuffer ? new Uint8Array(data) : (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.stringToBytes)(data),
7791 compressionType
7792 };
7793 });
7794 }
7795}
7796class DOMStandardFontDataFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_0__.BaseStandardFontDataFactory {
7797 _fetchData(url) {
7798 return fetchData(url, "arraybuffer").then(data => {
7799 return new Uint8Array(data);
7800 });
7801 }
7802}
7803class DOMSVGFactory extends _base_factory_js__WEBPACK_IMPORTED_MODULE_0__.BaseSVGFactory {
7804 _createSVG(type) {
7805 return document.createElementNS(SVG_NS, type);
7806 }
7807}
7808class PageViewport {
7809 constructor({
7810 viewBox,
7811 scale,
7812 rotation,
7813 offsetX = 0,
7814 offsetY = 0,
7815 dontFlip = false
7816 }) {
7817 this.viewBox = viewBox;
7818 this.scale = scale;
7819 this.rotation = rotation;
7820 this.offsetX = offsetX;
7821 this.offsetY = offsetY;
7822 const centerX = (viewBox[2] + viewBox[0]) / 2;
7823 const centerY = (viewBox[3] + viewBox[1]) / 2;
7824 let rotateA, rotateB, rotateC, rotateD;
7825 rotation %= 360;
7826 if (rotation < 0) {
7827 rotation += 360;
7828 }
7829 switch (rotation) {
7830 case 180:
7831 rotateA = -1;
7832 rotateB = 0;
7833 rotateC = 0;
7834 rotateD = 1;
7835 break;
7836 case 90:
7837 rotateA = 0;
7838 rotateB = 1;
7839 rotateC = 1;
7840 rotateD = 0;
7841 break;
7842 case 270:
7843 rotateA = 0;
7844 rotateB = -1;
7845 rotateC = -1;
7846 rotateD = 0;
7847 break;
7848 case 0:
7849 rotateA = 1;
7850 rotateB = 0;
7851 rotateC = 0;
7852 rotateD = -1;
7853 break;
7854 default:
7855 throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
7856 }
7857 if (dontFlip) {
7858 rotateC = -rotateC;
7859 rotateD = -rotateD;
7860 }
7861 let offsetCanvasX, offsetCanvasY;
7862 let width, height;
7863 if (rotateA === 0) {
7864 offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
7865 offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
7866 width = (viewBox[3] - viewBox[1]) * scale;
7867 height = (viewBox[2] - viewBox[0]) * scale;
7868 } else {
7869 offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
7870 offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
7871 width = (viewBox[2] - viewBox[0]) * scale;
7872 height = (viewBox[3] - viewBox[1]) * scale;
7873 }
7874 this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
7875 this.width = width;
7876 this.height = height;
7877 }
7878 get rawDims() {
7879 const {
7880 viewBox
7881 } = this;
7882 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "rawDims", {
7883 pageWidth: viewBox[2] - viewBox[0],
7884 pageHeight: viewBox[3] - viewBox[1],
7885 pageX: viewBox[0],
7886 pageY: viewBox[1]
7887 });
7888 }
7889 clone({
7890 scale = this.scale,
7891 rotation = this.rotation,
7892 offsetX = this.offsetX,
7893 offsetY = this.offsetY,
7894 dontFlip = false
7895 } = {}) {
7896 return new PageViewport({
7897 viewBox: this.viewBox.slice(),
7898 scale,
7899 rotation,
7900 offsetX,
7901 offsetY,
7902 dontFlip
7903 });
7904 }
7905 convertToViewportPoint(x, y) {
7906 return _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.Util.applyTransform([x, y], this.transform);
7907 }
7908 convertToViewportRectangle(rect) {
7909 const topLeft = _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.Util.applyTransform([rect[0], rect[1]], this.transform);
7910 const bottomRight = _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.Util.applyTransform([rect[2], rect[3]], this.transform);
7911 return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
7912 }
7913 convertToPdfPoint(x, y) {
7914 return _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.Util.applyInverseTransform([x, y], this.transform);
7915 }
7916}
7917class RenderingCancelledException extends _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.BaseException {
7918 constructor(msg, extraDelay = 0) {
7919 super(msg, "RenderingCancelledException");
7920 this.extraDelay = extraDelay;
7921 }
7922}
7923function isDataScheme(url) {
7924 const ii = url.length;
7925 let i = 0;
7926 while (i < ii && url[i].trim() === "") {
7927 i++;
7928 }
7929 return url.substring(i, i + 5).toLowerCase() === "data:";
7930}
7931function isPdfFile(filename) {
7932 return typeof filename === "string" && /\.pdf$/i.test(filename);
7933}
7934function getFilenameFromUrl(url, onlyStripPath = false) {
7935 if (!onlyStripPath) {
7936 [url] = url.split(/[#?]/, 1);
7937 }
7938 return url.substring(url.lastIndexOf("/") + 1);
7939}
7940function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
7941 if (typeof url !== "string") {
7942 return defaultFilename;
7943 }
7944 if (isDataScheme(url)) {
7945 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
7946 return defaultFilename;
7947 }
7948 const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
7949 const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
7950 const splitURI = reURI.exec(url);
7951 let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
7952 if (suggestedFilename) {
7953 suggestedFilename = suggestedFilename[0];
7954 if (suggestedFilename.includes("%")) {
7955 try {
7956 suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
7957 } catch {}
7958 }
7959 }
7960 return suggestedFilename || defaultFilename;
7961}
7962class StatTimer {
7963 started = Object.create(null);
7964 times = [];
7965 time(name) {
7966 if (name in this.started) {
7967 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.warn)(`Timer is already running for ${name}`);
7968 }
7969 this.started[name] = Date.now();
7970 }
7971 timeEnd(name) {
7972 if (!(name in this.started)) {
7973 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.warn)(`Timer has not been started for ${name}`);
7974 }
7975 this.times.push({
7976 name,
7977 start: this.started[name],
7978 end: Date.now()
7979 });
7980 delete this.started[name];
7981 }
7982 toString() {
7983 const outBuf = [];
7984 let longest = 0;
7985 for (const {
7986 name
7987 } of this.times) {
7988 longest = Math.max(name.length, longest);
7989 }
7990 for (const {
7991 name,
7992 start,
7993 end
7994 } of this.times) {
7995 outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
7996 }
7997 return outBuf.join("");
7998 }
7999}
8000function isValidFetchUrl(url, baseUrl) {
8001 try {
8002 const {
8003 protocol
8004 } = baseUrl ? new URL(url, baseUrl) : new URL(url);
8005 return protocol === "http:" || protocol === "https:";
8006 } catch {
8007 return false;
8008 }
8009}
8010function noContextMenu(e) {
8011 e.preventDefault();
8012}
8013function deprecated(details) {
8014 console.log("Deprecated API usage: " + details);
8015}
8016let pdfDateStringRegex;
8017class PDFDateString {
8018 static toDateObject(input) {
8019 if (!input || typeof input !== "string") {
8020 return null;
8021 }
8022 pdfDateStringRegex ||= new RegExp("^D:" + "(\\d{4})" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "([Z|+|-])?" + "(\\d{2})?" + "'?" + "(\\d{2})?" + "'?");
8023 const matches = pdfDateStringRegex.exec(input);
8024 if (!matches) {
8025 return null;
8026 }
8027 const year = parseInt(matches[1], 10);
8028 let month = parseInt(matches[2], 10);
8029 month = month >= 1 && month <= 12 ? month - 1 : 0;
8030 let day = parseInt(matches[3], 10);
8031 day = day >= 1 && day <= 31 ? day : 1;
8032 let hour = parseInt(matches[4], 10);
8033 hour = hour >= 0 && hour <= 23 ? hour : 0;
8034 let minute = parseInt(matches[5], 10);
8035 minute = minute >= 0 && minute <= 59 ? minute : 0;
8036 let second = parseInt(matches[6], 10);
8037 second = second >= 0 && second <= 59 ? second : 0;
8038 const universalTimeRelation = matches[7] || "Z";
8039 let offsetHour = parseInt(matches[8], 10);
8040 offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
8041 let offsetMinute = parseInt(matches[9], 10) || 0;
8042 offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
8043 if (universalTimeRelation === "-") {
8044 hour += offsetHour;
8045 minute += offsetMinute;
8046 } else if (universalTimeRelation === "+") {
8047 hour -= offsetHour;
8048 minute -= offsetMinute;
8049 }
8050 return new Date(Date.UTC(year, month, day, hour, minute, second));
8051 }
8052}
8053function getXfaPageViewport(xfaPage, {
8054 scale = 1,
8055 rotation = 0
8056}) {
8057 const {
8058 width,
8059 height
8060 } = xfaPage.attributes.style;
8061 const viewBox = [0, 0, parseInt(width), parseInt(height)];
8062 return new PageViewport({
8063 viewBox,
8064 scale,
8065 rotation
8066 });
8067}
8068function getRGB(color) {
8069 if (color.startsWith("#")) {
8070 const colorRGB = parseInt(color.slice(1), 16);
8071 return [(colorRGB & 0xff0000) >> 16, (colorRGB & 0x00ff00) >> 8, colorRGB & 0x0000ff];
8072 }
8073 if (color.startsWith("rgb(")) {
8074 return color.slice(4, -1).split(",").map(x => parseInt(x));
8075 }
8076 if (color.startsWith("rgba(")) {
8077 return color.slice(5, -1).split(",").map(x => parseInt(x)).slice(0, 3);
8078 }
8079 (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.warn)(`Not a valid color format: "${color}"`);
8080 return [0, 0, 0];
8081}
8082function getColorValues(colors) {
8083 const span = document.createElement("span");
8084 span.style.visibility = "hidden";
8085 document.body.append(span);
8086 for (const name of colors.keys()) {
8087 span.style.color = name;
8088 const computedColor = window.getComputedStyle(span).color;
8089 colors.set(name, getRGB(computedColor));
8090 }
8091 span.remove();
8092}
8093function getCurrentTransform(ctx) {
8094 const {
8095 a,
8096 b,
8097 c,
8098 d,
8099 e,
8100 f
8101 } = ctx.getTransform();
8102 return [a, b, c, d, e, f];
8103}
8104function getCurrentTransformInverse(ctx) {
8105 const {
8106 a,
8107 b,
8108 c,
8109 d,
8110 e,
8111 f
8112 } = ctx.getTransform().invertSelf();
8113 return [a, b, c, d, e, f];
8114}
8115function setLayerDimensions(div, viewport, mustFlip = false, mustRotate = true) {
8116 if (viewport instanceof PageViewport) {
8117 const {
8118 pageWidth,
8119 pageHeight
8120 } = viewport.rawDims;
8121 const {
8122 style
8123 } = div;
8124 const useRound = _shared_util_js__WEBPACK_IMPORTED_MODULE_1__.FeatureTest.isCSSRoundSupported;
8125 const w = `var(--scale-factor) * ${pageWidth}px`,
8126 h = `var(--scale-factor) * ${pageHeight}px`;
8127 const widthStr = useRound ? `round(${w}, 1px)` : `calc(${w})`,
8128 heightStr = useRound ? `round(${h}, 1px)` : `calc(${h})`;
8129 if (!mustFlip || viewport.rotation % 180 === 0) {
8130 style.width = widthStr;
8131 style.height = heightStr;
8132 } else {
8133 style.width = heightStr;
8134 style.height = widthStr;
8135 }
8136 }
8137 if (mustRotate) {
8138 div.setAttribute("data-main-rotation", viewport.rotation);
8139 }
8140}
8141
8142
8143/***/ }),
8144
8145/***/ 423:
8146/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8147
8148/* harmony export */ __webpack_require__.d(__webpack_exports__, {
8149/* harmony export */ DrawLayer: () => (/* binding */ DrawLayer)
8150/* harmony export */ });
8151/* harmony import */ var _display_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(473);
8152/* harmony import */ var _shared_util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(266);
8153
8154
8155class DrawLayer {
8156 #parent = null;
8157 #id = 0;
8158 #mapping = new Map();
8159 constructor({
8160 pageIndex
8161 }) {
8162 this.pageIndex = pageIndex;
8163 }
8164 setParent(parent) {
8165 if (!this.#parent) {
8166 this.#parent = parent;
8167 return;
8168 }
8169 if (this.#parent !== parent) {
8170 if (this.#mapping.size > 0) {
8171 for (const root of this.#mapping.values()) {
8172 root.remove();
8173 parent.append(root);
8174 }
8175 }
8176 this.#parent = parent;
8177 }
8178 }
8179 static get _svgFactory() {
8180 return (0,_shared_util_js__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_svgFactory", new _display_utils_js__WEBPACK_IMPORTED_MODULE_0__.DOMSVGFactory());
8181 }
8182 static #setBox(element, {
8183 x,
8184 y,
8185 width,
8186 height
8187 }) {
8188 const {
8189 style
8190 } = element;
8191 style.top = `${100 * y}%`;
8192 style.left = `${100 * x}%`;
8193 style.width = `${100 * width}%`;
8194 style.height = `${100 * height}%`;
8195 }
8196 #createSVG(box) {
8197 const svg = DrawLayer._svgFactory.create(1, 1, true);
8198 this.#parent.append(svg);
8199 DrawLayer.#setBox(svg, box);
8200 return svg;
8201 }
8202 highlight({
8203 outlines,
8204 box
8205 }, color, opacity) {
8206 const id = this.#id++;
8207 const root = this.#createSVG(box);
8208 root.classList.add("highlight");
8209 const defs = DrawLayer._svgFactory.createElement("defs");
8210 root.append(defs);
8211 const path = DrawLayer._svgFactory.createElement("path");
8212 defs.append(path);
8213 const pathId = `path_p${this.pageIndex}_${id}`;
8214 path.setAttribute("id", pathId);
8215 path.setAttribute("d", DrawLayer.#extractPathFromHighlightOutlines(outlines));
8216 const clipPath = DrawLayer._svgFactory.createElement("clipPath");
8217 defs.append(clipPath);
8218 const clipPathId = `clip_${pathId}`;
8219 clipPath.setAttribute("id", clipPathId);
8220 clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
8221 const clipPathUse = DrawLayer._svgFactory.createElement("use");
8222 clipPath.append(clipPathUse);
8223 clipPathUse.setAttribute("href", `#${pathId}`);
8224 clipPathUse.classList.add("clip");
8225 const use = DrawLayer._svgFactory.createElement("use");
8226 root.append(use);
8227 root.setAttribute("fill", color);
8228 root.setAttribute("fill-opacity", opacity);
8229 use.setAttribute("href", `#${pathId}`);
8230 this.#mapping.set(id, root);
8231 return {
8232 id,
8233 clipPathId: `url(#${clipPathId})`
8234 };
8235 }
8236 highlightOutline({
8237 outlines,
8238 box
8239 }) {
8240 const id = this.#id++;
8241 const root = this.#createSVG(box);
8242 root.classList.add("highlightOutline");
8243 const defs = DrawLayer._svgFactory.createElement("defs");
8244 root.append(defs);
8245 const path = DrawLayer._svgFactory.createElement("path");
8246 defs.append(path);
8247 const pathId = `path_p${this.pageIndex}_${id}`;
8248 path.setAttribute("id", pathId);
8249 path.setAttribute("d", DrawLayer.#extractPathFromHighlightOutlines(outlines));
8250 path.setAttribute("vector-effect", "non-scaling-stroke");
8251 const use1 = DrawLayer._svgFactory.createElement("use");
8252 root.append(use1);
8253 use1.setAttribute("href", `#${pathId}`);
8254 const use2 = use1.cloneNode();
8255 root.append(use2);
8256 use1.classList.add("mainOutline");
8257 use2.classList.add("secondaryOutline");
8258 this.#mapping.set(id, root);
8259 return id;
8260 }
8261 static #extractPathFromHighlightOutlines(polygons) {
8262 const buffer = [];
8263 for (const polygon of polygons) {
8264 let [prevX, prevY] = polygon;
8265 buffer.push(`M${prevX} ${prevY}`);
8266 for (let i = 2; i < polygon.length; i += 2) {
8267 const x = polygon[i];
8268 const y = polygon[i + 1];
8269 if (x === prevX) {
8270 buffer.push(`V${y}`);
8271 prevY = y;
8272 } else if (y === prevY) {
8273 buffer.push(`H${x}`);
8274 prevX = x;
8275 }
8276 }
8277 buffer.push("Z");
8278 }
8279 return buffer.join(" ");
8280 }
8281 updateBox(id, box) {
8282 DrawLayer.#setBox(this.#mapping.get(id), box);
8283 }
8284 rotate(id, angle) {
8285 this.#mapping.get(id).setAttribute("data-main-rotation", angle);
8286 }
8287 changeColor(id, color) {
8288 this.#mapping.get(id).setAttribute("fill", color);
8289 }
8290 changeOpacity(id, opacity) {
8291 this.#mapping.get(id).setAttribute("fill-opacity", opacity);
8292 }
8293 addClass(id, className) {
8294 this.#mapping.get(id).classList.add(className);
8295 }
8296 removeClass(id, className) {
8297 this.#mapping.get(id).classList.remove(className);
8298 }
8299 remove(id) {
8300 this.#mapping.get(id).remove();
8301 this.#mapping.delete(id);
8302 }
8303 destroy() {
8304 this.#parent = null;
8305 for (const root of this.#mapping.values()) {
8306 root.remove();
8307 }
8308 this.#mapping.clear();
8309 }
8310}
8311
8312
8313/***/ }),
8314
8315/***/ 331:
8316/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8317
8318
8319// EXPORTS
8320__webpack_require__.d(__webpack_exports__, {
8321 AnnotationEditorLayer: () => (/* binding */ AnnotationEditorLayer)
8322});
8323
8324// EXTERNAL MODULE: ./src/shared/util.js
8325var util = __webpack_require__(266);
8326// EXTERNAL MODULE: ./src/display/editor/editor.js + 1 modules
8327var editor_editor = __webpack_require__(796);
8328// EXTERNAL MODULE: ./src/display/editor/tools.js
8329var tools = __webpack_require__(812);
8330// EXTERNAL MODULE: ./src/display/annotation_layer.js + 1 modules
8331var annotation_layer = __webpack_require__(640);
8332;// CONCATENATED MODULE: ./src/display/editor/freetext.js
8333
8334
8335
8336
8337class FreeTextEditor extends editor_editor.AnnotationEditor {
8338 #boundEditorDivBlur = this.editorDivBlur.bind(this);
8339 #boundEditorDivFocus = this.editorDivFocus.bind(this);
8340 #boundEditorDivInput = this.editorDivInput.bind(this);
8341 #boundEditorDivKeydown = this.editorDivKeydown.bind(this);
8342 #color;
8343 #content = "";
8344 #editorDivId = `${this.id}-editor`;
8345 #fontSize;
8346 #initialData = null;
8347 static _freeTextDefaultContent = "";
8348 static _internalPadding = 0;
8349 static _defaultColor = null;
8350 static _defaultFontSize = 10;
8351 static get _keyboardManager() {
8352 const proto = FreeTextEditor.prototype;
8353 const arrowChecker = self => self.isEmpty();
8354 const small = tools.AnnotationEditorUIManager.TRANSLATE_SMALL;
8355 const big = tools.AnnotationEditorUIManager.TRANSLATE_BIG;
8356 return (0,util.shadow)(this, "_keyboardManager", new tools.KeyboardManager([[["ctrl+s", "mac+meta+s", "ctrl+p", "mac+meta+p"], proto.commitOrRemove, {
8357 bubbles: true
8358 }], [["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], proto.commitOrRemove], [["ArrowLeft", "mac+ArrowLeft"], proto._translateEmpty, {
8359 args: [-small, 0],
8360 checker: arrowChecker
8361 }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], proto._translateEmpty, {
8362 args: [-big, 0],
8363 checker: arrowChecker
8364 }], [["ArrowRight", "mac+ArrowRight"], proto._translateEmpty, {
8365 args: [small, 0],
8366 checker: arrowChecker
8367 }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], proto._translateEmpty, {
8368 args: [big, 0],
8369 checker: arrowChecker
8370 }], [["ArrowUp", "mac+ArrowUp"], proto._translateEmpty, {
8371 args: [0, -small],
8372 checker: arrowChecker
8373 }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], proto._translateEmpty, {
8374 args: [0, -big],
8375 checker: arrowChecker
8376 }], [["ArrowDown", "mac+ArrowDown"], proto._translateEmpty, {
8377 args: [0, small],
8378 checker: arrowChecker
8379 }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], proto._translateEmpty, {
8380 args: [0, big],
8381 checker: arrowChecker
8382 }]]));
8383 }
8384 static _type = "freetext";
8385 static _editorType = util.AnnotationEditorType.FREETEXT;
8386 constructor(params) {
8387 super({
8388 ...params,
8389 name: "freeTextEditor"
8390 });
8391 this.#color = params.color || FreeTextEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor;
8392 this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;
8393 }
8394 static initialize(l10n) {
8395 editor_editor.AnnotationEditor.initialize(l10n, {
8396 strings: ["pdfjs-free-text-default-content"]
8397 });
8398 const style = getComputedStyle(document.documentElement);
8399 this._internalPadding = parseFloat(style.getPropertyValue("--freetext-padding"));
8400 }
8401 static updateDefaultParams(type, value) {
8402 switch (type) {
8403 case util.AnnotationEditorParamsType.FREETEXT_SIZE:
8404 FreeTextEditor._defaultFontSize = value;
8405 break;
8406 case util.AnnotationEditorParamsType.FREETEXT_COLOR:
8407 FreeTextEditor._defaultColor = value;
8408 break;
8409 }
8410 }
8411 updateParams(type, value) {
8412 switch (type) {
8413 case util.AnnotationEditorParamsType.FREETEXT_SIZE:
8414 this.#updateFontSize(value);
8415 break;
8416 case util.AnnotationEditorParamsType.FREETEXT_COLOR:
8417 this.#updateColor(value);
8418 break;
8419 }
8420 }
8421 static get defaultPropertiesToUpdate() {
8422 return [[util.AnnotationEditorParamsType.FREETEXT_SIZE, FreeTextEditor._defaultFontSize], [util.AnnotationEditorParamsType.FREETEXT_COLOR, FreeTextEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor]];
8423 }
8424 get propertiesToUpdate() {
8425 return [[util.AnnotationEditorParamsType.FREETEXT_SIZE, this.#fontSize], [util.AnnotationEditorParamsType.FREETEXT_COLOR, this.#color]];
8426 }
8427 #updateFontSize(fontSize) {
8428 const setFontsize = size => {
8429 this.editorDiv.style.fontSize = `calc(${size}px * var(--scale-factor))`;
8430 this.translate(0, -(size - this.#fontSize) * this.parentScale);
8431 this.#fontSize = size;
8432 this.#setEditorDimensions();
8433 };
8434 const savedFontsize = this.#fontSize;
8435 this.addCommands({
8436 cmd: () => {
8437 setFontsize(fontSize);
8438 },
8439 undo: () => {
8440 setFontsize(savedFontsize);
8441 },
8442 mustExec: true,
8443 type: util.AnnotationEditorParamsType.FREETEXT_SIZE,
8444 overwriteIfSameType: true,
8445 keepUndo: true
8446 });
8447 }
8448 #updateColor(color) {
8449 const savedColor = this.#color;
8450 this.addCommands({
8451 cmd: () => {
8452 this.#color = this.editorDiv.style.color = color;
8453 },
8454 undo: () => {
8455 this.#color = this.editorDiv.style.color = savedColor;
8456 },
8457 mustExec: true,
8458 type: util.AnnotationEditorParamsType.FREETEXT_COLOR,
8459 overwriteIfSameType: true,
8460 keepUndo: true
8461 });
8462 }
8463 _translateEmpty(x, y) {
8464 this._uiManager.translateSelectedEditors(x, y, true);
8465 }
8466 getInitialTranslation() {
8467 const scale = this.parentScale;
8468 return [-FreeTextEditor._internalPadding * scale, -(FreeTextEditor._internalPadding + this.#fontSize) * scale];
8469 }
8470 rebuild() {
8471 if (!this.parent) {
8472 return;
8473 }
8474 super.rebuild();
8475 if (this.div === null) {
8476 return;
8477 }
8478 if (!this.isAttachedToDOM) {
8479 this.parent.add(this);
8480 }
8481 }
8482 enableEditMode() {
8483 if (this.isInEditMode()) {
8484 return;
8485 }
8486 this.parent.setEditingState(false);
8487 this.parent.updateToolbar(util.AnnotationEditorType.FREETEXT);
8488 super.enableEditMode();
8489 this.overlayDiv.classList.remove("enabled");
8490 this.editorDiv.contentEditable = true;
8491 this._isDraggable = false;
8492 this.div.removeAttribute("aria-activedescendant");
8493 this.editorDiv.addEventListener("keydown", this.#boundEditorDivKeydown);
8494 this.editorDiv.addEventListener("focus", this.#boundEditorDivFocus);
8495 this.editorDiv.addEventListener("blur", this.#boundEditorDivBlur);
8496 this.editorDiv.addEventListener("input", this.#boundEditorDivInput);
8497 }
8498 disableEditMode() {
8499 if (!this.isInEditMode()) {
8500 return;
8501 }
8502 this.parent.setEditingState(true);
8503 super.disableEditMode();
8504 this.overlayDiv.classList.add("enabled");
8505 this.editorDiv.contentEditable = false;
8506 this.div.setAttribute("aria-activedescendant", this.#editorDivId);
8507 this._isDraggable = true;
8508 this.editorDiv.removeEventListener("keydown", this.#boundEditorDivKeydown);
8509 this.editorDiv.removeEventListener("focus", this.#boundEditorDivFocus);
8510 this.editorDiv.removeEventListener("blur", this.#boundEditorDivBlur);
8511 this.editorDiv.removeEventListener("input", this.#boundEditorDivInput);
8512 this.div.focus({
8513 preventScroll: true
8514 });
8515 this.isEditing = false;
8516 this.parent.div.classList.add("freetextEditing");
8517 }
8518 focusin(event) {
8519 if (!this._focusEventsAllowed) {
8520 return;
8521 }
8522 super.focusin(event);
8523 if (event.target !== this.editorDiv) {
8524 this.editorDiv.focus();
8525 }
8526 }
8527 onceAdded() {
8528 if (this.width) {
8529 this.#cheatInitialRect();
8530 return;
8531 }
8532 this.enableEditMode();
8533 this.editorDiv.focus();
8534 if (this._initialOptions?.isCentered) {
8535 this.center();
8536 }
8537 this._initialOptions = null;
8538 }
8539 isEmpty() {
8540 return !this.editorDiv || this.editorDiv.innerText.trim() === "";
8541 }
8542 remove() {
8543 this.isEditing = false;
8544 if (this.parent) {
8545 this.parent.setEditingState(true);
8546 this.parent.div.classList.add("freetextEditing");
8547 }
8548 super.remove();
8549 }
8550 #extractText() {
8551 const divs = this.editorDiv.getElementsByTagName("div");
8552 if (divs.length === 0) {
8553 return this.editorDiv.innerText;
8554 }
8555 const buffer = [];
8556 for (const div of divs) {
8557 buffer.push(div.innerText.replace(/\r\n?|\n/, ""));
8558 }
8559 return buffer.join("\n");
8560 }
8561 #setEditorDimensions() {
8562 const [parentWidth, parentHeight] = this.parentDimensions;
8563 let rect;
8564 if (this.isAttachedToDOM) {
8565 rect = this.div.getBoundingClientRect();
8566 } else {
8567 const {
8568 currentLayer,
8569 div
8570 } = this;
8571 const savedDisplay = div.style.display;
8572 div.style.display = "hidden";
8573 currentLayer.div.append(this.div);
8574 rect = div.getBoundingClientRect();
8575 div.remove();
8576 div.style.display = savedDisplay;
8577 }
8578 if (this.rotation % 180 === this.parentRotation % 180) {
8579 this.width = rect.width / parentWidth;
8580 this.height = rect.height / parentHeight;
8581 } else {
8582 this.width = rect.height / parentWidth;
8583 this.height = rect.width / parentHeight;
8584 }
8585 this.fixAndSetPosition();
8586 }
8587 commit() {
8588 if (!this.isInEditMode()) {
8589 return;
8590 }
8591 super.commit();
8592 this.disableEditMode();
8593 const savedText = this.#content;
8594 const newText = this.#content = this.#extractText().trimEnd();
8595 if (savedText === newText) {
8596 return;
8597 }
8598 const setText = text => {
8599 this.#content = text;
8600 if (!text) {
8601 this.remove();
8602 return;
8603 }
8604 this.#setContent();
8605 this._uiManager.rebuild(this);
8606 this.#setEditorDimensions();
8607 };
8608 this.addCommands({
8609 cmd: () => {
8610 setText(newText);
8611 },
8612 undo: () => {
8613 setText(savedText);
8614 },
8615 mustExec: false
8616 });
8617 this.#setEditorDimensions();
8618 }
8619 shouldGetKeyboardEvents() {
8620 return this.isInEditMode();
8621 }
8622 enterInEditMode() {
8623 this.enableEditMode();
8624 this.editorDiv.focus();
8625 }
8626 dblclick(event) {
8627 this.enterInEditMode();
8628 }
8629 keydown(event) {
8630 if (event.target === this.div && event.key === "Enter") {
8631 this.enterInEditMode();
8632 event.preventDefault();
8633 }
8634 }
8635 editorDivKeydown(event) {
8636 FreeTextEditor._keyboardManager.exec(this, event);
8637 }
8638 editorDivFocus(event) {
8639 this.isEditing = true;
8640 }
8641 editorDivBlur(event) {
8642 this.isEditing = false;
8643 }
8644 editorDivInput(event) {
8645 this.parent.div.classList.toggle("freetextEditing", this.isEmpty());
8646 }
8647 disableEditing() {
8648 this.editorDiv.setAttribute("role", "comment");
8649 this.editorDiv.removeAttribute("aria-multiline");
8650 }
8651 enableEditing() {
8652 this.editorDiv.setAttribute("role", "textbox");
8653 this.editorDiv.setAttribute("aria-multiline", true);
8654 }
8655 render() {
8656 if (this.div) {
8657 return this.div;
8658 }
8659 let baseX, baseY;
8660 if (this.width) {
8661 baseX = this.x;
8662 baseY = this.y;
8663 }
8664 super.render();
8665 this.editorDiv = document.createElement("div");
8666 this.editorDiv.className = "internal";
8667 this.editorDiv.setAttribute("id", this.#editorDivId);
8668 this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text");
8669 this.enableEditing();
8670 editor_editor.AnnotationEditor._l10nPromise.get("pdfjs-free-text-default-content").then(msg => this.editorDiv?.setAttribute("default-content", msg));
8671 this.editorDiv.contentEditable = true;
8672 const {
8673 style
8674 } = this.editorDiv;
8675 style.fontSize = `calc(${this.#fontSize}px * var(--scale-factor))`;
8676 style.color = this.#color;
8677 this.div.append(this.editorDiv);
8678 this.overlayDiv = document.createElement("div");
8679 this.overlayDiv.classList.add("overlay", "enabled");
8680 this.div.append(this.overlayDiv);
8681 (0,tools.bindEvents)(this, this.div, ["dblclick", "keydown"]);
8682 if (this.width) {
8683 const [parentWidth, parentHeight] = this.parentDimensions;
8684 if (this.annotationElementId) {
8685 const {
8686 position
8687 } = this.#initialData;
8688 let [tx, ty] = this.getInitialTranslation();
8689 [tx, ty] = this.pageTranslationToScreen(tx, ty);
8690 const [pageWidth, pageHeight] = this.pageDimensions;
8691 const [pageX, pageY] = this.pageTranslation;
8692 let posX, posY;
8693 switch (this.rotation) {
8694 case 0:
8695 posX = baseX + (position[0] - pageX) / pageWidth;
8696 posY = baseY + this.height - (position[1] - pageY) / pageHeight;
8697 break;
8698 case 90:
8699 posX = baseX + (position[0] - pageX) / pageWidth;
8700 posY = baseY - (position[1] - pageY) / pageHeight;
8701 [tx, ty] = [ty, -tx];
8702 break;
8703 case 180:
8704 posX = baseX - this.width + (position[0] - pageX) / pageWidth;
8705 posY = baseY - (position[1] - pageY) / pageHeight;
8706 [tx, ty] = [-tx, -ty];
8707 break;
8708 case 270:
8709 posX = baseX + (position[0] - pageX - this.height * pageHeight) / pageWidth;
8710 posY = baseY + (position[1] - pageY - this.width * pageWidth) / pageHeight;
8711 [tx, ty] = [-ty, tx];
8712 break;
8713 }
8714 this.setAt(posX * parentWidth, posY * parentHeight, tx, ty);
8715 } else {
8716 this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
8717 }
8718 this.#setContent();
8719 this._isDraggable = true;
8720 this.editorDiv.contentEditable = false;
8721 } else {
8722 this._isDraggable = false;
8723 this.editorDiv.contentEditable = true;
8724 }
8725 return this.div;
8726 }
8727 #setContent() {
8728 this.editorDiv.replaceChildren();
8729 if (!this.#content) {
8730 return;
8731 }
8732 for (const line of this.#content.split("\n")) {
8733 const div = document.createElement("div");
8734 div.append(line ? document.createTextNode(line) : document.createElement("br"));
8735 this.editorDiv.append(div);
8736 }
8737 }
8738 get contentDiv() {
8739 return this.editorDiv;
8740 }
8741 static deserialize(data, parent, uiManager) {
8742 let initialData = null;
8743 if (data instanceof annotation_layer.FreeTextAnnotationElement) {
8744 const {
8745 data: {
8746 defaultAppearanceData: {
8747 fontSize,
8748 fontColor
8749 },
8750 rect,
8751 rotation,
8752 id
8753 },
8754 textContent,
8755 textPosition,
8756 parent: {
8757 page: {
8758 pageNumber
8759 }
8760 }
8761 } = data;
8762 if (!textContent || textContent.length === 0) {
8763 return null;
8764 }
8765 initialData = data = {
8766 annotationType: util.AnnotationEditorType.FREETEXT,
8767 color: Array.from(fontColor),
8768 fontSize,
8769 value: textContent.join("\n"),
8770 position: textPosition,
8771 pageIndex: pageNumber - 1,
8772 rect,
8773 rotation,
8774 id,
8775 deleted: false
8776 };
8777 }
8778 const editor = super.deserialize(data, parent, uiManager);
8779 editor.#fontSize = data.fontSize;
8780 editor.#color = util.Util.makeHexColor(...data.color);
8781 editor.#content = data.value;
8782 editor.annotationElementId = data.id || null;
8783 editor.#initialData = initialData;
8784 return editor;
8785 }
8786 serialize(isForCopying = false) {
8787 if (this.isEmpty()) {
8788 return null;
8789 }
8790 if (this.deleted) {
8791 return {
8792 pageIndex: this.pageIndex,
8793 id: this.annotationElementId,
8794 deleted: true
8795 };
8796 }
8797 const padding = FreeTextEditor._internalPadding * this.parentScale;
8798 const rect = this.getRect(padding, padding);
8799 const color = editor_editor.AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : this.#color);
8800 const serialized = {
8801 annotationType: util.AnnotationEditorType.FREETEXT,
8802 color,
8803 fontSize: this.#fontSize,
8804 value: this.#content,
8805 pageIndex: this.pageIndex,
8806 rect,
8807 rotation: this.rotation,
8808 structTreeParentId: this._structTreeParentId
8809 };
8810 if (isForCopying) {
8811 return serialized;
8812 }
8813 if (this.annotationElementId && !this.#hasElementChanged(serialized)) {
8814 return null;
8815 }
8816 serialized.id = this.annotationElementId;
8817 return serialized;
8818 }
8819 #hasElementChanged(serialized) {
8820 const {
8821 value,
8822 fontSize,
8823 color,
8824 rect,
8825 pageIndex
8826 } = this.#initialData;
8827 return serialized.value !== value || serialized.fontSize !== fontSize || serialized.rect.some((x, i) => Math.abs(x - rect[i]) >= 1) || serialized.color.some((c, i) => c !== color[i]) || serialized.pageIndex !== pageIndex;
8828 }
8829 #cheatInitialRect(delayed = false) {
8830 if (!this.annotationElementId) {
8831 return;
8832 }
8833 this.#setEditorDimensions();
8834 if (!delayed && (this.width === 0 || this.height === 0)) {
8835 setTimeout(() => this.#cheatInitialRect(true), 0);
8836 return;
8837 }
8838 const padding = FreeTextEditor._internalPadding * this.parentScale;
8839 this.#initialData.rect = this.getRect(padding, padding);
8840 }
8841}
8842
8843// EXTERNAL MODULE: ./src/display/display_utils.js
8844var display_utils = __webpack_require__(473);
8845;// CONCATENATED MODULE: ./src/display/editor/ink.js
8846
8847
8848
8849
8850
8851class InkEditor extends editor_editor.AnnotationEditor {
8852 #baseHeight = 0;
8853 #baseWidth = 0;
8854 #boundCanvasPointermove = this.canvasPointermove.bind(this);
8855 #boundCanvasPointerleave = this.canvasPointerleave.bind(this);
8856 #boundCanvasPointerup = this.canvasPointerup.bind(this);
8857 #boundCanvasPointerdown = this.canvasPointerdown.bind(this);
8858 #canvasContextMenuTimeoutId = null;
8859 #currentPath2D = new Path2D();
8860 #disableEditing = false;
8861 #hasSomethingToDraw = false;
8862 #isCanvasInitialized = false;
8863 #observer = null;
8864 #realWidth = 0;
8865 #realHeight = 0;
8866 #requestFrameCallback = null;
8867 static _defaultColor = null;
8868 static _defaultOpacity = 1;
8869 static _defaultThickness = 1;
8870 static _type = "ink";
8871 static _editorType = util.AnnotationEditorType.INK;
8872 constructor(params) {
8873 super({
8874 ...params,
8875 name: "inkEditor"
8876 });
8877 this.color = params.color || null;
8878 this.thickness = params.thickness || null;
8879 this.opacity = params.opacity || null;
8880 this.paths = [];
8881 this.bezierPath2D = [];
8882 this.allRawPaths = [];
8883 this.currentPath = [];
8884 this.scaleFactor = 1;
8885 this.translationX = this.translationY = 0;
8886 this.x = 0;
8887 this.y = 0;
8888 this._willKeepAspectRatio = true;
8889 }
8890 static initialize(l10n) {
8891 editor_editor.AnnotationEditor.initialize(l10n);
8892 }
8893 static updateDefaultParams(type, value) {
8894 switch (type) {
8895 case util.AnnotationEditorParamsType.INK_THICKNESS:
8896 InkEditor._defaultThickness = value;
8897 break;
8898 case util.AnnotationEditorParamsType.INK_COLOR:
8899 InkEditor._defaultColor = value;
8900 break;
8901 case util.AnnotationEditorParamsType.INK_OPACITY:
8902 InkEditor._defaultOpacity = value / 100;
8903 break;
8904 }
8905 }
8906 updateParams(type, value) {
8907 switch (type) {
8908 case util.AnnotationEditorParamsType.INK_THICKNESS:
8909 this.#updateThickness(value);
8910 break;
8911 case util.AnnotationEditorParamsType.INK_COLOR:
8912 this.#updateColor(value);
8913 break;
8914 case util.AnnotationEditorParamsType.INK_OPACITY:
8915 this.#updateOpacity(value);
8916 break;
8917 }
8918 }
8919 static get defaultPropertiesToUpdate() {
8920 return [[util.AnnotationEditorParamsType.INK_THICKNESS, InkEditor._defaultThickness], [util.AnnotationEditorParamsType.INK_COLOR, InkEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor], [util.AnnotationEditorParamsType.INK_OPACITY, Math.round(InkEditor._defaultOpacity * 100)]];
8921 }
8922 get propertiesToUpdate() {
8923 return [[util.AnnotationEditorParamsType.INK_THICKNESS, this.thickness || InkEditor._defaultThickness], [util.AnnotationEditorParamsType.INK_COLOR, this.color || InkEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor], [util.AnnotationEditorParamsType.INK_OPACITY, Math.round(100 * (this.opacity ?? InkEditor._defaultOpacity))]];
8924 }
8925 #updateThickness(thickness) {
8926 const savedThickness = this.thickness;
8927 this.addCommands({
8928 cmd: () => {
8929 this.thickness = thickness;
8930 this.#fitToContent();
8931 },
8932 undo: () => {
8933 this.thickness = savedThickness;
8934 this.#fitToContent();
8935 },
8936 mustExec: true,
8937 type: util.AnnotationEditorParamsType.INK_THICKNESS,
8938 overwriteIfSameType: true,
8939 keepUndo: true
8940 });
8941 }
8942 #updateColor(color) {
8943 const savedColor = this.color;
8944 this.addCommands({
8945 cmd: () => {
8946 this.color = color;
8947 this.#redraw();
8948 },
8949 undo: () => {
8950 this.color = savedColor;
8951 this.#redraw();
8952 },
8953 mustExec: true,
8954 type: util.AnnotationEditorParamsType.INK_COLOR,
8955 overwriteIfSameType: true,
8956 keepUndo: true
8957 });
8958 }
8959 #updateOpacity(opacity) {
8960 opacity /= 100;
8961 const savedOpacity = this.opacity;
8962 this.addCommands({
8963 cmd: () => {
8964 this.opacity = opacity;
8965 this.#redraw();
8966 },
8967 undo: () => {
8968 this.opacity = savedOpacity;
8969 this.#redraw();
8970 },
8971 mustExec: true,
8972 type: util.AnnotationEditorParamsType.INK_OPACITY,
8973 overwriteIfSameType: true,
8974 keepUndo: true
8975 });
8976 }
8977 rebuild() {
8978 if (!this.parent) {
8979 return;
8980 }
8981 super.rebuild();
8982 if (this.div === null) {
8983 return;
8984 }
8985 if (!this.canvas) {
8986 this.#createCanvas();
8987 this.#createObserver();
8988 }
8989 if (!this.isAttachedToDOM) {
8990 this.parent.add(this);
8991 this.#setCanvasDims();
8992 }
8993 this.#fitToContent();
8994 }
8995 remove() {
8996 if (this.canvas === null) {
8997 return;
8998 }
8999 if (!this.isEmpty()) {
9000 this.commit();
9001 }
9002 this.canvas.width = this.canvas.height = 0;
9003 this.canvas.remove();
9004 this.canvas = null;
9005 if (this.#canvasContextMenuTimeoutId) {
9006 clearTimeout(this.#canvasContextMenuTimeoutId);
9007 this.#canvasContextMenuTimeoutId = null;
9008 }
9009 this.#observer.disconnect();
9010 this.#observer = null;
9011 super.remove();
9012 }
9013 setParent(parent) {
9014 if (!this.parent && parent) {
9015 this._uiManager.removeShouldRescale(this);
9016 } else if (this.parent && parent === null) {
9017 this._uiManager.addShouldRescale(this);
9018 }
9019 super.setParent(parent);
9020 }
9021 onScaleChanging() {
9022 const [parentWidth, parentHeight] = this.parentDimensions;
9023 const width = this.width * parentWidth;
9024 const height = this.height * parentHeight;
9025 this.setDimensions(width, height);
9026 }
9027 enableEditMode() {
9028 if (this.#disableEditing || this.canvas === null) {
9029 return;
9030 }
9031 super.enableEditMode();
9032 this._isDraggable = false;
9033 this.canvas.addEventListener("pointerdown", this.#boundCanvasPointerdown);
9034 }
9035 disableEditMode() {
9036 if (!this.isInEditMode() || this.canvas === null) {
9037 return;
9038 }
9039 super.disableEditMode();
9040 this._isDraggable = !this.isEmpty();
9041 this.div.classList.remove("editing");
9042 this.canvas.removeEventListener("pointerdown", this.#boundCanvasPointerdown);
9043 }
9044 onceAdded() {
9045 this._isDraggable = !this.isEmpty();
9046 }
9047 isEmpty() {
9048 return this.paths.length === 0 || this.paths.length === 1 && this.paths[0].length === 0;
9049 }
9050 #getInitialBBox() {
9051 const {
9052 parentRotation,
9053 parentDimensions: [width, height]
9054 } = this;
9055 switch (parentRotation) {
9056 case 90:
9057 return [0, height, height, width];
9058 case 180:
9059 return [width, height, width, height];
9060 case 270:
9061 return [width, 0, height, width];
9062 default:
9063 return [0, 0, width, height];
9064 }
9065 }
9066 #setStroke() {
9067 const {
9068 ctx,
9069 color,
9070 opacity,
9071 thickness,
9072 parentScale,
9073 scaleFactor
9074 } = this;
9075 ctx.lineWidth = thickness * parentScale / scaleFactor;
9076 ctx.lineCap = "round";
9077 ctx.lineJoin = "round";
9078 ctx.miterLimit = 10;
9079 ctx.strokeStyle = `${color}${(0,tools.opacityToHex)(opacity)}`;
9080 }
9081 #startDrawing(x, y) {
9082 this.canvas.addEventListener("contextmenu", display_utils.noContextMenu);
9083 this.canvas.addEventListener("pointerleave", this.#boundCanvasPointerleave);
9084 this.canvas.addEventListener("pointermove", this.#boundCanvasPointermove);
9085 this.canvas.addEventListener("pointerup", this.#boundCanvasPointerup);
9086 this.canvas.removeEventListener("pointerdown", this.#boundCanvasPointerdown);
9087 this.isEditing = true;
9088 if (!this.#isCanvasInitialized) {
9089 this.#isCanvasInitialized = true;
9090 this.#setCanvasDims();
9091 this.thickness ||= InkEditor._defaultThickness;
9092 this.color ||= InkEditor._defaultColor || editor_editor.AnnotationEditor._defaultLineColor;
9093 this.opacity ??= InkEditor._defaultOpacity;
9094 }
9095 this.currentPath.push([x, y]);
9096 this.#hasSomethingToDraw = false;
9097 this.#setStroke();
9098 this.#requestFrameCallback = () => {
9099 this.#drawPoints();
9100 if (this.#requestFrameCallback) {
9101 window.requestAnimationFrame(this.#requestFrameCallback);
9102 }
9103 };
9104 window.requestAnimationFrame(this.#requestFrameCallback);
9105 }
9106 #draw(x, y) {
9107 const [lastX, lastY] = this.currentPath.at(-1);
9108 if (this.currentPath.length > 1 && x === lastX && y === lastY) {
9109 return;
9110 }
9111 const currentPath = this.currentPath;
9112 let path2D = this.#currentPath2D;
9113 currentPath.push([x, y]);
9114 this.#hasSomethingToDraw = true;
9115 if (currentPath.length <= 2) {
9116 path2D.moveTo(...currentPath[0]);
9117 path2D.lineTo(x, y);
9118 return;
9119 }
9120 if (currentPath.length === 3) {
9121 this.#currentPath2D = path2D = new Path2D();
9122 path2D.moveTo(...currentPath[0]);
9123 }
9124 this.#makeBezierCurve(path2D, ...currentPath.at(-3), ...currentPath.at(-2), x, y);
9125 }
9126 #endPath() {
9127 if (this.currentPath.length === 0) {
9128 return;
9129 }
9130 const lastPoint = this.currentPath.at(-1);
9131 this.#currentPath2D.lineTo(...lastPoint);
9132 }
9133 #stopDrawing(x, y) {
9134 this.#requestFrameCallback = null;
9135 x = Math.min(Math.max(x, 0), this.canvas.width);
9136 y = Math.min(Math.max(y, 0), this.canvas.height);
9137 this.#draw(x, y);
9138 this.#endPath();
9139 let bezier;
9140 if (this.currentPath.length !== 1) {
9141 bezier = this.#generateBezierPoints();
9142 } else {
9143 const xy = [x, y];
9144 bezier = [[xy, xy.slice(), xy.slice(), xy]];
9145 }
9146 const path2D = this.#currentPath2D;
9147 const currentPath = this.currentPath;
9148 this.currentPath = [];
9149 this.#currentPath2D = new Path2D();
9150 const cmd = () => {
9151 this.allRawPaths.push(currentPath);
9152 this.paths.push(bezier);
9153 this.bezierPath2D.push(path2D);
9154 this.rebuild();
9155 };
9156 const undo = () => {
9157 this.allRawPaths.pop();
9158 this.paths.pop();
9159 this.bezierPath2D.pop();
9160 if (this.paths.length === 0) {
9161 this.remove();
9162 } else {
9163 if (!this.canvas) {
9164 this.#createCanvas();
9165 this.#createObserver();
9166 }
9167 this.#fitToContent();
9168 }
9169 };
9170 this.addCommands({
9171 cmd,
9172 undo,
9173 mustExec: true
9174 });
9175 }
9176 #drawPoints() {
9177 if (!this.#hasSomethingToDraw) {
9178 return;
9179 }
9180 this.#hasSomethingToDraw = false;
9181 const thickness = Math.ceil(this.thickness * this.parentScale);
9182 const lastPoints = this.currentPath.slice(-3);
9183 const x = lastPoints.map(xy => xy[0]);
9184 const y = lastPoints.map(xy => xy[1]);
9185 const xMin = Math.min(...x) - thickness;
9186 const xMax = Math.max(...x) + thickness;
9187 const yMin = Math.min(...y) - thickness;
9188 const yMax = Math.max(...y) + thickness;
9189 const {
9190 ctx
9191 } = this;
9192 ctx.save();
9193 ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
9194 for (const path of this.bezierPath2D) {
9195 ctx.stroke(path);
9196 }
9197 ctx.stroke(this.#currentPath2D);
9198 ctx.restore();
9199 }
9200 #makeBezierCurve(path2D, x0, y0, x1, y1, x2, y2) {
9201 const prevX = (x0 + x1) / 2;
9202 const prevY = (y0 + y1) / 2;
9203 const x3 = (x1 + x2) / 2;
9204 const y3 = (y1 + y2) / 2;
9205 path2D.bezierCurveTo(prevX + 2 * (x1 - prevX) / 3, prevY + 2 * (y1 - prevY) / 3, x3 + 2 * (x1 - x3) / 3, y3 + 2 * (y1 - y3) / 3, x3, y3);
9206 }
9207 #generateBezierPoints() {
9208 const path = this.currentPath;
9209 if (path.length <= 2) {
9210 return [[path[0], path[0], path.at(-1), path.at(-1)]];
9211 }
9212 const bezierPoints = [];
9213 let i;
9214 let [x0, y0] = path[0];
9215 for (i = 1; i < path.length - 2; i++) {
9216 const [x1, y1] = path[i];
9217 const [x2, y2] = path[i + 1];
9218 const x3 = (x1 + x2) / 2;
9219 const y3 = (y1 + y2) / 2;
9220 const control1 = [x0 + 2 * (x1 - x0) / 3, y0 + 2 * (y1 - y0) / 3];
9221 const control2 = [x3 + 2 * (x1 - x3) / 3, y3 + 2 * (y1 - y3) / 3];
9222 bezierPoints.push([[x0, y0], control1, control2, [x3, y3]]);
9223 [x0, y0] = [x3, y3];
9224 }
9225 const [x1, y1] = path[i];
9226 const [x2, y2] = path[i + 1];
9227 const control1 = [x0 + 2 * (x1 - x0) / 3, y0 + 2 * (y1 - y0) / 3];
9228 const control2 = [x2 + 2 * (x1 - x2) / 3, y2 + 2 * (y1 - y2) / 3];
9229 bezierPoints.push([[x0, y0], control1, control2, [x2, y2]]);
9230 return bezierPoints;
9231 }
9232 #redraw() {
9233 if (this.isEmpty()) {
9234 this.#updateTransform();
9235 return;
9236 }
9237 this.#setStroke();
9238 const {
9239 canvas,
9240 ctx
9241 } = this;
9242 ctx.setTransform(1, 0, 0, 1, 0, 0);
9243 ctx.clearRect(0, 0, canvas.width, canvas.height);
9244 this.#updateTransform();
9245 for (const path of this.bezierPath2D) {
9246 ctx.stroke(path);
9247 }
9248 }
9249 commit() {
9250 if (this.#disableEditing) {
9251 return;
9252 }
9253 super.commit();
9254 this.isEditing = false;
9255 this.disableEditMode();
9256 this.setInForeground();
9257 this.#disableEditing = true;
9258 this.div.classList.add("disabled");
9259 this.#fitToContent(true);
9260 this.select();
9261 this.parent.addInkEditorIfNeeded(true);
9262 this.moveInDOM();
9263 this.div.focus({
9264 preventScroll: true
9265 });
9266 }
9267 focusin(event) {
9268 if (!this._focusEventsAllowed) {
9269 return;
9270 }
9271 super.focusin(event);
9272 this.enableEditMode();
9273 }
9274 canvasPointerdown(event) {
9275 if (event.button !== 0 || !this.isInEditMode() || this.#disableEditing) {
9276 return;
9277 }
9278 this.setInForeground();
9279 event.preventDefault();
9280 if (event.pointerType !== "mouse" && !this.div.contains(document.activeElement)) {
9281 this.div.focus({
9282 preventScroll: true
9283 });
9284 }
9285 this.#startDrawing(event.offsetX, event.offsetY);
9286 }
9287 canvasPointermove(event) {
9288 event.preventDefault();
9289 this.#draw(event.offsetX, event.offsetY);
9290 }
9291 canvasPointerup(event) {
9292 event.preventDefault();
9293 this.#endDrawing(event);
9294 }
9295 canvasPointerleave(event) {
9296 this.#endDrawing(event);
9297 }
9298 #endDrawing(event) {
9299 this.canvas.removeEventListener("pointerleave", this.#boundCanvasPointerleave);
9300 this.canvas.removeEventListener("pointermove", this.#boundCanvasPointermove);
9301 this.canvas.removeEventListener("pointerup", this.#boundCanvasPointerup);
9302 this.canvas.addEventListener("pointerdown", this.#boundCanvasPointerdown);
9303 if (this.#canvasContextMenuTimeoutId) {
9304 clearTimeout(this.#canvasContextMenuTimeoutId);
9305 }
9306 this.#canvasContextMenuTimeoutId = setTimeout(() => {
9307 this.#canvasContextMenuTimeoutId = null;
9308 this.canvas.removeEventListener("contextmenu", display_utils.noContextMenu);
9309 }, 10);
9310 this.#stopDrawing(event.offsetX, event.offsetY);
9311 this.addToAnnotationStorage();
9312 this.setInBackground();
9313 }
9314 #createCanvas() {
9315 this.canvas = document.createElement("canvas");
9316 this.canvas.width = this.canvas.height = 0;
9317 this.canvas.className = "inkEditorCanvas";
9318 this.canvas.setAttribute("data-l10n-id", "pdfjs-ink-canvas");
9319 this.div.append(this.canvas);
9320 this.ctx = this.canvas.getContext("2d");
9321 }
9322 #createObserver() {
9323 this.#observer = new ResizeObserver(entries => {
9324 const rect = entries[0].contentRect;
9325 if (rect.width && rect.height) {
9326 this.setDimensions(rect.width, rect.height);
9327 }
9328 });
9329 this.#observer.observe(this.div);
9330 }
9331 get isResizable() {
9332 return !this.isEmpty() && this.#disableEditing;
9333 }
9334 render() {
9335 if (this.div) {
9336 return this.div;
9337 }
9338 let baseX, baseY;
9339 if (this.width) {
9340 baseX = this.x;
9341 baseY = this.y;
9342 }
9343 super.render();
9344 this.div.setAttribute("data-l10n-id", "pdfjs-ink");
9345 const [x, y, w, h] = this.#getInitialBBox();
9346 this.setAt(x, y, 0, 0);
9347 this.setDims(w, h);
9348 this.#createCanvas();
9349 if (this.width) {
9350 const [parentWidth, parentHeight] = this.parentDimensions;
9351 this.setAspectRatio(this.width * parentWidth, this.height * parentHeight);
9352 this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
9353 this.#isCanvasInitialized = true;
9354 this.#setCanvasDims();
9355 this.setDims(this.width * parentWidth, this.height * parentHeight);
9356 this.#redraw();
9357 this.div.classList.add("disabled");
9358 } else {
9359 this.div.classList.add("editing");
9360 this.enableEditMode();
9361 }
9362 this.#createObserver();
9363 return this.div;
9364 }
9365 #setCanvasDims() {
9366 if (!this.#isCanvasInitialized) {
9367 return;
9368 }
9369 const [parentWidth, parentHeight] = this.parentDimensions;
9370 this.canvas.width = Math.ceil(this.width * parentWidth);
9371 this.canvas.height = Math.ceil(this.height * parentHeight);
9372 this.#updateTransform();
9373 }
9374 setDimensions(width, height) {
9375 const roundedWidth = Math.round(width);
9376 const roundedHeight = Math.round(height);
9377 if (this.#realWidth === roundedWidth && this.#realHeight === roundedHeight) {
9378 return;
9379 }
9380 this.#realWidth = roundedWidth;
9381 this.#realHeight = roundedHeight;
9382 this.canvas.style.visibility = "hidden";
9383 const [parentWidth, parentHeight] = this.parentDimensions;
9384 this.width = width / parentWidth;
9385 this.height = height / parentHeight;
9386 this.fixAndSetPosition();
9387 if (this.#disableEditing) {
9388 this.#setScaleFactor(width, height);
9389 }
9390 this.#setCanvasDims();
9391 this.#redraw();
9392 this.canvas.style.visibility = "visible";
9393 this.fixDims();
9394 }
9395 #setScaleFactor(width, height) {
9396 const padding = this.#getPadding();
9397 const scaleFactorW = (width - padding) / this.#baseWidth;
9398 const scaleFactorH = (height - padding) / this.#baseHeight;
9399 this.scaleFactor = Math.min(scaleFactorW, scaleFactorH);
9400 }
9401 #updateTransform() {
9402 const padding = this.#getPadding() / 2;
9403 this.ctx.setTransform(this.scaleFactor, 0, 0, this.scaleFactor, this.translationX * this.scaleFactor + padding, this.translationY * this.scaleFactor + padding);
9404 }
9405 static #buildPath2D(bezier) {
9406 const path2D = new Path2D();
9407 for (let i = 0, ii = bezier.length; i < ii; i++) {
9408 const [first, control1, control2, second] = bezier[i];
9409 if (i === 0) {
9410 path2D.moveTo(...first);
9411 }
9412 path2D.bezierCurveTo(control1[0], control1[1], control2[0], control2[1], second[0], second[1]);
9413 }
9414 return path2D;
9415 }
9416 static #toPDFCoordinates(points, rect, rotation) {
9417 const [blX, blY, trX, trY] = rect;
9418 switch (rotation) {
9419 case 0:
9420 for (let i = 0, ii = points.length; i < ii; i += 2) {
9421 points[i] += blX;
9422 points[i + 1] = trY - points[i + 1];
9423 }
9424 break;
9425 case 90:
9426 for (let i = 0, ii = points.length; i < ii; i += 2) {
9427 const x = points[i];
9428 points[i] = points[i + 1] + blX;
9429 points[i + 1] = x + blY;
9430 }
9431 break;
9432 case 180:
9433 for (let i = 0, ii = points.length; i < ii; i += 2) {
9434 points[i] = trX - points[i];
9435 points[i + 1] += blY;
9436 }
9437 break;
9438 case 270:
9439 for (let i = 0, ii = points.length; i < ii; i += 2) {
9440 const x = points[i];
9441 points[i] = trX - points[i + 1];
9442 points[i + 1] = trY - x;
9443 }
9444 break;
9445 default:
9446 throw new Error("Invalid rotation");
9447 }
9448 return points;
9449 }
9450 static #fromPDFCoordinates(points, rect, rotation) {
9451 const [blX, blY, trX, trY] = rect;
9452 switch (rotation) {
9453 case 0:
9454 for (let i = 0, ii = points.length; i < ii; i += 2) {
9455 points[i] -= blX;
9456 points[i + 1] = trY - points[i + 1];
9457 }
9458 break;
9459 case 90:
9460 for (let i = 0, ii = points.length; i < ii; i += 2) {
9461 const x = points[i];
9462 points[i] = points[i + 1] - blY;
9463 points[i + 1] = x - blX;
9464 }
9465 break;
9466 case 180:
9467 for (let i = 0, ii = points.length; i < ii; i += 2) {
9468 points[i] = trX - points[i];
9469 points[i + 1] -= blY;
9470 }
9471 break;
9472 case 270:
9473 for (let i = 0, ii = points.length; i < ii; i += 2) {
9474 const x = points[i];
9475 points[i] = trY - points[i + 1];
9476 points[i + 1] = trX - x;
9477 }
9478 break;
9479 default:
9480 throw new Error("Invalid rotation");
9481 }
9482 return points;
9483 }
9484 #serializePaths(s, tx, ty, rect) {
9485 const paths = [];
9486 const padding = this.thickness / 2;
9487 const shiftX = s * tx + padding;
9488 const shiftY = s * ty + padding;
9489 for (const bezier of this.paths) {
9490 const buffer = [];
9491 const points = [];
9492 for (let j = 0, jj = bezier.length; j < jj; j++) {
9493 const [first, control1, control2, second] = bezier[j];
9494 const p10 = s * first[0] + shiftX;
9495 const p11 = s * first[1] + shiftY;
9496 const p20 = s * control1[0] + shiftX;
9497 const p21 = s * control1[1] + shiftY;
9498 const p30 = s * control2[0] + shiftX;
9499 const p31 = s * control2[1] + shiftY;
9500 const p40 = s * second[0] + shiftX;
9501 const p41 = s * second[1] + shiftY;
9502 if (j === 0) {
9503 buffer.push(p10, p11);
9504 points.push(p10, p11);
9505 }
9506 buffer.push(p20, p21, p30, p31, p40, p41);
9507 points.push(p20, p21);
9508 if (j === jj - 1) {
9509 points.push(p40, p41);
9510 }
9511 }
9512 paths.push({
9513 bezier: InkEditor.#toPDFCoordinates(buffer, rect, this.rotation),
9514 points: InkEditor.#toPDFCoordinates(points, rect, this.rotation)
9515 });
9516 }
9517 return paths;
9518 }
9519 #getBbox() {
9520 let xMin = Infinity;
9521 let xMax = -Infinity;
9522 let yMin = Infinity;
9523 let yMax = -Infinity;
9524 for (const path of this.paths) {
9525 for (const [first, control1, control2, second] of path) {
9526 const bbox = util.Util.bezierBoundingBox(...first, ...control1, ...control2, ...second);
9527 xMin = Math.min(xMin, bbox[0]);
9528 yMin = Math.min(yMin, bbox[1]);
9529 xMax = Math.max(xMax, bbox[2]);
9530 yMax = Math.max(yMax, bbox[3]);
9531 }
9532 }
9533 return [xMin, yMin, xMax, yMax];
9534 }
9535 #getPadding() {
9536 return this.#disableEditing ? Math.ceil(this.thickness * this.parentScale) : 0;
9537 }
9538 #fitToContent(firstTime = false) {
9539 if (this.isEmpty()) {
9540 return;
9541 }
9542 if (!this.#disableEditing) {
9543 this.#redraw();
9544 return;
9545 }
9546 const bbox = this.#getBbox();
9547 const padding = this.#getPadding();
9548 this.#baseWidth = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[2] - bbox[0]);
9549 this.#baseHeight = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[3] - bbox[1]);
9550 const width = Math.ceil(padding + this.#baseWidth * this.scaleFactor);
9551 const height = Math.ceil(padding + this.#baseHeight * this.scaleFactor);
9552 const [parentWidth, parentHeight] = this.parentDimensions;
9553 this.width = width / parentWidth;
9554 this.height = height / parentHeight;
9555 this.setAspectRatio(width, height);
9556 const prevTranslationX = this.translationX;
9557 const prevTranslationY = this.translationY;
9558 this.translationX = -bbox[0];
9559 this.translationY = -bbox[1];
9560 this.#setCanvasDims();
9561 this.#redraw();
9562 this.#realWidth = width;
9563 this.#realHeight = height;
9564 this.setDims(width, height);
9565 const unscaledPadding = firstTime ? padding / this.scaleFactor / 2 : 0;
9566 this.translate(prevTranslationX - this.translationX - unscaledPadding, prevTranslationY - this.translationY - unscaledPadding);
9567 }
9568 static deserialize(data, parent, uiManager) {
9569 if (data instanceof annotation_layer.InkAnnotationElement) {
9570 return null;
9571 }
9572 const editor = super.deserialize(data, parent, uiManager);
9573 editor.thickness = data.thickness;
9574 editor.color = util.Util.makeHexColor(...data.color);
9575 editor.opacity = data.opacity;
9576 const [pageWidth, pageHeight] = editor.pageDimensions;
9577 const width = editor.width * pageWidth;
9578 const height = editor.height * pageHeight;
9579 const scaleFactor = editor.parentScale;
9580 const padding = data.thickness / 2;
9581 editor.#disableEditing = true;
9582 editor.#realWidth = Math.round(width);
9583 editor.#realHeight = Math.round(height);
9584 const {
9585 paths,
9586 rect,
9587 rotation
9588 } = data;
9589 for (let {
9590 bezier
9591 } of paths) {
9592 bezier = InkEditor.#fromPDFCoordinates(bezier, rect, rotation);
9593 const path = [];
9594 editor.paths.push(path);
9595 let p0 = scaleFactor * (bezier[0] - padding);
9596 let p1 = scaleFactor * (bezier[1] - padding);
9597 for (let i = 2, ii = bezier.length; i < ii; i += 6) {
9598 const p10 = scaleFactor * (bezier[i] - padding);
9599 const p11 = scaleFactor * (bezier[i + 1] - padding);
9600 const p20 = scaleFactor * (bezier[i + 2] - padding);
9601 const p21 = scaleFactor * (bezier[i + 3] - padding);
9602 const p30 = scaleFactor * (bezier[i + 4] - padding);
9603 const p31 = scaleFactor * (bezier[i + 5] - padding);
9604 path.push([[p0, p1], [p10, p11], [p20, p21], [p30, p31]]);
9605 p0 = p30;
9606 p1 = p31;
9607 }
9608 const path2D = this.#buildPath2D(path);
9609 editor.bezierPath2D.push(path2D);
9610 }
9611 const bbox = editor.#getBbox();
9612 editor.#baseWidth = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[2] - bbox[0]);
9613 editor.#baseHeight = Math.max(editor_editor.AnnotationEditor.MIN_SIZE, bbox[3] - bbox[1]);
9614 editor.#setScaleFactor(width, height);
9615 return editor;
9616 }
9617 serialize() {
9618 if (this.isEmpty()) {
9619 return null;
9620 }
9621 const rect = this.getRect(0, 0);
9622 const color = editor_editor.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);
9623 return {
9624 annotationType: util.AnnotationEditorType.INK,
9625 color,
9626 thickness: this.thickness,
9627 opacity: this.opacity,
9628 paths: this.#serializePaths(this.scaleFactor / this.parentScale, this.translationX, this.translationY, rect),
9629 pageIndex: this.pageIndex,
9630 rect,
9631 rotation: this.rotation,
9632 structTreeParentId: this._structTreeParentId
9633 };
9634 }
9635}
9636
9637;// CONCATENATED MODULE: ./src/display/editor/stamp.js
9638
9639
9640
9641
9642class StampEditor extends editor_editor.AnnotationEditor {
9643 #bitmap = null;
9644 #bitmapId = null;
9645 #bitmapPromise = null;
9646 #bitmapUrl = null;
9647 #bitmapFile = null;
9648 #bitmapFileName = "";
9649 #canvas = null;
9650 #observer = null;
9651 #resizeTimeoutId = null;
9652 #isSvg = false;
9653 #hasBeenAddedInUndoStack = false;
9654 static _type = "stamp";
9655 static _editorType = util.AnnotationEditorType.STAMP;
9656 constructor(params) {
9657 super({
9658 ...params,
9659 name: "stampEditor"
9660 });
9661 this.#bitmapUrl = params.bitmapUrl;
9662 this.#bitmapFile = params.bitmapFile;
9663 }
9664 static initialize(l10n) {
9665 editor_editor.AnnotationEditor.initialize(l10n);
9666 }
9667 static get supportedTypes() {
9668 const types = ["apng", "avif", "bmp", "gif", "jpeg", "png", "svg+xml", "webp", "x-icon"];
9669 return (0,util.shadow)(this, "supportedTypes", types.map(type => `image/${type}`));
9670 }
9671 static get supportedTypesStr() {
9672 return (0,util.shadow)(this, "supportedTypesStr", this.supportedTypes.join(","));
9673 }
9674 static isHandlingMimeForPasting(mime) {
9675 return this.supportedTypes.includes(mime);
9676 }
9677 static paste(item, parent) {
9678 parent.pasteEditor(util.AnnotationEditorType.STAMP, {
9679 bitmapFile: item.getAsFile()
9680 });
9681 }
9682 #getBitmapFetched(data, fromId = false) {
9683 if (!data) {
9684 this.remove();
9685 return;
9686 }
9687 this.#bitmap = data.bitmap;
9688 if (!fromId) {
9689 this.#bitmapId = data.id;
9690 this.#isSvg = data.isSvg;
9691 }
9692 if (data.file) {
9693 this.#bitmapFileName = data.file.name;
9694 }
9695 this.#createCanvas();
9696 }
9697 #getBitmapDone() {
9698 this.#bitmapPromise = null;
9699 this._uiManager.enableWaiting(false);
9700 if (this.#canvas) {
9701 this.div.focus();
9702 }
9703 }
9704 #getBitmap() {
9705 if (this.#bitmapId) {
9706 this._uiManager.enableWaiting(true);
9707 this._uiManager.imageManager.getFromId(this.#bitmapId).then(data => this.#getBitmapFetched(data, true)).finally(() => this.#getBitmapDone());
9708 return;
9709 }
9710 if (this.#bitmapUrl) {
9711 const url = this.#bitmapUrl;
9712 this.#bitmapUrl = null;
9713 this._uiManager.enableWaiting(true);
9714 this.#bitmapPromise = this._uiManager.imageManager.getFromUrl(url).then(data => this.#getBitmapFetched(data)).finally(() => this.#getBitmapDone());
9715 return;
9716 }
9717 if (this.#bitmapFile) {
9718 const file = this.#bitmapFile;
9719 this.#bitmapFile = null;
9720 this._uiManager.enableWaiting(true);
9721 this.#bitmapPromise = this._uiManager.imageManager.getFromFile(file).then(data => this.#getBitmapFetched(data)).finally(() => this.#getBitmapDone());
9722 return;
9723 }
9724 const input = document.createElement("input");
9725 input.type = "file";
9726 input.accept = StampEditor.supportedTypesStr;
9727 this.#bitmapPromise = new Promise(resolve => {
9728 input.addEventListener("change", async () => {
9729 if (!input.files || input.files.length === 0) {
9730 this.remove();
9731 } else {
9732 this._uiManager.enableWaiting(true);
9733 const data = await this._uiManager.imageManager.getFromFile(input.files[0]);
9734 this.#getBitmapFetched(data);
9735 }
9736 resolve();
9737 });
9738 input.addEventListener("cancel", () => {
9739 this.remove();
9740 resolve();
9741 });
9742 }).finally(() => this.#getBitmapDone());
9743 input.click();
9744 }
9745 remove() {
9746 if (this.#bitmapId) {
9747 this.#bitmap = null;
9748 this._uiManager.imageManager.deleteId(this.#bitmapId);
9749 this.#canvas?.remove();
9750 this.#canvas = null;
9751 this.#observer?.disconnect();
9752 this.#observer = null;
9753 if (this.#resizeTimeoutId) {
9754 clearTimeout(this.#resizeTimeoutId);
9755 this.#resizeTimeoutId = null;
9756 }
9757 }
9758 super.remove();
9759 }
9760 rebuild() {
9761 if (!this.parent) {
9762 if (this.#bitmapId) {
9763 this.#getBitmap();
9764 }
9765 return;
9766 }
9767 super.rebuild();
9768 if (this.div === null) {
9769 return;
9770 }
9771 if (this.#bitmapId) {
9772 this.#getBitmap();
9773 }
9774 if (!this.isAttachedToDOM) {
9775 this.parent.add(this);
9776 }
9777 }
9778 onceAdded() {
9779 this._isDraggable = true;
9780 this.div.focus();
9781 }
9782 isEmpty() {
9783 return !(this.#bitmapPromise || this.#bitmap || this.#bitmapUrl || this.#bitmapFile);
9784 }
9785 get isResizable() {
9786 return true;
9787 }
9788 render() {
9789 if (this.div) {
9790 return this.div;
9791 }
9792 let baseX, baseY;
9793 if (this.width) {
9794 baseX = this.x;
9795 baseY = this.y;
9796 }
9797 super.render();
9798 this.div.hidden = true;
9799 if (this.#bitmap) {
9800 this.#createCanvas();
9801 } else {
9802 this.#getBitmap();
9803 }
9804 if (this.width) {
9805 const [parentWidth, parentHeight] = this.parentDimensions;
9806 this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
9807 }
9808 return this.div;
9809 }
9810 #createCanvas() {
9811 const {
9812 div
9813 } = this;
9814 let {
9815 width,
9816 height
9817 } = this.#bitmap;
9818 const [pageWidth, pageHeight] = this.pageDimensions;
9819 const MAX_RATIO = 0.75;
9820 if (this.width) {
9821 width = this.width * pageWidth;
9822 height = this.height * pageHeight;
9823 } else if (width > MAX_RATIO * pageWidth || height > MAX_RATIO * pageHeight) {
9824 const factor = Math.min(MAX_RATIO * pageWidth / width, MAX_RATIO * pageHeight / height);
9825 width *= factor;
9826 height *= factor;
9827 }
9828 const [parentWidth, parentHeight] = this.parentDimensions;
9829 this.setDims(width * parentWidth / pageWidth, height * parentHeight / pageHeight);
9830 this._uiManager.enableWaiting(false);
9831 const canvas = this.#canvas = document.createElement("canvas");
9832 div.append(canvas);
9833 div.hidden = false;
9834 this.#drawBitmap(width, height);
9835 this.#createObserver();
9836 if (!this.#hasBeenAddedInUndoStack) {
9837 this.parent.addUndoableEditor(this);
9838 this.#hasBeenAddedInUndoStack = true;
9839 }
9840 this._uiManager._eventBus.dispatch("reporttelemetry", {
9841 source: this,
9842 details: {
9843 type: "editing",
9844 subtype: this.editorType,
9845 data: {
9846 action: "inserted_image"
9847 }
9848 }
9849 });
9850 this.addAltTextButton();
9851 if (this.#bitmapFileName) {
9852 canvas.setAttribute("aria-label", this.#bitmapFileName);
9853 }
9854 }
9855 #setDimensions(width, height) {
9856 const [parentWidth, parentHeight] = this.parentDimensions;
9857 this.width = width / parentWidth;
9858 this.height = height / parentHeight;
9859 this.setDims(width, height);
9860 if (this._initialOptions?.isCentered) {
9861 this.center();
9862 } else {
9863 this.fixAndSetPosition();
9864 }
9865 this._initialOptions = null;
9866 if (this.#resizeTimeoutId !== null) {
9867 clearTimeout(this.#resizeTimeoutId);
9868 }
9869 const TIME_TO_WAIT = 200;
9870 this.#resizeTimeoutId = setTimeout(() => {
9871 this.#resizeTimeoutId = null;
9872 this.#drawBitmap(width, height);
9873 }, TIME_TO_WAIT);
9874 }
9875 #scaleBitmap(width, height) {
9876 const {
9877 width: bitmapWidth,
9878 height: bitmapHeight
9879 } = this.#bitmap;
9880 let newWidth = bitmapWidth;
9881 let newHeight = bitmapHeight;
9882 let bitmap = this.#bitmap;
9883 while (newWidth > 2 * width || newHeight > 2 * height) {
9884 const prevWidth = newWidth;
9885 const prevHeight = newHeight;
9886 if (newWidth > 2 * width) {
9887 newWidth = newWidth >= 16384 ? Math.floor(newWidth / 2) - 1 : Math.ceil(newWidth / 2);
9888 }
9889 if (newHeight > 2 * height) {
9890 newHeight = newHeight >= 16384 ? Math.floor(newHeight / 2) - 1 : Math.ceil(newHeight / 2);
9891 }
9892 const offscreen = new OffscreenCanvas(newWidth, newHeight);
9893 const ctx = offscreen.getContext("2d");
9894 ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
9895 bitmap = offscreen.transferToImageBitmap();
9896 }
9897 return bitmap;
9898 }
9899 #drawBitmap(width, height) {
9900 width = Math.ceil(width);
9901 height = Math.ceil(height);
9902 const canvas = this.#canvas;
9903 if (!canvas || canvas.width === width && canvas.height === height) {
9904 return;
9905 }
9906 canvas.width = width;
9907 canvas.height = height;
9908 const bitmap = this.#isSvg ? this.#bitmap : this.#scaleBitmap(width, height);
9909 const ctx = canvas.getContext("2d");
9910 ctx.filter = this._uiManager.hcmFilter;
9911 ctx.drawImage(bitmap, 0, 0, bitmap.width, bitmap.height, 0, 0, width, height);
9912 }
9913 getImageForAltText() {
9914 return this.#canvas;
9915 }
9916 #serializeBitmap(toUrl) {
9917 if (toUrl) {
9918 if (this.#isSvg) {
9919 const url = this._uiManager.imageManager.getSvgUrl(this.#bitmapId);
9920 if (url) {
9921 return url;
9922 }
9923 }
9924 const canvas = document.createElement("canvas");
9925 ({
9926 width: canvas.width,
9927 height: canvas.height
9928 } = this.#bitmap);
9929 const ctx = canvas.getContext("2d");
9930 ctx.drawImage(this.#bitmap, 0, 0);
9931 return canvas.toDataURL();
9932 }
9933 if (this.#isSvg) {
9934 const [pageWidth, pageHeight] = this.pageDimensions;
9935 const width = Math.round(this.width * pageWidth * display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
9936 const height = Math.round(this.height * pageHeight * display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
9937 const offscreen = new OffscreenCanvas(width, height);
9938 const ctx = offscreen.getContext("2d");
9939 ctx.drawImage(this.#bitmap, 0, 0, this.#bitmap.width, this.#bitmap.height, 0, 0, width, height);
9940 return offscreen.transferToImageBitmap();
9941 }
9942 return structuredClone(this.#bitmap);
9943 }
9944 #createObserver() {
9945 this.#observer = new ResizeObserver(entries => {
9946 const rect = entries[0].contentRect;
9947 if (rect.width && rect.height) {
9948 this.#setDimensions(rect.width, rect.height);
9949 }
9950 });
9951 this.#observer.observe(this.div);
9952 }
9953 static deserialize(data, parent, uiManager) {
9954 if (data instanceof annotation_layer.StampAnnotationElement) {
9955 return null;
9956 }
9957 const editor = super.deserialize(data, parent, uiManager);
9958 const {
9959 rect,
9960 bitmapUrl,
9961 bitmapId,
9962 isSvg,
9963 accessibilityData
9964 } = data;
9965 if (bitmapId && uiManager.imageManager.isValidId(bitmapId)) {
9966 editor.#bitmapId = bitmapId;
9967 } else {
9968 editor.#bitmapUrl = bitmapUrl;
9969 }
9970 editor.#isSvg = isSvg;
9971 const [parentWidth, parentHeight] = editor.pageDimensions;
9972 editor.width = (rect[2] - rect[0]) / parentWidth;
9973 editor.height = (rect[3] - rect[1]) / parentHeight;
9974 if (accessibilityData) {
9975 editor.altTextData = accessibilityData;
9976 }
public/lib/pdf.mjs.map+0 -0
public/lib/pdf.worker.mjs+0 -0
public/lib/pdf.worker.mjs.map+0 -0
Diff truncated