pdf_viewer.js 169 KB

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