pdf_viewer.js 169 KB

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