pdf_viewer.js 172 KB

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