pdf_viewer.js 172 KB

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