pdf_viewer.js 222 KB

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