pdf_viewer.js 172 KB

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