pdf_viewer.js 260 KB

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