pdf_viewer.js 228 KB

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