pdf_viewer.js 218 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662
  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.2.228';
  233. var pdfjsBuild = 'd7afb74a';
  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) { 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. _classCallCheck(this, PDFLinkService);
  1610. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  1611. this.externalLinkTarget = externalLinkTarget;
  1612. this.externalLinkRel = externalLinkRel;
  1613. this.baseUrl = null;
  1614. this.pdfDocument = null;
  1615. this.pdfViewer = null;
  1616. this.pdfHistory = null;
  1617. this._pagesRefCache = null;
  1618. }
  1619. _createClass(PDFLinkService, [{
  1620. key: "setDocument",
  1621. value: function setDocument(pdfDocument) {
  1622. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1623. this.baseUrl = baseUrl;
  1624. this.pdfDocument = pdfDocument;
  1625. this._pagesRefCache = Object.create(null);
  1626. }
  1627. }, {
  1628. key: "setViewer",
  1629. value: function setViewer(pdfViewer) {
  1630. this.pdfViewer = pdfViewer;
  1631. }
  1632. }, {
  1633. key: "setHistory",
  1634. value: function setHistory(pdfHistory) {
  1635. this.pdfHistory = pdfHistory;
  1636. }
  1637. }, {
  1638. key: "navigateTo",
  1639. value: function navigateTo(dest) {
  1640. var _this = this;
  1641. var goToDestination = function goToDestination(_ref2) {
  1642. var namedDest = _ref2.namedDest,
  1643. explicitDest = _ref2.explicitDest;
  1644. var destRef = explicitDest[0],
  1645. pageNumber;
  1646. if (destRef instanceof Object) {
  1647. pageNumber = _this._cachedPageNumber(destRef);
  1648. if (pageNumber === null) {
  1649. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  1650. _this.cachePageRef(pageIndex + 1, destRef);
  1651. goToDestination({
  1652. namedDest: namedDest,
  1653. explicitDest: explicitDest
  1654. });
  1655. })["catch"](function () {
  1656. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  1657. });
  1658. return;
  1659. }
  1660. } else if (Number.isInteger(destRef)) {
  1661. pageNumber = destRef + 1;
  1662. } else {
  1663. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  1664. return;
  1665. }
  1666. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  1667. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  1668. return;
  1669. }
  1670. if (_this.pdfHistory) {
  1671. _this.pdfHistory.pushCurrentPosition();
  1672. _this.pdfHistory.push({
  1673. namedDest: namedDest,
  1674. explicitDest: explicitDest,
  1675. pageNumber: pageNumber
  1676. });
  1677. }
  1678. _this.pdfViewer.scrollPageIntoView({
  1679. pageNumber: pageNumber,
  1680. destArray: explicitDest
  1681. });
  1682. };
  1683. new Promise(function (resolve, reject) {
  1684. if (typeof dest === 'string') {
  1685. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  1686. resolve({
  1687. namedDest: dest,
  1688. explicitDest: destArray
  1689. });
  1690. });
  1691. return;
  1692. }
  1693. resolve({
  1694. namedDest: '',
  1695. explicitDest: dest
  1696. });
  1697. }).then(function (data) {
  1698. if (!Array.isArray(data.explicitDest)) {
  1699. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  1700. return;
  1701. }
  1702. goToDestination(data);
  1703. });
  1704. }
  1705. }, {
  1706. key: "getDestinationHash",
  1707. value: function getDestinationHash(dest) {
  1708. if (typeof dest === 'string') {
  1709. return this.getAnchorUrl('#' + escape(dest));
  1710. }
  1711. if (Array.isArray(dest)) {
  1712. var str = JSON.stringify(dest);
  1713. return this.getAnchorUrl('#' + escape(str));
  1714. }
  1715. return this.getAnchorUrl('');
  1716. }
  1717. }, {
  1718. key: "getAnchorUrl",
  1719. value: function getAnchorUrl(anchor) {
  1720. return (this.baseUrl || '') + anchor;
  1721. }
  1722. }, {
  1723. key: "setHash",
  1724. value: function setHash(hash) {
  1725. var pageNumber, dest;
  1726. if (hash.includes('=')) {
  1727. var params = (0, _ui_utils.parseQueryString)(hash);
  1728. if ('search' in params) {
  1729. this.eventBus.dispatch('findfromurlhash', {
  1730. source: this,
  1731. query: params['search'].replace(/"/g, ''),
  1732. phraseSearch: params['phrase'] === 'true'
  1733. });
  1734. }
  1735. if ('nameddest' in params) {
  1736. this.navigateTo(params.nameddest);
  1737. return;
  1738. }
  1739. if ('page' in params) {
  1740. pageNumber = params.page | 0 || 1;
  1741. }
  1742. if ('zoom' in params) {
  1743. var zoomArgs = params.zoom.split(',');
  1744. var zoomArg = zoomArgs[0];
  1745. var zoomArgNumber = parseFloat(zoomArg);
  1746. if (!zoomArg.includes('Fit')) {
  1747. dest = [null, {
  1748. name: 'XYZ'
  1749. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1750. } else {
  1751. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  1752. dest = [null, {
  1753. name: zoomArg
  1754. }];
  1755. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  1756. dest = [null, {
  1757. name: zoomArg
  1758. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1759. } else if (zoomArg === 'FitR') {
  1760. if (zoomArgs.length !== 5) {
  1761. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1762. } else {
  1763. dest = [null, {
  1764. name: zoomArg
  1765. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1766. }
  1767. } else {
  1768. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
  1769. }
  1770. }
  1771. }
  1772. if (dest) {
  1773. this.pdfViewer.scrollPageIntoView({
  1774. pageNumber: pageNumber || this.page,
  1775. destArray: dest,
  1776. allowNegativeOffset: true
  1777. });
  1778. } else if (pageNumber) {
  1779. this.page = pageNumber;
  1780. }
  1781. if ('pagemode' in params) {
  1782. this.eventBus.dispatch('pagemode', {
  1783. source: this,
  1784. mode: params.pagemode
  1785. });
  1786. }
  1787. } else {
  1788. dest = unescape(hash);
  1789. try {
  1790. dest = JSON.parse(dest);
  1791. if (!Array.isArray(dest)) {
  1792. dest = dest.toString();
  1793. }
  1794. } catch (ex) {}
  1795. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  1796. this.navigateTo(dest);
  1797. return;
  1798. }
  1799. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
  1800. }
  1801. }
  1802. }, {
  1803. key: "executeNamedAction",
  1804. value: function executeNamedAction(action) {
  1805. switch (action) {
  1806. case 'GoBack':
  1807. if (this.pdfHistory) {
  1808. this.pdfHistory.back();
  1809. }
  1810. break;
  1811. case 'GoForward':
  1812. if (this.pdfHistory) {
  1813. this.pdfHistory.forward();
  1814. }
  1815. break;
  1816. case 'NextPage':
  1817. if (this.page < this.pagesCount) {
  1818. this.page++;
  1819. }
  1820. break;
  1821. case 'PrevPage':
  1822. if (this.page > 1) {
  1823. this.page--;
  1824. }
  1825. break;
  1826. case 'LastPage':
  1827. this.page = this.pagesCount;
  1828. break;
  1829. case 'FirstPage':
  1830. this.page = 1;
  1831. break;
  1832. default:
  1833. break;
  1834. }
  1835. this.eventBus.dispatch('namedaction', {
  1836. source: this,
  1837. action: action
  1838. });
  1839. }
  1840. }, {
  1841. key: "cachePageRef",
  1842. value: function cachePageRef(pageNum, pageRef) {
  1843. if (!pageRef) {
  1844. return;
  1845. }
  1846. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1847. this._pagesRefCache[refStr] = pageNum;
  1848. }
  1849. }, {
  1850. key: "_cachedPageNumber",
  1851. value: function _cachedPageNumber(pageRef) {
  1852. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1853. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1854. }
  1855. }, {
  1856. key: "isPageVisible",
  1857. value: function isPageVisible(pageNumber) {
  1858. return this.pdfViewer.isPageVisible(pageNumber);
  1859. }
  1860. }, {
  1861. key: "pagesCount",
  1862. get: function get() {
  1863. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1864. }
  1865. }, {
  1866. key: "page",
  1867. get: function get() {
  1868. return this.pdfViewer.currentPageNumber;
  1869. },
  1870. set: function set(value) {
  1871. this.pdfViewer.currentPageNumber = value;
  1872. }
  1873. }, {
  1874. key: "rotation",
  1875. get: function get() {
  1876. return this.pdfViewer.pagesRotation;
  1877. },
  1878. set: function set(value) {
  1879. this.pdfViewer.pagesRotation = value;
  1880. }
  1881. }]);
  1882. return PDFLinkService;
  1883. }();
  1884. exports.PDFLinkService = PDFLinkService;
  1885. function isValidExplicitDestination(dest) {
  1886. if (!Array.isArray(dest)) {
  1887. return false;
  1888. }
  1889. var destLength = dest.length,
  1890. allowNull = true;
  1891. if (destLength < 2) {
  1892. return false;
  1893. }
  1894. var page = dest[0];
  1895. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1896. return false;
  1897. }
  1898. var zoom = dest[1];
  1899. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  1900. return false;
  1901. }
  1902. switch (zoom.name) {
  1903. case 'XYZ':
  1904. if (destLength !== 5) {
  1905. return false;
  1906. }
  1907. break;
  1908. case 'Fit':
  1909. case 'FitB':
  1910. return destLength === 2;
  1911. case 'FitH':
  1912. case 'FitBH':
  1913. case 'FitV':
  1914. case 'FitBV':
  1915. if (destLength !== 3) {
  1916. return false;
  1917. }
  1918. break;
  1919. case 'FitR':
  1920. if (destLength !== 6) {
  1921. return false;
  1922. }
  1923. allowNull = false;
  1924. break;
  1925. default:
  1926. return false;
  1927. }
  1928. for (var i = 2; i < destLength; i++) {
  1929. var param = dest[i];
  1930. if (!(typeof param === 'number' || allowNull && param === null)) {
  1931. return false;
  1932. }
  1933. }
  1934. return true;
  1935. }
  1936. var SimpleLinkService =
  1937. /*#__PURE__*/
  1938. function () {
  1939. function SimpleLinkService() {
  1940. _classCallCheck(this, SimpleLinkService);
  1941. this.externalLinkTarget = null;
  1942. this.externalLinkRel = null;
  1943. }
  1944. _createClass(SimpleLinkService, [{
  1945. key: "navigateTo",
  1946. value: function navigateTo(dest) {}
  1947. }, {
  1948. key: "getDestinationHash",
  1949. value: function getDestinationHash(dest) {
  1950. return '#';
  1951. }
  1952. }, {
  1953. key: "getAnchorUrl",
  1954. value: function getAnchorUrl(hash) {
  1955. return '#';
  1956. }
  1957. }, {
  1958. key: "setHash",
  1959. value: function setHash(hash) {}
  1960. }, {
  1961. key: "executeNamedAction",
  1962. value: function executeNamedAction(action) {}
  1963. }, {
  1964. key: "cachePageRef",
  1965. value: function cachePageRef(pageNum, pageRef) {}
  1966. }, {
  1967. key: "isPageVisible",
  1968. value: function isPageVisible(pageNumber) {
  1969. return true;
  1970. }
  1971. }, {
  1972. key: "pagesCount",
  1973. get: function get() {
  1974. return 0;
  1975. }
  1976. }, {
  1977. key: "page",
  1978. get: function get() {
  1979. return 0;
  1980. },
  1981. set: function set(value) {}
  1982. }, {
  1983. key: "rotation",
  1984. get: function get() {
  1985. return 0;
  1986. },
  1987. set: function set(value) {}
  1988. }]);
  1989. return SimpleLinkService;
  1990. }();
  1991. exports.SimpleLinkService = SimpleLinkService;
  1992. /***/ }),
  1993. /* 8 */
  1994. /***/ (function(module, exports, __w_pdfjs_require__) {
  1995. "use strict";
  1996. Object.defineProperty(exports, "__esModule", {
  1997. value: true
  1998. });
  1999. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  2000. var _ui_utils = __w_pdfjs_require__(3);
  2001. var _pdfjsLib = __w_pdfjs_require__(2);
  2002. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2003. 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); } }
  2004. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2005. var EXPAND_DIVS_TIMEOUT = 300;
  2006. var TextLayerBuilder =
  2007. /*#__PURE__*/
  2008. function () {
  2009. function TextLayerBuilder(_ref) {
  2010. var textLayerDiv = _ref.textLayerDiv,
  2011. eventBus = _ref.eventBus,
  2012. pageIndex = _ref.pageIndex,
  2013. viewport = _ref.viewport,
  2014. _ref$findController = _ref.findController,
  2015. findController = _ref$findController === void 0 ? null : _ref$findController,
  2016. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  2017. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  2018. _classCallCheck(this, TextLayerBuilder);
  2019. this.textLayerDiv = textLayerDiv;
  2020. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  2021. this.textContent = null;
  2022. this.textContentItemsStr = [];
  2023. this.textContentStream = null;
  2024. this.renderingDone = false;
  2025. this.pageIdx = pageIndex;
  2026. this.pageNumber = this.pageIdx + 1;
  2027. this.matches = [];
  2028. this.viewport = viewport;
  2029. this.textDivs = [];
  2030. this.findController = findController;
  2031. this.textLayerRenderTask = null;
  2032. this.enhanceTextSelection = enhanceTextSelection;
  2033. this._onUpdateTextLayerMatches = null;
  2034. this._bindMouse();
  2035. }
  2036. _createClass(TextLayerBuilder, [{
  2037. key: "_finishRendering",
  2038. value: function _finishRendering() {
  2039. this.renderingDone = true;
  2040. if (!this.enhanceTextSelection) {
  2041. var endOfContent = document.createElement('div');
  2042. endOfContent.className = 'endOfContent';
  2043. this.textLayerDiv.appendChild(endOfContent);
  2044. }
  2045. this.eventBus.dispatch('textlayerrendered', {
  2046. source: this,
  2047. pageNumber: this.pageNumber,
  2048. numTextDivs: this.textDivs.length
  2049. });
  2050. }
  2051. }, {
  2052. key: "render",
  2053. value: function render() {
  2054. var _this = this;
  2055. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2056. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  2057. return;
  2058. }
  2059. this.cancel();
  2060. this.textDivs = [];
  2061. var textLayerFrag = document.createDocumentFragment();
  2062. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  2063. textContent: this.textContent,
  2064. textContentStream: this.textContentStream,
  2065. container: textLayerFrag,
  2066. viewport: this.viewport,
  2067. textDivs: this.textDivs,
  2068. textContentItemsStr: this.textContentItemsStr,
  2069. timeout: timeout,
  2070. enhanceTextSelection: this.enhanceTextSelection
  2071. });
  2072. this.textLayerRenderTask.promise.then(function () {
  2073. _this.textLayerDiv.appendChild(textLayerFrag);
  2074. _this._finishRendering();
  2075. _this._updateMatches();
  2076. }, function (reason) {});
  2077. if (!this._onUpdateTextLayerMatches) {
  2078. this._onUpdateTextLayerMatches = function (evt) {
  2079. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  2080. _this._updateMatches();
  2081. }
  2082. };
  2083. this.eventBus.on('updatetextlayermatches', this._onUpdateTextLayerMatches);
  2084. }
  2085. }
  2086. }, {
  2087. key: "cancel",
  2088. value: function cancel() {
  2089. if (this.textLayerRenderTask) {
  2090. this.textLayerRenderTask.cancel();
  2091. this.textLayerRenderTask = null;
  2092. }
  2093. if (this._onUpdateTextLayerMatches) {
  2094. this.eventBus.off('updatetextlayermatches', this._onUpdateTextLayerMatches);
  2095. this._onUpdateTextLayerMatches = null;
  2096. }
  2097. }
  2098. }, {
  2099. key: "setTextContentStream",
  2100. value: function setTextContentStream(readableStream) {
  2101. this.cancel();
  2102. this.textContentStream = readableStream;
  2103. }
  2104. }, {
  2105. key: "setTextContent",
  2106. value: function setTextContent(textContent) {
  2107. this.cancel();
  2108. this.textContent = textContent;
  2109. }
  2110. }, {
  2111. key: "_convertMatches",
  2112. value: function _convertMatches(matches, matchesLength) {
  2113. if (!matches) {
  2114. return [];
  2115. }
  2116. var findController = this.findController,
  2117. textContentItemsStr = this.textContentItemsStr;
  2118. var i = 0,
  2119. iIndex = 0;
  2120. var end = textContentItemsStr.length - 1;
  2121. var queryLen = findController.state.query.length;
  2122. var result = [];
  2123. for (var m = 0, mm = matches.length; m < mm; m++) {
  2124. var matchIdx = matches[m];
  2125. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  2126. iIndex += textContentItemsStr[i].length;
  2127. i++;
  2128. }
  2129. if (i === textContentItemsStr.length) {
  2130. console.error('Could not find a matching mapping');
  2131. }
  2132. var match = {
  2133. begin: {
  2134. divIdx: i,
  2135. offset: matchIdx - iIndex
  2136. }
  2137. };
  2138. if (matchesLength) {
  2139. matchIdx += matchesLength[m];
  2140. } else {
  2141. matchIdx += queryLen;
  2142. }
  2143. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  2144. iIndex += textContentItemsStr[i].length;
  2145. i++;
  2146. }
  2147. match.end = {
  2148. divIdx: i,
  2149. offset: matchIdx - iIndex
  2150. };
  2151. result.push(match);
  2152. }
  2153. return result;
  2154. }
  2155. }, {
  2156. key: "_renderMatches",
  2157. value: function _renderMatches(matches) {
  2158. if (matches.length === 0) {
  2159. return;
  2160. }
  2161. var findController = this.findController,
  2162. pageIdx = this.pageIdx,
  2163. textContentItemsStr = this.textContentItemsStr,
  2164. textDivs = this.textDivs;
  2165. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  2166. var selectedMatchIdx = findController.selected.matchIdx;
  2167. var highlightAll = findController.state.highlightAll;
  2168. var prevEnd = null;
  2169. var infinity = {
  2170. divIdx: -1,
  2171. offset: undefined
  2172. };
  2173. function beginText(begin, className) {
  2174. var divIdx = begin.divIdx;
  2175. textDivs[divIdx].textContent = '';
  2176. appendTextToDiv(divIdx, 0, begin.offset, className);
  2177. }
  2178. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  2179. var div = textDivs[divIdx];
  2180. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  2181. var node = document.createTextNode(content);
  2182. if (className) {
  2183. var span = document.createElement('span');
  2184. span.className = className;
  2185. span.appendChild(node);
  2186. div.appendChild(span);
  2187. return;
  2188. }
  2189. div.appendChild(node);
  2190. }
  2191. var i0 = selectedMatchIdx,
  2192. i1 = i0 + 1;
  2193. if (highlightAll) {
  2194. i0 = 0;
  2195. i1 = matches.length;
  2196. } else if (!isSelectedPage) {
  2197. return;
  2198. }
  2199. for (var i = i0; i < i1; i++) {
  2200. var match = matches[i];
  2201. var begin = match.begin;
  2202. var end = match.end;
  2203. var isSelected = isSelectedPage && i === selectedMatchIdx;
  2204. var highlightSuffix = isSelected ? ' selected' : '';
  2205. if (isSelected) {
  2206. findController.scrollMatchIntoView({
  2207. element: textDivs[begin.divIdx],
  2208. pageIndex: pageIdx,
  2209. matchIndex: selectedMatchIdx
  2210. });
  2211. }
  2212. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  2213. if (prevEnd !== null) {
  2214. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2215. }
  2216. beginText(begin);
  2217. } else {
  2218. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  2219. }
  2220. if (begin.divIdx === end.divIdx) {
  2221. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  2222. } else {
  2223. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  2224. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  2225. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  2226. }
  2227. beginText(end, 'highlight end' + highlightSuffix);
  2228. }
  2229. prevEnd = end;
  2230. }
  2231. if (prevEnd) {
  2232. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2233. }
  2234. }
  2235. }, {
  2236. key: "_updateMatches",
  2237. value: function _updateMatches() {
  2238. if (!this.renderingDone) {
  2239. return;
  2240. }
  2241. var findController = this.findController,
  2242. matches = this.matches,
  2243. pageIdx = this.pageIdx,
  2244. textContentItemsStr = this.textContentItemsStr,
  2245. textDivs = this.textDivs;
  2246. var clearedUntilDivIdx = -1;
  2247. for (var i = 0, ii = matches.length; i < ii; i++) {
  2248. var match = matches[i];
  2249. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  2250. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  2251. var div = textDivs[n];
  2252. div.textContent = textContentItemsStr[n];
  2253. div.className = '';
  2254. }
  2255. clearedUntilDivIdx = match.end.divIdx + 1;
  2256. }
  2257. if (!findController || !findController.highlightMatches) {
  2258. return;
  2259. }
  2260. var pageMatches = findController.pageMatches[pageIdx] || null;
  2261. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  2262. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  2263. this._renderMatches(this.matches);
  2264. }
  2265. }, {
  2266. key: "_bindMouse",
  2267. value: function _bindMouse() {
  2268. var _this2 = this;
  2269. var div = this.textLayerDiv;
  2270. var expandDivsTimer = null;
  2271. div.addEventListener('mousedown', function (evt) {
  2272. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2273. _this2.textLayerRenderTask.expandTextDivs(true);
  2274. if (expandDivsTimer) {
  2275. clearTimeout(expandDivsTimer);
  2276. expandDivsTimer = null;
  2277. }
  2278. return;
  2279. }
  2280. var end = div.querySelector('.endOfContent');
  2281. if (!end) {
  2282. return;
  2283. }
  2284. var adjustTop = evt.target !== div;
  2285. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  2286. if (adjustTop) {
  2287. var divBounds = div.getBoundingClientRect();
  2288. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  2289. end.style.top = (r * 100).toFixed(2) + '%';
  2290. }
  2291. end.classList.add('active');
  2292. });
  2293. div.addEventListener('mouseup', function () {
  2294. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2295. expandDivsTimer = setTimeout(function () {
  2296. if (_this2.textLayerRenderTask) {
  2297. _this2.textLayerRenderTask.expandTextDivs(false);
  2298. }
  2299. expandDivsTimer = null;
  2300. }, EXPAND_DIVS_TIMEOUT);
  2301. return;
  2302. }
  2303. var end = div.querySelector('.endOfContent');
  2304. if (!end) {
  2305. return;
  2306. }
  2307. end.style.top = '';
  2308. end.classList.remove('active');
  2309. });
  2310. }
  2311. }]);
  2312. return TextLayerBuilder;
  2313. }();
  2314. exports.TextLayerBuilder = TextLayerBuilder;
  2315. var DefaultTextLayerFactory =
  2316. /*#__PURE__*/
  2317. function () {
  2318. function DefaultTextLayerFactory() {
  2319. _classCallCheck(this, DefaultTextLayerFactory);
  2320. }
  2321. _createClass(DefaultTextLayerFactory, [{
  2322. key: "createTextLayerBuilder",
  2323. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2324. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2325. return new TextLayerBuilder({
  2326. textLayerDiv: textLayerDiv,
  2327. pageIndex: pageIndex,
  2328. viewport: viewport,
  2329. enhanceTextSelection: enhanceTextSelection
  2330. });
  2331. }
  2332. }]);
  2333. return DefaultTextLayerFactory;
  2334. }();
  2335. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  2336. /***/ }),
  2337. /* 9 */
  2338. /***/ (function(module, exports, __w_pdfjs_require__) {
  2339. "use strict";
  2340. Object.defineProperty(exports, "__esModule", {
  2341. value: true
  2342. });
  2343. exports.DownloadManager = void 0;
  2344. var _pdfjsLib = __w_pdfjs_require__(2);
  2345. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2346. 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); } }
  2347. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2348. ;
  2349. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  2350. function _download(blobUrl, filename) {
  2351. var a = document.createElement('a');
  2352. if (!a.click) {
  2353. throw new Error('DownloadManager: "a.click()" is not supported.');
  2354. }
  2355. a.href = blobUrl;
  2356. a.target = '_parent';
  2357. if ('download' in a) {
  2358. a.download = filename;
  2359. }
  2360. (document.body || document.documentElement).appendChild(a);
  2361. a.click();
  2362. a.remove();
  2363. }
  2364. var DownloadManager =
  2365. /*#__PURE__*/
  2366. function () {
  2367. function DownloadManager(_ref) {
  2368. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  2369. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  2370. _classCallCheck(this, DownloadManager);
  2371. this.disableCreateObjectURL = disableCreateObjectURL;
  2372. }
  2373. _createClass(DownloadManager, [{
  2374. key: "downloadUrl",
  2375. value: function downloadUrl(url, filename) {
  2376. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  2377. return;
  2378. }
  2379. _download(url + '#pdfjs.action=download', filename);
  2380. }
  2381. }, {
  2382. key: "downloadData",
  2383. value: function downloadData(data, filename, contentType) {
  2384. if (navigator.msSaveBlob) {
  2385. navigator.msSaveBlob(new Blob([data], {
  2386. type: contentType
  2387. }), filename);
  2388. return;
  2389. }
  2390. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  2391. _download(blobUrl, filename);
  2392. }
  2393. }, {
  2394. key: "download",
  2395. value: function download(blob, url, filename) {
  2396. if (navigator.msSaveBlob) {
  2397. if (!navigator.msSaveBlob(blob, filename)) {
  2398. this.downloadUrl(url, filename);
  2399. }
  2400. return;
  2401. }
  2402. if (this.disableCreateObjectURL) {
  2403. this.downloadUrl(url, filename);
  2404. return;
  2405. }
  2406. var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
  2407. _download(blobUrl, filename);
  2408. }
  2409. }]);
  2410. return DownloadManager;
  2411. }();
  2412. exports.DownloadManager = DownloadManager;
  2413. /***/ }),
  2414. /* 10 */
  2415. /***/ (function(module, exports, __w_pdfjs_require__) {
  2416. "use strict";
  2417. Object.defineProperty(exports, "__esModule", {
  2418. value: true
  2419. });
  2420. exports.GenericL10n = void 0;
  2421. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  2422. __w_pdfjs_require__(11);
  2423. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2424. 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); } }
  2425. 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); }); }; }
  2426. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2427. 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); } }
  2428. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2429. var webL10n = document.webL10n;
  2430. var GenericL10n =
  2431. /*#__PURE__*/
  2432. function () {
  2433. function GenericL10n(lang) {
  2434. _classCallCheck(this, GenericL10n);
  2435. this._lang = lang;
  2436. this._ready = new Promise(function (resolve, reject) {
  2437. webL10n.setLanguage(lang, function () {
  2438. resolve(webL10n);
  2439. });
  2440. });
  2441. }
  2442. _createClass(GenericL10n, [{
  2443. key: "getLanguage",
  2444. value: function () {
  2445. var _getLanguage = _asyncToGenerator(
  2446. /*#__PURE__*/
  2447. _regenerator["default"].mark(function _callee() {
  2448. var l10n;
  2449. return _regenerator["default"].wrap(function _callee$(_context) {
  2450. while (1) {
  2451. switch (_context.prev = _context.next) {
  2452. case 0:
  2453. _context.next = 2;
  2454. return this._ready;
  2455. case 2:
  2456. l10n = _context.sent;
  2457. return _context.abrupt("return", l10n.getLanguage());
  2458. case 4:
  2459. case "end":
  2460. return _context.stop();
  2461. }
  2462. }
  2463. }, _callee, this);
  2464. }));
  2465. function getLanguage() {
  2466. return _getLanguage.apply(this, arguments);
  2467. }
  2468. return getLanguage;
  2469. }()
  2470. }, {
  2471. key: "getDirection",
  2472. value: function () {
  2473. var _getDirection = _asyncToGenerator(
  2474. /*#__PURE__*/
  2475. _regenerator["default"].mark(function _callee2() {
  2476. var l10n;
  2477. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2478. while (1) {
  2479. switch (_context2.prev = _context2.next) {
  2480. case 0:
  2481. _context2.next = 2;
  2482. return this._ready;
  2483. case 2:
  2484. l10n = _context2.sent;
  2485. return _context2.abrupt("return", l10n.getDirection());
  2486. case 4:
  2487. case "end":
  2488. return _context2.stop();
  2489. }
  2490. }
  2491. }, _callee2, this);
  2492. }));
  2493. function getDirection() {
  2494. return _getDirection.apply(this, arguments);
  2495. }
  2496. return getDirection;
  2497. }()
  2498. }, {
  2499. key: "get",
  2500. value: function () {
  2501. var _get = _asyncToGenerator(
  2502. /*#__PURE__*/
  2503. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  2504. var l10n;
  2505. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2506. while (1) {
  2507. switch (_context3.prev = _context3.next) {
  2508. case 0:
  2509. _context3.next = 2;
  2510. return this._ready;
  2511. case 2:
  2512. l10n = _context3.sent;
  2513. return _context3.abrupt("return", l10n.get(property, args, fallback));
  2514. case 4:
  2515. case "end":
  2516. return _context3.stop();
  2517. }
  2518. }
  2519. }, _callee3, this);
  2520. }));
  2521. function get(_x, _x2, _x3) {
  2522. return _get.apply(this, arguments);
  2523. }
  2524. return get;
  2525. }()
  2526. }, {
  2527. key: "translate",
  2528. value: function () {
  2529. var _translate = _asyncToGenerator(
  2530. /*#__PURE__*/
  2531. _regenerator["default"].mark(function _callee4(element) {
  2532. var l10n;
  2533. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2534. while (1) {
  2535. switch (_context4.prev = _context4.next) {
  2536. case 0:
  2537. _context4.next = 2;
  2538. return this._ready;
  2539. case 2:
  2540. l10n = _context4.sent;
  2541. return _context4.abrupt("return", l10n.translate(element));
  2542. case 4:
  2543. case "end":
  2544. return _context4.stop();
  2545. }
  2546. }
  2547. }, _callee4, this);
  2548. }));
  2549. function translate(_x4) {
  2550. return _translate.apply(this, arguments);
  2551. }
  2552. return translate;
  2553. }()
  2554. }]);
  2555. return GenericL10n;
  2556. }();
  2557. exports.GenericL10n = GenericL10n;
  2558. /***/ }),
  2559. /* 11 */
  2560. /***/ (function(module, exports, __w_pdfjs_require__) {
  2561. "use strict";
  2562. document.webL10n = function (window, document, undefined) {
  2563. var gL10nData = {};
  2564. var gTextData = '';
  2565. var gTextProp = 'textContent';
  2566. var gLanguage = '';
  2567. var gMacros = {};
  2568. var gReadyState = 'loading';
  2569. var gAsyncResourceLoading = true;
  2570. function getL10nResourceLinks() {
  2571. return document.querySelectorAll('link[type="application/l10n"]');
  2572. }
  2573. function getL10nDictionary() {
  2574. var script = document.querySelector('script[type="application/l10n"]');
  2575. return script ? JSON.parse(script.innerHTML) : null;
  2576. }
  2577. function getTranslatableChildren(element) {
  2578. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  2579. }
  2580. function getL10nAttributes(element) {
  2581. if (!element) return {};
  2582. var l10nId = element.getAttribute('data-l10n-id');
  2583. var l10nArgs = element.getAttribute('data-l10n-args');
  2584. var args = {};
  2585. if (l10nArgs) {
  2586. try {
  2587. args = JSON.parse(l10nArgs);
  2588. } catch (e) {
  2589. console.warn('could not parse arguments for #' + l10nId);
  2590. }
  2591. }
  2592. return {
  2593. id: l10nId,
  2594. args: args
  2595. };
  2596. }
  2597. function fireL10nReadyEvent(lang) {
  2598. var evtObject = document.createEvent('Event');
  2599. evtObject.initEvent('localized', true, false);
  2600. evtObject.language = lang;
  2601. document.dispatchEvent(evtObject);
  2602. }
  2603. function xhrLoadText(url, onSuccess, onFailure) {
  2604. onSuccess = onSuccess || function _onSuccess(data) {};
  2605. onFailure = onFailure || function _onFailure() {};
  2606. var xhr = new XMLHttpRequest();
  2607. xhr.open('GET', url, gAsyncResourceLoading);
  2608. if (xhr.overrideMimeType) {
  2609. xhr.overrideMimeType('text/plain; charset=utf-8');
  2610. }
  2611. xhr.onreadystatechange = function () {
  2612. if (xhr.readyState == 4) {
  2613. if (xhr.status == 200 || xhr.status === 0) {
  2614. onSuccess(xhr.responseText);
  2615. } else {
  2616. onFailure();
  2617. }
  2618. }
  2619. };
  2620. xhr.onerror = onFailure;
  2621. xhr.ontimeout = onFailure;
  2622. try {
  2623. xhr.send(null);
  2624. } catch (e) {
  2625. onFailure();
  2626. }
  2627. }
  2628. function parseResource(href, lang, successCallback, failureCallback) {
  2629. var baseURL = href.replace(/[^\/]*$/, '') || './';
  2630. function evalString(text) {
  2631. if (text.lastIndexOf('\\') < 0) return text;
  2632. 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, "'");
  2633. }
  2634. function parseProperties(text, parsedPropertiesCallback) {
  2635. var dictionary = {};
  2636. var reBlank = /^\s*|\s*$/;
  2637. var reComment = /^\s*#|^\s*$/;
  2638. var reSection = /^\s*\[(.*)\]\s*$/;
  2639. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  2640. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  2641. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  2642. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  2643. var currentLang = '*';
  2644. var genericLang = lang.split('-', 1)[0];
  2645. var skipLang = false;
  2646. var match = '';
  2647. function nextEntry() {
  2648. while (true) {
  2649. if (!entries.length) {
  2650. parsedRawLinesCallback();
  2651. return;
  2652. }
  2653. var line = entries.shift();
  2654. if (reComment.test(line)) continue;
  2655. if (extendedSyntax) {
  2656. match = reSection.exec(line);
  2657. if (match) {
  2658. currentLang = match[1].toLowerCase();
  2659. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  2660. continue;
  2661. } else if (skipLang) {
  2662. continue;
  2663. }
  2664. match = reImport.exec(line);
  2665. if (match) {
  2666. loadImport(baseURL + match[1], nextEntry);
  2667. return;
  2668. }
  2669. }
  2670. var tmp = line.match(reSplit);
  2671. if (tmp && tmp.length == 3) {
  2672. dictionary[tmp[1]] = evalString(tmp[2]);
  2673. }
  2674. }
  2675. }
  2676. nextEntry();
  2677. }
  2678. function loadImport(url, callback) {
  2679. xhrLoadText(url, function (content) {
  2680. parseRawLines(content, false, callback);
  2681. }, function () {
  2682. console.warn(url + ' not found.');
  2683. callback();
  2684. });
  2685. }
  2686. parseRawLines(text, true, function () {
  2687. parsedPropertiesCallback(dictionary);
  2688. });
  2689. }
  2690. xhrLoadText(href, function (response) {
  2691. gTextData += response;
  2692. parseProperties(response, function (data) {
  2693. for (var key in data) {
  2694. var id,
  2695. prop,
  2696. index = key.lastIndexOf('.');
  2697. if (index > 0) {
  2698. id = key.substring(0, index);
  2699. prop = key.substring(index + 1);
  2700. } else {
  2701. id = key;
  2702. prop = gTextProp;
  2703. }
  2704. if (!gL10nData[id]) {
  2705. gL10nData[id] = {};
  2706. }
  2707. gL10nData[id][prop] = data[key];
  2708. }
  2709. if (successCallback) {
  2710. successCallback();
  2711. }
  2712. });
  2713. }, failureCallback);
  2714. }
  2715. function loadLocale(lang, callback) {
  2716. if (lang) {
  2717. lang = lang.toLowerCase();
  2718. }
  2719. callback = callback || function _callback() {};
  2720. clear();
  2721. gLanguage = lang;
  2722. var langLinks = getL10nResourceLinks();
  2723. var langCount = langLinks.length;
  2724. if (langCount === 0) {
  2725. var dict = getL10nDictionary();
  2726. if (dict && dict.locales && dict.default_locale) {
  2727. console.log('using the embedded JSON directory, early way out');
  2728. gL10nData = dict.locales[lang];
  2729. if (!gL10nData) {
  2730. var defaultLocale = dict.default_locale.toLowerCase();
  2731. for (var anyCaseLang in dict.locales) {
  2732. anyCaseLang = anyCaseLang.toLowerCase();
  2733. if (anyCaseLang === lang) {
  2734. gL10nData = dict.locales[lang];
  2735. break;
  2736. } else if (anyCaseLang === defaultLocale) {
  2737. gL10nData = dict.locales[defaultLocale];
  2738. }
  2739. }
  2740. }
  2741. callback();
  2742. } else {
  2743. console.log('no resource to load, early way out');
  2744. }
  2745. fireL10nReadyEvent(lang);
  2746. gReadyState = 'complete';
  2747. return;
  2748. }
  2749. var onResourceLoaded = null;
  2750. var gResourceCount = 0;
  2751. onResourceLoaded = function onResourceLoaded() {
  2752. gResourceCount++;
  2753. if (gResourceCount >= langCount) {
  2754. callback();
  2755. fireL10nReadyEvent(lang);
  2756. gReadyState = 'complete';
  2757. }
  2758. };
  2759. function L10nResourceLink(link) {
  2760. var href = link.href;
  2761. this.load = function (lang, callback) {
  2762. parseResource(href, lang, callback, function () {
  2763. console.warn(href + ' not found.');
  2764. console.warn('"' + lang + '" resource not found');
  2765. gLanguage = '';
  2766. callback();
  2767. });
  2768. };
  2769. }
  2770. for (var i = 0; i < langCount; i++) {
  2771. var resource = new L10nResourceLink(langLinks[i]);
  2772. resource.load(lang, onResourceLoaded);
  2773. }
  2774. }
  2775. function clear() {
  2776. gL10nData = {};
  2777. gTextData = '';
  2778. gLanguage = '';
  2779. }
  2780. function getPluralRules(lang) {
  2781. var locales2rules = {
  2782. 'af': 3,
  2783. 'ak': 4,
  2784. 'am': 4,
  2785. 'ar': 1,
  2786. 'asa': 3,
  2787. 'az': 0,
  2788. 'be': 11,
  2789. 'bem': 3,
  2790. 'bez': 3,
  2791. 'bg': 3,
  2792. 'bh': 4,
  2793. 'bm': 0,
  2794. 'bn': 3,
  2795. 'bo': 0,
  2796. 'br': 20,
  2797. 'brx': 3,
  2798. 'bs': 11,
  2799. 'ca': 3,
  2800. 'cgg': 3,
  2801. 'chr': 3,
  2802. 'cs': 12,
  2803. 'cy': 17,
  2804. 'da': 3,
  2805. 'de': 3,
  2806. 'dv': 3,
  2807. 'dz': 0,
  2808. 'ee': 3,
  2809. 'el': 3,
  2810. 'en': 3,
  2811. 'eo': 3,
  2812. 'es': 3,
  2813. 'et': 3,
  2814. 'eu': 3,
  2815. 'fa': 0,
  2816. 'ff': 5,
  2817. 'fi': 3,
  2818. 'fil': 4,
  2819. 'fo': 3,
  2820. 'fr': 5,
  2821. 'fur': 3,
  2822. 'fy': 3,
  2823. 'ga': 8,
  2824. 'gd': 24,
  2825. 'gl': 3,
  2826. 'gsw': 3,
  2827. 'gu': 3,
  2828. 'guw': 4,
  2829. 'gv': 23,
  2830. 'ha': 3,
  2831. 'haw': 3,
  2832. 'he': 2,
  2833. 'hi': 4,
  2834. 'hr': 11,
  2835. 'hu': 0,
  2836. 'id': 0,
  2837. 'ig': 0,
  2838. 'ii': 0,
  2839. 'is': 3,
  2840. 'it': 3,
  2841. 'iu': 7,
  2842. 'ja': 0,
  2843. 'jmc': 3,
  2844. 'jv': 0,
  2845. 'ka': 0,
  2846. 'kab': 5,
  2847. 'kaj': 3,
  2848. 'kcg': 3,
  2849. 'kde': 0,
  2850. 'kea': 0,
  2851. 'kk': 3,
  2852. 'kl': 3,
  2853. 'km': 0,
  2854. 'kn': 0,
  2855. 'ko': 0,
  2856. 'ksb': 3,
  2857. 'ksh': 21,
  2858. 'ku': 3,
  2859. 'kw': 7,
  2860. 'lag': 18,
  2861. 'lb': 3,
  2862. 'lg': 3,
  2863. 'ln': 4,
  2864. 'lo': 0,
  2865. 'lt': 10,
  2866. 'lv': 6,
  2867. 'mas': 3,
  2868. 'mg': 4,
  2869. 'mk': 16,
  2870. 'ml': 3,
  2871. 'mn': 3,
  2872. 'mo': 9,
  2873. 'mr': 3,
  2874. 'ms': 0,
  2875. 'mt': 15,
  2876. 'my': 0,
  2877. 'nah': 3,
  2878. 'naq': 7,
  2879. 'nb': 3,
  2880. 'nd': 3,
  2881. 'ne': 3,
  2882. 'nl': 3,
  2883. 'nn': 3,
  2884. 'no': 3,
  2885. 'nr': 3,
  2886. 'nso': 4,
  2887. 'ny': 3,
  2888. 'nyn': 3,
  2889. 'om': 3,
  2890. 'or': 3,
  2891. 'pa': 3,
  2892. 'pap': 3,
  2893. 'pl': 13,
  2894. 'ps': 3,
  2895. 'pt': 3,
  2896. 'rm': 3,
  2897. 'ro': 9,
  2898. 'rof': 3,
  2899. 'ru': 11,
  2900. 'rwk': 3,
  2901. 'sah': 0,
  2902. 'saq': 3,
  2903. 'se': 7,
  2904. 'seh': 3,
  2905. 'ses': 0,
  2906. 'sg': 0,
  2907. 'sh': 11,
  2908. 'shi': 19,
  2909. 'sk': 12,
  2910. 'sl': 14,
  2911. 'sma': 7,
  2912. 'smi': 7,
  2913. 'smj': 7,
  2914. 'smn': 7,
  2915. 'sms': 7,
  2916. 'sn': 3,
  2917. 'so': 3,
  2918. 'sq': 3,
  2919. 'sr': 11,
  2920. 'ss': 3,
  2921. 'ssy': 3,
  2922. 'st': 3,
  2923. 'sv': 3,
  2924. 'sw': 3,
  2925. 'syr': 3,
  2926. 'ta': 3,
  2927. 'te': 3,
  2928. 'teo': 3,
  2929. 'th': 0,
  2930. 'ti': 4,
  2931. 'tig': 3,
  2932. 'tk': 3,
  2933. 'tl': 4,
  2934. 'tn': 3,
  2935. 'to': 0,
  2936. 'tr': 0,
  2937. 'ts': 3,
  2938. 'tzm': 22,
  2939. 'uk': 11,
  2940. 'ur': 3,
  2941. 've': 3,
  2942. 'vi': 0,
  2943. 'vun': 3,
  2944. 'wa': 4,
  2945. 'wae': 3,
  2946. 'wo': 0,
  2947. 'xh': 3,
  2948. 'xog': 3,
  2949. 'yo': 0,
  2950. 'zh': 0,
  2951. 'zu': 3
  2952. };
  2953. function isIn(n, list) {
  2954. return list.indexOf(n) !== -1;
  2955. }
  2956. function isBetween(n, start, end) {
  2957. return start <= n && n <= end;
  2958. }
  2959. var pluralRules = {
  2960. '0': function _(n) {
  2961. return 'other';
  2962. },
  2963. '1': function _(n) {
  2964. if (isBetween(n % 100, 3, 10)) return 'few';
  2965. if (n === 0) return 'zero';
  2966. if (isBetween(n % 100, 11, 99)) return 'many';
  2967. if (n == 2) return 'two';
  2968. if (n == 1) return 'one';
  2969. return 'other';
  2970. },
  2971. '2': function _(n) {
  2972. if (n !== 0 && n % 10 === 0) return 'many';
  2973. if (n == 2) return 'two';
  2974. if (n == 1) return 'one';
  2975. return 'other';
  2976. },
  2977. '3': function _(n) {
  2978. if (n == 1) return 'one';
  2979. return 'other';
  2980. },
  2981. '4': function _(n) {
  2982. if (isBetween(n, 0, 1)) return 'one';
  2983. return 'other';
  2984. },
  2985. '5': function _(n) {
  2986. if (isBetween(n, 0, 2) && n != 2) return 'one';
  2987. return 'other';
  2988. },
  2989. '6': function _(n) {
  2990. if (n === 0) return 'zero';
  2991. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2992. return 'other';
  2993. },
  2994. '7': function _(n) {
  2995. if (n == 2) return 'two';
  2996. if (n == 1) return 'one';
  2997. return 'other';
  2998. },
  2999. '8': function _(n) {
  3000. if (isBetween(n, 3, 6)) return 'few';
  3001. if (isBetween(n, 7, 10)) return 'many';
  3002. if (n == 2) return 'two';
  3003. if (n == 1) return 'one';
  3004. return 'other';
  3005. },
  3006. '9': function _(n) {
  3007. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3008. if (n == 1) return 'one';
  3009. return 'other';
  3010. },
  3011. '10': function _(n) {
  3012. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3013. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3014. return 'other';
  3015. },
  3016. '11': function _(n) {
  3017. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3018. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3019. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3020. return 'other';
  3021. },
  3022. '12': function _(n) {
  3023. if (isBetween(n, 2, 4)) return 'few';
  3024. if (n == 1) return 'one';
  3025. return 'other';
  3026. },
  3027. '13': function _(n) {
  3028. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3029. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3030. if (n == 1) return 'one';
  3031. return 'other';
  3032. },
  3033. '14': function _(n) {
  3034. if (isBetween(n % 100, 3, 4)) return 'few';
  3035. if (n % 100 == 2) return 'two';
  3036. if (n % 100 == 1) return 'one';
  3037. return 'other';
  3038. },
  3039. '15': function _(n) {
  3040. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3041. if (isBetween(n % 100, 11, 19)) return 'many';
  3042. if (n == 1) return 'one';
  3043. return 'other';
  3044. },
  3045. '16': function _(n) {
  3046. if (n % 10 == 1 && n != 11) return 'one';
  3047. return 'other';
  3048. },
  3049. '17': function _(n) {
  3050. if (n == 3) return 'few';
  3051. if (n === 0) return 'zero';
  3052. if (n == 6) return 'many';
  3053. if (n == 2) return 'two';
  3054. if (n == 1) return 'one';
  3055. return 'other';
  3056. },
  3057. '18': function _(n) {
  3058. if (n === 0) return 'zero';
  3059. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3060. return 'other';
  3061. },
  3062. '19': function _(n) {
  3063. if (isBetween(n, 2, 10)) return 'few';
  3064. if (isBetween(n, 0, 1)) return 'one';
  3065. return 'other';
  3066. },
  3067. '20': function _(n) {
  3068. 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';
  3069. if (n % 1000000 === 0 && n !== 0) return 'many';
  3070. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3071. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3072. return 'other';
  3073. },
  3074. '21': function _(n) {
  3075. if (n === 0) return 'zero';
  3076. if (n == 1) return 'one';
  3077. return 'other';
  3078. },
  3079. '22': function _(n) {
  3080. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3081. return 'other';
  3082. },
  3083. '23': function _(n) {
  3084. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3085. return 'other';
  3086. },
  3087. '24': function _(n) {
  3088. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3089. if (isIn(n, [2, 12])) return 'two';
  3090. if (isIn(n, [1, 11])) return 'one';
  3091. return 'other';
  3092. }
  3093. };
  3094. var index = locales2rules[lang.replace(/-.*$/, '')];
  3095. if (!(index in pluralRules)) {
  3096. console.warn('plural form unknown for [' + lang + ']');
  3097. return function () {
  3098. return 'other';
  3099. };
  3100. }
  3101. return pluralRules[index];
  3102. }
  3103. gMacros.plural = function (str, param, key, prop) {
  3104. var n = parseFloat(param);
  3105. if (isNaN(n)) return str;
  3106. if (prop != gTextProp) return str;
  3107. if (!gMacros._pluralRules) {
  3108. gMacros._pluralRules = getPluralRules(gLanguage);
  3109. }
  3110. var index = '[' + gMacros._pluralRules(n) + ']';
  3111. if (n === 0 && key + '[zero]' in gL10nData) {
  3112. str = gL10nData[key + '[zero]'][prop];
  3113. } else if (n == 1 && key + '[one]' in gL10nData) {
  3114. str = gL10nData[key + '[one]'][prop];
  3115. } else if (n == 2 && key + '[two]' in gL10nData) {
  3116. str = gL10nData[key + '[two]'][prop];
  3117. } else if (key + index in gL10nData) {
  3118. str = gL10nData[key + index][prop];
  3119. } else if (key + '[other]' in gL10nData) {
  3120. str = gL10nData[key + '[other]'][prop];
  3121. }
  3122. return str;
  3123. };
  3124. function getL10nData(key, args, fallback) {
  3125. var data = gL10nData[key];
  3126. if (!data) {
  3127. console.warn('#' + key + ' is undefined.');
  3128. if (!fallback) {
  3129. return null;
  3130. }
  3131. data = fallback;
  3132. }
  3133. var rv = {};
  3134. for (var prop in data) {
  3135. var str = data[prop];
  3136. str = substIndexes(str, args, key, prop);
  3137. str = substArguments(str, args, key);
  3138. rv[prop] = str;
  3139. }
  3140. return rv;
  3141. }
  3142. function substIndexes(str, args, key, prop) {
  3143. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3144. var reMatch = reIndex.exec(str);
  3145. if (!reMatch || !reMatch.length) return str;
  3146. var macroName = reMatch[1];
  3147. var paramName = reMatch[2];
  3148. var param;
  3149. if (args && paramName in args) {
  3150. param = args[paramName];
  3151. } else if (paramName in gL10nData) {
  3152. param = gL10nData[paramName];
  3153. }
  3154. if (macroName in gMacros) {
  3155. var macro = gMacros[macroName];
  3156. str = macro(str, param, key, prop);
  3157. }
  3158. return str;
  3159. }
  3160. function substArguments(str, args, key) {
  3161. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3162. return str.replace(reArgs, function (matched_text, arg) {
  3163. if (args && arg in args) {
  3164. return args[arg];
  3165. }
  3166. if (arg in gL10nData) {
  3167. return gL10nData[arg];
  3168. }
  3169. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3170. return matched_text;
  3171. });
  3172. }
  3173. function translateElement(element) {
  3174. var l10n = getL10nAttributes(element);
  3175. if (!l10n.id) return;
  3176. var data = getL10nData(l10n.id, l10n.args);
  3177. if (!data) {
  3178. console.warn('#' + l10n.id + ' is undefined.');
  3179. return;
  3180. }
  3181. if (data[gTextProp]) {
  3182. if (getChildElementCount(element) === 0) {
  3183. element[gTextProp] = data[gTextProp];
  3184. } else {
  3185. var children = element.childNodes;
  3186. var found = false;
  3187. for (var i = 0, l = children.length; i < l; i++) {
  3188. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3189. if (found) {
  3190. children[i].nodeValue = '';
  3191. } else {
  3192. children[i].nodeValue = data[gTextProp];
  3193. found = true;
  3194. }
  3195. }
  3196. }
  3197. if (!found) {
  3198. var textNode = document.createTextNode(data[gTextProp]);
  3199. element.insertBefore(textNode, element.firstChild);
  3200. }
  3201. }
  3202. delete data[gTextProp];
  3203. }
  3204. for (var k in data) {
  3205. element[k] = data[k];
  3206. }
  3207. }
  3208. function getChildElementCount(element) {
  3209. if (element.children) {
  3210. return element.children.length;
  3211. }
  3212. if (typeof element.childElementCount !== 'undefined') {
  3213. return element.childElementCount;
  3214. }
  3215. var count = 0;
  3216. for (var i = 0; i < element.childNodes.length; i++) {
  3217. count += element.nodeType === 1 ? 1 : 0;
  3218. }
  3219. return count;
  3220. }
  3221. function translateFragment(element) {
  3222. element = element || document.documentElement;
  3223. var children = getTranslatableChildren(element);
  3224. var elementCount = children.length;
  3225. for (var i = 0; i < elementCount; i++) {
  3226. translateElement(children[i]);
  3227. }
  3228. translateElement(element);
  3229. }
  3230. return {
  3231. get: function get(key, args, fallbackString) {
  3232. var index = key.lastIndexOf('.');
  3233. var prop = gTextProp;
  3234. if (index > 0) {
  3235. prop = key.substring(index + 1);
  3236. key = key.substring(0, index);
  3237. }
  3238. var fallback;
  3239. if (fallbackString) {
  3240. fallback = {};
  3241. fallback[prop] = fallbackString;
  3242. }
  3243. var data = getL10nData(key, args, fallback);
  3244. if (data && prop in data) {
  3245. return data[prop];
  3246. }
  3247. return '{{' + key + '}}';
  3248. },
  3249. getData: function getData() {
  3250. return gL10nData;
  3251. },
  3252. getText: function getText() {
  3253. return gTextData;
  3254. },
  3255. getLanguage: function getLanguage() {
  3256. return gLanguage;
  3257. },
  3258. setLanguage: function setLanguage(lang, callback) {
  3259. loadLocale(lang, function () {
  3260. if (callback) callback();
  3261. });
  3262. },
  3263. getDirection: function getDirection() {
  3264. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3265. var shortCode = gLanguage.split('-', 1)[0];
  3266. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3267. },
  3268. translate: translateFragment,
  3269. getReadyState: function getReadyState() {
  3270. return gReadyState;
  3271. },
  3272. ready: function ready(callback) {
  3273. if (!callback) {
  3274. return;
  3275. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3276. window.setTimeout(function () {
  3277. callback();
  3278. });
  3279. } else if (document.addEventListener) {
  3280. document.addEventListener('localized', function once() {
  3281. document.removeEventListener('localized', once);
  3282. callback();
  3283. });
  3284. }
  3285. }
  3286. };
  3287. }(window, document);
  3288. /***/ }),
  3289. /* 12 */
  3290. /***/ (function(module, exports, __w_pdfjs_require__) {
  3291. "use strict";
  3292. Object.defineProperty(exports, "__esModule", {
  3293. value: true
  3294. });
  3295. exports.PDFFindController = exports.FindState = void 0;
  3296. var _ui_utils = __w_pdfjs_require__(3);
  3297. var _pdfjsLib = __w_pdfjs_require__(2);
  3298. var _pdf_find_utils = __w_pdfjs_require__(13);
  3299. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3300. 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); } }
  3301. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3302. var FindState = {
  3303. FOUND: 0,
  3304. NOT_FOUND: 1,
  3305. WRAPPED: 2,
  3306. PENDING: 3
  3307. };
  3308. exports.FindState = FindState;
  3309. var FIND_TIMEOUT = 250;
  3310. var MATCH_SCROLL_OFFSET_TOP = -50;
  3311. var MATCH_SCROLL_OFFSET_LEFT = -400;
  3312. var CHARACTERS_TO_NORMALIZE = {
  3313. "\u2018": '\'',
  3314. "\u2019": '\'',
  3315. "\u201A": '\'',
  3316. "\u201B": '\'',
  3317. "\u201C": '"',
  3318. "\u201D": '"',
  3319. "\u201E": '"',
  3320. "\u201F": '"',
  3321. "\xBC": '1/4',
  3322. "\xBD": '1/2',
  3323. "\xBE": '3/4'
  3324. };
  3325. var normalizationRegex = null;
  3326. function normalize(text) {
  3327. if (!normalizationRegex) {
  3328. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3329. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  3330. }
  3331. return text.replace(normalizationRegex, function (ch) {
  3332. return CHARACTERS_TO_NORMALIZE[ch];
  3333. });
  3334. }
  3335. var PDFFindController =
  3336. /*#__PURE__*/
  3337. function () {
  3338. function PDFFindController(_ref) {
  3339. var linkService = _ref.linkService,
  3340. _ref$eventBus = _ref.eventBus,
  3341. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
  3342. _classCallCheck(this, PDFFindController);
  3343. this._linkService = linkService;
  3344. this._eventBus = eventBus;
  3345. this._reset();
  3346. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  3347. }
  3348. _createClass(PDFFindController, [{
  3349. key: "setDocument",
  3350. value: function setDocument(pdfDocument) {
  3351. if (this._pdfDocument) {
  3352. this._reset();
  3353. }
  3354. if (!pdfDocument) {
  3355. return;
  3356. }
  3357. this._pdfDocument = pdfDocument;
  3358. this._firstPageCapability.resolve();
  3359. }
  3360. }, {
  3361. key: "executeCommand",
  3362. value: function executeCommand(cmd, state) {
  3363. var _this = this;
  3364. if (!state) {
  3365. return;
  3366. }
  3367. var pdfDocument = this._pdfDocument;
  3368. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  3369. this._dirtyMatch = true;
  3370. }
  3371. this._state = state;
  3372. if (cmd !== 'findhighlightallchange') {
  3373. this._updateUIState(FindState.PENDING);
  3374. }
  3375. this._firstPageCapability.promise.then(function () {
  3376. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  3377. return;
  3378. }
  3379. _this._extractText();
  3380. var findbarClosed = !_this._highlightMatches;
  3381. var pendingTimeout = !!_this._findTimeout;
  3382. if (_this._findTimeout) {
  3383. clearTimeout(_this._findTimeout);
  3384. _this._findTimeout = null;
  3385. }
  3386. if (cmd === 'find') {
  3387. _this._findTimeout = setTimeout(function () {
  3388. _this._nextMatch();
  3389. _this._findTimeout = null;
  3390. }, FIND_TIMEOUT);
  3391. } else if (_this._dirtyMatch) {
  3392. _this._nextMatch();
  3393. } else if (cmd === 'findagain') {
  3394. _this._nextMatch();
  3395. if (findbarClosed && _this._state.highlightAll) {
  3396. _this._updateAllPages();
  3397. }
  3398. } else if (cmd === 'findhighlightallchange') {
  3399. if (pendingTimeout) {
  3400. _this._nextMatch();
  3401. } else {
  3402. _this._highlightMatches = true;
  3403. }
  3404. _this._updateAllPages();
  3405. } else {
  3406. _this._nextMatch();
  3407. }
  3408. });
  3409. }
  3410. }, {
  3411. key: "scrollMatchIntoView",
  3412. value: function scrollMatchIntoView(_ref2) {
  3413. var _ref2$element = _ref2.element,
  3414. element = _ref2$element === void 0 ? null : _ref2$element,
  3415. _ref2$pageIndex = _ref2.pageIndex,
  3416. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  3417. _ref2$matchIndex = _ref2.matchIndex,
  3418. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  3419. if (!this._scrollMatches || !element) {
  3420. return;
  3421. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  3422. return;
  3423. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  3424. return;
  3425. }
  3426. this._scrollMatches = false;
  3427. var spot = {
  3428. top: MATCH_SCROLL_OFFSET_TOP,
  3429. left: MATCH_SCROLL_OFFSET_LEFT
  3430. };
  3431. (0, _ui_utils.scrollIntoView)(element, spot, true);
  3432. }
  3433. }, {
  3434. key: "_reset",
  3435. value: function _reset() {
  3436. this._highlightMatches = false;
  3437. this._scrollMatches = false;
  3438. this._pdfDocument = null;
  3439. this._pageMatches = [];
  3440. this._pageMatchesLength = [];
  3441. this._state = null;
  3442. this._selected = {
  3443. pageIdx: -1,
  3444. matchIdx: -1
  3445. };
  3446. this._offset = {
  3447. pageIdx: null,
  3448. matchIdx: null,
  3449. wrapped: false
  3450. };
  3451. this._extractTextPromises = [];
  3452. this._pageContents = [];
  3453. this._matchesCountTotal = 0;
  3454. this._pagesToSearch = null;
  3455. this._pendingFindMatches = Object.create(null);
  3456. this._resumePageIdx = null;
  3457. this._dirtyMatch = false;
  3458. clearTimeout(this._findTimeout);
  3459. this._findTimeout = null;
  3460. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  3461. }
  3462. }, {
  3463. key: "_shouldDirtyMatch",
  3464. value: function _shouldDirtyMatch(cmd, state) {
  3465. if (state.query !== this._state.query) {
  3466. return true;
  3467. }
  3468. switch (cmd) {
  3469. case 'findagain':
  3470. var pageNumber = this._selected.pageIdx + 1;
  3471. var linkService = this._linkService;
  3472. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  3473. return true;
  3474. }
  3475. return false;
  3476. case 'findhighlightallchange':
  3477. return false;
  3478. }
  3479. return true;
  3480. }
  3481. }, {
  3482. key: "_prepareMatches",
  3483. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3484. function isSubTerm(matchesWithLength, currentIndex) {
  3485. var currentElem = matchesWithLength[currentIndex];
  3486. var nextElem = matchesWithLength[currentIndex + 1];
  3487. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3488. currentElem.skipped = true;
  3489. return true;
  3490. }
  3491. for (var i = currentIndex - 1; i >= 0; i--) {
  3492. var prevElem = matchesWithLength[i];
  3493. if (prevElem.skipped) {
  3494. continue;
  3495. }
  3496. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3497. break;
  3498. }
  3499. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3500. currentElem.skipped = true;
  3501. return true;
  3502. }
  3503. }
  3504. return false;
  3505. }
  3506. matchesWithLength.sort(function (a, b) {
  3507. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3508. });
  3509. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3510. if (isSubTerm(matchesWithLength, i)) {
  3511. continue;
  3512. }
  3513. matches.push(matchesWithLength[i].match);
  3514. matchesLength.push(matchesWithLength[i].matchLength);
  3515. }
  3516. }
  3517. }, {
  3518. key: "_isEntireWord",
  3519. value: function _isEntireWord(content, startIdx, length) {
  3520. if (startIdx > 0) {
  3521. var first = content.charCodeAt(startIdx);
  3522. var limit = content.charCodeAt(startIdx - 1);
  3523. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  3524. return false;
  3525. }
  3526. }
  3527. var endIdx = startIdx + length - 1;
  3528. if (endIdx < content.length - 1) {
  3529. var last = content.charCodeAt(endIdx);
  3530. var _limit = content.charCodeAt(endIdx + 1);
  3531. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  3532. return false;
  3533. }
  3534. }
  3535. return true;
  3536. }
  3537. }, {
  3538. key: "_calculatePhraseMatch",
  3539. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  3540. var matches = [];
  3541. var queryLen = query.length;
  3542. var matchIdx = -queryLen;
  3543. while (true) {
  3544. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3545. if (matchIdx === -1) {
  3546. break;
  3547. }
  3548. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  3549. continue;
  3550. }
  3551. matches.push(matchIdx);
  3552. }
  3553. this._pageMatches[pageIndex] = matches;
  3554. }
  3555. }, {
  3556. key: "_calculateWordMatch",
  3557. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  3558. var matchesWithLength = [];
  3559. var queryArray = query.match(/\S+/g);
  3560. for (var i = 0, len = queryArray.length; i < len; i++) {
  3561. var subquery = queryArray[i];
  3562. var subqueryLen = subquery.length;
  3563. var matchIdx = -subqueryLen;
  3564. while (true) {
  3565. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3566. if (matchIdx === -1) {
  3567. break;
  3568. }
  3569. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  3570. continue;
  3571. }
  3572. matchesWithLength.push({
  3573. match: matchIdx,
  3574. matchLength: subqueryLen,
  3575. skipped: false
  3576. });
  3577. }
  3578. }
  3579. this._pageMatchesLength[pageIndex] = [];
  3580. this._pageMatches[pageIndex] = [];
  3581. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  3582. }
  3583. }, {
  3584. key: "_calculateMatch",
  3585. value: function _calculateMatch(pageIndex) {
  3586. var pageContent = this._pageContents[pageIndex];
  3587. var query = this._query;
  3588. var _this$_state = this._state,
  3589. caseSensitive = _this$_state.caseSensitive,
  3590. entireWord = _this$_state.entireWord,
  3591. phraseSearch = _this$_state.phraseSearch;
  3592. if (query.length === 0) {
  3593. return;
  3594. }
  3595. if (!caseSensitive) {
  3596. pageContent = pageContent.toLowerCase();
  3597. query = query.toLowerCase();
  3598. }
  3599. if (phraseSearch) {
  3600. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  3601. } else {
  3602. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  3603. }
  3604. if (this._state.highlightAll) {
  3605. this._updatePage(pageIndex);
  3606. }
  3607. if (this._resumePageIdx === pageIndex) {
  3608. this._resumePageIdx = null;
  3609. this._nextPageMatch();
  3610. }
  3611. var pageMatchesCount = this._pageMatches[pageIndex].length;
  3612. if (pageMatchesCount > 0) {
  3613. this._matchesCountTotal += pageMatchesCount;
  3614. this._updateUIResultsCount();
  3615. }
  3616. }
  3617. }, {
  3618. key: "_extractText",
  3619. value: function _extractText() {
  3620. var _this2 = this;
  3621. if (this._extractTextPromises.length > 0) {
  3622. return;
  3623. }
  3624. var promise = Promise.resolve();
  3625. var _loop = function _loop(i, ii) {
  3626. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3627. _this2._extractTextPromises[i] = extractTextCapability.promise;
  3628. promise = promise.then(function () {
  3629. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  3630. return pdfPage.getTextContent({
  3631. normalizeWhitespace: true
  3632. });
  3633. }).then(function (textContent) {
  3634. var textItems = textContent.items;
  3635. var strBuf = [];
  3636. for (var j = 0, jj = textItems.length; j < jj; j++) {
  3637. strBuf.push(textItems[j].str);
  3638. }
  3639. _this2._pageContents[i] = normalize(strBuf.join(''));
  3640. extractTextCapability.resolve(i);
  3641. }, function (reason) {
  3642. console.error("Unable to get text content for page ".concat(i + 1), reason);
  3643. _this2._pageContents[i] = '';
  3644. extractTextCapability.resolve(i);
  3645. });
  3646. });
  3647. };
  3648. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  3649. _loop(i, ii);
  3650. }
  3651. }
  3652. }, {
  3653. key: "_updatePage",
  3654. value: function _updatePage(index) {
  3655. if (this._scrollMatches && this._selected.pageIdx === index) {
  3656. this._linkService.page = index + 1;
  3657. }
  3658. this._eventBus.dispatch('updatetextlayermatches', {
  3659. source: this,
  3660. pageIndex: index
  3661. });
  3662. }
  3663. }, {
  3664. key: "_updateAllPages",
  3665. value: function _updateAllPages() {
  3666. this._eventBus.dispatch('updatetextlayermatches', {
  3667. source: this,
  3668. pageIndex: -1
  3669. });
  3670. }
  3671. }, {
  3672. key: "_nextMatch",
  3673. value: function _nextMatch() {
  3674. var _this3 = this;
  3675. var previous = this._state.findPrevious;
  3676. var currentPageIndex = this._linkService.page - 1;
  3677. var numPages = this._linkService.pagesCount;
  3678. this._highlightMatches = true;
  3679. if (this._dirtyMatch) {
  3680. this._dirtyMatch = false;
  3681. this._selected.pageIdx = this._selected.matchIdx = -1;
  3682. this._offset.pageIdx = currentPageIndex;
  3683. this._offset.matchIdx = null;
  3684. this._offset.wrapped = false;
  3685. this._resumePageIdx = null;
  3686. this._pageMatches.length = 0;
  3687. this._pageMatchesLength.length = 0;
  3688. this._matchesCountTotal = 0;
  3689. this._updateAllPages();
  3690. for (var i = 0; i < numPages; i++) {
  3691. if (this._pendingFindMatches[i] === true) {
  3692. continue;
  3693. }
  3694. this._pendingFindMatches[i] = true;
  3695. this._extractTextPromises[i].then(function (pageIdx) {
  3696. delete _this3._pendingFindMatches[pageIdx];
  3697. _this3._calculateMatch(pageIdx);
  3698. });
  3699. }
  3700. }
  3701. if (this._query === '') {
  3702. this._updateUIState(FindState.FOUND);
  3703. return;
  3704. }
  3705. if (this._resumePageIdx) {
  3706. return;
  3707. }
  3708. var offset = this._offset;
  3709. this._pagesToSearch = numPages;
  3710. if (offset.matchIdx !== null) {
  3711. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  3712. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3713. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3714. this._updateMatch(true);
  3715. return;
  3716. }
  3717. this._advanceOffsetPage(previous);
  3718. }
  3719. this._nextPageMatch();
  3720. }
  3721. }, {
  3722. key: "_matchesReady",
  3723. value: function _matchesReady(matches) {
  3724. var offset = this._offset;
  3725. var numMatches = matches.length;
  3726. var previous = this._state.findPrevious;
  3727. if (numMatches) {
  3728. offset.matchIdx = previous ? numMatches - 1 : 0;
  3729. this._updateMatch(true);
  3730. return true;
  3731. }
  3732. this._advanceOffsetPage(previous);
  3733. if (offset.wrapped) {
  3734. offset.matchIdx = null;
  3735. if (this._pagesToSearch < 0) {
  3736. this._updateMatch(false);
  3737. return true;
  3738. }
  3739. }
  3740. return false;
  3741. }
  3742. }, {
  3743. key: "_nextPageMatch",
  3744. value: function _nextPageMatch() {
  3745. if (this._resumePageIdx !== null) {
  3746. console.error('There can only be one pending page.');
  3747. }
  3748. var matches = null;
  3749. do {
  3750. var pageIdx = this._offset.pageIdx;
  3751. matches = this._pageMatches[pageIdx];
  3752. if (!matches) {
  3753. this._resumePageIdx = pageIdx;
  3754. break;
  3755. }
  3756. } while (!this._matchesReady(matches));
  3757. }
  3758. }, {
  3759. key: "_advanceOffsetPage",
  3760. value: function _advanceOffsetPage(previous) {
  3761. var offset = this._offset;
  3762. var numPages = this._linkService.pagesCount;
  3763. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3764. offset.matchIdx = null;
  3765. this._pagesToSearch--;
  3766. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3767. offset.pageIdx = previous ? numPages - 1 : 0;
  3768. offset.wrapped = true;
  3769. }
  3770. }
  3771. }, {
  3772. key: "_updateMatch",
  3773. value: function _updateMatch() {
  3774. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3775. var state = FindState.NOT_FOUND;
  3776. var wrapped = this._offset.wrapped;
  3777. this._offset.wrapped = false;
  3778. if (found) {
  3779. var previousPage = this._selected.pageIdx;
  3780. this._selected.pageIdx = this._offset.pageIdx;
  3781. this._selected.matchIdx = this._offset.matchIdx;
  3782. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  3783. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  3784. this._updatePage(previousPage);
  3785. }
  3786. }
  3787. this._updateUIState(state, this._state.findPrevious);
  3788. if (this._selected.pageIdx !== -1) {
  3789. this._scrollMatches = true;
  3790. this._updatePage(this._selected.pageIdx);
  3791. }
  3792. }
  3793. }, {
  3794. key: "_onFindBarClose",
  3795. value: function _onFindBarClose(evt) {
  3796. var _this4 = this;
  3797. var pdfDocument = this._pdfDocument;
  3798. this._firstPageCapability.promise.then(function () {
  3799. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  3800. return;
  3801. }
  3802. if (_this4._findTimeout) {
  3803. clearTimeout(_this4._findTimeout);
  3804. _this4._findTimeout = null;
  3805. }
  3806. if (_this4._resumePageIdx) {
  3807. _this4._resumePageIdx = null;
  3808. _this4._dirtyMatch = true;
  3809. }
  3810. _this4._updateUIState(FindState.FOUND);
  3811. _this4._highlightMatches = false;
  3812. _this4._updateAllPages();
  3813. });
  3814. }
  3815. }, {
  3816. key: "_requestMatchesCount",
  3817. value: function _requestMatchesCount() {
  3818. var _this$_selected = this._selected,
  3819. pageIdx = _this$_selected.pageIdx,
  3820. matchIdx = _this$_selected.matchIdx;
  3821. var current = 0,
  3822. total = this._matchesCountTotal;
  3823. if (matchIdx !== -1) {
  3824. for (var i = 0; i < pageIdx; i++) {
  3825. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  3826. }
  3827. current += matchIdx + 1;
  3828. }
  3829. if (current < 1 || current > total) {
  3830. current = total = 0;
  3831. }
  3832. return {
  3833. current: current,
  3834. total: total
  3835. };
  3836. }
  3837. }, {
  3838. key: "_updateUIResultsCount",
  3839. value: function _updateUIResultsCount() {
  3840. this._eventBus.dispatch('updatefindmatchescount', {
  3841. source: this,
  3842. matchesCount: this._requestMatchesCount()
  3843. });
  3844. }
  3845. }, {
  3846. key: "_updateUIState",
  3847. value: function _updateUIState(state, previous) {
  3848. this._eventBus.dispatch('updatefindcontrolstate', {
  3849. source: this,
  3850. state: state,
  3851. previous: previous,
  3852. matchesCount: this._requestMatchesCount()
  3853. });
  3854. }
  3855. }, {
  3856. key: "highlightMatches",
  3857. get: function get() {
  3858. return this._highlightMatches;
  3859. }
  3860. }, {
  3861. key: "pageMatches",
  3862. get: function get() {
  3863. return this._pageMatches;
  3864. }
  3865. }, {
  3866. key: "pageMatchesLength",
  3867. get: function get() {
  3868. return this._pageMatchesLength;
  3869. }
  3870. }, {
  3871. key: "selected",
  3872. get: function get() {
  3873. return this._selected;
  3874. }
  3875. }, {
  3876. key: "state",
  3877. get: function get() {
  3878. return this._state;
  3879. }
  3880. }, {
  3881. key: "_query",
  3882. get: function get() {
  3883. if (this._state.query !== this._rawQuery) {
  3884. this._rawQuery = this._state.query;
  3885. this._normalizedQuery = normalize(this._state.query);
  3886. }
  3887. return this._normalizedQuery;
  3888. }
  3889. }]);
  3890. return PDFFindController;
  3891. }();
  3892. exports.PDFFindController = PDFFindController;
  3893. /***/ }),
  3894. /* 13 */
  3895. /***/ (function(module, exports, __w_pdfjs_require__) {
  3896. "use strict";
  3897. Object.defineProperty(exports, "__esModule", {
  3898. value: true
  3899. });
  3900. exports.getCharacterType = getCharacterType;
  3901. exports.CharacterType = void 0;
  3902. var CharacterType = {
  3903. SPACE: 0,
  3904. ALPHA_LETTER: 1,
  3905. PUNCT: 2,
  3906. HAN_LETTER: 3,
  3907. KATAKANA_LETTER: 4,
  3908. HIRAGANA_LETTER: 5,
  3909. HALFWIDTH_KATAKANA_LETTER: 6,
  3910. THAI_LETTER: 7
  3911. };
  3912. exports.CharacterType = CharacterType;
  3913. function isAlphabeticalScript(charCode) {
  3914. return charCode < 0x2E80;
  3915. }
  3916. function isAscii(charCode) {
  3917. return (charCode & 0xFF80) === 0;
  3918. }
  3919. function isAsciiAlpha(charCode) {
  3920. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  3921. }
  3922. function isAsciiDigit(charCode) {
  3923. return charCode >= 0x30 && charCode <= 0x39;
  3924. }
  3925. function isAsciiSpace(charCode) {
  3926. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  3927. }
  3928. function isHan(charCode) {
  3929. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  3930. }
  3931. function isKatakana(charCode) {
  3932. return charCode >= 0x30A0 && charCode <= 0x30FF;
  3933. }
  3934. function isHiragana(charCode) {
  3935. return charCode >= 0x3040 && charCode <= 0x309F;
  3936. }
  3937. function isHalfwidthKatakana(charCode) {
  3938. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  3939. }
  3940. function isThai(charCode) {
  3941. return (charCode & 0xFF80) === 0x0E00;
  3942. }
  3943. function getCharacterType(charCode) {
  3944. if (isAlphabeticalScript(charCode)) {
  3945. if (isAscii(charCode)) {
  3946. if (isAsciiSpace(charCode)) {
  3947. return CharacterType.SPACE;
  3948. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  3949. return CharacterType.ALPHA_LETTER;
  3950. }
  3951. return CharacterType.PUNCT;
  3952. } else if (isThai(charCode)) {
  3953. return CharacterType.THAI_LETTER;
  3954. } else if (charCode === 0xA0) {
  3955. return CharacterType.SPACE;
  3956. }
  3957. return CharacterType.ALPHA_LETTER;
  3958. }
  3959. if (isHan(charCode)) {
  3960. return CharacterType.HAN_LETTER;
  3961. } else if (isKatakana(charCode)) {
  3962. return CharacterType.KATAKANA_LETTER;
  3963. } else if (isHiragana(charCode)) {
  3964. return CharacterType.HIRAGANA_LETTER;
  3965. } else if (isHalfwidthKatakana(charCode)) {
  3966. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  3967. }
  3968. return CharacterType.ALPHA_LETTER;
  3969. }
  3970. /***/ }),
  3971. /* 14 */
  3972. /***/ (function(module, exports, __w_pdfjs_require__) {
  3973. "use strict";
  3974. Object.defineProperty(exports, "__esModule", {
  3975. value: true
  3976. });
  3977. exports.isDestHashesEqual = isDestHashesEqual;
  3978. exports.isDestArraysEqual = isDestArraysEqual;
  3979. exports.PDFHistory = void 0;
  3980. var _ui_utils = __w_pdfjs_require__(3);
  3981. 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); }
  3982. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  3983. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  3984. function _iterableToArrayLimit(arr, i) { 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; }
  3985. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3986. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3987. 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); } }
  3988. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3989. var HASH_CHANGE_TIMEOUT = 1000;
  3990. var POSITION_UPDATED_THRESHOLD = 50;
  3991. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  3992. function getCurrentHash() {
  3993. return document.location.hash;
  3994. }
  3995. function parseCurrentHash(linkService) {
  3996. var hash = unescape(getCurrentHash()).substring(1);
  3997. var params = (0, _ui_utils.parseQueryString)(hash);
  3998. var page = params.page | 0;
  3999. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  4000. page = null;
  4001. }
  4002. return {
  4003. hash: hash,
  4004. page: page,
  4005. rotation: linkService.rotation
  4006. };
  4007. }
  4008. var PDFHistory =
  4009. /*#__PURE__*/
  4010. function () {
  4011. function PDFHistory(_ref) {
  4012. var _this = this;
  4013. var linkService = _ref.linkService,
  4014. eventBus = _ref.eventBus;
  4015. _classCallCheck(this, PDFHistory);
  4016. this.linkService = linkService;
  4017. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  4018. this.initialized = false;
  4019. this.initialBookmark = null;
  4020. this.initialRotation = null;
  4021. this._boundEvents = Object.create(null);
  4022. this._isViewerInPresentationMode = false;
  4023. this._isPagesLoaded = false;
  4024. this.eventBus.on('presentationmodechanged', function (evt) {
  4025. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4026. });
  4027. this.eventBus.on('pagesloaded', function (evt) {
  4028. _this._isPagesLoaded = !!evt.pagesCount;
  4029. });
  4030. }
  4031. _createClass(PDFHistory, [{
  4032. key: "initialize",
  4033. value: function initialize(_ref2) {
  4034. var fingerprint = _ref2.fingerprint,
  4035. _ref2$resetHistory = _ref2.resetHistory,
  4036. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  4037. _ref2$updateUrl = _ref2.updateUrl,
  4038. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  4039. if (!fingerprint || typeof fingerprint !== 'string') {
  4040. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4041. return;
  4042. }
  4043. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  4044. this.fingerprint = fingerprint;
  4045. this._updateUrl = updateUrl === true;
  4046. if (!this.initialized) {
  4047. this._bindEvents();
  4048. }
  4049. var state = window.history.state;
  4050. this.initialized = true;
  4051. this.initialBookmark = null;
  4052. this.initialRotation = null;
  4053. this._popStateInProgress = false;
  4054. this._blockHashChange = 0;
  4055. this._currentHash = getCurrentHash();
  4056. this._numPositionUpdates = 0;
  4057. this._uid = this._maxUid = 0;
  4058. this._destination = null;
  4059. this._position = null;
  4060. if (!this._isValidState(state, true) || resetHistory) {
  4061. var _parseCurrentHash = parseCurrentHash(this.linkService),
  4062. hash = _parseCurrentHash.hash,
  4063. page = _parseCurrentHash.page,
  4064. rotation = _parseCurrentHash.rotation;
  4065. if (!hash || reInitialized || resetHistory) {
  4066. this._pushOrReplaceState(null, true);
  4067. return;
  4068. }
  4069. this._pushOrReplaceState({
  4070. hash: hash,
  4071. page: page,
  4072. rotation: rotation
  4073. }, true);
  4074. return;
  4075. }
  4076. var destination = state.destination;
  4077. this._updateInternalState(destination, state.uid, true);
  4078. if (this._uid > this._maxUid) {
  4079. this._maxUid = this._uid;
  4080. }
  4081. if (destination.rotation !== undefined) {
  4082. this.initialRotation = destination.rotation;
  4083. }
  4084. if (destination.dest) {
  4085. this.initialBookmark = JSON.stringify(destination.dest);
  4086. this._destination.page = null;
  4087. } else if (destination.hash) {
  4088. this.initialBookmark = destination.hash;
  4089. } else if (destination.page) {
  4090. this.initialBookmark = "page=".concat(destination.page);
  4091. }
  4092. }
  4093. }, {
  4094. key: "push",
  4095. value: function push(_ref3) {
  4096. var _this2 = this;
  4097. var _ref3$namedDest = _ref3.namedDest,
  4098. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  4099. explicitDest = _ref3.explicitDest,
  4100. pageNumber = _ref3.pageNumber;
  4101. if (!this.initialized) {
  4102. return;
  4103. }
  4104. if (namedDest && typeof namedDest !== 'string') {
  4105. console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  4106. return;
  4107. } else if (!Array.isArray(explicitDest)) {
  4108. console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  4109. return;
  4110. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4111. if (pageNumber !== null || this._destination) {
  4112. console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  4113. return;
  4114. }
  4115. }
  4116. var hash = namedDest || JSON.stringify(explicitDest);
  4117. if (!hash) {
  4118. return;
  4119. }
  4120. var forceReplace = false;
  4121. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4122. if (this._destination.page) {
  4123. return;
  4124. }
  4125. forceReplace = true;
  4126. }
  4127. if (this._popStateInProgress && !forceReplace) {
  4128. return;
  4129. }
  4130. this._pushOrReplaceState({
  4131. dest: explicitDest,
  4132. hash: hash,
  4133. page: pageNumber,
  4134. rotation: this.linkService.rotation
  4135. }, forceReplace);
  4136. if (!this._popStateInProgress) {
  4137. this._popStateInProgress = true;
  4138. Promise.resolve().then(function () {
  4139. _this2._popStateInProgress = false;
  4140. });
  4141. }
  4142. }
  4143. }, {
  4144. key: "pushCurrentPosition",
  4145. value: function pushCurrentPosition() {
  4146. if (!this.initialized || this._popStateInProgress) {
  4147. return;
  4148. }
  4149. this._tryPushCurrentPosition();
  4150. }
  4151. }, {
  4152. key: "back",
  4153. value: function back() {
  4154. if (!this.initialized || this._popStateInProgress) {
  4155. return;
  4156. }
  4157. var state = window.history.state;
  4158. if (this._isValidState(state) && state.uid > 0) {
  4159. window.history.back();
  4160. }
  4161. }
  4162. }, {
  4163. key: "forward",
  4164. value: function forward() {
  4165. if (!this.initialized || this._popStateInProgress) {
  4166. return;
  4167. }
  4168. var state = window.history.state;
  4169. if (this._isValidState(state) && state.uid < this._maxUid) {
  4170. window.history.forward();
  4171. }
  4172. }
  4173. }, {
  4174. key: "_pushOrReplaceState",
  4175. value: function _pushOrReplaceState(destination) {
  4176. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4177. var shouldReplace = forceReplace || !this._destination;
  4178. var newState = {
  4179. fingerprint: this.fingerprint,
  4180. uid: shouldReplace ? this._uid : this._uid + 1,
  4181. destination: destination
  4182. };
  4183. this._updateInternalState(destination, newState.uid);
  4184. var newUrl;
  4185. if (this._updateUrl && destination && destination.hash) {
  4186. var baseUrl = document.location.href.split('#')[0];
  4187. if (!baseUrl.startsWith('file://')) {
  4188. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  4189. }
  4190. }
  4191. if (shouldReplace) {
  4192. if (newUrl) {
  4193. window.history.replaceState(newState, '', newUrl);
  4194. } else {
  4195. window.history.replaceState(newState, '');
  4196. }
  4197. } else {
  4198. this._maxUid = this._uid;
  4199. if (newUrl) {
  4200. window.history.pushState(newState, '', newUrl);
  4201. } else {
  4202. window.history.pushState(newState, '');
  4203. }
  4204. }
  4205. }
  4206. }, {
  4207. key: "_tryPushCurrentPosition",
  4208. value: function _tryPushCurrentPosition() {
  4209. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4210. if (!this._position) {
  4211. return;
  4212. }
  4213. var position = this._position;
  4214. if (temporary) {
  4215. position = Object.assign(Object.create(null), this._position);
  4216. position.temporary = true;
  4217. }
  4218. if (!this._destination) {
  4219. this._pushOrReplaceState(position);
  4220. return;
  4221. }
  4222. if (this._destination.temporary) {
  4223. this._pushOrReplaceState(position, true);
  4224. return;
  4225. }
  4226. if (this._destination.hash === position.hash) {
  4227. return;
  4228. }
  4229. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4230. return;
  4231. }
  4232. var forceReplace = false;
  4233. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  4234. if (this._destination.dest || !this._destination.first) {
  4235. return;
  4236. }
  4237. forceReplace = true;
  4238. }
  4239. this._pushOrReplaceState(position, forceReplace);
  4240. }
  4241. }, {
  4242. key: "_isValidState",
  4243. value: function _isValidState(state) {
  4244. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4245. if (!state) {
  4246. return false;
  4247. }
  4248. if (state.fingerprint !== this.fingerprint) {
  4249. if (checkReload) {
  4250. if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
  4251. return false;
  4252. }
  4253. var _performance$getEntri = performance.getEntriesByType('navigation'),
  4254. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  4255. perfEntry = _performance$getEntri2[0];
  4256. if (!perfEntry || perfEntry.type !== 'reload') {
  4257. return false;
  4258. }
  4259. } else {
  4260. return false;
  4261. }
  4262. }
  4263. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4264. return false;
  4265. }
  4266. if (state.destination === null || _typeof(state.destination) !== 'object') {
  4267. return false;
  4268. }
  4269. return true;
  4270. }
  4271. }, {
  4272. key: "_updateInternalState",
  4273. value: function _updateInternalState(destination, uid) {
  4274. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4275. if (this._updateViewareaTimeout) {
  4276. clearTimeout(this._updateViewareaTimeout);
  4277. this._updateViewareaTimeout = null;
  4278. }
  4279. if (removeTemporary && destination && destination.temporary) {
  4280. delete destination.temporary;
  4281. }
  4282. this._destination = destination;
  4283. this._uid = uid;
  4284. this._numPositionUpdates = 0;
  4285. }
  4286. }, {
  4287. key: "_updateViewarea",
  4288. value: function _updateViewarea(_ref4) {
  4289. var _this3 = this;
  4290. var location = _ref4.location;
  4291. if (this._updateViewareaTimeout) {
  4292. clearTimeout(this._updateViewareaTimeout);
  4293. this._updateViewareaTimeout = null;
  4294. }
  4295. this._position = {
  4296. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  4297. page: this.linkService.page,
  4298. first: location.pageNumber,
  4299. rotation: location.rotation
  4300. };
  4301. if (this._popStateInProgress) {
  4302. return;
  4303. }
  4304. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4305. this._numPositionUpdates++;
  4306. }
  4307. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4308. this._updateViewareaTimeout = setTimeout(function () {
  4309. if (!_this3._popStateInProgress) {
  4310. _this3._tryPushCurrentPosition(true);
  4311. }
  4312. _this3._updateViewareaTimeout = null;
  4313. }, UPDATE_VIEWAREA_TIMEOUT);
  4314. }
  4315. }
  4316. }, {
  4317. key: "_popState",
  4318. value: function _popState(_ref5) {
  4319. var _this4 = this;
  4320. var state = _ref5.state;
  4321. var newHash = getCurrentHash(),
  4322. hashChanged = this._currentHash !== newHash;
  4323. this._currentHash = newHash;
  4324. if (!state || false) {
  4325. this._uid++;
  4326. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  4327. hash = _parseCurrentHash2.hash,
  4328. page = _parseCurrentHash2.page,
  4329. rotation = _parseCurrentHash2.rotation;
  4330. this._pushOrReplaceState({
  4331. hash: hash,
  4332. page: page,
  4333. rotation: rotation
  4334. }, true);
  4335. return;
  4336. }
  4337. if (!this._isValidState(state)) {
  4338. return;
  4339. }
  4340. this._popStateInProgress = true;
  4341. if (hashChanged) {
  4342. this._blockHashChange++;
  4343. (0, _ui_utils.waitOnEventOrTimeout)({
  4344. target: window,
  4345. name: 'hashchange',
  4346. delay: HASH_CHANGE_TIMEOUT
  4347. }).then(function () {
  4348. _this4._blockHashChange--;
  4349. });
  4350. }
  4351. var destination = state.destination;
  4352. this._updateInternalState(destination, state.uid, true);
  4353. if (this._uid > this._maxUid) {
  4354. this._maxUid = this._uid;
  4355. }
  4356. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4357. this.linkService.rotation = destination.rotation;
  4358. }
  4359. if (destination.dest) {
  4360. this.linkService.navigateTo(destination.dest);
  4361. } else if (destination.hash) {
  4362. this.linkService.setHash(destination.hash);
  4363. } else if (destination.page) {
  4364. this.linkService.page = destination.page;
  4365. }
  4366. Promise.resolve().then(function () {
  4367. _this4._popStateInProgress = false;
  4368. });
  4369. }
  4370. }, {
  4371. key: "_bindEvents",
  4372. value: function _bindEvents() {
  4373. var _this5 = this;
  4374. var _boundEvents = this._boundEvents,
  4375. eventBus = this.eventBus;
  4376. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  4377. _boundEvents.popState = this._popState.bind(this);
  4378. _boundEvents.pageHide = function (evt) {
  4379. if (!_this5._destination || _this5._destination.temporary) {
  4380. _this5._tryPushCurrentPosition();
  4381. }
  4382. };
  4383. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  4384. window.addEventListener('popstate', _boundEvents.popState);
  4385. window.addEventListener('pagehide', _boundEvents.pageHide);
  4386. }
  4387. }, {
  4388. key: "popStateInProgress",
  4389. get: function get() {
  4390. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4391. }
  4392. }]);
  4393. return PDFHistory;
  4394. }();
  4395. exports.PDFHistory = PDFHistory;
  4396. function isDestHashesEqual(destHash, pushHash) {
  4397. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  4398. return false;
  4399. }
  4400. if (destHash === pushHash) {
  4401. return true;
  4402. }
  4403. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4404. nameddest = _parseQueryString.nameddest;
  4405. if (nameddest === pushHash) {
  4406. return true;
  4407. }
  4408. return false;
  4409. }
  4410. function isDestArraysEqual(firstDest, secondDest) {
  4411. function isEntryEqual(first, second) {
  4412. if (_typeof(first) !== _typeof(second)) {
  4413. return false;
  4414. }
  4415. if (Array.isArray(first) || Array.isArray(second)) {
  4416. return false;
  4417. }
  4418. if (first !== null && _typeof(first) === 'object' && second !== null) {
  4419. if (Object.keys(first).length !== Object.keys(second).length) {
  4420. return false;
  4421. }
  4422. for (var key in first) {
  4423. if (!isEntryEqual(first[key], second[key])) {
  4424. return false;
  4425. }
  4426. }
  4427. return true;
  4428. }
  4429. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4430. }
  4431. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  4432. return false;
  4433. }
  4434. if (firstDest.length !== secondDest.length) {
  4435. return false;
  4436. }
  4437. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4438. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4439. return false;
  4440. }
  4441. }
  4442. return true;
  4443. }
  4444. /***/ }),
  4445. /* 15 */
  4446. /***/ (function(module, exports, __w_pdfjs_require__) {
  4447. "use strict";
  4448. Object.defineProperty(exports, "__esModule", {
  4449. value: true
  4450. });
  4451. exports.PDFPageView = void 0;
  4452. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  4453. var _ui_utils = __w_pdfjs_require__(3);
  4454. var _pdfjsLib = __w_pdfjs_require__(2);
  4455. var _pdf_rendering_queue = __w_pdfjs_require__(16);
  4456. var _viewer_compatibility = __w_pdfjs_require__(17);
  4457. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4458. 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); } }
  4459. 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); }); }; }
  4460. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4461. 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); } }
  4462. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4463. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  4464. var PDFPageView =
  4465. /*#__PURE__*/
  4466. function () {
  4467. function PDFPageView(options) {
  4468. _classCallCheck(this, PDFPageView);
  4469. var container = options.container;
  4470. var defaultViewport = options.defaultViewport;
  4471. this.id = options.id;
  4472. this.renderingId = 'page' + this.id;
  4473. this.pdfPage = null;
  4474. this.pageLabel = null;
  4475. this.rotation = 0;
  4476. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  4477. this.viewport = defaultViewport;
  4478. this.pdfPageRotate = defaultViewport.rotation;
  4479. this.hasRestrictedScaling = false;
  4480. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4481. this.imageResourcesPath = options.imageResourcesPath || '';
  4482. this.renderInteractiveForms = options.renderInteractiveForms || false;
  4483. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4484. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  4485. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  4486. this.renderingQueue = options.renderingQueue;
  4487. this.textLayerFactory = options.textLayerFactory;
  4488. this.annotationLayerFactory = options.annotationLayerFactory;
  4489. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4490. this.enableWebGL = options.enableWebGL || false;
  4491. this.l10n = options.l10n || _ui_utils.NullL10n;
  4492. this.paintTask = null;
  4493. this.paintedViewportMap = new WeakMap();
  4494. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4495. this.resume = null;
  4496. this.error = null;
  4497. this.onBeforeDraw = null;
  4498. this.onAfterDraw = null;
  4499. this.annotationLayer = null;
  4500. this.textLayer = null;
  4501. this.zoomLayer = null;
  4502. var div = document.createElement('div');
  4503. div.className = 'page';
  4504. div.style.width = Math.floor(this.viewport.width) + 'px';
  4505. div.style.height = Math.floor(this.viewport.height) + 'px';
  4506. div.setAttribute('data-page-number', this.id);
  4507. this.div = div;
  4508. container.appendChild(div);
  4509. }
  4510. _createClass(PDFPageView, [{
  4511. key: "setPdfPage",
  4512. value: function setPdfPage(pdfPage) {
  4513. this.pdfPage = pdfPage;
  4514. this.pdfPageRotate = pdfPage.rotate;
  4515. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4516. this.viewport = pdfPage.getViewport({
  4517. scale: this.scale * _ui_utils.CSS_UNITS,
  4518. rotation: totalRotation
  4519. });
  4520. this.stats = pdfPage.stats;
  4521. this.reset();
  4522. }
  4523. }, {
  4524. key: "destroy",
  4525. value: function destroy() {
  4526. this.reset();
  4527. if (this.pdfPage) {
  4528. this.pdfPage.cleanup();
  4529. }
  4530. }
  4531. }, {
  4532. key: "_resetZoomLayer",
  4533. value: function _resetZoomLayer() {
  4534. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4535. if (!this.zoomLayer) {
  4536. return;
  4537. }
  4538. var zoomLayerCanvas = this.zoomLayer.firstChild;
  4539. this.paintedViewportMap["delete"](zoomLayerCanvas);
  4540. zoomLayerCanvas.width = 0;
  4541. zoomLayerCanvas.height = 0;
  4542. if (removeFromDOM) {
  4543. this.zoomLayer.remove();
  4544. }
  4545. this.zoomLayer = null;
  4546. }
  4547. }, {
  4548. key: "reset",
  4549. value: function reset() {
  4550. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4551. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4552. this.cancelRendering(keepAnnotations);
  4553. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4554. var div = this.div;
  4555. div.style.width = Math.floor(this.viewport.width) + 'px';
  4556. div.style.height = Math.floor(this.viewport.height) + 'px';
  4557. var childNodes = div.childNodes;
  4558. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  4559. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  4560. for (var i = childNodes.length - 1; i >= 0; i--) {
  4561. var node = childNodes[i];
  4562. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  4563. continue;
  4564. }
  4565. div.removeChild(node);
  4566. }
  4567. div.removeAttribute('data-loaded');
  4568. if (currentAnnotationNode) {
  4569. this.annotationLayer.hide();
  4570. } else if (this.annotationLayer) {
  4571. this.annotationLayer.cancel();
  4572. this.annotationLayer = null;
  4573. }
  4574. if (!currentZoomLayerNode) {
  4575. if (this.canvas) {
  4576. this.paintedViewportMap["delete"](this.canvas);
  4577. this.canvas.width = 0;
  4578. this.canvas.height = 0;
  4579. delete this.canvas;
  4580. }
  4581. this._resetZoomLayer();
  4582. }
  4583. if (this.svg) {
  4584. this.paintedViewportMap["delete"](this.svg);
  4585. delete this.svg;
  4586. }
  4587. this.loadingIconDiv = document.createElement('div');
  4588. this.loadingIconDiv.className = 'loadingIcon';
  4589. div.appendChild(this.loadingIconDiv);
  4590. }
  4591. }, {
  4592. key: "update",
  4593. value: function update(scale, rotation) {
  4594. this.scale = scale || this.scale;
  4595. if (typeof rotation !== 'undefined') {
  4596. this.rotation = rotation;
  4597. }
  4598. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4599. this.viewport = this.viewport.clone({
  4600. scale: this.scale * _ui_utils.CSS_UNITS,
  4601. rotation: totalRotation
  4602. });
  4603. if (this.svg) {
  4604. this.cssTransform(this.svg, true);
  4605. this.eventBus.dispatch('pagerendered', {
  4606. source: this,
  4607. pageNumber: this.id,
  4608. cssTransform: true
  4609. });
  4610. return;
  4611. }
  4612. var isScalingRestricted = false;
  4613. if (this.canvas && this.maxCanvasPixels > 0) {
  4614. var outputScale = this.outputScale;
  4615. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  4616. isScalingRestricted = true;
  4617. }
  4618. }
  4619. if (this.canvas) {
  4620. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  4621. this.cssTransform(this.canvas, true);
  4622. this.eventBus.dispatch('pagerendered', {
  4623. source: this,
  4624. pageNumber: this.id,
  4625. cssTransform: true
  4626. });
  4627. return;
  4628. }
  4629. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  4630. this.zoomLayer = this.canvas.parentNode;
  4631. this.zoomLayer.style.position = 'absolute';
  4632. }
  4633. }
  4634. if (this.zoomLayer) {
  4635. this.cssTransform(this.zoomLayer.firstChild);
  4636. }
  4637. this.reset(true, true);
  4638. }
  4639. }, {
  4640. key: "cancelRendering",
  4641. value: function cancelRendering() {
  4642. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4643. if (this.paintTask) {
  4644. this.paintTask.cancel();
  4645. this.paintTask = null;
  4646. }
  4647. this.resume = null;
  4648. if (this.textLayer) {
  4649. this.textLayer.cancel();
  4650. this.textLayer = null;
  4651. }
  4652. if (!keepAnnotations && this.annotationLayer) {
  4653. this.annotationLayer.cancel();
  4654. this.annotationLayer = null;
  4655. }
  4656. }
  4657. }, {
  4658. key: "cssTransform",
  4659. value: function cssTransform(target) {
  4660. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4661. var width = this.viewport.width;
  4662. var height = this.viewport.height;
  4663. var div = this.div;
  4664. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  4665. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  4666. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  4667. var absRotation = Math.abs(relativeRotation);
  4668. var scaleX = 1,
  4669. scaleY = 1;
  4670. if (absRotation === 90 || absRotation === 270) {
  4671. scaleX = height / width;
  4672. scaleY = width / height;
  4673. }
  4674. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  4675. target.style.transform = cssTransform;
  4676. if (this.textLayer) {
  4677. var textLayerViewport = this.textLayer.viewport;
  4678. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  4679. var textAbsRotation = Math.abs(textRelativeRotation);
  4680. var scale = width / textLayerViewport.width;
  4681. if (textAbsRotation === 90 || textAbsRotation === 270) {
  4682. scale = width / textLayerViewport.height;
  4683. }
  4684. var textLayerDiv = this.textLayer.textLayerDiv;
  4685. var transX, transY;
  4686. switch (textAbsRotation) {
  4687. case 0:
  4688. transX = transY = 0;
  4689. break;
  4690. case 90:
  4691. transX = 0;
  4692. transY = '-' + textLayerDiv.style.height;
  4693. break;
  4694. case 180:
  4695. transX = '-' + textLayerDiv.style.width;
  4696. transY = '-' + textLayerDiv.style.height;
  4697. break;
  4698. case 270:
  4699. transX = '-' + textLayerDiv.style.width;
  4700. transY = 0;
  4701. break;
  4702. default:
  4703. console.error('Bad rotation value.');
  4704. break;
  4705. }
  4706. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  4707. textLayerDiv.style.transformOrigin = '0% 0%';
  4708. }
  4709. if (redrawAnnotations && this.annotationLayer) {
  4710. this.annotationLayer.render(this.viewport, 'display');
  4711. }
  4712. }
  4713. }, {
  4714. key: "getPagePoint",
  4715. value: function getPagePoint(x, y) {
  4716. return this.viewport.convertToPdfPoint(x, y);
  4717. }
  4718. }, {
  4719. key: "draw",
  4720. value: function draw() {
  4721. var _this = this;
  4722. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  4723. console.error('Must be in new state before drawing');
  4724. this.reset();
  4725. }
  4726. if (!this.pdfPage) {
  4727. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4728. return Promise.reject(new Error('Page is not loaded'));
  4729. }
  4730. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  4731. var pdfPage = this.pdfPage;
  4732. var div = this.div;
  4733. var canvasWrapper = document.createElement('div');
  4734. canvasWrapper.style.width = div.style.width;
  4735. canvasWrapper.style.height = div.style.height;
  4736. canvasWrapper.classList.add('canvasWrapper');
  4737. if (this.annotationLayer && this.annotationLayer.div) {
  4738. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  4739. } else {
  4740. div.appendChild(canvasWrapper);
  4741. }
  4742. var textLayer = null;
  4743. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  4744. var textLayerDiv = document.createElement('div');
  4745. textLayerDiv.className = 'textLayer';
  4746. textLayerDiv.style.width = canvasWrapper.style.width;
  4747. textLayerDiv.style.height = canvasWrapper.style.height;
  4748. if (this.annotationLayer && this.annotationLayer.div) {
  4749. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  4750. } else {
  4751. div.appendChild(textLayerDiv);
  4752. }
  4753. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  4754. }
  4755. this.textLayer = textLayer;
  4756. var renderContinueCallback = null;
  4757. if (this.renderingQueue) {
  4758. renderContinueCallback = function renderContinueCallback(cont) {
  4759. if (!_this.renderingQueue.isHighestPriority(_this)) {
  4760. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  4761. _this.resume = function () {
  4762. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  4763. cont();
  4764. };
  4765. return;
  4766. }
  4767. cont();
  4768. };
  4769. }
  4770. var finishPaintTask =
  4771. /*#__PURE__*/
  4772. function () {
  4773. var _ref = _asyncToGenerator(
  4774. /*#__PURE__*/
  4775. _regenerator["default"].mark(function _callee(error) {
  4776. return _regenerator["default"].wrap(function _callee$(_context) {
  4777. while (1) {
  4778. switch (_context.prev = _context.next) {
  4779. case 0:
  4780. if (paintTask === _this.paintTask) {
  4781. _this.paintTask = null;
  4782. }
  4783. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  4784. _context.next = 4;
  4785. break;
  4786. }
  4787. _this.error = null;
  4788. return _context.abrupt("return");
  4789. case 4:
  4790. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4791. if (_this.loadingIconDiv) {
  4792. div.removeChild(_this.loadingIconDiv);
  4793. delete _this.loadingIconDiv;
  4794. }
  4795. _this._resetZoomLayer(true);
  4796. _this.error = error;
  4797. _this.stats = pdfPage.stats;
  4798. if (_this.onAfterDraw) {
  4799. _this.onAfterDraw();
  4800. }
  4801. _this.eventBus.dispatch('pagerendered', {
  4802. source: _this,
  4803. pageNumber: _this.id,
  4804. cssTransform: false
  4805. });
  4806. if (!error) {
  4807. _context.next = 13;
  4808. break;
  4809. }
  4810. throw error;
  4811. case 13:
  4812. case "end":
  4813. return _context.stop();
  4814. }
  4815. }
  4816. }, _callee);
  4817. }));
  4818. return function finishPaintTask(_x) {
  4819. return _ref.apply(this, arguments);
  4820. };
  4821. }();
  4822. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  4823. paintTask.onRenderContinue = renderContinueCallback;
  4824. this.paintTask = paintTask;
  4825. var resultPromise = paintTask.promise.then(function () {
  4826. return finishPaintTask(null).then(function () {
  4827. if (textLayer) {
  4828. var readableStream = pdfPage.streamTextContent({
  4829. normalizeWhitespace: true
  4830. });
  4831. textLayer.setTextContentStream(readableStream);
  4832. textLayer.render();
  4833. }
  4834. });
  4835. }, function (reason) {
  4836. return finishPaintTask(reason);
  4837. });
  4838. if (this.annotationLayerFactory) {
  4839. if (!this.annotationLayer) {
  4840. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  4841. }
  4842. this.annotationLayer.render(this.viewport, 'display');
  4843. }
  4844. div.setAttribute('data-loaded', true);
  4845. if (this.onBeforeDraw) {
  4846. this.onBeforeDraw();
  4847. }
  4848. return resultPromise;
  4849. }
  4850. }, {
  4851. key: "paintOnCanvas",
  4852. value: function paintOnCanvas(canvasWrapper) {
  4853. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  4854. var result = {
  4855. promise: renderCapability.promise,
  4856. onRenderContinue: function onRenderContinue(cont) {
  4857. cont();
  4858. },
  4859. cancel: function cancel() {
  4860. renderTask.cancel();
  4861. }
  4862. };
  4863. var viewport = this.viewport;
  4864. var canvas = document.createElement('canvas');
  4865. canvas.id = this.renderingId;
  4866. canvas.setAttribute('hidden', 'hidden');
  4867. var isCanvasHidden = true;
  4868. var showCanvas = function showCanvas() {
  4869. if (isCanvasHidden) {
  4870. canvas.removeAttribute('hidden');
  4871. isCanvasHidden = false;
  4872. }
  4873. };
  4874. canvasWrapper.appendChild(canvas);
  4875. this.canvas = canvas;
  4876. canvas.mozOpaque = true;
  4877. var ctx = canvas.getContext('2d', {
  4878. alpha: false
  4879. });
  4880. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  4881. this.outputScale = outputScale;
  4882. if (this.useOnlyCssZoom) {
  4883. var actualSizeViewport = viewport.clone({
  4884. scale: _ui_utils.CSS_UNITS
  4885. });
  4886. outputScale.sx *= actualSizeViewport.width / viewport.width;
  4887. outputScale.sy *= actualSizeViewport.height / viewport.height;
  4888. outputScale.scaled = true;
  4889. }
  4890. if (this.maxCanvasPixels > 0) {
  4891. var pixelsInViewport = viewport.width * viewport.height;
  4892. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  4893. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  4894. outputScale.sx = maxScale;
  4895. outputScale.sy = maxScale;
  4896. outputScale.scaled = true;
  4897. this.hasRestrictedScaling = true;
  4898. } else {
  4899. this.hasRestrictedScaling = false;
  4900. }
  4901. }
  4902. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  4903. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  4904. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  4905. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  4906. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  4907. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  4908. this.paintedViewportMap.set(canvas, viewport);
  4909. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  4910. var renderContext = {
  4911. canvasContext: ctx,
  4912. transform: transform,
  4913. viewport: this.viewport,
  4914. enableWebGL: this.enableWebGL,
  4915. renderInteractiveForms: this.renderInteractiveForms
  4916. };
  4917. var renderTask = this.pdfPage.render(renderContext);
  4918. renderTask.onContinue = function (cont) {
  4919. showCanvas();
  4920. if (result.onRenderContinue) {
  4921. result.onRenderContinue(cont);
  4922. } else {
  4923. cont();
  4924. }
  4925. };
  4926. renderTask.promise.then(function () {
  4927. showCanvas();
  4928. renderCapability.resolve(undefined);
  4929. }, function (error) {
  4930. showCanvas();
  4931. renderCapability.reject(error);
  4932. });
  4933. return result;
  4934. }
  4935. }, {
  4936. key: "paintOnSvg",
  4937. value: function paintOnSvg(wrapper) {
  4938. var _this2 = this;
  4939. var cancelled = false;
  4940. var ensureNotCancelled = function ensureNotCancelled() {
  4941. if (cancelled) {
  4942. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  4943. }
  4944. };
  4945. var pdfPage = this.pdfPage;
  4946. var actualSizeViewport = this.viewport.clone({
  4947. scale: _ui_utils.CSS_UNITS
  4948. });
  4949. var promise = pdfPage.getOperatorList().then(function (opList) {
  4950. ensureNotCancelled();
  4951. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  4952. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  4953. ensureNotCancelled();
  4954. _this2.svg = svg;
  4955. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  4956. svg.style.width = wrapper.style.width;
  4957. svg.style.height = wrapper.style.height;
  4958. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4959. wrapper.appendChild(svg);
  4960. });
  4961. });
  4962. return {
  4963. promise: promise,
  4964. onRenderContinue: function onRenderContinue(cont) {
  4965. cont();
  4966. },
  4967. cancel: function cancel() {
  4968. cancelled = true;
  4969. }
  4970. };
  4971. }
  4972. }, {
  4973. key: "setPageLabel",
  4974. value: function setPageLabel(label) {
  4975. this.pageLabel = typeof label === 'string' ? label : null;
  4976. if (this.pageLabel !== null) {
  4977. this.div.setAttribute('data-page-label', this.pageLabel);
  4978. } else {
  4979. this.div.removeAttribute('data-page-label');
  4980. }
  4981. }
  4982. }, {
  4983. key: "width",
  4984. get: function get() {
  4985. return this.viewport.width;
  4986. }
  4987. }, {
  4988. key: "height",
  4989. get: function get() {
  4990. return this.viewport.height;
  4991. }
  4992. }]);
  4993. return PDFPageView;
  4994. }();
  4995. exports.PDFPageView = PDFPageView;
  4996. /***/ }),
  4997. /* 16 */
  4998. /***/ (function(module, exports, __w_pdfjs_require__) {
  4999. "use strict";
  5000. Object.defineProperty(exports, "__esModule", {
  5001. value: true
  5002. });
  5003. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  5004. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5005. 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); } }
  5006. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5007. var CLEANUP_TIMEOUT = 30000;
  5008. var RenderingStates = {
  5009. INITIAL: 0,
  5010. RUNNING: 1,
  5011. PAUSED: 2,
  5012. FINISHED: 3
  5013. };
  5014. exports.RenderingStates = RenderingStates;
  5015. var PDFRenderingQueue =
  5016. /*#__PURE__*/
  5017. function () {
  5018. function PDFRenderingQueue() {
  5019. _classCallCheck(this, PDFRenderingQueue);
  5020. this.pdfViewer = null;
  5021. this.pdfThumbnailViewer = null;
  5022. this.onIdle = null;
  5023. this.highestPriorityPage = null;
  5024. this.idleTimeout = null;
  5025. this.printing = false;
  5026. this.isThumbnailViewEnabled = false;
  5027. }
  5028. _createClass(PDFRenderingQueue, [{
  5029. key: "setViewer",
  5030. value: function setViewer(pdfViewer) {
  5031. this.pdfViewer = pdfViewer;
  5032. }
  5033. }, {
  5034. key: "setThumbnailViewer",
  5035. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5036. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5037. }
  5038. }, {
  5039. key: "isHighestPriority",
  5040. value: function isHighestPriority(view) {
  5041. return this.highestPriorityPage === view.renderingId;
  5042. }
  5043. }, {
  5044. key: "renderHighestPriority",
  5045. value: function renderHighestPriority(currentlyVisiblePages) {
  5046. if (this.idleTimeout) {
  5047. clearTimeout(this.idleTimeout);
  5048. this.idleTimeout = null;
  5049. }
  5050. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5051. return;
  5052. }
  5053. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5054. if (this.pdfThumbnailViewer.forceRendering()) {
  5055. return;
  5056. }
  5057. }
  5058. if (this.printing) {
  5059. return;
  5060. }
  5061. if (this.onIdle) {
  5062. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5063. }
  5064. }
  5065. }, {
  5066. key: "getHighestPriority",
  5067. value: function getHighestPriority(visible, views, scrolledDown) {
  5068. var visibleViews = visible.views;
  5069. var numVisible = visibleViews.length;
  5070. if (numVisible === 0) {
  5071. return null;
  5072. }
  5073. for (var i = 0; i < numVisible; ++i) {
  5074. var view = visibleViews[i].view;
  5075. if (!this.isViewFinished(view)) {
  5076. return view;
  5077. }
  5078. }
  5079. if (scrolledDown) {
  5080. var nextPageIndex = visible.last.id;
  5081. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5082. return views[nextPageIndex];
  5083. }
  5084. } else {
  5085. var previousPageIndex = visible.first.id - 2;
  5086. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5087. return views[previousPageIndex];
  5088. }
  5089. }
  5090. return null;
  5091. }
  5092. }, {
  5093. key: "isViewFinished",
  5094. value: function isViewFinished(view) {
  5095. return view.renderingState === RenderingStates.FINISHED;
  5096. }
  5097. }, {
  5098. key: "renderView",
  5099. value: function renderView(view) {
  5100. var _this = this;
  5101. switch (view.renderingState) {
  5102. case RenderingStates.FINISHED:
  5103. return false;
  5104. case RenderingStates.PAUSED:
  5105. this.highestPriorityPage = view.renderingId;
  5106. view.resume();
  5107. break;
  5108. case RenderingStates.RUNNING:
  5109. this.highestPriorityPage = view.renderingId;
  5110. break;
  5111. case RenderingStates.INITIAL:
  5112. this.highestPriorityPage = view.renderingId;
  5113. view.draw()["finally"](function () {
  5114. _this.renderHighestPriority();
  5115. });
  5116. break;
  5117. }
  5118. return true;
  5119. }
  5120. }]);
  5121. return PDFRenderingQueue;
  5122. }();
  5123. exports.PDFRenderingQueue = PDFRenderingQueue;
  5124. /***/ }),
  5125. /* 17 */
  5126. /***/ (function(module, exports, __w_pdfjs_require__) {
  5127. "use strict";
  5128. var compatibilityParams = Object.create(null);
  5129. {
  5130. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  5131. var isAndroid = /Android/.test(userAgent);
  5132. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  5133. (function checkCanvasSizeLimitation() {
  5134. if (isIOS || isAndroid) {
  5135. compatibilityParams.maxCanvasPixels = 5242880;
  5136. }
  5137. })();
  5138. }
  5139. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  5140. /***/ }),
  5141. /* 18 */
  5142. /***/ (function(module, exports, __w_pdfjs_require__) {
  5143. "use strict";
  5144. Object.defineProperty(exports, "__esModule", {
  5145. value: true
  5146. });
  5147. exports.PDFSinglePageViewer = void 0;
  5148. var _base_viewer = __w_pdfjs_require__(19);
  5149. var _pdfjsLib = __w_pdfjs_require__(2);
  5150. 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); }
  5151. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5152. 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); } }
  5153. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5154. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5155. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5156. 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); }
  5157. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5158. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5159. 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); }
  5160. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5161. var PDFSinglePageViewer =
  5162. /*#__PURE__*/
  5163. function (_BaseViewer) {
  5164. _inherits(PDFSinglePageViewer, _BaseViewer);
  5165. function PDFSinglePageViewer(options) {
  5166. var _this;
  5167. _classCallCheck(this, PDFSinglePageViewer);
  5168. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
  5169. _this.eventBus.on('pagesinit', function (evt) {
  5170. _this._ensurePageViewVisible();
  5171. });
  5172. return _this;
  5173. }
  5174. _createClass(PDFSinglePageViewer, [{
  5175. key: "_resetView",
  5176. value: function _resetView() {
  5177. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  5178. this._previousPageNumber = 1;
  5179. this._shadowViewer = document.createDocumentFragment();
  5180. this._updateScrollDown = null;
  5181. }
  5182. }, {
  5183. key: "_ensurePageViewVisible",
  5184. value: function _ensurePageViewVisible() {
  5185. var pageView = this._pages[this._currentPageNumber - 1];
  5186. var previousPageView = this._pages[this._previousPageNumber - 1];
  5187. var viewerNodes = this.viewer.childNodes;
  5188. switch (viewerNodes.length) {
  5189. case 0:
  5190. this.viewer.appendChild(pageView.div);
  5191. break;
  5192. case 1:
  5193. if (viewerNodes[0] !== previousPageView.div) {
  5194. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  5195. }
  5196. if (pageView === previousPageView) {
  5197. break;
  5198. }
  5199. this._shadowViewer.appendChild(previousPageView.div);
  5200. this.viewer.appendChild(pageView.div);
  5201. this.container.scrollTop = 0;
  5202. break;
  5203. default:
  5204. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  5205. }
  5206. this._previousPageNumber = this._currentPageNumber;
  5207. }
  5208. }, {
  5209. key: "_scrollUpdate",
  5210. value: function _scrollUpdate() {
  5211. if (this._updateScrollDown) {
  5212. this._updateScrollDown();
  5213. }
  5214. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  5215. }
  5216. }, {
  5217. key: "_scrollIntoView",
  5218. value: function _scrollIntoView(_ref) {
  5219. var _this2 = this;
  5220. var pageDiv = _ref.pageDiv,
  5221. _ref$pageSpot = _ref.pageSpot,
  5222. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  5223. _ref$pageNumber = _ref.pageNumber,
  5224. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  5225. if (pageNumber) {
  5226. this._setCurrentPageNumber(pageNumber);
  5227. }
  5228. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  5229. this._ensurePageViewVisible();
  5230. this.update();
  5231. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  5232. pageDiv: pageDiv,
  5233. pageSpot: pageSpot,
  5234. pageNumber: pageNumber
  5235. });
  5236. this._updateScrollDown = function () {
  5237. _this2.scroll.down = scrolledDown;
  5238. _this2._updateScrollDown = null;
  5239. };
  5240. }
  5241. }, {
  5242. key: "_getVisiblePages",
  5243. value: function _getVisiblePages() {
  5244. return this._getCurrentVisiblePage();
  5245. }
  5246. }, {
  5247. key: "_updateHelper",
  5248. value: function _updateHelper(visiblePages) {}
  5249. }, {
  5250. key: "_updateScrollMode",
  5251. value: function _updateScrollMode() {}
  5252. }, {
  5253. key: "_updateSpreadMode",
  5254. value: function _updateSpreadMode() {}
  5255. }, {
  5256. key: "_setDocumentViewerElement",
  5257. get: function get() {
  5258. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  5259. }
  5260. }, {
  5261. key: "_isScrollModeHorizontal",
  5262. get: function get() {
  5263. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  5264. }
  5265. }]);
  5266. return PDFSinglePageViewer;
  5267. }(_base_viewer.BaseViewer);
  5268. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  5269. /***/ }),
  5270. /* 19 */
  5271. /***/ (function(module, exports, __w_pdfjs_require__) {
  5272. "use strict";
  5273. Object.defineProperty(exports, "__esModule", {
  5274. value: true
  5275. });
  5276. exports.BaseViewer = void 0;
  5277. var _ui_utils = __w_pdfjs_require__(3);
  5278. var _pdf_rendering_queue = __w_pdfjs_require__(16);
  5279. var _annotation_layer_builder = __w_pdfjs_require__(1);
  5280. var _pdfjsLib = __w_pdfjs_require__(2);
  5281. var _pdf_page_view = __w_pdfjs_require__(15);
  5282. var _pdf_link_service = __w_pdfjs_require__(7);
  5283. var _text_layer_builder = __w_pdfjs_require__(8);
  5284. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5285. 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); } }
  5286. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5287. var DEFAULT_CACHE_SIZE = 10;
  5288. function PDFPageViewBuffer(size) {
  5289. var data = [];
  5290. this.push = function (view) {
  5291. var i = data.indexOf(view);
  5292. if (i >= 0) {
  5293. data.splice(i, 1);
  5294. }
  5295. data.push(view);
  5296. if (data.length > size) {
  5297. data.shift().destroy();
  5298. }
  5299. };
  5300. this.resize = function (newSize, pagesToKeep) {
  5301. size = newSize;
  5302. if (pagesToKeep) {
  5303. var pageIdsToKeep = new Set();
  5304. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  5305. pageIdsToKeep.add(pagesToKeep[i].id);
  5306. }
  5307. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  5308. return pageIdsToKeep.has(page.id);
  5309. });
  5310. }
  5311. while (data.length > size) {
  5312. data.shift().destroy();
  5313. }
  5314. };
  5315. }
  5316. function isSameScale(oldScale, newScale) {
  5317. if (newScale === oldScale) {
  5318. return true;
  5319. }
  5320. if (Math.abs(newScale - oldScale) < 1e-15) {
  5321. return true;
  5322. }
  5323. return false;
  5324. }
  5325. var BaseViewer =
  5326. /*#__PURE__*/
  5327. function () {
  5328. function BaseViewer(options) {
  5329. var _this = this;
  5330. _classCallCheck(this, BaseViewer);
  5331. if (this.constructor === BaseViewer) {
  5332. throw new Error('Cannot initialize BaseViewer.');
  5333. }
  5334. this._name = this.constructor.name;
  5335. this.container = options.container;
  5336. this.viewer = options.viewer || options.container.firstElementChild;
  5337. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  5338. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  5339. this.downloadManager = options.downloadManager || null;
  5340. this.findController = options.findController || null;
  5341. this.removePageBorders = options.removePageBorders || false;
  5342. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  5343. this.imageResourcesPath = options.imageResourcesPath || '';
  5344. this.renderInteractiveForms = options.renderInteractiveForms || false;
  5345. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  5346. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  5347. this.enableWebGL = options.enableWebGL || false;
  5348. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  5349. this.maxCanvasPixels = options.maxCanvasPixels;
  5350. this.l10n = options.l10n || _ui_utils.NullL10n;
  5351. this.defaultRenderingQueue = !options.renderingQueue;
  5352. if (this.defaultRenderingQueue) {
  5353. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  5354. this.renderingQueue.setViewer(this);
  5355. } else {
  5356. this.renderingQueue = options.renderingQueue;
  5357. }
  5358. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  5359. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  5360. this._resetView();
  5361. if (this.removePageBorders) {
  5362. this.viewer.classList.add('removePageBorders');
  5363. }
  5364. Promise.resolve().then(function () {
  5365. _this.eventBus.dispatch('baseviewerinit', {
  5366. source: _this
  5367. });
  5368. });
  5369. }
  5370. _createClass(BaseViewer, [{
  5371. key: "getPageView",
  5372. value: function getPageView(index) {
  5373. return this._pages[index];
  5374. }
  5375. }, {
  5376. key: "_setCurrentPageNumber",
  5377. value: function _setCurrentPageNumber(val) {
  5378. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5379. if (this._currentPageNumber === val) {
  5380. if (resetCurrentPageView) {
  5381. this._resetCurrentPageView();
  5382. }
  5383. return true;
  5384. }
  5385. if (!(0 < val && val <= this.pagesCount)) {
  5386. return false;
  5387. }
  5388. this._currentPageNumber = val;
  5389. this.eventBus.dispatch('pagechanging', {
  5390. source: this,
  5391. pageNumber: val,
  5392. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  5393. });
  5394. if (resetCurrentPageView) {
  5395. this._resetCurrentPageView();
  5396. }
  5397. return true;
  5398. }
  5399. }, {
  5400. key: "setDocument",
  5401. value: function setDocument(pdfDocument) {
  5402. var _this2 = this;
  5403. if (this.pdfDocument) {
  5404. this._cancelRendering();
  5405. this._resetView();
  5406. if (this.findController) {
  5407. this.findController.setDocument(null);
  5408. }
  5409. }
  5410. this.pdfDocument = pdfDocument;
  5411. if (!pdfDocument) {
  5412. return;
  5413. }
  5414. var pagesCount = pdfDocument.numPages;
  5415. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  5416. this.pagesPromise = pagesCapability.promise;
  5417. pagesCapability.promise.then(function () {
  5418. _this2._pageViewsReady = true;
  5419. _this2.eventBus.dispatch('pagesloaded', {
  5420. source: _this2,
  5421. pagesCount: pagesCount
  5422. });
  5423. });
  5424. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5425. this.onePageRendered = onePageRenderedCapability.promise;
  5426. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  5427. pageView.onBeforeDraw = function () {
  5428. _this2._buffer.push(pageView);
  5429. };
  5430. pageView.onAfterDraw = function () {
  5431. if (!onePageRenderedCapability.settled) {
  5432. onePageRenderedCapability.resolve();
  5433. }
  5434. };
  5435. };
  5436. var firstPagePromise = pdfDocument.getPage(1);
  5437. this.firstPagePromise = firstPagePromise;
  5438. firstPagePromise.then(function (pdfPage) {
  5439. var scale = _this2.currentScale;
  5440. var viewport = pdfPage.getViewport({
  5441. scale: scale * _ui_utils.CSS_UNITS
  5442. });
  5443. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  5444. var textLayerFactory = null;
  5445. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  5446. textLayerFactory = _this2;
  5447. }
  5448. var pageView = new _pdf_page_view.PDFPageView({
  5449. container: _this2._setDocumentViewerElement,
  5450. eventBus: _this2.eventBus,
  5451. id: pageNum,
  5452. scale: scale,
  5453. defaultViewport: viewport.clone(),
  5454. renderingQueue: _this2.renderingQueue,
  5455. textLayerFactory: textLayerFactory,
  5456. textLayerMode: _this2.textLayerMode,
  5457. annotationLayerFactory: _this2,
  5458. imageResourcesPath: _this2.imageResourcesPath,
  5459. renderInteractiveForms: _this2.renderInteractiveForms,
  5460. renderer: _this2.renderer,
  5461. enableWebGL: _this2.enableWebGL,
  5462. useOnlyCssZoom: _this2.useOnlyCssZoom,
  5463. maxCanvasPixels: _this2.maxCanvasPixels,
  5464. l10n: _this2.l10n
  5465. });
  5466. bindOnAfterAndBeforeDraw(pageView);
  5467. _this2._pages.push(pageView);
  5468. }
  5469. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  5470. _this2._updateSpreadMode();
  5471. }
  5472. onePageRenderedCapability.promise.then(function () {
  5473. if (_this2.findController) {
  5474. _this2.findController.setDocument(pdfDocument);
  5475. }
  5476. if (pdfDocument.loadingParams['disableAutoFetch']) {
  5477. pagesCapability.resolve();
  5478. return;
  5479. }
  5480. var getPagesLeft = pagesCount;
  5481. var _loop = function _loop(_pageNum) {
  5482. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  5483. var pageView = _this2._pages[_pageNum - 1];
  5484. if (!pageView.pdfPage) {
  5485. pageView.setPdfPage(pdfPage);
  5486. }
  5487. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  5488. if (--getPagesLeft === 0) {
  5489. pagesCapability.resolve();
  5490. }
  5491. }, function (reason) {
  5492. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  5493. if (--getPagesLeft === 0) {
  5494. pagesCapability.resolve();
  5495. }
  5496. });
  5497. };
  5498. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  5499. _loop(_pageNum);
  5500. }
  5501. });
  5502. _this2.eventBus.dispatch('pagesinit', {
  5503. source: _this2
  5504. });
  5505. if (_this2.defaultRenderingQueue) {
  5506. _this2.update();
  5507. }
  5508. })["catch"](function (reason) {
  5509. console.error('Unable to initialize viewer', reason);
  5510. });
  5511. }
  5512. }, {
  5513. key: "setPageLabels",
  5514. value: function setPageLabels(labels) {
  5515. if (!this.pdfDocument) {
  5516. return;
  5517. }
  5518. if (!labels) {
  5519. this._pageLabels = null;
  5520. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  5521. this._pageLabels = null;
  5522. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  5523. } else {
  5524. this._pageLabels = labels;
  5525. }
  5526. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5527. var pageView = this._pages[i];
  5528. var label = this._pageLabels && this._pageLabels[i];
  5529. pageView.setPageLabel(label);
  5530. }
  5531. }
  5532. }, {
  5533. key: "_resetView",
  5534. value: function _resetView() {
  5535. this._pages = [];
  5536. this._currentPageNumber = 1;
  5537. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  5538. this._currentScaleValue = null;
  5539. this._pageLabels = null;
  5540. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  5541. this._location = null;
  5542. this._pagesRotation = 0;
  5543. this._pagesRequests = [];
  5544. this._pageViewsReady = false;
  5545. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  5546. this._spreadMode = _ui_utils.SpreadMode.NONE;
  5547. this.viewer.textContent = '';
  5548. this._updateScrollMode();
  5549. }
  5550. }, {
  5551. key: "_scrollUpdate",
  5552. value: function _scrollUpdate() {
  5553. if (this.pagesCount === 0) {
  5554. return;
  5555. }
  5556. this.update();
  5557. }
  5558. }, {
  5559. key: "_scrollIntoView",
  5560. value: function _scrollIntoView(_ref) {
  5561. var pageDiv = _ref.pageDiv,
  5562. _ref$pageSpot = _ref.pageSpot,
  5563. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  5564. _ref$pageNumber = _ref.pageNumber,
  5565. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  5566. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  5567. }
  5568. }, {
  5569. key: "_setScaleUpdatePages",
  5570. value: function _setScaleUpdatePages(newScale, newValue) {
  5571. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5572. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5573. this._currentScaleValue = newValue.toString();
  5574. if (isSameScale(this._currentScale, newScale)) {
  5575. if (preset) {
  5576. this.eventBus.dispatch('scalechanging', {
  5577. source: this,
  5578. scale: newScale,
  5579. presetValue: newValue
  5580. });
  5581. }
  5582. return;
  5583. }
  5584. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5585. this._pages[i].update(newScale);
  5586. }
  5587. this._currentScale = newScale;
  5588. if (!noScroll) {
  5589. var page = this._currentPageNumber,
  5590. dest;
  5591. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  5592. page = this._location.pageNumber;
  5593. dest = [null, {
  5594. name: 'XYZ'
  5595. }, this._location.left, this._location.top, null];
  5596. }
  5597. this.scrollPageIntoView({
  5598. pageNumber: page,
  5599. destArray: dest,
  5600. allowNegativeOffset: true
  5601. });
  5602. }
  5603. this.eventBus.dispatch('scalechanging', {
  5604. source: this,
  5605. scale: newScale,
  5606. presetValue: preset ? newValue : undefined
  5607. });
  5608. if (this.defaultRenderingQueue) {
  5609. this.update();
  5610. }
  5611. }
  5612. }, {
  5613. key: "_setScale",
  5614. value: function _setScale(value) {
  5615. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5616. var scale = parseFloat(value);
  5617. if (scale > 0) {
  5618. this._setScaleUpdatePages(scale, value, noScroll, false);
  5619. } else {
  5620. var currentPage = this._pages[this._currentPageNumber - 1];
  5621. if (!currentPage) {
  5622. return;
  5623. }
  5624. var noPadding = this.isInPresentationMode || this.removePageBorders;
  5625. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  5626. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  5627. if (!noPadding && this._isScrollModeHorizontal) {
  5628. var _ref2 = [vPadding, hPadding];
  5629. hPadding = _ref2[0];
  5630. vPadding = _ref2[1];
  5631. }
  5632. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  5633. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  5634. switch (value) {
  5635. case 'page-actual':
  5636. scale = 1;
  5637. break;
  5638. case 'page-width':
  5639. scale = pageWidthScale;
  5640. break;
  5641. case 'page-height':
  5642. scale = pageHeightScale;
  5643. break;
  5644. case 'page-fit':
  5645. scale = Math.min(pageWidthScale, pageHeightScale);
  5646. break;
  5647. case 'auto':
  5648. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  5649. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  5650. break;
  5651. default:
  5652. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  5653. return;
  5654. }
  5655. this._setScaleUpdatePages(scale, value, noScroll, true);
  5656. }
  5657. }
  5658. }, {
  5659. key: "_resetCurrentPageView",
  5660. value: function _resetCurrentPageView() {
  5661. if (this.isInPresentationMode) {
  5662. this._setScale(this._currentScaleValue, true);
  5663. }
  5664. var pageView = this._pages[this._currentPageNumber - 1];
  5665. this._scrollIntoView({
  5666. pageDiv: pageView.div
  5667. });
  5668. }
  5669. }, {
  5670. key: "scrollPageIntoView",
  5671. value: function scrollPageIntoView(_ref3) {
  5672. var pageNumber = _ref3.pageNumber,
  5673. _ref3$destArray = _ref3.destArray,
  5674. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  5675. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  5676. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
  5677. if (!this.pdfDocument) {
  5678. return;
  5679. }
  5680. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  5681. if (!pageView) {
  5682. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  5683. return;
  5684. }
  5685. if (this.isInPresentationMode || !destArray) {
  5686. this._setCurrentPageNumber(pageNumber, true);
  5687. return;
  5688. }
  5689. var x = 0,
  5690. y = 0;
  5691. var width = 0,
  5692. height = 0,
  5693. widthScale,
  5694. heightScale;
  5695. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  5696. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  5697. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  5698. var scale = 0;
  5699. switch (destArray[1].name) {
  5700. case 'XYZ':
  5701. x = destArray[2];
  5702. y = destArray[3];
  5703. scale = destArray[4];
  5704. x = x !== null ? x : 0;
  5705. y = y !== null ? y : pageHeight;
  5706. break;
  5707. case 'Fit':
  5708. case 'FitB':
  5709. scale = 'page-fit';
  5710. break;
  5711. case 'FitH':
  5712. case 'FitBH':
  5713. y = destArray[2];
  5714. scale = 'page-width';
  5715. if (y === null && this._location) {
  5716. x = this._location.left;
  5717. y = this._location.top;
  5718. }
  5719. break;
  5720. case 'FitV':
  5721. case 'FitBV':
  5722. x = destArray[2];
  5723. width = pageWidth;
  5724. height = pageHeight;
  5725. scale = 'page-height';
  5726. break;
  5727. case 'FitR':
  5728. x = destArray[2];
  5729. y = destArray[3];
  5730. width = destArray[4] - x;
  5731. height = destArray[5] - y;
  5732. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  5733. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  5734. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  5735. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  5736. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  5737. break;
  5738. default:
  5739. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  5740. return;
  5741. }
  5742. if (scale && scale !== this._currentScale) {
  5743. this.currentScaleValue = scale;
  5744. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  5745. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  5746. }
  5747. if (scale === 'page-fit' && !destArray[4]) {
  5748. this._scrollIntoView({
  5749. pageDiv: pageView.div,
  5750. pageNumber: pageNumber
  5751. });
  5752. return;
  5753. }
  5754. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  5755. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  5756. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  5757. if (!allowNegativeOffset) {
  5758. left = Math.max(left, 0);
  5759. top = Math.max(top, 0);
  5760. }
  5761. this._scrollIntoView({
  5762. pageDiv: pageView.div,
  5763. pageSpot: {
  5764. left: left,
  5765. top: top
  5766. },
  5767. pageNumber: pageNumber
  5768. });
  5769. }
  5770. }, {
  5771. key: "_updateLocation",
  5772. value: function _updateLocation(firstPage) {
  5773. var currentScale = this._currentScale;
  5774. var currentScaleValue = this._currentScaleValue;
  5775. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  5776. var pageNumber = firstPage.id;
  5777. var pdfOpenParams = '#page=' + pageNumber;
  5778. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  5779. var currentPageView = this._pages[pageNumber - 1];
  5780. var container = this.container;
  5781. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  5782. var intLeft = Math.round(topLeft[0]);
  5783. var intTop = Math.round(topLeft[1]);
  5784. pdfOpenParams += ',' + intLeft + ',' + intTop;
  5785. this._location = {
  5786. pageNumber: pageNumber,
  5787. scale: normalizedScaleValue,
  5788. top: intTop,
  5789. left: intLeft,
  5790. rotation: this._pagesRotation,
  5791. pdfOpenParams: pdfOpenParams
  5792. };
  5793. }
  5794. }, {
  5795. key: "_updateHelper",
  5796. value: function _updateHelper(visiblePages) {
  5797. throw new Error('Not implemented: _updateHelper');
  5798. }
  5799. }, {
  5800. key: "update",
  5801. value: function update() {
  5802. var visible = this._getVisiblePages();
  5803. var visiblePages = visible.views,
  5804. numVisiblePages = visiblePages.length;
  5805. if (numVisiblePages === 0) {
  5806. return;
  5807. }
  5808. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  5809. this._buffer.resize(newCacheSize, visiblePages);
  5810. this.renderingQueue.renderHighestPriority(visible);
  5811. this._updateHelper(visiblePages);
  5812. this._updateLocation(visible.first);
  5813. this.eventBus.dispatch('updateviewarea', {
  5814. source: this,
  5815. location: this._location
  5816. });
  5817. }
  5818. }, {
  5819. key: "containsElement",
  5820. value: function containsElement(element) {
  5821. return this.container.contains(element);
  5822. }
  5823. }, {
  5824. key: "focus",
  5825. value: function focus() {
  5826. this.container.focus();
  5827. }
  5828. }, {
  5829. key: "_getCurrentVisiblePage",
  5830. value: function _getCurrentVisiblePage() {
  5831. if (!this.pagesCount) {
  5832. return {
  5833. views: []
  5834. };
  5835. }
  5836. var pageView = this._pages[this._currentPageNumber - 1];
  5837. var element = pageView.div;
  5838. var view = {
  5839. id: pageView.id,
  5840. x: element.offsetLeft + element.clientLeft,
  5841. y: element.offsetTop + element.clientTop,
  5842. view: pageView
  5843. };
  5844. return {
  5845. first: view,
  5846. last: view,
  5847. views: [view]
  5848. };
  5849. }
  5850. }, {
  5851. key: "_getVisiblePages",
  5852. value: function _getVisiblePages() {
  5853. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  5854. }
  5855. }, {
  5856. key: "isPageVisible",
  5857. value: function isPageVisible(pageNumber) {
  5858. if (!this.pdfDocument) {
  5859. return false;
  5860. }
  5861. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  5862. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  5863. return false;
  5864. }
  5865. return this._getVisiblePages().views.some(function (view) {
  5866. return view.id === pageNumber;
  5867. });
  5868. }
  5869. }, {
  5870. key: "cleanup",
  5871. value: function cleanup() {
  5872. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5873. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  5874. this._pages[i].reset();
  5875. }
  5876. }
  5877. }
  5878. }, {
  5879. key: "_cancelRendering",
  5880. value: function _cancelRendering() {
  5881. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5882. if (this._pages[i]) {
  5883. this._pages[i].cancelRendering();
  5884. }
  5885. }
  5886. }
  5887. }, {
  5888. key: "_ensurePdfPageLoaded",
  5889. value: function _ensurePdfPageLoaded(pageView) {
  5890. var _this3 = this;
  5891. if (pageView.pdfPage) {
  5892. return Promise.resolve(pageView.pdfPage);
  5893. }
  5894. var pageNumber = pageView.id;
  5895. if (this._pagesRequests[pageNumber]) {
  5896. return this._pagesRequests[pageNumber];
  5897. }
  5898. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  5899. if (!pageView.pdfPage) {
  5900. pageView.setPdfPage(pdfPage);
  5901. }
  5902. _this3._pagesRequests[pageNumber] = null;
  5903. return pdfPage;
  5904. })["catch"](function (reason) {
  5905. console.error('Unable to get page for page view', reason);
  5906. _this3._pagesRequests[pageNumber] = null;
  5907. });
  5908. this._pagesRequests[pageNumber] = promise;
  5909. return promise;
  5910. }
  5911. }, {
  5912. key: "forceRendering",
  5913. value: function forceRendering(currentlyVisiblePages) {
  5914. var _this4 = this;
  5915. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  5916. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  5917. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  5918. if (pageView) {
  5919. this._ensurePdfPageLoaded(pageView).then(function () {
  5920. _this4.renderingQueue.renderView(pageView);
  5921. });
  5922. return true;
  5923. }
  5924. return false;
  5925. }
  5926. }, {
  5927. key: "createTextLayerBuilder",
  5928. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  5929. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5930. return new _text_layer_builder.TextLayerBuilder({
  5931. textLayerDiv: textLayerDiv,
  5932. eventBus: this.eventBus,
  5933. pageIndex: pageIndex,
  5934. viewport: viewport,
  5935. findController: this.isInPresentationMode ? null : this.findController,
  5936. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  5937. });
  5938. }
  5939. }, {
  5940. key: "createAnnotationLayerBuilder",
  5941. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  5942. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  5943. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5944. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  5945. return new _annotation_layer_builder.AnnotationLayerBuilder({
  5946. pageDiv: pageDiv,
  5947. pdfPage: pdfPage,
  5948. imageResourcesPath: imageResourcesPath,
  5949. renderInteractiveForms: renderInteractiveForms,
  5950. linkService: this.linkService,
  5951. downloadManager: this.downloadManager,
  5952. l10n: l10n
  5953. });
  5954. }
  5955. }, {
  5956. key: "getPagesOverview",
  5957. value: function getPagesOverview() {
  5958. var pagesOverview = this._pages.map(function (pageView) {
  5959. var viewport = pageView.pdfPage.getViewport({
  5960. scale: 1
  5961. });
  5962. return {
  5963. width: viewport.width,
  5964. height: viewport.height,
  5965. rotation: viewport.rotation
  5966. };
  5967. });
  5968. if (!this.enablePrintAutoRotate) {
  5969. return pagesOverview;
  5970. }
  5971. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  5972. return pagesOverview.map(function (size) {
  5973. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  5974. return size;
  5975. }
  5976. return {
  5977. width: size.height,
  5978. height: size.width,
  5979. rotation: (size.rotation + 90) % 360
  5980. };
  5981. });
  5982. }
  5983. }, {
  5984. key: "_updateScrollMode",
  5985. value: function _updateScrollMode() {
  5986. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5987. var scrollMode = this._scrollMode,
  5988. viewer = this.viewer;
  5989. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  5990. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
  5991. if (!this.pdfDocument || !pageNumber) {
  5992. return;
  5993. }
  5994. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  5995. this._setScale(this._currentScaleValue, true);
  5996. }
  5997. this._setCurrentPageNumber(pageNumber, true);
  5998. this.update();
  5999. }
  6000. }, {
  6001. key: "_updateSpreadMode",
  6002. value: function _updateSpreadMode() {
  6003. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6004. if (!this.pdfDocument) {
  6005. return;
  6006. }
  6007. var viewer = this.viewer,
  6008. pages = this._pages;
  6009. viewer.textContent = '';
  6010. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  6011. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  6012. viewer.appendChild(pages[i].div);
  6013. }
  6014. } else {
  6015. var parity = this._spreadMode - 1;
  6016. var spread = null;
  6017. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  6018. if (spread === null) {
  6019. spread = document.createElement('div');
  6020. spread.className = 'spread';
  6021. viewer.appendChild(spread);
  6022. } else if (_i % 2 === parity) {
  6023. spread = spread.cloneNode(false);
  6024. viewer.appendChild(spread);
  6025. }
  6026. spread.appendChild(pages[_i].div);
  6027. }
  6028. }
  6029. if (!pageNumber) {
  6030. return;
  6031. }
  6032. this._setCurrentPageNumber(pageNumber, true);
  6033. this.update();
  6034. }
  6035. }, {
  6036. key: "pagesCount",
  6037. get: function get() {
  6038. return this._pages.length;
  6039. }
  6040. }, {
  6041. key: "pageViewsReady",
  6042. get: function get() {
  6043. return this._pageViewsReady;
  6044. }
  6045. }, {
  6046. key: "currentPageNumber",
  6047. get: function get() {
  6048. return this._currentPageNumber;
  6049. },
  6050. set: function set(val) {
  6051. if (!Number.isInteger(val)) {
  6052. throw new Error('Invalid page number.');
  6053. }
  6054. if (!this.pdfDocument) {
  6055. return;
  6056. }
  6057. if (!this._setCurrentPageNumber(val, true)) {
  6058. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  6059. }
  6060. }
  6061. }, {
  6062. key: "currentPageLabel",
  6063. get: function get() {
  6064. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  6065. },
  6066. set: function set(val) {
  6067. if (!this.pdfDocument) {
  6068. return;
  6069. }
  6070. var page = val | 0;
  6071. if (this._pageLabels) {
  6072. var i = this._pageLabels.indexOf(val);
  6073. if (i >= 0) {
  6074. page = i + 1;
  6075. }
  6076. }
  6077. if (!this._setCurrentPageNumber(page, true)) {
  6078. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  6079. }
  6080. }
  6081. }, {
  6082. key: "currentScale",
  6083. get: function get() {
  6084. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  6085. },
  6086. set: function set(val) {
  6087. if (isNaN(val)) {
  6088. throw new Error('Invalid numeric scale.');
  6089. }
  6090. if (!this.pdfDocument) {
  6091. return;
  6092. }
  6093. this._setScale(val, false);
  6094. }
  6095. }, {
  6096. key: "currentScaleValue",
  6097. get: function get() {
  6098. return this._currentScaleValue;
  6099. },
  6100. set: function set(val) {
  6101. if (!this.pdfDocument) {
  6102. return;
  6103. }
  6104. this._setScale(val, false);
  6105. }
  6106. }, {
  6107. key: "pagesRotation",
  6108. get: function get() {
  6109. return this._pagesRotation;
  6110. },
  6111. set: function set(rotation) {
  6112. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  6113. throw new Error('Invalid pages rotation angle.');
  6114. }
  6115. if (!this.pdfDocument) {
  6116. return;
  6117. }
  6118. if (this._pagesRotation === rotation) {
  6119. return;
  6120. }
  6121. this._pagesRotation = rotation;
  6122. var pageNumber = this._currentPageNumber;
  6123. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6124. var pageView = this._pages[i];
  6125. pageView.update(pageView.scale, rotation);
  6126. }
  6127. if (this._currentScaleValue) {
  6128. this._setScale(this._currentScaleValue, true);
  6129. }
  6130. this.eventBus.dispatch('rotationchanging', {
  6131. source: this,
  6132. pagesRotation: rotation,
  6133. pageNumber: pageNumber
  6134. });
  6135. if (this.defaultRenderingQueue) {
  6136. this.update();
  6137. }
  6138. }
  6139. }, {
  6140. key: "_setDocumentViewerElement",
  6141. get: function get() {
  6142. throw new Error('Not implemented: _setDocumentViewerElement');
  6143. }
  6144. }, {
  6145. key: "_isScrollModeHorizontal",
  6146. get: function get() {
  6147. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  6148. }
  6149. }, {
  6150. key: "isInPresentationMode",
  6151. get: function get() {
  6152. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  6153. }
  6154. }, {
  6155. key: "isChangingPresentationMode",
  6156. get: function get() {
  6157. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  6158. }
  6159. }, {
  6160. key: "isHorizontalScrollbarEnabled",
  6161. get: function get() {
  6162. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  6163. }
  6164. }, {
  6165. key: "isVerticalScrollbarEnabled",
  6166. get: function get() {
  6167. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  6168. }
  6169. }, {
  6170. key: "hasEqualPageSizes",
  6171. get: function get() {
  6172. var firstPageView = this._pages[0];
  6173. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  6174. var pageView = this._pages[i];
  6175. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  6176. return false;
  6177. }
  6178. }
  6179. return true;
  6180. }
  6181. }, {
  6182. key: "scrollMode",
  6183. get: function get() {
  6184. return this._scrollMode;
  6185. },
  6186. set: function set(mode) {
  6187. if (this._scrollMode === mode) {
  6188. return;
  6189. }
  6190. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  6191. throw new Error("Invalid scroll mode: ".concat(mode));
  6192. }
  6193. this._scrollMode = mode;
  6194. this.eventBus.dispatch('scrollmodechanged', {
  6195. source: this,
  6196. mode: mode
  6197. });
  6198. this._updateScrollMode(this._currentPageNumber);
  6199. }
  6200. }, {
  6201. key: "spreadMode",
  6202. get: function get() {
  6203. return this._spreadMode;
  6204. },
  6205. set: function set(mode) {
  6206. if (this._spreadMode === mode) {
  6207. return;
  6208. }
  6209. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  6210. throw new Error("Invalid spread mode: ".concat(mode));
  6211. }
  6212. this._spreadMode = mode;
  6213. this.eventBus.dispatch('spreadmodechanged', {
  6214. source: this,
  6215. mode: mode
  6216. });
  6217. this._updateSpreadMode(this._currentPageNumber);
  6218. }
  6219. }]);
  6220. return BaseViewer;
  6221. }();
  6222. exports.BaseViewer = BaseViewer;
  6223. /***/ }),
  6224. /* 20 */
  6225. /***/ (function(module, exports, __w_pdfjs_require__) {
  6226. "use strict";
  6227. Object.defineProperty(exports, "__esModule", {
  6228. value: true
  6229. });
  6230. exports.PDFViewer = void 0;
  6231. var _base_viewer = __w_pdfjs_require__(19);
  6232. var _pdfjsLib = __w_pdfjs_require__(2);
  6233. 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); }
  6234. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6235. 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); } }
  6236. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6237. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  6238. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6239. 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); }
  6240. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  6241. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6242. 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); }
  6243. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6244. var PDFViewer =
  6245. /*#__PURE__*/
  6246. function (_BaseViewer) {
  6247. _inherits(PDFViewer, _BaseViewer);
  6248. function PDFViewer() {
  6249. _classCallCheck(this, PDFViewer);
  6250. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  6251. }
  6252. _createClass(PDFViewer, [{
  6253. key: "_scrollIntoView",
  6254. value: function _scrollIntoView(_ref) {
  6255. var pageDiv = _ref.pageDiv,
  6256. _ref$pageSpot = _ref.pageSpot,
  6257. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  6258. _ref$pageNumber = _ref.pageNumber,
  6259. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  6260. if (!pageSpot && !this.isInPresentationMode) {
  6261. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  6262. var right = left + pageDiv.clientWidth;
  6263. var _this$container = this.container,
  6264. scrollLeft = _this$container.scrollLeft,
  6265. clientWidth = _this$container.clientWidth;
  6266. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  6267. pageSpot = {
  6268. left: 0,
  6269. top: 0
  6270. };
  6271. }
  6272. }
  6273. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  6274. pageDiv: pageDiv,
  6275. pageSpot: pageSpot,
  6276. pageNumber: pageNumber
  6277. });
  6278. }
  6279. }, {
  6280. key: "_getVisiblePages",
  6281. value: function _getVisiblePages() {
  6282. if (this.isInPresentationMode) {
  6283. return this._getCurrentVisiblePage();
  6284. }
  6285. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  6286. }
  6287. }, {
  6288. key: "_updateHelper",
  6289. value: function _updateHelper(visiblePages) {
  6290. if (this.isInPresentationMode) {
  6291. return;
  6292. }
  6293. var currentId = this._currentPageNumber;
  6294. var stillFullyVisible = false;
  6295. var _iteratorNormalCompletion = true;
  6296. var _didIteratorError = false;
  6297. var _iteratorError = undefined;
  6298. try {
  6299. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6300. var page = _step.value;
  6301. if (page.percent < 100) {
  6302. break;
  6303. }
  6304. if (page.id === currentId) {
  6305. stillFullyVisible = true;
  6306. break;
  6307. }
  6308. }
  6309. } catch (err) {
  6310. _didIteratorError = true;
  6311. _iteratorError = err;
  6312. } finally {
  6313. try {
  6314. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  6315. _iterator["return"]();
  6316. }
  6317. } finally {
  6318. if (_didIteratorError) {
  6319. throw _iteratorError;
  6320. }
  6321. }
  6322. }
  6323. if (!stillFullyVisible) {
  6324. currentId = visiblePages[0].id;
  6325. }
  6326. this._setCurrentPageNumber(currentId);
  6327. }
  6328. }, {
  6329. key: "_setDocumentViewerElement",
  6330. get: function get() {
  6331. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  6332. }
  6333. }]);
  6334. return PDFViewer;
  6335. }(_base_viewer.BaseViewer);
  6336. exports.PDFViewer = PDFViewer;
  6337. /***/ })
  6338. /******/ ]);
  6339. });
  6340. //# sourceMappingURL=pdf_viewer.js.map