pdf_viewer.js 169 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsDistWebPdfViewer = factory();
  31. })(typeof self !== 'undefined' ? self : this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, {
  71. /******/ configurable: false,
  72. /******/ enumerable: true,
  73. /******/ get: getter
  74. /******/ });
  75. /******/ }
  76. /******/ };
  77. /******/
  78. /******/ // getDefaultExport function for compatibility with non-harmony modules
  79. /******/ __w_pdfjs_require__.n = function(module) {
  80. /******/ var getter = module && module.__esModule ?
  81. /******/ function getDefault() { return module['default']; } :
  82. /******/ function getModuleExports() { return module; };
  83. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  84. /******/ return getter;
  85. /******/ };
  86. /******/
  87. /******/ // Object.prototype.hasOwnProperty.call
  88. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  89. /******/
  90. /******/ // __webpack_public_path__
  91. /******/ __w_pdfjs_require__.p = "";
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 9);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ([
  98. /* 0 */
  99. /***/ (function(module, exports, __w_pdfjs_require__) {
  100. "use strict";
  101. var pdfjsLib = void 0;
  102. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  103. pdfjsLib = window['pdfjs-dist/build/pdf'];
  104. } else {
  105. pdfjsLib = require('../build/pdf.js');
  106. }
  107. module.exports = pdfjsLib;
  108. /***/ }),
  109. /* 1 */
  110. /***/ (function(module, exports, __w_pdfjs_require__) {
  111. "use strict";
  112. Object.defineProperty(exports, "__esModule", {
  113. value: true
  114. });
  115. exports.waitOnEventOrTimeout = exports.WaitOnType = 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.PresentationModeState = exports.cloneObj = exports.isFileSchema = exports.isValidRotation = 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;
  116. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  117. 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; };
  118. var _pdfjsLib = __w_pdfjs_require__(0);
  119. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  120. var CSS_UNITS = 96.0 / 72.0;
  121. var DEFAULT_SCALE_VALUE = 'auto';
  122. var DEFAULT_SCALE = 1.0;
  123. var MIN_SCALE = 0.10;
  124. var MAX_SCALE = 10.0;
  125. var UNKNOWN_SCALE = 0;
  126. var MAX_AUTO_SCALE = 1.25;
  127. var SCROLLBAR_PADDING = 40;
  128. var VERTICAL_PADDING = 5;
  129. var PresentationModeState = {
  130. UNKNOWN: 0,
  131. NORMAL: 1,
  132. CHANGING: 2,
  133. FULLSCREEN: 3
  134. };
  135. var RendererType = {
  136. CANVAS: 'canvas',
  137. SVG: 'svg'
  138. };
  139. function formatL10nValue(text, args) {
  140. if (!args) {
  141. return text;
  142. }
  143. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  144. return name in args ? args[name] : '{{' + name + '}}';
  145. });
  146. }
  147. var NullL10n = {
  148. getDirection: function getDirection() {
  149. return Promise.resolve('ltr');
  150. },
  151. get: function get(property, args, fallback) {
  152. return Promise.resolve(formatL10nValue(fallback, args));
  153. },
  154. translate: function translate(element) {
  155. return Promise.resolve();
  156. }
  157. };
  158. _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;
  159. _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;
  160. _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
  161. _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false : _pdfjsLib.PDFJS.disableHistory;
  162. _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false : _pdfjsLib.PDFJS.disableTextLayer;
  163. {
  164. _pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjsLib.PDFJS.locale;
  165. }
  166. function getOutputScale(ctx) {
  167. var devicePixelRatio = window.devicePixelRatio || 1;
  168. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  169. var pixelRatio = devicePixelRatio / backingStoreRatio;
  170. return {
  171. sx: pixelRatio,
  172. sy: pixelRatio,
  173. scaled: pixelRatio !== 1
  174. };
  175. }
  176. function scrollIntoView(element, spot) {
  177. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  178. var parent = element.offsetParent;
  179. if (!parent) {
  180. console.error('offsetParent is not set -- cannot scroll');
  181. return;
  182. }
  183. var offsetY = element.offsetTop + element.clientTop;
  184. var offsetX = element.offsetLeft + element.clientLeft;
  185. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  186. if (parent.dataset._scaleY) {
  187. offsetY /= parent.dataset._scaleY;
  188. offsetX /= parent.dataset._scaleX;
  189. }
  190. offsetY += parent.offsetTop;
  191. offsetX += parent.offsetLeft;
  192. parent = parent.offsetParent;
  193. if (!parent) {
  194. return;
  195. }
  196. }
  197. if (spot) {
  198. if (spot.top !== undefined) {
  199. offsetY += spot.top;
  200. }
  201. if (spot.left !== undefined) {
  202. offsetX += spot.left;
  203. parent.scrollLeft = offsetX;
  204. }
  205. }
  206. parent.scrollTop = offsetY;
  207. }
  208. function watchScroll(viewAreaElement, callback) {
  209. var debounceScroll = function debounceScroll(evt) {
  210. if (rAF) {
  211. return;
  212. }
  213. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  214. rAF = null;
  215. var currentY = viewAreaElement.scrollTop;
  216. var lastY = state.lastY;
  217. if (currentY !== lastY) {
  218. state.down = currentY > lastY;
  219. }
  220. state.lastY = currentY;
  221. callback(state);
  222. });
  223. };
  224. var state = {
  225. down: true,
  226. lastY: viewAreaElement.scrollTop,
  227. _eventHandler: debounceScroll
  228. };
  229. var rAF = null;
  230. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  231. return state;
  232. }
  233. function parseQueryString(query) {
  234. var parts = query.split('&');
  235. var params = Object.create(null);
  236. for (var i = 0, ii = parts.length; i < ii; ++i) {
  237. var param = parts[i].split('=');
  238. var key = param[0].toLowerCase();
  239. var value = param.length > 1 ? param[1] : null;
  240. params[decodeURIComponent(key)] = decodeURIComponent(value);
  241. }
  242. return params;
  243. }
  244. function binarySearchFirstItem(items, condition) {
  245. var minIndex = 0;
  246. var maxIndex = items.length - 1;
  247. if (items.length === 0 || !condition(items[maxIndex])) {
  248. return items.length;
  249. }
  250. if (condition(items[minIndex])) {
  251. return minIndex;
  252. }
  253. while (minIndex < maxIndex) {
  254. var currentIndex = minIndex + maxIndex >> 1;
  255. var currentItem = items[currentIndex];
  256. if (condition(currentItem)) {
  257. maxIndex = currentIndex;
  258. } else {
  259. minIndex = currentIndex + 1;
  260. }
  261. }
  262. return minIndex;
  263. }
  264. function approximateFraction(x) {
  265. if (Math.floor(x) === x) {
  266. return [x, 1];
  267. }
  268. var xinv = 1 / x;
  269. var limit = 8;
  270. if (xinv > limit) {
  271. return [1, limit];
  272. } else if (Math.floor(xinv) === xinv) {
  273. return [1, xinv];
  274. }
  275. var x_ = x > 1 ? xinv : x;
  276. var a = 0,
  277. b = 1,
  278. c = 1,
  279. d = 1;
  280. while (true) {
  281. var p = a + c,
  282. q = b + d;
  283. if (q > limit) {
  284. break;
  285. }
  286. if (x_ <= p / q) {
  287. c = p;
  288. d = q;
  289. } else {
  290. a = p;
  291. b = q;
  292. }
  293. }
  294. var result = void 0;
  295. if (x_ - a / b < c / d - x_) {
  296. result = x_ === x ? [a, b] : [b, a];
  297. } else {
  298. result = x_ === x ? [c, d] : [d, c];
  299. }
  300. return result;
  301. }
  302. function roundToDivide(x, div) {
  303. var r = x % div;
  304. return r === 0 ? x : Math.round(x - r + div);
  305. }
  306. function getVisibleElements(scrollEl, views) {
  307. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  308. var top = scrollEl.scrollTop,
  309. bottom = top + scrollEl.clientHeight;
  310. var left = scrollEl.scrollLeft,
  311. right = left + scrollEl.clientWidth;
  312. function isElementBottomBelowViewTop(view) {
  313. var element = view.div;
  314. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  315. return elementBottom > top;
  316. }
  317. var visible = [],
  318. view = void 0,
  319. element = void 0;
  320. var currentHeight = void 0,
  321. viewHeight = void 0,
  322. hiddenHeight = void 0,
  323. percentHeight = void 0;
  324. var currentWidth = void 0,
  325. viewWidth = void 0;
  326. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  327. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  328. view = views[i];
  329. element = view.div;
  330. currentHeight = element.offsetTop + element.clientTop;
  331. viewHeight = element.clientHeight;
  332. if (currentHeight > bottom) {
  333. break;
  334. }
  335. currentWidth = element.offsetLeft + element.clientLeft;
  336. viewWidth = element.clientWidth;
  337. if (currentWidth + viewWidth < left || currentWidth > right) {
  338. continue;
  339. }
  340. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  341. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  342. visible.push({
  343. id: view.id,
  344. x: currentWidth,
  345. y: currentHeight,
  346. view: view,
  347. percent: percentHeight
  348. });
  349. }
  350. var first = visible[0];
  351. var last = visible[visible.length - 1];
  352. if (sortByVisibility) {
  353. visible.sort(function (a, b) {
  354. var pc = a.percent - b.percent;
  355. if (Math.abs(pc) > 0.001) {
  356. return -pc;
  357. }
  358. return a.id - b.id;
  359. });
  360. }
  361. return {
  362. first: first,
  363. last: last,
  364. views: visible
  365. };
  366. }
  367. function noContextMenuHandler(evt) {
  368. evt.preventDefault();
  369. }
  370. function isFileSchema(url) {
  371. var i = 0,
  372. ii = url.length;
  373. while (i < ii && url[i].trim() === '') {
  374. i++;
  375. }
  376. return url.substr(i, 7).toLowerCase() === 'file://';
  377. }
  378. function isDataSchema(url) {
  379. var i = 0,
  380. ii = url.length;
  381. while (i < ii && url[i].trim() === '') {
  382. i++;
  383. }
  384. return url.substr(i, 5).toLowerCase() === 'data:';
  385. }
  386. function getPDFFileNameFromURL(url) {
  387. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  388. if (isDataSchema(url)) {
  389. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  390. return defaultFilename;
  391. }
  392. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  393. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  394. var splitURI = reURI.exec(url);
  395. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  396. if (suggestedFilename) {
  397. suggestedFilename = suggestedFilename[0];
  398. if (suggestedFilename.includes('%')) {
  399. try {
  400. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  401. } catch (ex) {}
  402. }
  403. }
  404. return suggestedFilename || defaultFilename;
  405. }
  406. function normalizeWheelEventDelta(evt) {
  407. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  408. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  409. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  410. delta = -delta;
  411. }
  412. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  413. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  414. var MOUSE_PIXELS_PER_LINE = 30;
  415. var MOUSE_LINES_PER_PAGE = 30;
  416. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  417. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  418. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  419. delta /= MOUSE_LINES_PER_PAGE;
  420. }
  421. return delta;
  422. }
  423. function isValidRotation(angle) {
  424. return Number.isInteger(angle) && angle % 90 === 0;
  425. }
  426. function cloneObj(obj) {
  427. var result = Object.create(null);
  428. for (var i in obj) {
  429. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  430. result[i] = obj[i];
  431. }
  432. }
  433. return result;
  434. }
  435. var WaitOnType = {
  436. EVENT: 'event',
  437. TIMEOUT: 'timeout'
  438. };
  439. function waitOnEventOrTimeout(_ref) {
  440. var target = _ref.target,
  441. name = _ref.name,
  442. _ref$delay = _ref.delay,
  443. delay = _ref$delay === undefined ? 0 : _ref$delay;
  444. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  445. return Promise.reject(new Error('waitOnEventOrTimeout - invalid paramaters.'));
  446. }
  447. var capability = (0, _pdfjsLib.createPromiseCapability)();
  448. function handler(type) {
  449. if (target instanceof EventBus) {
  450. target.off(name, eventHandler);
  451. } else {
  452. target.removeEventListener(name, eventHandler);
  453. }
  454. if (timeout) {
  455. clearTimeout(timeout);
  456. }
  457. capability.resolve(type);
  458. }
  459. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  460. if (target instanceof EventBus) {
  461. target.on(name, eventHandler);
  462. } else {
  463. target.addEventListener(name, eventHandler);
  464. }
  465. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  466. var timeout = setTimeout(timeoutHandler, delay);
  467. return capability.promise;
  468. }
  469. var animationStarted = new Promise(function (resolve) {
  470. window.requestAnimationFrame(resolve);
  471. });
  472. var mozL10n = void 0;
  473. var localized = Promise.resolve();
  474. var EventBus = function () {
  475. function EventBus() {
  476. _classCallCheck(this, EventBus);
  477. this._listeners = Object.create(null);
  478. }
  479. _createClass(EventBus, [{
  480. key: 'on',
  481. value: function on(eventName, listener) {
  482. var eventListeners = this._listeners[eventName];
  483. if (!eventListeners) {
  484. eventListeners = [];
  485. this._listeners[eventName] = eventListeners;
  486. }
  487. eventListeners.push(listener);
  488. }
  489. }, {
  490. key: 'off',
  491. value: function off(eventName, listener) {
  492. var eventListeners = this._listeners[eventName];
  493. var i = void 0;
  494. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  495. return;
  496. }
  497. eventListeners.splice(i, 1);
  498. }
  499. }, {
  500. key: 'dispatch',
  501. value: function dispatch(eventName) {
  502. var eventListeners = this._listeners[eventName];
  503. if (!eventListeners || eventListeners.length === 0) {
  504. return;
  505. }
  506. var args = Array.prototype.slice.call(arguments, 1);
  507. eventListeners.slice(0).forEach(function (listener) {
  508. listener.apply(null, args);
  509. });
  510. }
  511. }]);
  512. return EventBus;
  513. }();
  514. function clamp(v, min, max) {
  515. return Math.min(Math.max(v, min), max);
  516. }
  517. var ProgressBar = function () {
  518. function ProgressBar(id) {
  519. var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  520. height = _ref2.height,
  521. width = _ref2.width,
  522. units = _ref2.units;
  523. _classCallCheck(this, ProgressBar);
  524. this.visible = true;
  525. this.div = document.querySelector(id + ' .progress');
  526. this.bar = this.div.parentNode;
  527. this.height = height || 100;
  528. this.width = width || 100;
  529. this.units = units || '%';
  530. this.div.style.height = this.height + this.units;
  531. this.percent = 0;
  532. }
  533. _createClass(ProgressBar, [{
  534. key: '_updateBar',
  535. value: function _updateBar() {
  536. if (this._indeterminate) {
  537. this.div.classList.add('indeterminate');
  538. this.div.style.width = this.width + this.units;
  539. return;
  540. }
  541. this.div.classList.remove('indeterminate');
  542. var progressSize = this.width * this._percent / 100;
  543. this.div.style.width = progressSize + this.units;
  544. }
  545. }, {
  546. key: 'setWidth',
  547. value: function setWidth(viewer) {
  548. if (!viewer) {
  549. return;
  550. }
  551. var container = viewer.parentNode;
  552. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  553. if (scrollbarWidth > 0) {
  554. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  555. }
  556. }
  557. }, {
  558. key: 'hide',
  559. value: function hide() {
  560. if (!this.visible) {
  561. return;
  562. }
  563. this.visible = false;
  564. this.bar.classList.add('hidden');
  565. document.body.classList.remove('loadingInProgress');
  566. }
  567. }, {
  568. key: 'show',
  569. value: function show() {
  570. if (this.visible) {
  571. return;
  572. }
  573. this.visible = true;
  574. document.body.classList.add('loadingInProgress');
  575. this.bar.classList.remove('hidden');
  576. }
  577. }, {
  578. key: 'percent',
  579. get: function get() {
  580. return this._percent;
  581. },
  582. set: function set(val) {
  583. this._indeterminate = isNaN(val);
  584. this._percent = clamp(val, 0, 100);
  585. this._updateBar();
  586. }
  587. }]);
  588. return ProgressBar;
  589. }();
  590. exports.CSS_UNITS = CSS_UNITS;
  591. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  592. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  593. exports.MIN_SCALE = MIN_SCALE;
  594. exports.MAX_SCALE = MAX_SCALE;
  595. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  596. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  597. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  598. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  599. exports.isValidRotation = isValidRotation;
  600. exports.isFileSchema = isFileSchema;
  601. exports.cloneObj = cloneObj;
  602. exports.PresentationModeState = PresentationModeState;
  603. exports.RendererType = RendererType;
  604. exports.mozL10n = mozL10n;
  605. exports.NullL10n = NullL10n;
  606. exports.EventBus = EventBus;
  607. exports.ProgressBar = ProgressBar;
  608. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  609. exports.noContextMenuHandler = noContextMenuHandler;
  610. exports.parseQueryString = parseQueryString;
  611. exports.getVisibleElements = getVisibleElements;
  612. exports.roundToDivide = roundToDivide;
  613. exports.approximateFraction = approximateFraction;
  614. exports.getOutputScale = getOutputScale;
  615. exports.scrollIntoView = scrollIntoView;
  616. exports.watchScroll = watchScroll;
  617. exports.binarySearchFirstItem = binarySearchFirstItem;
  618. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  619. exports.animationStarted = animationStarted;
  620. exports.localized = localized;
  621. exports.WaitOnType = WaitOnType;
  622. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  623. /***/ }),
  624. /* 2 */
  625. /***/ (function(module, exports, __w_pdfjs_require__) {
  626. "use strict";
  627. Object.defineProperty(exports, "__esModule", {
  628. value: true
  629. });
  630. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  631. var _ui_utils = __w_pdfjs_require__(1);
  632. function attachDOMEventsToEventBus(eventBus) {
  633. eventBus.on('documentload', function () {
  634. var event = document.createEvent('CustomEvent');
  635. event.initCustomEvent('documentload', true, true, {});
  636. window.dispatchEvent(event);
  637. });
  638. eventBus.on('pagerendered', function (evt) {
  639. var event = document.createEvent('CustomEvent');
  640. event.initCustomEvent('pagerendered', true, true, {
  641. pageNumber: evt.pageNumber,
  642. cssTransform: evt.cssTransform
  643. });
  644. evt.source.div.dispatchEvent(event);
  645. });
  646. eventBus.on('textlayerrendered', function (evt) {
  647. var event = document.createEvent('CustomEvent');
  648. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  649. evt.source.textLayerDiv.dispatchEvent(event);
  650. });
  651. eventBus.on('pagechange', function (evt) {
  652. var event = document.createEvent('UIEvents');
  653. event.initUIEvent('pagechange', true, true, window, 0);
  654. event.pageNumber = evt.pageNumber;
  655. evt.source.container.dispatchEvent(event);
  656. });
  657. eventBus.on('pagesinit', function (evt) {
  658. var event = document.createEvent('CustomEvent');
  659. event.initCustomEvent('pagesinit', true, true, null);
  660. evt.source.container.dispatchEvent(event);
  661. });
  662. eventBus.on('pagesloaded', function (evt) {
  663. var event = document.createEvent('CustomEvent');
  664. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  665. evt.source.container.dispatchEvent(event);
  666. });
  667. eventBus.on('scalechange', function (evt) {
  668. var event = document.createEvent('UIEvents');
  669. event.initUIEvent('scalechange', true, true, window, 0);
  670. event.scale = evt.scale;
  671. event.presetValue = evt.presetValue;
  672. evt.source.container.dispatchEvent(event);
  673. });
  674. eventBus.on('updateviewarea', function (evt) {
  675. var event = document.createEvent('UIEvents');
  676. event.initUIEvent('updateviewarea', true, true, window, 0);
  677. event.location = evt.location;
  678. evt.source.container.dispatchEvent(event);
  679. });
  680. eventBus.on('find', function (evt) {
  681. if (evt.source === window) {
  682. return;
  683. }
  684. var event = document.createEvent('CustomEvent');
  685. event.initCustomEvent('find' + evt.type, true, true, {
  686. query: evt.query,
  687. phraseSearch: evt.phraseSearch,
  688. caseSensitive: evt.caseSensitive,
  689. highlightAll: evt.highlightAll,
  690. findPrevious: evt.findPrevious
  691. });
  692. window.dispatchEvent(event);
  693. });
  694. eventBus.on('attachmentsloaded', function (evt) {
  695. var event = document.createEvent('CustomEvent');
  696. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  697. evt.source.container.dispatchEvent(event);
  698. });
  699. eventBus.on('sidebarviewchanged', function (evt) {
  700. var event = document.createEvent('CustomEvent');
  701. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  702. evt.source.outerContainer.dispatchEvent(event);
  703. });
  704. eventBus.on('pagemode', function (evt) {
  705. var event = document.createEvent('CustomEvent');
  706. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  707. evt.source.pdfViewer.container.dispatchEvent(event);
  708. });
  709. eventBus.on('namedaction', function (evt) {
  710. var event = document.createEvent('CustomEvent');
  711. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  712. evt.source.pdfViewer.container.dispatchEvent(event);
  713. });
  714. eventBus.on('presentationmodechanged', function (evt) {
  715. var event = document.createEvent('CustomEvent');
  716. event.initCustomEvent('presentationmodechanged', true, true, {
  717. active: evt.active,
  718. switchInProgress: evt.switchInProgress
  719. });
  720. window.dispatchEvent(event);
  721. });
  722. eventBus.on('outlineloaded', function (evt) {
  723. var event = document.createEvent('CustomEvent');
  724. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  725. evt.source.container.dispatchEvent(event);
  726. });
  727. }
  728. var globalEventBus = null;
  729. function getGlobalEventBus() {
  730. if (globalEventBus) {
  731. return globalEventBus;
  732. }
  733. globalEventBus = new _ui_utils.EventBus();
  734. attachDOMEventsToEventBus(globalEventBus);
  735. return globalEventBus;
  736. }
  737. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  738. exports.getGlobalEventBus = getGlobalEventBus;
  739. /***/ }),
  740. /* 3 */
  741. /***/ (function(module, exports, __w_pdfjs_require__) {
  742. "use strict";
  743. Object.defineProperty(exports, "__esModule", {
  744. value: true
  745. });
  746. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  747. 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; };
  748. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  749. var _dom_events = __w_pdfjs_require__(2);
  750. var _ui_utils = __w_pdfjs_require__(1);
  751. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  752. var PDFLinkService = function () {
  753. function PDFLinkService() {
  754. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  755. eventBus = _ref.eventBus;
  756. _classCallCheck(this, PDFLinkService);
  757. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  758. this.baseUrl = null;
  759. this.pdfDocument = null;
  760. this.pdfViewer = null;
  761. this.pdfHistory = null;
  762. this._pagesRefCache = null;
  763. }
  764. _createClass(PDFLinkService, [{
  765. key: 'setDocument',
  766. value: function setDocument(pdfDocument, baseUrl) {
  767. this.baseUrl = baseUrl;
  768. this.pdfDocument = pdfDocument;
  769. this._pagesRefCache = Object.create(null);
  770. }
  771. }, {
  772. key: 'setViewer',
  773. value: function setViewer(pdfViewer) {
  774. this.pdfViewer = pdfViewer;
  775. }
  776. }, {
  777. key: 'setHistory',
  778. value: function setHistory(pdfHistory) {
  779. this.pdfHistory = pdfHistory;
  780. }
  781. }, {
  782. key: 'navigateTo',
  783. value: function navigateTo(dest) {
  784. var _this = this;
  785. var goToDestination = function goToDestination(_ref2) {
  786. var namedDest = _ref2.namedDest,
  787. explicitDest = _ref2.explicitDest;
  788. var destRef = explicitDest[0],
  789. pageNumber = void 0;
  790. if (destRef instanceof Object) {
  791. pageNumber = _this._cachedPageNumber(destRef);
  792. if (pageNumber === null) {
  793. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  794. _this.cachePageRef(pageIndex + 1, destRef);
  795. goToDestination({
  796. namedDest: namedDest,
  797. explicitDest: explicitDest
  798. });
  799. }).catch(function () {
  800. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  801. });
  802. return;
  803. }
  804. } else if (Number.isInteger(destRef)) {
  805. pageNumber = destRef + 1;
  806. } else {
  807. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  808. return;
  809. }
  810. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  811. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  812. return;
  813. }
  814. if (_this.pdfHistory) {
  815. _this.pdfHistory.pushCurrentPosition();
  816. _this.pdfHistory.push({
  817. namedDest: namedDest,
  818. explicitDest: explicitDest,
  819. pageNumber: pageNumber
  820. });
  821. }
  822. _this.pdfViewer.scrollPageIntoView({
  823. pageNumber: pageNumber,
  824. destArray: explicitDest
  825. });
  826. };
  827. new Promise(function (resolve, reject) {
  828. if (typeof dest === 'string') {
  829. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  830. resolve({
  831. namedDest: dest,
  832. explicitDest: destArray
  833. });
  834. });
  835. return;
  836. }
  837. resolve({
  838. namedDest: '',
  839. explicitDest: dest
  840. });
  841. }).then(function (data) {
  842. if (!(data.explicitDest instanceof Array)) {
  843. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  844. return;
  845. }
  846. goToDestination(data);
  847. });
  848. }
  849. }, {
  850. key: 'getDestinationHash',
  851. value: function getDestinationHash(dest) {
  852. if (typeof dest === 'string') {
  853. return this.getAnchorUrl('#' + escape(dest));
  854. }
  855. if (dest instanceof Array) {
  856. var str = JSON.stringify(dest);
  857. return this.getAnchorUrl('#' + escape(str));
  858. }
  859. return this.getAnchorUrl('');
  860. }
  861. }, {
  862. key: 'getAnchorUrl',
  863. value: function getAnchorUrl(anchor) {
  864. return (this.baseUrl || '') + anchor;
  865. }
  866. }, {
  867. key: 'setHash',
  868. value: function setHash(hash) {
  869. var pageNumber = void 0,
  870. dest = void 0;
  871. if (hash.includes('=')) {
  872. var params = (0, _ui_utils.parseQueryString)(hash);
  873. if ('search' in params) {
  874. this.eventBus.dispatch('findfromurlhash', {
  875. source: this,
  876. query: params['search'].replace(/"/g, ''),
  877. phraseSearch: params['phrase'] === 'true'
  878. });
  879. }
  880. if ('nameddest' in params) {
  881. this.navigateTo(params.nameddest);
  882. return;
  883. }
  884. if ('page' in params) {
  885. pageNumber = params.page | 0 || 1;
  886. }
  887. if ('zoom' in params) {
  888. var zoomArgs = params.zoom.split(',');
  889. var zoomArg = zoomArgs[0];
  890. var zoomArgNumber = parseFloat(zoomArg);
  891. if (!zoomArg.includes('Fit')) {
  892. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  893. } else {
  894. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  895. dest = [null, { name: zoomArg }];
  896. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  897. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  898. } else if (zoomArg === 'FitR') {
  899. if (zoomArgs.length !== 5) {
  900. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  901. } else {
  902. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  903. }
  904. } else {
  905. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  906. }
  907. }
  908. }
  909. if (dest) {
  910. this.pdfViewer.scrollPageIntoView({
  911. pageNumber: pageNumber || this.page,
  912. destArray: dest,
  913. allowNegativeOffset: true
  914. });
  915. } else if (pageNumber) {
  916. this.page = pageNumber;
  917. }
  918. if ('pagemode' in params) {
  919. this.eventBus.dispatch('pagemode', {
  920. source: this,
  921. mode: params.pagemode
  922. });
  923. }
  924. } else {
  925. dest = unescape(hash);
  926. try {
  927. dest = JSON.parse(dest);
  928. if (!(dest instanceof Array)) {
  929. dest = dest.toString();
  930. }
  931. } catch (ex) {}
  932. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  933. this.navigateTo(dest);
  934. return;
  935. }
  936. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  937. }
  938. }
  939. }, {
  940. key: 'executeNamedAction',
  941. value: function executeNamedAction(action) {
  942. switch (action) {
  943. case 'GoBack':
  944. if (this.pdfHistory) {
  945. this.pdfHistory.back();
  946. }
  947. break;
  948. case 'GoForward':
  949. if (this.pdfHistory) {
  950. this.pdfHistory.forward();
  951. }
  952. break;
  953. case 'NextPage':
  954. if (this.page < this.pagesCount) {
  955. this.page++;
  956. }
  957. break;
  958. case 'PrevPage':
  959. if (this.page > 1) {
  960. this.page--;
  961. }
  962. break;
  963. case 'LastPage':
  964. this.page = this.pagesCount;
  965. break;
  966. case 'FirstPage':
  967. this.page = 1;
  968. break;
  969. default:
  970. break;
  971. }
  972. this.eventBus.dispatch('namedaction', {
  973. source: this,
  974. action: action
  975. });
  976. }
  977. }, {
  978. key: 'onFileAttachmentAnnotation',
  979. value: function onFileAttachmentAnnotation(_ref3) {
  980. var id = _ref3.id,
  981. filename = _ref3.filename,
  982. content = _ref3.content;
  983. this.eventBus.dispatch('fileattachmentannotation', {
  984. source: this,
  985. id: id,
  986. filename: filename,
  987. content: content
  988. });
  989. }
  990. }, {
  991. key: 'cachePageRef',
  992. value: function cachePageRef(pageNum, pageRef) {
  993. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  994. this._pagesRefCache[refStr] = pageNum;
  995. }
  996. }, {
  997. key: '_cachedPageNumber',
  998. value: function _cachedPageNumber(pageRef) {
  999. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1000. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1001. }
  1002. }, {
  1003. key: 'pagesCount',
  1004. get: function get() {
  1005. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1006. }
  1007. }, {
  1008. key: 'page',
  1009. get: function get() {
  1010. return this.pdfViewer.currentPageNumber;
  1011. },
  1012. set: function set(value) {
  1013. this.pdfViewer.currentPageNumber = value;
  1014. }
  1015. }, {
  1016. key: 'rotation',
  1017. get: function get() {
  1018. return this.pdfViewer.pagesRotation;
  1019. },
  1020. set: function set(value) {
  1021. this.pdfViewer.pagesRotation = value;
  1022. }
  1023. }]);
  1024. return PDFLinkService;
  1025. }();
  1026. function isValidExplicitDestination(dest) {
  1027. if (!(dest instanceof Array)) {
  1028. return false;
  1029. }
  1030. var destLength = dest.length,
  1031. allowNull = true;
  1032. if (destLength < 2) {
  1033. return false;
  1034. }
  1035. var page = dest[0];
  1036. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1037. return false;
  1038. }
  1039. var zoom = dest[1];
  1040. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  1041. return false;
  1042. }
  1043. switch (zoom.name) {
  1044. case 'XYZ':
  1045. if (destLength !== 5) {
  1046. return false;
  1047. }
  1048. break;
  1049. case 'Fit':
  1050. case 'FitB':
  1051. return destLength === 2;
  1052. case 'FitH':
  1053. case 'FitBH':
  1054. case 'FitV':
  1055. case 'FitBV':
  1056. if (destLength !== 3) {
  1057. return false;
  1058. }
  1059. break;
  1060. case 'FitR':
  1061. if (destLength !== 6) {
  1062. return false;
  1063. }
  1064. allowNull = false;
  1065. break;
  1066. default:
  1067. return false;
  1068. }
  1069. for (var i = 2; i < destLength; i++) {
  1070. var param = dest[i];
  1071. if (!(typeof param === 'number' || allowNull && param === null)) {
  1072. return false;
  1073. }
  1074. }
  1075. return true;
  1076. }
  1077. var SimpleLinkService = function () {
  1078. function SimpleLinkService() {
  1079. _classCallCheck(this, SimpleLinkService);
  1080. }
  1081. _createClass(SimpleLinkService, [{
  1082. key: 'navigateTo',
  1083. value: function navigateTo(dest) {}
  1084. }, {
  1085. key: 'getDestinationHash',
  1086. value: function getDestinationHash(dest) {
  1087. return '#';
  1088. }
  1089. }, {
  1090. key: 'getAnchorUrl',
  1091. value: function getAnchorUrl(hash) {
  1092. return '#';
  1093. }
  1094. }, {
  1095. key: 'setHash',
  1096. value: function setHash(hash) {}
  1097. }, {
  1098. key: 'executeNamedAction',
  1099. value: function executeNamedAction(action) {}
  1100. }, {
  1101. key: 'onFileAttachmentAnnotation',
  1102. value: function onFileAttachmentAnnotation(_ref4) {
  1103. var id = _ref4.id,
  1104. filename = _ref4.filename,
  1105. content = _ref4.content;
  1106. }
  1107. }, {
  1108. key: 'cachePageRef',
  1109. value: function cachePageRef(pageNum, pageRef) {}
  1110. }, {
  1111. key: 'page',
  1112. get: function get() {
  1113. return 0;
  1114. },
  1115. set: function set(value) {}
  1116. }, {
  1117. key: 'rotation',
  1118. get: function get() {
  1119. return 0;
  1120. },
  1121. set: function set(value) {}
  1122. }]);
  1123. return SimpleLinkService;
  1124. }();
  1125. exports.PDFLinkService = PDFLinkService;
  1126. exports.SimpleLinkService = SimpleLinkService;
  1127. /***/ }),
  1128. /* 4 */
  1129. /***/ (function(module, exports, __w_pdfjs_require__) {
  1130. "use strict";
  1131. Object.defineProperty(exports, "__esModule", {
  1132. value: true
  1133. });
  1134. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  1135. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1136. var _pdfjsLib = __w_pdfjs_require__(0);
  1137. var _ui_utils = __w_pdfjs_require__(1);
  1138. var _pdf_link_service = __w_pdfjs_require__(3);
  1139. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1140. var AnnotationLayerBuilder = function () {
  1141. function AnnotationLayerBuilder(_ref) {
  1142. var pageDiv = _ref.pageDiv,
  1143. pdfPage = _ref.pdfPage,
  1144. linkService = _ref.linkService,
  1145. downloadManager = _ref.downloadManager,
  1146. _ref$renderInteractiv = _ref.renderInteractiveForms,
  1147. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  1148. _ref$l10n = _ref.l10n,
  1149. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  1150. _classCallCheck(this, AnnotationLayerBuilder);
  1151. this.pageDiv = pageDiv;
  1152. this.pdfPage = pdfPage;
  1153. this.linkService = linkService;
  1154. this.downloadManager = downloadManager;
  1155. this.renderInteractiveForms = renderInteractiveForms;
  1156. this.l10n = l10n;
  1157. this.div = null;
  1158. this._cancelled = false;
  1159. }
  1160. _createClass(AnnotationLayerBuilder, [{
  1161. key: 'render',
  1162. value: function render(viewport) {
  1163. var _this = this;
  1164. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  1165. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  1166. if (_this._cancelled) {
  1167. return;
  1168. }
  1169. var parameters = {
  1170. viewport: viewport.clone({ dontFlip: true }),
  1171. div: _this.div,
  1172. annotations: annotations,
  1173. page: _this.pdfPage,
  1174. renderInteractiveForms: _this.renderInteractiveForms,
  1175. linkService: _this.linkService,
  1176. downloadManager: _this.downloadManager
  1177. };
  1178. if (_this.div) {
  1179. _pdfjsLib.AnnotationLayer.update(parameters);
  1180. } else {
  1181. if (annotations.length === 0) {
  1182. return;
  1183. }
  1184. _this.div = document.createElement('div');
  1185. _this.div.className = 'annotationLayer';
  1186. _this.pageDiv.appendChild(_this.div);
  1187. parameters.div = _this.div;
  1188. _pdfjsLib.AnnotationLayer.render(parameters);
  1189. _this.l10n.translate(_this.div);
  1190. }
  1191. });
  1192. }
  1193. }, {
  1194. key: 'cancel',
  1195. value: function cancel() {
  1196. this._cancelled = true;
  1197. }
  1198. }, {
  1199. key: 'hide',
  1200. value: function hide() {
  1201. if (!this.div) {
  1202. return;
  1203. }
  1204. this.div.setAttribute('hidden', 'true');
  1205. }
  1206. }]);
  1207. return AnnotationLayerBuilder;
  1208. }();
  1209. var DefaultAnnotationLayerFactory = function () {
  1210. function DefaultAnnotationLayerFactory() {
  1211. _classCallCheck(this, DefaultAnnotationLayerFactory);
  1212. }
  1213. _createClass(DefaultAnnotationLayerFactory, [{
  1214. key: 'createAnnotationLayerBuilder',
  1215. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  1216. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1217. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  1218. return new AnnotationLayerBuilder({
  1219. pageDiv: pageDiv,
  1220. pdfPage: pdfPage,
  1221. renderInteractiveForms: renderInteractiveForms,
  1222. linkService: new _pdf_link_service.SimpleLinkService(),
  1223. l10n: l10n
  1224. });
  1225. }
  1226. }]);
  1227. return DefaultAnnotationLayerFactory;
  1228. }();
  1229. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  1230. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  1231. /***/ }),
  1232. /* 5 */
  1233. /***/ (function(module, exports, __w_pdfjs_require__) {
  1234. "use strict";
  1235. Object.defineProperty(exports, "__esModule", {
  1236. value: true
  1237. });
  1238. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  1239. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1240. var _dom_events = __w_pdfjs_require__(2);
  1241. var _pdfjsLib = __w_pdfjs_require__(0);
  1242. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1243. var EXPAND_DIVS_TIMEOUT = 300;
  1244. var TextLayerBuilder = function () {
  1245. function TextLayerBuilder(_ref) {
  1246. var textLayerDiv = _ref.textLayerDiv,
  1247. eventBus = _ref.eventBus,
  1248. pageIndex = _ref.pageIndex,
  1249. viewport = _ref.viewport,
  1250. _ref$findController = _ref.findController,
  1251. findController = _ref$findController === undefined ? null : _ref$findController,
  1252. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  1253. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  1254. _classCallCheck(this, TextLayerBuilder);
  1255. this.textLayerDiv = textLayerDiv;
  1256. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  1257. this.textContent = null;
  1258. this.textContentItemsStr = [];
  1259. this.textContentStream = null;
  1260. this.renderingDone = false;
  1261. this.pageIdx = pageIndex;
  1262. this.pageNumber = this.pageIdx + 1;
  1263. this.matches = [];
  1264. this.viewport = viewport;
  1265. this.textDivs = [];
  1266. this.findController = findController;
  1267. this.textLayerRenderTask = null;
  1268. this.enhanceTextSelection = enhanceTextSelection;
  1269. this._bindMouse();
  1270. }
  1271. _createClass(TextLayerBuilder, [{
  1272. key: '_finishRendering',
  1273. value: function _finishRendering() {
  1274. this.renderingDone = true;
  1275. if (!this.enhanceTextSelection) {
  1276. var endOfContent = document.createElement('div');
  1277. endOfContent.className = 'endOfContent';
  1278. this.textLayerDiv.appendChild(endOfContent);
  1279. }
  1280. this.eventBus.dispatch('textlayerrendered', {
  1281. source: this,
  1282. pageNumber: this.pageNumber,
  1283. numTextDivs: this.textDivs.length
  1284. });
  1285. }
  1286. }, {
  1287. key: 'render',
  1288. value: function render() {
  1289. var _this = this;
  1290. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1291. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  1292. return;
  1293. }
  1294. this.cancel();
  1295. this.textDivs = [];
  1296. var textLayerFrag = document.createDocumentFragment();
  1297. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  1298. textContent: this.textContent,
  1299. textContentStream: this.textContentStream,
  1300. container: textLayerFrag,
  1301. viewport: this.viewport,
  1302. textDivs: this.textDivs,
  1303. textContentItemsStr: this.textContentItemsStr,
  1304. timeout: timeout,
  1305. enhanceTextSelection: this.enhanceTextSelection
  1306. });
  1307. this.textLayerRenderTask.promise.then(function () {
  1308. _this.textLayerDiv.appendChild(textLayerFrag);
  1309. _this._finishRendering();
  1310. _this.updateMatches();
  1311. }, function (reason) {});
  1312. }
  1313. }, {
  1314. key: 'cancel',
  1315. value: function cancel() {
  1316. if (this.textLayerRenderTask) {
  1317. this.textLayerRenderTask.cancel();
  1318. this.textLayerRenderTask = null;
  1319. }
  1320. }
  1321. }, {
  1322. key: 'setTextContentStream',
  1323. value: function setTextContentStream(readableStream) {
  1324. this.cancel();
  1325. this.textContentStream = readableStream;
  1326. }
  1327. }, {
  1328. key: 'setTextContent',
  1329. value: function setTextContent(textContent) {
  1330. this.cancel();
  1331. this.textContent = textContent;
  1332. }
  1333. }, {
  1334. key: 'convertMatches',
  1335. value: function convertMatches(matches, matchesLength) {
  1336. var i = 0;
  1337. var iIndex = 0;
  1338. var textContentItemsStr = this.textContentItemsStr;
  1339. var end = textContentItemsStr.length - 1;
  1340. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  1341. var ret = [];
  1342. if (!matches) {
  1343. return ret;
  1344. }
  1345. for (var m = 0, len = matches.length; m < len; m++) {
  1346. var matchIdx = matches[m];
  1347. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  1348. iIndex += textContentItemsStr[i].length;
  1349. i++;
  1350. }
  1351. if (i === textContentItemsStr.length) {
  1352. console.error('Could not find a matching mapping');
  1353. }
  1354. var match = {
  1355. begin: {
  1356. divIdx: i,
  1357. offset: matchIdx - iIndex
  1358. }
  1359. };
  1360. if (matchesLength) {
  1361. matchIdx += matchesLength[m];
  1362. } else {
  1363. matchIdx += queryLen;
  1364. }
  1365. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  1366. iIndex += textContentItemsStr[i].length;
  1367. i++;
  1368. }
  1369. match.end = {
  1370. divIdx: i,
  1371. offset: matchIdx - iIndex
  1372. };
  1373. ret.push(match);
  1374. }
  1375. return ret;
  1376. }
  1377. }, {
  1378. key: 'renderMatches',
  1379. value: function renderMatches(matches) {
  1380. if (matches.length === 0) {
  1381. return;
  1382. }
  1383. var textContentItemsStr = this.textContentItemsStr;
  1384. var textDivs = this.textDivs;
  1385. var prevEnd = null;
  1386. var pageIdx = this.pageIdx;
  1387. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  1388. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  1389. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  1390. var infinity = {
  1391. divIdx: -1,
  1392. offset: undefined
  1393. };
  1394. function beginText(begin, className) {
  1395. var divIdx = begin.divIdx;
  1396. textDivs[divIdx].textContent = '';
  1397. appendTextToDiv(divIdx, 0, begin.offset, className);
  1398. }
  1399. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  1400. var div = textDivs[divIdx];
  1401. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  1402. var node = document.createTextNode(content);
  1403. if (className) {
  1404. var span = document.createElement('span');
  1405. span.className = className;
  1406. span.appendChild(node);
  1407. div.appendChild(span);
  1408. return;
  1409. }
  1410. div.appendChild(node);
  1411. }
  1412. var i0 = selectedMatchIdx,
  1413. i1 = i0 + 1;
  1414. if (highlightAll) {
  1415. i0 = 0;
  1416. i1 = matches.length;
  1417. } else if (!isSelectedPage) {
  1418. return;
  1419. }
  1420. for (var i = i0; i < i1; i++) {
  1421. var match = matches[i];
  1422. var begin = match.begin;
  1423. var end = match.end;
  1424. var isSelected = isSelectedPage && i === selectedMatchIdx;
  1425. var highlightSuffix = isSelected ? ' selected' : '';
  1426. if (this.findController) {
  1427. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
  1428. }
  1429. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  1430. if (prevEnd !== null) {
  1431. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1432. }
  1433. beginText(begin);
  1434. } else {
  1435. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  1436. }
  1437. if (begin.divIdx === end.divIdx) {
  1438. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  1439. } else {
  1440. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  1441. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  1442. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  1443. }
  1444. beginText(end, 'highlight end' + highlightSuffix);
  1445. }
  1446. prevEnd = end;
  1447. }
  1448. if (prevEnd) {
  1449. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1450. }
  1451. }
  1452. }, {
  1453. key: 'updateMatches',
  1454. value: function updateMatches() {
  1455. if (!this.renderingDone) {
  1456. return;
  1457. }
  1458. var matches = this.matches;
  1459. var textDivs = this.textDivs;
  1460. var textContentItemsStr = this.textContentItemsStr;
  1461. var clearedUntilDivIdx = -1;
  1462. for (var i = 0, len = matches.length; i < len; i++) {
  1463. var match = matches[i];
  1464. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  1465. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  1466. var div = textDivs[n];
  1467. div.textContent = textContentItemsStr[n];
  1468. div.className = '';
  1469. }
  1470. clearedUntilDivIdx = match.end.divIdx + 1;
  1471. }
  1472. if (this.findController === null || !this.findController.active) {
  1473. return;
  1474. }
  1475. var pageMatches = void 0,
  1476. pageMatchesLength = void 0;
  1477. if (this.findController !== null) {
  1478. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  1479. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  1480. }
  1481. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  1482. this.renderMatches(this.matches);
  1483. }
  1484. }, {
  1485. key: '_bindMouse',
  1486. value: function _bindMouse() {
  1487. var _this2 = this;
  1488. var div = this.textLayerDiv;
  1489. var expandDivsTimer = null;
  1490. div.addEventListener('mousedown', function (evt) {
  1491. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1492. _this2.textLayerRenderTask.expandTextDivs(true);
  1493. if (expandDivsTimer) {
  1494. clearTimeout(expandDivsTimer);
  1495. expandDivsTimer = null;
  1496. }
  1497. return;
  1498. }
  1499. var end = div.querySelector('.endOfContent');
  1500. if (!end) {
  1501. return;
  1502. }
  1503. var adjustTop = evt.target !== div;
  1504. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  1505. if (adjustTop) {
  1506. var divBounds = div.getBoundingClientRect();
  1507. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  1508. end.style.top = (r * 100).toFixed(2) + '%';
  1509. }
  1510. end.classList.add('active');
  1511. });
  1512. div.addEventListener('mouseup', function () {
  1513. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1514. expandDivsTimer = setTimeout(function () {
  1515. if (_this2.textLayerRenderTask) {
  1516. _this2.textLayerRenderTask.expandTextDivs(false);
  1517. }
  1518. expandDivsTimer = null;
  1519. }, EXPAND_DIVS_TIMEOUT);
  1520. return;
  1521. }
  1522. var end = div.querySelector('.endOfContent');
  1523. if (!end) {
  1524. return;
  1525. }
  1526. end.style.top = '';
  1527. end.classList.remove('active');
  1528. });
  1529. }
  1530. }]);
  1531. return TextLayerBuilder;
  1532. }();
  1533. var DefaultTextLayerFactory = function () {
  1534. function DefaultTextLayerFactory() {
  1535. _classCallCheck(this, DefaultTextLayerFactory);
  1536. }
  1537. _createClass(DefaultTextLayerFactory, [{
  1538. key: 'createTextLayerBuilder',
  1539. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  1540. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1541. return new TextLayerBuilder({
  1542. textLayerDiv: textLayerDiv,
  1543. pageIndex: pageIndex,
  1544. viewport: viewport,
  1545. enhanceTextSelection: enhanceTextSelection
  1546. });
  1547. }
  1548. }]);
  1549. return DefaultTextLayerFactory;
  1550. }();
  1551. exports.TextLayerBuilder = TextLayerBuilder;
  1552. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  1553. /***/ }),
  1554. /* 6 */
  1555. /***/ (function(module, exports, __w_pdfjs_require__) {
  1556. "use strict";
  1557. Object.defineProperty(exports, "__esModule", {
  1558. value: true
  1559. });
  1560. exports.PDFPageView = undefined;
  1561. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1562. var _ui_utils = __w_pdfjs_require__(1);
  1563. var _pdfjsLib = __w_pdfjs_require__(0);
  1564. var _dom_events = __w_pdfjs_require__(2);
  1565. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  1566. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1567. var PDFPageView = function () {
  1568. function PDFPageView(options) {
  1569. _classCallCheck(this, PDFPageView);
  1570. var container = options.container;
  1571. var defaultViewport = options.defaultViewport;
  1572. this.id = options.id;
  1573. this.renderingId = 'page' + this.id;
  1574. this.pdfPage = null;
  1575. this.pageLabel = null;
  1576. this.rotation = 0;
  1577. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  1578. this.viewport = defaultViewport;
  1579. this.pdfPageRotate = defaultViewport.rotation;
  1580. this.hasRestrictedScaling = false;
  1581. this.enhanceTextSelection = options.enhanceTextSelection || false;
  1582. this.renderInteractiveForms = options.renderInteractiveForms || false;
  1583. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  1584. this.renderingQueue = options.renderingQueue;
  1585. this.textLayerFactory = options.textLayerFactory;
  1586. this.annotationLayerFactory = options.annotationLayerFactory;
  1587. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  1588. this.l10n = options.l10n || _ui_utils.NullL10n;
  1589. this.paintTask = null;
  1590. this.paintedViewportMap = new WeakMap();
  1591. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1592. this.resume = null;
  1593. this.error = null;
  1594. this.onBeforeDraw = null;
  1595. this.onAfterDraw = null;
  1596. this.annotationLayer = null;
  1597. this.textLayer = null;
  1598. this.zoomLayer = null;
  1599. var div = document.createElement('div');
  1600. div.className = 'page';
  1601. div.style.width = Math.floor(this.viewport.width) + 'px';
  1602. div.style.height = Math.floor(this.viewport.height) + 'px';
  1603. div.setAttribute('data-page-number', this.id);
  1604. this.div = div;
  1605. container.appendChild(div);
  1606. }
  1607. _createClass(PDFPageView, [{
  1608. key: 'setPdfPage',
  1609. value: function setPdfPage(pdfPage) {
  1610. this.pdfPage = pdfPage;
  1611. this.pdfPageRotate = pdfPage.rotate;
  1612. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1613. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  1614. this.stats = pdfPage.stats;
  1615. this.reset();
  1616. }
  1617. }, {
  1618. key: 'destroy',
  1619. value: function destroy() {
  1620. this.reset();
  1621. if (this.pdfPage) {
  1622. this.pdfPage.cleanup();
  1623. }
  1624. }
  1625. }, {
  1626. key: '_resetZoomLayer',
  1627. value: function _resetZoomLayer() {
  1628. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1629. if (!this.zoomLayer) {
  1630. return;
  1631. }
  1632. var zoomLayerCanvas = this.zoomLayer.firstChild;
  1633. this.paintedViewportMap.delete(zoomLayerCanvas);
  1634. zoomLayerCanvas.width = 0;
  1635. zoomLayerCanvas.height = 0;
  1636. if (removeFromDOM) {
  1637. this.zoomLayer.remove();
  1638. }
  1639. this.zoomLayer = null;
  1640. }
  1641. }, {
  1642. key: 'reset',
  1643. value: function reset() {
  1644. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1645. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1646. this.cancelRendering(keepAnnotations);
  1647. var div = this.div;
  1648. div.style.width = Math.floor(this.viewport.width) + 'px';
  1649. div.style.height = Math.floor(this.viewport.height) + 'px';
  1650. var childNodes = div.childNodes;
  1651. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  1652. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  1653. for (var i = childNodes.length - 1; i >= 0; i--) {
  1654. var node = childNodes[i];
  1655. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  1656. continue;
  1657. }
  1658. div.removeChild(node);
  1659. }
  1660. div.removeAttribute('data-loaded');
  1661. if (currentAnnotationNode) {
  1662. this.annotationLayer.hide();
  1663. } else if (this.annotationLayer) {
  1664. this.annotationLayer.cancel();
  1665. this.annotationLayer = null;
  1666. }
  1667. if (!currentZoomLayerNode) {
  1668. if (this.canvas) {
  1669. this.paintedViewportMap.delete(this.canvas);
  1670. this.canvas.width = 0;
  1671. this.canvas.height = 0;
  1672. delete this.canvas;
  1673. }
  1674. this._resetZoomLayer();
  1675. }
  1676. if (this.svg) {
  1677. this.paintedViewportMap.delete(this.svg);
  1678. delete this.svg;
  1679. }
  1680. this.loadingIconDiv = document.createElement('div');
  1681. this.loadingIconDiv.className = 'loadingIcon';
  1682. div.appendChild(this.loadingIconDiv);
  1683. }
  1684. }, {
  1685. key: 'update',
  1686. value: function update(scale, rotation) {
  1687. this.scale = scale || this.scale;
  1688. if (typeof rotation !== 'undefined') {
  1689. this.rotation = rotation;
  1690. }
  1691. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1692. this.viewport = this.viewport.clone({
  1693. scale: this.scale * _ui_utils.CSS_UNITS,
  1694. rotation: totalRotation
  1695. });
  1696. if (this.svg) {
  1697. this.cssTransform(this.svg, true);
  1698. this.eventBus.dispatch('pagerendered', {
  1699. source: this,
  1700. pageNumber: this.id,
  1701. cssTransform: true
  1702. });
  1703. return;
  1704. }
  1705. var isScalingRestricted = false;
  1706. if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  1707. var outputScale = this.outputScale;
  1708. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {
  1709. isScalingRestricted = true;
  1710. }
  1711. }
  1712. if (this.canvas) {
  1713. if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  1714. this.cssTransform(this.canvas, true);
  1715. this.eventBus.dispatch('pagerendered', {
  1716. source: this,
  1717. pageNumber: this.id,
  1718. cssTransform: true
  1719. });
  1720. return;
  1721. }
  1722. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  1723. this.zoomLayer = this.canvas.parentNode;
  1724. this.zoomLayer.style.position = 'absolute';
  1725. }
  1726. }
  1727. if (this.zoomLayer) {
  1728. this.cssTransform(this.zoomLayer.firstChild);
  1729. }
  1730. this.reset(true, true);
  1731. }
  1732. }, {
  1733. key: 'cancelRendering',
  1734. value: function cancelRendering() {
  1735. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1736. if (this.paintTask) {
  1737. this.paintTask.cancel();
  1738. this.paintTask = null;
  1739. }
  1740. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1741. this.resume = null;
  1742. if (this.textLayer) {
  1743. this.textLayer.cancel();
  1744. this.textLayer = null;
  1745. }
  1746. if (!keepAnnotations && this.annotationLayer) {
  1747. this.annotationLayer.cancel();
  1748. this.annotationLayer = null;
  1749. }
  1750. }
  1751. }, {
  1752. key: 'cssTransform',
  1753. value: function cssTransform(target) {
  1754. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1755. var width = this.viewport.width;
  1756. var height = this.viewport.height;
  1757. var div = this.div;
  1758. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  1759. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  1760. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  1761. var absRotation = Math.abs(relativeRotation);
  1762. var scaleX = 1,
  1763. scaleY = 1;
  1764. if (absRotation === 90 || absRotation === 270) {
  1765. scaleX = height / width;
  1766. scaleY = width / height;
  1767. }
  1768. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  1769. target.style.transform = cssTransform;
  1770. if (this.textLayer) {
  1771. var textLayerViewport = this.textLayer.viewport;
  1772. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  1773. var textAbsRotation = Math.abs(textRelativeRotation);
  1774. var scale = width / textLayerViewport.width;
  1775. if (textAbsRotation === 90 || textAbsRotation === 270) {
  1776. scale = width / textLayerViewport.height;
  1777. }
  1778. var textLayerDiv = this.textLayer.textLayerDiv;
  1779. var transX = void 0,
  1780. transY = void 0;
  1781. switch (textAbsRotation) {
  1782. case 0:
  1783. transX = transY = 0;
  1784. break;
  1785. case 90:
  1786. transX = 0;
  1787. transY = '-' + textLayerDiv.style.height;
  1788. break;
  1789. case 180:
  1790. transX = '-' + textLayerDiv.style.width;
  1791. transY = '-' + textLayerDiv.style.height;
  1792. break;
  1793. case 270:
  1794. transX = '-' + textLayerDiv.style.width;
  1795. transY = 0;
  1796. break;
  1797. default:
  1798. console.error('Bad rotation value.');
  1799. break;
  1800. }
  1801. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  1802. textLayerDiv.style.transformOrigin = '0% 0%';
  1803. }
  1804. if (redrawAnnotations && this.annotationLayer) {
  1805. this.annotationLayer.render(this.viewport, 'display');
  1806. }
  1807. }
  1808. }, {
  1809. key: 'getPagePoint',
  1810. value: function getPagePoint(x, y) {
  1811. return this.viewport.convertToPdfPoint(x, y);
  1812. }
  1813. }, {
  1814. key: 'draw',
  1815. value: function draw() {
  1816. var _this = this;
  1817. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  1818. console.error('Must be in new state before drawing');
  1819. this.reset();
  1820. }
  1821. if (!this.pdfPage) {
  1822. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1823. return Promise.reject(new Error('Page is not loaded'));
  1824. }
  1825. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1826. var pdfPage = this.pdfPage;
  1827. var div = this.div;
  1828. var canvasWrapper = document.createElement('div');
  1829. canvasWrapper.style.width = div.style.width;
  1830. canvasWrapper.style.height = div.style.height;
  1831. canvasWrapper.classList.add('canvasWrapper');
  1832. if (this.annotationLayer && this.annotationLayer.div) {
  1833. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  1834. } else {
  1835. div.appendChild(canvasWrapper);
  1836. }
  1837. var textLayer = null;
  1838. if (this.textLayerFactory) {
  1839. var textLayerDiv = document.createElement('div');
  1840. textLayerDiv.className = 'textLayer';
  1841. textLayerDiv.style.width = canvasWrapper.style.width;
  1842. textLayerDiv.style.height = canvasWrapper.style.height;
  1843. if (this.annotationLayer && this.annotationLayer.div) {
  1844. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  1845. } else {
  1846. div.appendChild(textLayerDiv);
  1847. }
  1848. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);
  1849. }
  1850. this.textLayer = textLayer;
  1851. var renderContinueCallback = null;
  1852. if (this.renderingQueue) {
  1853. renderContinueCallback = function renderContinueCallback(cont) {
  1854. if (!_this.renderingQueue.isHighestPriority(_this)) {
  1855. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  1856. _this.resume = function () {
  1857. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1858. cont();
  1859. };
  1860. return;
  1861. }
  1862. cont();
  1863. };
  1864. }
  1865. var finishPaintTask = function finishPaintTask(error) {
  1866. if (paintTask === _this.paintTask) {
  1867. _this.paintTask = null;
  1868. }
  1869. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  1870. _this.error = null;
  1871. return Promise.resolve(undefined);
  1872. }
  1873. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1874. if (_this.loadingIconDiv) {
  1875. div.removeChild(_this.loadingIconDiv);
  1876. delete _this.loadingIconDiv;
  1877. }
  1878. _this._resetZoomLayer(true);
  1879. _this.error = error;
  1880. _this.stats = pdfPage.stats;
  1881. if (_this.onAfterDraw) {
  1882. _this.onAfterDraw();
  1883. }
  1884. _this.eventBus.dispatch('pagerendered', {
  1885. source: _this,
  1886. pageNumber: _this.id,
  1887. cssTransform: false
  1888. });
  1889. if (error) {
  1890. return Promise.reject(error);
  1891. }
  1892. return Promise.resolve(undefined);
  1893. };
  1894. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  1895. paintTask.onRenderContinue = renderContinueCallback;
  1896. this.paintTask = paintTask;
  1897. var resultPromise = paintTask.promise.then(function () {
  1898. return finishPaintTask(null).then(function () {
  1899. if (textLayer) {
  1900. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  1901. textLayer.setTextContentStream(readableStream);
  1902. textLayer.render();
  1903. }
  1904. });
  1905. }, function (reason) {
  1906. return finishPaintTask(reason);
  1907. });
  1908. if (this.annotationLayerFactory) {
  1909. if (!this.annotationLayer) {
  1910. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
  1911. }
  1912. this.annotationLayer.render(this.viewport, 'display');
  1913. }
  1914. div.setAttribute('data-loaded', true);
  1915. if (this.onBeforeDraw) {
  1916. this.onBeforeDraw();
  1917. }
  1918. return resultPromise;
  1919. }
  1920. }, {
  1921. key: 'paintOnCanvas',
  1922. value: function paintOnCanvas(canvasWrapper) {
  1923. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  1924. var result = {
  1925. promise: renderCapability.promise,
  1926. onRenderContinue: function onRenderContinue(cont) {
  1927. cont();
  1928. },
  1929. cancel: function cancel() {
  1930. renderTask.cancel();
  1931. }
  1932. };
  1933. var viewport = this.viewport;
  1934. var canvas = document.createElement('canvas');
  1935. canvas.id = this.renderingId;
  1936. canvas.setAttribute('hidden', 'hidden');
  1937. var isCanvasHidden = true;
  1938. var showCanvas = function showCanvas() {
  1939. if (isCanvasHidden) {
  1940. canvas.removeAttribute('hidden');
  1941. isCanvasHidden = false;
  1942. }
  1943. };
  1944. canvasWrapper.appendChild(canvas);
  1945. this.canvas = canvas;
  1946. canvas.mozOpaque = true;
  1947. var ctx = canvas.getContext('2d', { alpha: false });
  1948. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  1949. this.outputScale = outputScale;
  1950. if (_pdfjsLib.PDFJS.useOnlyCssZoom) {
  1951. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  1952. outputScale.sx *= actualSizeViewport.width / viewport.width;
  1953. outputScale.sy *= actualSizeViewport.height / viewport.height;
  1954. outputScale.scaled = true;
  1955. }
  1956. if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  1957. var pixelsInViewport = viewport.width * viewport.height;
  1958. var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
  1959. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  1960. outputScale.sx = maxScale;
  1961. outputScale.sy = maxScale;
  1962. outputScale.scaled = true;
  1963. this.hasRestrictedScaling = true;
  1964. } else {
  1965. this.hasRestrictedScaling = false;
  1966. }
  1967. }
  1968. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  1969. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  1970. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  1971. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  1972. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  1973. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  1974. this.paintedViewportMap.set(canvas, viewport);
  1975. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  1976. var renderContext = {
  1977. canvasContext: ctx,
  1978. transform: transform,
  1979. viewport: this.viewport,
  1980. renderInteractiveForms: this.renderInteractiveForms
  1981. };
  1982. var renderTask = this.pdfPage.render(renderContext);
  1983. renderTask.onContinue = function (cont) {
  1984. showCanvas();
  1985. if (result.onRenderContinue) {
  1986. result.onRenderContinue(cont);
  1987. } else {
  1988. cont();
  1989. }
  1990. };
  1991. renderTask.promise.then(function () {
  1992. showCanvas();
  1993. renderCapability.resolve(undefined);
  1994. }, function (error) {
  1995. showCanvas();
  1996. renderCapability.reject(error);
  1997. });
  1998. return result;
  1999. }
  2000. }, {
  2001. key: 'paintOnSvg',
  2002. value: function paintOnSvg(wrapper) {
  2003. var _this2 = this;
  2004. var cancelled = false;
  2005. var ensureNotCancelled = function ensureNotCancelled() {
  2006. if (cancelled) {
  2007. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  2008. }
  2009. };
  2010. var pdfPage = this.pdfPage;
  2011. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  2012. var promise = pdfPage.getOperatorList().then(function (opList) {
  2013. ensureNotCancelled();
  2014. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  2015. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  2016. ensureNotCancelled();
  2017. _this2.svg = svg;
  2018. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  2019. svg.style.width = wrapper.style.width;
  2020. svg.style.height = wrapper.style.height;
  2021. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  2022. wrapper.appendChild(svg);
  2023. });
  2024. });
  2025. return {
  2026. promise: promise,
  2027. onRenderContinue: function onRenderContinue(cont) {
  2028. cont();
  2029. },
  2030. cancel: function cancel() {
  2031. cancelled = true;
  2032. }
  2033. };
  2034. }
  2035. }, {
  2036. key: 'setPageLabel',
  2037. value: function setPageLabel(label) {
  2038. this.pageLabel = typeof label === 'string' ? label : null;
  2039. if (this.pageLabel !== null) {
  2040. this.div.setAttribute('data-page-label', this.pageLabel);
  2041. } else {
  2042. this.div.removeAttribute('data-page-label');
  2043. }
  2044. }
  2045. }, {
  2046. key: 'width',
  2047. get: function get() {
  2048. return this.viewport.width;
  2049. }
  2050. }, {
  2051. key: 'height',
  2052. get: function get() {
  2053. return this.viewport.height;
  2054. }
  2055. }]);
  2056. return PDFPageView;
  2057. }();
  2058. exports.PDFPageView = PDFPageView;
  2059. /***/ }),
  2060. /* 7 */
  2061. /***/ (function(module, exports, __w_pdfjs_require__) {
  2062. "use strict";
  2063. Object.defineProperty(exports, "__esModule", {
  2064. value: true
  2065. });
  2066. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2067. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2068. var CLEANUP_TIMEOUT = 30000;
  2069. var RenderingStates = {
  2070. INITIAL: 0,
  2071. RUNNING: 1,
  2072. PAUSED: 2,
  2073. FINISHED: 3
  2074. };
  2075. var PDFRenderingQueue = function () {
  2076. function PDFRenderingQueue() {
  2077. _classCallCheck(this, PDFRenderingQueue);
  2078. this.pdfViewer = null;
  2079. this.pdfThumbnailViewer = null;
  2080. this.onIdle = null;
  2081. this.highestPriorityPage = null;
  2082. this.idleTimeout = null;
  2083. this.printing = false;
  2084. this.isThumbnailViewEnabled = false;
  2085. }
  2086. _createClass(PDFRenderingQueue, [{
  2087. key: "setViewer",
  2088. value: function setViewer(pdfViewer) {
  2089. this.pdfViewer = pdfViewer;
  2090. }
  2091. }, {
  2092. key: "setThumbnailViewer",
  2093. value: function setThumbnailViewer(pdfThumbnailViewer) {
  2094. this.pdfThumbnailViewer = pdfThumbnailViewer;
  2095. }
  2096. }, {
  2097. key: "isHighestPriority",
  2098. value: function isHighestPriority(view) {
  2099. return this.highestPriorityPage === view.renderingId;
  2100. }
  2101. }, {
  2102. key: "renderHighestPriority",
  2103. value: function renderHighestPriority(currentlyVisiblePages) {
  2104. if (this.idleTimeout) {
  2105. clearTimeout(this.idleTimeout);
  2106. this.idleTimeout = null;
  2107. }
  2108. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  2109. return;
  2110. }
  2111. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  2112. if (this.pdfThumbnailViewer.forceRendering()) {
  2113. return;
  2114. }
  2115. }
  2116. if (this.printing) {
  2117. return;
  2118. }
  2119. if (this.onIdle) {
  2120. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  2121. }
  2122. }
  2123. }, {
  2124. key: "getHighestPriority",
  2125. value: function getHighestPriority(visible, views, scrolledDown) {
  2126. var visibleViews = visible.views;
  2127. var numVisible = visibleViews.length;
  2128. if (numVisible === 0) {
  2129. return false;
  2130. }
  2131. for (var i = 0; i < numVisible; ++i) {
  2132. var view = visibleViews[i].view;
  2133. if (!this.isViewFinished(view)) {
  2134. return view;
  2135. }
  2136. }
  2137. if (scrolledDown) {
  2138. var nextPageIndex = visible.last.id;
  2139. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  2140. return views[nextPageIndex];
  2141. }
  2142. } else {
  2143. var previousPageIndex = visible.first.id - 2;
  2144. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  2145. return views[previousPageIndex];
  2146. }
  2147. }
  2148. return null;
  2149. }
  2150. }, {
  2151. key: "isViewFinished",
  2152. value: function isViewFinished(view) {
  2153. return view.renderingState === RenderingStates.FINISHED;
  2154. }
  2155. }, {
  2156. key: "renderView",
  2157. value: function renderView(view) {
  2158. var _this = this;
  2159. switch (view.renderingState) {
  2160. case RenderingStates.FINISHED:
  2161. return false;
  2162. case RenderingStates.PAUSED:
  2163. this.highestPriorityPage = view.renderingId;
  2164. view.resume();
  2165. break;
  2166. case RenderingStates.RUNNING:
  2167. this.highestPriorityPage = view.renderingId;
  2168. break;
  2169. case RenderingStates.INITIAL:
  2170. this.highestPriorityPage = view.renderingId;
  2171. var continueRendering = function continueRendering() {
  2172. _this.renderHighestPriority();
  2173. };
  2174. view.draw().then(continueRendering, continueRendering);
  2175. break;
  2176. }
  2177. return true;
  2178. }
  2179. }]);
  2180. return PDFRenderingQueue;
  2181. }();
  2182. exports.RenderingStates = RenderingStates;
  2183. exports.PDFRenderingQueue = PDFRenderingQueue;
  2184. /***/ }),
  2185. /* 8 */
  2186. /***/ (function(module, exports, __w_pdfjs_require__) {
  2187. "use strict";
  2188. Object.defineProperty(exports, "__esModule", {
  2189. value: true
  2190. });
  2191. exports.BaseViewer = undefined;
  2192. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2193. var _pdfjsLib = __w_pdfjs_require__(0);
  2194. var _ui_utils = __w_pdfjs_require__(1);
  2195. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  2196. var _annotation_layer_builder = __w_pdfjs_require__(4);
  2197. var _dom_events = __w_pdfjs_require__(2);
  2198. var _pdf_page_view = __w_pdfjs_require__(6);
  2199. var _pdf_link_service = __w_pdfjs_require__(3);
  2200. var _text_layer_builder = __w_pdfjs_require__(5);
  2201. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2202. var DEFAULT_CACHE_SIZE = 10;
  2203. function PDFPageViewBuffer(size) {
  2204. var data = [];
  2205. this.push = function (view) {
  2206. var i = data.indexOf(view);
  2207. if (i >= 0) {
  2208. data.splice(i, 1);
  2209. }
  2210. data.push(view);
  2211. if (data.length > size) {
  2212. data.shift().destroy();
  2213. }
  2214. };
  2215. this.resize = function (newSize) {
  2216. size = newSize;
  2217. while (data.length > size) {
  2218. data.shift().destroy();
  2219. }
  2220. };
  2221. }
  2222. function isSameScale(oldScale, newScale) {
  2223. if (newScale === oldScale) {
  2224. return true;
  2225. }
  2226. if (Math.abs(newScale - oldScale) < 1e-15) {
  2227. return true;
  2228. }
  2229. return false;
  2230. }
  2231. function isPortraitOrientation(size) {
  2232. return size.width <= size.height;
  2233. }
  2234. var BaseViewer = function () {
  2235. function BaseViewer(options) {
  2236. _classCallCheck(this, BaseViewer);
  2237. if (this.constructor === BaseViewer) {
  2238. throw new Error('Cannot initialize BaseViewer.');
  2239. }
  2240. this._name = this.constructor.name;
  2241. this.container = options.container;
  2242. this.viewer = options.viewer || options.container.firstElementChild;
  2243. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  2244. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  2245. this.downloadManager = options.downloadManager || null;
  2246. this.removePageBorders = options.removePageBorders || false;
  2247. this.enhanceTextSelection = options.enhanceTextSelection || false;
  2248. this.renderInteractiveForms = options.renderInteractiveForms || false;
  2249. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  2250. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  2251. this.l10n = options.l10n || _ui_utils.NullL10n;
  2252. this.defaultRenderingQueue = !options.renderingQueue;
  2253. if (this.defaultRenderingQueue) {
  2254. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  2255. this.renderingQueue.setViewer(this);
  2256. } else {
  2257. this.renderingQueue = options.renderingQueue;
  2258. }
  2259. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  2260. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  2261. this._resetView();
  2262. if (this.removePageBorders) {
  2263. this.viewer.classList.add('removePageBorders');
  2264. }
  2265. }
  2266. _createClass(BaseViewer, [{
  2267. key: 'getPageView',
  2268. value: function getPageView(index) {
  2269. return this._pages[index];
  2270. }
  2271. }, {
  2272. key: '_setCurrentPageNumber',
  2273. value: function _setCurrentPageNumber(val) {
  2274. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2275. if (this._currentPageNumber === val) {
  2276. if (resetCurrentPageView) {
  2277. this._resetCurrentPageView();
  2278. }
  2279. return;
  2280. }
  2281. if (!(0 < val && val <= this.pagesCount)) {
  2282. console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
  2283. return;
  2284. }
  2285. var arg = {
  2286. source: this,
  2287. pageNumber: val,
  2288. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  2289. };
  2290. this._currentPageNumber = val;
  2291. this.eventBus.dispatch('pagechanging', arg);
  2292. this.eventBus.dispatch('pagechange', arg);
  2293. if (resetCurrentPageView) {
  2294. this._resetCurrentPageView();
  2295. }
  2296. }
  2297. }, {
  2298. key: 'setDocument',
  2299. value: function setDocument(pdfDocument) {
  2300. var _this = this;
  2301. if (this.pdfDocument) {
  2302. this._cancelRendering();
  2303. this._resetView();
  2304. }
  2305. this.pdfDocument = pdfDocument;
  2306. if (!pdfDocument) {
  2307. return;
  2308. }
  2309. var pagesCount = pdfDocument.numPages;
  2310. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  2311. this.pagesPromise = pagesCapability.promise;
  2312. pagesCapability.promise.then(function () {
  2313. _this._pageViewsReady = true;
  2314. _this.eventBus.dispatch('pagesloaded', {
  2315. source: _this,
  2316. pagesCount: pagesCount
  2317. });
  2318. });
  2319. var isOnePageRenderedResolved = false;
  2320. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  2321. this.onePageRendered = onePageRenderedCapability.promise;
  2322. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  2323. pageView.onBeforeDraw = function () {
  2324. _this._buffer.push(pageView);
  2325. };
  2326. pageView.onAfterDraw = function () {
  2327. if (!isOnePageRenderedResolved) {
  2328. isOnePageRenderedResolved = true;
  2329. onePageRenderedCapability.resolve();
  2330. }
  2331. };
  2332. };
  2333. var firstPagePromise = pdfDocument.getPage(1);
  2334. this.firstPagePromise = firstPagePromise;
  2335. firstPagePromise.then(function (pdfPage) {
  2336. var scale = _this.currentScale;
  2337. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  2338. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  2339. var textLayerFactory = null;
  2340. if (!_pdfjsLib.PDFJS.disableTextLayer) {
  2341. textLayerFactory = _this;
  2342. }
  2343. var pageView = new _pdf_page_view.PDFPageView({
  2344. container: _this._setDocumentViewerElement,
  2345. eventBus: _this.eventBus,
  2346. id: pageNum,
  2347. scale: scale,
  2348. defaultViewport: viewport.clone(),
  2349. renderingQueue: _this.renderingQueue,
  2350. textLayerFactory: textLayerFactory,
  2351. annotationLayerFactory: _this,
  2352. enhanceTextSelection: _this.enhanceTextSelection,
  2353. renderInteractiveForms: _this.renderInteractiveForms,
  2354. renderer: _this.renderer,
  2355. l10n: _this.l10n
  2356. });
  2357. bindOnAfterAndBeforeDraw(pageView);
  2358. _this._pages.push(pageView);
  2359. }
  2360. onePageRenderedCapability.promise.then(function () {
  2361. if (_pdfjsLib.PDFJS.disableAutoFetch) {
  2362. pagesCapability.resolve();
  2363. return;
  2364. }
  2365. var getPagesLeft = pagesCount;
  2366. var _loop = function _loop(_pageNum) {
  2367. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  2368. var pageView = _this._pages[_pageNum - 1];
  2369. if (!pageView.pdfPage) {
  2370. pageView.setPdfPage(pdfPage);
  2371. }
  2372. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  2373. if (--getPagesLeft === 0) {
  2374. pagesCapability.resolve();
  2375. }
  2376. }, function (reason) {
  2377. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  2378. if (--getPagesLeft === 0) {
  2379. pagesCapability.resolve();
  2380. }
  2381. });
  2382. };
  2383. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  2384. _loop(_pageNum);
  2385. }
  2386. });
  2387. _this.eventBus.dispatch('pagesinit', { source: _this });
  2388. if (_this.defaultRenderingQueue) {
  2389. _this.update();
  2390. }
  2391. if (_this.findController) {
  2392. _this.findController.resolveFirstPage();
  2393. }
  2394. }).catch(function (reason) {
  2395. console.error('Unable to initialize viewer', reason);
  2396. });
  2397. }
  2398. }, {
  2399. key: 'setPageLabels',
  2400. value: function setPageLabels(labels) {
  2401. if (!this.pdfDocument) {
  2402. return;
  2403. }
  2404. if (!labels) {
  2405. this._pageLabels = null;
  2406. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  2407. this._pageLabels = null;
  2408. console.error(this._name + '.setPageLabels: Invalid page labels.');
  2409. } else {
  2410. this._pageLabels = labels;
  2411. }
  2412. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2413. var pageView = this._pages[i];
  2414. var label = this._pageLabels && this._pageLabels[i];
  2415. pageView.setPageLabel(label);
  2416. }
  2417. }
  2418. }, {
  2419. key: '_resetView',
  2420. value: function _resetView() {
  2421. this._pages = [];
  2422. this._currentPageNumber = 1;
  2423. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  2424. this._currentScaleValue = null;
  2425. this._pageLabels = null;
  2426. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  2427. this._location = null;
  2428. this._pagesRotation = 0;
  2429. this._pagesRequests = [];
  2430. this._pageViewsReady = false;
  2431. this.viewer.textContent = '';
  2432. }
  2433. }, {
  2434. key: '_scrollUpdate',
  2435. value: function _scrollUpdate() {
  2436. if (this.pagesCount === 0) {
  2437. return;
  2438. }
  2439. this.update();
  2440. }
  2441. }, {
  2442. key: '_scrollIntoView',
  2443. value: function _scrollIntoView(_ref) {
  2444. var pageDiv = _ref.pageDiv,
  2445. _ref$pageSpot = _ref.pageSpot,
  2446. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  2447. _ref$pageNumber = _ref.pageNumber,
  2448. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  2449. throw new Error('Not implemented: _scrollIntoView');
  2450. }
  2451. }, {
  2452. key: '_setScaleDispatchEvent',
  2453. value: function _setScaleDispatchEvent(newScale, newValue) {
  2454. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2455. var arg = {
  2456. source: this,
  2457. scale: newScale,
  2458. presetValue: preset ? newValue : undefined
  2459. };
  2460. this.eventBus.dispatch('scalechanging', arg);
  2461. this.eventBus.dispatch('scalechange', arg);
  2462. }
  2463. }, {
  2464. key: '_setScaleUpdatePages',
  2465. value: function _setScaleUpdatePages(newScale, newValue) {
  2466. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2467. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2468. this._currentScaleValue = newValue.toString();
  2469. if (isSameScale(this._currentScale, newScale)) {
  2470. if (preset) {
  2471. this._setScaleDispatchEvent(newScale, newValue, true);
  2472. }
  2473. return;
  2474. }
  2475. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2476. this._pages[i].update(newScale);
  2477. }
  2478. this._currentScale = newScale;
  2479. if (!noScroll) {
  2480. var page = this._currentPageNumber,
  2481. dest = void 0;
  2482. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  2483. page = this._location.pageNumber;
  2484. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  2485. }
  2486. this.scrollPageIntoView({
  2487. pageNumber: page,
  2488. destArray: dest,
  2489. allowNegativeOffset: true
  2490. });
  2491. }
  2492. this._setScaleDispatchEvent(newScale, newValue, preset);
  2493. if (this.defaultRenderingQueue) {
  2494. this.update();
  2495. }
  2496. }
  2497. }, {
  2498. key: '_setScale',
  2499. value: function _setScale(value) {
  2500. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2501. var scale = parseFloat(value);
  2502. if (scale > 0) {
  2503. this._setScaleUpdatePages(scale, value, noScroll, false);
  2504. } else {
  2505. var currentPage = this._pages[this._currentPageNumber - 1];
  2506. if (!currentPage) {
  2507. return;
  2508. }
  2509. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2510. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2511. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  2512. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  2513. switch (value) {
  2514. case 'page-actual':
  2515. scale = 1;
  2516. break;
  2517. case 'page-width':
  2518. scale = pageWidthScale;
  2519. break;
  2520. case 'page-height':
  2521. scale = pageHeightScale;
  2522. break;
  2523. case 'page-fit':
  2524. scale = Math.min(pageWidthScale, pageHeightScale);
  2525. break;
  2526. case 'auto':
  2527. var isLandscape = currentPage.width > currentPage.height;
  2528. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  2529. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  2530. break;
  2531. default:
  2532. console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
  2533. return;
  2534. }
  2535. this._setScaleUpdatePages(scale, value, noScroll, true);
  2536. }
  2537. }
  2538. }, {
  2539. key: '_resetCurrentPageView',
  2540. value: function _resetCurrentPageView() {
  2541. if (this.isInPresentationMode) {
  2542. this._setScale(this._currentScaleValue, true);
  2543. }
  2544. var pageView = this._pages[this._currentPageNumber - 1];
  2545. this._scrollIntoView({ pageDiv: pageView.div });
  2546. }
  2547. }, {
  2548. key: 'scrollPageIntoView',
  2549. value: function scrollPageIntoView(params) {
  2550. if (!this.pdfDocument) {
  2551. return;
  2552. }
  2553. var pageNumber = params.pageNumber || 0;
  2554. var dest = params.destArray || null;
  2555. var allowNegativeOffset = params.allowNegativeOffset || false;
  2556. if (this.isInPresentationMode || !dest) {
  2557. this._setCurrentPageNumber(pageNumber, true);
  2558. return;
  2559. }
  2560. var pageView = this._pages[pageNumber - 1];
  2561. if (!pageView) {
  2562. console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
  2563. return;
  2564. }
  2565. var x = 0,
  2566. y = 0;
  2567. var width = 0,
  2568. height = 0,
  2569. widthScale = void 0,
  2570. heightScale = void 0;
  2571. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  2572. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  2573. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  2574. var scale = 0;
  2575. switch (dest[1].name) {
  2576. case 'XYZ':
  2577. x = dest[2];
  2578. y = dest[3];
  2579. scale = dest[4];
  2580. x = x !== null ? x : 0;
  2581. y = y !== null ? y : pageHeight;
  2582. break;
  2583. case 'Fit':
  2584. case 'FitB':
  2585. scale = 'page-fit';
  2586. break;
  2587. case 'FitH':
  2588. case 'FitBH':
  2589. y = dest[2];
  2590. scale = 'page-width';
  2591. if (y === null && this._location) {
  2592. x = this._location.left;
  2593. y = this._location.top;
  2594. }
  2595. break;
  2596. case 'FitV':
  2597. case 'FitBV':
  2598. x = dest[2];
  2599. width = pageWidth;
  2600. height = pageHeight;
  2601. scale = 'page-height';
  2602. break;
  2603. case 'FitR':
  2604. x = dest[2];
  2605. y = dest[3];
  2606. width = dest[4] - x;
  2607. height = dest[5] - y;
  2608. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2609. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2610. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  2611. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  2612. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  2613. break;
  2614. default:
  2615. console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  2616. return;
  2617. }
  2618. if (scale && scale !== this._currentScale) {
  2619. this.currentScaleValue = scale;
  2620. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  2621. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2622. }
  2623. if (scale === 'page-fit' && !dest[4]) {
  2624. this._scrollIntoView({
  2625. pageDiv: pageView.div,
  2626. pageNumber: pageNumber
  2627. });
  2628. return;
  2629. }
  2630. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  2631. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  2632. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  2633. if (!allowNegativeOffset) {
  2634. left = Math.max(left, 0);
  2635. top = Math.max(top, 0);
  2636. }
  2637. this._scrollIntoView({
  2638. pageDiv: pageView.div,
  2639. pageSpot: {
  2640. left: left,
  2641. top: top
  2642. },
  2643. pageNumber: pageNumber
  2644. });
  2645. }
  2646. }, {
  2647. key: '_resizeBuffer',
  2648. value: function _resizeBuffer(numVisiblePages) {
  2649. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  2650. this._buffer.resize(suggestedCacheSize);
  2651. }
  2652. }, {
  2653. key: '_updateLocation',
  2654. value: function _updateLocation(firstPage) {
  2655. var currentScale = this._currentScale;
  2656. var currentScaleValue = this._currentScaleValue;
  2657. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  2658. var pageNumber = firstPage.id;
  2659. var pdfOpenParams = '#page=' + pageNumber;
  2660. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  2661. var currentPageView = this._pages[pageNumber - 1];
  2662. var container = this.container;
  2663. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  2664. var intLeft = Math.round(topLeft[0]);
  2665. var intTop = Math.round(topLeft[1]);
  2666. pdfOpenParams += ',' + intLeft + ',' + intTop;
  2667. this._location = {
  2668. pageNumber: pageNumber,
  2669. scale: normalizedScaleValue,
  2670. top: intTop,
  2671. left: intLeft,
  2672. rotation: this._pagesRotation,
  2673. pdfOpenParams: pdfOpenParams
  2674. };
  2675. }
  2676. }, {
  2677. key: 'update',
  2678. value: function update() {
  2679. throw new Error('Not implemented: update');
  2680. }
  2681. }, {
  2682. key: 'containsElement',
  2683. value: function containsElement(element) {
  2684. return this.container.contains(element);
  2685. }
  2686. }, {
  2687. key: 'focus',
  2688. value: function focus() {
  2689. this.container.focus();
  2690. }
  2691. }, {
  2692. key: '_getVisiblePages',
  2693. value: function _getVisiblePages() {
  2694. throw new Error('Not implemented: _getVisiblePages');
  2695. }
  2696. }, {
  2697. key: 'cleanup',
  2698. value: function cleanup() {
  2699. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2700. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  2701. this._pages[i].reset();
  2702. }
  2703. }
  2704. }
  2705. }, {
  2706. key: '_cancelRendering',
  2707. value: function _cancelRendering() {
  2708. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2709. if (this._pages[i]) {
  2710. this._pages[i].cancelRendering();
  2711. }
  2712. }
  2713. }
  2714. }, {
  2715. key: '_ensurePdfPageLoaded',
  2716. value: function _ensurePdfPageLoaded(pageView) {
  2717. var _this2 = this;
  2718. if (pageView.pdfPage) {
  2719. return Promise.resolve(pageView.pdfPage);
  2720. }
  2721. var pageNumber = pageView.id;
  2722. if (this._pagesRequests[pageNumber]) {
  2723. return this._pagesRequests[pageNumber];
  2724. }
  2725. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  2726. if (!pageView.pdfPage) {
  2727. pageView.setPdfPage(pdfPage);
  2728. }
  2729. _this2._pagesRequests[pageNumber] = null;
  2730. return pdfPage;
  2731. }).catch(function (reason) {
  2732. console.error('Unable to get page for page view', reason);
  2733. _this2._pagesRequests[pageNumber] = null;
  2734. });
  2735. this._pagesRequests[pageNumber] = promise;
  2736. return promise;
  2737. }
  2738. }, {
  2739. key: 'forceRendering',
  2740. value: function forceRendering(currentlyVisiblePages) {
  2741. var _this3 = this;
  2742. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  2743. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  2744. if (pageView) {
  2745. this._ensurePdfPageLoaded(pageView).then(function () {
  2746. _this3.renderingQueue.renderView(pageView);
  2747. });
  2748. return true;
  2749. }
  2750. return false;
  2751. }
  2752. }, {
  2753. key: 'getPageTextContent',
  2754. value: function getPageTextContent(pageIndex) {
  2755. return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
  2756. return page.getTextContent({ normalizeWhitespace: true });
  2757. });
  2758. }
  2759. }, {
  2760. key: 'createTextLayerBuilder',
  2761. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2762. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2763. return new _text_layer_builder.TextLayerBuilder({
  2764. textLayerDiv: textLayerDiv,
  2765. eventBus: this.eventBus,
  2766. pageIndex: pageIndex,
  2767. viewport: viewport,
  2768. findController: this.isInPresentationMode ? null : this.findController,
  2769. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  2770. });
  2771. }
  2772. }, {
  2773. key: 'createAnnotationLayerBuilder',
  2774. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  2775. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2776. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  2777. return new _annotation_layer_builder.AnnotationLayerBuilder({
  2778. pageDiv: pageDiv,
  2779. pdfPage: pdfPage,
  2780. renderInteractiveForms: renderInteractiveForms,
  2781. linkService: this.linkService,
  2782. downloadManager: this.downloadManager,
  2783. l10n: l10n
  2784. });
  2785. }
  2786. }, {
  2787. key: 'setFindController',
  2788. value: function setFindController(findController) {
  2789. this.findController = findController;
  2790. }
  2791. }, {
  2792. key: 'getPagesOverview',
  2793. value: function getPagesOverview() {
  2794. var pagesOverview = this._pages.map(function (pageView) {
  2795. var viewport = pageView.pdfPage.getViewport(1);
  2796. return {
  2797. width: viewport.width,
  2798. height: viewport.height,
  2799. rotation: viewport.rotation
  2800. };
  2801. });
  2802. if (!this.enablePrintAutoRotate) {
  2803. return pagesOverview;
  2804. }
  2805. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  2806. return pagesOverview.map(function (size) {
  2807. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  2808. return size;
  2809. }
  2810. return {
  2811. width: size.height,
  2812. height: size.width,
  2813. rotation: (size.rotation + 90) % 360
  2814. };
  2815. });
  2816. }
  2817. }, {
  2818. key: 'pagesCount',
  2819. get: function get() {
  2820. return this._pages.length;
  2821. }
  2822. }, {
  2823. key: 'pageViewsReady',
  2824. get: function get() {
  2825. return this._pageViewsReady;
  2826. }
  2827. }, {
  2828. key: 'currentPageNumber',
  2829. get: function get() {
  2830. return this._currentPageNumber;
  2831. },
  2832. set: function set(val) {
  2833. if (!Number.isInteger(val)) {
  2834. throw new Error('Invalid page number.');
  2835. }
  2836. if (!this.pdfDocument) {
  2837. return;
  2838. }
  2839. this._setCurrentPageNumber(val, true);
  2840. }
  2841. }, {
  2842. key: 'currentPageLabel',
  2843. get: function get() {
  2844. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  2845. },
  2846. set: function set(val) {
  2847. var pageNumber = val | 0;
  2848. if (this._pageLabels) {
  2849. var i = this._pageLabels.indexOf(val);
  2850. if (i >= 0) {
  2851. pageNumber = i + 1;
  2852. }
  2853. }
  2854. this.currentPageNumber = pageNumber;
  2855. }
  2856. }, {
  2857. key: 'currentScale',
  2858. get: function get() {
  2859. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  2860. },
  2861. set: function set(val) {
  2862. if (isNaN(val)) {
  2863. throw new Error('Invalid numeric scale');
  2864. }
  2865. if (!this.pdfDocument) {
  2866. return;
  2867. }
  2868. this._setScale(val, false);
  2869. }
  2870. }, {
  2871. key: 'currentScaleValue',
  2872. get: function get() {
  2873. return this._currentScaleValue;
  2874. },
  2875. set: function set(val) {
  2876. if (!this.pdfDocument) {
  2877. return;
  2878. }
  2879. this._setScale(val, false);
  2880. }
  2881. }, {
  2882. key: 'pagesRotation',
  2883. get: function get() {
  2884. return this._pagesRotation;
  2885. },
  2886. set: function set(rotation) {
  2887. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  2888. throw new Error('Invalid pages rotation angle.');
  2889. }
  2890. if (!this.pdfDocument) {
  2891. return;
  2892. }
  2893. if (this._pagesRotation === rotation) {
  2894. return;
  2895. }
  2896. this._pagesRotation = rotation;
  2897. var pageNumber = this._currentPageNumber;
  2898. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2899. var pageView = this._pages[i];
  2900. pageView.update(pageView.scale, rotation);
  2901. }
  2902. if (this._currentScaleValue) {
  2903. this._setScale(this._currentScaleValue, true);
  2904. }
  2905. this.eventBus.dispatch('rotationchanging', {
  2906. source: this,
  2907. pagesRotation: rotation,
  2908. pageNumber: pageNumber
  2909. });
  2910. if (this.defaultRenderingQueue) {
  2911. this.update();
  2912. }
  2913. }
  2914. }, {
  2915. key: '_setDocumentViewerElement',
  2916. get: function get() {
  2917. throw new Error('Not implemented: _setDocumentViewerElement');
  2918. }
  2919. }, {
  2920. key: 'isInPresentationMode',
  2921. get: function get() {
  2922. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  2923. }
  2924. }, {
  2925. key: 'isChangingPresentationMode',
  2926. get: function get() {
  2927. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  2928. }
  2929. }, {
  2930. key: 'isHorizontalScrollbarEnabled',
  2931. get: function get() {
  2932. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  2933. }
  2934. }, {
  2935. key: 'hasEqualPageSizes',
  2936. get: function get() {
  2937. var firstPageView = this._pages[0];
  2938. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  2939. var pageView = this._pages[i];
  2940. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  2941. return false;
  2942. }
  2943. }
  2944. return true;
  2945. }
  2946. }]);
  2947. return BaseViewer;
  2948. }();
  2949. exports.BaseViewer = BaseViewer;
  2950. /***/ }),
  2951. /* 9 */
  2952. /***/ (function(module, exports, __w_pdfjs_require__) {
  2953. "use strict";
  2954. Object.defineProperty(exports, "__esModule", {
  2955. value: true
  2956. });
  2957. exports.PDFJS = undefined;
  2958. var _annotation_layer_builder = __w_pdfjs_require__(4);
  2959. var _text_layer_builder = __w_pdfjs_require__(5);
  2960. var _ui_utils = __w_pdfjs_require__(1);
  2961. var _pdf_link_service = __w_pdfjs_require__(3);
  2962. var _download_manager = __w_pdfjs_require__(10);
  2963. var _genericl10n = __w_pdfjs_require__(11);
  2964. var _pdf_find_controller = __w_pdfjs_require__(13);
  2965. var _pdf_history = __w_pdfjs_require__(14);
  2966. var _pdfjs = __w_pdfjs_require__(0);
  2967. var _pdfjs2 = _interopRequireDefault(_pdfjs);
  2968. var _pdf_page_view = __w_pdfjs_require__(6);
  2969. var _pdf_single_page_viewer = __w_pdfjs_require__(15);
  2970. var _pdf_viewer = __w_pdfjs_require__(16);
  2971. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2972. var PDFJS = _pdfjs2.default.PDFJS;
  2973. PDFJS.PDFViewer = _pdf_viewer.PDFViewer;
  2974. PDFJS.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
  2975. PDFJS.PDFPageView = _pdf_page_view.PDFPageView;
  2976. PDFJS.PDFLinkService = _pdf_link_service.PDFLinkService;
  2977. PDFJS.SimpleLinkService = _pdf_link_service.SimpleLinkService;
  2978. PDFJS.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
  2979. PDFJS.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
  2980. PDFJS.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
  2981. PDFJS.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
  2982. PDFJS.PDFHistory = _pdf_history.PDFHistory;
  2983. PDFJS.PDFFindController = _pdf_find_controller.PDFFindController;
  2984. PDFJS.EventBus = _ui_utils.EventBus;
  2985. PDFJS.DownloadManager = _download_manager.DownloadManager;
  2986. PDFJS.ProgressBar = _ui_utils.ProgressBar;
  2987. PDFJS.GenericL10n = _genericl10n.GenericL10n;
  2988. PDFJS.NullL10n = _ui_utils.NullL10n;
  2989. exports.PDFJS = PDFJS;
  2990. /***/ }),
  2991. /* 10 */
  2992. /***/ (function(module, exports, __w_pdfjs_require__) {
  2993. "use strict";
  2994. Object.defineProperty(exports, "__esModule", {
  2995. value: true
  2996. });
  2997. exports.DownloadManager = undefined;
  2998. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2999. var _pdfjsLib = __w_pdfjs_require__(0);
  3000. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3001. ;
  3002. function _download(blobUrl, filename) {
  3003. var a = document.createElement('a');
  3004. if (!a.click) {
  3005. throw new Error('DownloadManager: "a.click()" is not supported.');
  3006. }
  3007. a.href = blobUrl;
  3008. a.target = '_parent';
  3009. if ('download' in a) {
  3010. a.download = filename;
  3011. }
  3012. (document.body || document.documentElement).appendChild(a);
  3013. a.click();
  3014. a.remove();
  3015. }
  3016. var DownloadManager = function () {
  3017. function DownloadManager() {
  3018. _classCallCheck(this, DownloadManager);
  3019. }
  3020. _createClass(DownloadManager, [{
  3021. key: 'downloadUrl',
  3022. value: function downloadUrl(url, filename) {
  3023. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  3024. return;
  3025. }
  3026. _download(url + '#pdfjs.action=download', filename);
  3027. }
  3028. }, {
  3029. key: 'downloadData',
  3030. value: function downloadData(data, filename, contentType) {
  3031. if (navigator.msSaveBlob) {
  3032. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  3033. }
  3034. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
  3035. _download(blobUrl, filename);
  3036. }
  3037. }, {
  3038. key: 'download',
  3039. value: function download(blob, url, filename) {
  3040. if (navigator.msSaveBlob) {
  3041. if (!navigator.msSaveBlob(blob, filename)) {
  3042. this.downloadUrl(url, filename);
  3043. }
  3044. return;
  3045. }
  3046. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  3047. this.downloadUrl(url, filename);
  3048. return;
  3049. }
  3050. var blobUrl = URL.createObjectURL(blob);
  3051. _download(blobUrl, filename);
  3052. }
  3053. }]);
  3054. return DownloadManager;
  3055. }();
  3056. exports.DownloadManager = DownloadManager;
  3057. /***/ }),
  3058. /* 11 */
  3059. /***/ (function(module, exports, __w_pdfjs_require__) {
  3060. "use strict";
  3061. Object.defineProperty(exports, "__esModule", {
  3062. value: true
  3063. });
  3064. exports.GenericL10n = undefined;
  3065. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3066. __w_pdfjs_require__(12);
  3067. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3068. var webL10n = document.webL10n;
  3069. var GenericL10n = function () {
  3070. function GenericL10n(lang) {
  3071. _classCallCheck(this, GenericL10n);
  3072. this._lang = lang;
  3073. this._ready = new Promise(function (resolve, reject) {
  3074. webL10n.setLanguage(lang, function () {
  3075. resolve(webL10n);
  3076. });
  3077. });
  3078. }
  3079. _createClass(GenericL10n, [{
  3080. key: 'getDirection',
  3081. value: function getDirection() {
  3082. return this._ready.then(function (l10n) {
  3083. return l10n.getDirection();
  3084. });
  3085. }
  3086. }, {
  3087. key: 'get',
  3088. value: function get(property, args, fallback) {
  3089. return this._ready.then(function (l10n) {
  3090. return l10n.get(property, args, fallback);
  3091. });
  3092. }
  3093. }, {
  3094. key: 'translate',
  3095. value: function translate(element) {
  3096. return this._ready.then(function (l10n) {
  3097. return l10n.translate(element);
  3098. });
  3099. }
  3100. }]);
  3101. return GenericL10n;
  3102. }();
  3103. exports.GenericL10n = GenericL10n;
  3104. /***/ }),
  3105. /* 12 */
  3106. /***/ (function(module, exports, __w_pdfjs_require__) {
  3107. "use strict";
  3108. document.webL10n = function (window, document, undefined) {
  3109. var gL10nData = {};
  3110. var gTextData = '';
  3111. var gTextProp = 'textContent';
  3112. var gLanguage = '';
  3113. var gMacros = {};
  3114. var gReadyState = 'loading';
  3115. var gAsyncResourceLoading = true;
  3116. function getL10nResourceLinks() {
  3117. return document.querySelectorAll('link[type="application/l10n"]');
  3118. }
  3119. function getL10nDictionary() {
  3120. var script = document.querySelector('script[type="application/l10n"]');
  3121. return script ? JSON.parse(script.innerHTML) : null;
  3122. }
  3123. function getTranslatableChildren(element) {
  3124. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  3125. }
  3126. function getL10nAttributes(element) {
  3127. if (!element) return {};
  3128. var l10nId = element.getAttribute('data-l10n-id');
  3129. var l10nArgs = element.getAttribute('data-l10n-args');
  3130. var args = {};
  3131. if (l10nArgs) {
  3132. try {
  3133. args = JSON.parse(l10nArgs);
  3134. } catch (e) {
  3135. console.warn('could not parse arguments for #' + l10nId);
  3136. }
  3137. }
  3138. return {
  3139. id: l10nId,
  3140. args: args
  3141. };
  3142. }
  3143. function fireL10nReadyEvent(lang) {
  3144. var evtObject = document.createEvent('Event');
  3145. evtObject.initEvent('localized', true, false);
  3146. evtObject.language = lang;
  3147. document.dispatchEvent(evtObject);
  3148. }
  3149. function xhrLoadText(url, onSuccess, onFailure) {
  3150. onSuccess = onSuccess || function _onSuccess(data) {};
  3151. onFailure = onFailure || function _onFailure() {};
  3152. var xhr = new XMLHttpRequest();
  3153. xhr.open('GET', url, gAsyncResourceLoading);
  3154. if (xhr.overrideMimeType) {
  3155. xhr.overrideMimeType('text/plain; charset=utf-8');
  3156. }
  3157. xhr.onreadystatechange = function () {
  3158. if (xhr.readyState == 4) {
  3159. if (xhr.status == 200 || xhr.status === 0) {
  3160. onSuccess(xhr.responseText);
  3161. } else {
  3162. onFailure();
  3163. }
  3164. }
  3165. };
  3166. xhr.onerror = onFailure;
  3167. xhr.ontimeout = onFailure;
  3168. try {
  3169. xhr.send(null);
  3170. } catch (e) {
  3171. onFailure();
  3172. }
  3173. }
  3174. function parseResource(href, lang, successCallback, failureCallback) {
  3175. var baseURL = href.replace(/[^\/]*$/, '') || './';
  3176. function evalString(text) {
  3177. if (text.lastIndexOf('\\') < 0) return text;
  3178. 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, "'");
  3179. }
  3180. function parseProperties(text, parsedPropertiesCallback) {
  3181. var dictionary = {};
  3182. var reBlank = /^\s*|\s*$/;
  3183. var reComment = /^\s*#|^\s*$/;
  3184. var reSection = /^\s*\[(.*)\]\s*$/;
  3185. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  3186. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  3187. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  3188. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  3189. var currentLang = '*';
  3190. var genericLang = lang.split('-', 1)[0];
  3191. var skipLang = false;
  3192. var match = '';
  3193. function nextEntry() {
  3194. while (true) {
  3195. if (!entries.length) {
  3196. parsedRawLinesCallback();
  3197. return;
  3198. }
  3199. var line = entries.shift();
  3200. if (reComment.test(line)) continue;
  3201. if (extendedSyntax) {
  3202. match = reSection.exec(line);
  3203. if (match) {
  3204. currentLang = match[1].toLowerCase();
  3205. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  3206. continue;
  3207. } else if (skipLang) {
  3208. continue;
  3209. }
  3210. match = reImport.exec(line);
  3211. if (match) {
  3212. loadImport(baseURL + match[1], nextEntry);
  3213. return;
  3214. }
  3215. }
  3216. var tmp = line.match(reSplit);
  3217. if (tmp && tmp.length == 3) {
  3218. dictionary[tmp[1]] = evalString(tmp[2]);
  3219. }
  3220. }
  3221. }
  3222. nextEntry();
  3223. }
  3224. function loadImport(url, callback) {
  3225. xhrLoadText(url, function (content) {
  3226. parseRawLines(content, false, callback);
  3227. }, function () {
  3228. console.warn(url + ' not found.');
  3229. callback();
  3230. });
  3231. }
  3232. parseRawLines(text, true, function () {
  3233. parsedPropertiesCallback(dictionary);
  3234. });
  3235. }
  3236. xhrLoadText(href, function (response) {
  3237. gTextData += response;
  3238. parseProperties(response, function (data) {
  3239. for (var key in data) {
  3240. var id,
  3241. prop,
  3242. index = key.lastIndexOf('.');
  3243. if (index > 0) {
  3244. id = key.substring(0, index);
  3245. prop = key.substr(index + 1);
  3246. } else {
  3247. id = key;
  3248. prop = gTextProp;
  3249. }
  3250. if (!gL10nData[id]) {
  3251. gL10nData[id] = {};
  3252. }
  3253. gL10nData[id][prop] = data[key];
  3254. }
  3255. if (successCallback) {
  3256. successCallback();
  3257. }
  3258. });
  3259. }, failureCallback);
  3260. }
  3261. function loadLocale(lang, callback) {
  3262. if (lang) {
  3263. lang = lang.toLowerCase();
  3264. }
  3265. callback = callback || function _callback() {};
  3266. clear();
  3267. gLanguage = lang;
  3268. var langLinks = getL10nResourceLinks();
  3269. var langCount = langLinks.length;
  3270. if (langCount === 0) {
  3271. var dict = getL10nDictionary();
  3272. if (dict && dict.locales && dict.default_locale) {
  3273. console.log('using the embedded JSON directory, early way out');
  3274. gL10nData = dict.locales[lang];
  3275. if (!gL10nData) {
  3276. var defaultLocale = dict.default_locale.toLowerCase();
  3277. for (var anyCaseLang in dict.locales) {
  3278. anyCaseLang = anyCaseLang.toLowerCase();
  3279. if (anyCaseLang === lang) {
  3280. gL10nData = dict.locales[lang];
  3281. break;
  3282. } else if (anyCaseLang === defaultLocale) {
  3283. gL10nData = dict.locales[defaultLocale];
  3284. }
  3285. }
  3286. }
  3287. callback();
  3288. } else {
  3289. console.log('no resource to load, early way out');
  3290. }
  3291. fireL10nReadyEvent(lang);
  3292. gReadyState = 'complete';
  3293. return;
  3294. }
  3295. var onResourceLoaded = null;
  3296. var gResourceCount = 0;
  3297. onResourceLoaded = function onResourceLoaded() {
  3298. gResourceCount++;
  3299. if (gResourceCount >= langCount) {
  3300. callback();
  3301. fireL10nReadyEvent(lang);
  3302. gReadyState = 'complete';
  3303. }
  3304. };
  3305. function L10nResourceLink(link) {
  3306. var href = link.href;
  3307. this.load = function (lang, callback) {
  3308. parseResource(href, lang, callback, function () {
  3309. console.warn(href + ' not found.');
  3310. console.warn('"' + lang + '" resource not found');
  3311. gLanguage = '';
  3312. callback();
  3313. });
  3314. };
  3315. }
  3316. for (var i = 0; i < langCount; i++) {
  3317. var resource = new L10nResourceLink(langLinks[i]);
  3318. resource.load(lang, onResourceLoaded);
  3319. }
  3320. }
  3321. function clear() {
  3322. gL10nData = {};
  3323. gTextData = '';
  3324. gLanguage = '';
  3325. }
  3326. function getPluralRules(lang) {
  3327. var locales2rules = {
  3328. 'af': 3,
  3329. 'ak': 4,
  3330. 'am': 4,
  3331. 'ar': 1,
  3332. 'asa': 3,
  3333. 'az': 0,
  3334. 'be': 11,
  3335. 'bem': 3,
  3336. 'bez': 3,
  3337. 'bg': 3,
  3338. 'bh': 4,
  3339. 'bm': 0,
  3340. 'bn': 3,
  3341. 'bo': 0,
  3342. 'br': 20,
  3343. 'brx': 3,
  3344. 'bs': 11,
  3345. 'ca': 3,
  3346. 'cgg': 3,
  3347. 'chr': 3,
  3348. 'cs': 12,
  3349. 'cy': 17,
  3350. 'da': 3,
  3351. 'de': 3,
  3352. 'dv': 3,
  3353. 'dz': 0,
  3354. 'ee': 3,
  3355. 'el': 3,
  3356. 'en': 3,
  3357. 'eo': 3,
  3358. 'es': 3,
  3359. 'et': 3,
  3360. 'eu': 3,
  3361. 'fa': 0,
  3362. 'ff': 5,
  3363. 'fi': 3,
  3364. 'fil': 4,
  3365. 'fo': 3,
  3366. 'fr': 5,
  3367. 'fur': 3,
  3368. 'fy': 3,
  3369. 'ga': 8,
  3370. 'gd': 24,
  3371. 'gl': 3,
  3372. 'gsw': 3,
  3373. 'gu': 3,
  3374. 'guw': 4,
  3375. 'gv': 23,
  3376. 'ha': 3,
  3377. 'haw': 3,
  3378. 'he': 2,
  3379. 'hi': 4,
  3380. 'hr': 11,
  3381. 'hu': 0,
  3382. 'id': 0,
  3383. 'ig': 0,
  3384. 'ii': 0,
  3385. 'is': 3,
  3386. 'it': 3,
  3387. 'iu': 7,
  3388. 'ja': 0,
  3389. 'jmc': 3,
  3390. 'jv': 0,
  3391. 'ka': 0,
  3392. 'kab': 5,
  3393. 'kaj': 3,
  3394. 'kcg': 3,
  3395. 'kde': 0,
  3396. 'kea': 0,
  3397. 'kk': 3,
  3398. 'kl': 3,
  3399. 'km': 0,
  3400. 'kn': 0,
  3401. 'ko': 0,
  3402. 'ksb': 3,
  3403. 'ksh': 21,
  3404. 'ku': 3,
  3405. 'kw': 7,
  3406. 'lag': 18,
  3407. 'lb': 3,
  3408. 'lg': 3,
  3409. 'ln': 4,
  3410. 'lo': 0,
  3411. 'lt': 10,
  3412. 'lv': 6,
  3413. 'mas': 3,
  3414. 'mg': 4,
  3415. 'mk': 16,
  3416. 'ml': 3,
  3417. 'mn': 3,
  3418. 'mo': 9,
  3419. 'mr': 3,
  3420. 'ms': 0,
  3421. 'mt': 15,
  3422. 'my': 0,
  3423. 'nah': 3,
  3424. 'naq': 7,
  3425. 'nb': 3,
  3426. 'nd': 3,
  3427. 'ne': 3,
  3428. 'nl': 3,
  3429. 'nn': 3,
  3430. 'no': 3,
  3431. 'nr': 3,
  3432. 'nso': 4,
  3433. 'ny': 3,
  3434. 'nyn': 3,
  3435. 'om': 3,
  3436. 'or': 3,
  3437. 'pa': 3,
  3438. 'pap': 3,
  3439. 'pl': 13,
  3440. 'ps': 3,
  3441. 'pt': 3,
  3442. 'rm': 3,
  3443. 'ro': 9,
  3444. 'rof': 3,
  3445. 'ru': 11,
  3446. 'rwk': 3,
  3447. 'sah': 0,
  3448. 'saq': 3,
  3449. 'se': 7,
  3450. 'seh': 3,
  3451. 'ses': 0,
  3452. 'sg': 0,
  3453. 'sh': 11,
  3454. 'shi': 19,
  3455. 'sk': 12,
  3456. 'sl': 14,
  3457. 'sma': 7,
  3458. 'smi': 7,
  3459. 'smj': 7,
  3460. 'smn': 7,
  3461. 'sms': 7,
  3462. 'sn': 3,
  3463. 'so': 3,
  3464. 'sq': 3,
  3465. 'sr': 11,
  3466. 'ss': 3,
  3467. 'ssy': 3,
  3468. 'st': 3,
  3469. 'sv': 3,
  3470. 'sw': 3,
  3471. 'syr': 3,
  3472. 'ta': 3,
  3473. 'te': 3,
  3474. 'teo': 3,
  3475. 'th': 0,
  3476. 'ti': 4,
  3477. 'tig': 3,
  3478. 'tk': 3,
  3479. 'tl': 4,
  3480. 'tn': 3,
  3481. 'to': 0,
  3482. 'tr': 0,
  3483. 'ts': 3,
  3484. 'tzm': 22,
  3485. 'uk': 11,
  3486. 'ur': 3,
  3487. 've': 3,
  3488. 'vi': 0,
  3489. 'vun': 3,
  3490. 'wa': 4,
  3491. 'wae': 3,
  3492. 'wo': 0,
  3493. 'xh': 3,
  3494. 'xog': 3,
  3495. 'yo': 0,
  3496. 'zh': 0,
  3497. 'zu': 3
  3498. };
  3499. function isIn(n, list) {
  3500. return list.indexOf(n) !== -1;
  3501. }
  3502. function isBetween(n, start, end) {
  3503. return start <= n && n <= end;
  3504. }
  3505. var pluralRules = {
  3506. '0': function _(n) {
  3507. return 'other';
  3508. },
  3509. '1': function _(n) {
  3510. if (isBetween(n % 100, 3, 10)) return 'few';
  3511. if (n === 0) return 'zero';
  3512. if (isBetween(n % 100, 11, 99)) return 'many';
  3513. if (n == 2) return 'two';
  3514. if (n == 1) return 'one';
  3515. return 'other';
  3516. },
  3517. '2': function _(n) {
  3518. if (n !== 0 && n % 10 === 0) return 'many';
  3519. if (n == 2) return 'two';
  3520. if (n == 1) return 'one';
  3521. return 'other';
  3522. },
  3523. '3': function _(n) {
  3524. if (n == 1) return 'one';
  3525. return 'other';
  3526. },
  3527. '4': function _(n) {
  3528. if (isBetween(n, 0, 1)) return 'one';
  3529. return 'other';
  3530. },
  3531. '5': function _(n) {
  3532. if (isBetween(n, 0, 2) && n != 2) return 'one';
  3533. return 'other';
  3534. },
  3535. '6': function _(n) {
  3536. if (n === 0) return 'zero';
  3537. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3538. return 'other';
  3539. },
  3540. '7': function _(n) {
  3541. if (n == 2) return 'two';
  3542. if (n == 1) return 'one';
  3543. return 'other';
  3544. },
  3545. '8': function _(n) {
  3546. if (isBetween(n, 3, 6)) return 'few';
  3547. if (isBetween(n, 7, 10)) return 'many';
  3548. if (n == 2) return 'two';
  3549. if (n == 1) return 'one';
  3550. return 'other';
  3551. },
  3552. '9': function _(n) {
  3553. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3554. if (n == 1) return 'one';
  3555. return 'other';
  3556. },
  3557. '10': function _(n) {
  3558. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3559. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3560. return 'other';
  3561. },
  3562. '11': function _(n) {
  3563. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3564. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3565. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3566. return 'other';
  3567. },
  3568. '12': function _(n) {
  3569. if (isBetween(n, 2, 4)) return 'few';
  3570. if (n == 1) return 'one';
  3571. return 'other';
  3572. },
  3573. '13': function _(n) {
  3574. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3575. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3576. if (n == 1) return 'one';
  3577. return 'other';
  3578. },
  3579. '14': function _(n) {
  3580. if (isBetween(n % 100, 3, 4)) return 'few';
  3581. if (n % 100 == 2) return 'two';
  3582. if (n % 100 == 1) return 'one';
  3583. return 'other';
  3584. },
  3585. '15': function _(n) {
  3586. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3587. if (isBetween(n % 100, 11, 19)) return 'many';
  3588. if (n == 1) return 'one';
  3589. return 'other';
  3590. },
  3591. '16': function _(n) {
  3592. if (n % 10 == 1 && n != 11) return 'one';
  3593. return 'other';
  3594. },
  3595. '17': function _(n) {
  3596. if (n == 3) return 'few';
  3597. if (n === 0) return 'zero';
  3598. if (n == 6) return 'many';
  3599. if (n == 2) return 'two';
  3600. if (n == 1) return 'one';
  3601. return 'other';
  3602. },
  3603. '18': function _(n) {
  3604. if (n === 0) return 'zero';
  3605. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3606. return 'other';
  3607. },
  3608. '19': function _(n) {
  3609. if (isBetween(n, 2, 10)) return 'few';
  3610. if (isBetween(n, 0, 1)) return 'one';
  3611. return 'other';
  3612. },
  3613. '20': function _(n) {
  3614. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  3615. if (n % 1000000 === 0 && n !== 0) return 'many';
  3616. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3617. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3618. return 'other';
  3619. },
  3620. '21': function _(n) {
  3621. if (n === 0) return 'zero';
  3622. if (n == 1) return 'one';
  3623. return 'other';
  3624. },
  3625. '22': function _(n) {
  3626. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3627. return 'other';
  3628. },
  3629. '23': function _(n) {
  3630. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3631. return 'other';
  3632. },
  3633. '24': function _(n) {
  3634. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3635. if (isIn(n, [2, 12])) return 'two';
  3636. if (isIn(n, [1, 11])) return 'one';
  3637. return 'other';
  3638. }
  3639. };
  3640. var index = locales2rules[lang.replace(/-.*$/, '')];
  3641. if (!(index in pluralRules)) {
  3642. console.warn('plural form unknown for [' + lang + ']');
  3643. return function () {
  3644. return 'other';
  3645. };
  3646. }
  3647. return pluralRules[index];
  3648. }
  3649. gMacros.plural = function (str, param, key, prop) {
  3650. var n = parseFloat(param);
  3651. if (isNaN(n)) return str;
  3652. if (prop != gTextProp) return str;
  3653. if (!gMacros._pluralRules) {
  3654. gMacros._pluralRules = getPluralRules(gLanguage);
  3655. }
  3656. var index = '[' + gMacros._pluralRules(n) + ']';
  3657. if (n === 0 && key + '[zero]' in gL10nData) {
  3658. str = gL10nData[key + '[zero]'][prop];
  3659. } else if (n == 1 && key + '[one]' in gL10nData) {
  3660. str = gL10nData[key + '[one]'][prop];
  3661. } else if (n == 2 && key + '[two]' in gL10nData) {
  3662. str = gL10nData[key + '[two]'][prop];
  3663. } else if (key + index in gL10nData) {
  3664. str = gL10nData[key + index][prop];
  3665. } else if (key + '[other]' in gL10nData) {
  3666. str = gL10nData[key + '[other]'][prop];
  3667. }
  3668. return str;
  3669. };
  3670. function getL10nData(key, args, fallback) {
  3671. var data = gL10nData[key];
  3672. if (!data) {
  3673. console.warn('#' + key + ' is undefined.');
  3674. if (!fallback) {
  3675. return null;
  3676. }
  3677. data = fallback;
  3678. }
  3679. var rv = {};
  3680. for (var prop in data) {
  3681. var str = data[prop];
  3682. str = substIndexes(str, args, key, prop);
  3683. str = substArguments(str, args, key);
  3684. rv[prop] = str;
  3685. }
  3686. return rv;
  3687. }
  3688. function substIndexes(str, args, key, prop) {
  3689. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3690. var reMatch = reIndex.exec(str);
  3691. if (!reMatch || !reMatch.length) return str;
  3692. var macroName = reMatch[1];
  3693. var paramName = reMatch[2];
  3694. var param;
  3695. if (args && paramName in args) {
  3696. param = args[paramName];
  3697. } else if (paramName in gL10nData) {
  3698. param = gL10nData[paramName];
  3699. }
  3700. if (macroName in gMacros) {
  3701. var macro = gMacros[macroName];
  3702. str = macro(str, param, key, prop);
  3703. }
  3704. return str;
  3705. }
  3706. function substArguments(str, args, key) {
  3707. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3708. return str.replace(reArgs, function (matched_text, arg) {
  3709. if (args && arg in args) {
  3710. return args[arg];
  3711. }
  3712. if (arg in gL10nData) {
  3713. return gL10nData[arg];
  3714. }
  3715. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3716. return matched_text;
  3717. });
  3718. }
  3719. function translateElement(element) {
  3720. var l10n = getL10nAttributes(element);
  3721. if (!l10n.id) return;
  3722. var data = getL10nData(l10n.id, l10n.args);
  3723. if (!data) {
  3724. console.warn('#' + l10n.id + ' is undefined.');
  3725. return;
  3726. }
  3727. if (data[gTextProp]) {
  3728. if (getChildElementCount(element) === 0) {
  3729. element[gTextProp] = data[gTextProp];
  3730. } else {
  3731. var children = element.childNodes;
  3732. var found = false;
  3733. for (var i = 0, l = children.length; i < l; i++) {
  3734. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3735. if (found) {
  3736. children[i].nodeValue = '';
  3737. } else {
  3738. children[i].nodeValue = data[gTextProp];
  3739. found = true;
  3740. }
  3741. }
  3742. }
  3743. if (!found) {
  3744. var textNode = document.createTextNode(data[gTextProp]);
  3745. element.insertBefore(textNode, element.firstChild);
  3746. }
  3747. }
  3748. delete data[gTextProp];
  3749. }
  3750. for (var k in data) {
  3751. element[k] = data[k];
  3752. }
  3753. }
  3754. function getChildElementCount(element) {
  3755. if (element.children) {
  3756. return element.children.length;
  3757. }
  3758. if (typeof element.childElementCount !== 'undefined') {
  3759. return element.childElementCount;
  3760. }
  3761. var count = 0;
  3762. for (var i = 0; i < element.childNodes.length; i++) {
  3763. count += element.nodeType === 1 ? 1 : 0;
  3764. }
  3765. return count;
  3766. }
  3767. function translateFragment(element) {
  3768. element = element || document.documentElement;
  3769. var children = getTranslatableChildren(element);
  3770. var elementCount = children.length;
  3771. for (var i = 0; i < elementCount; i++) {
  3772. translateElement(children[i]);
  3773. }
  3774. translateElement(element);
  3775. }
  3776. return {
  3777. get: function get(key, args, fallbackString) {
  3778. var index = key.lastIndexOf('.');
  3779. var prop = gTextProp;
  3780. if (index > 0) {
  3781. prop = key.substr(index + 1);
  3782. key = key.substring(0, index);
  3783. }
  3784. var fallback;
  3785. if (fallbackString) {
  3786. fallback = {};
  3787. fallback[prop] = fallbackString;
  3788. }
  3789. var data = getL10nData(key, args, fallback);
  3790. if (data && prop in data) {
  3791. return data[prop];
  3792. }
  3793. return '{{' + key + '}}';
  3794. },
  3795. getData: function getData() {
  3796. return gL10nData;
  3797. },
  3798. getText: function getText() {
  3799. return gTextData;
  3800. },
  3801. getLanguage: function getLanguage() {
  3802. return gLanguage;
  3803. },
  3804. setLanguage: function setLanguage(lang, callback) {
  3805. loadLocale(lang, function () {
  3806. if (callback) callback();
  3807. });
  3808. },
  3809. getDirection: function getDirection() {
  3810. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3811. var shortCode = gLanguage.split('-', 1)[0];
  3812. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3813. },
  3814. translate: translateFragment,
  3815. getReadyState: function getReadyState() {
  3816. return gReadyState;
  3817. },
  3818. ready: function ready(callback) {
  3819. if (!callback) {
  3820. return;
  3821. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3822. window.setTimeout(function () {
  3823. callback();
  3824. });
  3825. } else if (document.addEventListener) {
  3826. document.addEventListener('localized', function once() {
  3827. document.removeEventListener('localized', once);
  3828. callback();
  3829. });
  3830. }
  3831. }
  3832. };
  3833. }(window, document);
  3834. /***/ }),
  3835. /* 13 */
  3836. /***/ (function(module, exports, __w_pdfjs_require__) {
  3837. "use strict";
  3838. Object.defineProperty(exports, "__esModule", {
  3839. value: true
  3840. });
  3841. exports.PDFFindController = exports.FindState = undefined;
  3842. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3843. var _pdfjsLib = __w_pdfjs_require__(0);
  3844. var _ui_utils = __w_pdfjs_require__(1);
  3845. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3846. var FindState = {
  3847. FOUND: 0,
  3848. NOT_FOUND: 1,
  3849. WRAPPED: 2,
  3850. PENDING: 3
  3851. };
  3852. var FIND_SCROLL_OFFSET_TOP = -50;
  3853. var FIND_SCROLL_OFFSET_LEFT = -400;
  3854. var FIND_TIMEOUT = 250;
  3855. var CHARACTERS_TO_NORMALIZE = {
  3856. '\u2018': '\'',
  3857. '\u2019': '\'',
  3858. '\u201A': '\'',
  3859. '\u201B': '\'',
  3860. '\u201C': '"',
  3861. '\u201D': '"',
  3862. '\u201E': '"',
  3863. '\u201F': '"',
  3864. '\xBC': '1/4',
  3865. '\xBD': '1/2',
  3866. '\xBE': '3/4'
  3867. };
  3868. var PDFFindController = function () {
  3869. function PDFFindController(_ref) {
  3870. var pdfViewer = _ref.pdfViewer;
  3871. _classCallCheck(this, PDFFindController);
  3872. this.pdfViewer = pdfViewer;
  3873. this.onUpdateResultsCount = null;
  3874. this.onUpdateState = null;
  3875. this.reset();
  3876. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3877. this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
  3878. }
  3879. _createClass(PDFFindController, [{
  3880. key: 'reset',
  3881. value: function reset() {
  3882. var _this = this;
  3883. this.startedTextExtraction = false;
  3884. this.extractTextPromises = [];
  3885. this.pendingFindMatches = Object.create(null);
  3886. this.active = false;
  3887. this.pageContents = [];
  3888. this.pageMatches = [];
  3889. this.pageMatchesLength = null;
  3890. this.matchCount = 0;
  3891. this.selected = {
  3892. pageIdx: -1,
  3893. matchIdx: -1
  3894. };
  3895. this.offset = {
  3896. pageIdx: null,
  3897. matchIdx: null
  3898. };
  3899. this.pagesToSearch = null;
  3900. this.resumePageIdx = null;
  3901. this.state = null;
  3902. this.dirtyMatch = false;
  3903. this.findTimeout = null;
  3904. this._firstPagePromise = new Promise(function (resolve) {
  3905. _this.resolveFirstPage = resolve;
  3906. });
  3907. }
  3908. }, {
  3909. key: 'executeCommand',
  3910. value: function executeCommand(cmd, state) {
  3911. var _this2 = this;
  3912. if (this.state === null || cmd !== 'findagain') {
  3913. this.dirtyMatch = true;
  3914. }
  3915. this.state = state;
  3916. this._updateUIState(FindState.PENDING);
  3917. this._firstPagePromise.then(function () {
  3918. _this2._extractText();
  3919. clearTimeout(_this2.findTimeout);
  3920. if (cmd === 'find') {
  3921. _this2.findTimeout = setTimeout(_this2._nextMatch.bind(_this2), FIND_TIMEOUT);
  3922. } else {
  3923. _this2._nextMatch();
  3924. }
  3925. });
  3926. }
  3927. }, {
  3928. key: 'updateMatchPosition',
  3929. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  3930. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  3931. var spot = {
  3932. top: FIND_SCROLL_OFFSET_TOP,
  3933. left: FIND_SCROLL_OFFSET_LEFT
  3934. };
  3935. (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
  3936. }
  3937. }
  3938. }, {
  3939. key: '_normalize',
  3940. value: function _normalize(text) {
  3941. return text.replace(this.normalizationRegex, function (ch) {
  3942. return CHARACTERS_TO_NORMALIZE[ch];
  3943. });
  3944. }
  3945. }, {
  3946. key: '_prepareMatches',
  3947. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3948. function isSubTerm(matchesWithLength, currentIndex) {
  3949. var currentElem = matchesWithLength[currentIndex];
  3950. var nextElem = matchesWithLength[currentIndex + 1];
  3951. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3952. currentElem.skipped = true;
  3953. return true;
  3954. }
  3955. for (var i = currentIndex - 1; i >= 0; i--) {
  3956. var prevElem = matchesWithLength[i];
  3957. if (prevElem.skipped) {
  3958. continue;
  3959. }
  3960. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3961. break;
  3962. }
  3963. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3964. currentElem.skipped = true;
  3965. return true;
  3966. }
  3967. }
  3968. return false;
  3969. }
  3970. matchesWithLength.sort(function (a, b) {
  3971. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3972. });
  3973. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3974. if (isSubTerm(matchesWithLength, i)) {
  3975. continue;
  3976. }
  3977. matches.push(matchesWithLength[i].match);
  3978. matchesLength.push(matchesWithLength[i].matchLength);
  3979. }
  3980. }
  3981. }, {
  3982. key: '_calculatePhraseMatch',
  3983. value: function _calculatePhraseMatch(query, pageIndex, pageContent) {
  3984. var matches = [];
  3985. var queryLen = query.length;
  3986. var matchIdx = -queryLen;
  3987. while (true) {
  3988. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3989. if (matchIdx === -1) {
  3990. break;
  3991. }
  3992. matches.push(matchIdx);
  3993. }
  3994. this.pageMatches[pageIndex] = matches;
  3995. }
  3996. }, {
  3997. key: '_calculateWordMatch',
  3998. value: function _calculateWordMatch(query, pageIndex, pageContent) {
  3999. var matchesWithLength = [];
  4000. var queryArray = query.match(/\S+/g);
  4001. for (var i = 0, len = queryArray.length; i < len; i++) {
  4002. var subquery = queryArray[i];
  4003. var subqueryLen = subquery.length;
  4004. var matchIdx = -subqueryLen;
  4005. while (true) {
  4006. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  4007. if (matchIdx === -1) {
  4008. break;
  4009. }
  4010. matchesWithLength.push({
  4011. match: matchIdx,
  4012. matchLength: subqueryLen,
  4013. skipped: false
  4014. });
  4015. }
  4016. }
  4017. if (!this.pageMatchesLength) {
  4018. this.pageMatchesLength = [];
  4019. }
  4020. this.pageMatchesLength[pageIndex] = [];
  4021. this.pageMatches[pageIndex] = [];
  4022. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
  4023. }
  4024. }, {
  4025. key: '_calculateMatch',
  4026. value: function _calculateMatch(pageIndex) {
  4027. var pageContent = this._normalize(this.pageContents[pageIndex]);
  4028. var query = this._normalize(this.state.query);
  4029. var caseSensitive = this.state.caseSensitive;
  4030. var phraseSearch = this.state.phraseSearch;
  4031. var queryLen = query.length;
  4032. if (queryLen === 0) {
  4033. return;
  4034. }
  4035. if (!caseSensitive) {
  4036. pageContent = pageContent.toLowerCase();
  4037. query = query.toLowerCase();
  4038. }
  4039. if (phraseSearch) {
  4040. this._calculatePhraseMatch(query, pageIndex, pageContent);
  4041. } else {
  4042. this._calculateWordMatch(query, pageIndex, pageContent);
  4043. }
  4044. this._updatePage(pageIndex);
  4045. if (this.resumePageIdx === pageIndex) {
  4046. this.resumePageIdx = null;
  4047. this._nextPageMatch();
  4048. }
  4049. if (this.pageMatches[pageIndex].length > 0) {
  4050. this.matchCount += this.pageMatches[pageIndex].length;
  4051. this._updateUIResultsCount();
  4052. }
  4053. }
  4054. }, {
  4055. key: '_extractText',
  4056. value: function _extractText() {
  4057. var _this3 = this;
  4058. if (this.startedTextExtraction) {
  4059. return;
  4060. }
  4061. this.startedTextExtraction = true;
  4062. this.pageContents.length = 0;
  4063. var promise = Promise.resolve();
  4064. var _loop = function _loop(i, ii) {
  4065. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  4066. _this3.extractTextPromises[i] = extractTextCapability.promise;
  4067. promise = promise.then(function () {
  4068. return _this3.pdfViewer.getPageTextContent(i).then(function (textContent) {
  4069. var textItems = textContent.items;
  4070. var strBuf = [];
  4071. for (var j = 0, jj = textItems.length; j < jj; j++) {
  4072. strBuf.push(textItems[j].str);
  4073. }
  4074. _this3.pageContents[i] = strBuf.join('');
  4075. extractTextCapability.resolve(i);
  4076. }, function (reason) {
  4077. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  4078. _this3.pageContents[i] = '';
  4079. extractTextCapability.resolve(i);
  4080. });
  4081. });
  4082. };
  4083. for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
  4084. _loop(i, ii);
  4085. }
  4086. }
  4087. }, {
  4088. key: '_updatePage',
  4089. value: function _updatePage(index) {
  4090. if (this.selected.pageIdx === index) {
  4091. this.pdfViewer.currentPageNumber = index + 1;
  4092. }
  4093. var page = this.pdfViewer.getPageView(index);
  4094. if (page.textLayer) {
  4095. page.textLayer.updateMatches();
  4096. }
  4097. }
  4098. }, {
  4099. key: '_nextMatch',
  4100. value: function _nextMatch() {
  4101. var _this4 = this;
  4102. var previous = this.state.findPrevious;
  4103. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  4104. var numPages = this.pdfViewer.pagesCount;
  4105. this.active = true;
  4106. if (this.dirtyMatch) {
  4107. this.dirtyMatch = false;
  4108. this.selected.pageIdx = this.selected.matchIdx = -1;
  4109. this.offset.pageIdx = currentPageIndex;
  4110. this.offset.matchIdx = null;
  4111. this.hadMatch = false;
  4112. this.resumePageIdx = null;
  4113. this.pageMatches = [];
  4114. this.matchCount = 0;
  4115. this.pageMatchesLength = null;
  4116. for (var i = 0; i < numPages; i++) {
  4117. this._updatePage(i);
  4118. if (!(i in this.pendingFindMatches)) {
  4119. this.pendingFindMatches[i] = true;
  4120. this.extractTextPromises[i].then(function (pageIdx) {
  4121. delete _this4.pendingFindMatches[pageIdx];
  4122. _this4._calculateMatch(pageIdx);
  4123. });
  4124. }
  4125. }
  4126. }
  4127. if (this.state.query === '') {
  4128. this._updateUIState(FindState.FOUND);
  4129. return;
  4130. }
  4131. if (this.resumePageIdx) {
  4132. return;
  4133. }
  4134. var offset = this.offset;
  4135. this.pagesToSearch = numPages;
  4136. if (offset.matchIdx !== null) {
  4137. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  4138. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  4139. this.hadMatch = true;
  4140. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  4141. this._updateMatch(true);
  4142. return;
  4143. }
  4144. this._advanceOffsetPage(previous);
  4145. }
  4146. this._nextPageMatch();
  4147. }
  4148. }, {
  4149. key: '_matchesReady',
  4150. value: function _matchesReady(matches) {
  4151. var offset = this.offset;
  4152. var numMatches = matches.length;
  4153. var previous = this.state.findPrevious;
  4154. if (numMatches) {
  4155. this.hadMatch = true;
  4156. offset.matchIdx = previous ? numMatches - 1 : 0;
  4157. this._updateMatch(true);
  4158. return true;
  4159. }
  4160. this._advanceOffsetPage(previous);
  4161. if (offset.wrapped) {
  4162. offset.matchIdx = null;
  4163. if (this.pagesToSearch < 0) {
  4164. this._updateMatch(false);
  4165. return true;
  4166. }
  4167. }
  4168. return false;
  4169. }
  4170. }, {
  4171. key: '_nextPageMatch',
  4172. value: function _nextPageMatch() {
  4173. if (this.resumePageIdx !== null) {
  4174. console.error('There can only be one pending page.');
  4175. }
  4176. var matches = null;
  4177. do {
  4178. var pageIdx = this.offset.pageIdx;
  4179. matches = this.pageMatches[pageIdx];
  4180. if (!matches) {
  4181. this.resumePageIdx = pageIdx;
  4182. break;
  4183. }
  4184. } while (!this._matchesReady(matches));
  4185. }
  4186. }, {
  4187. key: '_advanceOffsetPage',
  4188. value: function _advanceOffsetPage(previous) {
  4189. var offset = this.offset;
  4190. var numPages = this.extractTextPromises.length;
  4191. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  4192. offset.matchIdx = null;
  4193. this.pagesToSearch--;
  4194. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  4195. offset.pageIdx = previous ? numPages - 1 : 0;
  4196. offset.wrapped = true;
  4197. }
  4198. }
  4199. }, {
  4200. key: '_updateMatch',
  4201. value: function _updateMatch() {
  4202. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4203. var state = FindState.NOT_FOUND;
  4204. var wrapped = this.offset.wrapped;
  4205. this.offset.wrapped = false;
  4206. if (found) {
  4207. var previousPage = this.selected.pageIdx;
  4208. this.selected.pageIdx = this.offset.pageIdx;
  4209. this.selected.matchIdx = this.offset.matchIdx;
  4210. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  4211. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  4212. this._updatePage(previousPage);
  4213. }
  4214. }
  4215. this._updateUIState(state, this.state.findPrevious);
  4216. if (this.selected.pageIdx !== -1) {
  4217. this._updatePage(this.selected.pageIdx);
  4218. }
  4219. }
  4220. }, {
  4221. key: '_updateUIResultsCount',
  4222. value: function _updateUIResultsCount() {
  4223. if (this.onUpdateResultsCount) {
  4224. this.onUpdateResultsCount(this.matchCount);
  4225. }
  4226. }
  4227. }, {
  4228. key: '_updateUIState',
  4229. value: function _updateUIState(state, previous) {
  4230. if (this.onUpdateState) {
  4231. this.onUpdateState(state, previous, this.matchCount);
  4232. }
  4233. }
  4234. }]);
  4235. return PDFFindController;
  4236. }();
  4237. exports.FindState = FindState;
  4238. exports.PDFFindController = PDFFindController;
  4239. /***/ }),
  4240. /* 14 */
  4241. /***/ (function(module, exports, __w_pdfjs_require__) {
  4242. "use strict";
  4243. Object.defineProperty(exports, "__esModule", {
  4244. value: true
  4245. });
  4246. exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
  4247. 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; };
  4248. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4249. var _ui_utils = __w_pdfjs_require__(1);
  4250. var _dom_events = __w_pdfjs_require__(2);
  4251. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4252. var HASH_CHANGE_TIMEOUT = 1000;
  4253. var POSITION_UPDATED_THRESHOLD = 50;
  4254. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  4255. function getCurrentHash() {
  4256. return document.location.hash;
  4257. }
  4258. function parseCurrentHash(linkService) {
  4259. var hash = unescape(getCurrentHash()).substring(1);
  4260. var params = (0, _ui_utils.parseQueryString)(hash);
  4261. var page = params.page | 0;
  4262. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  4263. page = null;
  4264. }
  4265. return {
  4266. hash: hash,
  4267. page: page,
  4268. rotation: linkService.rotation
  4269. };
  4270. }
  4271. var PDFHistory = function () {
  4272. function PDFHistory(_ref) {
  4273. var _this = this;
  4274. var linkService = _ref.linkService,
  4275. eventBus = _ref.eventBus;
  4276. _classCallCheck(this, PDFHistory);
  4277. this.linkService = linkService;
  4278. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  4279. this.initialized = false;
  4280. this.initialBookmark = null;
  4281. this.initialRotation = null;
  4282. this._boundEvents = Object.create(null);
  4283. this._isViewerInPresentationMode = false;
  4284. this._isPagesLoaded = false;
  4285. this.eventBus.on('presentationmodechanged', function (evt) {
  4286. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4287. });
  4288. this.eventBus.on('pagesloaded', function (evt) {
  4289. _this._isPagesLoaded = !!evt.pagesCount;
  4290. });
  4291. }
  4292. _createClass(PDFHistory, [{
  4293. key: 'initialize',
  4294. value: function initialize(fingerprint) {
  4295. var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4296. if (!fingerprint || typeof fingerprint !== 'string') {
  4297. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4298. return;
  4299. }
  4300. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  4301. this.fingerprint = fingerprint;
  4302. if (!this.initialized) {
  4303. this._bindEvents();
  4304. }
  4305. var state = window.history.state;
  4306. this.initialized = true;
  4307. this.initialBookmark = null;
  4308. this.initialRotation = null;
  4309. this._popStateInProgress = false;
  4310. this._blockHashChange = 0;
  4311. this._currentHash = getCurrentHash();
  4312. this._numPositionUpdates = 0;
  4313. this._uid = this._maxUid = 0;
  4314. this._destination = null;
  4315. this._position = null;
  4316. if (!this._isValidState(state) || resetHistory) {
  4317. var _parseCurrentHash = parseCurrentHash(this.linkService),
  4318. hash = _parseCurrentHash.hash,
  4319. page = _parseCurrentHash.page,
  4320. rotation = _parseCurrentHash.rotation;
  4321. if (!hash || reInitialized || resetHistory) {
  4322. this._pushOrReplaceState(null, true);
  4323. return;
  4324. }
  4325. this._pushOrReplaceState({
  4326. hash: hash,
  4327. page: page,
  4328. rotation: rotation
  4329. }, true);
  4330. return;
  4331. }
  4332. var destination = state.destination;
  4333. this._updateInternalState(destination, state.uid, true);
  4334. if (this._uid > this._maxUid) {
  4335. this._maxUid = this._uid;
  4336. }
  4337. if (destination.rotation !== undefined) {
  4338. this.initialRotation = destination.rotation;
  4339. }
  4340. if (destination.dest) {
  4341. this.initialBookmark = JSON.stringify(destination.dest);
  4342. this._destination.page = null;
  4343. } else if (destination.hash) {
  4344. this.initialBookmark = destination.hash;
  4345. } else if (destination.page) {
  4346. this.initialBookmark = 'page=' + destination.page;
  4347. }
  4348. }
  4349. }, {
  4350. key: 'push',
  4351. value: function push(_ref2) {
  4352. var _this2 = this;
  4353. var namedDest = _ref2.namedDest,
  4354. explicitDest = _ref2.explicitDest,
  4355. pageNumber = _ref2.pageNumber;
  4356. if (!this.initialized) {
  4357. return;
  4358. }
  4359. if (namedDest && typeof namedDest !== 'string' || !(explicitDest instanceof Array) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4360. console.error('PDFHistory.push: Invalid parameters.');
  4361. return;
  4362. }
  4363. var hash = namedDest || JSON.stringify(explicitDest);
  4364. if (!hash) {
  4365. return;
  4366. }
  4367. var forceReplace = false;
  4368. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4369. if (this._destination.page) {
  4370. return;
  4371. }
  4372. forceReplace = true;
  4373. }
  4374. if (this._popStateInProgress && !forceReplace) {
  4375. return;
  4376. }
  4377. this._pushOrReplaceState({
  4378. dest: explicitDest,
  4379. hash: hash,
  4380. page: pageNumber,
  4381. rotation: this.linkService.rotation
  4382. }, forceReplace);
  4383. if (!this._popStateInProgress) {
  4384. this._popStateInProgress = true;
  4385. Promise.resolve().then(function () {
  4386. _this2._popStateInProgress = false;
  4387. });
  4388. }
  4389. }
  4390. }, {
  4391. key: 'pushCurrentPosition',
  4392. value: function pushCurrentPosition() {
  4393. if (!this.initialized || this._popStateInProgress) {
  4394. return;
  4395. }
  4396. this._tryPushCurrentPosition();
  4397. }
  4398. }, {
  4399. key: 'back',
  4400. value: function back() {
  4401. if (!this.initialized || this._popStateInProgress) {
  4402. return;
  4403. }
  4404. var state = window.history.state;
  4405. if (this._isValidState(state) && state.uid > 0) {
  4406. window.history.back();
  4407. }
  4408. }
  4409. }, {
  4410. key: 'forward',
  4411. value: function forward() {
  4412. if (!this.initialized || this._popStateInProgress) {
  4413. return;
  4414. }
  4415. var state = window.history.state;
  4416. if (this._isValidState(state) && state.uid < this._maxUid) {
  4417. window.history.forward();
  4418. }
  4419. }
  4420. }, {
  4421. key: '_pushOrReplaceState',
  4422. value: function _pushOrReplaceState(destination) {
  4423. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4424. var shouldReplace = forceReplace || !this._destination;
  4425. var newState = {
  4426. fingerprint: this.fingerprint,
  4427. uid: shouldReplace ? this._uid : this._uid + 1,
  4428. destination: destination
  4429. };
  4430. this._updateInternalState(destination, newState.uid);
  4431. if (shouldReplace) {
  4432. window.history.replaceState(newState, '');
  4433. } else {
  4434. this._maxUid = this._uid;
  4435. window.history.pushState(newState, '');
  4436. }
  4437. }
  4438. }, {
  4439. key: '_tryPushCurrentPosition',
  4440. value: function _tryPushCurrentPosition() {
  4441. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4442. if (!this._position) {
  4443. return;
  4444. }
  4445. var position = this._position;
  4446. if (temporary) {
  4447. position = (0, _ui_utils.cloneObj)(this._position);
  4448. position.temporary = true;
  4449. }
  4450. if (!this._destination) {
  4451. this._pushOrReplaceState(position);
  4452. return;
  4453. }
  4454. if (this._destination.temporary) {
  4455. this._pushOrReplaceState(position, true);
  4456. return;
  4457. }
  4458. if (this._destination.hash === position.hash) {
  4459. return;
  4460. }
  4461. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4462. return;
  4463. }
  4464. var forceReplace = false;
  4465. if (this._destination.page === position.first || this._destination.page === position.page) {
  4466. if (this._destination.dest || !this._destination.first) {
  4467. return;
  4468. }
  4469. forceReplace = true;
  4470. }
  4471. this._pushOrReplaceState(position, forceReplace);
  4472. }
  4473. }, {
  4474. key: '_isValidState',
  4475. value: function _isValidState(state) {
  4476. if (!state) {
  4477. return false;
  4478. }
  4479. if (state.fingerprint !== this.fingerprint) {
  4480. return false;
  4481. }
  4482. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4483. return false;
  4484. }
  4485. if (state.destination === null || _typeof(state.destination) !== 'object') {
  4486. return false;
  4487. }
  4488. return true;
  4489. }
  4490. }, {
  4491. key: '_updateInternalState',
  4492. value: function _updateInternalState(destination, uid) {
  4493. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4494. if (this._updateViewareaTimeout) {
  4495. clearTimeout(this._updateViewareaTimeout);
  4496. this._updateViewareaTimeout = null;
  4497. }
  4498. if (removeTemporary && destination && destination.temporary) {
  4499. delete destination.temporary;
  4500. }
  4501. this._destination = destination;
  4502. this._uid = uid;
  4503. this._numPositionUpdates = 0;
  4504. }
  4505. }, {
  4506. key: '_updateViewarea',
  4507. value: function _updateViewarea(_ref3) {
  4508. var _this3 = this;
  4509. var location = _ref3.location;
  4510. if (this._updateViewareaTimeout) {
  4511. clearTimeout(this._updateViewareaTimeout);
  4512. this._updateViewareaTimeout = null;
  4513. }
  4514. this._position = {
  4515. hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
  4516. page: this.linkService.page,
  4517. first: location.pageNumber,
  4518. rotation: location.rotation
  4519. };
  4520. if (this._popStateInProgress) {
  4521. return;
  4522. }
  4523. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4524. this._numPositionUpdates++;
  4525. }
  4526. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4527. this._updateViewareaTimeout = setTimeout(function () {
  4528. if (!_this3._popStateInProgress) {
  4529. _this3._tryPushCurrentPosition(true);
  4530. }
  4531. _this3._updateViewareaTimeout = null;
  4532. }, UPDATE_VIEWAREA_TIMEOUT);
  4533. }
  4534. }
  4535. }, {
  4536. key: '_popState',
  4537. value: function _popState(_ref4) {
  4538. var _this4 = this;
  4539. var state = _ref4.state;
  4540. var newHash = getCurrentHash(),
  4541. hashChanged = this._currentHash !== newHash;
  4542. this._currentHash = newHash;
  4543. if (!state || false) {
  4544. this._uid++;
  4545. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  4546. hash = _parseCurrentHash2.hash,
  4547. page = _parseCurrentHash2.page,
  4548. rotation = _parseCurrentHash2.rotation;
  4549. this._pushOrReplaceState({
  4550. hash: hash,
  4551. page: page,
  4552. rotation: rotation
  4553. }, true);
  4554. return;
  4555. }
  4556. if (!this._isValidState(state)) {
  4557. return;
  4558. }
  4559. this._popStateInProgress = true;
  4560. if (hashChanged) {
  4561. this._blockHashChange++;
  4562. (0, _ui_utils.waitOnEventOrTimeout)({
  4563. target: window,
  4564. name: 'hashchange',
  4565. delay: HASH_CHANGE_TIMEOUT
  4566. }).then(function () {
  4567. _this4._blockHashChange--;
  4568. });
  4569. }
  4570. var destination = state.destination;
  4571. this._updateInternalState(destination, state.uid, true);
  4572. if (this._uid > this._maxUid) {
  4573. this._maxUid = this._uid;
  4574. }
  4575. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4576. this.linkService.rotation = destination.rotation;
  4577. }
  4578. if (destination.dest) {
  4579. this.linkService.navigateTo(destination.dest);
  4580. } else if (destination.hash) {
  4581. this.linkService.setHash(destination.hash);
  4582. } else if (destination.page) {
  4583. this.linkService.page = destination.page;
  4584. }
  4585. Promise.resolve().then(function () {
  4586. _this4._popStateInProgress = false;
  4587. });
  4588. }
  4589. }, {
  4590. key: '_bindEvents',
  4591. value: function _bindEvents() {
  4592. var _this5 = this;
  4593. var _boundEvents = this._boundEvents,
  4594. eventBus = this.eventBus;
  4595. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  4596. _boundEvents.popState = this._popState.bind(this);
  4597. _boundEvents.pageHide = function (evt) {
  4598. if (!_this5._destination || _this5._destination.temporary) {
  4599. _this5._tryPushCurrentPosition();
  4600. }
  4601. };
  4602. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  4603. window.addEventListener('popstate', _boundEvents.popState);
  4604. window.addEventListener('pagehide', _boundEvents.pageHide);
  4605. }
  4606. }, {
  4607. key: 'popStateInProgress',
  4608. get: function get() {
  4609. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4610. }
  4611. }]);
  4612. return PDFHistory;
  4613. }();
  4614. function isDestHashesEqual(destHash, pushHash) {
  4615. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  4616. return false;
  4617. }
  4618. if (destHash === pushHash) {
  4619. return true;
  4620. }
  4621. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4622. nameddest = _parseQueryString.nameddest;
  4623. if (nameddest === pushHash) {
  4624. return true;
  4625. }
  4626. return false;
  4627. }
  4628. function isDestArraysEqual(firstDest, secondDest) {
  4629. function isEntryEqual(first, second) {
  4630. if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
  4631. return false;
  4632. }
  4633. if (first instanceof Array || second instanceof Array) {
  4634. return false;
  4635. }
  4636. if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
  4637. if (Object.keys(first).length !== Object.keys(second).length) {
  4638. return false;
  4639. }
  4640. for (var key in first) {
  4641. if (!isEntryEqual(first[key], second[key])) {
  4642. return false;
  4643. }
  4644. }
  4645. return true;
  4646. }
  4647. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4648. }
  4649. if (!(firstDest instanceof Array && secondDest instanceof Array)) {
  4650. return false;
  4651. }
  4652. if (firstDest.length !== secondDest.length) {
  4653. return false;
  4654. }
  4655. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4656. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4657. return false;
  4658. }
  4659. }
  4660. return true;
  4661. }
  4662. exports.PDFHistory = PDFHistory;
  4663. exports.isDestHashesEqual = isDestHashesEqual;
  4664. exports.isDestArraysEqual = isDestArraysEqual;
  4665. /***/ }),
  4666. /* 15 */
  4667. /***/ (function(module, exports, __w_pdfjs_require__) {
  4668. "use strict";
  4669. Object.defineProperty(exports, "__esModule", {
  4670. value: true
  4671. });
  4672. exports.PDFSinglePageViewer = undefined;
  4673. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4674. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4675. var _base_viewer = __w_pdfjs_require__(8);
  4676. var _ui_utils = __w_pdfjs_require__(1);
  4677. var _pdfjsLib = __w_pdfjs_require__(0);
  4678. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4679. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4680. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4681. var PDFSinglePageViewer = function (_BaseViewer) {
  4682. _inherits(PDFSinglePageViewer, _BaseViewer);
  4683. function PDFSinglePageViewer(options) {
  4684. _classCallCheck(this, PDFSinglePageViewer);
  4685. var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
  4686. _this.eventBus.on('pagesinit', function (evt) {
  4687. _this._ensurePageViewVisible();
  4688. });
  4689. return _this;
  4690. }
  4691. _createClass(PDFSinglePageViewer, [{
  4692. key: '_resetView',
  4693. value: function _resetView() {
  4694. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
  4695. this._previousPageNumber = 1;
  4696. this._shadowViewer = document.createDocumentFragment();
  4697. }
  4698. }, {
  4699. key: '_ensurePageViewVisible',
  4700. value: function _ensurePageViewVisible() {
  4701. var pageView = this._pages[this._currentPageNumber - 1];
  4702. var previousPageView = this._pages[this._previousPageNumber - 1];
  4703. var viewerNodes = this.viewer.childNodes;
  4704. switch (viewerNodes.length) {
  4705. case 0:
  4706. this.viewer.appendChild(pageView.div);
  4707. break;
  4708. case 1:
  4709. if (viewerNodes[0] !== previousPageView.div) {
  4710. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  4711. }
  4712. if (pageView === previousPageView) {
  4713. break;
  4714. }
  4715. this._shadowViewer.appendChild(previousPageView.div);
  4716. this.viewer.appendChild(pageView.div);
  4717. this.container.scrollTop = 0;
  4718. break;
  4719. default:
  4720. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  4721. }
  4722. this._previousPageNumber = this._currentPageNumber;
  4723. }
  4724. }, {
  4725. key: '_scrollUpdate',
  4726. value: function _scrollUpdate() {
  4727. if (this._updateScrollDown) {
  4728. this._updateScrollDown();
  4729. }
  4730. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
  4731. }
  4732. }, {
  4733. key: '_scrollIntoView',
  4734. value: function _scrollIntoView(_ref) {
  4735. var _this2 = this;
  4736. var pageDiv = _ref.pageDiv,
  4737. _ref$pageSpot = _ref.pageSpot,
  4738. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  4739. _ref$pageNumber = _ref.pageNumber,
  4740. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  4741. if (pageNumber) {
  4742. this._setCurrentPageNumber(pageNumber);
  4743. }
  4744. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  4745. var previousLocation = this._location;
  4746. this._ensurePageViewVisible();
  4747. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4748. this._updateScrollDown = function () {
  4749. _this2.scroll.down = scrolledDown;
  4750. delete _this2._updateScrollDown;
  4751. };
  4752. setTimeout(function () {
  4753. if (_this2._location === previousLocation) {
  4754. if (_this2._updateScrollDown) {
  4755. _this2._updateScrollDown();
  4756. }
  4757. _this2.update();
  4758. }
  4759. }, 0);
  4760. }
  4761. }, {
  4762. key: '_getVisiblePages',
  4763. value: function _getVisiblePages() {
  4764. if (!this.pagesCount) {
  4765. return { views: [] };
  4766. }
  4767. var pageView = this._pages[this._currentPageNumber - 1];
  4768. var element = pageView.div;
  4769. var view = {
  4770. id: pageView.id,
  4771. x: element.offsetLeft + element.clientLeft,
  4772. y: element.offsetTop + element.clientTop,
  4773. view: pageView
  4774. };
  4775. return {
  4776. first: view,
  4777. last: view,
  4778. views: [view]
  4779. };
  4780. }
  4781. }, {
  4782. key: 'update',
  4783. value: function update() {
  4784. var visible = this._getVisiblePages();
  4785. var visiblePages = visible.views,
  4786. numVisiblePages = visiblePages.length;
  4787. if (numVisiblePages === 0) {
  4788. return;
  4789. }
  4790. this._resizeBuffer(numVisiblePages);
  4791. this.renderingQueue.renderHighestPriority(visible);
  4792. this._updateLocation(visible.first);
  4793. this.eventBus.dispatch('updateviewarea', {
  4794. source: this,
  4795. location: this._location
  4796. });
  4797. }
  4798. }, {
  4799. key: '_setDocumentViewerElement',
  4800. get: function get() {
  4801. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  4802. }
  4803. }]);
  4804. return PDFSinglePageViewer;
  4805. }(_base_viewer.BaseViewer);
  4806. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  4807. /***/ }),
  4808. /* 16 */
  4809. /***/ (function(module, exports, __w_pdfjs_require__) {
  4810. "use strict";
  4811. Object.defineProperty(exports, "__esModule", {
  4812. value: true
  4813. });
  4814. exports.PDFViewer = undefined;
  4815. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4816. var _ui_utils = __w_pdfjs_require__(1);
  4817. var _base_viewer = __w_pdfjs_require__(8);
  4818. var _pdfjsLib = __w_pdfjs_require__(0);
  4819. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4820. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4821. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4822. var PDFViewer = function (_BaseViewer) {
  4823. _inherits(PDFViewer, _BaseViewer);
  4824. function PDFViewer() {
  4825. _classCallCheck(this, PDFViewer);
  4826. return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
  4827. }
  4828. _createClass(PDFViewer, [{
  4829. key: '_scrollIntoView',
  4830. value: function _scrollIntoView(_ref) {
  4831. var pageDiv = _ref.pageDiv,
  4832. _ref$pageSpot = _ref.pageSpot,
  4833. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
  4834. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4835. }
  4836. }, {
  4837. key: '_getVisiblePages',
  4838. value: function _getVisiblePages() {
  4839. if (!this.isInPresentationMode) {
  4840. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
  4841. }
  4842. var currentPage = this._pages[this._currentPageNumber - 1];
  4843. var visible = [{
  4844. id: currentPage.id,
  4845. view: currentPage
  4846. }];
  4847. return {
  4848. first: currentPage,
  4849. last: currentPage,
  4850. views: visible
  4851. };
  4852. }
  4853. }, {
  4854. key: 'update',
  4855. value: function update() {
  4856. var visible = this._getVisiblePages();
  4857. var visiblePages = visible.views,
  4858. numVisiblePages = visiblePages.length;
  4859. if (numVisiblePages === 0) {
  4860. return;
  4861. }
  4862. this._resizeBuffer(numVisiblePages);
  4863. this.renderingQueue.renderHighestPriority(visible);
  4864. var currentId = this._currentPageNumber;
  4865. var stillFullyVisible = false;
  4866. for (var i = 0; i < numVisiblePages; ++i) {
  4867. var page = visiblePages[i];
  4868. if (page.percent < 100) {
  4869. break;
  4870. }
  4871. if (page.id === currentId) {
  4872. stillFullyVisible = true;
  4873. break;
  4874. }
  4875. }
  4876. if (!stillFullyVisible) {
  4877. currentId = visiblePages[0].id;
  4878. }
  4879. if (!this.isInPresentationMode) {
  4880. this._setCurrentPageNumber(currentId);
  4881. }
  4882. this._updateLocation(visible.first);
  4883. this.eventBus.dispatch('updateviewarea', {
  4884. source: this,
  4885. location: this._location
  4886. });
  4887. }
  4888. }, {
  4889. key: '_setDocumentViewerElement',
  4890. get: function get() {
  4891. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  4892. }
  4893. }]);
  4894. return PDFViewer;
  4895. }(_base_viewer.BaseViewer);
  4896. exports.PDFViewer = PDFViewer;
  4897. /***/ })
  4898. /******/ ]);
  4899. });
  4900. //# sourceMappingURL=pdf_viewer.js.map