pdf_viewer.js 169 KB

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