pdf_viewer.js 254 KB

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