viewer.js 479 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 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. /******/
  23. (function(modules) { // webpackBootstrap
  24. /******/ // The module cache
  25. /******/
  26. var installedModules = {};
  27. /******/
  28. /******/ // The require function
  29. /******/
  30. function __webpack_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/
  34. if (installedModules[moduleId]) {
  35. /******/
  36. return installedModules[moduleId].exports;
  37. /******/
  38. }
  39. /******/ // Create a new module (and put it into the cache)
  40. /******/
  41. var module = installedModules[moduleId] = {
  42. /******/
  43. i: moduleId,
  44. /******/
  45. l: false,
  46. /******/
  47. exports: {}
  48. /******/
  49. };
  50. /******/
  51. /******/ // Execute the module function
  52. /******/
  53. modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  54. /******/
  55. /******/ // Flag the module as loaded
  56. /******/
  57. module.l = true;
  58. /******/
  59. /******/ // Return the exports of the module
  60. /******/
  61. return module.exports;
  62. /******/
  63. }
  64. /******/
  65. /******/
  66. /******/ // expose the modules object (__webpack_modules__)
  67. /******/
  68. __webpack_require__.m = modules;
  69. /******/
  70. /******/ // expose the module cache
  71. /******/
  72. __webpack_require__.c = installedModules;
  73. /******/
  74. /******/ // define getter function for harmony exports
  75. /******/
  76. __webpack_require__.d = function(exports, name, getter) {
  77. /******/
  78. if (!__webpack_require__.o(exports, name)) {
  79. /******/
  80. Object.defineProperty(exports, name, {
  81. enumerable: true,
  82. get: getter
  83. });
  84. /******/
  85. }
  86. /******/
  87. };
  88. /******/
  89. /******/ // define __esModule on exports
  90. /******/
  91. __webpack_require__.r = function(exports) {
  92. /******/
  93. if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  94. /******/
  95. Object.defineProperty(exports, Symbol.toStringTag, {
  96. value: 'Module'
  97. });
  98. /******/
  99. }
  100. /******/
  101. Object.defineProperty(exports, '__esModule', {
  102. value: true
  103. });
  104. /******/
  105. };
  106. /******/
  107. /******/ // create a fake namespace object
  108. /******/ // mode & 1: value is a module id, require it
  109. /******/ // mode & 2: merge all properties of value into the ns
  110. /******/ // mode & 4: return value when already ns object
  111. /******/ // mode & 8|1: behave like require
  112. /******/
  113. __webpack_require__.t = function(value, mode) {
  114. /******/
  115. if (mode & 1) value = __webpack_require__(value);
  116. /******/
  117. if (mode & 8) return value;
  118. /******/
  119. if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  120. /******/
  121. var ns = Object.create(null);
  122. /******/
  123. __webpack_require__.r(ns);
  124. /******/
  125. Object.defineProperty(ns, 'default', {
  126. enumerable: true,
  127. value: value
  128. });
  129. /******/
  130. if (mode & 2 && typeof value != 'string')
  131. for (var key in value) __webpack_require__.d(ns, key, function(key) {
  132. return value[key];
  133. }.bind(null, key));
  134. /******/
  135. return ns;
  136. /******/
  137. };
  138. /******/
  139. /******/ // getDefaultExport function for compatibility with non-harmony modules
  140. /******/
  141. __webpack_require__.n = function(module) {
  142. /******/
  143. var getter = module && module.__esModule ?
  144. /******/
  145. function getDefault() {
  146. return module['default'];
  147. } :
  148. /******/
  149. function getModuleExports() {
  150. return module;
  151. };
  152. /******/
  153. __webpack_require__.d(getter, 'a', getter);
  154. /******/
  155. return getter;
  156. /******/
  157. };
  158. /******/
  159. /******/ // Object.prototype.hasOwnProperty.call
  160. /******/
  161. __webpack_require__.o = function(object, property) {
  162. return Object.prototype.hasOwnProperty.call(object, property);
  163. };
  164. /******/
  165. /******/ // __webpack_public_path__
  166. /******/
  167. __webpack_require__.p = "";
  168. /******/
  169. /******/
  170. /******/ // Load entry module and return exports
  171. /******/
  172. return __webpack_require__(__webpack_require__.s = 0);
  173. /******/
  174. })
  175. /************************************************************************/
  176. /******/
  177. ([
  178. /* 0 */
  179. /***/
  180. (function(module, exports, __webpack_require__) {
  181. "use strict";;
  182. var pdfjsWebApp, pdfjsWebAppOptions; {
  183. pdfjsWebApp = __webpack_require__(1);
  184. pdfjsWebAppOptions = __webpack_require__(6);
  185. }; {
  186. __webpack_require__(36);
  187. }; {
  188. __webpack_require__(41);
  189. }
  190. function getViewerConfiguration() {
  191. return {
  192. appContainer: document.body,
  193. mainContainer: document.getElementById('viewerContainer'),
  194. viewerContainer: document.getElementById('viewer'),
  195. eventBus: null,
  196. toolbar: {
  197. container: document.getElementById('toolbarViewer'),
  198. numPages: document.getElementById('numPages'),
  199. pageNumber: document.getElementById('pageNumber'),
  200. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  201. scaleSelect: document.getElementById('scaleSelect'),
  202. customScaleOption: document.getElementById('customScaleOption'),
  203. previous: document.getElementById('previous'),
  204. next: document.getElementById('next'),
  205. zoomIn: document.getElementById('zoomIn'),
  206. zoomOut: document.getElementById('zoomOut'),
  207. viewFind: document.getElementById('viewFind'),
  208. openFile: document.getElementById('openFile'),
  209. print: document.getElementById('print'),
  210. presentationModeButton: document.getElementById('presentationMode'),
  211. download: document.getElementById('download'),
  212. viewBookmark: document.getElementById('viewBookmark')
  213. },
  214. secondaryToolbar: {
  215. toolbar: document.getElementById('secondaryToolbar'),
  216. toggleButton: document.getElementById('secondaryToolbarToggle'),
  217. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  218. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  219. openFileButton: document.getElementById('secondaryOpenFile'),
  220. printButton: document.getElementById('secondaryPrint'),
  221. downloadButton: document.getElementById('secondaryDownload'),
  222. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  223. firstPageButton: document.getElementById('firstPage'),
  224. lastPageButton: document.getElementById('lastPage'),
  225. pageRotateCwButton: document.getElementById('pageRotateCw'),
  226. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  227. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  228. cursorHandToolButton: document.getElementById('cursorHandTool'),
  229. scrollVerticalButton: document.getElementById('scrollVertical'),
  230. scrollHorizontalButton: document.getElementById('scrollHorizontal'),
  231. scrollWrappedButton: document.getElementById('scrollWrapped'),
  232. spreadNoneButton: document.getElementById('spreadNone'),
  233. spreadOddButton: document.getElementById('spreadOdd'),
  234. spreadEvenButton: document.getElementById('spreadEven'),
  235. documentPropertiesButton: document.getElementById('documentProperties')
  236. },
  237. fullscreen: {
  238. contextFirstPage: document.getElementById('contextFirstPage'),
  239. contextLastPage: document.getElementById('contextLastPage'),
  240. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  241. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  242. },
  243. sidebar: {
  244. outerContainer: document.getElementById('outerContainer'),
  245. viewerContainer: document.getElementById('viewerContainer'),
  246. toggleButton: document.getElementById('sidebarToggle'),
  247. thumbnailButton: document.getElementById('viewThumbnail'),
  248. outlineButton: document.getElementById('viewOutline'),
  249. attachmentsButton: document.getElementById('viewAttachments'),
  250. thumbnailView: document.getElementById('thumbnailView'),
  251. outlineView: document.getElementById('outlineView'),
  252. attachmentsView: document.getElementById('attachmentsView')
  253. },
  254. sidebarResizer: {
  255. outerContainer: document.getElementById('outerContainer'),
  256. resizer: document.getElementById('sidebarResizer')
  257. },
  258. findBar: {
  259. bar: document.getElementById('findbar'),
  260. toggleButton: document.getElementById('viewFind'),
  261. findField: document.getElementById('findInput'),
  262. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  263. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  264. entireWordCheckbox: document.getElementById('findEntireWord'),
  265. findMsg: document.getElementById('findMsg'),
  266. findResultsCount: document.getElementById('findResultsCount'),
  267. findPreviousButton: document.getElementById('findPrevious'),
  268. findNextButton: document.getElementById('findNext')
  269. },
  270. passwordOverlay: {
  271. overlayName: 'passwordOverlay',
  272. container: document.getElementById('passwordOverlay'),
  273. label: document.getElementById('passwordText'),
  274. input: document.getElementById('password'),
  275. submitButton: document.getElementById('passwordSubmit'),
  276. cancelButton: document.getElementById('passwordCancel')
  277. },
  278. documentProperties: {
  279. overlayName: 'documentPropertiesOverlay',
  280. container: document.getElementById('documentPropertiesOverlay'),
  281. closeButton: document.getElementById('documentPropertiesClose'),
  282. fields: {
  283. 'fileName': document.getElementById('fileNameField'),
  284. 'fileSize': document.getElementById('fileSizeField'),
  285. 'title': document.getElementById('titleField'),
  286. 'author': document.getElementById('authorField'),
  287. 'subject': document.getElementById('subjectField'),
  288. 'keywords': document.getElementById('keywordsField'),
  289. 'creationDate': document.getElementById('creationDateField'),
  290. 'modificationDate': document.getElementById('modificationDateField'),
  291. 'creator': document.getElementById('creatorField'),
  292. 'producer': document.getElementById('producerField'),
  293. 'version': document.getElementById('versionField'),
  294. 'pageCount': document.getElementById('pageCountField'),
  295. 'pageSize': document.getElementById('pageSizeField'),
  296. 'linearized': document.getElementById('linearizedField')
  297. }
  298. },
  299. errorWrapper: {
  300. container: document.getElementById('errorWrapper'),
  301. errorMessage: document.getElementById('errorMessage'),
  302. closeButton: document.getElementById('errorClose'),
  303. errorMoreInfo: document.getElementById('errorMoreInfo'),
  304. moreInfoButton: document.getElementById('errorShowMore'),
  305. lessInfoButton: document.getElementById('errorShowLess')
  306. },
  307. printContainer: document.getElementById('printContainer'),
  308. openFileInputName: 'fileInput',
  309. debuggerScriptPath: './debugger.js'
  310. };
  311. }
  312. function webViewerLoad() {
  313. var config = getViewerConfiguration();
  314. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  315. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  316. var event = document.createEvent('CustomEvent');
  317. event.initCustomEvent('webviewerloaded', true, true, {});
  318. document.dispatchEvent(event);
  319. pdfjsWebApp.PDFViewerApplication.run(config);
  320. }
  321. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  322. webViewerLoad();
  323. } else {
  324. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  325. }
  326. /***/
  327. }),
  328. /* 1 */
  329. /***/
  330. (function(module, exports, __webpack_require__) {
  331. "use strict";
  332. Object.defineProperty(exports, "__esModule", {
  333. value: true
  334. });
  335. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication =
  336. void 0;
  337. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  338. var _ui_utils = __webpack_require__(5);
  339. var _app_options = __webpack_require__(6);
  340. var _pdfjsLib = __webpack_require__(7);
  341. var _pdf_cursor_tools = __webpack_require__(9);
  342. var _pdf_rendering_queue = __webpack_require__(11);
  343. var _pdf_sidebar = __webpack_require__(12);
  344. var _overlay_manager = __webpack_require__(13);
  345. var _password_prompt = __webpack_require__(14);
  346. var _pdf_attachment_viewer = __webpack_require__(15);
  347. var _pdf_document_properties = __webpack_require__(16);
  348. var _pdf_find_bar = __webpack_require__(17);
  349. var _pdf_find_controller = __webpack_require__(18);
  350. var _pdf_history = __webpack_require__(20);
  351. var _pdf_link_service = __webpack_require__(21);
  352. var _pdf_outline_viewer = __webpack_require__(22);
  353. var _pdf_presentation_mode = __webpack_require__(23);
  354. var _pdf_sidebar_resizer = __webpack_require__(24);
  355. var _pdf_thumbnail_viewer = __webpack_require__(25);
  356. var _pdf_viewer = __webpack_require__(27);
  357. var _secondary_toolbar = __webpack_require__(32);
  358. var _toolbar = __webpack_require__(34);
  359. var _view_history = __webpack_require__(35);
  360. function _interopRequireDefault(obj) {
  361. return obj && obj.__esModule ? obj : {
  362. "default": obj
  363. };
  364. }
  365. function _slicedToArray(arr, i) {
  366. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  367. }
  368. function _nonIterableRest() {
  369. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  370. }
  371. function _iterableToArrayLimit(arr, i) {
  372. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  373. "[object Arguments]")) {
  374. return;
  375. }
  376. var _arr = [];
  377. var _n = true;
  378. var _d = false;
  379. var _e = undefined;
  380. try {
  381. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  382. _arr.push(_s.value);
  383. if (i && _arr.length === i) break;
  384. }
  385. } catch (err) {
  386. _d = true;
  387. _e = err;
  388. } finally {
  389. try {
  390. if (!_n && _i["return"] != null) _i["return"]();
  391. } finally {
  392. if (_d) throw _e;
  393. }
  394. }
  395. return _arr;
  396. }
  397. function _arrayWithHoles(arr) {
  398. if (Array.isArray(arr)) return arr;
  399. }
  400. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  401. try {
  402. var info = gen[key](arg);
  403. var value = info.value;
  404. } catch (error) {
  405. reject(error);
  406. return;
  407. }
  408. if (info.done) {
  409. resolve(value);
  410. } else {
  411. Promise.resolve(value).then(_next, _throw);
  412. }
  413. }
  414. function _asyncToGenerator(fn) {
  415. return function() {
  416. var self = this,
  417. args = arguments;
  418. return new Promise(function(resolve, reject) {
  419. var gen = fn.apply(self, args);
  420. function _next(value) {
  421. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  422. }
  423. function _throw(err) {
  424. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  425. }
  426. _next(undefined);
  427. });
  428. };
  429. }
  430. var DEFAULT_SCALE_DELTA = 1.1;
  431. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  432. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  433. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  434. var ViewOnLoad = {
  435. UNKNOWN: -1,
  436. PREVIOUS: 0,
  437. INITIAL: 1
  438. };
  439. var DefaultExternalServices = {
  440. updateFindControlState: function updateFindControlState(data) {},
  441. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  442. initPassiveLoading: function initPassiveLoading(callbacks) {},
  443. fallback: function fallback(data, callback) {},
  444. reportTelemetry: function reportTelemetry(data) {},
  445. createDownloadManager: function createDownloadManager(options) {
  446. throw new Error('Not implemented: createDownloadManager');
  447. },
  448. createPreferences: function createPreferences() {
  449. throw new Error('Not implemented: createPreferences');
  450. },
  451. createL10n: function createL10n(options) {
  452. throw new Error('Not implemented: createL10n');
  453. },
  454. supportsIntegratedFind: false,
  455. supportsDocumentFonts: true,
  456. supportsDocumentColors: true,
  457. supportedMouseWheelZoomModifierKeys: {
  458. ctrlKey: true,
  459. metaKey: true
  460. }
  461. };
  462. exports.DefaultExternalServices = DefaultExternalServices;
  463. var PDFViewerApplication = {
  464. initialBookmark: document.location.hash.substring(1),
  465. initialized: false,
  466. fellback: false,
  467. appConfig: null,
  468. pdfDocument: null,
  469. pdfLoadingTask: null,
  470. printService: null,
  471. pdfViewer: null,
  472. pdfThumbnailViewer: null,
  473. pdfRenderingQueue: null,
  474. pdfPresentationMode: null,
  475. pdfDocumentProperties: null,
  476. pdfLinkService: null,
  477. pdfHistory: null,
  478. pdfSidebar: null,
  479. pdfSidebarResizer: null,
  480. pdfOutlineViewer: null,
  481. pdfAttachmentViewer: null,
  482. pdfCursorTools: null,
  483. store: null,
  484. downloadManager: null,
  485. overlayManager: null,
  486. preferences: null,
  487. toolbar: null,
  488. secondaryToolbar: null,
  489. eventBus: null,
  490. l10n: null,
  491. isInitialViewSet: false,
  492. downloadComplete: false,
  493. isViewerEmbedded: window.parent !== window,
  494. url: '',
  495. baseUrl: '',
  496. externalServices: DefaultExternalServices,
  497. _boundEvents: {},
  498. contentDispositionFilename: null,
  499. initialize: function() {
  500. var _initialize = _asyncToGenerator(
  501. /*#__PURE__*/
  502. _regenerator["default"].mark(function _callee(appConfig) {
  503. var _this = this;
  504. var appContainer;
  505. return _regenerator["default"].wrap(function _callee$(_context) {
  506. while (1) {
  507. switch (_context.prev = _context.next) {
  508. case 0:
  509. this.preferences = this.externalServices
  510. .createPreferences();
  511. this.appConfig = appConfig;
  512. _context.next = 4;
  513. return this._readPreferences();
  514. case 4:
  515. _context.next = 6;
  516. return this._parseHashParameters();
  517. case 6:
  518. _context.next = 8;
  519. return this._initializeL10n();
  520. case 8:
  521. if (this.isViewerEmbedded && _app_options
  522. .AppOptions.get('externalLinkTarget') ===
  523. _pdfjsLib.LinkTarget.NONE) {
  524. _app_options.AppOptions.set(
  525. 'externalLinkTarget', _pdfjsLib
  526. .LinkTarget.TOP);
  527. }
  528. _context.next = 11;
  529. return this._initializeViewerComponents();
  530. case 11:
  531. this.bindEvents();
  532. this.bindWindowEvents();
  533. appContainer = appConfig.appContainer ||
  534. document.documentElement;
  535. this.l10n.translate(appContainer).then(
  536. function() {
  537. _this.eventBus.dispatch(
  538. 'localized', {
  539. source: _this
  540. });
  541. });
  542. this.initialized = true;
  543. case 16:
  544. case "end":
  545. return _context.stop();
  546. }
  547. }
  548. }, _callee, this);
  549. }));
  550. function initialize(_x) {
  551. return _initialize.apply(this, arguments);
  552. }
  553. return initialize;
  554. }(),
  555. _readPreferences: function() {
  556. var _readPreferences2 = _asyncToGenerator(
  557. /*#__PURE__*/
  558. _regenerator["default"].mark(function _callee2() {
  559. var prefs, name;
  560. return _regenerator["default"].wrap(function _callee2$(_context2) {
  561. while (1) {
  562. switch (_context2.prev = _context2.next) {
  563. case 0:
  564. if (!(_app_options.AppOptions.get(
  565. 'disablePreferences') === true)) {
  566. _context2.next = 2;
  567. break;
  568. }
  569. return _context2.abrupt("return");
  570. case 2:
  571. _context2.prev = 2;
  572. _context2.next = 5;
  573. return this.preferences.getAll();
  574. case 5:
  575. prefs = _context2.sent;
  576. for (name in prefs) {
  577. _app_options.AppOptions.set(name, prefs[
  578. name]);
  579. }
  580. _context2.next = 12;
  581. break;
  582. case 9:
  583. _context2.prev = 9;
  584. _context2.t0 = _context2["catch"](2);
  585. console.error("_readPreferences: \"".concat(
  586. _context2.t0.message, "\"."));
  587. case 12:
  588. case "end":
  589. return _context2.stop();
  590. }
  591. }
  592. }, _callee2, this, [
  593. [2, 9]
  594. ]);
  595. }));
  596. function _readPreferences() {
  597. return _readPreferences2.apply(this, arguments);
  598. }
  599. return _readPreferences;
  600. }(),
  601. _parseHashParameters: function() {
  602. var _parseHashParameters2 = _asyncToGenerator(
  603. /*#__PURE__*/
  604. _regenerator["default"].mark(function _callee3() {
  605. var waitOn, hash, hashParams, viewer, enabled;
  606. return _regenerator["default"].wrap(function _callee3$(_context3) {
  607. while (1) {
  608. switch (_context3.prev = _context3.next) {
  609. case 0:
  610. if (_app_options.AppOptions.get(
  611. 'pdfBugEnabled')) {
  612. _context3.next = 2;
  613. break;
  614. }
  615. return _context3.abrupt("return", undefined);
  616. case 2:
  617. waitOn = [];
  618. hash = document.location.hash.substring(1);
  619. hashParams = (0, _ui_utils.parseQueryString)(
  620. hash);
  621. if ('disableworker' in hashParams && hashParams[
  622. 'disableworker'] === 'true') {
  623. waitOn.push(loadFakeWorker());
  624. }
  625. if ('disablerange' in hashParams) {
  626. _app_options.AppOptions.set('disableRange',
  627. hashParams['disablerange'] ===
  628. 'true');
  629. }
  630. if ('disablestream' in hashParams) {
  631. _app_options.AppOptions.set('disableStream',
  632. hashParams['disablestream'] ===
  633. 'true');
  634. }
  635. if ('disableautofetch' in hashParams) {
  636. _app_options.AppOptions.set(
  637. 'disableAutoFetch', hashParams[
  638. 'disableautofetch'] === 'true');
  639. }
  640. if ('disablefontface' in hashParams) {
  641. _app_options.AppOptions.set(
  642. 'disableFontFace', hashParams[
  643. 'disablefontface'] === 'true');
  644. }
  645. if ('disablehistory' in hashParams) {
  646. _app_options.AppOptions.set(
  647. 'disableHistory', hashParams[
  648. 'disablehistory'] === 'true');
  649. }
  650. if ('webgl' in hashParams) {
  651. _app_options.AppOptions.set('enableWebGL',
  652. hashParams['webgl'] === 'true');
  653. }
  654. if ('useonlycsszoom' in hashParams) {
  655. _app_options.AppOptions.set(
  656. 'useOnlyCssZoom', hashParams[
  657. 'useonlycsszoom'] === 'true');
  658. }
  659. if ('verbosity' in hashParams) {
  660. _app_options.AppOptions.set('verbosity',
  661. hashParams['verbosity'] | 0);
  662. }
  663. if (!('textlayer' in hashParams)) {
  664. _context3.next = 23;
  665. break;
  666. }
  667. _context3.t0 = hashParams['textlayer'];
  668. _context3.next = _context3.t0 === 'off' ? 18 :
  669. _context3.t0 === 'visible' ? 20 : _context3
  670. .t0 === 'shadow' ? 20 : _context3.t0 ===
  671. 'hover' ? 20 : 23;
  672. break;
  673. case 18:
  674. _app_options.AppOptions.set('textLayerMode',
  675. _ui_utils.TextLayerMode.DISABLE);
  676. return _context3.abrupt("break", 23);
  677. case 20:
  678. viewer = this.appConfig.viewerContainer;
  679. viewer.classList.add('textLayer-' + hashParams[
  680. 'textlayer']);
  681. return _context3.abrupt("break", 23);
  682. case 23:
  683. if ('pdfbug' in hashParams) {
  684. _app_options.AppOptions.set('pdfBug', true);
  685. enabled = hashParams['pdfbug'].split(',');
  686. waitOn.push(loadAndEnablePDFBug(enabled));
  687. }
  688. if ('locale' in hashParams) {
  689. _app_options.AppOptions.set('locale',
  690. hashParams['locale']);
  691. }
  692. return _context3.abrupt("return", Promise.all(
  693. waitOn)["catch"](function(reason) {
  694. console.error(
  695. "_parseHashParameters: \""
  696. .concat(reason.message,
  697. "\"."));
  698. }));
  699. case 26:
  700. case "end":
  701. return _context3.stop();
  702. }
  703. }
  704. }, _callee3, this);
  705. }));
  706. function _parseHashParameters() {
  707. return _parseHashParameters2.apply(this, arguments);
  708. }
  709. return _parseHashParameters;
  710. }(),
  711. _initializeL10n: function() {
  712. var _initializeL10n2 = _asyncToGenerator(
  713. /*#__PURE__*/
  714. _regenerator["default"].mark(function _callee4() {
  715. var dir;
  716. return _regenerator["default"].wrap(function _callee4$(_context4) {
  717. while (1) {
  718. switch (_context4.prev = _context4.next) {
  719. case 0:
  720. this.l10n = this.externalServices.createL10n({
  721. locale: _app_options.AppOptions.get(
  722. 'locale')
  723. });
  724. _context4.next = 3;
  725. return this.l10n.getDirection();
  726. case 3:
  727. dir = _context4.sent;
  728. document.getElementsByTagName('html')[0].dir =
  729. dir;
  730. case 5:
  731. case "end":
  732. return _context4.stop();
  733. }
  734. }
  735. }, _callee4, this);
  736. }));
  737. function _initializeL10n() {
  738. return _initializeL10n2.apply(this, arguments);
  739. }
  740. return _initializeL10n;
  741. }(),
  742. _initializeViewerComponents: function() {
  743. var _initializeViewerComponents2 = _asyncToGenerator(
  744. /*#__PURE__*/
  745. _regenerator["default"].mark(function _callee5() {
  746. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService,
  747. downloadManager, findController, container, viewer;
  748. return _regenerator["default"].wrap(function _callee5$(_context5) {
  749. while (1) {
  750. switch (_context5.prev = _context5.next) {
  751. case 0:
  752. appConfig = this.appConfig;
  753. this.overlayManager = new _overlay_manager
  754. .OverlayManager();
  755. eventBus = appConfig.eventBus || (0, _ui_utils
  756. .getGlobalEventBus)(_app_options
  757. .AppOptions.get('eventBusDispatchToDOM')
  758. );
  759. this.eventBus = eventBus;
  760. pdfRenderingQueue = new _pdf_rendering_queue
  761. .PDFRenderingQueue();
  762. pdfRenderingQueue.onIdle = this.cleanup.bind(
  763. this);
  764. this.pdfRenderingQueue = pdfRenderingQueue;
  765. pdfLinkService = new _pdf_link_service
  766. .PDFLinkService({
  767. eventBus: eventBus,
  768. externalLinkTarget: _app_options
  769. .AppOptions.get(
  770. 'externalLinkTarget'),
  771. externalLinkRel: _app_options
  772. .AppOptions.get(
  773. 'externalLinkRel')
  774. });
  775. this.pdfLinkService = pdfLinkService;
  776. downloadManager = this.externalServices
  777. .createDownloadManager({
  778. disableCreateObjectURL: _app_options
  779. .AppOptions.get(
  780. 'disableCreateObjectURL')
  781. });
  782. this.downloadManager = downloadManager;
  783. findController = new _pdf_find_controller
  784. .PDFFindController({
  785. linkService: pdfLinkService,
  786. eventBus: eventBus
  787. });
  788. this.findController = findController;
  789. container = appConfig.mainContainer;
  790. viewer = appConfig.viewerContainer;
  791. this.pdfViewer = new _pdf_viewer.PDFViewer({
  792. container: container,
  793. viewer: viewer,
  794. eventBus: eventBus,
  795. renderingQueue: pdfRenderingQueue,
  796. linkService: pdfLinkService,
  797. downloadManager: downloadManager,
  798. findController: findController,
  799. renderer: _app_options.AppOptions
  800. .get('renderer'),
  801. enableWebGL: _app_options.AppOptions
  802. .get('enableWebGL'),
  803. l10n: this.l10n,
  804. textLayerMode: _app_options
  805. .AppOptions.get(
  806. 'textLayerMode'),
  807. imageResourcesPath: _app_options
  808. .AppOptions.get(
  809. 'imageResourcesPath'),
  810. renderInteractiveForms: _app_options
  811. .AppOptions.get(
  812. 'renderInteractiveForms'),
  813. enablePrintAutoRotate: _app_options
  814. .AppOptions.get(
  815. 'enablePrintAutoRotate'),
  816. useOnlyCssZoom: _app_options
  817. .AppOptions.get(
  818. 'useOnlyCssZoom'),
  819. maxCanvasPixels: _app_options
  820. .AppOptions.get(
  821. 'maxCanvasPixels')
  822. });
  823. pdfRenderingQueue.setViewer(this.pdfViewer);
  824. pdfLinkService.setViewer(this.pdfViewer);
  825. this.pdfThumbnailViewer =
  826. new _pdf_thumbnail_viewer
  827. .PDFThumbnailViewer({
  828. container: appConfig.sidebar
  829. .thumbnailView,
  830. renderingQueue: pdfRenderingQueue,
  831. linkService: pdfLinkService,
  832. l10n: this.l10n
  833. });
  834. pdfRenderingQueue.setThumbnailViewer(this
  835. .pdfThumbnailViewer);
  836. this.pdfHistory = new _pdf_history.PDFHistory({
  837. linkService: pdfLinkService,
  838. eventBus: eventBus
  839. });
  840. pdfLinkService.setHistory(this.pdfHistory);
  841. if (!this.supportsIntegratedFind) {
  842. this.findBar = new _pdf_find_bar.PDFFindBar(
  843. appConfig.findBar, eventBus, this
  844. .l10n);
  845. }
  846. this.pdfDocumentProperties =
  847. new _pdf_document_properties
  848. .PDFDocumentProperties(appConfig
  849. .documentProperties, this
  850. .overlayManager, eventBus, this.l10n);
  851. this.pdfCursorTools = new _pdf_cursor_tools
  852. .PDFCursorTools({
  853. container: container,
  854. eventBus: eventBus,
  855. cursorToolOnLoad: _app_options
  856. .AppOptions.get(
  857. 'cursorToolOnLoad')
  858. });
  859. this.toolbar = new _toolbar.Toolbar(appConfig
  860. .toolbar, eventBus, this.l10n);
  861. this.secondaryToolbar = new _secondary_toolbar
  862. .SecondaryToolbar(appConfig
  863. .secondaryToolbar, container, eventBus);
  864. if (this.supportsFullscreen) {
  865. this.pdfPresentationMode =
  866. new _pdf_presentation_mode
  867. .PDFPresentationMode({
  868. container: container,
  869. viewer: viewer,
  870. pdfViewer: this.pdfViewer,
  871. eventBus: eventBus,
  872. contextMenuItems: appConfig
  873. .fullscreen
  874. });
  875. }
  876. this.passwordPrompt = new _password_prompt
  877. .PasswordPrompt(appConfig.passwordOverlay,
  878. this.overlayManager, this.l10n);
  879. this.pdfOutlineViewer = new _pdf_outline_viewer
  880. .PDFOutlineViewer({
  881. container: appConfig.sidebar
  882. .outlineView,
  883. eventBus: eventBus,
  884. linkService: pdfLinkService
  885. });
  886. this.pdfAttachmentViewer =
  887. new _pdf_attachment_viewer
  888. .PDFAttachmentViewer({
  889. container: appConfig.sidebar
  890. .attachmentsView,
  891. eventBus: eventBus,
  892. downloadManager: downloadManager
  893. });
  894. this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  895. elements: appConfig.sidebar,
  896. pdfViewer: this.pdfViewer,
  897. pdfThumbnailViewer: this
  898. .pdfThumbnailViewer,
  899. eventBus: eventBus,
  900. l10n: this.l10n
  901. });
  902. this.pdfSidebar.onToggled = this.forceRendering
  903. .bind(this);
  904. this.pdfSidebarResizer =
  905. new _pdf_sidebar_resizer.PDFSidebarResizer(
  906. appConfig.sidebarResizer, eventBus, this
  907. .l10n);
  908. case 34:
  909. case "end":
  910. return _context5.stop();
  911. }
  912. }
  913. }, _callee5, this);
  914. }));
  915. function _initializeViewerComponents() {
  916. return _initializeViewerComponents2.apply(this, arguments);
  917. }
  918. return _initializeViewerComponents;
  919. }(),
  920. run: function run(config) {
  921. this.initialize(config).then(webViewerInitialized);
  922. },
  923. zoomIn: function zoomIn(ticks) {
  924. if (this.pdfViewer.isInPresentationMode) {
  925. return;
  926. }
  927. var newScale = this.pdfViewer.currentScale;
  928. do {
  929. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  930. newScale = Math.ceil(newScale * 10) / 10;
  931. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  932. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  933. this.pdfViewer.currentScaleValue = newScale;
  934. },
  935. zoomOut: function zoomOut(ticks) {
  936. if (this.pdfViewer.isInPresentationMode) {
  937. return;
  938. }
  939. var newScale = this.pdfViewer.currentScale;
  940. do {
  941. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  942. newScale = Math.floor(newScale * 10) / 10;
  943. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  944. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  945. this.pdfViewer.currentScaleValue = newScale;
  946. },
  947. zoomReset: function zoomReset() {
  948. if (this.pdfViewer.isInPresentationMode) {
  949. return;
  950. }
  951. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  952. },
  953. get pagesCount() {
  954. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  955. },
  956. set page(val) {
  957. this.pdfViewer.currentPageNumber = val;
  958. },
  959. get page() {
  960. return this.pdfViewer.currentPageNumber;
  961. },
  962. get printing() {
  963. return !!this.printService;
  964. },
  965. get supportsPrinting() {
  966. return PDFPrintServiceFactory.instance.supportsPrinting;
  967. },
  968. get supportsFullscreen() {
  969. var support;
  970. var doc = document.documentElement;
  971. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc
  972. .webkitRequestFullScreen || doc.msRequestFullscreen);
  973. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false ||
  974. document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false
  975. ) {
  976. support = false;
  977. }
  978. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  979. },
  980. get supportsIntegratedFind() {
  981. return this.externalServices.supportsIntegratedFind;
  982. },
  983. get supportsDocumentFonts() {
  984. return this.externalServices.supportsDocumentFonts;
  985. },
  986. get supportsDocumentColors() {
  987. return this.externalServices.supportsDocumentColors;
  988. },
  989. get loadingBar() {
  990. var bar = new _ui_utils.ProgressBar('#loadingBar');
  991. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  992. },
  993. get supportedMouseWheelZoomModifierKeys() {
  994. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  995. },
  996. initPassiveLoading: function initPassiveLoading() {
  997. throw new Error('Not implemented: initPassiveLoading');
  998. },
  999. setTitleUsingUrl: function setTitleUsingUrl() {
  1000. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  1001. this.url = url;
  1002. this.baseUrl = url.split('#')[0];
  1003. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  1004. if (!title) {
  1005. try {
  1006. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  1007. } catch (ex) {
  1008. title = url;
  1009. }
  1010. }
  1011. this.setTitle(title);
  1012. },
  1013. setTitle: function setTitle(title) {
  1014. if (this.isViewerEmbedded) {
  1015. return;
  1016. }
  1017. document.title = title;
  1018. },
  1019. close: function() {
  1020. var _close = _asyncToGenerator(
  1021. /*#__PURE__*/
  1022. _regenerator["default"].mark(function _callee6() {
  1023. var errorWrapper, promise;
  1024. return _regenerator["default"].wrap(function _callee6$(_context6) {
  1025. while (1) {
  1026. switch (_context6.prev = _context6.next) {
  1027. case 0:
  1028. errorWrapper = this.appConfig.errorWrapper
  1029. .container;
  1030. errorWrapper.setAttribute('hidden', 'true');
  1031. if (this.pdfLoadingTask) {
  1032. _context6.next = 4;
  1033. break;
  1034. }
  1035. return _context6.abrupt("return", undefined);
  1036. case 4:
  1037. promise = this.pdfLoadingTask.destroy();
  1038. this.pdfLoadingTask = null;
  1039. if (this.pdfDocument) {
  1040. this.pdfDocument = null;
  1041. this.pdfThumbnailViewer.setDocument(null);
  1042. this.pdfViewer.setDocument(null);
  1043. this.pdfLinkService.setDocument(null);
  1044. this.pdfDocumentProperties.setDocument(
  1045. null);
  1046. }
  1047. this.store = null;
  1048. this.isInitialViewSet = false;
  1049. this.downloadComplete = false;
  1050. this.url = '';
  1051. this.baseUrl = '';
  1052. this.contentDispositionFilename = null;
  1053. this.pdfSidebar.reset();
  1054. this.pdfOutlineViewer.reset();
  1055. this.pdfAttachmentViewer.reset();
  1056. if (this.findBar) {
  1057. this.findBar.reset();
  1058. }
  1059. this.toolbar.reset();
  1060. this.secondaryToolbar.reset();
  1061. if (typeof PDFBug !== 'undefined') {
  1062. PDFBug.cleanup();
  1063. }
  1064. return _context6.abrupt("return", promise);
  1065. case 21:
  1066. case "end":
  1067. return _context6.stop();
  1068. }
  1069. }
  1070. }, _callee6, this);
  1071. }));
  1072. function close() {
  1073. return _close.apply(this, arguments);
  1074. }
  1075. return close;
  1076. }(),
  1077. open: function() {
  1078. var _open = _asyncToGenerator(
  1079. /*#__PURE__*/
  1080. _regenerator["default"].mark(function _callee7(file, args) {
  1081. var _this2 = this;
  1082. var workerParameters, key, parameters, apiParameters, _key, value,
  1083. _key2, _value, loadingTask;
  1084. return _regenerator["default"].wrap(function _callee7$(_context7) {
  1085. while (1) {
  1086. switch (_context7.prev = _context7.next) {
  1087. case 0:
  1088. if (!this.pdfLoadingTask) {
  1089. _context7.next = 3;
  1090. break;
  1091. }
  1092. _context7.next = 3;
  1093. return this.close();
  1094. case 3:
  1095. workerParameters = _app_options.AppOptions
  1096. .getAll(_app_options.OptionKind.WORKER);
  1097. for (key in workerParameters) {
  1098. _pdfjsLib.GlobalWorkerOptions[key] =
  1099. workerParameters[key];
  1100. }
  1101. parameters = Object.create(null);
  1102. if (typeof file === 'string') {
  1103. this.setTitleUsingUrl(file);
  1104. parameters.url = file;
  1105. } else if (file && 'byteLength' in file) {
  1106. parameters.data = file;
  1107. } else if (file.url && file.originalUrl) {
  1108. this.setTitleUsingUrl(file.originalUrl);
  1109. parameters.url = file.url;
  1110. }
  1111. apiParameters = _app_options.AppOptions.getAll(
  1112. _app_options.OptionKind.API);
  1113. for (_key in apiParameters) {
  1114. value = apiParameters[_key];
  1115. if (_key === 'docBaseUrl' && !value) {}
  1116. parameters[_key] = value;
  1117. }
  1118. if (args) {
  1119. for (_key2 in args) {
  1120. _value = args[_key2];
  1121. if (_key2 === 'length') {
  1122. this.pdfDocumentProperties
  1123. .setFileSize(_value);
  1124. }
  1125. parameters[_key2] = _value;
  1126. }
  1127. }
  1128. loadingTask = (0, _pdfjsLib.getDocument)(
  1129. parameters);
  1130. this.pdfLoadingTask = loadingTask;
  1131. loadingTask.onPassword = function(
  1132. updateCallback, reason) {
  1133. _this2.pdfLinkService
  1134. .externalLinkEnabled = false;
  1135. _this2.passwordPrompt.setUpdateCallback(
  1136. updateCallback, reason);
  1137. _this2.passwordPrompt.open();
  1138. };
  1139. loadingTask.onProgress = function(_ref) {
  1140. var loaded = _ref.loaded,
  1141. total = _ref.total;
  1142. _this2.progress(loaded / total);
  1143. };
  1144. loadingTask.onUnsupportedFeature = this.fallback
  1145. .bind(this);
  1146. return _context7.abrupt("return", loadingTask
  1147. .promise.then(function(pdfDocument) {
  1148. _this2.load(pdfDocument);
  1149. }, function(exception) {
  1150. if (loadingTask !== _this2
  1151. .pdfLoadingTask) {
  1152. return undefined;
  1153. }
  1154. var message = exception &&
  1155. exception.message;
  1156. var loadingErrorMessage;
  1157. if (exception instanceof _pdfjsLib
  1158. .InvalidPDFException) {
  1159. loadingErrorMessage = _this2
  1160. .l10n.get(
  1161. 'invalid_file_error',
  1162. null,
  1163. 'Invalid or corrupted PDF file.'
  1164. );
  1165. } else if (
  1166. exception instanceof _pdfjsLib
  1167. .MissingPDFException) {
  1168. loadingErrorMessage = _this2
  1169. .l10n.get(
  1170. 'missing_file_error',
  1171. null,
  1172. 'PDF 源文件已丢失'
  1173. );
  1174. } else if (
  1175. exception instanceof _pdfjsLib
  1176. .UnexpectedResponseException
  1177. ) {
  1178. loadingErrorMessage = _this2
  1179. .l10n.get(
  1180. 'unexpected_response_error',
  1181. null,
  1182. 'Unexpected server response.'
  1183. );
  1184. } else {
  1185. loadingErrorMessage = _this2
  1186. .l10n.get(
  1187. '加载错误',
  1188. null,
  1189. '加载PDF文件时发生错误,请检查源文件.'
  1190. );
  1191. }
  1192. return loadingErrorMessage.then(
  1193. function(msg) {
  1194. _this2.error(msg, {
  1195. message: message
  1196. });
  1197. throw new Error(
  1198. msg);
  1199. });
  1200. }));
  1201. case 16:
  1202. case "end":
  1203. return _context7.stop();
  1204. }
  1205. }
  1206. }, _callee7, this);
  1207. }));
  1208. function open(_x2, _x3) {
  1209. return _open.apply(this, arguments);
  1210. }
  1211. return open;
  1212. }(),
  1213. download: function download() {
  1214. var _this3 = this;
  1215. function downloadByUrl() {
  1216. downloadManager.downloadUrl(url, filename);
  1217. }
  1218. var url = this.baseUrl;
  1219. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(
  1220. this.url);
  1221. var downloadManager = this.downloadManager;
  1222. downloadManager.onerror = function(err) {
  1223. _this3.error("PDF failed to download: ".concat(err));
  1224. };
  1225. if (!this.pdfDocument || !this.downloadComplete) {
  1226. downloadByUrl();
  1227. return;
  1228. }
  1229. this.pdfDocument.getData().then(function(data) {
  1230. var blob = new Blob([data], {
  1231. type: 'application/pdf'
  1232. });
  1233. downloadManager.download(blob, url, filename);
  1234. })["catch"](downloadByUrl);
  1235. },
  1236. fallback: function fallback(featureId) {},
  1237. error: function error(message, moreInfo) {
  1238. var moreInfoText = [this.l10n.get('error_version_info', {
  1239. version: _pdfjsLib.version || '?',
  1240. build: _pdfjsLib.build || '?'
  1241. }, 'PDF.js v{{version}} (build: {{build}})')];
  1242. if (moreInfo) {
  1243. moreInfoText.push(this.l10n.get('error_message', {
  1244. message: moreInfo.message
  1245. }, 'Message: {{message}}'));
  1246. if (moreInfo.stack) {
  1247. moreInfoText.push(this.l10n.get('error_stack', {
  1248. stack: moreInfo.stack
  1249. }, 'Stack: {{stack}}'));
  1250. } else {
  1251. if (moreInfo.filename) {
  1252. moreInfoText.push(this.l10n.get('error_file', {
  1253. file: moreInfo.filename
  1254. }, 'File: {{file}}'));
  1255. }
  1256. if (moreInfo.lineNumber) {
  1257. moreInfoText.push(this.l10n.get('error_line', {
  1258. line: moreInfo.lineNumber
  1259. }, 'Line: {{line}}'));
  1260. }
  1261. }
  1262. }
  1263. var errorWrapperConfig = this.appConfig.errorWrapper;
  1264. var errorWrapper = errorWrapperConfig.container;
  1265. errorWrapper.removeAttribute('hidden');
  1266. var errorMessage = errorWrapperConfig.errorMessage;
  1267. errorMessage.textContent = message;
  1268. var closeButton = errorWrapperConfig.closeButton;
  1269. closeButton.onclick = function() {
  1270. errorWrapper.setAttribute('hidden', 'true');
  1271. };
  1272. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1273. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1274. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1275. moreInfoButton.onclick = function() {
  1276. errorMoreInfo.removeAttribute('hidden');
  1277. moreInfoButton.setAttribute('hidden', 'true');
  1278. lessInfoButton.removeAttribute('hidden');
  1279. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  1280. };
  1281. lessInfoButton.onclick = function() {
  1282. errorMoreInfo.setAttribute('hidden', 'true');
  1283. moreInfoButton.removeAttribute('hidden');
  1284. lessInfoButton.setAttribute('hidden', 'true');
  1285. };
  1286. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1287. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1288. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1289. moreInfoButton.removeAttribute('hidden');
  1290. lessInfoButton.setAttribute('hidden', 'true');
  1291. Promise.all(moreInfoText).then(function(parts) {
  1292. errorMoreInfo.value = parts.join('\n');
  1293. });
  1294. },
  1295. progress: function progress(level) {
  1296. var _this4 = this;
  1297. if (this.downloadComplete) {
  1298. return;
  1299. }
  1300. var percent = Math.round(level * 100);
  1301. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1302. this.loadingBar.percent = percent;
  1303. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams[
  1304. 'disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  1305. if (disableAutoFetch && percent) {
  1306. if (this.disableAutoFetchLoadingBarTimeout) {
  1307. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1308. this.disableAutoFetchLoadingBarTimeout = null;
  1309. }
  1310. this.loadingBar.show();
  1311. this.disableAutoFetchLoadingBarTimeout = setTimeout(function() {
  1312. _this4.loadingBar.hide();
  1313. _this4.disableAutoFetchLoadingBarTimeout = null;
  1314. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1315. }
  1316. }
  1317. },
  1318. load: function load(pdfDocument) {
  1319. var _this5 = this;
  1320. this.pdfDocument = pdfDocument;
  1321. pdfDocument.getDownloadInfo().then(function() {
  1322. _this5.downloadComplete = true;
  1323. _this5.loadingBar.hide();
  1324. firstPagePromise.then(function() {
  1325. _this5.eventBus.dispatch('documentloaded', {
  1326. source: _this5
  1327. });
  1328. });
  1329. });
  1330. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function() {});
  1331. var pageModePromise = pdfDocument.getPageMode()["catch"](function() {});
  1332. var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](
  1333. function() {});
  1334. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1335. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1336. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1337. var baseDocumentUrl;
  1338. baseDocumentUrl = null;
  1339. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1340. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1341. var pdfViewer = this.pdfViewer;
  1342. pdfViewer.setDocument(pdfDocument);
  1343. var firstPagePromise = pdfViewer.firstPagePromise;
  1344. var pagesPromise = pdfViewer.pagesPromise;
  1345. var onePageRendered = pdfViewer.onePageRendered;
  1346. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1347. pdfThumbnailViewer.setDocument(pdfDocument);
  1348. firstPagePromise.then(function(pdfPage) {
  1349. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1350. var storePromise = store.getMultiple({
  1351. page: null,
  1352. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1353. scrollLeft: '0',
  1354. scrollTop: '0',
  1355. rotation: null,
  1356. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1357. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1358. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1359. })["catch"](function() {});
  1360. Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise,
  1361. pageModePromise, openActionDestPromise
  1362. ]).then(
  1363. /*#__PURE__*/
  1364. function() {
  1365. var _ref3 = _asyncToGenerator(
  1366. /*#__PURE__*/
  1367. _regenerator["default"].mark(function _callee8(_ref2) {
  1368. var _ref4, timeStamp, _ref4$, values,
  1369. pageLayout, pageMode, openActionDest,
  1370. viewOnLoad, initialBookmark, zoom, hash,
  1371. rotation, sidebarView, scrollMode,
  1372. spreadMode;
  1373. return _regenerator["default"].wrap(
  1374. function _callee8$(_context8) {
  1375. while (1) {
  1376. switch (_context8.prev =
  1377. _context8.next) {
  1378. case 0:
  1379. _ref4 = _slicedToArray(
  1380. _ref2, 5),
  1381. timeStamp = _ref4[
  1382. 0], _ref4$ =
  1383. _ref4[
  1384. 1], values =
  1385. _ref4$ === void 0 ?
  1386. {} : _ref4$,
  1387. pageLayout = _ref4[
  1388. 2], pageMode =
  1389. _ref4[3],
  1390. openActionDest =
  1391. _ref4[4];
  1392. viewOnLoad =
  1393. _app_options
  1394. .AppOptions.get(
  1395. 'viewOnLoad');
  1396. _this5
  1397. ._initializePdfHistory({
  1398. fingerprint: pdfDocument
  1399. .fingerprint,
  1400. viewOnLoad: viewOnLoad,
  1401. initialDest: openActionDest
  1402. });
  1403. initialBookmark = _this5
  1404. .initialBookmark;
  1405. zoom = _app_options
  1406. .AppOptions.get(
  1407. 'defaultZoomValue'
  1408. );
  1409. hash = zoom ? "zoom="
  1410. .concat(zoom) :
  1411. null;
  1412. rotation = null;
  1413. sidebarView =
  1414. _app_options
  1415. .AppOptions.get(
  1416. 'sidebarViewOnLoad'
  1417. );
  1418. scrollMode =
  1419. _app_options
  1420. .AppOptions.get(
  1421. 'scrollModeOnLoad'
  1422. );
  1423. spreadMode =
  1424. _app_options
  1425. .AppOptions.get(
  1426. 'spreadModeOnLoad'
  1427. );
  1428. if (values.page &&
  1429. viewOnLoad !==
  1430. ViewOnLoad.INITIAL
  1431. ) {
  1432. hash = "page="
  1433. .concat(values
  1434. .page,
  1435. "&zoom=")
  1436. .concat(zoom ||
  1437. values.zoom,
  1438. ",") + ""
  1439. .concat(values
  1440. .scrollLeft,
  1441. ",").concat(
  1442. values
  1443. .scrollTop);
  1444. rotation = parseInt(
  1445. values
  1446. .rotation,
  1447. 10);
  1448. if (sidebarView ===
  1449. _pdf_sidebar
  1450. .SidebarView
  1451. .UNKNOWN) {
  1452. sidebarView =
  1453. values
  1454. .sidebarView |
  1455. 0;
  1456. }
  1457. if (scrollMode ===
  1458. _ui_utils
  1459. .ScrollMode
  1460. .UNKNOWN) {
  1461. scrollMode =
  1462. values
  1463. .scrollMode |
  1464. 0;
  1465. }
  1466. if (spreadMode ===
  1467. _ui_utils
  1468. .SpreadMode
  1469. .UNKNOWN) {
  1470. spreadMode =
  1471. values
  1472. .spreadMode |
  1473. 0;
  1474. }
  1475. }
  1476. if (pageMode &&
  1477. sidebarView ===
  1478. _pdf_sidebar
  1479. .SidebarView.UNKNOWN
  1480. ) {
  1481. sidebarView =
  1482. apiPageModeToSidebarView(
  1483. pageMode);
  1484. }
  1485. if (pageLayout &&
  1486. spreadMode ===
  1487. _ui_utils.SpreadMode
  1488. .UNKNOWN) {
  1489. spreadMode =
  1490. apiPageLayoutToSpreadMode(
  1491. pageLayout);
  1492. }
  1493. _this5.setInitialView(
  1494. hash, {
  1495. rotation: rotation,
  1496. sidebarView: sidebarView,
  1497. scrollMode: scrollMode,
  1498. spreadMode: spreadMode
  1499. });
  1500. _this5.eventBus
  1501. .dispatch(
  1502. 'documentinit', {
  1503. source: _this5
  1504. });
  1505. if (!_this5
  1506. .isViewerEmbedded) {
  1507. pdfViewer.focus();
  1508. }
  1509. _context8.next = 18;
  1510. return Promise.race([
  1511. pagesPromise,
  1512. new Promise(
  1513. function(
  1514. resolve
  1515. ) {
  1516. setTimeout
  1517. (resolve,
  1518. FORCE_PAGES_LOADED_TIMEOUT
  1519. );
  1520. })
  1521. ]);
  1522. case 18:
  1523. if (!(!initialBookmark &&
  1524. !hash)) {
  1525. _context8.next = 20;
  1526. break;
  1527. }
  1528. return _context8.abrupt(
  1529. "return");
  1530. case 20:
  1531. if (!pdfViewer
  1532. .hasEqualPageSizes
  1533. ) {
  1534. _context8.next = 22;
  1535. break;
  1536. }
  1537. return _context8.abrupt(
  1538. "return");
  1539. case 22:
  1540. _this5.initialBookmark =
  1541. initialBookmark;
  1542. pdfViewer
  1543. .currentScaleValue =
  1544. pdfViewer
  1545. .currentScaleValue;
  1546. _this5.setInitialView(
  1547. hash);
  1548. case 25:
  1549. case "end":
  1550. return _context8.stop();
  1551. }
  1552. }
  1553. }, _callee8);
  1554. }));
  1555. return function(_x4) {
  1556. return _ref3.apply(this, arguments);
  1557. };
  1558. }())["catch"](function() {
  1559. _this5.setInitialView();
  1560. }).then(function() {
  1561. pdfViewer.update();
  1562. });
  1563. });
  1564. pdfDocument.getPageLabels().then(function(labels) {
  1565. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1566. return;
  1567. }
  1568. var i = 0,
  1569. numLabels = labels.length;
  1570. if (numLabels !== _this5.pagesCount) {
  1571. console.error('The number of Page Labels does not match ' +
  1572. 'the number of pages in the document.');
  1573. return;
  1574. }
  1575. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1576. i++;
  1577. }
  1578. if (i === numLabels) {
  1579. return;
  1580. }
  1581. pdfViewer.setPageLabels(labels);
  1582. pdfThumbnailViewer.setPageLabels(labels);
  1583. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1584. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  1585. .currentPageLabel);
  1586. });
  1587. pagesPromise.then(function() {
  1588. if (!_this5.supportsPrinting) {
  1589. return;
  1590. }
  1591. pdfDocument.getJavaScript().then(function(javaScript) {
  1592. if (!javaScript) {
  1593. return;
  1594. }
  1595. javaScript.some(function(js) {
  1596. if (!js) {
  1597. return false;
  1598. }
  1599. console.warn(
  1600. 'Warning: JavaScript is not supported');
  1601. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES
  1602. .javaScript);
  1603. return true;
  1604. });
  1605. var regex = /\bprint\s*\(/;
  1606. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1607. var js = javaScript[i];
  1608. if (js && regex.test(js)) {
  1609. setTimeout(function() {
  1610. window.print();
  1611. });
  1612. return;
  1613. }
  1614. }
  1615. });
  1616. });
  1617. onePageRendered.then(function() {
  1618. pdfDocument.getOutline().then(function(outline) {
  1619. _this5.pdfOutlineViewer.render({
  1620. outline: outline
  1621. });
  1622. });
  1623. pdfDocument.getAttachments().then(function(attachments) {
  1624. _this5.pdfAttachmentViewer.render({
  1625. attachments: attachments
  1626. });
  1627. });
  1628. });
  1629. pdfDocument.getMetadata().then(function(_ref5) {
  1630. var info = _ref5.info,
  1631. metadata = _ref5.metadata,
  1632. contentDispositionFilename = _ref5.contentDispositionFilename;
  1633. _this5.documentInfo = info;
  1634. _this5.metadata = metadata;
  1635. _this5.contentDispositionFilename = contentDispositionFilename;
  1636. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info
  1637. .PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (
  1638. info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib
  1639. .version || '-') + (_app_options.AppOptions.get('enableWebGL') ?
  1640. ' [WebGL]' : '') + ')');
  1641. var pdfTitle;
  1642. if (metadata && metadata.has('dc:title')) {
  1643. var title = metadata.get('dc:title');
  1644. if (title !== 'Untitled') {
  1645. pdfTitle = title;
  1646. }
  1647. }
  1648. if (!pdfTitle && info && info['Title']) {
  1649. pdfTitle = info['Title'];
  1650. }
  1651. if (pdfTitle) {
  1652. _this5.setTitle("".concat(pdfTitle, " - ").concat(
  1653. contentDispositionFilename || document.title));
  1654. } else if (contentDispositionFilename) {
  1655. _this5.setTitle(contentDispositionFilename);
  1656. }
  1657. if (info.IsAcroFormPresent) {
  1658. console.warn('Warning: AcroForm/XFA is not supported');
  1659. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1660. }
  1661. });
  1662. },
  1663. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1664. var fingerprint = _ref6.fingerprint,
  1665. viewOnLoad = _ref6.viewOnLoad,
  1666. _ref6$initialDest = _ref6.initialDest,
  1667. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1668. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1669. return;
  1670. }
  1671. this.pdfHistory.initialize({
  1672. fingerprint: fingerprint,
  1673. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1674. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1675. });
  1676. if (this.pdfHistory.initialBookmark) {
  1677. this.initialBookmark = this.pdfHistory.initialBookmark;
  1678. this.initialRotation = this.pdfHistory.initialRotation;
  1679. }
  1680. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1681. this.initialBookmark = JSON.stringify(initialDest);
  1682. this.pdfHistory.push({
  1683. explicitDest: initialDest,
  1684. pageNumber: null
  1685. });
  1686. }
  1687. },
  1688. setInitialView: function setInitialView(storedHash) {
  1689. //=========自定义加载到指定页面
  1690. var c_url = window.location.href;
  1691. //获取参数
  1692. if (c_url.indexOf("&") && c_url.indexOf("=")) {
  1693. undefined
  1694. var c_urlArray = {}
  1695. var c_val = c_url.split('?')[1];
  1696. var c_valArray = c_val.split('&');
  1697. for (let i = 0; i < c_valArray.length; i++) {
  1698. undefined
  1699. let c_key = c_valArray[i].split('=')[0];
  1700. let c_value = c_valArray[i].split('=')[1];
  1701. c_urlArray[c_key] = c_value;
  1702. }
  1703. //跳转至指定页码
  1704. if (c_urlArray['page']) {
  1705. undefined
  1706. document.getElementById('pageNumber').value = c_urlArray['page'] * 1;
  1707. this.pdfViewer.currentPageNumber = c_urlArray['page'] * 1;
  1708. console.log('this.pdfViewer.currentPageNumber==', this.pdfViewer
  1709. .currentPageNumber)
  1710. }
  1711. }
  1712. //=================
  1713. var _this6 = this;
  1714. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1715. rotation = _ref7.rotation,
  1716. sidebarView = _ref7.sidebarView,
  1717. scrollMode = _ref7.scrollMode,
  1718. spreadMode = _ref7.spreadMode;
  1719. var setRotation = function setRotation(angle) {
  1720. if ((0, _ui_utils.isValidRotation)(angle)) {
  1721. _this6.pdfViewer.pagesRotation = angle;
  1722. }
  1723. };
  1724. var setViewerModes = function setViewerModes(scroll, spread) {
  1725. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1726. _this6.pdfViewer.scrollMode = scroll;
  1727. }
  1728. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1729. _this6.pdfViewer.spreadMode = spread;
  1730. }
  1731. };
  1732. this.isInitialViewSet = true;
  1733. this.pdfSidebar.setInitialView(sidebarView);
  1734. setViewerModes(scrollMode, spreadMode);
  1735. if (this.initialBookmark) {
  1736. setRotation(this.initialRotation);
  1737. delete this.initialRotation;
  1738. this.pdfLinkService.setHash(this.initialBookmark);
  1739. this.initialBookmark = null;
  1740. } else if (storedHash) {
  1741. setRotation(rotation);
  1742. this.pdfLinkService.setHash(storedHash);
  1743. }
  1744. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer
  1745. .currentPageLabel);
  1746. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1747. if (!this.pdfViewer.currentScaleValue) {
  1748. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1749. }
  1750. },
  1751. cleanup: function cleanup() {
  1752. if (!this.pdfDocument) {
  1753. return;
  1754. }
  1755. this.pdfViewer.cleanup();
  1756. this.pdfThumbnailViewer.cleanup();
  1757. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1758. this.pdfDocument.cleanup();
  1759. }
  1760. },
  1761. forceRendering: function forceRendering() {
  1762. this.pdfRenderingQueue.printing = this.printing;
  1763. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1764. this.pdfRenderingQueue.renderHighestPriority();
  1765. },
  1766. beforePrint: function beforePrint() {
  1767. var _this7 = this;
  1768. if (this.printService) {
  1769. return;
  1770. }
  1771. if (!this.supportsPrinting) {
  1772. this.l10n.get('printing_not_supported', null,
  1773. 'Warning: Printing is not fully supported by ' + 'this browser.').then(
  1774. function(printMessage) {
  1775. _this7.error(printMessage);
  1776. });
  1777. return;
  1778. }
  1779. if (!this.pdfViewer.pageViewsReady) {
  1780. this.l10n.get('printing_not_ready', null,
  1781. 'Warning: The PDF is not fully loaded for printing.').then(function(
  1782. notReadyMessage) {
  1783. window.alert(notReadyMessage);
  1784. });
  1785. return;
  1786. }
  1787. var pagesOverview = this.pdfViewer.getPagesOverview();
  1788. var printContainer = this.appConfig.printContainer;
  1789. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument,
  1790. pagesOverview, printContainer, this.l10n);
  1791. this.printService = printService;
  1792. this.forceRendering();
  1793. printService.layout();
  1794. },
  1795. afterPrint: function afterPrint() {
  1796. if (this.printService) {
  1797. this.printService.destroy();
  1798. this.printService = null;
  1799. }
  1800. this.forceRendering();
  1801. },
  1802. rotatePages: function rotatePages(delta) {
  1803. if (!this.pdfDocument) {
  1804. return;
  1805. }
  1806. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1807. this.pdfViewer.pagesRotation = newRotation;
  1808. },
  1809. requestPresentationMode: function requestPresentationMode() {
  1810. if (!this.pdfPresentationMode) {
  1811. return;
  1812. }
  1813. this.pdfPresentationMode.request();
  1814. },
  1815. bindEvents: function bindEvents() {
  1816. var eventBus = this.eventBus,
  1817. _boundEvents = this._boundEvents;
  1818. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1819. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1820. eventBus.on('resize', webViewerResize);
  1821. eventBus.on('hashchange', webViewerHashchange);
  1822. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1823. eventBus.on('afterprint', _boundEvents.afterPrint);
  1824. eventBus.on('pagerendered', webViewerPageRendered);
  1825. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1826. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1827. eventBus.on('pagechanging', webViewerPageChanging);
  1828. eventBus.on('scalechanging', webViewerScaleChanging);
  1829. eventBus.on('rotationchanging', webViewerRotationChanging);
  1830. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1831. eventBus.on('pagemode', webViewerPageMode);
  1832. eventBus.on('namedaction', webViewerNamedAction);
  1833. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1834. eventBus.on('presentationmode', webViewerPresentationMode);
  1835. eventBus.on('openfile', webViewerOpenFile);
  1836. eventBus.on('print', webViewerPrint);
  1837. eventBus.on('download', webViewerDownload);
  1838. eventBus.on('firstpage', webViewerFirstPage);
  1839. eventBus.on('lastpage', webViewerLastPage);
  1840. eventBus.on('nextpage', webViewerNextPage);
  1841. eventBus.on('previouspage', webViewerPreviousPage);
  1842. eventBus.on('zoomin', webViewerZoomIn);
  1843. eventBus.on('zoomout', webViewerZoomOut);
  1844. eventBus.on('zoomreset', webViewerZoomReset);
  1845. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1846. eventBus.on('scalechanged', webViewerScaleChanged);
  1847. eventBus.on('rotatecw', webViewerRotateCw);
  1848. eventBus.on('rotateccw', webViewerRotateCcw);
  1849. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1850. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1851. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1852. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1853. eventBus.on('documentproperties', webViewerDocumentProperties);
  1854. eventBus.on('find', webViewerFind);
  1855. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1856. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1857. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1858. eventBus.on('fileinputchange', webViewerFileInputChange);
  1859. },
  1860. bindWindowEvents: function bindWindowEvents() {
  1861. var eventBus = this.eventBus,
  1862. _boundEvents = this._boundEvents;
  1863. _boundEvents.windowResize = function() {
  1864. eventBus.dispatch('resize', {
  1865. source: window
  1866. });
  1867. };
  1868. _boundEvents.windowHashChange = function() {
  1869. eventBus.dispatch('hashchange', {
  1870. source: window,
  1871. hash: document.location.hash.substring(1)
  1872. });
  1873. };
  1874. _boundEvents.windowBeforePrint = function() {
  1875. eventBus.dispatch('beforeprint', {
  1876. source: window
  1877. });
  1878. };
  1879. _boundEvents.windowAfterPrint = function() {
  1880. eventBus.dispatch('afterprint', {
  1881. source: window
  1882. });
  1883. };
  1884. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1885. window.addEventListener('wheel', webViewerWheel, {
  1886. passive: false
  1887. });
  1888. window.addEventListener('click', webViewerClick);
  1889. window.addEventListener('keydown', webViewerKeyDown);
  1890. window.addEventListener('resize', _boundEvents.windowResize);
  1891. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1892. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1893. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1894. },
  1895. unbindEvents: function unbindEvents() {
  1896. var eventBus = this.eventBus,
  1897. _boundEvents = this._boundEvents;
  1898. eventBus.off('resize', webViewerResize);
  1899. eventBus.off('hashchange', webViewerHashchange);
  1900. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1901. eventBus.off('afterprint', _boundEvents.afterPrint);
  1902. eventBus.off('pagerendered', webViewerPageRendered);
  1903. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1904. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1905. eventBus.off('pagechanging', webViewerPageChanging);
  1906. eventBus.off('scalechanging', webViewerScaleChanging);
  1907. eventBus.off('rotationchanging', webViewerRotationChanging);
  1908. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1909. eventBus.off('pagemode', webViewerPageMode);
  1910. eventBus.off('namedaction', webViewerNamedAction);
  1911. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1912. eventBus.off('presentationmode', webViewerPresentationMode);
  1913. eventBus.off('openfile', webViewerOpenFile);
  1914. eventBus.off('print', webViewerPrint);
  1915. eventBus.off('download', webViewerDownload);
  1916. eventBus.off('firstpage', webViewerFirstPage);
  1917. eventBus.off('lastpage', webViewerLastPage);
  1918. eventBus.off('nextpage', webViewerNextPage);
  1919. eventBus.off('previouspage', webViewerPreviousPage);
  1920. eventBus.off('zoomin', webViewerZoomIn);
  1921. eventBus.off('zoomout', webViewerZoomOut);
  1922. eventBus.off('zoomreset', webViewerZoomReset);
  1923. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1924. eventBus.off('scalechanged', webViewerScaleChanged);
  1925. eventBus.off('rotatecw', webViewerRotateCw);
  1926. eventBus.off('rotateccw', webViewerRotateCcw);
  1927. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1928. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1929. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1930. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1931. eventBus.off('documentproperties', webViewerDocumentProperties);
  1932. eventBus.off('find', webViewerFind);
  1933. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1934. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1935. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1936. eventBus.off('fileinputchange', webViewerFileInputChange);
  1937. _boundEvents.beforePrint = null;
  1938. _boundEvents.afterPrint = null;
  1939. },
  1940. unbindWindowEvents: function unbindWindowEvents() {
  1941. var _boundEvents = this._boundEvents;
  1942. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1943. window.removeEventListener('wheel', webViewerWheel);
  1944. window.removeEventListener('click', webViewerClick);
  1945. window.removeEventListener('keydown', webViewerKeyDown);
  1946. window.removeEventListener('resize', _boundEvents.windowResize);
  1947. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1948. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1949. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1950. _boundEvents.windowResize = null;
  1951. _boundEvents.windowHashChange = null;
  1952. _boundEvents.windowBeforePrint = null;
  1953. _boundEvents.windowAfterPrint = null;
  1954. }
  1955. };
  1956. exports.PDFViewerApplication = PDFViewerApplication;
  1957. var validateFileURL; {
  1958. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1959. validateFileURL = function validateFileURL(file) {
  1960. if (file === undefined) {
  1961. return;
  1962. }
  1963. try {
  1964. var viewerOrigin = new URL(window.location.href).origin || 'null';
  1965. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1966. return;
  1967. }
  1968. var _ref8 = new URL(file, window.location.href),
  1969. origin = _ref8.origin,
  1970. protocol = _ref8.protocol;
  1971. // if (origin !== viewerOrigin && protocol !== 'blob:') {
  1972. // throw new Error('file origin does not match viewer\'s');
  1973. // }
  1974. } catch (ex) {
  1975. var message = ex && ex.message;
  1976. PDFViewerApplication.l10n.get('loading_error', null,
  1977. 'An error occurred while loading the PDF.').then(function(loadingErrorMessage) {
  1978. PDFViewerApplication.error(loadingErrorMessage, {
  1979. message: message
  1980. });
  1981. });
  1982. throw ex;
  1983. }
  1984. };
  1985. }
  1986. function loadFakeWorker() {
  1987. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1988. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1989. }
  1990. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1991. }
  1992. function loadAndEnablePDFBug(enabledTabs) {
  1993. var appConfig = PDFViewerApplication.appConfig;
  1994. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function() {
  1995. PDFBug.enable(enabledTabs);
  1996. PDFBug.init({
  1997. OPS: _pdfjsLib.OPS,
  1998. createObjectURL: _pdfjsLib.createObjectURL
  1999. }, appConfig.mainContainer);
  2000. });
  2001. }
  2002. function webViewerInitialized() {
  2003. var appConfig = PDFViewerApplication.appConfig;
  2004. var file;
  2005. var queryString = document.location.search.substring(1);
  2006. var params = (0, _ui_utils.parseQueryString)(queryString);
  2007. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  2008. validateFileURL(file);
  2009. var fileInput = document.createElement('input');
  2010. fileInput.id = appConfig.openFileInputName;
  2011. fileInput.className = 'fileInput';
  2012. fileInput.setAttribute('type', 'file');
  2013. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2014. document.body.appendChild(fileInput);
  2015. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2016. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  2017. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  2018. } else {
  2019. fileInput.value = null;
  2020. }
  2021. fileInput.addEventListener('change', function(evt) {
  2022. var files = evt.target.files;
  2023. if (!files || files.length === 0) {
  2024. return;
  2025. }
  2026. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  2027. source: this,
  2028. fileInput: evt.target
  2029. });
  2030. });
  2031. appConfig.mainContainer.addEventListener('dragover', function(evt) {
  2032. evt.preventDefault();
  2033. evt.dataTransfer.dropEffect = 'move';
  2034. });
  2035. appConfig.mainContainer.addEventListener('drop', function(evt) {
  2036. evt.preventDefault();
  2037. var files = evt.dataTransfer.files;
  2038. if (!files || files.length === 0) {
  2039. return;
  2040. }
  2041. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  2042. source: this,
  2043. fileInput: evt.dataTransfer
  2044. });
  2045. });
  2046. if (!PDFViewerApplication.supportsPrinting) {
  2047. appConfig.toolbar.print.classList.add('hidden');
  2048. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  2049. }
  2050. if (!PDFViewerApplication.supportsFullscreen) {
  2051. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  2052. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  2053. }
  2054. if (PDFViewerApplication.supportsIntegratedFind) {
  2055. appConfig.toolbar.viewFind.classList.add('hidden');
  2056. }
  2057. appConfig.mainContainer.addEventListener('transitionend', function(evt) {
  2058. if (evt.target === this) {
  2059. PDFViewerApplication.eventBus.dispatch('resize', {
  2060. source: this
  2061. });
  2062. }
  2063. }, true);
  2064. try {
  2065. webViewerOpenFileViaURL(file);
  2066. } catch (reason) {
  2067. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.')
  2068. .then(function(msg) {
  2069. PDFViewerApplication.error(msg, reason);
  2070. });
  2071. }
  2072. }
  2073. var webViewerOpenFileViaURL; {
  2074. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2075. if (file && file.lastIndexOf('file:', 0) === 0) {
  2076. PDFViewerApplication.setTitleUsingUrl(file);
  2077. var xhr = new XMLHttpRequest();
  2078. xhr.onload = function() {
  2079. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2080. };
  2081. xhr.open('GET', file);
  2082. xhr.responseType = 'arraybuffer';
  2083. xhr.send();
  2084. return;
  2085. }
  2086. if (file) {
  2087. PDFViewerApplication.open(file);
  2088. }
  2089. };
  2090. }
  2091. function webViewerPageRendered(evt) {
  2092. var pageNumber = evt.pageNumber;
  2093. var pageIndex = pageNumber - 1;
  2094. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  2095. if (pageNumber === PDFViewerApplication.page) {
  2096. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2097. }
  2098. if (!pageView) {
  2099. return;
  2100. }
  2101. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2102. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  2103. thumbnailView.setImage(pageView);
  2104. }
  2105. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  2106. Stats.add(pageNumber, pageView.stats);
  2107. }
  2108. if (pageView.error) {
  2109. PDFViewerApplication.l10n.get('rendering_error', null,
  2110. 'An error occurred while rendering the page.').then(function(msg) {
  2111. PDFViewerApplication.error(msg, pageView.error);
  2112. });
  2113. }
  2114. }
  2115. function webViewerTextLayerRendered(evt) {}
  2116. function webViewerPageMode(evt) {
  2117. var mode = evt.mode,
  2118. view;
  2119. switch (mode) {
  2120. case 'thumbs':
  2121. view = _pdf_sidebar.SidebarView.THUMBS;
  2122. break;
  2123. case 'bookmarks':
  2124. case 'outline':
  2125. view = _pdf_sidebar.SidebarView.OUTLINE;
  2126. break;
  2127. case 'attachments':
  2128. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  2129. break;
  2130. case 'none':
  2131. view = _pdf_sidebar.SidebarView.NONE;
  2132. break;
  2133. default:
  2134. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2135. return;
  2136. }
  2137. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2138. }
  2139. function webViewerNamedAction(evt) {
  2140. var action = evt.action;
  2141. switch (action) {
  2142. case 'GoToPage':
  2143. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2144. break;
  2145. case 'Find':
  2146. if (!PDFViewerApplication.supportsIntegratedFind) {
  2147. PDFViewerApplication.findBar.toggle();
  2148. }
  2149. break;
  2150. }
  2151. }
  2152. function webViewerPresentationModeChanged(evt) {
  2153. var active = evt.active,
  2154. switchInProgress = evt.switchInProgress;
  2155. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils
  2156. .PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN :
  2157. _ui_utils.PresentationModeState.NORMAL;
  2158. }
  2159. function webViewerSidebarViewChanged(evt) {
  2160. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar
  2161. .isThumbnailViewVisible;
  2162. var store = PDFViewerApplication.store;
  2163. if (store && PDFViewerApplication.isInitialViewSet) {
  2164. store.set('sidebarView', evt.view)["catch"](function() {});
  2165. }
  2166. }
  2167. function webViewerUpdateViewarea(evt) {
  2168. var location = evt.location,
  2169. store = PDFViewerApplication.store;
  2170. if (store && PDFViewerApplication.isInitialViewSet) {
  2171. store.setMultiple({
  2172. 'page': location.pageNumber,
  2173. 'zoom': location.scale,
  2174. 'scrollLeft': location.left,
  2175. 'scrollTop': location.top,
  2176. 'rotation': location.rotation
  2177. })["catch"](function() {});
  2178. }
  2179. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2180. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2181. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2182. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2183. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2184. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2185. }
  2186. function webViewerScrollModeChanged(evt) {
  2187. var store = PDFViewerApplication.store;
  2188. if (store && PDFViewerApplication.isInitialViewSet) {
  2189. store.set('scrollMode', evt.mode)["catch"](function() {});
  2190. }
  2191. }
  2192. function webViewerSpreadModeChanged(evt) {
  2193. var store = PDFViewerApplication.store;
  2194. if (store && PDFViewerApplication.isInitialViewSet) {
  2195. store.set('spreadMode', evt.mode)["catch"](function() {});
  2196. }
  2197. }
  2198. function webViewerResize() {
  2199. var pdfDocument = PDFViewerApplication.pdfDocument,
  2200. pdfViewer = PDFViewerApplication.pdfViewer;
  2201. if (!pdfDocument) {
  2202. return;
  2203. }
  2204. var currentScaleValue = pdfViewer.currentScaleValue;
  2205. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue ===
  2206. 'page-width') {
  2207. pdfViewer.currentScaleValue = currentScaleValue;
  2208. }
  2209. pdfViewer.update();
  2210. }
  2211. function webViewerHashchange(evt) {
  2212. var hash = evt.hash;
  2213. if (!hash) {
  2214. return;
  2215. }
  2216. if (!PDFViewerApplication.isInitialViewSet) {
  2217. PDFViewerApplication.initialBookmark = hash;
  2218. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2219. PDFViewerApplication.pdfLinkService.setHash(hash);
  2220. }
  2221. }
  2222. var webViewerFileInputChange; {
  2223. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2224. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2225. return;
  2226. }
  2227. var file = evt.fileInput.files[0];
  2228. if (URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  2229. var url = URL.createObjectURL(file);
  2230. if (file.name) {
  2231. url = {
  2232. url: url,
  2233. originalUrl: file.name
  2234. };
  2235. }
  2236. PDFViewerApplication.open(url);
  2237. } else {
  2238. PDFViewerApplication.setTitleUsingUrl(file.name);
  2239. var fileReader = new FileReader();
  2240. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  2241. var buffer = evt.target.result;
  2242. PDFViewerApplication.open(new Uint8Array(buffer));
  2243. };
  2244. fileReader.readAsArrayBuffer(file);
  2245. }
  2246. var appConfig = PDFViewerApplication.appConfig;
  2247. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  2248. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  2249. appConfig.toolbar.download.setAttribute('hidden', 'true');
  2250. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  2251. };
  2252. }
  2253. function webViewerPresentationMode() {
  2254. PDFViewerApplication.requestPresentationMode();
  2255. }
  2256. function webViewerOpenFile() {
  2257. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2258. document.getElementById(openFileInputName).click();
  2259. }
  2260. function webViewerPrint() {
  2261. window.print();
  2262. }
  2263. function webViewerDownload() {
  2264. PDFViewerApplication.download();
  2265. }
  2266. function webViewerFirstPage() {
  2267. if (PDFViewerApplication.pdfDocument) {
  2268. PDFViewerApplication.page = 1;
  2269. }
  2270. }
  2271. function webViewerLastPage() {
  2272. if (PDFViewerApplication.pdfDocument) {
  2273. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2274. }
  2275. }
  2276. function webViewerNextPage() {
  2277. PDFViewerApplication.page++;
  2278. }
  2279. function webViewerPreviousPage() {
  2280. PDFViewerApplication.page--;
  2281. }
  2282. function webViewerZoomIn() {
  2283. PDFViewerApplication.zoomIn();
  2284. }
  2285. function webViewerZoomOut() {
  2286. PDFViewerApplication.zoomOut();
  2287. }
  2288. function webViewerZoomReset() {
  2289. PDFViewerApplication.zoomReset();
  2290. }
  2291. function webViewerPageNumberChanged(evt) {
  2292. var pdfViewer = PDFViewerApplication.pdfViewer;
  2293. if (evt.value !== '') {
  2294. pdfViewer.currentPageLabel = evt.value;
  2295. }
  2296. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer
  2297. .currentPageLabel) {
  2298. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  2299. .currentPageLabel);
  2300. }
  2301. }
  2302. function webViewerScaleChanged(evt) {
  2303. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2304. }
  2305. function webViewerRotateCw() {
  2306. PDFViewerApplication.rotatePages(90);
  2307. }
  2308. function webViewerRotateCcw() {
  2309. PDFViewerApplication.rotatePages(-90);
  2310. }
  2311. function webViewerSwitchScrollMode(evt) {
  2312. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2313. }
  2314. function webViewerSwitchSpreadMode(evt) {
  2315. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2316. }
  2317. function webViewerDocumentProperties() {
  2318. PDFViewerApplication.pdfDocumentProperties.open();
  2319. }
  2320. function webViewerFind(evt) {
  2321. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  2322. query: evt.query,
  2323. phraseSearch: evt.phraseSearch,
  2324. caseSensitive: evt.caseSensitive,
  2325. entireWord: evt.entireWord,
  2326. highlightAll: evt.highlightAll,
  2327. findPrevious: evt.findPrevious
  2328. });
  2329. }
  2330. function webViewerFindFromUrlHash(evt) {
  2331. PDFViewerApplication.findController.executeCommand('find', {
  2332. query: evt.query,
  2333. phraseSearch: evt.phraseSearch,
  2334. caseSensitive: false,
  2335. entireWord: false,
  2336. highlightAll: true,
  2337. findPrevious: false
  2338. });
  2339. }
  2340. function webViewerUpdateFindMatchesCount(_ref9) {
  2341. var matchesCount = _ref9.matchesCount;
  2342. if (PDFViewerApplication.supportsIntegratedFind) {
  2343. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2344. } else {
  2345. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2346. }
  2347. }
  2348. function webViewerUpdateFindControlState(_ref10) {
  2349. var state = _ref10.state,
  2350. previous = _ref10.previous,
  2351. matchesCount = _ref10.matchesCount;
  2352. if (PDFViewerApplication.supportsIntegratedFind) {
  2353. PDFViewerApplication.externalServices.updateFindControlState({
  2354. result: state,
  2355. findPrevious: previous,
  2356. matchesCount: matchesCount
  2357. });
  2358. } else {
  2359. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2360. }
  2361. }
  2362. function webViewerScaleChanging(evt) {
  2363. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2364. PDFViewerApplication.pdfViewer.update();
  2365. }
  2366. function webViewerRotationChanging(evt) {
  2367. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2368. PDFViewerApplication.forceRendering();
  2369. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2370. }
  2371. function webViewerPageChanging(evt) {
  2372. var page = evt.pageNumber;
  2373. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2374. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2375. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2376. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2377. }
  2378. if (typeof Stats !== 'undefined' && Stats.enabled) {
  2379. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2380. if (pageView && pageView.stats) {
  2381. Stats.add(page, pageView.stats);
  2382. }
  2383. }
  2384. }
  2385. function webViewerVisibilityChange(evt) {
  2386. if (document.visibilityState === 'visible') {
  2387. setZoomDisabledTimeout();
  2388. }
  2389. }
  2390. var zoomDisabledTimeout = null;
  2391. function setZoomDisabledTimeout() {
  2392. if (zoomDisabledTimeout) {
  2393. clearTimeout(zoomDisabledTimeout);
  2394. }
  2395. zoomDisabledTimeout = setTimeout(function() {
  2396. zoomDisabledTimeout = null;
  2397. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2398. }
  2399. function webViewerWheel(evt) {
  2400. var pdfViewer = PDFViewerApplication.pdfViewer,
  2401. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2402. if (pdfViewer.isInPresentationMode) {
  2403. return;
  2404. }
  2405. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey &&
  2406. supportedMouseWheelZoomModifierKeys.metaKey) {
  2407. evt.preventDefault();
  2408. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  2409. return;
  2410. }
  2411. var previousScale = pdfViewer.currentScale;
  2412. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2413. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2414. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2415. if (ticks < 0) {
  2416. PDFViewerApplication.zoomOut(-ticks);
  2417. } else {
  2418. PDFViewerApplication.zoomIn(ticks);
  2419. }
  2420. var currentScale = pdfViewer.currentScale;
  2421. if (previousScale !== currentScale) {
  2422. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2423. var rect = pdfViewer.container.getBoundingClientRect();
  2424. var dx = evt.clientX - rect.left;
  2425. var dy = evt.clientY - rect.top;
  2426. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2427. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2428. }
  2429. } else {
  2430. setZoomDisabledTimeout();
  2431. }
  2432. }
  2433. function webViewerClick(evt) {
  2434. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2435. return;
  2436. }
  2437. var appConfig = PDFViewerApplication.appConfig;
  2438. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container
  2439. .contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2440. PDFViewerApplication.secondaryToolbar.close();
  2441. }
  2442. }
  2443. function webViewerKeyDown(evt) {
  2444. if (PDFViewerApplication.overlayManager.active) {
  2445. return;
  2446. }
  2447. var handled = false,
  2448. ensureViewerFocused = false;
  2449. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 :
  2450. 0);
  2451. var pdfViewer = PDFViewerApplication.pdfViewer;
  2452. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2453. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2454. switch (evt.keyCode) {
  2455. case 70:
  2456. if (!PDFViewerApplication.supportsIntegratedFind) {
  2457. PDFViewerApplication.findBar.open();
  2458. handled = true;
  2459. }
  2460. break;
  2461. case 71:
  2462. if (!PDFViewerApplication.supportsIntegratedFind) {
  2463. var findState = PDFViewerApplication.findController.state;
  2464. if (findState) {
  2465. PDFViewerApplication.findController.executeCommand('findagain', {
  2466. query: findState.query,
  2467. phraseSearch: findState.phraseSearch,
  2468. caseSensitive: findState.caseSensitive,
  2469. entireWord: findState.entireWord,
  2470. highlightAll: findState.highlightAll,
  2471. findPrevious: cmd === 5 || cmd === 12
  2472. });
  2473. }
  2474. handled = true;
  2475. }
  2476. break;
  2477. case 61:
  2478. case 107:
  2479. case 187:
  2480. case 171:
  2481. if (!isViewerInPresentationMode) {
  2482. PDFViewerApplication.zoomIn();
  2483. }
  2484. handled = true;
  2485. break;
  2486. case 173:
  2487. case 109:
  2488. case 189:
  2489. if (!isViewerInPresentationMode) {
  2490. PDFViewerApplication.zoomOut();
  2491. }
  2492. handled = true;
  2493. break;
  2494. case 48:
  2495. case 96:
  2496. if (!isViewerInPresentationMode) {
  2497. setTimeout(function() {
  2498. PDFViewerApplication.zoomReset();
  2499. });
  2500. handled = false;
  2501. }
  2502. break;
  2503. case 38:
  2504. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2505. PDFViewerApplication.page = 1;
  2506. handled = true;
  2507. ensureViewerFocused = true;
  2508. }
  2509. break;
  2510. case 40:
  2511. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication
  2512. .pagesCount) {
  2513. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2514. handled = true;
  2515. ensureViewerFocused = true;
  2516. }
  2517. break;
  2518. }
  2519. }
  2520. if (cmd === 1 || cmd === 8) {
  2521. switch (evt.keyCode) {
  2522. case 83:
  2523. PDFViewerApplication.download();
  2524. handled = true;
  2525. break;
  2526. }
  2527. }
  2528. if (cmd === 3 || cmd === 10) {
  2529. switch (evt.keyCode) {
  2530. case 80:
  2531. PDFViewerApplication.requestPresentationMode();
  2532. handled = true;
  2533. break;
  2534. case 71:
  2535. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2536. handled = true;
  2537. break;
  2538. }
  2539. }
  2540. if (handled) {
  2541. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2542. pdfViewer.focus();
  2543. }
  2544. evt.preventDefault();
  2545. return;
  2546. }
  2547. var curElement = document.activeElement || document.querySelector(':focus');
  2548. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2549. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName ===
  2550. 'SELECT') {
  2551. if (evt.keyCode !== 27) {
  2552. return;
  2553. }
  2554. }
  2555. if (cmd === 0) {
  2556. var turnPage = 0,
  2557. turnOnlyIfPageFit = false;
  2558. switch (evt.keyCode) {
  2559. case 38:
  2560. case 33:
  2561. if (pdfViewer.isVerticalScrollbarEnabled) {
  2562. turnOnlyIfPageFit = true;
  2563. }
  2564. turnPage = -1;
  2565. break;
  2566. case 8:
  2567. if (!isViewerInPresentationMode) {
  2568. turnOnlyIfPageFit = true;
  2569. }
  2570. turnPage = -1;
  2571. break;
  2572. case 37:
  2573. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2574. turnOnlyIfPageFit = true;
  2575. }
  2576. case 75:
  2577. case 80:
  2578. turnPage = -1;
  2579. break;
  2580. case 27:
  2581. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2582. PDFViewerApplication.secondaryToolbar.close();
  2583. handled = true;
  2584. }
  2585. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar
  2586. .opened) {
  2587. PDFViewerApplication.findBar.close();
  2588. handled = true;
  2589. }
  2590. break;
  2591. case 40:
  2592. case 34:
  2593. if (pdfViewer.isVerticalScrollbarEnabled) {
  2594. turnOnlyIfPageFit = true;
  2595. }
  2596. turnPage = 1;
  2597. break;
  2598. case 13:
  2599. case 32:
  2600. if (!isViewerInPresentationMode) {
  2601. turnOnlyIfPageFit = true;
  2602. }
  2603. turnPage = 1;
  2604. break;
  2605. case 39:
  2606. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2607. turnOnlyIfPageFit = true;
  2608. }
  2609. case 74:
  2610. case 78:
  2611. turnPage = 1;
  2612. break;
  2613. case 36:
  2614. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2615. PDFViewerApplication.page = 1;
  2616. handled = true;
  2617. ensureViewerFocused = true;
  2618. }
  2619. break;
  2620. case 35:
  2621. if (isViewerInPresentationMode || PDFViewerApplication.page <
  2622. PDFViewerApplication.pagesCount) {
  2623. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2624. handled = true;
  2625. ensureViewerFocused = true;
  2626. }
  2627. break;
  2628. case 83:
  2629. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool
  2630. .SELECT);
  2631. break;
  2632. case 72:
  2633. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool
  2634. .HAND);
  2635. break;
  2636. case 82:
  2637. PDFViewerApplication.rotatePages(90);
  2638. break;
  2639. case 115:
  2640. PDFViewerApplication.pdfSidebar.toggle();
  2641. break;
  2642. }
  2643. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2644. if (turnPage > 0) {
  2645. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2646. PDFViewerApplication.page++;
  2647. }
  2648. } else {
  2649. if (PDFViewerApplication.page > 1) {
  2650. PDFViewerApplication.page--;
  2651. }
  2652. }
  2653. handled = true;
  2654. }
  2655. }
  2656. if (cmd === 4) {
  2657. switch (evt.keyCode) {
  2658. case 13:
  2659. case 32:
  2660. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2661. break;
  2662. }
  2663. if (PDFViewerApplication.page > 1) {
  2664. PDFViewerApplication.page--;
  2665. }
  2666. handled = true;
  2667. break;
  2668. case 82:
  2669. PDFViewerApplication.rotatePages(-90);
  2670. break;
  2671. }
  2672. }
  2673. if (!handled && !isViewerInPresentationMode) {
  2674. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !==
  2675. 'BUTTON') {
  2676. ensureViewerFocused = true;
  2677. }
  2678. }
  2679. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2680. pdfViewer.focus();
  2681. }
  2682. if (handled) {
  2683. evt.preventDefault();
  2684. }
  2685. }
  2686. function apiPageLayoutToSpreadMode(layout) {
  2687. switch (layout) {
  2688. case 'SinglePage':
  2689. case 'OneColumn':
  2690. return _ui_utils.SpreadMode.NONE;
  2691. case 'TwoColumnLeft':
  2692. case 'TwoPageLeft':
  2693. return _ui_utils.SpreadMode.ODD;
  2694. case 'TwoColumnRight':
  2695. case 'TwoPageRight':
  2696. return _ui_utils.SpreadMode.EVEN;
  2697. }
  2698. return _ui_utils.SpreadMode.NONE;
  2699. }
  2700. function apiPageModeToSidebarView(mode) {
  2701. switch (mode) {
  2702. case 'UseNone':
  2703. return _pdf_sidebar.SidebarView.NONE;
  2704. case 'UseThumbs':
  2705. return _pdf_sidebar.SidebarView.THUMBS;
  2706. case 'UseOutlines':
  2707. return _pdf_sidebar.SidebarView.OUTLINE;
  2708. case 'UseAttachments':
  2709. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2710. case 'UseOC':
  2711. }
  2712. return _pdf_sidebar.SidebarView.NONE;
  2713. }
  2714. var PDFPrintServiceFactory = {
  2715. instance: {
  2716. supportsPrinting: false,
  2717. createPrintService: function createPrintService() {
  2718. throw new Error('Not implemented: createPrintService');
  2719. }
  2720. }
  2721. };
  2722. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2723. /***/
  2724. }),
  2725. /* 2 */
  2726. /***/
  2727. (function(module, exports, __webpack_require__) {
  2728. "use strict";
  2729. module.exports = __webpack_require__(3);
  2730. /***/
  2731. }),
  2732. /* 3 */
  2733. /***/
  2734. (function(module, exports, __webpack_require__) {
  2735. "use strict";
  2736. /* WEBPACK VAR INJECTION */
  2737. (function(module) {
  2738. function _typeof(obj) {
  2739. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  2740. _typeof = function _typeof(obj) {
  2741. return typeof obj;
  2742. };
  2743. } else {
  2744. _typeof = function _typeof(obj) {
  2745. return obj && typeof Symbol === "function" && obj.constructor === Symbol &&
  2746. obj !== Symbol.prototype ? "symbol" : typeof obj;
  2747. };
  2748. }
  2749. return _typeof(obj);
  2750. }
  2751. var runtime = function(exports) {
  2752. "use strict";
  2753. var Op = Object.prototype;
  2754. var hasOwn = Op.hasOwnProperty;
  2755. var undefined;
  2756. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2757. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2758. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2759. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2760. function wrap(innerFn, outerFn, self, tryLocsList) {
  2761. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn :
  2762. Generator;
  2763. var generator = Object.create(protoGenerator.prototype);
  2764. var context = new Context(tryLocsList || []);
  2765. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2766. return generator;
  2767. }
  2768. exports.wrap = wrap;
  2769. function tryCatch(fn, obj, arg) {
  2770. try {
  2771. return {
  2772. type: "normal",
  2773. arg: fn.call(obj, arg)
  2774. };
  2775. } catch (err) {
  2776. return {
  2777. type: "throw",
  2778. arg: err
  2779. };
  2780. }
  2781. }
  2782. var GenStateSuspendedStart = "suspendedStart";
  2783. var GenStateSuspendedYield = "suspendedYield";
  2784. var GenStateExecuting = "executing";
  2785. var GenStateCompleted = "completed";
  2786. var ContinueSentinel = {};
  2787. function Generator() {}
  2788. function GeneratorFunction() {}
  2789. function GeneratorFunctionPrototype() {}
  2790. var IteratorPrototype = {};
  2791. IteratorPrototype[iteratorSymbol] = function() {
  2792. return this;
  2793. };
  2794. var getProto = Object.getPrototypeOf;
  2795. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2796. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(
  2797. NativeIteratorPrototype, iteratorSymbol)) {
  2798. IteratorPrototype = NativeIteratorPrototype;
  2799. }
  2800. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(
  2801. IteratorPrototype);
  2802. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2803. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2804. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName =
  2805. "GeneratorFunction";
  2806. function defineIteratorMethods(prototype) {
  2807. ["next", "throw", "return"].forEach(function(method) {
  2808. prototype[method] = function(arg) {
  2809. return this._invoke(method, arg);
  2810. };
  2811. });
  2812. }
  2813. exports.isGeneratorFunction = function(genFun) {
  2814. var ctor = typeof genFun === "function" && genFun.constructor;
  2815. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) ===
  2816. "GeneratorFunction" : false;
  2817. };
  2818. exports.mark = function(genFun) {
  2819. if (Object.setPrototypeOf) {
  2820. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2821. } else {
  2822. genFun.__proto__ = GeneratorFunctionPrototype;
  2823. if (!(toStringTagSymbol in genFun)) {
  2824. genFun[toStringTagSymbol] = "GeneratorFunction";
  2825. }
  2826. }
  2827. genFun.prototype = Object.create(Gp);
  2828. return genFun;
  2829. };
  2830. exports.awrap = function(arg) {
  2831. return {
  2832. __await: arg
  2833. };
  2834. };
  2835. function AsyncIterator(generator) {
  2836. function invoke(method, arg, resolve, reject) {
  2837. var record = tryCatch(generator[method], generator, arg);
  2838. if (record.type === "throw") {
  2839. reject(record.arg);
  2840. } else {
  2841. var result = record.arg;
  2842. var value = result.value;
  2843. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2844. return Promise.resolve(value.__await).then(function(value) {
  2845. invoke("next", value, resolve, reject);
  2846. }, function(err) {
  2847. invoke("throw", err, resolve, reject);
  2848. });
  2849. }
  2850. return Promise.resolve(value).then(function(unwrapped) {
  2851. result.value = unwrapped;
  2852. resolve(result);
  2853. }, function(error) {
  2854. return invoke("throw", error, resolve, reject);
  2855. });
  2856. }
  2857. }
  2858. var previousPromise;
  2859. function enqueue(method, arg) {
  2860. function callInvokeWithMethodAndArg() {
  2861. return new Promise(function(resolve, reject) {
  2862. invoke(method, arg, resolve, reject);
  2863. });
  2864. }
  2865. return previousPromise = previousPromise ? previousPromise.then(
  2866. callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) :
  2867. callInvokeWithMethodAndArg();
  2868. }
  2869. this._invoke = enqueue;
  2870. }
  2871. defineIteratorMethods(AsyncIterator.prototype);
  2872. AsyncIterator.prototype[asyncIteratorSymbol] = function() {
  2873. return this;
  2874. };
  2875. exports.AsyncIterator = AsyncIterator;
  2876. exports.async = function(innerFn, outerFn, self, tryLocsList) {
  2877. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2878. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(
  2879. result) {
  2880. return result.done ? result.value : iter.next();
  2881. });
  2882. };
  2883. function makeInvokeMethod(innerFn, self, context) {
  2884. var state = GenStateSuspendedStart;
  2885. return function invoke(method, arg) {
  2886. if (state === GenStateExecuting) {
  2887. throw new Error("Generator is already running");
  2888. }
  2889. if (state === GenStateCompleted) {
  2890. if (method === "throw") {
  2891. throw arg;
  2892. }
  2893. return doneResult();
  2894. }
  2895. context.method = method;
  2896. context.arg = arg;
  2897. while (true) {
  2898. var delegate = context.delegate;
  2899. if (delegate) {
  2900. var delegateResult = maybeInvokeDelegate(delegate, context);
  2901. if (delegateResult) {
  2902. if (delegateResult === ContinueSentinel) continue;
  2903. return delegateResult;
  2904. }
  2905. }
  2906. if (context.method === "next") {
  2907. context.sent = context._sent = context.arg;
  2908. } else if (context.method === "throw") {
  2909. if (state === GenStateSuspendedStart) {
  2910. state = GenStateCompleted;
  2911. throw context.arg;
  2912. }
  2913. context.dispatchException(context.arg);
  2914. } else if (context.method === "return") {
  2915. context.abrupt("return", context.arg);
  2916. }
  2917. state = GenStateExecuting;
  2918. var record = tryCatch(innerFn, self, context);
  2919. if (record.type === "normal") {
  2920. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2921. if (record.arg === ContinueSentinel) {
  2922. continue;
  2923. }
  2924. return {
  2925. value: record.arg,
  2926. done: context.done
  2927. };
  2928. } else if (record.type === "throw") {
  2929. state = GenStateCompleted;
  2930. context.method = "throw";
  2931. context.arg = record.arg;
  2932. }
  2933. }
  2934. };
  2935. }
  2936. function maybeInvokeDelegate(delegate, context) {
  2937. var method = delegate.iterator[context.method];
  2938. if (method === undefined) {
  2939. context.delegate = null;
  2940. if (context.method === "throw") {
  2941. if (delegate.iterator["return"]) {
  2942. context.method = "return";
  2943. context.arg = undefined;
  2944. maybeInvokeDelegate(delegate, context);
  2945. if (context.method === "throw") {
  2946. return ContinueSentinel;
  2947. }
  2948. }
  2949. context.method = "throw";
  2950. context.arg = new TypeError(
  2951. "The iterator does not provide a 'throw' method");
  2952. }
  2953. return ContinueSentinel;
  2954. }
  2955. var record = tryCatch(method, delegate.iterator, context.arg);
  2956. if (record.type === "throw") {
  2957. context.method = "throw";
  2958. context.arg = record.arg;
  2959. context.delegate = null;
  2960. return ContinueSentinel;
  2961. }
  2962. var info = record.arg;
  2963. if (!info) {
  2964. context.method = "throw";
  2965. context.arg = new TypeError("iterator result is not an object");
  2966. context.delegate = null;
  2967. return ContinueSentinel;
  2968. }
  2969. if (info.done) {
  2970. context[delegate.resultName] = info.value;
  2971. context.next = delegate.nextLoc;
  2972. if (context.method !== "return") {
  2973. context.method = "next";
  2974. context.arg = undefined;
  2975. }
  2976. } else {
  2977. return info;
  2978. }
  2979. context.delegate = null;
  2980. return ContinueSentinel;
  2981. }
  2982. defineIteratorMethods(Gp);
  2983. Gp[toStringTagSymbol] = "Generator";
  2984. Gp[iteratorSymbol] = function() {
  2985. return this;
  2986. };
  2987. Gp.toString = function() {
  2988. return "[object Generator]";
  2989. };
  2990. function pushTryEntry(locs) {
  2991. var entry = {
  2992. tryLoc: locs[0]
  2993. };
  2994. if (1 in locs) {
  2995. entry.catchLoc = locs[1];
  2996. }
  2997. if (2 in locs) {
  2998. entry.finallyLoc = locs[2];
  2999. entry.afterLoc = locs[3];
  3000. }
  3001. this.tryEntries.push(entry);
  3002. }
  3003. function resetTryEntry(entry) {
  3004. var record = entry.completion || {};
  3005. record.type = "normal";
  3006. delete record.arg;
  3007. entry.completion = record;
  3008. }
  3009. function Context(tryLocsList) {
  3010. this.tryEntries = [{
  3011. tryLoc: "root"
  3012. }];
  3013. tryLocsList.forEach(pushTryEntry, this);
  3014. this.reset(true);
  3015. }
  3016. exports.keys = function(object) {
  3017. var keys = [];
  3018. for (var key in object) {
  3019. keys.push(key);
  3020. }
  3021. keys.reverse();
  3022. return function next() {
  3023. while (keys.length) {
  3024. var key = keys.pop();
  3025. if (key in object) {
  3026. next.value = key;
  3027. next.done = false;
  3028. return next;
  3029. }
  3030. }
  3031. next.done = true;
  3032. return next;
  3033. };
  3034. };
  3035. function values(iterable) {
  3036. if (iterable) {
  3037. var iteratorMethod = iterable[iteratorSymbol];
  3038. if (iteratorMethod) {
  3039. return iteratorMethod.call(iterable);
  3040. }
  3041. if (typeof iterable.next === "function") {
  3042. return iterable;
  3043. }
  3044. if (!isNaN(iterable.length)) {
  3045. var i = -1,
  3046. next = function next() {
  3047. while (++i < iterable.length) {
  3048. if (hasOwn.call(iterable, i)) {
  3049. next.value = iterable[i];
  3050. next.done = false;
  3051. return next;
  3052. }
  3053. }
  3054. next.value = undefined;
  3055. next.done = true;
  3056. return next;
  3057. };
  3058. return next.next = next;
  3059. }
  3060. }
  3061. return {
  3062. next: doneResult
  3063. };
  3064. }
  3065. exports.values = values;
  3066. function doneResult() {
  3067. return {
  3068. value: undefined,
  3069. done: true
  3070. };
  3071. }
  3072. Context.prototype = {
  3073. constructor: Context,
  3074. reset: function reset(skipTempReset) {
  3075. this.prev = 0;
  3076. this.next = 0;
  3077. this.sent = this._sent = undefined;
  3078. this.done = false;
  3079. this.delegate = null;
  3080. this.method = "next";
  3081. this.arg = undefined;
  3082. this.tryEntries.forEach(resetTryEntry);
  3083. if (!skipTempReset) {
  3084. for (var name in this) {
  3085. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(
  3086. +name.slice(1))) {
  3087. this[name] = undefined;
  3088. }
  3089. }
  3090. }
  3091. },
  3092. stop: function stop() {
  3093. this.done = true;
  3094. var rootEntry = this.tryEntries[0];
  3095. var rootRecord = rootEntry.completion;
  3096. if (rootRecord.type === "throw") {
  3097. throw rootRecord.arg;
  3098. }
  3099. return this.rval;
  3100. },
  3101. dispatchException: function dispatchException(exception) {
  3102. if (this.done) {
  3103. throw exception;
  3104. }
  3105. var context = this;
  3106. function handle(loc, caught) {
  3107. record.type = "throw";
  3108. record.arg = exception;
  3109. context.next = loc;
  3110. if (caught) {
  3111. context.method = "next";
  3112. context.arg = undefined;
  3113. }
  3114. return !!caught;
  3115. }
  3116. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3117. var entry = this.tryEntries[i];
  3118. var record = entry.completion;
  3119. if (entry.tryLoc === "root") {
  3120. return handle("end");
  3121. }
  3122. if (entry.tryLoc <= this.prev) {
  3123. var hasCatch = hasOwn.call(entry, "catchLoc");
  3124. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3125. if (hasCatch && hasFinally) {
  3126. if (this.prev < entry.catchLoc) {
  3127. return handle(entry.catchLoc, true);
  3128. } else if (this.prev < entry.finallyLoc) {
  3129. return handle(entry.finallyLoc);
  3130. }
  3131. } else if (hasCatch) {
  3132. if (this.prev < entry.catchLoc) {
  3133. return handle(entry.catchLoc, true);
  3134. }
  3135. } else if (hasFinally) {
  3136. if (this.prev < entry.finallyLoc) {
  3137. return handle(entry.finallyLoc);
  3138. }
  3139. } else {
  3140. throw new Error("try statement without catch or finally");
  3141. }
  3142. }
  3143. }
  3144. },
  3145. abrupt: function abrupt(type, arg) {
  3146. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3147. var entry = this.tryEntries[i];
  3148. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") &&
  3149. this.prev < entry.finallyLoc) {
  3150. var finallyEntry = entry;
  3151. break;
  3152. }
  3153. }
  3154. if (finallyEntry && (type === "break" || type === "continue") &&
  3155. finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3156. finallyEntry = null;
  3157. }
  3158. var record = finallyEntry ? finallyEntry.completion : {};
  3159. record.type = type;
  3160. record.arg = arg;
  3161. if (finallyEntry) {
  3162. this.method = "next";
  3163. this.next = finallyEntry.finallyLoc;
  3164. return ContinueSentinel;
  3165. }
  3166. return this.complete(record);
  3167. },
  3168. complete: function complete(record, afterLoc) {
  3169. if (record.type === "throw") {
  3170. throw record.arg;
  3171. }
  3172. if (record.type === "break" || record.type === "continue") {
  3173. this.next = record.arg;
  3174. } else if (record.type === "return") {
  3175. this.rval = this.arg = record.arg;
  3176. this.method = "return";
  3177. this.next = "end";
  3178. } else if (record.type === "normal" && afterLoc) {
  3179. this.next = afterLoc;
  3180. }
  3181. return ContinueSentinel;
  3182. },
  3183. finish: function finish(finallyLoc) {
  3184. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3185. var entry = this.tryEntries[i];
  3186. if (entry.finallyLoc === finallyLoc) {
  3187. this.complete(entry.completion, entry.afterLoc);
  3188. resetTryEntry(entry);
  3189. return ContinueSentinel;
  3190. }
  3191. }
  3192. },
  3193. "catch": function _catch(tryLoc) {
  3194. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3195. var entry = this.tryEntries[i];
  3196. if (entry.tryLoc === tryLoc) {
  3197. var record = entry.completion;
  3198. if (record.type === "throw") {
  3199. var thrown = record.arg;
  3200. resetTryEntry(entry);
  3201. }
  3202. return thrown;
  3203. }
  3204. }
  3205. throw new Error("illegal catch attempt");
  3206. },
  3207. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3208. this.delegate = {
  3209. iterator: values(iterable),
  3210. resultName: resultName,
  3211. nextLoc: nextLoc
  3212. };
  3213. if (this.method === "next") {
  3214. this.arg = undefined;
  3215. }
  3216. return ContinueSentinel;
  3217. }
  3218. };
  3219. return exports;
  3220. }((false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3221. try {
  3222. regeneratorRuntime = runtime;
  3223. } catch (accidentalStrictMode) {
  3224. Function("r", "regeneratorRuntime = r")(runtime);
  3225. }
  3226. /* WEBPACK VAR INJECTION */
  3227. }.call(this, __webpack_require__(4)(module)))
  3228. /***/
  3229. }),
  3230. /* 4 */
  3231. /***/
  3232. (function(module, exports, __webpack_require__) {
  3233. "use strict";
  3234. module.exports = function(module) {
  3235. if (!module.webpackPolyfill) {
  3236. module.deprecate = function() {};
  3237. module.paths = [];
  3238. if (!module.children) module.children = [];
  3239. Object.defineProperty(module, "loaded", {
  3240. enumerable: true,
  3241. get: function get() {
  3242. return module.l;
  3243. }
  3244. });
  3245. Object.defineProperty(module, "id", {
  3246. enumerable: true,
  3247. get: function get() {
  3248. return module.i;
  3249. }
  3250. });
  3251. module.webpackPolyfill = 1;
  3252. }
  3253. return module;
  3254. };
  3255. /***/
  3256. }),
  3257. /* 5 */
  3258. /***/
  3259. (function(module, exports, __webpack_require__) {
  3260. "use strict";
  3261. Object.defineProperty(exports, "__esModule", {
  3262. value: true
  3263. });
  3264. exports.isValidRotation = isValidRotation;
  3265. exports.isValidScrollMode = isValidScrollMode;
  3266. exports.isValidSpreadMode = isValidSpreadMode;
  3267. exports.isPortraitOrientation = isPortraitOrientation;
  3268. exports.getGlobalEventBus = getGlobalEventBus;
  3269. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3270. exports.noContextMenuHandler = noContextMenuHandler;
  3271. exports.parseQueryString = parseQueryString;
  3272. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3273. exports.getVisibleElements = getVisibleElements;
  3274. exports.roundToDivide = roundToDivide;
  3275. exports.getPageSizeInches = getPageSizeInches;
  3276. exports.approximateFraction = approximateFraction;
  3277. exports.getOutputScale = getOutputScale;
  3278. exports.scrollIntoView = scrollIntoView;
  3279. exports.watchScroll = watchScroll;
  3280. exports.binarySearchFirstItem = binarySearchFirstItem;
  3281. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3282. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3283. exports.moveToEndOfArray = moveToEndOfArray;
  3284. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports
  3285. .NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType =
  3286. exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports
  3287. .MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports
  3288. .DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
  3289. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3290. function _interopRequireDefault(obj) {
  3291. return obj && obj.__esModule ? obj : {
  3292. "default": obj
  3293. };
  3294. }
  3295. function _classCallCheck(instance, Constructor) {
  3296. if (!(instance instanceof Constructor)) {
  3297. throw new TypeError("Cannot call a class as a function");
  3298. }
  3299. }
  3300. function _defineProperties(target, props) {
  3301. for (var i = 0; i < props.length; i++) {
  3302. var descriptor = props[i];
  3303. descriptor.enumerable = descriptor.enumerable || false;
  3304. descriptor.configurable = true;
  3305. if ("value" in descriptor) descriptor.writable = true;
  3306. Object.defineProperty(target, descriptor.key, descriptor);
  3307. }
  3308. }
  3309. function _createClass(Constructor, protoProps, staticProps) {
  3310. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  3311. if (staticProps) _defineProperties(Constructor, staticProps);
  3312. return Constructor;
  3313. }
  3314. function _typeof(obj) {
  3315. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  3316. _typeof = function _typeof(obj) {
  3317. return typeof obj;
  3318. };
  3319. } else {
  3320. _typeof = function _typeof(obj) {
  3321. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  3322. Symbol.prototype ? "symbol" : typeof obj;
  3323. };
  3324. }
  3325. return _typeof(obj);
  3326. }
  3327. function _slicedToArray(arr, i) {
  3328. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  3329. }
  3330. function _nonIterableRest() {
  3331. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  3332. }
  3333. function _iterableToArrayLimit(arr, i) {
  3334. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  3335. "[object Arguments]")) {
  3336. return;
  3337. }
  3338. var _arr = [];
  3339. var _n = true;
  3340. var _d = false;
  3341. var _e = undefined;
  3342. try {
  3343. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  3344. _arr.push(_s.value);
  3345. if (i && _arr.length === i) break;
  3346. }
  3347. } catch (err) {
  3348. _d = true;
  3349. _e = err;
  3350. } finally {
  3351. try {
  3352. if (!_n && _i["return"] != null) _i["return"]();
  3353. } finally {
  3354. if (_d) throw _e;
  3355. }
  3356. }
  3357. return _arr;
  3358. }
  3359. function _arrayWithHoles(arr) {
  3360. if (Array.isArray(arr)) return arr;
  3361. }
  3362. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  3363. try {
  3364. var info = gen[key](arg);
  3365. var value = info.value;
  3366. } catch (error) {
  3367. reject(error);
  3368. return;
  3369. }
  3370. if (info.done) {
  3371. resolve(value);
  3372. } else {
  3373. Promise.resolve(value).then(_next, _throw);
  3374. }
  3375. }
  3376. function _asyncToGenerator(fn) {
  3377. return function() {
  3378. var self = this,
  3379. args = arguments;
  3380. return new Promise(function(resolve, reject) {
  3381. var gen = fn.apply(self, args);
  3382. function _next(value) {
  3383. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  3384. }
  3385. function _throw(err) {
  3386. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  3387. }
  3388. _next(undefined);
  3389. });
  3390. };
  3391. }
  3392. var CSS_UNITS = 96.0 / 72.0;
  3393. exports.CSS_UNITS = CSS_UNITS;
  3394. var DEFAULT_SCALE_VALUE = 'auto';
  3395. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3396. var DEFAULT_SCALE = 1.0;
  3397. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3398. var MIN_SCALE = 0.10;
  3399. exports.MIN_SCALE = MIN_SCALE;
  3400. var MAX_SCALE = 10.0;
  3401. exports.MAX_SCALE = MAX_SCALE;
  3402. var UNKNOWN_SCALE = 0;
  3403. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3404. var MAX_AUTO_SCALE = 1.25;
  3405. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3406. var SCROLLBAR_PADDING = 40;
  3407. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3408. var VERTICAL_PADDING = 5;
  3409. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3410. var PresentationModeState = {
  3411. UNKNOWN: 0,
  3412. NORMAL: 1,
  3413. CHANGING: 2,
  3414. FULLSCREEN: 3
  3415. };
  3416. exports.PresentationModeState = PresentationModeState;
  3417. var RendererType = {
  3418. CANVAS: 'canvas',
  3419. SVG: 'svg'
  3420. };
  3421. exports.RendererType = RendererType;
  3422. var TextLayerMode = {
  3423. DISABLE: 0,
  3424. ENABLE: 1,
  3425. ENABLE_ENHANCE: 2
  3426. };
  3427. exports.TextLayerMode = TextLayerMode;
  3428. var ScrollMode = {
  3429. UNKNOWN: -1,
  3430. VERTICAL: 0,
  3431. HORIZONTAL: 1,
  3432. WRAPPED: 2
  3433. };
  3434. exports.ScrollMode = ScrollMode;
  3435. var SpreadMode = {
  3436. UNKNOWN: -1,
  3437. NONE: 0,
  3438. ODD: 1,
  3439. EVEN: 2
  3440. };
  3441. exports.SpreadMode = SpreadMode;
  3442. function formatL10nValue(text, args) {
  3443. if (!args) {
  3444. return text;
  3445. }
  3446. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) {
  3447. return name in args ? args[name] : '{{' + name + '}}';
  3448. });
  3449. }
  3450. var NullL10n = {
  3451. getLanguage: function() {
  3452. var _getLanguage = _asyncToGenerator(
  3453. /*#__PURE__*/
  3454. _regenerator["default"].mark(function _callee() {
  3455. return _regenerator["default"].wrap(function _callee$(_context) {
  3456. while (1) {
  3457. switch (_context.prev = _context.next) {
  3458. case 0:
  3459. return _context.abrupt("return", 'en-us');
  3460. case 1:
  3461. case "end":
  3462. return _context.stop();
  3463. }
  3464. }
  3465. }, _callee);
  3466. }));
  3467. function getLanguage() {
  3468. return _getLanguage.apply(this, arguments);
  3469. }
  3470. return getLanguage;
  3471. }(),
  3472. getDirection: function() {
  3473. var _getDirection = _asyncToGenerator(
  3474. /*#__PURE__*/
  3475. _regenerator["default"].mark(function _callee2() {
  3476. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3477. while (1) {
  3478. switch (_context2.prev = _context2.next) {
  3479. case 0:
  3480. return _context2.abrupt("return", 'ltr');
  3481. case 1:
  3482. case "end":
  3483. return _context2.stop();
  3484. }
  3485. }
  3486. }, _callee2);
  3487. }));
  3488. function getDirection() {
  3489. return _getDirection.apply(this, arguments);
  3490. }
  3491. return getDirection;
  3492. }(),
  3493. get: function() {
  3494. var _get = _asyncToGenerator(
  3495. /*#__PURE__*/
  3496. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  3497. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3498. while (1) {
  3499. switch (_context3.prev = _context3.next) {
  3500. case 0:
  3501. return _context3.abrupt("return",
  3502. formatL10nValue(fallback, args));
  3503. case 1:
  3504. case "end":
  3505. return _context3.stop();
  3506. }
  3507. }
  3508. }, _callee3);
  3509. }));
  3510. function get(_x, _x2, _x3) {
  3511. return _get.apply(this, arguments);
  3512. }
  3513. return get;
  3514. }(),
  3515. translate: function() {
  3516. var _translate = _asyncToGenerator(
  3517. /*#__PURE__*/
  3518. _regenerator["default"].mark(function _callee4(element) {
  3519. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3520. while (1) {
  3521. switch (_context4.prev = _context4.next) {
  3522. case 0:
  3523. case "end":
  3524. return _context4.stop();
  3525. }
  3526. }
  3527. }, _callee4);
  3528. }));
  3529. function translate(_x4) {
  3530. return _translate.apply(this, arguments);
  3531. }
  3532. return translate;
  3533. }()
  3534. };
  3535. exports.NullL10n = NullL10n;
  3536. function getOutputScale(ctx) {
  3537. var devicePixelRatio = window.devicePixelRatio || 1;
  3538. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx
  3539. .msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3540. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3541. return {
  3542. sx: pixelRatio,
  3543. sy: pixelRatio,
  3544. scaled: pixelRatio !== 1
  3545. };
  3546. }
  3547. function scrollIntoView(element, spot) {
  3548. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
  3549. false;
  3550. var parent = element.offsetParent;
  3551. if (!parent) {
  3552. console.error('offsetParent is not set -- cannot scroll');
  3553. return;
  3554. }
  3555. var offsetY = element.offsetTop + element.clientTop;
  3556. var offsetX = element.offsetLeft + element.clientLeft;
  3557. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth ||
  3558. skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  3559. if (parent.dataset._scaleY) {
  3560. offsetY /= parent.dataset._scaleY;
  3561. offsetX /= parent.dataset._scaleX;
  3562. }
  3563. offsetY += parent.offsetTop;
  3564. offsetX += parent.offsetLeft;
  3565. parent = parent.offsetParent;
  3566. if (!parent) {
  3567. return;
  3568. }
  3569. }
  3570. if (spot) {
  3571. if (spot.top !== undefined) {
  3572. offsetY += spot.top;
  3573. }
  3574. if (spot.left !== undefined) {
  3575. offsetX += spot.left;
  3576. parent.scrollLeft = offsetX;
  3577. }
  3578. }
  3579. parent.scrollTop = offsetY;
  3580. }
  3581. function watchScroll(viewAreaElement, callback) {
  3582. var debounceScroll = function debounceScroll(evt) {
  3583. if (rAF) {
  3584. return;
  3585. }
  3586. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3587. rAF = null;
  3588. var currentX = viewAreaElement.scrollLeft;
  3589. var lastX = state.lastX;
  3590. if (currentX !== lastX) {
  3591. state.right = currentX > lastX;
  3592. }
  3593. state.lastX = currentX;
  3594. var currentY = viewAreaElement.scrollTop;
  3595. var lastY = state.lastY;
  3596. if (currentY !== lastY) {
  3597. state.down = currentY > lastY;
  3598. }
  3599. state.lastY = currentY;
  3600. callback(state);
  3601. });
  3602. };
  3603. var state = {
  3604. right: true,
  3605. down: true,
  3606. lastX: viewAreaElement.scrollLeft,
  3607. lastY: viewAreaElement.scrollTop,
  3608. _eventHandler: debounceScroll
  3609. };
  3610. var rAF = null;
  3611. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  3612. return state;
  3613. }
  3614. function parseQueryString(query) {
  3615. var parts = query.split('&');
  3616. var params = Object.create(null);
  3617. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3618. var param = parts[i].split('=');
  3619. var key = param[0].toLowerCase();
  3620. var value = param.length > 1 ? param[1] : null;
  3621. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3622. }
  3623. return params;
  3624. }
  3625. function binarySearchFirstItem(items, condition) {
  3626. var minIndex = 0;
  3627. var maxIndex = items.length - 1;
  3628. if (items.length === 0 || !condition(items[maxIndex])) {
  3629. return items.length;
  3630. }
  3631. if (condition(items[minIndex])) {
  3632. return minIndex;
  3633. }
  3634. while (minIndex < maxIndex) {
  3635. var currentIndex = minIndex + maxIndex >> 1;
  3636. var currentItem = items[currentIndex];
  3637. if (condition(currentItem)) {
  3638. maxIndex = currentIndex;
  3639. } else {
  3640. minIndex = currentIndex + 1;
  3641. }
  3642. }
  3643. return minIndex;
  3644. }
  3645. function approximateFraction(x) {
  3646. if (Math.floor(x) === x) {
  3647. return [x, 1];
  3648. }
  3649. var xinv = 1 / x;
  3650. var limit = 8;
  3651. if (xinv > limit) {
  3652. return [1, limit];
  3653. } else if (Math.floor(xinv) === xinv) {
  3654. return [1, xinv];
  3655. }
  3656. var x_ = x > 1 ? xinv : x;
  3657. var a = 0,
  3658. b = 1,
  3659. c = 1,
  3660. d = 1;
  3661. while (true) {
  3662. var p = a + c,
  3663. q = b + d;
  3664. if (q > limit) {
  3665. break;
  3666. }
  3667. if (x_ <= p / q) {
  3668. c = p;
  3669. d = q;
  3670. } else {
  3671. a = p;
  3672. b = q;
  3673. }
  3674. }
  3675. var result;
  3676. if (x_ - a / b < c / d - x_) {
  3677. result = x_ === x ? [a, b] : [b, a];
  3678. } else {
  3679. result = x_ === x ? [c, d] : [d, c];
  3680. }
  3681. return result;
  3682. }
  3683. function roundToDivide(x, div) {
  3684. var r = x % div;
  3685. return r === 0 ? x : Math.round(x - r + div);
  3686. }
  3687. function getPageSizeInches(_ref) {
  3688. var view = _ref.view,
  3689. userUnit = _ref.userUnit,
  3690. rotate = _ref.rotate;
  3691. var _view = _slicedToArray(view, 4),
  3692. x1 = _view[0],
  3693. y1 = _view[1],
  3694. x2 = _view[2],
  3695. y2 = _view[3];
  3696. var changeOrientation = rotate % 180 !== 0;
  3697. var width = (x2 - x1) / 72 * userUnit;
  3698. var height = (y2 - y1) / 72 * userUnit;
  3699. return {
  3700. width: changeOrientation ? height : width,
  3701. height: changeOrientation ? width : height
  3702. };
  3703. }
  3704. function backtrackBeforeAllVisibleElements(index, views, top) {
  3705. if (index < 2) {
  3706. return index;
  3707. }
  3708. var elt = views[index].div;
  3709. var pageTop = elt.offsetTop + elt.clientTop;
  3710. if (pageTop >= top) {
  3711. elt = views[index - 1].div;
  3712. pageTop = elt.offsetTop + elt.clientTop;
  3713. }
  3714. for (var i = index - 2; i >= 0; --i) {
  3715. elt = views[i].div;
  3716. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3717. break;
  3718. }
  3719. index = i;
  3720. }
  3721. return index;
  3722. }
  3723. function getVisibleElements(scrollEl, views) {
  3724. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3725. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3726. var top = scrollEl.scrollTop,
  3727. bottom = top + scrollEl.clientHeight;
  3728. var left = scrollEl.scrollLeft,
  3729. right = left + scrollEl.clientWidth;
  3730. function isElementBottomAfterViewTop(view) {
  3731. var element = view.div;
  3732. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3733. return elementBottom > top;
  3734. }
  3735. function isElementRightAfterViewLeft(view) {
  3736. var element = view.div;
  3737. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3738. return elementRight > left;
  3739. }
  3740. var visible = [],
  3741. numViews = views.length;
  3742. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ?
  3743. isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3744. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3745. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3746. }
  3747. var lastEdge = horizontal ? right : -1;
  3748. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3749. var view = views[i],
  3750. element = view.div;
  3751. var currentWidth = element.offsetLeft + element.clientLeft;
  3752. var currentHeight = element.offsetTop + element.clientTop;
  3753. var viewWidth = element.clientWidth,
  3754. viewHeight = element.clientHeight;
  3755. var viewRight = currentWidth + viewWidth;
  3756. var viewBottom = currentHeight + viewHeight;
  3757. if (lastEdge === -1) {
  3758. if (viewBottom >= bottom) {
  3759. lastEdge = viewBottom;
  3760. }
  3761. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3762. break;
  3763. }
  3764. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >=
  3765. right) {
  3766. continue;
  3767. }
  3768. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3769. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3770. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight /
  3771. viewWidth | 0;
  3772. visible.push({
  3773. id: view.id,
  3774. x: currentWidth,
  3775. y: currentHeight,
  3776. view: view,
  3777. percent: percent
  3778. });
  3779. }
  3780. var first = visible[0],
  3781. last = visible[visible.length - 1];
  3782. if (sortByVisibility) {
  3783. visible.sort(function(a, b) {
  3784. var pc = a.percent - b.percent;
  3785. if (Math.abs(pc) > 0.001) {
  3786. return -pc;
  3787. }
  3788. return a.id - b.id;
  3789. });
  3790. }
  3791. return {
  3792. first: first,
  3793. last: last,
  3794. views: visible
  3795. };
  3796. }
  3797. function noContextMenuHandler(evt) {
  3798. evt.preventDefault();
  3799. }
  3800. function isDataSchema(url) {
  3801. var i = 0,
  3802. ii = url.length;
  3803. while (i < ii && url[i].trim() === '') {
  3804. i++;
  3805. }
  3806. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3807. }
  3808. function getPDFFileNameFromURL(url) {
  3809. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  3810. 'document.pdf';
  3811. if (typeof url !== 'string') {
  3812. return defaultFilename;
  3813. }
  3814. if (isDataSchema(url)) {
  3815. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3816. return defaultFilename;
  3817. }
  3818. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3819. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3820. var splitURI = reURI.exec(url);
  3821. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename
  3822. .exec(splitURI[3]);
  3823. if (suggestedFilename) {
  3824. suggestedFilename = suggestedFilename[0];
  3825. if (suggestedFilename.includes('%')) {
  3826. try {
  3827. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3828. } catch (ex) {}
  3829. }
  3830. }
  3831. return suggestedFilename || defaultFilename;
  3832. }
  3833. function normalizeWheelEventDelta(evt) {
  3834. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3835. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3836. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3837. delta = -delta;
  3838. }
  3839. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3840. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3841. var MOUSE_PIXELS_PER_LINE = 30;
  3842. var MOUSE_LINES_PER_PAGE = 30;
  3843. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3844. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3845. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3846. delta /= MOUSE_LINES_PER_PAGE;
  3847. }
  3848. return delta;
  3849. }
  3850. function isValidRotation(angle) {
  3851. return Number.isInteger(angle) && angle % 90 === 0;
  3852. }
  3853. function isValidScrollMode(mode) {
  3854. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode
  3855. .UNKNOWN;
  3856. }
  3857. function isValidSpreadMode(mode) {
  3858. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode
  3859. .UNKNOWN;
  3860. }
  3861. function isPortraitOrientation(size) {
  3862. return size.width <= size.height;
  3863. }
  3864. var WaitOnType = {
  3865. EVENT: 'event',
  3866. TIMEOUT: 'timeout'
  3867. };
  3868. exports.WaitOnType = WaitOnType;
  3869. function waitOnEventOrTimeout(_ref2) {
  3870. var target = _ref2.target,
  3871. name = _ref2.name,
  3872. _ref2$delay = _ref2.delay,
  3873. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3874. return new Promise(function(resolve, reject) {
  3875. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number
  3876. .isInteger(delay) && delay >= 0)) {
  3877. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3878. }
  3879. function handler(type) {
  3880. if (target instanceof EventBus) {
  3881. target.off(name, eventHandler);
  3882. } else {
  3883. target.removeEventListener(name, eventHandler);
  3884. }
  3885. if (timeout) {
  3886. clearTimeout(timeout);
  3887. }
  3888. resolve(type);
  3889. }
  3890. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3891. if (target instanceof EventBus) {
  3892. target.on(name, eventHandler);
  3893. } else {
  3894. target.addEventListener(name, eventHandler);
  3895. }
  3896. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3897. var timeout = setTimeout(timeoutHandler, delay);
  3898. });
  3899. }
  3900. var animationStarted = new Promise(function(resolve) {
  3901. window.requestAnimationFrame(resolve);
  3902. });
  3903. exports.animationStarted = animationStarted;
  3904. var EventBus =
  3905. /*#__PURE__*/
  3906. function() {
  3907. function EventBus() {
  3908. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3909. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  3910. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  3911. _classCallCheck(this, EventBus);
  3912. this._listeners = Object.create(null);
  3913. this._dispatchToDOM = dispatchToDOM === true;
  3914. }
  3915. _createClass(EventBus, [{
  3916. key: "on",
  3917. value: function on(eventName, listener) {
  3918. var eventListeners = this._listeners[eventName];
  3919. if (!eventListeners) {
  3920. eventListeners = [];
  3921. this._listeners[eventName] = eventListeners;
  3922. }
  3923. eventListeners.push(listener);
  3924. }
  3925. }, {
  3926. key: "off",
  3927. value: function off(eventName, listener) {
  3928. var eventListeners = this._listeners[eventName];
  3929. var i;
  3930. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3931. return;
  3932. }
  3933. eventListeners.splice(i, 1);
  3934. }
  3935. }, {
  3936. key: "dispatch",
  3937. value: function dispatch(eventName) {
  3938. var eventListeners = this._listeners[eventName];
  3939. if (!eventListeners || eventListeners.length === 0) {
  3940. if (this._dispatchToDOM) {
  3941. var _args5 = Array.prototype.slice.call(arguments, 1);
  3942. this._dispatchDOMEvent(eventName, _args5);
  3943. }
  3944. return;
  3945. }
  3946. var args = Array.prototype.slice.call(arguments, 1);
  3947. eventListeners.slice(0).forEach(function(listener) {
  3948. listener.apply(null, args);
  3949. });
  3950. if (this._dispatchToDOM) {
  3951. this._dispatchDOMEvent(eventName, args);
  3952. }
  3953. }
  3954. }, {
  3955. key: "_dispatchDOMEvent",
  3956. value: function _dispatchDOMEvent(eventName) {
  3957. var args = arguments.length > 1 && arguments[1] !== undefined ?
  3958. arguments[1] : null;
  3959. var details = Object.create(null);
  3960. if (args && args.length > 0) {
  3961. var obj = args[0];
  3962. for (var key in obj) {
  3963. var value = obj[key];
  3964. if (key === 'source') {
  3965. if (value === window || value === document) {
  3966. return;
  3967. }
  3968. continue;
  3969. }
  3970. details[key] = value;
  3971. }
  3972. }
  3973. var event = document.createEvent('CustomEvent');
  3974. event.initCustomEvent(eventName, true, true, details);
  3975. document.dispatchEvent(event);
  3976. }
  3977. }]);
  3978. return EventBus;
  3979. }();
  3980. exports.EventBus = EventBus;
  3981. var globalEventBus = null;
  3982. function getGlobalEventBus() {
  3983. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3984. if (!globalEventBus) {
  3985. globalEventBus = new EventBus({
  3986. dispatchToDOM: dispatchToDOM
  3987. });
  3988. }
  3989. return globalEventBus;
  3990. }
  3991. function clamp(v, min, max) {
  3992. return Math.min(Math.max(v, min), max);
  3993. }
  3994. var ProgressBar =
  3995. /*#__PURE__*/
  3996. function() {
  3997. function ProgressBar(id) {
  3998. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3999. height = _ref4.height,
  4000. width = _ref4.width,
  4001. units = _ref4.units;
  4002. _classCallCheck(this, ProgressBar);
  4003. this.visible = true;
  4004. this.div = document.querySelector(id + ' .progress');
  4005. this.bar = this.div.parentNode;
  4006. this.height = height || 100;
  4007. this.width = width || 100;
  4008. this.units = units || '%';
  4009. this.div.style.height = this.height + this.units;
  4010. this.percent = 0;
  4011. }
  4012. _createClass(ProgressBar, [{
  4013. key: "_updateBar",
  4014. value: function _updateBar() {
  4015. if (this._indeterminate) {
  4016. this.div.classList.add('indeterminate');
  4017. this.div.style.width = this.width + this.units;
  4018. return;
  4019. }
  4020. this.div.classList.remove('indeterminate');
  4021. var progressSize = this.width * this._percent / 100;
  4022. this.div.style.width = progressSize + this.units;
  4023. }
  4024. }, {
  4025. key: "setWidth",
  4026. value: function setWidth(viewer) {
  4027. if (!viewer) {
  4028. return;
  4029. }
  4030. var container = viewer.parentNode;
  4031. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4032. if (scrollbarWidth > 0) {
  4033. this.bar.setAttribute('style', 'width: calc(100% - ' +
  4034. scrollbarWidth + 'px);');
  4035. }
  4036. }
  4037. }, {
  4038. key: "hide",
  4039. value: function hide() {
  4040. if (!this.visible) {
  4041. return;
  4042. }
  4043. this.visible = false;
  4044. this.bar.classList.add('hidden');
  4045. document.body.classList.remove('loadingInProgress');
  4046. }
  4047. }, {
  4048. key: "show",
  4049. value: function show() {
  4050. if (this.visible) {
  4051. return;
  4052. }
  4053. this.visible = true;
  4054. document.body.classList.add('loadingInProgress');
  4055. this.bar.classList.remove('hidden');
  4056. }
  4057. }, {
  4058. key: "percent",
  4059. get: function get() {
  4060. return this._percent;
  4061. },
  4062. set: function set(val) {
  4063. this._indeterminate = isNaN(val);
  4064. this._percent = clamp(val, 0, 100);
  4065. this._updateBar();
  4066. }
  4067. }]);
  4068. return ProgressBar;
  4069. }();
  4070. exports.ProgressBar = ProgressBar;
  4071. function moveToEndOfArray(arr, condition) {
  4072. var moved = [],
  4073. len = arr.length;
  4074. var write = 0;
  4075. for (var read = 0; read < len; ++read) {
  4076. if (condition(arr[read])) {
  4077. moved.push(arr[read]);
  4078. } else {
  4079. arr[write] = arr[read];
  4080. ++write;
  4081. }
  4082. }
  4083. for (var _read = 0; write < len; ++_read, ++write) {
  4084. arr[write] = moved[_read];
  4085. }
  4086. }
  4087. /***/
  4088. }),
  4089. /* 6 */
  4090. /***/
  4091. (function(module, exports, __webpack_require__) {
  4092. "use strict";
  4093. Object.defineProperty(exports, "__esModule", {
  4094. value: true
  4095. });
  4096. exports.OptionKind = exports.AppOptions = void 0;
  4097. var _pdfjsLib = __webpack_require__(7);
  4098. var _viewer_compatibility = __webpack_require__(8);
  4099. function _typeof(obj) {
  4100. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  4101. _typeof = function _typeof(obj) {
  4102. return typeof obj;
  4103. };
  4104. } else {
  4105. _typeof = function _typeof(obj) {
  4106. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  4107. Symbol.prototype ? "symbol" : typeof obj;
  4108. };
  4109. }
  4110. return _typeof(obj);
  4111. }
  4112. function _classCallCheck(instance, Constructor) {
  4113. if (!(instance instanceof Constructor)) {
  4114. throw new TypeError("Cannot call a class as a function");
  4115. }
  4116. }
  4117. function _defineProperties(target, props) {
  4118. for (var i = 0; i < props.length; i++) {
  4119. var descriptor = props[i];
  4120. descriptor.enumerable = descriptor.enumerable || false;
  4121. descriptor.configurable = true;
  4122. if ("value" in descriptor) descriptor.writable = true;
  4123. Object.defineProperty(target, descriptor.key, descriptor);
  4124. }
  4125. }
  4126. function _createClass(Constructor, protoProps, staticProps) {
  4127. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4128. if (staticProps) _defineProperties(Constructor, staticProps);
  4129. return Constructor;
  4130. }
  4131. var OptionKind = {
  4132. VIEWER: 0x02,
  4133. API: 0x04,
  4134. WORKER: 0x08,
  4135. PREFERENCE: 0x80
  4136. };
  4137. exports.OptionKind = OptionKind;
  4138. var defaultOptions = {
  4139. cursorToolOnLoad: {
  4140. value: 0,
  4141. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4142. },
  4143. defaultUrl: {
  4144. value: 'compressed.tracemonkey-pldi-09.pdf',
  4145. kind: OptionKind.VIEWER
  4146. },
  4147. defaultZoomValue: {
  4148. value: '',
  4149. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4150. },
  4151. disableHistory: {
  4152. value: false,
  4153. kind: OptionKind.VIEWER
  4154. },
  4155. disablePageLabels: {
  4156. value: false,
  4157. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4158. },
  4159. enablePrintAutoRotate: {
  4160. value: false,
  4161. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4162. },
  4163. enableWebGL: {
  4164. value: false,
  4165. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4166. },
  4167. eventBusDispatchToDOM: {
  4168. value: false,
  4169. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4170. },
  4171. externalLinkRel: {
  4172. value: 'noopener noreferrer nofollow',
  4173. kind: OptionKind.VIEWER
  4174. },
  4175. externalLinkTarget: {
  4176. value: 0,
  4177. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4178. },
  4179. historyUpdateUrl: {
  4180. value: false,
  4181. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4182. },
  4183. imageResourcesPath: {
  4184. value: './images/',
  4185. kind: OptionKind.VIEWER
  4186. },
  4187. maxCanvasPixels: {
  4188. value: 16777216,
  4189. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  4190. kind: OptionKind.VIEWER
  4191. },
  4192. pdfBugEnabled: {
  4193. value: false,
  4194. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4195. },
  4196. renderer: {
  4197. value: 'canvas',
  4198. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4199. },
  4200. renderInteractiveForms: {
  4201. value: false,
  4202. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4203. },
  4204. sidebarViewOnLoad: {
  4205. value: -1,
  4206. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4207. },
  4208. scrollModeOnLoad: {
  4209. value: -1,
  4210. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4211. },
  4212. spreadModeOnLoad: {
  4213. value: -1,
  4214. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4215. },
  4216. textLayerMode: {
  4217. value: 1,
  4218. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4219. },
  4220. useOnlyCssZoom: {
  4221. value: false,
  4222. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4223. },
  4224. viewOnLoad: {
  4225. value: 0,
  4226. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4227. },
  4228. cMapPacked: {
  4229. value: true,
  4230. kind: OptionKind.API
  4231. },
  4232. cMapUrl: {
  4233. value: '../web/cmaps/',
  4234. kind: OptionKind.API
  4235. },
  4236. disableAutoFetch: {
  4237. value: false,
  4238. kind: OptionKind.API + OptionKind.PREFERENCE
  4239. },
  4240. disableCreateObjectURL: {
  4241. value: false,
  4242. compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
  4243. kind: OptionKind.API
  4244. },
  4245. disableFontFace: {
  4246. value: false,
  4247. kind: OptionKind.API + OptionKind.PREFERENCE
  4248. },
  4249. disableRange: {
  4250. value: false,
  4251. kind: OptionKind.API + OptionKind.PREFERENCE
  4252. },
  4253. disableStream: {
  4254. value: false,
  4255. kind: OptionKind.API + OptionKind.PREFERENCE
  4256. },
  4257. docBaseUrl: {
  4258. value: '',
  4259. kind: OptionKind.API
  4260. },
  4261. isEvalSupported: {
  4262. value: true,
  4263. kind: OptionKind.API
  4264. },
  4265. maxImageSize: {
  4266. value: -1,
  4267. kind: OptionKind.API
  4268. },
  4269. pdfBug: {
  4270. value: false,
  4271. kind: OptionKind.API
  4272. },
  4273. verbosity: {
  4274. value: 1,
  4275. kind: OptionKind.API
  4276. },
  4277. workerPort: {
  4278. value: null,
  4279. kind: OptionKind.WORKER
  4280. },
  4281. workerSrc: {
  4282. value: '../build/pdf.worker.js',
  4283. kind: OptionKind.WORKER
  4284. }
  4285. }; {
  4286. defaultOptions.disablePreferences = {
  4287. value: false,
  4288. kind: OptionKind.VIEWER
  4289. };
  4290. defaultOptions.locale = {
  4291. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  4292. kind: OptionKind.VIEWER
  4293. };
  4294. defaultOptions.printResolution = {
  4295. value: 150,
  4296. kind: OptionKind.VIEWER
  4297. };
  4298. }
  4299. var userOptions = Object.create(null);
  4300. var AppOptions =
  4301. /*#__PURE__*/
  4302. function() {
  4303. function AppOptions() {
  4304. _classCallCheck(this, AppOptions);
  4305. throw new Error('Cannot initialize AppOptions.');
  4306. }
  4307. _createClass(AppOptions, null, [{
  4308. key: "get",
  4309. value: function get(name) {
  4310. var userOption = userOptions[name];
  4311. if (userOption !== undefined) {
  4312. return userOption;
  4313. }
  4314. var defaultOption = defaultOptions[name];
  4315. if (defaultOption !== undefined) {
  4316. return defaultOption.compatibility || defaultOption.value;
  4317. }
  4318. return undefined;
  4319. }
  4320. }, {
  4321. key: "getAll",
  4322. value: function getAll() {
  4323. var kind = arguments.length > 0 && arguments[0] !== undefined ?
  4324. arguments[0] : null;
  4325. var options = Object.create(null);
  4326. for (var name in defaultOptions) {
  4327. var defaultOption = defaultOptions[name];
  4328. if (kind) {
  4329. if ((kind & defaultOption.kind) === 0) {
  4330. continue;
  4331. }
  4332. if (kind === OptionKind.PREFERENCE) {
  4333. var value = defaultOption.value,
  4334. valueType = _typeof(value);
  4335. if (valueType === 'boolean' || valueType === 'string' ||
  4336. valueType === 'number' && Number.isInteger(value)) {
  4337. options[name] = value;
  4338. continue;
  4339. }
  4340. throw new Error("Invalid type for preference: ".concat(
  4341. name));
  4342. }
  4343. }
  4344. var userOption = userOptions[name];
  4345. options[name] = userOption !== undefined ? userOption :
  4346. defaultOption.compatibility || defaultOption.value;
  4347. }
  4348. return options;
  4349. }
  4350. }, {
  4351. key: "set",
  4352. value: function set(name, value) {
  4353. userOptions[name] = value;
  4354. }
  4355. }, {
  4356. key: "remove",
  4357. value: function remove(name) {
  4358. delete userOptions[name];
  4359. }
  4360. }]);
  4361. return AppOptions;
  4362. }();
  4363. exports.AppOptions = AppOptions;
  4364. /***/
  4365. }),
  4366. /* 7 */
  4367. /***/
  4368. (function(module, exports, __webpack_require__) {
  4369. "use strict";
  4370. var pdfjsLib;
  4371. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  4372. pdfjsLib = window['pdfjs-dist/build/pdf'];
  4373. } else {
  4374. pdfjsLib = require('../build/pdf.js');
  4375. }
  4376. module.exports = pdfjsLib;
  4377. /***/
  4378. }),
  4379. /* 8 */
  4380. /***/
  4381. (function(module, exports, __webpack_require__) {
  4382. "use strict";
  4383. var compatibilityParams = Object.create(null); {
  4384. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4385. var isAndroid = /Android/.test(userAgent);
  4386. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4387. (function checkCanvasSizeLimitation() {
  4388. if (isIOS || isAndroid) {
  4389. compatibilityParams.maxCanvasPixels = 5242880;
  4390. }
  4391. })();
  4392. }
  4393. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4394. /***/
  4395. }),
  4396. /* 9 */
  4397. /***/
  4398. (function(module, exports, __webpack_require__) {
  4399. "use strict";
  4400. Object.defineProperty(exports, "__esModule", {
  4401. value: true
  4402. });
  4403. exports.PDFCursorTools = exports.CursorTool = void 0;
  4404. var _grab_to_pan = __webpack_require__(10);
  4405. function _classCallCheck(instance, Constructor) {
  4406. if (!(instance instanceof Constructor)) {
  4407. throw new TypeError("Cannot call a class as a function");
  4408. }
  4409. }
  4410. function _defineProperties(target, props) {
  4411. for (var i = 0; i < props.length; i++) {
  4412. var descriptor = props[i];
  4413. descriptor.enumerable = descriptor.enumerable || false;
  4414. descriptor.configurable = true;
  4415. if ("value" in descriptor) descriptor.writable = true;
  4416. Object.defineProperty(target, descriptor.key, descriptor);
  4417. }
  4418. }
  4419. function _createClass(Constructor, protoProps, staticProps) {
  4420. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4421. if (staticProps) _defineProperties(Constructor, staticProps);
  4422. return Constructor;
  4423. }
  4424. var CursorTool = {
  4425. SELECT: 0,
  4426. HAND: 1,
  4427. ZOOM: 2
  4428. };
  4429. exports.CursorTool = CursorTool;
  4430. var PDFCursorTools =
  4431. /*#__PURE__*/
  4432. function() {
  4433. function PDFCursorTools(_ref) {
  4434. var _this = this;
  4435. var container = _ref.container,
  4436. eventBus = _ref.eventBus,
  4437. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4438. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT :
  4439. _ref$cursorToolOnLoad;
  4440. _classCallCheck(this, PDFCursorTools);
  4441. this.container = container;
  4442. this.eventBus = eventBus;
  4443. this.active = CursorTool.SELECT;
  4444. this.activeBeforePresentationMode = null;
  4445. this.handTool = new _grab_to_pan.GrabToPan({
  4446. element: this.container
  4447. });
  4448. this._addEventListeners();
  4449. Promise.resolve().then(function() {
  4450. _this.switchTool(cursorToolOnLoad);
  4451. });
  4452. }
  4453. _createClass(PDFCursorTools, [{
  4454. key: "switchTool",
  4455. value: function switchTool(tool) {
  4456. var _this2 = this;
  4457. if (this.activeBeforePresentationMode !== null) {
  4458. return;
  4459. }
  4460. if (tool === this.active) {
  4461. return;
  4462. }
  4463. var disableActiveTool = function disableActiveTool() {
  4464. switch (_this2.active) {
  4465. case CursorTool.SELECT:
  4466. break;
  4467. case CursorTool.HAND:
  4468. _this2.handTool.deactivate();
  4469. break;
  4470. case CursorTool.ZOOM:
  4471. }
  4472. };
  4473. switch (tool) {
  4474. case CursorTool.SELECT:
  4475. disableActiveTool();
  4476. break;
  4477. case CursorTool.HAND:
  4478. disableActiveTool();
  4479. this.handTool.activate();
  4480. break;
  4481. case CursorTool.ZOOM:
  4482. default:
  4483. console.error("switchTool: \"".concat(tool,
  4484. "\" is an unsupported value."));
  4485. return;
  4486. }
  4487. this.active = tool;
  4488. this._dispatchEvent();
  4489. }
  4490. }, {
  4491. key: "_dispatchEvent",
  4492. value: function _dispatchEvent() {
  4493. this.eventBus.dispatch('cursortoolchanged', {
  4494. source: this,
  4495. tool: this.active
  4496. });
  4497. }
  4498. }, {
  4499. key: "_addEventListeners",
  4500. value: function _addEventListeners() {
  4501. var _this3 = this;
  4502. this.eventBus.on('switchcursortool', function(evt) {
  4503. _this3.switchTool(evt.tool);
  4504. });
  4505. this.eventBus.on('presentationmodechanged', function(evt) {
  4506. if (evt.switchInProgress) {
  4507. return;
  4508. }
  4509. var previouslyActive;
  4510. if (evt.active) {
  4511. previouslyActive = _this3.active;
  4512. _this3.switchTool(CursorTool.SELECT);
  4513. _this3.activeBeforePresentationMode = previouslyActive;
  4514. } else {
  4515. previouslyActive = _this3.activeBeforePresentationMode;
  4516. _this3.activeBeforePresentationMode = null;
  4517. _this3.switchTool(previouslyActive);
  4518. }
  4519. });
  4520. }
  4521. }, {
  4522. key: "activeTool",
  4523. get: function get() {
  4524. return this.active;
  4525. }
  4526. }]);
  4527. return PDFCursorTools;
  4528. }();
  4529. exports.PDFCursorTools = PDFCursorTools;
  4530. /***/
  4531. }),
  4532. /* 10 */
  4533. /***/
  4534. (function(module, exports, __webpack_require__) {
  4535. "use strict";
  4536. Object.defineProperty(exports, "__esModule", {
  4537. value: true
  4538. });
  4539. exports.GrabToPan = GrabToPan;
  4540. function GrabToPan(options) {
  4541. this.element = options.element;
  4542. this.document = options.element.ownerDocument;
  4543. if (typeof options.ignoreTarget === 'function') {
  4544. this.ignoreTarget = options.ignoreTarget;
  4545. }
  4546. this.onActiveChanged = options.onActiveChanged;
  4547. this.activate = this.activate.bind(this);
  4548. this.deactivate = this.deactivate.bind(this);
  4549. this.toggle = this.toggle.bind(this);
  4550. this._onmousedown = this._onmousedown.bind(this);
  4551. this._onmousemove = this._onmousemove.bind(this);
  4552. this._endPan = this._endPan.bind(this);
  4553. var overlay = this.overlay = document.createElement('div');
  4554. overlay.className = 'grab-to-pan-grabbing';
  4555. }
  4556. GrabToPan.prototype = {
  4557. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  4558. activate: function GrabToPan_activate() {
  4559. if (!this.active) {
  4560. this.active = true;
  4561. this.element.addEventListener('mousedown', this._onmousedown, true);
  4562. this.element.classList.add(this.CSS_CLASS_GRAB);
  4563. if (this.onActiveChanged) {
  4564. this.onActiveChanged(true);
  4565. }
  4566. }
  4567. },
  4568. deactivate: function GrabToPan_deactivate() {
  4569. if (this.active) {
  4570. this.active = false;
  4571. this.element.removeEventListener('mousedown', this._onmousedown, true);
  4572. this._endPan();
  4573. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4574. if (this.onActiveChanged) {
  4575. this.onActiveChanged(false);
  4576. }
  4577. }
  4578. },
  4579. toggle: function GrabToPan_toggle() {
  4580. if (this.active) {
  4581. this.deactivate();
  4582. } else {
  4583. this.activate();
  4584. }
  4585. },
  4586. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4587. return node[matchesSelector](
  4588. 'a[href], a[href] *, input, textarea, button, button *, select, option');
  4589. },
  4590. _onmousedown: function GrabToPan__onmousedown(event) {
  4591. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4592. return;
  4593. }
  4594. if (event.originalTarget) {
  4595. try {
  4596. event.originalTarget.tagName;
  4597. } catch (e) {
  4598. return;
  4599. }
  4600. }
  4601. this.scrollLeftStart = this.element.scrollLeft;
  4602. this.scrollTopStart = this.element.scrollTop;
  4603. this.clientXStart = event.clientX;
  4604. this.clientYStart = event.clientY;
  4605. this.document.addEventListener('mousemove', this._onmousemove, true);
  4606. this.document.addEventListener('mouseup', this._endPan, true);
  4607. this.element.addEventListener('scroll', this._endPan, true);
  4608. event.preventDefault();
  4609. event.stopPropagation();
  4610. var focusedElement = document.activeElement;
  4611. if (focusedElement && !focusedElement.contains(event.target)) {
  4612. focusedElement.blur();
  4613. }
  4614. },
  4615. _onmousemove: function GrabToPan__onmousemove(event) {
  4616. this.element.removeEventListener('scroll', this._endPan, true);
  4617. if (isLeftMouseReleased(event)) {
  4618. this._endPan();
  4619. return;
  4620. }
  4621. var xDiff = event.clientX - this.clientXStart;
  4622. var yDiff = event.clientY - this.clientYStart;
  4623. var scrollTop = this.scrollTopStart - yDiff;
  4624. var scrollLeft = this.scrollLeftStart - xDiff;
  4625. if (this.element.scrollTo) {
  4626. this.element.scrollTo({
  4627. top: scrollTop,
  4628. left: scrollLeft,
  4629. behavior: 'instant'
  4630. });
  4631. } else {
  4632. this.element.scrollTop = scrollTop;
  4633. this.element.scrollLeft = scrollLeft;
  4634. }
  4635. if (!this.overlay.parentNode) {
  4636. document.body.appendChild(this.overlay);
  4637. }
  4638. },
  4639. _endPan: function GrabToPan__endPan() {
  4640. this.element.removeEventListener('scroll', this._endPan, true);
  4641. this.document.removeEventListener('mousemove', this._onmousemove, true);
  4642. this.document.removeEventListener('mouseup', this._endPan, true);
  4643. this.overlay.remove();
  4644. }
  4645. };
  4646. var matchesSelector;
  4647. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function(prefix) {
  4648. var name = prefix + 'atches';
  4649. if (name in document.documentElement) {
  4650. matchesSelector = name;
  4651. }
  4652. name += 'Selector';
  4653. if (name in document.documentElement) {
  4654. matchesSelector = name;
  4655. }
  4656. return matchesSelector;
  4657. });
  4658. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4659. var chrome = window.chrome;
  4660. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4661. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator
  4662. .userAgent);
  4663. function isLeftMouseReleased(event) {
  4664. if ('buttons' in event && isNotIEorIsIE10plus) {
  4665. return !(event.buttons & 1);
  4666. }
  4667. if (isChrome15OrOpera15plus || isSafari6plus) {
  4668. return event.which === 0;
  4669. }
  4670. return false;
  4671. }
  4672. /***/
  4673. }),
  4674. /* 11 */
  4675. /***/
  4676. (function(module, exports, __webpack_require__) {
  4677. "use strict";
  4678. Object.defineProperty(exports, "__esModule", {
  4679. value: true
  4680. });
  4681. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4682. function _classCallCheck(instance, Constructor) {
  4683. if (!(instance instanceof Constructor)) {
  4684. throw new TypeError("Cannot call a class as a function");
  4685. }
  4686. }
  4687. function _defineProperties(target, props) {
  4688. for (var i = 0; i < props.length; i++) {
  4689. var descriptor = props[i];
  4690. descriptor.enumerable = descriptor.enumerable || false;
  4691. descriptor.configurable = true;
  4692. if ("value" in descriptor) descriptor.writable = true;
  4693. Object.defineProperty(target, descriptor.key, descriptor);
  4694. }
  4695. }
  4696. function _createClass(Constructor, protoProps, staticProps) {
  4697. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4698. if (staticProps) _defineProperties(Constructor, staticProps);
  4699. return Constructor;
  4700. }
  4701. var CLEANUP_TIMEOUT = 30000;
  4702. var RenderingStates = {
  4703. INITIAL: 0,
  4704. RUNNING: 1,
  4705. PAUSED: 2,
  4706. FINISHED: 3
  4707. };
  4708. exports.RenderingStates = RenderingStates;
  4709. var PDFRenderingQueue =
  4710. /*#__PURE__*/
  4711. function() {
  4712. function PDFRenderingQueue() {
  4713. _classCallCheck(this, PDFRenderingQueue);
  4714. this.pdfViewer = null;
  4715. this.pdfThumbnailViewer = null;
  4716. this.onIdle = null;
  4717. this.highestPriorityPage = null;
  4718. this.idleTimeout = null;
  4719. this.printing = false;
  4720. this.isThumbnailViewEnabled = false;
  4721. }
  4722. _createClass(PDFRenderingQueue, [{
  4723. key: "setViewer",
  4724. value: function setViewer(pdfViewer) {
  4725. this.pdfViewer = pdfViewer;
  4726. }
  4727. }, {
  4728. key: "setThumbnailViewer",
  4729. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4730. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4731. }
  4732. }, {
  4733. key: "isHighestPriority",
  4734. value: function isHighestPriority(view) {
  4735. return this.highestPriorityPage === view.renderingId;
  4736. }
  4737. }, {
  4738. key: "renderHighestPriority",
  4739. value: function renderHighestPriority(currentlyVisiblePages) {
  4740. if (this.idleTimeout) {
  4741. clearTimeout(this.idleTimeout);
  4742. this.idleTimeout = null;
  4743. }
  4744. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4745. return;
  4746. }
  4747. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4748. if (this.pdfThumbnailViewer.forceRendering()) {
  4749. return;
  4750. }
  4751. }
  4752. if (this.printing) {
  4753. return;
  4754. }
  4755. if (this.onIdle) {
  4756. this.idleTimeout = setTimeout(this.onIdle.bind(this),
  4757. CLEANUP_TIMEOUT);
  4758. }
  4759. }
  4760. }, {
  4761. key: "getHighestPriority",
  4762. value: function getHighestPriority(visible, views, scrolledDown) {
  4763. var visibleViews = visible.views;
  4764. var numVisible = visibleViews.length;
  4765. if (numVisible === 0) {
  4766. return null;
  4767. }
  4768. for (var i = 0; i < numVisible; ++i) {
  4769. var view = visibleViews[i].view;
  4770. if (!this.isViewFinished(view)) {
  4771. return view;
  4772. }
  4773. }
  4774. if (scrolledDown) {
  4775. var nextPageIndex = visible.last.id;
  4776. if (views[nextPageIndex] && !this.isViewFinished(views[
  4777. nextPageIndex])) {
  4778. return views[nextPageIndex];
  4779. }
  4780. } else {
  4781. var previousPageIndex = visible.first.id - 2;
  4782. if (views[previousPageIndex] && !this.isViewFinished(views[
  4783. previousPageIndex])) {
  4784. return views[previousPageIndex];
  4785. }
  4786. }
  4787. return null;
  4788. }
  4789. }, {
  4790. key: "isViewFinished",
  4791. value: function isViewFinished(view) {
  4792. return view.renderingState === RenderingStates.FINISHED;
  4793. }
  4794. }, {
  4795. key: "renderView",
  4796. value: function renderView(view) {
  4797. var _this = this;
  4798. switch (view.renderingState) {
  4799. case RenderingStates.FINISHED:
  4800. return false;
  4801. case RenderingStates.PAUSED:
  4802. this.highestPriorityPage = view.renderingId;
  4803. view.resume();
  4804. break;
  4805. case RenderingStates.RUNNING:
  4806. this.highestPriorityPage = view.renderingId;
  4807. break;
  4808. case RenderingStates.INITIAL:
  4809. this.highestPriorityPage = view.renderingId;
  4810. view.draw()["finally"](function() {
  4811. _this.renderHighestPriority();
  4812. });
  4813. break;
  4814. }
  4815. return true;
  4816. }
  4817. }]);
  4818. return PDFRenderingQueue;
  4819. }();
  4820. exports.PDFRenderingQueue = PDFRenderingQueue;
  4821. /***/
  4822. }),
  4823. /* 12 */
  4824. /***/
  4825. (function(module, exports, __webpack_require__) {
  4826. "use strict";
  4827. Object.defineProperty(exports, "__esModule", {
  4828. value: true
  4829. });
  4830. exports.PDFSidebar = exports.SidebarView = void 0;
  4831. var _ui_utils = __webpack_require__(5);
  4832. var _pdf_rendering_queue = __webpack_require__(11);
  4833. function _classCallCheck(instance, Constructor) {
  4834. if (!(instance instanceof Constructor)) {
  4835. throw new TypeError("Cannot call a class as a function");
  4836. }
  4837. }
  4838. function _defineProperties(target, props) {
  4839. for (var i = 0; i < props.length; i++) {
  4840. var descriptor = props[i];
  4841. descriptor.enumerable = descriptor.enumerable || false;
  4842. descriptor.configurable = true;
  4843. if ("value" in descriptor) descriptor.writable = true;
  4844. Object.defineProperty(target, descriptor.key, descriptor);
  4845. }
  4846. }
  4847. function _createClass(Constructor, protoProps, staticProps) {
  4848. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4849. if (staticProps) _defineProperties(Constructor, staticProps);
  4850. return Constructor;
  4851. }
  4852. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  4853. var SidebarView = {
  4854. UNKNOWN: -1,
  4855. NONE: 0,
  4856. THUMBS: 1,
  4857. OUTLINE: 2,
  4858. ATTACHMENTS: 3,
  4859. LAYERS: 4
  4860. };
  4861. exports.SidebarView = SidebarView;
  4862. var PDFSidebar =
  4863. /*#__PURE__*/
  4864. function() {
  4865. function PDFSidebar(_ref) {
  4866. var elements = _ref.elements,
  4867. pdfViewer = _ref.pdfViewer,
  4868. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4869. eventBus = _ref.eventBus,
  4870. _ref$l10n = _ref.l10n,
  4871. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4872. _ref$disableNotificat = _ref.disableNotification,
  4873. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4874. _classCallCheck(this, PDFSidebar);
  4875. this.isOpen = false;
  4876. this.active = SidebarView.THUMBS;
  4877. this.isInitialViewSet = false;
  4878. this.onToggled = null;
  4879. this.pdfViewer = pdfViewer;
  4880. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4881. this.outerContainer = elements.outerContainer;
  4882. this.viewerContainer = elements.viewerContainer;
  4883. this.toggleButton = elements.toggleButton;
  4884. this.thumbnailButton = elements.thumbnailButton;
  4885. this.outlineButton = elements.outlineButton;
  4886. this.attachmentsButton = elements.attachmentsButton;
  4887. this.thumbnailView = elements.thumbnailView;
  4888. this.outlineView = elements.outlineView;
  4889. this.attachmentsView = elements.attachmentsView;
  4890. this.eventBus = eventBus;
  4891. this.l10n = l10n;
  4892. this._disableNotification = disableNotification;
  4893. this._addEventListeners();
  4894. }
  4895. _createClass(PDFSidebar, [{
  4896. key: "reset",
  4897. value: function reset() {
  4898. this.isInitialViewSet = false;
  4899. this._hideUINotification(null);
  4900. this.switchView(SidebarView.THUMBS);
  4901. this.outlineButton.disabled = false;
  4902. this.attachmentsButton.disabled = false;
  4903. }
  4904. }, {
  4905. key: "setInitialView",
  4906. value: function setInitialView() {
  4907. var view = arguments.length > 0 && arguments[0] !== undefined ?
  4908. arguments[0] : SidebarView.NONE;
  4909. if (this.isInitialViewSet) {
  4910. return;
  4911. }
  4912. this.isInitialViewSet = true;
  4913. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4914. this._dispatchEvent();
  4915. return;
  4916. }
  4917. if (!this._switchView(view, true)) {
  4918. this._dispatchEvent();
  4919. }
  4920. }
  4921. }, {
  4922. key: "switchView",
  4923. value: function switchView(view) {
  4924. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ?
  4925. arguments[1] : false;
  4926. this._switchView(view, forceOpen);
  4927. }
  4928. }, {
  4929. key: "_switchView",
  4930. value: function _switchView(view) {
  4931. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ?
  4932. arguments[1] : false;
  4933. var isViewChanged = view !== this.active;
  4934. var shouldForceRendering = false;
  4935. switch (view) {
  4936. case SidebarView.NONE:
  4937. if (this.isOpen) {
  4938. this.close();
  4939. return true;
  4940. }
  4941. return false;
  4942. case SidebarView.THUMBS:
  4943. if (this.isOpen && isViewChanged) {
  4944. shouldForceRendering = true;
  4945. }
  4946. break;
  4947. case SidebarView.OUTLINE:
  4948. if (this.outlineButton.disabled) {
  4949. return false;
  4950. }
  4951. break;
  4952. case SidebarView.ATTACHMENTS:
  4953. if (this.attachmentsButton.disabled) {
  4954. return false;
  4955. }
  4956. break;
  4957. default:
  4958. console.error("PDFSidebar._switchView: \"".concat(view,
  4959. "\" is not a valid view."));
  4960. return false;
  4961. }
  4962. this.active = view;
  4963. this.thumbnailButton.classList.toggle('toggled', view === SidebarView
  4964. .THUMBS);
  4965. this.outlineButton.classList.toggle('toggled', view === SidebarView
  4966. .OUTLINE);
  4967. this.attachmentsButton.classList.toggle('toggled', view === SidebarView
  4968. .ATTACHMENTS);
  4969. this.thumbnailView.classList.toggle('hidden', view !== SidebarView
  4970. .THUMBS);
  4971. this.outlineView.classList.toggle('hidden', view !== SidebarView
  4972. .OUTLINE);
  4973. this.attachmentsView.classList.toggle('hidden', view !== SidebarView
  4974. .ATTACHMENTS);
  4975. if (forceOpen && !this.isOpen) {
  4976. this.open();
  4977. return true;
  4978. }
  4979. if (shouldForceRendering) {
  4980. this._updateThumbnailViewer();
  4981. this._forceRendering();
  4982. }
  4983. if (isViewChanged) {
  4984. this._dispatchEvent();
  4985. }
  4986. this._hideUINotification(this.active);
  4987. return isViewChanged;
  4988. }
  4989. }, {
  4990. key: "open",
  4991. value: function open() {
  4992. if (this.isOpen) {
  4993. return;
  4994. }
  4995. this.isOpen = true;
  4996. this.toggleButton.classList.add('toggled');
  4997. this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
  4998. if (this.active === SidebarView.THUMBS) {
  4999. this._updateThumbnailViewer();
  5000. }
  5001. this._forceRendering();
  5002. this._dispatchEvent();
  5003. this._hideUINotification(this.active);
  5004. }
  5005. }, {
  5006. key: "close",
  5007. value: function close() {
  5008. if (!this.isOpen) {
  5009. return;
  5010. }
  5011. this.isOpen = false;
  5012. this.toggleButton.classList.remove('toggled');
  5013. this.outerContainer.classList.add('sidebarMoving');
  5014. this.outerContainer.classList.remove('sidebarOpen');
  5015. this._forceRendering();
  5016. this._dispatchEvent();
  5017. }
  5018. }, {
  5019. key: "toggle",
  5020. value: function toggle() {
  5021. if (this.isOpen) {
  5022. this.close();
  5023. } else {
  5024. this.open();
  5025. }
  5026. }
  5027. }, {
  5028. key: "_dispatchEvent",
  5029. value: function _dispatchEvent() {
  5030. this.eventBus.dispatch('sidebarviewchanged', {
  5031. source: this,
  5032. view: this.visibleView
  5033. });
  5034. }
  5035. }, {
  5036. key: "_forceRendering",
  5037. value: function _forceRendering() {
  5038. if (this.onToggled) {
  5039. this.onToggled();
  5040. } else {
  5041. this.pdfViewer.forceRendering();
  5042. this.pdfThumbnailViewer.forceRendering();
  5043. }
  5044. }
  5045. }, {
  5046. key: "_updateThumbnailViewer",
  5047. value: function _updateThumbnailViewer() {
  5048. var pdfViewer = this.pdfViewer,
  5049. pdfThumbnailViewer = this.pdfThumbnailViewer;
  5050. var pagesCount = pdfViewer.pagesCount;
  5051. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  5052. var pageView = pdfViewer.getPageView(pageIndex);
  5053. if (pageView && pageView.renderingState === _pdf_rendering_queue
  5054. .RenderingStates.FINISHED) {
  5055. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  5056. thumbnailView.setImage(pageView);
  5057. }
  5058. }
  5059. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  5060. }
  5061. }, {
  5062. key: "_showUINotification",
  5063. value: function _showUINotification(view) {
  5064. var _this = this;
  5065. if (this._disableNotification) {
  5066. return;
  5067. }
  5068. this.l10n.get('toggle_sidebar_notification.title', null,
  5069. 'Toggle Sidebar (document contains outline/attachments)').then(
  5070. function(msg) {
  5071. _this.toggleButton.title = msg;
  5072. });
  5073. if (!this.isOpen) {
  5074. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  5075. } else if (view === this.active) {
  5076. return;
  5077. }
  5078. switch (view) {
  5079. case SidebarView.OUTLINE:
  5080. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  5081. break;
  5082. case SidebarView.ATTACHMENTS:
  5083. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  5084. break;
  5085. }
  5086. }
  5087. }, {
  5088. key: "_hideUINotification",
  5089. value: function _hideUINotification(view) {
  5090. var _this2 = this;
  5091. if (this._disableNotification) {
  5092. return;
  5093. }
  5094. var removeNotification = function removeNotification(view) {
  5095. switch (view) {
  5096. case SidebarView.OUTLINE:
  5097. _this2.outlineButton.classList.remove(
  5098. UI_NOTIFICATION_CLASS);
  5099. break;
  5100. case SidebarView.ATTACHMENTS:
  5101. _this2.attachmentsButton.classList.remove(
  5102. UI_NOTIFICATION_CLASS);
  5103. break;
  5104. }
  5105. };
  5106. if (!this.isOpen && view !== null) {
  5107. return;
  5108. }
  5109. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  5110. if (view !== null) {
  5111. removeNotification(view);
  5112. return;
  5113. }
  5114. for (view in SidebarView) {
  5115. removeNotification(SidebarView[view]);
  5116. }
  5117. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(
  5118. function(msg) {
  5119. _this2.toggleButton.title = msg;
  5120. });
  5121. }
  5122. }, {
  5123. key: "_addEventListeners",
  5124. value: function _addEventListeners() {
  5125. var _this3 = this;
  5126. this.viewerContainer.addEventListener('transitionend', function(evt) {
  5127. if (evt.target === _this3.viewerContainer) {
  5128. _this3.outerContainer.classList.remove('sidebarMoving');
  5129. }
  5130. });
  5131. this.toggleButton.addEventListener('click', function() {
  5132. _this3.toggle();
  5133. });
  5134. this.thumbnailButton.addEventListener('click', function() {
  5135. _this3.switchView(SidebarView.THUMBS);
  5136. });
  5137. this.outlineButton.addEventListener('click', function() {
  5138. _this3.switchView(SidebarView.OUTLINE);
  5139. });
  5140. this.outlineButton.addEventListener('dblclick', function() {
  5141. _this3.eventBus.dispatch('toggleoutlinetree', {
  5142. source: _this3
  5143. });
  5144. });
  5145. this.attachmentsButton.addEventListener('click', function() {
  5146. _this3.switchView(SidebarView.ATTACHMENTS);
  5147. });
  5148. this.eventBus.on('outlineloaded', function(evt) {
  5149. var outlineCount = evt.outlineCount;
  5150. _this3.outlineButton.disabled = !outlineCount;
  5151. if (outlineCount) {
  5152. _this3._showUINotification(SidebarView.OUTLINE);
  5153. } else if (_this3.active === SidebarView.OUTLINE) {
  5154. _this3.switchView(SidebarView.THUMBS);
  5155. }
  5156. });
  5157. this.eventBus.on('attachmentsloaded', function(evt) {
  5158. if (evt.attachmentsCount) {
  5159. _this3.attachmentsButton.disabled = false;
  5160. _this3._showUINotification(SidebarView.ATTACHMENTS);
  5161. return;
  5162. }
  5163. Promise.resolve().then(function() {
  5164. if (_this3.attachmentsView.hasChildNodes()) {
  5165. return;
  5166. }
  5167. _this3.attachmentsButton.disabled = true;
  5168. if (_this3.active === SidebarView.ATTACHMENTS) {
  5169. _this3.switchView(SidebarView.THUMBS);
  5170. }
  5171. });
  5172. });
  5173. this.eventBus.on('presentationmodechanged', function(evt) {
  5174. if (!evt.active && !evt.switchInProgress && _this3
  5175. .isThumbnailViewVisible) {
  5176. _this3._updateThumbnailViewer();
  5177. }
  5178. });
  5179. }
  5180. }, {
  5181. key: "visibleView",
  5182. get: function get() {
  5183. return this.isOpen ? this.active : SidebarView.NONE;
  5184. }
  5185. }, {
  5186. key: "isThumbnailViewVisible",
  5187. get: function get() {
  5188. return this.isOpen && this.active === SidebarView.THUMBS;
  5189. }
  5190. }, {
  5191. key: "isOutlineViewVisible",
  5192. get: function get() {
  5193. return this.isOpen && this.active === SidebarView.OUTLINE;
  5194. }
  5195. }, {
  5196. key: "isAttachmentsViewVisible",
  5197. get: function get() {
  5198. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  5199. }
  5200. }]);
  5201. return PDFSidebar;
  5202. }();
  5203. exports.PDFSidebar = PDFSidebar;
  5204. /***/
  5205. }),
  5206. /* 13 */
  5207. /***/
  5208. (function(module, exports, __webpack_require__) {
  5209. "use strict";
  5210. Object.defineProperty(exports, "__esModule", {
  5211. value: true
  5212. });
  5213. exports.OverlayManager = void 0;
  5214. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5215. function _interopRequireDefault(obj) {
  5216. return obj && obj.__esModule ? obj : {
  5217. "default": obj
  5218. };
  5219. }
  5220. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  5221. try {
  5222. var info = gen[key](arg);
  5223. var value = info.value;
  5224. } catch (error) {
  5225. reject(error);
  5226. return;
  5227. }
  5228. if (info.done) {
  5229. resolve(value);
  5230. } else {
  5231. Promise.resolve(value).then(_next, _throw);
  5232. }
  5233. }
  5234. function _asyncToGenerator(fn) {
  5235. return function() {
  5236. var self = this,
  5237. args = arguments;
  5238. return new Promise(function(resolve, reject) {
  5239. var gen = fn.apply(self, args);
  5240. function _next(value) {
  5241. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  5242. }
  5243. function _throw(err) {
  5244. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  5245. }
  5246. _next(undefined);
  5247. });
  5248. };
  5249. }
  5250. function _classCallCheck(instance, Constructor) {
  5251. if (!(instance instanceof Constructor)) {
  5252. throw new TypeError("Cannot call a class as a function");
  5253. }
  5254. }
  5255. function _defineProperties(target, props) {
  5256. for (var i = 0; i < props.length; i++) {
  5257. var descriptor = props[i];
  5258. descriptor.enumerable = descriptor.enumerable || false;
  5259. descriptor.configurable = true;
  5260. if ("value" in descriptor) descriptor.writable = true;
  5261. Object.defineProperty(target, descriptor.key, descriptor);
  5262. }
  5263. }
  5264. function _createClass(Constructor, protoProps, staticProps) {
  5265. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5266. if (staticProps) _defineProperties(Constructor, staticProps);
  5267. return Constructor;
  5268. }
  5269. var OverlayManager =
  5270. /*#__PURE__*/
  5271. function() {
  5272. function OverlayManager() {
  5273. _classCallCheck(this, OverlayManager);
  5274. this._overlays = {};
  5275. this._active = null;
  5276. this._keyDownBound = this._keyDown.bind(this);
  5277. }
  5278. _createClass(OverlayManager, [{
  5279. key: "register",
  5280. value: function() {
  5281. var _register = _asyncToGenerator(
  5282. /*#__PURE__*/
  5283. _regenerator["default"].mark(function _callee(name, element) {
  5284. var callerCloseMethod,
  5285. canForceClose,
  5286. container,
  5287. _args = arguments;
  5288. return _regenerator["default"].wrap(function _callee$(
  5289. _context) {
  5290. while (1) {
  5291. switch (_context.prev = _context.next) {
  5292. case 0:
  5293. callerCloseMethod = _args
  5294. .length > 2 && _args[2] !==
  5295. undefined ? _args[2] : null;
  5296. canForceClose = _args.length >
  5297. 3 && _args[3] !==
  5298. undefined ? _args[3] :
  5299. false;
  5300. if (!(!name || !element || !(
  5301. container = element
  5302. .parentNode))) {
  5303. _context.next = 6;
  5304. break;
  5305. }
  5306. throw new Error(
  5307. 'Not enough parameters.'
  5308. );
  5309. case 6:
  5310. if (!this._overlays[name]) {
  5311. _context.next = 8;
  5312. break;
  5313. }
  5314. throw new Error(
  5315. 'The overlay is already registered.'
  5316. );
  5317. case 8:
  5318. this._overlays[name] = {
  5319. element: element,
  5320. container: container,
  5321. callerCloseMethod: callerCloseMethod,
  5322. canForceClose: canForceClose
  5323. };
  5324. case 9:
  5325. case "end":
  5326. return _context.stop();
  5327. }
  5328. }
  5329. }, _callee, this);
  5330. }));
  5331. function register(_x, _x2) {
  5332. return _register.apply(this, arguments);
  5333. }
  5334. return register;
  5335. }()
  5336. }, {
  5337. key: "unregister",
  5338. value: function() {
  5339. var _unregister = _asyncToGenerator(
  5340. /*#__PURE__*/
  5341. _regenerator["default"].mark(function _callee2(name) {
  5342. return _regenerator["default"].wrap(function _callee2$(
  5343. _context2) {
  5344. while (1) {
  5345. switch (_context2.prev = _context2
  5346. .next) {
  5347. case 0:
  5348. if (this._overlays[name]) {
  5349. _context2.next = 4;
  5350. break;
  5351. }
  5352. throw new Error(
  5353. 'The overlay does not exist.'
  5354. );
  5355. case 4:
  5356. if (!(this._active === name)) {
  5357. _context2.next = 6;
  5358. break;
  5359. }
  5360. throw new Error(
  5361. 'The overlay cannot be removed while it is active.'
  5362. );
  5363. case 6:
  5364. delete this._overlays[name];
  5365. case 7:
  5366. case "end":
  5367. return _context2.stop();
  5368. }
  5369. }
  5370. }, _callee2, this);
  5371. }));
  5372. function unregister(_x3) {
  5373. return _unregister.apply(this, arguments);
  5374. }
  5375. return unregister;
  5376. }()
  5377. }, {
  5378. key: "open",
  5379. value: function() {
  5380. var _open = _asyncToGenerator(
  5381. /*#__PURE__*/
  5382. _regenerator["default"].mark(function _callee3(name) {
  5383. return _regenerator["default"].wrap(function _callee3$(
  5384. _context3) {
  5385. while (1) {
  5386. switch (_context3.prev = _context3
  5387. .next) {
  5388. case 0:
  5389. if (this._overlays[name]) {
  5390. _context3.next = 4;
  5391. break;
  5392. }
  5393. throw new Error(
  5394. 'The overlay does not exist.'
  5395. );
  5396. case 4:
  5397. if (!this._active) {
  5398. _context3.next = 14;
  5399. break;
  5400. }
  5401. if (!this._overlays[name]
  5402. .canForceClose) {
  5403. _context3.next = 9;
  5404. break;
  5405. }
  5406. this._closeThroughCaller();
  5407. _context3.next = 14;
  5408. break;
  5409. case 9:
  5410. if (!(this._active === name)) {
  5411. _context3.next = 13;
  5412. break;
  5413. }
  5414. throw new Error(
  5415. 'The overlay is already active.'
  5416. );
  5417. case 13:
  5418. throw new Error(
  5419. 'Another overlay is currently active.'
  5420. );
  5421. case 14:
  5422. this._active = name;
  5423. this._overlays[this._active]
  5424. .element.classList.remove(
  5425. 'hidden');
  5426. this._overlays[this._active]
  5427. .container.classList.remove(
  5428. 'hidden');
  5429. window.addEventListener(
  5430. 'keydown', this
  5431. ._keyDownBound);
  5432. case 18:
  5433. case "end":
  5434. return _context3.stop();
  5435. }
  5436. }
  5437. }, _callee3, this);
  5438. }));
  5439. function open(_x4) {
  5440. return _open.apply(this, arguments);
  5441. }
  5442. return open;
  5443. }()
  5444. }, {
  5445. key: "close",
  5446. value: function() {
  5447. var _close = _asyncToGenerator(
  5448. /*#__PURE__*/
  5449. _regenerator["default"].mark(function _callee4(name) {
  5450. return _regenerator["default"].wrap(function _callee4$(
  5451. _context4) {
  5452. while (1) {
  5453. switch (_context4.prev = _context4
  5454. .next) {
  5455. case 0:
  5456. if (this._overlays[name]) {
  5457. _context4.next = 4;
  5458. break;
  5459. }
  5460. throw new Error(
  5461. 'The overlay does not exist.'
  5462. );
  5463. case 4:
  5464. if (this._active) {
  5465. _context4.next = 8;
  5466. break;
  5467. }
  5468. throw new Error(
  5469. 'The overlay is currently not active.'
  5470. );
  5471. case 8:
  5472. if (!(this._active !== name)) {
  5473. _context4.next = 10;
  5474. break;
  5475. }
  5476. throw new Error(
  5477. 'Another overlay is currently active.'
  5478. );
  5479. case 10:
  5480. this._overlays[this._active]
  5481. .container.classList.add(
  5482. 'hidden');
  5483. this._overlays[this._active]
  5484. .element.classList.add(
  5485. 'hidden');
  5486. this._active = null;
  5487. window.removeEventListener(
  5488. 'keydown', this
  5489. ._keyDownBound);
  5490. case 14:
  5491. case "end":
  5492. return _context4.stop();
  5493. }
  5494. }
  5495. }, _callee4, this);
  5496. }));
  5497. function close(_x5) {
  5498. return _close.apply(this, arguments);
  5499. }
  5500. return close;
  5501. }()
  5502. }, {
  5503. key: "_keyDown",
  5504. value: function _keyDown(evt) {
  5505. if (this._active && evt.keyCode === 27) {
  5506. this._closeThroughCaller();
  5507. evt.preventDefault();
  5508. }
  5509. }
  5510. }, {
  5511. key: "_closeThroughCaller",
  5512. value: function _closeThroughCaller() {
  5513. if (this._overlays[this._active].callerCloseMethod) {
  5514. this._overlays[this._active].callerCloseMethod();
  5515. }
  5516. if (this._active) {
  5517. this.close(this._active);
  5518. }
  5519. }
  5520. }, {
  5521. key: "active",
  5522. get: function get() {
  5523. return this._active;
  5524. }
  5525. }]);
  5526. return OverlayManager;
  5527. }();
  5528. exports.OverlayManager = OverlayManager;
  5529. /***/
  5530. }),
  5531. /* 14 */
  5532. /***/
  5533. (function(module, exports, __webpack_require__) {
  5534. "use strict";
  5535. Object.defineProperty(exports, "__esModule", {
  5536. value: true
  5537. });
  5538. exports.PasswordPrompt = void 0;
  5539. var _ui_utils = __webpack_require__(5);
  5540. var _pdfjsLib = __webpack_require__(7);
  5541. function _classCallCheck(instance, Constructor) {
  5542. if (!(instance instanceof Constructor)) {
  5543. throw new TypeError("Cannot call a class as a function");
  5544. }
  5545. }
  5546. function _defineProperties(target, props) {
  5547. for (var i = 0; i < props.length; i++) {
  5548. var descriptor = props[i];
  5549. descriptor.enumerable = descriptor.enumerable || false;
  5550. descriptor.configurable = true;
  5551. if ("value" in descriptor) descriptor.writable = true;
  5552. Object.defineProperty(target, descriptor.key, descriptor);
  5553. }
  5554. }
  5555. function _createClass(Constructor, protoProps, staticProps) {
  5556. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5557. if (staticProps) _defineProperties(Constructor, staticProps);
  5558. return Constructor;
  5559. }
  5560. var PasswordPrompt =
  5561. /*#__PURE__*/
  5562. function() {
  5563. function PasswordPrompt(options, overlayManager) {
  5564. var _this = this;
  5565. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  5566. .NullL10n;
  5567. _classCallCheck(this, PasswordPrompt);
  5568. this.overlayName = options.overlayName;
  5569. this.container = options.container;
  5570. this.label = options.label;
  5571. this.input = options.input;
  5572. this.submitButton = options.submitButton;
  5573. this.cancelButton = options.cancelButton;
  5574. this.overlayManager = overlayManager;
  5575. this.l10n = l10n;
  5576. this.updateCallback = null;
  5577. this.reason = null;
  5578. this.submitButton.addEventListener('click', this.verify.bind(this));
  5579. this.cancelButton.addEventListener('click', this.close.bind(this));
  5580. this.input.addEventListener('keydown', function(e) {
  5581. if (e.keyCode === 13) {
  5582. _this.verify();
  5583. }
  5584. });
  5585. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5586. }
  5587. _createClass(PasswordPrompt, [{
  5588. key: "open",
  5589. value: function open() {
  5590. var _this2 = this;
  5591. this.overlayManager.open(this.overlayName).then(function() {
  5592. _this2.input.focus();
  5593. var promptString;
  5594. if (_this2.reason === _pdfjsLib.PasswordResponses
  5595. .INCORRECT_PASSWORD) {
  5596. promptString = _this2.l10n.get('password_invalid', null,
  5597. 'Invalid password. Please try again.');
  5598. } else {
  5599. promptString = _this2.l10n.get('password_label', null,
  5600. 'Enter the password to open this PDF file.');
  5601. }
  5602. promptString.then(function(msg) {
  5603. _this2.label.textContent = msg;
  5604. });
  5605. });
  5606. }
  5607. }, {
  5608. key: "close",
  5609. value: function close() {
  5610. var _this3 = this;
  5611. this.overlayManager.close(this.overlayName).then(function() {
  5612. _this3.input.value = '';
  5613. });
  5614. }
  5615. }, {
  5616. key: "verify",
  5617. value: function verify() {
  5618. var password = this.input.value;
  5619. if (password && password.length > 0) {
  5620. this.close();
  5621. this.updateCallback(password);
  5622. }
  5623. }
  5624. }, {
  5625. key: "setUpdateCallback",
  5626. value: function setUpdateCallback(updateCallback, reason) {
  5627. this.updateCallback = updateCallback;
  5628. this.reason = reason;
  5629. }
  5630. }]);
  5631. return PasswordPrompt;
  5632. }();
  5633. exports.PasswordPrompt = PasswordPrompt;
  5634. /***/
  5635. }),
  5636. /* 15 */
  5637. /***/
  5638. (function(module, exports, __webpack_require__) {
  5639. "use strict";
  5640. Object.defineProperty(exports, "__esModule", {
  5641. value: true
  5642. });
  5643. exports.PDFAttachmentViewer = void 0;
  5644. var _pdfjsLib = __webpack_require__(7);
  5645. function _classCallCheck(instance, Constructor) {
  5646. if (!(instance instanceof Constructor)) {
  5647. throw new TypeError("Cannot call a class as a function");
  5648. }
  5649. }
  5650. function _defineProperties(target, props) {
  5651. for (var i = 0; i < props.length; i++) {
  5652. var descriptor = props[i];
  5653. descriptor.enumerable = descriptor.enumerable || false;
  5654. descriptor.configurable = true;
  5655. if ("value" in descriptor) descriptor.writable = true;
  5656. Object.defineProperty(target, descriptor.key, descriptor);
  5657. }
  5658. }
  5659. function _createClass(Constructor, protoProps, staticProps) {
  5660. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5661. if (staticProps) _defineProperties(Constructor, staticProps);
  5662. return Constructor;
  5663. }
  5664. var PDFAttachmentViewer =
  5665. /*#__PURE__*/
  5666. function() {
  5667. function PDFAttachmentViewer(_ref) {
  5668. var container = _ref.container,
  5669. eventBus = _ref.eventBus,
  5670. downloadManager = _ref.downloadManager;
  5671. _classCallCheck(this, PDFAttachmentViewer);
  5672. this.container = container;
  5673. this.eventBus = eventBus;
  5674. this.downloadManager = downloadManager;
  5675. this.reset();
  5676. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  5677. }
  5678. _createClass(PDFAttachmentViewer, [{
  5679. key: "reset",
  5680. value: function reset() {
  5681. var keepRenderedCapability = arguments.length > 0 && arguments[0] !==
  5682. undefined ? arguments[0] : false;
  5683. this.attachments = null;
  5684. this.container.textContent = '';
  5685. if (!keepRenderedCapability) {
  5686. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5687. }
  5688. }
  5689. }, {
  5690. key: "_dispatchEvent",
  5691. value: function _dispatchEvent(attachmentsCount) {
  5692. this._renderedCapability.resolve();
  5693. this.eventBus.dispatch('attachmentsloaded', {
  5694. source: this,
  5695. attachmentsCount: attachmentsCount
  5696. });
  5697. }
  5698. }, {
  5699. key: "_bindPdfLink",
  5700. value: function _bindPdfLink(button, content, filename) {
  5701. if (this.downloadManager.disableCreateObjectURL) {
  5702. throw new Error(
  5703. 'bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  5704. }
  5705. var blobUrl;
  5706. button.onclick = function() {
  5707. if (!blobUrl) {
  5708. blobUrl = (0, _pdfjsLib.createObjectURL)(content,
  5709. 'application/pdf');
  5710. }
  5711. var viewerUrl;
  5712. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' +
  5713. filename);
  5714. window.open(viewerUrl);
  5715. return false;
  5716. };
  5717. }
  5718. }, {
  5719. key: "_bindLink",
  5720. value: function _bindLink(button, content, filename) {
  5721. var _this = this;
  5722. button.onclick = function() {
  5723. _this.downloadManager.downloadData(content, filename, '');
  5724. return false;
  5725. };
  5726. }
  5727. }, {
  5728. key: "render",
  5729. value: function render(_ref2) {
  5730. var attachments = _ref2.attachments,
  5731. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5732. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false :
  5733. _ref2$keepRenderedCap;
  5734. var attachmentsCount = 0;
  5735. if (this.attachments) {
  5736. this.reset(keepRenderedCapability === true);
  5737. }
  5738. this.attachments = attachments || null;
  5739. if (!attachments) {
  5740. this._dispatchEvent(attachmentsCount);
  5741. return;
  5742. }
  5743. var names = Object.keys(attachments).sort(function(a, b) {
  5744. return a.toLowerCase().localeCompare(b.toLowerCase());
  5745. });
  5746. attachmentsCount = names.length;
  5747. for (var i = 0; i < attachmentsCount; i++) {
  5748. var item = attachments[names[i]];
  5749. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib
  5750. .getFilenameFromUrl)(item.filename));
  5751. var div = document.createElement('div');
  5752. div.className = 'attachmentsItem';
  5753. var button = document.createElement('button');
  5754. button.textContent = filename;
  5755. if (/\.pdf$/i.test(filename) && !this.downloadManager
  5756. .disableCreateObjectURL) {
  5757. this._bindPdfLink(button, item.content, filename);
  5758. } else {
  5759. this._bindLink(button, item.content, filename);
  5760. }
  5761. div.appendChild(button);
  5762. this.container.appendChild(div);
  5763. }
  5764. this._dispatchEvent(attachmentsCount);
  5765. }
  5766. }, {
  5767. key: "_appendAttachment",
  5768. value: function _appendAttachment(_ref3) {
  5769. var _this2 = this;
  5770. var id = _ref3.id,
  5771. filename = _ref3.filename,
  5772. content = _ref3.content;
  5773. this._renderedCapability.promise.then(function() {
  5774. var attachments = _this2.attachments;
  5775. if (!attachments) {
  5776. attachments = Object.create(null);
  5777. } else {
  5778. for (var name in attachments) {
  5779. if (id === name) {
  5780. return;
  5781. }
  5782. }
  5783. }
  5784. attachments[id] = {
  5785. filename: filename,
  5786. content: content
  5787. };
  5788. _this2.render({
  5789. attachments: attachments,
  5790. keepRenderedCapability: true
  5791. });
  5792. });
  5793. }
  5794. }]);
  5795. return PDFAttachmentViewer;
  5796. }();
  5797. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5798. /***/
  5799. }),
  5800. /* 16 */
  5801. /***/
  5802. (function(module, exports, __webpack_require__) {
  5803. "use strict";
  5804. Object.defineProperty(exports, "__esModule", {
  5805. value: true
  5806. });
  5807. exports.PDFDocumentProperties = void 0;
  5808. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5809. var _pdfjsLib = __webpack_require__(7);
  5810. var _ui_utils = __webpack_require__(5);
  5811. function _interopRequireDefault(obj) {
  5812. return obj && obj.__esModule ? obj : {
  5813. "default": obj
  5814. };
  5815. }
  5816. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  5817. try {
  5818. var info = gen[key](arg);
  5819. var value = info.value;
  5820. } catch (error) {
  5821. reject(error);
  5822. return;
  5823. }
  5824. if (info.done) {
  5825. resolve(value);
  5826. } else {
  5827. Promise.resolve(value).then(_next, _throw);
  5828. }
  5829. }
  5830. function _asyncToGenerator(fn) {
  5831. return function() {
  5832. var self = this,
  5833. args = arguments;
  5834. return new Promise(function(resolve, reject) {
  5835. var gen = fn.apply(self, args);
  5836. function _next(value) {
  5837. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  5838. }
  5839. function _throw(err) {
  5840. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  5841. }
  5842. _next(undefined);
  5843. });
  5844. };
  5845. }
  5846. function _slicedToArray(arr, i) {
  5847. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  5848. }
  5849. function _nonIterableRest() {
  5850. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  5851. }
  5852. function _iterableToArrayLimit(arr, i) {
  5853. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  5854. "[object Arguments]")) {
  5855. return;
  5856. }
  5857. var _arr = [];
  5858. var _n = true;
  5859. var _d = false;
  5860. var _e = undefined;
  5861. try {
  5862. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  5863. _arr.push(_s.value);
  5864. if (i && _arr.length === i) break;
  5865. }
  5866. } catch (err) {
  5867. _d = true;
  5868. _e = err;
  5869. } finally {
  5870. try {
  5871. if (!_n && _i["return"] != null) _i["return"]();
  5872. } finally {
  5873. if (_d) throw _e;
  5874. }
  5875. }
  5876. return _arr;
  5877. }
  5878. function _arrayWithHoles(arr) {
  5879. if (Array.isArray(arr)) return arr;
  5880. }
  5881. function _classCallCheck(instance, Constructor) {
  5882. if (!(instance instanceof Constructor)) {
  5883. throw new TypeError("Cannot call a class as a function");
  5884. }
  5885. }
  5886. function _defineProperties(target, props) {
  5887. for (var i = 0; i < props.length; i++) {
  5888. var descriptor = props[i];
  5889. descriptor.enumerable = descriptor.enumerable || false;
  5890. descriptor.configurable = true;
  5891. if ("value" in descriptor) descriptor.writable = true;
  5892. Object.defineProperty(target, descriptor.key, descriptor);
  5893. }
  5894. }
  5895. function _createClass(Constructor, protoProps, staticProps) {
  5896. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5897. if (staticProps) _defineProperties(Constructor, staticProps);
  5898. return Constructor;
  5899. }
  5900. var DEFAULT_FIELD_CONTENT = '-';
  5901. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  5902. var US_PAGE_NAMES = {
  5903. '8.5x11': 'Letter',
  5904. '8.5x14': 'Legal'
  5905. };
  5906. var METRIC_PAGE_NAMES = {
  5907. '297x420': 'A3',
  5908. '210x297': 'A4'
  5909. };
  5910. function getPageName(size, isPortrait, pageNames) {
  5911. var width = isPortrait ? size.width : size.height;
  5912. var height = isPortrait ? size.height : size.width;
  5913. return pageNames["".concat(width, "x").concat(height)];
  5914. }
  5915. var PDFDocumentProperties =
  5916. /*#__PURE__*/
  5917. function() {
  5918. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5919. var _this = this;
  5920. var overlayName = _ref.overlayName,
  5921. fields = _ref.fields,
  5922. container = _ref.container,
  5923. closeButton = _ref.closeButton;
  5924. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils
  5925. .NullL10n;
  5926. _classCallCheck(this, PDFDocumentProperties);
  5927. this.overlayName = overlayName;
  5928. this.fields = fields;
  5929. this.container = container;
  5930. this.overlayManager = overlayManager;
  5931. this.l10n = l10n;
  5932. this._reset();
  5933. if (closeButton) {
  5934. closeButton.addEventListener('click', this.close.bind(this));
  5935. }
  5936. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5937. if (eventBus) {
  5938. eventBus.on('pagechanging', function(evt) {
  5939. _this._currentPageNumber = evt.pageNumber;
  5940. });
  5941. eventBus.on('rotationchanging', function(evt) {
  5942. _this._pagesRotation = evt.pagesRotation;
  5943. });
  5944. }
  5945. this._isNonMetricLocale = true;
  5946. l10n.getLanguage().then(function(locale) {
  5947. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5948. });
  5949. }
  5950. _createClass(PDFDocumentProperties, [{
  5951. key: "open",
  5952. value: function open() {
  5953. var _this2 = this;
  5954. var freezeFieldData = function freezeFieldData(data) {
  5955. Object.defineProperty(_this2, 'fieldData', {
  5956. value: Object.freeze(data),
  5957. writable: false,
  5958. enumerable: true,
  5959. configurable: true
  5960. });
  5961. };
  5962. Promise.all([this.overlayManager.open(this.overlayName), this
  5963. ._dataAvailableCapability.promise
  5964. ]).then(function() {
  5965. var currentPageNumber = _this2._currentPageNumber;
  5966. var pagesRotation = _this2._pagesRotation;
  5967. if (_this2.fieldData && currentPageNumber === _this2
  5968. .fieldData['_currentPageNumber'] && pagesRotation ===
  5969. _this2.fieldData['_pagesRotation']) {
  5970. _this2._updateUI();
  5971. return;
  5972. }
  5973. _this2.pdfDocument.getMetadata().then(function(_ref2) {
  5974. var info = _ref2.info,
  5975. metadata = _ref2.metadata,
  5976. contentDispositionFilename = _ref2
  5977. .contentDispositionFilename;
  5978. return Promise.all([info, metadata,
  5979. contentDispositionFilename || (0,
  5980. _ui_utils.getPDFFileNameFromURL)
  5981. (_this2.url || ''), _this2
  5982. ._parseFileSize(_this2
  5983. .maybeFileSize), _this2
  5984. ._parseDate(info.CreationDate),
  5985. _this2._parseDate(info.ModDate),
  5986. _this2.pdfDocument.getPage(
  5987. currentPageNumber).then(
  5988. function(pdfPage) {
  5989. return _this2
  5990. ._parsePageSize((0,
  5991. _ui_utils
  5992. .getPageSizeInches
  5993. )(pdfPage),
  5994. pagesRotation);
  5995. }), _this2._parseLinearization(
  5996. info.IsLinearized)
  5997. ]);
  5998. }).then(function(_ref3) {
  5999. var _ref4 = _slicedToArray(_ref3, 8),
  6000. info = _ref4[0],
  6001. metadata = _ref4[1],
  6002. fileName = _ref4[2],
  6003. fileSize = _ref4[3],
  6004. creationDate = _ref4[4],
  6005. modDate = _ref4[5],
  6006. pageSize = _ref4[6],
  6007. isLinearized = _ref4[7];
  6008. freezeFieldData({
  6009. 'fileName': fileName,
  6010. 'fileSize': fileSize,
  6011. 'title': info.Title,
  6012. 'author': info.Author,
  6013. 'subject': info.Subject,
  6014. 'keywords': info.Keywords,
  6015. 'creationDate': creationDate,
  6016. 'modificationDate': modDate,
  6017. 'creator': info.Creator,
  6018. 'producer': info.Producer,
  6019. 'version': info.PDFFormatVersion,
  6020. 'pageCount': _this2.pdfDocument
  6021. .numPages,
  6022. 'pageSize': pageSize,
  6023. 'linearized': isLinearized,
  6024. '_currentPageNumber': currentPageNumber,
  6025. '_pagesRotation': pagesRotation
  6026. });
  6027. _this2._updateUI();
  6028. return _this2.pdfDocument.getDownloadInfo();
  6029. }).then(function(_ref5) {
  6030. var length = _ref5.length;
  6031. _this2.maybeFileSize = length;
  6032. return _this2._parseFileSize(length);
  6033. }).then(function(fileSize) {
  6034. if (fileSize === _this2.fieldData['fileSize']) {
  6035. return;
  6036. }
  6037. var data = Object.assign(Object.create(null),
  6038. _this2.fieldData);
  6039. data['fileSize'] = fileSize;
  6040. freezeFieldData(data);
  6041. _this2._updateUI();
  6042. });
  6043. });
  6044. }
  6045. }, {
  6046. key: "close",
  6047. value: function close() {
  6048. this.overlayManager.close(this.overlayName);
  6049. }
  6050. }, {
  6051. key: "setDocument",
  6052. value: function setDocument(pdfDocument) {
  6053. var url = arguments.length > 1 && arguments[1] !== undefined ?
  6054. arguments[1] : null;
  6055. if (this.pdfDocument) {
  6056. this._reset();
  6057. this._updateUI(true);
  6058. }
  6059. if (!pdfDocument) {
  6060. return;
  6061. }
  6062. this.pdfDocument = pdfDocument;
  6063. this.url = url;
  6064. this._dataAvailableCapability.resolve();
  6065. }
  6066. }, {
  6067. key: "setFileSize",
  6068. value: function setFileSize(fileSize) {
  6069. if (Number.isInteger(fileSize) && fileSize > 0) {
  6070. this.maybeFileSize = fileSize;
  6071. }
  6072. }
  6073. }, {
  6074. key: "_reset",
  6075. value: function _reset() {
  6076. this.pdfDocument = null;
  6077. this.url = null;
  6078. this.maybeFileSize = 0;
  6079. delete this.fieldData;
  6080. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)
  6081. ();
  6082. this._currentPageNumber = 1;
  6083. this._pagesRotation = 0;
  6084. }
  6085. }, {
  6086. key: "_updateUI",
  6087. value: function _updateUI() {
  6088. var reset = arguments.length > 0 && arguments[0] !== undefined ?
  6089. arguments[0] : false;
  6090. if (reset || !this.fieldData) {
  6091. for (var id in this.fields) {
  6092. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6093. }
  6094. return;
  6095. }
  6096. if (this.overlayManager.active !== this.overlayName) {
  6097. return;
  6098. }
  6099. for (var _id in this.fields) {
  6100. var content = this.fieldData[_id];
  6101. this.fields[_id].textContent = content || content === 0 ? content :
  6102. DEFAULT_FIELD_CONTENT;
  6103. }
  6104. }
  6105. }, {
  6106. key: "_parseFileSize",
  6107. value: function() {
  6108. var _parseFileSize2 = _asyncToGenerator(
  6109. /*#__PURE__*/
  6110. _regenerator["default"].mark(function _callee() {
  6111. var fileSize,
  6112. kb,
  6113. _args = arguments;
  6114. return _regenerator["default"].wrap(function _callee$(
  6115. _context) {
  6116. while (1) {
  6117. switch (_context.prev = _context.next) {
  6118. case 0:
  6119. fileSize = _args.length > 0 &&
  6120. _args[0] !== undefined ?
  6121. _args[0] : 0;
  6122. kb = fileSize / 1024;
  6123. if (kb) {
  6124. _context.next = 6;
  6125. break;
  6126. }
  6127. return _context.abrupt("return",
  6128. undefined);
  6129. case 6:
  6130. if (!(kb < 1024)) {
  6131. _context.next = 8;
  6132. break;
  6133. }
  6134. return _context.abrupt("return",
  6135. this.l10n.get(
  6136. 'document_properties_kb', {
  6137. size_kb: (+kb
  6138. .toPrecision(
  6139. 3))
  6140. .toLocaleString(),
  6141. size_b: fileSize
  6142. .toLocaleString()
  6143. },
  6144. '{{size_kb}} KB ({{size_b}} bytes)'
  6145. ));
  6146. case 8:
  6147. return _context.abrupt("return",
  6148. this.l10n.get(
  6149. 'document_properties_mb', {
  6150. size_mb: (+(kb /
  6151. 1024
  6152. )
  6153. .toPrecision(
  6154. 3))
  6155. .toLocaleString(),
  6156. size_b: fileSize
  6157. .toLocaleString()
  6158. },
  6159. '{{size_mb}} MB ({{size_b}} bytes)'
  6160. ));
  6161. case 9:
  6162. case "end":
  6163. return _context.stop();
  6164. }
  6165. }
  6166. }, _callee, this);
  6167. }));
  6168. function _parseFileSize() {
  6169. return _parseFileSize2.apply(this, arguments);
  6170. }
  6171. return _parseFileSize;
  6172. }()
  6173. }, {
  6174. key: "_parsePageSize",
  6175. value: function() {
  6176. var _parsePageSize2 = _asyncToGenerator(
  6177. /*#__PURE__*/
  6178. _regenerator["default"].mark(function _callee2(pageSizeInches,
  6179. pagesRotation) {
  6180. var _this3 = this;
  6181. var isPortrait, sizeInches, sizeMillimeters, pageName,
  6182. name, exactMillimeters, intMillimeters;
  6183. return _regenerator["default"].wrap(function _callee2$(
  6184. _context2) {
  6185. while (1) {
  6186. switch (_context2.prev = _context2
  6187. .next) {
  6188. case 0:
  6189. if (pageSizeInches) {
  6190. _context2.next = 2;
  6191. break;
  6192. }
  6193. return _context2.abrupt(
  6194. "return", undefined);
  6195. case 2:
  6196. if (pagesRotation % 180 !== 0) {
  6197. pageSizeInches = {
  6198. width: pageSizeInches
  6199. .height,
  6200. height: pageSizeInches
  6201. .width
  6202. };
  6203. }
  6204. isPortrait = (0, _ui_utils
  6205. .isPortraitOrientation)(
  6206. pageSizeInches);
  6207. sizeInches = {
  6208. width: Math.round(
  6209. pageSizeInches
  6210. .width * 100) /
  6211. 100,
  6212. height: Math.round(
  6213. pageSizeInches
  6214. .height * 100) /
  6215. 100
  6216. };
  6217. sizeMillimeters = {
  6218. width: Math.round(
  6219. pageSizeInches
  6220. .width * 25.4 *
  6221. 10) / 10,
  6222. height: Math.round(
  6223. pageSizeInches
  6224. .height * 25.4 *
  6225. 10) / 10
  6226. };
  6227. pageName = null;
  6228. name = getPageName(sizeInches,
  6229. isPortrait,
  6230. US_PAGE_NAMES) ||
  6231. getPageName(sizeMillimeters,
  6232. isPortrait,
  6233. METRIC_PAGE_NAMES);
  6234. if (!name && !(Number.isInteger(
  6235. sizeMillimeters
  6236. .width) && Number
  6237. .isInteger(
  6238. sizeMillimeters
  6239. .height))) {
  6240. exactMillimeters = {
  6241. width: pageSizeInches
  6242. .width * 25.4,
  6243. height: pageSizeInches
  6244. .height * 25.4
  6245. };
  6246. intMillimeters = {
  6247. width: Math.round(
  6248. sizeMillimeters
  6249. .width),
  6250. height: Math.round(
  6251. sizeMillimeters
  6252. .height)
  6253. };
  6254. if (Math.abs(
  6255. exactMillimeters
  6256. .width -
  6257. intMillimeters.width
  6258. ) < 0.1 && Math.abs(
  6259. exactMillimeters
  6260. .height -
  6261. intMillimeters
  6262. .height) < 0.1) {
  6263. name = getPageName(
  6264. intMillimeters,
  6265. isPortrait,
  6266. METRIC_PAGE_NAMES
  6267. );
  6268. if (name) {
  6269. sizeInches = {
  6270. width: Math
  6271. .round(
  6272. intMillimeters
  6273. .width /
  6274. 25.4 *
  6275. 100
  6276. ) /
  6277. 100,
  6278. height: Math
  6279. .round(
  6280. intMillimeters
  6281. .height /
  6282. 25.4 *
  6283. 100
  6284. ) /
  6285. 100
  6286. };
  6287. sizeMillimeters =
  6288. intMillimeters;
  6289. }
  6290. }
  6291. }
  6292. if (name) {
  6293. pageName = this.l10n.get(
  6294. 'document_properties_page_size_name_' +
  6295. name.toLowerCase(),
  6296. null, name);
  6297. }
  6298. return _context2.abrupt(
  6299. "return", Promise.all([
  6300. this
  6301. ._isNonMetricLocale ?
  6302. sizeInches :
  6303. sizeMillimeters,
  6304. this.l10n.get(
  6305. 'document_properties_page_size_unit_' +
  6306. (this
  6307. ._isNonMetricLocale ?
  6308. 'inches' :
  6309. 'millimeters'
  6310. ), null,
  6311. this
  6312. ._isNonMetricLocale ?
  6313. 'in' : 'mm'
  6314. ), pageName,
  6315. this.l10n.get(
  6316. 'document_properties_page_size_orientation_' +
  6317. (isPortrait ?
  6318. 'portrait' :
  6319. 'landscape'
  6320. ), null,
  6321. isPortrait ?
  6322. 'portrait' :
  6323. 'landscape')
  6324. ]).then(function(
  6325. _ref6) {
  6326. var _ref7 =
  6327. _slicedToArray(
  6328. _ref6, 4
  6329. ),
  6330. _ref7$ =
  6331. _ref7[0],
  6332. width =
  6333. _ref7$
  6334. .width,
  6335. height =
  6336. _ref7$
  6337. .height,
  6338. unit =
  6339. _ref7[1],
  6340. name =
  6341. _ref7[2],
  6342. orientation =
  6343. _ref7[3];
  6344. return _this3
  6345. .l10n.get(
  6346. 'document_properties_page_size_dimension_' +
  6347. (name ?
  6348. 'name_' :
  6349. ''
  6350. ) +
  6351. 'string', {
  6352. width: width
  6353. .toLocaleString(),
  6354. height: height
  6355. .toLocaleString(),
  6356. unit: unit,
  6357. name: name,
  6358. orientation: orientation
  6359. },
  6360. '{{width}} × {{height}} {{unit}} (' +
  6361. (name ?
  6362. '{{name}}, ' :
  6363. ''
  6364. ) +
  6365. '{{orientation}})'
  6366. );
  6367. }));
  6368. case 11:
  6369. case "end":
  6370. return _context2.stop();
  6371. }
  6372. }
  6373. }, _callee2, this);
  6374. }));
  6375. function _parsePageSize(_x, _x2) {
  6376. return _parsePageSize2.apply(this, arguments);
  6377. }
  6378. return _parsePageSize;
  6379. }()
  6380. }, {
  6381. key: "_parseDate",
  6382. value: function() {
  6383. var _parseDate2 = _asyncToGenerator(
  6384. /*#__PURE__*/
  6385. _regenerator["default"].mark(function _callee3(inputDate) {
  6386. var dateObject;
  6387. return _regenerator["default"].wrap(function _callee3$(
  6388. _context3) {
  6389. while (1) {
  6390. switch (_context3.prev = _context3
  6391. .next) {
  6392. case 0:
  6393. dateObject = _pdfjsLib
  6394. .PDFDateString.toDateObject(
  6395. inputDate);
  6396. if (dateObject) {
  6397. _context3.next = 3;
  6398. break;
  6399. }
  6400. return _context3.abrupt(
  6401. "return", undefined);
  6402. case 3:
  6403. return _context3.abrupt(
  6404. "return", this.l10n.get(
  6405. 'document_properties_date_string', {
  6406. date: dateObject
  6407. .toLocaleDateString(),
  6408. time: dateObject
  6409. .toLocaleTimeString()
  6410. },
  6411. '{{date}}, {{time}}'
  6412. ));
  6413. case 4:
  6414. case "end":
  6415. return _context3.stop();
  6416. }
  6417. }
  6418. }, _callee3, this);
  6419. }));
  6420. function _parseDate(_x3) {
  6421. return _parseDate2.apply(this, arguments);
  6422. }
  6423. return _parseDate;
  6424. }()
  6425. }, {
  6426. key: "_parseLinearization",
  6427. value: function _parseLinearization(isLinearized) {
  6428. return this.l10n.get('document_properties_linearized_' + (isLinearized ?
  6429. 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  6430. }
  6431. }]);
  6432. return PDFDocumentProperties;
  6433. }();
  6434. exports.PDFDocumentProperties = PDFDocumentProperties;
  6435. /***/
  6436. }),
  6437. /* 17 */
  6438. /***/
  6439. (function(module, exports, __webpack_require__) {
  6440. "use strict";
  6441. Object.defineProperty(exports, "__esModule", {
  6442. value: true
  6443. });
  6444. exports.PDFFindBar = void 0;
  6445. var _ui_utils = __webpack_require__(5);
  6446. var _pdf_find_controller = __webpack_require__(18);
  6447. function _classCallCheck(instance, Constructor) {
  6448. if (!(instance instanceof Constructor)) {
  6449. throw new TypeError("Cannot call a class as a function");
  6450. }
  6451. }
  6452. function _defineProperties(target, props) {
  6453. for (var i = 0; i < props.length; i++) {
  6454. var descriptor = props[i];
  6455. descriptor.enumerable = descriptor.enumerable || false;
  6456. descriptor.configurable = true;
  6457. if ("value" in descriptor) descriptor.writable = true;
  6458. Object.defineProperty(target, descriptor.key, descriptor);
  6459. }
  6460. }
  6461. function _createClass(Constructor, protoProps, staticProps) {
  6462. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  6463. if (staticProps) _defineProperties(Constructor, staticProps);
  6464. return Constructor;
  6465. }
  6466. var MATCHES_COUNT_LIMIT = 1000;
  6467. var PDFFindBar =
  6468. /*#__PURE__*/
  6469. function() {
  6470. function PDFFindBar(options) {
  6471. var _this = this;
  6472. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0,
  6473. _ui_utils.getGlobalEventBus)();
  6474. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  6475. .NullL10n;
  6476. _classCallCheck(this, PDFFindBar);
  6477. this.opened = false;
  6478. this.bar = options.bar || null;
  6479. this.toggleButton = options.toggleButton || null;
  6480. this.findField = options.findField || null;
  6481. this.highlightAll = options.highlightAllCheckbox || null;
  6482. this.caseSensitive = options.caseSensitiveCheckbox || null;
  6483. this.entireWord = options.entireWordCheckbox || null;
  6484. this.findMsg = options.findMsg || null;
  6485. this.findResultsCount = options.findResultsCount || null;
  6486. this.findPreviousButton = options.findPreviousButton || null;
  6487. this.findNextButton = options.findNextButton || null;
  6488. this.eventBus = eventBus;
  6489. this.l10n = l10n;
  6490. this.toggleButton.addEventListener('click', function() {
  6491. _this.toggle();
  6492. });
  6493. this.findField.addEventListener('input', function() {
  6494. _this.dispatchEvent('');
  6495. });
  6496. this.bar.addEventListener('keydown', function(e) {
  6497. switch (e.keyCode) {
  6498. case 13:
  6499. if (e.target === _this.findField) {
  6500. _this.dispatchEvent('again', e.shiftKey);
  6501. }
  6502. break;
  6503. case 27:
  6504. _this.close();
  6505. break;
  6506. }
  6507. });
  6508. this.findPreviousButton.addEventListener('click', function() {
  6509. _this.dispatchEvent('again', true);
  6510. });
  6511. this.findNextButton.addEventListener('click', function() {
  6512. _this.dispatchEvent('again', false);
  6513. });
  6514. this.highlightAll.addEventListener('click', function() {
  6515. _this.dispatchEvent('highlightallchange');
  6516. });
  6517. this.caseSensitive.addEventListener('click', function() {
  6518. _this.dispatchEvent('casesensitivitychange');
  6519. });
  6520. this.entireWord.addEventListener('click', function() {
  6521. _this.dispatchEvent('entirewordchange');
  6522. });
  6523. this.eventBus.on('resize', this._adjustWidth.bind(this));
  6524. }
  6525. _createClass(PDFFindBar, [{
  6526. key: "reset",
  6527. value: function reset() {
  6528. this.updateUIState();
  6529. }
  6530. }, {
  6531. key: "dispatchEvent",
  6532. value: function dispatchEvent(type, findPrev) {
  6533. this.eventBus.dispatch('find', {
  6534. source: this,
  6535. type: type,
  6536. query: this.findField.value,
  6537. phraseSearch: true,
  6538. caseSensitive: this.caseSensitive.checked,
  6539. entireWord: this.entireWord.checked,
  6540. highlightAll: this.highlightAll.checked,
  6541. findPrevious: findPrev
  6542. });
  6543. }
  6544. }, {
  6545. key: "updateUIState",
  6546. value: function updateUIState(state, previous, matchesCount) {
  6547. var _this2 = this;
  6548. var notFound = false;
  6549. var findMsg = '';
  6550. var status = '';
  6551. switch (state) {
  6552. case _pdf_find_controller.FindState.FOUND:
  6553. break;
  6554. case _pdf_find_controller.FindState.PENDING:
  6555. status = 'pending';
  6556. break;
  6557. case _pdf_find_controller.FindState.NOT_FOUND:
  6558. findMsg = this.l10n.get('find_not_found', null,
  6559. 'Phrase not found');
  6560. notFound = true;
  6561. break;
  6562. case _pdf_find_controller.FindState.WRAPPED:
  6563. if (previous) {
  6564. findMsg = this.l10n.get('find_reached_top', null,
  6565. 'Reached top of document, continued from bottom');
  6566. } else {
  6567. findMsg = this.l10n.get('find_reached_bottom', null,
  6568. 'Reached end of document, continued from top');
  6569. }
  6570. break;
  6571. }
  6572. this.findField.classList.toggle('notFound', notFound);
  6573. this.findField.setAttribute('data-status', status);
  6574. Promise.resolve(findMsg).then(function(msg) {
  6575. _this2.findMsg.textContent = msg;
  6576. _this2._adjustWidth();
  6577. });
  6578. this.updateResultsCount(matchesCount);
  6579. }
  6580. }, {
  6581. key: "updateResultsCount",
  6582. value: function updateResultsCount() {
  6583. var _this3 = this;
  6584. var _ref = arguments.length > 0 && arguments[0] !== undefined ?
  6585. arguments[0] : {},
  6586. _ref$current = _ref.current,
  6587. current = _ref$current === void 0 ? 0 : _ref$current,
  6588. _ref$total = _ref.total,
  6589. total = _ref$total === void 0 ? 0 : _ref$total;
  6590. if (!this.findResultsCount) {
  6591. return;
  6592. }
  6593. var matchesCountMsg = '',
  6594. limit = MATCHES_COUNT_LIMIT;
  6595. if (total > 0) {
  6596. if (total > limit) {
  6597. matchesCountMsg = this.l10n.get('find_match_count_limit', {
  6598. limit: limit
  6599. }, 'More than {{limit}} match' + (limit !== 1 ? 'es' :
  6600. ''));
  6601. } else {
  6602. matchesCountMsg = this.l10n.get('find_match_count', {
  6603. current: current,
  6604. total: total
  6605. }, '{{current}} of {{total}} match' + (total !== 1 ?
  6606. 'es' : ''));
  6607. }
  6608. }
  6609. Promise.resolve(matchesCountMsg).then(function(msg) {
  6610. _this3.findResultsCount.textContent = msg;
  6611. _this3.findResultsCount.classList.toggle('hidden', !total);
  6612. _this3._adjustWidth();
  6613. });
  6614. }
  6615. }, {
  6616. key: "open",
  6617. value: function open() {
  6618. if (!this.opened) {
  6619. this.opened = true;
  6620. this.toggleButton.classList.add('toggled');
  6621. this.bar.classList.remove('hidden');
  6622. }
  6623. this.findField.select();
  6624. this.findField.focus();
  6625. this._adjustWidth();
  6626. }
  6627. }, {
  6628. key: "close",
  6629. value: function close() {
  6630. if (!this.opened) {
  6631. return;
  6632. }
  6633. this.opened = false;
  6634. this.toggleButton.classList.remove('toggled');
  6635. this.bar.classList.add('hidden');
  6636. this.eventBus.dispatch('findbarclose', {
  6637. source: this
  6638. });
  6639. }
  6640. }, {
  6641. key: "toggle",
  6642. value: function toggle() {
  6643. if (this.opened) {
  6644. this.close();
  6645. } else {
  6646. this.open();
  6647. }
  6648. }
  6649. }, {
  6650. key: "_adjustWidth",
  6651. value: function _adjustWidth() {
  6652. if (!this.opened) {
  6653. return;
  6654. }
  6655. this.bar.classList.remove('wrapContainers');
  6656. var findbarHeight = this.bar.clientHeight;
  6657. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6658. if (findbarHeight > inputContainerHeight) {
  6659. this.bar.classList.add('wrapContainers');
  6660. }
  6661. }
  6662. }]);
  6663. return PDFFindBar;
  6664. }();
  6665. exports.PDFFindBar = PDFFindBar;
  6666. /***/
  6667. }),
  6668. /* 18 */
  6669. /***/
  6670. (function(module, exports, __webpack_require__) {
  6671. "use strict";
  6672. Object.defineProperty(exports, "__esModule", {
  6673. value: true
  6674. });
  6675. exports.PDFFindController = exports.FindState = void 0;
  6676. var _ui_utils = __webpack_require__(5);
  6677. var _pdfjsLib = __webpack_require__(7);
  6678. var _pdf_find_utils = __webpack_require__(19);
  6679. function _classCallCheck(instance, Constructor) {
  6680. if (!(instance instanceof Constructor)) {
  6681. throw new TypeError("Cannot call a class as a function");
  6682. }
  6683. }
  6684. function _defineProperties(target, props) {
  6685. for (var i = 0; i < props.length; i++) {
  6686. var descriptor = props[i];
  6687. descriptor.enumerable = descriptor.enumerable || false;
  6688. descriptor.configurable = true;
  6689. if ("value" in descriptor) descriptor.writable = true;
  6690. Object.defineProperty(target, descriptor.key, descriptor);
  6691. }
  6692. }
  6693. function _createClass(Constructor, protoProps, staticProps) {
  6694. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  6695. if (staticProps) _defineProperties(Constructor, staticProps);
  6696. return Constructor;
  6697. }
  6698. var FindState = {
  6699. FOUND: 0,
  6700. NOT_FOUND: 1,
  6701. WRAPPED: 2,
  6702. PENDING: 3
  6703. };
  6704. exports.FindState = FindState;
  6705. var FIND_TIMEOUT = 250;
  6706. var MATCH_SCROLL_OFFSET_TOP = -50;
  6707. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6708. var CHARACTERS_TO_NORMALIZE = {
  6709. "\u2018": '\'',
  6710. "\u2019": '\'',
  6711. "\u201A": '\'',
  6712. "\u201B": '\'',
  6713. "\u201C": '"',
  6714. "\u201D": '"',
  6715. "\u201E": '"',
  6716. "\u201F": '"',
  6717. "\xBC": '1/4',
  6718. "\xBD": '1/2',
  6719. "\xBE": '3/4'
  6720. };
  6721. var normalizationRegex = null;
  6722. function normalize(text) {
  6723. if (!normalizationRegex) {
  6724. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  6725. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  6726. }
  6727. return text.replace(normalizationRegex, function(ch) {
  6728. return CHARACTERS_TO_NORMALIZE[ch];
  6729. });
  6730. }
  6731. var PDFFindController =
  6732. /*#__PURE__*/
  6733. function() {
  6734. function PDFFindController(_ref) {
  6735. var linkService = _ref.linkService,
  6736. _ref$eventBus = _ref.eventBus,
  6737. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() :
  6738. _ref$eventBus;
  6739. _classCallCheck(this, PDFFindController);
  6740. this._linkService = linkService;
  6741. this._eventBus = eventBus;
  6742. this._reset();
  6743. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  6744. }
  6745. _createClass(PDFFindController, [{
  6746. key: "setDocument",
  6747. value: function setDocument(pdfDocument) {
  6748. if (this._pdfDocument) {
  6749. this._reset();
  6750. }
  6751. if (!pdfDocument) {
  6752. return;
  6753. }
  6754. this._pdfDocument = pdfDocument;
  6755. this._firstPageCapability.resolve();
  6756. }
  6757. }, {
  6758. key: "executeCommand",
  6759. value: function executeCommand(cmd, state) {
  6760. var _this = this;
  6761. if (!state) {
  6762. return;
  6763. }
  6764. var pdfDocument = this._pdfDocument;
  6765. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6766. this._dirtyMatch = true;
  6767. }
  6768. this._state = state;
  6769. if (cmd !== 'findhighlightallchange') {
  6770. this._updateUIState(FindState.PENDING);
  6771. }
  6772. this._firstPageCapability.promise.then(function() {
  6773. if (!_this._pdfDocument || pdfDocument && _this
  6774. ._pdfDocument !== pdfDocument) {
  6775. return;
  6776. }
  6777. _this._extractText();
  6778. var findbarClosed = !_this._highlightMatches;
  6779. var pendingTimeout = !!_this._findTimeout;
  6780. if (_this._findTimeout) {
  6781. clearTimeout(_this._findTimeout);
  6782. _this._findTimeout = null;
  6783. }
  6784. if (cmd === 'find') {
  6785. _this._findTimeout = setTimeout(function() {
  6786. _this._nextMatch();
  6787. _this._findTimeout = null;
  6788. }, FIND_TIMEOUT);
  6789. } else if (_this._dirtyMatch) {
  6790. _this._nextMatch();
  6791. } else if (cmd === 'findagain') {
  6792. _this._nextMatch();
  6793. if (findbarClosed && _this._state.highlightAll) {
  6794. _this._updateAllPages();
  6795. }
  6796. } else if (cmd === 'findhighlightallchange') {
  6797. if (pendingTimeout) {
  6798. _this._nextMatch();
  6799. } else {
  6800. _this._highlightMatches = true;
  6801. }
  6802. _this._updateAllPages();
  6803. } else {
  6804. _this._nextMatch();
  6805. }
  6806. });
  6807. }
  6808. }, {
  6809. key: "scrollMatchIntoView",
  6810. value: function scrollMatchIntoView(_ref2) {
  6811. var _ref2$element = _ref2.element,
  6812. element = _ref2$element === void 0 ? null : _ref2$element,
  6813. _ref2$pageIndex = _ref2.pageIndex,
  6814. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6815. _ref2$matchIndex = _ref2.matchIndex,
  6816. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6817. if (!this._scrollMatches || !element) {
  6818. return;
  6819. } else if (matchIndex === -1 || matchIndex !== this._selected
  6820. .matchIdx) {
  6821. return;
  6822. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6823. return;
  6824. }
  6825. this._scrollMatches = false;
  6826. var spot = {
  6827. top: MATCH_SCROLL_OFFSET_TOP,
  6828. left: MATCH_SCROLL_OFFSET_LEFT
  6829. };
  6830. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6831. }
  6832. }, {
  6833. key: "_reset",
  6834. value: function _reset() {
  6835. this._highlightMatches = false;
  6836. this._scrollMatches = false;
  6837. this._pdfDocument = null;
  6838. this._pageMatches = [];
  6839. this._pageMatchesLength = [];
  6840. this._state = null;
  6841. this._selected = {
  6842. pageIdx: -1,
  6843. matchIdx: -1
  6844. };
  6845. this._offset = {
  6846. pageIdx: null,
  6847. matchIdx: null,
  6848. wrapped: false
  6849. };
  6850. this._extractTextPromises = [];
  6851. this._pageContents = [];
  6852. this._matchesCountTotal = 0;
  6853. this._pagesToSearch = null;
  6854. this._pendingFindMatches = Object.create(null);
  6855. this._resumePageIdx = null;
  6856. this._dirtyMatch = false;
  6857. clearTimeout(this._findTimeout);
  6858. this._findTimeout = null;
  6859. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6860. }
  6861. }, {
  6862. key: "_shouldDirtyMatch",
  6863. value: function _shouldDirtyMatch(cmd, state) {
  6864. if (state.query !== this._state.query) {
  6865. return true;
  6866. }
  6867. switch (cmd) {
  6868. case 'findagain':
  6869. var pageNumber = this._selected.pageIdx + 1;
  6870. var linkService = this._linkService;
  6871. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount &&
  6872. pageNumber !== linkService.page && !linkService
  6873. .isPageVisible(pageNumber)) {
  6874. return true;
  6875. }
  6876. return false;
  6877. case 'findhighlightallchange':
  6878. return false;
  6879. }
  6880. return true;
  6881. }
  6882. }, {
  6883. key: "_prepareMatches",
  6884. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6885. function isSubTerm(matchesWithLength, currentIndex) {
  6886. var currentElem = matchesWithLength[currentIndex];
  6887. var nextElem = matchesWithLength[currentIndex + 1];
  6888. if (currentIndex < matchesWithLength.length - 1 && currentElem
  6889. .match === nextElem.match) {
  6890. currentElem.skipped = true;
  6891. return true;
  6892. }
  6893. for (var i = currentIndex - 1; i >= 0; i--) {
  6894. var prevElem = matchesWithLength[i];
  6895. if (prevElem.skipped) {
  6896. continue;
  6897. }
  6898. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6899. break;
  6900. }
  6901. if (prevElem.match + prevElem.matchLength >= currentElem.match +
  6902. currentElem.matchLength) {
  6903. currentElem.skipped = true;
  6904. return true;
  6905. }
  6906. }
  6907. return false;
  6908. }
  6909. matchesWithLength.sort(function(a, b) {
  6910. return a.match === b.match ? a.matchLength - b.matchLength :
  6911. a.match - b.match;
  6912. });
  6913. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6914. if (isSubTerm(matchesWithLength, i)) {
  6915. continue;
  6916. }
  6917. matches.push(matchesWithLength[i].match);
  6918. matchesLength.push(matchesWithLength[i].matchLength);
  6919. }
  6920. }
  6921. }, {
  6922. key: "_isEntireWord",
  6923. value: function _isEntireWord(content, startIdx, length) {
  6924. if (startIdx > 0) {
  6925. var first = content.charCodeAt(startIdx);
  6926. var limit = content.charCodeAt(startIdx - 1);
  6927. if ((0, _pdf_find_utils.getCharacterType)(first) === (0,
  6928. _pdf_find_utils.getCharacterType)(limit)) {
  6929. return false;
  6930. }
  6931. }
  6932. var endIdx = startIdx + length - 1;
  6933. if (endIdx < content.length - 1) {
  6934. var last = content.charCodeAt(endIdx);
  6935. var _limit = content.charCodeAt(endIdx + 1);
  6936. if ((0, _pdf_find_utils.getCharacterType)(last) === (0,
  6937. _pdf_find_utils.getCharacterType)(_limit)) {
  6938. return false;
  6939. }
  6940. }
  6941. return true;
  6942. }
  6943. }, {
  6944. key: "_calculatePhraseMatch",
  6945. value: function _calculatePhraseMatch(query, pageIndex, pageContent,
  6946. entireWord) {
  6947. var matches = [];
  6948. var queryLen = query.length;
  6949. var matchIdx = -queryLen;
  6950. while (true) {
  6951. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6952. if (matchIdx === -1) {
  6953. break;
  6954. }
  6955. if (entireWord && !this._isEntireWord(pageContent, matchIdx,
  6956. queryLen)) {
  6957. continue;
  6958. }
  6959. matches.push(matchIdx);
  6960. }
  6961. this._pageMatches[pageIndex] = matches;
  6962. }
  6963. }, {
  6964. key: "_calculateWordMatch",
  6965. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6966. var matchesWithLength = [];
  6967. var queryArray = query.match(/\S+/g);
  6968. for (var i = 0, len = queryArray.length; i < len; i++) {
  6969. var subquery = queryArray[i];
  6970. var subqueryLen = subquery.length;
  6971. var matchIdx = -subqueryLen;
  6972. while (true) {
  6973. matchIdx = pageContent.indexOf(subquery, matchIdx +
  6974. subqueryLen);
  6975. if (matchIdx === -1) {
  6976. break;
  6977. }
  6978. if (entireWord && !this._isEntireWord(pageContent, matchIdx,
  6979. subqueryLen)) {
  6980. continue;
  6981. }
  6982. matchesWithLength.push({
  6983. match: matchIdx,
  6984. matchLength: subqueryLen,
  6985. skipped: false
  6986. });
  6987. }
  6988. }
  6989. this._pageMatchesLength[pageIndex] = [];
  6990. this._pageMatches[pageIndex] = [];
  6991. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex],
  6992. this._pageMatchesLength[pageIndex]);
  6993. }
  6994. }, {
  6995. key: "_calculateMatch",
  6996. value: function _calculateMatch(pageIndex) {
  6997. var pageContent = this._pageContents[pageIndex];
  6998. var query = this._query;
  6999. var _this$_state = this._state,
  7000. caseSensitive = _this$_state.caseSensitive,
  7001. entireWord = _this$_state.entireWord,
  7002. phraseSearch = _this$_state.phraseSearch;
  7003. if (query.length === 0) {
  7004. return;
  7005. }
  7006. if (!caseSensitive) {
  7007. pageContent = pageContent.toLowerCase();
  7008. query = query.toLowerCase();
  7009. }
  7010. if (phraseSearch) {
  7011. this._calculatePhraseMatch(query, pageIndex, pageContent,
  7012. entireWord);
  7013. } else {
  7014. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  7015. }
  7016. if (this._state.highlightAll) {
  7017. this._updatePage(pageIndex);
  7018. }
  7019. if (this._resumePageIdx === pageIndex) {
  7020. this._resumePageIdx = null;
  7021. this._nextPageMatch();
  7022. }
  7023. var pageMatchesCount = this._pageMatches[pageIndex].length;
  7024. if (pageMatchesCount > 0) {
  7025. this._matchesCountTotal += pageMatchesCount;
  7026. this._updateUIResultsCount();
  7027. }
  7028. }
  7029. }, {
  7030. key: "_extractText",
  7031. value: function _extractText() {
  7032. var _this2 = this;
  7033. if (this._extractTextPromises.length > 0) {
  7034. return;
  7035. }
  7036. var promise = Promise.resolve();
  7037. var _loop = function _loop(i, ii) {
  7038. var extractTextCapability = (0, _pdfjsLib
  7039. .createPromiseCapability)();
  7040. _this2._extractTextPromises[i] = extractTextCapability.promise;
  7041. promise = promise.then(function() {
  7042. return _this2._pdfDocument.getPage(i + 1).then(
  7043. function(pdfPage) {
  7044. return pdfPage.getTextContent({
  7045. normalizeWhitespace: true
  7046. });
  7047. }).then(function(textContent) {
  7048. var textItems = textContent.items;
  7049. var strBuf = [];
  7050. for (var j = 0, jj = textItems
  7051. .length; j < jj; j++) {
  7052. strBuf.push(textItems[j].str);
  7053. }
  7054. _this2._pageContents[i] = normalize(
  7055. strBuf.join(''));
  7056. extractTextCapability.resolve(i);
  7057. }, function(reason) {
  7058. console.error(
  7059. "Unable to get text content for page "
  7060. .concat(i + 1), reason);
  7061. _this2._pageContents[i] = '';
  7062. extractTextCapability.resolve(i);
  7063. });
  7064. });
  7065. };
  7066. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  7067. _loop(i, ii);
  7068. }
  7069. }
  7070. }, {
  7071. key: "_updatePage",
  7072. value: function _updatePage(index) {
  7073. if (this._scrollMatches && this._selected.pageIdx === index) {
  7074. this._linkService.page = index + 1;
  7075. }
  7076. this._eventBus.dispatch('updatetextlayermatches', {
  7077. source: this,
  7078. pageIndex: index
  7079. });
  7080. }
  7081. }, {
  7082. key: "_updateAllPages",
  7083. value: function _updateAllPages() {
  7084. this._eventBus.dispatch('updatetextlayermatches', {
  7085. source: this,
  7086. pageIndex: -1
  7087. });
  7088. }
  7089. }, {
  7090. key: "_nextMatch",
  7091. value: function _nextMatch() {
  7092. var _this3 = this;
  7093. var previous = this._state.findPrevious;
  7094. var currentPageIndex = this._linkService.page - 1;
  7095. var numPages = this._linkService.pagesCount;
  7096. this._highlightMatches = true;
  7097. if (this._dirtyMatch) {
  7098. this._dirtyMatch = false;
  7099. this._selected.pageIdx = this._selected.matchIdx = -1;
  7100. this._offset.pageIdx = currentPageIndex;
  7101. this._offset.matchIdx = null;
  7102. this._offset.wrapped = false;
  7103. this._resumePageIdx = null;
  7104. this._pageMatches.length = 0;
  7105. this._pageMatchesLength.length = 0;
  7106. this._matchesCountTotal = 0;
  7107. this._updateAllPages();
  7108. for (var i = 0; i < numPages; i++) {
  7109. if (this._pendingFindMatches[i] === true) {
  7110. continue;
  7111. }
  7112. this._pendingFindMatches[i] = true;
  7113. this._extractTextPromises[i].then(function(pageIdx) {
  7114. delete _this3._pendingFindMatches[pageIdx];
  7115. _this3._calculateMatch(pageIdx);
  7116. });
  7117. }
  7118. }
  7119. if (this._query === '') {
  7120. this._updateUIState(FindState.FOUND);
  7121. return;
  7122. }
  7123. if (this._resumePageIdx) {
  7124. return;
  7125. }
  7126. var offset = this._offset;
  7127. this._pagesToSearch = numPages;
  7128. if (offset.matchIdx !== null) {
  7129. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  7130. if (!previous && offset.matchIdx + 1 < numPageMatches || previous &&
  7131. offset.matchIdx > 0) {
  7132. offset.matchIdx = previous ? offset.matchIdx - 1 : offset
  7133. .matchIdx + 1;
  7134. this._updateMatch(true);
  7135. return;
  7136. }
  7137. this._advanceOffsetPage(previous);
  7138. }
  7139. this._nextPageMatch();
  7140. }
  7141. }, {
  7142. key: "_matchesReady",
  7143. value: function _matchesReady(matches) {
  7144. var offset = this._offset;
  7145. var numMatches = matches.length;
  7146. var previous = this._state.findPrevious;
  7147. if (numMatches) {
  7148. offset.matchIdx = previous ? numMatches - 1 : 0;
  7149. this._updateMatch(true);
  7150. return true;
  7151. }
  7152. this._advanceOffsetPage(previous);
  7153. if (offset.wrapped) {
  7154. offset.matchIdx = null;
  7155. if (this._pagesToSearch < 0) {
  7156. this._updateMatch(false);
  7157. return true;
  7158. }
  7159. }
  7160. return false;
  7161. }
  7162. }, {
  7163. key: "_nextPageMatch",
  7164. value: function _nextPageMatch() {
  7165. if (this._resumePageIdx !== null) {
  7166. console.error('There can only be one pending page.');
  7167. }
  7168. var matches = null;
  7169. do {
  7170. var pageIdx = this._offset.pageIdx;
  7171. matches = this._pageMatches[pageIdx];
  7172. if (!matches) {
  7173. this._resumePageIdx = pageIdx;
  7174. break;
  7175. }
  7176. } while (!this._matchesReady(matches));
  7177. }
  7178. }, {
  7179. key: "_advanceOffsetPage",
  7180. value: function _advanceOffsetPage(previous) {
  7181. var offset = this._offset;
  7182. var numPages = this._linkService.pagesCount;
  7183. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7184. offset.matchIdx = null;
  7185. this._pagesToSearch--;
  7186. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7187. offset.pageIdx = previous ? numPages - 1 : 0;
  7188. offset.wrapped = true;
  7189. }
  7190. }
  7191. }, {
  7192. key: "_updateMatch",
  7193. value: function _updateMatch() {
  7194. var found = arguments.length > 0 && arguments[0] !== undefined ?
  7195. arguments[0] : false;
  7196. var state = FindState.NOT_FOUND;
  7197. var wrapped = this._offset.wrapped;
  7198. this._offset.wrapped = false;
  7199. if (found) {
  7200. var previousPage = this._selected.pageIdx;
  7201. this._selected.pageIdx = this._offset.pageIdx;
  7202. this._selected.matchIdx = this._offset.matchIdx;
  7203. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7204. if (previousPage !== -1 && previousPage !== this._selected
  7205. .pageIdx) {
  7206. this._updatePage(previousPage);
  7207. }
  7208. }
  7209. this._updateUIState(state, this._state.findPrevious);
  7210. if (this._selected.pageIdx !== -1) {
  7211. this._scrollMatches = true;
  7212. this._updatePage(this._selected.pageIdx);
  7213. }
  7214. }
  7215. }, {
  7216. key: "_onFindBarClose",
  7217. value: function _onFindBarClose(evt) {
  7218. var _this4 = this;
  7219. var pdfDocument = this._pdfDocument;
  7220. this._firstPageCapability.promise.then(function() {
  7221. if (!_this4._pdfDocument || pdfDocument && _this4
  7222. ._pdfDocument !== pdfDocument) {
  7223. return;
  7224. }
  7225. if (_this4._findTimeout) {
  7226. clearTimeout(_this4._findTimeout);
  7227. _this4._findTimeout = null;
  7228. }
  7229. if (_this4._resumePageIdx) {
  7230. _this4._resumePageIdx = null;
  7231. _this4._dirtyMatch = true;
  7232. }
  7233. _this4._updateUIState(FindState.FOUND);
  7234. _this4._highlightMatches = false;
  7235. _this4._updateAllPages();
  7236. });
  7237. }
  7238. }, {
  7239. key: "_requestMatchesCount",
  7240. value: function _requestMatchesCount() {
  7241. var _this$_selected = this._selected,
  7242. pageIdx = _this$_selected.pageIdx,
  7243. matchIdx = _this$_selected.matchIdx;
  7244. var current = 0,
  7245. total = this._matchesCountTotal;
  7246. if (matchIdx !== -1) {
  7247. for (var i = 0; i < pageIdx; i++) {
  7248. current += this._pageMatches[i] && this._pageMatches[i]
  7249. .length || 0;
  7250. }
  7251. current += matchIdx + 1;
  7252. }
  7253. if (current < 1 || current > total) {
  7254. current = total = 0;
  7255. }
  7256. return {
  7257. current: current,
  7258. total: total
  7259. };
  7260. }
  7261. }, {
  7262. key: "_updateUIResultsCount",
  7263. value: function _updateUIResultsCount() {
  7264. this._eventBus.dispatch('updatefindmatchescount', {
  7265. source: this,
  7266. matchesCount: this._requestMatchesCount()
  7267. });
  7268. }
  7269. }, {
  7270. key: "_updateUIState",
  7271. value: function _updateUIState(state, previous) {
  7272. this._eventBus.dispatch('updatefindcontrolstate', {
  7273. source: this,
  7274. state: state,
  7275. previous: previous,
  7276. matchesCount: this._requestMatchesCount()
  7277. });
  7278. }
  7279. }, {
  7280. key: "highlightMatches",
  7281. get: function get() {
  7282. return this._highlightMatches;
  7283. }
  7284. }, {
  7285. key: "pageMatches",
  7286. get: function get() {
  7287. return this._pageMatches;
  7288. }
  7289. }, {
  7290. key: "pageMatchesLength",
  7291. get: function get() {
  7292. return this._pageMatchesLength;
  7293. }
  7294. }, {
  7295. key: "selected",
  7296. get: function get() {
  7297. return this._selected;
  7298. }
  7299. }, {
  7300. key: "state",
  7301. get: function get() {
  7302. return this._state;
  7303. }
  7304. }, {
  7305. key: "_query",
  7306. get: function get() {
  7307. if (this._state.query !== this._rawQuery) {
  7308. this._rawQuery = this._state.query;
  7309. this._normalizedQuery = normalize(this._state.query);
  7310. }
  7311. return this._normalizedQuery;
  7312. }
  7313. }]);
  7314. return PDFFindController;
  7315. }();
  7316. exports.PDFFindController = PDFFindController;
  7317. /***/
  7318. }),
  7319. /* 19 */
  7320. /***/
  7321. (function(module, exports, __webpack_require__) {
  7322. "use strict";
  7323. Object.defineProperty(exports, "__esModule", {
  7324. value: true
  7325. });
  7326. exports.getCharacterType = getCharacterType;
  7327. exports.CharacterType = void 0;
  7328. var CharacterType = {
  7329. SPACE: 0,
  7330. ALPHA_LETTER: 1,
  7331. PUNCT: 2,
  7332. HAN_LETTER: 3,
  7333. KATAKANA_LETTER: 4,
  7334. HIRAGANA_LETTER: 5,
  7335. HALFWIDTH_KATAKANA_LETTER: 6,
  7336. THAI_LETTER: 7
  7337. };
  7338. exports.CharacterType = CharacterType;
  7339. function isAlphabeticalScript(charCode) {
  7340. return charCode < 0x2E80;
  7341. }
  7342. function isAscii(charCode) {
  7343. return (charCode & 0xFF80) === 0;
  7344. }
  7345. function isAsciiAlpha(charCode) {
  7346. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  7347. }
  7348. function isAsciiDigit(charCode) {
  7349. return charCode >= 0x30 && charCode <= 0x39;
  7350. }
  7351. function isAsciiSpace(charCode) {
  7352. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  7353. }
  7354. function isHan(charCode) {
  7355. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  7356. }
  7357. function isKatakana(charCode) {
  7358. return charCode >= 0x30A0 && charCode <= 0x30FF;
  7359. }
  7360. function isHiragana(charCode) {
  7361. return charCode >= 0x3040 && charCode <= 0x309F;
  7362. }
  7363. function isHalfwidthKatakana(charCode) {
  7364. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  7365. }
  7366. function isThai(charCode) {
  7367. return (charCode & 0xFF80) === 0x0E00;
  7368. }
  7369. function getCharacterType(charCode) {
  7370. if (isAlphabeticalScript(charCode)) {
  7371. if (isAscii(charCode)) {
  7372. if (isAsciiSpace(charCode)) {
  7373. return CharacterType.SPACE;
  7374. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  7375. return CharacterType.ALPHA_LETTER;
  7376. }
  7377. return CharacterType.PUNCT;
  7378. } else if (isThai(charCode)) {
  7379. return CharacterType.THAI_LETTER;
  7380. } else if (charCode === 0xA0) {
  7381. return CharacterType.SPACE;
  7382. }
  7383. return CharacterType.ALPHA_LETTER;
  7384. }
  7385. if (isHan(charCode)) {
  7386. return CharacterType.HAN_LETTER;
  7387. } else if (isKatakana(charCode)) {
  7388. return CharacterType.KATAKANA_LETTER;
  7389. } else if (isHiragana(charCode)) {
  7390. return CharacterType.HIRAGANA_LETTER;
  7391. } else if (isHalfwidthKatakana(charCode)) {
  7392. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7393. }
  7394. return CharacterType.ALPHA_LETTER;
  7395. }
  7396. /***/
  7397. }),
  7398. /* 20 */
  7399. /***/
  7400. (function(module, exports, __webpack_require__) {
  7401. "use strict";
  7402. Object.defineProperty(exports, "__esModule", {
  7403. value: true
  7404. });
  7405. exports.isDestHashesEqual = isDestHashesEqual;
  7406. exports.isDestArraysEqual = isDestArraysEqual;
  7407. exports.PDFHistory = void 0;
  7408. var _ui_utils = __webpack_require__(5);
  7409. function _typeof(obj) {
  7410. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  7411. _typeof = function _typeof(obj) {
  7412. return typeof obj;
  7413. };
  7414. } else {
  7415. _typeof = function _typeof(obj) {
  7416. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  7417. Symbol.prototype ? "symbol" : typeof obj;
  7418. };
  7419. }
  7420. return _typeof(obj);
  7421. }
  7422. function _slicedToArray(arr, i) {
  7423. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  7424. }
  7425. function _nonIterableRest() {
  7426. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  7427. }
  7428. function _iterableToArrayLimit(arr, i) {
  7429. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  7430. "[object Arguments]")) {
  7431. return;
  7432. }
  7433. var _arr = [];
  7434. var _n = true;
  7435. var _d = false;
  7436. var _e = undefined;
  7437. try {
  7438. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  7439. _arr.push(_s.value);
  7440. if (i && _arr.length === i) break;
  7441. }
  7442. } catch (err) {
  7443. _d = true;
  7444. _e = err;
  7445. } finally {
  7446. try {
  7447. if (!_n && _i["return"] != null) _i["return"]();
  7448. } finally {
  7449. if (_d) throw _e;
  7450. }
  7451. }
  7452. return _arr;
  7453. }
  7454. function _arrayWithHoles(arr) {
  7455. if (Array.isArray(arr)) return arr;
  7456. }
  7457. function _classCallCheck(instance, Constructor) {
  7458. if (!(instance instanceof Constructor)) {
  7459. throw new TypeError("Cannot call a class as a function");
  7460. }
  7461. }
  7462. function _defineProperties(target, props) {
  7463. for (var i = 0; i < props.length; i++) {
  7464. var descriptor = props[i];
  7465. descriptor.enumerable = descriptor.enumerable || false;
  7466. descriptor.configurable = true;
  7467. if ("value" in descriptor) descriptor.writable = true;
  7468. Object.defineProperty(target, descriptor.key, descriptor);
  7469. }
  7470. }
  7471. function _createClass(Constructor, protoProps, staticProps) {
  7472. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7473. if (staticProps) _defineProperties(Constructor, staticProps);
  7474. return Constructor;
  7475. }
  7476. var HASH_CHANGE_TIMEOUT = 1000;
  7477. var POSITION_UPDATED_THRESHOLD = 50;
  7478. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  7479. function getCurrentHash() {
  7480. return document.location.hash;
  7481. }
  7482. function parseCurrentHash(linkService) {
  7483. var hash = unescape(getCurrentHash()).substring(1);
  7484. var params = (0, _ui_utils.parseQueryString)(hash);
  7485. var page = params.page | 0;
  7486. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  7487. page = null;
  7488. }
  7489. return {
  7490. hash: hash,
  7491. page: page,
  7492. rotation: linkService.rotation
  7493. };
  7494. }
  7495. var PDFHistory =
  7496. /*#__PURE__*/
  7497. function() {
  7498. function PDFHistory(_ref) {
  7499. var _this = this;
  7500. var linkService = _ref.linkService,
  7501. eventBus = _ref.eventBus;
  7502. _classCallCheck(this, PDFHistory);
  7503. this.linkService = linkService;
  7504. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  7505. this.initialized = false;
  7506. this.initialBookmark = null;
  7507. this.initialRotation = null;
  7508. this._boundEvents = Object.create(null);
  7509. this._isViewerInPresentationMode = false;
  7510. this._isPagesLoaded = false;
  7511. this.eventBus.on('presentationmodechanged', function(evt) {
  7512. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  7513. });
  7514. this.eventBus.on('pagesloaded', function(evt) {
  7515. _this._isPagesLoaded = !!evt.pagesCount;
  7516. });
  7517. }
  7518. //pdf预览历史
  7519. _createClass(PDFHistory, [{
  7520. key: "initialize",
  7521. value: function initialize(_ref2) {
  7522. var fingerprint = _ref2.fingerprint,
  7523. _ref2$resetHistory = _ref2.resetHistory,
  7524. resetHistory = _ref2$resetHistory === void 0 ? false :
  7525. _ref2$resetHistory,
  7526. _ref2$updateUrl = _ref2.updateUrl,
  7527. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  7528. if (!fingerprint || typeof fingerprint !== 'string') {
  7529. console.error(
  7530. 'PDFHistory.initialize: The "fingerprint" must be a non-empty string.'
  7531. );
  7532. return;
  7533. }
  7534. var reInitialized = this.initialized && this.fingerprint !==
  7535. fingerprint;
  7536. this.fingerprint = fingerprint;
  7537. this._updateUrl = updateUrl === true;
  7538. if (!this.initialized) {
  7539. this._bindEvents();
  7540. }
  7541. var state = window.history.state;
  7542. this.initialized = true;
  7543. this.initialBookmark = null;
  7544. this.initialRotation = null;
  7545. this._popStateInProgress = false;
  7546. this._blockHashChange = 0;
  7547. this._currentHash = getCurrentHash();
  7548. this._numPositionUpdates = 0;
  7549. this._uid = this._maxUid = 0;
  7550. this._destination = null;
  7551. this._position = null;
  7552. if (!this._isValidState(state, true) || resetHistory) {
  7553. var _parseCurrentHash = parseCurrentHash(this.linkService),
  7554. hash = _parseCurrentHash.hash,
  7555. page = _parseCurrentHash.page,
  7556. rotation = _parseCurrentHash.rotation;
  7557. if (!hash || reInitialized || resetHistory) {
  7558. this._pushOrReplaceState(null, true);
  7559. return;
  7560. }
  7561. this._pushOrReplaceState({
  7562. hash: hash,
  7563. page: page,
  7564. rotation: rotation
  7565. }, true);
  7566. return;
  7567. }
  7568. var destination = state.destination;
  7569. this._updateInternalState(destination, state.uid, true);
  7570. if (this._uid > this._maxUid) {
  7571. this._maxUid = this._uid;
  7572. }
  7573. if (destination.rotation !== undefined) {
  7574. this.initialRotation = destination.rotation;
  7575. }
  7576. if (destination.dest) {
  7577. this.initialBookmark = JSON.stringify(destination.dest);
  7578. this._destination.page = null;
  7579. } else if (destination.hash) {
  7580. this.initialBookmark = destination.hash;
  7581. } else if (destination.page) {
  7582. this.initialBookmark = "page=".concat(destination.page);
  7583. }
  7584. }
  7585. }, {
  7586. key: "push",
  7587. value: function push(_ref3) {
  7588. var _this2 = this;
  7589. var _ref3$namedDest = _ref3.namedDest,
  7590. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  7591. explicitDest = _ref3.explicitDest,
  7592. pageNumber = _ref3.pageNumber;
  7593. if (!this.initialized) {
  7594. return;
  7595. }
  7596. if (namedDest && typeof namedDest !== 'string') {
  7597. console.error('PDFHistory.push: ' + "\"".concat(namedDest,
  7598. "\" is not a valid namedDest parameter."));
  7599. return;
  7600. } else if (!Array.isArray(explicitDest)) {
  7601. console.error('PDFHistory.push: ' + "\"".concat(explicitDest,
  7602. "\" is not a valid explicitDest parameter."));
  7603. return;
  7604. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 &&
  7605. pageNumber <= this.linkService.pagesCount)) {
  7606. if (pageNumber !== null || this._destination) {
  7607. console.error('PDFHistory.push: ' + "\"".concat(pageNumber,
  7608. "\" is not a valid pageNumber parameter."));
  7609. return;
  7610. }
  7611. }
  7612. var hash = namedDest || JSON.stringify(explicitDest);
  7613. if (!hash) {
  7614. return;
  7615. }
  7616. var forceReplace = false;
  7617. if (this._destination && (isDestHashesEqual(this._destination.hash,
  7618. hash) || isDestArraysEqual(this._destination.dest,
  7619. explicitDest))) {
  7620. if (this._destination.page) {
  7621. return;
  7622. }
  7623. forceReplace = true;
  7624. }
  7625. if (this._popStateInProgress && !forceReplace) {
  7626. return;
  7627. }
  7628. this._pushOrReplaceState({
  7629. dest: explicitDest,
  7630. hash: hash,
  7631. page: pageNumber,
  7632. rotation: this.linkService.rotation
  7633. }, forceReplace);
  7634. if (!this._popStateInProgress) {
  7635. this._popStateInProgress = true;
  7636. Promise.resolve().then(function() {
  7637. _this2._popStateInProgress = false;
  7638. });
  7639. }
  7640. }
  7641. }, {
  7642. key: "pushCurrentPosition",
  7643. value: function pushCurrentPosition() {
  7644. if (!this.initialized || this._popStateInProgress) {
  7645. return;
  7646. }
  7647. this._tryPushCurrentPosition();
  7648. }
  7649. }, {
  7650. key: "back",
  7651. value: function back() {
  7652. if (!this.initialized || this._popStateInProgress) {
  7653. return;
  7654. }
  7655. var state = window.history.state;
  7656. if (this._isValidState(state) && state.uid > 0) {
  7657. window.history.back();
  7658. }
  7659. }
  7660. }, {
  7661. key: "forward",
  7662. value: function forward() {
  7663. if (!this.initialized || this._popStateInProgress) {
  7664. return;
  7665. }
  7666. var state = window.history.state;
  7667. if (this._isValidState(state) && state.uid < this._maxUid) {
  7668. window.history.forward();
  7669. }
  7670. }
  7671. }, {
  7672. key: "_pushOrReplaceState",
  7673. value: function _pushOrReplaceState(destination) {
  7674. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ?
  7675. arguments[1] : false;
  7676. var shouldReplace = forceReplace || !this._destination;
  7677. var newState = {
  7678. fingerprint: this.fingerprint,
  7679. uid: shouldReplace ? this._uid : this._uid + 1,
  7680. destination: destination
  7681. };
  7682. this._updateInternalState(destination, newState.uid);
  7683. var newUrl;
  7684. if (this._updateUrl && destination && destination.hash) {
  7685. var baseUrl = document.location.href.split('#')[0];
  7686. if (!baseUrl.startsWith('file://')) {
  7687. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7688. }
  7689. }
  7690. if (shouldReplace) {
  7691. if (newUrl) {
  7692. window.history.replaceState(newState, '', newUrl);
  7693. } else {
  7694. window.history.replaceState(newState, '');
  7695. }
  7696. } else {
  7697. this._maxUid = this._uid;
  7698. if (newUrl) {
  7699. window.history.pushState(newState, '', newUrl);
  7700. } else {
  7701. window.history.pushState(newState, '');
  7702. }
  7703. }
  7704. }
  7705. }, {
  7706. key: "_tryPushCurrentPosition",
  7707. value: function _tryPushCurrentPosition() {
  7708. var temporary = arguments.length > 0 && arguments[0] !== undefined ?
  7709. arguments[0] : false;
  7710. if (!this._position) {
  7711. return;
  7712. }
  7713. var position = this._position;
  7714. if (temporary) {
  7715. position = Object.assign(Object.create(null), this._position);
  7716. position.temporary = true;
  7717. }
  7718. if (!this._destination) {
  7719. this._pushOrReplaceState(position);
  7720. return;
  7721. }
  7722. if (this._destination.temporary) {
  7723. this._pushOrReplaceState(position, true);
  7724. return;
  7725. }
  7726. if (this._destination.hash === position.hash) {
  7727. return;
  7728. }
  7729. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this
  7730. ._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7731. return;
  7732. }
  7733. var forceReplace = false;
  7734. if (this._destination.page >= position.first && this._destination
  7735. .page <= position.page) {
  7736. if (this._destination.dest || !this._destination.first) {
  7737. return;
  7738. }
  7739. forceReplace = true;
  7740. }
  7741. this._pushOrReplaceState(position, forceReplace);
  7742. }
  7743. }, {
  7744. key: "_isValidState",
  7745. value: function _isValidState(state) {
  7746. var checkReload = arguments.length > 1 && arguments[1] !== undefined ?
  7747. arguments[1] : false;
  7748. if (!state) {
  7749. return false;
  7750. }
  7751. if (state.fingerprint !== this.fingerprint) {
  7752. if (checkReload) {
  7753. if (typeof state.fingerprint !== 'string' || state.fingerprint
  7754. .length !== this.fingerprint.length) {
  7755. return false;
  7756. }
  7757. var _performance$getEntri = performance.getEntriesByType(
  7758. 'navigation'),
  7759. _performance$getEntri2 = _slicedToArray(
  7760. _performance$getEntri, 1),
  7761. perfEntry = _performance$getEntri2[0];
  7762. if (!perfEntry || perfEntry.type !== 'reload') {
  7763. return false;
  7764. }
  7765. } else {
  7766. return false;
  7767. }
  7768. }
  7769. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7770. return false;
  7771. }
  7772. if (state.destination === null || _typeof(state.destination) !==
  7773. 'object') {
  7774. return false;
  7775. }
  7776. return true;
  7777. }
  7778. }, {
  7779. key: "_updateInternalState",
  7780. value: function _updateInternalState(destination, uid) {
  7781. var removeTemporary = arguments.length > 2 && arguments[2] !==
  7782. undefined ? arguments[2] : false;
  7783. if (this._updateViewareaTimeout) {
  7784. clearTimeout(this._updateViewareaTimeout);
  7785. this._updateViewareaTimeout = null;
  7786. }
  7787. if (removeTemporary && destination && destination.temporary) {
  7788. delete destination.temporary;
  7789. }
  7790. this._destination = destination;
  7791. this._uid = uid;
  7792. this._numPositionUpdates = 0;
  7793. }
  7794. }, {
  7795. key: "_updateViewarea",
  7796. value: function _updateViewarea(_ref4) {
  7797. var _this3 = this;
  7798. var location = _ref4.location;
  7799. if (this._updateViewareaTimeout) {
  7800. clearTimeout(this._updateViewareaTimeout);
  7801. this._updateViewareaTimeout = null;
  7802. }
  7803. this._position = {
  7804. hash: this._isViewerInPresentationMode ? "page=".concat(location
  7805. .pageNumber) : location.pdfOpenParams.substring(1),
  7806. page: this.linkService.page,
  7807. first: location.pageNumber,
  7808. rotation: location.rotation
  7809. };
  7810. if (this._popStateInProgress) {
  7811. return;
  7812. }
  7813. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this
  7814. ._destination && !this._destination.page) {
  7815. this._numPositionUpdates++;
  7816. }
  7817. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7818. this._updateViewareaTimeout = setTimeout(function() {
  7819. if (!_this3._popStateInProgress) {
  7820. _this3._tryPushCurrentPosition(true);
  7821. }
  7822. _this3._updateViewareaTimeout = null;
  7823. }, UPDATE_VIEWAREA_TIMEOUT);
  7824. }
  7825. }
  7826. }, {
  7827. key: "_popState",
  7828. value: function _popState(_ref5) {
  7829. var _this4 = this;
  7830. var state = _ref5.state;
  7831. var newHash = getCurrentHash(),
  7832. hashChanged = this._currentHash !== newHash;
  7833. this._currentHash = newHash;
  7834. if (!state || false) {
  7835. this._uid++;
  7836. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  7837. hash = _parseCurrentHash2.hash,
  7838. page = _parseCurrentHash2.page,
  7839. rotation = _parseCurrentHash2.rotation;
  7840. this._pushOrReplaceState({
  7841. hash: hash,
  7842. page: page,
  7843. rotation: rotation
  7844. }, true);
  7845. return;
  7846. }
  7847. if (!this._isValidState(state)) {
  7848. return;
  7849. }
  7850. this._popStateInProgress = true;
  7851. if (hashChanged) {
  7852. this._blockHashChange++;
  7853. (0, _ui_utils.waitOnEventOrTimeout)({
  7854. target: window,
  7855. name: 'hashchange',
  7856. delay: HASH_CHANGE_TIMEOUT
  7857. }).then(function() {
  7858. _this4._blockHashChange--;
  7859. });
  7860. }
  7861. var destination = state.destination;
  7862. this._updateInternalState(destination, state.uid, true);
  7863. if (this._uid > this._maxUid) {
  7864. this._maxUid = this._uid;
  7865. }
  7866. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7867. this.linkService.rotation = destination.rotation;
  7868. }
  7869. if (destination.dest) {
  7870. this.linkService.navigateTo(destination.dest);
  7871. } else if (destination.hash) {
  7872. this.linkService.setHash(destination.hash);
  7873. } else if (destination.page) {
  7874. this.linkService.page = destination.page;
  7875. }
  7876. Promise.resolve().then(function() {
  7877. _this4._popStateInProgress = false;
  7878. });
  7879. }
  7880. }, {
  7881. key: "_bindEvents",
  7882. value: function _bindEvents() {
  7883. var _this5 = this;
  7884. var _boundEvents = this._boundEvents,
  7885. eventBus = this.eventBus;
  7886. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  7887. _boundEvents.popState = this._popState.bind(this);
  7888. _boundEvents.pageHide = function(evt) {
  7889. if (!_this5._destination || _this5._destination.temporary) {
  7890. _this5._tryPushCurrentPosition();
  7891. }
  7892. };
  7893. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  7894. window.addEventListener('popstate', _boundEvents.popState);
  7895. window.addEventListener('pagehide', _boundEvents.pageHide);
  7896. }
  7897. }, {
  7898. key: "popStateInProgress",
  7899. get: function get() {
  7900. return this.initialized && (this._popStateInProgress || this
  7901. ._blockHashChange > 0);
  7902. }
  7903. }]);
  7904. return PDFHistory;
  7905. }();
  7906. exports.PDFHistory = PDFHistory;
  7907. function isDestHashesEqual(destHash, pushHash) {
  7908. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  7909. return false;
  7910. }
  7911. if (destHash === pushHash) {
  7912. return true;
  7913. }
  7914. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7915. nameddest = _parseQueryString.nameddest;
  7916. if (nameddest === pushHash) {
  7917. return true;
  7918. }
  7919. return false;
  7920. }
  7921. function isDestArraysEqual(firstDest, secondDest) {
  7922. function isEntryEqual(first, second) {
  7923. if (_typeof(first) !== _typeof(second)) {
  7924. return false;
  7925. }
  7926. if (Array.isArray(first) || Array.isArray(second)) {
  7927. return false;
  7928. }
  7929. if (first !== null && _typeof(first) === 'object' && second !== null) {
  7930. if (Object.keys(first).length !== Object.keys(second).length) {
  7931. return false;
  7932. }
  7933. for (var key in first) {
  7934. if (!isEntryEqual(first[key], second[key])) {
  7935. return false;
  7936. }
  7937. }
  7938. return true;
  7939. }
  7940. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7941. }
  7942. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7943. return false;
  7944. }
  7945. if (firstDest.length !== secondDest.length) {
  7946. return false;
  7947. }
  7948. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7949. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7950. return false;
  7951. }
  7952. }
  7953. return true;
  7954. }
  7955. /***/
  7956. }),
  7957. /* 21 */
  7958. /***/
  7959. (function(module, exports, __webpack_require__) {
  7960. "use strict";
  7961. Object.defineProperty(exports, "__esModule", {
  7962. value: true
  7963. });
  7964. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7965. var _ui_utils = __webpack_require__(5);
  7966. function _typeof(obj) {
  7967. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  7968. _typeof = function _typeof(obj) {
  7969. return typeof obj;
  7970. };
  7971. } else {
  7972. _typeof = function _typeof(obj) {
  7973. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  7974. Symbol.prototype ? "symbol" : typeof obj;
  7975. };
  7976. }
  7977. return _typeof(obj);
  7978. }
  7979. function _classCallCheck(instance, Constructor) {
  7980. if (!(instance instanceof Constructor)) {
  7981. throw new TypeError("Cannot call a class as a function");
  7982. }
  7983. }
  7984. function _defineProperties(target, props) {
  7985. for (var i = 0; i < props.length; i++) {
  7986. var descriptor = props[i];
  7987. descriptor.enumerable = descriptor.enumerable || false;
  7988. descriptor.configurable = true;
  7989. if ("value" in descriptor) descriptor.writable = true;
  7990. Object.defineProperty(target, descriptor.key, descriptor);
  7991. }
  7992. }
  7993. function _createClass(Constructor, protoProps, staticProps) {
  7994. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7995. if (staticProps) _defineProperties(Constructor, staticProps);
  7996. return Constructor;
  7997. }
  7998. var PDFLinkService =
  7999. /*#__PURE__*/
  8000. function() {
  8001. function PDFLinkService() {
  8002. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8003. eventBus = _ref.eventBus,
  8004. _ref$externalLinkTarg = _ref.externalLinkTarget,
  8005. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  8006. _ref$externalLinkRel = _ref.externalLinkRel,
  8007. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  8008. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  8009. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab;
  8010. _classCallCheck(this, PDFLinkService);
  8011. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  8012. this.externalLinkTarget = externalLinkTarget;
  8013. this.externalLinkRel = externalLinkRel;
  8014. this.externalLinkEnabled = externalLinkEnabled;
  8015. this.baseUrl = null;
  8016. this.pdfDocument = null;
  8017. this.pdfViewer = null;
  8018. this.pdfHistory = null;
  8019. this._pagesRefCache = null;
  8020. }
  8021. _createClass(PDFLinkService, [{
  8022. key: "setDocument",
  8023. value: function setDocument(pdfDocument) {
  8024. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ?
  8025. arguments[1] : null;
  8026. this.baseUrl = baseUrl;
  8027. this.pdfDocument = pdfDocument;
  8028. this._pagesRefCache = Object.create(null);
  8029. }
  8030. }, {
  8031. key: "setViewer",
  8032. value: function setViewer(pdfViewer) {
  8033. this.pdfViewer = pdfViewer;
  8034. }
  8035. }, {
  8036. key: "setHistory",
  8037. value: function setHistory(pdfHistory) {
  8038. this.pdfHistory = pdfHistory;
  8039. }
  8040. }, {
  8041. key: "navigateTo",
  8042. value: function navigateTo(dest) {
  8043. var _this = this;
  8044. var goToDestination = function goToDestination(_ref2) {
  8045. var namedDest = _ref2.namedDest,
  8046. explicitDest = _ref2.explicitDest;
  8047. var destRef = explicitDest[0],
  8048. pageNumber;
  8049. if (destRef instanceof Object) {
  8050. pageNumber = _this._cachedPageNumber(destRef);
  8051. if (pageNumber === null) {
  8052. _this.pdfDocument.getPageIndex(destRef).then(function(
  8053. pageIndex) {
  8054. _this.cachePageRef(pageIndex + 1, destRef);
  8055. goToDestination({
  8056. namedDest: namedDest,
  8057. explicitDest: explicitDest
  8058. });
  8059. })["catch"](function() {
  8060. console.error(
  8061. "PDFLinkService.navigateTo: \""
  8062. .concat(destRef, "\" is not ") +
  8063. "a valid page reference, for dest=\""
  8064. .concat(dest, "\"."));
  8065. });
  8066. return;
  8067. }
  8068. } else if (Number.isInteger(destRef)) {
  8069. pageNumber = destRef + 1;
  8070. } else {
  8071. console.error("PDFLinkService.navigateTo: \"".concat(
  8072. destRef, "\" is not ") +
  8073. "a valid destination reference, for dest=\"".concat(
  8074. dest, "\"."));
  8075. return;
  8076. }
  8077. if (!pageNumber || pageNumber < 1 || pageNumber > _this
  8078. .pagesCount) {
  8079. console.error("PDFLinkService.navigateTo: \"".concat(
  8080. pageNumber, "\" is not ") +
  8081. "a valid page number, for dest=\"".concat(dest,
  8082. "\"."));
  8083. return;
  8084. }
  8085. if (_this.pdfHistory) {
  8086. _this.pdfHistory.pushCurrentPosition();
  8087. _this.pdfHistory.push({
  8088. namedDest: namedDest,
  8089. explicitDest: explicitDest,
  8090. pageNumber: pageNumber
  8091. });
  8092. }
  8093. _this.pdfViewer.scrollPageIntoView({
  8094. pageNumber: pageNumber,
  8095. destArray: explicitDest
  8096. });
  8097. };
  8098. new Promise(function(resolve, reject) {
  8099. if (typeof dest === 'string') {
  8100. _this.pdfDocument.getDestination(dest).then(function(
  8101. destArray) {
  8102. resolve({
  8103. namedDest: dest,
  8104. explicitDest: destArray
  8105. });
  8106. });
  8107. return;
  8108. }
  8109. resolve({
  8110. namedDest: '',
  8111. explicitDest: dest
  8112. });
  8113. }).then(function(data) {
  8114. if (!Array.isArray(data.explicitDest)) {
  8115. console.error("PDFLinkService.navigateTo: \"".concat(
  8116. data.explicitDest, "\" is") +
  8117. " not a valid destination array, for dest=\""
  8118. .concat(dest, "\"."));
  8119. return;
  8120. }
  8121. goToDestination(data);
  8122. });
  8123. }
  8124. }, {
  8125. key: "getDestinationHash",
  8126. value: function getDestinationHash(dest) {
  8127. if (typeof dest === 'string') {
  8128. return this.getAnchorUrl('#' + escape(dest));
  8129. }
  8130. if (Array.isArray(dest)) {
  8131. var str = JSON.stringify(dest);
  8132. return this.getAnchorUrl('#' + escape(str));
  8133. }
  8134. return this.getAnchorUrl('');
  8135. }
  8136. }, {
  8137. key: "getAnchorUrl",
  8138. value: function getAnchorUrl(anchor) {
  8139. return (this.baseUrl || '') + anchor;
  8140. }
  8141. }, {
  8142. key: "setHash",
  8143. value: function setHash(hash) {
  8144. var pageNumber, dest;
  8145. if (hash.includes('=')) {
  8146. var params = (0, _ui_utils.parseQueryString)(hash);
  8147. if ('search' in params) {
  8148. this.eventBus.dispatch('findfromurlhash', {
  8149. source: this,
  8150. query: params['search'].replace(/"/g, ''),
  8151. phraseSearch: params['phrase'] === 'true'
  8152. });
  8153. }
  8154. if ('nameddest' in params) {
  8155. this.navigateTo(params.nameddest);
  8156. return;
  8157. }
  8158. if ('page' in params) {
  8159. pageNumber = params.page | 0 || 1;
  8160. }
  8161. if ('zoom' in params) {
  8162. var zoomArgs = params.zoom.split(',');
  8163. var zoomArg = zoomArgs[0];
  8164. var zoomArgNumber = parseFloat(zoomArg);
  8165. if (!zoomArg.includes('Fit')) {
  8166. dest = [null, {
  8167. name: 'XYZ'
  8168. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null,
  8169. zoomArgs.length > 2 ? zoomArgs[2] | 0 : null,
  8170. zoomArgNumber ? zoomArgNumber / 100 : zoomArg
  8171. ];
  8172. } else {
  8173. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  8174. dest = [null, {
  8175. name: zoomArg
  8176. }];
  8177. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' ||
  8178. zoomArg === 'FitV' || zoomArg === 'FitBV') {
  8179. dest = [null, {
  8180. name: zoomArg
  8181. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  8182. } else if (zoomArg === 'FitR') {
  8183. if (zoomArgs.length !== 5) {
  8184. console.error(
  8185. 'PDFLinkService.setHash: Not enough parameters for "FitR".'
  8186. );
  8187. } else {
  8188. dest = [null, {
  8189. name: zoomArg
  8190. }, zoomArgs[1] | 0, zoomArgs[2] | 0,
  8191. zoomArgs[3] | 0, zoomArgs[4] | 0
  8192. ];
  8193. }
  8194. } else {
  8195. console.error("PDFLinkService.setHash: \"".concat(
  8196. zoomArg, "\" is not ") +
  8197. 'a valid zoom value.');
  8198. }
  8199. }
  8200. }
  8201. if (dest) {
  8202. this.pdfViewer.scrollPageIntoView({
  8203. pageNumber: pageNumber || this.page,
  8204. destArray: dest,
  8205. allowNegativeOffset: true
  8206. });
  8207. } else if (pageNumber) {
  8208. this.page = pageNumber;
  8209. }
  8210. if ('pagemode' in params) {
  8211. this.eventBus.dispatch('pagemode', {
  8212. source: this,
  8213. mode: params.pagemode
  8214. });
  8215. }
  8216. } else {
  8217. dest = unescape(hash);
  8218. try {
  8219. dest = JSON.parse(dest);
  8220. if (!Array.isArray(dest)) {
  8221. dest = dest.toString();
  8222. }
  8223. } catch (ex) {}
  8224. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  8225. this.navigateTo(dest);
  8226. return;
  8227. }
  8228. console.error("PDFLinkService.setHash: \"".concat(unescape(hash),
  8229. "\" is not ") + 'a valid destination.');
  8230. }
  8231. }
  8232. }, {
  8233. key: "executeNamedAction",
  8234. value: function executeNamedAction(action) {
  8235. switch (action) {
  8236. case 'GoBack':
  8237. if (this.pdfHistory) {
  8238. this.pdfHistory.back();
  8239. }
  8240. break;
  8241. case 'GoForward':
  8242. if (this.pdfHistory) {
  8243. this.pdfHistory.forward();
  8244. }
  8245. break;
  8246. case 'NextPage':
  8247. if (this.page < this.pagesCount) {
  8248. this.page++;
  8249. }
  8250. break;
  8251. case 'PrevPage':
  8252. if (this.page > 1) {
  8253. this.page--;
  8254. }
  8255. break;
  8256. case 'LastPage':
  8257. this.page = this.pagesCount;
  8258. break;
  8259. case 'FirstPage':
  8260. this.page = 1;
  8261. break;
  8262. default:
  8263. break;
  8264. }
  8265. this.eventBus.dispatch('namedaction', {
  8266. source: this,
  8267. action: action
  8268. });
  8269. }
  8270. }, {
  8271. key: "cachePageRef",
  8272. value: function cachePageRef(pageNum, pageRef) {
  8273. if (!pageRef) {
  8274. return;
  8275. }
  8276. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : ""
  8277. .concat(pageRef.num, "R").concat(pageRef.gen);
  8278. this._pagesRefCache[refStr] = pageNum;
  8279. }
  8280. }, {
  8281. key: "_cachedPageNumber",
  8282. value: function _cachedPageNumber(pageRef) {
  8283. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : ""
  8284. .concat(pageRef.num, "R").concat(pageRef.gen);
  8285. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  8286. }
  8287. }, {
  8288. key: "isPageVisible",
  8289. value: function isPageVisible(pageNumber) {
  8290. return this.pdfViewer.isPageVisible(pageNumber);
  8291. }
  8292. }, {
  8293. key: "pagesCount",
  8294. get: function get() {
  8295. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  8296. }
  8297. }, {
  8298. key: "page",
  8299. get: function get() {
  8300. return this.pdfViewer.currentPageNumber;
  8301. },
  8302. set: function set(value) {
  8303. this.pdfViewer.currentPageNumber = value;
  8304. }
  8305. }, {
  8306. key: "rotation",
  8307. get: function get() {
  8308. return this.pdfViewer.pagesRotation;
  8309. },
  8310. set: function set(value) {
  8311. this.pdfViewer.pagesRotation = value;
  8312. }
  8313. }]);
  8314. return PDFLinkService;
  8315. }();
  8316. exports.PDFLinkService = PDFLinkService;
  8317. function isValidExplicitDestination(dest) {
  8318. if (!Array.isArray(dest)) {
  8319. return false;
  8320. }
  8321. var destLength = dest.length,
  8322. allowNull = true;
  8323. if (destLength < 2) {
  8324. return false;
  8325. }
  8326. var page = dest[0];
  8327. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(
  8328. Number.isInteger(page) && page >= 0)) {
  8329. return false;
  8330. }
  8331. var zoom = dest[1];
  8332. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  8333. return false;
  8334. }
  8335. switch (zoom.name) {
  8336. case 'XYZ':
  8337. if (destLength !== 5) {
  8338. return false;
  8339. }
  8340. break;
  8341. case 'Fit':
  8342. case 'FitB':
  8343. return destLength === 2;
  8344. case 'FitH':
  8345. case 'FitBH':
  8346. case 'FitV':
  8347. case 'FitBV':
  8348. if (destLength !== 3) {
  8349. return false;
  8350. }
  8351. break;
  8352. case 'FitR':
  8353. if (destLength !== 6) {
  8354. return false;
  8355. }
  8356. allowNull = false;
  8357. break;
  8358. default:
  8359. return false;
  8360. }
  8361. for (var i = 2; i < destLength; i++) {
  8362. var param = dest[i];
  8363. if (!(typeof param === 'number' || allowNull && param === null)) {
  8364. return false;
  8365. }
  8366. }
  8367. return true;
  8368. }
  8369. var SimpleLinkService =
  8370. /*#__PURE__*/
  8371. function() {
  8372. function SimpleLinkService() {
  8373. _classCallCheck(this, SimpleLinkService);
  8374. this.externalLinkTarget = null;
  8375. this.externalLinkRel = null;
  8376. this.externalLinkEnabled = true;
  8377. }
  8378. _createClass(SimpleLinkService, [{
  8379. key: "navigateTo",
  8380. value: function navigateTo(dest) {}
  8381. }, {
  8382. key: "getDestinationHash",
  8383. value: function getDestinationHash(dest) {
  8384. return '#';
  8385. }
  8386. }, {
  8387. key: "getAnchorUrl",
  8388. value: function getAnchorUrl(hash) {
  8389. return '#';
  8390. }
  8391. }, {
  8392. key: "setHash",
  8393. value: function setHash(hash) {}
  8394. }, {
  8395. key: "executeNamedAction",
  8396. value: function executeNamedAction(action) {}
  8397. }, {
  8398. key: "cachePageRef",
  8399. value: function cachePageRef(pageNum, pageRef) {}
  8400. }, {
  8401. key: "isPageVisible",
  8402. value: function isPageVisible(pageNumber) {
  8403. return true;
  8404. }
  8405. }, {
  8406. key: "pagesCount",
  8407. get: function get() {
  8408. return 0;
  8409. }
  8410. }, {
  8411. key: "page",
  8412. get: function get() {
  8413. return 0;
  8414. },
  8415. set: function set(value) {}
  8416. }, {
  8417. key: "rotation",
  8418. get: function get() {
  8419. return 0;
  8420. },
  8421. set: function set(value) {}
  8422. }]);
  8423. return SimpleLinkService;
  8424. }();
  8425. exports.SimpleLinkService = SimpleLinkService;
  8426. /***/
  8427. }),
  8428. /* 22 */
  8429. /***/
  8430. (function(module, exports, __webpack_require__) {
  8431. "use strict";
  8432. Object.defineProperty(exports, "__esModule", {
  8433. value: true
  8434. });
  8435. exports.PDFOutlineViewer = void 0;
  8436. var _pdfjsLib = __webpack_require__(7);
  8437. function _classCallCheck(instance, Constructor) {
  8438. if (!(instance instanceof Constructor)) {
  8439. throw new TypeError("Cannot call a class as a function");
  8440. }
  8441. }
  8442. function _defineProperties(target, props) {
  8443. for (var i = 0; i < props.length; i++) {
  8444. var descriptor = props[i];
  8445. descriptor.enumerable = descriptor.enumerable || false;
  8446. descriptor.configurable = true;
  8447. if ("value" in descriptor) descriptor.writable = true;
  8448. Object.defineProperty(target, descriptor.key, descriptor);
  8449. }
  8450. }
  8451. function _createClass(Constructor, protoProps, staticProps) {
  8452. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8453. if (staticProps) _defineProperties(Constructor, staticProps);
  8454. return Constructor;
  8455. }
  8456. var DEFAULT_TITLE = "\u2013";
  8457. var PDFOutlineViewer =
  8458. /*#__PURE__*/
  8459. function() {
  8460. function PDFOutlineViewer(_ref) {
  8461. var container = _ref.container,
  8462. linkService = _ref.linkService,
  8463. eventBus = _ref.eventBus;
  8464. _classCallCheck(this, PDFOutlineViewer);
  8465. this.container = container;
  8466. this.linkService = linkService;
  8467. this.eventBus = eventBus;
  8468. this.reset();
  8469. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  8470. }
  8471. _createClass(PDFOutlineViewer, [{
  8472. key: "reset",
  8473. value: function reset() {
  8474. this.outline = null;
  8475. this.lastToggleIsShow = true;
  8476. this.container.textContent = '';
  8477. this.container.classList.remove('outlineWithDeepNesting');
  8478. }
  8479. }, {
  8480. key: "_dispatchEvent",
  8481. value: function _dispatchEvent(outlineCount) {
  8482. this.eventBus.dispatch('outlineloaded', {
  8483. source: this,
  8484. outlineCount: outlineCount
  8485. });
  8486. }
  8487. }, {
  8488. key: "_bindLink",
  8489. value: function _bindLink(element, _ref2) {
  8490. var url = _ref2.url,
  8491. newWindow = _ref2.newWindow,
  8492. dest = _ref2.dest;
  8493. var linkService = this.linkService;
  8494. if (url) {
  8495. (0, _pdfjsLib.addLinkAttributes)(element, {
  8496. url: url,
  8497. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService
  8498. .externalLinkTarget,
  8499. rel: linkService.externalLinkRel,
  8500. enabled: linkService.externalLinkEnabled
  8501. });
  8502. return;
  8503. }
  8504. element.href = linkService.getDestinationHash(dest);
  8505. element.onclick = function() {
  8506. if (dest) {
  8507. linkService.navigateTo(dest);
  8508. }
  8509. return false;
  8510. };
  8511. }
  8512. }, {
  8513. key: "_setStyles",
  8514. value: function _setStyles(element, _ref3) {
  8515. var bold = _ref3.bold,
  8516. italic = _ref3.italic;
  8517. var styleStr = '';
  8518. if (bold) {
  8519. styleStr += 'font-weight: bold;';
  8520. }
  8521. if (italic) {
  8522. styleStr += 'font-style: italic;';
  8523. }
  8524. if (styleStr) {
  8525. element.setAttribute('style', styleStr);
  8526. }
  8527. }
  8528. }, {
  8529. key: "_addToggleButton",
  8530. value: function _addToggleButton(div, _ref4) {
  8531. var _this = this;
  8532. var count = _ref4.count,
  8533. items = _ref4.items;
  8534. var toggler = document.createElement('div');
  8535. toggler.className = 'outlineItemToggler';
  8536. if (count < 0 && Math.abs(count) === items.length) {
  8537. toggler.classList.add('outlineItemsHidden');
  8538. }
  8539. toggler.onclick = function(evt) {
  8540. evt.stopPropagation();
  8541. toggler.classList.toggle('outlineItemsHidden');
  8542. if (evt.shiftKey) {
  8543. var shouldShowAll = !toggler.classList.contains(
  8544. 'outlineItemsHidden');
  8545. _this._toggleOutlineItem(div, shouldShowAll);
  8546. }
  8547. };
  8548. div.insertBefore(toggler, div.firstChild);
  8549. }
  8550. }, {
  8551. key: "_toggleOutlineItem",
  8552. value: function _toggleOutlineItem(root) {
  8553. var show = arguments.length > 1 && arguments[1] !== undefined ?
  8554. arguments[1] : false;
  8555. this.lastToggleIsShow = show;
  8556. var _iteratorNormalCompletion = true;
  8557. var _didIteratorError = false;
  8558. var _iteratorError = undefined;
  8559. try {
  8560. for (var _iterator = root.querySelectorAll('.outlineItemToggler')[
  8561. Symbol.iterator](), _step; !(_iteratorNormalCompletion = (
  8562. _step = _iterator.next()).done); _iteratorNormalCompletion =
  8563. true) {
  8564. var toggler = _step.value;
  8565. toggler.classList.toggle('outlineItemsHidden', !show);
  8566. }
  8567. } catch (err) {
  8568. _didIteratorError = true;
  8569. _iteratorError = err;
  8570. } finally {
  8571. try {
  8572. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  8573. _iterator["return"]();
  8574. }
  8575. } finally {
  8576. if (_didIteratorError) {
  8577. throw _iteratorError;
  8578. }
  8579. }
  8580. }
  8581. }
  8582. }, {
  8583. key: "toggleOutlineTree",
  8584. value: function toggleOutlineTree() {
  8585. if (!this.outline) {
  8586. return;
  8587. }
  8588. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  8589. }
  8590. }, {
  8591. key: "render",
  8592. value: function render(_ref5) {
  8593. var outline = _ref5.outline;
  8594. var outlineCount = 0;
  8595. if (this.outline) {
  8596. this.reset();
  8597. }
  8598. this.outline = outline || null;
  8599. if (!outline) {
  8600. this._dispatchEvent(outlineCount);
  8601. return;
  8602. }
  8603. var fragment = document.createDocumentFragment();
  8604. var queue = [{
  8605. parent: fragment,
  8606. items: this.outline
  8607. }];
  8608. var hasAnyNesting = false;
  8609. while (queue.length > 0) {
  8610. var levelData = queue.shift();
  8611. var _iteratorNormalCompletion2 = true;
  8612. var _didIteratorError2 = false;
  8613. var _iteratorError2 = undefined;
  8614. try {
  8615. for (var _iterator2 = levelData.items[Symbol.iterator](),
  8616. _step2; !(_iteratorNormalCompletion2 = (_step2 =
  8617. _iterator2
  8618. .next()).done); _iteratorNormalCompletion2 = true) {
  8619. var item = _step2.value;
  8620. var div = document.createElement('div');
  8621. div.className = 'outlineItem';
  8622. var element = document.createElement('a');
  8623. this._bindLink(element, item);
  8624. this._setStyles(element, item);
  8625. element.textContent = (0, _pdfjsLib.removeNullCharacters)(
  8626. item.title) || DEFAULT_TITLE;
  8627. div.appendChild(element);
  8628. if (item.items.length > 0) {
  8629. hasAnyNesting = true;
  8630. this._addToggleButton(div, item);
  8631. var itemsDiv = document.createElement('div');
  8632. itemsDiv.className = 'outlineItems';
  8633. div.appendChild(itemsDiv);
  8634. queue.push({
  8635. parent: itemsDiv,
  8636. items: item.items
  8637. });
  8638. }
  8639. levelData.parent.appendChild(div);
  8640. outlineCount++;
  8641. }
  8642. } catch (err) {
  8643. _didIteratorError2 = true;
  8644. _iteratorError2 = err;
  8645. } finally {
  8646. try {
  8647. if (!_iteratorNormalCompletion2 && _iterator2["return"] !=
  8648. null) {
  8649. _iterator2["return"]();
  8650. }
  8651. } finally {
  8652. if (_didIteratorError2) {
  8653. throw _iteratorError2;
  8654. }
  8655. }
  8656. }
  8657. }
  8658. if (hasAnyNesting) {
  8659. this.container.classList.add('outlineWithDeepNesting');
  8660. this.lastToggleIsShow = fragment.querySelectorAll(
  8661. '.outlineItemsHidden').length === 0;
  8662. }
  8663. this.container.appendChild(fragment);
  8664. this._dispatchEvent(outlineCount);
  8665. }
  8666. }]);
  8667. return PDFOutlineViewer;
  8668. }();
  8669. exports.PDFOutlineViewer = PDFOutlineViewer;
  8670. /***/
  8671. }),
  8672. /* 23 */
  8673. /***/
  8674. (function(module, exports, __webpack_require__) {
  8675. "use strict";
  8676. Object.defineProperty(exports, "__esModule", {
  8677. value: true
  8678. });
  8679. exports.PDFPresentationMode = void 0;
  8680. var _ui_utils = __webpack_require__(5);
  8681. function _classCallCheck(instance, Constructor) {
  8682. if (!(instance instanceof Constructor)) {
  8683. throw new TypeError("Cannot call a class as a function");
  8684. }
  8685. }
  8686. function _defineProperties(target, props) {
  8687. for (var i = 0; i < props.length; i++) {
  8688. var descriptor = props[i];
  8689. descriptor.enumerable = descriptor.enumerable || false;
  8690. descriptor.configurable = true;
  8691. if ("value" in descriptor) descriptor.writable = true;
  8692. Object.defineProperty(target, descriptor.key, descriptor);
  8693. }
  8694. }
  8695. function _createClass(Constructor, protoProps, staticProps) {
  8696. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8697. if (staticProps) _defineProperties(Constructor, staticProps);
  8698. return Constructor;
  8699. }
  8700. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8701. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8702. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  8703. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  8704. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8705. var PAGE_SWITCH_THRESHOLD = 0.1;
  8706. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8707. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8708. var PDFPresentationMode =
  8709. /*#__PURE__*/
  8710. function() {
  8711. function PDFPresentationMode(_ref) {
  8712. var _this = this;
  8713. var container = _ref.container,
  8714. _ref$viewer = _ref.viewer,
  8715. viewer = _ref$viewer === void 0 ? null : _ref$viewer,
  8716. pdfViewer = _ref.pdfViewer,
  8717. eventBus = _ref.eventBus,
  8718. _ref$contextMenuItems = _ref.contextMenuItems,
  8719. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8720. _classCallCheck(this, PDFPresentationMode);
  8721. this.container = container;
  8722. this.viewer = viewer || container.firstElementChild;
  8723. this.pdfViewer = pdfViewer;
  8724. this.eventBus = eventBus;
  8725. this.active = false;
  8726. this.args = null;
  8727. this.contextMenuOpen = false;
  8728. this.mouseScrollTimeStamp = 0;
  8729. this.mouseScrollDelta = 0;
  8730. this.touchSwipeState = null;
  8731. if (contextMenuItems) {
  8732. contextMenuItems.contextFirstPage.addEventListener('click', function() {
  8733. _this.contextMenuOpen = false;
  8734. _this.eventBus.dispatch('firstpage', {
  8735. source: _this
  8736. });
  8737. });
  8738. contextMenuItems.contextLastPage.addEventListener('click', function() {
  8739. _this.contextMenuOpen = false;
  8740. _this.eventBus.dispatch('lastpage', {
  8741. source: _this
  8742. });
  8743. });
  8744. contextMenuItems.contextPageRotateCw.addEventListener('click', function() {
  8745. _this.contextMenuOpen = false;
  8746. _this.eventBus.dispatch('rotatecw', {
  8747. source: _this
  8748. });
  8749. });
  8750. contextMenuItems.contextPageRotateCcw.addEventListener('click', function() {
  8751. _this.contextMenuOpen = false;
  8752. _this.eventBus.dispatch('rotateccw', {
  8753. source: _this
  8754. });
  8755. });
  8756. }
  8757. }
  8758. _createClass(PDFPresentationMode, [{
  8759. key: "request",
  8760. value: function request() {
  8761. if (this.switchInProgress || this.active || !this.viewer
  8762. .hasChildNodes()) {
  8763. return false;
  8764. }
  8765. this._addFullscreenChangeListeners();
  8766. this._setSwitchInProgress();
  8767. this._notifyStateChange();
  8768. if (this.container.requestFullscreen) {
  8769. this.container.requestFullscreen();
  8770. } else if (this.container.mozRequestFullScreen) {
  8771. this.container.mozRequestFullScreen();
  8772. } else if (this.container.webkitRequestFullscreen) {
  8773. this.container.webkitRequestFullscreen(Element
  8774. .ALLOW_KEYBOARD_INPUT);
  8775. } else if (this.container.msRequestFullscreen) {
  8776. this.container.msRequestFullscreen();
  8777. } else {
  8778. return false;
  8779. }
  8780. this.args = {
  8781. page: this.pdfViewer.currentPageNumber,
  8782. previousScale: this.pdfViewer.currentScaleValue
  8783. };
  8784. return true;
  8785. }
  8786. }, {
  8787. key: "_mouseWheel",
  8788. value: function _mouseWheel(evt) {
  8789. if (!this.active) {
  8790. return;
  8791. }
  8792. evt.preventDefault();
  8793. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8794. var currentTime = new Date().getTime();
  8795. var storedTime = this.mouseScrollTimeStamp;
  8796. if (currentTime > storedTime && currentTime - storedTime <
  8797. MOUSE_SCROLL_COOLDOWN_TIME) {
  8798. return;
  8799. }
  8800. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta <
  8801. 0 && delta > 0) {
  8802. this._resetMouseScrollState();
  8803. }
  8804. this.mouseScrollDelta += delta;
  8805. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8806. var totalDelta = this.mouseScrollDelta;
  8807. this._resetMouseScrollState();
  8808. var success = totalDelta > 0 ? this._goToPreviousPage() : this
  8809. ._goToNextPage();
  8810. if (success) {
  8811. this.mouseScrollTimeStamp = currentTime;
  8812. }
  8813. }
  8814. }
  8815. }, {
  8816. key: "_goToPreviousPage",
  8817. value: function _goToPreviousPage() {
  8818. var page = this.pdfViewer.currentPageNumber;
  8819. if (page <= 1) {
  8820. return false;
  8821. }
  8822. this.pdfViewer.currentPageNumber = page - 1;
  8823. return true;
  8824. }
  8825. }, {
  8826. key: "_goToNextPage",
  8827. value: function _goToNextPage() {
  8828. var page = this.pdfViewer.currentPageNumber;
  8829. if (page >= this.pdfViewer.pagesCount) {
  8830. return false;
  8831. }
  8832. this.pdfViewer.currentPageNumber = page + 1;
  8833. return true;
  8834. }
  8835. }, {
  8836. key: "_notifyStateChange",
  8837. value: function _notifyStateChange() {
  8838. this.eventBus.dispatch('presentationmodechanged', {
  8839. source: this,
  8840. active: this.active,
  8841. switchInProgress: !!this.switchInProgress
  8842. });
  8843. }
  8844. }, {
  8845. key: "_setSwitchInProgress",
  8846. value: function _setSwitchInProgress() {
  8847. var _this2 = this;
  8848. if (this.switchInProgress) {
  8849. clearTimeout(this.switchInProgress);
  8850. }
  8851. this.switchInProgress = setTimeout(function() {
  8852. _this2._removeFullscreenChangeListeners();
  8853. delete _this2.switchInProgress;
  8854. _this2._notifyStateChange();
  8855. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8856. }
  8857. }, {
  8858. key: "_resetSwitchInProgress",
  8859. value: function _resetSwitchInProgress() {
  8860. if (this.switchInProgress) {
  8861. clearTimeout(this.switchInProgress);
  8862. delete this.switchInProgress;
  8863. }
  8864. }
  8865. }, {
  8866. key: "_enter",
  8867. value: function _enter() {
  8868. var _this3 = this;
  8869. this.active = true;
  8870. this._resetSwitchInProgress();
  8871. this._notifyStateChange();
  8872. this.container.classList.add(ACTIVE_SELECTOR);
  8873. setTimeout(function() {
  8874. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8875. _this3.pdfViewer.currentScaleValue = 'page-fit';
  8876. }, 0);
  8877. this._addWindowListeners();
  8878. this._showControls();
  8879. this.contextMenuOpen = false;
  8880. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  8881. window.getSelection().removeAllRanges();
  8882. }
  8883. }, {
  8884. key: "_exit",
  8885. value: function _exit() {
  8886. var _this4 = this;
  8887. var page = this.pdfViewer.currentPageNumber;
  8888. this.container.classList.remove(ACTIVE_SELECTOR);
  8889. setTimeout(function() {
  8890. _this4.active = false;
  8891. _this4._removeFullscreenChangeListeners();
  8892. _this4._notifyStateChange();
  8893. _this4.pdfViewer.currentScaleValue = _this4.args
  8894. .previousScale;
  8895. _this4.pdfViewer.currentPageNumber = page;
  8896. _this4.args = null;
  8897. }, 0);
  8898. this._removeWindowListeners();
  8899. this._hideControls();
  8900. this._resetMouseScrollState();
  8901. this.container.removeAttribute('contextmenu');
  8902. this.contextMenuOpen = false;
  8903. }
  8904. }, {
  8905. key: "_mouseDown",
  8906. value: function _mouseDown(evt) {
  8907. if (this.contextMenuOpen) {
  8908. this.contextMenuOpen = false;
  8909. evt.preventDefault();
  8910. return;
  8911. }
  8912. if (evt.button === 0) {
  8913. var isInternalLink = evt.target.href && evt.target.classList
  8914. .contains('internalLink');
  8915. if (!isInternalLink) {
  8916. evt.preventDefault();
  8917. if (evt.shiftKey) {
  8918. this._goToPreviousPage();
  8919. } else {
  8920. this._goToNextPage();
  8921. }
  8922. }
  8923. }
  8924. }
  8925. }, {
  8926. key: "_contextMenu",
  8927. value: function _contextMenu() {
  8928. this.contextMenuOpen = true;
  8929. }
  8930. }, {
  8931. key: "_showControls",
  8932. value: function _showControls() {
  8933. var _this5 = this;
  8934. if (this.controlsTimeout) {
  8935. clearTimeout(this.controlsTimeout);
  8936. } else {
  8937. this.container.classList.add(CONTROLS_SELECTOR);
  8938. }
  8939. this.controlsTimeout = setTimeout(function() {
  8940. _this5.container.classList.remove(CONTROLS_SELECTOR);
  8941. delete _this5.controlsTimeout;
  8942. }, DELAY_BEFORE_HIDING_CONTROLS);
  8943. }
  8944. }, {
  8945. key: "_hideControls",
  8946. value: function _hideControls() {
  8947. if (!this.controlsTimeout) {
  8948. return;
  8949. }
  8950. clearTimeout(this.controlsTimeout);
  8951. this.container.classList.remove(CONTROLS_SELECTOR);
  8952. delete this.controlsTimeout;
  8953. }
  8954. }, {
  8955. key: "_resetMouseScrollState",
  8956. value: function _resetMouseScrollState() {
  8957. this.mouseScrollTimeStamp = 0;
  8958. this.mouseScrollDelta = 0;
  8959. }
  8960. }, {
  8961. key: "_touchSwipe",
  8962. value: function _touchSwipe(evt) {
  8963. if (!this.active) {
  8964. return;
  8965. }
  8966. if (evt.touches.length > 1) {
  8967. this.touchSwipeState = null;
  8968. return;
  8969. }
  8970. switch (evt.type) {
  8971. case 'touchstart':
  8972. this.touchSwipeState = {
  8973. startX: evt.touches[0].pageX,
  8974. startY: evt.touches[0].pageY,
  8975. endX: evt.touches[0].pageX,
  8976. endY: evt.touches[0].pageY
  8977. };
  8978. break;
  8979. case 'touchmove':
  8980. if (this.touchSwipeState === null) {
  8981. return;
  8982. }
  8983. this.touchSwipeState.endX = evt.touches[0].pageX;
  8984. this.touchSwipeState.endY = evt.touches[0].pageY;
  8985. evt.preventDefault();
  8986. break;
  8987. case 'touchend':
  8988. if (this.touchSwipeState === null) {
  8989. return;
  8990. }
  8991. var delta = 0;
  8992. var dx = this.touchSwipeState.endX - this.touchSwipeState
  8993. .startX;
  8994. var dy = this.touchSwipeState.endY - this.touchSwipeState
  8995. .startY;
  8996. var absAngle = Math.abs(Math.atan2(dy, dx));
  8997. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <=
  8998. SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI -
  8999. SWIPE_ANGLE_THRESHOLD)) {
  9000. delta = dx;
  9001. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math
  9002. .abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9003. delta = dy;
  9004. }
  9005. if (delta > 0) {
  9006. this._goToPreviousPage();
  9007. } else if (delta < 0) {
  9008. this._goToNextPage();
  9009. }
  9010. break;
  9011. }
  9012. }
  9013. }, {
  9014. key: "_addWindowListeners",
  9015. value: function _addWindowListeners() {
  9016. this.showControlsBind = this._showControls.bind(this);
  9017. this.mouseDownBind = this._mouseDown.bind(this);
  9018. this.mouseWheelBind = this._mouseWheel.bind(this);
  9019. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  9020. this.contextMenuBind = this._contextMenu.bind(this);
  9021. this.touchSwipeBind = this._touchSwipe.bind(this);
  9022. window.addEventListener('mousemove', this.showControlsBind);
  9023. window.addEventListener('mousedown', this.mouseDownBind);
  9024. window.addEventListener('wheel', this.mouseWheelBind);
  9025. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  9026. window.addEventListener('contextmenu', this.contextMenuBind);
  9027. window.addEventListener('touchstart', this.touchSwipeBind);
  9028. window.addEventListener('touchmove', this.touchSwipeBind);
  9029. window.addEventListener('touchend', this.touchSwipeBind);
  9030. }
  9031. }, {
  9032. key: "_removeWindowListeners",
  9033. value: function _removeWindowListeners() {
  9034. window.removeEventListener('mousemove', this.showControlsBind);
  9035. window.removeEventListener('mousedown', this.mouseDownBind);
  9036. window.removeEventListener('wheel', this.mouseWheelBind);
  9037. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  9038. window.removeEventListener('contextmenu', this.contextMenuBind);
  9039. window.removeEventListener('touchstart', this.touchSwipeBind);
  9040. window.removeEventListener('touchmove', this.touchSwipeBind);
  9041. window.removeEventListener('touchend', this.touchSwipeBind);
  9042. delete this.showControlsBind;
  9043. delete this.mouseDownBind;
  9044. delete this.mouseWheelBind;
  9045. delete this.resetMouseScrollStateBind;
  9046. delete this.contextMenuBind;
  9047. delete this.touchSwipeBind;
  9048. }
  9049. }, {
  9050. key: "_fullscreenChange",
  9051. value: function _fullscreenChange() {
  9052. if (this.isFullscreen) {
  9053. this._enter();
  9054. } else {
  9055. this._exit();
  9056. }
  9057. }
  9058. }, {
  9059. key: "_addFullscreenChangeListeners",
  9060. value: function _addFullscreenChangeListeners() {
  9061. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  9062. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  9063. window.addEventListener('mozfullscreenchange', this
  9064. .fullscreenChangeBind);
  9065. window.addEventListener('webkitfullscreenchange', this
  9066. .fullscreenChangeBind);
  9067. window.addEventListener('MSFullscreenChange', this
  9068. .fullscreenChangeBind);
  9069. }
  9070. }, {
  9071. key: "_removeFullscreenChangeListeners",
  9072. value: function _removeFullscreenChangeListeners() {
  9073. window.removeEventListener('fullscreenchange', this
  9074. .fullscreenChangeBind);
  9075. window.removeEventListener('mozfullscreenchange', this
  9076. .fullscreenChangeBind);
  9077. window.removeEventListener('webkitfullscreenchange', this
  9078. .fullscreenChangeBind);
  9079. window.removeEventListener('MSFullscreenChange', this
  9080. .fullscreenChangeBind);
  9081. delete this.fullscreenChangeBind;
  9082. }
  9083. }, {
  9084. key: "isFullscreen",
  9085. get: function get() {
  9086. return !!(document.fullscreenElement || document.mozFullScreen ||
  9087. document.webkitIsFullScreen || document.msFullscreenElement);
  9088. }
  9089. }]);
  9090. return PDFPresentationMode;
  9091. }();
  9092. exports.PDFPresentationMode = PDFPresentationMode;
  9093. /***/
  9094. }),
  9095. /* 24 */
  9096. /***/
  9097. (function(module, exports, __webpack_require__) {
  9098. "use strict";
  9099. Object.defineProperty(exports, "__esModule", {
  9100. value: true
  9101. });
  9102. exports.PDFSidebarResizer = void 0;
  9103. var _ui_utils = __webpack_require__(5);
  9104. function _classCallCheck(instance, Constructor) {
  9105. if (!(instance instanceof Constructor)) {
  9106. throw new TypeError("Cannot call a class as a function");
  9107. }
  9108. }
  9109. function _defineProperties(target, props) {
  9110. for (var i = 0; i < props.length; i++) {
  9111. var descriptor = props[i];
  9112. descriptor.enumerable = descriptor.enumerable || false;
  9113. descriptor.configurable = true;
  9114. if ("value" in descriptor) descriptor.writable = true;
  9115. Object.defineProperty(target, descriptor.key, descriptor);
  9116. }
  9117. }
  9118. function _createClass(Constructor, protoProps, staticProps) {
  9119. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9120. if (staticProps) _defineProperties(Constructor, staticProps);
  9121. return Constructor;
  9122. }
  9123. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  9124. var SIDEBAR_MIN_WIDTH = 200;
  9125. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  9126. var PDFSidebarResizer =
  9127. /*#__PURE__*/
  9128. function() {
  9129. function PDFSidebarResizer(options, eventBus) {
  9130. var _this = this;
  9131. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  9132. .NullL10n;
  9133. _classCallCheck(this, PDFSidebarResizer);
  9134. this.enabled = false;
  9135. this.isRTL = false;
  9136. this.sidebarOpen = false;
  9137. this.doc = document.documentElement;
  9138. this._width = null;
  9139. this._outerContainerWidth = null;
  9140. this._boundEvents = Object.create(null);
  9141. this.outerContainer = options.outerContainer;
  9142. this.resizer = options.resizer;
  9143. this.eventBus = eventBus;
  9144. this.l10n = l10n;
  9145. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(
  9146. SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  9147. console.warn('PDFSidebarResizer: ' +
  9148. 'The browser does not support resizing of the sidebar.');
  9149. return;
  9150. }
  9151. this.enabled = true;
  9152. this.resizer.classList.remove('hidden');
  9153. this.l10n.getDirection().then(function(dir) {
  9154. _this.isRTL = dir === 'rtl';
  9155. });
  9156. this._addEventListeners();
  9157. }
  9158. _createClass(PDFSidebarResizer, [{
  9159. key: "_updateWidth",
  9160. value: function _updateWidth() {
  9161. var width = arguments.length > 0 && arguments[0] !== undefined ?
  9162. arguments[0] : 0;
  9163. if (!this.enabled) {
  9164. return false;
  9165. }
  9166. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  9167. if (width > maxWidth) {
  9168. width = maxWidth;
  9169. }
  9170. if (width < SIDEBAR_MIN_WIDTH) {
  9171. width = SIDEBAR_MIN_WIDTH;
  9172. }
  9173. if (width === this._width) {
  9174. return false;
  9175. }
  9176. this._width = width;
  9177. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  9178. return true;
  9179. }
  9180. }, {
  9181. key: "_mouseMove",
  9182. value: function _mouseMove(evt) {
  9183. var width = evt.clientX;
  9184. if (this.isRTL) {
  9185. width = this.outerContainerWidth - width;
  9186. }
  9187. this._updateWidth(width);
  9188. }
  9189. }, {
  9190. key: "_mouseUp",
  9191. value: function _mouseUp(evt) {
  9192. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9193. this.eventBus.dispatch('resize', {
  9194. source: this
  9195. });
  9196. var _boundEvents = this._boundEvents;
  9197. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  9198. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  9199. }
  9200. }, {
  9201. key: "_addEventListeners",
  9202. value: function _addEventListeners() {
  9203. var _this2 = this;
  9204. if (!this.enabled) {
  9205. return;
  9206. }
  9207. var _boundEvents = this._boundEvents;
  9208. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9209. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9210. this.resizer.addEventListener('mousedown', function(evt) {
  9211. if (evt.button !== 0) {
  9212. return;
  9213. }
  9214. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9215. window.addEventListener('mousemove', _boundEvents
  9216. .mouseMove);
  9217. window.addEventListener('mouseup', _boundEvents.mouseUp);
  9218. });
  9219. this.eventBus.on('sidebarviewchanged', function(evt) {
  9220. _this2.sidebarOpen = !!(evt && evt.view);
  9221. });
  9222. this.eventBus.on('resize', function(evt) {
  9223. if (evt && evt.source === window) {
  9224. _this2._outerContainerWidth = null;
  9225. if (_this2._width) {
  9226. if (_this2.sidebarOpen) {
  9227. _this2.outerContainer.classList.add(
  9228. SIDEBAR_RESIZING_CLASS);
  9229. var updated = _this2._updateWidth(_this2
  9230. ._width);
  9231. Promise.resolve().then(function() {
  9232. _this2.outerContainer.classList
  9233. .remove(SIDEBAR_RESIZING_CLASS);
  9234. if (updated) {
  9235. _this2.eventBus.dispatch(
  9236. 'resize', {
  9237. source: _this2
  9238. });
  9239. }
  9240. });
  9241. } else {
  9242. _this2._updateWidth(_this2._width);
  9243. }
  9244. }
  9245. }
  9246. });
  9247. }
  9248. }, {
  9249. key: "outerContainerWidth",
  9250. get: function get() {
  9251. if (!this._outerContainerWidth) {
  9252. this._outerContainerWidth = this.outerContainer.clientWidth;
  9253. }
  9254. return this._outerContainerWidth;
  9255. }
  9256. }]);
  9257. return PDFSidebarResizer;
  9258. }();
  9259. exports.PDFSidebarResizer = PDFSidebarResizer;
  9260. /***/
  9261. }),
  9262. /* 25 */
  9263. /***/
  9264. (function(module, exports, __webpack_require__) {
  9265. "use strict";
  9266. Object.defineProperty(exports, "__esModule", {
  9267. value: true
  9268. });
  9269. exports.PDFThumbnailViewer = void 0;
  9270. var _ui_utils = __webpack_require__(5);
  9271. var _pdf_thumbnail_view = __webpack_require__(26);
  9272. function _classCallCheck(instance, Constructor) {
  9273. if (!(instance instanceof Constructor)) {
  9274. throw new TypeError("Cannot call a class as a function");
  9275. }
  9276. }
  9277. function _defineProperties(target, props) {
  9278. for (var i = 0; i < props.length; i++) {
  9279. var descriptor = props[i];
  9280. descriptor.enumerable = descriptor.enumerable || false;
  9281. descriptor.configurable = true;
  9282. if ("value" in descriptor) descriptor.writable = true;
  9283. Object.defineProperty(target, descriptor.key, descriptor);
  9284. }
  9285. }
  9286. function _createClass(Constructor, protoProps, staticProps) {
  9287. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9288. if (staticProps) _defineProperties(Constructor, staticProps);
  9289. return Constructor;
  9290. }
  9291. var THUMBNAIL_SCROLL_MARGIN = -19;
  9292. var THUMBNAIL_SELECTED_CLASS = 'selected';
  9293. var PDFThumbnailViewer =
  9294. /*#__PURE__*/
  9295. function() {
  9296. function PDFThumbnailViewer(_ref) {
  9297. var container = _ref.container,
  9298. linkService = _ref.linkService,
  9299. renderingQueue = _ref.renderingQueue,
  9300. _ref$l10n = _ref.l10n,
  9301. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9302. _classCallCheck(this, PDFThumbnailViewer);
  9303. this.container = container;
  9304. this.linkService = linkService;
  9305. this.renderingQueue = renderingQueue;
  9306. this.l10n = l10n;
  9307. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  9308. this._resetView();
  9309. }
  9310. _createClass(PDFThumbnailViewer, [{
  9311. key: "_scrollUpdated",
  9312. value: function _scrollUpdated() {
  9313. this.renderingQueue.renderHighestPriority();
  9314. }
  9315. }, {
  9316. key: "getThumbnail",
  9317. value: function getThumbnail(index) {
  9318. return this._thumbnails[index];
  9319. }
  9320. }, {
  9321. key: "_getVisibleThumbs",
  9322. value: function _getVisibleThumbs() {
  9323. return (0, _ui_utils.getVisibleElements)(this.container, this
  9324. ._thumbnails);
  9325. }
  9326. }, {
  9327. key: "scrollThumbnailIntoView",
  9328. value: function scrollThumbnailIntoView(pageNumber) {
  9329. if (!this.pdfDocument) {
  9330. return;
  9331. }
  9332. var thumbnailView = this._thumbnails[pageNumber - 1];
  9333. if (!thumbnailView) {
  9334. console.error(
  9335. 'scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9336. return;
  9337. }
  9338. if (pageNumber !== this._currentPageNumber) {
  9339. var prevThumbnailView = this._thumbnails[this._currentPageNumber -
  9340. 1];
  9341. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9342. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9343. }
  9344. var visibleThumbs = this._getVisibleThumbs();
  9345. var numVisibleThumbs = visibleThumbs.views.length;
  9346. if (numVisibleThumbs > 0) {
  9347. var first = visibleThumbs.first.id;
  9348. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  9349. var shouldScroll = false;
  9350. if (pageNumber <= first || pageNumber >= last) {
  9351. shouldScroll = true;
  9352. } else {
  9353. visibleThumbs.views.some(function(view) {
  9354. if (view.id !== pageNumber) {
  9355. return false;
  9356. }
  9357. shouldScroll = view.percent < 100;
  9358. return true;
  9359. });
  9360. }
  9361. if (shouldScroll) {
  9362. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9363. top: THUMBNAIL_SCROLL_MARGIN
  9364. });
  9365. }
  9366. }
  9367. this._currentPageNumber = pageNumber;
  9368. }
  9369. }, {
  9370. key: "cleanup",
  9371. value: function cleanup() {
  9372. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  9373. }
  9374. }, {
  9375. key: "_resetView",
  9376. value: function _resetView() {
  9377. this._thumbnails = [];
  9378. this._currentPageNumber = 1;
  9379. this._pageLabels = null;
  9380. this._pagesRotation = 0;
  9381. this._pagesRequests = [];
  9382. this.container.textContent = '';
  9383. }
  9384. }, {
  9385. key: "setDocument",
  9386. value: function setDocument(pdfDocument) {
  9387. var _this = this;
  9388. if (this.pdfDocument) {
  9389. this._cancelRendering();
  9390. this._resetView();
  9391. }
  9392. this.pdfDocument = pdfDocument;
  9393. if (!pdfDocument) {
  9394. return;
  9395. }
  9396. pdfDocument.getPage(1).then(function(firstPage) {
  9397. var pagesCount = pdfDocument.numPages;
  9398. var viewport = firstPage.getViewport({
  9399. scale: 1
  9400. });
  9401. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9402. var thumbnail = new _pdf_thumbnail_view
  9403. .PDFThumbnailView({
  9404. container: _this.container,
  9405. id: pageNum,
  9406. defaultViewport: viewport.clone(),
  9407. linkService: _this.linkService,
  9408. renderingQueue: _this.renderingQueue,
  9409. disableCanvasToImageConversion: false,
  9410. l10n: _this.l10n
  9411. });
  9412. _this._thumbnails.push(thumbnail);
  9413. }
  9414. var thumbnailView = _this._thumbnails[_this
  9415. ._currentPageNumber - 1];
  9416. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9417. })["catch"](function(reason) {
  9418. console.error('Unable to initialize thumbnail viewer',
  9419. reason);
  9420. });
  9421. }
  9422. }, {
  9423. key: "_cancelRendering",
  9424. value: function _cancelRendering() {
  9425. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9426. if (this._thumbnails[i]) {
  9427. this._thumbnails[i].cancelRendering();
  9428. }
  9429. }
  9430. }
  9431. }, {
  9432. key: "setPageLabels",
  9433. value: function setPageLabels(labels) {
  9434. if (!this.pdfDocument) {
  9435. return;
  9436. }
  9437. if (!labels) {
  9438. this._pageLabels = null;
  9439. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages ===
  9440. labels.length)) {
  9441. this._pageLabels = null;
  9442. console.error(
  9443. 'PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  9444. } else {
  9445. this._pageLabels = labels;
  9446. }
  9447. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9448. var label = this._pageLabels && this._pageLabels[i];
  9449. this._thumbnails[i].setPageLabel(label);
  9450. }
  9451. }
  9452. }, {
  9453. key: "_ensurePdfPageLoaded",
  9454. value: function _ensurePdfPageLoaded(thumbView) {
  9455. var _this2 = this;
  9456. if (thumbView.pdfPage) {
  9457. return Promise.resolve(thumbView.pdfPage);
  9458. }
  9459. var pageNumber = thumbView.id;
  9460. if (this._pagesRequests[pageNumber]) {
  9461. return this._pagesRequests[pageNumber];
  9462. }
  9463. var promise = this.pdfDocument.getPage(pageNumber).then(function(
  9464. pdfPage) {
  9465. thumbView.setPdfPage(pdfPage);
  9466. _this2._pagesRequests[pageNumber] = null;
  9467. return pdfPage;
  9468. })["catch"](function(reason) {
  9469. console.error('Unable to get page for thumb view', reason);
  9470. _this2._pagesRequests[pageNumber] = null;
  9471. });
  9472. this._pagesRequests[pageNumber] = promise;
  9473. return promise;
  9474. }
  9475. }, {
  9476. key: "forceRendering",
  9477. value: function forceRendering() {
  9478. var _this3 = this;
  9479. var visibleThumbs = this._getVisibleThumbs();
  9480. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs,
  9481. this._thumbnails, this.scroll.down);
  9482. if (thumbView) {
  9483. this._ensurePdfPageLoaded(thumbView).then(function() {
  9484. _this3.renderingQueue.renderView(thumbView);
  9485. });
  9486. return true;
  9487. }
  9488. return false;
  9489. }
  9490. }, {
  9491. key: "pagesRotation",
  9492. get: function get() {
  9493. return this._pagesRotation;
  9494. },
  9495. set: function set(rotation) {
  9496. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9497. throw new Error('Invalid thumbnails rotation angle.');
  9498. }
  9499. if (!this.pdfDocument) {
  9500. return;
  9501. }
  9502. if (this._pagesRotation === rotation) {
  9503. return;
  9504. }
  9505. this._pagesRotation = rotation;
  9506. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9507. this._thumbnails[i].update(rotation);
  9508. }
  9509. }
  9510. }]);
  9511. return PDFThumbnailViewer;
  9512. }();
  9513. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9514. /***/
  9515. }),
  9516. /* 26 */
  9517. /***/
  9518. (function(module, exports, __webpack_require__) {
  9519. "use strict";
  9520. Object.defineProperty(exports, "__esModule", {
  9521. value: true
  9522. });
  9523. exports.PDFThumbnailView = void 0;
  9524. var _pdfjsLib = __webpack_require__(7);
  9525. var _ui_utils = __webpack_require__(5);
  9526. var _pdf_rendering_queue = __webpack_require__(11);
  9527. function _classCallCheck(instance, Constructor) {
  9528. if (!(instance instanceof Constructor)) {
  9529. throw new TypeError("Cannot call a class as a function");
  9530. }
  9531. }
  9532. function _defineProperties(target, props) {
  9533. for (var i = 0; i < props.length; i++) {
  9534. var descriptor = props[i];
  9535. descriptor.enumerable = descriptor.enumerable || false;
  9536. descriptor.configurable = true;
  9537. if ("value" in descriptor) descriptor.writable = true;
  9538. Object.defineProperty(target, descriptor.key, descriptor);
  9539. }
  9540. }
  9541. function _createClass(Constructor, protoProps, staticProps) {
  9542. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9543. if (staticProps) _defineProperties(Constructor, staticProps);
  9544. return Constructor;
  9545. }
  9546. var MAX_NUM_SCALING_STEPS = 3;
  9547. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  9548. var THUMBNAIL_WIDTH = 98;
  9549. var TempImageFactory = function TempImageFactoryClosure() {
  9550. var tempCanvasCache = null;
  9551. return {
  9552. getCanvas: function getCanvas(width, height) {
  9553. var tempCanvas = tempCanvasCache;
  9554. if (!tempCanvas) {
  9555. tempCanvas = document.createElement('canvas');
  9556. tempCanvasCache = tempCanvas;
  9557. }
  9558. tempCanvas.width = width;
  9559. tempCanvas.height = height;
  9560. tempCanvas.mozOpaque = true;
  9561. var ctx = tempCanvas.getContext('2d', {
  9562. alpha: false
  9563. });
  9564. ctx.save();
  9565. ctx.fillStyle = 'rgb(255, 255, 255)';
  9566. ctx.fillRect(0, 0, width, height);
  9567. ctx.restore();
  9568. return tempCanvas;
  9569. },
  9570. destroyCanvas: function destroyCanvas() {
  9571. var tempCanvas = tempCanvasCache;
  9572. if (tempCanvas) {
  9573. tempCanvas.width = 0;
  9574. tempCanvas.height = 0;
  9575. }
  9576. tempCanvasCache = null;
  9577. }
  9578. };
  9579. }();
  9580. var PDFThumbnailView =
  9581. /*#__PURE__*/
  9582. function() {
  9583. function PDFThumbnailView(_ref) {
  9584. var container = _ref.container,
  9585. id = _ref.id,
  9586. defaultViewport = _ref.defaultViewport,
  9587. linkService = _ref.linkService,
  9588. renderingQueue = _ref.renderingQueue,
  9589. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  9590. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false :
  9591. _ref$disableCanvasToI,
  9592. _ref$l10n = _ref.l10n,
  9593. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9594. _classCallCheck(this, PDFThumbnailView);
  9595. this.id = id;
  9596. this.renderingId = 'thumbnail' + id;
  9597. this.pageLabel = null;
  9598. this.pdfPage = null;
  9599. this.rotation = 0;
  9600. this.viewport = defaultViewport;
  9601. this.pdfPageRotate = defaultViewport.rotation;
  9602. this.linkService = linkService;
  9603. this.renderingQueue = renderingQueue;
  9604. this.renderTask = null;
  9605. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9606. this.resume = null;
  9607. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9608. this.pageWidth = this.viewport.width;
  9609. this.pageHeight = this.viewport.height;
  9610. this.pageRatio = this.pageWidth / this.pageHeight;
  9611. this.canvasWidth = THUMBNAIL_WIDTH;
  9612. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9613. this.scale = this.canvasWidth / this.pageWidth;
  9614. this.l10n = l10n;
  9615. var anchor = document.createElement('a');
  9616. anchor.href = linkService.getAnchorUrl('#page=' + id);
  9617. this.l10n.get('thumb_page_title', {
  9618. page: id
  9619. }, 'Page {{page}}').then(function(msg) {
  9620. anchor.title = msg;
  9621. });
  9622. anchor.onclick = function() {
  9623. linkService.page = id;
  9624. return false;
  9625. };
  9626. this.anchor = anchor;
  9627. var div = document.createElement('div');
  9628. div.className = 'thumbnail';
  9629. div.setAttribute('data-page-number', this.id);
  9630. this.div = div;
  9631. var ring = document.createElement('div');
  9632. ring.className = 'thumbnailSelectionRing';
  9633. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9634. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  9635. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  9636. this.ring = ring;
  9637. div.appendChild(ring);
  9638. anchor.appendChild(div);
  9639. container.appendChild(anchor);
  9640. }
  9641. _createClass(PDFThumbnailView, [{
  9642. key: "setPdfPage",
  9643. value: function setPdfPage(pdfPage) {
  9644. this.pdfPage = pdfPage;
  9645. this.pdfPageRotate = pdfPage.rotate;
  9646. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9647. this.viewport = pdfPage.getViewport({
  9648. scale: 1,
  9649. rotation: totalRotation
  9650. });
  9651. this.reset();
  9652. }
  9653. }, {
  9654. key: "reset",
  9655. value: function reset() {
  9656. this.cancelRendering();
  9657. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9658. this.pageWidth = this.viewport.width;
  9659. this.pageHeight = this.viewport.height;
  9660. this.pageRatio = this.pageWidth / this.pageHeight;
  9661. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9662. this.scale = this.canvasWidth / this.pageWidth;
  9663. this.div.removeAttribute('data-loaded');
  9664. var ring = this.ring;
  9665. var childNodes = ring.childNodes;
  9666. for (var i = childNodes.length - 1; i >= 0; i--) {
  9667. ring.removeChild(childNodes[i]);
  9668. }
  9669. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9670. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  9671. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  9672. if (this.canvas) {
  9673. this.canvas.width = 0;
  9674. this.canvas.height = 0;
  9675. delete this.canvas;
  9676. }
  9677. if (this.image) {
  9678. this.image.removeAttribute('src');
  9679. delete this.image;
  9680. }
  9681. }
  9682. }, {
  9683. key: "update",
  9684. value: function update(rotation) {
  9685. if (typeof rotation !== 'undefined') {
  9686. this.rotation = rotation;
  9687. }
  9688. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9689. this.viewport = this.viewport.clone({
  9690. scale: 1,
  9691. rotation: totalRotation
  9692. });
  9693. this.reset();
  9694. }
  9695. }, {
  9696. key: "cancelRendering",
  9697. value: function cancelRendering() {
  9698. if (this.renderTask) {
  9699. this.renderTask.cancel();
  9700. this.renderTask = null;
  9701. }
  9702. this.resume = null;
  9703. }
  9704. }, {
  9705. key: "_getPageDrawContext",
  9706. value: function _getPageDrawContext() {
  9707. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ?
  9708. arguments[0] : false;
  9709. var canvas = document.createElement('canvas');
  9710. this.canvas = canvas;
  9711. canvas.mozOpaque = true;
  9712. var ctx = canvas.getContext('2d', {
  9713. alpha: false
  9714. });
  9715. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9716. canvas.width = this.canvasWidth * outputScale.sx | 0;
  9717. canvas.height = this.canvasHeight * outputScale.sy | 0;
  9718. canvas.style.width = this.canvasWidth + 'px';
  9719. canvas.style.height = this.canvasHeight + 'px';
  9720. if (!noCtxScale && outputScale.scaled) {
  9721. ctx.scale(outputScale.sx, outputScale.sy);
  9722. }
  9723. return ctx;
  9724. }
  9725. }, {
  9726. key: "_convertCanvasToImage",
  9727. value: function _convertCanvasToImage() {
  9728. var _this = this;
  9729. if (!this.canvas) {
  9730. return;
  9731. }
  9732. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9733. .FINISHED) {
  9734. return;
  9735. }
  9736. var id = this.renderingId;
  9737. var className = 'thumbnailImage';
  9738. if (this.disableCanvasToImageConversion) {
  9739. this.canvas.id = id;
  9740. this.canvas.className = className;
  9741. this.l10n.get('thumb_page_canvas', {
  9742. page: this.pageId
  9743. }, 'Thumbnail of Page {{page}}').then(function(msg) {
  9744. _this.canvas.setAttribute('aria-label', msg);
  9745. });
  9746. this.div.setAttribute('data-loaded', true);
  9747. this.ring.appendChild(this.canvas);
  9748. return;
  9749. }
  9750. var image = document.createElement('img');
  9751. image.id = id;
  9752. image.className = className;
  9753. this.l10n.get('thumb_page_canvas', {
  9754. page: this.pageId
  9755. }, 'Thumbnail of Page {{page}}').then(function(msg) {
  9756. image.setAttribute('aria-label', msg);
  9757. });
  9758. image.style.width = this.canvasWidth + 'px';
  9759. image.style.height = this.canvasHeight + 'px';
  9760. image.src = this.canvas.toDataURL();
  9761. this.image = image;
  9762. this.div.setAttribute('data-loaded', true);
  9763. this.ring.appendChild(image);
  9764. this.canvas.width = 0;
  9765. this.canvas.height = 0;
  9766. delete this.canvas;
  9767. }
  9768. }, {
  9769. key: "draw",
  9770. value: function draw() {
  9771. var _this2 = this;
  9772. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9773. .INITIAL) {
  9774. console.error('Must be in new state before drawing');
  9775. return Promise.resolve(undefined);
  9776. }
  9777. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9778. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9779. var finishRenderTask = function finishRenderTask(error) {
  9780. if (renderTask === _this2.renderTask) {
  9781. _this2.renderTask = null;
  9782. }
  9783. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9784. renderCapability.resolve(undefined);
  9785. return;
  9786. }
  9787. _this2.renderingState = _pdf_rendering_queue.RenderingStates
  9788. .FINISHED;
  9789. _this2._convertCanvasToImage();
  9790. if (!error) {
  9791. renderCapability.resolve(undefined);
  9792. } else {
  9793. renderCapability.reject(error);
  9794. }
  9795. };
  9796. var ctx = this._getPageDrawContext();
  9797. var drawViewport = this.viewport.clone({
  9798. scale: this.scale
  9799. });
  9800. var renderContinueCallback = function renderContinueCallback(cont) {
  9801. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  9802. _this2.renderingState = _pdf_rendering_queue.RenderingStates
  9803. .PAUSED;
  9804. _this2.resume = function() {
  9805. _this2.renderingState = _pdf_rendering_queue
  9806. .RenderingStates.RUNNING;
  9807. cont();
  9808. };
  9809. return;
  9810. }
  9811. cont();
  9812. };
  9813. var renderContext = {
  9814. canvasContext: ctx,
  9815. viewport: drawViewport
  9816. };
  9817. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  9818. renderTask.onContinue = renderContinueCallback;
  9819. renderTask.promise.then(function() {
  9820. finishRenderTask(null);
  9821. }, function(error) {
  9822. finishRenderTask(error);
  9823. });
  9824. return renderCapability.promise;
  9825. }
  9826. }, {
  9827. key: "setImage",
  9828. value: function setImage(pageView) {
  9829. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9830. .INITIAL) {
  9831. return;
  9832. }
  9833. var img = pageView.canvas;
  9834. if (!img) {
  9835. return;
  9836. }
  9837. if (!this.pdfPage) {
  9838. this.setPdfPage(pageView.pdfPage);
  9839. }
  9840. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9841. var ctx = this._getPageDrawContext(true);
  9842. var canvas = ctx.canvas;
  9843. if (img.width <= 2 * canvas.width) {
  9844. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width,
  9845. canvas.height);
  9846. this._convertCanvasToImage();
  9847. return;
  9848. }
  9849. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  9850. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  9851. var reducedImage = TempImageFactory.getCanvas(reducedWidth,
  9852. reducedHeight);
  9853. var reducedImageCtx = reducedImage.getContext('2d');
  9854. while (reducedWidth > img.width || reducedHeight > img.height) {
  9855. reducedWidth >>= 1;
  9856. reducedHeight >>= 1;
  9857. }
  9858. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0,
  9859. reducedWidth, reducedHeight);
  9860. while (reducedWidth > 2 * canvas.width) {
  9861. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth,
  9862. reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  9863. reducedWidth >>= 1;
  9864. reducedHeight >>= 1;
  9865. }
  9866. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0,
  9867. canvas.width, canvas.height);
  9868. this._convertCanvasToImage();
  9869. }
  9870. }, {
  9871. key: "setPageLabel",
  9872. value: function setPageLabel(label) {
  9873. var _this3 = this;
  9874. this.pageLabel = typeof label === 'string' ? label : null;
  9875. this.l10n.get('thumb_page_title', {
  9876. page: this.pageId
  9877. }, 'Page {{page}}').then(function(msg) {
  9878. _this3.anchor.title = msg;
  9879. });
  9880. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9881. .FINISHED) {
  9882. return;
  9883. }
  9884. this.l10n.get('thumb_page_canvas', {
  9885. page: this.pageId
  9886. }, 'Thumbnail of Page {{page}}').then(function(ariaLabel) {
  9887. if (_this3.image) {
  9888. _this3.image.setAttribute('aria-label', ariaLabel);
  9889. } else if (_this3.disableCanvasToImageConversion && _this3
  9890. .canvas) {
  9891. _this3.canvas.setAttribute('aria-label', ariaLabel);
  9892. }
  9893. });
  9894. }
  9895. }, {
  9896. key: "pageId",
  9897. get: function get() {
  9898. return this.pageLabel !== null ? this.pageLabel : this.id;
  9899. }
  9900. }], [{
  9901. key: "cleanup",
  9902. value: function cleanup() {
  9903. TempImageFactory.destroyCanvas();
  9904. }
  9905. }]);
  9906. return PDFThumbnailView;
  9907. }();
  9908. exports.PDFThumbnailView = PDFThumbnailView;
  9909. /***/
  9910. }),
  9911. /* 27 */
  9912. /***/
  9913. (function(module, exports, __webpack_require__) {
  9914. "use strict";
  9915. Object.defineProperty(exports, "__esModule", {
  9916. value: true
  9917. });
  9918. exports.PDFViewer = void 0;
  9919. var _base_viewer = __webpack_require__(28);
  9920. var _pdfjsLib = __webpack_require__(7);
  9921. function _typeof(obj) {
  9922. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  9923. _typeof = function _typeof(obj) {
  9924. return typeof obj;
  9925. };
  9926. } else {
  9927. _typeof = function _typeof(obj) {
  9928. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  9929. Symbol.prototype ? "symbol" : typeof obj;
  9930. };
  9931. }
  9932. return _typeof(obj);
  9933. }
  9934. function _classCallCheck(instance, Constructor) {
  9935. if (!(instance instanceof Constructor)) {
  9936. throw new TypeError("Cannot call a class as a function");
  9937. }
  9938. }
  9939. function _defineProperties(target, props) {
  9940. for (var i = 0; i < props.length; i++) {
  9941. var descriptor = props[i];
  9942. descriptor.enumerable = descriptor.enumerable || false;
  9943. descriptor.configurable = true;
  9944. if ("value" in descriptor) descriptor.writable = true;
  9945. Object.defineProperty(target, descriptor.key, descriptor);
  9946. }
  9947. }
  9948. function _createClass(Constructor, protoProps, staticProps) {
  9949. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9950. if (staticProps) _defineProperties(Constructor, staticProps);
  9951. return Constructor;
  9952. }
  9953. function _possibleConstructorReturn(self, call) {
  9954. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  9955. return call;
  9956. }
  9957. return _assertThisInitialized(self);
  9958. }
  9959. function _assertThisInitialized(self) {
  9960. if (self === void 0) {
  9961. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  9962. }
  9963. return self;
  9964. }
  9965. function _get(target, property, receiver) {
  9966. if (typeof Reflect !== "undefined" && Reflect.get) {
  9967. _get = Reflect.get;
  9968. } else {
  9969. _get = function _get(target, property, receiver) {
  9970. var base = _superPropBase(target, property);
  9971. if (!base) return;
  9972. var desc = Object.getOwnPropertyDescriptor(base, property);
  9973. if (desc.get) {
  9974. return desc.get.call(receiver);
  9975. }
  9976. return desc.value;
  9977. };
  9978. }
  9979. return _get(target, property, receiver || target);
  9980. }
  9981. function _superPropBase(object, property) {
  9982. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  9983. object = _getPrototypeOf(object);
  9984. if (object === null) break;
  9985. }
  9986. return object;
  9987. }
  9988. function _getPrototypeOf(o) {
  9989. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  9990. return o.__proto__ || Object.getPrototypeOf(o);
  9991. };
  9992. return _getPrototypeOf(o);
  9993. }
  9994. function _inherits(subClass, superClass) {
  9995. if (typeof superClass !== "function" && superClass !== null) {
  9996. throw new TypeError("Super expression must either be null or a function");
  9997. }
  9998. subClass.prototype = Object.create(superClass && superClass.prototype, {
  9999. constructor: {
  10000. value: subClass,
  10001. writable: true,
  10002. configurable: true
  10003. }
  10004. });
  10005. if (superClass) _setPrototypeOf(subClass, superClass);
  10006. }
  10007. function _setPrototypeOf(o, p) {
  10008. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  10009. o.__proto__ = p;
  10010. return o;
  10011. };
  10012. return _setPrototypeOf(o, p);
  10013. }
  10014. var PDFViewer =
  10015. /*#__PURE__*/
  10016. function(_BaseViewer) {
  10017. _inherits(PDFViewer, _BaseViewer);
  10018. function PDFViewer() {
  10019. _classCallCheck(this, PDFViewer);
  10020. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  10021. }
  10022. _createClass(PDFViewer, [{
  10023. key: "_scrollIntoView",
  10024. value: function _scrollIntoView(_ref) {
  10025. var pageDiv = _ref.pageDiv,
  10026. _ref$pageSpot = _ref.pageSpot,
  10027. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10028. _ref$pageNumber = _ref.pageNumber,
  10029. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10030. if (!pageSpot && !this.isInPresentationMode) {
  10031. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  10032. var right = left + pageDiv.clientWidth;
  10033. var _this$container = this.container,
  10034. scrollLeft = _this$container.scrollLeft,
  10035. clientWidth = _this$container.clientWidth;
  10036. if (this._isScrollModeHorizontal || left < scrollLeft || right >
  10037. scrollLeft + clientWidth) {
  10038. pageSpot = {
  10039. left: 0,
  10040. top: 0
  10041. };
  10042. }
  10043. }
  10044. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this)
  10045. .call(this, {
  10046. pageDiv: pageDiv,
  10047. pageSpot: pageSpot,
  10048. pageNumber: pageNumber
  10049. });
  10050. }
  10051. }, {
  10052. key: "_getVisiblePages",
  10053. value: function _getVisiblePages() {
  10054. if (this.isInPresentationMode) {
  10055. return this._getCurrentVisiblePage();
  10056. }
  10057. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages",
  10058. this).call(this);
  10059. }
  10060. }, {
  10061. key: "_updateHelper",
  10062. value: function _updateHelper(visiblePages) {
  10063. if (this.isInPresentationMode) {
  10064. return;
  10065. }
  10066. var currentId = this._currentPageNumber;
  10067. var stillFullyVisible = false;
  10068. var _iteratorNormalCompletion = true;
  10069. var _didIteratorError = false;
  10070. var _iteratorError = undefined;
  10071. try {
  10072. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(
  10073. _iteratorNormalCompletion = (_step = _iterator.next()).done
  10074. ); _iteratorNormalCompletion = true) {
  10075. var page = _step.value;
  10076. if (page.percent < 100) {
  10077. break;
  10078. }
  10079. if (page.id === currentId) {
  10080. stillFullyVisible = true;
  10081. break;
  10082. }
  10083. }
  10084. } catch (err) {
  10085. _didIteratorError = true;
  10086. _iteratorError = err;
  10087. } finally {
  10088. try {
  10089. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  10090. _iterator["return"]();
  10091. }
  10092. } finally {
  10093. if (_didIteratorError) {
  10094. throw _iteratorError;
  10095. }
  10096. }
  10097. }
  10098. if (!stillFullyVisible) {
  10099. currentId = visiblePages[0].id;
  10100. }
  10101. this._setCurrentPageNumber(currentId);
  10102. }
  10103. }, {
  10104. key: "_setDocumentViewerElement",
  10105. get: function get() {
  10106. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this
  10107. .viewer);
  10108. }
  10109. }]);
  10110. return PDFViewer;
  10111. }(_base_viewer.BaseViewer);
  10112. exports.PDFViewer = PDFViewer;
  10113. /***/
  10114. }),
  10115. /* 28 */
  10116. /***/
  10117. (function(module, exports, __webpack_require__) {
  10118. "use strict";
  10119. Object.defineProperty(exports, "__esModule", {
  10120. value: true
  10121. });
  10122. exports.BaseViewer = void 0;
  10123. var _ui_utils = __webpack_require__(5);
  10124. var _pdf_rendering_queue = __webpack_require__(11);
  10125. var _annotation_layer_builder = __webpack_require__(29);
  10126. var _pdfjsLib = __webpack_require__(7);
  10127. var _pdf_page_view = __webpack_require__(30);
  10128. var _pdf_link_service = __webpack_require__(21);
  10129. var _text_layer_builder = __webpack_require__(31);
  10130. function _classCallCheck(instance, Constructor) {
  10131. if (!(instance instanceof Constructor)) {
  10132. throw new TypeError("Cannot call a class as a function");
  10133. }
  10134. }
  10135. function _defineProperties(target, props) {
  10136. for (var i = 0; i < props.length; i++) {
  10137. var descriptor = props[i];
  10138. descriptor.enumerable = descriptor.enumerable || false;
  10139. descriptor.configurable = true;
  10140. if ("value" in descriptor) descriptor.writable = true;
  10141. Object.defineProperty(target, descriptor.key, descriptor);
  10142. }
  10143. }
  10144. function _createClass(Constructor, protoProps, staticProps) {
  10145. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  10146. if (staticProps) _defineProperties(Constructor, staticProps);
  10147. return Constructor;
  10148. }
  10149. var DEFAULT_CACHE_SIZE = 10;
  10150. function PDFPageViewBuffer(size) {
  10151. var data = [];
  10152. this.push = function(view) {
  10153. var i = data.indexOf(view);
  10154. if (i >= 0) {
  10155. data.splice(i, 1);
  10156. }
  10157. data.push(view);
  10158. if (data.length > size) {
  10159. data.shift().destroy();
  10160. }
  10161. };
  10162. this.resize = function(newSize, pagesToKeep) {
  10163. size = newSize;
  10164. if (pagesToKeep) {
  10165. var pageIdsToKeep = new Set();
  10166. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  10167. pageIdsToKeep.add(pagesToKeep[i].id);
  10168. }
  10169. (0, _ui_utils.moveToEndOfArray)(data, function(page) {
  10170. return pageIdsToKeep.has(page.id);
  10171. });
  10172. }
  10173. while (data.length > size) {
  10174. data.shift().destroy();
  10175. }
  10176. };
  10177. }
  10178. function isSameScale(oldScale, newScale) {
  10179. if (newScale === oldScale) {
  10180. return true;
  10181. }
  10182. if (Math.abs(newScale - oldScale) < 1e-15) {
  10183. return true;
  10184. }
  10185. return false;
  10186. }
  10187. var BaseViewer =
  10188. /*#__PURE__*/
  10189. function() {
  10190. function BaseViewer(options) {
  10191. var _this = this;
  10192. _classCallCheck(this, BaseViewer);
  10193. if (this.constructor === BaseViewer) {
  10194. throw new Error('Cannot initialize BaseViewer.');
  10195. }
  10196. this._name = this.constructor.name;
  10197. this.container = options.container;
  10198. this.viewer = options.viewer || options.container.firstElementChild;
  10199. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  10200. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10201. this.downloadManager = options.downloadManager || null;
  10202. this.findController = options.findController || null;
  10203. this.removePageBorders = options.removePageBorders || false;
  10204. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode :
  10205. _ui_utils.TextLayerMode.ENABLE;
  10206. this.imageResourcesPath = options.imageResourcesPath || '';
  10207. this.renderInteractiveForms = options.renderInteractiveForms || false;
  10208. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10209. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10210. this.enableWebGL = options.enableWebGL || false;
  10211. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10212. this.maxCanvasPixels = options.maxCanvasPixels;
  10213. this.l10n = options.l10n || _ui_utils.NullL10n;
  10214. this.defaultRenderingQueue = !options.renderingQueue;
  10215. if (this.defaultRenderingQueue) {
  10216. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10217. this.renderingQueue.setViewer(this);
  10218. } else {
  10219. this.renderingQueue = options.renderingQueue;
  10220. }
  10221. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10222. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10223. this._onBeforeDraw = this._onAfterDraw = null;
  10224. this._resetView();
  10225. if (this.removePageBorders) {
  10226. this.viewer.classList.add('removePageBorders');
  10227. }
  10228. Promise.resolve().then(function() {
  10229. _this.eventBus.dispatch('baseviewerinit', {
  10230. source: _this
  10231. });
  10232. });
  10233. }
  10234. _createClass(BaseViewer, [{
  10235. key: "getPageView",
  10236. value: function getPageView(index) {
  10237. return this._pages[index];
  10238. }
  10239. }, {
  10240. key: "_setCurrentPageNumber",
  10241. value: function _setCurrentPageNumber(val) {
  10242. var resetCurrentPageView = arguments.length > 1 && arguments[1] !==
  10243. undefined ? arguments[1] : false;
  10244. if (this._currentPageNumber === val) {
  10245. if (resetCurrentPageView) {
  10246. this._resetCurrentPageView();
  10247. }
  10248. return true;
  10249. }
  10250. if (!(0 < val && val <= this.pagesCount)) {
  10251. return false;
  10252. }
  10253. this._currentPageNumber = val;
  10254. this.eventBus.dispatch('pagechanging', {
  10255. source: this,
  10256. pageNumber: val,
  10257. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  10258. });
  10259. if (resetCurrentPageView) {
  10260. this._resetCurrentPageView();
  10261. }
  10262. return true;
  10263. }
  10264. }, {
  10265. key: "setDocument",
  10266. value: function setDocument(pdfDocument) {
  10267. var _this2 = this;
  10268. if (this.pdfDocument) {
  10269. this._cancelRendering();
  10270. this._resetView();
  10271. if (this.findController) {
  10272. this.findController.setDocument(null);
  10273. }
  10274. }
  10275. this.pdfDocument = pdfDocument;
  10276. if (!pdfDocument) {
  10277. return;
  10278. }
  10279. var pagesCount = pdfDocument.numPages;
  10280. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10281. this.pagesPromise = pagesCapability.promise;
  10282. pagesCapability.promise.then(function() {
  10283. _this2._pageViewsReady = true;
  10284. _this2.eventBus.dispatch('pagesloaded', {
  10285. source: _this2,
  10286. pagesCount: pagesCount
  10287. });
  10288. });
  10289. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)
  10290. ();
  10291. this.onePageRendered = onePageRenderedCapability.promise;
  10292. var firstPagePromise = pdfDocument.getPage(1);
  10293. this.firstPagePromise = firstPagePromise;
  10294. this._onBeforeDraw = function(evt) {
  10295. var pageView = _this2._pages[evt.pageNumber - 1];
  10296. if (!pageView) {
  10297. return;
  10298. }
  10299. _this2._buffer.push(pageView);
  10300. };
  10301. this.eventBus.on('pagerender', this._onBeforeDraw);
  10302. this._onAfterDraw = function(evt) {
  10303. if (evt.cssTransform || onePageRenderedCapability.settled) {
  10304. return;
  10305. }
  10306. onePageRenderedCapability.resolve();
  10307. _this2.eventBus.off('pagerendered', _this2._onAfterDraw);
  10308. _this2._onAfterDraw = null;
  10309. };
  10310. this.eventBus.on('pagerendered', this._onAfterDraw);
  10311. firstPagePromise.then(function(pdfPage) {
  10312. var scale = _this2.currentScale;
  10313. var viewport = pdfPage.getViewport({
  10314. scale: scale * _ui_utils.CSS_UNITS
  10315. });
  10316. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10317. var textLayerFactory = null;
  10318. if (_this2.textLayerMode !== _ui_utils.TextLayerMode
  10319. .DISABLE) {
  10320. textLayerFactory = _this2;
  10321. }
  10322. var pageView = new _pdf_page_view.PDFPageView({
  10323. container: _this2._setDocumentViewerElement,
  10324. eventBus: _this2.eventBus,
  10325. id: pageNum,
  10326. scale: scale,
  10327. defaultViewport: viewport.clone(),
  10328. renderingQueue: _this2.renderingQueue,
  10329. textLayerFactory: textLayerFactory,
  10330. textLayerMode: _this2.textLayerMode,
  10331. annotationLayerFactory: _this2,
  10332. imageResourcesPath: _this2
  10333. .imageResourcesPath,
  10334. renderInteractiveForms: _this2
  10335. .renderInteractiveForms,
  10336. renderer: _this2.renderer,
  10337. enableWebGL: _this2.enableWebGL,
  10338. useOnlyCssZoom: _this2.useOnlyCssZoom,
  10339. maxCanvasPixels: _this2.maxCanvasPixels,
  10340. l10n: _this2.l10n
  10341. });
  10342. _this2._pages.push(pageView);
  10343. }
  10344. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10345. _this2._updateSpreadMode();
  10346. }
  10347. onePageRenderedCapability.promise.then(function() {
  10348. if (_this2.findController) {
  10349. _this2.findController.setDocument(
  10350. pdfDocument);
  10351. }
  10352. if (pdfDocument.loadingParams[
  10353. 'disableAutoFetch']) {
  10354. pagesCapability.resolve();
  10355. return;
  10356. }
  10357. var getPagesLeft = pagesCount;
  10358. var _loop = function _loop(_pageNum) {
  10359. pdfDocument.getPage(_pageNum).then(
  10360. function(pdfPage) {
  10361. var pageView = _this2
  10362. ._pages[_pageNum - 1];
  10363. if (!pageView.pdfPage) {
  10364. pageView.setPdfPage(
  10365. pdfPage);
  10366. }
  10367. _this2.linkService
  10368. .cachePageRef(_pageNum,
  10369. pdfPage.ref);
  10370. if (--getPagesLeft === 0) {
  10371. pagesCapability
  10372. .resolve();
  10373. }
  10374. },
  10375. function(reason) {
  10376. console.error(
  10377. "Unable to get page "
  10378. .concat(_pageNum,
  10379. " to initialize viewer"
  10380. ), reason);
  10381. if (--getPagesLeft === 0) {
  10382. pagesCapability
  10383. .resolve();
  10384. }
  10385. });
  10386. };
  10387. for (var _pageNum = 1; _pageNum <=
  10388. pagesCount; ++_pageNum) {
  10389. _loop(_pageNum);
  10390. }
  10391. });
  10392. _this2.eventBus.dispatch('pagesinit', {
  10393. source: _this2
  10394. });
  10395. if (_this2.defaultRenderingQueue) {
  10396. _this2.update();
  10397. }
  10398. })["catch"](function(reason) {
  10399. console.error('Unable to initialize viewer', reason);
  10400. });
  10401. }
  10402. }, {
  10403. key: "setPageLabels",
  10404. value: function setPageLabels(labels) {
  10405. if (!this.pdfDocument) {
  10406. return;
  10407. }
  10408. if (!labels) {
  10409. this._pageLabels = null;
  10410. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages ===
  10411. labels.length)) {
  10412. this._pageLabels = null;
  10413. console.error("".concat(this._name,
  10414. ".setPageLabels: Invalid page labels."));
  10415. } else {
  10416. this._pageLabels = labels;
  10417. }
  10418. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10419. var pageView = this._pages[i];
  10420. var label = this._pageLabels && this._pageLabels[i];
  10421. pageView.setPageLabel(label);
  10422. }
  10423. }
  10424. }, {
  10425. key: "_resetView",
  10426. value: function _resetView() {
  10427. this._pages = [];
  10428. this._currentPageNumber = 1;
  10429. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10430. this._currentScaleValue = null;
  10431. this._pageLabels = null;
  10432. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  10433. this._location = null;
  10434. this._pagesRotation = 0;
  10435. this._pagesRequests = [];
  10436. this._pageViewsReady = false;
  10437. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10438. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10439. if (this._onBeforeDraw) {
  10440. this.eventBus.off('pagerender', this._onBeforeDraw);
  10441. this._onBeforeDraw = null;
  10442. }
  10443. if (this._onAfterDraw) {
  10444. this.eventBus.off('pagerendered', this._onAfterDraw);
  10445. this._onAfterDraw = null;
  10446. }
  10447. this.viewer.textContent = '';
  10448. this._updateScrollMode();
  10449. }
  10450. }, {
  10451. key: "_scrollUpdate",
  10452. value: function _scrollUpdate() {
  10453. if (this.pagesCount === 0) {
  10454. return;
  10455. }
  10456. this.update();
  10457. }
  10458. }, {
  10459. key: "_scrollIntoView",
  10460. value: function _scrollIntoView(_ref) {
  10461. var pageDiv = _ref.pageDiv,
  10462. _ref$pageSpot = _ref.pageSpot,
  10463. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10464. _ref$pageNumber = _ref.pageNumber,
  10465. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10466. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10467. }
  10468. }, {
  10469. key: "_setScaleUpdatePages",
  10470. value: function _setScaleUpdatePages(newScale, newValue) {
  10471. var noScroll = arguments.length > 2 && arguments[2] !== undefined ?
  10472. arguments[2] : false;
  10473. var preset = arguments.length > 3 && arguments[3] !== undefined ?
  10474. arguments[3] : false;
  10475. this._currentScaleValue = newValue.toString();
  10476. if (isSameScale(this._currentScale, newScale)) {
  10477. if (preset) {
  10478. this.eventBus.dispatch('scalechanging', {
  10479. source: this,
  10480. scale: newScale,
  10481. presetValue: newValue
  10482. });
  10483. }
  10484. return;
  10485. }
  10486. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10487. this._pages[i].update(newScale);
  10488. }
  10489. this._currentScale = newScale;
  10490. if (!noScroll) {
  10491. var page = this._currentPageNumber,
  10492. dest;
  10493. if (this._location && !(this.isInPresentationMode || this
  10494. .isChangingPresentationMode)) {
  10495. page = this._location.pageNumber;
  10496. dest = [null, {
  10497. name: 'XYZ'
  10498. }, this._location.left, this._location.top, null];
  10499. }
  10500. this.scrollPageIntoView({
  10501. pageNumber: page,
  10502. destArray: dest,
  10503. allowNegativeOffset: true
  10504. });
  10505. }
  10506. this.eventBus.dispatch('scalechanging', {
  10507. source: this,
  10508. scale: newScale,
  10509. presetValue: preset ? newValue : undefined
  10510. });
  10511. if (this.defaultRenderingQueue) {
  10512. this.update();
  10513. }
  10514. }
  10515. }, {
  10516. key: "_setScale",
  10517. value: function _setScale(value) {
  10518. var noScroll = arguments.length > 1 && arguments[1] !== undefined ?
  10519. arguments[1] : false;
  10520. var scale = parseFloat(value);
  10521. if (scale > 0) {
  10522. this._setScaleUpdatePages(scale, value, noScroll, false);
  10523. } else {
  10524. var currentPage = this._pages[this._currentPageNumber - 1];
  10525. if (!currentPage) {
  10526. return;
  10527. }
  10528. var noPadding = this.isInPresentationMode || this.removePageBorders;
  10529. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10530. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  10531. if (!noPadding && this._isScrollModeHorizontal) {
  10532. var _ref2 = [vPadding, hPadding];
  10533. hPadding = _ref2[0];
  10534. vPadding = _ref2[1];
  10535. }
  10536. var pageWidthScale = (this.container.clientWidth - hPadding) /
  10537. currentPage.width * currentPage.scale;
  10538. var pageHeightScale = (this.container.clientHeight - vPadding) /
  10539. currentPage.height * currentPage.scale;
  10540. switch (value) {
  10541. case 'page-actual':
  10542. scale = 1;
  10543. break;
  10544. case 'page-width':
  10545. scale = pageWidthScale;
  10546. break;
  10547. case 'page-height':
  10548. scale = pageHeightScale;
  10549. break;
  10550. case 'page-fit':
  10551. scale = Math.min(pageWidthScale, pageHeightScale);
  10552. break;
  10553. case 'auto':
  10554. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(
  10555. currentPage) ? pageWidthScale : Math.min(
  10556. pageHeightScale, pageWidthScale);
  10557. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10558. break;
  10559. default:
  10560. console.error("".concat(this._name, "._setScale: \"")
  10561. .concat(value, "\" is an unknown zoom value."));
  10562. return;
  10563. }
  10564. this._setScaleUpdatePages(scale, value, noScroll, true);
  10565. }
  10566. }
  10567. }, {
  10568. key: "_resetCurrentPageView",
  10569. value: function _resetCurrentPageView() {
  10570. if (this.isInPresentationMode) {
  10571. this._setScale(this._currentScaleValue, true);
  10572. }
  10573. var pageView = this._pages[this._currentPageNumber - 1];
  10574. this._scrollIntoView({
  10575. pageDiv: pageView.div
  10576. });
  10577. }
  10578. }, {
  10579. key: "scrollPageIntoView",
  10580. value: function scrollPageIntoView(_ref3) {
  10581. var pageNumber = _ref3.pageNumber,
  10582. _ref3$destArray = _ref3.destArray,
  10583. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  10584. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  10585. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false :
  10586. _ref3$allowNegativeOf;
  10587. if (!this.pdfDocument) {
  10588. return;
  10589. }
  10590. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber -
  10591. 1];
  10592. if (!pageView) {
  10593. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\""
  10594. .concat(pageNumber,
  10595. "\" is not a valid pageNumber parameter."));
  10596. return;
  10597. }
  10598. if (this.isInPresentationMode || !destArray) {
  10599. this._setCurrentPageNumber(pageNumber, true);
  10600. return;
  10601. }
  10602. var x = 0,
  10603. y = 0;
  10604. var width = 0,
  10605. height = 0,
  10606. widthScale,
  10607. heightScale;
  10608. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  10609. var pageWidth = (changeOrientation ? pageView.height : pageView.width) /
  10610. pageView.scale / _ui_utils.CSS_UNITS;
  10611. var pageHeight = (changeOrientation ? pageView.width : pageView
  10612. .height) / pageView.scale / _ui_utils.CSS_UNITS;
  10613. var scale = 0;
  10614. switch (destArray[1].name) {
  10615. case 'XYZ':
  10616. x = destArray[2];
  10617. y = destArray[3];
  10618. scale = destArray[4];
  10619. x = x !== null ? x : 0;
  10620. y = y !== null ? y : pageHeight;
  10621. break;
  10622. case 'Fit':
  10623. case 'FitB':
  10624. scale = 'page-fit';
  10625. break;
  10626. case 'FitH':
  10627. case 'FitBH':
  10628. y = destArray[2];
  10629. scale = 'page-width';
  10630. if (y === null && this._location) {
  10631. x = this._location.left;
  10632. y = this._location.top;
  10633. }
  10634. break;
  10635. case 'FitV':
  10636. case 'FitBV':
  10637. x = destArray[2];
  10638. width = pageWidth;
  10639. height = pageHeight;
  10640. scale = 'page-height';
  10641. break;
  10642. case 'FitR':
  10643. x = destArray[2];
  10644. y = destArray[3];
  10645. width = destArray[4] - x;
  10646. height = destArray[5] - y;
  10647. var hPadding = this.removePageBorders ? 0 : _ui_utils
  10648. .SCROLLBAR_PADDING;
  10649. var vPadding = this.removePageBorders ? 0 : _ui_utils
  10650. .VERTICAL_PADDING;
  10651. widthScale = (this.container.clientWidth - hPadding) / width /
  10652. _ui_utils.CSS_UNITS;
  10653. heightScale = (this.container.clientHeight - vPadding) /
  10654. height / _ui_utils.CSS_UNITS;
  10655. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10656. break;
  10657. default:
  10658. console.error("".concat(this._name, ".scrollPageIntoView: ") +
  10659. "\"".concat(destArray[1].name,
  10660. "\" is not a valid destination type."));
  10661. return;
  10662. }
  10663. if (scale && scale !== this._currentScale) {
  10664. this.currentScaleValue = scale;
  10665. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10666. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10667. }
  10668. if (scale === 'page-fit' && !destArray[4]) {
  10669. this._scrollIntoView({
  10670. pageDiv: pageView.div,
  10671. pageNumber: pageNumber
  10672. });
  10673. return;
  10674. }
  10675. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y),
  10676. pageView.viewport.convertToViewportPoint(x + width, y + height)
  10677. ];
  10678. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10679. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10680. if (!allowNegativeOffset) {
  10681. left = Math.max(left, 0);
  10682. top = Math.max(top, 0);
  10683. }
  10684. this._scrollIntoView({
  10685. pageDiv: pageView.div,
  10686. pageSpot: {
  10687. left: left,
  10688. top: top
  10689. },
  10690. pageNumber: pageNumber
  10691. });
  10692. }
  10693. }, {
  10694. key: "_updateLocation",
  10695. value: function _updateLocation(firstPage) {
  10696. var currentScale = this._currentScale;
  10697. var currentScaleValue = this._currentScaleValue;
  10698. var normalizedScaleValue = parseFloat(currentScaleValue) ===
  10699. currentScale ? Math.round(currentScale * 10000) / 100 :
  10700. currentScaleValue;
  10701. var pageNumber = firstPage.id;
  10702. var pdfOpenParams = '#page=' + pageNumber;
  10703. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  10704. var currentPageView = this._pages[pageNumber - 1];
  10705. var container = this.container;
  10706. var topLeft = currentPageView.getPagePoint(container.scrollLeft -
  10707. firstPage.x, container.scrollTop - firstPage.y);
  10708. var intLeft = Math.round(topLeft[0]);
  10709. var intTop = Math.round(topLeft[1]);
  10710. pdfOpenParams += ',' + intLeft + ',' + intTop;
  10711. this._location = {
  10712. pageNumber: pageNumber,
  10713. scale: normalizedScaleValue,
  10714. top: intTop,
  10715. left: intLeft,
  10716. rotation: this._pagesRotation,
  10717. pdfOpenParams: pdfOpenParams
  10718. };
  10719. }
  10720. }, {
  10721. key: "_updateHelper",
  10722. value: function _updateHelper(visiblePages) {
  10723. throw new Error('Not implemented: _updateHelper');
  10724. }
  10725. }, {
  10726. key: "update",
  10727. value: function update() {
  10728. var visible = this._getVisiblePages();
  10729. var visiblePages = visible.views,
  10730. numVisiblePages = visiblePages.length;
  10731. if (numVisiblePages === 0) {
  10732. return;
  10733. }
  10734. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages +
  10735. 1);
  10736. this._buffer.resize(newCacheSize, visiblePages);
  10737. this.renderingQueue.renderHighestPriority(visible);
  10738. this._updateHelper(visiblePages);
  10739. this._updateLocation(visible.first);
  10740. this.eventBus.dispatch('updateviewarea', {
  10741. source: this,
  10742. location: this._location
  10743. });
  10744. }
  10745. }, {
  10746. key: "containsElement",
  10747. value: function containsElement(element) {
  10748. return this.container.contains(element);
  10749. }
  10750. }, {
  10751. key: "focus",
  10752. value: function focus() {
  10753. this.container.focus();
  10754. }
  10755. }, {
  10756. key: "_getCurrentVisiblePage",
  10757. value: function _getCurrentVisiblePage() {
  10758. if (!this.pagesCount) {
  10759. return {
  10760. views: []
  10761. };
  10762. }
  10763. var pageView = this._pages[this._currentPageNumber - 1];
  10764. var element = pageView.div;
  10765. var view = {
  10766. id: pageView.id,
  10767. x: element.offsetLeft + element.clientLeft,
  10768. y: element.offsetTop + element.clientTop,
  10769. view: pageView
  10770. };
  10771. return {
  10772. first: view,
  10773. last: view,
  10774. views: [view]
  10775. };
  10776. }
  10777. }, {
  10778. key: "_getVisiblePages",
  10779. value: function _getVisiblePages() {
  10780. return (0, _ui_utils.getVisibleElements)(this.container, this._pages,
  10781. true, this._isScrollModeHorizontal);
  10782. }
  10783. }, {
  10784. key: "isPageVisible",
  10785. value: function isPageVisible(pageNumber) {
  10786. if (!this.pdfDocument) {
  10787. return false;
  10788. }
  10789. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  10790. console.error("".concat(this._name, ".isPageVisible: \"").concat(
  10791. pageNumber, "\" is out of bounds."));
  10792. return false;
  10793. }
  10794. return this._getVisiblePages().views.some(function(view) {
  10795. return view.id === pageNumber;
  10796. });
  10797. }
  10798. }, {
  10799. key: "cleanup",
  10800. value: function cleanup() {
  10801. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10802. if (this._pages[i] && this._pages[i].renderingState !==
  10803. _pdf_rendering_queue.RenderingStates.FINISHED) {
  10804. this._pages[i].reset();
  10805. }
  10806. }
  10807. }
  10808. }, {
  10809. key: "_cancelRendering",
  10810. value: function _cancelRendering() {
  10811. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10812. if (this._pages[i]) {
  10813. this._pages[i].cancelRendering();
  10814. }
  10815. }
  10816. }
  10817. }, {
  10818. key: "_ensurePdfPageLoaded",
  10819. value: function _ensurePdfPageLoaded(pageView) {
  10820. var _this3 = this;
  10821. if (pageView.pdfPage) {
  10822. return Promise.resolve(pageView.pdfPage);
  10823. }
  10824. var pageNumber = pageView.id;
  10825. if (this._pagesRequests[pageNumber]) {
  10826. return this._pagesRequests[pageNumber];
  10827. }
  10828. var promise = this.pdfDocument.getPage(pageNumber).then(function(
  10829. pdfPage) {
  10830. if (!pageView.pdfPage) {
  10831. pageView.setPdfPage(pdfPage);
  10832. }
  10833. _this3._pagesRequests[pageNumber] = null;
  10834. return pdfPage;
  10835. })["catch"](function(reason) {
  10836. console.error('Unable to get page for page view', reason);
  10837. _this3._pagesRequests[pageNumber] = null;
  10838. });
  10839. this._pagesRequests[pageNumber] = promise;
  10840. return promise;
  10841. }
  10842. }, {
  10843. key: "forceRendering",
  10844. value: function forceRendering(currentlyVisiblePages) {
  10845. var _this4 = this;
  10846. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  10847. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right :
  10848. this.scroll.down;
  10849. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this
  10850. ._pages, scrollAhead);
  10851. if (pageView) {
  10852. this._ensurePdfPageLoaded(pageView).then(function() {
  10853. _this4.renderingQueue.renderView(pageView);
  10854. });
  10855. return true;
  10856. }
  10857. return false;
  10858. }
  10859. }, {
  10860. key: "createTextLayerBuilder",
  10861. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10862. var enhanceTextSelection = arguments.length > 3 && arguments[3] !==
  10863. undefined ? arguments[3] : false;
  10864. return new _text_layer_builder.TextLayerBuilder({
  10865. textLayerDiv: textLayerDiv,
  10866. eventBus: this.eventBus,
  10867. pageIndex: pageIndex,
  10868. viewport: viewport,
  10869. findController: this.isInPresentationMode ? null : this
  10870. .findController,
  10871. enhanceTextSelection: this.isInPresentationMode ? false :
  10872. enhanceTextSelection
  10873. });
  10874. }
  10875. }, {
  10876. key: "createAnnotationLayerBuilder",
  10877. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  10878. var imageResourcesPath = arguments.length > 2 && arguments[2] !==
  10879. undefined ? arguments[2] : '';
  10880. var renderInteractiveForms = arguments.length > 3 && arguments[3] !==
  10881. undefined ? arguments[3] : false;
  10882. var l10n = arguments.length > 4 && arguments[4] !== undefined ?
  10883. arguments[4] : _ui_utils.NullL10n;
  10884. return new _annotation_layer_builder.AnnotationLayerBuilder({
  10885. pageDiv: pageDiv,
  10886. pdfPage: pdfPage,
  10887. imageResourcesPath: imageResourcesPath,
  10888. renderInteractiveForms: renderInteractiveForms,
  10889. linkService: this.linkService,
  10890. downloadManager: this.downloadManager,
  10891. l10n: l10n
  10892. });
  10893. }
  10894. }, {
  10895. key: "getPagesOverview",
  10896. value: function getPagesOverview() {
  10897. var pagesOverview = this._pages.map(function(pageView) {
  10898. var viewport = pageView.pdfPage.getViewport({
  10899. scale: 1
  10900. });
  10901. return {
  10902. width: viewport.width,
  10903. height: viewport.height,
  10904. rotation: viewport.rotation
  10905. };
  10906. });
  10907. if (!this.enablePrintAutoRotate) {
  10908. return pagesOverview;
  10909. }
  10910. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(
  10911. pagesOverview[0]);
  10912. return pagesOverview.map(function(size) {
  10913. if (isFirstPagePortrait === (0, _ui_utils
  10914. .isPortraitOrientation)(size)) {
  10915. return size;
  10916. }
  10917. return {
  10918. width: size.height,
  10919. height: size.width,
  10920. rotation: (size.rotation + 90) % 360
  10921. };
  10922. });
  10923. }
  10924. }, {
  10925. key: "_updateScrollMode",
  10926. value: function _updateScrollMode() {
  10927. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ?
  10928. arguments[0] : null;
  10929. var scrollMode = this._scrollMode,
  10930. viewer = this.viewer;
  10931. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils
  10932. .ScrollMode.HORIZONTAL);
  10933. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils
  10934. .ScrollMode.WRAPPED);
  10935. if (!this.pdfDocument || !pageNumber) {
  10936. return;
  10937. }
  10938. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  10939. this._setScale(this._currentScaleValue, true);
  10940. }
  10941. this._setCurrentPageNumber(pageNumber, true);
  10942. this.update();
  10943. }
  10944. }, {
  10945. key: "_updateSpreadMode",
  10946. value: function _updateSpreadMode() {
  10947. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ?
  10948. arguments[0] : null;
  10949. if (!this.pdfDocument) {
  10950. return;
  10951. }
  10952. var viewer = this.viewer,
  10953. pages = this._pages;
  10954. viewer.textContent = '';
  10955. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10956. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  10957. viewer.appendChild(pages[i].div);
  10958. }
  10959. } else {
  10960. var parity = this._spreadMode - 1;
  10961. var spread = null;
  10962. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  10963. if (spread === null) {
  10964. spread = document.createElement('div');
  10965. spread.className = 'spread';
  10966. viewer.appendChild(spread);
  10967. } else if (_i % 2 === parity) {
  10968. spread = spread.cloneNode(false);
  10969. viewer.appendChild(spread);
  10970. }
  10971. spread.appendChild(pages[_i].div);
  10972. }
  10973. }
  10974. if (!pageNumber) {
  10975. return;
  10976. }
  10977. this._setCurrentPageNumber(pageNumber, true);
  10978. this.update();
  10979. }
  10980. }, {
  10981. key: "pagesCount",
  10982. get: function get() {
  10983. return this._pages.length;
  10984. }
  10985. }, {
  10986. key: "pageViewsReady",
  10987. get: function get() {
  10988. return this._pageViewsReady;
  10989. }
  10990. }, {
  10991. key: "currentPageNumber",
  10992. get: function get() {
  10993. return this._currentPageNumber;
  10994. },
  10995. set: function set(val) {
  10996. if (!Number.isInteger(val)) {
  10997. throw new Error('Invalid page number.');
  10998. }
  10999. if (!this.pdfDocument) {
  11000. return;
  11001. }
  11002. if (!this._setCurrentPageNumber(val, true)) {
  11003. console.error("".concat(this._name, ".currentPageNumber: \"")
  11004. .concat(val, "\" is not a valid page."));
  11005. }
  11006. }
  11007. }, {
  11008. key: "currentPageLabel",
  11009. get: function get() {
  11010. return this._pageLabels && this._pageLabels[this._currentPageNumber -
  11011. 1];
  11012. },
  11013. set: function set(val) {
  11014. if (!this.pdfDocument) {
  11015. return;
  11016. }
  11017. var page = val | 0;
  11018. if (this._pageLabels) {
  11019. var i = this._pageLabels.indexOf(val);
  11020. if (i >= 0) {
  11021. page = i + 1;
  11022. }
  11023. }
  11024. if (!this._setCurrentPageNumber(page, true)) {
  11025. console.error("".concat(this._name, ".currentPageLabel: \"").concat(
  11026. val, "\" is not a valid page."));
  11027. }
  11028. }
  11029. }, {
  11030. key: "currentScale",
  11031. get: function get() {
  11032. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this
  11033. ._currentScale : _ui_utils.DEFAULT_SCALE;
  11034. },
  11035. set: function set(val) {
  11036. if (isNaN(val)) {
  11037. throw new Error('Invalid numeric scale.');
  11038. }
  11039. if (!this.pdfDocument) {
  11040. return;
  11041. }
  11042. this._setScale(val, false);
  11043. }
  11044. }, {
  11045. key: "currentScaleValue",
  11046. get: function get() {
  11047. return this._currentScaleValue;
  11048. },
  11049. set: function set(val) {
  11050. if (!this.pdfDocument) {
  11051. return;
  11052. }
  11053. this._setScale(val, false);
  11054. }
  11055. }, {
  11056. key: "pagesRotation",
  11057. get: function get() {
  11058. return this._pagesRotation;
  11059. },
  11060. set: function set(rotation) {
  11061. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  11062. throw new Error('Invalid pages rotation angle.');
  11063. }
  11064. if (!this.pdfDocument) {
  11065. return;
  11066. }
  11067. if (this._pagesRotation === rotation) {
  11068. return;
  11069. }
  11070. this._pagesRotation = rotation;
  11071. var pageNumber = this._currentPageNumber;
  11072. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11073. var pageView = this._pages[i];
  11074. pageView.update(pageView.scale, rotation);
  11075. }
  11076. if (this._currentScaleValue) {
  11077. this._setScale(this._currentScaleValue, true);
  11078. }
  11079. this.eventBus.dispatch('rotationchanging', {
  11080. source: this,
  11081. pagesRotation: rotation,
  11082. pageNumber: pageNumber
  11083. });
  11084. if (this.defaultRenderingQueue) {
  11085. this.update();
  11086. }
  11087. }
  11088. }, {
  11089. key: "_setDocumentViewerElement",
  11090. get: function get() {
  11091. throw new Error('Not implemented: _setDocumentViewerElement');
  11092. }
  11093. }, {
  11094. key: "_isScrollModeHorizontal",
  11095. get: function get() {
  11096. return this.isInPresentationMode ? false : this._scrollMode ===
  11097. _ui_utils.ScrollMode.HORIZONTAL;
  11098. }
  11099. }, {
  11100. key: "isInPresentationMode",
  11101. get: function get() {
  11102. return this.presentationModeState === _ui_utils.PresentationModeState
  11103. .FULLSCREEN;
  11104. }
  11105. }, {
  11106. key: "isChangingPresentationMode",
  11107. get: function get() {
  11108. return this.presentationModeState === _ui_utils.PresentationModeState
  11109. .CHANGING;
  11110. }
  11111. }, {
  11112. key: "isHorizontalScrollbarEnabled",
  11113. get: function get() {
  11114. return this.isInPresentationMode ? false : this.container.scrollWidth >
  11115. this.container.clientWidth;
  11116. }
  11117. }, {
  11118. key: "isVerticalScrollbarEnabled",
  11119. get: function get() {
  11120. return this.isInPresentationMode ? false : this.container.scrollHeight >
  11121. this.container.clientHeight;
  11122. }
  11123. }, {
  11124. key: "hasEqualPageSizes",
  11125. get: function get() {
  11126. var firstPageView = this._pages[0];
  11127. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  11128. var pageView = this._pages[i];
  11129. if (pageView.width !== firstPageView.width || pageView.height !==
  11130. firstPageView.height) {
  11131. return false;
  11132. }
  11133. }
  11134. return true;
  11135. }
  11136. }, {
  11137. key: "scrollMode",
  11138. get: function get() {
  11139. return this._scrollMode;
  11140. },
  11141. set: function set(mode) {
  11142. if (this._scrollMode === mode) {
  11143. return;
  11144. }
  11145. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11146. throw new Error("Invalid scroll mode: ".concat(mode));
  11147. }
  11148. this._scrollMode = mode;
  11149. this.eventBus.dispatch('scrollmodechanged', {
  11150. source: this,
  11151. mode: mode
  11152. });
  11153. this._updateScrollMode(this._currentPageNumber);
  11154. }
  11155. }, {
  11156. key: "spreadMode",
  11157. get: function get() {
  11158. return this._spreadMode;
  11159. },
  11160. set: function set(mode) {
  11161. if (this._spreadMode === mode) {
  11162. return;
  11163. }
  11164. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11165. throw new Error("Invalid spread mode: ".concat(mode));
  11166. }
  11167. this._spreadMode = mode;
  11168. this.eventBus.dispatch('spreadmodechanged', {
  11169. source: this,
  11170. mode: mode
  11171. });
  11172. this._updateSpreadMode(this._currentPageNumber);
  11173. }
  11174. }]);
  11175. return BaseViewer;
  11176. }();
  11177. exports.BaseViewer = BaseViewer;
  11178. /***/
  11179. }),
  11180. /* 29 */
  11181. /***/
  11182. (function(module, exports, __webpack_require__) {
  11183. "use strict";
  11184. Object.defineProperty(exports, "__esModule", {
  11185. value: true
  11186. });
  11187. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  11188. var _pdfjsLib = __webpack_require__(7);
  11189. var _ui_utils = __webpack_require__(5);
  11190. var _pdf_link_service = __webpack_require__(21);
  11191. function _classCallCheck(instance, Constructor) {
  11192. if (!(instance instanceof Constructor)) {
  11193. throw new TypeError("Cannot call a class as a function");
  11194. }
  11195. }
  11196. function _defineProperties(target, props) {
  11197. for (var i = 0; i < props.length; i++) {
  11198. var descriptor = props[i];
  11199. descriptor.enumerable = descriptor.enumerable || false;
  11200. descriptor.configurable = true;
  11201. if ("value" in descriptor) descriptor.writable = true;
  11202. Object.defineProperty(target, descriptor.key, descriptor);
  11203. }
  11204. }
  11205. function _createClass(Constructor, protoProps, staticProps) {
  11206. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  11207. if (staticProps) _defineProperties(Constructor, staticProps);
  11208. return Constructor;
  11209. }
  11210. var AnnotationLayerBuilder =
  11211. /*#__PURE__*/
  11212. function() {
  11213. function AnnotationLayerBuilder(_ref) {
  11214. var pageDiv = _ref.pageDiv,
  11215. pdfPage = _ref.pdfPage,
  11216. linkService = _ref.linkService,
  11217. downloadManager = _ref.downloadManager,
  11218. _ref$imageResourcesPa = _ref.imageResourcesPath,
  11219. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  11220. _ref$renderInteractiv = _ref.renderInteractiveForms,
  11221. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false :
  11222. _ref$renderInteractiv,
  11223. _ref$l10n = _ref.l10n,
  11224. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  11225. _classCallCheck(this, AnnotationLayerBuilder);
  11226. this.pageDiv = pageDiv;
  11227. this.pdfPage = pdfPage;
  11228. this.linkService = linkService;
  11229. this.downloadManager = downloadManager;
  11230. this.imageResourcesPath = imageResourcesPath;
  11231. this.renderInteractiveForms = renderInteractiveForms;
  11232. this.l10n = l10n;
  11233. this.div = null;
  11234. this._cancelled = false;
  11235. }
  11236. _createClass(AnnotationLayerBuilder, [{
  11237. key: "render",
  11238. value: function render(viewport) {
  11239. var _this = this;
  11240. var intent = arguments.length > 1 && arguments[1] !== undefined ?
  11241. arguments[1] : 'display';
  11242. this.pdfPage.getAnnotations({
  11243. intent: intent
  11244. }).then(function(annotations) {
  11245. if (_this._cancelled) {
  11246. return;
  11247. }
  11248. var parameters = {
  11249. viewport: viewport.clone({
  11250. dontFlip: true
  11251. }),
  11252. div: _this.div,
  11253. annotations: annotations,
  11254. page: _this.pdfPage,
  11255. imageResourcesPath: _this.imageResourcesPath,
  11256. renderInteractiveForms: _this
  11257. .renderInteractiveForms,
  11258. linkService: _this.linkService,
  11259. downloadManager: _this.downloadManager
  11260. };
  11261. if (_this.div) {
  11262. _pdfjsLib.AnnotationLayer.update(parameters);
  11263. } else {
  11264. if (annotations.length === 0) {
  11265. return;
  11266. }
  11267. _this.div = document.createElement('div');
  11268. _this.div.className = 'annotationLayer';
  11269. _this.pageDiv.appendChild(_this.div);
  11270. parameters.div = _this.div;
  11271. _pdfjsLib.AnnotationLayer.render(parameters);
  11272. _this.l10n.translate(_this.div);
  11273. }
  11274. });
  11275. }
  11276. }, {
  11277. key: "cancel",
  11278. value: function cancel() {
  11279. this._cancelled = true;
  11280. }
  11281. }, {
  11282. key: "hide",
  11283. value: function hide() {
  11284. if (!this.div) {
  11285. return;
  11286. }
  11287. this.div.setAttribute('hidden', 'true');
  11288. }
  11289. }]);
  11290. return AnnotationLayerBuilder;
  11291. }();
  11292. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  11293. var DefaultAnnotationLayerFactory =
  11294. /*#__PURE__*/
  11295. function() {
  11296. function DefaultAnnotationLayerFactory() {
  11297. _classCallCheck(this, DefaultAnnotationLayerFactory);
  11298. }
  11299. _createClass(DefaultAnnotationLayerFactory, [{
  11300. key: "createAnnotationLayerBuilder",
  11301. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11302. var imageResourcesPath = arguments.length > 2 && arguments[2] !==
  11303. undefined ? arguments[2] : '';
  11304. var renderInteractiveForms = arguments.length > 3 && arguments[3] !==
  11305. undefined ? arguments[3] : false;
  11306. var l10n = arguments.length > 4 && arguments[4] !== undefined ?
  11307. arguments[4] : _ui_utils.NullL10n;
  11308. return new AnnotationLayerBuilder({
  11309. pageDiv: pageDiv,
  11310. pdfPage: pdfPage,
  11311. imageResourcesPath: imageResourcesPath,
  11312. renderInteractiveForms: renderInteractiveForms,
  11313. linkService: new _pdf_link_service.SimpleLinkService(),
  11314. l10n: l10n
  11315. });
  11316. }
  11317. }]);
  11318. return DefaultAnnotationLayerFactory;
  11319. }();
  11320. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  11321. /***/
  11322. }),
  11323. /* 30 */
  11324. /***/
  11325. (function(module, exports, __webpack_require__) {
  11326. "use strict";
  11327. Object.defineProperty(exports, "__esModule", {
  11328. value: true
  11329. });
  11330. exports.PDFPageView = void 0;
  11331. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11332. var _ui_utils = __webpack_require__(5);
  11333. var _pdfjsLib = __webpack_require__(7);
  11334. var _pdf_rendering_queue = __webpack_require__(11);
  11335. var _viewer_compatibility = __webpack_require__(8);
  11336. function _interopRequireDefault(obj) {
  11337. return obj && obj.__esModule ? obj : {
  11338. "default": obj
  11339. };
  11340. }
  11341. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  11342. try {
  11343. var info = gen[key](arg);
  11344. var value = info.value;
  11345. } catch (error) {
  11346. reject(error);
  11347. return;
  11348. }
  11349. if (info.done) {
  11350. resolve(value);
  11351. } else {
  11352. Promise.resolve(value).then(_next, _throw);
  11353. }
  11354. }
  11355. function _asyncToGenerator(fn) {
  11356. return function() {
  11357. var self = this,
  11358. args = arguments;
  11359. return new Promise(function(resolve, reject) {
  11360. var gen = fn.apply(self, args);
  11361. function _next(value) {
  11362. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  11363. }
  11364. function _throw(err) {
  11365. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  11366. }
  11367. _next(undefined);
  11368. });
  11369. };
  11370. }
  11371. function _classCallCheck(instance, Constructor) {
  11372. if (!(instance instanceof Constructor)) {
  11373. throw new TypeError("Cannot call a class as a function");
  11374. }
  11375. }
  11376. function _defineProperties(target, props) {
  11377. for (var i = 0; i < props.length; i++) {
  11378. var descriptor = props[i];
  11379. descriptor.enumerable = descriptor.enumerable || false;
  11380. descriptor.configurable = true;
  11381. if ("value" in descriptor) descriptor.writable = true;
  11382. Object.defineProperty(target, descriptor.key, descriptor);
  11383. }
  11384. }
  11385. function _createClass(Constructor, protoProps, staticProps) {
  11386. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  11387. if (staticProps) _defineProperties(Constructor, staticProps);
  11388. return Constructor;
  11389. }
  11390. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  11391. var PDFPageView =
  11392. /*#__PURE__*/
  11393. function() {
  11394. function PDFPageView(options) {
  11395. _classCallCheck(this, PDFPageView);
  11396. var container = options.container;
  11397. var defaultViewport = options.defaultViewport;
  11398. this.id = options.id;
  11399. this.renderingId = 'page' + this.id;
  11400. this.pdfPage = null;
  11401. this.pageLabel = null;
  11402. this.rotation = 0;
  11403. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  11404. this.viewport = defaultViewport;
  11405. this.pdfPageRotate = defaultViewport.rotation;
  11406. this.hasRestrictedScaling = false;
  11407. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode :
  11408. _ui_utils.TextLayerMode.ENABLE;
  11409. this.imageResourcesPath = options.imageResourcesPath || '';
  11410. this.renderInteractiveForms = options.renderInteractiveForms || false;
  11411. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11412. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  11413. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  11414. this.renderingQueue = options.renderingQueue;
  11415. this.textLayerFactory = options.textLayerFactory;
  11416. this.annotationLayerFactory = options.annotationLayerFactory;
  11417. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11418. this.enableWebGL = options.enableWebGL || false;
  11419. this.l10n = options.l10n || _ui_utils.NullL10n;
  11420. this.paintTask = null;
  11421. this.paintedViewportMap = new WeakMap();
  11422. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11423. this.resume = null;
  11424. this.error = null;
  11425. this.annotationLayer = null;
  11426. this.textLayer = null;
  11427. this.zoomLayer = null;
  11428. var div = document.createElement('div');
  11429. div.className = 'page';
  11430. div.style.width = Math.floor(this.viewport.width) + 'px';
  11431. div.style.height = Math.floor(this.viewport.height) + 'px';
  11432. div.setAttribute('data-page-number', this.id);
  11433. this.div = div;
  11434. container.appendChild(div);
  11435. }
  11436. _createClass(PDFPageView, [{
  11437. key: "setPdfPage",
  11438. value: function setPdfPage(pdfPage) {
  11439. this.pdfPage = pdfPage;
  11440. this.pdfPageRotate = pdfPage.rotate;
  11441. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11442. this.viewport = pdfPage.getViewport({
  11443. scale: this.scale * _ui_utils.CSS_UNITS,
  11444. rotation: totalRotation
  11445. });
  11446. this.stats = pdfPage.stats;
  11447. this.reset();
  11448. }
  11449. }, {
  11450. key: "destroy",
  11451. value: function destroy() {
  11452. this.reset();
  11453. if (this.pdfPage) {
  11454. this.pdfPage.cleanup();
  11455. }
  11456. }
  11457. }, {
  11458. key: "_resetZoomLayer",
  11459. value: function _resetZoomLayer() {
  11460. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ?
  11461. arguments[0] : false;
  11462. if (!this.zoomLayer) {
  11463. return;
  11464. }
  11465. var zoomLayerCanvas = this.zoomLayer.firstChild;
  11466. this.paintedViewportMap["delete"](zoomLayerCanvas);
  11467. zoomLayerCanvas.width = 0;
  11468. zoomLayerCanvas.height = 0;
  11469. if (removeFromDOM) {
  11470. this.zoomLayer.remove();
  11471. }
  11472. this.zoomLayer = null;
  11473. }
  11474. }, {
  11475. key: "reset",
  11476. value: function reset() {
  11477. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ?
  11478. arguments[0] : false;
  11479. var keepAnnotations = arguments.length > 1 && arguments[1] !==
  11480. undefined ? arguments[1] : false;
  11481. this.cancelRendering(keepAnnotations);
  11482. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11483. var div = this.div;
  11484. div.style.width = Math.floor(this.viewport.width) + 'px';
  11485. div.style.height = Math.floor(this.viewport.height) + 'px';
  11486. var childNodes = div.childNodes;
  11487. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  11488. var currentAnnotationNode = keepAnnotations && this.annotationLayer &&
  11489. this.annotationLayer.div || null;
  11490. for (var i = childNodes.length - 1; i >= 0; i--) {
  11491. var node = childNodes[i];
  11492. if (currentZoomLayerNode === node || currentAnnotationNode ===
  11493. node) {
  11494. continue;
  11495. }
  11496. div.removeChild(node);
  11497. }
  11498. div.removeAttribute('data-loaded');
  11499. if (currentAnnotationNode) {
  11500. this.annotationLayer.hide();
  11501. } else if (this.annotationLayer) {
  11502. this.annotationLayer.cancel();
  11503. this.annotationLayer = null;
  11504. }
  11505. if (!currentZoomLayerNode) {
  11506. if (this.canvas) {
  11507. this.paintedViewportMap["delete"](this.canvas);
  11508. this.canvas.width = 0;
  11509. this.canvas.height = 0;
  11510. delete this.canvas;
  11511. }
  11512. this._resetZoomLayer();
  11513. }
  11514. if (this.svg) {
  11515. this.paintedViewportMap["delete"](this.svg);
  11516. delete this.svg;
  11517. }
  11518. this.loadingIconDiv = document.createElement('div');
  11519. this.loadingIconDiv.className = 'loadingIcon';
  11520. div.appendChild(this.loadingIconDiv);
  11521. }
  11522. }, {
  11523. key: "update",
  11524. value: function update(scale, rotation) {
  11525. this.scale = scale || this.scale;
  11526. if (typeof rotation !== 'undefined') {
  11527. this.rotation = rotation;
  11528. }
  11529. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11530. this.viewport = this.viewport.clone({
  11531. scale: this.scale * _ui_utils.CSS_UNITS,
  11532. rotation: totalRotation
  11533. });
  11534. if (this.svg) {
  11535. this.cssTransform(this.svg, true);
  11536. this.eventBus.dispatch('pagerendered', {
  11537. source: this,
  11538. pageNumber: this.id,
  11539. cssTransform: true,
  11540. timestamp: performance.now()
  11541. });
  11542. return;
  11543. }
  11544. var isScalingRestricted = false;
  11545. if (this.canvas && this.maxCanvasPixels > 0) {
  11546. var outputScale = this.outputScale;
  11547. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math
  11548. .floor(this.viewport.height) * outputScale.sy | 0) > this
  11549. .maxCanvasPixels) {
  11550. isScalingRestricted = true;
  11551. }
  11552. }
  11553. if (this.canvas) {
  11554. if (this.useOnlyCssZoom || this.hasRestrictedScaling &&
  11555. isScalingRestricted) {
  11556. this.cssTransform(this.canvas, true);
  11557. this.eventBus.dispatch('pagerendered', {
  11558. source: this,
  11559. pageNumber: this.id,
  11560. cssTransform: true,
  11561. timestamp: performance.now()
  11562. });
  11563. return;
  11564. }
  11565. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  11566. this.zoomLayer = this.canvas.parentNode;
  11567. this.zoomLayer.style.position = 'absolute';
  11568. }
  11569. }
  11570. if (this.zoomLayer) {
  11571. this.cssTransform(this.zoomLayer.firstChild);
  11572. }
  11573. this.reset(true, true);
  11574. }
  11575. }, {
  11576. key: "cancelRendering",
  11577. value: function cancelRendering() {
  11578. var keepAnnotations = arguments.length > 0 && arguments[0] !==
  11579. undefined ? arguments[0] : false;
  11580. if (this.paintTask) {
  11581. this.paintTask.cancel();
  11582. this.paintTask = null;
  11583. }
  11584. this.resume = null;
  11585. if (this.textLayer) {
  11586. this.textLayer.cancel();
  11587. this.textLayer = null;
  11588. }
  11589. if (!keepAnnotations && this.annotationLayer) {
  11590. this.annotationLayer.cancel();
  11591. this.annotationLayer = null;
  11592. }
  11593. }
  11594. }, {
  11595. key: "cssTransform",
  11596. value: function cssTransform(target) {
  11597. var redrawAnnotations = arguments.length > 1 && arguments[1] !==
  11598. undefined ? arguments[1] : false;
  11599. var width = this.viewport.width;
  11600. var height = this.viewport.height;
  11601. var div = this.div;
  11602. target.style.width = target.parentNode.style.width = div.style.width =
  11603. Math.floor(width) + 'px';
  11604. target.style.height = target.parentNode.style.height = div.style
  11605. .height = Math.floor(height) + 'px';
  11606. var relativeRotation = this.viewport.rotation - this.paintedViewportMap
  11607. .get(target).rotation;
  11608. var absRotation = Math.abs(relativeRotation);
  11609. var scaleX = 1,
  11610. scaleY = 1;
  11611. if (absRotation === 90 || absRotation === 270) {
  11612. scaleX = height / width;
  11613. scaleY = width / height;
  11614. }
  11615. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' +
  11616. scaleX + ',' + scaleY + ')';
  11617. target.style.transform = cssTransform;
  11618. if (this.textLayer) {
  11619. var textLayerViewport = this.textLayer.viewport;
  11620. var textRelativeRotation = this.viewport.rotation -
  11621. textLayerViewport.rotation;
  11622. var textAbsRotation = Math.abs(textRelativeRotation);
  11623. var scale = width / textLayerViewport.width;
  11624. if (textAbsRotation === 90 || textAbsRotation === 270) {
  11625. scale = width / textLayerViewport.height;
  11626. }
  11627. var textLayerDiv = this.textLayer.textLayerDiv;
  11628. var transX, transY;
  11629. switch (textAbsRotation) {
  11630. case 0:
  11631. transX = transY = 0;
  11632. break;
  11633. case 90:
  11634. transX = 0;
  11635. transY = '-' + textLayerDiv.style.height;
  11636. break;
  11637. case 180:
  11638. transX = '-' + textLayerDiv.style.width;
  11639. transY = '-' + textLayerDiv.style.height;
  11640. break;
  11641. case 270:
  11642. transX = '-' + textLayerDiv.style.width;
  11643. transY = 0;
  11644. break;
  11645. default:
  11646. console.error('Bad rotation value.');
  11647. break;
  11648. }
  11649. textLayerDiv.style.transform = 'rotate(' + textAbsRotation +
  11650. 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' +
  11651. 'translate(' + transX + ', ' + transY + ')';
  11652. textLayerDiv.style.transformOrigin = '0% 0%';
  11653. }
  11654. if (redrawAnnotations && this.annotationLayer) {
  11655. this.annotationLayer.render(this.viewport, 'display');
  11656. }
  11657. }
  11658. }, {
  11659. key: "getPagePoint",
  11660. value: function getPagePoint(x, y) {
  11661. return this.viewport.convertToPdfPoint(x, y);
  11662. }
  11663. }, {
  11664. key: "draw",
  11665. value: function draw() {
  11666. var _this = this;
  11667. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  11668. .INITIAL) {
  11669. console.error('Must be in new state before drawing');
  11670. this.reset();
  11671. }
  11672. if (!this.pdfPage) {
  11673. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  11674. return Promise.reject(new Error('Page is not loaded'));
  11675. }
  11676. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  11677. var pdfPage = this.pdfPage;
  11678. var div = this.div;
  11679. var canvasWrapper = document.createElement('div');
  11680. canvasWrapper.style.width = div.style.width;
  11681. canvasWrapper.style.height = div.style.height;
  11682. canvasWrapper.classList.add('canvasWrapper');
  11683. if (this.annotationLayer && this.annotationLayer.div) {
  11684. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  11685. } else {
  11686. div.appendChild(canvasWrapper);
  11687. }
  11688. var textLayer = null;
  11689. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this
  11690. .textLayerFactory) {
  11691. var textLayerDiv = document.createElement('div');
  11692. textLayerDiv.className = 'textLayer';
  11693. textLayerDiv.style.width = canvasWrapper.style.width;
  11694. textLayerDiv.style.height = canvasWrapper.style.height;
  11695. if (this.annotationLayer && this.annotationLayer.div) {
  11696. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  11697. } else {
  11698. div.appendChild(textLayerDiv);
  11699. }
  11700. textLayer = this.textLayerFactory.createTextLayerBuilder(
  11701. textLayerDiv, this.id - 1, this.viewport, this
  11702. .textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  11703. }
  11704. this.textLayer = textLayer;
  11705. var renderContinueCallback = null;
  11706. if (this.renderingQueue) {
  11707. renderContinueCallback = function renderContinueCallback(cont) {
  11708. if (!_this.renderingQueue.isHighestPriority(_this)) {
  11709. _this.renderingState = _pdf_rendering_queue
  11710. .RenderingStates.PAUSED;
  11711. _this.resume = function() {
  11712. _this.renderingState = _pdf_rendering_queue
  11713. .RenderingStates.RUNNING;
  11714. cont();
  11715. };
  11716. return;
  11717. }
  11718. cont();
  11719. };
  11720. }
  11721. var finishPaintTask =
  11722. /*#__PURE__*/
  11723. function() {
  11724. var _ref = _asyncToGenerator(
  11725. /*#__PURE__*/
  11726. _regenerator["default"].mark(function _callee(error) {
  11727. return _regenerator["default"].wrap(
  11728. function _callee$(_context) {
  11729. while (1) {
  11730. switch (_context.prev = _context
  11731. .next) {
  11732. case 0:
  11733. if (paintTask === _this
  11734. .paintTask) {
  11735. _this.paintTask =
  11736. null;
  11737. }
  11738. if (!(error instanceof _pdfjsLib
  11739. .RenderingCancelledException
  11740. )) {
  11741. _context.next = 4;
  11742. break;
  11743. }
  11744. _this.error = null;
  11745. return _context.abrupt(
  11746. "return");
  11747. case 4:
  11748. _this.renderingState =
  11749. _pdf_rendering_queue
  11750. .RenderingStates
  11751. .FINISHED;
  11752. if (_this
  11753. .loadingIconDiv) {
  11754. div.removeChild(
  11755. _this
  11756. .loadingIconDiv
  11757. );
  11758. delete _this
  11759. .loadingIconDiv;
  11760. }
  11761. _this._resetZoomLayer(
  11762. true);
  11763. _this.error = error;
  11764. _this.stats = pdfPage
  11765. .stats;
  11766. _this.eventBus.dispatch(
  11767. 'pagerendered', {
  11768. source: _this,
  11769. pageNumber: _this
  11770. .id,
  11771. cssTransform: false,
  11772. timestamp: performance
  11773. .now()
  11774. });
  11775. if (!error) {
  11776. _context.next = 12;
  11777. break;
  11778. }
  11779. throw error;
  11780. case 12:
  11781. case "end":
  11782. return _context.stop();
  11783. }
  11784. }
  11785. }, _callee);
  11786. }));
  11787. return function finishPaintTask(_x) {
  11788. return _ref.apply(this, arguments);
  11789. };
  11790. }();
  11791. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this
  11792. .paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  11793. paintTask.onRenderContinue = renderContinueCallback;
  11794. this.paintTask = paintTask;
  11795. var resultPromise = paintTask.promise.then(function() {
  11796. return finishPaintTask(null).then(function() {
  11797. if (textLayer) {
  11798. var readableStream = pdfPage
  11799. .streamTextContent({
  11800. normalizeWhitespace: true
  11801. });
  11802. textLayer.setTextContentStream(
  11803. readableStream);
  11804. textLayer.render();
  11805. }
  11806. });
  11807. }, function(reason) {
  11808. return finishPaintTask(reason);
  11809. });
  11810. if (this.annotationLayerFactory) {
  11811. if (!this.annotationLayer) {
  11812. this.annotationLayer = this.annotationLayerFactory
  11813. .createAnnotationLayerBuilder(div, pdfPage, this
  11814. .imageResourcesPath, this.renderInteractiveForms, this
  11815. .l10n);
  11816. }
  11817. this.annotationLayer.render(this.viewport, 'display');
  11818. }
  11819. div.setAttribute('data-loaded', true);
  11820. this.eventBus.dispatch('pagerender', {
  11821. source: this,
  11822. pageNumber: this.id
  11823. });
  11824. return resultPromise;
  11825. }
  11826. }, {
  11827. key: "paintOnCanvas",
  11828. value: function paintOnCanvas(canvasWrapper) {
  11829. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  11830. var result = {
  11831. promise: renderCapability.promise,
  11832. onRenderContinue: function onRenderContinue(cont) {
  11833. cont();
  11834. },
  11835. cancel: function cancel() {
  11836. renderTask.cancel();
  11837. }
  11838. };
  11839. var viewport = this.viewport;
  11840. var canvas = document.createElement('canvas');
  11841. canvas.id = this.renderingId;
  11842. canvas.setAttribute('hidden', 'hidden');
  11843. var isCanvasHidden = true;
  11844. var showCanvas = function showCanvas() {
  11845. if (isCanvasHidden) {
  11846. canvas.removeAttribute('hidden');
  11847. isCanvasHidden = false;
  11848. }
  11849. };
  11850. canvasWrapper.appendChild(canvas);
  11851. this.canvas = canvas;
  11852. canvas.mozOpaque = true;
  11853. var ctx = canvas.getContext('2d', {
  11854. alpha: false
  11855. });
  11856. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  11857. this.outputScale = outputScale;
  11858. if (this.useOnlyCssZoom) {
  11859. var actualSizeViewport = viewport.clone({
  11860. scale: _ui_utils.CSS_UNITS
  11861. });
  11862. outputScale.sx *= actualSizeViewport.width / viewport.width;
  11863. outputScale.sy *= actualSizeViewport.height / viewport.height;
  11864. outputScale.scaled = true;
  11865. }
  11866. if (this.maxCanvasPixels > 0) {
  11867. var pixelsInViewport = viewport.width * viewport.height;
  11868. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  11869. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  11870. outputScale.sx = maxScale;
  11871. outputScale.sy = maxScale;
  11872. outputScale.scaled = true;
  11873. this.hasRestrictedScaling = true;
  11874. } else {
  11875. this.hasRestrictedScaling = false;
  11876. }
  11877. }
  11878. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  11879. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  11880. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale
  11881. .sx, sfx[0]);
  11882. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height *
  11883. outputScale.sy, sfy[0]);
  11884. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[
  11885. 1]) + 'px';
  11886. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[
  11887. 1]) + 'px';
  11888. this.paintedViewportMap.set(canvas, viewport);
  11889. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0,
  11890. outputScale.sy, 0, 0
  11891. ];
  11892. var renderContext = {
  11893. canvasContext: ctx,
  11894. transform: transform,
  11895. viewport: this.viewport,
  11896. enableWebGL: this.enableWebGL,
  11897. renderInteractiveForms: this.renderInteractiveForms
  11898. };
  11899. var renderTask = this.pdfPage.render(renderContext);
  11900. renderTask.onContinue = function(cont) {
  11901. showCanvas();
  11902. if (result.onRenderContinue) {
  11903. result.onRenderContinue(cont);
  11904. } else {
  11905. cont();
  11906. }
  11907. };
  11908. renderTask.promise.then(function() {
  11909. showCanvas();
  11910. renderCapability.resolve(undefined);
  11911. }, function(error) {
  11912. showCanvas();
  11913. renderCapability.reject(error);
  11914. });
  11915. return result;
  11916. }
  11917. }, {
  11918. key: "paintOnSvg",
  11919. value: function paintOnSvg(wrapper) {
  11920. var _this2 = this;
  11921. var cancelled = false;
  11922. var ensureNotCancelled = function ensureNotCancelled() {
  11923. if (cancelled) {
  11924. throw new _pdfjsLib.RenderingCancelledException(
  11925. 'Rendering cancelled, page ' + _this2.id, 'svg');
  11926. }
  11927. };
  11928. var pdfPage = this.pdfPage;
  11929. var actualSizeViewport = this.viewport.clone({
  11930. scale: _ui_utils.CSS_UNITS
  11931. });
  11932. var promise = pdfPage.getOperatorList().then(function(opList) {
  11933. ensureNotCancelled();
  11934. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs,
  11935. pdfPage.objs);
  11936. return svgGfx.getSVG(opList, actualSizeViewport).then(
  11937. function(svg) {
  11938. ensureNotCancelled();
  11939. _this2.svg = svg;
  11940. _this2.paintedViewportMap.set(svg,
  11941. actualSizeViewport);
  11942. svg.style.width = wrapper.style.width;
  11943. svg.style.height = wrapper.style.height;
  11944. _this2.renderingState = _pdf_rendering_queue
  11945. .RenderingStates.FINISHED;
  11946. wrapper.appendChild(svg);
  11947. });
  11948. });
  11949. return {
  11950. promise: promise,
  11951. onRenderContinue: function onRenderContinue(cont) {
  11952. cont();
  11953. },
  11954. cancel: function cancel() {
  11955. cancelled = true;
  11956. }
  11957. };
  11958. }
  11959. }, {
  11960. key: "setPageLabel",
  11961. value: function setPageLabel(label) {
  11962. this.pageLabel = typeof label === 'string' ? label : null;
  11963. if (this.pageLabel !== null) {
  11964. this.div.setAttribute('data-page-label', this.pageLabel);
  11965. } else {
  11966. this.div.removeAttribute('data-page-label');
  11967. }
  11968. }
  11969. }, {
  11970. key: "width",
  11971. get: function get() {
  11972. return this.viewport.width;
  11973. }
  11974. }, {
  11975. key: "height",
  11976. get: function get() {
  11977. return this.viewport.height;
  11978. }
  11979. }]);
  11980. return PDFPageView;
  11981. }();
  11982. exports.PDFPageView = PDFPageView;
  11983. /***/
  11984. }),
  11985. /* 31 */
  11986. /***/
  11987. (function(module, exports, __webpack_require__) {
  11988. "use strict";
  11989. Object.defineProperty(exports, "__esModule", {
  11990. value: true
  11991. });
  11992. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  11993. var _ui_utils = __webpack_require__(5);
  11994. var _pdfjsLib = __webpack_require__(7);
  11995. function _classCallCheck(instance, Constructor) {
  11996. if (!(instance instanceof Constructor)) {
  11997. throw new TypeError("Cannot call a class as a function");
  11998. }
  11999. }
  12000. function _defineProperties(target, props) {
  12001. for (var i = 0; i < props.length; i++) {
  12002. var descriptor = props[i];
  12003. descriptor.enumerable = descriptor.enumerable || false;
  12004. descriptor.configurable = true;
  12005. if ("value" in descriptor) descriptor.writable = true;
  12006. Object.defineProperty(target, descriptor.key, descriptor);
  12007. }
  12008. }
  12009. function _createClass(Constructor, protoProps, staticProps) {
  12010. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12011. if (staticProps) _defineProperties(Constructor, staticProps);
  12012. return Constructor;
  12013. }
  12014. var EXPAND_DIVS_TIMEOUT = 300;
  12015. var TextLayerBuilder =
  12016. /*#__PURE__*/
  12017. function() {
  12018. function TextLayerBuilder(_ref) {
  12019. var textLayerDiv = _ref.textLayerDiv,
  12020. eventBus = _ref.eventBus,
  12021. pageIndex = _ref.pageIndex,
  12022. viewport = _ref.viewport,
  12023. _ref$findController = _ref.findController,
  12024. findController = _ref$findController === void 0 ? null : _ref$findController,
  12025. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  12026. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  12027. _classCallCheck(this, TextLayerBuilder);
  12028. this.textLayerDiv = textLayerDiv;
  12029. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  12030. this.textContent = null;
  12031. this.textContentItemsStr = [];
  12032. this.textContentStream = null;
  12033. this.renderingDone = false;
  12034. this.pageIdx = pageIndex;
  12035. this.pageNumber = this.pageIdx + 1;
  12036. this.matches = [];
  12037. this.viewport = viewport;
  12038. this.textDivs = [];
  12039. this.findController = findController;
  12040. this.textLayerRenderTask = null;
  12041. this.enhanceTextSelection = enhanceTextSelection;
  12042. this._onUpdateTextLayerMatches = null;
  12043. this._bindMouse();
  12044. }
  12045. _createClass(TextLayerBuilder, [{
  12046. key: "_finishRendering",
  12047. value: function _finishRendering() {
  12048. this.renderingDone = true;
  12049. if (!this.enhanceTextSelection) {
  12050. var endOfContent = document.createElement('div');
  12051. endOfContent.className = 'endOfContent';
  12052. this.textLayerDiv.appendChild(endOfContent);
  12053. }
  12054. this.eventBus.dispatch('textlayerrendered', {
  12055. source: this,
  12056. pageNumber: this.pageNumber,
  12057. numTextDivs: this.textDivs.length
  12058. });
  12059. }
  12060. }, {
  12061. key: "render",
  12062. value: function render() {
  12063. var _this = this;
  12064. var timeout = arguments.length > 0 && arguments[0] !== undefined ?
  12065. arguments[0] : 0;
  12066. if (!(this.textContent || this.textContentStream) || this
  12067. .renderingDone) {
  12068. return;
  12069. }
  12070. this.cancel();
  12071. this.textDivs = [];
  12072. var textLayerFrag = document.createDocumentFragment();
  12073. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12074. textContent: this.textContent,
  12075. textContentStream: this.textContentStream,
  12076. container: textLayerFrag,
  12077. viewport: this.viewport,
  12078. textDivs: this.textDivs,
  12079. textContentItemsStr: this.textContentItemsStr,
  12080. timeout: timeout,
  12081. enhanceTextSelection: this.enhanceTextSelection
  12082. });
  12083. this.textLayerRenderTask.promise.then(function() {
  12084. _this.textLayerDiv.appendChild(textLayerFrag);
  12085. _this._finishRendering();
  12086. _this._updateMatches();
  12087. }, function(reason) {});
  12088. if (!this._onUpdateTextLayerMatches) {
  12089. this._onUpdateTextLayerMatches = function(evt) {
  12090. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -
  12091. 1) {
  12092. _this._updateMatches();
  12093. }
  12094. };
  12095. this.eventBus.on('updatetextlayermatches', this
  12096. ._onUpdateTextLayerMatches);
  12097. }
  12098. }
  12099. }, {
  12100. key: "cancel",
  12101. value: function cancel() {
  12102. if (this.textLayerRenderTask) {
  12103. this.textLayerRenderTask.cancel();
  12104. this.textLayerRenderTask = null;
  12105. }
  12106. if (this._onUpdateTextLayerMatches) {
  12107. this.eventBus.off('updatetextlayermatches', this
  12108. ._onUpdateTextLayerMatches);
  12109. this._onUpdateTextLayerMatches = null;
  12110. }
  12111. }
  12112. }, {
  12113. key: "setTextContentStream",
  12114. value: function setTextContentStream(readableStream) {
  12115. this.cancel();
  12116. this.textContentStream = readableStream;
  12117. }
  12118. }, {
  12119. key: "setTextContent",
  12120. value: function setTextContent(textContent) {
  12121. this.cancel();
  12122. this.textContent = textContent;
  12123. }
  12124. }, {
  12125. key: "_convertMatches",
  12126. value: function _convertMatches(matches, matchesLength) {
  12127. if (!matches) {
  12128. return [];
  12129. }
  12130. var findController = this.findController,
  12131. textContentItemsStr = this.textContentItemsStr;
  12132. var i = 0,
  12133. iIndex = 0;
  12134. var end = textContentItemsStr.length - 1;
  12135. var queryLen = findController.state.query.length;
  12136. var result = [];
  12137. for (var m = 0, mm = matches.length; m < mm; m++) {
  12138. var matchIdx = matches[m];
  12139. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i]
  12140. .length) {
  12141. iIndex += textContentItemsStr[i].length;
  12142. i++;
  12143. }
  12144. if (i === textContentItemsStr.length) {
  12145. console.error('Could not find a matching mapping');
  12146. }
  12147. var match = {
  12148. begin: {
  12149. divIdx: i,
  12150. offset: matchIdx - iIndex
  12151. }
  12152. };
  12153. if (matchesLength) {
  12154. matchIdx += matchesLength[m];
  12155. } else {
  12156. matchIdx += queryLen;
  12157. }
  12158. while (i !== end && matchIdx > iIndex + textContentItemsStr[i]
  12159. .length) {
  12160. iIndex += textContentItemsStr[i].length;
  12161. i++;
  12162. }
  12163. match.end = {
  12164. divIdx: i,
  12165. offset: matchIdx - iIndex
  12166. };
  12167. result.push(match);
  12168. }
  12169. return result;
  12170. }
  12171. }, {
  12172. key: "_renderMatches",
  12173. value: function _renderMatches(matches) {
  12174. if (matches.length === 0) {
  12175. return;
  12176. }
  12177. var findController = this.findController,
  12178. pageIdx = this.pageIdx,
  12179. textContentItemsStr = this.textContentItemsStr,
  12180. textDivs = this.textDivs;
  12181. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  12182. var selectedMatchIdx = findController.selected.matchIdx;
  12183. var highlightAll = findController.state.highlightAll;
  12184. var prevEnd = null;
  12185. var infinity = {
  12186. divIdx: -1,
  12187. offset: undefined
  12188. };
  12189. function beginText(begin, className) {
  12190. var divIdx = begin.divIdx;
  12191. textDivs[divIdx].textContent = '';
  12192. appendTextToDiv(divIdx, 0, begin.offset, className);
  12193. }
  12194. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12195. var div = textDivs[divIdx];
  12196. var content = textContentItemsStr[divIdx].substring(fromOffset,
  12197. toOffset);
  12198. var node = document.createTextNode(content);
  12199. if (className) {
  12200. var span = document.createElement('span');
  12201. span.className = className;
  12202. span.appendChild(node);
  12203. div.appendChild(span);
  12204. return;
  12205. }
  12206. div.appendChild(node);
  12207. }
  12208. var i0 = selectedMatchIdx,
  12209. i1 = i0 + 1;
  12210. if (highlightAll) {
  12211. i0 = 0;
  12212. i1 = matches.length;
  12213. } else if (!isSelectedPage) {
  12214. return;
  12215. }
  12216. for (var i = i0; i < i1; i++) {
  12217. var match = matches[i];
  12218. var begin = match.begin;
  12219. var end = match.end;
  12220. var isSelected = isSelectedPage && i === selectedMatchIdx;
  12221. var highlightSuffix = isSelected ? ' selected' : '';
  12222. if (isSelected) {
  12223. findController.scrollMatchIntoView({
  12224. element: textDivs[begin.divIdx],
  12225. pageIndex: pageIdx,
  12226. matchIndex: selectedMatchIdx
  12227. });
  12228. }
  12229. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12230. if (prevEnd !== null) {
  12231. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity
  12232. .offset);
  12233. }
  12234. beginText(begin);
  12235. } else {
  12236. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12237. }
  12238. if (begin.divIdx === end.divIdx) {
  12239. appendTextToDiv(begin.divIdx, begin.offset, end.offset,
  12240. 'highlight' + highlightSuffix);
  12241. } else {
  12242. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset,
  12243. 'highlight begin' + highlightSuffix);
  12244. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 <
  12245. n1; n0++) {
  12246. textDivs[n0].className = 'highlight middle' +
  12247. highlightSuffix;
  12248. }
  12249. beginText(end, 'highlight end' + highlightSuffix);
  12250. }
  12251. prevEnd = end;
  12252. }
  12253. if (prevEnd) {
  12254. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12255. }
  12256. }
  12257. }, {
  12258. key: "_updateMatches",
  12259. value: function _updateMatches() {
  12260. if (!this.renderingDone) {
  12261. return;
  12262. }
  12263. var findController = this.findController,
  12264. matches = this.matches,
  12265. pageIdx = this.pageIdx,
  12266. textContentItemsStr = this.textContentItemsStr,
  12267. textDivs = this.textDivs;
  12268. var clearedUntilDivIdx = -1;
  12269. for (var i = 0, ii = matches.length; i < ii; i++) {
  12270. var match = matches[i];
  12271. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12272. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  12273. var div = textDivs[n];
  12274. div.textContent = textContentItemsStr[n];
  12275. div.className = '';
  12276. }
  12277. clearedUntilDivIdx = match.end.divIdx + 1;
  12278. }
  12279. if (!findController || !findController.highlightMatches) {
  12280. return;
  12281. }
  12282. var pageMatches = findController.pageMatches[pageIdx] || null;
  12283. var pageMatchesLength = findController.pageMatchesLength[pageIdx] ||
  12284. null;
  12285. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12286. this._renderMatches(this.matches);
  12287. }
  12288. }, {
  12289. key: "_bindMouse",
  12290. value: function _bindMouse() {
  12291. var _this2 = this;
  12292. var div = this.textLayerDiv;
  12293. var expandDivsTimer = null;
  12294. div.addEventListener('mousedown', function(evt) {
  12295. if (_this2.enhanceTextSelection && _this2
  12296. .textLayerRenderTask) {
  12297. _this2.textLayerRenderTask.expandTextDivs(true);
  12298. if (expandDivsTimer) {
  12299. clearTimeout(expandDivsTimer);
  12300. expandDivsTimer = null;
  12301. }
  12302. return;
  12303. }
  12304. var end = div.querySelector('.endOfContent');
  12305. if (!end) {
  12306. return;
  12307. }
  12308. var adjustTop = evt.target !== div;
  12309. adjustTop = adjustTop && window.getComputedStyle(end)
  12310. .getPropertyValue('-moz-user-select') !== 'none';
  12311. if (adjustTop) {
  12312. var divBounds = div.getBoundingClientRect();
  12313. var r = Math.max(0, (evt.pageY - divBounds.top) /
  12314. divBounds.height);
  12315. end.style.top = (r * 100).toFixed(2) + '%';
  12316. }
  12317. end.classList.add('active');
  12318. });
  12319. div.addEventListener('mouseup', function() {
  12320. if (_this2.enhanceTextSelection && _this2
  12321. .textLayerRenderTask) {
  12322. expandDivsTimer = setTimeout(function() {
  12323. if (_this2.textLayerRenderTask) {
  12324. _this2.textLayerRenderTask
  12325. .expandTextDivs(false);
  12326. }
  12327. expandDivsTimer = null;
  12328. }, EXPAND_DIVS_TIMEOUT);
  12329. return;
  12330. }
  12331. var end = div.querySelector('.endOfContent');
  12332. if (!end) {
  12333. return;
  12334. }
  12335. end.style.top = '';
  12336. end.classList.remove('active');
  12337. });
  12338. }
  12339. }]);
  12340. return TextLayerBuilder;
  12341. }();
  12342. exports.TextLayerBuilder = TextLayerBuilder;
  12343. var DefaultTextLayerFactory =
  12344. /*#__PURE__*/
  12345. function() {
  12346. function DefaultTextLayerFactory() {
  12347. _classCallCheck(this, DefaultTextLayerFactory);
  12348. }
  12349. _createClass(DefaultTextLayerFactory, [{
  12350. key: "createTextLayerBuilder",
  12351. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  12352. var enhanceTextSelection = arguments.length > 3 && arguments[3] !==
  12353. undefined ? arguments[3] : false;
  12354. return new TextLayerBuilder({
  12355. textLayerDiv: textLayerDiv,
  12356. pageIndex: pageIndex,
  12357. viewport: viewport,
  12358. enhanceTextSelection: enhanceTextSelection
  12359. });
  12360. }
  12361. }]);
  12362. return DefaultTextLayerFactory;
  12363. }();
  12364. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  12365. /***/
  12366. }),
  12367. /* 32 */
  12368. /***/
  12369. (function(module, exports, __webpack_require__) {
  12370. "use strict";
  12371. Object.defineProperty(exports, "__esModule", {
  12372. value: true
  12373. });
  12374. exports.SecondaryToolbar = void 0;
  12375. var _ui_utils = __webpack_require__(5);
  12376. var _pdf_cursor_tools = __webpack_require__(9);
  12377. var _pdf_single_page_viewer = __webpack_require__(33);
  12378. function _classCallCheck(instance, Constructor) {
  12379. if (!(instance instanceof Constructor)) {
  12380. throw new TypeError("Cannot call a class as a function");
  12381. }
  12382. }
  12383. function _defineProperties(target, props) {
  12384. for (var i = 0; i < props.length; i++) {
  12385. var descriptor = props[i];
  12386. descriptor.enumerable = descriptor.enumerable || false;
  12387. descriptor.configurable = true;
  12388. if ("value" in descriptor) descriptor.writable = true;
  12389. Object.defineProperty(target, descriptor.key, descriptor);
  12390. }
  12391. }
  12392. function _createClass(Constructor, protoProps, staticProps) {
  12393. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12394. if (staticProps) _defineProperties(Constructor, staticProps);
  12395. return Constructor;
  12396. }
  12397. var SecondaryToolbar =
  12398. /*#__PURE__*/
  12399. function() {
  12400. function SecondaryToolbar(options, mainContainer, eventBus) {
  12401. var _this = this;
  12402. _classCallCheck(this, SecondaryToolbar);
  12403. this.toolbar = options.toolbar;
  12404. this.toggleButton = options.toggleButton;
  12405. this.toolbarButtonContainer = options.toolbarButtonContainer;
  12406. this.buttons = [{
  12407. element: options.presentationModeButton,
  12408. eventName: 'presentationmode',
  12409. close: true
  12410. }, {
  12411. element: options.openFileButton,
  12412. eventName: 'openfile',
  12413. close: true
  12414. }, {
  12415. element: options.printButton,
  12416. eventName: 'print',
  12417. close: true
  12418. }, {
  12419. element: options.downloadButton,
  12420. eventName: 'download',
  12421. close: true
  12422. }, {
  12423. element: options.viewBookmarkButton,
  12424. eventName: null,
  12425. close: true
  12426. }, {
  12427. element: options.firstPageButton,
  12428. eventName: 'firstpage',
  12429. close: true
  12430. }, {
  12431. element: options.lastPageButton,
  12432. eventName: 'lastpage',
  12433. close: true
  12434. }, {
  12435. element: options.pageRotateCwButton,
  12436. eventName: 'rotatecw',
  12437. close: false
  12438. }, {
  12439. element: options.pageRotateCcwButton,
  12440. eventName: 'rotateccw',
  12441. close: false
  12442. }, {
  12443. element: options.cursorSelectToolButton,
  12444. eventName: 'switchcursortool',
  12445. eventDetails: {
  12446. tool: _pdf_cursor_tools.CursorTool.SELECT
  12447. },
  12448. close: true
  12449. }, {
  12450. element: options.cursorHandToolButton,
  12451. eventName: 'switchcursortool',
  12452. eventDetails: {
  12453. tool: _pdf_cursor_tools.CursorTool.HAND
  12454. },
  12455. close: true
  12456. }, {
  12457. element: options.scrollVerticalButton,
  12458. eventName: 'switchscrollmode',
  12459. eventDetails: {
  12460. mode: _ui_utils.ScrollMode.VERTICAL
  12461. },
  12462. close: true
  12463. }, {
  12464. element: options.scrollHorizontalButton,
  12465. eventName: 'switchscrollmode',
  12466. eventDetails: {
  12467. mode: _ui_utils.ScrollMode.HORIZONTAL
  12468. },
  12469. close: true
  12470. }, {
  12471. element: options.scrollWrappedButton,
  12472. eventName: 'switchscrollmode',
  12473. eventDetails: {
  12474. mode: _ui_utils.ScrollMode.WRAPPED
  12475. },
  12476. close: true
  12477. }, {
  12478. element: options.spreadNoneButton,
  12479. eventName: 'switchspreadmode',
  12480. eventDetails: {
  12481. mode: _ui_utils.SpreadMode.NONE
  12482. },
  12483. close: true
  12484. }, {
  12485. element: options.spreadOddButton,
  12486. eventName: 'switchspreadmode',
  12487. eventDetails: {
  12488. mode: _ui_utils.SpreadMode.ODD
  12489. },
  12490. close: true
  12491. }, {
  12492. element: options.spreadEvenButton,
  12493. eventName: 'switchspreadmode',
  12494. eventDetails: {
  12495. mode: _ui_utils.SpreadMode.EVEN
  12496. },
  12497. close: true
  12498. }, {
  12499. element: options.documentPropertiesButton,
  12500. eventName: 'documentproperties',
  12501. close: true
  12502. }];
  12503. this.items = {
  12504. firstPage: options.firstPageButton,
  12505. lastPage: options.lastPageButton,
  12506. pageRotateCw: options.pageRotateCwButton,
  12507. pageRotateCcw: options.pageRotateCcwButton
  12508. };
  12509. this.mainContainer = mainContainer;
  12510. this.eventBus = eventBus;
  12511. this.opened = false;
  12512. this.containerHeight = null;
  12513. this.previousContainerHeight = null;
  12514. this.reset();
  12515. this._bindClickListeners();
  12516. this._bindCursorToolsListener(options);
  12517. this._bindScrollModeListener(options);
  12518. this._bindSpreadModeListener(options);
  12519. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  12520. this.eventBus.on('baseviewerinit', function(evt) {
  12521. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  12522. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons',
  12523. 'hiddenSpreadModeButtons');
  12524. } else {
  12525. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons',
  12526. 'hiddenSpreadModeButtons');
  12527. }
  12528. });
  12529. }
  12530. _createClass(SecondaryToolbar, [{
  12531. key: "setPageNumber",
  12532. value: function setPageNumber(pageNumber) {
  12533. this.pageNumber = pageNumber;
  12534. this._updateUIState();
  12535. }
  12536. }, {
  12537. key: "setPagesCount",
  12538. value: function setPagesCount(pagesCount) {
  12539. this.pagesCount = pagesCount;
  12540. this._updateUIState();
  12541. }
  12542. }, {
  12543. key: "reset",
  12544. value: function reset() {
  12545. this.pageNumber = 0;
  12546. this.pagesCount = 0;
  12547. this._updateUIState();
  12548. this.eventBus.dispatch('secondarytoolbarreset', {
  12549. source: this
  12550. });
  12551. }
  12552. }, {
  12553. key: "_updateUIState",
  12554. value: function _updateUIState() {
  12555. this.items.firstPage.disabled = this.pageNumber <= 1;
  12556. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  12557. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  12558. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  12559. }
  12560. }, {
  12561. key: "_bindClickListeners",
  12562. value: function _bindClickListeners() {
  12563. var _this2 = this;
  12564. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  12565. var _loop = function _loop(button) {
  12566. var _this2$buttons$button = _this2.buttons[button],
  12567. element = _this2$buttons$button.element,
  12568. eventName = _this2$buttons$button.eventName,
  12569. close = _this2$buttons$button.close,
  12570. eventDetails = _this2$buttons$button.eventDetails;
  12571. element.addEventListener('click', function(evt) {
  12572. if (eventName !== null) {
  12573. var details = {
  12574. source: _this2
  12575. };
  12576. for (var property in eventDetails) {
  12577. details[property] = eventDetails[property];
  12578. }
  12579. _this2.eventBus.dispatch(eventName, details);
  12580. }
  12581. if (close) {
  12582. _this2.close();
  12583. }
  12584. });
  12585. };
  12586. for (var button in this.buttons) {
  12587. _loop(button);
  12588. }
  12589. }
  12590. }, {
  12591. key: "_bindCursorToolsListener",
  12592. value: function _bindCursorToolsListener(buttons) {
  12593. this.eventBus.on('cursortoolchanged', function(_ref) {
  12594. var tool = _ref.tool;
  12595. buttons.cursorSelectToolButton.classList.toggle('toggled',
  12596. tool === _pdf_cursor_tools.CursorTool.SELECT);
  12597. buttons.cursorHandToolButton.classList.toggle('toggled',
  12598. tool === _pdf_cursor_tools.CursorTool.HAND);
  12599. });
  12600. }
  12601. }, {
  12602. key: "_bindScrollModeListener",
  12603. value: function _bindScrollModeListener(buttons) {
  12604. var _this3 = this;
  12605. function scrollModeChanged(_ref2) {
  12606. var mode = _ref2.mode;
  12607. buttons.scrollVerticalButton.classList.toggle('toggled', mode ===
  12608. _ui_utils.ScrollMode.VERTICAL);
  12609. buttons.scrollHorizontalButton.classList.toggle('toggled', mode ===
  12610. _ui_utils.ScrollMode.HORIZONTAL);
  12611. buttons.scrollWrappedButton.classList.toggle('toggled', mode ===
  12612. _ui_utils.ScrollMode.WRAPPED);
  12613. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode
  12614. .HORIZONTAL;
  12615. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  12616. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  12617. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  12618. }
  12619. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  12620. this.eventBus.on('secondarytoolbarreset', function(evt) {
  12621. if (evt.source === _this3) {
  12622. scrollModeChanged({
  12623. mode: _ui_utils.ScrollMode.VERTICAL
  12624. });
  12625. }
  12626. });
  12627. }
  12628. }, {
  12629. key: "_bindSpreadModeListener",
  12630. value: function _bindSpreadModeListener(buttons) {
  12631. var _this4 = this;
  12632. function spreadModeChanged(_ref3) {
  12633. var mode = _ref3.mode;
  12634. buttons.spreadNoneButton.classList.toggle('toggled', mode ===
  12635. _ui_utils.SpreadMode.NONE);
  12636. buttons.spreadOddButton.classList.toggle('toggled', mode ===
  12637. _ui_utils.SpreadMode.ODD);
  12638. buttons.spreadEvenButton.classList.toggle('toggled', mode ===
  12639. _ui_utils.SpreadMode.EVEN);
  12640. }
  12641. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  12642. this.eventBus.on('secondarytoolbarreset', function(evt) {
  12643. if (evt.source === _this4) {
  12644. spreadModeChanged({
  12645. mode: _ui_utils.SpreadMode.NONE
  12646. });
  12647. }
  12648. });
  12649. }
  12650. }, {
  12651. key: "open",
  12652. value: function open() {
  12653. if (this.opened) {
  12654. return;
  12655. }
  12656. this.opened = true;
  12657. this._setMaxHeight();
  12658. this.toggleButton.classList.add('toggled');
  12659. this.toolbar.classList.remove('hidden');
  12660. }
  12661. }, {
  12662. key: "close",
  12663. value: function close() {
  12664. if (!this.opened) {
  12665. return;
  12666. }
  12667. this.opened = false;
  12668. this.toolbar.classList.add('hidden');
  12669. this.toggleButton.classList.remove('toggled');
  12670. }
  12671. }, {
  12672. key: "toggle",
  12673. value: function toggle() {
  12674. if (this.opened) {
  12675. this.close();
  12676. } else {
  12677. this.open();
  12678. }
  12679. }
  12680. }, {
  12681. key: "_setMaxHeight",
  12682. value: function _setMaxHeight() {
  12683. if (!this.opened) {
  12684. return;
  12685. }
  12686. this.containerHeight = this.mainContainer.clientHeight;
  12687. if (this.containerHeight === this.previousContainerHeight) {
  12688. return;
  12689. }
  12690. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this
  12691. .containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  12692. this.previousContainerHeight = this.containerHeight;
  12693. }
  12694. }, {
  12695. key: "isOpen",
  12696. get: function get() {
  12697. return this.opened;
  12698. }
  12699. }]);
  12700. return SecondaryToolbar;
  12701. }();
  12702. exports.SecondaryToolbar = SecondaryToolbar;
  12703. /***/
  12704. }),
  12705. /* 33 */
  12706. /***/
  12707. (function(module, exports, __webpack_require__) {
  12708. "use strict";
  12709. Object.defineProperty(exports, "__esModule", {
  12710. value: true
  12711. });
  12712. exports.PDFSinglePageViewer = void 0;
  12713. var _base_viewer = __webpack_require__(28);
  12714. var _pdfjsLib = __webpack_require__(7);
  12715. function _typeof(obj) {
  12716. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  12717. _typeof = function _typeof(obj) {
  12718. return typeof obj;
  12719. };
  12720. } else {
  12721. _typeof = function _typeof(obj) {
  12722. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  12723. Symbol.prototype ? "symbol" : typeof obj;
  12724. };
  12725. }
  12726. return _typeof(obj);
  12727. }
  12728. function _classCallCheck(instance, Constructor) {
  12729. if (!(instance instanceof Constructor)) {
  12730. throw new TypeError("Cannot call a class as a function");
  12731. }
  12732. }
  12733. function _defineProperties(target, props) {
  12734. for (var i = 0; i < props.length; i++) {
  12735. var descriptor = props[i];
  12736. descriptor.enumerable = descriptor.enumerable || false;
  12737. descriptor.configurable = true;
  12738. if ("value" in descriptor) descriptor.writable = true;
  12739. Object.defineProperty(target, descriptor.key, descriptor);
  12740. }
  12741. }
  12742. function _createClass(Constructor, protoProps, staticProps) {
  12743. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12744. if (staticProps) _defineProperties(Constructor, staticProps);
  12745. return Constructor;
  12746. }
  12747. function _possibleConstructorReturn(self, call) {
  12748. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  12749. return call;
  12750. }
  12751. return _assertThisInitialized(self);
  12752. }
  12753. function _assertThisInitialized(self) {
  12754. if (self === void 0) {
  12755. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  12756. }
  12757. return self;
  12758. }
  12759. function _get(target, property, receiver) {
  12760. if (typeof Reflect !== "undefined" && Reflect.get) {
  12761. _get = Reflect.get;
  12762. } else {
  12763. _get = function _get(target, property, receiver) {
  12764. var base = _superPropBase(target, property);
  12765. if (!base) return;
  12766. var desc = Object.getOwnPropertyDescriptor(base, property);
  12767. if (desc.get) {
  12768. return desc.get.call(receiver);
  12769. }
  12770. return desc.value;
  12771. };
  12772. }
  12773. return _get(target, property, receiver || target);
  12774. }
  12775. function _superPropBase(object, property) {
  12776. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  12777. object = _getPrototypeOf(object);
  12778. if (object === null) break;
  12779. }
  12780. return object;
  12781. }
  12782. function _getPrototypeOf(o) {
  12783. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  12784. return o.__proto__ || Object.getPrototypeOf(o);
  12785. };
  12786. return _getPrototypeOf(o);
  12787. }
  12788. function _inherits(subClass, superClass) {
  12789. if (typeof superClass !== "function" && superClass !== null) {
  12790. throw new TypeError("Super expression must either be null or a function");
  12791. }
  12792. subClass.prototype = Object.create(superClass && superClass.prototype, {
  12793. constructor: {
  12794. value: subClass,
  12795. writable: true,
  12796. configurable: true
  12797. }
  12798. });
  12799. if (superClass) _setPrototypeOf(subClass, superClass);
  12800. }
  12801. function _setPrototypeOf(o, p) {
  12802. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  12803. o.__proto__ = p;
  12804. return o;
  12805. };
  12806. return _setPrototypeOf(o, p);
  12807. }
  12808. var PDFSinglePageViewer =
  12809. /*#__PURE__*/
  12810. function(_BaseViewer) {
  12811. _inherits(PDFSinglePageViewer, _BaseViewer);
  12812. function PDFSinglePageViewer(options) {
  12813. var _this;
  12814. _classCallCheck(this, PDFSinglePageViewer);
  12815. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this,
  12816. options));
  12817. _this.eventBus.on('pagesinit', function(evt) {
  12818. _this._ensurePageViewVisible();
  12819. });
  12820. return _this;
  12821. }
  12822. _createClass(PDFSinglePageViewer, [{
  12823. key: "_resetView",
  12824. value: function _resetView() {
  12825. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this)
  12826. .call(this);
  12827. this._previousPageNumber = 1;
  12828. this._shadowViewer = document.createDocumentFragment();
  12829. this._updateScrollDown = null;
  12830. }
  12831. }, {
  12832. key: "_ensurePageViewVisible",
  12833. value: function _ensurePageViewVisible() {
  12834. var pageView = this._pages[this._currentPageNumber - 1];
  12835. var previousPageView = this._pages[this._previousPageNumber - 1];
  12836. var viewerNodes = this.viewer.childNodes;
  12837. switch (viewerNodes.length) {
  12838. case 0:
  12839. this.viewer.appendChild(pageView.div);
  12840. break;
  12841. case 1:
  12842. if (viewerNodes[0] !== previousPageView.div) {
  12843. throw new Error(
  12844. '_ensurePageViewVisible: Unexpected previously visible page.'
  12845. );
  12846. }
  12847. if (pageView === previousPageView) {
  12848. break;
  12849. }
  12850. this._shadowViewer.appendChild(previousPageView.div);
  12851. this.viewer.appendChild(pageView.div);
  12852. this.container.scrollTop = 0;
  12853. break;
  12854. default:
  12855. throw new Error(
  12856. '_ensurePageViewVisible: Only one page should be visible at a time.'
  12857. );
  12858. }
  12859. this._previousPageNumber = this._currentPageNumber;
  12860. }
  12861. }, {
  12862. key: "_scrollUpdate",
  12863. value: function _scrollUpdate() {
  12864. if (this._updateScrollDown) {
  12865. this._updateScrollDown();
  12866. }
  12867. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate",
  12868. this).call(this);
  12869. }
  12870. }, {
  12871. key: "_scrollIntoView",
  12872. value: function _scrollIntoView(_ref) {
  12873. var _this2 = this;
  12874. var pageDiv = _ref.pageDiv,
  12875. _ref$pageSpot = _ref.pageSpot,
  12876. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  12877. _ref$pageNumber = _ref.pageNumber,
  12878. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  12879. if (pageNumber) {
  12880. this._setCurrentPageNumber(pageNumber);
  12881. }
  12882. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  12883. this._ensurePageViewVisible();
  12884. this.update();
  12885. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView",
  12886. this).call(this, {
  12887. pageDiv: pageDiv,
  12888. pageSpot: pageSpot,
  12889. pageNumber: pageNumber
  12890. });
  12891. this._updateScrollDown = function() {
  12892. _this2.scroll.down = scrolledDown;
  12893. _this2._updateScrollDown = null;
  12894. };
  12895. }
  12896. }, {
  12897. key: "_getVisiblePages",
  12898. value: function _getVisiblePages() {
  12899. return this._getCurrentVisiblePage();
  12900. }
  12901. }, {
  12902. key: "_updateHelper",
  12903. value: function _updateHelper(visiblePages) {}
  12904. }, {
  12905. key: "_updateScrollMode",
  12906. value: function _updateScrollMode() {}
  12907. }, {
  12908. key: "_updateSpreadMode",
  12909. value: function _updateSpreadMode() {}
  12910. }, {
  12911. key: "_setDocumentViewerElement",
  12912. get: function get() {
  12913. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this
  12914. ._shadowViewer);
  12915. }
  12916. }, {
  12917. key: "_isScrollModeHorizontal",
  12918. get: function get() {
  12919. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  12920. }
  12921. }]);
  12922. return PDFSinglePageViewer;
  12923. }(_base_viewer.BaseViewer);
  12924. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  12925. /***/
  12926. }),
  12927. /* 34 */
  12928. /***/
  12929. (function(module, exports, __webpack_require__) {
  12930. "use strict";
  12931. Object.defineProperty(exports, "__esModule", {
  12932. value: true
  12933. });
  12934. exports.Toolbar = void 0;
  12935. var _ui_utils = __webpack_require__(5);
  12936. function _classCallCheck(instance, Constructor) {
  12937. if (!(instance instanceof Constructor)) {
  12938. throw new TypeError("Cannot call a class as a function");
  12939. }
  12940. }
  12941. function _defineProperties(target, props) {
  12942. for (var i = 0; i < props.length; i++) {
  12943. var descriptor = props[i];
  12944. descriptor.enumerable = descriptor.enumerable || false;
  12945. descriptor.configurable = true;
  12946. if ("value" in descriptor) descriptor.writable = true;
  12947. Object.defineProperty(target, descriptor.key, descriptor);
  12948. }
  12949. }
  12950. function _createClass(Constructor, protoProps, staticProps) {
  12951. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12952. if (staticProps) _defineProperties(Constructor, staticProps);
  12953. return Constructor;
  12954. }
  12955. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  12956. var SCALE_SELECT_CONTAINER_PADDING = 8;
  12957. var SCALE_SELECT_PADDING = 22;
  12958. var Toolbar =
  12959. /*#__PURE__*/
  12960. function() {
  12961. function Toolbar(options, eventBus) {
  12962. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  12963. .NullL10n;
  12964. _classCallCheck(this, Toolbar);
  12965. this.toolbar = options.container;
  12966. this.eventBus = eventBus;
  12967. this.l10n = l10n;
  12968. this.items = options;
  12969. this._wasLocalized = false;
  12970. this.reset();
  12971. this._bindListeners();
  12972. }
  12973. _createClass(Toolbar, [{
  12974. key: "setPageNumber",
  12975. value: function setPageNumber(pageNumber, pageLabel) {
  12976. this.pageNumber = pageNumber;
  12977. this.pageLabel = pageLabel;
  12978. this._updateUIState(false);
  12979. }
  12980. }, {
  12981. key: "setPagesCount",
  12982. value: function setPagesCount(pagesCount, hasPageLabels) {
  12983. this.pagesCount = pagesCount;
  12984. this.hasPageLabels = hasPageLabels;
  12985. this._updateUIState(true);
  12986. }
  12987. }, {
  12988. key: "setPageScale",
  12989. value: function setPageScale(pageScaleValue, pageScale) {
  12990. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  12991. this.pageScale = pageScale;
  12992. this._updateUIState(false);
  12993. }
  12994. }, {
  12995. key: "reset",
  12996. value: function reset() {
  12997. this.pageNumber = 0;
  12998. this.pageLabel = null;
  12999. this.hasPageLabels = false;
  13000. this.pagesCount = 0;
  13001. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13002. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13003. this._updateUIState(true);
  13004. this.updateLoadingIndicatorState();
  13005. }
  13006. }, {
  13007. key: "_bindListeners",
  13008. value: function _bindListeners() {
  13009. var _this = this;
  13010. var eventBus = this.eventBus,
  13011. items = this.items;
  13012. var self = this;
  13013. items.previous.addEventListener('click', function() {
  13014. eventBus.dispatch('previouspage', {
  13015. source: self
  13016. });
  13017. });
  13018. items.next.addEventListener('click', function() {
  13019. eventBus.dispatch('nextpage', {
  13020. source: self
  13021. });
  13022. });
  13023. items.zoomIn.addEventListener('click', function() {
  13024. eventBus.dispatch('zoomin', {
  13025. source: self
  13026. });
  13027. });
  13028. items.zoomOut.addEventListener('click', function() {
  13029. eventBus.dispatch('zoomout', {
  13030. source: self
  13031. });
  13032. });
  13033. items.pageNumber.addEventListener('click', function() {
  13034. this.select();
  13035. });
  13036. items.pageNumber.addEventListener('change', function() {
  13037. eventBus.dispatch('pagenumberchanged', {
  13038. source: self,
  13039. value: this.value
  13040. });
  13041. });
  13042. items.scaleSelect.addEventListener('change', function() {
  13043. if (this.value === 'custom') {
  13044. return;
  13045. }
  13046. eventBus.dispatch('scalechanged', {
  13047. source: self,
  13048. value: this.value
  13049. });
  13050. });
  13051. items.presentationModeButton.addEventListener('click', function() {
  13052. eventBus.dispatch('presentationmode', {
  13053. source: self
  13054. });
  13055. });
  13056. items.openFile.addEventListener('click', function() {
  13057. eventBus.dispatch('openfile', {
  13058. source: self
  13059. });
  13060. });
  13061. items.print.addEventListener('click', function() {
  13062. eventBus.dispatch('print', {
  13063. source: self
  13064. });
  13065. });
  13066. items.download.addEventListener('click', function() {
  13067. eventBus.dispatch('download', {
  13068. source: self
  13069. });
  13070. });
  13071. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13072. eventBus.on('localized', function() {
  13073. _this._localized();
  13074. });
  13075. }
  13076. }, {
  13077. key: "_localized",
  13078. value: function _localized() {
  13079. this._wasLocalized = true;
  13080. this._adjustScaleWidth();
  13081. this._updateUIState(true);
  13082. }
  13083. }, {
  13084. key: "_updateUIState",
  13085. value: function _updateUIState() {
  13086. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ?
  13087. arguments[0] : false;
  13088. if (!this._wasLocalized) {
  13089. return;
  13090. }
  13091. var pageNumber = this.pageNumber,
  13092. pagesCount = this.pagesCount,
  13093. pageScaleValue = this.pageScaleValue,
  13094. pageScale = this.pageScale,
  13095. items = this.items;
  13096. if (resetNumPages) {
  13097. if (this.hasPageLabels) {
  13098. items.pageNumber.type = 'text';
  13099. } else {
  13100. items.pageNumber.type = 'number';
  13101. this.l10n.get('of_pages', {
  13102. pagesCount: pagesCount
  13103. }, 'of {{pagesCount}}').then(function(msg) {
  13104. items.numPages.textContent = msg;
  13105. });
  13106. }
  13107. items.pageNumber.max = pagesCount;
  13108. }
  13109. if (this.hasPageLabels) {
  13110. items.pageNumber.value = this.pageLabel;
  13111. this.l10n.get('page_of_pages', {
  13112. pageNumber: pageNumber,
  13113. pagesCount: pagesCount
  13114. }, '({{pageNumber}} of {{pagesCount}})').then(function(msg) {
  13115. items.numPages.textContent = msg;
  13116. });
  13117. } else {
  13118. items.pageNumber.value = pageNumber;
  13119. }
  13120. items.previous.disabled = pageNumber <= 1;
  13121. items.next.disabled = pageNumber >= pagesCount;
  13122. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13123. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13124. var customScale = Math.round(pageScale * 10000) / 100;
  13125. this.l10n.get('page_scale_percent', {
  13126. scale: customScale
  13127. }, '{{scale}}%').then(function(msg) {
  13128. var options = items.scaleSelect.options;
  13129. var predefinedValueFound = false;
  13130. for (var i = 0, ii = options.length; i < ii; i++) {
  13131. var option = options[i];
  13132. if (option.value !== pageScaleValue) {
  13133. option.selected = false;
  13134. continue;
  13135. }
  13136. option.selected = true;
  13137. predefinedValueFound = true;
  13138. }
  13139. if (!predefinedValueFound) {
  13140. items.customScaleOption.textContent = msg;
  13141. items.customScaleOption.selected = true;
  13142. }
  13143. });
  13144. }
  13145. }, {
  13146. key: "updateLoadingIndicatorState",
  13147. value: function updateLoadingIndicatorState() {
  13148. var loading = arguments.length > 0 && arguments[0] !== undefined ?
  13149. arguments[0] : false;
  13150. var pageNumberInput = this.items.pageNumber;
  13151. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR,
  13152. loading);
  13153. }
  13154. }, {
  13155. key: "_adjustScaleWidth",
  13156. value: function _adjustScaleWidth() {
  13157. var container = this.items.scaleSelectContainer;
  13158. var select = this.items.scaleSelect;
  13159. _ui_utils.animationStarted.then(function() {
  13160. if (container.clientWidth === 0) {
  13161. container.setAttribute('style', 'display: inherit;');
  13162. }
  13163. if (container.clientWidth > 0) {
  13164. select.setAttribute('style', 'min-width: inherit;');
  13165. var width = select.clientWidth +
  13166. SCALE_SELECT_CONTAINER_PADDING;
  13167. select.setAttribute('style', 'min-width: ' + (width +
  13168. SCALE_SELECT_PADDING) + 'px;');
  13169. container.setAttribute('style', 'min-width: ' + width +
  13170. 'px; ' + 'max-width: ' + width + 'px;');
  13171. }
  13172. });
  13173. }
  13174. }]);
  13175. return Toolbar;
  13176. }();
  13177. exports.Toolbar = Toolbar;
  13178. /***/
  13179. }),
  13180. /* 35 */
  13181. /***/
  13182. (function(module, exports, __webpack_require__) {
  13183. "use strict";
  13184. Object.defineProperty(exports, "__esModule", {
  13185. value: true
  13186. });
  13187. exports.ViewHistory = void 0;
  13188. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  13189. function _interopRequireDefault(obj) {
  13190. return obj && obj.__esModule ? obj : {
  13191. "default": obj
  13192. };
  13193. }
  13194. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13195. try {
  13196. var info = gen[key](arg);
  13197. var value = info.value;
  13198. } catch (error) {
  13199. reject(error);
  13200. return;
  13201. }
  13202. if (info.done) {
  13203. resolve(value);
  13204. } else {
  13205. Promise.resolve(value).then(_next, _throw);
  13206. }
  13207. }
  13208. function _asyncToGenerator(fn) {
  13209. return function() {
  13210. var self = this,
  13211. args = arguments;
  13212. return new Promise(function(resolve, reject) {
  13213. var gen = fn.apply(self, args);
  13214. function _next(value) {
  13215. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  13216. }
  13217. function _throw(err) {
  13218. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  13219. }
  13220. _next(undefined);
  13221. });
  13222. };
  13223. }
  13224. function _classCallCheck(instance, Constructor) {
  13225. if (!(instance instanceof Constructor)) {
  13226. throw new TypeError("Cannot call a class as a function");
  13227. }
  13228. }
  13229. function _defineProperties(target, props) {
  13230. for (var i = 0; i < props.length; i++) {
  13231. var descriptor = props[i];
  13232. descriptor.enumerable = descriptor.enumerable || false;
  13233. descriptor.configurable = true;
  13234. if ("value" in descriptor) descriptor.writable = true;
  13235. Object.defineProperty(target, descriptor.key, descriptor);
  13236. }
  13237. }
  13238. function _createClass(Constructor, protoProps, staticProps) {
  13239. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  13240. if (staticProps) _defineProperties(Constructor, staticProps);
  13241. return Constructor;
  13242. }
  13243. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13244. var ViewHistory =
  13245. /*#__PURE__*/
  13246. function() {
  13247. function ViewHistory(fingerprint) {
  13248. var _this = this;
  13249. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  13250. DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13251. _classCallCheck(this, ViewHistory);
  13252. this.fingerprint = fingerprint;
  13253. this.cacheSize = cacheSize;
  13254. this._initializedPromise = this._readFromStorage().then(function(databaseStr) {
  13255. var database = JSON.parse(databaseStr || '{}');
  13256. if (!('files' in database)) {
  13257. database.files = [];
  13258. } else {
  13259. while (database.files.length >= _this.cacheSize) {
  13260. database.files.shift();
  13261. }
  13262. }
  13263. var index = -1;
  13264. for (var i = 0, length = database.files.length; i < length; i++) {
  13265. var branch = database.files[i];
  13266. if (branch.fingerprint === _this.fingerprint) {
  13267. index = i;
  13268. break;
  13269. }
  13270. }
  13271. if (index === -1) {
  13272. index = database.files.push({
  13273. fingerprint: _this.fingerprint
  13274. }) - 1;
  13275. }
  13276. _this.file = database.files[index];
  13277. _this.database = database;
  13278. });
  13279. }
  13280. _createClass(ViewHistory, [{
  13281. key: "_writeToStorage",
  13282. value: function() {
  13283. var _writeToStorage2 = _asyncToGenerator(
  13284. /*#__PURE__*/
  13285. _regenerator["default"].mark(function _callee() {
  13286. var databaseStr;
  13287. return _regenerator["default"].wrap(function _callee$(
  13288. _context) {
  13289. while (1) {
  13290. switch (_context.prev = _context.next) {
  13291. case 0:
  13292. databaseStr = JSON.stringify(
  13293. this.database);
  13294. // localStorage.setItem(
  13295. // 'pdfjs.history',
  13296. // databaseStr);
  13297. // let arr = this.database.files[0]
  13298. /* 这里不读缓存 走window事件 */
  13299. let data = [{
  13300. totalPage: window
  13301. .PDFViewerApplication
  13302. .pagesCount
  13303. },
  13304. {
  13305. page: window
  13306. .PDFViewerApplication
  13307. .page
  13308. },
  13309. ]
  13310. // console.log("0000",window.PDFViewerApplication.page,window.PDFViewerApplication.pagesCount)
  13311. // console.log("pdf记录:",data)
  13312. // uni.webView.getEnv(function(res) {
  13313. // console.log('当前环境:' + JSON.stringify(res));
  13314. // });
  13315. uni.postMessage({
  13316. data: data
  13317. });
  13318. case 2:
  13319. case "end":
  13320. return _context.stop();
  13321. }
  13322. }
  13323. }, _callee, this);
  13324. }));
  13325. function _writeToStorage() {
  13326. return _writeToStorage2.apply(this, arguments);
  13327. }
  13328. return _writeToStorage;
  13329. }()
  13330. }, {
  13331. key: "_readFromStorage",
  13332. value: function() {
  13333. var _readFromStorage2 = _asyncToGenerator(
  13334. /*#__PURE__*/
  13335. _regenerator["default"].mark(function _callee2() {
  13336. return _regenerator["default"].wrap(function _callee2$(
  13337. _context2) {
  13338. while (1) {
  13339. switch (_context2.prev = _context2
  13340. .next) {
  13341. case 0:
  13342. return _context2.abrupt(
  13343. "return", localStorage
  13344. .getItem(
  13345. 'pdfjs.history'));
  13346. case 1:
  13347. case "end":
  13348. return _context2.stop();
  13349. }
  13350. }
  13351. }, _callee2);
  13352. }));
  13353. function _readFromStorage() {
  13354. return _readFromStorage2.apply(this, arguments);
  13355. }
  13356. return _readFromStorage;
  13357. }()
  13358. }, {
  13359. key: "set",
  13360. value: function() {
  13361. var _set = _asyncToGenerator(
  13362. /*#__PURE__*/
  13363. _regenerator["default"].mark(function _callee3(name, val) {
  13364. return _regenerator["default"].wrap(function _callee3$(
  13365. _context3) {
  13366. while (1) {
  13367. switch (_context3.prev = _context3
  13368. .next) {
  13369. case 0:
  13370. _context3.next = 2;
  13371. return this._initializedPromise;
  13372. case 2:
  13373. this.file[name] = val;
  13374. return _context3.abrupt(
  13375. "return", this
  13376. ._writeToStorage());
  13377. case 4:
  13378. case "end":
  13379. return _context3.stop();
  13380. }
  13381. }
  13382. }, _callee3, this);
  13383. }));
  13384. function set(_x, _x2) {
  13385. return _set.apply(this, arguments);
  13386. }
  13387. return set;
  13388. }()
  13389. }, {
  13390. key: "setMultiple",
  13391. value: function() {
  13392. var _setMultiple = _asyncToGenerator(
  13393. /*#__PURE__*/
  13394. _regenerator["default"].mark(function _callee4(properties) {
  13395. var name;
  13396. return _regenerator["default"].wrap(function _callee4$(
  13397. _context4) {
  13398. while (1) {
  13399. switch (_context4.prev = _context4
  13400. .next) {
  13401. case 0:
  13402. _context4.next = 2;
  13403. return this._initializedPromise;
  13404. case 2:
  13405. for (name in properties) {
  13406. this.file[name] =
  13407. properties[name];
  13408. }
  13409. return _context4.abrupt(
  13410. "return", this
  13411. ._writeToStorage());
  13412. case 4:
  13413. case "end":
  13414. return _context4.stop();
  13415. }
  13416. }
  13417. }, _callee4, this);
  13418. }));
  13419. function setMultiple(_x3) {
  13420. return _setMultiple.apply(this, arguments);
  13421. }
  13422. return setMultiple;
  13423. }()
  13424. }, {
  13425. key: "get",
  13426. value: function() {
  13427. var _get = _asyncToGenerator(
  13428. /*#__PURE__*/
  13429. _regenerator["default"].mark(function _callee5(name,
  13430. defaultValue) {
  13431. var val;
  13432. return _regenerator["default"].wrap(function _callee5$(
  13433. _context5) {
  13434. while (1) {
  13435. switch (_context5.prev = _context5
  13436. .next) {
  13437. case 0:
  13438. _context5.next = 2;
  13439. return this._initializedPromise;
  13440. case 2:
  13441. val = this.file[name];
  13442. return _context5.abrupt(
  13443. "return", val !==
  13444. undefined ? val :
  13445. defaultValue);
  13446. case 4:
  13447. case "end":
  13448. return _context5.stop();
  13449. }
  13450. }
  13451. }, _callee5, this);
  13452. }));
  13453. function get(_x4, _x5) {
  13454. return _get.apply(this, arguments);
  13455. }
  13456. return get;
  13457. }()
  13458. }, {
  13459. key: "getMultiple",
  13460. value: function() {
  13461. var _getMultiple = _asyncToGenerator(
  13462. /*#__PURE__*/
  13463. _regenerator["default"].mark(function _callee6(properties) {
  13464. var values, name, val;
  13465. return _regenerator["default"].wrap(function _callee6$(
  13466. _context6) {
  13467. while (1) {
  13468. switch (_context6.prev = _context6
  13469. .next) {
  13470. case 0:
  13471. _context6.next = 2;
  13472. return this._initializedPromise;
  13473. case 2:
  13474. values = Object.create(null);
  13475. for (name in properties) {
  13476. val = this.file[name];
  13477. values[name] = val !==
  13478. undefined ? val :
  13479. properties[name];
  13480. }
  13481. return _context6.abrupt(
  13482. "return", values);
  13483. case 5:
  13484. case "end":
  13485. return _context6.stop();
  13486. }
  13487. }
  13488. }, _callee6, this);
  13489. }));
  13490. function getMultiple(_x6) {
  13491. return _getMultiple.apply(this, arguments);
  13492. }
  13493. return getMultiple;
  13494. }()
  13495. }]);
  13496. return ViewHistory;
  13497. }();
  13498. exports.ViewHistory = ViewHistory;
  13499. /***/
  13500. }),
  13501. /* 36 */
  13502. /***/
  13503. (function(module, exports, __webpack_require__) {
  13504. "use strict";
  13505. Object.defineProperty(exports, "__esModule", {
  13506. value: true
  13507. });
  13508. exports.GenericCom = void 0;
  13509. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  13510. var _app = __webpack_require__(1);
  13511. var _preferences = __webpack_require__(37);
  13512. var _download_manager = __webpack_require__(38);
  13513. var _genericl10n = __webpack_require__(39);
  13514. function _interopRequireDefault(obj) {
  13515. return obj && obj.__esModule ? obj : {
  13516. "default": obj
  13517. };
  13518. }
  13519. function _typeof(obj) {
  13520. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  13521. _typeof = function _typeof(obj) {
  13522. return typeof obj;
  13523. };
  13524. } else {
  13525. _typeof = function _typeof(obj) {
  13526. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  13527. Symbol.prototype ? "symbol" : typeof obj;
  13528. };
  13529. }
  13530. return _typeof(obj);
  13531. }
  13532. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13533. try {
  13534. var info = gen[key](arg);
  13535. var value = info.value;
  13536. } catch (error) {
  13537. reject(error);
  13538. return;
  13539. }
  13540. if (info.done) {
  13541. resolve(value);
  13542. } else {
  13543. Promise.resolve(value).then(_next, _throw);
  13544. }
  13545. }
  13546. function _asyncToGenerator(fn) {
  13547. return function() {
  13548. var self = this,
  13549. args = arguments;
  13550. return new Promise(function(resolve, reject) {
  13551. var gen = fn.apply(self, args);
  13552. function _next(value) {
  13553. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  13554. }
  13555. function _throw(err) {
  13556. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  13557. }
  13558. _next(undefined);
  13559. });
  13560. };
  13561. }
  13562. function _classCallCheck(instance, Constructor) {
  13563. if (!(instance instanceof Constructor)) {
  13564. throw new TypeError("Cannot call a class as a function");
  13565. }
  13566. }
  13567. function _defineProperties(target, props) {
  13568. for (var i = 0; i < props.length; i++) {
  13569. var descriptor = props[i];
  13570. descriptor.enumerable = descriptor.enumerable || false;
  13571. descriptor.configurable = true;
  13572. if ("value" in descriptor) descriptor.writable = true;
  13573. Object.defineProperty(target, descriptor.key, descriptor);
  13574. }
  13575. }
  13576. function _createClass(Constructor, protoProps, staticProps) {
  13577. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  13578. if (staticProps) _defineProperties(Constructor, staticProps);
  13579. return Constructor;
  13580. }
  13581. function _possibleConstructorReturn(self, call) {
  13582. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  13583. return call;
  13584. }
  13585. return _assertThisInitialized(self);
  13586. }
  13587. function _assertThisInitialized(self) {
  13588. if (self === void 0) {
  13589. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  13590. }
  13591. return self;
  13592. }
  13593. function _getPrototypeOf(o) {
  13594. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  13595. return o.__proto__ || Object.getPrototypeOf(o);
  13596. };
  13597. return _getPrototypeOf(o);
  13598. }
  13599. function _inherits(subClass, superClass) {
  13600. if (typeof superClass !== "function" && superClass !== null) {
  13601. throw new TypeError("Super expression must either be null or a function");
  13602. }
  13603. subClass.prototype = Object.create(superClass && superClass.prototype, {
  13604. constructor: {
  13605. value: subClass,
  13606. writable: true,
  13607. configurable: true
  13608. }
  13609. });
  13610. if (superClass) _setPrototypeOf(subClass, superClass);
  13611. }
  13612. function _setPrototypeOf(o, p) {
  13613. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  13614. o.__proto__ = p;
  13615. return o;
  13616. };
  13617. return _setPrototypeOf(o, p);
  13618. }
  13619. ;
  13620. var GenericCom = {};
  13621. exports.GenericCom = GenericCom;
  13622. var GenericPreferences =
  13623. /*#__PURE__*/
  13624. function(_BasePreferences) {
  13625. _inherits(GenericPreferences, _BasePreferences);
  13626. function GenericPreferences() {
  13627. _classCallCheck(this, GenericPreferences);
  13628. return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this,
  13629. arguments));
  13630. }
  13631. _createClass(GenericPreferences, [{
  13632. key: "_writeToStorage",
  13633. value: function() {
  13634. var _writeToStorage2 = _asyncToGenerator(
  13635. /*#__PURE__*/
  13636. _regenerator["default"].mark(function _callee(prefObj) {
  13637. return _regenerator["default"].wrap(function _callee$(
  13638. _context) {
  13639. while (1) {
  13640. switch (_context.prev = _context.next) {
  13641. case 0:
  13642. localStorage.setItem(
  13643. 'pdfjs.preferences',
  13644. JSON.stringify(prefObj));
  13645. case 1:
  13646. case "end":
  13647. return _context.stop();
  13648. }
  13649. }
  13650. }, _callee);
  13651. }));
  13652. function _writeToStorage(_x) {
  13653. return _writeToStorage2.apply(this, arguments);
  13654. }
  13655. return _writeToStorage;
  13656. }()
  13657. }, {
  13658. key: "_readFromStorage",
  13659. value: function() {
  13660. var _readFromStorage2 = _asyncToGenerator(
  13661. /*#__PURE__*/
  13662. _regenerator["default"].mark(function _callee2(prefObj) {
  13663. return _regenerator["default"].wrap(function _callee2$(
  13664. _context2) {
  13665. while (1) {
  13666. switch (_context2.prev = _context2
  13667. .next) {
  13668. case 0:
  13669. return _context2.abrupt(
  13670. "return", JSON.parse(
  13671. localStorage
  13672. .getItem(
  13673. 'pdfjs.preferences'
  13674. )));
  13675. case 1:
  13676. case "end":
  13677. return _context2.stop();
  13678. }
  13679. }
  13680. }, _callee2);
  13681. }));
  13682. function _readFromStorage(_x2) {
  13683. return _readFromStorage2.apply(this, arguments);
  13684. }
  13685. return _readFromStorage;
  13686. }()
  13687. }]);
  13688. return GenericPreferences;
  13689. }(_preferences.BasePreferences);
  13690. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  13691. GenericExternalServices.createDownloadManager = function(options) {
  13692. return new _download_manager.DownloadManager(options);
  13693. };
  13694. GenericExternalServices.createPreferences = function() {
  13695. return new GenericPreferences();
  13696. };
  13697. GenericExternalServices.createL10n = function(_ref) {
  13698. var _ref$locale = _ref.locale,
  13699. locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
  13700. return new _genericl10n.GenericL10n(locale);
  13701. };
  13702. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  13703. /***/
  13704. }),
  13705. /* 37 */
  13706. /***/
  13707. (function(module, exports, __webpack_require__) {
  13708. "use strict";
  13709. Object.defineProperty(exports, "__esModule", {
  13710. value: true
  13711. });
  13712. exports.BasePreferences = void 0;
  13713. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  13714. function _interopRequireDefault(obj) {
  13715. return obj && obj.__esModule ? obj : {
  13716. "default": obj
  13717. };
  13718. }
  13719. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13720. try {
  13721. var info = gen[key](arg);
  13722. var value = info.value;
  13723. } catch (error) {
  13724. reject(error);
  13725. return;
  13726. }
  13727. if (info.done) {
  13728. resolve(value);
  13729. } else {
  13730. Promise.resolve(value).then(_next, _throw);
  13731. }
  13732. }
  13733. function _asyncToGenerator(fn) {
  13734. return function() {
  13735. var self = this,
  13736. args = arguments;
  13737. return new Promise(function(resolve, reject) {
  13738. var gen = fn.apply(self, args);
  13739. function _next(value) {
  13740. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  13741. }
  13742. function _throw(err) {
  13743. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  13744. }
  13745. _next(undefined);
  13746. });
  13747. };
  13748. }
  13749. function _typeof(obj) {
  13750. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  13751. _typeof = function _typeof(obj) {
  13752. return typeof obj;
  13753. };
  13754. } else {
  13755. _typeof = function _typeof(obj) {
  13756. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  13757. Symbol.prototype ? "symbol" : typeof obj;
  13758. };
  13759. }
  13760. return _typeof(obj);
  13761. }
  13762. function _classCallCheck(instance, Constructor) {
  13763. if (!(instance instanceof Constructor)) {
  13764. throw new TypeError("Cannot call a class as a function");
  13765. }
  13766. }
  13767. function _defineProperties(target, props) {
  13768. for (var i = 0; i < props.length; i++) {
  13769. var descriptor = props[i];
  13770. descriptor.enumerable = descriptor.enumerable || false;
  13771. descriptor.configurable = true;
  13772. if ("value" in descriptor) descriptor.writable = true;
  13773. Object.defineProperty(target, descriptor.key, descriptor);
  13774. }
  13775. }
  13776. function _createClass(Constructor, protoProps, staticProps) {
  13777. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  13778. if (staticProps) _defineProperties(Constructor, staticProps);
  13779. return Constructor;
  13780. }
  13781. var defaultPreferences = null;
  13782. function getDefaultPreferences() {
  13783. if (!defaultPreferences) {
  13784. defaultPreferences = Promise.resolve({
  13785. "cursorToolOnLoad": 0,
  13786. "defaultZoomValue": "",
  13787. "disablePageLabels": false,
  13788. "enablePrintAutoRotate": false,
  13789. "enableWebGL": false,
  13790. "eventBusDispatchToDOM": false,
  13791. "externalLinkTarget": 0,
  13792. "historyUpdateUrl": false,
  13793. "pdfBugEnabled": false,
  13794. "renderer": "canvas",
  13795. "renderInteractiveForms": false,
  13796. "sidebarViewOnLoad": -1,
  13797. "scrollModeOnLoad": -1,
  13798. "spreadModeOnLoad": -1,
  13799. "textLayerMode": 1,
  13800. "useOnlyCssZoom": false,
  13801. "viewOnLoad": 0,
  13802. "disableAutoFetch": false,
  13803. "disableFontFace": false,
  13804. "disableRange": false,
  13805. "disableStream": false
  13806. });
  13807. }
  13808. return defaultPreferences;
  13809. }
  13810. var BasePreferences =
  13811. /*#__PURE__*/
  13812. function() {
  13813. function BasePreferences() {
  13814. var _this = this;
  13815. _classCallCheck(this, BasePreferences);
  13816. if (this.constructor === BasePreferences) {
  13817. throw new Error('Cannot initialize BasePreferences.');
  13818. }
  13819. this.prefs = null;
  13820. this._initializedPromise = getDefaultPreferences().then(function(defaults) {
  13821. Object.defineProperty(_this, 'defaults', {
  13822. value: Object.freeze(defaults),
  13823. writable: false,
  13824. enumerable: true,
  13825. configurable: false
  13826. });
  13827. _this.prefs = Object.assign(Object.create(null), defaults);
  13828. return _this._readFromStorage(defaults);
  13829. }).then(function(prefs) {
  13830. if (!prefs) {
  13831. return;
  13832. }
  13833. for (var name in prefs) {
  13834. var defaultValue = _this.defaults[name],
  13835. prefValue = prefs[name];
  13836. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(
  13837. defaultValue)) {
  13838. continue;
  13839. }
  13840. _this.prefs[name] = prefValue;
  13841. }
  13842. });
  13843. }
  13844. _createClass(BasePreferences, [{
  13845. key: "_writeToStorage",
  13846. value: function() {
  13847. var _writeToStorage2 = _asyncToGenerator(
  13848. /*#__PURE__*/
  13849. _regenerator["default"].mark(function _callee(prefObj) {
  13850. return _regenerator["default"].wrap(function _callee$(
  13851. _context) {
  13852. while (1) {
  13853. switch (_context.prev = _context.next) {
  13854. case 0:
  13855. throw new Error(
  13856. 'Not implemented: _writeToStorage'
  13857. );
  13858. case 1:
  13859. case "end":
  13860. return _context.stop();
  13861. }
  13862. }
  13863. }, _callee);
  13864. }));
  13865. function _writeToStorage(_x) {
  13866. return _writeToStorage2.apply(this, arguments);
  13867. }
  13868. return _writeToStorage;
  13869. }()
  13870. }, {
  13871. key: "_readFromStorage",
  13872. value: function() {
  13873. var _readFromStorage2 = _asyncToGenerator(
  13874. /*#__PURE__*/
  13875. _regenerator["default"].mark(function _callee2(prefObj) {
  13876. return _regenerator["default"].wrap(function _callee2$(
  13877. _context2) {
  13878. while (1) {
  13879. switch (_context2.prev = _context2
  13880. .next) {
  13881. case 0:
  13882. throw new Error(
  13883. 'Not implemented: _readFromStorage'
  13884. );
  13885. case 1:
  13886. case "end":
  13887. return _context2.stop();
  13888. }
  13889. }
  13890. }, _callee2);
  13891. }));
  13892. function _readFromStorage(_x2) {
  13893. return _readFromStorage2.apply(this, arguments);
  13894. }
  13895. return _readFromStorage;
  13896. }()
  13897. }, {
  13898. key: "reset",
  13899. value: function() {
  13900. var _reset = _asyncToGenerator(
  13901. /*#__PURE__*/
  13902. _regenerator["default"].mark(function _callee3() {
  13903. return _regenerator["default"].wrap(function _callee3$(
  13904. _context3) {
  13905. while (1) {
  13906. switch (_context3.prev = _context3
  13907. .next) {
  13908. case 0:
  13909. _context3.next = 2;
  13910. return this._initializedPromise;
  13911. case 2:
  13912. this.prefs = Object.assign(
  13913. Object.create(null),
  13914. this.defaults);
  13915. return _context3.abrupt(
  13916. "return", this
  13917. ._writeToStorage(this
  13918. .defaults));
  13919. case 4:
  13920. case "end":
  13921. return _context3.stop();
  13922. }
  13923. }
  13924. }, _callee3, this);
  13925. }));
  13926. function reset() {
  13927. return _reset.apply(this, arguments);
  13928. }
  13929. return reset;
  13930. }()
  13931. }, {
  13932. key: "set",
  13933. value: function() {
  13934. var _set = _asyncToGenerator(
  13935. /*#__PURE__*/
  13936. _regenerator["default"].mark(function _callee4(name, value) {
  13937. var defaultValue, valueType, defaultType;
  13938. return _regenerator["default"].wrap(function _callee4$(
  13939. _context4) {
  13940. while (1) {
  13941. switch (_context4.prev = _context4
  13942. .next) {
  13943. case 0:
  13944. _context4.next = 2;
  13945. return this._initializedPromise;
  13946. case 2:
  13947. defaultValue = this.defaults[
  13948. name];
  13949. if (!(defaultValue ===
  13950. undefined)) {
  13951. _context4.next = 7;
  13952. break;
  13953. }
  13954. throw new Error(
  13955. "Set preference: \""
  13956. .concat(name,
  13957. "\" is undefined."));
  13958. case 7:
  13959. if (!(value === undefined)) {
  13960. _context4.next = 9;
  13961. break;
  13962. }
  13963. throw new Error(
  13964. 'Set preference: no value is specified.'
  13965. );
  13966. case 9:
  13967. valueType = _typeof(value);
  13968. defaultType = _typeof(
  13969. defaultValue);
  13970. if (!(valueType !==
  13971. defaultType)) {
  13972. _context4.next = 19;
  13973. break;
  13974. }
  13975. if (!(valueType === 'number' &&
  13976. defaultType === 'string'
  13977. )) {
  13978. _context4.next = 16;
  13979. break;
  13980. }
  13981. value = value.toString();
  13982. _context4.next = 17;
  13983. break;
  13984. case 16:
  13985. throw new Error(
  13986. "Set preference: \""
  13987. .concat(value,
  13988. "\" is a ").concat(
  13989. valueType, ", ") +
  13990. "expected a ".concat(
  13991. defaultType, "."));
  13992. case 17:
  13993. _context4.next = 21;
  13994. break;
  13995. case 19:
  13996. if (!(valueType === 'number' &&
  13997. !Number.isInteger(value)
  13998. )) {
  13999. _context4.next = 21;
  14000. break;
  14001. }
  14002. throw new Error(
  14003. "Set preference: \""
  14004. .concat(value,
  14005. "\" must be an integer."
  14006. ));
  14007. case 21:
  14008. this.prefs[name] = value;
  14009. return _context4.abrupt(
  14010. "return", this
  14011. ._writeToStorage(this
  14012. .prefs));
  14013. case 23:
  14014. case "end":
  14015. return _context4.stop();
  14016. }
  14017. }
  14018. }, _callee4, this);
  14019. }));
  14020. function set(_x3, _x4) {
  14021. return _set.apply(this, arguments);
  14022. }
  14023. return set;
  14024. }()
  14025. }, {
  14026. key: "get",
  14027. value: function() {
  14028. var _get = _asyncToGenerator(
  14029. /*#__PURE__*/
  14030. _regenerator["default"].mark(function _callee5(name) {
  14031. var defaultValue, prefValue;
  14032. return _regenerator["default"].wrap(function _callee5$(
  14033. _context5) {
  14034. while (1) {
  14035. switch (_context5.prev = _context5
  14036. .next) {
  14037. case 0:
  14038. _context5.next = 2;
  14039. return this._initializedPromise;
  14040. case 2:
  14041. defaultValue = this.defaults[
  14042. name];
  14043. if (!(defaultValue ===
  14044. undefined)) {
  14045. _context5.next = 7;
  14046. break;
  14047. }
  14048. throw new Error(
  14049. "Get preference: \""
  14050. .concat(name,
  14051. "\" is undefined."));
  14052. case 7:
  14053. prefValue = this.prefs[name];
  14054. if (!(prefValue !==
  14055. undefined)) {
  14056. _context5.next = 10;
  14057. break;
  14058. }
  14059. return _context5.abrupt(
  14060. "return", prefValue);
  14061. case 10:
  14062. return _context5.abrupt(
  14063. "return", defaultValue);
  14064. case 11:
  14065. case "end":
  14066. return _context5.stop();
  14067. }
  14068. }
  14069. }, _callee5, this);
  14070. }));
  14071. function get(_x5) {
  14072. return _get.apply(this, arguments);
  14073. }
  14074. return get;
  14075. }()
  14076. }, {
  14077. key: "getAll",
  14078. value: function() {
  14079. var _getAll = _asyncToGenerator(
  14080. /*#__PURE__*/
  14081. _regenerator["default"].mark(function _callee6() {
  14082. return _regenerator["default"].wrap(function _callee6$(
  14083. _context6) {
  14084. while (1) {
  14085. switch (_context6.prev = _context6
  14086. .next) {
  14087. case 0:
  14088. _context6.next = 2;
  14089. return this._initializedPromise;
  14090. case 2:
  14091. return _context6.abrupt(
  14092. "return", Object.assign(
  14093. Object.create(null),
  14094. this.defaults, this
  14095. .prefs));
  14096. case 3:
  14097. case "end":
  14098. return _context6.stop();
  14099. }
  14100. }
  14101. }, _callee6, this);
  14102. }));
  14103. function getAll() {
  14104. return _getAll.apply(this, arguments);
  14105. }
  14106. return getAll;
  14107. }()
  14108. }]);
  14109. return BasePreferences;
  14110. }();
  14111. exports.BasePreferences = BasePreferences;
  14112. /***/
  14113. }),
  14114. /* 38 */
  14115. /***/
  14116. (function(module, exports, __webpack_require__) {
  14117. "use strict";
  14118. Object.defineProperty(exports, "__esModule", {
  14119. value: true
  14120. });
  14121. exports.DownloadManager = void 0;
  14122. var _pdfjsLib = __webpack_require__(7);
  14123. function _classCallCheck(instance, Constructor) {
  14124. if (!(instance instanceof Constructor)) {
  14125. throw new TypeError("Cannot call a class as a function");
  14126. }
  14127. }
  14128. function _defineProperties(target, props) {
  14129. for (var i = 0; i < props.length; i++) {
  14130. var descriptor = props[i];
  14131. descriptor.enumerable = descriptor.enumerable || false;
  14132. descriptor.configurable = true;
  14133. if ("value" in descriptor) descriptor.writable = true;
  14134. Object.defineProperty(target, descriptor.key, descriptor);
  14135. }
  14136. }
  14137. function _createClass(Constructor, protoProps, staticProps) {
  14138. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14139. if (staticProps) _defineProperties(Constructor, staticProps);
  14140. return Constructor;
  14141. }
  14142. ;
  14143. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  14144. function _download(blobUrl, filename) {
  14145. var a = document.createElement('a');
  14146. if (!a.click) {
  14147. throw new Error('DownloadManager: "a.click()" is not supported.');
  14148. }
  14149. a.href = blobUrl;
  14150. a.target = '_parent';
  14151. if ('download' in a) {
  14152. a.download = filename;
  14153. }
  14154. (document.body || document.documentElement).appendChild(a);
  14155. a.click();
  14156. a.remove();
  14157. }
  14158. var DownloadManager =
  14159. /*#__PURE__*/
  14160. function() {
  14161. function DownloadManager(_ref) {
  14162. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  14163. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL :
  14164. _ref$disableCreateObj;
  14165. _classCallCheck(this, DownloadManager);
  14166. this.disableCreateObjectURL = disableCreateObjectURL;
  14167. }
  14168. _createClass(DownloadManager, [{
  14169. key: "downloadUrl",
  14170. value: function downloadUrl(url, filename) {
  14171. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  14172. return;
  14173. }
  14174. _download(url + '#pdfjs.action=download', filename);
  14175. }
  14176. }, {
  14177. key: "downloadData",
  14178. value: function downloadData(data, filename, contentType) {
  14179. if (navigator.msSaveBlob) {
  14180. navigator.msSaveBlob(new Blob([data], {
  14181. type: contentType
  14182. }), filename);
  14183. return;
  14184. }
  14185. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this
  14186. .disableCreateObjectURL);
  14187. _download(blobUrl, filename);
  14188. }
  14189. }, {
  14190. key: "download",
  14191. value: function download(blob, url, filename) {
  14192. if (navigator.msSaveBlob) {
  14193. if (!navigator.msSaveBlob(blob, filename)) {
  14194. this.downloadUrl(url, filename);
  14195. }
  14196. return;
  14197. }
  14198. if (this.disableCreateObjectURL) {
  14199. this.downloadUrl(url, filename);
  14200. return;
  14201. }
  14202. var blobUrl = URL.createObjectURL(blob);
  14203. _download(blobUrl, filename);
  14204. }
  14205. }]);
  14206. return DownloadManager;
  14207. }();
  14208. exports.DownloadManager = DownloadManager;
  14209. /***/
  14210. }),
  14211. /* 39 */
  14212. /***/
  14213. (function(module, exports, __webpack_require__) {
  14214. "use strict";
  14215. Object.defineProperty(exports, "__esModule", {
  14216. value: true
  14217. });
  14218. exports.GenericL10n = void 0;
  14219. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  14220. __webpack_require__(40);
  14221. function _interopRequireDefault(obj) {
  14222. return obj && obj.__esModule ? obj : {
  14223. "default": obj
  14224. };
  14225. }
  14226. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  14227. try {
  14228. var info = gen[key](arg);
  14229. var value = info.value;
  14230. } catch (error) {
  14231. reject(error);
  14232. return;
  14233. }
  14234. if (info.done) {
  14235. resolve(value);
  14236. } else {
  14237. Promise.resolve(value).then(_next, _throw);
  14238. }
  14239. }
  14240. function _asyncToGenerator(fn) {
  14241. return function() {
  14242. var self = this,
  14243. args = arguments;
  14244. return new Promise(function(resolve, reject) {
  14245. var gen = fn.apply(self, args);
  14246. function _next(value) {
  14247. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  14248. }
  14249. function _throw(err) {
  14250. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  14251. }
  14252. _next(undefined);
  14253. });
  14254. };
  14255. }
  14256. function _classCallCheck(instance, Constructor) {
  14257. if (!(instance instanceof Constructor)) {
  14258. throw new TypeError("Cannot call a class as a function");
  14259. }
  14260. }
  14261. function _defineProperties(target, props) {
  14262. for (var i = 0; i < props.length; i++) {
  14263. var descriptor = props[i];
  14264. descriptor.enumerable = descriptor.enumerable || false;
  14265. descriptor.configurable = true;
  14266. if ("value" in descriptor) descriptor.writable = true;
  14267. Object.defineProperty(target, descriptor.key, descriptor);
  14268. }
  14269. }
  14270. function _createClass(Constructor, protoProps, staticProps) {
  14271. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14272. if (staticProps) _defineProperties(Constructor, staticProps);
  14273. return Constructor;
  14274. }
  14275. var webL10n = document.webL10n;
  14276. var GenericL10n =
  14277. /*#__PURE__*/
  14278. function() {
  14279. function GenericL10n(lang) {
  14280. _classCallCheck(this, GenericL10n);
  14281. this._lang = lang;
  14282. this._ready = new Promise(function(resolve, reject) {
  14283. webL10n.setLanguage(lang, function() {
  14284. resolve(webL10n);
  14285. });
  14286. });
  14287. }
  14288. _createClass(GenericL10n, [{
  14289. key: "getLanguage",
  14290. value: function() {
  14291. var _getLanguage = _asyncToGenerator(
  14292. /*#__PURE__*/
  14293. _regenerator["default"].mark(function _callee() {
  14294. var l10n;
  14295. return _regenerator["default"].wrap(function _callee$(
  14296. _context) {
  14297. while (1) {
  14298. switch (_context.prev = _context.next) {
  14299. case 0:
  14300. _context.next = 2;
  14301. return this._ready;
  14302. case 2:
  14303. l10n = _context.sent;
  14304. return _context.abrupt("return",
  14305. l10n.getLanguage());
  14306. case 4:
  14307. case "end":
  14308. return _context.stop();
  14309. }
  14310. }
  14311. }, _callee, this);
  14312. }));
  14313. function getLanguage() {
  14314. return _getLanguage.apply(this, arguments);
  14315. }
  14316. return getLanguage;
  14317. }()
  14318. }, {
  14319. key: "getDirection",
  14320. value: function() {
  14321. var _getDirection = _asyncToGenerator(
  14322. /*#__PURE__*/
  14323. _regenerator["default"].mark(function _callee2() {
  14324. var l10n;
  14325. return _regenerator["default"].wrap(function _callee2$(
  14326. _context2) {
  14327. while (1) {
  14328. switch (_context2.prev = _context2
  14329. .next) {
  14330. case 0:
  14331. _context2.next = 2;
  14332. return this._ready;
  14333. case 2:
  14334. l10n = _context2.sent;
  14335. return _context2.abrupt(
  14336. "return", l10n
  14337. .getDirection());
  14338. case 4:
  14339. case "end":
  14340. return _context2.stop();
  14341. }
  14342. }
  14343. }, _callee2, this);
  14344. }));
  14345. function getDirection() {
  14346. return _getDirection.apply(this, arguments);
  14347. }
  14348. return getDirection;
  14349. }()
  14350. }, {
  14351. key: "get",
  14352. value: function() {
  14353. var _get = _asyncToGenerator(
  14354. /*#__PURE__*/
  14355. _regenerator["default"].mark(function _callee3(property, args,
  14356. fallback) {
  14357. var l10n;
  14358. return _regenerator["default"].wrap(function _callee3$(
  14359. _context3) {
  14360. while (1) {
  14361. switch (_context3.prev = _context3
  14362. .next) {
  14363. case 0:
  14364. _context3.next = 2;
  14365. return this._ready;
  14366. case 2:
  14367. l10n = _context3.sent;
  14368. return _context3.abrupt(
  14369. "return", l10n.get(
  14370. property, args,
  14371. fallback));
  14372. case 4:
  14373. case "end":
  14374. return _context3.stop();
  14375. }
  14376. }
  14377. }, _callee3, this);
  14378. }));
  14379. function get(_x, _x2, _x3) {
  14380. return _get.apply(this, arguments);
  14381. }
  14382. return get;
  14383. }()
  14384. }, {
  14385. key: "translate",
  14386. value: function() {
  14387. var _translate = _asyncToGenerator(
  14388. /*#__PURE__*/
  14389. _regenerator["default"].mark(function _callee4(element) {
  14390. var l10n;
  14391. return _regenerator["default"].wrap(function _callee4$(
  14392. _context4) {
  14393. while (1) {
  14394. switch (_context4.prev = _context4
  14395. .next) {
  14396. case 0:
  14397. _context4.next = 2;
  14398. return this._ready;
  14399. case 2:
  14400. l10n = _context4.sent;
  14401. return _context4.abrupt(
  14402. "return", l10n
  14403. .translate(element));
  14404. case 4:
  14405. case "end":
  14406. return _context4.stop();
  14407. }
  14408. }
  14409. }, _callee4, this);
  14410. }));
  14411. function translate(_x4) {
  14412. return _translate.apply(this, arguments);
  14413. }
  14414. return translate;
  14415. }()
  14416. }]);
  14417. return GenericL10n;
  14418. }();
  14419. exports.GenericL10n = GenericL10n;
  14420. /***/
  14421. }),
  14422. /* 40 */
  14423. /***/
  14424. (function(module, exports, __webpack_require__) {
  14425. "use strict";
  14426. document.webL10n = function(window, document, undefined) {
  14427. var gL10nData = {};
  14428. var gTextData = '';
  14429. var gTextProp = 'textContent';
  14430. var gLanguage = '';
  14431. var gMacros = {};
  14432. var gReadyState = 'loading';
  14433. var gAsyncResourceLoading = true;
  14434. function getL10nResourceLinks() {
  14435. return document.querySelectorAll('link[type="application/l10n"]');
  14436. }
  14437. function getL10nDictionary() {
  14438. var script = document.querySelector('script[type="application/l10n"]');
  14439. return script ? JSON.parse(script.innerHTML) : null;
  14440. }
  14441. function getTranslatableChildren(element) {
  14442. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14443. }
  14444. function getL10nAttributes(element) {
  14445. if (!element) return {};
  14446. var l10nId = element.getAttribute('data-l10n-id');
  14447. var l10nArgs = element.getAttribute('data-l10n-args');
  14448. var args = {};
  14449. if (l10nArgs) {
  14450. try {
  14451. args = JSON.parse(l10nArgs);
  14452. } catch (e) {
  14453. console.warn('could not parse arguments for #' + l10nId);
  14454. }
  14455. }
  14456. return {
  14457. id: l10nId,
  14458. args: args
  14459. };
  14460. }
  14461. function xhrLoadText(url, onSuccess, onFailure) {
  14462. onSuccess = onSuccess || function _onSuccess(data) {};
  14463. onFailure = onFailure || function _onFailure() {};
  14464. var xhr = new XMLHttpRequest();
  14465. xhr.open('GET', url, gAsyncResourceLoading);
  14466. if (xhr.overrideMimeType) {
  14467. xhr.overrideMimeType('text/plain; charset=utf-8');
  14468. }
  14469. xhr.onreadystatechange = function() {
  14470. if (xhr.readyState == 4) {
  14471. if (xhr.status == 200 || xhr.status === 0) {
  14472. onSuccess(xhr.responseText);
  14473. } else {
  14474. onFailure();
  14475. }
  14476. }
  14477. };
  14478. xhr.onerror = onFailure;
  14479. xhr.ontimeout = onFailure;
  14480. try {
  14481. xhr.send(null);
  14482. } catch (e) {
  14483. onFailure();
  14484. }
  14485. }
  14486. function parseResource(href, lang, successCallback, failureCallback) {
  14487. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14488. function evalString(text) {
  14489. if (text.lastIndexOf('\\') < 0) return text;
  14490. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(
  14491. /\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{')
  14492. .replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  14493. }
  14494. function parseProperties(text, parsedPropertiesCallback) {
  14495. var dictionary = {};
  14496. var reBlank = /^\s*|\s*$/;
  14497. var reComment = /^\s*#|^\s*$/;
  14498. var reSection = /^\s*\[(.*)\]\s*$/;
  14499. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14500. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14501. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14502. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14503. var currentLang = '*';
  14504. var genericLang = lang.split('-', 1)[0];
  14505. var skipLang = false;
  14506. var match = '';
  14507. function nextEntry() {
  14508. while (true) {
  14509. if (!entries.length) {
  14510. parsedRawLinesCallback();
  14511. return;
  14512. }
  14513. var line = entries.shift();
  14514. if (reComment.test(line)) continue;
  14515. if (extendedSyntax) {
  14516. match = reSection.exec(line);
  14517. if (match) {
  14518. currentLang = match[1].toLowerCase();
  14519. skipLang = currentLang !== '*' && currentLang !== lang &&
  14520. currentLang !== genericLang;
  14521. continue;
  14522. } else if (skipLang) {
  14523. continue;
  14524. }
  14525. match = reImport.exec(line);
  14526. if (match) {
  14527. loadImport(baseURL + match[1], nextEntry);
  14528. return;
  14529. }
  14530. }
  14531. var tmp = line.match(reSplit);
  14532. if (tmp && tmp.length == 3) {
  14533. dictionary[tmp[1]] = evalString(tmp[2]);
  14534. }
  14535. }
  14536. }
  14537. nextEntry();
  14538. }
  14539. function loadImport(url, callback) {
  14540. xhrLoadText(url, function(content) {
  14541. parseRawLines(content, false, callback);
  14542. }, function() {
  14543. console.warn(url + ' not found.');
  14544. callback();
  14545. });
  14546. }
  14547. parseRawLines(text, true, function() {
  14548. parsedPropertiesCallback(dictionary);
  14549. });
  14550. }
  14551. xhrLoadText(href, function(response) {
  14552. gTextData += response;
  14553. parseProperties(response, function(data) {
  14554. for (var key in data) {
  14555. var id,
  14556. prop,
  14557. index = key.lastIndexOf('.');
  14558. if (index > 0) {
  14559. id = key.substring(0, index);
  14560. prop = key.substring(index + 1);
  14561. } else {
  14562. id = key;
  14563. prop = gTextProp;
  14564. }
  14565. if (!gL10nData[id]) {
  14566. gL10nData[id] = {};
  14567. }
  14568. gL10nData[id][prop] = data[key];
  14569. }
  14570. if (successCallback) {
  14571. successCallback();
  14572. }
  14573. });
  14574. }, failureCallback);
  14575. }
  14576. function loadLocale(lang, callback) {
  14577. if (lang) {
  14578. lang = lang.toLowerCase();
  14579. }
  14580. callback = callback || function _callback() {};
  14581. clear();
  14582. gLanguage = lang;
  14583. var langLinks = getL10nResourceLinks();
  14584. var langCount = langLinks.length;
  14585. if (langCount === 0) {
  14586. var dict = getL10nDictionary();
  14587. if (dict && dict.locales && dict.default_locale) {
  14588. console.log('using the embedded JSON directory, early way out');
  14589. gL10nData = dict.locales[lang];
  14590. if (!gL10nData) {
  14591. var defaultLocale = dict.default_locale.toLowerCase();
  14592. for (var anyCaseLang in dict.locales) {
  14593. anyCaseLang = anyCaseLang.toLowerCase();
  14594. if (anyCaseLang === lang) {
  14595. gL10nData = dict.locales[lang];
  14596. break;
  14597. } else if (anyCaseLang === defaultLocale) {
  14598. gL10nData = dict.locales[defaultLocale];
  14599. }
  14600. }
  14601. }
  14602. callback();
  14603. } else {
  14604. console.log('no resource to load, early way out');
  14605. }
  14606. gReadyState = 'complete';
  14607. return;
  14608. }
  14609. var onResourceLoaded = null;
  14610. var gResourceCount = 0;
  14611. onResourceLoaded = function onResourceLoaded() {
  14612. gResourceCount++;
  14613. if (gResourceCount >= langCount) {
  14614. callback();
  14615. gReadyState = 'complete';
  14616. }
  14617. };
  14618. function L10nResourceLink(link) {
  14619. var href = link.href;
  14620. this.load = function(lang, callback) {
  14621. parseResource(href, lang, callback, function() {
  14622. console.warn(href + ' not found.');
  14623. console.warn('"' + lang + '" resource not found');
  14624. gLanguage = '';
  14625. callback();
  14626. });
  14627. };
  14628. }
  14629. for (var i = 0; i < langCount; i++) {
  14630. var resource = new L10nResourceLink(langLinks[i]);
  14631. resource.load(lang, onResourceLoaded);
  14632. }
  14633. }
  14634. function clear() {
  14635. gL10nData = {};
  14636. gTextData = '';
  14637. gLanguage = '';
  14638. }
  14639. function getPluralRules(lang) {
  14640. var locales2rules = {
  14641. 'af': 3,
  14642. 'ak': 4,
  14643. 'am': 4,
  14644. 'ar': 1,
  14645. 'asa': 3,
  14646. 'az': 0,
  14647. 'be': 11,
  14648. 'bem': 3,
  14649. 'bez': 3,
  14650. 'bg': 3,
  14651. 'bh': 4,
  14652. 'bm': 0,
  14653. 'bn': 3,
  14654. 'bo': 0,
  14655. 'br': 20,
  14656. 'brx': 3,
  14657. 'bs': 11,
  14658. 'ca': 3,
  14659. 'cgg': 3,
  14660. 'chr': 3,
  14661. 'cs': 12,
  14662. 'cy': 17,
  14663. 'da': 3,
  14664. 'de': 3,
  14665. 'dv': 3,
  14666. 'dz': 0,
  14667. 'ee': 3,
  14668. 'el': 3,
  14669. 'en': 3,
  14670. 'eo': 3,
  14671. 'es': 3,
  14672. 'et': 3,
  14673. 'eu': 3,
  14674. 'fa': 0,
  14675. 'ff': 5,
  14676. 'fi': 3,
  14677. 'fil': 4,
  14678. 'fo': 3,
  14679. 'fr': 5,
  14680. 'fur': 3,
  14681. 'fy': 3,
  14682. 'ga': 8,
  14683. 'gd': 24,
  14684. 'gl': 3,
  14685. 'gsw': 3,
  14686. 'gu': 3,
  14687. 'guw': 4,
  14688. 'gv': 23,
  14689. 'ha': 3,
  14690. 'haw': 3,
  14691. 'he': 2,
  14692. 'hi': 4,
  14693. 'hr': 11,
  14694. 'hu': 0,
  14695. 'id': 0,
  14696. 'ig': 0,
  14697. 'ii': 0,
  14698. 'is': 3,
  14699. 'it': 3,
  14700. 'iu': 7,
  14701. 'ja': 0,
  14702. 'jmc': 3,
  14703. 'jv': 0,
  14704. 'ka': 0,
  14705. 'kab': 5,
  14706. 'kaj': 3,
  14707. 'kcg': 3,
  14708. 'kde': 0,
  14709. 'kea': 0,
  14710. 'kk': 3,
  14711. 'kl': 3,
  14712. 'km': 0,
  14713. 'kn': 0,
  14714. 'ko': 0,
  14715. 'ksb': 3,
  14716. 'ksh': 21,
  14717. 'ku': 3,
  14718. 'kw': 7,
  14719. 'lag': 18,
  14720. 'lb': 3,
  14721. 'lg': 3,
  14722. 'ln': 4,
  14723. 'lo': 0,
  14724. 'lt': 10,
  14725. 'lv': 6,
  14726. 'mas': 3,
  14727. 'mg': 4,
  14728. 'mk': 16,
  14729. 'ml': 3,
  14730. 'mn': 3,
  14731. 'mo': 9,
  14732. 'mr': 3,
  14733. 'ms': 0,
  14734. 'mt': 15,
  14735. 'my': 0,
  14736. 'nah': 3,
  14737. 'naq': 7,
  14738. 'nb': 3,
  14739. 'nd': 3,
  14740. 'ne': 3,
  14741. 'nl': 3,
  14742. 'nn': 3,
  14743. 'no': 3,
  14744. 'nr': 3,
  14745. 'nso': 4,
  14746. 'ny': 3,
  14747. 'nyn': 3,
  14748. 'om': 3,
  14749. 'or': 3,
  14750. 'pa': 3,
  14751. 'pap': 3,
  14752. 'pl': 13,
  14753. 'ps': 3,
  14754. 'pt': 3,
  14755. 'rm': 3,
  14756. 'ro': 9,
  14757. 'rof': 3,
  14758. 'ru': 11,
  14759. 'rwk': 3,
  14760. 'sah': 0,
  14761. 'saq': 3,
  14762. 'se': 7,
  14763. 'seh': 3,
  14764. 'ses': 0,
  14765. 'sg': 0,
  14766. 'sh': 11,
  14767. 'shi': 19,
  14768. 'sk': 12,
  14769. 'sl': 14,
  14770. 'sma': 7,
  14771. 'smi': 7,
  14772. 'smj': 7,
  14773. 'smn': 7,
  14774. 'sms': 7,
  14775. 'sn': 3,
  14776. 'so': 3,
  14777. 'sq': 3,
  14778. 'sr': 11,
  14779. 'ss': 3,
  14780. 'ssy': 3,
  14781. 'st': 3,
  14782. 'sv': 3,
  14783. 'sw': 3,
  14784. 'syr': 3,
  14785. 'ta': 3,
  14786. 'te': 3,
  14787. 'teo': 3,
  14788. 'th': 0,
  14789. 'ti': 4,
  14790. 'tig': 3,
  14791. 'tk': 3,
  14792. 'tl': 4,
  14793. 'tn': 3,
  14794. 'to': 0,
  14795. 'tr': 0,
  14796. 'ts': 3,
  14797. 'tzm': 22,
  14798. 'uk': 11,
  14799. 'ur': 3,
  14800. 've': 3,
  14801. 'vi': 0,
  14802. 'vun': 3,
  14803. 'wa': 4,
  14804. 'wae': 3,
  14805. 'wo': 0,
  14806. 'xh': 3,
  14807. 'xog': 3,
  14808. 'yo': 0,
  14809. 'zh': 0,
  14810. 'zu': 3
  14811. };
  14812. function isIn(n, list) {
  14813. return list.indexOf(n) !== -1;
  14814. }
  14815. function isBetween(n, start, end) {
  14816. return start <= n && n <= end;
  14817. }
  14818. var pluralRules = {
  14819. '0': function _(n) {
  14820. return 'other';
  14821. },
  14822. '1': function _(n) {
  14823. if (isBetween(n % 100, 3, 10)) return 'few';
  14824. if (n === 0) return 'zero';
  14825. if (isBetween(n % 100, 11, 99)) return 'many';
  14826. if (n == 2) return 'two';
  14827. if (n == 1) return 'one';
  14828. return 'other';
  14829. },
  14830. '2': function _(n) {
  14831. if (n !== 0 && n % 10 === 0) return 'many';
  14832. if (n == 2) return 'two';
  14833. if (n == 1) return 'one';
  14834. return 'other';
  14835. },
  14836. '3': function _(n) {
  14837. if (n == 1) return 'one';
  14838. return 'other';
  14839. },
  14840. '4': function _(n) {
  14841. if (isBetween(n, 0, 1)) return 'one';
  14842. return 'other';
  14843. },
  14844. '5': function _(n) {
  14845. if (isBetween(n, 0, 2) && n != 2) return 'one';
  14846. return 'other';
  14847. },
  14848. '6': function _(n) {
  14849. if (n === 0) return 'zero';
  14850. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14851. return 'other';
  14852. },
  14853. '7': function _(n) {
  14854. if (n == 2) return 'two';
  14855. if (n == 1) return 'one';
  14856. return 'other';
  14857. },
  14858. '8': function _(n) {
  14859. if (isBetween(n, 3, 6)) return 'few';
  14860. if (isBetween(n, 7, 10)) return 'many';
  14861. if (n == 2) return 'two';
  14862. if (n == 1) return 'one';
  14863. return 'other';
  14864. },
  14865. '9': function _(n) {
  14866. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  14867. if (n == 1) return 'one';
  14868. return 'other';
  14869. },
  14870. '10': function _(n) {
  14871. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  14872. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  14873. return 'other';
  14874. },
  14875. '11': function _(n) {
  14876. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14877. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14))
  14878. return 'many';
  14879. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14880. return 'other';
  14881. },
  14882. '12': function _(n) {
  14883. if (isBetween(n, 2, 4)) return 'few';
  14884. if (n == 1) return 'one';
  14885. return 'other';
  14886. },
  14887. '13': function _(n) {
  14888. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14889. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) ||
  14890. isBetween(n % 100, 12, 14)) return 'many';
  14891. if (n == 1) return 'one';
  14892. return 'other';
  14893. },
  14894. '14': function _(n) {
  14895. if (isBetween(n % 100, 3, 4)) return 'few';
  14896. if (n % 100 == 2) return 'two';
  14897. if (n % 100 == 1) return 'one';
  14898. return 'other';
  14899. },
  14900. '15': function _(n) {
  14901. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  14902. if (isBetween(n % 100, 11, 19)) return 'many';
  14903. if (n == 1) return 'one';
  14904. return 'other';
  14905. },
  14906. '16': function _(n) {
  14907. if (n % 10 == 1 && n != 11) return 'one';
  14908. return 'other';
  14909. },
  14910. '17': function _(n) {
  14911. if (n == 3) return 'few';
  14912. if (n === 0) return 'zero';
  14913. if (n == 6) return 'many';
  14914. if (n == 2) return 'two';
  14915. if (n == 1) return 'one';
  14916. return 'other';
  14917. },
  14918. '18': function _(n) {
  14919. if (n === 0) return 'zero';
  14920. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  14921. return 'other';
  14922. },
  14923. '19': function _(n) {
  14924. if (isBetween(n, 2, 10)) return 'few';
  14925. if (isBetween(n, 0, 1)) return 'one';
  14926. return 'other';
  14927. },
  14928. '20': function _(n) {
  14929. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10,
  14930. 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99)))
  14931. return 'few';
  14932. if (n % 1000000 === 0 && n !== 0) return 'many';
  14933. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  14934. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  14935. return 'other';
  14936. },
  14937. '21': function _(n) {
  14938. if (n === 0) return 'zero';
  14939. if (n == 1) return 'one';
  14940. return 'other';
  14941. },
  14942. '22': function _(n) {
  14943. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  14944. return 'other';
  14945. },
  14946. '23': function _(n) {
  14947. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  14948. return 'other';
  14949. },
  14950. '24': function _(n) {
  14951. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  14952. if (isIn(n, [2, 12])) return 'two';
  14953. if (isIn(n, [1, 11])) return 'one';
  14954. return 'other';
  14955. }
  14956. };
  14957. var index = locales2rules[lang.replace(/-.*$/, '')];
  14958. if (!(index in pluralRules)) {
  14959. console.warn('plural form unknown for [' + lang + ']');
  14960. return function() {
  14961. return 'other';
  14962. };
  14963. }
  14964. return pluralRules[index];
  14965. }
  14966. gMacros.plural = function(str, param, key, prop) {
  14967. var n = parseFloat(param);
  14968. if (isNaN(n)) return str;
  14969. if (prop != gTextProp) return str;
  14970. if (!gMacros._pluralRules) {
  14971. gMacros._pluralRules = getPluralRules(gLanguage);
  14972. }
  14973. var index = '[' + gMacros._pluralRules(n) + ']';
  14974. if (n === 0 && key + '[zero]' in gL10nData) {
  14975. str = gL10nData[key + '[zero]'][prop];
  14976. } else if (n == 1 && key + '[one]' in gL10nData) {
  14977. str = gL10nData[key + '[one]'][prop];
  14978. } else if (n == 2 && key + '[two]' in gL10nData) {
  14979. str = gL10nData[key + '[two]'][prop];
  14980. } else if (key + index in gL10nData) {
  14981. str = gL10nData[key + index][prop];
  14982. } else if (key + '[other]' in gL10nData) {
  14983. str = gL10nData[key + '[other]'][prop];
  14984. }
  14985. return str;
  14986. };
  14987. function getL10nData(key, args, fallback) {
  14988. var data = gL10nData[key];
  14989. if (!data) {
  14990. // console.warn('#' + key + ' is undefined.');
  14991. if (!fallback) {
  14992. return null;
  14993. }
  14994. data = fallback;
  14995. }
  14996. var rv = {};
  14997. for (var prop in data) {
  14998. var str = data[prop];
  14999. str = substIndexes(str, args, key, prop);
  15000. str = substArguments(str, args, key);
  15001. rv[prop] = str;
  15002. }
  15003. return rv;
  15004. }
  15005. function substIndexes(str, args, key, prop) {
  15006. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15007. var reMatch = reIndex.exec(str);
  15008. if (!reMatch || !reMatch.length) return str;
  15009. var macroName = reMatch[1];
  15010. var paramName = reMatch[2];
  15011. var param;
  15012. if (args && paramName in args) {
  15013. param = args[paramName];
  15014. } else if (paramName in gL10nData) {
  15015. param = gL10nData[paramName];
  15016. }
  15017. if (macroName in gMacros) {
  15018. var macro = gMacros[macroName];
  15019. str = macro(str, param, key, prop);
  15020. }
  15021. return str;
  15022. }
  15023. function substArguments(str, args, key) {
  15024. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15025. return str.replace(reArgs, function(matched_text, arg) {
  15026. if (args && arg in args) {
  15027. return args[arg];
  15028. }
  15029. if (arg in gL10nData) {
  15030. return gL10nData[arg];
  15031. }
  15032. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15033. return matched_text;
  15034. });
  15035. }
  15036. function translateElement(element) {
  15037. var l10n = getL10nAttributes(element);
  15038. if (!l10n.id) return;
  15039. var data = getL10nData(l10n.id, l10n.args);
  15040. if (!data) {
  15041. // console.warn('#' + l10n.id + ' is undefined.');
  15042. return;
  15043. }
  15044. if (data[gTextProp]) {
  15045. if (getChildElementCount(element) === 0) {
  15046. element[gTextProp] = data[gTextProp];
  15047. } else {
  15048. var children = element.childNodes;
  15049. var found = false;
  15050. for (var i = 0, l = children.length; i < l; i++) {
  15051. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15052. if (found) {
  15053. children[i].nodeValue = '';
  15054. } else {
  15055. children[i].nodeValue = data[gTextProp];
  15056. found = true;
  15057. }
  15058. }
  15059. }
  15060. if (!found) {
  15061. var textNode = document.createTextNode(data[gTextProp]);
  15062. element.insertBefore(textNode, element.firstChild);
  15063. }
  15064. }
  15065. delete data[gTextProp];
  15066. }
  15067. for (var k in data) {
  15068. element[k] = data[k];
  15069. }
  15070. }
  15071. function getChildElementCount(element) {
  15072. if (element.children) {
  15073. return element.children.length;
  15074. }
  15075. if (typeof element.childElementCount !== 'undefined') {
  15076. return element.childElementCount;
  15077. }
  15078. var count = 0;
  15079. for (var i = 0; i < element.childNodes.length; i++) {
  15080. count += element.nodeType === 1 ? 1 : 0;
  15081. }
  15082. return count;
  15083. }
  15084. function translateFragment(element) {
  15085. element = element || document.documentElement;
  15086. var children = getTranslatableChildren(element);
  15087. var elementCount = children.length;
  15088. for (var i = 0; i < elementCount; i++) {
  15089. translateElement(children[i]);
  15090. }
  15091. translateElement(element);
  15092. }
  15093. return {
  15094. get: function get(key, args, fallbackString) {
  15095. var index = key.lastIndexOf('.');
  15096. var prop = gTextProp;
  15097. if (index > 0) {
  15098. prop = key.substring(index + 1);
  15099. key = key.substring(0, index);
  15100. }
  15101. var fallback;
  15102. if (fallbackString) {
  15103. fallback = {};
  15104. fallback[prop] = fallbackString;
  15105. }
  15106. var data = getL10nData(key, args, fallback);
  15107. if (data && prop in data) {
  15108. return data[prop];
  15109. }
  15110. return '{{' + key + '}}';
  15111. },
  15112. getData: function getData() {
  15113. return gL10nData;
  15114. },
  15115. getText: function getText() {
  15116. return gTextData;
  15117. },
  15118. getLanguage: function getLanguage() {
  15119. return gLanguage;
  15120. },
  15121. setLanguage: function setLanguage(lang, callback) {
  15122. loadLocale(lang, function() {
  15123. if (callback) callback();
  15124. });
  15125. },
  15126. getDirection: function getDirection() {
  15127. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15128. var shortCode = gLanguage.split('-', 1)[0];
  15129. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15130. },
  15131. translate: translateFragment,
  15132. getReadyState: function getReadyState() {
  15133. return gReadyState;
  15134. },
  15135. ready: function ready(callback) {
  15136. if (!callback) {
  15137. return;
  15138. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15139. window.setTimeout(function() {
  15140. callback();
  15141. });
  15142. } else if (document.addEventListener) {
  15143. document.addEventListener('localized', function once() {
  15144. document.removeEventListener('localized', once);
  15145. callback();
  15146. });
  15147. }
  15148. }
  15149. };
  15150. }(window, document);
  15151. /***/
  15152. }),
  15153. /* 41 */
  15154. /***/
  15155. (function(module, exports, __webpack_require__) {
  15156. "use strict";
  15157. Object.defineProperty(exports, "__esModule", {
  15158. value: true
  15159. });
  15160. exports.PDFPrintService = PDFPrintService;
  15161. var _ui_utils = __webpack_require__(5);
  15162. var _app = __webpack_require__(1);
  15163. var _app_options = __webpack_require__(6);
  15164. var activeService = null;
  15165. var overlayManager = null;
  15166. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  15167. var scratchCanvas = activeService.scratchCanvas;
  15168. var PRINT_RESOLUTION = _app_options.AppOptions.get('printResolution') || 150;
  15169. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  15170. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15171. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15172. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  15173. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  15174. var ctx = scratchCanvas.getContext('2d');
  15175. ctx.save();
  15176. ctx.fillStyle = 'rgb(255, 255, 255)';
  15177. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15178. ctx.restore();
  15179. return pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  15180. var renderContext = {
  15181. canvasContext: ctx,
  15182. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15183. viewport: pdfPage.getViewport({
  15184. scale: 1,
  15185. rotation: size.rotation
  15186. }),
  15187. intent: 'print'
  15188. };
  15189. return pdfPage.render(renderContext).promise;
  15190. }).then(function() {
  15191. return {
  15192. width: width,
  15193. height: height
  15194. };
  15195. });
  15196. }
  15197. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  15198. this.pdfDocument = pdfDocument;
  15199. this.pagesOverview = pagesOverview;
  15200. this.printContainer = printContainer;
  15201. this.l10n = l10n || _ui_utils.NullL10n;
  15202. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  15203. this.currentPage = -1;
  15204. this.scratchCanvas = document.createElement('canvas');
  15205. }
  15206. PDFPrintService.prototype = {
  15207. layout: function layout() {
  15208. this.throwIfInactive();
  15209. var body = document.querySelector('body');
  15210. body.setAttribute('data-pdfjsprinting', true);
  15211. var hasEqualPageSizes = this.pagesOverview.every(function(size) {
  15212. return size.width === this.pagesOverview[0].width && size.height === this
  15213. .pagesOverview[0].height;
  15214. }, this);
  15215. if (!hasEqualPageSizes) {
  15216. console.warn('Not all pages have the same size. The printed ' +
  15217. 'result may be incorrect!');
  15218. }
  15219. this.pageStyleSheet = document.createElement('style');
  15220. var pageSize = this.pagesOverview[0];
  15221. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' +
  15222. '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  15223. body.appendChild(this.pageStyleSheet);
  15224. },
  15225. destroy: function destroy() {
  15226. if (activeService !== this) {
  15227. return;
  15228. }
  15229. this.printContainer.textContent = '';
  15230. var body = document.querySelector('body');
  15231. body.removeAttribute('data-pdfjsprinting');
  15232. if (this.pageStyleSheet) {
  15233. this.pageStyleSheet.remove();
  15234. this.pageStyleSheet = null;
  15235. }
  15236. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15237. this.scratchCanvas = null;
  15238. activeService = null;
  15239. ensureOverlay().then(function() {
  15240. if (overlayManager.active !== 'printServiceOverlay') {
  15241. return;
  15242. }
  15243. overlayManager.close('printServiceOverlay');
  15244. });
  15245. },
  15246. renderPages: function renderPages() {
  15247. var _this = this;
  15248. var pageCount = this.pagesOverview.length;
  15249. var renderNextPage = function renderNextPage(resolve, reject) {
  15250. _this.throwIfInactive();
  15251. if (++_this.currentPage >= pageCount) {
  15252. renderProgress(pageCount, pageCount, _this.l10n);
  15253. resolve();
  15254. return;
  15255. }
  15256. var index = _this.currentPage;
  15257. renderProgress(index, pageCount, _this.l10n);
  15258. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index])
  15259. .then(_this.useRenderedPage.bind(_this)).then(function() {
  15260. renderNextPage(resolve, reject);
  15261. }, reject);
  15262. };
  15263. return new Promise(renderNextPage);
  15264. },
  15265. useRenderedPage: function useRenderedPage(printItem) {
  15266. this.throwIfInactive();
  15267. var img = document.createElement('img');
  15268. img.style.width = printItem.width;
  15269. img.style.height = printItem.height;
  15270. var scratchCanvas = this.scratchCanvas;
  15271. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  15272. scratchCanvas.toBlob(function(blob) {
  15273. img.src = URL.createObjectURL(blob);
  15274. });
  15275. } else {
  15276. img.src = scratchCanvas.toDataURL();
  15277. }
  15278. var wrapper = document.createElement('div');
  15279. wrapper.appendChild(img);
  15280. this.printContainer.appendChild(wrapper);
  15281. return new Promise(function(resolve, reject) {
  15282. img.onload = resolve;
  15283. img.onerror = reject;
  15284. });
  15285. },
  15286. performPrint: function performPrint() {
  15287. var _this2 = this;
  15288. this.throwIfInactive();
  15289. return new Promise(function(resolve) {
  15290. setTimeout(function() {
  15291. if (!_this2.active) {
  15292. resolve();
  15293. return;
  15294. }
  15295. print.call(window);
  15296. setTimeout(resolve, 20);
  15297. }, 0);
  15298. });
  15299. },
  15300. get active() {
  15301. return this === activeService;
  15302. },
  15303. throwIfInactive: function throwIfInactive() {
  15304. if (!this.active) {
  15305. throw new Error('This print request was cancelled or completed.');
  15306. }
  15307. }
  15308. };
  15309. var print = window.print;
  15310. window.print = function print() {
  15311. if (activeService) {
  15312. console.warn('Ignored window.print() because of a pending print job.');
  15313. return;
  15314. }
  15315. ensureOverlay().then(function() {
  15316. if (activeService) {
  15317. overlayManager.open('printServiceOverlay');
  15318. }
  15319. });
  15320. try {
  15321. dispatchEvent('beforeprint');
  15322. } finally {
  15323. if (!activeService) {
  15324. console.error('Expected print service to be initialized.');
  15325. ensureOverlay().then(function() {
  15326. if (overlayManager.active === 'printServiceOverlay') {
  15327. overlayManager.close('printServiceOverlay');
  15328. }
  15329. });
  15330. return;
  15331. }
  15332. var activeServiceOnEntry = activeService;
  15333. activeService.renderPages().then(function() {
  15334. return activeServiceOnEntry.performPrint();
  15335. })["catch"](function() {}).then(function() {
  15336. if (activeServiceOnEntry.active) {
  15337. abort();
  15338. }
  15339. });
  15340. }
  15341. };
  15342. function dispatchEvent(eventType) {
  15343. var event = document.createEvent('CustomEvent');
  15344. event.initCustomEvent(eventType, false, false, 'custom');
  15345. window.dispatchEvent(event);
  15346. }
  15347. function abort() {
  15348. if (activeService) {
  15349. activeService.destroy();
  15350. dispatchEvent('afterprint');
  15351. }
  15352. }
  15353. function renderProgress(index, total, l10n) {
  15354. var progressContainer = document.getElementById('printServiceOverlay');
  15355. var progress = Math.round(100 * index / total);
  15356. var progressBar = progressContainer.querySelector('progress');
  15357. var progressPerc = progressContainer.querySelector('.relative-progress');
  15358. progressBar.value = progress;
  15359. l10n.get('print_progress_percent', {
  15360. progress: progress
  15361. }, progress + '%').then(function(msg) {
  15362. progressPerc.textContent = msg;
  15363. });
  15364. }
  15365. var hasAttachEvent = !!document.attachEvent;
  15366. window.addEventListener('keydown', function(event) {
  15367. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event
  15368. .shiftKey || window.chrome || window.opera)) {
  15369. window.print();
  15370. if (hasAttachEvent) {
  15371. return;
  15372. }
  15373. event.preventDefault();
  15374. if (event.stopImmediatePropagation) {
  15375. event.stopImmediatePropagation();
  15376. } else {
  15377. event.stopPropagation();
  15378. }
  15379. }
  15380. }, true);
  15381. if (hasAttachEvent) {
  15382. document.attachEvent('onkeydown', function(event) {
  15383. event = event || window.event;
  15384. if (event.keyCode === 80 && event.ctrlKey) {
  15385. event.keyCode = 0;
  15386. return false;
  15387. }
  15388. });
  15389. }
  15390. if ('onbeforeprint' in window) {
  15391. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  15392. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  15393. event.stopImmediatePropagation();
  15394. }
  15395. };
  15396. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  15397. window.addEventListener('afterprint', stopPropagationIfNeeded);
  15398. }
  15399. var overlayPromise;
  15400. function ensureOverlay() {
  15401. if (!overlayPromise) {
  15402. overlayManager = _app.PDFViewerApplication.overlayManager;
  15403. if (!overlayManager) {
  15404. throw new Error('The overlay manager has not yet been initialized.');
  15405. }
  15406. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById(
  15407. 'printServiceOverlay'), abort, true);
  15408. document.getElementById('printCancel').onclick = abort;
  15409. }
  15410. return overlayPromise;
  15411. }
  15412. _app.PDFPrintServiceFactory.instance = {
  15413. supportsPrinting: true,
  15414. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer,
  15415. l10n) {
  15416. if (activeService) {
  15417. throw new Error('The print service is created and active.');
  15418. }
  15419. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  15420. return activeService;
  15421. }
  15422. };
  15423. /***/
  15424. })
  15425. /******/
  15426. ]);
  15427. //# sourceMappingURL=viewer.js.map