pdf_viewer.js 269 KB

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