2
0

pdf_viewer.js 220 KB

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