pdf_viewer.js 218 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677
  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. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. Object.defineProperty(exports, "__esModule", {
  123. value: true
  124. });
  125. Object.defineProperty(exports, "AnnotationLayerBuilder", {
  126. enumerable: true,
  127. get: function get() {
  128. return _annotation_layer_builder.AnnotationLayerBuilder;
  129. }
  130. });
  131. Object.defineProperty(exports, "DefaultAnnotationLayerFactory", {
  132. enumerable: true,
  133. get: function get() {
  134. return _annotation_layer_builder.DefaultAnnotationLayerFactory;
  135. }
  136. });
  137. Object.defineProperty(exports, "DefaultTextLayerFactory", {
  138. enumerable: true,
  139. get: function get() {
  140. return _text_layer_builder.DefaultTextLayerFactory;
  141. }
  142. });
  143. Object.defineProperty(exports, "TextLayerBuilder", {
  144. enumerable: true,
  145. get: function get() {
  146. return _text_layer_builder.TextLayerBuilder;
  147. }
  148. });
  149. Object.defineProperty(exports, "EventBus", {
  150. enumerable: true,
  151. get: function get() {
  152. return _ui_utils.EventBus;
  153. }
  154. });
  155. Object.defineProperty(exports, "NullL10n", {
  156. enumerable: true,
  157. get: function get() {
  158. return _ui_utils.NullL10n;
  159. }
  160. });
  161. Object.defineProperty(exports, "ProgressBar", {
  162. enumerable: true,
  163. get: function get() {
  164. return _ui_utils.ProgressBar;
  165. }
  166. });
  167. Object.defineProperty(exports, "PDFLinkService", {
  168. enumerable: true,
  169. get: function get() {
  170. return _pdf_link_service.PDFLinkService;
  171. }
  172. });
  173. Object.defineProperty(exports, "SimpleLinkService", {
  174. enumerable: true,
  175. get: function get() {
  176. return _pdf_link_service.SimpleLinkService;
  177. }
  178. });
  179. Object.defineProperty(exports, "DownloadManager", {
  180. enumerable: true,
  181. get: function get() {
  182. return _download_manager.DownloadManager;
  183. }
  184. });
  185. Object.defineProperty(exports, "GenericL10n", {
  186. enumerable: true,
  187. get: function get() {
  188. return _genericl10n.GenericL10n;
  189. }
  190. });
  191. Object.defineProperty(exports, "PDFFindController", {
  192. enumerable: true,
  193. get: function get() {
  194. return _pdf_find_controller.PDFFindController;
  195. }
  196. });
  197. Object.defineProperty(exports, "PDFHistory", {
  198. enumerable: true,
  199. get: function get() {
  200. return _pdf_history.PDFHistory;
  201. }
  202. });
  203. Object.defineProperty(exports, "PDFPageView", {
  204. enumerable: true,
  205. get: function get() {
  206. return _pdf_page_view.PDFPageView;
  207. }
  208. });
  209. Object.defineProperty(exports, "PDFSinglePageViewer", {
  210. enumerable: true,
  211. get: function get() {
  212. return _pdf_single_page_viewer.PDFSinglePageViewer;
  213. }
  214. });
  215. Object.defineProperty(exports, "PDFViewer", {
  216. enumerable: true,
  217. get: function get() {
  218. return _pdf_viewer.PDFViewer;
  219. }
  220. });
  221. var _annotation_layer_builder = __w_pdfjs_require__(1);
  222. var _text_layer_builder = __w_pdfjs_require__(8);
  223. var _ui_utils = __w_pdfjs_require__(3);
  224. var _pdf_link_service = __w_pdfjs_require__(7);
  225. var _download_manager = __w_pdfjs_require__(9);
  226. var _genericl10n = __w_pdfjs_require__(10);
  227. var _pdf_find_controller = __w_pdfjs_require__(12);
  228. var _pdf_history = __w_pdfjs_require__(14);
  229. var _pdf_page_view = __w_pdfjs_require__(15);
  230. var _pdf_single_page_viewer = __w_pdfjs_require__(18);
  231. var _pdf_viewer = __w_pdfjs_require__(20);
  232. var pdfjsVersion = '2.3.200';
  233. var pdfjsBuild = '4ae3f9fc';
  234. (0, _ui_utils.getGlobalEventBus)(true);
  235. /***/ }),
  236. /* 1 */
  237. /***/ (function(module, exports, __w_pdfjs_require__) {
  238. "use strict";
  239. Object.defineProperty(exports, "__esModule", {
  240. value: true
  241. });
  242. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  243. var _pdfjsLib = __w_pdfjs_require__(2);
  244. var _ui_utils = __w_pdfjs_require__(3);
  245. var _pdf_link_service = __w_pdfjs_require__(7);
  246. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  247. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  248. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  249. var AnnotationLayerBuilder =
  250. /*#__PURE__*/
  251. function () {
  252. function AnnotationLayerBuilder(_ref) {
  253. var pageDiv = _ref.pageDiv,
  254. pdfPage = _ref.pdfPage,
  255. linkService = _ref.linkService,
  256. downloadManager = _ref.downloadManager,
  257. _ref$imageResourcesPa = _ref.imageResourcesPath,
  258. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  259. _ref$renderInteractiv = _ref.renderInteractiveForms,
  260. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  261. _ref$l10n = _ref.l10n,
  262. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  263. _classCallCheck(this, AnnotationLayerBuilder);
  264. this.pageDiv = pageDiv;
  265. this.pdfPage = pdfPage;
  266. this.linkService = linkService;
  267. this.downloadManager = downloadManager;
  268. this.imageResourcesPath = imageResourcesPath;
  269. this.renderInteractiveForms = renderInteractiveForms;
  270. this.l10n = l10n;
  271. this.div = null;
  272. this._cancelled = false;
  273. }
  274. _createClass(AnnotationLayerBuilder, [{
  275. key: "render",
  276. value: function render(viewport) {
  277. var _this = this;
  278. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  279. this.pdfPage.getAnnotations({
  280. intent: intent
  281. }).then(function (annotations) {
  282. if (_this._cancelled) {
  283. return;
  284. }
  285. var parameters = {
  286. viewport: viewport.clone({
  287. dontFlip: true
  288. }),
  289. div: _this.div,
  290. annotations: annotations,
  291. page: _this.pdfPage,
  292. imageResourcesPath: _this.imageResourcesPath,
  293. renderInteractiveForms: _this.renderInteractiveForms,
  294. linkService: _this.linkService,
  295. downloadManager: _this.downloadManager
  296. };
  297. if (_this.div) {
  298. _pdfjsLib.AnnotationLayer.update(parameters);
  299. } else {
  300. if (annotations.length === 0) {
  301. return;
  302. }
  303. _this.div = document.createElement('div');
  304. _this.div.className = 'annotationLayer';
  305. _this.pageDiv.appendChild(_this.div);
  306. parameters.div = _this.div;
  307. _pdfjsLib.AnnotationLayer.render(parameters);
  308. _this.l10n.translate(_this.div);
  309. }
  310. });
  311. }
  312. }, {
  313. key: "cancel",
  314. value: function cancel() {
  315. this._cancelled = true;
  316. }
  317. }, {
  318. key: "hide",
  319. value: function hide() {
  320. if (!this.div) {
  321. return;
  322. }
  323. this.div.setAttribute('hidden', 'true');
  324. }
  325. }]);
  326. return AnnotationLayerBuilder;
  327. }();
  328. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  329. var DefaultAnnotationLayerFactory =
  330. /*#__PURE__*/
  331. function () {
  332. function DefaultAnnotationLayerFactory() {
  333. _classCallCheck(this, DefaultAnnotationLayerFactory);
  334. }
  335. _createClass(DefaultAnnotationLayerFactory, [{
  336. key: "createAnnotationLayerBuilder",
  337. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  338. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  339. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  340. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  341. return new AnnotationLayerBuilder({
  342. pageDiv: pageDiv,
  343. pdfPage: pdfPage,
  344. imageResourcesPath: imageResourcesPath,
  345. renderInteractiveForms: renderInteractiveForms,
  346. linkService: new _pdf_link_service.SimpleLinkService(),
  347. l10n: l10n
  348. });
  349. }
  350. }]);
  351. return DefaultAnnotationLayerFactory;
  352. }();
  353. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  354. /***/ }),
  355. /* 2 */
  356. /***/ (function(module, exports, __w_pdfjs_require__) {
  357. "use strict";
  358. var pdfjsLib;
  359. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  360. pdfjsLib = window['pdfjs-dist/build/pdf'];
  361. } else {
  362. pdfjsLib = require('../build/pdf.js');
  363. }
  364. module.exports = pdfjsLib;
  365. /***/ }),
  366. /* 3 */
  367. /***/ (function(module, exports, __w_pdfjs_require__) {
  368. "use strict";
  369. Object.defineProperty(exports, "__esModule", {
  370. value: true
  371. });
  372. exports.isValidRotation = isValidRotation;
  373. exports.isValidScrollMode = isValidScrollMode;
  374. exports.isValidSpreadMode = isValidSpreadMode;
  375. exports.isPortraitOrientation = isPortraitOrientation;
  376. exports.getGlobalEventBus = getGlobalEventBus;
  377. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  378. exports.noContextMenuHandler = noContextMenuHandler;
  379. exports.parseQueryString = parseQueryString;
  380. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  381. exports.getVisibleElements = getVisibleElements;
  382. exports.roundToDivide = roundToDivide;
  383. exports.getPageSizeInches = getPageSizeInches;
  384. exports.approximateFraction = approximateFraction;
  385. exports.getOutputScale = getOutputScale;
  386. exports.scrollIntoView = scrollIntoView;
  387. exports.watchScroll = watchScroll;
  388. exports.binarySearchFirstItem = binarySearchFirstItem;
  389. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  390. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  391. exports.moveToEndOfArray = moveToEndOfArray;
  392. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
  393. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  394. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  395. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  396. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  397. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  398. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  399. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  400. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  401. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  402. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  403. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  404. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  405. var CSS_UNITS = 96.0 / 72.0;
  406. exports.CSS_UNITS = CSS_UNITS;
  407. var DEFAULT_SCALE_VALUE = 'auto';
  408. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  409. var DEFAULT_SCALE = 1.0;
  410. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  411. var MIN_SCALE = 0.10;
  412. exports.MIN_SCALE = MIN_SCALE;
  413. var MAX_SCALE = 10.0;
  414. exports.MAX_SCALE = MAX_SCALE;
  415. var UNKNOWN_SCALE = 0;
  416. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  417. var MAX_AUTO_SCALE = 1.25;
  418. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  419. var SCROLLBAR_PADDING = 40;
  420. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  421. var VERTICAL_PADDING = 5;
  422. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  423. var PresentationModeState = {
  424. UNKNOWN: 0,
  425. NORMAL: 1,
  426. CHANGING: 2,
  427. FULLSCREEN: 3
  428. };
  429. exports.PresentationModeState = PresentationModeState;
  430. var RendererType = {
  431. CANVAS: 'canvas',
  432. SVG: 'svg'
  433. };
  434. exports.RendererType = RendererType;
  435. var TextLayerMode = {
  436. DISABLE: 0,
  437. ENABLE: 1,
  438. ENABLE_ENHANCE: 2
  439. };
  440. exports.TextLayerMode = TextLayerMode;
  441. var ScrollMode = {
  442. UNKNOWN: -1,
  443. VERTICAL: 0,
  444. HORIZONTAL: 1,
  445. WRAPPED: 2
  446. };
  447. exports.ScrollMode = ScrollMode;
  448. var SpreadMode = {
  449. UNKNOWN: -1,
  450. NONE: 0,
  451. ODD: 1,
  452. EVEN: 2
  453. };
  454. exports.SpreadMode = SpreadMode;
  455. function formatL10nValue(text, args) {
  456. if (!args) {
  457. return text;
  458. }
  459. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  460. return name in args ? args[name] : '{{' + name + '}}';
  461. });
  462. }
  463. var NullL10n = {
  464. getLanguage: function () {
  465. var _getLanguage = _asyncToGenerator(
  466. /*#__PURE__*/
  467. _regenerator["default"].mark(function _callee() {
  468. return _regenerator["default"].wrap(function _callee$(_context) {
  469. while (1) {
  470. switch (_context.prev = _context.next) {
  471. case 0:
  472. return _context.abrupt("return", 'en-us');
  473. case 1:
  474. case "end":
  475. return _context.stop();
  476. }
  477. }
  478. }, _callee);
  479. }));
  480. function getLanguage() {
  481. return _getLanguage.apply(this, arguments);
  482. }
  483. return getLanguage;
  484. }(),
  485. getDirection: function () {
  486. var _getDirection = _asyncToGenerator(
  487. /*#__PURE__*/
  488. _regenerator["default"].mark(function _callee2() {
  489. return _regenerator["default"].wrap(function _callee2$(_context2) {
  490. while (1) {
  491. switch (_context2.prev = _context2.next) {
  492. case 0:
  493. return _context2.abrupt("return", 'ltr');
  494. case 1:
  495. case "end":
  496. return _context2.stop();
  497. }
  498. }
  499. }, _callee2);
  500. }));
  501. function getDirection() {
  502. return _getDirection.apply(this, arguments);
  503. }
  504. return getDirection;
  505. }(),
  506. get: function () {
  507. var _get = _asyncToGenerator(
  508. /*#__PURE__*/
  509. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  510. return _regenerator["default"].wrap(function _callee3$(_context3) {
  511. while (1) {
  512. switch (_context3.prev = _context3.next) {
  513. case 0:
  514. return _context3.abrupt("return", formatL10nValue(fallback, args));
  515. case 1:
  516. case "end":
  517. return _context3.stop();
  518. }
  519. }
  520. }, _callee3);
  521. }));
  522. function get(_x, _x2, _x3) {
  523. return _get.apply(this, arguments);
  524. }
  525. return get;
  526. }(),
  527. translate: function () {
  528. var _translate = _asyncToGenerator(
  529. /*#__PURE__*/
  530. _regenerator["default"].mark(function _callee4(element) {
  531. return _regenerator["default"].wrap(function _callee4$(_context4) {
  532. while (1) {
  533. switch (_context4.prev = _context4.next) {
  534. case 0:
  535. case "end":
  536. return _context4.stop();
  537. }
  538. }
  539. }, _callee4);
  540. }));
  541. function translate(_x4) {
  542. return _translate.apply(this, arguments);
  543. }
  544. return translate;
  545. }()
  546. };
  547. exports.NullL10n = NullL10n;
  548. function getOutputScale(ctx) {
  549. var devicePixelRatio = window.devicePixelRatio || 1;
  550. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  551. var pixelRatio = devicePixelRatio / backingStoreRatio;
  552. return {
  553. sx: pixelRatio,
  554. sy: pixelRatio,
  555. scaled: pixelRatio !== 1
  556. };
  557. }
  558. function scrollIntoView(element, spot) {
  559. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  560. var parent = element.offsetParent;
  561. if (!parent) {
  562. console.error('offsetParent is not set -- cannot scroll');
  563. return;
  564. }
  565. var offsetY = element.offsetTop + element.clientTop;
  566. var offsetX = element.offsetLeft + element.clientLeft;
  567. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  568. if (parent.dataset._scaleY) {
  569. offsetY /= parent.dataset._scaleY;
  570. offsetX /= parent.dataset._scaleX;
  571. }
  572. offsetY += parent.offsetTop;
  573. offsetX += parent.offsetLeft;
  574. parent = parent.offsetParent;
  575. if (!parent) {
  576. return;
  577. }
  578. }
  579. if (spot) {
  580. if (spot.top !== undefined) {
  581. offsetY += spot.top;
  582. }
  583. if (spot.left !== undefined) {
  584. offsetX += spot.left;
  585. parent.scrollLeft = offsetX;
  586. }
  587. }
  588. parent.scrollTop = offsetY;
  589. }
  590. function watchScroll(viewAreaElement, callback) {
  591. var debounceScroll = function debounceScroll(evt) {
  592. if (rAF) {
  593. return;
  594. }
  595. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  596. rAF = null;
  597. var currentX = viewAreaElement.scrollLeft;
  598. var lastX = state.lastX;
  599. if (currentX !== lastX) {
  600. state.right = currentX > lastX;
  601. }
  602. state.lastX = currentX;
  603. var currentY = viewAreaElement.scrollTop;
  604. var lastY = state.lastY;
  605. if (currentY !== lastY) {
  606. state.down = currentY > lastY;
  607. }
  608. state.lastY = currentY;
  609. callback(state);
  610. });
  611. };
  612. var state = {
  613. right: true,
  614. down: true,
  615. lastX: viewAreaElement.scrollLeft,
  616. lastY: viewAreaElement.scrollTop,
  617. _eventHandler: debounceScroll
  618. };
  619. var rAF = null;
  620. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  621. return state;
  622. }
  623. function parseQueryString(query) {
  624. var parts = query.split('&');
  625. var params = Object.create(null);
  626. for (var i = 0, ii = parts.length; i < ii; ++i) {
  627. var param = parts[i].split('=');
  628. var key = param[0].toLowerCase();
  629. var value = param.length > 1 ? param[1] : null;
  630. params[decodeURIComponent(key)] = decodeURIComponent(value);
  631. }
  632. return params;
  633. }
  634. function binarySearchFirstItem(items, condition) {
  635. var minIndex = 0;
  636. var maxIndex = items.length - 1;
  637. if (items.length === 0 || !condition(items[maxIndex])) {
  638. return items.length;
  639. }
  640. if (condition(items[minIndex])) {
  641. return minIndex;
  642. }
  643. while (minIndex < maxIndex) {
  644. var currentIndex = minIndex + maxIndex >> 1;
  645. var currentItem = items[currentIndex];
  646. if (condition(currentItem)) {
  647. maxIndex = currentIndex;
  648. } else {
  649. minIndex = currentIndex + 1;
  650. }
  651. }
  652. return minIndex;
  653. }
  654. function approximateFraction(x) {
  655. if (Math.floor(x) === x) {
  656. return [x, 1];
  657. }
  658. var xinv = 1 / x;
  659. var limit = 8;
  660. if (xinv > limit) {
  661. return [1, limit];
  662. } else if (Math.floor(xinv) === xinv) {
  663. return [1, xinv];
  664. }
  665. var x_ = x > 1 ? xinv : x;
  666. var a = 0,
  667. b = 1,
  668. c = 1,
  669. d = 1;
  670. while (true) {
  671. var p = a + c,
  672. q = b + d;
  673. if (q > limit) {
  674. break;
  675. }
  676. if (x_ <= p / q) {
  677. c = p;
  678. d = q;
  679. } else {
  680. a = p;
  681. b = q;
  682. }
  683. }
  684. var result;
  685. if (x_ - a / b < c / d - x_) {
  686. result = x_ === x ? [a, b] : [b, a];
  687. } else {
  688. result = x_ === x ? [c, d] : [d, c];
  689. }
  690. return result;
  691. }
  692. function roundToDivide(x, div) {
  693. var r = x % div;
  694. return r === 0 ? x : Math.round(x - r + div);
  695. }
  696. function getPageSizeInches(_ref) {
  697. var view = _ref.view,
  698. userUnit = _ref.userUnit,
  699. rotate = _ref.rotate;
  700. var _view = _slicedToArray(view, 4),
  701. x1 = _view[0],
  702. y1 = _view[1],
  703. x2 = _view[2],
  704. y2 = _view[3];
  705. var changeOrientation = rotate % 180 !== 0;
  706. var width = (x2 - x1) / 72 * userUnit;
  707. var height = (y2 - y1) / 72 * userUnit;
  708. return {
  709. width: changeOrientation ? height : width,
  710. height: changeOrientation ? width : height
  711. };
  712. }
  713. function backtrackBeforeAllVisibleElements(index, views, top) {
  714. if (index < 2) {
  715. return index;
  716. }
  717. var elt = views[index].div;
  718. var pageTop = elt.offsetTop + elt.clientTop;
  719. if (pageTop >= top) {
  720. elt = views[index - 1].div;
  721. pageTop = elt.offsetTop + elt.clientTop;
  722. }
  723. for (var i = index - 2; i >= 0; --i) {
  724. elt = views[i].div;
  725. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  726. break;
  727. }
  728. index = i;
  729. }
  730. return index;
  731. }
  732. function getVisibleElements(scrollEl, views) {
  733. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  734. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  735. var top = scrollEl.scrollTop,
  736. bottom = top + scrollEl.clientHeight;
  737. var left = scrollEl.scrollLeft,
  738. right = left + scrollEl.clientWidth;
  739. function isElementBottomAfterViewTop(view) {
  740. var element = view.div;
  741. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  742. return elementBottom > top;
  743. }
  744. function isElementRightAfterViewLeft(view) {
  745. var element = view.div;
  746. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  747. return elementRight > left;
  748. }
  749. var visible = [],
  750. numViews = views.length;
  751. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  752. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  753. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  754. }
  755. var lastEdge = horizontal ? right : -1;
  756. for (var i = firstVisibleElementInd; i < numViews; i++) {
  757. var view = views[i],
  758. element = view.div;
  759. var currentWidth = element.offsetLeft + element.clientLeft;
  760. var currentHeight = element.offsetTop + element.clientTop;
  761. var viewWidth = element.clientWidth,
  762. viewHeight = element.clientHeight;
  763. var viewRight = currentWidth + viewWidth;
  764. var viewBottom = currentHeight + viewHeight;
  765. if (lastEdge === -1) {
  766. if (viewBottom >= bottom) {
  767. lastEdge = viewBottom;
  768. }
  769. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  770. break;
  771. }
  772. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  773. continue;
  774. }
  775. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  776. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  777. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  778. visible.push({
  779. id: view.id,
  780. x: currentWidth,
  781. y: currentHeight,
  782. view: view,
  783. percent: percent
  784. });
  785. }
  786. var first = visible[0],
  787. last = visible[visible.length - 1];
  788. if (sortByVisibility) {
  789. visible.sort(function (a, b) {
  790. var pc = a.percent - b.percent;
  791. if (Math.abs(pc) > 0.001) {
  792. return -pc;
  793. }
  794. return a.id - b.id;
  795. });
  796. }
  797. return {
  798. first: first,
  799. last: last,
  800. views: visible
  801. };
  802. }
  803. function noContextMenuHandler(evt) {
  804. evt.preventDefault();
  805. }
  806. function isDataSchema(url) {
  807. var i = 0,
  808. ii = url.length;
  809. while (i < ii && url[i].trim() === '') {
  810. i++;
  811. }
  812. return url.substring(i, i + 5).toLowerCase() === 'data:';
  813. }
  814. function getPDFFileNameFromURL(url) {
  815. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  816. if (typeof url !== 'string') {
  817. return defaultFilename;
  818. }
  819. if (isDataSchema(url)) {
  820. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  821. return defaultFilename;
  822. }
  823. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  824. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  825. var splitURI = reURI.exec(url);
  826. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  827. if (suggestedFilename) {
  828. suggestedFilename = suggestedFilename[0];
  829. if (suggestedFilename.includes('%')) {
  830. try {
  831. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  832. } catch (ex) {}
  833. }
  834. }
  835. return suggestedFilename || defaultFilename;
  836. }
  837. function normalizeWheelEventDelta(evt) {
  838. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  839. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  840. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  841. delta = -delta;
  842. }
  843. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  844. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  845. var MOUSE_PIXELS_PER_LINE = 30;
  846. var MOUSE_LINES_PER_PAGE = 30;
  847. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  848. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  849. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  850. delta /= MOUSE_LINES_PER_PAGE;
  851. }
  852. return delta;
  853. }
  854. function isValidRotation(angle) {
  855. return Number.isInteger(angle) && angle % 90 === 0;
  856. }
  857. function isValidScrollMode(mode) {
  858. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  859. }
  860. function isValidSpreadMode(mode) {
  861. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  862. }
  863. function isPortraitOrientation(size) {
  864. return size.width <= size.height;
  865. }
  866. var WaitOnType = {
  867. EVENT: 'event',
  868. TIMEOUT: 'timeout'
  869. };
  870. exports.WaitOnType = WaitOnType;
  871. function waitOnEventOrTimeout(_ref2) {
  872. var target = _ref2.target,
  873. name = _ref2.name,
  874. _ref2$delay = _ref2.delay,
  875. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  876. return new Promise(function (resolve, reject) {
  877. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  878. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  879. }
  880. function handler(type) {
  881. if (target instanceof EventBus) {
  882. target.off(name, eventHandler);
  883. } else {
  884. target.removeEventListener(name, eventHandler);
  885. }
  886. if (timeout) {
  887. clearTimeout(timeout);
  888. }
  889. resolve(type);
  890. }
  891. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  892. if (target instanceof EventBus) {
  893. target.on(name, eventHandler);
  894. } else {
  895. target.addEventListener(name, eventHandler);
  896. }
  897. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  898. var timeout = setTimeout(timeoutHandler, delay);
  899. });
  900. }
  901. var animationStarted = new Promise(function (resolve) {
  902. window.requestAnimationFrame(resolve);
  903. });
  904. exports.animationStarted = animationStarted;
  905. var EventBus =
  906. /*#__PURE__*/
  907. function () {
  908. function EventBus() {
  909. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  910. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  911. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  912. _classCallCheck(this, EventBus);
  913. this._listeners = Object.create(null);
  914. this._dispatchToDOM = dispatchToDOM === true;
  915. }
  916. _createClass(EventBus, [{
  917. key: "on",
  918. value: function on(eventName, listener) {
  919. var eventListeners = this._listeners[eventName];
  920. if (!eventListeners) {
  921. eventListeners = [];
  922. this._listeners[eventName] = eventListeners;
  923. }
  924. eventListeners.push(listener);
  925. }
  926. }, {
  927. key: "off",
  928. value: function off(eventName, listener) {
  929. var eventListeners = this._listeners[eventName];
  930. var i;
  931. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  932. return;
  933. }
  934. eventListeners.splice(i, 1);
  935. }
  936. }, {
  937. key: "dispatch",
  938. value: function dispatch(eventName) {
  939. var eventListeners = this._listeners[eventName];
  940. if (!eventListeners || eventListeners.length === 0) {
  941. if (this._dispatchToDOM) {
  942. var _args5 = Array.prototype.slice.call(arguments, 1);
  943. this._dispatchDOMEvent(eventName, _args5);
  944. }
  945. return;
  946. }
  947. var args = Array.prototype.slice.call(arguments, 1);
  948. eventListeners.slice(0).forEach(function (listener) {
  949. listener.apply(null, args);
  950. });
  951. if (this._dispatchToDOM) {
  952. this._dispatchDOMEvent(eventName, args);
  953. }
  954. }
  955. }, {
  956. key: "_dispatchDOMEvent",
  957. value: function _dispatchDOMEvent(eventName) {
  958. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  959. var details = Object.create(null);
  960. if (args && args.length > 0) {
  961. var obj = args[0];
  962. for (var key in obj) {
  963. var value = obj[key];
  964. if (key === 'source') {
  965. if (value === window || value === document) {
  966. return;
  967. }
  968. continue;
  969. }
  970. details[key] = value;
  971. }
  972. }
  973. var event = document.createEvent('CustomEvent');
  974. event.initCustomEvent(eventName, true, true, details);
  975. document.dispatchEvent(event);
  976. }
  977. }]);
  978. return EventBus;
  979. }();
  980. exports.EventBus = EventBus;
  981. var globalEventBus = null;
  982. function getGlobalEventBus() {
  983. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  984. if (!globalEventBus) {
  985. globalEventBus = new EventBus({
  986. dispatchToDOM: dispatchToDOM
  987. });
  988. }
  989. return globalEventBus;
  990. }
  991. function clamp(v, min, max) {
  992. return Math.min(Math.max(v, min), max);
  993. }
  994. var ProgressBar =
  995. /*#__PURE__*/
  996. function () {
  997. function ProgressBar(id) {
  998. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  999. height = _ref4.height,
  1000. width = _ref4.width,
  1001. units = _ref4.units;
  1002. _classCallCheck(this, ProgressBar);
  1003. this.visible = true;
  1004. this.div = document.querySelector(id + ' .progress');
  1005. this.bar = this.div.parentNode;
  1006. this.height = height || 100;
  1007. this.width = width || 100;
  1008. this.units = units || '%';
  1009. this.div.style.height = this.height + this.units;
  1010. this.percent = 0;
  1011. }
  1012. _createClass(ProgressBar, [{
  1013. key: "_updateBar",
  1014. value: function _updateBar() {
  1015. if (this._indeterminate) {
  1016. this.div.classList.add('indeterminate');
  1017. this.div.style.width = this.width + this.units;
  1018. return;
  1019. }
  1020. this.div.classList.remove('indeterminate');
  1021. var progressSize = this.width * this._percent / 100;
  1022. this.div.style.width = progressSize + this.units;
  1023. }
  1024. }, {
  1025. key: "setWidth",
  1026. value: function setWidth(viewer) {
  1027. if (!viewer) {
  1028. return;
  1029. }
  1030. var container = viewer.parentNode;
  1031. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  1032. if (scrollbarWidth > 0) {
  1033. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  1034. }
  1035. }
  1036. }, {
  1037. key: "hide",
  1038. value: function hide() {
  1039. if (!this.visible) {
  1040. return;
  1041. }
  1042. this.visible = false;
  1043. this.bar.classList.add('hidden');
  1044. document.body.classList.remove('loadingInProgress');
  1045. }
  1046. }, {
  1047. key: "show",
  1048. value: function show() {
  1049. if (this.visible) {
  1050. return;
  1051. }
  1052. this.visible = true;
  1053. document.body.classList.add('loadingInProgress');
  1054. this.bar.classList.remove('hidden');
  1055. }
  1056. }, {
  1057. key: "percent",
  1058. get: function get() {
  1059. return this._percent;
  1060. },
  1061. set: function set(val) {
  1062. this._indeterminate = isNaN(val);
  1063. this._percent = clamp(val, 0, 100);
  1064. this._updateBar();
  1065. }
  1066. }]);
  1067. return ProgressBar;
  1068. }();
  1069. exports.ProgressBar = ProgressBar;
  1070. function moveToEndOfArray(arr, condition) {
  1071. var moved = [],
  1072. len = arr.length;
  1073. var write = 0;
  1074. for (var read = 0; read < len; ++read) {
  1075. if (condition(arr[read])) {
  1076. moved.push(arr[read]);
  1077. } else {
  1078. arr[write] = arr[read];
  1079. ++write;
  1080. }
  1081. }
  1082. for (var _read = 0; write < len; ++_read, ++write) {
  1083. arr[write] = moved[_read];
  1084. }
  1085. }
  1086. /***/ }),
  1087. /* 4 */
  1088. /***/ (function(module, exports, __w_pdfjs_require__) {
  1089. "use strict";
  1090. module.exports = __w_pdfjs_require__(5);
  1091. /***/ }),
  1092. /* 5 */
  1093. /***/ (function(module, exports, __w_pdfjs_require__) {
  1094. "use strict";
  1095. /* WEBPACK VAR INJECTION */(function(module) {
  1096. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1097. var runtime = function (exports) {
  1098. "use strict";
  1099. var Op = Object.prototype;
  1100. var hasOwn = Op.hasOwnProperty;
  1101. var undefined;
  1102. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  1103. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  1104. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  1105. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  1106. function wrap(innerFn, outerFn, self, tryLocsList) {
  1107. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  1108. var generator = Object.create(protoGenerator.prototype);
  1109. var context = new Context(tryLocsList || []);
  1110. generator._invoke = makeInvokeMethod(innerFn, self, context);
  1111. return generator;
  1112. }
  1113. exports.wrap = wrap;
  1114. function tryCatch(fn, obj, arg) {
  1115. try {
  1116. return {
  1117. type: "normal",
  1118. arg: fn.call(obj, arg)
  1119. };
  1120. } catch (err) {
  1121. return {
  1122. type: "throw",
  1123. arg: err
  1124. };
  1125. }
  1126. }
  1127. var GenStateSuspendedStart = "suspendedStart";
  1128. var GenStateSuspendedYield = "suspendedYield";
  1129. var GenStateExecuting = "executing";
  1130. var GenStateCompleted = "completed";
  1131. var ContinueSentinel = {};
  1132. function Generator() {}
  1133. function GeneratorFunction() {}
  1134. function GeneratorFunctionPrototype() {}
  1135. var IteratorPrototype = {};
  1136. IteratorPrototype[iteratorSymbol] = function () {
  1137. return this;
  1138. };
  1139. var getProto = Object.getPrototypeOf;
  1140. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1141. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  1142. IteratorPrototype = NativeIteratorPrototype;
  1143. }
  1144. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  1145. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  1146. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  1147. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  1148. function defineIteratorMethods(prototype) {
  1149. ["next", "throw", "return"].forEach(function (method) {
  1150. prototype[method] = function (arg) {
  1151. return this._invoke(method, arg);
  1152. };
  1153. });
  1154. }
  1155. exports.isGeneratorFunction = function (genFun) {
  1156. var ctor = typeof genFun === "function" && genFun.constructor;
  1157. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  1158. };
  1159. exports.mark = function (genFun) {
  1160. if (Object.setPrototypeOf) {
  1161. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  1162. } else {
  1163. genFun.__proto__ = GeneratorFunctionPrototype;
  1164. if (!(toStringTagSymbol in genFun)) {
  1165. genFun[toStringTagSymbol] = "GeneratorFunction";
  1166. }
  1167. }
  1168. genFun.prototype = Object.create(Gp);
  1169. return genFun;
  1170. };
  1171. exports.awrap = function (arg) {
  1172. return {
  1173. __await: arg
  1174. };
  1175. };
  1176. function AsyncIterator(generator) {
  1177. function invoke(method, arg, resolve, reject) {
  1178. var record = tryCatch(generator[method], generator, arg);
  1179. if (record.type === "throw") {
  1180. reject(record.arg);
  1181. } else {
  1182. var result = record.arg;
  1183. var value = result.value;
  1184. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  1185. return Promise.resolve(value.__await).then(function (value) {
  1186. invoke("next", value, resolve, reject);
  1187. }, function (err) {
  1188. invoke("throw", err, resolve, reject);
  1189. });
  1190. }
  1191. return Promise.resolve(value).then(function (unwrapped) {
  1192. result.value = unwrapped;
  1193. resolve(result);
  1194. }, function (error) {
  1195. return invoke("throw", error, resolve, reject);
  1196. });
  1197. }
  1198. }
  1199. var previousPromise;
  1200. function enqueue(method, arg) {
  1201. function callInvokeWithMethodAndArg() {
  1202. return new Promise(function (resolve, reject) {
  1203. invoke(method, arg, resolve, reject);
  1204. });
  1205. }
  1206. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1207. }
  1208. this._invoke = enqueue;
  1209. }
  1210. defineIteratorMethods(AsyncIterator.prototype);
  1211. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  1212. return this;
  1213. };
  1214. exports.AsyncIterator = AsyncIterator;
  1215. exports.async = function (innerFn, outerFn, self, tryLocsList) {
  1216. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  1217. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  1218. return result.done ? result.value : iter.next();
  1219. });
  1220. };
  1221. function makeInvokeMethod(innerFn, self, context) {
  1222. var state = GenStateSuspendedStart;
  1223. return function invoke(method, arg) {
  1224. if (state === GenStateExecuting) {
  1225. throw new Error("Generator is already running");
  1226. }
  1227. if (state === GenStateCompleted) {
  1228. if (method === "throw") {
  1229. throw arg;
  1230. }
  1231. return doneResult();
  1232. }
  1233. context.method = method;
  1234. context.arg = arg;
  1235. while (true) {
  1236. var delegate = context.delegate;
  1237. if (delegate) {
  1238. var delegateResult = maybeInvokeDelegate(delegate, context);
  1239. if (delegateResult) {
  1240. if (delegateResult === ContinueSentinel) continue;
  1241. return delegateResult;
  1242. }
  1243. }
  1244. if (context.method === "next") {
  1245. context.sent = context._sent = context.arg;
  1246. } else if (context.method === "throw") {
  1247. if (state === GenStateSuspendedStart) {
  1248. state = GenStateCompleted;
  1249. throw context.arg;
  1250. }
  1251. context.dispatchException(context.arg);
  1252. } else if (context.method === "return") {
  1253. context.abrupt("return", context.arg);
  1254. }
  1255. state = GenStateExecuting;
  1256. var record = tryCatch(innerFn, self, context);
  1257. if (record.type === "normal") {
  1258. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  1259. if (record.arg === ContinueSentinel) {
  1260. continue;
  1261. }
  1262. return {
  1263. value: record.arg,
  1264. done: context.done
  1265. };
  1266. } else if (record.type === "throw") {
  1267. state = GenStateCompleted;
  1268. context.method = "throw";
  1269. context.arg = record.arg;
  1270. }
  1271. }
  1272. };
  1273. }
  1274. function maybeInvokeDelegate(delegate, context) {
  1275. var method = delegate.iterator[context.method];
  1276. if (method === undefined) {
  1277. context.delegate = null;
  1278. if (context.method === "throw") {
  1279. if (delegate.iterator["return"]) {
  1280. context.method = "return";
  1281. context.arg = undefined;
  1282. maybeInvokeDelegate(delegate, context);
  1283. if (context.method === "throw") {
  1284. return ContinueSentinel;
  1285. }
  1286. }
  1287. context.method = "throw";
  1288. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1289. }
  1290. return ContinueSentinel;
  1291. }
  1292. var record = tryCatch(method, delegate.iterator, context.arg);
  1293. if (record.type === "throw") {
  1294. context.method = "throw";
  1295. context.arg = record.arg;
  1296. context.delegate = null;
  1297. return ContinueSentinel;
  1298. }
  1299. var info = record.arg;
  1300. if (!info) {
  1301. context.method = "throw";
  1302. context.arg = new TypeError("iterator result is not an object");
  1303. context.delegate = null;
  1304. return ContinueSentinel;
  1305. }
  1306. if (info.done) {
  1307. context[delegate.resultName] = info.value;
  1308. context.next = delegate.nextLoc;
  1309. if (context.method !== "return") {
  1310. context.method = "next";
  1311. context.arg = undefined;
  1312. }
  1313. } else {
  1314. return info;
  1315. }
  1316. context.delegate = null;
  1317. return ContinueSentinel;
  1318. }
  1319. defineIteratorMethods(Gp);
  1320. Gp[toStringTagSymbol] = "Generator";
  1321. Gp[iteratorSymbol] = function () {
  1322. return this;
  1323. };
  1324. Gp.toString = function () {
  1325. return "[object Generator]";
  1326. };
  1327. function pushTryEntry(locs) {
  1328. var entry = {
  1329. tryLoc: locs[0]
  1330. };
  1331. if (1 in locs) {
  1332. entry.catchLoc = locs[1];
  1333. }
  1334. if (2 in locs) {
  1335. entry.finallyLoc = locs[2];
  1336. entry.afterLoc = locs[3];
  1337. }
  1338. this.tryEntries.push(entry);
  1339. }
  1340. function resetTryEntry(entry) {
  1341. var record = entry.completion || {};
  1342. record.type = "normal";
  1343. delete record.arg;
  1344. entry.completion = record;
  1345. }
  1346. function Context(tryLocsList) {
  1347. this.tryEntries = [{
  1348. tryLoc: "root"
  1349. }];
  1350. tryLocsList.forEach(pushTryEntry, this);
  1351. this.reset(true);
  1352. }
  1353. exports.keys = function (object) {
  1354. var keys = [];
  1355. for (var key in object) {
  1356. keys.push(key);
  1357. }
  1358. keys.reverse();
  1359. return function next() {
  1360. while (keys.length) {
  1361. var key = keys.pop();
  1362. if (key in object) {
  1363. next.value = key;
  1364. next.done = false;
  1365. return next;
  1366. }
  1367. }
  1368. next.done = true;
  1369. return next;
  1370. };
  1371. };
  1372. function values(iterable) {
  1373. if (iterable) {
  1374. var iteratorMethod = iterable[iteratorSymbol];
  1375. if (iteratorMethod) {
  1376. return iteratorMethod.call(iterable);
  1377. }
  1378. if (typeof iterable.next === "function") {
  1379. return iterable;
  1380. }
  1381. if (!isNaN(iterable.length)) {
  1382. var i = -1,
  1383. next = function next() {
  1384. while (++i < iterable.length) {
  1385. if (hasOwn.call(iterable, i)) {
  1386. next.value = iterable[i];
  1387. next.done = false;
  1388. return next;
  1389. }
  1390. }
  1391. next.value = undefined;
  1392. next.done = true;
  1393. return next;
  1394. };
  1395. return next.next = next;
  1396. }
  1397. }
  1398. return {
  1399. next: doneResult
  1400. };
  1401. }
  1402. exports.values = values;
  1403. function doneResult() {
  1404. return {
  1405. value: undefined,
  1406. done: true
  1407. };
  1408. }
  1409. Context.prototype = {
  1410. constructor: Context,
  1411. reset: function reset(skipTempReset) {
  1412. this.prev = 0;
  1413. this.next = 0;
  1414. this.sent = this._sent = undefined;
  1415. this.done = false;
  1416. this.delegate = null;
  1417. this.method = "next";
  1418. this.arg = undefined;
  1419. this.tryEntries.forEach(resetTryEntry);
  1420. if (!skipTempReset) {
  1421. for (var name in this) {
  1422. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  1423. this[name] = undefined;
  1424. }
  1425. }
  1426. }
  1427. },
  1428. stop: function stop() {
  1429. this.done = true;
  1430. var rootEntry = this.tryEntries[0];
  1431. var rootRecord = rootEntry.completion;
  1432. if (rootRecord.type === "throw") {
  1433. throw rootRecord.arg;
  1434. }
  1435. return this.rval;
  1436. },
  1437. dispatchException: function dispatchException(exception) {
  1438. if (this.done) {
  1439. throw exception;
  1440. }
  1441. var context = this;
  1442. function handle(loc, caught) {
  1443. record.type = "throw";
  1444. record.arg = exception;
  1445. context.next = loc;
  1446. if (caught) {
  1447. context.method = "next";
  1448. context.arg = undefined;
  1449. }
  1450. return !!caught;
  1451. }
  1452. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1453. var entry = this.tryEntries[i];
  1454. var record = entry.completion;
  1455. if (entry.tryLoc === "root") {
  1456. return handle("end");
  1457. }
  1458. if (entry.tryLoc <= this.prev) {
  1459. var hasCatch = hasOwn.call(entry, "catchLoc");
  1460. var hasFinally = hasOwn.call(entry, "finallyLoc");
  1461. if (hasCatch && hasFinally) {
  1462. if (this.prev < entry.catchLoc) {
  1463. return handle(entry.catchLoc, true);
  1464. } else if (this.prev < entry.finallyLoc) {
  1465. return handle(entry.finallyLoc);
  1466. }
  1467. } else if (hasCatch) {
  1468. if (this.prev < entry.catchLoc) {
  1469. return handle(entry.catchLoc, true);
  1470. }
  1471. } else if (hasFinally) {
  1472. if (this.prev < entry.finallyLoc) {
  1473. return handle(entry.finallyLoc);
  1474. }
  1475. } else {
  1476. throw new Error("try statement without catch or finally");
  1477. }
  1478. }
  1479. }
  1480. },
  1481. abrupt: function abrupt(type, arg) {
  1482. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1483. var entry = this.tryEntries[i];
  1484. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1485. var finallyEntry = entry;
  1486. break;
  1487. }
  1488. }
  1489. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  1490. finallyEntry = null;
  1491. }
  1492. var record = finallyEntry ? finallyEntry.completion : {};
  1493. record.type = type;
  1494. record.arg = arg;
  1495. if (finallyEntry) {
  1496. this.method = "next";
  1497. this.next = finallyEntry.finallyLoc;
  1498. return ContinueSentinel;
  1499. }
  1500. return this.complete(record);
  1501. },
  1502. complete: function complete(record, afterLoc) {
  1503. if (record.type === "throw") {
  1504. throw record.arg;
  1505. }
  1506. if (record.type === "break" || record.type === "continue") {
  1507. this.next = record.arg;
  1508. } else if (record.type === "return") {
  1509. this.rval = this.arg = record.arg;
  1510. this.method = "return";
  1511. this.next = "end";
  1512. } else if (record.type === "normal" && afterLoc) {
  1513. this.next = afterLoc;
  1514. }
  1515. return ContinueSentinel;
  1516. },
  1517. finish: function finish(finallyLoc) {
  1518. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1519. var entry = this.tryEntries[i];
  1520. if (entry.finallyLoc === finallyLoc) {
  1521. this.complete(entry.completion, entry.afterLoc);
  1522. resetTryEntry(entry);
  1523. return ContinueSentinel;
  1524. }
  1525. }
  1526. },
  1527. "catch": function _catch(tryLoc) {
  1528. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1529. var entry = this.tryEntries[i];
  1530. if (entry.tryLoc === tryLoc) {
  1531. var record = entry.completion;
  1532. if (record.type === "throw") {
  1533. var thrown = record.arg;
  1534. resetTryEntry(entry);
  1535. }
  1536. return thrown;
  1537. }
  1538. }
  1539. throw new Error("illegal catch attempt");
  1540. },
  1541. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  1542. this.delegate = {
  1543. iterator: values(iterable),
  1544. resultName: resultName,
  1545. nextLoc: nextLoc
  1546. };
  1547. if (this.method === "next") {
  1548. this.arg = undefined;
  1549. }
  1550. return ContinueSentinel;
  1551. }
  1552. };
  1553. return exports;
  1554. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  1555. try {
  1556. regeneratorRuntime = runtime;
  1557. } catch (accidentalStrictMode) {
  1558. Function("r", "regeneratorRuntime = r")(runtime);
  1559. }
  1560. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(6)(module)))
  1561. /***/ }),
  1562. /* 6 */
  1563. /***/ (function(module, exports, __w_pdfjs_require__) {
  1564. "use strict";
  1565. module.exports = function (module) {
  1566. if (!module.webpackPolyfill) {
  1567. module.deprecate = function () {};
  1568. module.paths = [];
  1569. if (!module.children) module.children = [];
  1570. Object.defineProperty(module, "loaded", {
  1571. enumerable: true,
  1572. get: function get() {
  1573. return module.l;
  1574. }
  1575. });
  1576. Object.defineProperty(module, "id", {
  1577. enumerable: true,
  1578. get: function get() {
  1579. return module.i;
  1580. }
  1581. });
  1582. module.webpackPolyfill = 1;
  1583. }
  1584. return module;
  1585. };
  1586. /***/ }),
  1587. /* 7 */
  1588. /***/ (function(module, exports, __w_pdfjs_require__) {
  1589. "use strict";
  1590. Object.defineProperty(exports, "__esModule", {
  1591. value: true
  1592. });
  1593. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  1594. var _ui_utils = __w_pdfjs_require__(3);
  1595. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1596. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1597. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1598. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1599. var PDFLinkService =
  1600. /*#__PURE__*/
  1601. function () {
  1602. function PDFLinkService() {
  1603. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1604. eventBus = _ref.eventBus,
  1605. _ref$externalLinkTarg = _ref.externalLinkTarget,
  1606. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  1607. _ref$externalLinkRel = _ref.externalLinkRel,
  1608. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  1609. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  1610. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab;
  1611. _classCallCheck(this, PDFLinkService);
  1612. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  1613. this.externalLinkTarget = externalLinkTarget;
  1614. this.externalLinkRel = externalLinkRel;
  1615. this.externalLinkEnabled = externalLinkEnabled;
  1616. this.baseUrl = null;
  1617. this.pdfDocument = null;
  1618. this.pdfViewer = null;
  1619. this.pdfHistory = null;
  1620. this._pagesRefCache = null;
  1621. }
  1622. _createClass(PDFLinkService, [{
  1623. key: "setDocument",
  1624. value: function setDocument(pdfDocument) {
  1625. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1626. this.baseUrl = baseUrl;
  1627. this.pdfDocument = pdfDocument;
  1628. this._pagesRefCache = Object.create(null);
  1629. }
  1630. }, {
  1631. key: "setViewer",
  1632. value: function setViewer(pdfViewer) {
  1633. this.pdfViewer = pdfViewer;
  1634. }
  1635. }, {
  1636. key: "setHistory",
  1637. value: function setHistory(pdfHistory) {
  1638. this.pdfHistory = pdfHistory;
  1639. }
  1640. }, {
  1641. key: "navigateTo",
  1642. value: function navigateTo(dest) {
  1643. var _this = this;
  1644. var goToDestination = function goToDestination(_ref2) {
  1645. var namedDest = _ref2.namedDest,
  1646. explicitDest = _ref2.explicitDest;
  1647. var destRef = explicitDest[0],
  1648. pageNumber;
  1649. if (destRef instanceof Object) {
  1650. pageNumber = _this._cachedPageNumber(destRef);
  1651. if (pageNumber === null) {
  1652. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  1653. _this.cachePageRef(pageIndex + 1, destRef);
  1654. goToDestination({
  1655. namedDest: namedDest,
  1656. explicitDest: explicitDest
  1657. });
  1658. })["catch"](function () {
  1659. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  1660. });
  1661. return;
  1662. }
  1663. } else if (Number.isInteger(destRef)) {
  1664. pageNumber = destRef + 1;
  1665. } else {
  1666. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  1667. return;
  1668. }
  1669. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  1670. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  1671. return;
  1672. }
  1673. if (_this.pdfHistory) {
  1674. _this.pdfHistory.pushCurrentPosition();
  1675. _this.pdfHistory.push({
  1676. namedDest: namedDest,
  1677. explicitDest: explicitDest,
  1678. pageNumber: pageNumber
  1679. });
  1680. }
  1681. _this.pdfViewer.scrollPageIntoView({
  1682. pageNumber: pageNumber,
  1683. destArray: explicitDest
  1684. });
  1685. };
  1686. new Promise(function (resolve, reject) {
  1687. if (typeof dest === 'string') {
  1688. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  1689. resolve({
  1690. namedDest: dest,
  1691. explicitDest: destArray
  1692. });
  1693. });
  1694. return;
  1695. }
  1696. resolve({
  1697. namedDest: '',
  1698. explicitDest: dest
  1699. });
  1700. }).then(function (data) {
  1701. if (!Array.isArray(data.explicitDest)) {
  1702. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  1703. return;
  1704. }
  1705. goToDestination(data);
  1706. });
  1707. }
  1708. }, {
  1709. key: "getDestinationHash",
  1710. value: function getDestinationHash(dest) {
  1711. if (typeof dest === 'string') {
  1712. return this.getAnchorUrl('#' + escape(dest));
  1713. }
  1714. if (Array.isArray(dest)) {
  1715. var str = JSON.stringify(dest);
  1716. return this.getAnchorUrl('#' + escape(str));
  1717. }
  1718. return this.getAnchorUrl('');
  1719. }
  1720. }, {
  1721. key: "getAnchorUrl",
  1722. value: function getAnchorUrl(anchor) {
  1723. return (this.baseUrl || '') + anchor;
  1724. }
  1725. }, {
  1726. key: "setHash",
  1727. value: function setHash(hash) {
  1728. var pageNumber, dest;
  1729. if (hash.includes('=')) {
  1730. var params = (0, _ui_utils.parseQueryString)(hash);
  1731. if ('search' in params) {
  1732. this.eventBus.dispatch('findfromurlhash', {
  1733. source: this,
  1734. query: params['search'].replace(/"/g, ''),
  1735. phraseSearch: params['phrase'] === 'true'
  1736. });
  1737. }
  1738. if ('nameddest' in params) {
  1739. this.navigateTo(params.nameddest);
  1740. return;
  1741. }
  1742. if ('page' in params) {
  1743. pageNumber = params.page | 0 || 1;
  1744. }
  1745. if ('zoom' in params) {
  1746. var zoomArgs = params.zoom.split(',');
  1747. var zoomArg = zoomArgs[0];
  1748. var zoomArgNumber = parseFloat(zoomArg);
  1749. if (!zoomArg.includes('Fit')) {
  1750. dest = [null, {
  1751. name: 'XYZ'
  1752. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1753. } else {
  1754. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  1755. dest = [null, {
  1756. name: zoomArg
  1757. }];
  1758. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  1759. dest = [null, {
  1760. name: zoomArg
  1761. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1762. } else if (zoomArg === 'FitR') {
  1763. if (zoomArgs.length !== 5) {
  1764. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1765. } else {
  1766. dest = [null, {
  1767. name: zoomArg
  1768. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1769. }
  1770. } else {
  1771. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
  1772. }
  1773. }
  1774. }
  1775. if (dest) {
  1776. this.pdfViewer.scrollPageIntoView({
  1777. pageNumber: pageNumber || this.page,
  1778. destArray: dest,
  1779. allowNegativeOffset: true
  1780. });
  1781. } else if (pageNumber) {
  1782. this.page = pageNumber;
  1783. }
  1784. if ('pagemode' in params) {
  1785. this.eventBus.dispatch('pagemode', {
  1786. source: this,
  1787. mode: params.pagemode
  1788. });
  1789. }
  1790. } else {
  1791. dest = unescape(hash);
  1792. try {
  1793. dest = JSON.parse(dest);
  1794. if (!Array.isArray(dest)) {
  1795. dest = dest.toString();
  1796. }
  1797. } catch (ex) {}
  1798. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  1799. this.navigateTo(dest);
  1800. return;
  1801. }
  1802. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
  1803. }
  1804. }
  1805. }, {
  1806. key: "executeNamedAction",
  1807. value: function executeNamedAction(action) {
  1808. switch (action) {
  1809. case 'GoBack':
  1810. if (this.pdfHistory) {
  1811. this.pdfHistory.back();
  1812. }
  1813. break;
  1814. case 'GoForward':
  1815. if (this.pdfHistory) {
  1816. this.pdfHistory.forward();
  1817. }
  1818. break;
  1819. case 'NextPage':
  1820. if (this.page < this.pagesCount) {
  1821. this.page++;
  1822. }
  1823. break;
  1824. case 'PrevPage':
  1825. if (this.page > 1) {
  1826. this.page--;
  1827. }
  1828. break;
  1829. case 'LastPage':
  1830. this.page = this.pagesCount;
  1831. break;
  1832. case 'FirstPage':
  1833. this.page = 1;
  1834. break;
  1835. default:
  1836. break;
  1837. }
  1838. this.eventBus.dispatch('namedaction', {
  1839. source: this,
  1840. action: action
  1841. });
  1842. }
  1843. }, {
  1844. key: "cachePageRef",
  1845. value: function cachePageRef(pageNum, pageRef) {
  1846. if (!pageRef) {
  1847. return;
  1848. }
  1849. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1850. this._pagesRefCache[refStr] = pageNum;
  1851. }
  1852. }, {
  1853. key: "_cachedPageNumber",
  1854. value: function _cachedPageNumber(pageRef) {
  1855. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1856. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1857. }
  1858. }, {
  1859. key: "isPageVisible",
  1860. value: function isPageVisible(pageNumber) {
  1861. return this.pdfViewer.isPageVisible(pageNumber);
  1862. }
  1863. }, {
  1864. key: "pagesCount",
  1865. get: function get() {
  1866. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1867. }
  1868. }, {
  1869. key: "page",
  1870. get: function get() {
  1871. return this.pdfViewer.currentPageNumber;
  1872. },
  1873. set: function set(value) {
  1874. this.pdfViewer.currentPageNumber = value;
  1875. }
  1876. }, {
  1877. key: "rotation",
  1878. get: function get() {
  1879. return this.pdfViewer.pagesRotation;
  1880. },
  1881. set: function set(value) {
  1882. this.pdfViewer.pagesRotation = value;
  1883. }
  1884. }]);
  1885. return PDFLinkService;
  1886. }();
  1887. exports.PDFLinkService = PDFLinkService;
  1888. function isValidExplicitDestination(dest) {
  1889. if (!Array.isArray(dest)) {
  1890. return false;
  1891. }
  1892. var destLength = dest.length,
  1893. allowNull = true;
  1894. if (destLength < 2) {
  1895. return false;
  1896. }
  1897. var page = dest[0];
  1898. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1899. return false;
  1900. }
  1901. var zoom = dest[1];
  1902. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  1903. return false;
  1904. }
  1905. switch (zoom.name) {
  1906. case 'XYZ':
  1907. if (destLength !== 5) {
  1908. return false;
  1909. }
  1910. break;
  1911. case 'Fit':
  1912. case 'FitB':
  1913. return destLength === 2;
  1914. case 'FitH':
  1915. case 'FitBH':
  1916. case 'FitV':
  1917. case 'FitBV':
  1918. if (destLength !== 3) {
  1919. return false;
  1920. }
  1921. break;
  1922. case 'FitR':
  1923. if (destLength !== 6) {
  1924. return false;
  1925. }
  1926. allowNull = false;
  1927. break;
  1928. default:
  1929. return false;
  1930. }
  1931. for (var i = 2; i < destLength; i++) {
  1932. var param = dest[i];
  1933. if (!(typeof param === 'number' || allowNull && param === null)) {
  1934. return false;
  1935. }
  1936. }
  1937. return true;
  1938. }
  1939. var SimpleLinkService =
  1940. /*#__PURE__*/
  1941. function () {
  1942. function SimpleLinkService() {
  1943. _classCallCheck(this, SimpleLinkService);
  1944. this.externalLinkTarget = null;
  1945. this.externalLinkRel = null;
  1946. this.externalLinkEnabled = true;
  1947. }
  1948. _createClass(SimpleLinkService, [{
  1949. key: "navigateTo",
  1950. value: function navigateTo(dest) {}
  1951. }, {
  1952. key: "getDestinationHash",
  1953. value: function getDestinationHash(dest) {
  1954. return '#';
  1955. }
  1956. }, {
  1957. key: "getAnchorUrl",
  1958. value: function getAnchorUrl(hash) {
  1959. return '#';
  1960. }
  1961. }, {
  1962. key: "setHash",
  1963. value: function setHash(hash) {}
  1964. }, {
  1965. key: "executeNamedAction",
  1966. value: function executeNamedAction(action) {}
  1967. }, {
  1968. key: "cachePageRef",
  1969. value: function cachePageRef(pageNum, pageRef) {}
  1970. }, {
  1971. key: "isPageVisible",
  1972. value: function isPageVisible(pageNumber) {
  1973. return true;
  1974. }
  1975. }, {
  1976. key: "pagesCount",
  1977. get: function get() {
  1978. return 0;
  1979. }
  1980. }, {
  1981. key: "page",
  1982. get: function get() {
  1983. return 0;
  1984. },
  1985. set: function set(value) {}
  1986. }, {
  1987. key: "rotation",
  1988. get: function get() {
  1989. return 0;
  1990. },
  1991. set: function set(value) {}
  1992. }]);
  1993. return SimpleLinkService;
  1994. }();
  1995. exports.SimpleLinkService = SimpleLinkService;
  1996. /***/ }),
  1997. /* 8 */
  1998. /***/ (function(module, exports, __w_pdfjs_require__) {
  1999. "use strict";
  2000. Object.defineProperty(exports, "__esModule", {
  2001. value: true
  2002. });
  2003. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  2004. var _ui_utils = __w_pdfjs_require__(3);
  2005. var _pdfjsLib = __w_pdfjs_require__(2);
  2006. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2007. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2008. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2009. var EXPAND_DIVS_TIMEOUT = 300;
  2010. var TextLayerBuilder =
  2011. /*#__PURE__*/
  2012. function () {
  2013. function TextLayerBuilder(_ref) {
  2014. var textLayerDiv = _ref.textLayerDiv,
  2015. eventBus = _ref.eventBus,
  2016. pageIndex = _ref.pageIndex,
  2017. viewport = _ref.viewport,
  2018. _ref$findController = _ref.findController,
  2019. findController = _ref$findController === void 0 ? null : _ref$findController,
  2020. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  2021. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  2022. _classCallCheck(this, TextLayerBuilder);
  2023. this.textLayerDiv = textLayerDiv;
  2024. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  2025. this.textContent = null;
  2026. this.textContentItemsStr = [];
  2027. this.textContentStream = null;
  2028. this.renderingDone = false;
  2029. this.pageIdx = pageIndex;
  2030. this.pageNumber = this.pageIdx + 1;
  2031. this.matches = [];
  2032. this.viewport = viewport;
  2033. this.textDivs = [];
  2034. this.findController = findController;
  2035. this.textLayerRenderTask = null;
  2036. this.enhanceTextSelection = enhanceTextSelection;
  2037. this._onUpdateTextLayerMatches = null;
  2038. this._bindMouse();
  2039. }
  2040. _createClass(TextLayerBuilder, [{
  2041. key: "_finishRendering",
  2042. value: function _finishRendering() {
  2043. this.renderingDone = true;
  2044. if (!this.enhanceTextSelection) {
  2045. var endOfContent = document.createElement('div');
  2046. endOfContent.className = 'endOfContent';
  2047. this.textLayerDiv.appendChild(endOfContent);
  2048. }
  2049. this.eventBus.dispatch('textlayerrendered', {
  2050. source: this,
  2051. pageNumber: this.pageNumber,
  2052. numTextDivs: this.textDivs.length
  2053. });
  2054. }
  2055. }, {
  2056. key: "render",
  2057. value: function render() {
  2058. var _this = this;
  2059. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2060. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  2061. return;
  2062. }
  2063. this.cancel();
  2064. this.textDivs = [];
  2065. var textLayerFrag = document.createDocumentFragment();
  2066. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  2067. textContent: this.textContent,
  2068. textContentStream: this.textContentStream,
  2069. container: textLayerFrag,
  2070. viewport: this.viewport,
  2071. textDivs: this.textDivs,
  2072. textContentItemsStr: this.textContentItemsStr,
  2073. timeout: timeout,
  2074. enhanceTextSelection: this.enhanceTextSelection
  2075. });
  2076. this.textLayerRenderTask.promise.then(function () {
  2077. _this.textLayerDiv.appendChild(textLayerFrag);
  2078. _this._finishRendering();
  2079. _this._updateMatches();
  2080. }, function (reason) {});
  2081. if (!this._onUpdateTextLayerMatches) {
  2082. this._onUpdateTextLayerMatches = function (evt) {
  2083. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  2084. _this._updateMatches();
  2085. }
  2086. };
  2087. this.eventBus.on('updatetextlayermatches', this._onUpdateTextLayerMatches);
  2088. }
  2089. }
  2090. }, {
  2091. key: "cancel",
  2092. value: function cancel() {
  2093. if (this.textLayerRenderTask) {
  2094. this.textLayerRenderTask.cancel();
  2095. this.textLayerRenderTask = null;
  2096. }
  2097. if (this._onUpdateTextLayerMatches) {
  2098. this.eventBus.off('updatetextlayermatches', this._onUpdateTextLayerMatches);
  2099. this._onUpdateTextLayerMatches = null;
  2100. }
  2101. }
  2102. }, {
  2103. key: "setTextContentStream",
  2104. value: function setTextContentStream(readableStream) {
  2105. this.cancel();
  2106. this.textContentStream = readableStream;
  2107. }
  2108. }, {
  2109. key: "setTextContent",
  2110. value: function setTextContent(textContent) {
  2111. this.cancel();
  2112. this.textContent = textContent;
  2113. }
  2114. }, {
  2115. key: "_convertMatches",
  2116. value: function _convertMatches(matches, matchesLength) {
  2117. if (!matches) {
  2118. return [];
  2119. }
  2120. var findController = this.findController,
  2121. textContentItemsStr = this.textContentItemsStr;
  2122. var i = 0,
  2123. iIndex = 0;
  2124. var end = textContentItemsStr.length - 1;
  2125. var queryLen = findController.state.query.length;
  2126. var result = [];
  2127. for (var m = 0, mm = matches.length; m < mm; m++) {
  2128. var matchIdx = matches[m];
  2129. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  2130. iIndex += textContentItemsStr[i].length;
  2131. i++;
  2132. }
  2133. if (i === textContentItemsStr.length) {
  2134. console.error('Could not find a matching mapping');
  2135. }
  2136. var match = {
  2137. begin: {
  2138. divIdx: i,
  2139. offset: matchIdx - iIndex
  2140. }
  2141. };
  2142. if (matchesLength) {
  2143. matchIdx += matchesLength[m];
  2144. } else {
  2145. matchIdx += queryLen;
  2146. }
  2147. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  2148. iIndex += textContentItemsStr[i].length;
  2149. i++;
  2150. }
  2151. match.end = {
  2152. divIdx: i,
  2153. offset: matchIdx - iIndex
  2154. };
  2155. result.push(match);
  2156. }
  2157. return result;
  2158. }
  2159. }, {
  2160. key: "_renderMatches",
  2161. value: function _renderMatches(matches) {
  2162. if (matches.length === 0) {
  2163. return;
  2164. }
  2165. var findController = this.findController,
  2166. pageIdx = this.pageIdx,
  2167. textContentItemsStr = this.textContentItemsStr,
  2168. textDivs = this.textDivs;
  2169. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  2170. var selectedMatchIdx = findController.selected.matchIdx;
  2171. var highlightAll = findController.state.highlightAll;
  2172. var prevEnd = null;
  2173. var infinity = {
  2174. divIdx: -1,
  2175. offset: undefined
  2176. };
  2177. function beginText(begin, className) {
  2178. var divIdx = begin.divIdx;
  2179. textDivs[divIdx].textContent = '';
  2180. appendTextToDiv(divIdx, 0, begin.offset, className);
  2181. }
  2182. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  2183. var div = textDivs[divIdx];
  2184. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  2185. var node = document.createTextNode(content);
  2186. if (className) {
  2187. var span = document.createElement('span');
  2188. span.className = className;
  2189. span.appendChild(node);
  2190. div.appendChild(span);
  2191. return;
  2192. }
  2193. div.appendChild(node);
  2194. }
  2195. var i0 = selectedMatchIdx,
  2196. i1 = i0 + 1;
  2197. if (highlightAll) {
  2198. i0 = 0;
  2199. i1 = matches.length;
  2200. } else if (!isSelectedPage) {
  2201. return;
  2202. }
  2203. for (var i = i0; i < i1; i++) {
  2204. var match = matches[i];
  2205. var begin = match.begin;
  2206. var end = match.end;
  2207. var isSelected = isSelectedPage && i === selectedMatchIdx;
  2208. var highlightSuffix = isSelected ? ' selected' : '';
  2209. if (isSelected) {
  2210. findController.scrollMatchIntoView({
  2211. element: textDivs[begin.divIdx],
  2212. pageIndex: pageIdx,
  2213. matchIndex: selectedMatchIdx
  2214. });
  2215. }
  2216. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  2217. if (prevEnd !== null) {
  2218. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2219. }
  2220. beginText(begin);
  2221. } else {
  2222. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  2223. }
  2224. if (begin.divIdx === end.divIdx) {
  2225. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  2226. } else {
  2227. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  2228. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  2229. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  2230. }
  2231. beginText(end, 'highlight end' + highlightSuffix);
  2232. }
  2233. prevEnd = end;
  2234. }
  2235. if (prevEnd) {
  2236. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2237. }
  2238. }
  2239. }, {
  2240. key: "_updateMatches",
  2241. value: function _updateMatches() {
  2242. if (!this.renderingDone) {
  2243. return;
  2244. }
  2245. var findController = this.findController,
  2246. matches = this.matches,
  2247. pageIdx = this.pageIdx,
  2248. textContentItemsStr = this.textContentItemsStr,
  2249. textDivs = this.textDivs;
  2250. var clearedUntilDivIdx = -1;
  2251. for (var i = 0, ii = matches.length; i < ii; i++) {
  2252. var match = matches[i];
  2253. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  2254. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  2255. var div = textDivs[n];
  2256. div.textContent = textContentItemsStr[n];
  2257. div.className = '';
  2258. }
  2259. clearedUntilDivIdx = match.end.divIdx + 1;
  2260. }
  2261. if (!findController || !findController.highlightMatches) {
  2262. return;
  2263. }
  2264. var pageMatches = findController.pageMatches[pageIdx] || null;
  2265. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  2266. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  2267. this._renderMatches(this.matches);
  2268. }
  2269. }, {
  2270. key: "_bindMouse",
  2271. value: function _bindMouse() {
  2272. var _this2 = this;
  2273. var div = this.textLayerDiv;
  2274. var expandDivsTimer = null;
  2275. div.addEventListener('mousedown', function (evt) {
  2276. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2277. _this2.textLayerRenderTask.expandTextDivs(true);
  2278. if (expandDivsTimer) {
  2279. clearTimeout(expandDivsTimer);
  2280. expandDivsTimer = null;
  2281. }
  2282. return;
  2283. }
  2284. var end = div.querySelector('.endOfContent');
  2285. if (!end) {
  2286. return;
  2287. }
  2288. var adjustTop = evt.target !== div;
  2289. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  2290. if (adjustTop) {
  2291. var divBounds = div.getBoundingClientRect();
  2292. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  2293. end.style.top = (r * 100).toFixed(2) + '%';
  2294. }
  2295. end.classList.add('active');
  2296. });
  2297. div.addEventListener('mouseup', function () {
  2298. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2299. expandDivsTimer = setTimeout(function () {
  2300. if (_this2.textLayerRenderTask) {
  2301. _this2.textLayerRenderTask.expandTextDivs(false);
  2302. }
  2303. expandDivsTimer = null;
  2304. }, EXPAND_DIVS_TIMEOUT);
  2305. return;
  2306. }
  2307. var end = div.querySelector('.endOfContent');
  2308. if (!end) {
  2309. return;
  2310. }
  2311. end.style.top = '';
  2312. end.classList.remove('active');
  2313. });
  2314. }
  2315. }]);
  2316. return TextLayerBuilder;
  2317. }();
  2318. exports.TextLayerBuilder = TextLayerBuilder;
  2319. var DefaultTextLayerFactory =
  2320. /*#__PURE__*/
  2321. function () {
  2322. function DefaultTextLayerFactory() {
  2323. _classCallCheck(this, DefaultTextLayerFactory);
  2324. }
  2325. _createClass(DefaultTextLayerFactory, [{
  2326. key: "createTextLayerBuilder",
  2327. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2328. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2329. return new TextLayerBuilder({
  2330. textLayerDiv: textLayerDiv,
  2331. pageIndex: pageIndex,
  2332. viewport: viewport,
  2333. enhanceTextSelection: enhanceTextSelection
  2334. });
  2335. }
  2336. }]);
  2337. return DefaultTextLayerFactory;
  2338. }();
  2339. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  2340. /***/ }),
  2341. /* 9 */
  2342. /***/ (function(module, exports, __w_pdfjs_require__) {
  2343. "use strict";
  2344. Object.defineProperty(exports, "__esModule", {
  2345. value: true
  2346. });
  2347. exports.DownloadManager = void 0;
  2348. var _pdfjsLib = __w_pdfjs_require__(2);
  2349. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2350. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2351. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2352. ;
  2353. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  2354. function _download(blobUrl, filename) {
  2355. var a = document.createElement('a');
  2356. if (!a.click) {
  2357. throw new Error('DownloadManager: "a.click()" is not supported.');
  2358. }
  2359. a.href = blobUrl;
  2360. a.target = '_parent';
  2361. if ('download' in a) {
  2362. a.download = filename;
  2363. }
  2364. (document.body || document.documentElement).appendChild(a);
  2365. a.click();
  2366. a.remove();
  2367. }
  2368. var DownloadManager =
  2369. /*#__PURE__*/
  2370. function () {
  2371. function DownloadManager(_ref) {
  2372. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  2373. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  2374. _classCallCheck(this, DownloadManager);
  2375. this.disableCreateObjectURL = disableCreateObjectURL;
  2376. }
  2377. _createClass(DownloadManager, [{
  2378. key: "downloadUrl",
  2379. value: function downloadUrl(url, filename) {
  2380. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  2381. return;
  2382. }
  2383. _download(url + '#pdfjs.action=download', filename);
  2384. }
  2385. }, {
  2386. key: "downloadData",
  2387. value: function downloadData(data, filename, contentType) {
  2388. if (navigator.msSaveBlob) {
  2389. navigator.msSaveBlob(new Blob([data], {
  2390. type: contentType
  2391. }), filename);
  2392. return;
  2393. }
  2394. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  2395. _download(blobUrl, filename);
  2396. }
  2397. }, {
  2398. key: "download",
  2399. value: function download(blob, url, filename) {
  2400. if (navigator.msSaveBlob) {
  2401. if (!navigator.msSaveBlob(blob, filename)) {
  2402. this.downloadUrl(url, filename);
  2403. }
  2404. return;
  2405. }
  2406. if (this.disableCreateObjectURL) {
  2407. this.downloadUrl(url, filename);
  2408. return;
  2409. }
  2410. var blobUrl = URL.createObjectURL(blob);
  2411. _download(blobUrl, filename);
  2412. }
  2413. }]);
  2414. return DownloadManager;
  2415. }();
  2416. exports.DownloadManager = DownloadManager;
  2417. /***/ }),
  2418. /* 10 */
  2419. /***/ (function(module, exports, __w_pdfjs_require__) {
  2420. "use strict";
  2421. Object.defineProperty(exports, "__esModule", {
  2422. value: true
  2423. });
  2424. exports.GenericL10n = void 0;
  2425. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  2426. __w_pdfjs_require__(11);
  2427. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2428. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2429. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2430. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2431. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2432. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2433. var webL10n = document.webL10n;
  2434. var GenericL10n =
  2435. /*#__PURE__*/
  2436. function () {
  2437. function GenericL10n(lang) {
  2438. _classCallCheck(this, GenericL10n);
  2439. this._lang = lang;
  2440. this._ready = new Promise(function (resolve, reject) {
  2441. webL10n.setLanguage(lang, function () {
  2442. resolve(webL10n);
  2443. });
  2444. });
  2445. }
  2446. _createClass(GenericL10n, [{
  2447. key: "getLanguage",
  2448. value: function () {
  2449. var _getLanguage = _asyncToGenerator(
  2450. /*#__PURE__*/
  2451. _regenerator["default"].mark(function _callee() {
  2452. var l10n;
  2453. return _regenerator["default"].wrap(function _callee$(_context) {
  2454. while (1) {
  2455. switch (_context.prev = _context.next) {
  2456. case 0:
  2457. _context.next = 2;
  2458. return this._ready;
  2459. case 2:
  2460. l10n = _context.sent;
  2461. return _context.abrupt("return", l10n.getLanguage());
  2462. case 4:
  2463. case "end":
  2464. return _context.stop();
  2465. }
  2466. }
  2467. }, _callee, this);
  2468. }));
  2469. function getLanguage() {
  2470. return _getLanguage.apply(this, arguments);
  2471. }
  2472. return getLanguage;
  2473. }()
  2474. }, {
  2475. key: "getDirection",
  2476. value: function () {
  2477. var _getDirection = _asyncToGenerator(
  2478. /*#__PURE__*/
  2479. _regenerator["default"].mark(function _callee2() {
  2480. var l10n;
  2481. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2482. while (1) {
  2483. switch (_context2.prev = _context2.next) {
  2484. case 0:
  2485. _context2.next = 2;
  2486. return this._ready;
  2487. case 2:
  2488. l10n = _context2.sent;
  2489. return _context2.abrupt("return", l10n.getDirection());
  2490. case 4:
  2491. case "end":
  2492. return _context2.stop();
  2493. }
  2494. }
  2495. }, _callee2, this);
  2496. }));
  2497. function getDirection() {
  2498. return _getDirection.apply(this, arguments);
  2499. }
  2500. return getDirection;
  2501. }()
  2502. }, {
  2503. key: "get",
  2504. value: function () {
  2505. var _get = _asyncToGenerator(
  2506. /*#__PURE__*/
  2507. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  2508. var l10n;
  2509. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2510. while (1) {
  2511. switch (_context3.prev = _context3.next) {
  2512. case 0:
  2513. _context3.next = 2;
  2514. return this._ready;
  2515. case 2:
  2516. l10n = _context3.sent;
  2517. return _context3.abrupt("return", l10n.get(property, args, fallback));
  2518. case 4:
  2519. case "end":
  2520. return _context3.stop();
  2521. }
  2522. }
  2523. }, _callee3, this);
  2524. }));
  2525. function get(_x, _x2, _x3) {
  2526. return _get.apply(this, arguments);
  2527. }
  2528. return get;
  2529. }()
  2530. }, {
  2531. key: "translate",
  2532. value: function () {
  2533. var _translate = _asyncToGenerator(
  2534. /*#__PURE__*/
  2535. _regenerator["default"].mark(function _callee4(element) {
  2536. var l10n;
  2537. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2538. while (1) {
  2539. switch (_context4.prev = _context4.next) {
  2540. case 0:
  2541. _context4.next = 2;
  2542. return this._ready;
  2543. case 2:
  2544. l10n = _context4.sent;
  2545. return _context4.abrupt("return", l10n.translate(element));
  2546. case 4:
  2547. case "end":
  2548. return _context4.stop();
  2549. }
  2550. }
  2551. }, _callee4, this);
  2552. }));
  2553. function translate(_x4) {
  2554. return _translate.apply(this, arguments);
  2555. }
  2556. return translate;
  2557. }()
  2558. }]);
  2559. return GenericL10n;
  2560. }();
  2561. exports.GenericL10n = GenericL10n;
  2562. /***/ }),
  2563. /* 11 */
  2564. /***/ (function(module, exports, __w_pdfjs_require__) {
  2565. "use strict";
  2566. document.webL10n = function (window, document, undefined) {
  2567. var gL10nData = {};
  2568. var gTextData = '';
  2569. var gTextProp = 'textContent';
  2570. var gLanguage = '';
  2571. var gMacros = {};
  2572. var gReadyState = 'loading';
  2573. var gAsyncResourceLoading = true;
  2574. function getL10nResourceLinks() {
  2575. return document.querySelectorAll('link[type="application/l10n"]');
  2576. }
  2577. function getL10nDictionary() {
  2578. var script = document.querySelector('script[type="application/l10n"]');
  2579. return script ? JSON.parse(script.innerHTML) : null;
  2580. }
  2581. function getTranslatableChildren(element) {
  2582. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  2583. }
  2584. function getL10nAttributes(element) {
  2585. if (!element) return {};
  2586. var l10nId = element.getAttribute('data-l10n-id');
  2587. var l10nArgs = element.getAttribute('data-l10n-args');
  2588. var args = {};
  2589. if (l10nArgs) {
  2590. try {
  2591. args = JSON.parse(l10nArgs);
  2592. } catch (e) {
  2593. console.warn('could not parse arguments for #' + l10nId);
  2594. }
  2595. }
  2596. return {
  2597. id: l10nId,
  2598. args: args
  2599. };
  2600. }
  2601. function xhrLoadText(url, onSuccess, onFailure) {
  2602. onSuccess = onSuccess || function _onSuccess(data) {};
  2603. onFailure = onFailure || function _onFailure() {};
  2604. var xhr = new XMLHttpRequest();
  2605. xhr.open('GET', url, gAsyncResourceLoading);
  2606. if (xhr.overrideMimeType) {
  2607. xhr.overrideMimeType('text/plain; charset=utf-8');
  2608. }
  2609. xhr.onreadystatechange = function () {
  2610. if (xhr.readyState == 4) {
  2611. if (xhr.status == 200 || xhr.status === 0) {
  2612. onSuccess(xhr.responseText);
  2613. } else {
  2614. onFailure();
  2615. }
  2616. }
  2617. };
  2618. xhr.onerror = onFailure;
  2619. xhr.ontimeout = onFailure;
  2620. try {
  2621. xhr.send(null);
  2622. } catch (e) {
  2623. onFailure();
  2624. }
  2625. }
  2626. function parseResource(href, lang, successCallback, failureCallback) {
  2627. var baseURL = href.replace(/[^\/]*$/, '') || './';
  2628. function evalString(text) {
  2629. if (text.lastIndexOf('\\') < 0) return text;
  2630. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  2631. }
  2632. function parseProperties(text, parsedPropertiesCallback) {
  2633. var dictionary = {};
  2634. var reBlank = /^\s*|\s*$/;
  2635. var reComment = /^\s*#|^\s*$/;
  2636. var reSection = /^\s*\[(.*)\]\s*$/;
  2637. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  2638. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  2639. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  2640. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  2641. var currentLang = '*';
  2642. var genericLang = lang.split('-', 1)[0];
  2643. var skipLang = false;
  2644. var match = '';
  2645. function nextEntry() {
  2646. while (true) {
  2647. if (!entries.length) {
  2648. parsedRawLinesCallback();
  2649. return;
  2650. }
  2651. var line = entries.shift();
  2652. if (reComment.test(line)) continue;
  2653. if (extendedSyntax) {
  2654. match = reSection.exec(line);
  2655. if (match) {
  2656. currentLang = match[1].toLowerCase();
  2657. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  2658. continue;
  2659. } else if (skipLang) {
  2660. continue;
  2661. }
  2662. match = reImport.exec(line);
  2663. if (match) {
  2664. loadImport(baseURL + match[1], nextEntry);
  2665. return;
  2666. }
  2667. }
  2668. var tmp = line.match(reSplit);
  2669. if (tmp && tmp.length == 3) {
  2670. dictionary[tmp[1]] = evalString(tmp[2]);
  2671. }
  2672. }
  2673. }
  2674. nextEntry();
  2675. }
  2676. function loadImport(url, callback) {
  2677. xhrLoadText(url, function (content) {
  2678. parseRawLines(content, false, callback);
  2679. }, function () {
  2680. console.warn(url + ' not found.');
  2681. callback();
  2682. });
  2683. }
  2684. parseRawLines(text, true, function () {
  2685. parsedPropertiesCallback(dictionary);
  2686. });
  2687. }
  2688. xhrLoadText(href, function (response) {
  2689. gTextData += response;
  2690. parseProperties(response, function (data) {
  2691. for (var key in data) {
  2692. var id,
  2693. prop,
  2694. index = key.lastIndexOf('.');
  2695. if (index > 0) {
  2696. id = key.substring(0, index);
  2697. prop = key.substring(index + 1);
  2698. } else {
  2699. id = key;
  2700. prop = gTextProp;
  2701. }
  2702. if (!gL10nData[id]) {
  2703. gL10nData[id] = {};
  2704. }
  2705. gL10nData[id][prop] = data[key];
  2706. }
  2707. if (successCallback) {
  2708. successCallback();
  2709. }
  2710. });
  2711. }, failureCallback);
  2712. }
  2713. function loadLocale(lang, callback) {
  2714. if (lang) {
  2715. lang = lang.toLowerCase();
  2716. }
  2717. callback = callback || function _callback() {};
  2718. clear();
  2719. gLanguage = lang;
  2720. var langLinks = getL10nResourceLinks();
  2721. var langCount = langLinks.length;
  2722. if (langCount === 0) {
  2723. var dict = getL10nDictionary();
  2724. if (dict && dict.locales && dict.default_locale) {
  2725. console.log('using the embedded JSON directory, early way out');
  2726. gL10nData = dict.locales[lang];
  2727. if (!gL10nData) {
  2728. var defaultLocale = dict.default_locale.toLowerCase();
  2729. for (var anyCaseLang in dict.locales) {
  2730. anyCaseLang = anyCaseLang.toLowerCase();
  2731. if (anyCaseLang === lang) {
  2732. gL10nData = dict.locales[lang];
  2733. break;
  2734. } else if (anyCaseLang === defaultLocale) {
  2735. gL10nData = dict.locales[defaultLocale];
  2736. }
  2737. }
  2738. }
  2739. callback();
  2740. } else {
  2741. console.log('no resource to load, early way out');
  2742. }
  2743. gReadyState = 'complete';
  2744. return;
  2745. }
  2746. var onResourceLoaded = null;
  2747. var gResourceCount = 0;
  2748. onResourceLoaded = function onResourceLoaded() {
  2749. gResourceCount++;
  2750. if (gResourceCount >= langCount) {
  2751. callback();
  2752. gReadyState = 'complete';
  2753. }
  2754. };
  2755. function L10nResourceLink(link) {
  2756. var href = link.href;
  2757. this.load = function (lang, callback) {
  2758. parseResource(href, lang, callback, function () {
  2759. console.warn(href + ' not found.');
  2760. console.warn('"' + lang + '" resource not found');
  2761. gLanguage = '';
  2762. callback();
  2763. });
  2764. };
  2765. }
  2766. for (var i = 0; i < langCount; i++) {
  2767. var resource = new L10nResourceLink(langLinks[i]);
  2768. resource.load(lang, onResourceLoaded);
  2769. }
  2770. }
  2771. function clear() {
  2772. gL10nData = {};
  2773. gTextData = '';
  2774. gLanguage = '';
  2775. }
  2776. function getPluralRules(lang) {
  2777. var locales2rules = {
  2778. 'af': 3,
  2779. 'ak': 4,
  2780. 'am': 4,
  2781. 'ar': 1,
  2782. 'asa': 3,
  2783. 'az': 0,
  2784. 'be': 11,
  2785. 'bem': 3,
  2786. 'bez': 3,
  2787. 'bg': 3,
  2788. 'bh': 4,
  2789. 'bm': 0,
  2790. 'bn': 3,
  2791. 'bo': 0,
  2792. 'br': 20,
  2793. 'brx': 3,
  2794. 'bs': 11,
  2795. 'ca': 3,
  2796. 'cgg': 3,
  2797. 'chr': 3,
  2798. 'cs': 12,
  2799. 'cy': 17,
  2800. 'da': 3,
  2801. 'de': 3,
  2802. 'dv': 3,
  2803. 'dz': 0,
  2804. 'ee': 3,
  2805. 'el': 3,
  2806. 'en': 3,
  2807. 'eo': 3,
  2808. 'es': 3,
  2809. 'et': 3,
  2810. 'eu': 3,
  2811. 'fa': 0,
  2812. 'ff': 5,
  2813. 'fi': 3,
  2814. 'fil': 4,
  2815. 'fo': 3,
  2816. 'fr': 5,
  2817. 'fur': 3,
  2818. 'fy': 3,
  2819. 'ga': 8,
  2820. 'gd': 24,
  2821. 'gl': 3,
  2822. 'gsw': 3,
  2823. 'gu': 3,
  2824. 'guw': 4,
  2825. 'gv': 23,
  2826. 'ha': 3,
  2827. 'haw': 3,
  2828. 'he': 2,
  2829. 'hi': 4,
  2830. 'hr': 11,
  2831. 'hu': 0,
  2832. 'id': 0,
  2833. 'ig': 0,
  2834. 'ii': 0,
  2835. 'is': 3,
  2836. 'it': 3,
  2837. 'iu': 7,
  2838. 'ja': 0,
  2839. 'jmc': 3,
  2840. 'jv': 0,
  2841. 'ka': 0,
  2842. 'kab': 5,
  2843. 'kaj': 3,
  2844. 'kcg': 3,
  2845. 'kde': 0,
  2846. 'kea': 0,
  2847. 'kk': 3,
  2848. 'kl': 3,
  2849. 'km': 0,
  2850. 'kn': 0,
  2851. 'ko': 0,
  2852. 'ksb': 3,
  2853. 'ksh': 21,
  2854. 'ku': 3,
  2855. 'kw': 7,
  2856. 'lag': 18,
  2857. 'lb': 3,
  2858. 'lg': 3,
  2859. 'ln': 4,
  2860. 'lo': 0,
  2861. 'lt': 10,
  2862. 'lv': 6,
  2863. 'mas': 3,
  2864. 'mg': 4,
  2865. 'mk': 16,
  2866. 'ml': 3,
  2867. 'mn': 3,
  2868. 'mo': 9,
  2869. 'mr': 3,
  2870. 'ms': 0,
  2871. 'mt': 15,
  2872. 'my': 0,
  2873. 'nah': 3,
  2874. 'naq': 7,
  2875. 'nb': 3,
  2876. 'nd': 3,
  2877. 'ne': 3,
  2878. 'nl': 3,
  2879. 'nn': 3,
  2880. 'no': 3,
  2881. 'nr': 3,
  2882. 'nso': 4,
  2883. 'ny': 3,
  2884. 'nyn': 3,
  2885. 'om': 3,
  2886. 'or': 3,
  2887. 'pa': 3,
  2888. 'pap': 3,
  2889. 'pl': 13,
  2890. 'ps': 3,
  2891. 'pt': 3,
  2892. 'rm': 3,
  2893. 'ro': 9,
  2894. 'rof': 3,
  2895. 'ru': 11,
  2896. 'rwk': 3,
  2897. 'sah': 0,
  2898. 'saq': 3,
  2899. 'se': 7,
  2900. 'seh': 3,
  2901. 'ses': 0,
  2902. 'sg': 0,
  2903. 'sh': 11,
  2904. 'shi': 19,
  2905. 'sk': 12,
  2906. 'sl': 14,
  2907. 'sma': 7,
  2908. 'smi': 7,
  2909. 'smj': 7,
  2910. 'smn': 7,
  2911. 'sms': 7,
  2912. 'sn': 3,
  2913. 'so': 3,
  2914. 'sq': 3,
  2915. 'sr': 11,
  2916. 'ss': 3,
  2917. 'ssy': 3,
  2918. 'st': 3,
  2919. 'sv': 3,
  2920. 'sw': 3,
  2921. 'syr': 3,
  2922. 'ta': 3,
  2923. 'te': 3,
  2924. 'teo': 3,
  2925. 'th': 0,
  2926. 'ti': 4,
  2927. 'tig': 3,
  2928. 'tk': 3,
  2929. 'tl': 4,
  2930. 'tn': 3,
  2931. 'to': 0,
  2932. 'tr': 0,
  2933. 'ts': 3,
  2934. 'tzm': 22,
  2935. 'uk': 11,
  2936. 'ur': 3,
  2937. 've': 3,
  2938. 'vi': 0,
  2939. 'vun': 3,
  2940. 'wa': 4,
  2941. 'wae': 3,
  2942. 'wo': 0,
  2943. 'xh': 3,
  2944. 'xog': 3,
  2945. 'yo': 0,
  2946. 'zh': 0,
  2947. 'zu': 3
  2948. };
  2949. function isIn(n, list) {
  2950. return list.indexOf(n) !== -1;
  2951. }
  2952. function isBetween(n, start, end) {
  2953. return start <= n && n <= end;
  2954. }
  2955. var pluralRules = {
  2956. '0': function _(n) {
  2957. return 'other';
  2958. },
  2959. '1': function _(n) {
  2960. if (isBetween(n % 100, 3, 10)) return 'few';
  2961. if (n === 0) return 'zero';
  2962. if (isBetween(n % 100, 11, 99)) return 'many';
  2963. if (n == 2) return 'two';
  2964. if (n == 1) return 'one';
  2965. return 'other';
  2966. },
  2967. '2': function _(n) {
  2968. if (n !== 0 && n % 10 === 0) return 'many';
  2969. if (n == 2) return 'two';
  2970. if (n == 1) return 'one';
  2971. return 'other';
  2972. },
  2973. '3': function _(n) {
  2974. if (n == 1) return 'one';
  2975. return 'other';
  2976. },
  2977. '4': function _(n) {
  2978. if (isBetween(n, 0, 1)) return 'one';
  2979. return 'other';
  2980. },
  2981. '5': function _(n) {
  2982. if (isBetween(n, 0, 2) && n != 2) return 'one';
  2983. return 'other';
  2984. },
  2985. '6': function _(n) {
  2986. if (n === 0) return 'zero';
  2987. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2988. return 'other';
  2989. },
  2990. '7': function _(n) {
  2991. if (n == 2) return 'two';
  2992. if (n == 1) return 'one';
  2993. return 'other';
  2994. },
  2995. '8': function _(n) {
  2996. if (isBetween(n, 3, 6)) return 'few';
  2997. if (isBetween(n, 7, 10)) return 'many';
  2998. if (n == 2) return 'two';
  2999. if (n == 1) return 'one';
  3000. return 'other';
  3001. },
  3002. '9': function _(n) {
  3003. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3004. if (n == 1) return 'one';
  3005. return 'other';
  3006. },
  3007. '10': function _(n) {
  3008. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3009. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3010. return 'other';
  3011. },
  3012. '11': function _(n) {
  3013. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3014. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3015. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3016. return 'other';
  3017. },
  3018. '12': function _(n) {
  3019. if (isBetween(n, 2, 4)) return 'few';
  3020. if (n == 1) return 'one';
  3021. return 'other';
  3022. },
  3023. '13': function _(n) {
  3024. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3025. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3026. if (n == 1) return 'one';
  3027. return 'other';
  3028. },
  3029. '14': function _(n) {
  3030. if (isBetween(n % 100, 3, 4)) return 'few';
  3031. if (n % 100 == 2) return 'two';
  3032. if (n % 100 == 1) return 'one';
  3033. return 'other';
  3034. },
  3035. '15': function _(n) {
  3036. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3037. if (isBetween(n % 100, 11, 19)) return 'many';
  3038. if (n == 1) return 'one';
  3039. return 'other';
  3040. },
  3041. '16': function _(n) {
  3042. if (n % 10 == 1 && n != 11) return 'one';
  3043. return 'other';
  3044. },
  3045. '17': function _(n) {
  3046. if (n == 3) return 'few';
  3047. if (n === 0) return 'zero';
  3048. if (n == 6) return 'many';
  3049. if (n == 2) return 'two';
  3050. if (n == 1) return 'one';
  3051. return 'other';
  3052. },
  3053. '18': function _(n) {
  3054. if (n === 0) return 'zero';
  3055. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3056. return 'other';
  3057. },
  3058. '19': function _(n) {
  3059. if (isBetween(n, 2, 10)) return 'few';
  3060. if (isBetween(n, 0, 1)) return 'one';
  3061. return 'other';
  3062. },
  3063. '20': function _(n) {
  3064. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  3065. if (n % 1000000 === 0 && n !== 0) return 'many';
  3066. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3067. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3068. return 'other';
  3069. },
  3070. '21': function _(n) {
  3071. if (n === 0) return 'zero';
  3072. if (n == 1) return 'one';
  3073. return 'other';
  3074. },
  3075. '22': function _(n) {
  3076. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3077. return 'other';
  3078. },
  3079. '23': function _(n) {
  3080. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3081. return 'other';
  3082. },
  3083. '24': function _(n) {
  3084. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3085. if (isIn(n, [2, 12])) return 'two';
  3086. if (isIn(n, [1, 11])) return 'one';
  3087. return 'other';
  3088. }
  3089. };
  3090. var index = locales2rules[lang.replace(/-.*$/, '')];
  3091. if (!(index in pluralRules)) {
  3092. console.warn('plural form unknown for [' + lang + ']');
  3093. return function () {
  3094. return 'other';
  3095. };
  3096. }
  3097. return pluralRules[index];
  3098. }
  3099. gMacros.plural = function (str, param, key, prop) {
  3100. var n = parseFloat(param);
  3101. if (isNaN(n)) return str;
  3102. if (prop != gTextProp) return str;
  3103. if (!gMacros._pluralRules) {
  3104. gMacros._pluralRules = getPluralRules(gLanguage);
  3105. }
  3106. var index = '[' + gMacros._pluralRules(n) + ']';
  3107. if (n === 0 && key + '[zero]' in gL10nData) {
  3108. str = gL10nData[key + '[zero]'][prop];
  3109. } else if (n == 1 && key + '[one]' in gL10nData) {
  3110. str = gL10nData[key + '[one]'][prop];
  3111. } else if (n == 2 && key + '[two]' in gL10nData) {
  3112. str = gL10nData[key + '[two]'][prop];
  3113. } else if (key + index in gL10nData) {
  3114. str = gL10nData[key + index][prop];
  3115. } else if (key + '[other]' in gL10nData) {
  3116. str = gL10nData[key + '[other]'][prop];
  3117. }
  3118. return str;
  3119. };
  3120. function getL10nData(key, args, fallback) {
  3121. var data = gL10nData[key];
  3122. if (!data) {
  3123. console.warn('#' + key + ' is undefined.');
  3124. if (!fallback) {
  3125. return null;
  3126. }
  3127. data = fallback;
  3128. }
  3129. var rv = {};
  3130. for (var prop in data) {
  3131. var str = data[prop];
  3132. str = substIndexes(str, args, key, prop);
  3133. str = substArguments(str, args, key);
  3134. rv[prop] = str;
  3135. }
  3136. return rv;
  3137. }
  3138. function substIndexes(str, args, key, prop) {
  3139. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3140. var reMatch = reIndex.exec(str);
  3141. if (!reMatch || !reMatch.length) return str;
  3142. var macroName = reMatch[1];
  3143. var paramName = reMatch[2];
  3144. var param;
  3145. if (args && paramName in args) {
  3146. param = args[paramName];
  3147. } else if (paramName in gL10nData) {
  3148. param = gL10nData[paramName];
  3149. }
  3150. if (macroName in gMacros) {
  3151. var macro = gMacros[macroName];
  3152. str = macro(str, param, key, prop);
  3153. }
  3154. return str;
  3155. }
  3156. function substArguments(str, args, key) {
  3157. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3158. return str.replace(reArgs, function (matched_text, arg) {
  3159. if (args && arg in args) {
  3160. return args[arg];
  3161. }
  3162. if (arg in gL10nData) {
  3163. return gL10nData[arg];
  3164. }
  3165. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3166. return matched_text;
  3167. });
  3168. }
  3169. function translateElement(element) {
  3170. var l10n = getL10nAttributes(element);
  3171. if (!l10n.id) return;
  3172. var data = getL10nData(l10n.id, l10n.args);
  3173. if (!data) {
  3174. console.warn('#' + l10n.id + ' is undefined.');
  3175. return;
  3176. }
  3177. if (data[gTextProp]) {
  3178. if (getChildElementCount(element) === 0) {
  3179. element[gTextProp] = data[gTextProp];
  3180. } else {
  3181. var children = element.childNodes;
  3182. var found = false;
  3183. for (var i = 0, l = children.length; i < l; i++) {
  3184. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3185. if (found) {
  3186. children[i].nodeValue = '';
  3187. } else {
  3188. children[i].nodeValue = data[gTextProp];
  3189. found = true;
  3190. }
  3191. }
  3192. }
  3193. if (!found) {
  3194. var textNode = document.createTextNode(data[gTextProp]);
  3195. element.insertBefore(textNode, element.firstChild);
  3196. }
  3197. }
  3198. delete data[gTextProp];
  3199. }
  3200. for (var k in data) {
  3201. element[k] = data[k];
  3202. }
  3203. }
  3204. function getChildElementCount(element) {
  3205. if (element.children) {
  3206. return element.children.length;
  3207. }
  3208. if (typeof element.childElementCount !== 'undefined') {
  3209. return element.childElementCount;
  3210. }
  3211. var count = 0;
  3212. for (var i = 0; i < element.childNodes.length; i++) {
  3213. count += element.nodeType === 1 ? 1 : 0;
  3214. }
  3215. return count;
  3216. }
  3217. function translateFragment(element) {
  3218. element = element || document.documentElement;
  3219. var children = getTranslatableChildren(element);
  3220. var elementCount = children.length;
  3221. for (var i = 0; i < elementCount; i++) {
  3222. translateElement(children[i]);
  3223. }
  3224. translateElement(element);
  3225. }
  3226. return {
  3227. get: function get(key, args, fallbackString) {
  3228. var index = key.lastIndexOf('.');
  3229. var prop = gTextProp;
  3230. if (index > 0) {
  3231. prop = key.substring(index + 1);
  3232. key = key.substring(0, index);
  3233. }
  3234. var fallback;
  3235. if (fallbackString) {
  3236. fallback = {};
  3237. fallback[prop] = fallbackString;
  3238. }
  3239. var data = getL10nData(key, args, fallback);
  3240. if (data && prop in data) {
  3241. return data[prop];
  3242. }
  3243. return '{{' + key + '}}';
  3244. },
  3245. getData: function getData() {
  3246. return gL10nData;
  3247. },
  3248. getText: function getText() {
  3249. return gTextData;
  3250. },
  3251. getLanguage: function getLanguage() {
  3252. return gLanguage;
  3253. },
  3254. setLanguage: function setLanguage(lang, callback) {
  3255. loadLocale(lang, function () {
  3256. if (callback) callback();
  3257. });
  3258. },
  3259. getDirection: function getDirection() {
  3260. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3261. var shortCode = gLanguage.split('-', 1)[0];
  3262. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3263. },
  3264. translate: translateFragment,
  3265. getReadyState: function getReadyState() {
  3266. return gReadyState;
  3267. },
  3268. ready: function ready(callback) {
  3269. if (!callback) {
  3270. return;
  3271. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3272. window.setTimeout(function () {
  3273. callback();
  3274. });
  3275. } else if (document.addEventListener) {
  3276. document.addEventListener('localized', function once() {
  3277. document.removeEventListener('localized', once);
  3278. callback();
  3279. });
  3280. }
  3281. }
  3282. };
  3283. }(window, document);
  3284. /***/ }),
  3285. /* 12 */
  3286. /***/ (function(module, exports, __w_pdfjs_require__) {
  3287. "use strict";
  3288. Object.defineProperty(exports, "__esModule", {
  3289. value: true
  3290. });
  3291. exports.PDFFindController = exports.FindState = void 0;
  3292. var _ui_utils = __w_pdfjs_require__(3);
  3293. var _pdfjsLib = __w_pdfjs_require__(2);
  3294. var _pdf_find_utils = __w_pdfjs_require__(13);
  3295. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3296. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3297. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3298. var FindState = {
  3299. FOUND: 0,
  3300. NOT_FOUND: 1,
  3301. WRAPPED: 2,
  3302. PENDING: 3
  3303. };
  3304. exports.FindState = FindState;
  3305. var FIND_TIMEOUT = 250;
  3306. var MATCH_SCROLL_OFFSET_TOP = -50;
  3307. var MATCH_SCROLL_OFFSET_LEFT = -400;
  3308. var CHARACTERS_TO_NORMALIZE = {
  3309. "\u2018": '\'',
  3310. "\u2019": '\'',
  3311. "\u201A": '\'',
  3312. "\u201B": '\'',
  3313. "\u201C": '"',
  3314. "\u201D": '"',
  3315. "\u201E": '"',
  3316. "\u201F": '"',
  3317. "\xBC": '1/4',
  3318. "\xBD": '1/2',
  3319. "\xBE": '3/4'
  3320. };
  3321. var normalizationRegex = null;
  3322. function normalize(text) {
  3323. if (!normalizationRegex) {
  3324. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3325. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  3326. }
  3327. return text.replace(normalizationRegex, function (ch) {
  3328. return CHARACTERS_TO_NORMALIZE[ch];
  3329. });
  3330. }
  3331. var PDFFindController =
  3332. /*#__PURE__*/
  3333. function () {
  3334. function PDFFindController(_ref) {
  3335. var linkService = _ref.linkService,
  3336. _ref$eventBus = _ref.eventBus,
  3337. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
  3338. _classCallCheck(this, PDFFindController);
  3339. this._linkService = linkService;
  3340. this._eventBus = eventBus;
  3341. this._reset();
  3342. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  3343. }
  3344. _createClass(PDFFindController, [{
  3345. key: "setDocument",
  3346. value: function setDocument(pdfDocument) {
  3347. if (this._pdfDocument) {
  3348. this._reset();
  3349. }
  3350. if (!pdfDocument) {
  3351. return;
  3352. }
  3353. this._pdfDocument = pdfDocument;
  3354. this._firstPageCapability.resolve();
  3355. }
  3356. }, {
  3357. key: "executeCommand",
  3358. value: function executeCommand(cmd, state) {
  3359. var _this = this;
  3360. if (!state) {
  3361. return;
  3362. }
  3363. var pdfDocument = this._pdfDocument;
  3364. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  3365. this._dirtyMatch = true;
  3366. }
  3367. this._state = state;
  3368. if (cmd !== 'findhighlightallchange') {
  3369. this._updateUIState(FindState.PENDING);
  3370. }
  3371. this._firstPageCapability.promise.then(function () {
  3372. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  3373. return;
  3374. }
  3375. _this._extractText();
  3376. var findbarClosed = !_this._highlightMatches;
  3377. var pendingTimeout = !!_this._findTimeout;
  3378. if (_this._findTimeout) {
  3379. clearTimeout(_this._findTimeout);
  3380. _this._findTimeout = null;
  3381. }
  3382. if (cmd === 'find') {
  3383. _this._findTimeout = setTimeout(function () {
  3384. _this._nextMatch();
  3385. _this._findTimeout = null;
  3386. }, FIND_TIMEOUT);
  3387. } else if (_this._dirtyMatch) {
  3388. _this._nextMatch();
  3389. } else if (cmd === 'findagain') {
  3390. _this._nextMatch();
  3391. if (findbarClosed && _this._state.highlightAll) {
  3392. _this._updateAllPages();
  3393. }
  3394. } else if (cmd === 'findhighlightallchange') {
  3395. if (pendingTimeout) {
  3396. _this._nextMatch();
  3397. } else {
  3398. _this._highlightMatches = true;
  3399. }
  3400. _this._updateAllPages();
  3401. } else {
  3402. _this._nextMatch();
  3403. }
  3404. });
  3405. }
  3406. }, {
  3407. key: "scrollMatchIntoView",
  3408. value: function scrollMatchIntoView(_ref2) {
  3409. var _ref2$element = _ref2.element,
  3410. element = _ref2$element === void 0 ? null : _ref2$element,
  3411. _ref2$pageIndex = _ref2.pageIndex,
  3412. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  3413. _ref2$matchIndex = _ref2.matchIndex,
  3414. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  3415. if (!this._scrollMatches || !element) {
  3416. return;
  3417. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  3418. return;
  3419. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  3420. return;
  3421. }
  3422. this._scrollMatches = false;
  3423. var spot = {
  3424. top: MATCH_SCROLL_OFFSET_TOP,
  3425. left: MATCH_SCROLL_OFFSET_LEFT
  3426. };
  3427. (0, _ui_utils.scrollIntoView)(element, spot, true);
  3428. }
  3429. }, {
  3430. key: "_reset",
  3431. value: function _reset() {
  3432. this._highlightMatches = false;
  3433. this._scrollMatches = false;
  3434. this._pdfDocument = null;
  3435. this._pageMatches = [];
  3436. this._pageMatchesLength = [];
  3437. this._state = null;
  3438. this._selected = {
  3439. pageIdx: -1,
  3440. matchIdx: -1
  3441. };
  3442. this._offset = {
  3443. pageIdx: null,
  3444. matchIdx: null,
  3445. wrapped: false
  3446. };
  3447. this._extractTextPromises = [];
  3448. this._pageContents = [];
  3449. this._matchesCountTotal = 0;
  3450. this._pagesToSearch = null;
  3451. this._pendingFindMatches = Object.create(null);
  3452. this._resumePageIdx = null;
  3453. this._dirtyMatch = false;
  3454. clearTimeout(this._findTimeout);
  3455. this._findTimeout = null;
  3456. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  3457. }
  3458. }, {
  3459. key: "_shouldDirtyMatch",
  3460. value: function _shouldDirtyMatch(cmd, state) {
  3461. if (state.query !== this._state.query) {
  3462. return true;
  3463. }
  3464. switch (cmd) {
  3465. case 'findagain':
  3466. var pageNumber = this._selected.pageIdx + 1;
  3467. var linkService = this._linkService;
  3468. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  3469. return true;
  3470. }
  3471. return false;
  3472. case 'findhighlightallchange':
  3473. return false;
  3474. }
  3475. return true;
  3476. }
  3477. }, {
  3478. key: "_prepareMatches",
  3479. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3480. function isSubTerm(matchesWithLength, currentIndex) {
  3481. var currentElem = matchesWithLength[currentIndex];
  3482. var nextElem = matchesWithLength[currentIndex + 1];
  3483. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3484. currentElem.skipped = true;
  3485. return true;
  3486. }
  3487. for (var i = currentIndex - 1; i >= 0; i--) {
  3488. var prevElem = matchesWithLength[i];
  3489. if (prevElem.skipped) {
  3490. continue;
  3491. }
  3492. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3493. break;
  3494. }
  3495. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3496. currentElem.skipped = true;
  3497. return true;
  3498. }
  3499. }
  3500. return false;
  3501. }
  3502. matchesWithLength.sort(function (a, b) {
  3503. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3504. });
  3505. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3506. if (isSubTerm(matchesWithLength, i)) {
  3507. continue;
  3508. }
  3509. matches.push(matchesWithLength[i].match);
  3510. matchesLength.push(matchesWithLength[i].matchLength);
  3511. }
  3512. }
  3513. }, {
  3514. key: "_isEntireWord",
  3515. value: function _isEntireWord(content, startIdx, length) {
  3516. if (startIdx > 0) {
  3517. var first = content.charCodeAt(startIdx);
  3518. var limit = content.charCodeAt(startIdx - 1);
  3519. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  3520. return false;
  3521. }
  3522. }
  3523. var endIdx = startIdx + length - 1;
  3524. if (endIdx < content.length - 1) {
  3525. var last = content.charCodeAt(endIdx);
  3526. var _limit = content.charCodeAt(endIdx + 1);
  3527. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  3528. return false;
  3529. }
  3530. }
  3531. return true;
  3532. }
  3533. }, {
  3534. key: "_calculatePhraseMatch",
  3535. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  3536. var matches = [];
  3537. var queryLen = query.length;
  3538. var matchIdx = -queryLen;
  3539. while (true) {
  3540. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3541. if (matchIdx === -1) {
  3542. break;
  3543. }
  3544. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  3545. continue;
  3546. }
  3547. matches.push(matchIdx);
  3548. }
  3549. this._pageMatches[pageIndex] = matches;
  3550. }
  3551. }, {
  3552. key: "_calculateWordMatch",
  3553. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  3554. var matchesWithLength = [];
  3555. var queryArray = query.match(/\S+/g);
  3556. for (var i = 0, len = queryArray.length; i < len; i++) {
  3557. var subquery = queryArray[i];
  3558. var subqueryLen = subquery.length;
  3559. var matchIdx = -subqueryLen;
  3560. while (true) {
  3561. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3562. if (matchIdx === -1) {
  3563. break;
  3564. }
  3565. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  3566. continue;
  3567. }
  3568. matchesWithLength.push({
  3569. match: matchIdx,
  3570. matchLength: subqueryLen,
  3571. skipped: false
  3572. });
  3573. }
  3574. }
  3575. this._pageMatchesLength[pageIndex] = [];
  3576. this._pageMatches[pageIndex] = [];
  3577. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  3578. }
  3579. }, {
  3580. key: "_calculateMatch",
  3581. value: function _calculateMatch(pageIndex) {
  3582. var pageContent = this._pageContents[pageIndex];
  3583. var query = this._query;
  3584. var _this$_state = this._state,
  3585. caseSensitive = _this$_state.caseSensitive,
  3586. entireWord = _this$_state.entireWord,
  3587. phraseSearch = _this$_state.phraseSearch;
  3588. if (query.length === 0) {
  3589. return;
  3590. }
  3591. if (!caseSensitive) {
  3592. pageContent = pageContent.toLowerCase();
  3593. query = query.toLowerCase();
  3594. }
  3595. if (phraseSearch) {
  3596. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  3597. } else {
  3598. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  3599. }
  3600. if (this._state.highlightAll) {
  3601. this._updatePage(pageIndex);
  3602. }
  3603. if (this._resumePageIdx === pageIndex) {
  3604. this._resumePageIdx = null;
  3605. this._nextPageMatch();
  3606. }
  3607. var pageMatchesCount = this._pageMatches[pageIndex].length;
  3608. if (pageMatchesCount > 0) {
  3609. this._matchesCountTotal += pageMatchesCount;
  3610. this._updateUIResultsCount();
  3611. }
  3612. }
  3613. }, {
  3614. key: "_extractText",
  3615. value: function _extractText() {
  3616. var _this2 = this;
  3617. if (this._extractTextPromises.length > 0) {
  3618. return;
  3619. }
  3620. var promise = Promise.resolve();
  3621. var _loop = function _loop(i, ii) {
  3622. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3623. _this2._extractTextPromises[i] = extractTextCapability.promise;
  3624. promise = promise.then(function () {
  3625. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  3626. return pdfPage.getTextContent({
  3627. normalizeWhitespace: true
  3628. });
  3629. }).then(function (textContent) {
  3630. var textItems = textContent.items;
  3631. var strBuf = [];
  3632. for (var j = 0, jj = textItems.length; j < jj; j++) {
  3633. strBuf.push(textItems[j].str);
  3634. }
  3635. _this2._pageContents[i] = normalize(strBuf.join(''));
  3636. extractTextCapability.resolve(i);
  3637. }, function (reason) {
  3638. console.error("Unable to get text content for page ".concat(i + 1), reason);
  3639. _this2._pageContents[i] = '';
  3640. extractTextCapability.resolve(i);
  3641. });
  3642. });
  3643. };
  3644. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  3645. _loop(i, ii);
  3646. }
  3647. }
  3648. }, {
  3649. key: "_updatePage",
  3650. value: function _updatePage(index) {
  3651. if (this._scrollMatches && this._selected.pageIdx === index) {
  3652. this._linkService.page = index + 1;
  3653. }
  3654. this._eventBus.dispatch('updatetextlayermatches', {
  3655. source: this,
  3656. pageIndex: index
  3657. });
  3658. }
  3659. }, {
  3660. key: "_updateAllPages",
  3661. value: function _updateAllPages() {
  3662. this._eventBus.dispatch('updatetextlayermatches', {
  3663. source: this,
  3664. pageIndex: -1
  3665. });
  3666. }
  3667. }, {
  3668. key: "_nextMatch",
  3669. value: function _nextMatch() {
  3670. var _this3 = this;
  3671. var previous = this._state.findPrevious;
  3672. var currentPageIndex = this._linkService.page - 1;
  3673. var numPages = this._linkService.pagesCount;
  3674. this._highlightMatches = true;
  3675. if (this._dirtyMatch) {
  3676. this._dirtyMatch = false;
  3677. this._selected.pageIdx = this._selected.matchIdx = -1;
  3678. this._offset.pageIdx = currentPageIndex;
  3679. this._offset.matchIdx = null;
  3680. this._offset.wrapped = false;
  3681. this._resumePageIdx = null;
  3682. this._pageMatches.length = 0;
  3683. this._pageMatchesLength.length = 0;
  3684. this._matchesCountTotal = 0;
  3685. this._updateAllPages();
  3686. for (var i = 0; i < numPages; i++) {
  3687. if (this._pendingFindMatches[i] === true) {
  3688. continue;
  3689. }
  3690. this._pendingFindMatches[i] = true;
  3691. this._extractTextPromises[i].then(function (pageIdx) {
  3692. delete _this3._pendingFindMatches[pageIdx];
  3693. _this3._calculateMatch(pageIdx);
  3694. });
  3695. }
  3696. }
  3697. if (this._query === '') {
  3698. this._updateUIState(FindState.FOUND);
  3699. return;
  3700. }
  3701. if (this._resumePageIdx) {
  3702. return;
  3703. }
  3704. var offset = this._offset;
  3705. this._pagesToSearch = numPages;
  3706. if (offset.matchIdx !== null) {
  3707. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  3708. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3709. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3710. this._updateMatch(true);
  3711. return;
  3712. }
  3713. this._advanceOffsetPage(previous);
  3714. }
  3715. this._nextPageMatch();
  3716. }
  3717. }, {
  3718. key: "_matchesReady",
  3719. value: function _matchesReady(matches) {
  3720. var offset = this._offset;
  3721. var numMatches = matches.length;
  3722. var previous = this._state.findPrevious;
  3723. if (numMatches) {
  3724. offset.matchIdx = previous ? numMatches - 1 : 0;
  3725. this._updateMatch(true);
  3726. return true;
  3727. }
  3728. this._advanceOffsetPage(previous);
  3729. if (offset.wrapped) {
  3730. offset.matchIdx = null;
  3731. if (this._pagesToSearch < 0) {
  3732. this._updateMatch(false);
  3733. return true;
  3734. }
  3735. }
  3736. return false;
  3737. }
  3738. }, {
  3739. key: "_nextPageMatch",
  3740. value: function _nextPageMatch() {
  3741. if (this._resumePageIdx !== null) {
  3742. console.error('There can only be one pending page.');
  3743. }
  3744. var matches = null;
  3745. do {
  3746. var pageIdx = this._offset.pageIdx;
  3747. matches = this._pageMatches[pageIdx];
  3748. if (!matches) {
  3749. this._resumePageIdx = pageIdx;
  3750. break;
  3751. }
  3752. } while (!this._matchesReady(matches));
  3753. }
  3754. }, {
  3755. key: "_advanceOffsetPage",
  3756. value: function _advanceOffsetPage(previous) {
  3757. var offset = this._offset;
  3758. var numPages = this._linkService.pagesCount;
  3759. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3760. offset.matchIdx = null;
  3761. this._pagesToSearch--;
  3762. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3763. offset.pageIdx = previous ? numPages - 1 : 0;
  3764. offset.wrapped = true;
  3765. }
  3766. }
  3767. }, {
  3768. key: "_updateMatch",
  3769. value: function _updateMatch() {
  3770. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3771. var state = FindState.NOT_FOUND;
  3772. var wrapped = this._offset.wrapped;
  3773. this._offset.wrapped = false;
  3774. if (found) {
  3775. var previousPage = this._selected.pageIdx;
  3776. this._selected.pageIdx = this._offset.pageIdx;
  3777. this._selected.matchIdx = this._offset.matchIdx;
  3778. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  3779. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  3780. this._updatePage(previousPage);
  3781. }
  3782. }
  3783. this._updateUIState(state, this._state.findPrevious);
  3784. if (this._selected.pageIdx !== -1) {
  3785. this._scrollMatches = true;
  3786. this._updatePage(this._selected.pageIdx);
  3787. }
  3788. }
  3789. }, {
  3790. key: "_onFindBarClose",
  3791. value: function _onFindBarClose(evt) {
  3792. var _this4 = this;
  3793. var pdfDocument = this._pdfDocument;
  3794. this._firstPageCapability.promise.then(function () {
  3795. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  3796. return;
  3797. }
  3798. if (_this4._findTimeout) {
  3799. clearTimeout(_this4._findTimeout);
  3800. _this4._findTimeout = null;
  3801. }
  3802. if (_this4._resumePageIdx) {
  3803. _this4._resumePageIdx = null;
  3804. _this4._dirtyMatch = true;
  3805. }
  3806. _this4._updateUIState(FindState.FOUND);
  3807. _this4._highlightMatches = false;
  3808. _this4._updateAllPages();
  3809. });
  3810. }
  3811. }, {
  3812. key: "_requestMatchesCount",
  3813. value: function _requestMatchesCount() {
  3814. var _this$_selected = this._selected,
  3815. pageIdx = _this$_selected.pageIdx,
  3816. matchIdx = _this$_selected.matchIdx;
  3817. var current = 0,
  3818. total = this._matchesCountTotal;
  3819. if (matchIdx !== -1) {
  3820. for (var i = 0; i < pageIdx; i++) {
  3821. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  3822. }
  3823. current += matchIdx + 1;
  3824. }
  3825. if (current < 1 || current > total) {
  3826. current = total = 0;
  3827. }
  3828. return {
  3829. current: current,
  3830. total: total
  3831. };
  3832. }
  3833. }, {
  3834. key: "_updateUIResultsCount",
  3835. value: function _updateUIResultsCount() {
  3836. this._eventBus.dispatch('updatefindmatchescount', {
  3837. source: this,
  3838. matchesCount: this._requestMatchesCount()
  3839. });
  3840. }
  3841. }, {
  3842. key: "_updateUIState",
  3843. value: function _updateUIState(state, previous) {
  3844. this._eventBus.dispatch('updatefindcontrolstate', {
  3845. source: this,
  3846. state: state,
  3847. previous: previous,
  3848. matchesCount: this._requestMatchesCount()
  3849. });
  3850. }
  3851. }, {
  3852. key: "highlightMatches",
  3853. get: function get() {
  3854. return this._highlightMatches;
  3855. }
  3856. }, {
  3857. key: "pageMatches",
  3858. get: function get() {
  3859. return this._pageMatches;
  3860. }
  3861. }, {
  3862. key: "pageMatchesLength",
  3863. get: function get() {
  3864. return this._pageMatchesLength;
  3865. }
  3866. }, {
  3867. key: "selected",
  3868. get: function get() {
  3869. return this._selected;
  3870. }
  3871. }, {
  3872. key: "state",
  3873. get: function get() {
  3874. return this._state;
  3875. }
  3876. }, {
  3877. key: "_query",
  3878. get: function get() {
  3879. if (this._state.query !== this._rawQuery) {
  3880. this._rawQuery = this._state.query;
  3881. this._normalizedQuery = normalize(this._state.query);
  3882. }
  3883. return this._normalizedQuery;
  3884. }
  3885. }]);
  3886. return PDFFindController;
  3887. }();
  3888. exports.PDFFindController = PDFFindController;
  3889. /***/ }),
  3890. /* 13 */
  3891. /***/ (function(module, exports, __w_pdfjs_require__) {
  3892. "use strict";
  3893. Object.defineProperty(exports, "__esModule", {
  3894. value: true
  3895. });
  3896. exports.getCharacterType = getCharacterType;
  3897. exports.CharacterType = void 0;
  3898. var CharacterType = {
  3899. SPACE: 0,
  3900. ALPHA_LETTER: 1,
  3901. PUNCT: 2,
  3902. HAN_LETTER: 3,
  3903. KATAKANA_LETTER: 4,
  3904. HIRAGANA_LETTER: 5,
  3905. HALFWIDTH_KATAKANA_LETTER: 6,
  3906. THAI_LETTER: 7
  3907. };
  3908. exports.CharacterType = CharacterType;
  3909. function isAlphabeticalScript(charCode) {
  3910. return charCode < 0x2E80;
  3911. }
  3912. function isAscii(charCode) {
  3913. return (charCode & 0xFF80) === 0;
  3914. }
  3915. function isAsciiAlpha(charCode) {
  3916. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  3917. }
  3918. function isAsciiDigit(charCode) {
  3919. return charCode >= 0x30 && charCode <= 0x39;
  3920. }
  3921. function isAsciiSpace(charCode) {
  3922. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  3923. }
  3924. function isHan(charCode) {
  3925. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  3926. }
  3927. function isKatakana(charCode) {
  3928. return charCode >= 0x30A0 && charCode <= 0x30FF;
  3929. }
  3930. function isHiragana(charCode) {
  3931. return charCode >= 0x3040 && charCode <= 0x309F;
  3932. }
  3933. function isHalfwidthKatakana(charCode) {
  3934. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  3935. }
  3936. function isThai(charCode) {
  3937. return (charCode & 0xFF80) === 0x0E00;
  3938. }
  3939. function getCharacterType(charCode) {
  3940. if (isAlphabeticalScript(charCode)) {
  3941. if (isAscii(charCode)) {
  3942. if (isAsciiSpace(charCode)) {
  3943. return CharacterType.SPACE;
  3944. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  3945. return CharacterType.ALPHA_LETTER;
  3946. }
  3947. return CharacterType.PUNCT;
  3948. } else if (isThai(charCode)) {
  3949. return CharacterType.THAI_LETTER;
  3950. } else if (charCode === 0xA0) {
  3951. return CharacterType.SPACE;
  3952. }
  3953. return CharacterType.ALPHA_LETTER;
  3954. }
  3955. if (isHan(charCode)) {
  3956. return CharacterType.HAN_LETTER;
  3957. } else if (isKatakana(charCode)) {
  3958. return CharacterType.KATAKANA_LETTER;
  3959. } else if (isHiragana(charCode)) {
  3960. return CharacterType.HIRAGANA_LETTER;
  3961. } else if (isHalfwidthKatakana(charCode)) {
  3962. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  3963. }
  3964. return CharacterType.ALPHA_LETTER;
  3965. }
  3966. /***/ }),
  3967. /* 14 */
  3968. /***/ (function(module, exports, __w_pdfjs_require__) {
  3969. "use strict";
  3970. Object.defineProperty(exports, "__esModule", {
  3971. value: true
  3972. });
  3973. exports.isDestHashesEqual = isDestHashesEqual;
  3974. exports.isDestArraysEqual = isDestArraysEqual;
  3975. exports.PDFHistory = void 0;
  3976. var _ui_utils = __w_pdfjs_require__(3);
  3977. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3978. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  3979. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  3980. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3981. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3982. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3983. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3984. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3985. var HASH_CHANGE_TIMEOUT = 1000;
  3986. var POSITION_UPDATED_THRESHOLD = 50;
  3987. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  3988. function getCurrentHash() {
  3989. return document.location.hash;
  3990. }
  3991. function parseCurrentHash(linkService) {
  3992. var hash = unescape(getCurrentHash()).substring(1);
  3993. var params = (0, _ui_utils.parseQueryString)(hash);
  3994. var page = params.page | 0;
  3995. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  3996. page = null;
  3997. }
  3998. return {
  3999. hash: hash,
  4000. page: page,
  4001. rotation: linkService.rotation
  4002. };
  4003. }
  4004. var PDFHistory =
  4005. /*#__PURE__*/
  4006. function () {
  4007. function PDFHistory(_ref) {
  4008. var _this = this;
  4009. var linkService = _ref.linkService,
  4010. eventBus = _ref.eventBus;
  4011. _classCallCheck(this, PDFHistory);
  4012. this.linkService = linkService;
  4013. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  4014. this.initialized = false;
  4015. this.initialBookmark = null;
  4016. this.initialRotation = null;
  4017. this._boundEvents = Object.create(null);
  4018. this._isViewerInPresentationMode = false;
  4019. this._isPagesLoaded = false;
  4020. this.eventBus.on('presentationmodechanged', function (evt) {
  4021. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4022. });
  4023. this.eventBus.on('pagesloaded', function (evt) {
  4024. _this._isPagesLoaded = !!evt.pagesCount;
  4025. });
  4026. }
  4027. _createClass(PDFHistory, [{
  4028. key: "initialize",
  4029. value: function initialize(_ref2) {
  4030. var fingerprint = _ref2.fingerprint,
  4031. _ref2$resetHistory = _ref2.resetHistory,
  4032. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  4033. _ref2$updateUrl = _ref2.updateUrl,
  4034. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  4035. if (!fingerprint || typeof fingerprint !== 'string') {
  4036. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4037. return;
  4038. }
  4039. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  4040. this.fingerprint = fingerprint;
  4041. this._updateUrl = updateUrl === true;
  4042. if (!this.initialized) {
  4043. this._bindEvents();
  4044. }
  4045. var state = window.history.state;
  4046. this.initialized = true;
  4047. this.initialBookmark = null;
  4048. this.initialRotation = null;
  4049. this._popStateInProgress = false;
  4050. this._blockHashChange = 0;
  4051. this._currentHash = getCurrentHash();
  4052. this._numPositionUpdates = 0;
  4053. this._uid = this._maxUid = 0;
  4054. this._destination = null;
  4055. this._position = null;
  4056. if (!this._isValidState(state, true) || resetHistory) {
  4057. var _parseCurrentHash = parseCurrentHash(this.linkService),
  4058. hash = _parseCurrentHash.hash,
  4059. page = _parseCurrentHash.page,
  4060. rotation = _parseCurrentHash.rotation;
  4061. if (!hash || reInitialized || resetHistory) {
  4062. this._pushOrReplaceState(null, true);
  4063. return;
  4064. }
  4065. this._pushOrReplaceState({
  4066. hash: hash,
  4067. page: page,
  4068. rotation: rotation
  4069. }, true);
  4070. return;
  4071. }
  4072. var destination = state.destination;
  4073. this._updateInternalState(destination, state.uid, true);
  4074. if (this._uid > this._maxUid) {
  4075. this._maxUid = this._uid;
  4076. }
  4077. if (destination.rotation !== undefined) {
  4078. this.initialRotation = destination.rotation;
  4079. }
  4080. if (destination.dest) {
  4081. this.initialBookmark = JSON.stringify(destination.dest);
  4082. this._destination.page = null;
  4083. } else if (destination.hash) {
  4084. this.initialBookmark = destination.hash;
  4085. } else if (destination.page) {
  4086. this.initialBookmark = "page=".concat(destination.page);
  4087. }
  4088. }
  4089. }, {
  4090. key: "push",
  4091. value: function push(_ref3) {
  4092. var _this2 = this;
  4093. var _ref3$namedDest = _ref3.namedDest,
  4094. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  4095. explicitDest = _ref3.explicitDest,
  4096. pageNumber = _ref3.pageNumber;
  4097. if (!this.initialized) {
  4098. return;
  4099. }
  4100. if (namedDest && typeof namedDest !== 'string') {
  4101. console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  4102. return;
  4103. } else if (!Array.isArray(explicitDest)) {
  4104. console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  4105. return;
  4106. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4107. if (pageNumber !== null || this._destination) {
  4108. console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  4109. return;
  4110. }
  4111. }
  4112. var hash = namedDest || JSON.stringify(explicitDest);
  4113. if (!hash) {
  4114. return;
  4115. }
  4116. var forceReplace = false;
  4117. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4118. if (this._destination.page) {
  4119. return;
  4120. }
  4121. forceReplace = true;
  4122. }
  4123. if (this._popStateInProgress && !forceReplace) {
  4124. return;
  4125. }
  4126. this._pushOrReplaceState({
  4127. dest: explicitDest,
  4128. hash: hash,
  4129. page: pageNumber,
  4130. rotation: this.linkService.rotation
  4131. }, forceReplace);
  4132. if (!this._popStateInProgress) {
  4133. this._popStateInProgress = true;
  4134. Promise.resolve().then(function () {
  4135. _this2._popStateInProgress = false;
  4136. });
  4137. }
  4138. }
  4139. }, {
  4140. key: "pushCurrentPosition",
  4141. value: function pushCurrentPosition() {
  4142. if (!this.initialized || this._popStateInProgress) {
  4143. return;
  4144. }
  4145. this._tryPushCurrentPosition();
  4146. }
  4147. }, {
  4148. key: "back",
  4149. value: function back() {
  4150. if (!this.initialized || this._popStateInProgress) {
  4151. return;
  4152. }
  4153. var state = window.history.state;
  4154. if (this._isValidState(state) && state.uid > 0) {
  4155. window.history.back();
  4156. }
  4157. }
  4158. }, {
  4159. key: "forward",
  4160. value: function forward() {
  4161. if (!this.initialized || this._popStateInProgress) {
  4162. return;
  4163. }
  4164. var state = window.history.state;
  4165. if (this._isValidState(state) && state.uid < this._maxUid) {
  4166. window.history.forward();
  4167. }
  4168. }
  4169. }, {
  4170. key: "_pushOrReplaceState",
  4171. value: function _pushOrReplaceState(destination) {
  4172. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4173. var shouldReplace = forceReplace || !this._destination;
  4174. var newState = {
  4175. fingerprint: this.fingerprint,
  4176. uid: shouldReplace ? this._uid : this._uid + 1,
  4177. destination: destination
  4178. };
  4179. this._updateInternalState(destination, newState.uid);
  4180. var newUrl;
  4181. if (this._updateUrl && destination && destination.hash) {
  4182. var baseUrl = document.location.href.split('#')[0];
  4183. if (!baseUrl.startsWith('file://')) {
  4184. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  4185. }
  4186. }
  4187. if (shouldReplace) {
  4188. if (newUrl) {
  4189. window.history.replaceState(newState, '', newUrl);
  4190. } else {
  4191. window.history.replaceState(newState, '');
  4192. }
  4193. } else {
  4194. this._maxUid = this._uid;
  4195. if (newUrl) {
  4196. window.history.pushState(newState, '', newUrl);
  4197. } else {
  4198. window.history.pushState(newState, '');
  4199. }
  4200. }
  4201. }
  4202. }, {
  4203. key: "_tryPushCurrentPosition",
  4204. value: function _tryPushCurrentPosition() {
  4205. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4206. if (!this._position) {
  4207. return;
  4208. }
  4209. var position = this._position;
  4210. if (temporary) {
  4211. position = Object.assign(Object.create(null), this._position);
  4212. position.temporary = true;
  4213. }
  4214. if (!this._destination) {
  4215. this._pushOrReplaceState(position);
  4216. return;
  4217. }
  4218. if (this._destination.temporary) {
  4219. this._pushOrReplaceState(position, true);
  4220. return;
  4221. }
  4222. if (this._destination.hash === position.hash) {
  4223. return;
  4224. }
  4225. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4226. return;
  4227. }
  4228. var forceReplace = false;
  4229. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  4230. if (this._destination.dest || !this._destination.first) {
  4231. return;
  4232. }
  4233. forceReplace = true;
  4234. }
  4235. this._pushOrReplaceState(position, forceReplace);
  4236. }
  4237. }, {
  4238. key: "_isValidState",
  4239. value: function _isValidState(state) {
  4240. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4241. if (!state) {
  4242. return false;
  4243. }
  4244. if (state.fingerprint !== this.fingerprint) {
  4245. if (checkReload) {
  4246. if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
  4247. return false;
  4248. }
  4249. var _performance$getEntri = performance.getEntriesByType('navigation'),
  4250. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  4251. perfEntry = _performance$getEntri2[0];
  4252. if (!perfEntry || perfEntry.type !== 'reload') {
  4253. return false;
  4254. }
  4255. } else {
  4256. return false;
  4257. }
  4258. }
  4259. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4260. return false;
  4261. }
  4262. if (state.destination === null || _typeof(state.destination) !== 'object') {
  4263. return false;
  4264. }
  4265. return true;
  4266. }
  4267. }, {
  4268. key: "_updateInternalState",
  4269. value: function _updateInternalState(destination, uid) {
  4270. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4271. if (this._updateViewareaTimeout) {
  4272. clearTimeout(this._updateViewareaTimeout);
  4273. this._updateViewareaTimeout = null;
  4274. }
  4275. if (removeTemporary && destination && destination.temporary) {
  4276. delete destination.temporary;
  4277. }
  4278. this._destination = destination;
  4279. this._uid = uid;
  4280. this._numPositionUpdates = 0;
  4281. }
  4282. }, {
  4283. key: "_updateViewarea",
  4284. value: function _updateViewarea(_ref4) {
  4285. var _this3 = this;
  4286. var location = _ref4.location;
  4287. if (this._updateViewareaTimeout) {
  4288. clearTimeout(this._updateViewareaTimeout);
  4289. this._updateViewareaTimeout = null;
  4290. }
  4291. this._position = {
  4292. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  4293. page: this.linkService.page,
  4294. first: location.pageNumber,
  4295. rotation: location.rotation
  4296. };
  4297. if (this._popStateInProgress) {
  4298. return;
  4299. }
  4300. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4301. this._numPositionUpdates++;
  4302. }
  4303. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4304. this._updateViewareaTimeout = setTimeout(function () {
  4305. if (!_this3._popStateInProgress) {
  4306. _this3._tryPushCurrentPosition(true);
  4307. }
  4308. _this3._updateViewareaTimeout = null;
  4309. }, UPDATE_VIEWAREA_TIMEOUT);
  4310. }
  4311. }
  4312. }, {
  4313. key: "_popState",
  4314. value: function _popState(_ref5) {
  4315. var _this4 = this;
  4316. var state = _ref5.state;
  4317. var newHash = getCurrentHash(),
  4318. hashChanged = this._currentHash !== newHash;
  4319. this._currentHash = newHash;
  4320. if (!state || false) {
  4321. this._uid++;
  4322. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  4323. hash = _parseCurrentHash2.hash,
  4324. page = _parseCurrentHash2.page,
  4325. rotation = _parseCurrentHash2.rotation;
  4326. this._pushOrReplaceState({
  4327. hash: hash,
  4328. page: page,
  4329. rotation: rotation
  4330. }, true);
  4331. return;
  4332. }
  4333. if (!this._isValidState(state)) {
  4334. return;
  4335. }
  4336. this._popStateInProgress = true;
  4337. if (hashChanged) {
  4338. this._blockHashChange++;
  4339. (0, _ui_utils.waitOnEventOrTimeout)({
  4340. target: window,
  4341. name: 'hashchange',
  4342. delay: HASH_CHANGE_TIMEOUT
  4343. }).then(function () {
  4344. _this4._blockHashChange--;
  4345. });
  4346. }
  4347. var destination = state.destination;
  4348. this._updateInternalState(destination, state.uid, true);
  4349. if (this._uid > this._maxUid) {
  4350. this._maxUid = this._uid;
  4351. }
  4352. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4353. this.linkService.rotation = destination.rotation;
  4354. }
  4355. if (destination.dest) {
  4356. this.linkService.navigateTo(destination.dest);
  4357. } else if (destination.hash) {
  4358. this.linkService.setHash(destination.hash);
  4359. } else if (destination.page) {
  4360. this.linkService.page = destination.page;
  4361. }
  4362. Promise.resolve().then(function () {
  4363. _this4._popStateInProgress = false;
  4364. });
  4365. }
  4366. }, {
  4367. key: "_bindEvents",
  4368. value: function _bindEvents() {
  4369. var _this5 = this;
  4370. var _boundEvents = this._boundEvents,
  4371. eventBus = this.eventBus;
  4372. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  4373. _boundEvents.popState = this._popState.bind(this);
  4374. _boundEvents.pageHide = function (evt) {
  4375. if (!_this5._destination || _this5._destination.temporary) {
  4376. _this5._tryPushCurrentPosition();
  4377. }
  4378. };
  4379. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  4380. window.addEventListener('popstate', _boundEvents.popState);
  4381. window.addEventListener('pagehide', _boundEvents.pageHide);
  4382. }
  4383. }, {
  4384. key: "popStateInProgress",
  4385. get: function get() {
  4386. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4387. }
  4388. }]);
  4389. return PDFHistory;
  4390. }();
  4391. exports.PDFHistory = PDFHistory;
  4392. function isDestHashesEqual(destHash, pushHash) {
  4393. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  4394. return false;
  4395. }
  4396. if (destHash === pushHash) {
  4397. return true;
  4398. }
  4399. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4400. nameddest = _parseQueryString.nameddest;
  4401. if (nameddest === pushHash) {
  4402. return true;
  4403. }
  4404. return false;
  4405. }
  4406. function isDestArraysEqual(firstDest, secondDest) {
  4407. function isEntryEqual(first, second) {
  4408. if (_typeof(first) !== _typeof(second)) {
  4409. return false;
  4410. }
  4411. if (Array.isArray(first) || Array.isArray(second)) {
  4412. return false;
  4413. }
  4414. if (first !== null && _typeof(first) === 'object' && second !== null) {
  4415. if (Object.keys(first).length !== Object.keys(second).length) {
  4416. return false;
  4417. }
  4418. for (var key in first) {
  4419. if (!isEntryEqual(first[key], second[key])) {
  4420. return false;
  4421. }
  4422. }
  4423. return true;
  4424. }
  4425. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4426. }
  4427. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  4428. return false;
  4429. }
  4430. if (firstDest.length !== secondDest.length) {
  4431. return false;
  4432. }
  4433. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4434. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4435. return false;
  4436. }
  4437. }
  4438. return true;
  4439. }
  4440. /***/ }),
  4441. /* 15 */
  4442. /***/ (function(module, exports, __w_pdfjs_require__) {
  4443. "use strict";
  4444. Object.defineProperty(exports, "__esModule", {
  4445. value: true
  4446. });
  4447. exports.PDFPageView = void 0;
  4448. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  4449. var _ui_utils = __w_pdfjs_require__(3);
  4450. var _pdfjsLib = __w_pdfjs_require__(2);
  4451. var _pdf_rendering_queue = __w_pdfjs_require__(16);
  4452. var _viewer_compatibility = __w_pdfjs_require__(17);
  4453. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4454. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4455. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4456. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4457. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4458. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4459. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  4460. var PDFPageView =
  4461. /*#__PURE__*/
  4462. function () {
  4463. function PDFPageView(options) {
  4464. _classCallCheck(this, PDFPageView);
  4465. var container = options.container;
  4466. var defaultViewport = options.defaultViewport;
  4467. this.id = options.id;
  4468. this.renderingId = 'page' + this.id;
  4469. this.pdfPage = null;
  4470. this.pageLabel = null;
  4471. this.rotation = 0;
  4472. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  4473. this.viewport = defaultViewport;
  4474. this.pdfPageRotate = defaultViewport.rotation;
  4475. this.hasRestrictedScaling = false;
  4476. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4477. this.imageResourcesPath = options.imageResourcesPath || '';
  4478. this.renderInteractiveForms = options.renderInteractiveForms || false;
  4479. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4480. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  4481. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  4482. this.renderingQueue = options.renderingQueue;
  4483. this.textLayerFactory = options.textLayerFactory;
  4484. this.annotationLayerFactory = options.annotationLayerFactory;
  4485. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4486. this.enableWebGL = options.enableWebGL || false;
  4487. this.l10n = options.l10n || _ui_utils.NullL10n;
  4488. this.paintTask = null;
  4489. this.paintedViewportMap = new WeakMap();
  4490. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4491. this.resume = null;
  4492. this.error = null;
  4493. this.annotationLayer = null;
  4494. this.textLayer = null;
  4495. this.zoomLayer = null;
  4496. var div = document.createElement('div');
  4497. div.className = 'page';
  4498. div.style.width = Math.floor(this.viewport.width) + 'px';
  4499. div.style.height = Math.floor(this.viewport.height) + 'px';
  4500. div.setAttribute('data-page-number', this.id);
  4501. this.div = div;
  4502. container.appendChild(div);
  4503. }
  4504. _createClass(PDFPageView, [{
  4505. key: "setPdfPage",
  4506. value: function setPdfPage(pdfPage) {
  4507. this.pdfPage = pdfPage;
  4508. this.pdfPageRotate = pdfPage.rotate;
  4509. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4510. this.viewport = pdfPage.getViewport({
  4511. scale: this.scale * _ui_utils.CSS_UNITS,
  4512. rotation: totalRotation
  4513. });
  4514. this.stats = pdfPage.stats;
  4515. this.reset();
  4516. }
  4517. }, {
  4518. key: "destroy",
  4519. value: function destroy() {
  4520. this.reset();
  4521. if (this.pdfPage) {
  4522. this.pdfPage.cleanup();
  4523. }
  4524. }
  4525. }, {
  4526. key: "_resetZoomLayer",
  4527. value: function _resetZoomLayer() {
  4528. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4529. if (!this.zoomLayer) {
  4530. return;
  4531. }
  4532. var zoomLayerCanvas = this.zoomLayer.firstChild;
  4533. this.paintedViewportMap["delete"](zoomLayerCanvas);
  4534. zoomLayerCanvas.width = 0;
  4535. zoomLayerCanvas.height = 0;
  4536. if (removeFromDOM) {
  4537. this.zoomLayer.remove();
  4538. }
  4539. this.zoomLayer = null;
  4540. }
  4541. }, {
  4542. key: "reset",
  4543. value: function reset() {
  4544. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4545. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4546. this.cancelRendering(keepAnnotations);
  4547. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4548. var div = this.div;
  4549. div.style.width = Math.floor(this.viewport.width) + 'px';
  4550. div.style.height = Math.floor(this.viewport.height) + 'px';
  4551. var childNodes = div.childNodes;
  4552. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  4553. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  4554. for (var i = childNodes.length - 1; i >= 0; i--) {
  4555. var node = childNodes[i];
  4556. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  4557. continue;
  4558. }
  4559. div.removeChild(node);
  4560. }
  4561. div.removeAttribute('data-loaded');
  4562. if (currentAnnotationNode) {
  4563. this.annotationLayer.hide();
  4564. } else if (this.annotationLayer) {
  4565. this.annotationLayer.cancel();
  4566. this.annotationLayer = null;
  4567. }
  4568. if (!currentZoomLayerNode) {
  4569. if (this.canvas) {
  4570. this.paintedViewportMap["delete"](this.canvas);
  4571. this.canvas.width = 0;
  4572. this.canvas.height = 0;
  4573. delete this.canvas;
  4574. }
  4575. this._resetZoomLayer();
  4576. }
  4577. if (this.svg) {
  4578. this.paintedViewportMap["delete"](this.svg);
  4579. delete this.svg;
  4580. }
  4581. this.loadingIconDiv = document.createElement('div');
  4582. this.loadingIconDiv.className = 'loadingIcon';
  4583. div.appendChild(this.loadingIconDiv);
  4584. }
  4585. }, {
  4586. key: "update",
  4587. value: function update(scale, rotation) {
  4588. this.scale = scale || this.scale;
  4589. if (typeof rotation !== 'undefined') {
  4590. this.rotation = rotation;
  4591. }
  4592. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4593. this.viewport = this.viewport.clone({
  4594. scale: this.scale * _ui_utils.CSS_UNITS,
  4595. rotation: totalRotation
  4596. });
  4597. if (this.svg) {
  4598. this.cssTransform(this.svg, true);
  4599. this.eventBus.dispatch('pagerendered', {
  4600. source: this,
  4601. pageNumber: this.id,
  4602. cssTransform: true,
  4603. timestamp: performance.now()
  4604. });
  4605. return;
  4606. }
  4607. var isScalingRestricted = false;
  4608. if (this.canvas && this.maxCanvasPixels > 0) {
  4609. var outputScale = this.outputScale;
  4610. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  4611. isScalingRestricted = true;
  4612. }
  4613. }
  4614. if (this.canvas) {
  4615. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  4616. this.cssTransform(this.canvas, true);
  4617. this.eventBus.dispatch('pagerendered', {
  4618. source: this,
  4619. pageNumber: this.id,
  4620. cssTransform: true,
  4621. timestamp: performance.now()
  4622. });
  4623. return;
  4624. }
  4625. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  4626. this.zoomLayer = this.canvas.parentNode;
  4627. this.zoomLayer.style.position = 'absolute';
  4628. }
  4629. }
  4630. if (this.zoomLayer) {
  4631. this.cssTransform(this.zoomLayer.firstChild);
  4632. }
  4633. this.reset(true, true);
  4634. }
  4635. }, {
  4636. key: "cancelRendering",
  4637. value: function cancelRendering() {
  4638. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4639. if (this.paintTask) {
  4640. this.paintTask.cancel();
  4641. this.paintTask = null;
  4642. }
  4643. this.resume = null;
  4644. if (this.textLayer) {
  4645. this.textLayer.cancel();
  4646. this.textLayer = null;
  4647. }
  4648. if (!keepAnnotations && this.annotationLayer) {
  4649. this.annotationLayer.cancel();
  4650. this.annotationLayer = null;
  4651. }
  4652. }
  4653. }, {
  4654. key: "cssTransform",
  4655. value: function cssTransform(target) {
  4656. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4657. var width = this.viewport.width;
  4658. var height = this.viewport.height;
  4659. var div = this.div;
  4660. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  4661. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  4662. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  4663. var absRotation = Math.abs(relativeRotation);
  4664. var scaleX = 1,
  4665. scaleY = 1;
  4666. if (absRotation === 90 || absRotation === 270) {
  4667. scaleX = height / width;
  4668. scaleY = width / height;
  4669. }
  4670. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  4671. target.style.transform = cssTransform;
  4672. if (this.textLayer) {
  4673. var textLayerViewport = this.textLayer.viewport;
  4674. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  4675. var textAbsRotation = Math.abs(textRelativeRotation);
  4676. var scale = width / textLayerViewport.width;
  4677. if (textAbsRotation === 90 || textAbsRotation === 270) {
  4678. scale = width / textLayerViewport.height;
  4679. }
  4680. var textLayerDiv = this.textLayer.textLayerDiv;
  4681. var transX, transY;
  4682. switch (textAbsRotation) {
  4683. case 0:
  4684. transX = transY = 0;
  4685. break;
  4686. case 90:
  4687. transX = 0;
  4688. transY = '-' + textLayerDiv.style.height;
  4689. break;
  4690. case 180:
  4691. transX = '-' + textLayerDiv.style.width;
  4692. transY = '-' + textLayerDiv.style.height;
  4693. break;
  4694. case 270:
  4695. transX = '-' + textLayerDiv.style.width;
  4696. transY = 0;
  4697. break;
  4698. default:
  4699. console.error('Bad rotation value.');
  4700. break;
  4701. }
  4702. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  4703. textLayerDiv.style.transformOrigin = '0% 0%';
  4704. }
  4705. if (redrawAnnotations && this.annotationLayer) {
  4706. this.annotationLayer.render(this.viewport, 'display');
  4707. }
  4708. }
  4709. }, {
  4710. key: "getPagePoint",
  4711. value: function getPagePoint(x, y) {
  4712. return this.viewport.convertToPdfPoint(x, y);
  4713. }
  4714. }, {
  4715. key: "draw",
  4716. value: function draw() {
  4717. var _this = this;
  4718. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  4719. console.error('Must be in new state before drawing');
  4720. this.reset();
  4721. }
  4722. if (!this.pdfPage) {
  4723. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4724. return Promise.reject(new Error('Page is not loaded'));
  4725. }
  4726. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  4727. var pdfPage = this.pdfPage;
  4728. var div = this.div;
  4729. var canvasWrapper = document.createElement('div');
  4730. canvasWrapper.style.width = div.style.width;
  4731. canvasWrapper.style.height = div.style.height;
  4732. canvasWrapper.classList.add('canvasWrapper');
  4733. if (this.annotationLayer && this.annotationLayer.div) {
  4734. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  4735. } else {
  4736. div.appendChild(canvasWrapper);
  4737. }
  4738. var textLayer = null;
  4739. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  4740. var textLayerDiv = document.createElement('div');
  4741. textLayerDiv.className = 'textLayer';
  4742. textLayerDiv.style.width = canvasWrapper.style.width;
  4743. textLayerDiv.style.height = canvasWrapper.style.height;
  4744. if (this.annotationLayer && this.annotationLayer.div) {
  4745. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  4746. } else {
  4747. div.appendChild(textLayerDiv);
  4748. }
  4749. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  4750. }
  4751. this.textLayer = textLayer;
  4752. var renderContinueCallback = null;
  4753. if (this.renderingQueue) {
  4754. renderContinueCallback = function renderContinueCallback(cont) {
  4755. if (!_this.renderingQueue.isHighestPriority(_this)) {
  4756. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  4757. _this.resume = function () {
  4758. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  4759. cont();
  4760. };
  4761. return;
  4762. }
  4763. cont();
  4764. };
  4765. }
  4766. var finishPaintTask =
  4767. /*#__PURE__*/
  4768. function () {
  4769. var _ref = _asyncToGenerator(
  4770. /*#__PURE__*/
  4771. _regenerator["default"].mark(function _callee(error) {
  4772. return _regenerator["default"].wrap(function _callee$(_context) {
  4773. while (1) {
  4774. switch (_context.prev = _context.next) {
  4775. case 0:
  4776. if (paintTask === _this.paintTask) {
  4777. _this.paintTask = null;
  4778. }
  4779. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  4780. _context.next = 4;
  4781. break;
  4782. }
  4783. _this.error = null;
  4784. return _context.abrupt("return");
  4785. case 4:
  4786. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4787. if (_this.loadingIconDiv) {
  4788. div.removeChild(_this.loadingIconDiv);
  4789. delete _this.loadingIconDiv;
  4790. }
  4791. _this._resetZoomLayer(true);
  4792. _this.error = error;
  4793. _this.stats = pdfPage.stats;
  4794. _this.eventBus.dispatch('pagerendered', {
  4795. source: _this,
  4796. pageNumber: _this.id,
  4797. cssTransform: false,
  4798. timestamp: performance.now()
  4799. });
  4800. if (!error) {
  4801. _context.next = 12;
  4802. break;
  4803. }
  4804. throw error;
  4805. case 12:
  4806. case "end":
  4807. return _context.stop();
  4808. }
  4809. }
  4810. }, _callee);
  4811. }));
  4812. return function finishPaintTask(_x) {
  4813. return _ref.apply(this, arguments);
  4814. };
  4815. }();
  4816. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  4817. paintTask.onRenderContinue = renderContinueCallback;
  4818. this.paintTask = paintTask;
  4819. var resultPromise = paintTask.promise.then(function () {
  4820. return finishPaintTask(null).then(function () {
  4821. if (textLayer) {
  4822. var readableStream = pdfPage.streamTextContent({
  4823. normalizeWhitespace: true
  4824. });
  4825. textLayer.setTextContentStream(readableStream);
  4826. textLayer.render();
  4827. }
  4828. });
  4829. }, function (reason) {
  4830. return finishPaintTask(reason);
  4831. });
  4832. if (this.annotationLayerFactory) {
  4833. if (!this.annotationLayer) {
  4834. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  4835. }
  4836. this.annotationLayer.render(this.viewport, 'display');
  4837. }
  4838. div.setAttribute('data-loaded', true);
  4839. this.eventBus.dispatch('pagerender', {
  4840. source: this,
  4841. pageNumber: this.id
  4842. });
  4843. return resultPromise;
  4844. }
  4845. }, {
  4846. key: "paintOnCanvas",
  4847. value: function paintOnCanvas(canvasWrapper) {
  4848. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  4849. var result = {
  4850. promise: renderCapability.promise,
  4851. onRenderContinue: function onRenderContinue(cont) {
  4852. cont();
  4853. },
  4854. cancel: function cancel() {
  4855. renderTask.cancel();
  4856. }
  4857. };
  4858. var viewport = this.viewport;
  4859. var canvas = document.createElement('canvas');
  4860. canvas.id = this.renderingId;
  4861. canvas.setAttribute('hidden', 'hidden');
  4862. var isCanvasHidden = true;
  4863. var showCanvas = function showCanvas() {
  4864. if (isCanvasHidden) {
  4865. canvas.removeAttribute('hidden');
  4866. isCanvasHidden = false;
  4867. }
  4868. };
  4869. canvasWrapper.appendChild(canvas);
  4870. this.canvas = canvas;
  4871. canvas.mozOpaque = true;
  4872. var ctx = canvas.getContext('2d', {
  4873. alpha: false
  4874. });
  4875. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  4876. this.outputScale = outputScale;
  4877. if (this.useOnlyCssZoom) {
  4878. var actualSizeViewport = viewport.clone({
  4879. scale: _ui_utils.CSS_UNITS
  4880. });
  4881. outputScale.sx *= actualSizeViewport.width / viewport.width;
  4882. outputScale.sy *= actualSizeViewport.height / viewport.height;
  4883. outputScale.scaled = true;
  4884. }
  4885. if (this.maxCanvasPixels > 0) {
  4886. var pixelsInViewport = viewport.width * viewport.height;
  4887. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  4888. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  4889. outputScale.sx = maxScale;
  4890. outputScale.sy = maxScale;
  4891. outputScale.scaled = true;
  4892. this.hasRestrictedScaling = true;
  4893. } else {
  4894. this.hasRestrictedScaling = false;
  4895. }
  4896. }
  4897. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  4898. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  4899. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  4900. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  4901. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  4902. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  4903. this.paintedViewportMap.set(canvas, viewport);
  4904. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  4905. var renderContext = {
  4906. canvasContext: ctx,
  4907. transform: transform,
  4908. viewport: this.viewport,
  4909. enableWebGL: this.enableWebGL,
  4910. renderInteractiveForms: this.renderInteractiveForms
  4911. };
  4912. var renderTask = this.pdfPage.render(renderContext);
  4913. renderTask.onContinue = function (cont) {
  4914. showCanvas();
  4915. if (result.onRenderContinue) {
  4916. result.onRenderContinue(cont);
  4917. } else {
  4918. cont();
  4919. }
  4920. };
  4921. renderTask.promise.then(function () {
  4922. showCanvas();
  4923. renderCapability.resolve(undefined);
  4924. }, function (error) {
  4925. showCanvas();
  4926. renderCapability.reject(error);
  4927. });
  4928. return result;
  4929. }
  4930. }, {
  4931. key: "paintOnSvg",
  4932. value: function paintOnSvg(wrapper) {
  4933. var _this2 = this;
  4934. var cancelled = false;
  4935. var ensureNotCancelled = function ensureNotCancelled() {
  4936. if (cancelled) {
  4937. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  4938. }
  4939. };
  4940. var pdfPage = this.pdfPage;
  4941. var actualSizeViewport = this.viewport.clone({
  4942. scale: _ui_utils.CSS_UNITS
  4943. });
  4944. var promise = pdfPage.getOperatorList().then(function (opList) {
  4945. ensureNotCancelled();
  4946. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  4947. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  4948. ensureNotCancelled();
  4949. _this2.svg = svg;
  4950. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  4951. svg.style.width = wrapper.style.width;
  4952. svg.style.height = wrapper.style.height;
  4953. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4954. wrapper.appendChild(svg);
  4955. });
  4956. });
  4957. return {
  4958. promise: promise,
  4959. onRenderContinue: function onRenderContinue(cont) {
  4960. cont();
  4961. },
  4962. cancel: function cancel() {
  4963. cancelled = true;
  4964. }
  4965. };
  4966. }
  4967. }, {
  4968. key: "setPageLabel",
  4969. value: function setPageLabel(label) {
  4970. this.pageLabel = typeof label === 'string' ? label : null;
  4971. if (this.pageLabel !== null) {
  4972. this.div.setAttribute('data-page-label', this.pageLabel);
  4973. } else {
  4974. this.div.removeAttribute('data-page-label');
  4975. }
  4976. }
  4977. }, {
  4978. key: "width",
  4979. get: function get() {
  4980. return this.viewport.width;
  4981. }
  4982. }, {
  4983. key: "height",
  4984. get: function get() {
  4985. return this.viewport.height;
  4986. }
  4987. }]);
  4988. return PDFPageView;
  4989. }();
  4990. exports.PDFPageView = PDFPageView;
  4991. /***/ }),
  4992. /* 16 */
  4993. /***/ (function(module, exports, __w_pdfjs_require__) {
  4994. "use strict";
  4995. Object.defineProperty(exports, "__esModule", {
  4996. value: true
  4997. });
  4998. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4999. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5000. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5001. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5002. var CLEANUP_TIMEOUT = 30000;
  5003. var RenderingStates = {
  5004. INITIAL: 0,
  5005. RUNNING: 1,
  5006. PAUSED: 2,
  5007. FINISHED: 3
  5008. };
  5009. exports.RenderingStates = RenderingStates;
  5010. var PDFRenderingQueue =
  5011. /*#__PURE__*/
  5012. function () {
  5013. function PDFRenderingQueue() {
  5014. _classCallCheck(this, PDFRenderingQueue);
  5015. this.pdfViewer = null;
  5016. this.pdfThumbnailViewer = null;
  5017. this.onIdle = null;
  5018. this.highestPriorityPage = null;
  5019. this.idleTimeout = null;
  5020. this.printing = false;
  5021. this.isThumbnailViewEnabled = false;
  5022. }
  5023. _createClass(PDFRenderingQueue, [{
  5024. key: "setViewer",
  5025. value: function setViewer(pdfViewer) {
  5026. this.pdfViewer = pdfViewer;
  5027. }
  5028. }, {
  5029. key: "setThumbnailViewer",
  5030. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5031. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5032. }
  5033. }, {
  5034. key: "isHighestPriority",
  5035. value: function isHighestPriority(view) {
  5036. return this.highestPriorityPage === view.renderingId;
  5037. }
  5038. }, {
  5039. key: "renderHighestPriority",
  5040. value: function renderHighestPriority(currentlyVisiblePages) {
  5041. if (this.idleTimeout) {
  5042. clearTimeout(this.idleTimeout);
  5043. this.idleTimeout = null;
  5044. }
  5045. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5046. return;
  5047. }
  5048. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5049. if (this.pdfThumbnailViewer.forceRendering()) {
  5050. return;
  5051. }
  5052. }
  5053. if (this.printing) {
  5054. return;
  5055. }
  5056. if (this.onIdle) {
  5057. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5058. }
  5059. }
  5060. }, {
  5061. key: "getHighestPriority",
  5062. value: function getHighestPriority(visible, views, scrolledDown) {
  5063. var visibleViews = visible.views;
  5064. var numVisible = visibleViews.length;
  5065. if (numVisible === 0) {
  5066. return null;
  5067. }
  5068. for (var i = 0; i < numVisible; ++i) {
  5069. var view = visibleViews[i].view;
  5070. if (!this.isViewFinished(view)) {
  5071. return view;
  5072. }
  5073. }
  5074. if (scrolledDown) {
  5075. var nextPageIndex = visible.last.id;
  5076. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5077. return views[nextPageIndex];
  5078. }
  5079. } else {
  5080. var previousPageIndex = visible.first.id - 2;
  5081. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5082. return views[previousPageIndex];
  5083. }
  5084. }
  5085. return null;
  5086. }
  5087. }, {
  5088. key: "isViewFinished",
  5089. value: function isViewFinished(view) {
  5090. return view.renderingState === RenderingStates.FINISHED;
  5091. }
  5092. }, {
  5093. key: "renderView",
  5094. value: function renderView(view) {
  5095. var _this = this;
  5096. switch (view.renderingState) {
  5097. case RenderingStates.FINISHED:
  5098. return false;
  5099. case RenderingStates.PAUSED:
  5100. this.highestPriorityPage = view.renderingId;
  5101. view.resume();
  5102. break;
  5103. case RenderingStates.RUNNING:
  5104. this.highestPriorityPage = view.renderingId;
  5105. break;
  5106. case RenderingStates.INITIAL:
  5107. this.highestPriorityPage = view.renderingId;
  5108. view.draw()["finally"](function () {
  5109. _this.renderHighestPriority();
  5110. });
  5111. break;
  5112. }
  5113. return true;
  5114. }
  5115. }]);
  5116. return PDFRenderingQueue;
  5117. }();
  5118. exports.PDFRenderingQueue = PDFRenderingQueue;
  5119. /***/ }),
  5120. /* 17 */
  5121. /***/ (function(module, exports, __w_pdfjs_require__) {
  5122. "use strict";
  5123. var compatibilityParams = Object.create(null);
  5124. {
  5125. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  5126. var isAndroid = /Android/.test(userAgent);
  5127. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  5128. (function checkCanvasSizeLimitation() {
  5129. if (isIOS || isAndroid) {
  5130. compatibilityParams.maxCanvasPixels = 5242880;
  5131. }
  5132. })();
  5133. }
  5134. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  5135. /***/ }),
  5136. /* 18 */
  5137. /***/ (function(module, exports, __w_pdfjs_require__) {
  5138. "use strict";
  5139. Object.defineProperty(exports, "__esModule", {
  5140. value: true
  5141. });
  5142. exports.PDFSinglePageViewer = void 0;
  5143. var _base_viewer = __w_pdfjs_require__(19);
  5144. var _pdfjsLib = __w_pdfjs_require__(2);
  5145. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5146. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5147. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5148. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5149. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5150. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5151. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  5152. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5153. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5154. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  5155. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5156. var PDFSinglePageViewer =
  5157. /*#__PURE__*/
  5158. function (_BaseViewer) {
  5159. _inherits(PDFSinglePageViewer, _BaseViewer);
  5160. function PDFSinglePageViewer(options) {
  5161. var _this;
  5162. _classCallCheck(this, PDFSinglePageViewer);
  5163. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
  5164. _this.eventBus.on('pagesinit', function (evt) {
  5165. _this._ensurePageViewVisible();
  5166. });
  5167. return _this;
  5168. }
  5169. _createClass(PDFSinglePageViewer, [{
  5170. key: "_resetView",
  5171. value: function _resetView() {
  5172. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  5173. this._previousPageNumber = 1;
  5174. this._shadowViewer = document.createDocumentFragment();
  5175. this._updateScrollDown = null;
  5176. }
  5177. }, {
  5178. key: "_ensurePageViewVisible",
  5179. value: function _ensurePageViewVisible() {
  5180. var pageView = this._pages[this._currentPageNumber - 1];
  5181. var previousPageView = this._pages[this._previousPageNumber - 1];
  5182. var viewerNodes = this.viewer.childNodes;
  5183. switch (viewerNodes.length) {
  5184. case 0:
  5185. this.viewer.appendChild(pageView.div);
  5186. break;
  5187. case 1:
  5188. if (viewerNodes[0] !== previousPageView.div) {
  5189. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  5190. }
  5191. if (pageView === previousPageView) {
  5192. break;
  5193. }
  5194. this._shadowViewer.appendChild(previousPageView.div);
  5195. this.viewer.appendChild(pageView.div);
  5196. this.container.scrollTop = 0;
  5197. break;
  5198. default:
  5199. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  5200. }
  5201. this._previousPageNumber = this._currentPageNumber;
  5202. }
  5203. }, {
  5204. key: "_scrollUpdate",
  5205. value: function _scrollUpdate() {
  5206. if (this._updateScrollDown) {
  5207. this._updateScrollDown();
  5208. }
  5209. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  5210. }
  5211. }, {
  5212. key: "_scrollIntoView",
  5213. value: function _scrollIntoView(_ref) {
  5214. var _this2 = this;
  5215. var pageDiv = _ref.pageDiv,
  5216. _ref$pageSpot = _ref.pageSpot,
  5217. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  5218. _ref$pageNumber = _ref.pageNumber,
  5219. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  5220. if (pageNumber) {
  5221. this._setCurrentPageNumber(pageNumber);
  5222. }
  5223. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  5224. this._ensurePageViewVisible();
  5225. this.update();
  5226. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  5227. pageDiv: pageDiv,
  5228. pageSpot: pageSpot,
  5229. pageNumber: pageNumber
  5230. });
  5231. this._updateScrollDown = function () {
  5232. _this2.scroll.down = scrolledDown;
  5233. _this2._updateScrollDown = null;
  5234. };
  5235. }
  5236. }, {
  5237. key: "_getVisiblePages",
  5238. value: function _getVisiblePages() {
  5239. return this._getCurrentVisiblePage();
  5240. }
  5241. }, {
  5242. key: "_updateHelper",
  5243. value: function _updateHelper(visiblePages) {}
  5244. }, {
  5245. key: "_updateScrollMode",
  5246. value: function _updateScrollMode() {}
  5247. }, {
  5248. key: "_updateSpreadMode",
  5249. value: function _updateSpreadMode() {}
  5250. }, {
  5251. key: "_setDocumentViewerElement",
  5252. get: function get() {
  5253. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  5254. }
  5255. }, {
  5256. key: "_isScrollModeHorizontal",
  5257. get: function get() {
  5258. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  5259. }
  5260. }]);
  5261. return PDFSinglePageViewer;
  5262. }(_base_viewer.BaseViewer);
  5263. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  5264. /***/ }),
  5265. /* 19 */
  5266. /***/ (function(module, exports, __w_pdfjs_require__) {
  5267. "use strict";
  5268. Object.defineProperty(exports, "__esModule", {
  5269. value: true
  5270. });
  5271. exports.BaseViewer = void 0;
  5272. var _ui_utils = __w_pdfjs_require__(3);
  5273. var _pdf_rendering_queue = __w_pdfjs_require__(16);
  5274. var _annotation_layer_builder = __w_pdfjs_require__(1);
  5275. var _pdfjsLib = __w_pdfjs_require__(2);
  5276. var _pdf_page_view = __w_pdfjs_require__(15);
  5277. var _pdf_link_service = __w_pdfjs_require__(7);
  5278. var _text_layer_builder = __w_pdfjs_require__(8);
  5279. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5280. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5281. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5282. var DEFAULT_CACHE_SIZE = 10;
  5283. function PDFPageViewBuffer(size) {
  5284. var data = [];
  5285. this.push = function (view) {
  5286. var i = data.indexOf(view);
  5287. if (i >= 0) {
  5288. data.splice(i, 1);
  5289. }
  5290. data.push(view);
  5291. if (data.length > size) {
  5292. data.shift().destroy();
  5293. }
  5294. };
  5295. this.resize = function (newSize, pagesToKeep) {
  5296. size = newSize;
  5297. if (pagesToKeep) {
  5298. var pageIdsToKeep = new Set();
  5299. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  5300. pageIdsToKeep.add(pagesToKeep[i].id);
  5301. }
  5302. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  5303. return pageIdsToKeep.has(page.id);
  5304. });
  5305. }
  5306. while (data.length > size) {
  5307. data.shift().destroy();
  5308. }
  5309. };
  5310. }
  5311. function isSameScale(oldScale, newScale) {
  5312. if (newScale === oldScale) {
  5313. return true;
  5314. }
  5315. if (Math.abs(newScale - oldScale) < 1e-15) {
  5316. return true;
  5317. }
  5318. return false;
  5319. }
  5320. var BaseViewer =
  5321. /*#__PURE__*/
  5322. function () {
  5323. function BaseViewer(options) {
  5324. var _this = this;
  5325. _classCallCheck(this, BaseViewer);
  5326. if (this.constructor === BaseViewer) {
  5327. throw new Error('Cannot initialize BaseViewer.');
  5328. }
  5329. this._name = this.constructor.name;
  5330. this.container = options.container;
  5331. this.viewer = options.viewer || options.container.firstElementChild;
  5332. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  5333. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  5334. this.downloadManager = options.downloadManager || null;
  5335. this.findController = options.findController || null;
  5336. this.removePageBorders = options.removePageBorders || false;
  5337. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  5338. this.imageResourcesPath = options.imageResourcesPath || '';
  5339. this.renderInteractiveForms = options.renderInteractiveForms || false;
  5340. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  5341. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  5342. this.enableWebGL = options.enableWebGL || false;
  5343. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  5344. this.maxCanvasPixels = options.maxCanvasPixels;
  5345. this.l10n = options.l10n || _ui_utils.NullL10n;
  5346. this.defaultRenderingQueue = !options.renderingQueue;
  5347. if (this.defaultRenderingQueue) {
  5348. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  5349. this.renderingQueue.setViewer(this);
  5350. } else {
  5351. this.renderingQueue = options.renderingQueue;
  5352. }
  5353. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  5354. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  5355. this._onBeforeDraw = this._onAfterDraw = null;
  5356. this._resetView();
  5357. if (this.removePageBorders) {
  5358. this.viewer.classList.add('removePageBorders');
  5359. }
  5360. Promise.resolve().then(function () {
  5361. _this.eventBus.dispatch('baseviewerinit', {
  5362. source: _this
  5363. });
  5364. });
  5365. }
  5366. _createClass(BaseViewer, [{
  5367. key: "getPageView",
  5368. value: function getPageView(index) {
  5369. return this._pages[index];
  5370. }
  5371. }, {
  5372. key: "_setCurrentPageNumber",
  5373. value: function _setCurrentPageNumber(val) {
  5374. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5375. if (this._currentPageNumber === val) {
  5376. if (resetCurrentPageView) {
  5377. this._resetCurrentPageView();
  5378. }
  5379. return true;
  5380. }
  5381. if (!(0 < val && val <= this.pagesCount)) {
  5382. return false;
  5383. }
  5384. this._currentPageNumber = val;
  5385. this.eventBus.dispatch('pagechanging', {
  5386. source: this,
  5387. pageNumber: val,
  5388. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  5389. });
  5390. if (resetCurrentPageView) {
  5391. this._resetCurrentPageView();
  5392. }
  5393. return true;
  5394. }
  5395. }, {
  5396. key: "setDocument",
  5397. value: function setDocument(pdfDocument) {
  5398. var _this2 = this;
  5399. if (this.pdfDocument) {
  5400. this._cancelRendering();
  5401. this._resetView();
  5402. if (this.findController) {
  5403. this.findController.setDocument(null);
  5404. }
  5405. }
  5406. this.pdfDocument = pdfDocument;
  5407. if (!pdfDocument) {
  5408. return;
  5409. }
  5410. var pagesCount = pdfDocument.numPages;
  5411. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  5412. this.pagesPromise = pagesCapability.promise;
  5413. pagesCapability.promise.then(function () {
  5414. _this2._pageViewsReady = true;
  5415. _this2.eventBus.dispatch('pagesloaded', {
  5416. source: _this2,
  5417. pagesCount: pagesCount
  5418. });
  5419. });
  5420. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5421. this.onePageRendered = onePageRenderedCapability.promise;
  5422. var firstPagePromise = pdfDocument.getPage(1);
  5423. this.firstPagePromise = firstPagePromise;
  5424. this._onBeforeDraw = function (evt) {
  5425. var pageView = _this2._pages[evt.pageNumber - 1];
  5426. if (!pageView) {
  5427. return;
  5428. }
  5429. _this2._buffer.push(pageView);
  5430. };
  5431. this.eventBus.on('pagerender', this._onBeforeDraw);
  5432. this._onAfterDraw = function (evt) {
  5433. if (evt.cssTransform || onePageRenderedCapability.settled) {
  5434. return;
  5435. }
  5436. onePageRenderedCapability.resolve();
  5437. _this2.eventBus.off('pagerendered', _this2._onAfterDraw);
  5438. _this2._onAfterDraw = null;
  5439. };
  5440. this.eventBus.on('pagerendered', this._onAfterDraw);
  5441. firstPagePromise.then(function (pdfPage) {
  5442. var scale = _this2.currentScale;
  5443. var viewport = pdfPage.getViewport({
  5444. scale: scale * _ui_utils.CSS_UNITS
  5445. });
  5446. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  5447. var textLayerFactory = null;
  5448. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  5449. textLayerFactory = _this2;
  5450. }
  5451. var pageView = new _pdf_page_view.PDFPageView({
  5452. container: _this2._setDocumentViewerElement,
  5453. eventBus: _this2.eventBus,
  5454. id: pageNum,
  5455. scale: scale,
  5456. defaultViewport: viewport.clone(),
  5457. renderingQueue: _this2.renderingQueue,
  5458. textLayerFactory: textLayerFactory,
  5459. textLayerMode: _this2.textLayerMode,
  5460. annotationLayerFactory: _this2,
  5461. imageResourcesPath: _this2.imageResourcesPath,
  5462. renderInteractiveForms: _this2.renderInteractiveForms,
  5463. renderer: _this2.renderer,
  5464. enableWebGL: _this2.enableWebGL,
  5465. useOnlyCssZoom: _this2.useOnlyCssZoom,
  5466. maxCanvasPixels: _this2.maxCanvasPixels,
  5467. l10n: _this2.l10n
  5468. });
  5469. _this2._pages.push(pageView);
  5470. }
  5471. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  5472. _this2._updateSpreadMode();
  5473. }
  5474. onePageRenderedCapability.promise.then(function () {
  5475. if (_this2.findController) {
  5476. _this2.findController.setDocument(pdfDocument);
  5477. }
  5478. if (pdfDocument.loadingParams['disableAutoFetch']) {
  5479. pagesCapability.resolve();
  5480. return;
  5481. }
  5482. var getPagesLeft = pagesCount;
  5483. var _loop = function _loop(_pageNum) {
  5484. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  5485. var pageView = _this2._pages[_pageNum - 1];
  5486. if (!pageView.pdfPage) {
  5487. pageView.setPdfPage(pdfPage);
  5488. }
  5489. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  5490. if (--getPagesLeft === 0) {
  5491. pagesCapability.resolve();
  5492. }
  5493. }, function (reason) {
  5494. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  5495. if (--getPagesLeft === 0) {
  5496. pagesCapability.resolve();
  5497. }
  5498. });
  5499. };
  5500. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  5501. _loop(_pageNum);
  5502. }
  5503. });
  5504. _this2.eventBus.dispatch('pagesinit', {
  5505. source: _this2
  5506. });
  5507. if (_this2.defaultRenderingQueue) {
  5508. _this2.update();
  5509. }
  5510. })["catch"](function (reason) {
  5511. console.error('Unable to initialize viewer', reason);
  5512. });
  5513. }
  5514. }, {
  5515. key: "setPageLabels",
  5516. value: function setPageLabels(labels) {
  5517. if (!this.pdfDocument) {
  5518. return;
  5519. }
  5520. if (!labels) {
  5521. this._pageLabels = null;
  5522. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  5523. this._pageLabels = null;
  5524. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  5525. } else {
  5526. this._pageLabels = labels;
  5527. }
  5528. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5529. var pageView = this._pages[i];
  5530. var label = this._pageLabels && this._pageLabels[i];
  5531. pageView.setPageLabel(label);
  5532. }
  5533. }
  5534. }, {
  5535. key: "_resetView",
  5536. value: function _resetView() {
  5537. this._pages = [];
  5538. this._currentPageNumber = 1;
  5539. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  5540. this._currentScaleValue = null;
  5541. this._pageLabels = null;
  5542. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  5543. this._location = null;
  5544. this._pagesRotation = 0;
  5545. this._pagesRequests = [];
  5546. this._pageViewsReady = false;
  5547. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  5548. this._spreadMode = _ui_utils.SpreadMode.NONE;
  5549. if (this._onBeforeDraw) {
  5550. this.eventBus.off('pagerender', this._onBeforeDraw);
  5551. this._onBeforeDraw = null;
  5552. }
  5553. if (this._onAfterDraw) {
  5554. this.eventBus.off('pagerendered', this._onAfterDraw);
  5555. this._onAfterDraw = null;
  5556. }
  5557. this.viewer.textContent = '';
  5558. this._updateScrollMode();
  5559. }
  5560. }, {
  5561. key: "_scrollUpdate",
  5562. value: function _scrollUpdate() {
  5563. if (this.pagesCount === 0) {
  5564. return;
  5565. }
  5566. this.update();
  5567. }
  5568. }, {
  5569. key: "_scrollIntoView",
  5570. value: function _scrollIntoView(_ref) {
  5571. var pageDiv = _ref.pageDiv,
  5572. _ref$pageSpot = _ref.pageSpot,
  5573. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  5574. _ref$pageNumber = _ref.pageNumber,
  5575. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  5576. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  5577. }
  5578. }, {
  5579. key: "_setScaleUpdatePages",
  5580. value: function _setScaleUpdatePages(newScale, newValue) {
  5581. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5582. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5583. this._currentScaleValue = newValue.toString();
  5584. if (isSameScale(this._currentScale, newScale)) {
  5585. if (preset) {
  5586. this.eventBus.dispatch('scalechanging', {
  5587. source: this,
  5588. scale: newScale,
  5589. presetValue: newValue
  5590. });
  5591. }
  5592. return;
  5593. }
  5594. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5595. this._pages[i].update(newScale);
  5596. }
  5597. this._currentScale = newScale;
  5598. if (!noScroll) {
  5599. var page = this._currentPageNumber,
  5600. dest;
  5601. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  5602. page = this._location.pageNumber;
  5603. dest = [null, {
  5604. name: 'XYZ'
  5605. }, this._location.left, this._location.top, null];
  5606. }
  5607. this.scrollPageIntoView({
  5608. pageNumber: page,
  5609. destArray: dest,
  5610. allowNegativeOffset: true
  5611. });
  5612. }
  5613. this.eventBus.dispatch('scalechanging', {
  5614. source: this,
  5615. scale: newScale,
  5616. presetValue: preset ? newValue : undefined
  5617. });
  5618. if (this.defaultRenderingQueue) {
  5619. this.update();
  5620. }
  5621. }
  5622. }, {
  5623. key: "_setScale",
  5624. value: function _setScale(value) {
  5625. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5626. var scale = parseFloat(value);
  5627. if (scale > 0) {
  5628. this._setScaleUpdatePages(scale, value, noScroll, false);
  5629. } else {
  5630. var currentPage = this._pages[this._currentPageNumber - 1];
  5631. if (!currentPage) {
  5632. return;
  5633. }
  5634. var noPadding = this.isInPresentationMode || this.removePageBorders;
  5635. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  5636. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  5637. if (!noPadding && this._isScrollModeHorizontal) {
  5638. var _ref2 = [vPadding, hPadding];
  5639. hPadding = _ref2[0];
  5640. vPadding = _ref2[1];
  5641. }
  5642. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  5643. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  5644. switch (value) {
  5645. case 'page-actual':
  5646. scale = 1;
  5647. break;
  5648. case 'page-width':
  5649. scale = pageWidthScale;
  5650. break;
  5651. case 'page-height':
  5652. scale = pageHeightScale;
  5653. break;
  5654. case 'page-fit':
  5655. scale = Math.min(pageWidthScale, pageHeightScale);
  5656. break;
  5657. case 'auto':
  5658. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  5659. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  5660. break;
  5661. default:
  5662. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  5663. return;
  5664. }
  5665. this._setScaleUpdatePages(scale, value, noScroll, true);
  5666. }
  5667. }
  5668. }, {
  5669. key: "_resetCurrentPageView",
  5670. value: function _resetCurrentPageView() {
  5671. if (this.isInPresentationMode) {
  5672. this._setScale(this._currentScaleValue, true);
  5673. }
  5674. var pageView = this._pages[this._currentPageNumber - 1];
  5675. this._scrollIntoView({
  5676. pageDiv: pageView.div
  5677. });
  5678. }
  5679. }, {
  5680. key: "scrollPageIntoView",
  5681. value: function scrollPageIntoView(_ref3) {
  5682. var pageNumber = _ref3.pageNumber,
  5683. _ref3$destArray = _ref3.destArray,
  5684. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  5685. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  5686. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
  5687. if (!this.pdfDocument) {
  5688. return;
  5689. }
  5690. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  5691. if (!pageView) {
  5692. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  5693. return;
  5694. }
  5695. if (this.isInPresentationMode || !destArray) {
  5696. this._setCurrentPageNumber(pageNumber, true);
  5697. return;
  5698. }
  5699. var x = 0,
  5700. y = 0;
  5701. var width = 0,
  5702. height = 0,
  5703. widthScale,
  5704. heightScale;
  5705. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  5706. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  5707. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  5708. var scale = 0;
  5709. switch (destArray[1].name) {
  5710. case 'XYZ':
  5711. x = destArray[2];
  5712. y = destArray[3];
  5713. scale = destArray[4];
  5714. x = x !== null ? x : 0;
  5715. y = y !== null ? y : pageHeight;
  5716. break;
  5717. case 'Fit':
  5718. case 'FitB':
  5719. scale = 'page-fit';
  5720. break;
  5721. case 'FitH':
  5722. case 'FitBH':
  5723. y = destArray[2];
  5724. scale = 'page-width';
  5725. if (y === null && this._location) {
  5726. x = this._location.left;
  5727. y = this._location.top;
  5728. }
  5729. break;
  5730. case 'FitV':
  5731. case 'FitBV':
  5732. x = destArray[2];
  5733. width = pageWidth;
  5734. height = pageHeight;
  5735. scale = 'page-height';
  5736. break;
  5737. case 'FitR':
  5738. x = destArray[2];
  5739. y = destArray[3];
  5740. width = destArray[4] - x;
  5741. height = destArray[5] - y;
  5742. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  5743. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  5744. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  5745. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  5746. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  5747. break;
  5748. default:
  5749. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  5750. return;
  5751. }
  5752. if (scale && scale !== this._currentScale) {
  5753. this.currentScaleValue = scale;
  5754. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  5755. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  5756. }
  5757. if (scale === 'page-fit' && !destArray[4]) {
  5758. this._scrollIntoView({
  5759. pageDiv: pageView.div,
  5760. pageNumber: pageNumber
  5761. });
  5762. return;
  5763. }
  5764. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  5765. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  5766. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  5767. if (!allowNegativeOffset) {
  5768. left = Math.max(left, 0);
  5769. top = Math.max(top, 0);
  5770. }
  5771. this._scrollIntoView({
  5772. pageDiv: pageView.div,
  5773. pageSpot: {
  5774. left: left,
  5775. top: top
  5776. },
  5777. pageNumber: pageNumber
  5778. });
  5779. }
  5780. }, {
  5781. key: "_updateLocation",
  5782. value: function _updateLocation(firstPage) {
  5783. var currentScale = this._currentScale;
  5784. var currentScaleValue = this._currentScaleValue;
  5785. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  5786. var pageNumber = firstPage.id;
  5787. var pdfOpenParams = '#page=' + pageNumber;
  5788. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  5789. var currentPageView = this._pages[pageNumber - 1];
  5790. var container = this.container;
  5791. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  5792. var intLeft = Math.round(topLeft[0]);
  5793. var intTop = Math.round(topLeft[1]);
  5794. pdfOpenParams += ',' + intLeft + ',' + intTop;
  5795. this._location = {
  5796. pageNumber: pageNumber,
  5797. scale: normalizedScaleValue,
  5798. top: intTop,
  5799. left: intLeft,
  5800. rotation: this._pagesRotation,
  5801. pdfOpenParams: pdfOpenParams
  5802. };
  5803. }
  5804. }, {
  5805. key: "_updateHelper",
  5806. value: function _updateHelper(visiblePages) {
  5807. throw new Error('Not implemented: _updateHelper');
  5808. }
  5809. }, {
  5810. key: "update",
  5811. value: function update() {
  5812. var visible = this._getVisiblePages();
  5813. var visiblePages = visible.views,
  5814. numVisiblePages = visiblePages.length;
  5815. if (numVisiblePages === 0) {
  5816. return;
  5817. }
  5818. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  5819. this._buffer.resize(newCacheSize, visiblePages);
  5820. this.renderingQueue.renderHighestPriority(visible);
  5821. this._updateHelper(visiblePages);
  5822. this._updateLocation(visible.first);
  5823. this.eventBus.dispatch('updateviewarea', {
  5824. source: this,
  5825. location: this._location
  5826. });
  5827. }
  5828. }, {
  5829. key: "containsElement",
  5830. value: function containsElement(element) {
  5831. return this.container.contains(element);
  5832. }
  5833. }, {
  5834. key: "focus",
  5835. value: function focus() {
  5836. this.container.focus();
  5837. }
  5838. }, {
  5839. key: "_getCurrentVisiblePage",
  5840. value: function _getCurrentVisiblePage() {
  5841. if (!this.pagesCount) {
  5842. return {
  5843. views: []
  5844. };
  5845. }
  5846. var pageView = this._pages[this._currentPageNumber - 1];
  5847. var element = pageView.div;
  5848. var view = {
  5849. id: pageView.id,
  5850. x: element.offsetLeft + element.clientLeft,
  5851. y: element.offsetTop + element.clientTop,
  5852. view: pageView
  5853. };
  5854. return {
  5855. first: view,
  5856. last: view,
  5857. views: [view]
  5858. };
  5859. }
  5860. }, {
  5861. key: "_getVisiblePages",
  5862. value: function _getVisiblePages() {
  5863. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  5864. }
  5865. }, {
  5866. key: "isPageVisible",
  5867. value: function isPageVisible(pageNumber) {
  5868. if (!this.pdfDocument) {
  5869. return false;
  5870. }
  5871. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  5872. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  5873. return false;
  5874. }
  5875. return this._getVisiblePages().views.some(function (view) {
  5876. return view.id === pageNumber;
  5877. });
  5878. }
  5879. }, {
  5880. key: "cleanup",
  5881. value: function cleanup() {
  5882. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5883. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  5884. this._pages[i].reset();
  5885. }
  5886. }
  5887. }
  5888. }, {
  5889. key: "_cancelRendering",
  5890. value: function _cancelRendering() {
  5891. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5892. if (this._pages[i]) {
  5893. this._pages[i].cancelRendering();
  5894. }
  5895. }
  5896. }
  5897. }, {
  5898. key: "_ensurePdfPageLoaded",
  5899. value: function _ensurePdfPageLoaded(pageView) {
  5900. var _this3 = this;
  5901. if (pageView.pdfPage) {
  5902. return Promise.resolve(pageView.pdfPage);
  5903. }
  5904. var pageNumber = pageView.id;
  5905. if (this._pagesRequests[pageNumber]) {
  5906. return this._pagesRequests[pageNumber];
  5907. }
  5908. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  5909. if (!pageView.pdfPage) {
  5910. pageView.setPdfPage(pdfPage);
  5911. }
  5912. _this3._pagesRequests[pageNumber] = null;
  5913. return pdfPage;
  5914. })["catch"](function (reason) {
  5915. console.error('Unable to get page for page view', reason);
  5916. _this3._pagesRequests[pageNumber] = null;
  5917. });
  5918. this._pagesRequests[pageNumber] = promise;
  5919. return promise;
  5920. }
  5921. }, {
  5922. key: "forceRendering",
  5923. value: function forceRendering(currentlyVisiblePages) {
  5924. var _this4 = this;
  5925. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  5926. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  5927. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  5928. if (pageView) {
  5929. this._ensurePdfPageLoaded(pageView).then(function () {
  5930. _this4.renderingQueue.renderView(pageView);
  5931. });
  5932. return true;
  5933. }
  5934. return false;
  5935. }
  5936. }, {
  5937. key: "createTextLayerBuilder",
  5938. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  5939. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5940. return new _text_layer_builder.TextLayerBuilder({
  5941. textLayerDiv: textLayerDiv,
  5942. eventBus: this.eventBus,
  5943. pageIndex: pageIndex,
  5944. viewport: viewport,
  5945. findController: this.isInPresentationMode ? null : this.findController,
  5946. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  5947. });
  5948. }
  5949. }, {
  5950. key: "createAnnotationLayerBuilder",
  5951. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  5952. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  5953. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5954. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  5955. return new _annotation_layer_builder.AnnotationLayerBuilder({
  5956. pageDiv: pageDiv,
  5957. pdfPage: pdfPage,
  5958. imageResourcesPath: imageResourcesPath,
  5959. renderInteractiveForms: renderInteractiveForms,
  5960. linkService: this.linkService,
  5961. downloadManager: this.downloadManager,
  5962. l10n: l10n
  5963. });
  5964. }
  5965. }, {
  5966. key: "getPagesOverview",
  5967. value: function getPagesOverview() {
  5968. var pagesOverview = this._pages.map(function (pageView) {
  5969. var viewport = pageView.pdfPage.getViewport({
  5970. scale: 1
  5971. });
  5972. return {
  5973. width: viewport.width,
  5974. height: viewport.height,
  5975. rotation: viewport.rotation
  5976. };
  5977. });
  5978. if (!this.enablePrintAutoRotate) {
  5979. return pagesOverview;
  5980. }
  5981. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  5982. return pagesOverview.map(function (size) {
  5983. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  5984. return size;
  5985. }
  5986. return {
  5987. width: size.height,
  5988. height: size.width,
  5989. rotation: (size.rotation + 90) % 360
  5990. };
  5991. });
  5992. }
  5993. }, {
  5994. key: "_updateScrollMode",
  5995. value: function _updateScrollMode() {
  5996. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5997. var scrollMode = this._scrollMode,
  5998. viewer = this.viewer;
  5999. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  6000. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
  6001. if (!this.pdfDocument || !pageNumber) {
  6002. return;
  6003. }
  6004. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  6005. this._setScale(this._currentScaleValue, true);
  6006. }
  6007. this._setCurrentPageNumber(pageNumber, true);
  6008. this.update();
  6009. }
  6010. }, {
  6011. key: "_updateSpreadMode",
  6012. value: function _updateSpreadMode() {
  6013. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6014. if (!this.pdfDocument) {
  6015. return;
  6016. }
  6017. var viewer = this.viewer,
  6018. pages = this._pages;
  6019. viewer.textContent = '';
  6020. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  6021. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  6022. viewer.appendChild(pages[i].div);
  6023. }
  6024. } else {
  6025. var parity = this._spreadMode - 1;
  6026. var spread = null;
  6027. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  6028. if (spread === null) {
  6029. spread = document.createElement('div');
  6030. spread.className = 'spread';
  6031. viewer.appendChild(spread);
  6032. } else if (_i % 2 === parity) {
  6033. spread = spread.cloneNode(false);
  6034. viewer.appendChild(spread);
  6035. }
  6036. spread.appendChild(pages[_i].div);
  6037. }
  6038. }
  6039. if (!pageNumber) {
  6040. return;
  6041. }
  6042. this._setCurrentPageNumber(pageNumber, true);
  6043. this.update();
  6044. }
  6045. }, {
  6046. key: "pagesCount",
  6047. get: function get() {
  6048. return this._pages.length;
  6049. }
  6050. }, {
  6051. key: "pageViewsReady",
  6052. get: function get() {
  6053. return this._pageViewsReady;
  6054. }
  6055. }, {
  6056. key: "currentPageNumber",
  6057. get: function get() {
  6058. return this._currentPageNumber;
  6059. },
  6060. set: function set(val) {
  6061. if (!Number.isInteger(val)) {
  6062. throw new Error('Invalid page number.');
  6063. }
  6064. if (!this.pdfDocument) {
  6065. return;
  6066. }
  6067. if (!this._setCurrentPageNumber(val, true)) {
  6068. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  6069. }
  6070. }
  6071. }, {
  6072. key: "currentPageLabel",
  6073. get: function get() {
  6074. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  6075. },
  6076. set: function set(val) {
  6077. if (!this.pdfDocument) {
  6078. return;
  6079. }
  6080. var page = val | 0;
  6081. if (this._pageLabels) {
  6082. var i = this._pageLabels.indexOf(val);
  6083. if (i >= 0) {
  6084. page = i + 1;
  6085. }
  6086. }
  6087. if (!this._setCurrentPageNumber(page, true)) {
  6088. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  6089. }
  6090. }
  6091. }, {
  6092. key: "currentScale",
  6093. get: function get() {
  6094. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  6095. },
  6096. set: function set(val) {
  6097. if (isNaN(val)) {
  6098. throw new Error('Invalid numeric scale.');
  6099. }
  6100. if (!this.pdfDocument) {
  6101. return;
  6102. }
  6103. this._setScale(val, false);
  6104. }
  6105. }, {
  6106. key: "currentScaleValue",
  6107. get: function get() {
  6108. return this._currentScaleValue;
  6109. },
  6110. set: function set(val) {
  6111. if (!this.pdfDocument) {
  6112. return;
  6113. }
  6114. this._setScale(val, false);
  6115. }
  6116. }, {
  6117. key: "pagesRotation",
  6118. get: function get() {
  6119. return this._pagesRotation;
  6120. },
  6121. set: function set(rotation) {
  6122. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  6123. throw new Error('Invalid pages rotation angle.');
  6124. }
  6125. if (!this.pdfDocument) {
  6126. return;
  6127. }
  6128. if (this._pagesRotation === rotation) {
  6129. return;
  6130. }
  6131. this._pagesRotation = rotation;
  6132. var pageNumber = this._currentPageNumber;
  6133. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6134. var pageView = this._pages[i];
  6135. pageView.update(pageView.scale, rotation);
  6136. }
  6137. if (this._currentScaleValue) {
  6138. this._setScale(this._currentScaleValue, true);
  6139. }
  6140. this.eventBus.dispatch('rotationchanging', {
  6141. source: this,
  6142. pagesRotation: rotation,
  6143. pageNumber: pageNumber
  6144. });
  6145. if (this.defaultRenderingQueue) {
  6146. this.update();
  6147. }
  6148. }
  6149. }, {
  6150. key: "_setDocumentViewerElement",
  6151. get: function get() {
  6152. throw new Error('Not implemented: _setDocumentViewerElement');
  6153. }
  6154. }, {
  6155. key: "_isScrollModeHorizontal",
  6156. get: function get() {
  6157. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  6158. }
  6159. }, {
  6160. key: "isInPresentationMode",
  6161. get: function get() {
  6162. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  6163. }
  6164. }, {
  6165. key: "isChangingPresentationMode",
  6166. get: function get() {
  6167. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  6168. }
  6169. }, {
  6170. key: "isHorizontalScrollbarEnabled",
  6171. get: function get() {
  6172. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  6173. }
  6174. }, {
  6175. key: "isVerticalScrollbarEnabled",
  6176. get: function get() {
  6177. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  6178. }
  6179. }, {
  6180. key: "hasEqualPageSizes",
  6181. get: function get() {
  6182. var firstPageView = this._pages[0];
  6183. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  6184. var pageView = this._pages[i];
  6185. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  6186. return false;
  6187. }
  6188. }
  6189. return true;
  6190. }
  6191. }, {
  6192. key: "scrollMode",
  6193. get: function get() {
  6194. return this._scrollMode;
  6195. },
  6196. set: function set(mode) {
  6197. if (this._scrollMode === mode) {
  6198. return;
  6199. }
  6200. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  6201. throw new Error("Invalid scroll mode: ".concat(mode));
  6202. }
  6203. this._scrollMode = mode;
  6204. this.eventBus.dispatch('scrollmodechanged', {
  6205. source: this,
  6206. mode: mode
  6207. });
  6208. this._updateScrollMode(this._currentPageNumber);
  6209. }
  6210. }, {
  6211. key: "spreadMode",
  6212. get: function get() {
  6213. return this._spreadMode;
  6214. },
  6215. set: function set(mode) {
  6216. if (this._spreadMode === mode) {
  6217. return;
  6218. }
  6219. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  6220. throw new Error("Invalid spread mode: ".concat(mode));
  6221. }
  6222. this._spreadMode = mode;
  6223. this.eventBus.dispatch('spreadmodechanged', {
  6224. source: this,
  6225. mode: mode
  6226. });
  6227. this._updateSpreadMode(this._currentPageNumber);
  6228. }
  6229. }]);
  6230. return BaseViewer;
  6231. }();
  6232. exports.BaseViewer = BaseViewer;
  6233. /***/ }),
  6234. /* 20 */
  6235. /***/ (function(module, exports, __w_pdfjs_require__) {
  6236. "use strict";
  6237. Object.defineProperty(exports, "__esModule", {
  6238. value: true
  6239. });
  6240. exports.PDFViewer = void 0;
  6241. var _base_viewer = __w_pdfjs_require__(19);
  6242. var _pdfjsLib = __w_pdfjs_require__(2);
  6243. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6244. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6245. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6246. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6247. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  6248. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6249. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  6250. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  6251. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6252. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  6253. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6254. var PDFViewer =
  6255. /*#__PURE__*/
  6256. function (_BaseViewer) {
  6257. _inherits(PDFViewer, _BaseViewer);
  6258. function PDFViewer() {
  6259. _classCallCheck(this, PDFViewer);
  6260. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  6261. }
  6262. _createClass(PDFViewer, [{
  6263. key: "_scrollIntoView",
  6264. value: function _scrollIntoView(_ref) {
  6265. var pageDiv = _ref.pageDiv,
  6266. _ref$pageSpot = _ref.pageSpot,
  6267. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  6268. _ref$pageNumber = _ref.pageNumber,
  6269. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  6270. if (!pageSpot && !this.isInPresentationMode) {
  6271. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  6272. var right = left + pageDiv.clientWidth;
  6273. var _this$container = this.container,
  6274. scrollLeft = _this$container.scrollLeft,
  6275. clientWidth = _this$container.clientWidth;
  6276. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  6277. pageSpot = {
  6278. left: 0,
  6279. top: 0
  6280. };
  6281. }
  6282. }
  6283. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  6284. pageDiv: pageDiv,
  6285. pageSpot: pageSpot,
  6286. pageNumber: pageNumber
  6287. });
  6288. }
  6289. }, {
  6290. key: "_getVisiblePages",
  6291. value: function _getVisiblePages() {
  6292. if (this.isInPresentationMode) {
  6293. return this._getCurrentVisiblePage();
  6294. }
  6295. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  6296. }
  6297. }, {
  6298. key: "_updateHelper",
  6299. value: function _updateHelper(visiblePages) {
  6300. if (this.isInPresentationMode) {
  6301. return;
  6302. }
  6303. var currentId = this._currentPageNumber;
  6304. var stillFullyVisible = false;
  6305. var _iteratorNormalCompletion = true;
  6306. var _didIteratorError = false;
  6307. var _iteratorError = undefined;
  6308. try {
  6309. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6310. var page = _step.value;
  6311. if (page.percent < 100) {
  6312. break;
  6313. }
  6314. if (page.id === currentId) {
  6315. stillFullyVisible = true;
  6316. break;
  6317. }
  6318. }
  6319. } catch (err) {
  6320. _didIteratorError = true;
  6321. _iteratorError = err;
  6322. } finally {
  6323. try {
  6324. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  6325. _iterator["return"]();
  6326. }
  6327. } finally {
  6328. if (_didIteratorError) {
  6329. throw _iteratorError;
  6330. }
  6331. }
  6332. }
  6333. if (!stillFullyVisible) {
  6334. currentId = visiblePages[0].id;
  6335. }
  6336. this._setCurrentPageNumber(currentId);
  6337. }
  6338. }, {
  6339. key: "_setDocumentViewerElement",
  6340. get: function get() {
  6341. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  6342. }
  6343. }]);
  6344. return PDFViewer;
  6345. }(_base_viewer.BaseViewer);
  6346. exports.PDFViewer = PDFViewer;
  6347. /***/ })
  6348. /******/ ]);
  6349. });
  6350. //# sourceMappingURL=pdf_viewer.js.map