pdf_viewer.js 210 KB

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