pdf_viewer.js 208 KB

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