pdf_viewer.js 306 KB

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