pdf_viewer2.js 227 KB

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