pdf_viewer.js 225 KB

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