/* Copyright 2017 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ (function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId]){return installedModules[moduleId].exports}var module=installedModules[moduleId]={i:moduleId,l:false,exports:{}};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.l=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.i=function(value){return value};__webpack_require__.d=function(exports,name,getter){if(!__webpack_require__.o(exports,name)){Object.defineProperty(exports,name,{configurable:false,enumerable:true,get:getter})}};__webpack_require__.n=function(module){var getter=module&&module.__esModule?function getDefault(){return module['default']}:function getModuleExports(){return module};__webpack_require__.d(getter,'a',getter);return getter};__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)};__webpack_require__.p="";return __webpack_require__(__webpack_require__.s=33)})([(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.localized=exports.animationStarted=exports.normalizeWheelEventDelta=exports.binarySearchFirstItem=exports.watchScroll=exports.scrollIntoView=exports.getOutputScale=exports.approximateFraction=exports.roundToDivide=exports.getVisibleElements=exports.parseQueryString=exports.noContextMenuHandler=exports.getPDFFileNameFromURL=exports.ProgressBar=exports.EventBus=exports.NullL10n=exports.mozL10n=exports.RendererType=exports.cloneObj=exports.VERTICAL_PADDING=exports.SCROLLBAR_PADDING=exports.MAX_AUTO_SCALE=exports.UNKNOWN_SCALE=exports.MAX_SCALE=exports.MIN_SCALE=exports.DEFAULT_SCALE=exports.DEFAULT_SCALE_VALUE=exports.CSS_UNITS=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i2&&arguments[2]!==undefined?arguments[2]:false;var parent=element.offsetParent;if(!parent){console.error('offsetParent is not set -- cannot scroll');return}var offsetY=element.offsetTop+element.clientTop;var offsetX=element.offsetLeft+element.clientLeft;while(parent.clientHeight===parent.scrollHeight||skipOverflowHiddenElements&&getComputedStyle(parent).overflow==='hidden'){if(parent.dataset._scaleY){offsetY/=parent.dataset._scaleY;offsetX/=parent.dataset._scaleX}offsetY+=parent.offsetTop;offsetX+=parent.offsetLeft;parent=parent.offsetParent;if(!parent){return}}if(spot){if(spot.top!==undefined){offsetY+=spot.top}if(spot.left!==undefined){offsetX+=spot.left;parent.scrollLeft=offsetX}}parent.scrollTop=offsetY}function watchScroll(viewAreaElement,callback){var debounceScroll=function debounceScroll(evt){if(rAF){return}rAF=window.requestAnimationFrame(function viewAreaElementScrolled(){rAF=null;var currentY=viewAreaElement.scrollTop;var lastY=state.lastY;if(currentY!==lastY){state.down=currentY>lastY}state.lastY=currentY;callback(state)})};var state={down:true,lastY:viewAreaElement.scrollTop,_eventHandler:debounceScroll};var rAF=null;viewAreaElement.addEventListener('scroll',debounceScroll,true);return state}function parseQueryString(query){var parts=query.split('&');var params=Object.create(null);for(var i=0,ii=parts.length;i1?param[1]:null;params[decodeURIComponent(key)]=decodeURIComponent(value)}return params}function binarySearchFirstItem(items,condition){var minIndex=0;var maxIndex=items.length-1;if(items.length===0||!condition(items[maxIndex])){return items.length}if(condition(items[minIndex])){return minIndex}while(minIndex>1;var currentItem=items[currentIndex];if(condition(currentItem)){maxIndex=currentIndex}else{minIndex=currentIndex+1}}return minIndex}function approximateFraction(x){if(Math.floor(x)===x){return[x,1]}var xinv=1/x;var limit=8;if(xinv>limit){return[1,limit]}else if(Math.floor(xinv)===xinv){return[1,xinv]}var x_=x>1?xinv:x;var a=0,b=1,c=1,d=1;while(true){var p=a+c,q=b+d;if(q>limit){break}if(x_<=p/q){c=p;d=q}else{a=p;b=q}}var result=void 0;if(x_-a/b2&&arguments[2]!==undefined?arguments[2]:false;var top=scrollEl.scrollTop,bottom=top+scrollEl.clientHeight;var left=scrollEl.scrollLeft,right=left+scrollEl.clientWidth;function isElementBottomBelowViewTop(view){var element=view.div;var elementBottom=element.offsetTop+element.clientTop+element.clientHeight;return elementBottom>top}var visible=[],view=void 0,element=void 0;var currentHeight=void 0,viewHeight=void 0,hiddenHeight=void 0,percentHeight=void 0;var currentWidth=void 0,viewWidth=void 0;var firstVisibleElementInd=views.length===0?0:binarySearchFirstItem(views,isElementBottomBelowViewTop);for(var i=firstVisibleElementInd,ii=views.length;ibottom){break}currentWidth=element.offsetLeft+element.clientLeft;viewWidth=element.clientWidth;if(currentWidth+viewWidthright){continue}hiddenHeight=Math.max(0,top-currentHeight)+Math.max(0,currentHeight+viewHeight-bottom);percentHeight=(viewHeight-hiddenHeight)*100/viewHeight|0;visible.push({id:view.id,x:currentWidth,y:currentHeight,view:view,percent:percentHeight})}var first=visible[0];var last=visible[visible.length-1];if(sortByVisibility){visible.sort(function(a,b){var pc=a.percent-b.percent;if(Math.abs(pc)>0.001){return-pc}return a.id-b.id})}return{first:first,last:last,views:visible}}function noContextMenuHandler(evt){evt.preventDefault()}function isDataSchema(url){var i=0,ii=url.length;while(i1&&arguments[1]!==undefined?arguments[1]:'document.pdf';if(isDataSchema(url)){console.warn('getPDFFileNameFromURL: '+'ignoring "data:" URL for performance reasons.');return defaultFilename}var reURI=/^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;var reFilename=/[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;var splitURI=reURI.exec(url);var suggestedFilename=reFilename.exec(splitURI[1])||reFilename.exec(splitURI[2])||reFilename.exec(splitURI[3]);if(suggestedFilename){suggestedFilename=suggestedFilename[0];if(suggestedFilename.indexOf('%')!==-1){try{suggestedFilename=reFilename.exec(decodeURIComponent(suggestedFilename))[0]}catch(ex){}}}return suggestedFilename||defaultFilename}function normalizeWheelEventDelta(evt){var delta=Math.sqrt(evt.deltaX*evt.deltaX+evt.deltaY*evt.deltaY);var angle=Math.atan2(evt.deltaY,evt.deltaX);if(-0.25*Math.PI1&&arguments[1]!==undefined?arguments[1]:{},height=_ref.height,width=_ref.width,units=_ref.units;_classCallCheck(this,ProgressBar);this.visible=true;this.div=document.querySelector(id+' .progress');this.bar=this.div.parentNode;this.height=height||100;this.width=width||100;this.units=units||'%';this.div.style.height=this.height+this.units;this.percent=0}_createClass(ProgressBar,[{key:'_updateBar',value:function _updateBar(){if(this._indeterminate){this.div.classList.add('indeterminate');this.div.style.width=this.width+this.units;return}this.div.classList.remove('indeterminate');var progressSize=this.width*this._percent/100;this.div.style.width=progressSize+this.units}},{key:'setWidth',value:function setWidth(viewer){if(!viewer){return}var container=viewer.parentNode;var scrollbarWidth=container.offsetWidth-viewer.offsetWidth;if(scrollbarWidth>0){this.bar.setAttribute('style','width: calc(100% - '+scrollbarWidth+'px);')}}},{key:'hide',value:function hide(){if(!this.visible){return}this.visible=false;this.bar.classList.add('hidden');document.body.classList.remove('loadingInProgress')}},{key:'show',value:function show(){if(this.visible){return}this.visible=true;document.body.classList.add('loadingInProgress');this.bar.classList.remove('hidden')}},{key:'percent',get:function get(){return this._percent},set:function set(val){this._indeterminate=isNaN(val);this._percent=clamp(val,0,100);this._updateBar()}}]);return ProgressBar}();exports.CSS_UNITS=CSS_UNITS;exports.DEFAULT_SCALE_VALUE=DEFAULT_SCALE_VALUE;exports.DEFAULT_SCALE=DEFAULT_SCALE;exports.MIN_SCALE=MIN_SCALE;exports.MAX_SCALE=MAX_SCALE;exports.UNKNOWN_SCALE=UNKNOWN_SCALE;exports.MAX_AUTO_SCALE=MAX_AUTO_SCALE;exports.SCROLLBAR_PADDING=SCROLLBAR_PADDING;exports.VERTICAL_PADDING=VERTICAL_PADDING;exports.cloneObj=cloneObj;exports.RendererType=RendererType;exports.mozL10n=mozL10n;exports.NullL10n=NullL10n;exports.EventBus=EventBus;exports.ProgressBar=ProgressBar;exports.getPDFFileNameFromURL=getPDFFileNameFromURL;exports.noContextMenuHandler=noContextMenuHandler;exports.parseQueryString=parseQueryString;exports.getVisibleElements=getVisibleElements;exports.roundToDivide=roundToDivide;exports.approximateFraction=approximateFraction;exports.getOutputScale=getOutputScale;exports.scrollIntoView=scrollIntoView;exports.watchScroll=watchScroll;exports.binarySearchFirstItem=binarySearchFirstItem;exports.normalizeWheelEventDelta=normalizeWheelEventDelta;exports.animationStarted=animationStarted;exports.localized=localized}),(function(module,exports,__webpack_require__){"use strict";var pdfjsLib;if(typeof window!=='undefined'&&window['pdfjs-dist/build/pdf']){pdfjsLib=window['pdfjs-dist/build/pdf']}else{pdfjsLib=require('../build/pdf.js')}module.exports=pdfjsLib}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getGlobalEventBus=exports.attachDOMEventsToEventBus=undefined;var _ui_utils=__webpack_require__(0);function attachDOMEventsToEventBus(eventBus){eventBus.on('documentload',function(){var event=document.createEvent('CustomEvent');event.initCustomEvent('documentload',true,true,{});window.dispatchEvent(event)});eventBus.on('pagerendered',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('pagerendered',true,true,{pageNumber:evt.pageNumber,cssTransform:evt.cssTransform});evt.source.div.dispatchEvent(event)});eventBus.on('textlayerrendered',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('textlayerrendered',true,true,{pageNumber:evt.pageNumber});evt.source.textLayerDiv.dispatchEvent(event)});eventBus.on('pagechange',function(evt){var event=document.createEvent('UIEvents');event.initUIEvent('pagechange',true,true,window,0);event.pageNumber=evt.pageNumber;evt.source.container.dispatchEvent(event)});eventBus.on('pagesinit',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('pagesinit',true,true,null);evt.source.container.dispatchEvent(event)});eventBus.on('pagesloaded',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('pagesloaded',true,true,{pagesCount:evt.pagesCount});evt.source.container.dispatchEvent(event)});eventBus.on('scalechange',function(evt){var event=document.createEvent('UIEvents');event.initUIEvent('scalechange',true,true,window,0);event.scale=evt.scale;event.presetValue=evt.presetValue;evt.source.container.dispatchEvent(event)});eventBus.on('updateviewarea',function(evt){var event=document.createEvent('UIEvents');event.initUIEvent('updateviewarea',true,true,window,0);event.location=evt.location;evt.source.container.dispatchEvent(event)});eventBus.on('find',function(evt){if(evt.source===window){return}var event=document.createEvent('CustomEvent');event.initCustomEvent('find'+evt.type,true,true,{query:evt.query,phraseSearch:evt.phraseSearch,caseSensitive:evt.caseSensitive,highlightAll:evt.highlightAll,findPrevious:evt.findPrevious});window.dispatchEvent(event)});eventBus.on('attachmentsloaded',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('attachmentsloaded',true,true,{attachmentsCount:evt.attachmentsCount});evt.source.container.dispatchEvent(event)});eventBus.on('sidebarviewchanged',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('sidebarviewchanged',true,true,{view:evt.view});evt.source.outerContainer.dispatchEvent(event)});eventBus.on('pagemode',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('pagemode',true,true,{mode:evt.mode});evt.source.pdfViewer.container.dispatchEvent(event)});eventBus.on('namedaction',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('namedaction',true,true,{action:evt.action});evt.source.pdfViewer.container.dispatchEvent(event)});eventBus.on('presentationmodechanged',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('presentationmodechanged',true,true,{active:evt.active,switchInProgress:evt.switchInProgress});window.dispatchEvent(event)});eventBus.on('outlineloaded',function(evt){var event=document.createEvent('CustomEvent');event.initCustomEvent('outlineloaded',true,true,{outlineCount:evt.outlineCount});evt.source.container.dispatchEvent(event)})}var globalEventBus=null;function getGlobalEventBus(){if(globalEventBus){return globalEventBus}globalEventBus=new _ui_utils.EventBus();attachDOMEventsToEventBus(globalEventBus);return globalEventBus}exports.attachDOMEventsToEventBus=attachDOMEventsToEventBus;exports.getGlobalEventBus=getGlobalEventBus}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&newScale<_ui_utils.MAX_SCALE);this.pdfViewer.currentScaleValue=newScale},zoomOut:function zoomOut(ticks){var newScale=this.pdfViewer.currentScale;do{newScale=(newScale/DEFAULT_SCALE_DELTA).toFixed(2);newScale=Math.floor(newScale*10)/10;newScale=Math.max(_ui_utils.MIN_SCALE,newScale)}while(--ticks>0&&newScale>_ui_utils.MIN_SCALE);this.pdfViewer.currentScaleValue=newScale},get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0},get pageRotation(){return this.pdfViewer.pagesRotation},set page(val){this.pdfViewer.currentPageNumber=val},get page(){return this.pdfViewer.currentPageNumber},get printing(){return!!this.printService},get supportsPrinting(){return PDFPrintServiceFactory.instance.supportsPrinting},get supportsFullscreen(){var support=void 0;var doc=document.documentElement;support=!!(doc.requestFullscreen||doc.mozRequestFullScreen||doc.webkitRequestFullScreen||doc.msRequestFullscreen);if(document.fullscreenEnabled===false||document.mozFullScreenEnabled===false||document.webkitFullscreenEnabled===false||document.msFullscreenEnabled===false){support=false}if(support&&_pdfjsLib.PDFJS.disableFullscreen===true){support=false}return(0,_pdfjsLib.shadow)(this,'supportsFullscreen',support)},get supportsIntegratedFind(){return this.externalServices.supportsIntegratedFind},get supportsDocumentFonts(){return this.externalServices.supportsDocumentFonts},get supportsDocumentColors(){return this.externalServices.supportsDocumentColors},get loadingBar(){var bar=new _ui_utils.ProgressBar('#loadingBar');return(0,_pdfjsLib.shadow)(this,'loadingBar',bar)},get supportedMouseWheelZoomModifierKeys(){return this.externalServices.supportedMouseWheelZoomModifierKeys},initPassiveLoading:function initPassiveLoading(){throw new Error('Not implemented: initPassiveLoading');},setTitleUsingUrl:function setTitleUsingUrl(url){this.url=url;this.baseUrl=url.split('#')[0];var title=(0,_ui_utils.getPDFFileNameFromURL)(url,'');if(!title){try{title=decodeURIComponent((0,_pdfjsLib.getFilenameFromUrl)(url))||url}catch(ex){title=url}}this.setTitle(title)},setTitle:function setTitle(title){if(this.isViewerEmbedded){return}document.title=title},close:function close(){var errorWrapper=this.appConfig.errorWrapper.container;errorWrapper.setAttribute('hidden','true');if(!this.pdfLoadingTask){return Promise.resolve()}var promise=this.pdfLoadingTask.destroy();this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null,null);this.pdfDocumentProperties.setDocument(null,null)}this.store=null;this.isInitialViewSet=false;this.downloadComplete=false;this.pdfSidebar.reset();this.pdfOutlineViewer.reset();this.pdfAttachmentViewer.reset();this.findController.reset();this.findBar.reset();this.toolbar.reset();this.secondaryToolbar.reset();if(typeof PDFBug!=='undefined'){PDFBug.cleanup()}return promise},open:function open(file,args){var _this3=this;if(arguments.length>2||typeof args==='number'){return Promise.reject(new Error('Call of open() with obsolete signature.'))}if(this.pdfLoadingTask){return this.close().then(function(){_this3.preferences.reload();return _this3.open(file,args)})}var parameters=Object.create(null),scale=void 0;if(typeof file==='string'){this.setTitleUsingUrl(file);parameters.url=file}else if(file&&'byteLength'in file){parameters.data=file}else if(file.url&&file.originalUrl){this.setTitleUsingUrl(file.originalUrl);parameters.url=file.url}if(args){for(var prop in args){parameters[prop]=args[prop]}if(args.scale){scale=args.scale}if(args.length){this.pdfDocumentProperties.setFileSize(args.length)}}var loadingTask=(0,_pdfjsLib.getDocument)(parameters);this.pdfLoadingTask=loadingTask;loadingTask.onPassword=function(updateCallback,reason){_this3.passwordPrompt.setUpdateCallback(updateCallback,reason);_this3.passwordPrompt.open()};loadingTask.onProgress=function(_ref){var loaded=_ref.loaded,total=_ref.total;_this3.progress(loaded/total)};loadingTask.onUnsupportedFeature=this.fallback.bind(this);return loadingTask.promise.then(function(pdfDocument){_this3.load(pdfDocument,scale)},function(exception){var message=exception&&exception.message;var loadingErrorMessage=void 0;if(exception instanceof _pdfjsLib.InvalidPDFException){loadingErrorMessage=_this3.l10n.get('invalid_file_error',null,'Invalid or corrupted PDF file.')}else if(exception instanceof _pdfjsLib.MissingPDFException){loadingErrorMessage=_this3.l10n.get('missing_file_error',null,'Missing PDF file.')}else if(exception instanceof _pdfjsLib.UnexpectedResponseException){loadingErrorMessage=_this3.l10n.get('unexpected_response_error',null,'Unexpected server response.')}else{loadingErrorMessage=_this3.l10n.get('loading_error',null,'An error occurred while loading the PDF.')}return loadingErrorMessage.then(function(msg){_this3.error(msg,{message:message});throw new Error(msg);})})},download:function download(){var _this4=this;function downloadByUrl(){downloadManager.downloadUrl(url,filename)}var url=this.baseUrl;var filename=(0,_ui_utils.getPDFFileNameFromURL)(this.url);var downloadManager=this.downloadManager;downloadManager.onerror=function(err){_this4.error('PDF failed to download: '+err)};if(!this.pdfDocument||!this.downloadComplete){downloadByUrl();return}this.pdfDocument.getData().then(function(data){var blob=(0,_pdfjsLib.createBlob)(data,'application/pdf');downloadManager.download(blob,url,filename)}).catch(downloadByUrl)},fallback:function fallback(featureId){},error:function error(message,moreInfo){var moreInfoText=[this.l10n.get('error_version_info',{version:_pdfjsLib.version||'?',build:_pdfjsLib.build||'?'},'PDF.js v{{version}} (build: {{build}})')];if(moreInfo){moreInfoText.push(this.l10n.get('error_message',{message:moreInfo.message},'Message: {{message}}'));if(moreInfo.stack){moreInfoText.push(this.l10n.get('error_stack',{stack:moreInfo.stack},'Stack: {{stack}}'))}else{if(moreInfo.filename){moreInfoText.push(this.l10n.get('error_file',{file:moreInfo.filename},'File: {{file}}'))}if(moreInfo.lineNumber){moreInfoText.push(this.l10n.get('error_line',{line:moreInfo.lineNumber},'Line: {{line}}'))}}}var errorWrapperConfig=this.appConfig.errorWrapper;var errorWrapper=errorWrapperConfig.container;errorWrapper.removeAttribute('hidden');var errorMessage=errorWrapperConfig.errorMessage;errorMessage.textContent=message;var closeButton=errorWrapperConfig.closeButton;closeButton.onclick=function(){errorWrapper.setAttribute('hidden','true')};var errorMoreInfo=errorWrapperConfig.errorMoreInfo;var moreInfoButton=errorWrapperConfig.moreInfoButton;var lessInfoButton=errorWrapperConfig.lessInfoButton;moreInfoButton.onclick=function(){errorMoreInfo.removeAttribute('hidden');moreInfoButton.setAttribute('hidden','true');lessInfoButton.removeAttribute('hidden');errorMoreInfo.style.height=errorMoreInfo.scrollHeight+'px'};lessInfoButton.onclick=function(){errorMoreInfo.setAttribute('hidden','true');moreInfoButton.removeAttribute('hidden');lessInfoButton.setAttribute('hidden','true')};moreInfoButton.oncontextmenu=_ui_utils.noContextMenuHandler;lessInfoButton.oncontextmenu=_ui_utils.noContextMenuHandler;closeButton.oncontextmenu=_ui_utils.noContextMenuHandler;moreInfoButton.removeAttribute('hidden');lessInfoButton.setAttribute('hidden','true');Promise.all(moreInfoText).then(function(parts){errorMoreInfo.value=parts.join('\n')})},progress:function progress(level){var _this5=this;if(this.downloadComplete){return}var percent=Math.round(level*100);if(percent>this.loadingBar.percent||isNaN(percent)){this.loadingBar.percent=percent;if(_pdfjsLib.PDFJS.disableAutoFetch&&percent){if(this.disableAutoFetchLoadingBarTimeout){clearTimeout(this.disableAutoFetchLoadingBarTimeout);this.disableAutoFetchLoadingBarTimeout=null}this.loadingBar.show();this.disableAutoFetchLoadingBarTimeout=setTimeout(function(){_this5.loadingBar.hide();_this5.disableAutoFetchLoadingBarTimeout=null},DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT)}}},load:function load(pdfDocument,scale){var _this6=this;scale=scale||_ui_utils.UNKNOWN_SCALE;this.pdfDocument=pdfDocument;pdfDocument.getDownloadInfo().then(function(){_this6.downloadComplete=true;_this6.loadingBar.hide();firstPagePromise.then(function(){_this6.eventBus.dispatch('documentload',{source:_this6})})});var pageModePromise=pdfDocument.getPageMode().catch(function(){});this.toolbar.setPagesCount(pdfDocument.numPages,false);this.secondaryToolbar.setPagesCount(pdfDocument.numPages);var id=this.documentFingerprint=pdfDocument.fingerprint;var store=this.store=new _view_history.ViewHistory(id);var baseDocumentUrl=void 0;baseDocumentUrl=null;this.pdfLinkService.setDocument(pdfDocument,baseDocumentUrl);this.pdfDocumentProperties.setDocument(pdfDocument,this.url);var pdfViewer=this.pdfViewer;pdfViewer.setDocument(pdfDocument);var firstPagePromise=pdfViewer.firstPagePromise;var pagesPromise=pdfViewer.pagesPromise;var onePageRendered=pdfViewer.onePageRendered;var pdfThumbnailViewer=this.pdfThumbnailViewer;pdfThumbnailViewer.setDocument(pdfDocument);firstPagePromise.then(function(pdfPage){_this6.loadingBar.setWidth(_this6.appConfig.viewerContainer);if(!_pdfjsLib.PDFJS.disableHistory&&!_this6.isViewerEmbedded){if(!_this6.viewerPrefs['showPreviousViewOnLoad']){_this6.pdfHistory.clearHistoryState()}_this6.pdfHistory.initialize(_this6.documentFingerprint);if(_this6.pdfHistory.initialDestination){_this6.initialDestination=_this6.pdfHistory.initialDestination}else if(_this6.pdfHistory.initialBookmark){_this6.initialBookmark=_this6.pdfHistory.initialBookmark}}var initialParams={destination:_this6.initialDestination,bookmark:_this6.initialBookmark,hash:null};var storePromise=store.getMultiple({exists:false,page:'1',zoom:_ui_utils.DEFAULT_SCALE_VALUE,scrollLeft:'0',scrollTop:'0',sidebarView:_pdf_sidebar.SidebarView.NONE}).catch(function(){});Promise.all([storePromise,pageModePromise]).then(function(_ref2){var _ref3=_slicedToArray(_ref2,2),_ref3$=_ref3[0],values=_ref3$===undefined?{}:_ref3$,pageMode=_ref3[1];var hash=_this6.viewerPrefs['defaultZoomValue']?'zoom='+_this6.viewerPrefs['defaultZoomValue']:null;var sidebarView=_this6.viewerPrefs['sidebarViewOnLoad'];if(values.exists&&_this6.viewerPrefs['showPreviousViewOnLoad']){hash='page='+values.page+'&zoom='+(_this6.viewerPrefs['defaultZoomValue']||values.zoom)+','+values.scrollLeft+','+values.scrollTop;sidebarView=sidebarView||values.sidebarView|0}if(pageMode&&!_this6.viewerPrefs['disablePageMode']){sidebarView=sidebarView||apiPageModeToSidebarView(pageMode)}return{hash:hash,sidebarView:sidebarView}}).then(function(_ref4){var hash=_ref4.hash,sidebarView=_ref4.sidebarView;_this6.setInitialView(hash,{sidebarView:sidebarView,scale:scale});initialParams.hash=hash;if(!_this6.isViewerEmbedded){pdfViewer.focus()}return pagesPromise}).then(function(){if(!initialParams.destination&&!initialParams.bookmark&&!initialParams.hash){return}if(pdfViewer.hasEqualPageSizes){return}_this6.initialDestination=initialParams.destination;_this6.initialBookmark=initialParams.bookmark;pdfViewer.currentScaleValue=pdfViewer.currentScaleValue;_this6.setInitialView(initialParams.hash)}).then(function(){pdfViewer.update()})});pdfDocument.getPageLabels().then(function(labels){if(!labels||_this6.viewerPrefs['disablePageLabels']){return}var i=0,numLabels=labels.length;if(numLabels!==_this6.pagesCount){console.error('The number of Page Labels does not match '+'the number of pages in the document.');return}while(i1&&arguments[1]!==undefined?arguments[1]:{};var _options$scale=options.scale,scale=_options$scale===undefined?0:_options$scale,_options$sidebarView=options.sidebarView,sidebarView=_options$sidebarView===undefined?_pdf_sidebar.SidebarView.NONE:_options$sidebarView;this.isInitialViewSet=true;this.pdfSidebar.setInitialView(sidebarView);if(this.initialDestination){this.pdfLinkService.navigateTo(this.initialDestination);this.initialDestination=null}else if(this.initialBookmark){this.pdfLinkService.setHash(this.initialBookmark);this.pdfHistory.push({hash:this.initialBookmark},true);this.initialBookmark=null}else if(storedHash){this.pdfLinkService.setHash(storedHash)}else if(scale){this.pdfViewer.currentScaleValue=scale;this.page=1}this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);if(!this.pdfViewer.currentScaleValue){this.pdfViewer.currentScaleValue=_ui_utils.DEFAULT_SCALE_VALUE}},cleanup:function cleanup(){if(!this.pdfDocument){return}this.pdfViewer.cleanup();this.pdfThumbnailViewer.cleanup();if(this.pdfViewer.renderer!==_ui_utils.RendererType.SVG){this.pdfDocument.cleanup()}},forceRendering:function forceRendering(){this.pdfRenderingQueue.printing=this.printing;this.pdfRenderingQueue.isThumbnailViewEnabled=this.pdfSidebar.isThumbnailViewVisible;this.pdfRenderingQueue.renderHighestPriority()},beforePrint:function beforePrint(){var _this7=this;if(this.printService){return}if(!this.supportsPrinting){this.l10n.get('printing_not_supported',null,'Warning: Printing is not fully supported by '+'this browser.').then(function(printMessage){_this7.error(printMessage)});return}if(!this.pdfViewer.pageViewsReady){this.l10n.get('printing_not_ready',null,'Warning: The PDF is not fully loaded for printing.').then(function(notReadyMessage){window.alert(notReadyMessage)});return}var pagesOverview=this.pdfViewer.getPagesOverview();var printContainer=this.appConfig.printContainer;var printService=PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument,pagesOverview,printContainer,this.l10n);this.printService=printService;this.forceRendering();printService.layout()},afterPrint:function pdfViewSetupAfterPrint(){if(this.printService){this.printService.destroy();this.printService=null}this.forceRendering()},rotatePages:function rotatePages(delta){if(!this.pdfDocument){return}var pdfViewer=this.pdfViewer,pdfThumbnailViewer=this.pdfThumbnailViewer;var pageNumber=pdfViewer.currentPageNumber;var newRotation=(pdfViewer.pagesRotation+360+delta)%360;pdfViewer.pagesRotation=newRotation;pdfThumbnailViewer.pagesRotation=newRotation;this.forceRendering();pdfViewer.currentPageNumber=pageNumber},requestPresentationMode:function requestPresentationMode(){if(!this.pdfPresentationMode){return}this.pdfPresentationMode.request()},bindEvents:function bindEvents(){var eventBus=this.eventBus,_boundEvents=this._boundEvents;_boundEvents.beforePrint=this.beforePrint.bind(this);_boundEvents.afterPrint=this.afterPrint.bind(this);eventBus.on('resize',webViewerResize);eventBus.on('hashchange',webViewerHashchange);eventBus.on('beforeprint',_boundEvents.beforePrint);eventBus.on('afterprint',_boundEvents.afterPrint);eventBus.on('pagerendered',webViewerPageRendered);eventBus.on('textlayerrendered',webViewerTextLayerRendered);eventBus.on('updateviewarea',webViewerUpdateViewarea);eventBus.on('pagechanging',webViewerPageChanging);eventBus.on('scalechanging',webViewerScaleChanging);eventBus.on('sidebarviewchanged',webViewerSidebarViewChanged);eventBus.on('pagemode',webViewerPageMode);eventBus.on('namedaction',webViewerNamedAction);eventBus.on('presentationmodechanged',webViewerPresentationModeChanged);eventBus.on('presentationmode',webViewerPresentationMode);eventBus.on('openfile',webViewerOpenFile);eventBus.on('print',webViewerPrint);eventBus.on('download',webViewerDownload);eventBus.on('firstpage',webViewerFirstPage);eventBus.on('lastpage',webViewerLastPage);eventBus.on('nextpage',webViewerNextPage);eventBus.on('previouspage',webViewerPreviousPage);eventBus.on('zoomin',webViewerZoomIn);eventBus.on('zoomout',webViewerZoomOut);eventBus.on('pagenumberchanged',webViewerPageNumberChanged);eventBus.on('scalechanged',webViewerScaleChanged);eventBus.on('rotatecw',webViewerRotateCw);eventBus.on('rotateccw',webViewerRotateCcw);eventBus.on('documentproperties',webViewerDocumentProperties);eventBus.on('find',webViewerFind);eventBus.on('findfromurlhash',webViewerFindFromUrlHash);eventBus.on('fileinputchange',webViewerFileInputChange)},bindWindowEvents:function bindWindowEvents(){var eventBus=this.eventBus,_boundEvents=this._boundEvents;_boundEvents.windowResize=function(){eventBus.dispatch('resize')};_boundEvents.windowHashChange=function(){eventBus.dispatch('hashchange',{hash:document.location.hash.substring(1)})};_boundEvents.windowBeforePrint=function(){eventBus.dispatch('beforeprint')};_boundEvents.windowAfterPrint=function(){eventBus.dispatch('afterprint')};window.addEventListener('wheel',webViewerWheel);window.addEventListener('click',webViewerClick);window.addEventListener('keydown',webViewerKeyDown);window.addEventListener('resize',_boundEvents.windowResize);window.addEventListener('hashchange',_boundEvents.windowHashChange);window.addEventListener('beforeprint',_boundEvents.windowBeforePrint);window.addEventListener('afterprint',_boundEvents.windowAfterPrint);_boundEvents.windowChange=function(evt){var files=evt.target.files;if(!files||files.length===0){return}eventBus.dispatch('fileinputchange',{fileInput:evt.target})};window.addEventListener('change',_boundEvents.windowChange)},unbindEvents:function unbindEvents(){var eventBus=this.eventBus,_boundEvents=this._boundEvents;eventBus.off('resize',webViewerResize);eventBus.off('hashchange',webViewerHashchange);eventBus.off('beforeprint',_boundEvents.beforePrint);eventBus.off('afterprint',_boundEvents.afterPrint);eventBus.off('pagerendered',webViewerPageRendered);eventBus.off('textlayerrendered',webViewerTextLayerRendered);eventBus.off('updateviewarea',webViewerUpdateViewarea);eventBus.off('pagechanging',webViewerPageChanging);eventBus.off('scalechanging',webViewerScaleChanging);eventBus.off('sidebarviewchanged',webViewerSidebarViewChanged);eventBus.off('pagemode',webViewerPageMode);eventBus.off('namedaction',webViewerNamedAction);eventBus.off('presentationmodechanged',webViewerPresentationModeChanged);eventBus.off('presentationmode',webViewerPresentationMode);eventBus.off('openfile',webViewerOpenFile);eventBus.off('print',webViewerPrint);eventBus.off('download',webViewerDownload);eventBus.off('firstpage',webViewerFirstPage);eventBus.off('lastpage',webViewerLastPage);eventBus.off('nextpage',webViewerNextPage);eventBus.off('previouspage',webViewerPreviousPage);eventBus.off('zoomin',webViewerZoomIn);eventBus.off('zoomout',webViewerZoomOut);eventBus.off('pagenumberchanged',webViewerPageNumberChanged);eventBus.off('scalechanged',webViewerScaleChanged);eventBus.off('rotatecw',webViewerRotateCw);eventBus.off('rotateccw',webViewerRotateCcw);eventBus.off('documentproperties',webViewerDocumentProperties);eventBus.off('find',webViewerFind);eventBus.off('findfromurlhash',webViewerFindFromUrlHash);eventBus.off('fileinputchange',webViewerFileInputChange);_boundEvents.beforePrint=null;_boundEvents.afterPrint=null},unbindWindowEvents:function unbindWindowEvents(){var _boundEvents=this._boundEvents;window.removeEventListener('wheel',webViewerWheel);window.removeEventListener('click',webViewerClick);window.removeEventListener('keydown',webViewerKeyDown);window.removeEventListener('resize',_boundEvents.windowResize);window.removeEventListener('hashchange',_boundEvents.windowHashChange);window.removeEventListener('beforeprint',_boundEvents.windowBeforePrint);window.removeEventListener('afterprint',_boundEvents.windowAfterPrint);window.removeEventListener('change',_boundEvents.windowChange);_boundEvents.windowChange=null;_boundEvents.windowResize=null;_boundEvents.windowHashChange=null;_boundEvents.windowBeforePrint=null;_boundEvents.windowAfterPrint=null}};var validateFileURL=void 0;{var HOSTED_VIEWER_ORIGINS=['null','http://mozilla.github.io','https://mozilla.github.io'];validateFileURL=function validateFileURL(file){if(file===undefined){return}try{var viewerOrigin=new URL(window.location.href).origin||'null';if(HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin)>=0){return}var fileOrigin=new URL(file,window.location.href).origin;if(fileOrigin!==viewerOrigin){throw new Error('file origin does not match viewer\'s');}}catch(ex){var message=ex&&ex.message;PDFViewerApplication.l10n.get('loading_error',null,'An error occurred while loading the PDF.').then(function(loadingErrorMessage){PDFViewerApplication.error(loadingErrorMessage,{message:message})});throw ex;}}}function loadAndEnablePDFBug(enabledTabs){return new Promise(function(resolve,reject){var appConfig=PDFViewerApplication.appConfig;var script=document.createElement('script');script.src=appConfig.debuggerScriptPath;script.onload=function(){PDFBug.enable(enabledTabs);PDFBug.init({PDFJS:_pdfjsLib.PDFJS,OPS:_pdfjsLib.OPS},appConfig.mainContainer);resolve()};script.onerror=function(){reject(new Error('Cannot load debugger at '+script.src))};(document.getElementsByTagName('head')[0]||document.body).appendChild(script)})}function webViewerInitialized(){var appConfig=PDFViewerApplication.appConfig;var file=void 0;var queryString=document.location.search.substring(1);var params=(0,_ui_utils.parseQueryString)(queryString);file='file'in params?params.file:appConfig.defaultUrl;validateFileURL(file);var waitForBeforeOpening=[];var fileInput=document.createElement('input');fileInput.id=appConfig.openFileInputName;fileInput.className='fileInput';fileInput.setAttribute('type','file');fileInput.oncontextmenu=_ui_utils.noContextMenuHandler;document.body.appendChild(fileInput);if(!window.File||!window.FileReader||!window.FileList||!window.Blob){appConfig.toolbar.openFile.setAttribute('hidden','true');appConfig.secondaryToolbar.openFileButton.setAttribute('hidden','true')}else{fileInput.value=null}if(PDFViewerApplication.viewerPrefs['pdfBugEnabled']){var hash=document.location.hash.substring(1);var hashParams=(0,_ui_utils.parseQueryString)(hash);if('disableworker'in hashParams){_pdfjsLib.PDFJS.disableWorker=hashParams['disableworker']==='true'}if('disablerange'in hashParams){_pdfjsLib.PDFJS.disableRange=hashParams['disablerange']==='true'}if('disablestream'in hashParams){_pdfjsLib.PDFJS.disableStream=hashParams['disablestream']==='true'}if('disableautofetch'in hashParams){_pdfjsLib.PDFJS.disableAutoFetch=hashParams['disableautofetch']==='true'}if('disablefontface'in hashParams){_pdfjsLib.PDFJS.disableFontFace=hashParams['disablefontface']==='true'}if('disablehistory'in hashParams){_pdfjsLib.PDFJS.disableHistory=hashParams['disablehistory']==='true'}if('webgl'in hashParams){_pdfjsLib.PDFJS.disableWebGL=hashParams['webgl']!=='true'}if('useonlycsszoom'in hashParams){_pdfjsLib.PDFJS.useOnlyCssZoom=hashParams['useonlycsszoom']==='true'}if('verbosity'in hashParams){_pdfjsLib.PDFJS.verbosity=hashParams['verbosity']|0}if('ignorecurrentpositiononzoom'in hashParams){_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom=hashParams['ignorecurrentpositiononzoom']==='true'}if('textlayer'in hashParams){switch(hashParams['textlayer']){case'off':_pdfjsLib.PDFJS.disableTextLayer=true;break;case'visible':case'shadow':case'hover':var viewer=appConfig.viewerContainer;viewer.classList.add('textLayer-'+hashParams['textlayer']);break}}if('pdfbug'in hashParams){_pdfjsLib.PDFJS.pdfBug=true;var pdfBug=hashParams['pdfbug'];var enabled=pdfBug.split(',');waitForBeforeOpening.push(loadAndEnablePDFBug(enabled))}}if(!PDFViewerApplication.supportsPrinting){appConfig.toolbar.print.classList.add('hidden');appConfig.secondaryToolbar.printButton.classList.add('hidden')}if(!PDFViewerApplication.supportsFullscreen){appConfig.toolbar.presentationModeButton.classList.add('hidden');appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden')}if(PDFViewerApplication.supportsIntegratedFind){appConfig.toolbar.viewFind.classList.add('hidden')}appConfig.sidebar.mainContainer.addEventListener('transitionend',function(evt){if(evt.target===this){PDFViewerApplication.eventBus.dispatch('resize')}},true);appConfig.sidebar.toggleButton.addEventListener('click',function(){PDFViewerApplication.pdfSidebar.toggle()});Promise.all(waitForBeforeOpening).then(function(){webViewerOpenFileViaURL(file)}).catch(function(reason){PDFViewerApplication.l10n.get('loading_error',null,'An error occurred while opening.').then(function(msg){PDFViewerApplication.error(msg,reason)})})}var webViewerOpenFileViaURL=void 0;{webViewerOpenFileViaURL=function webViewerOpenFileViaURL(file){if(file&&file.lastIndexOf('file:',0)===0){PDFViewerApplication.setTitleUsingUrl(file);var xhr=new XMLHttpRequest();xhr.onload=function(){PDFViewerApplication.open(new Uint8Array(xhr.response))};try{xhr.open('GET',file);xhr.responseType='arraybuffer';xhr.send()}catch(ex){PDFViewerApplication.l10n.get('loading_error',null,'An error occurred while loading the PDF.').then(function(msg){PDFViewerApplication.error(msg,ex)})}return}if(file){PDFViewerApplication.open(file)}}}function webViewerPageRendered(evt){var pageNumber=evt.pageNumber;var pageIndex=pageNumber-1;var pageView=PDFViewerApplication.pdfViewer.getPageView(pageIndex);if(pageNumber===PDFViewerApplication.page){PDFViewerApplication.toolbar.updateLoadingIndicatorState(false)}if(!pageView){return}if(PDFViewerApplication.pdfSidebar.isThumbnailViewVisible){var thumbnailView=PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);thumbnailView.setImage(pageView)}if(_pdfjsLib.PDFJS.pdfBug&&Stats.enabled&&pageView.stats){Stats.add(pageNumber,pageView.stats)}if(pageView.error){PDFViewerApplication.l10n.get('rendering_error',null,'An error occurred while rendering the page.').then(function(msg){PDFViewerApplication.error(msg,pageView.error)})}}function webViewerTextLayerRendered(evt){}function webViewerPageMode(evt){var mode=evt.mode,view=void 0;switch(mode){case'thumbs':view=_pdf_sidebar.SidebarView.THUMBS;break;case'bookmarks':case'outline':view=_pdf_sidebar.SidebarView.OUTLINE;break;case'attachments':view=_pdf_sidebar.SidebarView.ATTACHMENTS;break;case'none':view=_pdf_sidebar.SidebarView.NONE;break;default:console.error('Invalid "pagemode" hash parameter: '+mode);return}PDFViewerApplication.pdfSidebar.switchView(view,true)}function webViewerNamedAction(evt){var action=evt.action;switch(action){case'GoToPage':PDFViewerApplication.appConfig.toolbar.pageNumber.select();break;case'Find':if(!PDFViewerApplication.supportsIntegratedFind){PDFViewerApplication.findBar.toggle()}break}}function webViewerPresentationModeChanged(evt){var active=evt.active,switchInProgress=evt.switchInProgress;PDFViewerApplication.pdfViewer.presentationModeState=switchInProgress?_pdf_viewer.PresentationModeState.CHANGING:active?_pdf_viewer.PresentationModeState.FULLSCREEN:_pdf_viewer.PresentationModeState.NORMAL}function webViewerSidebarViewChanged(evt){PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled=PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;var store=PDFViewerApplication.store;if(store&&PDFViewerApplication.isInitialViewSet){store.set('sidebarView',evt.view).catch(function(){})}}function webViewerUpdateViewarea(evt){var location=evt.location,store=PDFViewerApplication.store;if(store&&PDFViewerApplication.isInitialViewSet){store.setMultiple({'exists':true,'page':location.pageNumber,'zoom':location.scale,'scrollLeft':location.left,'scrollTop':location.top}).catch(function(){})}var href=PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);PDFViewerApplication.appConfig.toolbar.viewBookmark.href=href;PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href=href;PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams,location.pageNumber);var currentPage=PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page-1);var loading=currentPage.renderingState!==_pdf_rendering_queue.RenderingStates.FINISHED;PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading)}function webViewerResize(){var pdfDocument=PDFViewerApplication.pdfDocument,pdfViewer=PDFViewerApplication.pdfViewer;if(!pdfDocument){return}var currentScaleValue=pdfViewer.currentScaleValue;if(currentScaleValue==='auto'||currentScaleValue==='page-fit'||currentScaleValue==='page-width'){pdfViewer.currentScaleValue=currentScaleValue}pdfViewer.update()}function webViewerHashchange(evt){if(PDFViewerApplication.pdfHistory.isHashChangeUnlocked){var hash=evt.hash;if(!hash){return}if(!PDFViewerApplication.isInitialViewSet){PDFViewerApplication.initialBookmark=hash}else{PDFViewerApplication.pdfLinkService.setHash(hash)}}}var webViewerFileInputChange=void 0;{webViewerFileInputChange=function webViewerFileInputChange(evt){var file=evt.fileInput.files[0];if(!_pdfjsLib.PDFJS.disableCreateObjectURL&&URL.createObjectURL){PDFViewerApplication.open(URL.createObjectURL(file))}else{var fileReader=new FileReader();fileReader.onload=function webViewerChangeFileReaderOnload(evt){var buffer=evt.target.result;PDFViewerApplication.open(new Uint8Array(buffer))};fileReader.readAsArrayBuffer(file)}PDFViewerApplication.setTitleUsingUrl(file.name);var appConfig=PDFViewerApplication.appConfig;appConfig.toolbar.viewBookmark.setAttribute('hidden','true');appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden','true');appConfig.toolbar.download.setAttribute('hidden','true');appConfig.secondaryToolbar.downloadButton.setAttribute('hidden','true')}}function webViewerPresentationMode(){PDFViewerApplication.requestPresentationMode()}function webViewerOpenFile(){var openFileInputName=PDFViewerApplication.appConfig.openFileInputName;document.getElementById(openFileInputName).click()}function webViewerPrint(){window.print()}function webViewerDownload(){PDFViewerApplication.download()}function webViewerFirstPage(){if(PDFViewerApplication.pdfDocument){PDFViewerApplication.page=1}}function webViewerLastPage(){if(PDFViewerApplication.pdfDocument){PDFViewerApplication.page=PDFViewerApplication.pagesCount}}function webViewerNextPage(){PDFViewerApplication.page++}function webViewerPreviousPage(){PDFViewerApplication.page--}function webViewerZoomIn(){PDFViewerApplication.zoomIn()}function webViewerZoomOut(){PDFViewerApplication.zoomOut()}function webViewerPageNumberChanged(evt){var pdfViewer=PDFViewerApplication.pdfViewer;pdfViewer.currentPageLabel=evt.value;if(evt.value!==pdfViewer.currentPageNumber.toString()&&evt.value!==pdfViewer.currentPageLabel){PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber,pdfViewer.currentPageLabel)}}function webViewerScaleChanged(evt){PDFViewerApplication.pdfViewer.currentScaleValue=evt.value}function webViewerRotateCw(){PDFViewerApplication.rotatePages(90)}function webViewerRotateCcw(){PDFViewerApplication.rotatePages(-90)}function webViewerDocumentProperties(){PDFViewerApplication.pdfDocumentProperties.open()}function webViewerFind(evt){PDFViewerApplication.findController.executeCommand('find'+evt.type,{query:evt.query,phraseSearch:evt.phraseSearch,caseSensitive:evt.caseSensitive,highlightAll:evt.highlightAll,findPrevious:evt.findPrevious})}function webViewerFindFromUrlHash(evt){PDFViewerApplication.findController.executeCommand('find',{query:evt.query,phraseSearch:evt.phraseSearch,caseSensitive:false,highlightAll:true,findPrevious:false})}function webViewerScaleChanging(evt){PDFViewerApplication.toolbar.setPageScale(evt.presetValue,evt.scale);PDFViewerApplication.pdfViewer.update()}function webViewerPageChanging(evt){var page=evt.pageNumber;PDFViewerApplication.toolbar.setPageNumber(page,evt.pageLabel||null);PDFViewerApplication.secondaryToolbar.setPageNumber(page);if(PDFViewerApplication.pdfSidebar.isThumbnailViewVisible){PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page)}if(_pdfjsLib.PDFJS.pdfBug&&Stats.enabled){var pageView=PDFViewerApplication.pdfViewer.getPageView(page-1);if(pageView.stats){Stats.add(page,pageView.stats)}}}var zoomDisabled=false,zoomDisabledTimeout=void 0;function webViewerWheel(evt){var pdfViewer=PDFViewerApplication.pdfViewer;if(pdfViewer.isInPresentationMode){return}if(evt.ctrlKey||evt.metaKey){var support=PDFViewerApplication.supportedMouseWheelZoomModifierKeys;if(evt.ctrlKey&&!support.ctrlKey||evt.metaKey&&!support.metaKey){return}evt.preventDefault();if(zoomDisabled){return}var previousScale=pdfViewer.currentScale;var delta=(0,_ui_utils.normalizeWheelEventDelta)(evt);var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE=3.0;var ticks=delta*MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;if(ticks<0){PDFViewerApplication.zoomOut(-ticks)}else{PDFViewerApplication.zoomIn(ticks)}var currentScale=pdfViewer.currentScale;if(previousScale!==currentScale){var scaleCorrectionFactor=currentScale/previousScale-1;var rect=pdfViewer.container.getBoundingClientRect();var dx=evt.clientX-rect.left;var dy=evt.clientY-rect.top;pdfViewer.container.scrollLeft+=dx*scaleCorrectionFactor;pdfViewer.container.scrollTop+=dy*scaleCorrectionFactor}}else{zoomDisabled=true;clearTimeout(zoomDisabledTimeout);zoomDisabledTimeout=setTimeout(function(){zoomDisabled=false},1000)}}function webViewerClick(evt){if(!PDFViewerApplication.secondaryToolbar.isOpen){return}var appConfig=PDFViewerApplication.appConfig;if(PDFViewerApplication.pdfViewer.containsElement(evt.target)||appConfig.toolbar.container.contains(evt.target)&&evt.target!==appConfig.secondaryToolbar.toggleButton){PDFViewerApplication.secondaryToolbar.close()}}function webViewerKeyDown(evt){if(PDFViewerApplication.overlayManager.active){return}var handled=false,ensureViewerFocused=false;var cmd=(evt.ctrlKey?1:0)|(evt.altKey?2:0)|(evt.shiftKey?4:0)|(evt.metaKey?8:0);var pdfViewer=PDFViewerApplication.pdfViewer;var isViewerInPresentationMode=pdfViewer&&pdfViewer.isInPresentationMode;if(cmd===1||cmd===8||cmd===5||cmd===12){switch(evt.keyCode){case 70:if(!PDFViewerApplication.supportsIntegratedFind){PDFViewerApplication.findBar.open();handled=true}break;case 71:if(!PDFViewerApplication.supportsIntegratedFind){var findState=PDFViewerApplication.findController.state;if(findState){PDFViewerApplication.findController.executeCommand('findagain',{query:findState.query,phraseSearch:findState.phraseSearch,caseSensitive:findState.caseSensitive,highlightAll:findState.highlightAll,findPrevious:cmd===5||cmd===12})}handled=true}break;case 61:case 107:case 187:case 171:if(!isViewerInPresentationMode){PDFViewerApplication.zoomIn()}handled=true;break;case 173:case 109:case 189:if(!isViewerInPresentationMode){PDFViewerApplication.zoomOut()}handled=true;break;case 48:case 96:if(!isViewerInPresentationMode){setTimeout(function(){pdfViewer.currentScaleValue=_ui_utils.DEFAULT_SCALE_VALUE});handled=false}break;case 38:if(isViewerInPresentationMode||PDFViewerApplication.page>1){PDFViewerApplication.page=1;handled=true;ensureViewerFocused=true}break;case 40:if(isViewerInPresentationMode||PDFViewerApplication.page1){PDFViewerApplication.page--}handled=true;break;case 27:if(PDFViewerApplication.secondaryToolbar.isOpen){PDFViewerApplication.secondaryToolbar.close();handled=true}if(!PDFViewerApplication.supportsIntegratedFind&&PDFViewerApplication.findBar.opened){PDFViewerApplication.findBar.close();handled=true}break;case 40:case 34:case 32:if(!isViewerInPresentationMode&&pdfViewer.currentScaleValue!=='page-fit'){break}case 39:if(pdfViewer.isHorizontalScrollbarEnabled){break}case 74:case 78:if(PDFViewerApplication.page1){PDFViewerApplication.page=1;handled=true;ensureViewerFocused=true}break;case 35:if(isViewerInPresentationMode||PDFViewerApplication.page1){PDFViewerApplication.page--}handled=true;break;case 82:PDFViewerApplication.rotatePages(-90);break}}if(!handled&&!isViewerInPresentationMode){if(evt.keyCode>=33&&evt.keyCode<=40||evt.keyCode===32&&curElementTagName!=='BUTTON'){ensureViewerFocused=true}}if(cmd===2){switch(evt.keyCode){case 37:if(isViewerInPresentationMode){PDFViewerApplication.pdfHistory.back();handled=true}break;case 39:if(isViewerInPresentationMode){PDFViewerApplication.pdfHistory.forward();handled=true}break}}if(ensureViewerFocused&&!pdfViewer.containsElement(curElement)){pdfViewer.focus()}if(handled){evt.preventDefault()}}function apiPageModeToSidebarView(mode){switch(mode){case'UseNone':return _pdf_sidebar.SidebarView.NONE;case'UseThumbs':return _pdf_sidebar.SidebarView.THUMBS;case'UseOutlines':return _pdf_sidebar.SidebarView.OUTLINE;case'UseAttachments':return _pdf_sidebar.SidebarView.ATTACHMENTS;case'UseOC':}return _pdf_sidebar.SidebarView.NONE}var PDFPrintServiceFactory={instance:{supportsPrinting:false,createPrintService:function createPrintService(){throw new Error('Not implemented: createPrintService');}}};exports.PDFViewerApplication=PDFViewerApplication;exports.DefaultExternalServices=DefaultExternalServices;exports.PDFPrintServiceFactory=PDFPrintServiceFactory}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SimpleLinkService=exports.PDFLinkService=undefined;var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:{},eventBus=_ref.eventBus;_classCallCheck(this,PDFLinkService);this.eventBus=eventBus||(0,_dom_events.getGlobalEventBus)();this.baseUrl=null;this.pdfDocument=null;this.pdfViewer=null;this.pdfHistory=null;this._pagesRefCache=null}_createClass(PDFLinkService,[{key:'setDocument',value:function setDocument(pdfDocument,baseUrl){this.baseUrl=baseUrl;this.pdfDocument=pdfDocument;this._pagesRefCache=Object.create(null)}},{key:'setViewer',value:function setViewer(pdfViewer){this.pdfViewer=pdfViewer}},{key:'setHistory',value:function setHistory(pdfHistory){this.pdfHistory=pdfHistory}},{key:'navigateTo',value:function navigateTo(dest){var _this=this;var goToDestination=function goToDestination(_ref2){var namedDest=_ref2.namedDest,explicitDest=_ref2.explicitDest;var destRef=explicitDest[0],pageNumber=void 0;if(destRef instanceof Object){pageNumber=_this._cachedPageNumber(destRef);if(pageNumber===null){_this.pdfDocument.getPageIndex(destRef).then(function(pageIndex){_this.cachePageRef(pageIndex+1,destRef);goToDestination({namedDest:namedDest,explicitDest:explicitDest})}).catch(function(){console.error('PDFLinkService.navigateTo: "'+destRef+'" is not '+('a valid page reference, for dest="'+dest+'".'))});return}}else if((destRef|0)===destRef){pageNumber=destRef+1}else{console.error('PDFLinkService.navigateTo: "'+destRef+'" is not '+('a valid destination reference, for dest="'+dest+'".'));return}if(!pageNumber||pageNumber<1||pageNumber>_this.pagesCount){console.error('PDFLinkService.navigateTo: "'+pageNumber+'" is not '+('a valid page number, for dest="'+dest+'".'));return}_this.pdfViewer.scrollPageIntoView({pageNumber:pageNumber,destArray:explicitDest});if(_this.pdfHistory){_this.pdfHistory.push({dest:explicitDest,hash:namedDest,page:pageNumber})}};new Promise(function(resolve,reject){if(typeof dest==='string'){_this.pdfDocument.getDestination(dest).then(function(destArray){resolve({namedDest:dest,explicitDest:destArray})});return}resolve({namedDest:'',explicitDest:dest})}).then(function(data){if(!(data.explicitDest instanceof Array)){console.error('PDFLinkService.navigateTo: "'+data.explicitDest+'" is'+(' not a valid destination array, for dest="'+dest+'".'));return}goToDestination(data)})}},{key:'getDestinationHash',value:function getDestinationHash(dest){if(typeof dest==='string'){return this.getAnchorUrl('#'+escape(dest))}if(dest instanceof Array){var str=JSON.stringify(dest);return this.getAnchorUrl('#'+escape(str))}return this.getAnchorUrl('')}},{key:'getAnchorUrl',value:function getAnchorUrl(anchor){return(this.baseUrl||'')+anchor}},{key:'setHash',value:function setHash(hash){var pageNumber=void 0,dest=void 0;if(hash.indexOf('=')>=0){var params=(0,_ui_utils.parseQueryString)(hash);if('search'in params){this.eventBus.dispatch('findfromurlhash',{source:this,query:params['search'].replace(/"/g,''),phraseSearch:params['phrase']==='true'})}if('nameddest'in params){if(this.pdfHistory){this.pdfHistory.updateNextHashParam(params.nameddest)}this.navigateTo(params.nameddest);return}if('page'in params){pageNumber=params.page|0||1}if('zoom'in params){var zoomArgs=params.zoom.split(',');var zoomArg=zoomArgs[0];var zoomArgNumber=parseFloat(zoomArg);if(zoomArg.indexOf('Fit')===-1){dest=[null,{name:'XYZ'},zoomArgs.length>1?zoomArgs[1]|0:null,zoomArgs.length>2?zoomArgs[2]|0:null,zoomArgNumber?zoomArgNumber/100:zoomArg]}else{if(zoomArg==='Fit'||zoomArg==='FitB'){dest=[null,{name:zoomArg}]}else if(zoomArg==='FitH'||zoomArg==='FitBH'||zoomArg==='FitV'||zoomArg==='FitBV'){dest=[null,{name:zoomArg},zoomArgs.length>1?zoomArgs[1]|0:null]}else if(zoomArg==='FitR'){if(zoomArgs.length!==5){console.error('PDFLinkService.setHash: Not enough parameters for "FitR".')}else{dest=[null,{name:zoomArg},zoomArgs[1]|0,zoomArgs[2]|0,zoomArgs[3]|0,zoomArgs[4]|0]}}else{console.error('PDFLinkService.setHash: "'+zoomArg+'" is not '+'a valid zoom value.')}}}if(dest){this.pdfViewer.scrollPageIntoView({pageNumber:pageNumber||this.page,destArray:dest,allowNegativeOffset:true})}else if(pageNumber){this.page=pageNumber}if('pagemode'in params){this.eventBus.dispatch('pagemode',{source:this,mode:params.pagemode})}}else{if(/^\d+$/.test(hash)&&hash<=this.pagesCount){console.warn('PDFLinkService_setHash: specifying a page number '+'directly after the hash symbol (#) is deprecated, '+('please use the "#page='+hash+'" form instead.'));this.page=hash|0}dest=unescape(hash);try{dest=JSON.parse(dest);if(!(dest instanceof Array)){dest=dest.toString()}}catch(ex){}if(typeof dest==='string'||isValidExplicitDestination(dest)){if(this.pdfHistory){this.pdfHistory.updateNextHashParam(dest)}this.navigateTo(dest);return}console.error('PDFLinkService.setHash: "'+unescape(hash)+'" is not '+'a valid destination.')}}},{key:'executeNamedAction',value:function executeNamedAction(action){switch(action){case'GoBack':if(this.pdfHistory){this.pdfHistory.back()}break;case'GoForward':if(this.pdfHistory){this.pdfHistory.forward()}break;case'NextPage':if(this.page1){this.page--}break;case'LastPage':this.page=this.pagesCount;break;case'FirstPage':this.page=1;break;default:break}this.eventBus.dispatch('namedaction',{source:this,action:action})}},{key:'onFileAttachmentAnnotation',value:function onFileAttachmentAnnotation(_ref3){var id=_ref3.id,filename=_ref3.filename,content=_ref3.content;this.eventBus.dispatch('fileattachmentannotation',{source:this,id:id,filename:filename,content:content})}},{key:'cachePageRef',value:function cachePageRef(pageNum,pageRef){var refStr=pageRef.num+' '+pageRef.gen+' R';this._pagesRefCache[refStr]=pageNum}},{key:'_cachedPageNumber',value:function _cachedPageNumber(pageRef){var refStr=pageRef.num+' '+pageRef.gen+' R';return this._pagesRefCache&&this._pagesRefCache[refStr]||null}},{key:'pagesCount',get:function get(){return this.pdfDocument?this.pdfDocument.numPages:0}},{key:'page',get:function get(){return this.pdfViewer.currentPageNumber},set:function set(value){this.pdfViewer.currentPageNumber=value}}]);return PDFLinkService}();function isValidExplicitDestination(dest){if(!(dest instanceof Array)){return false}var destLength=dest.length,allowNull=true;if(destLength<2){return false}var page=dest[0];if(!((typeof page==='undefined'?'undefined':_typeof(page))==='object'&&typeof page.num==='number'&&(page.num|0)===page.num&&typeof page.gen==='number'&&(page.gen|0)===page.gen)&&!(typeof page==='number'&&(page|0)===page&&page>=0)){return false}var zoom=dest[1];if(!((typeof zoom==='undefined'?'undefined':_typeof(zoom))==='object'&&typeof zoom.name==='string')){return false}switch(zoom.name){case'XYZ':if(destLength!==5){return false}break;case'Fit':case'FitB':return destLength===2;case'FitH':case'FitBH':case'FitV':case'FitBV':if(destLength!==3){return false}break;case'FitR':if(destLength!==6){return false}allowNull=false;break;default:return false}for(var i=2;i=0;i--){var prevElem=matchesWithLength[i];if(prevElem.skipped){continue}if(prevElem.match+prevElem.matchLength=currentElem.match+currentElem.matchLength){currentElem.skipped=true;return true}}return false}matchesWithLength.sort(function(a,b){return a.match===b.match?a.matchLength-b.matchLength:a.match-b.match});for(var i=0,len=matchesWithLength.length;i0){this.matchCount+=this.pageMatches[pageIndex].length;this.updateUIResultsCount()}}},{key:'extractText',value:function extractText(){var _this2=this;if(this.startedTextExtraction){return}this.startedTextExtraction=true;this.pageContents.length=0;var promise=Promise.resolve();var _loop=function _loop(i,ii){var extractTextCapability=(0,_pdfjsLib.createPromiseCapability)();_this2.extractTextPromises[i]=extractTextCapability.promise;promise=promise.then(function(){return _this2.pdfViewer.getPageTextContent(i).then(function(textContent){var textItems=textContent.items;var strBuf=[];for(var j=0,jj=textItems.length;j0){this.hadMatch=true;offset.matchIdx=previous?offset.matchIdx-1:offset.matchIdx+1;this.updateMatch(true);return}this.advanceOffsetPage(previous)}this.nextPageMatch()}},{key:'matchesReady',value:function matchesReady(matches){var offset=this.offset;var numMatches=matches.length;var previous=this.state.findPrevious;if(numMatches){this.hadMatch=true;offset.matchIdx=previous?numMatches-1:0;this.updateMatch(true);return true}this.advanceOffsetPage(previous);if(offset.wrapped){offset.matchIdx=null;if(this.pagesToSearch<0){this.updateMatch(false);return true}}return false}},{key:'updateMatchPosition',value:function updateMatchPosition(pageIndex,matchIndex,elements,beginIdx){if(this.selected.matchIdx===matchIndex&&this.selected.pageIdx===pageIndex){var spot={top:FIND_SCROLL_OFFSET_TOP,left:FIND_SCROLL_OFFSET_LEFT};(0,_ui_utils.scrollIntoView)(elements[beginIdx],spot,true)}}},{key:'nextPageMatch',value:function nextPageMatch(){if(this.resumePageIdx!==null){console.error('There can only be one pending page.')}var matches=null;do{var pageIdx=this.offset.pageIdx;matches=this.pageMatches[pageIdx];if(!matches){this.resumePageIdx=pageIdx;break}}while(!this.matchesReady(matches))}},{key:'advanceOffsetPage',value:function advanceOffsetPage(previous){var offset=this.offset;var numPages=this.extractTextPromises.length;offset.pageIdx=previous?offset.pageIdx-1:offset.pageIdx+1;offset.matchIdx=null;this.pagesToSearch--;if(offset.pageIdx>=numPages||offset.pageIdx<0){offset.pageIdx=previous?numPages-1:0;offset.wrapped=true}}},{key:'updateMatch',value:function updateMatch(){var found=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var state=FindState.NOT_FOUND;var wrapped=this.offset.wrapped;this.offset.wrapped=false;if(found){var previousPage=this.selected.pageIdx;this.selected.pageIdx=this.offset.pageIdx;this.selected.matchIdx=this.offset.matchIdx;state=wrapped?FindState.WRAPPED:FindState.FOUND;if(previousPage!==-1&&previousPage!==this.selected.pageIdx){this.updatePage(previousPage)}}this.updateUIState(state,this.state.findPrevious);if(this.selected.pageIdx!==-1){this.updatePage(this.selected.pageIdx)}}},{key:'updateUIResultsCount',value:function updateUIResultsCount(){if(this.onUpdateResultsCount){this.onUpdateResultsCount(this.matchCount)}}},{key:'updateUIState',value:function updateUIState(state,previous){if(this.onUpdateState){this.onUpdateState(state,previous,this.matchCount)}}}]);return PDFFindController}();exports.FindState=FindState;exports.PDFFindController=PDFFindController}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.GenericCom=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i=pageCount){renderProgress(pageCount,pageCount,_this.l10n);resolve();return}var index=_this.currentPage;renderProgress(index,pageCount,_this.l10n);renderPage(_this,_this.pdfDocument,index+1,_this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function(){renderNextPage(resolve,reject)},reject)};return new Promise(renderNextPage)},useRenderedPage:function useRenderedPage(printItem){this.throwIfInactive();var img=document.createElement('img');img.style.width=printItem.width;img.style.height=printItem.height;var scratchCanvas=this.scratchCanvas;if('toBlob'in scratchCanvas&&!_pdfjsLib.PDFJS.disableCreateObjectURL){scratchCanvas.toBlob(function(blob){img.src=URL.createObjectURL(blob)})}else{img.src=scratchCanvas.toDataURL()}var wrapper=document.createElement('div');wrapper.appendChild(img);this.printContainer.appendChild(wrapper);return new Promise(function(resolve,reject){img.onload=resolve;img.onerror=reject})},performPrint:function performPrint(){var _this2=this;this.throwIfInactive();return new Promise(function(resolve){setTimeout(function(){if(!_this2.active){resolve();return}print.call(window);setTimeout(resolve,20)},0)})},get active(){return this===activeService},throwIfInactive:function throwIfInactive(){if(!this.active){throw new Error('This print request was cancelled or completed.');}}};var print=window.print;window.print=function print(){if(activeService){console.warn('Ignored window.print() because of a pending print job.');return}ensureOverlay().then(function(){if(activeService){overlayManager.open('printServiceOverlay')}});try{dispatchEvent('beforeprint')}finally{if(!activeService){console.error('Expected print service to be initialized.');ensureOverlay().then(function(){if(overlayManager.active==='printServiceOverlay'){overlayManager.close('printServiceOverlay')}});return}var activeServiceOnEntry=activeService;activeService.renderPages().then(function(){return activeServiceOnEntry.performPrint()}).catch(function(){}).then(function(){if(activeServiceOnEntry.active){abort()}})}};function dispatchEvent(eventType){var event=document.createEvent('CustomEvent');event.initCustomEvent(eventType,false,false,'custom');window.dispatchEvent(event)}function abort(){if(activeService){activeService.destroy();dispatchEvent('afterprint')}}function renderProgress(index,total,l10n){var progressContainer=document.getElementById('printServiceOverlay');var progress=Math.round(100*index/total);var progressBar=progressContainer.querySelector('progress');var progressPerc=progressContainer.querySelector('.relative-progress');progressBar.value=progress;l10n.get('print_progress_percent',{progress:progress},progress+'%').then(function(msg){progressPerc.textContent=msg})}var hasAttachEvent=!!document.attachEvent;window.addEventListener('keydown',function(event){if(event.keyCode===80&&(event.ctrlKey||event.metaKey)&&!event.altKey&&(!event.shiftKey||window.chrome||window.opera)){window.print();if(hasAttachEvent){return}event.preventDefault();if(event.stopImmediatePropagation){event.stopImmediatePropagation()}else{event.stopPropagation()}return}},true);if(hasAttachEvent){document.attachEvent('onkeydown',function(event){event=event||window.event;if(event.keyCode===80&&event.ctrlKey){event.keyCode=0;return false}})}if('onbeforeprint'in window){var stopPropagationIfNeeded=function stopPropagationIfNeeded(event){if(event.detail!=='custom'&&event.stopImmediatePropagation){event.stopImmediatePropagation()}};window.addEventListener('beforeprint',stopPropagationIfNeeded);window.addEventListener('afterprint',stopPropagationIfNeeded)}var overlayPromise;function ensureOverlay(){if(!overlayPromise){overlayManager=_app.PDFViewerApplication.overlayManager;if(!overlayManager){throw new Error('The overlay manager has not yet been initialized.');}overlayPromise=overlayManager.register('printServiceOverlay',document.getElementById('printServiceOverlay'),abort,true);document.getElementById('printCancel').onclick=abort}return overlayPromise}_app.PDFPrintServiceFactory.instance={supportsPrinting:true,createPrintService:function createPrintService(pdfDocument,pagesOverview,printContainer,l10n){if(activeService){throw new Error('The print service is created and active.');}activeService=new PDFPrintService(pdfDocument,pagesOverview,printContainer,l10n);return activeService}};exports.PDFPrintService=PDFPrintService}),(function(module,exports,__webpack_require__){"use strict";document.webL10n=function(window,document,undefined){var gL10nData={};var gTextData='';var gTextProp='textContent';var gLanguage='';var gMacros={};var gReadyState='loading';var gAsyncResourceLoading=true;function getL10nResourceLinks(){return document.querySelectorAll('link[type="application/l10n"]')}function getL10nDictionary(){var script=document.querySelector('script[type="application/l10n"]');return script?JSON.parse(script.innerHTML):null}function getTranslatableChildren(element){return element?element.querySelectorAll('*[data-l10n-id]'):[]}function getL10nAttributes(element){if(!element)return{};var l10nId=element.getAttribute('data-l10n-id');var l10nArgs=element.getAttribute('data-l10n-args');var args={};if(l10nArgs){try{args=JSON.parse(l10nArgs)}catch(e){console.warn('could not parse arguments for #'+l10nId)}}return{id:l10nId,args:args}}function fireL10nReadyEvent(lang){var evtObject=document.createEvent('Event');evtObject.initEvent('localized',true,false);evtObject.language=lang;document.dispatchEvent(evtObject)}function xhrLoadText(url,onSuccess,onFailure){onSuccess=onSuccess||function _onSuccess(data){};onFailure=onFailure||function _onFailure(){};var xhr=new XMLHttpRequest();xhr.open('GET',url,gAsyncResourceLoading);if(xhr.overrideMimeType){xhr.overrideMimeType('text/plain; charset=utf-8')}xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status==200||xhr.status===0){onSuccess(xhr.responseText)}else{onFailure()}}};xhr.onerror=onFailure;xhr.ontimeout=onFailure;try{xhr.send(null)}catch(e){onFailure()}}function parseResource(href,lang,successCallback,failureCallback){var baseURL=href.replace(/[^\/]*$/,'')||'./';function evalString(text){if(text.lastIndexOf('\\')<0)return text;return text.replace(/\\\\/g,'\\').replace(/\\n/g,'\n').replace(/\\r/g,'\r').replace(/\\t/g,'\t').replace(/\\b/g,'\b').replace(/\\f/g,'\f').replace(/\\{/g,'{').replace(/\\}/g,'}').replace(/\\"/g,'"').replace(/\\'/g,"'")}function parseProperties(text,parsedPropertiesCallback){var dictionary={};var reBlank=/^\s*|\s*$/;var reComment=/^\s*#|^\s*$/;var reSection=/^\s*\[(.*)\]\s*$/;var reImport=/^\s*@import\s+url\((.*)\)\s*$/i;var reSplit=/^([^=\s]*)\s*=\s*(.+)$/;function parseRawLines(rawText,extendedSyntax,parsedRawLinesCallback){var entries=rawText.replace(reBlank,'').split(/[\r\n]+/);var currentLang='*';var genericLang=lang.split('-',1)[0];var skipLang=false;var match='';function nextEntry(){while(true){if(!entries.length){parsedRawLinesCallback();return}var line=entries.shift();if(reComment.test(line))continue;if(extendedSyntax){match=reSection.exec(line);if(match){currentLang=match[1].toLowerCase();skipLang=currentLang!=='*'&¤tLang!==lang&¤tLang!==genericLang;continue}else if(skipLang){continue}match=reImport.exec(line);if(match){loadImport(baseURL+match[1],nextEntry);return}}var tmp=line.match(reSplit);if(tmp&&tmp.length==3){dictionary[tmp[1]]=evalString(tmp[2])}}}nextEntry()}function loadImport(url,callback){xhrLoadText(url,function(content){parseRawLines(content,false,callback)},function(){console.warn(url+' not found.');callback()})}parseRawLines(text,true,function(){parsedPropertiesCallback(dictionary)})}xhrLoadText(href,function(response){gTextData+=response;parseProperties(response,function(data){for(var key in data){var id,prop,index=key.lastIndexOf('.');if(index>0){id=key.substring(0,index);prop=key.substr(index+1)}else{id=key;prop=gTextProp}if(!gL10nData[id]){gL10nData[id]={}}gL10nData[id][prop]=data[key]}if(successCallback){successCallback()}})},failureCallback)}function loadLocale(lang,callback){if(lang){lang=lang.toLowerCase()}callback=callback||function _callback(){};clear();gLanguage=lang;var langLinks=getL10nResourceLinks();var langCount=langLinks.length;if(langCount===0){var dict=getL10nDictionary();if(dict&&dict.locales&&dict.default_locale){console.log('using the embedded JSON directory, early way out');gL10nData=dict.locales[lang];if(!gL10nData){var defaultLocale=dict.default_locale.toLowerCase();for(var anyCaseLang in dict.locales){anyCaseLang=anyCaseLang.toLowerCase();if(anyCaseLang===lang){gL10nData=dict.locales[lang];break}else if(anyCaseLang===defaultLocale){gL10nData=dict.locales[defaultLocale]}}}callback()}else{console.log('no resource to load, early way out')}fireL10nReadyEvent(lang);gReadyState='complete';return}var onResourceLoaded=null;var gResourceCount=0;onResourceLoaded=function onResourceLoaded(){gResourceCount++;if(gResourceCount>=langCount){callback();fireL10nReadyEvent(lang);gReadyState='complete'}};function L10nResourceLink(link){var href=link.href;this.load=function(lang,callback){parseResource(href,lang,callback,function(){console.warn(href+' not found.');console.warn('"'+lang+'" resource not found');gLanguage='';callback()})}}for(var i=0;i0){prop=key.substr(index+1);key=key.substring(0,index)}var fallback;if(fallbackString){fallback={};fallback[prop]=fallbackString}var data=getL10nData(key,args,fallback);if(data&&prop in data){return data[prop]}return'{{'+key+'}}'},getData:function getData(){return gL10nData},getText:function getText(){return gTextData},getLanguage:function getLanguage(){return gLanguage},setLanguage:function setLanguage(lang,callback){loadLocale(lang,function(){if(callback)callback()})},getDirection:function getDirection(){var rtlList=['ar','he','fa','ps','ur'];var shortCode=gLanguage.split('-',1)[0];return rtlList.indexOf(shortCode)>=0?'rtl':'ltr'},translate:translateFragment,getReadyState:function getReadyState(){return gReadyState},ready:function ready(callback){if(!callback){return}else if(gReadyState=='complete'||gReadyState=='interactive'){window.setTimeout(function(){callback()})}else if(document.addEventListener){document.addEventListener('localized',function once(){document.removeEventListener('localized',once);callback()})}}}}(window,document)}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DefaultAnnotationLayerFactory=exports.AnnotationLayerBuilder=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i1&&arguments[1]!==undefined?arguments[1]:'display';this.pdfPage.getAnnotations({intent:intent}).then(function(annotations){var parameters={viewport:viewport.clone({dontFlip:true}),div:_this.div,annotations:annotations,page:_this.pdfPage,renderInteractiveForms:_this.renderInteractiveForms,linkService:_this.linkService,downloadManager:_this.downloadManager};if(_this.div){_pdfjsLib.AnnotationLayer.update(parameters)}else{if(annotations.length===0){return}_this.div=document.createElement('div');_this.div.className='annotationLayer';_this.pageDiv.appendChild(_this.div);parameters.div=_this.div;_pdfjsLib.AnnotationLayer.render(parameters);_this.l10n.translate(_this.div)}})}},{key:'hide',value:function hide(){if(!this.div){return}this.div.setAttribute('hidden','true')}}]);return AnnotationLayerBuilder}();var DefaultAnnotationLayerFactory=function(){function DefaultAnnotationLayerFactory(){_classCallCheck(this,DefaultAnnotationLayerFactory)}_createClass(DefaultAnnotationLayerFactory,[{key:'createAnnotationLayerBuilder',value:function createAnnotationLayerBuilder(pageDiv,pdfPage){var renderInteractiveForms=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var l10n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:_ui_utils.NullL10n;return new AnnotationLayerBuilder({pageDiv:pageDiv,pdfPage:pdfPage,renderInteractiveForms:renderInteractiveForms,linkService:new _pdf_link_service.SimpleLinkService(),l10n:l10n})}}]);return DefaultAnnotationLayerFactory}();exports.AnnotationLayerBuilder=AnnotationLayerBuilder;exports.DefaultAnnotationLayerFactory=DefaultAnnotationLayerFactory}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DownloadManager=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i9;var chrome=window.chrome;var isChrome15OrOpera15plus=chrome&&(chrome.webstore||chrome.app);var isSafari6plus=/Apple/.test(navigator.vendor)&&/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);function isLeftMouseReleased(event){if('buttons'in event&&isNotIEorIsIE10plus){return!(event.buttons&1)}if(isChrome15OrOpera15plus||isSafari6plus){return event.which===0}}exports.GrabToPan=GrabToPan}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i2&&arguments[2]!==undefined?arguments[2]:null;var canForceClose=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return new Promise(function(resolve){var container=void 0;if(!name||!element||!(container=element.parentNode)){throw new Error('Not enough parameters.');}else if(_this._overlays[name]){throw new Error('The overlay is already registered.');}_this._overlays[name]={element:element,container:container,callerCloseMethod:callerCloseMethod,canForceClose:canForceClose};resolve()})}},{key:'unregister',value:function unregister(name){var _this2=this;return new Promise(function(resolve){if(!_this2._overlays[name]){throw new Error('The overlay does not exist.');}else if(_this2._active===name){throw new Error('The overlay cannot be removed while it is active.');}delete _this2._overlays[name];resolve()})}},{key:'open',value:function open(name){var _this3=this;return new Promise(function(resolve){if(!_this3._overlays[name]){throw new Error('The overlay does not exist.');}else if(_this3._active){if(_this3._overlays[name].canForceClose){_this3._closeThroughCaller()}else if(_this3._active===name){throw new Error('The overlay is already active.');}else{throw new Error('Another overlay is currently active.');}}_this3._active=name;_this3._overlays[_this3._active].element.classList.remove('hidden');_this3._overlays[_this3._active].container.classList.remove('hidden');window.addEventListener('keydown',_this3._keyDownBound);resolve()})}},{key:'close',value:function close(name){var _this4=this;return new Promise(function(resolve){if(!_this4._overlays[name]){throw new Error('The overlay does not exist.');}else if(!_this4._active){throw new Error('The overlay is currently not active.');}else if(_this4._active!==name){throw new Error('Another overlay is currently active.');}_this4._overlays[_this4._active].container.classList.add('hidden');_this4._overlays[_this4._active].element.classList.add('hidden');_this4._active=null;window.removeEventListener('keydown',_this4._keyDownBound);resolve()})}},{key:'_keyDown',value:function _keyDown(evt){if(this._active&&evt.keyCode===27){this._closeThroughCaller();evt.preventDefault()}}},{key:'_closeThroughCaller',value:function _closeThroughCaller(){if(this._overlays[this._active].callerCloseMethod){this._overlays[this._active].callerCloseMethod()}if(this._active){this.close(this._active)}}},{key:'active',get:function get(){return this._active}}]);return OverlayManager}();exports.OverlayManager=OverlayManager}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PasswordPrompt=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i2&&arguments[2]!==undefined?arguments[2]:_ui_utils.NullL10n;_classCallCheck(this,PasswordPrompt);this.overlayName=options.overlayName;this.container=options.container;this.label=options.label;this.input=options.input;this.submitButton=options.submitButton;this.cancelButton=options.cancelButton;this.overlayManager=overlayManager;this.l10n=l10n;this.updateCallback=null;this.reason=null;this.submitButton.addEventListener('click',this.verify.bind(this));this.cancelButton.addEventListener('click',this.close.bind(this));this.input.addEventListener('keydown',function(e){if(e.keyCode===13){_this.verify()}});this.overlayManager.register(this.overlayName,this.container,this.close.bind(this),true)}_createClass(PasswordPrompt,[{key:'open',value:function open(){var _this2=this;this.overlayManager.open(this.overlayName).then(function(){_this2.input.focus();var promptString=void 0;if(_this2.reason===_pdfjsLib.PasswordResponses.INCORRECT_PASSWORD){promptString=_this2.l10n.get('password_invalid',null,'Invalid password. Please try again.')}else{promptString=_this2.l10n.get('password_label',null,'Enter the password to open this PDF file.')}promptString.then(function(msg){_this2.label.textContent=msg})})}},{key:'close',value:function close(){var _this3=this;this.overlayManager.close(this.overlayName).then(function(){_this3.input.value=''})}},{key:'verify',value:function verify(){var password=this.input.value;if(password&&password.length>0){this.close();return this.updateCallback(password)}}},{key:'setUpdateCallback',value:function setUpdateCallback(updateCallback,reason){this.updateCallback=updateCallback;this.reason=reason}}]);return PasswordPrompt}();exports.PasswordPrompt=PasswordPrompt}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFAttachmentViewer=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:false;this.attachments=null;this.container.textContent='';if(!keepRenderedCapability){this._renderedCapability=(0,_pdfjsLib.createPromiseCapability)()}}},{key:'_dispatchEvent',value:function _dispatchEvent(attachmentsCount){this.eventBus.dispatch('attachmentsloaded',{source:this,attachmentsCount:attachmentsCount});this._renderedCapability.resolve()}},{key:'_bindPdfLink',value:function _bindPdfLink(button,content,filename){if(_pdfjsLib.PDFJS.disableCreateObjectURL){throw new Error('bindPdfLink: '+'Unsupported "PDFJS.disableCreateObjectURL" value.');}var blobUrl=void 0;button.onclick=function(){if(!blobUrl){blobUrl=(0,_pdfjsLib.createObjectURL)(content,'application/pdf')}var viewerUrl=void 0;viewerUrl='?file='+encodeURIComponent(blobUrl+'#'+filename);window.open(viewerUrl);return false}}},{key:'_bindLink',value:function _bindLink(button,content,filename){var _this=this;button.onclick=function(){_this.downloadManager.downloadData(content,filename,'');return false}}},{key:'render',value:function render(_ref2){var attachments=_ref2.attachments,_ref2$keepRenderedCap=_ref2.keepRenderedCapability,keepRenderedCapability=_ref2$keepRenderedCap===undefined?false:_ref2$keepRenderedCap;var attachmentsCount=0;if(this.attachments){this.reset(keepRenderedCapability===true)}this.attachments=attachments||null;if(!attachments){this._dispatchEvent(attachmentsCount);return}var names=Object.keys(attachments).sort(function(a,b){return a.toLowerCase().localeCompare(b.toLowerCase())});attachmentsCount=names.length;for(var i=0;i2&&arguments[2]!==undefined?arguments[2]:_ui_utils.NullL10n;_classCallCheck(this,PDFDocumentProperties);this.overlayName=overlayName;this.fields=fields;this.container=container;this.overlayManager=overlayManager;this.l10n=l10n;this._reset();if(closeButton){closeButton.addEventListener('click',this.close.bind(this))}this.overlayManager.register(this.overlayName,this.container,this.close.bind(this))}_createClass(PDFDocumentProperties,[{key:'open',value:function open(){var _this=this;var freezeFieldData=function freezeFieldData(data){Object.defineProperty(_this,'fieldData',{value:Object.freeze(data),writable:false,enumerable:true,configurable:true})};Promise.all([this.overlayManager.open(this.overlayName),this._dataAvailableCapability.promise]).then(function(){if(_this.fieldData){_this._updateUI();return}_this.pdfDocument.getMetadata().then(function(_ref2){var info=_ref2.info,metadata=_ref2.metadata;return Promise.all([info,metadata,_this._parseFileSize(_this.maybeFileSize),_this._parseDate(info.CreationDate),_this._parseDate(info.ModDate)])}).then(function(_ref3){var _ref4=_slicedToArray(_ref3,5),info=_ref4[0],metadata=_ref4[1],fileSize=_ref4[2],creationDate=_ref4[3],modificationDate=_ref4[4];freezeFieldData({'fileName':(0,_ui_utils.getPDFFileNameFromURL)(_this.url),'fileSize':fileSize,'title':info.Title,'author':info.Author,'subject':info.Subject,'keywords':info.Keywords,'creationDate':creationDate,'modificationDate':modificationDate,'creator':info.Creator,'producer':info.Producer,'version':info.PDFFormatVersion,'pageCount':_this.pdfDocument.numPages});_this._updateUI();return _this.pdfDocument.getDownloadInfo()}).then(function(_ref5){var length=_ref5.length;return _this._parseFileSize(length)}).then(function(fileSize){var data=(0,_ui_utils.cloneObj)(_this.fieldData);data['fileSize']=fileSize;freezeFieldData(data);_this._updateUI()})})}},{key:'close',value:function close(){this.overlayManager.close(this.overlayName)}},{key:'setDocument',value:function setDocument(pdfDocument,url){if(this.pdfDocument){this._reset();this._updateUI(true)}if(!pdfDocument){return}this.pdfDocument=pdfDocument;this.url=url;this._dataAvailableCapability.resolve()}},{key:'setFileSize',value:function setFileSize(fileSize){if(typeof fileSize==='number'&&fileSize>0){this.maybeFileSize=fileSize}}},{key:'_reset',value:function _reset(){this.pdfDocument=null;this.url=null;this.maybeFileSize=0;delete this.fieldData;this._dataAvailableCapability=(0,_pdfjsLib.createPromiseCapability)()}},{key:'_updateUI',value:function _updateUI(){var reset=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(reset||!this.fieldData){for(var id in this.fields){this.fields[id].textContent=DEFAULT_FIELD_CONTENT}return}if(this.overlayManager.active!==this.overlayName){return}for(var _id in this.fields){var content=this.fieldData[_id];this.fields[_id].textContent=content||content===0?content:DEFAULT_FIELD_CONTENT}}},{key:'_parseFileSize',value:function _parseFileSize(){var fileSize=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var kb=fileSize/1024;if(!kb){return Promise.resolve(undefined)}else if(kb<1024){return this.l10n.get('document_properties_kb',{size_kb:(+kb.toPrecision(3)).toLocaleString(),size_b:fileSize.toLocaleString()},'{{size_kb}} KB ({{size_b}} bytes)')}return this.l10n.get('document_properties_mb',{size_mb:(+(kb/1024).toPrecision(3)).toLocaleString(),size_b:fileSize.toLocaleString()},'{{size_mb}} MB ({{size_b}} bytes)')}},{key:'_parseDate',value:function _parseDate(inputDate){if(!inputDate){return}var dateToParse=inputDate;if(dateToParse.substring(0,2)==='D:'){dateToParse=dateToParse.substring(2)}var year=parseInt(dateToParse.substring(0,4),10);var month=parseInt(dateToParse.substring(4,6),10)-1;var day=parseInt(dateToParse.substring(6,8),10);var hours=parseInt(dateToParse.substring(8,10),10);var minutes=parseInt(dateToParse.substring(10,12),10);var seconds=parseInt(dateToParse.substring(12,14),10);var utRel=dateToParse.substring(14,15);var offsetHours=parseInt(dateToParse.substring(15,17),10);var offsetMinutes=parseInt(dateToParse.substring(18,20),10);if(utRel==='-'){hours+=offsetHours;minutes+=offsetMinutes}else if(utRel==='+'){hours-=offsetHours;minutes-=offsetMinutes}var date=new Date(Date.UTC(year,month,day,hours,minutes,seconds));var dateString=date.toLocaleDateString();var timeString=date.toLocaleTimeString();return this.l10n.get('document_properties_date_string',{date:dateString,time:timeString},'{{date}}, {{time}}')}}]);return PDFDocumentProperties}();exports.PDFDocumentProperties=PDFDocumentProperties}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFFindBar=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i1&&arguments[1]!==undefined?arguments[1]:_ui_utils.NullL10n;_classCallCheck(this,PDFFindBar);this.opened=false;this.bar=options.bar||null;this.toggleButton=options.toggleButton||null;this.findField=options.findField||null;this.highlightAll=options.highlightAllCheckbox||null;this.caseSensitive=options.caseSensitiveCheckbox||null;this.findMsg=options.findMsg||null;this.findResultsCount=options.findResultsCount||null;this.findStatusIcon=options.findStatusIcon||null;this.findPreviousButton=options.findPreviousButton||null;this.findNextButton=options.findNextButton||null;this.findController=options.findController||null;this.eventBus=options.eventBus;this.l10n=l10n;if(this.findController===null){throw new Error('PDFFindBar cannot be used without a '+'PDFFindController instance.');}this.toggleButton.addEventListener('click',function(){_this.toggle()});this.findField.addEventListener('input',function(){_this.dispatchEvent('')});this.bar.addEventListener('keydown',function(e){switch(e.keyCode){case 13:if(e.target===_this.findField){_this.dispatchEvent('again',e.shiftKey)}break;case 27:_this.close();break}});this.findPreviousButton.addEventListener('click',function(){_this.dispatchEvent('again',true)});this.findNextButton.addEventListener('click',function(){_this.dispatchEvent('again',false)});this.highlightAll.addEventListener('click',function(){_this.dispatchEvent('highlightallchange')});this.caseSensitive.addEventListener('click',function(){_this.dispatchEvent('casesensitivitychange')});this.eventBus.on('resize',this._adjustWidth.bind(this))}_createClass(PDFFindBar,[{key:'reset',value:function reset(){this.updateUIState()}},{key:'dispatchEvent',value:function dispatchEvent(type,findPrev){this.eventBus.dispatch('find',{source:this,type:type,query:this.findField.value,caseSensitive:this.caseSensitive.checked,phraseSearch:true,highlightAll:this.highlightAll.checked,findPrevious:findPrev})}},{key:'updateUIState',value:function updateUIState(state,previous,matchCount){var _this2=this;var notFound=false;var findMsg='';var status='';switch(state){case _pdf_find_controller.FindState.FOUND:break;case _pdf_find_controller.FindState.PENDING:status='pending';break;case _pdf_find_controller.FindState.NOT_FOUND:findMsg=this.l10n.get('find_not_found',null,'Phrase not found');notFound=true;break;case _pdf_find_controller.FindState.WRAPPED:if(previous){findMsg=this.l10n.get('find_reached_top',null,'Reached top of document, continued from bottom')}else{findMsg=this.l10n.get('find_reached_bottom',null,'Reached end of document, continued from top')}break}if(notFound){this.findField.classList.add('notFound')}else{this.findField.classList.remove('notFound')}this.findField.setAttribute('data-status',status);Promise.resolve(findMsg).then(function(msg){_this2.findMsg.textContent=msg;_this2._adjustWidth()});this.updateResultsCount(matchCount)}},{key:'updateResultsCount',value:function updateResultsCount(matchCount){if(!this.findResultsCount){return}if(!matchCount){this.findResultsCount.classList.add('hidden');this.findResultsCount.textContent=''}else{this.findResultsCount.textContent=matchCount.toLocaleString();this.findResultsCount.classList.remove('hidden')}this._adjustWidth()}},{key:'open',value:function open(){if(!this.opened){this.opened=true;this.toggleButton.classList.add('toggled');this.bar.classList.remove('hidden')}this.findField.select();this.findField.focus();this._adjustWidth()}},{key:'close',value:function close(){if(!this.opened){return}this.opened=false;this.toggleButton.classList.remove('toggled');this.bar.classList.add('hidden');this.findController.active=false}},{key:'toggle',value:function toggle(){if(this.opened){this.close()}else{this.open()}}},{key:'_adjustWidth',value:function _adjustWidth(){if(!this.opened){return}this.bar.classList.remove('wrapContainers');var findbarHeight=this.bar.clientHeight;var inputContainerHeight=this.bar.firstElementChild.clientHeight;if(findbarHeight>inputContainerHeight){this.bar.classList.add('wrapContainers')}}}]);return PDFFindBar}();exports.PDFFindBar=PDFFindBar}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFHistory=undefined;var _dom_events=__webpack_require__(2);function PDFHistory(options){this.linkService=options.linkService;this.eventBus=options.eventBus||(0,_dom_events.getGlobalEventBus)();this.initialized=false;this.initialDestination=null;this.initialBookmark=null}PDFHistory.prototype={initialize:function pdfHistoryInitialize(fingerprint){this.initialized=true;this.reInitialized=false;this.allowHashChange=true;this.historyUnlocked=true;this.isViewerInPresentationMode=false;this.previousHash=window.location.hash.substring(1);this.currentBookmark='';this.currentPage=0;this.updatePreviousBookmark=false;this.previousBookmark='';this.previousPage=0;this.nextHashParam='';this.fingerprint=fingerprint;this.currentUid=this.uid=0;this.current={};var state=window.history.state;if(this._isStateObjectDefined(state)){if(state.target.dest){this.initialDestination=state.target.dest}else{this.initialBookmark=state.target.hash}this.currentUid=state.uid;this.uid=state.uid+1;this.current=state.target}else{if(state&&state.fingerprint&&this.fingerprint!==state.fingerprint){this.reInitialized=true}this._pushOrReplaceState({fingerprint:this.fingerprint},true)}var self=this;window.addEventListener('popstate',function pdfHistoryPopstate(evt){if(!self.historyUnlocked){return}if(evt.state){self._goTo(evt.state);return}if(self.uid===0){var previousParams=self.previousHash&&self.currentBookmark&&self.previousHash!==self.currentBookmark?{hash:self.currentBookmark,page:self.currentPage}:{page:1};replacePreviousHistoryState(previousParams,function(){updateHistoryWithCurrentHash()})}else{updateHistoryWithCurrentHash()}});function updateHistoryWithCurrentHash(){self.previousHash=window.location.hash.slice(1);self._pushToHistory({hash:self.previousHash},false,true);self._updatePreviousBookmark()}function replacePreviousHistoryState(params,callback){self.historyUnlocked=false;self.allowHashChange=false;window.addEventListener('popstate',rewriteHistoryAfterBack);history.back();function rewriteHistoryAfterBack(){window.removeEventListener('popstate',rewriteHistoryAfterBack);window.addEventListener('popstate',rewriteHistoryAfterForward);self._pushToHistory(params,false,true);history.forward()}function rewriteHistoryAfterForward(){window.removeEventListener('popstate',rewriteHistoryAfterForward);self.allowHashChange=true;self.historyUnlocked=true;callback()}}function pdfHistoryBeforeUnload(){var previousParams=self._getPreviousParams(null,true);if(previousParams){var replacePrevious=!self.current.dest&&self.current.hash!==self.previousHash;self._pushToHistory(previousParams,false,replacePrevious);self._updatePreviousBookmark()}window.removeEventListener('beforeunload',pdfHistoryBeforeUnload)}window.addEventListener('beforeunload',pdfHistoryBeforeUnload);window.addEventListener('pageshow',function pdfHistoryPageShow(evt){window.addEventListener('beforeunload',pdfHistoryBeforeUnload)});self.eventBus.on('presentationmodechanged',function(e){self.isViewerInPresentationMode=e.active})},clearHistoryState:function pdfHistory_clearHistoryState(){this._pushOrReplaceState(null,true)},_isStateObjectDefined:function pdfHistory_isStateObjectDefined(state){return state&&state.uid>=0&&state.fingerprint&&this.fingerprint===state.fingerprint&&state.target&&state.target.hash?true:false},_pushOrReplaceState:function pdfHistory_pushOrReplaceState(stateObj,replace){if(replace){window.history.replaceState(stateObj,'',document.URL)}else{window.history.pushState(stateObj,'',document.URL)}},get isHashChangeUnlocked(){if(!this.initialized){return true}return this.allowHashChange},_updatePreviousBookmark:function pdfHistory_updatePreviousBookmark(){if(this.updatePreviousBookmark&&this.currentBookmark&&this.currentPage){this.previousBookmark=this.currentBookmark;this.previousPage=this.currentPage;this.updatePreviousBookmark=false}},updateCurrentBookmark:function pdfHistoryUpdateCurrentBookmark(bookmark,pageNum){if(this.initialized){this.currentBookmark=bookmark.substring(1);this.currentPage=pageNum|0;this._updatePreviousBookmark()}},updateNextHashParam:function pdfHistoryUpdateNextHashParam(param){if(this.initialized){this.nextHashParam=param}},push:function pdfHistoryPush(params,isInitialBookmark){if(!(this.initialized&&this.historyUnlocked)){return}if(params.dest&&!params.hash){params.hash=this.current.hash&&this.current.dest&&this.current.dest===params.dest?this.current.hash:this.linkService.getDestinationHash(params.dest).split('#')[1]}if(params.page){params.page|=0}if(isInitialBookmark){var target=window.history.state.target;if(!target){this._pushToHistory(params,false);this.previousHash=window.location.hash.substring(1)}this.updatePreviousBookmark=this.nextHashParam?false:true;if(target){this._updatePreviousBookmark()}return}if(this.nextHashParam){if(this.nextHashParam===params.hash){this.nextHashParam=null;this.updatePreviousBookmark=true;return}this.nextHashParam=null}if(params.hash){if(this.current.hash){if(this.current.hash!==params.hash){this._pushToHistory(params,true)}else{if(!this.current.page&¶ms.page){this._pushToHistory(params,false,true)}this.updatePreviousBookmark=true}}else{this._pushToHistory(params,true)}}else if(this.current.page&¶ms.page&&this.current.page!==params.page){this._pushToHistory(params,true)}},_getPreviousParams:function pdfHistory_getPreviousParams(onlyCheckPage,beforeUnload){if(!(this.currentBookmark&&this.currentPage)){return null}else if(this.updatePreviousBookmark){this.updatePreviousBookmark=false}if(this.uid>0&&!(this.previousBookmark&&this.previousPage)){return null}if(!this.current.dest&&!onlyCheckPage||beforeUnload){if(this.previousBookmark===this.currentBookmark){return null}}else if(this.current.page||onlyCheckPage){if(this.previousPage===this.currentPage){return null}}else{return null}var params={hash:this.currentBookmark,page:this.currentPage};if(this.isViewerInPresentationMode){params.hash=null}return params},_stateObj:function pdfHistory_stateObj(params){return{fingerprint:this.fingerprint,uid:this.uid,target:params}},_pushToHistory:function pdfHistory_pushToHistory(params,addPrevious,overwrite){if(!this.initialized){return}if(!params.hash&¶ms.page){params.hash='page='+params.page}if(addPrevious&&!overwrite){var previousParams=this._getPreviousParams();if(previousParams){var replacePrevious=!this.current.dest&&this.current.hash!==this.previousHash;this._pushToHistory(previousParams,false,replacePrevious)}}this._pushOrReplaceState(this._stateObj(params),overwrite||this.uid===0);this.currentUid=this.uid++;this.current=params;this.updatePreviousBookmark=true},_goTo:function pdfHistory_goTo(state){if(!(this.initialized&&this.historyUnlocked&&this._isStateObjectDefined(state))){return}if(!this.reInitialized&&state.uidthis.uid){this.uid=state.uid}this.current=state.target;this.updatePreviousBookmark=true;var currentHash=window.location.hash.substring(1);if(this.previousHash!==currentHash){this.allowHashChange=false}this.previousHash=currentHash;this.historyUnlocked=true},back:function pdfHistoryBack(){this.go(-1)},forward:function pdfHistoryForward(){this.go(1)},go:function pdfHistoryGo(direction){if(this.initialized&&this.historyUnlocked){var state=window.history.state;if(direction===-1&&state&&state.uid>0){window.history.back()}else if(direction===1&&state&&state.uid0){var levelData=queue.shift();for(var i=0,len=levelData.items.length;i0){hasAnyNesting=true;this._addToggleButton(div);var itemsDiv=document.createElement('div');itemsDiv.className='outlineItems';div.appendChild(itemsDiv);queue.push({parent:itemsDiv,items:item.items})}levelData.parent.appendChild(div);outlineCount++}}if(hasAnyNesting){this.container.classList.add('outlineWithDeepNesting')}this.container.appendChild(fragment);this._dispatchEvent(outlineCount)}}]);return PDFOutlineViewer}();exports.PDFOutlineViewer=PDFOutlineViewer}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFPageView=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:false;if(!this.zoomLayer){return}var zoomLayerCanvas=this.zoomLayer.firstChild;this.paintedViewportMap.delete(zoomLayerCanvas);zoomLayerCanvas.width=0;zoomLayerCanvas.height=0;if(removeFromDOM){this.zoomLayer.remove()}this.zoomLayer=null}},{key:'reset',value:function reset(){var keepZoomLayer=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var keepAnnotations=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;this.cancelRendering();var div=this.div;div.style.width=Math.floor(this.viewport.width)+'px';div.style.height=Math.floor(this.viewport.height)+'px';var childNodes=div.childNodes;var currentZoomLayerNode=keepZoomLayer&&this.zoomLayer||null;var currentAnnotationNode=keepAnnotations&&this.annotationLayer&&this.annotationLayer.div||null;for(var i=childNodes.length-1;i>=0;i--){var node=childNodes[i];if(currentZoomLayerNode===node||currentAnnotationNode===node){continue}div.removeChild(node)}div.removeAttribute('data-loaded');if(currentAnnotationNode){this.annotationLayer.hide()}else{this.annotationLayer=null}if(!currentZoomLayerNode){if(this.canvas){this.paintedViewportMap.delete(this.canvas);this.canvas.width=0;this.canvas.height=0;delete this.canvas}this._resetZoomLayer()}if(this.svg){this.paintedViewportMap.delete(this.svg);delete this.svg}this.loadingIconDiv=document.createElement('div');this.loadingIconDiv.className='loadingIcon';div.appendChild(this.loadingIconDiv)}},{key:'update',value:function update(scale,rotation){this.scale=scale||this.scale;if(typeof rotation!=='undefined'){this.rotation=rotation}var totalRotation=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:this.scale*_ui_utils.CSS_UNITS,rotation:totalRotation});if(this.svg){this.cssTransform(this.svg,true);this.eventBus.dispatch('pagerendered',{source:this,pageNumber:this.id,cssTransform:true});return}var isScalingRestricted=false;if(this.canvas&&_pdfjsLib.PDFJS.maxCanvasPixels>0){var outputScale=this.outputScale;if((Math.floor(this.viewport.width)*outputScale.sx|0)*(Math.floor(this.viewport.height)*outputScale.sy|0)>_pdfjsLib.PDFJS.maxCanvasPixels){isScalingRestricted=true}}if(this.canvas){if(_pdfjsLib.PDFJS.useOnlyCssZoom||this.hasRestrictedScaling&&isScalingRestricted){this.cssTransform(this.canvas,true);this.eventBus.dispatch('pagerendered',{source:this,pageNumber:this.id,cssTransform:true});return}if(!this.zoomLayer&&!this.canvas.hasAttribute('hidden')){this.zoomLayer=this.canvas.parentNode;this.zoomLayer.style.position='absolute'}}if(this.zoomLayer){this.cssTransform(this.zoomLayer.firstChild)}this.reset(true,true)}},{key:'cancelRendering',value:function cancelRendering(){if(this.paintTask){this.paintTask.cancel();this.paintTask=null}this.renderingState=_pdf_rendering_queue.RenderingStates.INITIAL;this.resume=null;if(this.textLayer){this.textLayer.cancel();this.textLayer=null}}},{key:'cssTransform',value:function cssTransform(target){var redrawAnnotations=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var width=this.viewport.width;var height=this.viewport.height;var div=this.div;target.style.width=target.parentNode.style.width=div.style.width=Math.floor(width)+'px';target.style.height=target.parentNode.style.height=div.style.height=Math.floor(height)+'px';var relativeRotation=this.viewport.rotation-this.paintedViewportMap.get(target).rotation;var absRotation=Math.abs(relativeRotation);var scaleX=1,scaleY=1;if(absRotation===90||absRotation===270){scaleX=height/width;scaleY=width/height}var cssTransform='rotate('+relativeRotation+'deg) '+'scale('+scaleX+','+scaleY+')';_pdfjsLib.CustomStyle.setProp('transform',target,cssTransform);if(this.textLayer){var textLayerViewport=this.textLayer.viewport;var textRelativeRotation=this.viewport.rotation-textLayerViewport.rotation;var textAbsRotation=Math.abs(textRelativeRotation);var scale=width/textLayerViewport.width;if(textAbsRotation===90||textAbsRotation===270){scale=width/textLayerViewport.height}var textLayerDiv=this.textLayer.textLayerDiv;var transX=void 0,transY=void 0;switch(textAbsRotation){case 0:transX=transY=0;break;case 90:transX=0;transY='-'+textLayerDiv.style.height;break;case 180:transX='-'+textLayerDiv.style.width;transY='-'+textLayerDiv.style.height;break;case 270:transX='-'+textLayerDiv.style.width;transY=0;break;default:console.error('Bad rotation value.');break}_pdfjsLib.CustomStyle.setProp('transform',textLayerDiv,'rotate('+textAbsRotation+'deg) '+'scale('+scale+', '+scale+') '+'translate('+transX+', '+transY+')');_pdfjsLib.CustomStyle.setProp('transformOrigin',textLayerDiv,'0% 0%')}if(redrawAnnotations&&this.annotationLayer){this.annotationLayer.render(this.viewport,'display')}}},{key:'getPagePoint',value:function getPagePoint(x,y){return this.viewport.convertToPdfPoint(x,y)}},{key:'draw',value:function draw(){var _this=this;if(this.renderingState!==_pdf_rendering_queue.RenderingStates.INITIAL){console.error('Must be in new state before drawing');this.reset()}if(!this.pdfPage){this.renderingState=_pdf_rendering_queue.RenderingStates.FINISHED;return Promise.reject(new Error('Page is not loaded'))}this.renderingState=_pdf_rendering_queue.RenderingStates.RUNNING;var pdfPage=this.pdfPage;var div=this.div;var canvasWrapper=document.createElement('div');canvasWrapper.style.width=div.style.width;canvasWrapper.style.height=div.style.height;canvasWrapper.classList.add('canvasWrapper');if(this.annotationLayer&&this.annotationLayer.div){div.insertBefore(canvasWrapper,this.annotationLayer.div)}else{div.appendChild(canvasWrapper)}var textLayer=null;if(this.textLayerFactory){var textLayerDiv=document.createElement('div');textLayerDiv.className='textLayer';textLayerDiv.style.width=canvasWrapper.style.width;textLayerDiv.style.height=canvasWrapper.style.height;if(this.annotationLayer&&this.annotationLayer.div){div.insertBefore(textLayerDiv,this.annotationLayer.div)}else{div.appendChild(textLayerDiv)}textLayer=this.textLayerFactory.createTextLayerBuilder(textLayerDiv,this.id-1,this.viewport,this.enhanceTextSelection)}this.textLayer=textLayer;var renderContinueCallback=null;if(this.renderingQueue){renderContinueCallback=function renderContinueCallback(cont){if(!_this.renderingQueue.isHighestPriority(_this)){_this.renderingState=_pdf_rendering_queue.RenderingStates.PAUSED;_this.resume=function(){_this.renderingState=_pdf_rendering_queue.RenderingStates.RUNNING;cont()};return}cont()}}var finishPaintTask=function finishPaintTask(error){if(paintTask===_this.paintTask){_this.paintTask=null}if(error==='cancelled'||error instanceof _pdfjsLib.RenderingCancelledException){_this.error=null;return Promise.resolve(undefined)}_this.renderingState=_pdf_rendering_queue.RenderingStates.FINISHED;if(_this.loadingIconDiv){div.removeChild(_this.loadingIconDiv);delete _this.loadingIconDiv}_this._resetZoomLayer(true);_this.error=error;_this.stats=pdfPage.stats;if(_this.onAfterDraw){_this.onAfterDraw()}_this.eventBus.dispatch('pagerendered',{source:_this,pageNumber:_this.id,cssTransform:false});if(error){return Promise.reject(error)}return Promise.resolve(undefined)};var paintTask=this.renderer===_ui_utils.RendererType.SVG?this.paintOnSvg(canvasWrapper):this.paintOnCanvas(canvasWrapper);paintTask.onRenderContinue=renderContinueCallback;this.paintTask=paintTask;var resultPromise=paintTask.promise.then(function(){return finishPaintTask(null).then(function(){if(textLayer){var readableStream=pdfPage.streamTextContent({normalizeWhitespace:true});textLayer.setTextContentStream(readableStream);textLayer.render()}})},function(reason){return finishPaintTask(reason)});if(this.annotationLayerFactory){if(!this.annotationLayer){this.annotationLayer=this.annotationLayerFactory.createAnnotationLayerBuilder(div,pdfPage,this.renderInteractiveForms,this.l10n)}this.annotationLayer.render(this.viewport,'display')}div.setAttribute('data-loaded',true);if(this.onBeforeDraw){this.onBeforeDraw()}return resultPromise}},{key:'paintOnCanvas',value:function paintOnCanvas(canvasWrapper){var renderCapability=(0,_pdfjsLib.createPromiseCapability)();var result={promise:renderCapability.promise,onRenderContinue:function onRenderContinue(cont){cont()},cancel:function cancel(){renderTask.cancel()}};var viewport=this.viewport;var canvas=document.createElement('canvas');canvas.id=this.renderingId;canvas.setAttribute('hidden','hidden');var isCanvasHidden=true;var showCanvas=function showCanvas(){if(isCanvasHidden){canvas.removeAttribute('hidden');isCanvasHidden=false}};canvasWrapper.appendChild(canvas);this.canvas=canvas;canvas.mozOpaque=true;var ctx=canvas.getContext('2d',{alpha:false});var outputScale=(0,_ui_utils.getOutputScale)(ctx);this.outputScale=outputScale;if(_pdfjsLib.PDFJS.useOnlyCssZoom){var actualSizeViewport=viewport.clone({scale:_ui_utils.CSS_UNITS});outputScale.sx*=actualSizeViewport.width/viewport.width;outputScale.sy*=actualSizeViewport.height/viewport.height;outputScale.scaled=true}if(_pdfjsLib.PDFJS.maxCanvasPixels>0){var pixelsInViewport=viewport.width*viewport.height;var maxScale=Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels/pixelsInViewport);if(outputScale.sx>maxScale||outputScale.sy>maxScale){outputScale.sx=maxScale;outputScale.sy=maxScale;outputScale.scaled=true;this.hasRestrictedScaling=true}else{this.hasRestrictedScaling=false}}var sfx=(0,_ui_utils.approximateFraction)(outputScale.sx);var sfy=(0,_ui_utils.approximateFraction)(outputScale.sy);canvas.width=(0,_ui_utils.roundToDivide)(viewport.width*outputScale.sx,sfx[0]);canvas.height=(0,_ui_utils.roundToDivide)(viewport.height*outputScale.sy,sfy[0]);canvas.style.width=(0,_ui_utils.roundToDivide)(viewport.width,sfx[1])+'px';canvas.style.height=(0,_ui_utils.roundToDivide)(viewport.height,sfy[1])+'px';this.paintedViewportMap.set(canvas,viewport);var transform=!outputScale.scaled?null:[outputScale.sx,0,0,outputScale.sy,0,0];var renderContext={canvasContext:ctx,transform:transform,viewport:this.viewport,renderInteractiveForms:this.renderInteractiveForms};var renderTask=this.pdfPage.render(renderContext);renderTask.onContinue=function(cont){showCanvas();if(result.onRenderContinue){result.onRenderContinue(cont)}else{cont()}};renderTask.promise.then(function(){showCanvas();renderCapability.resolve(undefined)},function(error){showCanvas();renderCapability.reject(error)});return result}},{key:'paintOnSvg',value:function paintOnSvg(wrapper){var _this2=this;var cancelled=false;var ensureNotCancelled=function ensureNotCancelled(){if(cancelled){if(_pdfjsLib.PDFJS.pdfjsNext){throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page '+_this2.id,'svg');}else{throw'cancelled';}}};var pdfPage=this.pdfPage;var actualSizeViewport=this.viewport.clone({scale:_ui_utils.CSS_UNITS});var promise=pdfPage.getOperatorList().then(function(opList){ensureNotCancelled();var svgGfx=new _pdfjsLib.SVGGraphics(pdfPage.commonObjs,pdfPage.objs);return svgGfx.getSVG(opList,actualSizeViewport).then(function(svg){ensureNotCancelled();_this2.svg=svg;_this2.paintedViewportMap.set(svg,actualSizeViewport);svg.style.width=wrapper.style.width;svg.style.height=wrapper.style.height;_this2.renderingState=_pdf_rendering_queue.RenderingStates.FINISHED;wrapper.appendChild(svg)})});return{promise:promise,onRenderContinue:function onRenderContinue(cont){cont()},cancel:function cancel(){cancelled=true}}}},{key:'setPageLabel',value:function setPageLabel(label){this.pageLabel=typeof label==='string'?label:null;if(this.pageLabel!==null){this.div.setAttribute('data-page-label',this.pageLabel)}else{this.div.removeAttribute('data-page-label')}}},{key:'width',get:function get(){return this.viewport.width}},{key:'height',get:function get(){return this.viewport.height}}]);return PDFPageView}();exports.PDFPageView=PDFPageView}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFPresentationMode=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;istoredTime&¤tTime-storedTime0&&delta<0||this.mouseScrollDelta<0&&delta>0){this._resetMouseScrollState()}this.mouseScrollDelta+=delta;if(Math.abs(this.mouseScrollDelta)>=PAGE_SWITCH_THRESHOLD){var totalDelta=this.mouseScrollDelta;this._resetMouseScrollState();var success=totalDelta>0?this._goToPreviousPage():this._goToNextPage();if(success){this.mouseScrollTimeStamp=currentTime}}}},{key:'_goToPreviousPage',value:function _goToPreviousPage(){var page=this.pdfViewer.currentPageNumber;if(page<=1){return false}this.pdfViewer.currentPageNumber=page-1;return true}},{key:'_goToNextPage',value:function _goToNextPage(){var page=this.pdfViewer.currentPageNumber;if(page>=this.pdfViewer.pagesCount){return false}this.pdfViewer.currentPageNumber=page+1;return true}},{key:'_notifyStateChange',value:function _notifyStateChange(){this.eventBus.dispatch('presentationmodechanged',{source:this,active:this.active,switchInProgress:!!this.switchInProgress})}},{key:'_setSwitchInProgress',value:function _setSwitchInProgress(){var _this2=this;if(this.switchInProgress){clearTimeout(this.switchInProgress)}this.switchInProgress=setTimeout(function(){_this2._removeFullscreenChangeListeners();delete _this2.switchInProgress;_this2._notifyStateChange()},DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS)}},{key:'_resetSwitchInProgress',value:function _resetSwitchInProgress(){if(this.switchInProgress){clearTimeout(this.switchInProgress);delete this.switchInProgress}}},{key:'_enter',value:function _enter(){var _this3=this;this.active=true;this._resetSwitchInProgress();this._notifyStateChange();this.container.classList.add(ACTIVE_SELECTOR);setTimeout(function(){_this3.pdfViewer.currentPageNumber=_this3.args.page;_this3.pdfViewer.currentScaleValue='page-fit'},0);this._addWindowListeners();this._showControls();this.contextMenuOpen=false;this.container.setAttribute('contextmenu','viewerContextMenu');window.getSelection().removeAllRanges()}},{key:'_exit',value:function _exit(){var _this4=this;var page=this.pdfViewer.currentPageNumber;this.container.classList.remove(ACTIVE_SELECTOR);setTimeout(function(){_this4.active=false;_this4._removeFullscreenChangeListeners();_this4._notifyStateChange();_this4.pdfViewer.currentScaleValue=_this4.args.previousScale;_this4.pdfViewer.currentPageNumber=page;_this4.args=null},0);this._removeWindowListeners();this._hideControls();this._resetMouseScrollState();this.container.removeAttribute('contextmenu');this.contextMenuOpen=false}},{key:'_mouseDown',value:function _mouseDown(evt){if(this.contextMenuOpen){this.contextMenuOpen=false;evt.preventDefault();return}if(evt.button===0){var isInternalLink=evt.target.href&&evt.target.classList.contains('internalLink');if(!isInternalLink){evt.preventDefault();if(evt.shiftKey){this._goToPreviousPage()}else{this._goToNextPage()}}}}},{key:'_contextMenu',value:function _contextMenu(){this.contextMenuOpen=true}},{key:'_showControls',value:function _showControls(){var _this5=this;if(this.controlsTimeout){clearTimeout(this.controlsTimeout)}else{this.container.classList.add(CONTROLS_SELECTOR)}this.controlsTimeout=setTimeout(function(){_this5.container.classList.remove(CONTROLS_SELECTOR);delete _this5.controlsTimeout},DELAY_BEFORE_HIDING_CONTROLS)}},{key:'_hideControls',value:function _hideControls(){if(!this.controlsTimeout){return}clearTimeout(this.controlsTimeout);this.container.classList.remove(CONTROLS_SELECTOR);delete this.controlsTimeout}},{key:'_resetMouseScrollState',value:function _resetMouseScrollState(){this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0}},{key:'_touchSwipe',value:function _touchSwipe(evt){if(!this.active){return}if(evt.touches.length>1){this.touchSwipeState=null;return}switch(evt.type){case'touchstart':this.touchSwipeState={startX:evt.touches[0].pageX,startY:evt.touches[0].pageY,endX:evt.touches[0].pageX,endY:evt.touches[0].pageY};break;case'touchmove':if(this.touchSwipeState===null){return}this.touchSwipeState.endX=evt.touches[0].pageX;this.touchSwipeState.endY=evt.touches[0].pageY;evt.preventDefault();break;case'touchend':if(this.touchSwipeState===null){return}var delta=0;var dx=this.touchSwipeState.endX-this.touchSwipeState.startX;var dy=this.touchSwipeState.endY-this.touchSwipeState.startY;var absAngle=Math.abs(Math.atan2(dy,dx));if(Math.abs(dx)>SWIPE_MIN_DISTANCE_THRESHOLD&&(absAngle<=SWIPE_ANGLE_THRESHOLD||absAngle>=Math.PI-SWIPE_ANGLE_THRESHOLD)){delta=dx}else if(Math.abs(dy)>SWIPE_MIN_DISTANCE_THRESHOLD&&Math.abs(absAngle-Math.PI/2)<=SWIPE_ANGLE_THRESHOLD){delta=dy}if(delta>0){this._goToPreviousPage()}else if(delta<0){this._goToNextPage()}break}}},{key:'_addWindowListeners',value:function _addWindowListeners(){this.showControlsBind=this._showControls.bind(this);this.mouseDownBind=this._mouseDown.bind(this);this.mouseWheelBind=this._mouseWheel.bind(this);this.resetMouseScrollStateBind=this._resetMouseScrollState.bind(this);this.contextMenuBind=this._contextMenu.bind(this);this.touchSwipeBind=this._touchSwipe.bind(this);window.addEventListener('mousemove',this.showControlsBind);window.addEventListener('mousedown',this.mouseDownBind);window.addEventListener('wheel',this.mouseWheelBind);window.addEventListener('keydown',this.resetMouseScrollStateBind);window.addEventListener('contextmenu',this.contextMenuBind);window.addEventListener('touchstart',this.touchSwipeBind);window.addEventListener('touchmove',this.touchSwipeBind);window.addEventListener('touchend',this.touchSwipeBind)}},{key:'_removeWindowListeners',value:function _removeWindowListeners(){window.removeEventListener('mousemove',this.showControlsBind);window.removeEventListener('mousedown',this.mouseDownBind);window.removeEventListener('wheel',this.mouseWheelBind);window.removeEventListener('keydown',this.resetMouseScrollStateBind);window.removeEventListener('contextmenu',this.contextMenuBind);window.removeEventListener('touchstart',this.touchSwipeBind);window.removeEventListener('touchmove',this.touchSwipeBind);window.removeEventListener('touchend',this.touchSwipeBind);delete this.showControlsBind;delete this.mouseDownBind;delete this.mouseWheelBind;delete this.resetMouseScrollStateBind;delete this.contextMenuBind;delete this.touchSwipeBind}},{key:'_fullscreenChange',value:function _fullscreenChange(){if(this.isFullscreen){this._enter()}else{this._exit()}}},{key:'_addFullscreenChangeListeners',value:function _addFullscreenChangeListeners(){this.fullscreenChangeBind=this._fullscreenChange.bind(this);window.addEventListener('fullscreenchange',this.fullscreenChangeBind);window.addEventListener('mozfullscreenchange',this.fullscreenChangeBind);window.addEventListener('webkitfullscreenchange',this.fullscreenChangeBind);window.addEventListener('MSFullscreenChange',this.fullscreenChangeBind)}},{key:'_removeFullscreenChangeListeners',value:function _removeFullscreenChangeListeners(){window.removeEventListener('fullscreenchange',this.fullscreenChangeBind);window.removeEventListener('mozfullscreenchange',this.fullscreenChangeBind);window.removeEventListener('webkitfullscreenchange',this.fullscreenChangeBind);window.removeEventListener('MSFullscreenChange',this.fullscreenChangeBind);delete this.fullscreenChangeBind}},{key:'isFullscreen',get:function get(){return!!(document.fullscreenElement||document.mozFullScreen||document.webkitIsFullScreen||document.msFullscreenElement)}}]);return PDFPresentationMode}();exports.PDFPresentationMode=PDFPresentationMode}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFSidebar=exports.SidebarView=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i1&&arguments[1]!==undefined?arguments[1]:_ui_utils.NullL10n;_classCallCheck(this,PDFSidebar);this.isOpen=false;this.active=SidebarView.THUMBS;this.isInitialViewSet=false;this.onToggled=null;this.pdfViewer=options.pdfViewer;this.pdfThumbnailViewer=options.pdfThumbnailViewer;this.pdfOutlineViewer=options.pdfOutlineViewer;this.mainContainer=options.mainContainer;this.outerContainer=options.outerContainer;this.eventBus=options.eventBus;this.toggleButton=options.toggleButton;this.thumbnailButton=options.thumbnailButton;this.outlineButton=options.outlineButton;this.attachmentsButton=options.attachmentsButton;this.thumbnailView=options.thumbnailView;this.outlineView=options.outlineView;this.attachmentsView=options.attachmentsView;this.disableNotification=options.disableNotification||false;this.l10n=l10n;this._addEventListeners()}_createClass(PDFSidebar,[{key:'reset',value:function reset(){this.isInitialViewSet=false;this._hideUINotification(null);this.switchView(SidebarView.THUMBS);this.outlineButton.disabled=false;this.attachmentsButton.disabled=false}},{key:'setInitialView',value:function setInitialView(view){if(this.isInitialViewSet){return}this.isInitialViewSet=true;if(this.isOpen&&view===SidebarView.NONE){this._dispatchEvent();return}var isViewPreserved=view===this.visibleView;this.switchView(view,true);if(isViewPreserved){this._dispatchEvent()}}},{key:'switchView',value:function switchView(view){var forceOpen=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(view===SidebarView.NONE){this.close();return}var isViewChanged=view!==this.active;var shouldForceRendering=false;switch(view){case SidebarView.THUMBS:this.thumbnailButton.classList.add('toggled');this.outlineButton.classList.remove('toggled');this.attachmentsButton.classList.remove('toggled');this.thumbnailView.classList.remove('hidden');this.outlineView.classList.add('hidden');this.attachmentsView.classList.add('hidden');if(this.isOpen&&isViewChanged){this._updateThumbnailViewer();shouldForceRendering=true}break;case SidebarView.OUTLINE:if(this.outlineButton.disabled){return}this.thumbnailButton.classList.remove('toggled');this.outlineButton.classList.add('toggled');this.attachmentsButton.classList.remove('toggled');this.thumbnailView.classList.add('hidden');this.outlineView.classList.remove('hidden');this.attachmentsView.classList.add('hidden');break;case SidebarView.ATTACHMENTS:if(this.attachmentsButton.disabled){return}this.thumbnailButton.classList.remove('toggled');this.outlineButton.classList.remove('toggled');this.attachmentsButton.classList.add('toggled');this.thumbnailView.classList.add('hidden');this.outlineView.classList.add('hidden');this.attachmentsView.classList.remove('hidden');break;default:console.error('PDFSidebar_switchView: "'+view+'" is an unsupported value.');return}this.active=view|0;if(forceOpen&&!this.isOpen){this.open();return}if(shouldForceRendering){this._forceRendering()}if(isViewChanged){this._dispatchEvent()}this._hideUINotification(this.active)}},{key:'open',value:function open(){if(this.isOpen){return}this.isOpen=true;this.toggleButton.classList.add('toggled');this.outerContainer.classList.add('sidebarMoving');this.outerContainer.classList.add('sidebarOpen');if(this.active===SidebarView.THUMBS){this._updateThumbnailViewer()}this._forceRendering();this._dispatchEvent();this._hideUINotification(this.active)}},{key:'close',value:function close(){if(!this.isOpen){return}this.isOpen=false;this.toggleButton.classList.remove('toggled');this.outerContainer.classList.add('sidebarMoving');this.outerContainer.classList.remove('sidebarOpen');this._forceRendering();this._dispatchEvent()}},{key:'toggle',value:function toggle(){if(this.isOpen){this.close()}else{this.open()}}},{key:'_dispatchEvent',value:function _dispatchEvent(){this.eventBus.dispatch('sidebarviewchanged',{source:this,view:this.visibleView})}},{key:'_forceRendering',value:function _forceRendering(){if(this.onToggled){this.onToggled()}else{this.pdfViewer.forceRendering();this.pdfThumbnailViewer.forceRendering()}}},{key:'_updateThumbnailViewer',value:function _updateThumbnailViewer(){var pdfViewer=this.pdfViewer,pdfThumbnailViewer=this.pdfThumbnailViewer;var pagesCount=pdfViewer.pagesCount;for(var pageIndex=0;pageIndex=0;i--){ring.removeChild(childNodes[i])}var borderAdjustment=2*THUMBNAIL_CANVAS_BORDER_WIDTH;ring.style.width=this.canvasWidth+borderAdjustment+'px';ring.style.height=this.canvasHeight+borderAdjustment+'px';if(this.canvas){this.canvas.width=0;this.canvas.height=0;delete this.canvas}if(this.image){this.image.removeAttribute('src');delete this.image}}},{key:'update',value:function update(rotation){if(typeof rotation!=='undefined'){this.rotation=rotation}var totalRotation=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:totalRotation});this.reset()}},{key:'cancelRendering',value:function cancelRendering(){if(this.renderTask){this.renderTask.cancel();this.renderTask=null}this.renderingState=_pdf_rendering_queue.RenderingStates.INITIAL;this.resume=null}},{key:'_getPageDrawContext',value:function _getPageDrawContext(){var noCtxScale=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var canvas=document.createElement('canvas');this.canvas=canvas;canvas.mozOpaque=true;var ctx=canvas.getContext('2d',{alpha:false});var outputScale=(0,_ui_utils.getOutputScale)(ctx);canvas.width=this.canvasWidth*outputScale.sx|0;canvas.height=this.canvasHeight*outputScale.sy|0;canvas.style.width=this.canvasWidth+'px';canvas.style.height=this.canvasHeight+'px';if(!noCtxScale&&outputScale.scaled){ctx.scale(outputScale.sx,outputScale.sy)}return ctx}},{key:'_convertCanvasToImage',value:function _convertCanvasToImage(){var _this=this;if(!this.canvas){return}if(this.renderingState!==_pdf_rendering_queue.RenderingStates.FINISHED){return}var id=this.renderingId;var className='thumbnailImage';if(this.disableCanvasToImageConversion){this.canvas.id=id;this.canvas.className=className;this.l10n.get('thumb_page_canvas',{page:this.pageId},'Thumbnail of Page {{page}}').then(function(msg){_this.canvas.setAttribute('aria-label',msg)});this.div.setAttribute('data-loaded',true);this.ring.appendChild(this.canvas);return}var image=document.createElement('img');image.id=id;image.className=className;this.l10n.get('thumb_page_canvas',{page:this.pageId},'Thumbnail of Page {{page}}').then(function(msg){image.setAttribute('aria-label',msg)});image.style.width=this.canvasWidth+'px';image.style.height=this.canvasHeight+'px';image.src=this.canvas.toDataURL();this.image=image;this.div.setAttribute('data-loaded',true);this.ring.appendChild(image);this.canvas.width=0;this.canvas.height=0;delete this.canvas}},{key:'draw',value:function draw(){var _this2=this;if(this.renderingState!==_pdf_rendering_queue.RenderingStates.INITIAL){console.error('Must be in new state before drawing');return Promise.resolve(undefined)}this.renderingState=_pdf_rendering_queue.RenderingStates.RUNNING;var renderCapability=(0,_pdfjsLib.createPromiseCapability)();var finishRenderTask=function finishRenderTask(error){if(renderTask===_this2.renderTask){_this2.renderTask=null}if(error==='cancelled'||error instanceof _pdfjsLib.RenderingCancelledException){renderCapability.resolve(undefined);return}_this2.renderingState=_pdf_rendering_queue.RenderingStates.FINISHED;_this2._convertCanvasToImage();if(!error){renderCapability.resolve(undefined)}else{renderCapability.reject(error)}};var ctx=this._getPageDrawContext();var drawViewport=this.viewport.clone({scale:this.scale});var renderContinueCallback=function renderContinueCallback(cont){if(!_this2.renderingQueue.isHighestPriority(_this2)){_this2.renderingState=_pdf_rendering_queue.RenderingStates.PAUSED;_this2.resume=function(){_this2.renderingState=_pdf_rendering_queue.RenderingStates.RUNNING;cont()};return}cont()};var renderContext={canvasContext:ctx,viewport:drawViewport};var renderTask=this.renderTask=this.pdfPage.render(renderContext);renderTask.onContinue=renderContinueCallback;renderTask.promise.then(function(){finishRenderTask(null)},function(error){finishRenderTask(error)});return renderCapability.promise}},{key:'setImage',value:function setImage(pageView){if(this.renderingState!==_pdf_rendering_queue.RenderingStates.INITIAL){return}var img=pageView.canvas;if(!img){return}if(!this.pdfPage){this.setPdfPage(pageView.pdfPage)}this.renderingState=_pdf_rendering_queue.RenderingStates.FINISHED;var ctx=this._getPageDrawContext(true);var canvas=ctx.canvas;if(img.width<=2*canvas.width){ctx.drawImage(img,0,0,img.width,img.height,0,0,canvas.width,canvas.height);this._convertCanvasToImage();return}var reducedWidth=canvas.width<img.width||reducedHeight>img.height){reducedWidth>>=1;reducedHeight>>=1}reducedImageCtx.drawImage(img,0,0,img.width,img.height,0,0,reducedWidth,reducedHeight);while(reducedWidth>2*canvas.width){reducedImageCtx.drawImage(reducedImage,0,0,reducedWidth,reducedHeight,0,0,reducedWidth>>1,reducedHeight>>1);reducedWidth>>=1;reducedHeight>>=1}ctx.drawImage(reducedImage,0,0,reducedWidth,reducedHeight,0,0,canvas.width,canvas.height);this._convertCanvasToImage()}},{key:'setPageLabel',value:function setPageLabel(label){var _this3=this;this.pageLabel=typeof label==='string'?label:null;this.l10n.get('thumb_page_title',{page:this.pageId},'Page {{page}}').then(function(msg){_this3.anchor.title=msg});if(this.renderingState!==_pdf_rendering_queue.RenderingStates.FINISHED){return}this.l10n.get('thumb_page_canvas',{page:this.pageId},'Thumbnail of Page {{page}}').then(function(ariaLabel){if(_this3.image){_this3.image.setAttribute('aria-label',ariaLabel)}else if(_this3.disableCanvasToImageConversion&&_this3.canvas){_this3.canvas.setAttribute('aria-label',ariaLabel)}})}},{key:'pageId',get:function get(){return this.pageLabel!==null?this.pageLabel:this.id}}],[{key:'cleanup',value:function cleanup(){TempImageFactory.destroyCanvas()}}]);return PDFThumbnailView}();exports.PDFThumbnailView=PDFThumbnailView}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PDFThumbnailViewer=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var first=visibleThumbs.first.id;var last=numVisibleThumbs>1?visibleThumbs.last.id:first;if(page<=first||page>=last){(0,_ui_utils.scrollIntoView)(thumbnail,{top:THUMBNAIL_SCROLL_MARGIN})}}}},{key:'cleanup',value:function cleanup(){_pdf_thumbnail_view.PDFThumbnailView.cleanup()}},{key:'_resetView',value:function _resetView(){this._thumbnails=[];this._pageLabels=null;this._pagesRotation=0;this._pagesRequests=[];this.container.textContent=''}},{key:'setDocument',value:function setDocument(pdfDocument){var _this=this;if(this.pdfDocument){this._cancelRendering();this._resetView()}this.pdfDocument=pdfDocument;if(!pdfDocument){return}pdfDocument.getPage(1).then(function(firstPage){var pagesCount=pdfDocument.numPages;var viewport=firstPage.getViewport(1.0);for(var pageNum=1;pageNum<=pagesCount;++pageNum){var thumbnail=new _pdf_thumbnail_view.PDFThumbnailView({container:_this.container,id:pageNum,defaultViewport:viewport.clone(),linkService:_this.linkService,renderingQueue:_this.renderingQueue,disableCanvasToImageConversion:false,l10n:_this.l10n});_this._thumbnails.push(thumbnail)}}).catch(function(reason){console.error('Unable to initialize thumbnail viewer',reason)})}},{key:'_cancelRendering',value:function _cancelRendering(){for(var i=0,ii=this._thumbnails.length;i=0){data.splice(i,1)}data.push(view);if(data.length>size){data.shift().destroy()}};this.resize=function(newSize){size=newSize;while(data.length>size){data.shift().destroy()}}}function isSameScale(oldScale,newScale){if(newScale===oldScale){return true}if(Math.abs(newScale-oldScale)<1e-15){return true}return false}function isPortraitOrientation(size){return size.width<=size.height}var PDFViewer=function(){function PDFViewer(options){_classCallCheck(this,PDFViewer);this.container=options.container;this.viewer=options.viewer||options.container.firstElementChild;this.eventBus=options.eventBus||(0,_dom_events.getGlobalEventBus)();this.linkService=options.linkService||new _pdf_link_service.SimpleLinkService();this.downloadManager=options.downloadManager||null;this.removePageBorders=options.removePageBorders||false;this.enhanceTextSelection=options.enhanceTextSelection||false;this.renderInteractiveForms=options.renderInteractiveForms||false;this.enablePrintAutoRotate=options.enablePrintAutoRotate||false;this.renderer=options.renderer||_ui_utils.RendererType.CANVAS;this.l10n=options.l10n||_ui_utils.NullL10n;this.defaultRenderingQueue=!options.renderingQueue;if(this.defaultRenderingQueue){this.renderingQueue=new _pdf_rendering_queue.PDFRenderingQueue();this.renderingQueue.setViewer(this)}else{this.renderingQueue=options.renderingQueue}this.scroll=(0,_ui_utils.watchScroll)(this.container,this._scrollUpdate.bind(this));this.presentationModeState=PresentationModeState.UNKNOWN;this._resetView();if(this.removePageBorders){this.viewer.classList.add('removePageBorders')}}_createClass(PDFViewer,[{key:'getPageView',value:function getPageView(index){return this._pages[index]}},{key:'_setCurrentPageNumber',value:function _setCurrentPageNumber(val){var resetCurrentPageView=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(this._currentPageNumber===val){if(resetCurrentPageView){this._resetCurrentPageView()}return}if(!(02&&arguments[2]!==undefined?arguments[2]:false;var arg={source:this,scale:newScale,presetValue:preset?newValue:undefined};this.eventBus.dispatch('scalechanging',arg);this.eventBus.dispatch('scalechange',arg)}},{key:'_setScaleUpdatePages',value:function _setScaleUpdatePages(newScale,newValue){var noScroll=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var preset=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;this._currentScaleValue=newValue.toString();if(isSameScale(this._currentScale,newScale)){if(preset){this._setScaleDispatchEvent(newScale,newValue,true)}return}for(var i=0,ii=this._pages.length;i1&&arguments[1]!==undefined?arguments[1]:false;var scale=parseFloat(value);if(scale>0){this._setScaleUpdatePages(scale,value,noScroll,false)}else{var currentPage=this._pages[this._currentPageNumber-1];if(!currentPage){return}var hPadding=this.isInPresentationMode||this.removePageBorders?0:_ui_utils.SCROLLBAR_PADDING;var vPadding=this.isInPresentationMode||this.removePageBorders?0:_ui_utils.VERTICAL_PADDING;var pageWidthScale=(this.container.clientWidth-hPadding)/currentPage.width*currentPage.scale;var pageHeightScale=(this.container.clientHeight-vPadding)/currentPage.height*currentPage.scale;switch(value){case'page-actual':scale=1;break;case'page-width':scale=pageWidthScale;break;case'page-height':scale=pageHeightScale;break;case'page-fit':scale=Math.min(pageWidthScale,pageHeightScale);break;case'auto':var isLandscape=currentPage.width>currentPage.height;var horizontalScale=isLandscape?Math.min(pageHeightScale,pageWidthScale):pageWidthScale;scale=Math.min(_ui_utils.MAX_AUTO_SCALE,horizontalScale);break;default:console.error('PDFViewer._setScale: "'+value+'" is an unknown zoom value.');return}this._setScaleUpdatePages(scale,value,noScroll,true)}}},{key:'_resetCurrentPageView',value:function _resetCurrentPageView(){if(this.isInPresentationMode){this._setScale(this._currentScaleValue,true)}var pageView=this._pages[this._currentPageNumber-1];(0,_ui_utils.scrollIntoView)(pageView.div)}},{key:'scrollPageIntoView',value:function scrollPageIntoView(params){if(!this.pdfDocument){return}if(arguments.length>1||typeof params==='number'){console.warn('Call of scrollPageIntoView() with obsolete signature.');var paramObj={};if(typeof params==='number'){paramObj.pageNumber=params}if(arguments[1]instanceof Array){paramObj.destArray=arguments[1]}params=paramObj}var pageNumber=params.pageNumber||0;var dest=params.destArray||null;var allowNegativeOffset=params.allowNegativeOffset||false;if(this.isInPresentationMode||!dest){this._setCurrentPageNumber(pageNumber,true);return}var pageView=this._pages[pageNumber-1];if(!pageView){console.error('PDFViewer.scrollPageIntoView: Invalid "pageNumber" parameter.');return}var x=0,y=0;var width=0,height=0,widthScale=void 0,heightScale=void 0;var changeOrientation=pageView.rotation%180===0?false:true;var pageWidth=(changeOrientation?pageView.height:pageView.width)/pageView.scale/_ui_utils.CSS_UNITS;var pageHeight=(changeOrientation?pageView.width:pageView.height)/pageView.scale/_ui_utils.CSS_UNITS;var scale=0;switch(dest[1].name){case'XYZ':x=dest[2];y=dest[3];scale=dest[4];x=x!==null?x:0;y=y!==null?y:pageHeight;break;case'Fit':case'FitB':scale='page-fit';break;case'FitH':case'FitBH':y=dest[2];scale='page-width';if(y===null&&this._location){x=this._location.left;y=this._location.top}break;case'FitV':case'FitBV':x=dest[2];width=pageWidth;height=pageHeight;scale='page-height';break;case'FitR':x=dest[2];y=dest[3];width=dest[4]-x;height=dest[5]-y;var hPadding=this.removePageBorders?0:_ui_utils.SCROLLBAR_PADDING;var vPadding=this.removePageBorders?0:_ui_utils.VERTICAL_PADDING;widthScale=(this.container.clientWidth-hPadding)/width/_ui_utils.CSS_UNITS;heightScale=(this.container.clientHeight-vPadding)/height/_ui_utils.CSS_UNITS;scale=Math.min(Math.abs(widthScale),Math.abs(heightScale));break;default:console.error('PDFViewer.scrollPageIntoView: "'+dest[1].name+'" '+'is not a valid destination type.');return}if(scale&&scale!==this._currentScale){this.currentScaleValue=scale}else if(this._currentScale===_ui_utils.UNKNOWN_SCALE){this.currentScaleValue=_ui_utils.DEFAULT_SCALE_VALUE}if(scale==='page-fit'&&!dest[4]){(0,_ui_utils.scrollIntoView)(pageView.div);return}var boundingRect=[pageView.viewport.convertToViewportPoint(x,y),pageView.viewport.convertToViewportPoint(x+width,y+height)];var left=Math.min(boundingRect[0][0],boundingRect[1][0]);var top=Math.min(boundingRect[0][1],boundingRect[1][1]);if(!allowNegativeOffset){left=Math.max(left,0);top=Math.max(top,0)}(0,_ui_utils.scrollIntoView)(pageView.div,{left:left,top:top})}},{key:'_updateLocation',value:function _updateLocation(firstPage){var currentScale=this._currentScale;var currentScaleValue=this._currentScaleValue;var normalizedScaleValue=parseFloat(currentScaleValue)===currentScale?Math.round(currentScale*10000)/100:currentScaleValue;var pageNumber=firstPage.id;var pdfOpenParams='#page='+pageNumber;pdfOpenParams+='&zoom='+normalizedScaleValue;var currentPageView=this._pages[pageNumber-1];var container=this.container;var topLeft=currentPageView.getPagePoint(container.scrollLeft-firstPage.x,container.scrollTop-firstPage.y);var intLeft=Math.round(topLeft[0]);var intTop=Math.round(topLeft[1]);pdfOpenParams+=','+intLeft+','+intTop;this._location={pageNumber:pageNumber,scale:normalizedScaleValue,top:intTop,left:intLeft,pdfOpenParams:pdfOpenParams}}},{key:'update',value:function update(){var visible=this._getVisiblePages();var visiblePages=visible.views;if(visiblePages.length===0){return}var suggestedCacheSize=Math.max(DEFAULT_CACHE_SIZE,2*visiblePages.length+1);this._buffer.resize(suggestedCacheSize);this.renderingQueue.renderHighestPriority(visible);var currentId=this._currentPageNumber;var firstPage=visible.first;var stillFullyVisible=false;for(var i=0,ii=visiblePages.length;i3&&arguments[3]!==undefined?arguments[3]:false;return new _text_layer_builder.TextLayerBuilder({textLayerDiv:textLayerDiv,eventBus:this.eventBus,pageIndex:pageIndex,viewport:viewport,findController:this.isInPresentationMode?null:this.findController,enhanceTextSelection:this.isInPresentationMode?false:enhanceTextSelection})}},{key:'createAnnotationLayerBuilder',value:function createAnnotationLayerBuilder(pageDiv,pdfPage){var renderInteractiveForms=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var l10n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:_ui_utils.NullL10n;return new _annotation_layer_builder.AnnotationLayerBuilder({pageDiv:pageDiv,pdfPage:pdfPage,renderInteractiveForms:renderInteractiveForms,linkService:this.linkService,downloadManager:this.downloadManager,l10n:l10n})}},{key:'setFindController',value:function setFindController(findController){this.findController=findController}},{key:'getPagesOverview',value:function getPagesOverview(){var pagesOverview=this._pages.map(function(pageView){var viewport=pageView.pdfPage.getViewport(1);return{width:viewport.width,height:viewport.height,rotation:viewport.rotation}});if(!this.enablePrintAutoRotate){return pagesOverview}var isFirstPagePortrait=isPortraitOrientation(pagesOverview[0]);return pagesOverview.map(function(size){if(isFirstPagePortrait===isPortraitOrientation(size)){return size}return{width:size.height,height:size.width,rotation:(size.rotation+90)%360}})}},{key:'pagesCount',get:function get(){return this._pages.length}},{key:'pageViewsReady',get:function get(){return this._pageViewsReady}},{key:'currentPageNumber',get:function get(){return this._currentPageNumber},set:function set(val){if((val|0)!==val){throw new Error('Invalid page number.');}if(!this.pdfDocument){return}this._setCurrentPageNumber(val,true)}},{key:'currentPageLabel',get:function get(){return this._pageLabels&&this._pageLabels[this._currentPageNumber-1]},set:function set(val){var pageNumber=val|0;if(this._pageLabels){var i=this._pageLabels.indexOf(val);if(i>=0){pageNumber=i+1}}this.currentPageNumber=pageNumber}},{key:'currentScale',get:function get(){return this._currentScale!==_ui_utils.UNKNOWN_SCALE?this._currentScale:_ui_utils.DEFAULT_SCALE},set:function set(val){if(isNaN(val)){throw new Error('Invalid numeric scale');}if(!this.pdfDocument){return}this._setScale(val,false)}},{key:'currentScaleValue',get:function get(){return this._currentScaleValue},set:function set(val){if(!this.pdfDocument){return}this._setScale(val,false)}},{key:'pagesRotation',get:function get(){return this._pagesRotation},set:function set(rotation){if(!(typeof rotation==='number'&&rotation%90===0)){throw new Error('Invalid pages rotation angle.');}if(!this.pdfDocument){return}this._pagesRotation=rotation;for(var i=0,ii=this._pages.length;ithis.container.clientWidth}},{key:'hasEqualPageSizes',get:function get(){var firstPageView=this._pages[0];for(var i=1,ii=this._pages.length;i=this.pagesCount;this.items.pageRotateCw.disabled=this.pagesCount===0;this.items.pageRotateCcw.disabled=this.pagesCount===0}},{key:'_bindClickListeners',value:function _bindClickListeners(){var _this=this;this.toggleButton.addEventListener('click',this.toggle.bind(this));var _loop=function _loop(button){var _buttons$button=_this.buttons[button],element=_buttons$button.element,eventName=_buttons$button.eventName,close=_buttons$button.close,eventDetails=_buttons$button.eventDetails;element.addEventListener('click',function(evt){if(eventName!==null){var details={source:_this};for(var property in eventDetails){details[property]=eventDetails[property]}_this.eventBus.dispatch(eventName,details)}if(close){_this.close()}})};for(var button in this.buttons){_loop(button)}}},{key:'_bindCursorToolsListener',value:function _bindCursorToolsListener(buttons){this.eventBus.on('cursortoolchanged',function(evt){buttons.cursorSelectToolButton.classList.remove('toggled');buttons.cursorHandToolButton.classList.remove('toggled');switch(evt.tool){case _pdf_cursor_tools.CursorTool.SELECT:buttons.cursorSelectToolButton.classList.add('toggled');break;case _pdf_cursor_tools.CursorTool.HAND:buttons.cursorHandToolButton.classList.add('toggled');break}})}},{key:'open',value:function open(){if(this.opened){return}this.opened=true;this._setMaxHeight();this.toggleButton.classList.add('toggled');this.toolbar.classList.remove('hidden')}},{key:'close',value:function close(){if(!this.opened){return}this.opened=false;this.toolbar.classList.add('hidden');this.toggleButton.classList.remove('toggled')}},{key:'toggle',value:function toggle(){if(this.opened){this.close()}else{this.open()}}},{key:'_setMaxHeight',value:function _setMaxHeight(){if(!this.opened){return}this.containerHeight=this.mainContainer.clientHeight;if(this.containerHeight===this.previousContainerHeight){return}this.toolbarButtonContainer.setAttribute('style','max-height: '+(this.containerHeight-_ui_utils.SCROLLBAR_PADDING)+'px;');this.previousContainerHeight=this.containerHeight}},{key:'isOpen',get:function get(){return this.opened}}]);return SecondaryToolbar}();exports.SecondaryToolbar=SecondaryToolbar}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DefaultTextLayerFactory=exports.TextLayerBuilder=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:0;if(!(this.textContent||this.textContentStream)||this.renderingDone){return}this.cancel();this.textDivs=[];var textLayerFrag=document.createDocumentFragment();this.textLayerRenderTask=(0,_pdfjsLib.renderTextLayer)({textContent:this.textContent,textContentStream:this.textContentStream,container:textLayerFrag,viewport:this.viewport,textDivs:this.textDivs,textContentItemsStr:this.textContentItemsStr,timeout:timeout,enhanceTextSelection:this.enhanceTextSelection});this.textLayerRenderTask.promise.then(function(){_this.textLayerDiv.appendChild(textLayerFrag);_this._finishRendering();_this.updateMatches()},function(reason){})}},{key:'cancel',value:function cancel(){if(this.textLayerRenderTask){this.textLayerRenderTask.cancel();this.textLayerRenderTask=null}}},{key:'setTextContentStream',value:function setTextContentStream(readableStream){this.cancel();this.textContentStream=readableStream}},{key:'setTextContent',value:function setTextContent(textContent){this.cancel();this.textContent=textContent}},{key:'convertMatches',value:function convertMatches(matches,matchesLength){var i=0;var iIndex=0;var textContentItemsStr=this.textContentItemsStr;var end=textContentItemsStr.length-1;var queryLen=this.findController===null?0:this.findController.state.query.length;var ret=[];if(!matches){return ret}for(var m=0,len=matches.length;m=iIndex+textContentItemsStr[i].length){iIndex+=textContentItemsStr[i].length;i++}if(i===textContentItemsStr.length){console.error('Could not find a matching mapping')}var match={begin:{divIdx:i,offset:matchIdx-iIndex}};if(matchesLength){matchIdx+=matchesLength[m]}else{matchIdx+=queryLen}while(i!==end&&matchIdx>iIndex+textContentItemsStr[i].length){iIndex+=textContentItemsStr[i].length;i++}match.end={divIdx:i,offset:matchIdx-iIndex};ret.push(match)}return ret}},{key:'renderMatches',value:function renderMatches(matches){if(matches.length===0){return}var textContentItemsStr=this.textContentItemsStr;var textDivs=this.textDivs;var prevEnd=null;var pageIdx=this.pageIdx;var isSelectedPage=this.findController===null?false:pageIdx===this.findController.selected.pageIdx;var selectedMatchIdx=this.findController===null?-1:this.findController.selected.matchIdx;var highlightAll=this.findController===null?false:this.findController.state.highlightAll;var infinity={divIdx:-1,offset:undefined};function beginText(begin,className){var divIdx=begin.divIdx;textDivs[divIdx].textContent='';appendTextToDiv(divIdx,0,begin.offset,className)}function appendTextToDiv(divIdx,fromOffset,toOffset,className){var div=textDivs[divIdx];var content=textContentItemsStr[divIdx].substring(fromOffset,toOffset);var node=document.createTextNode(content);if(className){var span=document.createElement('span');span.className=className;span.appendChild(node);div.appendChild(span);return}div.appendChild(node)}var i0=selectedMatchIdx,i1=i0+1;if(highlightAll){i0=0;i1=matches.length}else if(!isSelectedPage){return}for(var i=i0;i3&&arguments[3]!==undefined?arguments[3]:false;return new TextLayerBuilder({textLayerDiv:textLayerDiv,pageIndex:pageIndex,viewport:viewport,enhanceTextSelection:enhanceTextSelection})}}]);return DefaultTextLayerFactory}();exports.TextLayerBuilder=TextLayerBuilder;exports.DefaultTextLayerFactory=DefaultTextLayerFactory}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Toolbar=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i3&&arguments[3]!==undefined?arguments[3]:_ui_utils.NullL10n;_classCallCheck(this,Toolbar);this.toolbar=options.container;this.mainContainer=mainContainer;this.eventBus=eventBus;this.l10n=l10n;this.items=options;this._wasLocalized=false;this.reset();this._bindListeners()}_createClass(Toolbar,[{key:'setPageNumber',value:function setPageNumber(pageNumber,pageLabel){this.pageNumber=pageNumber;this.pageLabel=pageLabel;this._updateUIState(false)}},{key:'setPagesCount',value:function setPagesCount(pagesCount,hasPageLabels){this.pagesCount=pagesCount;this.hasPageLabels=hasPageLabels;this._updateUIState(true)}},{key:'setPageScale',value:function setPageScale(pageScaleValue,pageScale){this.pageScaleValue=pageScaleValue;this.pageScale=pageScale;this._updateUIState(false)}},{key:'reset',value:function reset(){this.pageNumber=0;this.pageLabel=null;this.hasPageLabels=false;this.pagesCount=0;this.pageScaleValue=_ui_utils.DEFAULT_SCALE_VALUE;this.pageScale=_ui_utils.DEFAULT_SCALE;this._updateUIState(true)}},{key:'_bindListeners',value:function _bindListeners(){var _this=this;var eventBus=this.eventBus,items=this.items;var self=this;items.previous.addEventListener('click',function(){eventBus.dispatch('previouspage')});items.next.addEventListener('click',function(){eventBus.dispatch('nextpage')});items.zoomIn.addEventListener('click',function(){eventBus.dispatch('zoomin')});items.zoomOut.addEventListener('click',function(){eventBus.dispatch('zoomout')});items.pageNumber.addEventListener('click',function(){this.select()});items.pageNumber.addEventListener('change',function(){eventBus.dispatch('pagenumberchanged',{source:self,value:this.value})});items.scaleSelect.addEventListener('change',function(){if(this.value==='custom'){return}eventBus.dispatch('scalechanged',{source:self,value:this.value})});items.presentationModeButton.addEventListener('click',function(){eventBus.dispatch('presentationmode')});items.openFile.addEventListener('click',function(){eventBus.dispatch('openfile')});items.print.addEventListener('click',function(){eventBus.dispatch('print')});items.download.addEventListener('click',function(){eventBus.dispatch('download')});items.scaleSelect.oncontextmenu=_ui_utils.noContextMenuHandler;eventBus.on('localized',function(){_this._localized()})}},{key:'_localized',value:function _localized(){this._wasLocalized=true;this._adjustScaleWidth();this._updateUIState(true)}},{key:'_updateUIState',value:function _updateUIState(){var resetNumPages=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(!this._wasLocalized){return}var pageNumber=this.pageNumber,pagesCount=this.pagesCount,items=this.items;var scaleValue=(this.pageScaleValue||this.pageScale).toString();var scale=this.pageScale;if(resetNumPages){if(this.hasPageLabels){items.pageNumber.type='text'}else{items.pageNumber.type='number';this.l10n.get('of_pages',{pagesCount:pagesCount},'of {{pagesCount}}').then(function(msg){items.numPages.textContent=msg})}items.pageNumber.max=pagesCount}if(this.hasPageLabels){items.pageNumber.value=this.pageLabel;this.l10n.get('page_of_pages',{pageNumber:pageNumber,pagesCount:pagesCount},'({{pageNumber}} of {{pagesCount}})').then(function(msg){items.numPages.textContent=msg})}else{items.pageNumber.value=pageNumber}items.previous.disabled=pageNumber<=1;items.next.disabled=pageNumber>=pagesCount;items.zoomOut.disabled=scale<=_ui_utils.MIN_SCALE;items.zoomIn.disabled=scale>=_ui_utils.MAX_SCALE;var customScale=Math.round(scale*10000)/100;this.l10n.get('page_scale_percent',{scale:customScale},'{{scale}}%').then(function(msg){var options=items.scaleSelect.options;var predefinedValueFound=false;for(var i=0,ii=options.length;i0&&arguments[0]!==undefined?arguments[0]:false;var pageNumberInput=this.items.pageNumber;if(loading){pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR)}else{pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR)}}},{key:'_adjustScaleWidth',value:function _adjustScaleWidth(){var container=this.items.scaleSelectContainer;var select=this.items.scaleSelect;_ui_utils.animationStarted.then(function(){if(container.clientWidth===0){container.setAttribute('style','display: inherit;')}if(container.clientWidth>0){select.setAttribute('style','min-width: inherit;');var width=select.clientWidth+SCALE_SELECT_CONTAINER_PADDING;select.setAttribute('style','min-width: '+(width+SCALE_SELECT_PADDING)+'px;');container.setAttribute('style','min-width: '+width+'px; '+'max-width: '+width+'px;')}})}}]);return Toolbar}();exports.Toolbar=Toolbar}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i1&&arguments[1]!==undefined?arguments[1]:DEFAULT_VIEW_HISTORY_CACHE_SIZE;_classCallCheck(this,ViewHistory);this.fingerprint=fingerprint;this.cacheSize=cacheSize;this._initializedPromise=this._readFromStorage().then(function(databaseStr){var database=JSON.parse(databaseStr||'{}');if(!('files'in database)){database.files=[]}if(database.files.length>=_this.cacheSize){database.files.shift()}var index=void 0;for(var i=0,length=database.files.length;i