UNPKG

pdfviewer

Version:

PDF Viewer using Mozila PDF JS.

3 lines (2 loc) 52.6 kB
"use strict";!function(e,t){function i(e){var t=e.indexOf("#"),i=e.indexOf("?"),n=Math.min(t>0?t:e.length,i>0?i:e.length);return e.substring(e.lastIndexOf("/",n)+1,n)}function n(t){var i=e.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,r=i/n;return{sx:r,sy:r,scaled:1!==r}}function r(e,t){var i=e.offsetParent,n=e.offsetTop+e.clientTop,r=e.offsetLeft+e.clientLeft;if(!i)return void console.error("offsetParent is not set -- cannot scroll");for(;i.clientHeight===i.scrollHeight;)if(i.dataset._scaleY&&(n/=i.dataset._scaleY,r/=i.dataset._scaleX),n+=i.offsetTop,r+=i.offsetLeft,i=i.offsetParent,!i)return;t&&(void 0!==t.top&&(n+=t.top),void 0!==t.left&&(r+=t.left,i.scrollLeft=r)),i.scrollTop=n}function o(t,i){var n=function(n){o||(o=e.requestAnimationFrame(function(){o=null;var e=t.scrollTop,n=r.lastY;e!==n&&(r.down=e>n),r.lastY=e,i(r)}))},r={down:!0,lastY:t.scrollTop,_eventHandler:n},o=null;return t.addEventListener("scroll",n,!0),r}function s(e,t){var i=0,n=e.length-1;if(0===e.length||!t(e[n]))return e.length;if(t(e[i]))return i;for(;n>i;){var r=i+n>>1,o=e[r];t(o)?n=r:i=r+1}return i}function a(e,t,i){function n(e){var t=e.div,i=t.offsetTop+t.clientTop+t.clientHeight;return i>f}for(var r,o,a,l,d,h,c,u,f=e.scrollTop,g=f+e.clientHeight,v=e.scrollLeft,p=v+e.clientWidth,m=[],w=0===t.length?0:s(t,n),b=w,y=t.length;y>b&&(r=t[b],o=r.div,a=o.offsetTop+o.clientTop,l=o.clientHeight,!(a>g));b++)c=o.offsetLeft+o.clientLeft,u=o.clientWidth,v>c+u||c>p||(d=Math.max(0,f-a)+Math.max(0,a+l-g),h=100*(l-d)/l|0,m.push({id:r.id,x:c,y:a,view:r,percent:h}));var P=m[0],S=m[m.length-1];return i&&m.sort(function(e,t){var i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id}),{first:P,last:S,views:m}}function l(e){e.preventDefault()}function d(e){var t=/^(?:([^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,i=/[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=t.exec(e),r=i.exec(n[1])||i.exec(n[2])||i.exec(n[3]);if(r&&(r=r[0],-1!==r.indexOf("%")))try{r=i.exec(decodeURIComponent(r))[0]}catch(o){}return r||"document.pdf"}function h(e){return!V.test(e)}function c(){}function u(){q.initialize().then(f)}function f(i){var i=decodeURIComponent(e.FILE_URL||""),n=PDFJS.locale||navigator.language;Q.setLanguage(n),q.supportsPrinting||t.getElementById("print").classList.add("hidden"),PDFJS.UnsupportedManager.listen(q.fallback.bind(q));var r=t.getElementById("mainContainer"),o=t.getElementById("outerContainer");if(r.addEventListener("transitionend",function(i){if(i.target===r){var n=t.createEvent("UIEvents");n.initUIEvent("resize",!1,!1,e,0),e.dispatchEvent(n),o.classList.remove("sidebarMoving")}},!0),t.getElementById("zoomIn").addEventListener("click",function(){q.zoomIn()}),t.getElementById("zoomOut").addEventListener("click",function(){q.zoomOut()}),t.getElementById("print").addEventListener("click",function(){e.print()}),t.getElementById("download").addEventListener("click",q.download.bind(q)),i&&0===i.lastIndexOf("file:",0)){q.setTitleUsingUrl(i);var s=new XMLHttpRequest;s.onload=function(){q.open(new Uint8Array(s.response),0)};try{s.open("GET",i),s.responseType="arraybuffer",s.send()}catch(a){q.error(Q.get("loading_error",null,"An error occurred while loading the PDF."),a)}}else i&&q.open(i,j)}function g(){q.initialized&&q.pdfViewer.update()}function v(e){{var t=40;"DOMMouseScroll"===e.type?-e.detail:e.wheelDelta/t}}var p={showPreviousViewOnLoad:!0,defaultZoomValue:"",sidebarViewOnLoad:0,enableHandToolOnLoad:!1,enableWebGL:!1,pdfBugEnabled:!1,disableRange:!1,disableStream:!1,disableAutoFetch:!1,disableFontFace:!1,disableTextLayer:!1,useOnlyCssZoom:!1};t.webL10n=function(e,t,i){function n(){return t.querySelectorAll('link[type="application/l10n"]')}function r(){var e=t.querySelector('script[type="application/l10n"]');return e?JSON.parse(e.innerHTML):null}function o(e){return e?e.querySelectorAll("*[data-l10n-id]"):[]}function s(e){if(!e)return{};var t=e.getAttribute("data-l10n-id"),i=e.getAttribute("data-l10n-args"),n={};if(i)try{n=JSON.parse(i)}catch(r){console.warn("could not parse arguments for #"+t)}return{id:t,args:n}}function a(e){var i=t.createEvent("Event");i.initEvent("localized",!0,!1),i.language=e,t.dispatchEvent(i)}function l(e,t,i){t=t||function(e){},i=i||function(){console.warn(e+" not found.")};var n=new XMLHttpRequest;n.open("GET",e,L),n.overrideMimeType&&n.overrideMimeType("text/plain; charset=utf-8"),n.onreadystatechange=function(){4==n.readyState&&(200==n.status||0===n.status?t(n.responseText):i())},n.onerror=i,n.ontimeout=i;try{n.send(null)}catch(r){i()}}function d(e,t,i,n){function r(e){return e.lastIndexOf("\\")<0?e:e.replace(/\\\\/g,"\\").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\{/g,"{").replace(/\\}/g,"}").replace(/\\"/g,'"').replace(/\\'/g,"'")}function o(e,i){function n(e,i,n){function l(){for(;;){if(!g.length)return void n();var e=g.shift();if(!h.test(e)){if(i){if(w=c.exec(e)){v=w[1].toLowerCase(),m="*"!==v&&v!==t&&v!==p;continue}if(m)continue;if(w=u.exec(e))return void o(s+w[1],l)}var d=e.match(f);d&&3==d.length&&(a[d[1]]=r(d[2]))}}}var g=e.replace(d,"").split(/[\r\n]+/),v="*",p=t.split("-",1)[0],m=!1,w="";l()}function o(e,t){l(e,function(e){n(e,!1,t)},null)}var a={},d=/^\s*|\s*$/,h=/^\s*#|^\s*$/,c=/^\s*\[(.*)\]\s*$/,u=/^\s*@import\s+url\((.*)\)\s*$/i,f=/^([^=\s]*)\s*=\s*(.+)$/;n(e,!0,function(){i(a)})}var s=e.replace(/[^\/]*$/,"")||"./";l(e,function(e){y+=e,o(e,function(e){for(var t in e){var n,r,o=t.lastIndexOf(".");o>0?(n=t.substring(0,o),r=t.substr(o+1)):(n=t,r=P),b[n]||(b[n]={}),b[n][r]=e[t]}i&&i()})},n)}function h(e,t){function i(e){var t=e.href;this.load=function(e,i){d(t,e,i,function(){console.warn(t+" not found."),console.warn('"'+e+'" resource not found'),S="",i()})}}e&&(e=e.toLowerCase()),t=t||function(){},c(),S=e;var o=n(),s=o.length;if(0===s){var l=r();if(l&&l.locales&&l.default_locale){if(console.log("using the embedded JSON directory, early way out"),b=l.locales[e],!b){var h=l.default_locale.toLowerCase();for(var u in l.locales){if(u=u.toLowerCase(),u===e){b=l.locales[e];break}u===h&&(b=l.locales[h])}}t()}else console.log("no resource to load, early way out");return a(e),void(E="complete")}var f=null,g=0;f=function(){g++,g>=s&&(t(),a(e),E="complete")};for(var v=0;s>v;v++){var p=new i(o[v]);p.load(e,f)}}function c(){b={},y="",S=""}function u(e){function t(e,t){return-1!==t.indexOf(e)}function i(e,t,i){return e>=t&&i>=e}var n={af:3,ak:4,am:4,ar:1,asa:3,az:0,be:11,bem:3,bez:3,bg:3,bh:4,bm:0,bn:3,bo:0,br:20,brx:3,bs:11,ca:3,cgg:3,chr:3,cs:12,cy:17,da:3,de:3,dv:3,dz:0,ee:3,el:3,en:3,eo:3,es:3,et:3,eu:3,fa:0,ff:5,fi:3,fil:4,fo:3,fr:5,fur:3,fy:3,ga:8,gd:24,gl:3,gsw:3,gu:3,guw:4,gv:23,ha:3,haw:3,he:2,hi:4,hr:11,hu:0,id:0,ig:0,ii:0,is:3,it:3,iu:7,ja:0,jmc:3,jv:0,ka:0,kab:5,kaj:3,kcg:3,kde:0,kea:0,kk:3,kl:3,km:0,kn:0,ko:0,ksb:3,ksh:21,ku:3,kw:7,lag:18,lb:3,lg:3,ln:4,lo:0,lt:10,lv:6,mas:3,mg:4,mk:16,ml:3,mn:3,mo:9,mr:3,ms:0,mt:15,my:0,nah:3,naq:7,nb:3,nd:3,ne:3,nl:3,nn:3,no:3,nr:3,nso:4,ny:3,nyn:3,om:3,or:3,pa:3,pap:3,pl:13,ps:3,pt:3,rm:3,ro:9,rof:3,ru:11,rwk:3,sah:0,saq:3,se:7,seh:3,ses:0,sg:0,sh:11,shi:19,sk:12,sl:14,sma:7,smi:7,smj:7,smn:7,sms:7,sn:3,so:3,sq:3,sr:11,ss:3,ssy:3,st:3,sv:3,sw:3,syr:3,ta:3,te:3,teo:3,th:0,ti:4,tig:3,tk:3,tl:4,tn:3,to:0,tr:0,ts:3,tzm:22,uk:11,ur:3,ve:3,vi:0,vun:3,wa:4,wae:3,wo:0,xh:3,xog:3,yo:0,zh:0,zu:3},r={0:function(e){return"other"},1:function(e){return i(e%100,3,10)?"few":0===e?"zero":i(e%100,11,99)?"many":2==e?"two":1==e?"one":"other"},2:function(e){return 0!==e&&e%10===0?"many":2==e?"two":1==e?"one":"other"},3:function(e){return 1==e?"one":"other"},4:function(e){return i(e,0,1)?"one":"other"},5:function(e){return i(e,0,2)&&2!=e?"one":"other"},6:function(e){return 0===e?"zero":e%10==1&&e%100!=11?"one":"other"},7:function(e){return 2==e?"two":1==e?"one":"other"},8:function(e){return i(e,3,6)?"few":i(e,7,10)?"many":2==e?"two":1==e?"one":"other"},9:function(e){return 0===e||1!=e&&i(e%100,1,19)?"few":1==e?"one":"other"},10:function(e){return i(e%10,2,9)&&!i(e%100,11,19)?"few":e%10!=1||i(e%100,11,19)?"other":"one"},11:function(e){return i(e%10,2,4)&&!i(e%100,12,14)?"few":e%10===0||i(e%10,5,9)||i(e%100,11,14)?"many":e%10==1&&e%100!=11?"one":"other"},12:function(e){return i(e,2,4)?"few":1==e?"one":"other"},13:function(e){return i(e%10,2,4)&&!i(e%100,12,14)?"few":1!=e&&i(e%10,0,1)||i(e%10,5,9)||i(e%100,12,14)?"many":1==e?"one":"other"},14:function(e){return i(e%100,3,4)?"few":e%100==2?"two":e%100==1?"one":"other"},15:function(e){return 0===e||i(e%100,2,10)?"few":i(e%100,11,19)?"many":1==e?"one":"other"},16:function(e){return e%10==1&&11!=e?"one":"other"},17:function(e){return 3==e?"few":0===e?"zero":6==e?"many":2==e?"two":1==e?"one":"other"},18:function(e){return 0===e?"zero":i(e,0,2)&&0!==e&&2!=e?"one":"other"},19:function(e){return i(e,2,10)?"few":i(e,0,1)?"one":"other"},20:function(e){return!i(e%10,3,4)&&e%10!=9||i(e%100,10,19)||i(e%100,70,79)||i(e%100,90,99)?e%1e6===0&&0!==e?"many":e%10!=2||t(e%100,[12,72,92])?e%10!=1||t(e%100,[11,71,91])?"other":"one":"two":"few"},21:function(e){return 0===e?"zero":1==e?"one":"other"},22:function(e){return i(e,0,1)||i(e,11,99)?"one":"other"},23:function(e){return i(e%10,1,2)||e%20===0?"one":"other"},24:function(e){return i(e,3,10)||i(e,13,19)?"few":t(e,[2,12])?"two":t(e,[1,11])?"one":"other"}},o=n[e.replace(/-.*$/,"")];return o in r?r[o]:(console.warn("plural form unknown for ["+e+"]"),function(){return"other"})}function f(e,t,i){var n=b[e];if(!n){if(console.warn("#"+e+" is undefined."),!i)return null;n=i}var r={};for(var o in n){var s=n[o];s=g(s,t,e,o),s=v(s,t,e),r[o]=s}return r}function g(e,t,i,n){var r=/\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/,o=r.exec(e);if(!o||!o.length)return e;var s,a=o[1],l=o[2];if(t&&l in t?s=t[l]:l in b&&(s=b[l]),a in x){var d=x[a];e=d(e,s,i,n)}return e}function v(e,t,i){var n=/\{\{\s*(.+?)\s*\}\}/g;return e.replace(n,function(e,n){return t&&n in t?t[n]:n in b?b[n]:(console.log("argument {{"+n+"}} for #"+i+" is undefined."),e)})}function p(e){var i=s(e);if(i.id){var n=f(i.id,i.args);if(!n)return void console.warn("#"+i.id+" is undefined.");if(n[P]){if(0===m(e))e[P]=n[P];else{for(var r=e.childNodes,o=!1,a=0,l=r.length;l>a;a++)3===r[a].nodeType&&/\S/.test(r[a].nodeValue)&&(o?r[a].nodeValue="":(r[a].nodeValue=n[P],o=!0));if(!o){var d=t.createTextNode(n[P]);e.insertBefore(d,e.firstChild)}}delete n[P]}for(var h in n)e[h]=n[h]}}function m(e){if(e.children)return e.children.length;if("undefined"!=typeof e.childElementCount)return e.childElementCount;for(var t=0,i=0;i<e.childNodes.length;i++)t+=1===e.nodeType?1:0;return t}function w(e){e=e||t.documentElement;for(var i=o(e),n=i.length,r=0;n>r;r++)p(i[r]);p(e)}var b={},y="",P="textContent",S="",x={},E="loading",L=!0;return x.plural=function(e,t,i,n){var r=parseFloat(t);if(isNaN(r))return e;if(n!=P)return e;x._pluralRules||(x._pluralRules=u(S));var o="["+x._pluralRules(r)+"]";return 0===r&&i+"[zero]"in b?e=b[i+"[zero]"][n]:1==r&&i+"[one]"in b?e=b[i+"[one]"][n]:2==r&&i+"[two]"in b?e=b[i+"[two]"][n]:i+o in b?e=b[i+o][n]:i+"[other]"in b&&(e=b[i+"[other]"][n]),e},{get:function(e,t,i){var n=e.lastIndexOf("."),r=P;n>0&&(r=e.substr(n+1),e=e.substring(0,n));var o;i&&(o={},o[r]=i);var s=f(e,t,o);return s&&r in s?s[r]:"{{"+e+"}}"},getData:function(){return b},getText:function(){return y},getLanguage:function(){return S},setLanguage:function(e,t){h(e,function(){t&&t(),w()})},getDirection:function(){var e=["ar","he","fa","ps","ur"],t=S.split("-",1)[0];return e.indexOf(t)>=0?"rtl":"ltr"},translate:w,getReadyState:function(){return E},ready:function(i){i&&("complete"==E||"interactive"==E?e.setTimeout(function(){i()}):t.addEventListener&&t.addEventListener("localized",function n(){t.removeEventListener("localized",n),i()}))}}}(e,t);var m=96/72,w="auto",b=0,y=1.25,P=40,S=5,x=function(){function e(){}var i=["ms","Moz","Webkit","O"],n={};return e.getProp=function(e,r){if(1===arguments.length&&"string"==typeof n[e])return n[e];r=r||t.documentElement;var o,s,a=r.style;if("string"==typeof a[e])return n[e]=e;s=e.charAt(0).toUpperCase()+e.slice(1);for(var l=0,d=i.length;d>l;l++)if(o=i[l]+s,"string"==typeof a[o])return n[e]=o;return n[e]="undefined"},e.setProp=function(e,t,i){var n=this.getProp(e);"undefined"!==n&&(t.style[n]=i)},e}(),E=function(){function e(e,t,i){return Math.min(Math.max(e,t),i)}function i(e,i){this.visible=!0,this.div=t.querySelector(e+" .progress"),this.bar=this.div.parentNode,this.height=i.height||100,this.width=i.width||100,this.units=i.units||"%",this.div.style.height=this.height+this.units,this.percent=0}return i.prototype={updateBar:function(){if(this._indeterminate)return this.div.classList.add("indeterminate"),void(this.div.style.width=this.width+this.units);this.div.classList.remove("indeterminate");var e=this.width*this._percent/100;this.div.style.width=e+this.units},get percent(){return this._percent},set percent(t){this._indeterminate=isNaN(t),this._percent=e(t,0,100),this.updateBar()},setWidth:function(e){if(e){var t=e.parentNode,i=t.offsetWidth-e.offsetWidth;i>0&&this.bar.setAttribute("style","width: calc(100% - "+i+"px);")}},hide:function(){this.visible&&(this.visible=!1,this.bar.classList.add("hidden"),t.body.classList.remove("loadingInProgress"))},show:function(){this.visible||(this.visible=!0,t.body.classList.add("loadingInProgress"),this.bar.classList.remove("hidden"))}},i}(),L={prefs:Object.create(p),isInitializedPromiseResolved:!1,initializedPromise:null,initialize:function(){return this.initializedPromise=this._readFromStorage(p).then(function(e){this.isInitializedPromiseResolved=!0,e&&(this.prefs=e)}.bind(this))},_writeToStorage:function(e){return Promise.resolve()},_readFromStorage:function(e){return Promise.resolve()},reset:function(){return this.initializedPromise.then(function(){return this.prefs=Object.create(p),this._writeToStorage(p)}.bind(this))},reload:function(){return this.initializedPromise.then(function(){this._readFromStorage(p).then(function(e){e&&(this.prefs=e)}.bind(this))}.bind(this))},set:function(e,t){return this.initializedPromise.then(function(){if(void 0===p[e])throw new Error("preferencesSet: '"+e+"' is undefined.");if(void 0===t)throw new Error("preferencesSet: no value is specified.");var i=typeof t,n=typeof p[e];if(i!==n){if("number"!==i||"string"!==n)throw new Error("Preferences_set: '"+t+"' is a \""+i+'", expected "'+n+'".');t=t.toString()}else if("number"===i&&(0|t)!==t)throw new Error("Preferences_set: '"+t+'\' must be an "integer".');return this.prefs[e]=t,this._writeToStorage(this.prefs)}.bind(this))},get:function(e){return this.initializedPromise.then(function(){var t=p[e];if(void 0===t)throw new Error("preferencesGet: '"+e+"' is undefined.");var i=this.prefs[e];return void 0!==i?i:t}.bind(this))}};L._writeToStorage=function(e){return new Promise(function(t){localStorage.setItem("pdfjs.preferences",JSON.stringify(e)),t()})},L._readFromStorage=function(e){return new Promise(function(e){var t=JSON.parse(localStorage.getItem("pdfjs.preferences"));e(t)})};var C=function(){function i(i,n){var r=t.createElement("a");if(r.click)r.href=i,r.target="_parent","download"in r&&(r.download=n),(t.body||t.documentElement).appendChild(r),r.click(),r.parentNode.removeChild(r);else{if(e.top===e&&i.split("#")[0]===e.location.href.split("#")[0]){var o=-1===i.indexOf("?")?"?":"&";i=i.replace(/#|$/,o+"$&")}e.open(i,"_parent")}}function n(){}return n.prototype={downloadUrl:function(e,t){PDFJS.isValidUrl(e,!0)&&i(e+"#pdfjs.action=download",t)},downloadData:function(e,t,n){if(navigator.msSaveBlob)return navigator.msSaveBlob(new Blob([e],{type:n}),t);var r=PDFJS.createObjectURL(e,n);i(r,t)},download:function(e,t,n){if(!URL)return void this.downloadUrl(t,n);if(navigator.msSaveBlob)return void(navigator.msSaveBlob(e,n)||this.downloadUrl(t,n));var r=URL.createObjectURL(e);i(r,n)}},n}(),I=3e4,D={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},F=function(){function e(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1}return e.prototype={setViewer:function(e){this.pdfViewer=e},setThumbnailViewer:function(e){this.pdfThumbnailViewer=e},isHighestPriority:function(e){return this.highestPriorityPage===e.renderingId},renderHighestPriority:function(e){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(e)||this.pdfThumbnailViewer&&this.isThumbnailViewEnabled&&this.pdfThumbnailViewer.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),I))},getHighestPriority:function(e,t,i){var n=e.views,r=n.length;if(0===r)return!1;for(var o=0;r>o;++o){var s=n[o].view;if(!this.isViewFinished(s))return s}if(i){var a=e.last.id;if(t[a]&&!this.isViewFinished(t[a]))return t[a]}else{var l=e.first.id-2;if(t[l]&&!this.isViewFinished(t[l]))return t[l]}return null},isViewFinished:function(e){return e.renderingState===D.FINISHED},renderView:function(e){var t=e.renderingState;switch(t){case D.FINISHED:return!1;case D.PAUSED:this.highestPriorityPage=e.renderingId,e.resume();break;case D.RUNNING:this.highestPriorityPage=e.renderingId;break;case D.INITIAL:this.highestPriorityPage=e.renderingId;var i=function(){this.renderHighestPriority()}.bind(this);e.draw().then(i,i)}return!0}},e}(),T=200,N=function(){function e(e){var i=e.container,n=e.id,r=e.scale,o=e.defaultViewport,s=e.renderingQueue,a=e.textLayerFactory;this.id=n,this.renderingId="page"+n,this.rotation=0,this.scale=r||1,this.viewport=o,this.pdfPageRotate=o.rotation,this.hasRestrictedScaling=!1,this.renderingQueue=s,this.textLayerFactory=a,this.renderingState=D.INITIAL,this.resume=null,this.onBeforeDraw=null,this.onAfterDraw=null,this.textLayer=null,this.zoomLayer=null,this.annotationLayer=null;var l=t.createElement("div");l.id="pageContainer"+this.id,l.className="page",l.style.width=Math.floor(this.viewport.width)+"px",l.style.height=Math.floor(this.viewport.height)+"px",l.setAttribute("data-page-number",this.id),this.div=l,i.appendChild(l)}return e.prototype={setPdfPage:function(e){this.pdfPage=e,this.pdfPageRotate=e.rotate;var t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport(this.scale*m,t),this.stats=e.stats,this.reset()},destroy:function(){this.zoomLayer=null,this.reset(),this.pdfPage&&this.pdfPage.destroy()},reset:function(e){this.renderTask&&this.renderTask.cancel(),this.resume=null,this.renderingState=D.INITIAL;var i=this.div;i.style.width=Math.floor(this.viewport.width)+"px",i.style.height=Math.floor(this.viewport.height)+"px";for(var n=i.childNodes,r=this.zoomLayer||null,o=e&&this.annotationLayer&&this.annotationLayer.div||null,s=n.length-1;s>=0;s--){var a=n[s];r!==a&&o!==a&&i.removeChild(a)}i.removeAttribute("data-loaded"),e?this.annotationLayer&&this.annotationLayer.hide():this.annotationLayer=null,this.canvas&&(this.canvas.width=0,this.canvas.height=0,delete this.canvas),this.loadingIconDiv=t.createElement("div"),this.loadingIconDiv.className="loadingIcon",i.appendChild(this.loadingIconDiv)},update:function(e,t){this.scale=e||this.scale,"undefined"!=typeof t&&(this.rotation=t);var i=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:this.scale*m,rotation:i});var r=!1;if(this.canvas&&PDFJS.maxCanvasPixels>0){{var o=this.canvas.getContext("2d"),s=n(o),a=this.viewport.width*this.viewport.height;Math.sqrt(PDFJS.maxCanvasPixels/a)}(Math.floor(this.viewport.width)*s.sx|0)*(Math.floor(this.viewport.height)*s.sy|0)>PDFJS.maxCanvasPixels&&(r=!0)}return this.canvas&&(PDFJS.useOnlyCssZoom||this.hasRestrictedScaling&&r)?void this.cssTransform(this.canvas,!0):(this.canvas&&!this.zoomLayer&&(this.zoomLayer=this.canvas.parentNode,this.zoomLayer.style.position="absolute"),this.zoomLayer&&this.cssTransform(this.zoomLayer.firstChild),void this.reset(!0))},updatePosition:function(){this.textLayer&&this.textLayer.render(T)},cssTransform:function(e,t){var i=this.viewport.width,n=this.viewport.height,r=this.div;e.style.width=e.parentNode.style.width=r.style.width=Math.floor(i)+"px",e.style.height=e.parentNode.style.height=r.style.height=Math.floor(n)+"px";var o=this.viewport.rotation-e._viewport.rotation,s=Math.abs(o),a=1,l=1;(90===s||270===s)&&(a=n/i,l=i/n);var d="rotate("+o+"deg) scale("+a+","+l+")";if(x.setProp("transform",e,d),this.textLayer){var h=this.textLayer.viewport,c=this.viewport.rotation-h.rotation,u=Math.abs(c),f=i/h.width;(90===u||270===u)&&(f=i/h.height);var g,v,p=this.textLayer.textLayerDiv;switch(u){case 0:g=v=0;break;case 90:g=0,v="-"+p.style.height;break;case 180:g="-"+p.style.width,v="-"+p.style.height;break;case 270:g="-"+p.style.width,v=0;break;default:console.error("Bad rotation value.")}x.setProp("transform",p,"rotate("+u+"deg) scale("+f+", "+f+") translate("+g+", "+v+")"),x.setProp("transformOrigin",p,"0% 0%")}t&&this.annotationLayer&&this.annotationLayer.setupAnnotations(this.viewport)},get width(){return this.viewport.width},get height(){return this.viewport.height},getPagePoint:function(e,t){return this.viewport.convertToPdfPoint(e,t)},draw:function(){function e(e){if(S===b.renderTask&&(b.renderTask=null),"cancelled"===e)return void p(e);b.renderingState=D.FINISHED,b.loadingIconDiv&&(o.removeChild(b.loadingIconDiv),delete b.loadingIconDiv),b.zoomLayer&&(o.removeChild(b.zoomLayer),b.zoomLayer=null),b.error=e,b.stats=i.stats,b.onAfterDraw&&b.onAfterDraw();var n=t.createEvent("CustomEvent");n.initCustomEvent("pagerendered",!0,!0,{pageNumber:b.id}),o.dispatchEvent(n);var r=t.createEvent("CustomEvent");r.initCustomEvent("pagerender",!0,!0,{pageNumber:i.pageNumber}),o.dispatchEvent(r),e?p(e):v(void 0)}this.renderingState!==D.INITIAL&&console.error("Must be in new state before drawing"),this.renderingState=D.RUNNING;var i=this.pdfPage,r=this.viewport,o=this.div,s=t.createElement("div");s.style.width=o.style.width,s.style.height=o.style.height,s.classList.add("canvasWrapper");var a=t.createElement("canvas");a.id="page"+this.id,s.appendChild(a),this.annotationLayer?o.insertBefore(s,this.annotationLayer.div):o.appendChild(s),this.canvas=a;var l=a.getContext("2d"),d=n(l);if(PDFJS.useOnlyCssZoom){var h=r.clone({scale:m});d.sx*=h.width/r.width,d.sy*=h.height/r.height,d.scaled=!0}if(PDFJS.maxCanvasPixels>0){var c=r.width*r.height,u=Math.sqrt(PDFJS.maxCanvasPixels/c);d.sx>u||d.sy>u?(d.sx=u,d.sy=u,d.scaled=!0,this.hasRestrictedScaling=!0):this.hasRestrictedScaling=!1}a.width=Math.floor(r.width)*d.sx|0,a.height=Math.floor(r.height)*d.sy|0,a.style.width=Math.floor(r.width)+"px",a.style.height=Math.floor(r.height)+"px",a._viewport=r;var f=null,g=null;this.textLayerFactory&&(f=t.createElement("div"),f.className="textLayer",f.style.width=a.style.width,f.style.height=a.style.height,this.annotationLayer?o.insertBefore(f,this.annotationLayer.div):o.appendChild(f),g=this.textLayerFactory.createTextLayerBuilder(f,this.id-1,this.viewport)),this.textLayer=g,l._scaleX=d.sx,l._scaleY=d.sy,d.scaled&&l.scale(d.sx,d.sy);var v,p,w=new Promise(function(e,t){v=e,p=t}),b=this,y=null;this.renderingQueue&&(y=function(e){return b.renderingQueue.isHighestPriority(b)?void e():(b.renderingState=D.PAUSED,void(b.resume=function(){b.renderingState=D.RUNNING,e()}))});var P={canvasContext:l,viewport:this.viewport,continueCallback:y},S=this.renderTask=this.pdfPage.render(P);return this.renderTask.promise.then(function(){e(null),g&&b.pdfPage.getTextContent().then(function(e){g.setTextContent(e),g.render(T)})},function(t){e(t)}),o.setAttribute("data-loaded",!0),b.onBeforeDraw&&b.onBeforeDraw(),w},beforePrint:function(){var e=this.pdfPage,i=e.getViewport(1),n=2,r=t.createElement("canvas");r.width=Math.floor(i.width)*n,r.height=Math.floor(i.height)*n,r.style.width=n*i.width+"pt",r.style.height=n*i.height+"pt";var o="scale("+1/n+", "+1/n+")";x.setProp("transform",r,o),x.setProp("transformOrigin",r,"0% 0%");var s=t.getElementById("printContainer"),a=t.createElement("div");a.style.width=i.width+"pt",a.style.height=i.height+"pt",a.appendChild(r),s.appendChild(a),r.mozPrintCallback=function(t){var o=t.context;o.save(),o.fillStyle="rgb(255, 255, 255)",o.fillRect(0,0,r.width,r.height),o.restore(),o.scale(n,n);var s={canvasContext:o,viewport:i,intent:"print"};e.render(s).promise.then(function(){t.done()},function(e){console.error(e),"abort"in t?t.abort():t.done()})}}},e}(),_=1e5,V=/\S/,R=function(){function e(e){this.textLayerDiv=e.textLayerDiv,this.renderingDone=!1,this.divContentDone=!1,this.pageIdx=e.pageIndex,this.pageNumber=this.pageIdx+1,this.matches=[],this.viewport=e.viewport,this.textDivs=[],this.findController=e.findController||null}return e.prototype={_finishRendering:function(){this.renderingDone=!0;var e=t.createEvent("CustomEvent");e.initCustomEvent("textlayerrendered",!0,!0,{pageNumber:this.pageNumber}),this.textLayerDiv.dispatchEvent(e)},renderLayer:function(){var e=t.createDocumentFragment(),i=this.textDivs,n=i.length,r=t.createElement("canvas"),o=r.getContext("2d");if(n>_)return void this._finishRendering();for(var s,a,l=0;n>l;l++){var d=i[l];if(void 0===d.dataset.isWhitespace){var h=d.style.fontSize,c=d.style.fontFamily;(h!==s||c!==a)&&(o.font=h+" "+c,s=h,a=c);var u=o.measureText(d.textContent).width;if(u>0){e.appendChild(d);var f;if(void 0!==d.dataset.canvasWidth){var g=d.dataset.canvasWidth/u;f="scaleX("+g+")"}else f="";var v=d.dataset.angle;v&&(f="rotate("+v+"deg) "+f),f&&x.setProp("transform",d,f)}}}this.textLayerDiv.appendChild(e),this._finishRendering(),this.updateMatches()},render:function(e){if(this.divContentDone&&!this.renderingDone)if(this.renderTimer&&(clearTimeout(this.renderTimer),this.renderTimer=null),e){var t=this;this.renderTimer=setTimeout(function(){t.renderLayer(),t.renderTimer=null},e)}else this.renderLayer()},appendText:function(e,i){var n=i[e.fontName],r=t.createElement("div");if(this.textDivs.push(r),h(e.str))return void(r.dataset.isWhitespace=!0);var o=PDFJS.Util.transform(this.viewport.transform,e.transform),s=Math.atan2(o[1],o[0]);n.vertical&&(s+=Math.PI/2);var a=Math.sqrt(o[2]*o[2]+o[3]*o[3]),l=a;n.ascent?l=n.ascent*l:n.descent&&(l=(1+n.descent)*l);var d,c;0===s?(d=o[4],c=o[5]-l):(d=o[4]+l*Math.sin(s),c=o[5]-l*Math.cos(s)),r.style.left=d+"px",r.style.top=c+"px",r.style.fontSize=a+"px",r.style.fontFamily=n.fontFamily,r.textContent=e.str,PDFJS.pdfBug&&(r.dataset.fontName=e.fontName),0!==s&&(r.dataset.angle=s*(180/Math.PI)),r.textContent.length>1&&(r.dataset.canvasWidth=n.vertical?e.height*this.viewport.scale:e.width*this.viewport.scale)},setTextContent:function(e){this.textContent=e;for(var t=e.items,i=0,n=t.length;n>i;i++)this.appendText(t[i],e.styles);this.divContentDone=!0},convertMatches:function(e){for(var t=0,i=0,n=this.textContent.items,r=n.length-1,o=null===this.findController?0:this.findController.state.query.length,s=[],a=0,l=e.length;l>a;a++){for(var d=e[a];t!==r&&d>=i+n[t].str.length;)i+=n[t].str.length,t++;t===n.length&&console.error("Could not find a matching mapping");var h={begin:{divIdx:t,offset:d-i}};for(d+=o;t!==r&&d>i+n[t].str.length;)i+=n[t].str.length,t++;h.end={divIdx:t,offset:d-i},s.push(h)}return s},renderMatches:function(e){function i(e,t){var i=e.divIdx;o[i].textContent="",n(i,0,e.offset,t)}function n(e,i,n,s){var a=o[e],l=r[e].str.substring(i,n),d=t.createTextNode(l);if(s){var h=t.createElement("span");return h.className=s,h.appendChild(d),void a.appendChild(h)}a.appendChild(d)}if(0!==e.length){var r=this.textContent.items,o=this.textDivs,s=null,a=this.pageIdx,l=null===this.findController?!1:a===this.findController.selected.pageIdx,d=null===this.findController?-1:this.findController.selected.matchIdx,h=null===this.findController?!1:this.findController.state.highlightAll,c={divIdx:-1,offset:void 0},u=d,f=u+1;if(h)u=0,f=e.length;else if(!l)return;for(var g=u;f>g;g++){var v=e[g],p=v.begin,m=v.end,w=l&&g===d,b=w?" selected":"";if(this.findController&&this.findController.updateMatchPosition(a,g,o,p.divIdx,m.divIdx),s&&p.divIdx===s.divIdx?n(s.divIdx,s.offset,p.offset):(null!==s&&n(s.divIdx,s.offset,c.offset),i(p)),p.divIdx===m.divIdx)n(p.divIdx,p.offset,m.offset,"highlight"+b);else{n(p.divIdx,p.offset,c.offset,"highlight begin"+b);for(var y=p.divIdx+1,P=m.divIdx;P>y;y++)o[y].className="highlight middle"+b;i(m,"highlight end"+b)}s=m}s&&n(s.divIdx,s.offset,c.offset)}},updateMatches:function(){if(this.renderingDone){for(var e=this.matches,t=this.textDivs,i=this.textContent.items,n=-1,r=0,o=e.length;o>r;r++){for(var s=e[r],a=Math.max(n,s.begin.divIdx),l=a,d=s.end.divIdx;d>=l;l++){var h=t[l];h.textContent=i[l].str,h.className=""}n=s.end.divIdx+1}null!==this.findController&&this.findController.active&&(this.matches=this.convertMatches(null===this.findController?[]:this.findController.pageMatches[this.pageIdx]||[]),this.renderMatches(this.matches))}}},e}();c.prototype={createTextLayerBuilder:function(e,t,i){return new R({textLayerDiv:e,pageIndex:t,viewport:i})}};var M={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},k=!1,B=10,O=function(){function i(e){var t=[];this.push=function(i){var n=t.indexOf(i);n>=0&&t.splice(n,1),t.push(i),t.length>e&&t.shift().destroy()},this.resize=function(i){for(e=i;t.length>e;)t.shift().destroy()}}function n(e){this.container=e.container,this.viewer=e.viewer||e.container.firstElementChild,this.linkService=e.linkService||new U(this),this.removePageBorders=e.removePageBorders||!1,this.defaultRenderingQueue=!e.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new F,this.renderingQueue.setViewer(this)):this.renderingQueue=e.renderingQueue,this.scroll=o(this.container,this._scrollUpdate.bind(this)),this.updateInProgress=!1,this.presentationModeState=M.UNKNOWN,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders")}return n.prototype={get pagesCount(){return this.pages.length},getPageView:function(e){return this.pages[e]},get currentPageNumber(){return this._currentPageNumber},set currentPageNumber(i){if(!this.pdfDocument)return void(this._currentPageNumber=i);var n=t.createEvent("UIEvents");return n.initUIEvent("pagechange",!0,!0,e,0),n.updateInProgress=this.updateInProgress,i>0&&i<=this.pagesCount?(n.previousPageNumber=this._currentPageNumber,this._currentPageNumber=i,n.pageNumber=i,void this.container.dispatchEvent(n)):(n.pageNumber=this._currentPageNumber,n.previousPageNumber=i,void this.container.dispatchEvent(n))},get currentScale(){return this._currentScale},set currentScale(e){if(isNaN(e))throw new Error("Invalid numeric scale");return this.pdfDocument?void this._setScale(e,!1):(this._currentScale=e,void(this._currentScaleValue=e.toString()))},get currentScaleValue(){return this._currentScaleValue},set currentScaleValue(e){return this.pdfDocument?void this._setScale(e,!1):(this._currentScale=isNaN(e)?b:e,void(this._currentScaleValue=e))},get pagesRotation(){return this._pagesRotation},set pagesRotation(e){this._pagesRotation=e;for(var t=0,i=this.pages.length;i>t;t++){var n=this.pages[t];n.update(n.scale,e)}this._setScale(this._currentScaleValue,!0)},setDocument:function(e){if(this.pdfDocument&&this._resetView(),this.pdfDocument=e,e){var i,n=e.numPages,r=this.pagesRefMap={},o=this,s=new Promise(function(e){i=e});this.pagesPromise=s,s.then(function(){var e=t.createEvent("CustomEvent");e.initCustomEvent("pagesloaded",!0,!0,{pagesCount:n}),o.container.dispatchEvent(e)});var a=!1,l=null,d=new Promise(function(e){l=e});this.onePageRendered=d;var h=function(e){e.onBeforeDraw=function(){o._buffer.push(this)},e.onAfterDraw=function(){a||(a=!0,l())}},c=e.getPage(1);return this.firstPagePromise=c,c.then(function(s){for(var a=this._currentScale||1,l=s.getViewport(a*m),c=1;n>=c;++c){var u=null;PDFJS.disableTextLayer||(u=this);var f=new N({container:this.viewer,id:c,scale:a,defaultViewport:l.clone(),renderingQueue:this.renderingQueue,textLayerFactory:u,annotationsLayerFactory:this});h(f),this.pages.push(f)}d.then(function(){if(PDFJS.disableAutoFetch)i();else for(var t=n,s=1;n>=s;++s)e.getPage(s).then(function(e,n){var s=o.pages[e-1]; s.pdfPage||s.setPdfPage(n);var a=n.ref.num+" "+n.ref.gen+" R";r[a]=e,t--,t||i()}.bind(null,s))});var g=t.createEvent("CustomEvent");g.initCustomEvent("pagesinit",!0,!0,null),o.container.dispatchEvent(g),this.defaultRenderingQueue&&this.update(),this.findController&&this.findController.resolveFirstPage()}.bind(this))}},_resetView:function(){this.pages=[],this._currentPageNumber=1,this._currentScale=b,this._currentScaleValue=null,this._buffer=new i(B),this.location=null,this._pagesRotation=0,this._pagesRequests=[];for(var e=this.viewer;e.hasChildNodes();)e.removeChild(e.lastChild)},_scrollUpdate:function(){if(0!==this.pagesCount){this.update();for(var e=0,t=this.pages.length;t>e;e++)this.pages[e].updatePosition()}},_setScaleDispatchEvent:function(i,n,r){var o=t.createEvent("UIEvents");o.initUIEvent("scalechange",!0,!0,e,0),o.scale=i,r&&(o.presetValue=n),this.container.dispatchEvent(o)},_setScaleUpdatePages:function(e,t,i,n){if(this._currentScaleValue=t,e===this._currentScale)return void(n&&this._setScaleDispatchEvent(e,t,!0));for(var r=0,o=this.pages.length;o>r;r++)this.pages[r].update(e);if(this._currentScale=e,!i){var s,a=this._currentPageNumber,l=this.presentationModeState===M.CHANGING||this.presentationModeState===M.FULLSCREEN;!this.location||l||k||(a=this.location.pageNumber,s=[null,{name:"XYZ"},this.location.left,this.location.top,null]),this.scrollPageIntoView(a,s)}this._setScaleDispatchEvent(e,t,n)},_setScale:function(e,t){if("custom"!==e){var i=parseFloat(e);if(i>0)this._setScaleUpdatePages(i,e,t,!1);else{var n=this.pages[this._currentPageNumber-1];if(!n)return;var r=this.presentationModeState===M.FULLSCREEN,o=r||this.removePageBorders?0:P,s=r||this.removePageBorders?0:S,a=(this.container.clientWidth-o)/n.width*n.scale,l=(this.container.clientHeight-s)/n.height*n.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=l;break;case"page-fit":i=Math.min(a,l);break;case"auto":var d=n.width>n.height,h=d?Math.min(l,a):a;i=Math.min(y,h);break;default:return void console.error("pdfViewSetScale: '"+e+"' is an unknown zoom value.")}this._setScaleUpdatePages(i,e,t,!0)}}},scrollPageIntoView:function(e,t){var i=this.pages[e-1];if(this.presentationModeState===M.FULLSCREEN){if(this.linkService.page!==i.id)return void(this.linkService.page=i.id);t=null,this._setScale(this.currentScaleValue,!0)}if(!t)return void r(i.div);var n,o,s=0,a=0,l=0,d=0,h=i.rotation%180===0?!1:!0,c=(h?i.height:i.width)/i.scale/m,u=(h?i.width:i.height)/i.scale/m,f=0;switch(t[1].name){case"XYZ":s=t[2],a=t[3],f=t[4],s=null!==s?s:0,a=null!==a?a:u;break;case"Fit":case"FitB":f="page-fit";break;case"FitH":case"FitBH":a=t[2],f="page-width";break;case"FitV":case"FitBV":s=t[2],l=c,d=u,f="page-height";break;case"FitR":s=t[2],a=t[3],l=t[4]-s,d=t[5]-a;var g=this.container,v=this.removePageBorders?0:P,p=this.removePageBorders?0:S;n=(g.clientWidth-v)/l/m,o=(g.clientHeight-p)/d/m,f=Math.min(Math.abs(n),Math.abs(o));break;default:return}if(f&&f!==this.currentScale?this.currentScaleValue=f:this.currentScale===b&&(this.currentScaleValue=w),"page-fit"===f&&!t[4])return void r(i.div);var y=[i.viewport.convertToViewportPoint(s,a),i.viewport.convertToViewportPoint(s+l,a+d)],x=Math.min(y[0][0],y[1][0]),E=Math.min(y[0][1],y[1][1]);r(i.div,{left:x,top:E})},_updateLocation:function(e){var t=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===t?Math.round(1e4*t)/100:i,r=e.id,o="#page="+r;o+="&zoom="+n;var s=this.pages[r-1],a=this.container,l=s.getPagePoint(a.scrollLeft-e.x,a.scrollTop-e.y),d=Math.round(l[0]),h=Math.round(l[1]);o+=","+d+","+h,this.location={pageNumber:r,scale:n,top:h,left:d,pdfOpenParams:o}},update:function(){var i=this._getVisiblePages(),n=i.views;if(0!==n.length){this.updateInProgress=!0;var r=Math.max(B,2*n.length+1);this._buffer.resize(r),this.renderingQueue.renderHighestPriority(i);for(var o=this.currentPageNumber,s=i.first,a=0,l=n.length,d=!1;l>a;++a){var h=n[a];if(h.percent<100)break;if(h.id===o){d=!0;break}}d||(o=n[0].id),this.presentationModeState!==M.FULLSCREEN&&(this.currentPageNumber=o),this._updateLocation(s),this.updateInProgress=!1;var c=t.createEvent("UIEvents");c.initUIEvent("updateviewarea",!0,!0,e,0),this.container.dispatchEvent(c)}},containsElement:function(e){return this.container.contains(e)},focus:function(){this.container.focus()},blur:function(){this.container.blur()},get isHorizontalScrollbarEnabled(){return this.presentationModeState===M.FULLSCREEN?!1:this.container.scrollWidth>this.container.clientWidth},_getVisiblePages:function(){if(this.presentationModeState!==M.FULLSCREEN)return a(this.container,this.pages,!0);var e=[],t=this.pages[this._currentPageNumber-1];return e.push({id:t.id,view:t}),{first:t,last:t,views:e}},cleanup:function(){for(var e=0,t=this.pages.length;t>e;e++)this.pages[e]&&this.pages[e].renderingState!==D.FINISHED&&this.pages[e].reset()},_ensurePdfPageLoaded:function(e){if(e.pdfPage)return Promise.resolve(e.pdfPage);var t=e.id;if(this._pagesRequests[t])return this._pagesRequests[t];var i=this.pdfDocument.getPage(t).then(function(i){return e.setPdfPage(i),this._pagesRequests[t]=null,i}.bind(this));return this._pagesRequests[t]=i,i},forceRendering:function(e){var t=e||this._getVisiblePages(),i=this.renderingQueue.getHighestPriority(t,this.pages,this.scroll.down);return i?(this._ensurePdfPageLoaded(i).then(function(){this.renderingQueue.renderView(i)}.bind(this)),!0):!1},getPageTextContent:function(e){return this.pdfDocument.getPage(e+1).then(function(e){return e.getTextContent()})},createTextLayerBuilder:function(e,t,i){var n=this.presentationModeState===M.FULLSCREEN;return new R({textLayerDiv:e,pageIndex:t,viewport:i,findController:n?null:this.findController})},setFindController:function(e){this.findController=e}},n}(),U=function(){function e(e){this.pdfViewer=e}return e.prototype={get page(){return this.pdfViewer.currentPageNumber},set page(e){this.pdfViewer.currentPageNumber=e},navigateTo:function(e){},getDestinationHash:function(e){return"#"},getAnchorUrl:function(e){return"#"},setHash:function(e){},executeNamedAction:function(e){}},e}(),A={overlays:{},active:null,register:function(e,i,n){return new Promise(function(r){var o,s;if(!(e&&(o=t.getElementById(e))&&(s=o.parentNode)))throw new Error("Not enough parameters.");if(this.overlays[e])throw new Error("The overlay is already registered.");this.overlays[e]={element:o,container:s,callerCloseMethod:i||null,canForceClose:n||!1},r()}.bind(this))},unregister:function(e){return new Promise(function(t){if(!this.overlays[e])throw new Error("The overlay does not exist.");if(this.active===e)throw new Error("The overlay cannot be removed while it is active.");delete this.overlays[e],t()}.bind(this))},open:function(t){return new Promise(function(i){if(!this.overlays[t])throw new Error("The overlay does not exist.");if(this.active){if(!this.overlays[t].canForceClose)throw new Error(this.active===t?"The overlay is already active.":"Another overlay is currently active.");this._closeThroughCaller()}this.active=t,this.overlays[this.active].element.classList.remove("hidden"),this.overlays[this.active].container.classList.remove("hidden"),e.addEventListener("keydown",this._keyDown),i()}.bind(this))},close:function(t){return new Promise(function(i){if(!this.overlays[t])throw new Error("The overlay does not exist.");if(!this.active)throw new Error("The overlay is currently not active.");if(this.active!==t)throw new Error("Another overlay is currently active.");this.overlays[this.active].container.classList.add("hidden"),this.overlays[this.active].element.classList.add("hidden"),this.active=null,e.removeEventListener("keydown",this._keyDown),i()}.bind(this))},_keyDown:function(e){var t=A;t.active&&27===e.keyCode&&(t._closeThroughCaller(),e.preventDefault())},_closeThroughCaller:function(){this.overlays[this.active].callerCloseMethod&&this.overlays[this.active].callerCloseMethod(),this.active&&this.close(this.active)}},z={overlayName:null,updatePassword:null,reason:null,passwordField:null,passwordText:null,passwordSubmit:null,passwordCancel:null,initialize:function(e){this.overlayName=e.overlayName,this.passwordField=e.passwordField,this.passwordText=e.passwordText,this.passwordSubmit=e.passwordSubmit,this.passwordCancel=e.passwordCancel,this.passwordSubmit.addEventListener("click",this.verifyPassword.bind(this)),this.passwordCancel.addEventListener("click",this.close.bind(this)),this.passwordField.addEventListener("keydown",function(e){13===e.keyCode&&this.verifyPassword()}.bind(this)),A.register(this.overlayName,this.close.bind(this),!0)},open:function(){A.open(this.overlayName).then(function(){this.passwordField.focus();var e=Q.get("password_label",null,"Enter the password to open this PDF file.");this.reason===PDFJS.PasswordResponses.INCORRECT_PASSWORD&&(e=Q.get("password_invalid",null,"Invalid password. Please try again.")),this.passwordText.textContent=e}.bind(this))},close:function(){A.close(this.overlayName).then(function(){this.passwordField.value=""}.bind(this))},verifyPassword:function(){var e=this.passwordField.value;return e&&e.length>0?(this.close(),this.updatePassword(e)):void 0}},j=1.1,J=.25,W=10,H=5e3,Q=t.mozL10n||t.webL10n,q={initialized:!1,fellback:!1,pdfDocument:null,sidebarOpen:!1,printing:!1,pdfViewer:null,pdfRenderingQueue:null,updateScaleControls:!0,isInitialViewSet:!1,animationStartedPromise:null,mouseScrollTimeStamp:0,mouseScrollDelta:0,preferencePdfBugEnabled:!1,preferenceShowPreviousViewOnLoad:!0,preferenceDefaultZoomValue:"",isViewerEmbedded:e.parent!==e,url:"",initialize:function(){var e=new F;e.onIdle=this.cleanup.bind(this),this.pdfRenderingQueue=e;var i=t.getElementById("viewerContainer"),n=t.getElementById("viewer");this.pdfViewer=new O({container:i,viewer:n,renderingQueue:e,linkService:this}),e.setViewer(this.pdfViewer),L.initialize(),z.initialize({overlayName:"passwordOverlay",passwordField:t.getElementById("password"),passwordText:t.getElementById("passwordText"),passwordSubmit:t.getElementById("passwordSubmit"),passwordCancel:t.getElementById("passwordCancel")});var r=this,o=Promise.all([L.get("enableWebGL").then(function(e){PDFJS.disableWebGL=!e}),L.get("sidebarViewOnLoad").then(function(e){r.preferenceSidebarViewOnLoad=e}),L.get("pdfBugEnabled").then(function(e){r.preferencePdfBugEnabled=e}),L.get("showPreviousViewOnLoad").then(function(e){r.preferenceShowPreviousViewOnLoad=e}),L.get("defaultZoomValue").then(function(e){r.preferenceDefaultZoomValue=e}),L.get("disableTextLayer").then(function(e){PDFJS.disableTextLayer!==!0&&(PDFJS.disableTextLayer=e)}),L.get("disableRange").then(function(e){PDFJS.disableRange!==!0&&(PDFJS.disableRange=e)}),L.get("disableAutoFetch").then(function(e){PDFJS.disableAutoFetch=e}),L.get("disableFontFace").then(function(e){PDFJS.disableFontFace!==!0&&(PDFJS.disableFontFace=e)}),L.get("useOnlyCssZoom").then(function(e){PDFJS.useOnlyCssZoom=e})])["catch"](function(e){});return o.then(function(){q.initialized=!0})},zoomIn:function(e){var t=this.pdfViewer.currentScale;do t=(t*j).toFixed(2),t=Math.ceil(10*t)/10,t=Math.min(W,t);while(--e&&W>t);this.setScale(t,!0),g()},zoomOut:function(e){var t=this.pdfViewer.currentScale;do t=(t/j).toFixed(2),t=Math.floor(10*t)/10,t=Math.max(J,t);while(--e&&t>J);this.setScale(t,!0),g()},get currentScaleValue(){return this.pdfViewer.currentScaleValue},get pagesCount(){return this.pdfDocument.numPages},set page(e){this.pdfViewer.currentPageNumber=e},get page(){return this.pdfViewer.currentPageNumber},get supportsPrinting(){t.createElement("canvas");return!0},get supportsDocumentColors(){var e=!0;return PDFJS.shadow(this,"supportsDocumentColors",e)},get loadingBar(){var e=new E("#loadingBar",{});return PDFJS.shadow(this,"loadingBar",e)},setTitleUsingUrl:function(e){this.url=e;try{this.setTitle(decodeURIComponent(i(e))||e)}catch(t){this.setTitle(e)}},setTitle:function(e){this.isViewerEmbedded||(t.title=e)},close:function(){var e=t.getElementById("errorWrapper");e.setAttribute("hidden","true"),this.pdfDocument&&(this.pdfDocument.destroy(),this.pdfDocument=null,this.pdfViewer.setDocument(null),"undefined"!=typeof PDFBug&&PDFBug.cleanup())},open:function(t,i,n,r,o){function s(e){d.progress(e.loaded/e.total)}this.pdfDocument&&L.reload(),this.close();var a={password:n};if("string"==typeof t?(this.setTitleUsingUrl(t),a.url=t):t&&"byteLength"in t?a.data=t:t.url&&t.originalUrl&&(this.setTitleUsingUrl(t.originalUrl),a.url=t.url),o)for(var l in o)a[l]=o[l];var d=this;d.loading=!0,d.downloadComplete=!1;var h=function(e,t){z.updatePassword=e,z.reason=t,z.open()};PDFJS.getDocument(a,r,h,s).then(function(e){d.load(e,i),d.loading=!1},function(t){var i=t&&t.message,n=Q.get("loading_error",null,"An error occurred while loading the PDF.");t instanceof PDFJS.InvalidPDFException?n=Q.get("invalid_file_error",null,"Invalid or corrupted PDF file."):t instanceof PDFJS.MissingPDFException?n=Q.get("missing_file_error",null,"Missing PDF file."):t instanceof PDFJS.UnexpectedResponseException&&(n=Q.get("unexpected_response_error",null,"Unexpected server response."));var r={message:i};"function"==typeof e.onerror?e.onerror():(d.error(n,r),d.loading=!1)})},download:function(){function e(){n.downloadUrl(t,i)}var t=this.url.split("#")[0],i=d(t),n=new C;return n.onerror=function(e){q.error("PDF failed to download.")},this.pdfDocument&&this.downloadComplete?void this.pdfDocument.getData().then(function(e){var r=PDFJS.createBlob(e,"application/pdf");n.download(r,t,i)},e).then(null,e):void e()},fallback:function(e){},getAnchorUrl:function(e){return e},error:function(e,i){var n=Q.get("error_version_info",{version:PDFJS.version||"?",build:PDFJS.build||"?"},"PDF.js v{{version}} (build: {{build}})")+"\n";i&&(n+=Q.get("error_message",{message:i.message},"Message: {{message}}"),i.stack?n+="\n"+Q.get("error_stack",{stack:i.stack},"Stack: {{stack}}"):(i.filename&&(n+="\n"+Q.get("error_file",{file:i.filename},"File: {{file}}")),i.lineNumber&&(n+="\n"+Q.get("error_line",{line:i.lineNumber},"Line: {{line}}"))));var r=t.getElementById("errorWrapper");r.removeAttribute("hidden");var o=t.getElementById("errorMessage");o.textContent=e;var s=t.getElementById("errorClose");s.onclick=function(){r.setAttribute("hidden","true")};var a=t.getElementById("errorMoreInfo"),d=t.getElementById("errorShowMore"),h=t.getElementById("errorShowLess");d.onclick=function(){a.removeAttribute("hidden"),d.setAttribute("hidden","true"),h.removeAttribute("hidden"),a.style.height=a.scrollHeight+"px"},h.onclick=function(){a.setAttribute("hidden","true"),d.removeAttribute("hidden"),h.setAttribute("hidden","true")},d.oncontextmenu=l,h.oncontextmenu=l,s.oncontextmenu=l,d.removeAttribute("hidden"),h.setAttribute("hidden","true"),a.value=n},progress:function(e){var t=Math.round(100*e);(t>this.loadingBar.percent||isNaN(t))&&(this.loadingBar.percent=t,PDFJS.disableAutoFetch&&t&&(this.disableAutoFetchLoadingBarTimeout&&(clearTimeout(this.disableAutoFetchLoadingBarTimeout),this.disableAutoFetchLoadingBarTimeout=null),this.loadingBar.show(),this.disableAutoFetchLoadingBarTimeout=setTimeout(function(){this.loadingBar.hide(),this.disableAutoFetchLoadingBarTimeout=null}.bind(this),H)))},load:function(i,n){var r=this;n=n||b,this.pdfDocument=i;var o=i.getDownloadInfo().then(function(){r.downloadComplete=!0,r.loadingBar.hide(),t.querySelector(".toolbar").style.opacity=1}),s=(i.numPages,this.documentFingerprint=i.fingerprint,this.pdfViewer);s.currentScale=n,s.setDocument(i);{var a=s.firstPagePromise,l=s.pagesPromise;s.onePageRendered}this.isInitialViewSet=!1,this.pagesRefMap=s.pagesRefMap,a.then(function(i){o.then(function(){var i=t.createEvent("CustomEvent");i.initCustomEvent("documentload",!0,!0,{}),e.dispatchEvent(i)}),r.loadingBar.setWidth(t.getElementById("viewer")),r.setInitialView(null,n)}),l.then(function(){r.supportsPrinting&&i.getJavaScript().then(function(t){t.length&&(console.warn("Warning: JavaScript is not supported"),r.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript));for(var i=/\bprint\s*\(/g,n=0,o=t.length;o>n;n++){var s=t[n];if(s&&i.test(s))return void setTimeout(function(){e.print()})}})}),i.getMetadata().then(function(e){var n=e.info,o=e.metadata;r.documentInfo=n,r.metadata=o,console.log("PDF "+i.fingerprint+" ["+n.PDFFormatVersion+" "+(n.Producer||"-").trim()+" / "+(n.Creator||"-").trim()+"] (PDF.js: "+(PDFJS.version||"-")+(PDFJS.disableWebGL?"":" [WebGL]")+")");var s;if(o&&o.has("dc:title")){var a=o.get("dc:title");"Untitled"!==a&&(s=a)}!s&&n&&n.Title&&(s=n.Title),s&&r.setTitle(s+" - "+t.title),n.IsAcroFormPresent&&(console.warn("Warning: AcroForm/XFA is not supported"),r.fallback(PDFJS.UNSUPPORTED_FEATURES.forms))})},setInitialView:function(e,t){this.isInitialViewSet=!0,this.setScale(t,!0),this.page=1,this.pdfViewer.currentScale===b&&this.setScale(w,!0)},cleanup:function(){this.pdfViewer.cleanup(),this.pdfDocument.cleanup()},forceRendering:function(){this.pdfRenderingQueue.printing=this.printing,this.pdfRenderingQueue.isThumbnailViewEnabled=this.sidebarOpen,this.pdfRenderingQueue.renderHighestPriority()},parseQueryString:function(e){for(var t=e.split("&"),i={},n=0,r=t.length;r>n;++n){var o=t[n].split("="),s=o[0].toLowerCase(),a=o.length>1?o[1]:null;i[decodeURIComponent(s)]=decodeURIComponent(a)}return i},beforePrint:function(){if(!this.supportsPrinting){var i=Q.get("printing_not_supported",null,"Warning: Printing is not fully supported by this browser.");return void this.error(i)}var n,r,o=!1;if(this.pagesCount){for(n=0,r=this.pagesCount;r>n;++n)if(!this.pdfViewer.getPageView(n).pdfPage){o=!0;break}}else o=!0;if(o){var s=Q.get("printing_not_ready",null,"Warning: The PDF is not fully loaded for printing.");return void e.alert(s)}this.printing=!0,this.forceRendering();var a=t.querySelector("body");for(a.setAttribute("data-mozPrintCallback",!0),n=0,r=this.pagesCount;r>n;++n)this.pdfViewer.getPageView(n).beforePrint()},afterPrint:function(){for(var e=t.getElementById("printContainer");e.hasChildNodes();)e.removeChild(e.lastChild);this.printing