viewer.mjs 511 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 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. /******/ var __webpack_modules__ = ({
  23. /***/ 8759:
  24. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  25. // EXPORTS
  26. __webpack_require__.d(__webpack_exports__, {
  27. FluentBundle: () => (/* reexport */ FluentBundle),
  28. FluentResource: () => (/* reexport */ FluentResource)
  29. });
  30. // UNUSED EXPORTS: FluentDateTime, FluentNone, FluentNumber, FluentType
  31. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/types.js
  32. class FluentType {
  33. constructor(value) {
  34. this.value = value;
  35. }
  36. valueOf() {
  37. return this.value;
  38. }
  39. }
  40. class FluentNone extends FluentType {
  41. constructor(value = "???") {
  42. super(value);
  43. }
  44. toString(scope) {
  45. return `{${this.value}}`;
  46. }
  47. }
  48. class FluentNumber extends FluentType {
  49. constructor(value, opts = {}) {
  50. super(value);
  51. this.opts = opts;
  52. }
  53. toString(scope) {
  54. try {
  55. const nf = scope.memoizeIntlObject(Intl.NumberFormat, this.opts);
  56. return nf.format(this.value);
  57. } catch (err) {
  58. scope.reportError(err);
  59. return this.value.toString(10);
  60. }
  61. }
  62. }
  63. class FluentDateTime extends FluentType {
  64. constructor(value, opts = {}) {
  65. super(value);
  66. this.opts = opts;
  67. }
  68. toString(scope) {
  69. try {
  70. const dtf = scope.memoizeIntlObject(Intl.DateTimeFormat, this.opts);
  71. return dtf.format(this.value);
  72. } catch (err) {
  73. scope.reportError(err);
  74. return new Date(this.value).toISOString();
  75. }
  76. }
  77. }
  78. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resolver.js
  79. const MAX_PLACEABLES = 100;
  80. const FSI = "\u2068";
  81. const PDI = "\u2069";
  82. function match(scope, selector, key) {
  83. if (key === selector) {
  84. return true;
  85. }
  86. if (key instanceof FluentNumber && selector instanceof FluentNumber && key.value === selector.value) {
  87. return true;
  88. }
  89. if (selector instanceof FluentNumber && typeof key === "string") {
  90. let category = scope.memoizeIntlObject(Intl.PluralRules, selector.opts).select(selector.value);
  91. if (key === category) {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. function getDefault(scope, variants, star) {
  98. if (variants[star]) {
  99. return resolvePattern(scope, variants[star].value);
  100. }
  101. scope.reportError(new RangeError("No default"));
  102. return new FluentNone();
  103. }
  104. function getArguments(scope, args) {
  105. const positional = [];
  106. const named = Object.create(null);
  107. for (const arg of args) {
  108. if (arg.type === "narg") {
  109. named[arg.name] = resolveExpression(scope, arg.value);
  110. } else {
  111. positional.push(resolveExpression(scope, arg));
  112. }
  113. }
  114. return {
  115. positional,
  116. named
  117. };
  118. }
  119. function resolveExpression(scope, expr) {
  120. switch (expr.type) {
  121. case "str":
  122. return expr.value;
  123. case "num":
  124. return new FluentNumber(expr.value, {
  125. minimumFractionDigits: expr.precision
  126. });
  127. case "var":
  128. return resolveVariableReference(scope, expr);
  129. case "mesg":
  130. return resolveMessageReference(scope, expr);
  131. case "term":
  132. return resolveTermReference(scope, expr);
  133. case "func":
  134. return resolveFunctionReference(scope, expr);
  135. case "select":
  136. return resolveSelectExpression(scope, expr);
  137. default:
  138. return new FluentNone();
  139. }
  140. }
  141. function resolveVariableReference(scope, {
  142. name
  143. }) {
  144. let arg;
  145. if (scope.params) {
  146. if (Object.prototype.hasOwnProperty.call(scope.params, name)) {
  147. arg = scope.params[name];
  148. } else {
  149. return new FluentNone(`$${name}`);
  150. }
  151. } else if (scope.args && Object.prototype.hasOwnProperty.call(scope.args, name)) {
  152. arg = scope.args[name];
  153. } else {
  154. scope.reportError(new ReferenceError(`Unknown variable: $${name}`));
  155. return new FluentNone(`$${name}`);
  156. }
  157. if (arg instanceof FluentType) {
  158. return arg;
  159. }
  160. switch (typeof arg) {
  161. case "string":
  162. return arg;
  163. case "number":
  164. return new FluentNumber(arg);
  165. case "object":
  166. if (arg instanceof Date) {
  167. return new FluentDateTime(arg.getTime());
  168. }
  169. default:
  170. scope.reportError(new TypeError(`Variable type not supported: $${name}, ${typeof arg}`));
  171. return new FluentNone(`$${name}`);
  172. }
  173. }
  174. function resolveMessageReference(scope, {
  175. name,
  176. attr
  177. }) {
  178. const message = scope.bundle._messages.get(name);
  179. if (!message) {
  180. scope.reportError(new ReferenceError(`Unknown message: ${name}`));
  181. return new FluentNone(name);
  182. }
  183. if (attr) {
  184. const attribute = message.attributes[attr];
  185. if (attribute) {
  186. return resolvePattern(scope, attribute);
  187. }
  188. scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
  189. return new FluentNone(`${name}.${attr}`);
  190. }
  191. if (message.value) {
  192. return resolvePattern(scope, message.value);
  193. }
  194. scope.reportError(new ReferenceError(`No value: ${name}`));
  195. return new FluentNone(name);
  196. }
  197. function resolveTermReference(scope, {
  198. name,
  199. attr,
  200. args
  201. }) {
  202. const id = `-${name}`;
  203. const term = scope.bundle._terms.get(id);
  204. if (!term) {
  205. scope.reportError(new ReferenceError(`Unknown term: ${id}`));
  206. return new FluentNone(id);
  207. }
  208. if (attr) {
  209. const attribute = term.attributes[attr];
  210. if (attribute) {
  211. scope.params = getArguments(scope, args).named;
  212. const resolved = resolvePattern(scope, attribute);
  213. scope.params = null;
  214. return resolved;
  215. }
  216. scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
  217. return new FluentNone(`${id}.${attr}`);
  218. }
  219. scope.params = getArguments(scope, args).named;
  220. const resolved = resolvePattern(scope, term.value);
  221. scope.params = null;
  222. return resolved;
  223. }
  224. function resolveFunctionReference(scope, {
  225. name,
  226. args
  227. }) {
  228. let func = scope.bundle._functions[name];
  229. if (!func) {
  230. scope.reportError(new ReferenceError(`Unknown function: ${name}()`));
  231. return new FluentNone(`${name}()`);
  232. }
  233. if (typeof func !== "function") {
  234. scope.reportError(new TypeError(`Function ${name}() is not callable`));
  235. return new FluentNone(`${name}()`);
  236. }
  237. try {
  238. let resolved = getArguments(scope, args);
  239. return func(resolved.positional, resolved.named);
  240. } catch (err) {
  241. scope.reportError(err);
  242. return new FluentNone(`${name}()`);
  243. }
  244. }
  245. function resolveSelectExpression(scope, {
  246. selector,
  247. variants,
  248. star
  249. }) {
  250. let sel = resolveExpression(scope, selector);
  251. if (sel instanceof FluentNone) {
  252. return getDefault(scope, variants, star);
  253. }
  254. for (const variant of variants) {
  255. const key = resolveExpression(scope, variant.key);
  256. if (match(scope, sel, key)) {
  257. return resolvePattern(scope, variant.value);
  258. }
  259. }
  260. return getDefault(scope, variants, star);
  261. }
  262. function resolveComplexPattern(scope, ptn) {
  263. if (scope.dirty.has(ptn)) {
  264. scope.reportError(new RangeError("Cyclic reference"));
  265. return new FluentNone();
  266. }
  267. scope.dirty.add(ptn);
  268. const result = [];
  269. const useIsolating = scope.bundle._useIsolating && ptn.length > 1;
  270. for (const elem of ptn) {
  271. if (typeof elem === "string") {
  272. result.push(scope.bundle._transform(elem));
  273. continue;
  274. }
  275. scope.placeables++;
  276. if (scope.placeables > MAX_PLACEABLES) {
  277. scope.dirty.delete(ptn);
  278. throw new RangeError(`Too many placeables expanded: ${scope.placeables}, ` + `max allowed is ${MAX_PLACEABLES}`);
  279. }
  280. if (useIsolating) {
  281. result.push(FSI);
  282. }
  283. result.push(resolveExpression(scope, elem).toString(scope));
  284. if (useIsolating) {
  285. result.push(PDI);
  286. }
  287. }
  288. scope.dirty.delete(ptn);
  289. return result.join("");
  290. }
  291. function resolvePattern(scope, value) {
  292. if (typeof value === "string") {
  293. return scope.bundle._transform(value);
  294. }
  295. return resolveComplexPattern(scope, value);
  296. }
  297. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/scope.js
  298. class Scope {
  299. constructor(bundle, errors, args) {
  300. this.dirty = new WeakSet();
  301. this.params = null;
  302. this.placeables = 0;
  303. this.bundle = bundle;
  304. this.errors = errors;
  305. this.args = args;
  306. }
  307. reportError(error) {
  308. if (!this.errors || !(error instanceof Error)) {
  309. throw error;
  310. }
  311. this.errors.push(error);
  312. }
  313. memoizeIntlObject(ctor, opts) {
  314. let cache = this.bundle._intls.get(ctor);
  315. if (!cache) {
  316. cache = {};
  317. this.bundle._intls.set(ctor, cache);
  318. }
  319. let id = JSON.stringify(opts);
  320. if (!cache[id]) {
  321. cache[id] = new ctor(this.bundle.locales, opts);
  322. }
  323. return cache[id];
  324. }
  325. }
  326. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/builtins.js
  327. function values(opts, allowed) {
  328. const unwrapped = Object.create(null);
  329. for (const [name, opt] of Object.entries(opts)) {
  330. if (allowed.includes(name)) {
  331. unwrapped[name] = opt.valueOf();
  332. }
  333. }
  334. return unwrapped;
  335. }
  336. const NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"];
  337. function NUMBER(args, opts) {
  338. let arg = args[0];
  339. if (arg instanceof FluentNone) {
  340. return new FluentNone(`NUMBER(${arg.valueOf()})`);
  341. }
  342. if (arg instanceof FluentNumber) {
  343. return new FluentNumber(arg.valueOf(), {
  344. ...arg.opts,
  345. ...values(opts, NUMBER_ALLOWED)
  346. });
  347. }
  348. if (arg instanceof FluentDateTime) {
  349. return new FluentNumber(arg.valueOf(), {
  350. ...values(opts, NUMBER_ALLOWED)
  351. });
  352. }
  353. throw new TypeError("Invalid argument to NUMBER");
  354. }
  355. const DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"];
  356. function DATETIME(args, opts) {
  357. let arg = args[0];
  358. if (arg instanceof FluentNone) {
  359. return new FluentNone(`DATETIME(${arg.valueOf()})`);
  360. }
  361. if (arg instanceof FluentDateTime) {
  362. return new FluentDateTime(arg.valueOf(), {
  363. ...arg.opts,
  364. ...values(opts, DATETIME_ALLOWED)
  365. });
  366. }
  367. if (arg instanceof FluentNumber) {
  368. return new FluentDateTime(arg.valueOf(), {
  369. ...values(opts, DATETIME_ALLOWED)
  370. });
  371. }
  372. throw new TypeError("Invalid argument to DATETIME");
  373. }
  374. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/memoizer.js
  375. const cache = new Map();
  376. function getMemoizerForLocale(locales) {
  377. const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales;
  378. let memoizer = cache.get(stringLocale);
  379. if (memoizer === undefined) {
  380. memoizer = new Map();
  381. cache.set(stringLocale, memoizer);
  382. }
  383. return memoizer;
  384. }
  385. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/bundle.js
  386. class FluentBundle {
  387. constructor(locales, {
  388. functions,
  389. useIsolating = true,
  390. transform = v => v
  391. } = {}) {
  392. this._terms = new Map();
  393. this._messages = new Map();
  394. this.locales = Array.isArray(locales) ? locales : [locales];
  395. this._functions = {
  396. NUMBER: NUMBER,
  397. DATETIME: DATETIME,
  398. ...functions
  399. };
  400. this._useIsolating = useIsolating;
  401. this._transform = transform;
  402. this._intls = getMemoizerForLocale(locales);
  403. }
  404. hasMessage(id) {
  405. return this._messages.has(id);
  406. }
  407. getMessage(id) {
  408. return this._messages.get(id);
  409. }
  410. addResource(res, {
  411. allowOverrides = false
  412. } = {}) {
  413. const errors = [];
  414. for (let i = 0; i < res.body.length; i++) {
  415. let entry = res.body[i];
  416. if (entry.id.startsWith("-")) {
  417. if (allowOverrides === false && this._terms.has(entry.id)) {
  418. errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`));
  419. continue;
  420. }
  421. this._terms.set(entry.id, entry);
  422. } else {
  423. if (allowOverrides === false && this._messages.has(entry.id)) {
  424. errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`));
  425. continue;
  426. }
  427. this._messages.set(entry.id, entry);
  428. }
  429. }
  430. return errors;
  431. }
  432. formatPattern(pattern, args = null, errors = null) {
  433. if (typeof pattern === "string") {
  434. return this._transform(pattern);
  435. }
  436. let scope = new Scope(this, errors, args);
  437. try {
  438. let value = resolveComplexPattern(scope, pattern);
  439. return value.toString(scope);
  440. } catch (err) {
  441. if (scope.errors && err instanceof Error) {
  442. scope.errors.push(err);
  443. return new FluentNone().toString(scope);
  444. }
  445. throw err;
  446. }
  447. }
  448. }
  449. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resource.js
  450. const RE_MESSAGE_START = /^(-?[a-zA-Z][\w-]*) *= */gm;
  451. const RE_ATTRIBUTE_START = /\.([a-zA-Z][\w-]*) *= */y;
  452. const RE_VARIANT_START = /\*?\[/y;
  453. const RE_NUMBER_LITERAL = /(-?[0-9]+(?:\.([0-9]+))?)/y;
  454. const RE_IDENTIFIER = /([a-zA-Z][\w-]*)/y;
  455. const RE_REFERENCE = /([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y;
  456. const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/;
  457. const RE_TEXT_RUN = /([^{}\n\r]+)/y;
  458. const RE_STRING_RUN = /([^\\"\n\r]*)/y;
  459. const RE_STRING_ESCAPE = /\\([\\"])/y;
  460. const RE_UNICODE_ESCAPE = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y;
  461. const RE_LEADING_NEWLINES = /^\n+/;
  462. const RE_TRAILING_SPACES = / +$/;
  463. const RE_BLANK_LINES = / *\r?\n/g;
  464. const RE_INDENT = /( *)$/;
  465. const TOKEN_BRACE_OPEN = /{\s*/y;
  466. const TOKEN_BRACE_CLOSE = /\s*}/y;
  467. const TOKEN_BRACKET_OPEN = /\[\s*/y;
  468. const TOKEN_BRACKET_CLOSE = /\s*] */y;
  469. const TOKEN_PAREN_OPEN = /\s*\(\s*/y;
  470. const TOKEN_ARROW = /\s*->\s*/y;
  471. const TOKEN_COLON = /\s*:\s*/y;
  472. const TOKEN_COMMA = /\s*,?\s*/y;
  473. const TOKEN_BLANK = /\s+/y;
  474. class FluentResource {
  475. constructor(source) {
  476. this.body = [];
  477. RE_MESSAGE_START.lastIndex = 0;
  478. let cursor = 0;
  479. while (true) {
  480. let next = RE_MESSAGE_START.exec(source);
  481. if (next === null) {
  482. break;
  483. }
  484. cursor = RE_MESSAGE_START.lastIndex;
  485. try {
  486. this.body.push(parseMessage(next[1]));
  487. } catch (err) {
  488. if (err instanceof SyntaxError) {
  489. continue;
  490. }
  491. throw err;
  492. }
  493. }
  494. function test(re) {
  495. re.lastIndex = cursor;
  496. return re.test(source);
  497. }
  498. function consumeChar(char, errorClass) {
  499. if (source[cursor] === char) {
  500. cursor++;
  501. return true;
  502. }
  503. if (errorClass) {
  504. throw new errorClass(`Expected ${char}`);
  505. }
  506. return false;
  507. }
  508. function consumeToken(re, errorClass) {
  509. if (test(re)) {
  510. cursor = re.lastIndex;
  511. return true;
  512. }
  513. if (errorClass) {
  514. throw new errorClass(`Expected ${re.toString()}`);
  515. }
  516. return false;
  517. }
  518. function match(re) {
  519. re.lastIndex = cursor;
  520. let result = re.exec(source);
  521. if (result === null) {
  522. throw new SyntaxError(`Expected ${re.toString()}`);
  523. }
  524. cursor = re.lastIndex;
  525. return result;
  526. }
  527. function match1(re) {
  528. return match(re)[1];
  529. }
  530. function parseMessage(id) {
  531. let value = parsePattern();
  532. let attributes = parseAttributes();
  533. if (value === null && Object.keys(attributes).length === 0) {
  534. throw new SyntaxError("Expected message value or attributes");
  535. }
  536. return {
  537. id,
  538. value,
  539. attributes
  540. };
  541. }
  542. function parseAttributes() {
  543. let attrs = Object.create(null);
  544. while (test(RE_ATTRIBUTE_START)) {
  545. let name = match1(RE_ATTRIBUTE_START);
  546. let value = parsePattern();
  547. if (value === null) {
  548. throw new SyntaxError("Expected attribute value");
  549. }
  550. attrs[name] = value;
  551. }
  552. return attrs;
  553. }
  554. function parsePattern() {
  555. let first;
  556. if (test(RE_TEXT_RUN)) {
  557. first = match1(RE_TEXT_RUN);
  558. }
  559. if (source[cursor] === "{" || source[cursor] === "}") {
  560. return parsePatternElements(first ? [first] : [], Infinity);
  561. }
  562. let indent = parseIndent();
  563. if (indent) {
  564. if (first) {
  565. return parsePatternElements([first, indent], indent.length);
  566. }
  567. indent.value = trim(indent.value, RE_LEADING_NEWLINES);
  568. return parsePatternElements([indent], indent.length);
  569. }
  570. if (first) {
  571. return trim(first, RE_TRAILING_SPACES);
  572. }
  573. return null;
  574. }
  575. function parsePatternElements(elements = [], commonIndent) {
  576. while (true) {
  577. if (test(RE_TEXT_RUN)) {
  578. elements.push(match1(RE_TEXT_RUN));
  579. continue;
  580. }
  581. if (source[cursor] === "{") {
  582. elements.push(parsePlaceable());
  583. continue;
  584. }
  585. if (source[cursor] === "}") {
  586. throw new SyntaxError("Unbalanced closing brace");
  587. }
  588. let indent = parseIndent();
  589. if (indent) {
  590. elements.push(indent);
  591. commonIndent = Math.min(commonIndent, indent.length);
  592. continue;
  593. }
  594. break;
  595. }
  596. let lastIndex = elements.length - 1;
  597. let lastElement = elements[lastIndex];
  598. if (typeof lastElement === "string") {
  599. elements[lastIndex] = trim(lastElement, RE_TRAILING_SPACES);
  600. }
  601. let baked = [];
  602. for (let element of elements) {
  603. if (element instanceof Indent) {
  604. element = element.value.slice(0, element.value.length - commonIndent);
  605. }
  606. if (element) {
  607. baked.push(element);
  608. }
  609. }
  610. return baked;
  611. }
  612. function parsePlaceable() {
  613. consumeToken(TOKEN_BRACE_OPEN, SyntaxError);
  614. let selector = parseInlineExpression();
  615. if (consumeToken(TOKEN_BRACE_CLOSE)) {
  616. return selector;
  617. }
  618. if (consumeToken(TOKEN_ARROW)) {
  619. let variants = parseVariants();
  620. consumeToken(TOKEN_BRACE_CLOSE, SyntaxError);
  621. return {
  622. type: "select",
  623. selector,
  624. ...variants
  625. };
  626. }
  627. throw new SyntaxError("Unclosed placeable");
  628. }
  629. function parseInlineExpression() {
  630. if (source[cursor] === "{") {
  631. return parsePlaceable();
  632. }
  633. if (test(RE_REFERENCE)) {
  634. let [, sigil, name, attr = null] = match(RE_REFERENCE);
  635. if (sigil === "$") {
  636. return {
  637. type: "var",
  638. name
  639. };
  640. }
  641. if (consumeToken(TOKEN_PAREN_OPEN)) {
  642. let args = parseArguments();
  643. if (sigil === "-") {
  644. return {
  645. type: "term",
  646. name,
  647. attr,
  648. args
  649. };
  650. }
  651. if (RE_FUNCTION_NAME.test(name)) {
  652. return {
  653. type: "func",
  654. name,
  655. args
  656. };
  657. }
  658. throw new SyntaxError("Function names must be all upper-case");
  659. }
  660. if (sigil === "-") {
  661. return {
  662. type: "term",
  663. name,
  664. attr,
  665. args: []
  666. };
  667. }
  668. return {
  669. type: "mesg",
  670. name,
  671. attr
  672. };
  673. }
  674. return parseLiteral();
  675. }
  676. function parseArguments() {
  677. let args = [];
  678. while (true) {
  679. switch (source[cursor]) {
  680. case ")":
  681. cursor++;
  682. return args;
  683. case undefined:
  684. throw new SyntaxError("Unclosed argument list");
  685. }
  686. args.push(parseArgument());
  687. consumeToken(TOKEN_COMMA);
  688. }
  689. }
  690. function parseArgument() {
  691. let expr = parseInlineExpression();
  692. if (expr.type !== "mesg") {
  693. return expr;
  694. }
  695. if (consumeToken(TOKEN_COLON)) {
  696. return {
  697. type: "narg",
  698. name: expr.name,
  699. value: parseLiteral()
  700. };
  701. }
  702. return expr;
  703. }
  704. function parseVariants() {
  705. let variants = [];
  706. let count = 0;
  707. let star;
  708. while (test(RE_VARIANT_START)) {
  709. if (consumeChar("*")) {
  710. star = count;
  711. }
  712. let key = parseVariantKey();
  713. let value = parsePattern();
  714. if (value === null) {
  715. throw new SyntaxError("Expected variant value");
  716. }
  717. variants[count++] = {
  718. key,
  719. value
  720. };
  721. }
  722. if (count === 0) {
  723. return null;
  724. }
  725. if (star === undefined) {
  726. throw new SyntaxError("Expected default variant");
  727. }
  728. return {
  729. variants,
  730. star
  731. };
  732. }
  733. function parseVariantKey() {
  734. consumeToken(TOKEN_BRACKET_OPEN, SyntaxError);
  735. let key;
  736. if (test(RE_NUMBER_LITERAL)) {
  737. key = parseNumberLiteral();
  738. } else {
  739. key = {
  740. type: "str",
  741. value: match1(RE_IDENTIFIER)
  742. };
  743. }
  744. consumeToken(TOKEN_BRACKET_CLOSE, SyntaxError);
  745. return key;
  746. }
  747. function parseLiteral() {
  748. if (test(RE_NUMBER_LITERAL)) {
  749. return parseNumberLiteral();
  750. }
  751. if (source[cursor] === '"') {
  752. return parseStringLiteral();
  753. }
  754. throw new SyntaxError("Invalid expression");
  755. }
  756. function parseNumberLiteral() {
  757. let [, value, fraction = ""] = match(RE_NUMBER_LITERAL);
  758. let precision = fraction.length;
  759. return {
  760. type: "num",
  761. value: parseFloat(value),
  762. precision
  763. };
  764. }
  765. function parseStringLiteral() {
  766. consumeChar('"', SyntaxError);
  767. let value = "";
  768. while (true) {
  769. value += match1(RE_STRING_RUN);
  770. if (source[cursor] === "\\") {
  771. value += parseEscapeSequence();
  772. continue;
  773. }
  774. if (consumeChar('"')) {
  775. return {
  776. type: "str",
  777. value
  778. };
  779. }
  780. throw new SyntaxError("Unclosed string literal");
  781. }
  782. }
  783. function parseEscapeSequence() {
  784. if (test(RE_STRING_ESCAPE)) {
  785. return match1(RE_STRING_ESCAPE);
  786. }
  787. if (test(RE_UNICODE_ESCAPE)) {
  788. let [, codepoint4, codepoint6] = match(RE_UNICODE_ESCAPE);
  789. let codepoint = parseInt(codepoint4 || codepoint6, 16);
  790. return codepoint <= 0xd7ff || 0xe000 <= codepoint ? String.fromCodePoint(codepoint) : "�";
  791. }
  792. throw new SyntaxError("Unknown escape sequence");
  793. }
  794. function parseIndent() {
  795. let start = cursor;
  796. consumeToken(TOKEN_BLANK);
  797. switch (source[cursor]) {
  798. case ".":
  799. case "[":
  800. case "*":
  801. case "}":
  802. case undefined:
  803. return false;
  804. case "{":
  805. return makeIndent(source.slice(start, cursor));
  806. }
  807. if (source[cursor - 1] === " ") {
  808. return makeIndent(source.slice(start, cursor));
  809. }
  810. return false;
  811. }
  812. function trim(text, re) {
  813. return text.replace(re, "");
  814. }
  815. function makeIndent(blank) {
  816. let value = blank.replace(RE_BLANK_LINES, "\n");
  817. let length = RE_INDENT.exec(blank)[1].length;
  818. return new Indent(value, length);
  819. }
  820. }
  821. }
  822. class Indent {
  823. constructor(value, length) {
  824. this.value = value;
  825. this.length = length;
  826. }
  827. }
  828. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/index.js
  829. /***/ }),
  830. /***/ 8275:
  831. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  832. // EXPORTS
  833. __webpack_require__.d(__webpack_exports__, {
  834. DOMLocalization: () => (/* reexport */ DOMLocalization)
  835. });
  836. // UNUSED EXPORTS: Localization
  837. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/overlay.js
  838. const reOverlay = /<|&#?\w+;/;
  839. const TEXT_LEVEL_ELEMENTS = {
  840. "http://www.w3.org/1999/xhtml": ["em", "strong", "small", "s", "cite", "q", "dfn", "abbr", "data", "time", "code", "var", "samp", "kbd", "sub", "sup", "i", "b", "u", "mark", "bdi", "bdo", "span", "br", "wbr"]
  841. };
  842. const LOCALIZABLE_ATTRIBUTES = {
  843. "http://www.w3.org/1999/xhtml": {
  844. global: ["title", "aria-label", "aria-valuetext"],
  845. a: ["download"],
  846. area: ["download", "alt"],
  847. input: ["alt", "placeholder"],
  848. menuitem: ["label"],
  849. menu: ["label"],
  850. optgroup: ["label"],
  851. option: ["label"],
  852. track: ["label"],
  853. img: ["alt"],
  854. textarea: ["placeholder"],
  855. th: ["abbr"]
  856. },
  857. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": {
  858. global: ["accesskey", "aria-label", "aria-valuetext", "label", "title", "tooltiptext"],
  859. description: ["value"],
  860. key: ["key", "keycode"],
  861. label: ["value"],
  862. textbox: ["placeholder", "value"]
  863. }
  864. };
  865. function translateElement(element, translation) {
  866. const {
  867. value
  868. } = translation;
  869. if (typeof value === "string") {
  870. if (element.localName === "title" && element.namespaceURI === "http://www.w3.org/1999/xhtml") {
  871. element.textContent = value;
  872. } else if (!reOverlay.test(value)) {
  873. element.textContent = value;
  874. } else {
  875. const templateElement = element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "template");
  876. templateElement.innerHTML = value;
  877. overlayChildNodes(templateElement.content, element);
  878. }
  879. }
  880. overlayAttributes(translation, element);
  881. }
  882. function overlayChildNodes(fromFragment, toElement) {
  883. for (const childNode of fromFragment.childNodes) {
  884. if (childNode.nodeType === childNode.TEXT_NODE) {
  885. continue;
  886. }
  887. if (childNode.hasAttribute("data-l10n-name")) {
  888. const sanitized = getNodeForNamedElement(toElement, childNode);
  889. fromFragment.replaceChild(sanitized, childNode);
  890. continue;
  891. }
  892. if (isElementAllowed(childNode)) {
  893. const sanitized = createSanitizedElement(childNode);
  894. fromFragment.replaceChild(sanitized, childNode);
  895. continue;
  896. }
  897. console.warn(`An element of forbidden type "${childNode.localName}" was found in ` + "the translation. Only safe text-level elements and elements with " + "data-l10n-name are allowed.");
  898. fromFragment.replaceChild(createTextNodeFromTextContent(childNode), childNode);
  899. }
  900. toElement.textContent = "";
  901. toElement.appendChild(fromFragment);
  902. }
  903. function hasAttribute(attributes, name) {
  904. if (!attributes) {
  905. return false;
  906. }
  907. for (let attr of attributes) {
  908. if (attr.name === name) {
  909. return true;
  910. }
  911. }
  912. return false;
  913. }
  914. function overlayAttributes(fromElement, toElement) {
  915. const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null;
  916. for (const attr of Array.from(toElement.attributes)) {
  917. if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) {
  918. toElement.removeAttribute(attr.name);
  919. }
  920. }
  921. if (!fromElement.attributes) {
  922. return;
  923. }
  924. for (const attr of Array.from(fromElement.attributes)) {
  925. if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) {
  926. toElement.setAttribute(attr.name, attr.value);
  927. }
  928. }
  929. }
  930. function getNodeForNamedElement(sourceElement, translatedChild) {
  931. const childName = translatedChild.getAttribute("data-l10n-name");
  932. const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`);
  933. if (!sourceChild) {
  934. console.warn(`An element named "${childName}" wasn't found in the source.`);
  935. return createTextNodeFromTextContent(translatedChild);
  936. }
  937. if (sourceChild.localName !== translatedChild.localName) {
  938. console.warn(`An element named "${childName}" was found in the translation ` + `but its type ${translatedChild.localName} didn't match the ` + `element found in the source (${sourceChild.localName}).`);
  939. return createTextNodeFromTextContent(translatedChild);
  940. }
  941. sourceElement.removeChild(sourceChild);
  942. const clone = sourceChild.cloneNode(false);
  943. return shallowPopulateUsing(translatedChild, clone);
  944. }
  945. function createSanitizedElement(element) {
  946. const clone = element.ownerDocument.createElement(element.localName);
  947. return shallowPopulateUsing(element, clone);
  948. }
  949. function createTextNodeFromTextContent(element) {
  950. return element.ownerDocument.createTextNode(element.textContent);
  951. }
  952. function isElementAllowed(element) {
  953. const allowed = TEXT_LEVEL_ELEMENTS[element.namespaceURI];
  954. return allowed && allowed.includes(element.localName);
  955. }
  956. function isAttrNameLocalizable(name, element, explicitlyAllowed = null) {
  957. if (explicitlyAllowed && explicitlyAllowed.includes(name)) {
  958. return true;
  959. }
  960. const allowed = LOCALIZABLE_ATTRIBUTES[element.namespaceURI];
  961. if (!allowed) {
  962. return false;
  963. }
  964. const attrName = name.toLowerCase();
  965. const elemName = element.localName;
  966. if (allowed.global.includes(attrName)) {
  967. return true;
  968. }
  969. if (!allowed[elemName]) {
  970. return false;
  971. }
  972. if (allowed[elemName].includes(attrName)) {
  973. return true;
  974. }
  975. if (element.namespaceURI === "http://www.w3.org/1999/xhtml" && elemName === "input" && attrName === "value") {
  976. const type = element.type.toLowerCase();
  977. if (type === "submit" || type === "button" || type === "reset") {
  978. return true;
  979. }
  980. }
  981. return false;
  982. }
  983. function shallowPopulateUsing(fromElement, toElement) {
  984. toElement.textContent = fromElement.textContent;
  985. overlayAttributes(fromElement, toElement);
  986. return toElement;
  987. }
  988. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_iterable.mjs
  989. class CachedIterable extends Array {
  990. static from(iterable) {
  991. if (iterable instanceof this) {
  992. return iterable;
  993. }
  994. return new this(iterable);
  995. }
  996. }
  997. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_sync_iterable.mjs
  998. class CachedSyncIterable extends CachedIterable {
  999. constructor(iterable) {
  1000. super();
  1001. if (Symbol.iterator in Object(iterable)) {
  1002. this.iterator = iterable[Symbol.iterator]();
  1003. } else {
  1004. throw new TypeError("Argument must implement the iteration protocol.");
  1005. }
  1006. }
  1007. [Symbol.iterator]() {
  1008. const cached = this;
  1009. let cur = 0;
  1010. return {
  1011. next() {
  1012. if (cached.length <= cur) {
  1013. cached.push(cached.iterator.next());
  1014. }
  1015. return cached[cur++];
  1016. }
  1017. };
  1018. }
  1019. touchNext(count = 1) {
  1020. let idx = 0;
  1021. while (idx++ < count) {
  1022. const last = this[this.length - 1];
  1023. if (last && last.done) {
  1024. break;
  1025. }
  1026. this.push(this.iterator.next());
  1027. }
  1028. return this[this.length - 1];
  1029. }
  1030. }
  1031. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_async_iterable.mjs
  1032. class CachedAsyncIterable extends CachedIterable {
  1033. constructor(iterable) {
  1034. super();
  1035. if (Symbol.asyncIterator in Object(iterable)) {
  1036. this.iterator = iterable[Symbol.asyncIterator]();
  1037. } else if (Symbol.iterator in Object(iterable)) {
  1038. this.iterator = iterable[Symbol.iterator]();
  1039. } else {
  1040. throw new TypeError("Argument must implement the iteration protocol.");
  1041. }
  1042. }
  1043. [Symbol.asyncIterator]() {
  1044. const cached = this;
  1045. let cur = 0;
  1046. return {
  1047. async next() {
  1048. if (cached.length <= cur) {
  1049. cached.push(cached.iterator.next());
  1050. }
  1051. return cached[cur++];
  1052. }
  1053. };
  1054. }
  1055. async touchNext(count = 1) {
  1056. let idx = 0;
  1057. while (idx++ < count) {
  1058. const last = this[this.length - 1];
  1059. if (last && (await last).done) {
  1060. break;
  1061. }
  1062. this.push(this.iterator.next());
  1063. }
  1064. return this[this.length - 1];
  1065. }
  1066. }
  1067. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/index.mjs
  1068. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/localization.js
  1069. class Localization {
  1070. constructor(resourceIds = [], generateBundles) {
  1071. this.resourceIds = resourceIds;
  1072. this.generateBundles = generateBundles;
  1073. this.onChange(true);
  1074. }
  1075. addResourceIds(resourceIds, eager = false) {
  1076. this.resourceIds.push(...resourceIds);
  1077. this.onChange(eager);
  1078. return this.resourceIds.length;
  1079. }
  1080. removeResourceIds(resourceIds) {
  1081. this.resourceIds = this.resourceIds.filter(r => !resourceIds.includes(r));
  1082. this.onChange();
  1083. return this.resourceIds.length;
  1084. }
  1085. async formatWithFallback(keys, method) {
  1086. const translations = [];
  1087. let hasAtLeastOneBundle = false;
  1088. for await (const bundle of this.bundles) {
  1089. hasAtLeastOneBundle = true;
  1090. const missingIds = keysFromBundle(method, bundle, keys, translations);
  1091. if (missingIds.size === 0) {
  1092. break;
  1093. }
  1094. if (typeof console !== "undefined") {
  1095. const locale = bundle.locales[0];
  1096. const ids = Array.from(missingIds).join(", ");
  1097. console.warn(`[fluent] Missing translations in ${locale}: ${ids}`);
  1098. }
  1099. }
  1100. if (!hasAtLeastOneBundle && typeof console !== "undefined") {
  1101. console.warn(`[fluent] Request for keys failed because no resource bundles got generated.
  1102. keys: ${JSON.stringify(keys)}.
  1103. resourceIds: ${JSON.stringify(this.resourceIds)}.`);
  1104. }
  1105. return translations;
  1106. }
  1107. formatMessages(keys) {
  1108. return this.formatWithFallback(keys, messageFromBundle);
  1109. }
  1110. formatValues(keys) {
  1111. return this.formatWithFallback(keys, valueFromBundle);
  1112. }
  1113. async formatValue(id, args) {
  1114. const [val] = await this.formatValues([{
  1115. id,
  1116. args
  1117. }]);
  1118. return val;
  1119. }
  1120. handleEvent() {
  1121. this.onChange();
  1122. }
  1123. onChange(eager = false) {
  1124. this.bundles = CachedAsyncIterable.from(this.generateBundles(this.resourceIds));
  1125. if (eager) {
  1126. this.bundles.touchNext(2);
  1127. }
  1128. }
  1129. }
  1130. function valueFromBundle(bundle, errors, message, args) {
  1131. if (message.value) {
  1132. return bundle.formatPattern(message.value, args, errors);
  1133. }
  1134. return null;
  1135. }
  1136. function messageFromBundle(bundle, errors, message, args) {
  1137. const formatted = {
  1138. value: null,
  1139. attributes: null
  1140. };
  1141. if (message.value) {
  1142. formatted.value = bundle.formatPattern(message.value, args, errors);
  1143. }
  1144. let attrNames = Object.keys(message.attributes);
  1145. if (attrNames.length > 0) {
  1146. formatted.attributes = new Array(attrNames.length);
  1147. for (let [i, name] of attrNames.entries()) {
  1148. let value = bundle.formatPattern(message.attributes[name], args, errors);
  1149. formatted.attributes[i] = {
  1150. name,
  1151. value
  1152. };
  1153. }
  1154. }
  1155. return formatted;
  1156. }
  1157. function keysFromBundle(method, bundle, keys, translations) {
  1158. const messageErrors = [];
  1159. const missingIds = new Set();
  1160. keys.forEach(({
  1161. id,
  1162. args
  1163. }, i) => {
  1164. if (translations[i] !== undefined) {
  1165. return;
  1166. }
  1167. let message = bundle.getMessage(id);
  1168. if (message) {
  1169. messageErrors.length = 0;
  1170. translations[i] = method(bundle, messageErrors, message, args);
  1171. if (messageErrors.length > 0 && typeof console !== "undefined") {
  1172. const locale = bundle.locales[0];
  1173. const errors = messageErrors.join(", ");
  1174. console.warn(`[fluent][resolver] errors in ${locale}/${id}: ${errors}.`);
  1175. }
  1176. } else {
  1177. missingIds.add(id);
  1178. }
  1179. });
  1180. return missingIds;
  1181. }
  1182. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/dom_localization.js
  1183. const L10NID_ATTR_NAME = "data-l10n-id";
  1184. const L10NARGS_ATTR_NAME = "data-l10n-args";
  1185. const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`;
  1186. class DOMLocalization extends Localization {
  1187. constructor(resourceIds, generateBundles) {
  1188. super(resourceIds, generateBundles);
  1189. this.roots = new Set();
  1190. this.pendingrAF = null;
  1191. this.pendingElements = new Set();
  1192. this.windowElement = null;
  1193. this.mutationObserver = null;
  1194. this.observerConfig = {
  1195. attributes: true,
  1196. characterData: false,
  1197. childList: true,
  1198. subtree: true,
  1199. attributeFilter: [L10NID_ATTR_NAME, L10NARGS_ATTR_NAME]
  1200. };
  1201. }
  1202. onChange(eager = false) {
  1203. super.onChange(eager);
  1204. if (this.roots) {
  1205. this.translateRoots();
  1206. }
  1207. }
  1208. setAttributes(element, id, args) {
  1209. element.setAttribute(L10NID_ATTR_NAME, id);
  1210. if (args) {
  1211. element.setAttribute(L10NARGS_ATTR_NAME, JSON.stringify(args));
  1212. } else {
  1213. element.removeAttribute(L10NARGS_ATTR_NAME);
  1214. }
  1215. return element;
  1216. }
  1217. getAttributes(element) {
  1218. return {
  1219. id: element.getAttribute(L10NID_ATTR_NAME),
  1220. args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
  1221. };
  1222. }
  1223. connectRoot(newRoot) {
  1224. for (const root of this.roots) {
  1225. if (root === newRoot || root.contains(newRoot) || newRoot.contains(root)) {
  1226. throw new Error("Cannot add a root that overlaps with existing root.");
  1227. }
  1228. }
  1229. if (this.windowElement) {
  1230. if (this.windowElement !== newRoot.ownerDocument.defaultView) {
  1231. throw new Error(`Cannot connect a root:
  1232. DOMLocalization already has a root from a different window.`);
  1233. }
  1234. } else {
  1235. this.windowElement = newRoot.ownerDocument.defaultView;
  1236. this.mutationObserver = new this.windowElement.MutationObserver(mutations => this.translateMutations(mutations));
  1237. }
  1238. this.roots.add(newRoot);
  1239. this.mutationObserver.observe(newRoot, this.observerConfig);
  1240. }
  1241. disconnectRoot(root) {
  1242. this.roots.delete(root);
  1243. this.pauseObserving();
  1244. if (this.roots.size === 0) {
  1245. this.mutationObserver = null;
  1246. this.windowElement = null;
  1247. this.pendingrAF = null;
  1248. this.pendingElements.clear();
  1249. return true;
  1250. }
  1251. this.resumeObserving();
  1252. return false;
  1253. }
  1254. translateRoots() {
  1255. const roots = Array.from(this.roots);
  1256. return Promise.all(roots.map(root => this.translateFragment(root)));
  1257. }
  1258. pauseObserving() {
  1259. if (!this.mutationObserver) {
  1260. return;
  1261. }
  1262. this.translateMutations(this.mutationObserver.takeRecords());
  1263. this.mutationObserver.disconnect();
  1264. }
  1265. resumeObserving() {
  1266. if (!this.mutationObserver) {
  1267. return;
  1268. }
  1269. for (const root of this.roots) {
  1270. this.mutationObserver.observe(root, this.observerConfig);
  1271. }
  1272. }
  1273. translateMutations(mutations) {
  1274. for (const mutation of mutations) {
  1275. switch (mutation.type) {
  1276. case "attributes":
  1277. if (mutation.target.hasAttribute("data-l10n-id")) {
  1278. this.pendingElements.add(mutation.target);
  1279. }
  1280. break;
  1281. case "childList":
  1282. for (const addedNode of mutation.addedNodes) {
  1283. if (addedNode.nodeType === addedNode.ELEMENT_NODE) {
  1284. if (addedNode.childElementCount) {
  1285. for (const element of this.getTranslatables(addedNode)) {
  1286. this.pendingElements.add(element);
  1287. }
  1288. } else if (addedNode.hasAttribute(L10NID_ATTR_NAME)) {
  1289. this.pendingElements.add(addedNode);
  1290. }
  1291. }
  1292. }
  1293. break;
  1294. }
  1295. }
  1296. if (this.pendingElements.size > 0) {
  1297. if (this.pendingrAF === null) {
  1298. this.pendingrAF = this.windowElement.requestAnimationFrame(() => {
  1299. this.translateElements(Array.from(this.pendingElements));
  1300. this.pendingElements.clear();
  1301. this.pendingrAF = null;
  1302. });
  1303. }
  1304. }
  1305. }
  1306. translateFragment(frag) {
  1307. return this.translateElements(this.getTranslatables(frag));
  1308. }
  1309. async translateElements(elements) {
  1310. if (!elements.length) {
  1311. return undefined;
  1312. }
  1313. const keys = elements.map(this.getKeysForElement);
  1314. const translations = await this.formatMessages(keys);
  1315. return this.applyTranslations(elements, translations);
  1316. }
  1317. applyTranslations(elements, translations) {
  1318. this.pauseObserving();
  1319. for (let i = 0; i < elements.length; i++) {
  1320. if (translations[i] !== undefined) {
  1321. translateElement(elements[i], translations[i]);
  1322. }
  1323. }
  1324. this.resumeObserving();
  1325. }
  1326. getTranslatables(element) {
  1327. const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY));
  1328. if (typeof element.hasAttribute === "function" && element.hasAttribute(L10NID_ATTR_NAME)) {
  1329. nodes.push(element);
  1330. }
  1331. return nodes;
  1332. }
  1333. getKeysForElement(element) {
  1334. return {
  1335. id: element.getAttribute(L10NID_ATTR_NAME),
  1336. args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
  1337. };
  1338. }
  1339. }
  1340. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/index.js
  1341. /***/ }),
  1342. /***/ 631:
  1343. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1344. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1345. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1346. /* harmony export */ AltTextManager: () => (/* binding */ AltTextManager)
  1347. /* harmony export */ });
  1348. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  1349. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  1350. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1351. class AltTextManager {
  1352. #boundUpdateUIState = this.#updateUIState.bind(this);
  1353. #boundSetPosition = this.#setPosition.bind(this);
  1354. #boundOnClick = this.#onClick.bind(this);
  1355. #currentEditor = null;
  1356. #cancelButton;
  1357. #dialog;
  1358. #eventBus;
  1359. #hasUsedPointer = false;
  1360. #optionDescription;
  1361. #optionDecorative;
  1362. #overlayManager;
  1363. #saveButton;
  1364. #textarea;
  1365. #uiManager;
  1366. #previousAltText = null;
  1367. #svgElement = null;
  1368. #rectElement = null;
  1369. #container;
  1370. #telemetryData = null;
  1371. constructor({
  1372. dialog,
  1373. optionDescription,
  1374. optionDecorative,
  1375. textarea,
  1376. cancelButton,
  1377. saveButton
  1378. }, container, overlayManager, eventBus) {
  1379. this.#dialog = dialog;
  1380. this.#optionDescription = optionDescription;
  1381. this.#optionDecorative = optionDecorative;
  1382. this.#textarea = textarea;
  1383. this.#cancelButton = cancelButton;
  1384. this.#saveButton = saveButton;
  1385. this.#overlayManager = overlayManager;
  1386. this.#eventBus = eventBus;
  1387. this.#container = container;
  1388. dialog.addEventListener("close", this.#close.bind(this));
  1389. dialog.addEventListener("contextmenu", event => {
  1390. if (event.target !== this.#textarea) {
  1391. event.preventDefault();
  1392. }
  1393. });
  1394. cancelButton.addEventListener("click", this.#finish.bind(this));
  1395. saveButton.addEventListener("click", this.#save.bind(this));
  1396. optionDescription.addEventListener("change", this.#boundUpdateUIState);
  1397. optionDecorative.addEventListener("change", this.#boundUpdateUIState);
  1398. this.#overlayManager.register(dialog);
  1399. }
  1400. get _elements() {
  1401. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_elements", [this.#optionDescription, this.#optionDecorative, this.#textarea, this.#saveButton, this.#cancelButton]);
  1402. }
  1403. #createSVGElement() {
  1404. if (this.#svgElement) {
  1405. return;
  1406. }
  1407. const svgFactory = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.DOMSVGFactory();
  1408. const svg = this.#svgElement = svgFactory.createElement("svg");
  1409. svg.setAttribute("width", "0");
  1410. svg.setAttribute("height", "0");
  1411. const defs = svgFactory.createElement("defs");
  1412. svg.append(defs);
  1413. const mask = svgFactory.createElement("mask");
  1414. defs.append(mask);
  1415. mask.setAttribute("id", "alttext-manager-mask");
  1416. mask.setAttribute("maskContentUnits", "objectBoundingBox");
  1417. let rect = svgFactory.createElement("rect");
  1418. mask.append(rect);
  1419. rect.setAttribute("fill", "white");
  1420. rect.setAttribute("width", "1");
  1421. rect.setAttribute("height", "1");
  1422. rect.setAttribute("x", "0");
  1423. rect.setAttribute("y", "0");
  1424. rect = this.#rectElement = svgFactory.createElement("rect");
  1425. mask.append(rect);
  1426. rect.setAttribute("fill", "black");
  1427. this.#dialog.append(svg);
  1428. }
  1429. async editAltText(uiManager, editor) {
  1430. if (this.#currentEditor || !editor) {
  1431. return;
  1432. }
  1433. this.#createSVGElement();
  1434. this.#hasUsedPointer = false;
  1435. for (const element of this._elements) {
  1436. element.addEventListener("click", this.#boundOnClick);
  1437. }
  1438. const {
  1439. altText,
  1440. decorative
  1441. } = editor.altTextData;
  1442. if (decorative === true) {
  1443. this.#optionDecorative.checked = true;
  1444. this.#optionDescription.checked = false;
  1445. } else {
  1446. this.#optionDecorative.checked = false;
  1447. this.#optionDescription.checked = true;
  1448. }
  1449. this.#previousAltText = this.#textarea.value = altText?.trim() || "";
  1450. this.#updateUIState();
  1451. this.#currentEditor = editor;
  1452. this.#uiManager = uiManager;
  1453. this.#uiManager.removeEditListeners();
  1454. this.#eventBus._on("resize", this.#boundSetPosition);
  1455. try {
  1456. await this.#overlayManager.open(this.#dialog);
  1457. this.#setPosition();
  1458. } catch (ex) {
  1459. this.#close();
  1460. throw ex;
  1461. }
  1462. }
  1463. #setPosition() {
  1464. if (!this.#currentEditor) {
  1465. return;
  1466. }
  1467. const dialog = this.#dialog;
  1468. const {
  1469. style
  1470. } = dialog;
  1471. const {
  1472. x: containerX,
  1473. y: containerY,
  1474. width: containerW,
  1475. height: containerH
  1476. } = this.#container.getBoundingClientRect();
  1477. const {
  1478. innerWidth: windowW,
  1479. innerHeight: windowH
  1480. } = window;
  1481. const {
  1482. width: dialogW,
  1483. height: dialogH
  1484. } = dialog.getBoundingClientRect();
  1485. const {
  1486. x,
  1487. y,
  1488. width,
  1489. height
  1490. } = this.#currentEditor.getClientDimensions();
  1491. const MARGIN = 10;
  1492. const isLTR = this.#uiManager.direction === "ltr";
  1493. const xs = Math.max(x, containerX);
  1494. const xe = Math.min(x + width, containerX + containerW);
  1495. const ys = Math.max(y, containerY);
  1496. const ye = Math.min(y + height, containerY + containerH);
  1497. this.#rectElement.setAttribute("width", `${(xe - xs) / windowW}`);
  1498. this.#rectElement.setAttribute("height", `${(ye - ys) / windowH}`);
  1499. this.#rectElement.setAttribute("x", `${xs / windowW}`);
  1500. this.#rectElement.setAttribute("y", `${ys / windowH}`);
  1501. let left = null;
  1502. let top = Math.max(y, 0);
  1503. top += Math.min(windowH - (top + dialogH), 0);
  1504. if (isLTR) {
  1505. if (x + width + MARGIN + dialogW < windowW) {
  1506. left = x + width + MARGIN;
  1507. } else if (x > dialogW + MARGIN) {
  1508. left = x - dialogW - MARGIN;
  1509. }
  1510. } else if (x > dialogW + MARGIN) {
  1511. left = x - dialogW - MARGIN;
  1512. } else if (x + width + MARGIN + dialogW < windowW) {
  1513. left = x + width + MARGIN;
  1514. }
  1515. if (left === null) {
  1516. top = null;
  1517. left = Math.max(x, 0);
  1518. left += Math.min(windowW - (left + dialogW), 0);
  1519. if (y > dialogH + MARGIN) {
  1520. top = y - dialogH - MARGIN;
  1521. } else if (y + height + MARGIN + dialogH < windowH) {
  1522. top = y + height + MARGIN;
  1523. }
  1524. }
  1525. if (top !== null) {
  1526. dialog.classList.add("positioned");
  1527. if (isLTR) {
  1528. style.left = `${left}px`;
  1529. } else {
  1530. style.right = `${windowW - left - dialogW}px`;
  1531. }
  1532. style.top = `${top}px`;
  1533. } else {
  1534. dialog.classList.remove("positioned");
  1535. style.left = "";
  1536. style.top = "";
  1537. }
  1538. }
  1539. #finish() {
  1540. if (this.#overlayManager.active === this.#dialog) {
  1541. this.#overlayManager.close(this.#dialog);
  1542. }
  1543. }
  1544. #close() {
  1545. this.#eventBus.dispatch("reporttelemetry", {
  1546. source: this,
  1547. details: {
  1548. type: "editing",
  1549. subtype: this.#currentEditor.editorType,
  1550. data: this.#telemetryData || {
  1551. action: "alt_text_cancel",
  1552. alt_text_keyboard: !this.#hasUsedPointer
  1553. }
  1554. }
  1555. });
  1556. this.#telemetryData = null;
  1557. this.#removeOnClickListeners();
  1558. this.#uiManager?.addEditListeners();
  1559. this.#eventBus._off("resize", this.#boundSetPosition);
  1560. this.#currentEditor.altTextFinish();
  1561. this.#currentEditor = null;
  1562. this.#uiManager = null;
  1563. }
  1564. #updateUIState() {
  1565. this.#textarea.disabled = this.#optionDecorative.checked;
  1566. }
  1567. #save() {
  1568. const altText = this.#textarea.value.trim();
  1569. const decorative = this.#optionDecorative.checked;
  1570. this.#currentEditor.altTextData = {
  1571. altText,
  1572. decorative
  1573. };
  1574. this.#telemetryData = {
  1575. action: "alt_text_save",
  1576. alt_text_description: !!altText,
  1577. alt_text_edit: !!this.#previousAltText && this.#previousAltText !== altText,
  1578. alt_text_decorative: decorative,
  1579. alt_text_keyboard: !this.#hasUsedPointer
  1580. };
  1581. this.#finish();
  1582. }
  1583. #onClick(evt) {
  1584. if (evt.detail === 0) {
  1585. return;
  1586. }
  1587. this.#hasUsedPointer = true;
  1588. this.#removeOnClickListeners();
  1589. }
  1590. #removeOnClickListeners() {
  1591. for (const element of this._elements) {
  1592. element.removeEventListener("click", this.#boundOnClick);
  1593. }
  1594. }
  1595. destroy() {
  1596. this.#uiManager = null;
  1597. this.#finish();
  1598. this.#svgElement?.remove();
  1599. this.#svgElement = this.#rectElement = null;
  1600. }
  1601. }
  1602. __webpack_async_result__();
  1603. } catch(e) { __webpack_async_result__(e); } });
  1604. /***/ }),
  1605. /***/ 2640:
  1606. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1607. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1608. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1609. /* harmony export */ AnnotationEditorLayerBuilder: () => (/* binding */ AnnotationEditorLayerBuilder)
  1610. /* harmony export */ });
  1611. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  1612. /* harmony import */ var web_l10n_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7910);
  1613. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_l10n_utils__WEBPACK_IMPORTED_MODULE_1__]);
  1614. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_l10n_utils__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  1615. class AnnotationEditorLayerBuilder {
  1616. #annotationLayer = null;
  1617. #drawLayer = null;
  1618. #textLayer = null;
  1619. #uiManager;
  1620. constructor(options) {
  1621. this.pageDiv = options.pageDiv;
  1622. this.pdfPage = options.pdfPage;
  1623. this.accessibilityManager = options.accessibilityManager;
  1624. this.l10n = options.l10n || web_l10n_utils__WEBPACK_IMPORTED_MODULE_1__.NullL10n;
  1625. this.annotationEditorLayer = null;
  1626. this.div = null;
  1627. this._cancelled = false;
  1628. this.#uiManager = options.uiManager;
  1629. this.#annotationLayer = options.annotationLayer || null;
  1630. this.#textLayer = options.textLayer || null;
  1631. this.#drawLayer = options.drawLayer || null;
  1632. }
  1633. async render(viewport, intent = "display") {
  1634. if (intent !== "display") {
  1635. return;
  1636. }
  1637. if (this._cancelled) {
  1638. return;
  1639. }
  1640. const clonedViewport = viewport.clone({
  1641. dontFlip: true
  1642. });
  1643. if (this.div) {
  1644. this.annotationEditorLayer.update({
  1645. viewport: clonedViewport
  1646. });
  1647. this.show();
  1648. return;
  1649. }
  1650. const div = this.div = document.createElement("div");
  1651. div.className = "annotationEditorLayer";
  1652. div.tabIndex = 0;
  1653. div.hidden = true;
  1654. div.dir = this.#uiManager.direction;
  1655. this.pageDiv.append(div);
  1656. this.annotationEditorLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorLayer({
  1657. uiManager: this.#uiManager,
  1658. div,
  1659. accessibilityManager: this.accessibilityManager,
  1660. pageIndex: this.pdfPage.pageNumber - 1,
  1661. l10n: this.l10n,
  1662. viewport: clonedViewport,
  1663. annotationLayer: this.#annotationLayer,
  1664. textLayer: this.#textLayer,
  1665. drawLayer: this.#drawLayer
  1666. });
  1667. const parameters = {
  1668. viewport: clonedViewport,
  1669. div,
  1670. annotations: null,
  1671. intent
  1672. };
  1673. this.annotationEditorLayer.render(parameters);
  1674. this.show();
  1675. }
  1676. cancel() {
  1677. this._cancelled = true;
  1678. if (!this.div) {
  1679. return;
  1680. }
  1681. this.pageDiv = null;
  1682. this.annotationEditorLayer.destroy();
  1683. this.div.remove();
  1684. }
  1685. hide() {
  1686. if (!this.div) {
  1687. return;
  1688. }
  1689. this.div.hidden = true;
  1690. }
  1691. show() {
  1692. if (!this.div || this.annotationEditorLayer.isEmpty) {
  1693. return;
  1694. }
  1695. this.div.hidden = false;
  1696. }
  1697. }
  1698. __webpack_async_result__();
  1699. } catch(e) { __webpack_async_result__(e); } });
  1700. /***/ }),
  1701. /***/ 1296:
  1702. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1703. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1704. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1705. /* harmony export */ AnnotationEditorParams: () => (/* binding */ AnnotationEditorParams)
  1706. /* harmony export */ });
  1707. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  1708. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  1709. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1710. class AnnotationEditorParams {
  1711. constructor(options, eventBus) {
  1712. this.eventBus = eventBus;
  1713. this.#bindListeners(options);
  1714. }
  1715. #bindListeners({
  1716. editorFreeTextFontSize,
  1717. editorFreeTextColor,
  1718. editorInkColor,
  1719. editorInkThickness,
  1720. editorInkOpacity,
  1721. editorStampAddImage
  1722. }) {
  1723. const dispatchEvent = (typeStr, value) => {
  1724. this.eventBus.dispatch("switchannotationeditorparams", {
  1725. source: this,
  1726. type: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType[typeStr],
  1727. value
  1728. });
  1729. };
  1730. editorFreeTextFontSize.addEventListener("input", function () {
  1731. dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
  1732. });
  1733. editorFreeTextColor.addEventListener("input", function () {
  1734. dispatchEvent("FREETEXT_COLOR", this.value);
  1735. });
  1736. editorInkColor.addEventListener("input", function () {
  1737. dispatchEvent("INK_COLOR", this.value);
  1738. });
  1739. editorInkThickness.addEventListener("input", function () {
  1740. dispatchEvent("INK_THICKNESS", this.valueAsNumber);
  1741. });
  1742. editorInkOpacity.addEventListener("input", function () {
  1743. dispatchEvent("INK_OPACITY", this.valueAsNumber);
  1744. });
  1745. editorStampAddImage.addEventListener("click", () => {
  1746. dispatchEvent("CREATE");
  1747. });
  1748. this.eventBus._on("annotationeditorparamschanged", evt => {
  1749. for (const [type, value] of evt.details) {
  1750. switch (type) {
  1751. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.FREETEXT_SIZE:
  1752. editorFreeTextFontSize.value = value;
  1753. break;
  1754. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.FREETEXT_COLOR:
  1755. editorFreeTextColor.value = value;
  1756. break;
  1757. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_COLOR:
  1758. editorInkColor.value = value;
  1759. break;
  1760. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_THICKNESS:
  1761. editorInkThickness.value = value;
  1762. break;
  1763. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_OPACITY:
  1764. editorInkOpacity.value = value;
  1765. break;
  1766. }
  1767. }
  1768. });
  1769. }
  1770. }
  1771. __webpack_async_result__();
  1772. } catch(e) { __webpack_async_result__(e); } });
  1773. /***/ }),
  1774. /***/ 6735:
  1775. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1776. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1777. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1778. /* harmony export */ AnnotationLayerBuilder: () => (/* binding */ AnnotationLayerBuilder)
  1779. /* harmony export */ });
  1780. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  1781. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  1782. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  1783. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1784. class AnnotationLayerBuilder {
  1785. #onPresentationModeChanged = null;
  1786. constructor({
  1787. pageDiv,
  1788. pdfPage,
  1789. linkService,
  1790. downloadManager,
  1791. annotationStorage = null,
  1792. imageResourcesPath = "",
  1793. renderForms = true,
  1794. enableScripting = false,
  1795. hasJSActionsPromise = null,
  1796. fieldObjectsPromise = null,
  1797. annotationCanvasMap = null,
  1798. accessibilityManager = null
  1799. }) {
  1800. this.pageDiv = pageDiv;
  1801. this.pdfPage = pdfPage;
  1802. this.linkService = linkService;
  1803. this.downloadManager = downloadManager;
  1804. this.imageResourcesPath = imageResourcesPath;
  1805. this.renderForms = renderForms;
  1806. this.annotationStorage = annotationStorage;
  1807. this.enableScripting = enableScripting;
  1808. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  1809. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  1810. this._annotationCanvasMap = annotationCanvasMap;
  1811. this._accessibilityManager = accessibilityManager;
  1812. this.annotationLayer = null;
  1813. this.div = null;
  1814. this._cancelled = false;
  1815. this._eventBus = linkService.eventBus;
  1816. }
  1817. async render(viewport, intent = "display") {
  1818. if (this.div) {
  1819. if (this._cancelled || !this.annotationLayer) {
  1820. return;
  1821. }
  1822. this.annotationLayer.update({
  1823. viewport: viewport.clone({
  1824. dontFlip: true
  1825. })
  1826. });
  1827. return;
  1828. }
  1829. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  1830. intent
  1831. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  1832. if (this._cancelled) {
  1833. return;
  1834. }
  1835. const div = this.div = document.createElement("div");
  1836. div.className = "annotationLayer";
  1837. this.pageDiv.append(div);
  1838. if (annotations.length === 0) {
  1839. this.hide();
  1840. return;
  1841. }
  1842. this.annotationLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationLayer({
  1843. div,
  1844. accessibilityManager: this._accessibilityManager,
  1845. annotationCanvasMap: this._annotationCanvasMap,
  1846. page: this.pdfPage,
  1847. viewport: viewport.clone({
  1848. dontFlip: true
  1849. })
  1850. });
  1851. await this.annotationLayer.render({
  1852. annotations,
  1853. imageResourcesPath: this.imageResourcesPath,
  1854. renderForms: this.renderForms,
  1855. linkService: this.linkService,
  1856. downloadManager: this.downloadManager,
  1857. annotationStorage: this.annotationStorage,
  1858. enableScripting: this.enableScripting,
  1859. hasJSActions,
  1860. fieldObjects
  1861. });
  1862. if (this.linkService.isInPresentationMode) {
  1863. this.#updatePresentationModeState(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN);
  1864. }
  1865. if (!this.#onPresentationModeChanged) {
  1866. this.#onPresentationModeChanged = evt => {
  1867. this.#updatePresentationModeState(evt.state);
  1868. };
  1869. this._eventBus?._on("presentationmodechanged", this.#onPresentationModeChanged);
  1870. }
  1871. }
  1872. cancel() {
  1873. this._cancelled = true;
  1874. if (this.#onPresentationModeChanged) {
  1875. this._eventBus?._off("presentationmodechanged", this.#onPresentationModeChanged);
  1876. this.#onPresentationModeChanged = null;
  1877. }
  1878. }
  1879. hide() {
  1880. if (!this.div) {
  1881. return;
  1882. }
  1883. this.div.hidden = true;
  1884. }
  1885. #updatePresentationModeState(state) {
  1886. if (!this.div) {
  1887. return;
  1888. }
  1889. let disableFormElements = false;
  1890. switch (state) {
  1891. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN:
  1892. disableFormElements = true;
  1893. break;
  1894. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL:
  1895. break;
  1896. default:
  1897. return;
  1898. }
  1899. for (const section of this.div.childNodes) {
  1900. if (section.hasAttribute("data-internal-link")) {
  1901. continue;
  1902. }
  1903. section.inert = disableFormElements;
  1904. }
  1905. }
  1906. }
  1907. __webpack_async_result__();
  1908. } catch(e) { __webpack_async_result__(e); } });
  1909. /***/ }),
  1910. /***/ 39:
  1911. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1912. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1913. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1914. /* harmony export */ DefaultExternalServices: () => (/* binding */ DefaultExternalServices),
  1915. /* harmony export */ PDFPrintServiceFactory: () => (/* binding */ PDFPrintServiceFactory),
  1916. /* harmony export */ PDFViewerApplication: () => (/* binding */ PDFViewerApplication)
  1917. /* harmony export */ });
  1918. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  1919. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1869);
  1920. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8961);
  1921. /* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6554);
  1922. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3234);
  1923. /* harmony import */ var web_alt_text_manager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(631);
  1924. /* harmony import */ var web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1296);
  1925. /* harmony import */ var _overlay_manager_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(1996);
  1926. /* harmony import */ var _password_prompt_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6329);
  1927. /* harmony import */ var web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(716);
  1928. /* harmony import */ var web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3611);
  1929. /* harmony import */ var web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(6312);
  1930. /* harmony import */ var web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1795);
  1931. /* harmony import */ var _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3557);
  1932. /* harmony import */ var _pdf_history_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(6418);
  1933. /* harmony import */ var web_pdf_layer_viewer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(3706);
  1934. /* harmony import */ var web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(1141);
  1935. /* harmony import */ var web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(323);
  1936. /* harmony import */ var _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(5119);
  1937. /* harmony import */ var _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(2599);
  1938. /* harmony import */ var web_pdf_sidebar__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(4487);
  1939. /* harmony import */ var web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(3510);
  1940. /* harmony import */ var _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(9290);
  1941. /* harmony import */ var web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(1544);
  1942. /* harmony import */ var web_toolbar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(276);
  1943. /* harmony import */ var _view_history_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(1096);
  1944. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, web_alt_text_manager__WEBPACK_IMPORTED_MODULE_5__, web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_6__, _password_prompt_js__WEBPACK_IMPORTED_MODULE_7__, web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_8__, web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_9__, web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_10__, web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_11__, _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_12__, web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_15__, web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_16__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_17__, _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_18__, web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_20__, _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_21__, web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_22__, web_toolbar__WEBPACK_IMPORTED_MODULE_23__]);
  1945. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, web_alt_text_manager__WEBPACK_IMPORTED_MODULE_5__, web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_6__, _password_prompt_js__WEBPACK_IMPORTED_MODULE_7__, web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_8__, web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_9__, web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_10__, web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_11__, _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_12__, web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_15__, web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_16__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_17__, _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_18__, web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_20__, _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_21__, web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_22__, web_toolbar__WEBPACK_IMPORTED_MODULE_23__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  1946. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  1947. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  1948. const ViewOnLoad = {
  1949. UNKNOWN: -1,
  1950. PREVIOUS: 0,
  1951. INITIAL: 1
  1952. };
  1953. class DefaultExternalServices {
  1954. constructor() {
  1955. throw new Error("Cannot initialize DefaultExternalServices.");
  1956. }
  1957. static updateFindControlState(data) {}
  1958. static updateFindMatchesCount(data) {}
  1959. static initPassiveLoading(callbacks) {}
  1960. static reportTelemetry(data) {}
  1961. static createDownloadManager() {
  1962. throw new Error("Not implemented: createDownloadManager");
  1963. }
  1964. static createPreferences() {
  1965. throw new Error("Not implemented: createPreferences");
  1966. }
  1967. static async createL10n() {
  1968. throw new Error("Not implemented: createL10n");
  1969. }
  1970. static createScripting() {
  1971. throw new Error("Not implemented: createScripting");
  1972. }
  1973. static updateEditorStates(data) {
  1974. throw new Error("Not implemented: updateEditorStates");
  1975. }
  1976. static getNimbusExperimentData() {
  1977. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "getNimbusExperimentData", Promise.resolve(null));
  1978. }
  1979. }
  1980. const PDFViewerApplication = {
  1981. initialBookmark: document.location.hash.substring(1),
  1982. _initializedCapability: new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability(),
  1983. appConfig: null,
  1984. pdfDocument: null,
  1985. pdfLoadingTask: null,
  1986. printService: null,
  1987. pdfViewer: null,
  1988. pdfThumbnailViewer: null,
  1989. pdfRenderingQueue: null,
  1990. pdfPresentationMode: null,
  1991. pdfDocumentProperties: null,
  1992. pdfLinkService: null,
  1993. pdfHistory: null,
  1994. pdfSidebar: null,
  1995. pdfOutlineViewer: null,
  1996. pdfAttachmentViewer: null,
  1997. pdfLayerViewer: null,
  1998. pdfCursorTools: null,
  1999. pdfScriptingManager: null,
  2000. store: null,
  2001. downloadManager: null,
  2002. overlayManager: null,
  2003. preferences: null,
  2004. toolbar: null,
  2005. secondaryToolbar: null,
  2006. eventBus: null,
  2007. l10n: null,
  2008. annotationEditorParams: null,
  2009. isInitialViewSet: false,
  2010. downloadComplete: false,
  2011. isViewerEmbedded: window.parent !== window,
  2012. url: "",
  2013. baseUrl: "",
  2014. _downloadUrl: "",
  2015. externalServices: DefaultExternalServices,
  2016. _boundEvents: Object.create(null),
  2017. documentInfo: null,
  2018. metadata: null,
  2019. _contentDispositionFilename: null,
  2020. _contentLength: null,
  2021. _saveInProgress: false,
  2022. _wheelUnusedTicks: 0,
  2023. _wheelUnusedFactor: 1,
  2024. _touchUnusedTicks: 0,
  2025. _touchUnusedFactor: 1,
  2026. _PDFBug: null,
  2027. _hasAnnotationEditors: false,
  2028. _title: document.title,
  2029. _printAnnotationStoragePromise: null,
  2030. _touchInfo: null,
  2031. _isCtrlKeyDown: false,
  2032. _nimbusDataPromise: null,
  2033. async initialize(appConfig) {
  2034. let l10nPromise;
  2035. this.appConfig = appConfig;
  2036. try {
  2037. await this.preferences.initializedPromise;
  2038. } catch (ex) {
  2039. console.error(`initialize: "${ex.message}".`);
  2040. }
  2041. if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pdfBugEnabled")) {
  2042. await this._parseHashParams();
  2043. }
  2044. let mode;
  2045. switch (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("viewerCssTheme")) {
  2046. case 1:
  2047. mode = "is-light";
  2048. break;
  2049. case 2:
  2050. mode = "is-dark";
  2051. break;
  2052. }
  2053. if (mode) {
  2054. document.documentElement.classList.add(mode);
  2055. }
  2056. l10nPromise = this.externalServices.createL10n();
  2057. this.l10n = await l10nPromise;
  2058. document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
  2059. this.l10n.translate(appConfig.appContainer || document.documentElement);
  2060. if (this.isViewerEmbedded && _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkTarget") === _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_4__.LinkTarget.NONE) {
  2061. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("externalLinkTarget", _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_4__.LinkTarget.TOP);
  2062. }
  2063. await this._initializeViewerComponents();
  2064. this.bindEvents();
  2065. this.bindWindowEvents();
  2066. this._initializedCapability.resolve();
  2067. },
  2068. async _parseHashParams() {
  2069. const hash = document.location.hash.substring(1);
  2070. if (!hash) {
  2071. return;
  2072. }
  2073. const {
  2074. mainContainer,
  2075. viewerContainer
  2076. } = this.appConfig,
  2077. params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
  2078. if (params.get("disableworker") === "true") {
  2079. try {
  2080. await loadFakeWorker();
  2081. } catch (ex) {
  2082. console.error(`_parseHashParams: "${ex.message}".`);
  2083. }
  2084. }
  2085. if (params.has("disablerange")) {
  2086. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableRange", params.get("disablerange") === "true");
  2087. }
  2088. if (params.has("disablestream")) {
  2089. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableStream", params.get("disablestream") === "true");
  2090. }
  2091. if (params.has("disableautofetch")) {
  2092. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  2093. }
  2094. if (params.has("disablefontface")) {
  2095. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  2096. }
  2097. if (params.has("disablehistory")) {
  2098. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  2099. }
  2100. if (params.has("verbosity")) {
  2101. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("verbosity", params.get("verbosity") | 0);
  2102. }
  2103. if (params.has("textlayer")) {
  2104. switch (params.get("textlayer")) {
  2105. case "off":
  2106. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("textLayerMode", _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.TextLayerMode.DISABLE);
  2107. break;
  2108. case "visible":
  2109. case "shadow":
  2110. case "hover":
  2111. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  2112. try {
  2113. await loadPDFBug(this);
  2114. this._PDFBug.loadCSS();
  2115. } catch (ex) {
  2116. console.error(`_parseHashParams: "${ex.message}".`);
  2117. }
  2118. break;
  2119. }
  2120. }
  2121. if (params.has("pdfbug")) {
  2122. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("pdfBug", true);
  2123. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("fontExtraProperties", true);
  2124. const enabled = params.get("pdfbug").split(",");
  2125. try {
  2126. await loadPDFBug(this);
  2127. this._PDFBug.init(mainContainer, enabled);
  2128. } catch (ex) {
  2129. console.error(`_parseHashParams: "${ex.message}".`);
  2130. }
  2131. }
  2132. if (params.has("locale")) {
  2133. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("locale", params.get("locale"));
  2134. }
  2135. },
  2136. async _initializeViewerComponents() {
  2137. const {
  2138. appConfig,
  2139. externalServices,
  2140. l10n
  2141. } = this;
  2142. const eventBus = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("isInAutomation") ? new _event_utils_js__WEBPACK_IMPORTED_MODULE_3__.AutomationEventBus() : new _event_utils_js__WEBPACK_IMPORTED_MODULE_3__.EventBus();
  2143. this.eventBus = eventBus;
  2144. this.overlayManager = new _overlay_manager_js__WEBPACK_IMPORTED_MODULE_24__.OverlayManager();
  2145. const pdfRenderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_17__.PDFRenderingQueue();
  2146. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  2147. this.pdfRenderingQueue = pdfRenderingQueue;
  2148. const pdfLinkService = new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_4__.PDFLinkService({
  2149. eventBus,
  2150. externalLinkTarget: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkTarget"),
  2151. externalLinkRel: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkRel"),
  2152. ignoreDestinationZoom: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("ignoreDestinationZoom")
  2153. });
  2154. this.pdfLinkService = pdfLinkService;
  2155. const downloadManager = externalServices.createDownloadManager();
  2156. this.downloadManager = downloadManager;
  2157. const findController = new _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_12__.PDFFindController({
  2158. linkService: pdfLinkService,
  2159. eventBus,
  2160. updateMatchesCountOnProgress: true
  2161. });
  2162. this.findController = findController;
  2163. const pdfScriptingManager = new _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_18__.PDFScriptingManager({
  2164. eventBus,
  2165. externalServices,
  2166. docProperties: this._scriptingDocProperties.bind(this)
  2167. });
  2168. this.pdfScriptingManager = pdfScriptingManager;
  2169. const container = appConfig.mainContainer,
  2170. viewer = appConfig.viewerContainer;
  2171. const annotationEditorMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("annotationEditorMode");
  2172. const isOffscreenCanvasSupported = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("isOffscreenCanvasSupported") && pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.FeatureTest.isOffscreenCanvasSupported;
  2173. const pageColors = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  2174. background: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageColorsBackground"),
  2175. foreground: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageColorsForeground")
  2176. } : null;
  2177. const altTextManager = appConfig.altTextDialog ? new web_alt_text_manager__WEBPACK_IMPORTED_MODULE_5__.AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
  2178. const pdfViewer = new _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_21__.PDFViewer({
  2179. container,
  2180. viewer,
  2181. eventBus,
  2182. renderingQueue: pdfRenderingQueue,
  2183. linkService: pdfLinkService,
  2184. downloadManager,
  2185. altTextManager,
  2186. findController,
  2187. scriptingManager: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableScripting") && pdfScriptingManager,
  2188. l10n,
  2189. textLayerMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("textLayerMode"),
  2190. annotationMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("annotationMode"),
  2191. annotationEditorMode,
  2192. annotationEditorHighlightColors: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("highlightEditorColors"),
  2193. imageResourcesPath: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("imageResourcesPath"),
  2194. enablePrintAutoRotate: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePrintAutoRotate"),
  2195. isOffscreenCanvasSupported,
  2196. maxCanvasPixels: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("maxCanvasPixels"),
  2197. enablePermissions: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePermissions"),
  2198. pageColors
  2199. });
  2200. this.pdfViewer = pdfViewer;
  2201. pdfRenderingQueue.setViewer(pdfViewer);
  2202. pdfLinkService.setViewer(pdfViewer);
  2203. pdfScriptingManager.setViewer(pdfViewer);
  2204. if (appConfig.sidebar?.thumbnailView) {
  2205. this.pdfThumbnailViewer = new web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_20__.PDFThumbnailViewer({
  2206. container: appConfig.sidebar.thumbnailView,
  2207. eventBus,
  2208. renderingQueue: pdfRenderingQueue,
  2209. linkService: pdfLinkService,
  2210. pageColors
  2211. });
  2212. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  2213. }
  2214. if (!this.isViewerEmbedded && !_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disableHistory")) {
  2215. this.pdfHistory = new _pdf_history_js__WEBPACK_IMPORTED_MODULE_13__.PDFHistory({
  2216. linkService: pdfLinkService,
  2217. eventBus
  2218. });
  2219. pdfLinkService.setHistory(this.pdfHistory);
  2220. }
  2221. if (!this.supportsIntegratedFind && appConfig.findBar) {
  2222. this.findBar = new web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_11__.PDFFindBar(appConfig.findBar, eventBus);
  2223. }
  2224. if (appConfig.annotationEditorParams) {
  2225. if (annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.DISABLE) {
  2226. if (!isOffscreenCanvasSupported) {
  2227. appConfig.toolbar?.editorStampButton?.classList.add("hidden");
  2228. }
  2229. const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
  2230. if (editorHighlightButton && _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableHighlightEditor")) {
  2231. editorHighlightButton.hidden = false;
  2232. }
  2233. this.annotationEditorParams = new web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_6__.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  2234. } else {
  2235. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  2236. document.getElementById(id)?.classList.add("hidden");
  2237. }
  2238. }
  2239. }
  2240. if (appConfig.documentProperties) {
  2241. this.pdfDocumentProperties = new web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_10__.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
  2242. }
  2243. if (appConfig.secondaryToolbar?.cursorHandToolButton) {
  2244. this.pdfCursorTools = new web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_9__.PDFCursorTools({
  2245. container,
  2246. eventBus,
  2247. cursorToolOnLoad: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("cursorToolOnLoad")
  2248. });
  2249. }
  2250. if (appConfig.toolbar) {
  2251. this.toolbar = new web_toolbar__WEBPACK_IMPORTED_MODULE_23__.Toolbar(appConfig.toolbar, eventBus);
  2252. }
  2253. if (appConfig.secondaryToolbar) {
  2254. this.secondaryToolbar = new web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_22__.SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
  2255. }
  2256. if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
  2257. this.pdfPresentationMode = new web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_16__.PDFPresentationMode({
  2258. container,
  2259. pdfViewer,
  2260. eventBus
  2261. });
  2262. }
  2263. if (appConfig.passwordOverlay) {
  2264. this.passwordPrompt = new _password_prompt_js__WEBPACK_IMPORTED_MODULE_7__.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.isViewerEmbedded);
  2265. }
  2266. if (appConfig.sidebar?.outlineView) {
  2267. this.pdfOutlineViewer = new web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_15__.PDFOutlineViewer({
  2268. container: appConfig.sidebar.outlineView,
  2269. eventBus,
  2270. l10n,
  2271. linkService: pdfLinkService,
  2272. downloadManager
  2273. });
  2274. }
  2275. if (appConfig.sidebar?.attachmentsView) {
  2276. this.pdfAttachmentViewer = new web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_8__.PDFAttachmentViewer({
  2277. container: appConfig.sidebar.attachmentsView,
  2278. eventBus,
  2279. l10n,
  2280. downloadManager
  2281. });
  2282. }
  2283. if (appConfig.sidebar?.layersView) {
  2284. this.pdfLayerViewer = new web_pdf_layer_viewer__WEBPACK_IMPORTED_MODULE_14__.PDFLayerViewer({
  2285. container: appConfig.sidebar.layersView,
  2286. eventBus,
  2287. l10n
  2288. });
  2289. }
  2290. if (appConfig.sidebar) {
  2291. this.pdfSidebar = new web_pdf_sidebar__WEBPACK_IMPORTED_MODULE_19__.PDFSidebar({
  2292. elements: appConfig.sidebar,
  2293. eventBus,
  2294. l10n
  2295. });
  2296. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  2297. this.pdfSidebar.onUpdateThumbnails = () => {
  2298. for (const pageView of pdfViewer.getCachedPageViews()) {
  2299. if (pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  2300. this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
  2301. }
  2302. }
  2303. this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  2304. };
  2305. }
  2306. },
  2307. async run(config) {
  2308. this.preferences = this.externalServices.createPreferences();
  2309. await this.initialize(config);
  2310. const {
  2311. appConfig,
  2312. eventBus
  2313. } = this;
  2314. let file;
  2315. const queryString = document.location.search.substring(1);
  2316. const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(queryString);
  2317. file = params.get("file") ?? _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultUrl");
  2318. validateFileURL(file);
  2319. const fileInput = appConfig.openFileInput;
  2320. fileInput.value = null;
  2321. fileInput.addEventListener("change", function (evt) {
  2322. const {
  2323. files
  2324. } = evt.target;
  2325. if (!files || files.length === 0) {
  2326. return;
  2327. }
  2328. eventBus.dispatch("fileinputchange", {
  2329. source: this,
  2330. fileInput: evt.target
  2331. });
  2332. });
  2333. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2334. evt.preventDefault();
  2335. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  2336. });
  2337. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2338. evt.preventDefault();
  2339. const {
  2340. files
  2341. } = evt.dataTransfer;
  2342. if (!files || files.length === 0) {
  2343. return;
  2344. }
  2345. eventBus.dispatch("fileinputchange", {
  2346. source: this,
  2347. fileInput: evt.dataTransfer
  2348. });
  2349. });
  2350. if (!_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsDocumentFonts")) {
  2351. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableFontFace", true);
  2352. this.l10n.get("pdfjs-web-fonts-disabled").then(msg => {
  2353. console.warn(msg);
  2354. });
  2355. }
  2356. if (!this.supportsPrinting) {
  2357. appConfig.toolbar?.print?.classList.add("hidden");
  2358. appConfig.secondaryToolbar?.printButton.classList.add("hidden");
  2359. }
  2360. if (!this.supportsFullscreen) {
  2361. appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
  2362. }
  2363. if (this.supportsIntegratedFind) {
  2364. appConfig.toolbar?.viewFind?.classList.add("hidden");
  2365. }
  2366. if (file) {
  2367. this.open({
  2368. url: file
  2369. });
  2370. } else {
  2371. this._hideViewBookmark();
  2372. }
  2373. },
  2374. get initialized() {
  2375. return this._initializedCapability.settled;
  2376. },
  2377. get initializedPromise() {
  2378. return this._initializedCapability.promise;
  2379. },
  2380. zoomIn(steps, scaleFactor) {
  2381. if (this.pdfViewer.isInPresentationMode) {
  2382. return;
  2383. }
  2384. this.pdfViewer.increaseScale({
  2385. drawingDelay: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomDelay"),
  2386. steps,
  2387. scaleFactor
  2388. });
  2389. },
  2390. zoomOut(steps, scaleFactor) {
  2391. if (this.pdfViewer.isInPresentationMode) {
  2392. return;
  2393. }
  2394. this.pdfViewer.decreaseScale({
  2395. drawingDelay: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomDelay"),
  2396. steps,
  2397. scaleFactor
  2398. });
  2399. },
  2400. zoomReset() {
  2401. if (this.pdfViewer.isInPresentationMode) {
  2402. return;
  2403. }
  2404. this.pdfViewer.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE;
  2405. },
  2406. get pagesCount() {
  2407. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  2408. },
  2409. get page() {
  2410. return this.pdfViewer.currentPageNumber;
  2411. },
  2412. set page(val) {
  2413. this.pdfViewer.currentPageNumber = val;
  2414. },
  2415. get supportsPrinting() {
  2416. return PDFPrintServiceFactory.instance.supportsPrinting;
  2417. },
  2418. get supportsFullscreen() {
  2419. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  2420. },
  2421. get supportsPinchToZoom() {
  2422. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsPinchToZoom", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsPinchToZoom"));
  2423. },
  2424. get supportsIntegratedFind() {
  2425. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsIntegratedFind", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsIntegratedFind"));
  2426. },
  2427. get loadingBar() {
  2428. const barElement = document.getElementById("loadingBar");
  2429. const bar = barElement ? new _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ProgressBar(barElement) : null;
  2430. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "loadingBar", bar);
  2431. },
  2432. get supportsMouseWheelZoomCtrlKey() {
  2433. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsMouseWheelZoomCtrlKey", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsMouseWheelZoomCtrlKey"));
  2434. },
  2435. get supportsMouseWheelZoomMetaKey() {
  2436. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsMouseWheelZoomMetaKey", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsMouseWheelZoomMetaKey"));
  2437. },
  2438. initPassiveLoading(file) {
  2439. throw new Error("Not implemented: initPassiveLoading");
  2440. },
  2441. setTitleUsingUrl(url = "", downloadUrl = null) {
  2442. this.url = url;
  2443. this.baseUrl = url.split("#", 1)[0];
  2444. if (downloadUrl) {
  2445. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0];
  2446. }
  2447. if ((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.isDataScheme)(url)) {
  2448. this._hideViewBookmark();
  2449. }
  2450. let title = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getPdfFilenameFromUrl)(url, "");
  2451. if (!title) {
  2452. try {
  2453. title = decodeURIComponent((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getFilenameFromUrl)(url)) || url;
  2454. } catch {
  2455. title = url;
  2456. }
  2457. }
  2458. this.setTitle(title);
  2459. },
  2460. setTitle(title = this._title) {
  2461. this._title = title;
  2462. if (this.isViewerEmbedded) {
  2463. return;
  2464. }
  2465. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  2466. document.title = `${editorIndicator ? "* " : ""}${title}`;
  2467. },
  2468. get _docFilename() {
  2469. return this._contentDispositionFilename || (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getPdfFilenameFromUrl)(this.url);
  2470. },
  2471. _hideViewBookmark() {
  2472. const {
  2473. secondaryToolbar
  2474. } = this.appConfig;
  2475. secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
  2476. if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
  2477. document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
  2478. }
  2479. },
  2480. async close() {
  2481. this._unblockDocumentLoadEvent();
  2482. this._hideViewBookmark();
  2483. if (!this.pdfLoadingTask) {
  2484. return;
  2485. }
  2486. if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
  2487. try {
  2488. await this.save();
  2489. } catch {}
  2490. }
  2491. const promises = [];
  2492. promises.push(this.pdfLoadingTask.destroy());
  2493. this.pdfLoadingTask = null;
  2494. if (this.pdfDocument) {
  2495. this.pdfDocument = null;
  2496. this.pdfThumbnailViewer?.setDocument(null);
  2497. this.pdfViewer.setDocument(null);
  2498. this.pdfLinkService.setDocument(null);
  2499. this.pdfDocumentProperties?.setDocument(null);
  2500. }
  2501. this.pdfLinkService.externalLinkEnabled = true;
  2502. this.store = null;
  2503. this.isInitialViewSet = false;
  2504. this.downloadComplete = false;
  2505. this.url = "";
  2506. this.baseUrl = "";
  2507. this._downloadUrl = "";
  2508. this.documentInfo = null;
  2509. this.metadata = null;
  2510. this._contentDispositionFilename = null;
  2511. this._contentLength = null;
  2512. this._saveInProgress = false;
  2513. this._hasAnnotationEditors = false;
  2514. promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
  2515. this.setTitle();
  2516. this.pdfSidebar?.reset();
  2517. this.pdfOutlineViewer?.reset();
  2518. this.pdfAttachmentViewer?.reset();
  2519. this.pdfLayerViewer?.reset();
  2520. this.pdfHistory?.reset();
  2521. this.findBar?.reset();
  2522. this.toolbar?.reset();
  2523. this.secondaryToolbar?.reset();
  2524. this._PDFBug?.cleanup();
  2525. await Promise.all(promises);
  2526. },
  2527. async open(args) {
  2528. if (this.pdfLoadingTask) {
  2529. await this.close();
  2530. }
  2531. const workerParams = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.getAll(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.OptionKind.WORKER);
  2532. Object.assign(pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions, workerParams);
  2533. if (args.url) {
  2534. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  2535. }
  2536. const apiParams = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.getAll(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.OptionKind.API);
  2537. const loadingTask = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getDocument)({
  2538. ...apiParams,
  2539. ...args
  2540. });
  2541. this.pdfLoadingTask = loadingTask;
  2542. loadingTask.onPassword = (updateCallback, reason) => {
  2543. if (this.isViewerEmbedded) {
  2544. this._unblockDocumentLoadEvent();
  2545. }
  2546. this.pdfLinkService.externalLinkEnabled = false;
  2547. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2548. this.passwordPrompt.open();
  2549. };
  2550. loadingTask.onProgress = ({
  2551. loaded,
  2552. total
  2553. }) => {
  2554. this.progress(loaded / total);
  2555. };
  2556. return loadingTask.promise.then(pdfDocument => {
  2557. this.load(pdfDocument);
  2558. }, reason => {
  2559. if (loadingTask !== this.pdfLoadingTask) {
  2560. return undefined;
  2561. }
  2562. let key = "pdfjs-loading-error";
  2563. if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.InvalidPDFException) {
  2564. key = "pdfjs-invalid-file-error";
  2565. } else if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.MissingPDFException) {
  2566. key = "pdfjs-missing-file-error";
  2567. } else if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.UnexpectedResponseException) {
  2568. key = "pdfjs-unexpected-response-error";
  2569. }
  2570. return this.l10n.get(key).then(msg => {
  2571. this._documentError(msg, {
  2572. message: reason?.message
  2573. });
  2574. throw reason;
  2575. });
  2576. });
  2577. },
  2578. _ensureDownloadComplete() {
  2579. if (this.pdfDocument && this.downloadComplete) {
  2580. return;
  2581. }
  2582. throw new Error("PDF document not downloaded.");
  2583. },
  2584. async download(options = {}) {
  2585. const url = this._downloadUrl,
  2586. filename = this._docFilename;
  2587. try {
  2588. this._ensureDownloadComplete();
  2589. const data = await this.pdfDocument.getData();
  2590. const blob = new Blob([data], {
  2591. type: "application/pdf"
  2592. });
  2593. await this.downloadManager.download(blob, url, filename, options);
  2594. } catch {
  2595. await this.downloadManager.downloadUrl(url, filename, options);
  2596. }
  2597. },
  2598. async save(options = {}) {
  2599. if (this._saveInProgress) {
  2600. return;
  2601. }
  2602. this._saveInProgress = true;
  2603. await this.pdfScriptingManager.dispatchWillSave();
  2604. const url = this._downloadUrl,
  2605. filename = this._docFilename;
  2606. try {
  2607. this._ensureDownloadComplete();
  2608. const data = await this.pdfDocument.saveDocument();
  2609. const blob = new Blob([data], {
  2610. type: "application/pdf"
  2611. });
  2612. await this.downloadManager.download(blob, url, filename, options);
  2613. } catch (reason) {
  2614. console.error(`Error when saving the document: ${reason.message}`);
  2615. await this.download(options);
  2616. } finally {
  2617. await this.pdfScriptingManager.dispatchDidSave();
  2618. this._saveInProgress = false;
  2619. }
  2620. if (this._hasAnnotationEditors) {
  2621. this.externalServices.reportTelemetry({
  2622. type: "editing",
  2623. data: {
  2624. type: "save"
  2625. }
  2626. });
  2627. }
  2628. },
  2629. downloadOrSave(options = {}) {
  2630. if (this.pdfDocument?.annotationStorage.size > 0) {
  2631. this.save(options);
  2632. } else {
  2633. this.download(options);
  2634. }
  2635. },
  2636. openInExternalApp() {
  2637. this.downloadOrSave({
  2638. openInExternalApp: true
  2639. });
  2640. },
  2641. _documentError(message, moreInfo = null) {
  2642. this._unblockDocumentLoadEvent();
  2643. this._otherError(message, moreInfo);
  2644. this.eventBus.dispatch("documenterror", {
  2645. source: this,
  2646. message,
  2647. reason: moreInfo?.message ?? null
  2648. });
  2649. },
  2650. _otherError(message, moreInfo = null) {
  2651. const moreInfoText = [`PDF.js v${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} (build: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"})`];
  2652. if (moreInfo) {
  2653. moreInfoText.push(`Message: ${moreInfo.message}`);
  2654. if (moreInfo.stack) {
  2655. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  2656. } else {
  2657. if (moreInfo.filename) {
  2658. moreInfoText.push(`File: ${moreInfo.filename}`);
  2659. }
  2660. if (moreInfo.lineNumber) {
  2661. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  2662. }
  2663. }
  2664. }
  2665. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  2666. },
  2667. progress(level) {
  2668. if (!this.loadingBar || this.downloadComplete) {
  2669. return;
  2670. }
  2671. const percent = Math.round(level * 100);
  2672. if (percent <= this.loadingBar.percent) {
  2673. return;
  2674. }
  2675. this.loadingBar.percent = percent;
  2676. if (this.pdfDocument?.loadingParams.disableAutoFetch ?? _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disableAutoFetch")) {
  2677. this.loadingBar.setDisableAutoFetch();
  2678. }
  2679. },
  2680. load(pdfDocument) {
  2681. this.pdfDocument = pdfDocument;
  2682. pdfDocument.getDownloadInfo().then(({
  2683. length
  2684. }) => {
  2685. this._contentLength = length;
  2686. this.downloadComplete = true;
  2687. this.loadingBar?.hide();
  2688. firstPagePromise.then(() => {
  2689. this.eventBus.dispatch("documentloaded", {
  2690. source: this
  2691. });
  2692. });
  2693. });
  2694. const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
  2695. const pageModePromise = pdfDocument.getPageMode().catch(() => {});
  2696. const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
  2697. this.toolbar?.setPagesCount(pdfDocument.numPages, false);
  2698. this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
  2699. this.pdfLinkService.setDocument(pdfDocument);
  2700. this.pdfDocumentProperties?.setDocument(pdfDocument);
  2701. const pdfViewer = this.pdfViewer;
  2702. pdfViewer.setDocument(pdfDocument);
  2703. const {
  2704. firstPagePromise,
  2705. onePageRendered,
  2706. pagesPromise
  2707. } = pdfViewer;
  2708. this.pdfThumbnailViewer?.setDocument(pdfDocument);
  2709. const storedPromise = (this.store = new _view_history_js__WEBPACK_IMPORTED_MODULE_25__.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  2710. page: null,
  2711. zoom: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE,
  2712. scrollLeft: "0",
  2713. scrollTop: "0",
  2714. rotation: null,
  2715. sidebarView: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN,
  2716. scrollMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN,
  2717. spreadMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN
  2718. }).catch(() => {});
  2719. firstPagePromise.then(pdfPage => {
  2720. this.loadingBar?.setWidth(this.appConfig.viewerContainer);
  2721. this._initializeAnnotationStorageCallbacks(pdfDocument);
  2722. Promise.all([_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => {
  2723. const viewOnLoad = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("viewOnLoad");
  2724. this._initializePdfHistory({
  2725. fingerprint: pdfDocument.fingerprints[0],
  2726. viewOnLoad,
  2727. initialDest: openAction?.dest
  2728. });
  2729. const initialBookmark = this.initialBookmark;
  2730. const zoom = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomValue");
  2731. let hash = zoom ? `zoom=${zoom}` : null;
  2732. let rotation = null;
  2733. let sidebarView = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("sidebarViewOnLoad");
  2734. let scrollMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("scrollModeOnLoad");
  2735. let spreadMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("spreadModeOnLoad");
  2736. if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  2737. hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  2738. rotation = parseInt(stored.rotation, 10);
  2739. if (sidebarView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
  2740. sidebarView = stored.sidebarView | 0;
  2741. }
  2742. if (scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN) {
  2743. scrollMode = stored.scrollMode | 0;
  2744. }
  2745. if (spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN) {
  2746. spreadMode = stored.spreadMode | 0;
  2747. }
  2748. }
  2749. if (pageMode && sidebarView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
  2750. sidebarView = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageModeToSidebarView)(pageMode);
  2751. }
  2752. if (pageLayout && scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN && spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN) {
  2753. const modes = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageLayoutToViewerModes)(pageLayout);
  2754. spreadMode = modes.spreadMode;
  2755. }
  2756. this.setInitialView(hash, {
  2757. rotation,
  2758. sidebarView,
  2759. scrollMode,
  2760. spreadMode
  2761. });
  2762. this.eventBus.dispatch("documentinit", {
  2763. source: this
  2764. });
  2765. if (!this.isViewerEmbedded) {
  2766. pdfViewer.focus();
  2767. }
  2768. await Promise.race([pagesPromise, new Promise(resolve => {
  2769. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  2770. })]);
  2771. if (!initialBookmark && !hash) {
  2772. return;
  2773. }
  2774. if (pdfViewer.hasEqualPageSizes) {
  2775. return;
  2776. }
  2777. this.initialBookmark = initialBookmark;
  2778. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  2779. this.setInitialView(hash);
  2780. }).catch(() => {
  2781. this.setInitialView();
  2782. }).then(function () {
  2783. pdfViewer.update();
  2784. });
  2785. });
  2786. pagesPromise.then(() => {
  2787. this._unblockDocumentLoadEvent();
  2788. this._initializeAutoPrint(pdfDocument, openActionPromise);
  2789. }, reason => {
  2790. this.l10n.get("pdfjs-loading-error").then(msg => {
  2791. this._documentError(msg, {
  2792. message: reason?.message
  2793. });
  2794. });
  2795. });
  2796. onePageRendered.then(data => {
  2797. this.externalServices.reportTelemetry({
  2798. type: "pageInfo",
  2799. timestamp: data.timestamp
  2800. });
  2801. if (this.pdfOutlineViewer) {
  2802. pdfDocument.getOutline().then(outline => {
  2803. if (pdfDocument !== this.pdfDocument) {
  2804. return;
  2805. }
  2806. this.pdfOutlineViewer.render({
  2807. outline,
  2808. pdfDocument
  2809. });
  2810. });
  2811. }
  2812. if (this.pdfAttachmentViewer) {
  2813. pdfDocument.getAttachments().then(attachments => {
  2814. if (pdfDocument !== this.pdfDocument) {
  2815. return;
  2816. }
  2817. this.pdfAttachmentViewer.render({
  2818. attachments
  2819. });
  2820. });
  2821. }
  2822. if (this.pdfLayerViewer) {
  2823. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  2824. if (pdfDocument !== this.pdfDocument) {
  2825. return;
  2826. }
  2827. this.pdfLayerViewer.render({
  2828. optionalContentConfig,
  2829. pdfDocument
  2830. });
  2831. });
  2832. }
  2833. });
  2834. this._initializePageLabels(pdfDocument);
  2835. this._initializeMetadata(pdfDocument);
  2836. },
  2837. async _scriptingDocProperties(pdfDocument) {
  2838. if (!this.documentInfo) {
  2839. await new Promise(resolve => {
  2840. this.eventBus._on("metadataloaded", resolve, {
  2841. once: true
  2842. });
  2843. });
  2844. if (pdfDocument !== this.pdfDocument) {
  2845. return null;
  2846. }
  2847. }
  2848. if (!this._contentLength) {
  2849. await new Promise(resolve => {
  2850. this.eventBus._on("documentloaded", resolve, {
  2851. once: true
  2852. });
  2853. });
  2854. if (pdfDocument !== this.pdfDocument) {
  2855. return null;
  2856. }
  2857. }
  2858. return {
  2859. ...this.documentInfo,
  2860. baseURL: this.baseUrl,
  2861. filesize: this._contentLength,
  2862. filename: this._docFilename,
  2863. metadata: this.metadata?.getRaw(),
  2864. authors: this.metadata?.get("dc:creator"),
  2865. numPages: this.pagesCount,
  2866. URL: this.url
  2867. };
  2868. },
  2869. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  2870. const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]);
  2871. if (pdfDocument !== this.pdfDocument) {
  2872. return;
  2873. }
  2874. let triggerAutoPrint = openAction?.action === "Print";
  2875. if (jsActions) {
  2876. console.warn("Warning: JavaScript support is not enabled");
  2877. for (const name in jsActions) {
  2878. if (triggerAutoPrint) {
  2879. break;
  2880. }
  2881. switch (name) {
  2882. case "WillClose":
  2883. case "WillSave":
  2884. case "DidSave":
  2885. case "WillPrint":
  2886. case "DidPrint":
  2887. continue;
  2888. }
  2889. triggerAutoPrint = jsActions[name].some(js => _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.AutoPrintRegExp.test(js));
  2890. }
  2891. }
  2892. if (triggerAutoPrint) {
  2893. this.triggerPrinting();
  2894. }
  2895. },
  2896. async _initializeMetadata(pdfDocument) {
  2897. const {
  2898. info,
  2899. metadata,
  2900. contentDispositionFilename,
  2901. contentLength
  2902. } = await pdfDocument.getMetadata();
  2903. if (pdfDocument !== this.pdfDocument) {
  2904. return;
  2905. }
  2906. this.documentInfo = info;
  2907. this.metadata = metadata;
  2908. this._contentDispositionFilename ??= contentDispositionFilename;
  2909. this._contentLength ??= contentLength;
  2910. console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} [${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"}])`);
  2911. let pdfTitle = info.Title;
  2912. const metadataTitle = metadata?.get("dc:title");
  2913. if (metadataTitle) {
  2914. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2915. pdfTitle = metadataTitle;
  2916. }
  2917. }
  2918. if (pdfTitle) {
  2919. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  2920. } else if (this._contentDispositionFilename) {
  2921. this.setTitle(this._contentDispositionFilename);
  2922. }
  2923. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  2924. if (pdfDocument.loadingParams.enableXfa) {
  2925. console.warn("Warning: XFA Foreground documents are not supported");
  2926. } else {
  2927. console.warn("Warning: XFA support is not enabled");
  2928. }
  2929. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  2930. console.warn("Warning: Interactive form support is not enabled");
  2931. }
  2932. if (info.IsSignaturesPresent) {
  2933. console.warn("Warning: Digital signatures validation is not supported");
  2934. }
  2935. this.eventBus.dispatch("metadataloaded", {
  2936. source: this
  2937. });
  2938. },
  2939. async _initializePageLabels(pdfDocument) {
  2940. const labels = await pdfDocument.getPageLabels();
  2941. if (pdfDocument !== this.pdfDocument) {
  2942. return;
  2943. }
  2944. if (!labels || _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disablePageLabels")) {
  2945. return;
  2946. }
  2947. const numLabels = labels.length;
  2948. let standardLabels = 0,
  2949. emptyLabels = 0;
  2950. for (let i = 0; i < numLabels; i++) {
  2951. const label = labels[i];
  2952. if (label === (i + 1).toString()) {
  2953. standardLabels++;
  2954. } else if (label === "") {
  2955. emptyLabels++;
  2956. } else {
  2957. break;
  2958. }
  2959. }
  2960. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  2961. return;
  2962. }
  2963. const {
  2964. pdfViewer,
  2965. pdfThumbnailViewer,
  2966. toolbar
  2967. } = this;
  2968. pdfViewer.setPageLabels(labels);
  2969. pdfThumbnailViewer?.setPageLabels(labels);
  2970. toolbar?.setPagesCount(numLabels, true);
  2971. toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2972. },
  2973. _initializePdfHistory({
  2974. fingerprint,
  2975. viewOnLoad,
  2976. initialDest = null
  2977. }) {
  2978. if (!this.pdfHistory) {
  2979. return;
  2980. }
  2981. this.pdfHistory.initialize({
  2982. fingerprint,
  2983. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2984. updateUrl: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("historyUpdateUrl")
  2985. });
  2986. if (this.pdfHistory.initialBookmark) {
  2987. this.initialBookmark = this.pdfHistory.initialBookmark;
  2988. this.initialRotation = this.pdfHistory.initialRotation;
  2989. }
  2990. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2991. this.initialBookmark = JSON.stringify(initialDest);
  2992. this.pdfHistory.push({
  2993. explicitDest: initialDest,
  2994. pageNumber: null
  2995. });
  2996. }
  2997. },
  2998. _initializeAnnotationStorageCallbacks(pdfDocument) {
  2999. if (pdfDocument !== this.pdfDocument) {
  3000. return;
  3001. }
  3002. const {
  3003. annotationStorage
  3004. } = pdfDocument;
  3005. annotationStorage.onSetModified = () => {
  3006. window.addEventListener("beforeunload", beforeUnload);
  3007. this._annotationStorageModified = true;
  3008. };
  3009. annotationStorage.onResetModified = () => {
  3010. window.removeEventListener("beforeunload", beforeUnload);
  3011. delete this._annotationStorageModified;
  3012. };
  3013. annotationStorage.onAnnotationEditor = typeStr => {
  3014. this._hasAnnotationEditors = !!typeStr;
  3015. this.setTitle();
  3016. if (typeStr) {
  3017. this.externalServices.reportTelemetry({
  3018. type: "editing",
  3019. data: {
  3020. type: typeStr
  3021. }
  3022. });
  3023. }
  3024. };
  3025. },
  3026. setInitialView(storedHash, {
  3027. rotation,
  3028. sidebarView,
  3029. scrollMode,
  3030. spreadMode
  3031. } = {}) {
  3032. const setRotation = angle => {
  3033. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(angle)) {
  3034. this.pdfViewer.pagesRotation = angle;
  3035. }
  3036. };
  3037. const setViewerModes = (scroll, spread) => {
  3038. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidScrollMode)(scroll)) {
  3039. this.pdfViewer.scrollMode = scroll;
  3040. }
  3041. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidSpreadMode)(spread)) {
  3042. this.pdfViewer.spreadMode = spread;
  3043. }
  3044. };
  3045. this.isInitialViewSet = true;
  3046. this.pdfSidebar?.setInitialView(sidebarView);
  3047. setViewerModes(scrollMode, spreadMode);
  3048. if (this.initialBookmark) {
  3049. setRotation(this.initialRotation);
  3050. delete this.initialRotation;
  3051. this.pdfLinkService.setHash(this.initialBookmark);
  3052. this.initialBookmark = null;
  3053. } else if (storedHash) {
  3054. setRotation(rotation);
  3055. this.pdfLinkService.setHash(storedHash);
  3056. }
  3057. this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  3058. this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
  3059. if (!this.pdfViewer.currentScaleValue) {
  3060. this.pdfViewer.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE;
  3061. }
  3062. },
  3063. _cleanup() {
  3064. if (!this.pdfDocument) {
  3065. return;
  3066. }
  3067. this.pdfViewer.cleanup();
  3068. this.pdfThumbnailViewer?.cleanup();
  3069. this.pdfDocument.cleanup(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("fontExtraProperties"));
  3070. },
  3071. forceRendering() {
  3072. this.pdfRenderingQueue.printing = !!this.printService;
  3073. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  3074. this.pdfRenderingQueue.renderHighestPriority();
  3075. },
  3076. beforePrint() {
  3077. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => {
  3078. return this.pdfDocument?.annotationStorage.print;
  3079. });
  3080. if (this.printService) {
  3081. return;
  3082. }
  3083. if (!this.supportsPrinting) {
  3084. this.l10n.get("pdfjs-printing-not-supported").then(msg => {
  3085. this._otherError(msg);
  3086. });
  3087. return;
  3088. }
  3089. if (!this.pdfViewer.pageViewsReady) {
  3090. this.l10n.get("pdfjs-printing-not-ready").then(msg => {
  3091. window.alert(msg);
  3092. });
  3093. return;
  3094. }
  3095. const pagesOverview = this.pdfViewer.getPagesOverview();
  3096. const printContainer = this.appConfig.printContainer;
  3097. const printResolution = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("printResolution");
  3098. const optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  3099. const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this._printAnnotationStoragePromise);
  3100. this.printService = printService;
  3101. this.forceRendering();
  3102. this.setTitle();
  3103. printService.layout();
  3104. if (this._hasAnnotationEditors) {
  3105. this.externalServices.reportTelemetry({
  3106. type: "editing",
  3107. data: {
  3108. type: "print"
  3109. }
  3110. });
  3111. }
  3112. },
  3113. afterPrint() {
  3114. if (this._printAnnotationStoragePromise) {
  3115. this._printAnnotationStoragePromise.then(() => {
  3116. this.pdfScriptingManager.dispatchDidPrint();
  3117. });
  3118. this._printAnnotationStoragePromise = null;
  3119. }
  3120. if (this.printService) {
  3121. this.printService.destroy();
  3122. this.printService = null;
  3123. this.pdfDocument?.annotationStorage.resetModified();
  3124. }
  3125. this.forceRendering();
  3126. this.setTitle();
  3127. },
  3128. rotatePages(delta) {
  3129. this.pdfViewer.pagesRotation += delta;
  3130. },
  3131. requestPresentationMode() {
  3132. this.pdfPresentationMode?.request();
  3133. },
  3134. triggerPrinting() {
  3135. if (!this.supportsPrinting) {
  3136. return;
  3137. }
  3138. window.print();
  3139. },
  3140. bindEvents() {
  3141. const {
  3142. eventBus,
  3143. _boundEvents
  3144. } = this;
  3145. _boundEvents.beforePrint = this.beforePrint.bind(this);
  3146. _boundEvents.afterPrint = this.afterPrint.bind(this);
  3147. eventBus._on("resize", webViewerResize);
  3148. eventBus._on("hashchange", webViewerHashchange);
  3149. eventBus._on("beforeprint", _boundEvents.beforePrint);
  3150. eventBus._on("afterprint", _boundEvents.afterPrint);
  3151. eventBus._on("pagerender", webViewerPageRender);
  3152. eventBus._on("pagerendered", webViewerPageRendered);
  3153. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  3154. eventBus._on("pagechanging", webViewerPageChanging);
  3155. eventBus._on("scalechanging", webViewerScaleChanging);
  3156. eventBus._on("rotationchanging", webViewerRotationChanging);
  3157. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  3158. eventBus._on("pagemode", webViewerPageMode);
  3159. eventBus._on("namedaction", webViewerNamedAction);
  3160. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  3161. eventBus._on("presentationmode", webViewerPresentationMode);
  3162. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode);
  3163. eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams);
  3164. eventBus._on("print", webViewerPrint);
  3165. eventBus._on("download", webViewerDownload);
  3166. eventBus._on("openinexternalapp", webViewerOpenInExternalApp);
  3167. eventBus._on("firstpage", webViewerFirstPage);
  3168. eventBus._on("lastpage", webViewerLastPage);
  3169. eventBus._on("nextpage", webViewerNextPage);
  3170. eventBus._on("previouspage", webViewerPreviousPage);
  3171. eventBus._on("zoomin", webViewerZoomIn);
  3172. eventBus._on("zoomout", webViewerZoomOut);
  3173. eventBus._on("zoomreset", webViewerZoomReset);
  3174. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  3175. eventBus._on("scalechanged", webViewerScaleChanged);
  3176. eventBus._on("rotatecw", webViewerRotateCw);
  3177. eventBus._on("rotateccw", webViewerRotateCcw);
  3178. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  3179. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  3180. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  3181. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  3182. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  3183. eventBus._on("documentproperties", webViewerDocumentProperties);
  3184. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  3185. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  3186. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  3187. if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pdfBug")) {
  3188. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  3189. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  3190. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  3191. }
  3192. eventBus._on("fileinputchange", webViewerFileInputChange);
  3193. eventBus._on("openfile", webViewerOpenFile);
  3194. },
  3195. bindWindowEvents() {
  3196. const {
  3197. eventBus,
  3198. _boundEvents
  3199. } = this;
  3200. function addWindowResolutionChange(evt = null) {
  3201. if (evt) {
  3202. webViewerResolutionChange(evt);
  3203. }
  3204. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  3205. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  3206. once: true
  3207. });
  3208. _boundEvents.removeWindowResolutionChange ||= function () {
  3209. mediaQueryList.removeEventListener("change", addWindowResolutionChange);
  3210. _boundEvents.removeWindowResolutionChange = null;
  3211. };
  3212. }
  3213. addWindowResolutionChange();
  3214. _boundEvents.windowResize = () => {
  3215. eventBus.dispatch("resize", {
  3216. source: window
  3217. });
  3218. };
  3219. _boundEvents.windowHashChange = () => {
  3220. eventBus.dispatch("hashchange", {
  3221. source: window,
  3222. hash: document.location.hash.substring(1)
  3223. });
  3224. };
  3225. _boundEvents.windowBeforePrint = () => {
  3226. eventBus.dispatch("beforeprint", {
  3227. source: window
  3228. });
  3229. };
  3230. _boundEvents.windowAfterPrint = () => {
  3231. eventBus.dispatch("afterprint", {
  3232. source: window
  3233. });
  3234. };
  3235. _boundEvents.windowUpdateFromSandbox = event => {
  3236. eventBus.dispatch("updatefromsandbox", {
  3237. source: window,
  3238. detail: event.detail
  3239. });
  3240. };
  3241. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  3242. window.addEventListener("wheel", webViewerWheel, {
  3243. passive: false
  3244. });
  3245. window.addEventListener("touchstart", webViewerTouchStart, {
  3246. passive: false
  3247. });
  3248. window.addEventListener("touchmove", webViewerTouchMove, {
  3249. passive: false
  3250. });
  3251. window.addEventListener("touchend", webViewerTouchEnd, {
  3252. passive: false
  3253. });
  3254. window.addEventListener("click", webViewerClick);
  3255. window.addEventListener("keydown", webViewerKeyDown);
  3256. window.addEventListener("keyup", webViewerKeyUp);
  3257. window.addEventListener("resize", _boundEvents.windowResize);
  3258. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  3259. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  3260. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  3261. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  3262. },
  3263. unbindEvents() {
  3264. const {
  3265. eventBus,
  3266. _boundEvents
  3267. } = this;
  3268. eventBus._off("resize", webViewerResize);
  3269. eventBus._off("hashchange", webViewerHashchange);
  3270. eventBus._off("beforeprint", _boundEvents.beforePrint);
  3271. eventBus._off("afterprint", _boundEvents.afterPrint);
  3272. eventBus._off("pagerender", webViewerPageRender);
  3273. eventBus._off("pagerendered", webViewerPageRendered);
  3274. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  3275. eventBus._off("pagechanging", webViewerPageChanging);
  3276. eventBus._off("scalechanging", webViewerScaleChanging);
  3277. eventBus._off("rotationchanging", webViewerRotationChanging);
  3278. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  3279. eventBus._off("pagemode", webViewerPageMode);
  3280. eventBus._off("namedaction", webViewerNamedAction);
  3281. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  3282. eventBus._off("presentationmode", webViewerPresentationMode);
  3283. eventBus._off("print", webViewerPrint);
  3284. eventBus._off("download", webViewerDownload);
  3285. eventBus._off("openinexternalapp", webViewerOpenInExternalApp);
  3286. eventBus._off("firstpage", webViewerFirstPage);
  3287. eventBus._off("lastpage", webViewerLastPage);
  3288. eventBus._off("nextpage", webViewerNextPage);
  3289. eventBus._off("previouspage", webViewerPreviousPage);
  3290. eventBus._off("zoomin", webViewerZoomIn);
  3291. eventBus._off("zoomout", webViewerZoomOut);
  3292. eventBus._off("zoomreset", webViewerZoomReset);
  3293. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  3294. eventBus._off("scalechanged", webViewerScaleChanged);
  3295. eventBus._off("rotatecw", webViewerRotateCw);
  3296. eventBus._off("rotateccw", webViewerRotateCcw);
  3297. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  3298. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  3299. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  3300. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  3301. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  3302. eventBus._off("documentproperties", webViewerDocumentProperties);
  3303. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  3304. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  3305. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  3306. if (_boundEvents.reportPageStatsPDFBug) {
  3307. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  3308. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  3309. _boundEvents.reportPageStatsPDFBug = null;
  3310. }
  3311. eventBus._off("fileinputchange", webViewerFileInputChange);
  3312. eventBus._off("openfile", webViewerOpenFile);
  3313. _boundEvents.beforePrint = null;
  3314. _boundEvents.afterPrint = null;
  3315. },
  3316. unbindWindowEvents() {
  3317. const {
  3318. _boundEvents
  3319. } = this;
  3320. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  3321. window.removeEventListener("wheel", webViewerWheel, {
  3322. passive: false
  3323. });
  3324. window.removeEventListener("touchstart", webViewerTouchStart, {
  3325. passive: false
  3326. });
  3327. window.removeEventListener("touchmove", webViewerTouchMove, {
  3328. passive: false
  3329. });
  3330. window.removeEventListener("touchend", webViewerTouchEnd, {
  3331. passive: false
  3332. });
  3333. window.removeEventListener("click", webViewerClick);
  3334. window.removeEventListener("keydown", webViewerKeyDown);
  3335. window.removeEventListener("keyup", webViewerKeyUp);
  3336. window.removeEventListener("resize", _boundEvents.windowResize);
  3337. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  3338. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  3339. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  3340. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  3341. _boundEvents.removeWindowResolutionChange?.();
  3342. _boundEvents.windowResize = null;
  3343. _boundEvents.windowHashChange = null;
  3344. _boundEvents.windowBeforePrint = null;
  3345. _boundEvents.windowAfterPrint = null;
  3346. _boundEvents.windowUpdateFromSandbox = null;
  3347. },
  3348. _accumulateTicks(ticks, prop) {
  3349. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  3350. this[prop] = 0;
  3351. }
  3352. this[prop] += ticks;
  3353. const wholeTicks = Math.trunc(this[prop]);
  3354. this[prop] -= wholeTicks;
  3355. return wholeTicks;
  3356. },
  3357. _accumulateFactor(previousScale, factor, prop) {
  3358. if (factor === 1) {
  3359. return 1;
  3360. }
  3361. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  3362. this[prop] = 1;
  3363. }
  3364. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  3365. this[prop] = factor / newFactor;
  3366. return newFactor;
  3367. },
  3368. _centerAtPos(previousScale, x, y) {
  3369. const {
  3370. pdfViewer
  3371. } = this;
  3372. const scaleDiff = pdfViewer.currentScale / previousScale - 1;
  3373. if (scaleDiff !== 0) {
  3374. const [top, left] = pdfViewer.containerTopLeft;
  3375. pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
  3376. pdfViewer.container.scrollTop += (y - top) * scaleDiff;
  3377. }
  3378. },
  3379. _unblockDocumentLoadEvent() {
  3380. document.blockUnblockOnload?.(false);
  3381. this._unblockDocumentLoadEvent = () => {};
  3382. },
  3383. get scriptingReady() {
  3384. return this.pdfScriptingManager.ready;
  3385. }
  3386. };
  3387. {
  3388. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  3389. var validateFileURL = function (file) {
  3390. if (!file) {
  3391. return;
  3392. }
  3393. try {
  3394. const viewerOrigin = new URL(window.location.href).origin || "null";
  3395. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  3396. return;
  3397. }
  3398. const fileOrigin = new URL(file, window.location.href).origin;
  3399. if (fileOrigin !== viewerOrigin) {
  3400. throw new Error("file origin does not match viewer's");
  3401. }
  3402. } catch (ex) {
  3403. PDFViewerApplication.l10n.get("pdfjs-loading-error").then(msg => {
  3404. PDFViewerApplication._documentError(msg, {
  3405. message: ex?.message
  3406. });
  3407. });
  3408. throw ex;
  3409. }
  3410. };
  3411. }
  3412. async function loadFakeWorker() {
  3413. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions.workerSrc ||= _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("workerSrc");
  3414. await import(/* webpackIgnore: true */ pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PDFWorker.workerSrc);
  3415. }
  3416. async function loadPDFBug(self) {
  3417. const {
  3418. debuggerScriptPath
  3419. } = self.appConfig;
  3420. const {
  3421. PDFBug
  3422. } = await import(/* webpackIgnore: true */ debuggerScriptPath);
  3423. self._PDFBug = PDFBug;
  3424. }
  3425. function reportPageStatsPDFBug({
  3426. pageNumber
  3427. }) {
  3428. if (!globalThis.Stats?.enabled) {
  3429. return;
  3430. }
  3431. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3432. globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
  3433. }
  3434. function webViewerPageRender({
  3435. pageNumber
  3436. }) {
  3437. if (pageNumber === PDFViewerApplication.page) {
  3438. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true);
  3439. }
  3440. }
  3441. function webViewerPageRendered({
  3442. pageNumber,
  3443. error
  3444. }) {
  3445. if (pageNumber === PDFViewerApplication.page) {
  3446. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false);
  3447. }
  3448. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  3449. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3450. const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
  3451. if (pageView) {
  3452. thumbnailView?.setImage(pageView);
  3453. }
  3454. }
  3455. if (error) {
  3456. PDFViewerApplication.l10n.get("pdfjs-rendering-error").then(msg => {
  3457. PDFViewerApplication._otherError(msg, error);
  3458. });
  3459. }
  3460. }
  3461. function webViewerPageMode({
  3462. mode
  3463. }) {
  3464. let view;
  3465. switch (mode) {
  3466. case "thumbs":
  3467. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  3468. break;
  3469. case "bookmarks":
  3470. case "outline":
  3471. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE;
  3472. break;
  3473. case "attachments":
  3474. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS;
  3475. break;
  3476. case "layers":
  3477. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS;
  3478. break;
  3479. case "none":
  3480. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE;
  3481. break;
  3482. default:
  3483. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3484. return;
  3485. }
  3486. PDFViewerApplication.pdfSidebar?.switchView(view, true);
  3487. }
  3488. function webViewerNamedAction(evt) {
  3489. switch (evt.action) {
  3490. case "GoToPage":
  3491. PDFViewerApplication.appConfig.toolbar?.pageNumber.select();
  3492. break;
  3493. case "Find":
  3494. if (!PDFViewerApplication.supportsIntegratedFind) {
  3495. PDFViewerApplication?.findBar.toggle();
  3496. }
  3497. break;
  3498. case "Print":
  3499. PDFViewerApplication.triggerPrinting();
  3500. break;
  3501. case "SaveAs":
  3502. PDFViewerApplication.downloadOrSave();
  3503. break;
  3504. }
  3505. }
  3506. function webViewerPresentationModeChanged(evt) {
  3507. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3508. }
  3509. function webViewerSidebarViewChanged({
  3510. view
  3511. }) {
  3512. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  3513. if (PDFViewerApplication.isInitialViewSet) {
  3514. PDFViewerApplication.store?.set("sidebarView", view).catch(() => {});
  3515. }
  3516. }
  3517. function webViewerUpdateViewarea({
  3518. location
  3519. }) {
  3520. if (PDFViewerApplication.isInitialViewSet) {
  3521. PDFViewerApplication.store?.setMultiple({
  3522. page: location.pageNumber,
  3523. zoom: location.scale,
  3524. scrollLeft: location.left,
  3525. scrollTop: location.top,
  3526. rotation: location.rotation
  3527. }).catch(() => {});
  3528. }
  3529. if (PDFViewerApplication.appConfig.secondaryToolbar) {
  3530. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3531. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3532. }
  3533. }
  3534. function webViewerScrollModeChanged(evt) {
  3535. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3536. PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {});
  3537. }
  3538. }
  3539. function webViewerSpreadModeChanged(evt) {
  3540. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3541. PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
  3542. }
  3543. }
  3544. function webViewerResize() {
  3545. const {
  3546. pdfDocument,
  3547. pdfViewer,
  3548. pdfRenderingQueue
  3549. } = PDFViewerApplication;
  3550. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  3551. return;
  3552. }
  3553. if (!pdfDocument) {
  3554. return;
  3555. }
  3556. const currentScaleValue = pdfViewer.currentScaleValue;
  3557. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  3558. pdfViewer.currentScaleValue = currentScaleValue;
  3559. }
  3560. pdfViewer.update();
  3561. }
  3562. function webViewerHashchange(evt) {
  3563. const hash = evt.hash;
  3564. if (!hash) {
  3565. return;
  3566. }
  3567. if (!PDFViewerApplication.isInitialViewSet) {
  3568. PDFViewerApplication.initialBookmark = hash;
  3569. } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
  3570. PDFViewerApplication.pdfLinkService.setHash(hash);
  3571. }
  3572. }
  3573. {
  3574. var webViewerFileInputChange = function (evt) {
  3575. if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
  3576. return;
  3577. }
  3578. const file = evt.fileInput.files[0];
  3579. PDFViewerApplication.open({
  3580. url: URL.createObjectURL(file),
  3581. originalUrl: file.name
  3582. });
  3583. };
  3584. var webViewerOpenFile = function (evt) {
  3585. const fileInput = PDFViewerApplication.appConfig.openFileInput;
  3586. fileInput.click();
  3587. };
  3588. }
  3589. function webViewerPresentationMode() {
  3590. PDFViewerApplication.requestPresentationMode();
  3591. }
  3592. function webViewerSwitchAnnotationEditorMode(evt) {
  3593. PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
  3594. }
  3595. function webViewerSwitchAnnotationEditorParams(evt) {
  3596. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  3597. }
  3598. function webViewerPrint() {
  3599. PDFViewerApplication.triggerPrinting();
  3600. }
  3601. function webViewerDownload() {
  3602. PDFViewerApplication.downloadOrSave();
  3603. }
  3604. function webViewerOpenInExternalApp() {
  3605. PDFViewerApplication.openInExternalApp();
  3606. }
  3607. function webViewerFirstPage() {
  3608. PDFViewerApplication.page = 1;
  3609. }
  3610. function webViewerLastPage() {
  3611. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3612. }
  3613. function webViewerNextPage() {
  3614. PDFViewerApplication.pdfViewer.nextPage();
  3615. }
  3616. function webViewerPreviousPage() {
  3617. PDFViewerApplication.pdfViewer.previousPage();
  3618. }
  3619. function webViewerZoomIn() {
  3620. PDFViewerApplication.zoomIn();
  3621. }
  3622. function webViewerZoomOut() {
  3623. PDFViewerApplication.zoomOut();
  3624. }
  3625. function webViewerZoomReset() {
  3626. PDFViewerApplication.zoomReset();
  3627. }
  3628. function webViewerPageNumberChanged(evt) {
  3629. const pdfViewer = PDFViewerApplication.pdfViewer;
  3630. if (evt.value !== "") {
  3631. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3632. }
  3633. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3634. PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3635. }
  3636. }
  3637. function webViewerScaleChanged(evt) {
  3638. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3639. }
  3640. function webViewerRotateCw() {
  3641. PDFViewerApplication.rotatePages(90);
  3642. }
  3643. function webViewerRotateCcw() {
  3644. PDFViewerApplication.rotatePages(-90);
  3645. }
  3646. function webViewerOptionalContentConfig(evt) {
  3647. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3648. }
  3649. function webViewerSwitchScrollMode(evt) {
  3650. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3651. }
  3652. function webViewerSwitchSpreadMode(evt) {
  3653. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3654. }
  3655. function webViewerDocumentProperties() {
  3656. PDFViewerApplication.pdfDocumentProperties?.open();
  3657. }
  3658. function webViewerFindFromUrlHash(evt) {
  3659. PDFViewerApplication.eventBus.dispatch("find", {
  3660. source: evt.source,
  3661. type: "",
  3662. query: evt.query,
  3663. caseSensitive: false,
  3664. entireWord: false,
  3665. highlightAll: true,
  3666. findPrevious: false,
  3667. matchDiacritics: true
  3668. });
  3669. }
  3670. function webViewerUpdateFindMatchesCount({
  3671. matchesCount
  3672. }) {
  3673. if (PDFViewerApplication.supportsIntegratedFind) {
  3674. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3675. } else {
  3676. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3677. }
  3678. }
  3679. function webViewerUpdateFindControlState({
  3680. state,
  3681. previous,
  3682. matchesCount,
  3683. rawQuery
  3684. }) {
  3685. if (PDFViewerApplication.supportsIntegratedFind) {
  3686. PDFViewerApplication.externalServices.updateFindControlState({
  3687. result: state,
  3688. findPrevious: previous,
  3689. matchesCount,
  3690. rawQuery
  3691. });
  3692. } else {
  3693. PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount);
  3694. }
  3695. }
  3696. function webViewerScaleChanging(evt) {
  3697. PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale);
  3698. PDFViewerApplication.pdfViewer.update();
  3699. }
  3700. function webViewerRotationChanging(evt) {
  3701. if (PDFViewerApplication.pdfThumbnailViewer) {
  3702. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3703. }
  3704. PDFViewerApplication.forceRendering();
  3705. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3706. }
  3707. function webViewerPageChanging({
  3708. pageNumber,
  3709. pageLabel
  3710. }) {
  3711. PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel);
  3712. PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber);
  3713. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  3714. PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
  3715. }
  3716. const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3717. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING);
  3718. }
  3719. function webViewerResolutionChange(evt) {
  3720. PDFViewerApplication.pdfViewer.refresh();
  3721. }
  3722. function webViewerVisibilityChange(evt) {
  3723. if (document.visibilityState === "visible") {
  3724. setZoomDisabledTimeout();
  3725. }
  3726. }
  3727. let zoomDisabledTimeout = null;
  3728. function setZoomDisabledTimeout() {
  3729. if (zoomDisabledTimeout) {
  3730. clearTimeout(zoomDisabledTimeout);
  3731. }
  3732. zoomDisabledTimeout = setTimeout(function () {
  3733. zoomDisabledTimeout = null;
  3734. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3735. }
  3736. function webViewerWheel(evt) {
  3737. const {
  3738. pdfViewer,
  3739. supportsMouseWheelZoomCtrlKey,
  3740. supportsMouseWheelZoomMetaKey,
  3741. supportsPinchToZoom
  3742. } = PDFViewerApplication;
  3743. if (pdfViewer.isInPresentationMode) {
  3744. return;
  3745. }
  3746. const deltaMode = evt.deltaMode;
  3747. let scaleFactor = Math.exp(-evt.deltaY / 100);
  3748. const isBuiltInMac = false;
  3749. const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  3750. if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
  3751. evt.preventDefault();
  3752. if (zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
  3753. return;
  3754. }
  3755. const previousScale = pdfViewer.currentScale;
  3756. if (isPinchToZoom && supportsPinchToZoom) {
  3757. scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
  3758. if (scaleFactor < 1) {
  3759. PDFViewerApplication.zoomOut(null, scaleFactor);
  3760. } else if (scaleFactor > 1) {
  3761. PDFViewerApplication.zoomIn(null, scaleFactor);
  3762. } else {
  3763. return;
  3764. }
  3765. } else {
  3766. const delta = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeWheelEventDirection)(evt);
  3767. let ticks = 0;
  3768. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3769. if (Math.abs(delta) >= 1) {
  3770. ticks = Math.sign(delta);
  3771. } else {
  3772. ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
  3773. }
  3774. } else {
  3775. const PIXELS_PER_LINE_SCALE = 30;
  3776. ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  3777. }
  3778. if (ticks < 0) {
  3779. PDFViewerApplication.zoomOut(-ticks);
  3780. } else if (ticks > 0) {
  3781. PDFViewerApplication.zoomIn(ticks);
  3782. } else {
  3783. return;
  3784. }
  3785. }
  3786. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
  3787. } else {
  3788. setZoomDisabledTimeout();
  3789. }
  3790. }
  3791. function webViewerTouchStart(evt) {
  3792. if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  3793. return;
  3794. }
  3795. evt.preventDefault();
  3796. if (evt.touches.length !== 2 || PDFViewerApplication.overlayManager.active) {
  3797. PDFViewerApplication._touchInfo = null;
  3798. return;
  3799. }
  3800. let [touch0, touch1] = evt.touches;
  3801. if (touch0.identifier > touch1.identifier) {
  3802. [touch0, touch1] = [touch1, touch0];
  3803. }
  3804. PDFViewerApplication._touchInfo = {
  3805. touch0X: touch0.pageX,
  3806. touch0Y: touch0.pageY,
  3807. touch1X: touch1.pageX,
  3808. touch1Y: touch1.pageY
  3809. };
  3810. }
  3811. function webViewerTouchMove(evt) {
  3812. if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
  3813. return;
  3814. }
  3815. const {
  3816. pdfViewer,
  3817. _touchInfo,
  3818. supportsPinchToZoom
  3819. } = PDFViewerApplication;
  3820. let [touch0, touch1] = evt.touches;
  3821. if (touch0.identifier > touch1.identifier) {
  3822. [touch0, touch1] = [touch1, touch0];
  3823. }
  3824. const {
  3825. pageX: page0X,
  3826. pageY: page0Y
  3827. } = touch0;
  3828. const {
  3829. pageX: page1X,
  3830. pageY: page1Y
  3831. } = touch1;
  3832. const {
  3833. touch0X: pTouch0X,
  3834. touch0Y: pTouch0Y,
  3835. touch1X: pTouch1X,
  3836. touch1Y: pTouch1Y
  3837. } = _touchInfo;
  3838. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  3839. return;
  3840. }
  3841. _touchInfo.touch0X = page0X;
  3842. _touchInfo.touch0Y = page0Y;
  3843. _touchInfo.touch1X = page1X;
  3844. _touchInfo.touch1Y = page1Y;
  3845. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  3846. const v1X = pTouch1X - page0X;
  3847. const v1Y = pTouch1Y - page0Y;
  3848. const v2X = page1X - page0X;
  3849. const v2Y = page1Y - page0Y;
  3850. const det = v1X * v2Y - v1Y * v2X;
  3851. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3852. return;
  3853. }
  3854. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  3855. const v1X = pTouch0X - page1X;
  3856. const v1Y = pTouch0Y - page1Y;
  3857. const v2X = page0X - page1X;
  3858. const v2Y = page0Y - page1Y;
  3859. const det = v1X * v2Y - v1Y * v2X;
  3860. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3861. return;
  3862. }
  3863. } else {
  3864. const diff0X = page0X - pTouch0X;
  3865. const diff1X = page1X - pTouch1X;
  3866. const diff0Y = page0Y - pTouch0Y;
  3867. const diff1Y = page1Y - pTouch1Y;
  3868. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  3869. if (dotProduct >= 0) {
  3870. return;
  3871. }
  3872. }
  3873. evt.preventDefault();
  3874. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  3875. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  3876. const previousScale = pdfViewer.currentScale;
  3877. if (supportsPinchToZoom) {
  3878. const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
  3879. if (newScaleFactor < 1) {
  3880. PDFViewerApplication.zoomOut(null, newScaleFactor);
  3881. } else if (newScaleFactor > 1) {
  3882. PDFViewerApplication.zoomIn(null, newScaleFactor);
  3883. } else {
  3884. return;
  3885. }
  3886. } else {
  3887. const PIXELS_PER_LINE_SCALE = 30;
  3888. const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  3889. if (ticks < 0) {
  3890. PDFViewerApplication.zoomOut(-ticks);
  3891. } else if (ticks > 0) {
  3892. PDFViewerApplication.zoomIn(ticks);
  3893. } else {
  3894. return;
  3895. }
  3896. }
  3897. PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
  3898. }
  3899. function webViewerTouchEnd(evt) {
  3900. if (!PDFViewerApplication._touchInfo) {
  3901. return;
  3902. }
  3903. evt.preventDefault();
  3904. PDFViewerApplication._touchInfo = null;
  3905. PDFViewerApplication._touchUnusedTicks = 0;
  3906. PDFViewerApplication._touchUnusedFactor = 1;
  3907. }
  3908. function webViewerClick(evt) {
  3909. if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
  3910. return;
  3911. }
  3912. const appConfig = PDFViewerApplication.appConfig;
  3913. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
  3914. PDFViewerApplication.secondaryToolbar.close();
  3915. }
  3916. }
  3917. function webViewerKeyUp(evt) {
  3918. if (evt.key === "Control") {
  3919. PDFViewerApplication._isCtrlKeyDown = false;
  3920. }
  3921. }
  3922. function webViewerKeyDown(evt) {
  3923. PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
  3924. if (PDFViewerApplication.overlayManager.active) {
  3925. return;
  3926. }
  3927. const {
  3928. eventBus,
  3929. pdfViewer
  3930. } = PDFViewerApplication;
  3931. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  3932. let handled = false,
  3933. ensureViewerFocused = false;
  3934. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3935. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3936. switch (evt.keyCode) {
  3937. case 70:
  3938. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3939. PDFViewerApplication.findBar?.open();
  3940. handled = true;
  3941. }
  3942. break;
  3943. case 71:
  3944. if (!PDFViewerApplication.supportsIntegratedFind) {
  3945. const {
  3946. state
  3947. } = PDFViewerApplication.findController;
  3948. if (state) {
  3949. const newState = {
  3950. source: window,
  3951. type: "again",
  3952. findPrevious: cmd === 5 || cmd === 12
  3953. };
  3954. eventBus.dispatch("find", {
  3955. ...state,
  3956. ...newState
  3957. });
  3958. }
  3959. handled = true;
  3960. }
  3961. break;
  3962. case 61:
  3963. case 107:
  3964. case 187:
  3965. case 171:
  3966. PDFViewerApplication.zoomIn();
  3967. handled = true;
  3968. break;
  3969. case 173:
  3970. case 109:
  3971. case 189:
  3972. PDFViewerApplication.zoomOut();
  3973. handled = true;
  3974. break;
  3975. case 48:
  3976. case 96:
  3977. if (!isViewerInPresentationMode) {
  3978. setTimeout(function () {
  3979. PDFViewerApplication.zoomReset();
  3980. });
  3981. handled = false;
  3982. }
  3983. break;
  3984. case 38:
  3985. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3986. PDFViewerApplication.page = 1;
  3987. handled = true;
  3988. ensureViewerFocused = true;
  3989. }
  3990. break;
  3991. case 40:
  3992. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3993. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3994. handled = true;
  3995. ensureViewerFocused = true;
  3996. }
  3997. break;
  3998. }
  3999. }
  4000. if (cmd === 1 || cmd === 8) {
  4001. switch (evt.keyCode) {
  4002. case 83:
  4003. eventBus.dispatch("download", {
  4004. source: window
  4005. });
  4006. handled = true;
  4007. break;
  4008. case 79:
  4009. {
  4010. eventBus.dispatch("openfile", {
  4011. source: window
  4012. });
  4013. handled = true;
  4014. }
  4015. break;
  4016. }
  4017. }
  4018. if (cmd === 3 || cmd === 10) {
  4019. switch (evt.keyCode) {
  4020. case 80:
  4021. PDFViewerApplication.requestPresentationMode();
  4022. handled = true;
  4023. PDFViewerApplication.externalServices.reportTelemetry({
  4024. type: "buttons",
  4025. data: {
  4026. id: "presentationModeKeyboard"
  4027. }
  4028. });
  4029. break;
  4030. case 71:
  4031. if (PDFViewerApplication.appConfig.toolbar) {
  4032. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  4033. handled = true;
  4034. }
  4035. break;
  4036. }
  4037. }
  4038. if (handled) {
  4039. if (ensureViewerFocused && !isViewerInPresentationMode) {
  4040. pdfViewer.focus();
  4041. }
  4042. evt.preventDefault();
  4043. return;
  4044. }
  4045. const curElement = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getActiveOrFocusedElement)();
  4046. const curElementTagName = curElement?.tagName.toUpperCase();
  4047. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElementTagName === "BUTTON" && (evt.keyCode === 13 || evt.keyCode === 32) || curElement?.isContentEditable) {
  4048. if (evt.keyCode !== 27) {
  4049. return;
  4050. }
  4051. }
  4052. if (cmd === 0) {
  4053. let turnPage = 0,
  4054. turnOnlyIfPageFit = false;
  4055. switch (evt.keyCode) {
  4056. case 38:
  4057. case 33:
  4058. if (pdfViewer.isVerticalScrollbarEnabled) {
  4059. turnOnlyIfPageFit = true;
  4060. }
  4061. turnPage = -1;
  4062. break;
  4063. case 8:
  4064. if (!isViewerInPresentationMode) {
  4065. turnOnlyIfPageFit = true;
  4066. }
  4067. turnPage = -1;
  4068. break;
  4069. case 37:
  4070. if (pdfViewer.isHorizontalScrollbarEnabled) {
  4071. turnOnlyIfPageFit = true;
  4072. }
  4073. case 75:
  4074. case 80:
  4075. turnPage = -1;
  4076. break;
  4077. case 27:
  4078. if (PDFViewerApplication.secondaryToolbar?.isOpen) {
  4079. PDFViewerApplication.secondaryToolbar.close();
  4080. handled = true;
  4081. }
  4082. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) {
  4083. PDFViewerApplication.findBar.close();
  4084. handled = true;
  4085. }
  4086. break;
  4087. case 40:
  4088. case 34:
  4089. if (pdfViewer.isVerticalScrollbarEnabled) {
  4090. turnOnlyIfPageFit = true;
  4091. }
  4092. turnPage = 1;
  4093. break;
  4094. case 13:
  4095. case 32:
  4096. if (!isViewerInPresentationMode) {
  4097. turnOnlyIfPageFit = true;
  4098. }
  4099. turnPage = 1;
  4100. break;
  4101. case 39:
  4102. if (pdfViewer.isHorizontalScrollbarEnabled) {
  4103. turnOnlyIfPageFit = true;
  4104. }
  4105. case 74:
  4106. case 78:
  4107. turnPage = 1;
  4108. break;
  4109. case 36:
  4110. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  4111. PDFViewerApplication.page = 1;
  4112. handled = true;
  4113. ensureViewerFocused = true;
  4114. }
  4115. break;
  4116. case 35:
  4117. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  4118. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  4119. handled = true;
  4120. ensureViewerFocused = true;
  4121. }
  4122. break;
  4123. case 83:
  4124. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT);
  4125. break;
  4126. case 72:
  4127. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND);
  4128. break;
  4129. case 82:
  4130. PDFViewerApplication.rotatePages(90);
  4131. break;
  4132. case 115:
  4133. PDFViewerApplication.pdfSidebar?.toggle();
  4134. break;
  4135. }
  4136. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  4137. if (turnPage > 0) {
  4138. pdfViewer.nextPage();
  4139. } else {
  4140. pdfViewer.previousPage();
  4141. }
  4142. handled = true;
  4143. }
  4144. }
  4145. if (cmd === 4) {
  4146. switch (evt.keyCode) {
  4147. case 13:
  4148. case 32:
  4149. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  4150. break;
  4151. }
  4152. pdfViewer.previousPage();
  4153. handled = true;
  4154. break;
  4155. case 82:
  4156. PDFViewerApplication.rotatePages(-90);
  4157. break;
  4158. }
  4159. }
  4160. if (!handled && !isViewerInPresentationMode) {
  4161. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  4162. ensureViewerFocused = true;
  4163. }
  4164. }
  4165. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  4166. pdfViewer.focus();
  4167. }
  4168. if (handled) {
  4169. evt.preventDefault();
  4170. }
  4171. }
  4172. function beforeUnload(evt) {
  4173. evt.preventDefault();
  4174. evt.returnValue = "";
  4175. return false;
  4176. }
  4177. function webViewerAnnotationEditorStatesChanged(data) {
  4178. PDFViewerApplication.externalServices.updateEditorStates(data);
  4179. }
  4180. function webViewerReportTelemetry({
  4181. details
  4182. }) {
  4183. PDFViewerApplication.externalServices.reportTelemetry(details);
  4184. }
  4185. const PDFPrintServiceFactory = {
  4186. instance: {
  4187. supportsPrinting: false,
  4188. createPrintService() {
  4189. throw new Error("Not implemented: createPrintService");
  4190. }
  4191. }
  4192. };
  4193. __webpack_async_result__();
  4194. } catch(e) { __webpack_async_result__(e); } });
  4195. /***/ }),
  4196. /***/ 8961:
  4197. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  4198. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4199. /* harmony export */ AppOptions: () => (/* binding */ AppOptions),
  4200. /* harmony export */ OptionKind: () => (/* binding */ OptionKind),
  4201. /* harmony export */ compatibilityParams: () => (/* binding */ compatibilityParams)
  4202. /* harmony export */ });
  4203. const compatibilityParams = Object.create(null);
  4204. {
  4205. const userAgent = navigator.userAgent || "";
  4206. const platform = navigator.platform || "";
  4207. const maxTouchPoints = navigator.maxTouchPoints || 1;
  4208. const isAndroid = /Android/.test(userAgent);
  4209. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4210. (function checkCanvasSizeLimitation() {
  4211. if (isIOS || isAndroid) {
  4212. compatibilityParams.maxCanvasPixels = 5242880;
  4213. }
  4214. })();
  4215. }
  4216. const OptionKind = {
  4217. BROWSER: 0x01,
  4218. VIEWER: 0x02,
  4219. API: 0x04,
  4220. WORKER: 0x08,
  4221. PREFERENCE: 0x80
  4222. };
  4223. const defaultOptions = {
  4224. canvasMaxAreaInBytes: {
  4225. value: -1,
  4226. kind: OptionKind.BROWSER + OptionKind.API
  4227. },
  4228. isInAutomation: {
  4229. value: false,
  4230. kind: OptionKind.BROWSER
  4231. },
  4232. supportsDocumentFonts: {
  4233. value: true,
  4234. kind: OptionKind.BROWSER
  4235. },
  4236. supportsIntegratedFind: {
  4237. value: false,
  4238. kind: OptionKind.BROWSER
  4239. },
  4240. supportsMouseWheelZoomCtrlKey: {
  4241. value: true,
  4242. kind: OptionKind.BROWSER
  4243. },
  4244. supportsMouseWheelZoomMetaKey: {
  4245. value: true,
  4246. kind: OptionKind.BROWSER
  4247. },
  4248. supportsPinchToZoom: {
  4249. value: true,
  4250. kind: OptionKind.BROWSER
  4251. },
  4252. annotationEditorMode: {
  4253. value: 0,
  4254. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4255. },
  4256. annotationMode: {
  4257. value: 2,
  4258. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4259. },
  4260. cursorToolOnLoad: {
  4261. value: 0,
  4262. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4263. },
  4264. defaultZoomDelay: {
  4265. value: 400,
  4266. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4267. },
  4268. defaultZoomValue: {
  4269. value: "",
  4270. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4271. },
  4272. disableHistory: {
  4273. value: false,
  4274. kind: OptionKind.VIEWER
  4275. },
  4276. disablePageLabels: {
  4277. value: false,
  4278. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4279. },
  4280. enableHighlightEditor: {
  4281. value: false,
  4282. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4283. },
  4284. enablePermissions: {
  4285. value: false,
  4286. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4287. },
  4288. enablePrintAutoRotate: {
  4289. value: true,
  4290. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4291. },
  4292. enableScripting: {
  4293. value: true,
  4294. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4295. },
  4296. externalLinkRel: {
  4297. value: "noopener noreferrer nofollow",
  4298. kind: OptionKind.VIEWER
  4299. },
  4300. externalLinkTarget: {
  4301. value: 0,
  4302. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4303. },
  4304. highlightEditorColors: {
  4305. value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
  4306. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4307. },
  4308. historyUpdateUrl: {
  4309. value: false,
  4310. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4311. },
  4312. ignoreDestinationZoom: {
  4313. value: false,
  4314. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4315. },
  4316. imageResourcesPath: {
  4317. value: "./images/",
  4318. kind: OptionKind.VIEWER
  4319. },
  4320. maxCanvasPixels: {
  4321. value: 16777216,
  4322. kind: OptionKind.VIEWER
  4323. },
  4324. forcePageColors: {
  4325. value: false,
  4326. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4327. },
  4328. pageColorsBackground: {
  4329. value: "Canvas",
  4330. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4331. },
  4332. pageColorsForeground: {
  4333. value: "CanvasText",
  4334. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4335. },
  4336. pdfBugEnabled: {
  4337. value: false,
  4338. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4339. },
  4340. printResolution: {
  4341. value: 150,
  4342. kind: OptionKind.VIEWER
  4343. },
  4344. sidebarViewOnLoad: {
  4345. value: -1,
  4346. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4347. },
  4348. scrollModeOnLoad: {
  4349. value: -1,
  4350. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4351. },
  4352. spreadModeOnLoad: {
  4353. value: -1,
  4354. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4355. },
  4356. textLayerMode: {
  4357. value: 1,
  4358. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4359. },
  4360. viewOnLoad: {
  4361. value: 0,
  4362. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4363. },
  4364. cMapPacked: {
  4365. value: true,
  4366. kind: OptionKind.API
  4367. },
  4368. cMapUrl: {
  4369. value: "../web/cmaps/",
  4370. kind: OptionKind.API
  4371. },
  4372. disableAutoFetch: {
  4373. value: false,
  4374. kind: OptionKind.API + OptionKind.PREFERENCE
  4375. },
  4376. disableFontFace: {
  4377. value: false,
  4378. kind: OptionKind.API + OptionKind.PREFERENCE
  4379. },
  4380. disableRange: {
  4381. value: false,
  4382. kind: OptionKind.API + OptionKind.PREFERENCE
  4383. },
  4384. disableStream: {
  4385. value: false,
  4386. kind: OptionKind.API + OptionKind.PREFERENCE
  4387. },
  4388. docBaseUrl: {
  4389. value: "",
  4390. kind: OptionKind.API
  4391. },
  4392. enableXfa: {
  4393. value: true,
  4394. kind: OptionKind.API + OptionKind.PREFERENCE
  4395. },
  4396. fontExtraProperties: {
  4397. value: false,
  4398. kind: OptionKind.API
  4399. },
  4400. isEvalSupported: {
  4401. value: true,
  4402. kind: OptionKind.API
  4403. },
  4404. isOffscreenCanvasSupported: {
  4405. value: true,
  4406. kind: OptionKind.API
  4407. },
  4408. maxImageSize: {
  4409. value: -1,
  4410. kind: OptionKind.API
  4411. },
  4412. pdfBug: {
  4413. value: false,
  4414. kind: OptionKind.API
  4415. },
  4416. standardFontDataUrl: {
  4417. value: "../web/standard_fonts/",
  4418. kind: OptionKind.API
  4419. },
  4420. verbosity: {
  4421. value: 1,
  4422. kind: OptionKind.API
  4423. },
  4424. workerPort: {
  4425. value: null,
  4426. kind: OptionKind.WORKER
  4427. },
  4428. workerSrc: {
  4429. value: "../build/pdf.worker.mjs",
  4430. kind: OptionKind.WORKER
  4431. }
  4432. };
  4433. {
  4434. defaultOptions.defaultUrl = {
  4435. value: "compressed.tracemonkey-pldi-09.pdf",
  4436. kind: OptionKind.VIEWER
  4437. };
  4438. defaultOptions.sandboxBundleSrc = {
  4439. value: "../build/pdf.sandbox.mjs",
  4440. kind: OptionKind.VIEWER
  4441. };
  4442. defaultOptions.viewerCssTheme = {
  4443. value: 0,
  4444. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4445. };
  4446. }
  4447. {
  4448. defaultOptions.disablePreferences = {
  4449. value: false,
  4450. kind: OptionKind.VIEWER
  4451. };
  4452. defaultOptions.locale = {
  4453. value: navigator.language || "en-US",
  4454. kind: OptionKind.VIEWER
  4455. };
  4456. }
  4457. const userOptions = Object.create(null);
  4458. class AppOptions {
  4459. constructor() {
  4460. throw new Error("Cannot initialize AppOptions.");
  4461. }
  4462. static get(name) {
  4463. const userOption = userOptions[name];
  4464. if (userOption !== undefined) {
  4465. return userOption;
  4466. }
  4467. const defaultOption = defaultOptions[name];
  4468. if (defaultOption !== undefined) {
  4469. return compatibilityParams[name] ?? defaultOption.value;
  4470. }
  4471. return undefined;
  4472. }
  4473. static getAll(kind = null) {
  4474. const options = Object.create(null);
  4475. for (const name in defaultOptions) {
  4476. const defaultOption = defaultOptions[name];
  4477. if (kind) {
  4478. if (!(kind & defaultOption.kind)) {
  4479. continue;
  4480. }
  4481. }
  4482. const userOption = userOptions[name];
  4483. options[name] = userOption !== undefined ? userOption : compatibilityParams[name] ?? defaultOption.value;
  4484. }
  4485. return options;
  4486. }
  4487. static set(name, value) {
  4488. userOptions[name] = value;
  4489. }
  4490. static setAll(options, init = false) {
  4491. if (init) {
  4492. if (this.get("disablePreferences")) {
  4493. return;
  4494. }
  4495. if (Object.keys(userOptions).length) {
  4496. console.warn("setAll: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  4497. }
  4498. }
  4499. for (const name in options) {
  4500. userOptions[name] = options[name];
  4501. }
  4502. }
  4503. static remove(name) {
  4504. delete userOptions[name];
  4505. }
  4506. }
  4507. /***/ }),
  4508. /***/ 9415:
  4509. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  4510. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4511. /* harmony export */ BaseTreeViewer: () => (/* binding */ BaseTreeViewer)
  4512. /* harmony export */ });
  4513. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  4514. const TREEITEM_OFFSET_TOP = -100;
  4515. const TREEITEM_SELECTED_CLASS = "selected";
  4516. class BaseTreeViewer {
  4517. constructor(options) {
  4518. if (this.constructor === BaseTreeViewer) {
  4519. throw new Error("Cannot initialize BaseTreeViewer.");
  4520. }
  4521. this.container = options.container;
  4522. this.eventBus = options.eventBus;
  4523. this._l10n = options.l10n;
  4524. this.reset();
  4525. }
  4526. reset() {
  4527. this._pdfDocument = null;
  4528. this._lastToggleIsShow = true;
  4529. this._currentTreeItem = null;
  4530. this.container.textContent = "";
  4531. this.container.classList.remove("treeWithDeepNesting");
  4532. }
  4533. _dispatchEvent(count) {
  4534. throw new Error("Not implemented: _dispatchEvent");
  4535. }
  4536. _bindLink(element, params) {
  4537. throw new Error("Not implemented: _bindLink");
  4538. }
  4539. _normalizeTextContent(str) {
  4540. return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(str, true) || "\u2013";
  4541. }
  4542. _addToggleButton(div, hidden = false) {
  4543. const toggler = document.createElement("div");
  4544. toggler.className = "treeItemToggler";
  4545. if (hidden) {
  4546. toggler.classList.add("treeItemsHidden");
  4547. }
  4548. toggler.onclick = evt => {
  4549. evt.stopPropagation();
  4550. toggler.classList.toggle("treeItemsHidden");
  4551. if (evt.shiftKey) {
  4552. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  4553. this._toggleTreeItem(div, shouldShowAll);
  4554. }
  4555. };
  4556. div.prepend(toggler);
  4557. }
  4558. _toggleTreeItem(root, show = false) {
  4559. this._l10n.pause();
  4560. this._lastToggleIsShow = show;
  4561. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  4562. toggler.classList.toggle("treeItemsHidden", !show);
  4563. }
  4564. this._l10n.resume();
  4565. }
  4566. _toggleAllTreeItems() {
  4567. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  4568. }
  4569. _finishRendering(fragment, count, hasAnyNesting = false) {
  4570. if (hasAnyNesting) {
  4571. this.container.classList.add("treeWithDeepNesting");
  4572. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  4573. }
  4574. this._l10n.pause();
  4575. this.container.append(fragment);
  4576. this._l10n.resume();
  4577. this._dispatchEvent(count);
  4578. }
  4579. render(params) {
  4580. throw new Error("Not implemented: render");
  4581. }
  4582. _updateCurrentTreeItem(treeItem = null) {
  4583. if (this._currentTreeItem) {
  4584. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  4585. this._currentTreeItem = null;
  4586. }
  4587. if (treeItem) {
  4588. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  4589. this._currentTreeItem = treeItem;
  4590. }
  4591. }
  4592. _scrollToCurrentTreeItem(treeItem) {
  4593. if (!treeItem) {
  4594. return;
  4595. }
  4596. this._l10n.pause();
  4597. let currentNode = treeItem.parentNode;
  4598. while (currentNode && currentNode !== this.container) {
  4599. if (currentNode.classList.contains("treeItem")) {
  4600. const toggler = currentNode.firstElementChild;
  4601. toggler?.classList.remove("treeItemsHidden");
  4602. }
  4603. currentNode = currentNode.parentNode;
  4604. }
  4605. this._l10n.resume();
  4606. this._updateCurrentTreeItem(treeItem);
  4607. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  4608. }
  4609. }
  4610. /***/ }),
  4611. /***/ 4397:
  4612. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  4613. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  4614. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4615. /* harmony export */ DownloadManager: () => (/* binding */ DownloadManager)
  4616. /* harmony export */ });
  4617. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  4618. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  4619. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  4620. ;
  4621. function download(blobUrl, filename) {
  4622. const a = document.createElement("a");
  4623. if (!a.click) {
  4624. throw new Error('DownloadManager: "a.click()" is not supported.');
  4625. }
  4626. a.href = blobUrl;
  4627. a.target = "_parent";
  4628. if ("download" in a) {
  4629. a.download = filename;
  4630. }
  4631. (document.body || document.documentElement).append(a);
  4632. a.click();
  4633. a.remove();
  4634. }
  4635. class DownloadManager {
  4636. #openBlobUrls = new WeakMap();
  4637. downloadUrl(url, filename, _options) {
  4638. if (!(0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.createValidAbsoluteUrl)(url, "http://example.com")) {
  4639. console.error(`downloadUrl - not a valid URL: ${url}`);
  4640. return;
  4641. }
  4642. download(url + "#pdfjs.action=download", filename);
  4643. }
  4644. downloadData(data, filename, contentType) {
  4645. const blobUrl = URL.createObjectURL(new Blob([data], {
  4646. type: contentType
  4647. }));
  4648. download(blobUrl, filename);
  4649. }
  4650. openOrDownloadData(data, filename, dest = null) {
  4651. const isPdfData = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.isPdfFile)(filename);
  4652. const contentType = isPdfData ? "application/pdf" : "";
  4653. if (isPdfData) {
  4654. let blobUrl = this.#openBlobUrls.get(data);
  4655. if (!blobUrl) {
  4656. blobUrl = URL.createObjectURL(new Blob([data], {
  4657. type: contentType
  4658. }));
  4659. this.#openBlobUrls.set(data, blobUrl);
  4660. }
  4661. let viewerUrl;
  4662. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  4663. if (dest) {
  4664. viewerUrl += `#${escape(dest)}`;
  4665. }
  4666. try {
  4667. window.open(viewerUrl);
  4668. return true;
  4669. } catch (ex) {
  4670. console.error(`openOrDownloadData: ${ex}`);
  4671. URL.revokeObjectURL(blobUrl);
  4672. this.#openBlobUrls.delete(data);
  4673. }
  4674. }
  4675. this.downloadData(data, filename, contentType);
  4676. return false;
  4677. }
  4678. download(blob, url, filename, _options) {
  4679. const blobUrl = URL.createObjectURL(blob);
  4680. download(blobUrl, filename);
  4681. }
  4682. }
  4683. __webpack_async_result__();
  4684. } catch(e) { __webpack_async_result__(e); } });
  4685. /***/ }),
  4686. /***/ 758:
  4687. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  4688. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  4689. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4690. /* harmony export */ DrawLayerBuilder: () => (/* binding */ DrawLayerBuilder)
  4691. /* harmony export */ });
  4692. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  4693. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  4694. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  4695. class DrawLayerBuilder {
  4696. #drawLayer = null;
  4697. constructor(options) {
  4698. this.pageIndex = options.pageIndex;
  4699. }
  4700. async render(intent = "display") {
  4701. if (intent !== "display" || this.#drawLayer || this._cancelled) {
  4702. return;
  4703. }
  4704. this.#drawLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.DrawLayer({
  4705. pageIndex: this.pageIndex
  4706. });
  4707. }
  4708. cancel() {
  4709. this._cancelled = true;
  4710. if (!this.#drawLayer) {
  4711. return;
  4712. }
  4713. this.#drawLayer.destroy();
  4714. this.#drawLayer = null;
  4715. }
  4716. setParent(parent) {
  4717. this.#drawLayer?.setParent(parent);
  4718. }
  4719. getDrawLayer() {
  4720. return this.#drawLayer;
  4721. }
  4722. }
  4723. __webpack_async_result__();
  4724. } catch(e) { __webpack_async_result__(e); } });
  4725. /***/ }),
  4726. /***/ 6554:
  4727. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  4728. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4729. /* harmony export */ AutomationEventBus: () => (/* binding */ AutomationEventBus),
  4730. /* harmony export */ EventBus: () => (/* binding */ EventBus),
  4731. /* harmony export */ waitOnEventOrTimeout: () => (/* binding */ waitOnEventOrTimeout)
  4732. /* harmony export */ });
  4733. /* unused harmony export WaitOnType */
  4734. const WaitOnType = {
  4735. EVENT: "event",
  4736. TIMEOUT: "timeout"
  4737. };
  4738. function waitOnEventOrTimeout({
  4739. target,
  4740. name,
  4741. delay = 0
  4742. }) {
  4743. return new Promise(function (resolve, reject) {
  4744. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  4745. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  4746. }
  4747. function handler(type) {
  4748. if (target instanceof EventBus) {
  4749. target._off(name, eventHandler);
  4750. } else {
  4751. target.removeEventListener(name, eventHandler);
  4752. }
  4753. if (timeout) {
  4754. clearTimeout(timeout);
  4755. }
  4756. resolve(type);
  4757. }
  4758. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  4759. if (target instanceof EventBus) {
  4760. target._on(name, eventHandler);
  4761. } else {
  4762. target.addEventListener(name, eventHandler);
  4763. }
  4764. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  4765. const timeout = setTimeout(timeoutHandler, delay);
  4766. });
  4767. }
  4768. class EventBus {
  4769. #listeners = Object.create(null);
  4770. on(eventName, listener, options = null) {
  4771. this._on(eventName, listener, {
  4772. external: true,
  4773. once: options?.once
  4774. });
  4775. }
  4776. off(eventName, listener, options = null) {
  4777. this._off(eventName, listener, {
  4778. external: true,
  4779. once: options?.once
  4780. });
  4781. }
  4782. dispatch(eventName, data) {
  4783. const eventListeners = this.#listeners[eventName];
  4784. if (!eventListeners || eventListeners.length === 0) {
  4785. return;
  4786. }
  4787. let externalListeners;
  4788. for (const {
  4789. listener,
  4790. external,
  4791. once
  4792. } of eventListeners.slice(0)) {
  4793. if (once) {
  4794. this._off(eventName, listener);
  4795. }
  4796. if (external) {
  4797. (externalListeners ||= []).push(listener);
  4798. continue;
  4799. }
  4800. listener(data);
  4801. }
  4802. if (externalListeners) {
  4803. for (const listener of externalListeners) {
  4804. listener(data);
  4805. }
  4806. externalListeners = null;
  4807. }
  4808. }
  4809. _on(eventName, listener, options = null) {
  4810. const eventListeners = this.#listeners[eventName] ||= [];
  4811. eventListeners.push({
  4812. listener,
  4813. external: options?.external === true,
  4814. once: options?.once === true
  4815. });
  4816. }
  4817. _off(eventName, listener, options = null) {
  4818. const eventListeners = this.#listeners[eventName];
  4819. if (!eventListeners) {
  4820. return;
  4821. }
  4822. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  4823. if (eventListeners[i].listener === listener) {
  4824. eventListeners.splice(i, 1);
  4825. return;
  4826. }
  4827. }
  4828. }
  4829. }
  4830. class AutomationEventBus extends EventBus {
  4831. dispatch(eventName, data) {
  4832. throw new Error("Not implemented: AutomationEventBus.dispatch");
  4833. }
  4834. }
  4835. /***/ }),
  4836. /***/ 9170:
  4837. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  4838. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  4839. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4840. /* harmony export */ GenericScripting: () => (/* binding */ GenericScripting)
  4841. /* harmony export */ });
  4842. /* unused harmony export docProperties */
  4843. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  4844. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  4845. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  4846. async function docProperties(pdfDocument) {
  4847. const url = "",
  4848. baseUrl = url.split("#")[0];
  4849. let {
  4850. info,
  4851. metadata,
  4852. contentDispositionFilename,
  4853. contentLength
  4854. } = await pdfDocument.getMetadata();
  4855. if (!contentLength) {
  4856. const {
  4857. length
  4858. } = await pdfDocument.getDownloadInfo();
  4859. contentLength = length;
  4860. }
  4861. return {
  4862. ...info,
  4863. baseURL: baseUrl,
  4864. filesize: contentLength,
  4865. filename: contentDispositionFilename || getPdfFilenameFromUrl(url),
  4866. metadata: metadata?.getRaw(),
  4867. authors: metadata?.get("dc:creator"),
  4868. numPages: pdfDocument.numPages,
  4869. URL: url
  4870. };
  4871. }
  4872. class GenericScripting {
  4873. constructor(sandboxBundleSrc) {
  4874. this._ready = new Promise((resolve, reject) => {
  4875. const sandbox = import(/* webpackIgnore: true */ sandboxBundleSrc);
  4876. sandbox.then(pdfjsSandbox => {
  4877. resolve(pdfjsSandbox.QuickJSSandbox());
  4878. }).catch(reject);
  4879. });
  4880. }
  4881. async createSandbox(data) {
  4882. const sandbox = await this._ready;
  4883. sandbox.create(data);
  4884. }
  4885. async dispatchEventInSandbox(event) {
  4886. const sandbox = await this._ready;
  4887. setTimeout(() => sandbox.dispatchEvent(event), 0);
  4888. }
  4889. async destroySandbox() {
  4890. const sandbox = await this._ready;
  4891. sandbox.nukeSandbox();
  4892. }
  4893. }
  4894. __webpack_async_result__();
  4895. } catch(e) { __webpack_async_result__(e); } });
  4896. /***/ }),
  4897. /***/ 1546:
  4898. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  4899. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  4900. /* unused harmony export GenericCom */
  4901. /* harmony import */ var _app_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39);
  4902. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8961);
  4903. /* harmony import */ var _preferences_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(216);
  4904. /* harmony import */ var _download_manager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4397);
  4905. /* harmony import */ var _genericl10n_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(450);
  4906. /* harmony import */ var _generic_scripting_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9170);
  4907. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_app_js__WEBPACK_IMPORTED_MODULE_0__, _download_manager_js__WEBPACK_IMPORTED_MODULE_3__, _genericl10n_js__WEBPACK_IMPORTED_MODULE_4__, _generic_scripting_js__WEBPACK_IMPORTED_MODULE_5__]);
  4908. ([_app_js__WEBPACK_IMPORTED_MODULE_0__, _download_manager_js__WEBPACK_IMPORTED_MODULE_3__, _genericl10n_js__WEBPACK_IMPORTED_MODULE_4__, _generic_scripting_js__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  4909. ;
  4910. const GenericCom = {};
  4911. class GenericPreferences extends _preferences_js__WEBPACK_IMPORTED_MODULE_2__.BasePreferences {
  4912. async _writeToStorage(prefObj) {
  4913. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  4914. }
  4915. async _readFromStorage(prefObj) {
  4916. return {
  4917. prefs: JSON.parse(localStorage.getItem("pdfjs.preferences"))
  4918. };
  4919. }
  4920. }
  4921. class GenericExternalServices extends _app_js__WEBPACK_IMPORTED_MODULE_0__.DefaultExternalServices {
  4922. static createDownloadManager() {
  4923. return new _download_manager_js__WEBPACK_IMPORTED_MODULE_3__.DownloadManager();
  4924. }
  4925. static createPreferences() {
  4926. return new GenericPreferences();
  4927. }
  4928. static async createL10n() {
  4929. return new _genericl10n_js__WEBPACK_IMPORTED_MODULE_4__.GenericL10n(_app_options_js__WEBPACK_IMPORTED_MODULE_1__.AppOptions.get("locale"));
  4930. }
  4931. static createScripting() {
  4932. return new _generic_scripting_js__WEBPACK_IMPORTED_MODULE_5__.GenericScripting(_app_options_js__WEBPACK_IMPORTED_MODULE_1__.AppOptions.get("sandboxBundleSrc"));
  4933. }
  4934. }
  4935. _app_js__WEBPACK_IMPORTED_MODULE_0__.PDFViewerApplication.externalServices = GenericExternalServices;
  4936. __webpack_async_result__();
  4937. } catch(e) { __webpack_async_result__(e); } });
  4938. /***/ }),
  4939. /***/ 450:
  4940. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  4941. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  4942. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4943. /* harmony export */ GenericL10n: () => (/* binding */ GenericL10n)
  4944. /* harmony export */ });
  4945. /* harmony import */ var fluent_bundle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8759);
  4946. /* harmony import */ var fluent_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8275);
  4947. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1869);
  4948. /* harmony import */ var _l10n_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4065);
  4949. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__]);
  4950. pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  4951. class GenericL10n extends _l10n_js__WEBPACK_IMPORTED_MODULE_3__.L10n {
  4952. constructor(lang) {
  4953. super({
  4954. lang
  4955. });
  4956. this._setL10n(new fluent_dom__WEBPACK_IMPORTED_MODULE_1__.DOMLocalization([], GenericL10n.#generateBundles.bind(GenericL10n, "en-us", this.getLanguage())));
  4957. }
  4958. static async *#generateBundles(defaultLang, baseLang) {
  4959. const {
  4960. baseURL,
  4961. paths
  4962. } = await this.#getPaths();
  4963. const langs = [baseLang];
  4964. if (defaultLang !== baseLang) {
  4965. const shortLang = baseLang.split("-", 1)[0];
  4966. if (shortLang !== baseLang) {
  4967. langs.push(shortLang);
  4968. }
  4969. langs.push(defaultLang);
  4970. }
  4971. for (const lang of langs) {
  4972. const bundle = await this.#createBundle(lang, baseURL, paths);
  4973. if (bundle) {
  4974. yield bundle;
  4975. }
  4976. }
  4977. }
  4978. static async #createBundle(lang, baseURL, paths) {
  4979. const path = paths[lang];
  4980. if (!path) {
  4981. return null;
  4982. }
  4983. const url = new URL(path, baseURL);
  4984. const text = await (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.fetchData)(url, "text");
  4985. const resource = new fluent_bundle__WEBPACK_IMPORTED_MODULE_0__.FluentResource(text);
  4986. const bundle = new fluent_bundle__WEBPACK_IMPORTED_MODULE_0__.FluentBundle(lang);
  4987. const errors = bundle.addResource(resource);
  4988. if (errors.length) {
  4989. console.error("L10n errors", errors);
  4990. }
  4991. return bundle;
  4992. }
  4993. static async #getPaths() {
  4994. const {
  4995. href
  4996. } = document.querySelector(`link[type="application/l10n"]`);
  4997. const paths = await (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.fetchData)(href, "json");
  4998. return {
  4999. baseURL: href.replace(/[^/]*$/, "") || "./",
  5000. paths
  5001. };
  5002. }
  5003. }
  5004. __webpack_async_result__();
  5005. } catch(e) { __webpack_async_result__(e); } });
  5006. /***/ }),
  5007. /***/ 6143:
  5008. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5009. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5010. /* harmony export */ GrabToPan: () => (/* binding */ GrabToPan)
  5011. /* harmony export */ });
  5012. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  5013. class GrabToPan {
  5014. constructor({
  5015. element
  5016. }) {
  5017. this.element = element;
  5018. this.document = element.ownerDocument;
  5019. this.activate = this.activate.bind(this);
  5020. this.deactivate = this.deactivate.bind(this);
  5021. this.toggle = this.toggle.bind(this);
  5022. this._onMouseDown = this.#onMouseDown.bind(this);
  5023. this._onMouseMove = this.#onMouseMove.bind(this);
  5024. this._endPan = this.#endPan.bind(this);
  5025. const overlay = this.overlay = document.createElement("div");
  5026. overlay.className = "grab-to-pan-grabbing";
  5027. }
  5028. activate() {
  5029. if (!this.active) {
  5030. this.active = true;
  5031. this.element.addEventListener("mousedown", this._onMouseDown, true);
  5032. this.element.classList.add(CSS_CLASS_GRAB);
  5033. }
  5034. }
  5035. deactivate() {
  5036. if (this.active) {
  5037. this.active = false;
  5038. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  5039. this._endPan();
  5040. this.element.classList.remove(CSS_CLASS_GRAB);
  5041. }
  5042. }
  5043. toggle() {
  5044. if (this.active) {
  5045. this.deactivate();
  5046. } else {
  5047. this.activate();
  5048. }
  5049. }
  5050. ignoreTarget(node) {
  5051. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  5052. }
  5053. #onMouseDown(event) {
  5054. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  5055. return;
  5056. }
  5057. if (event.originalTarget) {
  5058. try {
  5059. event.originalTarget.tagName;
  5060. } catch {
  5061. return;
  5062. }
  5063. }
  5064. this.scrollLeftStart = this.element.scrollLeft;
  5065. this.scrollTopStart = this.element.scrollTop;
  5066. this.clientXStart = event.clientX;
  5067. this.clientYStart = event.clientY;
  5068. this.document.addEventListener("mousemove", this._onMouseMove, true);
  5069. this.document.addEventListener("mouseup", this._endPan, true);
  5070. this.element.addEventListener("scroll", this._endPan, true);
  5071. event.preventDefault();
  5072. event.stopPropagation();
  5073. const focusedElement = document.activeElement;
  5074. if (focusedElement && !focusedElement.contains(event.target)) {
  5075. focusedElement.blur();
  5076. }
  5077. }
  5078. #onMouseMove(event) {
  5079. this.element.removeEventListener("scroll", this._endPan, true);
  5080. if (!(event.buttons & 1)) {
  5081. this._endPan();
  5082. return;
  5083. }
  5084. const xDiff = event.clientX - this.clientXStart;
  5085. const yDiff = event.clientY - this.clientYStart;
  5086. this.element.scrollTo({
  5087. top: this.scrollTopStart - yDiff,
  5088. left: this.scrollLeftStart - xDiff,
  5089. behavior: "instant"
  5090. });
  5091. if (!this.overlay.parentNode) {
  5092. document.body.append(this.overlay);
  5093. }
  5094. }
  5095. #endPan() {
  5096. this.element.removeEventListener("scroll", this._endPan, true);
  5097. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  5098. this.document.removeEventListener("mouseup", this._endPan, true);
  5099. this.overlay.remove();
  5100. }
  5101. }
  5102. /***/ }),
  5103. /***/ 4065:
  5104. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5105. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5106. /* harmony export */ L10n: () => (/* binding */ L10n)
  5107. /* harmony export */ });
  5108. class L10n {
  5109. #dir;
  5110. #lang;
  5111. #l10n;
  5112. constructor({
  5113. lang,
  5114. isRTL
  5115. }, l10n = null) {
  5116. this.#lang = L10n.#fixupLangCode(lang);
  5117. this.#l10n = l10n;
  5118. this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr";
  5119. }
  5120. _setL10n(l10n) {
  5121. this.#l10n = l10n;
  5122. }
  5123. getLanguage() {
  5124. return this.#lang;
  5125. }
  5126. getDirection() {
  5127. return this.#dir;
  5128. }
  5129. async get(ids, args = null, fallback) {
  5130. if (Array.isArray(ids)) {
  5131. ids = ids.map(id => ({
  5132. id
  5133. }));
  5134. const messages = await this.#l10n.formatMessages(ids);
  5135. return messages.map(message => message.value);
  5136. }
  5137. const messages = await this.#l10n.formatMessages([{
  5138. id: ids,
  5139. args
  5140. }]);
  5141. return messages?.[0].value || fallback;
  5142. }
  5143. async translate(element) {
  5144. try {
  5145. this.#l10n.connectRoot(element);
  5146. await this.#l10n.translateRoots();
  5147. } catch {}
  5148. }
  5149. pause() {
  5150. this.#l10n.pauseObserving();
  5151. }
  5152. resume() {
  5153. this.#l10n.resumeObserving();
  5154. }
  5155. static #fixupLangCode(langCode) {
  5156. langCode = langCode?.toLowerCase() || "en-us";
  5157. const PARTIAL_LANG_CODES = {
  5158. en: "en-us",
  5159. es: "es-es",
  5160. fy: "fy-nl",
  5161. ga: "ga-ie",
  5162. gu: "gu-in",
  5163. hi: "hi-in",
  5164. hy: "hy-am",
  5165. nb: "nb-no",
  5166. ne: "ne-np",
  5167. nn: "nn-no",
  5168. pa: "pa-in",
  5169. pt: "pt-pt",
  5170. sv: "sv-se",
  5171. zh: "zh-cn"
  5172. };
  5173. return PARTIAL_LANG_CODES[langCode] || langCode;
  5174. }
  5175. static #isRTL(lang) {
  5176. const shortCode = lang.split("-", 1)[0];
  5177. return ["ar", "he", "fa", "ps", "ur"].includes(shortCode);
  5178. }
  5179. }
  5180. /***/ }),
  5181. /***/ 7910:
  5182. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5183. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5184. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5185. /* harmony export */ NullL10n: () => (/* binding */ NullL10n)
  5186. /* harmony export */ });
  5187. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  5188. /* harmony import */ var fluent_bundle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8759);
  5189. /* harmony import */ var fluent_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8275);
  5190. /* harmony import */ var _l10n_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4065);
  5191. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5192. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5193. class ConstL10n extends _l10n_js__WEBPACK_IMPORTED_MODULE_3__.L10n {
  5194. constructor(lang) {
  5195. super({
  5196. lang
  5197. });
  5198. this._setL10n(new fluent_dom__WEBPACK_IMPORTED_MODULE_2__.DOMLocalization([], ConstL10n.#generateBundles.bind(ConstL10n, lang)));
  5199. }
  5200. static async *#generateBundles(lang) {
  5201. const text = 'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-open-in-app-button =\n .title = Open in app\npdfjs-open-in-app-button-label = Open in app\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties\u2026\npdfjs-document-properties-button-label = Document Properties\u2026\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-kb = { $size_kb } KB ({ $size_b } bytes)\npdfjs-document-properties-mb = { $size_mb } MB ({ $size_b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-string = { $date }, { $time }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xD7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xD7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-string = { $date }, { $time }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-free-text =\n .aria-label = Text Editor\npdfjs-free-text-default-content = Start typing\u2026\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can\u2019t see the image or when it doesn\u2019t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, \u201CA young man sits down at a table to eat a meal\u201D\npdfjs-editor-resizer-label-top-left = Top left corner \u2014 resize\npdfjs-editor-resizer-label-top-middle = Top middle \u2014 resize\npdfjs-editor-resizer-label-top-right = Top right corner \u2014 resize\npdfjs-editor-resizer-label-middle-right = Middle right \u2014 resize\npdfjs-editor-resizer-label-bottom-right = Bottom right corner \u2014 resize\npdfjs-editor-resizer-label-bottom-middle = Bottom middle \u2014 resize\npdfjs-editor-resizer-label-bottom-left = Bottom left corner \u2014 resize\npdfjs-editor-resizer-label-middle-left = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red';
  5202. const resource = new fluent_bundle__WEBPACK_IMPORTED_MODULE_1__.FluentResource(text);
  5203. const bundle = new fluent_bundle__WEBPACK_IMPORTED_MODULE_1__.FluentBundle(lang);
  5204. const errors = bundle.addResource(resource);
  5205. if (errors.length) {
  5206. console.error("L10n errors", errors);
  5207. }
  5208. yield bundle;
  5209. }
  5210. static get instance() {
  5211. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "instance", new ConstL10n("en-us"));
  5212. }
  5213. }
  5214. const NullL10n = {
  5215. getLanguage() {
  5216. return ConstL10n.instance.getLanguage();
  5217. },
  5218. getDirection() {
  5219. return ConstL10n.instance.getDirection();
  5220. },
  5221. async get(ids, args = null, fallback) {
  5222. return ConstL10n.instance.get(ids, args, fallback);
  5223. },
  5224. async translate(element) {
  5225. return ConstL10n.instance.translate(element);
  5226. },
  5227. pause() {
  5228. return ConstL10n.instance.pause();
  5229. },
  5230. resume() {
  5231. return ConstL10n.instance.resume();
  5232. }
  5233. };
  5234. __webpack_async_result__();
  5235. } catch(e) { __webpack_async_result__(e); } });
  5236. /***/ }),
  5237. /***/ 1996:
  5238. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5239. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5240. /* harmony export */ OverlayManager: () => (/* binding */ OverlayManager)
  5241. /* harmony export */ });
  5242. class OverlayManager {
  5243. #overlays = new WeakMap();
  5244. #active = null;
  5245. get active() {
  5246. return this.#active;
  5247. }
  5248. async register(dialog, canForceClose = false) {
  5249. if (typeof dialog !== "object") {
  5250. throw new Error("Not enough parameters.");
  5251. } else if (this.#overlays.has(dialog)) {
  5252. throw new Error("The overlay is already registered.");
  5253. }
  5254. this.#overlays.set(dialog, {
  5255. canForceClose
  5256. });
  5257. dialog.addEventListener("cancel", evt => {
  5258. this.#active = null;
  5259. });
  5260. }
  5261. async open(dialog) {
  5262. if (!this.#overlays.has(dialog)) {
  5263. throw new Error("The overlay does not exist.");
  5264. } else if (this.#active) {
  5265. if (this.#active === dialog) {
  5266. throw new Error("The overlay is already active.");
  5267. } else if (this.#overlays.get(dialog).canForceClose) {
  5268. await this.close();
  5269. } else {
  5270. throw new Error("Another overlay is currently active.");
  5271. }
  5272. }
  5273. this.#active = dialog;
  5274. dialog.showModal();
  5275. }
  5276. async close(dialog = this.#active) {
  5277. if (!this.#overlays.has(dialog)) {
  5278. throw new Error("The overlay does not exist.");
  5279. } else if (!this.#active) {
  5280. throw new Error("The overlay is currently not active.");
  5281. } else if (this.#active !== dialog) {
  5282. throw new Error("Another overlay is currently active.");
  5283. }
  5284. dialog.close();
  5285. this.#active = null;
  5286. }
  5287. }
  5288. /***/ }),
  5289. /***/ 6329:
  5290. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5291. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5292. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5293. /* harmony export */ PasswordPrompt: () => (/* binding */ PasswordPrompt)
  5294. /* harmony export */ });
  5295. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  5296. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5297. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5298. class PasswordPrompt {
  5299. #activeCapability = null;
  5300. #updateCallback = null;
  5301. #reason = null;
  5302. constructor(options, overlayManager, isViewerEmbedded = false) {
  5303. this.dialog = options.dialog;
  5304. this.label = options.label;
  5305. this.input = options.input;
  5306. this.submitButton = options.submitButton;
  5307. this.cancelButton = options.cancelButton;
  5308. this.overlayManager = overlayManager;
  5309. this._isViewerEmbedded = isViewerEmbedded;
  5310. this.submitButton.addEventListener("click", this.#verify.bind(this));
  5311. this.cancelButton.addEventListener("click", this.close.bind(this));
  5312. this.input.addEventListener("keydown", e => {
  5313. if (e.keyCode === 13) {
  5314. this.#verify();
  5315. }
  5316. });
  5317. this.overlayManager.register(this.dialog, true);
  5318. this.dialog.addEventListener("close", this.#cancel.bind(this));
  5319. }
  5320. async open() {
  5321. if (this.#activeCapability) {
  5322. await this.#activeCapability.promise;
  5323. }
  5324. this.#activeCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
  5325. try {
  5326. await this.overlayManager.open(this.dialog);
  5327. } catch (ex) {
  5328. this.#activeCapability.resolve();
  5329. throw ex;
  5330. }
  5331. const passwordIncorrect = this.#reason === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PasswordResponses.INCORRECT_PASSWORD;
  5332. if (!this._isViewerEmbedded || passwordIncorrect) {
  5333. this.input.focus();
  5334. }
  5335. this.label.setAttribute("data-l10n-id", `pdfjs-password-${passwordIncorrect ? "invalid" : "label"}`);
  5336. }
  5337. async close() {
  5338. if (this.overlayManager.active === this.dialog) {
  5339. this.overlayManager.close(this.dialog);
  5340. }
  5341. }
  5342. #verify() {
  5343. const password = this.input.value;
  5344. if (password?.length > 0) {
  5345. this.#invokeCallback(password);
  5346. }
  5347. }
  5348. #cancel() {
  5349. this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  5350. this.#activeCapability.resolve();
  5351. }
  5352. #invokeCallback(password) {
  5353. if (!this.#updateCallback) {
  5354. return;
  5355. }
  5356. this.close();
  5357. this.input.value = "";
  5358. this.#updateCallback(password);
  5359. this.#updateCallback = null;
  5360. }
  5361. async setUpdateCallback(updateCallback, reason) {
  5362. if (this.#activeCapability) {
  5363. await this.#activeCapability.promise;
  5364. }
  5365. this.#updateCallback = updateCallback;
  5366. this.#reason = reason;
  5367. }
  5368. }
  5369. __webpack_async_result__();
  5370. } catch(e) { __webpack_async_result__(e); } });
  5371. /***/ }),
  5372. /***/ 716:
  5373. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5374. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5375. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5376. /* harmony export */ PDFAttachmentViewer: () => (/* binding */ PDFAttachmentViewer)
  5377. /* harmony export */ });
  5378. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  5379. /* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9415);
  5380. /* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6554);
  5381. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5382. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5383. class PDFAttachmentViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_1__.BaseTreeViewer {
  5384. constructor(options) {
  5385. super(options);
  5386. this.downloadManager = options.downloadManager;
  5387. this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
  5388. }
  5389. reset(keepRenderedCapability = false) {
  5390. super.reset();
  5391. this._attachments = null;
  5392. if (!keepRenderedCapability) {
  5393. this._renderedCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
  5394. }
  5395. this._pendingDispatchEvent = false;
  5396. }
  5397. async _dispatchEvent(attachmentsCount) {
  5398. this._renderedCapability.resolve();
  5399. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  5400. this._pendingDispatchEvent = true;
  5401. await (0,_event_utils_js__WEBPACK_IMPORTED_MODULE_2__.waitOnEventOrTimeout)({
  5402. target: this.eventBus,
  5403. name: "annotationlayerrendered",
  5404. delay: 1000
  5405. });
  5406. if (!this._pendingDispatchEvent) {
  5407. return;
  5408. }
  5409. }
  5410. this._pendingDispatchEvent = false;
  5411. this.eventBus.dispatch("attachmentsloaded", {
  5412. source: this,
  5413. attachmentsCount
  5414. });
  5415. }
  5416. _bindLink(element, {
  5417. content,
  5418. filename
  5419. }) {
  5420. element.onclick = () => {
  5421. this.downloadManager.openOrDownloadData(content, filename);
  5422. return false;
  5423. };
  5424. }
  5425. render({
  5426. attachments,
  5427. keepRenderedCapability = false
  5428. }) {
  5429. if (this._attachments) {
  5430. this.reset(keepRenderedCapability);
  5431. }
  5432. this._attachments = attachments || null;
  5433. if (!attachments) {
  5434. this._dispatchEvent(0);
  5435. return;
  5436. }
  5437. const fragment = document.createDocumentFragment();
  5438. let attachmentsCount = 0;
  5439. for (const name in attachments) {
  5440. const item = attachments[name];
  5441. const content = item.content,
  5442. filename = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.getFilenameFromUrl)(item.filename, true);
  5443. const div = document.createElement("div");
  5444. div.className = "treeItem";
  5445. const element = document.createElement("a");
  5446. this._bindLink(element, {
  5447. content,
  5448. filename
  5449. });
  5450. element.textContent = this._normalizeTextContent(filename);
  5451. div.append(element);
  5452. fragment.append(div);
  5453. attachmentsCount++;
  5454. }
  5455. this._finishRendering(fragment, attachmentsCount);
  5456. }
  5457. #appendAttachment({
  5458. filename,
  5459. content
  5460. }) {
  5461. const renderedPromise = this._renderedCapability.promise;
  5462. renderedPromise.then(() => {
  5463. if (renderedPromise !== this._renderedCapability.promise) {
  5464. return;
  5465. }
  5466. const attachments = this._attachments || Object.create(null);
  5467. for (const name in attachments) {
  5468. if (filename === name) {
  5469. return;
  5470. }
  5471. }
  5472. attachments[filename] = {
  5473. filename,
  5474. content
  5475. };
  5476. this.render({
  5477. attachments,
  5478. keepRenderedCapability: true
  5479. });
  5480. });
  5481. }
  5482. }
  5483. __webpack_async_result__();
  5484. } catch(e) { __webpack_async_result__(e); } });
  5485. /***/ }),
  5486. /***/ 3611:
  5487. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5488. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5489. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5490. /* harmony export */ PDFCursorTools: () => (/* binding */ PDFCursorTools)
  5491. /* harmony export */ });
  5492. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  5493. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  5494. /* harmony import */ var _grab_to_pan_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6143);
  5495. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5496. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5497. class PDFCursorTools {
  5498. #active = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT;
  5499. #prevActive = null;
  5500. constructor({
  5501. container,
  5502. eventBus,
  5503. cursorToolOnLoad = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT
  5504. }) {
  5505. this.container = container;
  5506. this.eventBus = eventBus;
  5507. this.#addEventListeners();
  5508. Promise.resolve().then(() => {
  5509. this.switchTool(cursorToolOnLoad);
  5510. });
  5511. }
  5512. get activeTool() {
  5513. return this.#active;
  5514. }
  5515. switchTool(tool) {
  5516. if (this.#prevActive !== null) {
  5517. return;
  5518. }
  5519. if (tool === this.#active) {
  5520. return;
  5521. }
  5522. const disableActiveTool = () => {
  5523. switch (this.#active) {
  5524. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT:
  5525. break;
  5526. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.HAND:
  5527. this._handTool.deactivate();
  5528. break;
  5529. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.ZOOM:
  5530. }
  5531. };
  5532. switch (tool) {
  5533. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT:
  5534. disableActiveTool();
  5535. break;
  5536. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.HAND:
  5537. disableActiveTool();
  5538. this._handTool.activate();
  5539. break;
  5540. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.ZOOM:
  5541. default:
  5542. console.error(`switchTool: "${tool}" is an unsupported value.`);
  5543. return;
  5544. }
  5545. this.#active = tool;
  5546. this.eventBus.dispatch("cursortoolchanged", {
  5547. source: this,
  5548. tool
  5549. });
  5550. }
  5551. #addEventListeners() {
  5552. this.eventBus._on("switchcursortool", evt => {
  5553. this.switchTool(evt.tool);
  5554. });
  5555. let annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE,
  5556. presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL;
  5557. const disableActive = () => {
  5558. const prevActive = this.#active;
  5559. this.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT);
  5560. this.#prevActive ??= prevActive;
  5561. };
  5562. const enableActive = () => {
  5563. const prevActive = this.#prevActive;
  5564. if (prevActive !== null && annotationEditorMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE && presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL) {
  5565. this.#prevActive = null;
  5566. this.switchTool(prevActive);
  5567. }
  5568. };
  5569. this.eventBus._on("secondarytoolbarreset", evt => {
  5570. if (this.#prevActive !== null) {
  5571. annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
  5572. presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL;
  5573. enableActive();
  5574. }
  5575. });
  5576. this.eventBus._on("annotationeditormodechanged", ({
  5577. mode
  5578. }) => {
  5579. annotationEditorMode = mode;
  5580. if (mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE) {
  5581. enableActive();
  5582. } else {
  5583. disableActive();
  5584. }
  5585. });
  5586. this.eventBus._on("presentationmodechanged", ({
  5587. state
  5588. }) => {
  5589. presentationModeState = state;
  5590. if (state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL) {
  5591. enableActive();
  5592. } else if (state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN) {
  5593. disableActive();
  5594. }
  5595. });
  5596. }
  5597. get _handTool() {
  5598. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_handTool", new _grab_to_pan_js__WEBPACK_IMPORTED_MODULE_2__.GrabToPan({
  5599. element: this.container
  5600. }));
  5601. }
  5602. }
  5603. __webpack_async_result__();
  5604. } catch(e) { __webpack_async_result__(e); } });
  5605. /***/ }),
  5606. /***/ 6312:
  5607. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5608. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5609. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5610. /* harmony export */ PDFDocumentProperties: () => (/* binding */ PDFDocumentProperties)
  5611. /* harmony export */ });
  5612. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  5613. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1869);
  5614. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  5615. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5616. const DEFAULT_FIELD_CONTENT = "-";
  5617. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5618. const US_PAGE_NAMES = {
  5619. "8.5x11": "letter",
  5620. "8.5x14": "legal"
  5621. };
  5622. const METRIC_PAGE_NAMES = {
  5623. "297x420": "a-three",
  5624. "210x297": "a-four"
  5625. };
  5626. function getPageName(size, isPortrait, pageNames) {
  5627. const width = isPortrait ? size.width : size.height;
  5628. const height = isPortrait ? size.height : size.width;
  5629. return pageNames[`${width}x${height}`];
  5630. }
  5631. class PDFDocumentProperties {
  5632. #fieldData = null;
  5633. constructor({
  5634. dialog,
  5635. fields,
  5636. closeButton
  5637. }, overlayManager, eventBus, l10n, fileNameLookup) {
  5638. this.dialog = dialog;
  5639. this.fields = fields;
  5640. this.overlayManager = overlayManager;
  5641. this.l10n = l10n;
  5642. this._fileNameLookup = fileNameLookup;
  5643. this.#reset();
  5644. closeButton.addEventListener("click", this.close.bind(this));
  5645. this.overlayManager.register(this.dialog);
  5646. eventBus._on("pagechanging", evt => {
  5647. this._currentPageNumber = evt.pageNumber;
  5648. });
  5649. eventBus._on("rotationchanging", evt => {
  5650. this._pagesRotation = evt.pagesRotation;
  5651. });
  5652. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
  5653. }
  5654. async open() {
  5655. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  5656. const currentPageNumber = this._currentPageNumber;
  5657. const pagesRotation = this._pagesRotation;
  5658. if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
  5659. this.#updateUI();
  5660. return;
  5661. }
  5662. const {
  5663. info,
  5664. contentLength
  5665. } = await this.pdfDocument.getMetadata();
  5666. const [fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([this._fileNameLookup(), this.#parseFileSize(contentLength), this.#parseDate(info.CreationDate), this.#parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
  5667. return this.#parsePageSize((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getPageSizeInches)(pdfPage), pagesRotation);
  5668. }), this.#parseLinearization(info.IsLinearized)]);
  5669. this.#fieldData = Object.freeze({
  5670. fileName,
  5671. fileSize,
  5672. title: info.Title,
  5673. author: info.Author,
  5674. subject: info.Subject,
  5675. keywords: info.Keywords,
  5676. creationDate,
  5677. modificationDate,
  5678. creator: info.Creator,
  5679. producer: info.Producer,
  5680. version: info.PDFFormatVersion,
  5681. pageCount: this.pdfDocument.numPages,
  5682. pageSize,
  5683. linearized: isLinearized,
  5684. _currentPageNumber: currentPageNumber,
  5685. _pagesRotation: pagesRotation
  5686. });
  5687. this.#updateUI();
  5688. const {
  5689. length
  5690. } = await this.pdfDocument.getDownloadInfo();
  5691. if (contentLength === length) {
  5692. return;
  5693. }
  5694. const data = Object.assign(Object.create(null), this.#fieldData);
  5695. data.fileSize = await this.#parseFileSize(length);
  5696. this.#fieldData = Object.freeze(data);
  5697. this.#updateUI();
  5698. }
  5699. async close() {
  5700. this.overlayManager.close(this.dialog);
  5701. }
  5702. setDocument(pdfDocument) {
  5703. if (this.pdfDocument) {
  5704. this.#reset();
  5705. this.#updateUI(true);
  5706. }
  5707. if (!pdfDocument) {
  5708. return;
  5709. }
  5710. this.pdfDocument = pdfDocument;
  5711. this._dataAvailableCapability.resolve();
  5712. }
  5713. #reset() {
  5714. this.pdfDocument = null;
  5715. this.#fieldData = null;
  5716. this._dataAvailableCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability();
  5717. this._currentPageNumber = 1;
  5718. this._pagesRotation = 0;
  5719. }
  5720. #updateUI(reset = false) {
  5721. if (reset || !this.#fieldData) {
  5722. for (const id in this.fields) {
  5723. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5724. }
  5725. return;
  5726. }
  5727. if (this.overlayManager.active !== this.dialog) {
  5728. return;
  5729. }
  5730. for (const id in this.fields) {
  5731. const content = this.#fieldData[id];
  5732. this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5733. }
  5734. }
  5735. async #parseFileSize(fileSize = 0) {
  5736. const kb = fileSize / 1024,
  5737. mb = kb / 1024;
  5738. if (!kb) {
  5739. return undefined;
  5740. }
  5741. return this.l10n.get(`pdfjs-document-properties-${mb >= 1 ? "mb" : "kb"}`, {
  5742. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  5743. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  5744. size_b: fileSize.toLocaleString()
  5745. });
  5746. }
  5747. async #parsePageSize(pageSizeInches, pagesRotation) {
  5748. if (!pageSizeInches) {
  5749. return undefined;
  5750. }
  5751. if (pagesRotation % 180 !== 0) {
  5752. pageSizeInches = {
  5753. width: pageSizeInches.height,
  5754. height: pageSizeInches.width
  5755. };
  5756. }
  5757. const isPortrait = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isPortraitOrientation)(pageSizeInches);
  5758. let sizeInches = {
  5759. width: Math.round(pageSizeInches.width * 100) / 100,
  5760. height: Math.round(pageSizeInches.height * 100) / 100
  5761. };
  5762. let sizeMillimeters = {
  5763. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5764. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5765. };
  5766. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5767. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5768. const exactMillimeters = {
  5769. width: pageSizeInches.width * 25.4,
  5770. height: pageSizeInches.height * 25.4
  5771. };
  5772. const intMillimeters = {
  5773. width: Math.round(sizeMillimeters.width),
  5774. height: Math.round(sizeMillimeters.height)
  5775. };
  5776. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5777. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5778. if (rawName) {
  5779. sizeInches = {
  5780. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5781. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5782. };
  5783. sizeMillimeters = intMillimeters;
  5784. }
  5785. }
  5786. }
  5787. const [{
  5788. width,
  5789. height
  5790. }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`pdfjs-document-properties-page-size-unit-${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`pdfjs-document-properties-page-size-name-${rawName}`), this.l10n.get(`pdfjs-document-properties-page-size-orientation-${isPortrait ? "portrait" : "landscape"}`)]);
  5791. return this.l10n.get(`pdfjs-document-properties-page-size-dimension-${name ? "name-" : ""}string`, {
  5792. width: width.toLocaleString(),
  5793. height: height.toLocaleString(),
  5794. unit,
  5795. name,
  5796. orientation
  5797. });
  5798. }
  5799. async #parseDate(inputDate) {
  5800. const dateObject = pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PDFDateString.toDateObject(inputDate);
  5801. if (!dateObject) {
  5802. return undefined;
  5803. }
  5804. return this.l10n.get("pdfjs-document-properties-date-string", {
  5805. date: dateObject.toLocaleDateString(),
  5806. time: dateObject.toLocaleTimeString()
  5807. });
  5808. }
  5809. #parseLinearization(isLinearized) {
  5810. return this.l10n.get(`pdfjs-document-properties-linearized-${isLinearized ? "yes" : "no"}`);
  5811. }
  5812. }
  5813. __webpack_async_result__();
  5814. } catch(e) { __webpack_async_result__(e); } });
  5815. /***/ }),
  5816. /***/ 1795:
  5817. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5818. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5819. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5820. /* harmony export */ PDFFindBar: () => (/* binding */ PDFFindBar)
  5821. /* harmony export */ });
  5822. /* harmony import */ var _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3557);
  5823. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  5824. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__]);
  5825. _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5826. const MATCHES_COUNT_LIMIT = 1000;
  5827. class PDFFindBar {
  5828. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  5829. constructor(options, eventBus) {
  5830. this.opened = false;
  5831. this.bar = options.bar;
  5832. this.toggleButton = options.toggleButton;
  5833. this.findField = options.findField;
  5834. this.highlightAll = options.highlightAllCheckbox;
  5835. this.caseSensitive = options.caseSensitiveCheckbox;
  5836. this.matchDiacritics = options.matchDiacriticsCheckbox;
  5837. this.entireWord = options.entireWordCheckbox;
  5838. this.findMsg = options.findMsg;
  5839. this.findResultsCount = options.findResultsCount;
  5840. this.findPreviousButton = options.findPreviousButton;
  5841. this.findNextButton = options.findNextButton;
  5842. this.eventBus = eventBus;
  5843. this.toggleButton.addEventListener("click", () => {
  5844. this.toggle();
  5845. });
  5846. this.findField.addEventListener("input", () => {
  5847. this.dispatchEvent("");
  5848. });
  5849. this.bar.addEventListener("keydown", e => {
  5850. switch (e.keyCode) {
  5851. case 13:
  5852. if (e.target === this.findField) {
  5853. this.dispatchEvent("again", e.shiftKey);
  5854. }
  5855. break;
  5856. case 27:
  5857. this.close();
  5858. break;
  5859. }
  5860. });
  5861. this.findPreviousButton.addEventListener("click", () => {
  5862. this.dispatchEvent("again", true);
  5863. });
  5864. this.findNextButton.addEventListener("click", () => {
  5865. this.dispatchEvent("again", false);
  5866. });
  5867. this.highlightAll.addEventListener("click", () => {
  5868. this.dispatchEvent("highlightallchange");
  5869. });
  5870. this.caseSensitive.addEventListener("click", () => {
  5871. this.dispatchEvent("casesensitivitychange");
  5872. });
  5873. this.entireWord.addEventListener("click", () => {
  5874. this.dispatchEvent("entirewordchange");
  5875. });
  5876. this.matchDiacritics.addEventListener("click", () => {
  5877. this.dispatchEvent("diacriticmatchingchange");
  5878. });
  5879. }
  5880. reset() {
  5881. this.updateUIState();
  5882. }
  5883. dispatchEvent(type, findPrev = false) {
  5884. this.eventBus.dispatch("find", {
  5885. source: this,
  5886. type,
  5887. query: this.findField.value,
  5888. caseSensitive: this.caseSensitive.checked,
  5889. entireWord: this.entireWord.checked,
  5890. highlightAll: this.highlightAll.checked,
  5891. findPrevious: findPrev,
  5892. matchDiacritics: this.matchDiacritics.checked
  5893. });
  5894. }
  5895. updateUIState(state, previous, matchesCount) {
  5896. const {
  5897. findField,
  5898. findMsg
  5899. } = this;
  5900. let findMsgId = "",
  5901. status = "";
  5902. switch (state) {
  5903. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.FOUND:
  5904. break;
  5905. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.PENDING:
  5906. status = "pending";
  5907. break;
  5908. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.NOT_FOUND:
  5909. findMsgId = "pdfjs-find-not-found";
  5910. status = "notFound";
  5911. break;
  5912. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.WRAPPED:
  5913. findMsgId = `pdfjs-find-reached-${previous ? "top" : "bottom"}`;
  5914. break;
  5915. }
  5916. findField.setAttribute("data-status", status);
  5917. findField.setAttribute("aria-invalid", state === _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.NOT_FOUND);
  5918. findMsg.setAttribute("data-status", status);
  5919. if (findMsgId) {
  5920. findMsg.setAttribute("data-l10n-id", findMsgId);
  5921. } else {
  5922. findMsg.removeAttribute("data-l10n-id");
  5923. findMsg.textContent = "";
  5924. }
  5925. this.updateResultsCount(matchesCount);
  5926. }
  5927. updateResultsCount({
  5928. current = 0,
  5929. total = 0
  5930. } = {}) {
  5931. const {
  5932. findResultsCount
  5933. } = this;
  5934. if (total > 0) {
  5935. const limit = MATCHES_COUNT_LIMIT;
  5936. findResultsCount.setAttribute("data-l10n-id", `pdfjs-find-match-count${total > limit ? "-limit" : ""}`);
  5937. findResultsCount.setAttribute("data-l10n-args", JSON.stringify({
  5938. limit,
  5939. current,
  5940. total
  5941. }));
  5942. } else {
  5943. findResultsCount.removeAttribute("data-l10n-id");
  5944. findResultsCount.textContent = "";
  5945. }
  5946. }
  5947. open() {
  5948. if (!this.opened) {
  5949. this.#resizeObserver.observe(this.bar.parentNode);
  5950. this.#resizeObserver.observe(this.bar);
  5951. this.opened = true;
  5952. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleExpandedBtn)(this.toggleButton, true, this.bar);
  5953. }
  5954. this.findField.select();
  5955. this.findField.focus();
  5956. }
  5957. close() {
  5958. if (!this.opened) {
  5959. return;
  5960. }
  5961. this.#resizeObserver.disconnect();
  5962. this.opened = false;
  5963. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleExpandedBtn)(this.toggleButton, false, this.bar);
  5964. this.eventBus.dispatch("findbarclose", {
  5965. source: this
  5966. });
  5967. }
  5968. toggle() {
  5969. if (this.opened) {
  5970. this.close();
  5971. } else {
  5972. this.open();
  5973. }
  5974. }
  5975. #resizeObserverCallback(entries) {
  5976. const {
  5977. bar
  5978. } = this;
  5979. bar.classList.remove("wrapContainers");
  5980. const findbarHeight = bar.clientHeight;
  5981. const inputContainerHeight = bar.firstElementChild.clientHeight;
  5982. if (findbarHeight > inputContainerHeight) {
  5983. bar.classList.add("wrapContainers");
  5984. }
  5985. }
  5986. }
  5987. __webpack_async_result__();
  5988. } catch(e) { __webpack_async_result__(e); } });
  5989. /***/ }),
  5990. /***/ 3557:
  5991. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5992. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5993. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5994. /* harmony export */ FindState: () => (/* binding */ FindState),
  5995. /* harmony export */ PDFFindController: () => (/* binding */ PDFFindController)
  5996. /* harmony export */ });
  5997. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  5998. /* harmony import */ var _pdf_find_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6839);
  5999. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1869);
  6000. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__]);
  6001. pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  6002. const FindState = {
  6003. FOUND: 0,
  6004. NOT_FOUND: 1,
  6005. WRAPPED: 2,
  6006. PENDING: 3
  6007. };
  6008. const FIND_TIMEOUT = 250;
  6009. const MATCH_SCROLL_OFFSET_TOP = -50;
  6010. const MATCH_SCROLL_OFFSET_LEFT = -400;
  6011. const CHARACTERS_TO_NORMALIZE = {
  6012. "\u2010": "-",
  6013. "\u2018": "'",
  6014. "\u2019": "'",
  6015. "\u201A": "'",
  6016. "\u201B": "'",
  6017. "\u201C": '"',
  6018. "\u201D": '"',
  6019. "\u201E": '"',
  6020. "\u201F": '"',
  6021. "\u00BC": "1/4",
  6022. "\u00BD": "1/2",
  6023. "\u00BE": "3/4"
  6024. };
  6025. 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]);
  6026. let DIACRITICS_EXCEPTION_STR;
  6027. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  6028. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  6029. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  6030. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  6031. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  6032. const SYLLABLES_LENGTHS = new Map();
  6033. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  6034. const NFKC_CHARS_TO_NORMALIZE = new Map();
  6035. let noSyllablesRegExp = null;
  6036. let withSyllablesRegExp = null;
  6037. function normalize(text) {
  6038. const syllablePositions = [];
  6039. let m;
  6040. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  6041. let {
  6042. index
  6043. } = m;
  6044. for (const char of m[0]) {
  6045. let len = SYLLABLES_LENGTHS.get(char);
  6046. if (!len) {
  6047. len = char.normalize("NFD").length;
  6048. SYLLABLES_LENGTHS.set(char, len);
  6049. }
  6050. syllablePositions.push([len, index++]);
  6051. }
  6052. }
  6053. let normalizationRegex;
  6054. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  6055. normalizationRegex = noSyllablesRegExp;
  6056. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  6057. normalizationRegex = withSyllablesRegExp;
  6058. } else {
  6059. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6060. const toNormalizeWithNFKC = (0,_pdf_find_utils_js__WEBPACK_IMPORTED_MODULE_1__.getNormalizeWithNFKC)();
  6061. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  6062. const HKDiacritics = "(?:\u3099|\u309A)";
  6063. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  6064. if (syllablePositions.length === 0) {
  6065. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  6066. } else {
  6067. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  6068. }
  6069. }
  6070. const rawDiacriticsPositions = [];
  6071. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  6072. rawDiacriticsPositions.push([m[0].length, m.index]);
  6073. }
  6074. let normalized = text.normalize("NFD");
  6075. const positions = [[0, 0]];
  6076. let rawDiacriticsIndex = 0;
  6077. let syllableIndex = 0;
  6078. let shift = 0;
  6079. let shiftOrigin = 0;
  6080. let eol = 0;
  6081. let hasDiacritics = false;
  6082. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
  6083. i -= shiftOrigin;
  6084. if (p1) {
  6085. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  6086. const jj = replacement.length;
  6087. for (let j = 1; j < jj; j++) {
  6088. positions.push([i - shift + j, shift - j]);
  6089. }
  6090. shift -= jj - 1;
  6091. return replacement;
  6092. }
  6093. if (p2) {
  6094. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  6095. if (!replacement) {
  6096. replacement = p2.normalize("NFKC");
  6097. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  6098. }
  6099. const jj = replacement.length;
  6100. for (let j = 1; j < jj; j++) {
  6101. positions.push([i - shift + j, shift - j]);
  6102. }
  6103. shift -= jj - 1;
  6104. return replacement;
  6105. }
  6106. if (p3) {
  6107. hasDiacritics = true;
  6108. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  6109. ++rawDiacriticsIndex;
  6110. } else {
  6111. positions.push([i - 1 - shift + 1, shift - 1]);
  6112. shift -= 1;
  6113. shiftOrigin += 1;
  6114. }
  6115. positions.push([i - shift + 1, shift]);
  6116. shiftOrigin += 1;
  6117. eol += 1;
  6118. return p3.charAt(0);
  6119. }
  6120. if (p4) {
  6121. const hasTrailingDashEOL = p4.endsWith("\n");
  6122. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  6123. hasDiacritics = true;
  6124. let jj = len;
  6125. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  6126. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  6127. ++rawDiacriticsIndex;
  6128. }
  6129. for (let j = 1; j <= jj; j++) {
  6130. positions.push([i - 1 - shift + j, shift - j]);
  6131. }
  6132. shift -= jj;
  6133. shiftOrigin += jj;
  6134. if (hasTrailingDashEOL) {
  6135. i += len - 1;
  6136. positions.push([i - shift + 1, 1 + shift]);
  6137. shift += 1;
  6138. shiftOrigin += 1;
  6139. eol += 1;
  6140. return p4.slice(0, len);
  6141. }
  6142. return p4;
  6143. }
  6144. if (p5) {
  6145. const len = p5.length - 2;
  6146. positions.push([i - shift + len, 1 + shift]);
  6147. shift += 1;
  6148. shiftOrigin += 1;
  6149. eol += 1;
  6150. return p5.slice(0, -2);
  6151. }
  6152. if (p6) {
  6153. const len = p6.length - 1;
  6154. positions.push([i - shift + len, shift]);
  6155. shiftOrigin += 1;
  6156. eol += 1;
  6157. return p6.slice(0, -1);
  6158. }
  6159. if (p7) {
  6160. positions.push([i - shift + 1, shift - 1]);
  6161. shift -= 1;
  6162. shiftOrigin += 1;
  6163. eol += 1;
  6164. return " ";
  6165. }
  6166. if (i + eol === syllablePositions[syllableIndex]?.[1]) {
  6167. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  6168. ++syllableIndex;
  6169. for (let j = 1; j <= newCharLen; j++) {
  6170. positions.push([i - (shift - j), shift - j]);
  6171. }
  6172. shift -= newCharLen;
  6173. shiftOrigin += newCharLen;
  6174. }
  6175. return p8;
  6176. });
  6177. positions.push([normalized.length, shift]);
  6178. return [normalized, positions, hasDiacritics];
  6179. }
  6180. function getOriginalIndex(diffs, pos, len) {
  6181. if (!diffs) {
  6182. return [pos, len];
  6183. }
  6184. const start = pos;
  6185. const end = pos + len - 1;
  6186. let i = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(diffs, x => x[0] >= start);
  6187. if (diffs[i][0] > start) {
  6188. --i;
  6189. }
  6190. let j = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  6191. if (diffs[j][0] > end) {
  6192. --j;
  6193. }
  6194. const oldStart = start + diffs[i][1];
  6195. const oldEnd = end + diffs[j][1];
  6196. const oldLen = oldEnd + 1 - oldStart;
  6197. return [oldStart, oldLen];
  6198. }
  6199. class PDFFindController {
  6200. #state = null;
  6201. #updateMatchesCountOnProgress = true;
  6202. #visitedPagesCount = 0;
  6203. constructor({
  6204. linkService,
  6205. eventBus,
  6206. updateMatchesCountOnProgress = true
  6207. }) {
  6208. this._linkService = linkService;
  6209. this._eventBus = eventBus;
  6210. this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
  6211. this.onIsPageVisible = null;
  6212. this.#reset();
  6213. eventBus._on("find", this.#onFind.bind(this));
  6214. eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
  6215. }
  6216. get highlightMatches() {
  6217. return this._highlightMatches;
  6218. }
  6219. get pageMatches() {
  6220. return this._pageMatches;
  6221. }
  6222. get pageMatchesLength() {
  6223. return this._pageMatchesLength;
  6224. }
  6225. get selected() {
  6226. return this._selected;
  6227. }
  6228. get state() {
  6229. return this.#state;
  6230. }
  6231. setDocument(pdfDocument) {
  6232. if (this._pdfDocument) {
  6233. this.#reset();
  6234. }
  6235. if (!pdfDocument) {
  6236. return;
  6237. }
  6238. this._pdfDocument = pdfDocument;
  6239. this._firstPageCapability.resolve();
  6240. }
  6241. #onFind(state) {
  6242. if (!state) {
  6243. return;
  6244. }
  6245. const pdfDocument = this._pdfDocument;
  6246. const {
  6247. type
  6248. } = state;
  6249. if (this.#state === null || this.#shouldDirtyMatch(state)) {
  6250. this._dirtyMatch = true;
  6251. }
  6252. this.#state = state;
  6253. if (type !== "highlightallchange") {
  6254. this.#updateUIState(FindState.PENDING);
  6255. }
  6256. this._firstPageCapability.promise.then(() => {
  6257. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  6258. return;
  6259. }
  6260. this.#extractText();
  6261. const findbarClosed = !this._highlightMatches;
  6262. const pendingTimeout = !!this._findTimeout;
  6263. if (this._findTimeout) {
  6264. clearTimeout(this._findTimeout);
  6265. this._findTimeout = null;
  6266. }
  6267. if (!type) {
  6268. this._findTimeout = setTimeout(() => {
  6269. this.#nextMatch();
  6270. this._findTimeout = null;
  6271. }, FIND_TIMEOUT);
  6272. } else if (this._dirtyMatch) {
  6273. this.#nextMatch();
  6274. } else if (type === "again") {
  6275. this.#nextMatch();
  6276. if (findbarClosed && this.#state.highlightAll) {
  6277. this.#updateAllPages();
  6278. }
  6279. } else if (type === "highlightallchange") {
  6280. if (pendingTimeout) {
  6281. this.#nextMatch();
  6282. } else {
  6283. this._highlightMatches = true;
  6284. }
  6285. this.#updateAllPages();
  6286. } else {
  6287. this.#nextMatch();
  6288. }
  6289. });
  6290. }
  6291. scrollMatchIntoView({
  6292. element = null,
  6293. selectedLeft = 0,
  6294. pageIndex = -1,
  6295. matchIndex = -1
  6296. }) {
  6297. if (!this._scrollMatches || !element) {
  6298. return;
  6299. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6300. return;
  6301. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6302. return;
  6303. }
  6304. this._scrollMatches = false;
  6305. const spot = {
  6306. top: MATCH_SCROLL_OFFSET_TOP,
  6307. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  6308. };
  6309. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.scrollIntoView)(element, spot, true);
  6310. }
  6311. #reset() {
  6312. this._highlightMatches = false;
  6313. this._scrollMatches = false;
  6314. this._pdfDocument = null;
  6315. this._pageMatches = [];
  6316. this._pageMatchesLength = [];
  6317. this.#visitedPagesCount = 0;
  6318. this.#state = null;
  6319. this._selected = {
  6320. pageIdx: -1,
  6321. matchIdx: -1
  6322. };
  6323. this._offset = {
  6324. pageIdx: null,
  6325. matchIdx: null,
  6326. wrapped: false
  6327. };
  6328. this._extractTextPromises = [];
  6329. this._pageContents = [];
  6330. this._pageDiffs = [];
  6331. this._hasDiacritics = [];
  6332. this._matchesCountTotal = 0;
  6333. this._pagesToSearch = null;
  6334. this._pendingFindMatches = new Set();
  6335. this._resumePageIdx = null;
  6336. this._dirtyMatch = false;
  6337. clearTimeout(this._findTimeout);
  6338. this._findTimeout = null;
  6339. this._firstPageCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.PromiseCapability();
  6340. }
  6341. get #query() {
  6342. const {
  6343. query
  6344. } = this.#state;
  6345. if (typeof query === "string") {
  6346. if (query !== this._rawQuery) {
  6347. this._rawQuery = query;
  6348. [this._normalizedQuery] = normalize(query);
  6349. }
  6350. return this._normalizedQuery;
  6351. }
  6352. return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
  6353. }
  6354. #shouldDirtyMatch(state) {
  6355. const newQuery = state.query,
  6356. prevQuery = this.#state.query;
  6357. const newType = typeof newQuery,
  6358. prevType = typeof prevQuery;
  6359. if (newType !== prevType) {
  6360. return true;
  6361. }
  6362. if (newType === "string") {
  6363. if (newQuery !== prevQuery) {
  6364. return true;
  6365. }
  6366. } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
  6367. return true;
  6368. }
  6369. switch (state.type) {
  6370. case "again":
  6371. const pageNumber = this._selected.pageIdx + 1;
  6372. const linkService = this._linkService;
  6373. return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
  6374. case "highlightallchange":
  6375. return false;
  6376. }
  6377. return true;
  6378. }
  6379. #isEntireWord(content, startIdx, length) {
  6380. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  6381. if (match) {
  6382. const first = content.charCodeAt(startIdx);
  6383. const limit = match[1].charCodeAt(0);
  6384. if ((0,_pdf_find_utils_js__WEBPACK_IMPORTED_MODULE_1__.getCharacterType)(first) === (0,_pdf_find_utils_js__WEBPACK_IMPORTED_MODULE_1__.getCharacterType)(limit)) {
  6385. return false;
  6386. }
  6387. }
  6388. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  6389. if (match) {
  6390. const last = content.charCodeAt(startIdx + length - 1);
  6391. const limit = match[1].charCodeAt(0);
  6392. if ((0,_pdf_find_utils_js__WEBPACK_IMPORTED_MODULE_1__.getCharacterType)(last) === (0,_pdf_find_utils_js__WEBPACK_IMPORTED_MODULE_1__.getCharacterType)(limit)) {
  6393. return false;
  6394. }
  6395. }
  6396. return true;
  6397. }
  6398. #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
  6399. const matches = this._pageMatches[pageIndex] = [];
  6400. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  6401. if (!query) {
  6402. return;
  6403. }
  6404. const diffs = this._pageDiffs[pageIndex];
  6405. let match;
  6406. while ((match = query.exec(pageContent)) !== null) {
  6407. if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
  6408. continue;
  6409. }
  6410. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  6411. if (matchLen) {
  6412. matches.push(matchPos);
  6413. matchesLength.push(matchLen);
  6414. }
  6415. }
  6416. }
  6417. #convertToRegExpString(query, hasDiacritics) {
  6418. const {
  6419. matchDiacritics
  6420. } = this.#state;
  6421. let isUnicode = false;
  6422. query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  6423. if (p1) {
  6424. return `[ ]*\\${p1}[ ]*`;
  6425. }
  6426. if (p2) {
  6427. return `[ ]*${p2}[ ]*`;
  6428. }
  6429. if (p3) {
  6430. return "[ ]+";
  6431. }
  6432. if (matchDiacritics) {
  6433. return p4 || p5;
  6434. }
  6435. if (p4) {
  6436. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  6437. }
  6438. if (hasDiacritics) {
  6439. isUnicode = true;
  6440. return `${p5}\\p{M}*`;
  6441. }
  6442. return p5;
  6443. });
  6444. const trailingSpaces = "[ ]*";
  6445. if (query.endsWith(trailingSpaces)) {
  6446. query = query.slice(0, query.length - trailingSpaces.length);
  6447. }
  6448. if (matchDiacritics) {
  6449. if (hasDiacritics) {
  6450. DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
  6451. isUnicode = true;
  6452. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  6453. }
  6454. }
  6455. return [isUnicode, query];
  6456. }
  6457. #calculateMatch(pageIndex) {
  6458. let query = this.#query;
  6459. if (query.length === 0) {
  6460. return;
  6461. }
  6462. const {
  6463. caseSensitive,
  6464. entireWord
  6465. } = this.#state;
  6466. const pageContent = this._pageContents[pageIndex];
  6467. const hasDiacritics = this._hasDiacritics[pageIndex];
  6468. let isUnicode = false;
  6469. if (typeof query === "string") {
  6470. [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
  6471. } else {
  6472. query = query.sort().reverse().map(q => {
  6473. const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
  6474. isUnicode ||= isUnicodePart;
  6475. return `(${queryPart})`;
  6476. }).join("|");
  6477. }
  6478. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  6479. query = query ? new RegExp(query, flags) : null;
  6480. this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
  6481. if (this.#state.highlightAll) {
  6482. this.#updatePage(pageIndex);
  6483. }
  6484. if (this._resumePageIdx === pageIndex) {
  6485. this._resumePageIdx = null;
  6486. this.#nextPageMatch();
  6487. }
  6488. const pageMatchesCount = this._pageMatches[pageIndex].length;
  6489. this._matchesCountTotal += pageMatchesCount;
  6490. if (this.#updateMatchesCountOnProgress) {
  6491. if (pageMatchesCount > 0) {
  6492. this.#updateUIResultsCount();
  6493. }
  6494. } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
  6495. this.#updateUIResultsCount();
  6496. }
  6497. }
  6498. #extractText() {
  6499. if (this._extractTextPromises.length > 0) {
  6500. return;
  6501. }
  6502. let promise = Promise.resolve();
  6503. const textOptions = {
  6504. disableNormalization: true
  6505. };
  6506. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6507. const extractTextCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.PromiseCapability();
  6508. this._extractTextPromises[i] = extractTextCapability.promise;
  6509. promise = promise.then(() => {
  6510. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  6511. return pdfPage.getTextContent(textOptions);
  6512. }).then(textContent => {
  6513. const strBuf = [];
  6514. for (const textItem of textContent.items) {
  6515. strBuf.push(textItem.str);
  6516. if (textItem.hasEOL) {
  6517. strBuf.push("\n");
  6518. }
  6519. }
  6520. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  6521. extractTextCapability.resolve();
  6522. }, reason => {
  6523. console.error(`Unable to get text content for page ${i + 1}`, reason);
  6524. this._pageContents[i] = "";
  6525. this._pageDiffs[i] = null;
  6526. this._hasDiacritics[i] = false;
  6527. extractTextCapability.resolve();
  6528. });
  6529. });
  6530. }
  6531. }
  6532. #updatePage(index) {
  6533. if (this._scrollMatches && this._selected.pageIdx === index) {
  6534. this._linkService.page = index + 1;
  6535. }
  6536. this._eventBus.dispatch("updatetextlayermatches", {
  6537. source: this,
  6538. pageIndex: index
  6539. });
  6540. }
  6541. #updateAllPages() {
  6542. this._eventBus.dispatch("updatetextlayermatches", {
  6543. source: this,
  6544. pageIndex: -1
  6545. });
  6546. }
  6547. #nextMatch() {
  6548. const previous = this.#state.findPrevious;
  6549. const currentPageIndex = this._linkService.page - 1;
  6550. const numPages = this._linkService.pagesCount;
  6551. this._highlightMatches = true;
  6552. if (this._dirtyMatch) {
  6553. this._dirtyMatch = false;
  6554. this._selected.pageIdx = this._selected.matchIdx = -1;
  6555. this._offset.pageIdx = currentPageIndex;
  6556. this._offset.matchIdx = null;
  6557. this._offset.wrapped = false;
  6558. this._resumePageIdx = null;
  6559. this._pageMatches.length = 0;
  6560. this._pageMatchesLength.length = 0;
  6561. this.#visitedPagesCount = 0;
  6562. this._matchesCountTotal = 0;
  6563. this.#updateAllPages();
  6564. for (let i = 0; i < numPages; i++) {
  6565. if (this._pendingFindMatches.has(i)) {
  6566. continue;
  6567. }
  6568. this._pendingFindMatches.add(i);
  6569. this._extractTextPromises[i].then(() => {
  6570. this._pendingFindMatches.delete(i);
  6571. this.#calculateMatch(i);
  6572. });
  6573. }
  6574. }
  6575. const query = this.#query;
  6576. if (query.length === 0) {
  6577. this.#updateUIState(FindState.FOUND);
  6578. return;
  6579. }
  6580. if (this._resumePageIdx) {
  6581. return;
  6582. }
  6583. const offset = this._offset;
  6584. this._pagesToSearch = numPages;
  6585. if (offset.matchIdx !== null) {
  6586. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  6587. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6588. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6589. this.#updateMatch(true);
  6590. return;
  6591. }
  6592. this.#advanceOffsetPage(previous);
  6593. }
  6594. this.#nextPageMatch();
  6595. }
  6596. #matchesReady(matches) {
  6597. const offset = this._offset;
  6598. const numMatches = matches.length;
  6599. const previous = this.#state.findPrevious;
  6600. if (numMatches) {
  6601. offset.matchIdx = previous ? numMatches - 1 : 0;
  6602. this.#updateMatch(true);
  6603. return true;
  6604. }
  6605. this.#advanceOffsetPage(previous);
  6606. if (offset.wrapped) {
  6607. offset.matchIdx = null;
  6608. if (this._pagesToSearch < 0) {
  6609. this.#updateMatch(false);
  6610. return true;
  6611. }
  6612. }
  6613. return false;
  6614. }
  6615. #nextPageMatch() {
  6616. if (this._resumePageIdx !== null) {
  6617. console.error("There can only be one pending page.");
  6618. }
  6619. let matches = null;
  6620. do {
  6621. const pageIdx = this._offset.pageIdx;
  6622. matches = this._pageMatches[pageIdx];
  6623. if (!matches) {
  6624. this._resumePageIdx = pageIdx;
  6625. break;
  6626. }
  6627. } while (!this.#matchesReady(matches));
  6628. }
  6629. #advanceOffsetPage(previous) {
  6630. const offset = this._offset;
  6631. const numPages = this._linkService.pagesCount;
  6632. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6633. offset.matchIdx = null;
  6634. this._pagesToSearch--;
  6635. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6636. offset.pageIdx = previous ? numPages - 1 : 0;
  6637. offset.wrapped = true;
  6638. }
  6639. }
  6640. #updateMatch(found = false) {
  6641. let state = FindState.NOT_FOUND;
  6642. const wrapped = this._offset.wrapped;
  6643. this._offset.wrapped = false;
  6644. if (found) {
  6645. const previousPage = this._selected.pageIdx;
  6646. this._selected.pageIdx = this._offset.pageIdx;
  6647. this._selected.matchIdx = this._offset.matchIdx;
  6648. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6649. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6650. this.#updatePage(previousPage);
  6651. }
  6652. }
  6653. this.#updateUIState(state, this.#state.findPrevious);
  6654. if (this._selected.pageIdx !== -1) {
  6655. this._scrollMatches = true;
  6656. this.#updatePage(this._selected.pageIdx);
  6657. }
  6658. }
  6659. #onFindBarClose(evt) {
  6660. const pdfDocument = this._pdfDocument;
  6661. this._firstPageCapability.promise.then(() => {
  6662. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  6663. return;
  6664. }
  6665. if (this._findTimeout) {
  6666. clearTimeout(this._findTimeout);
  6667. this._findTimeout = null;
  6668. }
  6669. if (this._resumePageIdx) {
  6670. this._resumePageIdx = null;
  6671. this._dirtyMatch = true;
  6672. }
  6673. this.#updateUIState(FindState.FOUND);
  6674. this._highlightMatches = false;
  6675. this.#updateAllPages();
  6676. });
  6677. }
  6678. #requestMatchesCount() {
  6679. const {
  6680. pageIdx,
  6681. matchIdx
  6682. } = this._selected;
  6683. let current = 0,
  6684. total = this._matchesCountTotal;
  6685. if (matchIdx !== -1) {
  6686. for (let i = 0; i < pageIdx; i++) {
  6687. current += this._pageMatches[i]?.length || 0;
  6688. }
  6689. current += matchIdx + 1;
  6690. }
  6691. if (current < 1 || current > total) {
  6692. current = total = 0;
  6693. }
  6694. return {
  6695. current,
  6696. total
  6697. };
  6698. }
  6699. #updateUIResultsCount() {
  6700. this._eventBus.dispatch("updatefindmatchescount", {
  6701. source: this,
  6702. matchesCount: this.#requestMatchesCount()
  6703. });
  6704. }
  6705. #updateUIState(state, previous = false) {
  6706. if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
  6707. return;
  6708. }
  6709. this._eventBus.dispatch("updatefindcontrolstate", {
  6710. source: this,
  6711. state,
  6712. previous,
  6713. matchesCount: this.#requestMatchesCount(),
  6714. rawQuery: this.#state?.query ?? null
  6715. });
  6716. }
  6717. }
  6718. __webpack_async_result__();
  6719. } catch(e) { __webpack_async_result__(e); } });
  6720. /***/ }),
  6721. /***/ 6839:
  6722. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  6723. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6724. /* harmony export */ getCharacterType: () => (/* binding */ getCharacterType),
  6725. /* harmony export */ getNormalizeWithNFKC: () => (/* binding */ getNormalizeWithNFKC)
  6726. /* harmony export */ });
  6727. /* unused harmony export CharacterType */
  6728. const CharacterType = {
  6729. SPACE: 0,
  6730. ALPHA_LETTER: 1,
  6731. PUNCT: 2,
  6732. HAN_LETTER: 3,
  6733. KATAKANA_LETTER: 4,
  6734. HIRAGANA_LETTER: 5,
  6735. HALFWIDTH_KATAKANA_LETTER: 6,
  6736. THAI_LETTER: 7
  6737. };
  6738. function isAlphabeticalScript(charCode) {
  6739. return charCode < 0x2e80;
  6740. }
  6741. function isAscii(charCode) {
  6742. return (charCode & 0xff80) === 0;
  6743. }
  6744. function isAsciiAlpha(charCode) {
  6745. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6746. }
  6747. function isAsciiDigit(charCode) {
  6748. return charCode >= 0x30 && charCode <= 0x39;
  6749. }
  6750. function isAsciiSpace(charCode) {
  6751. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6752. }
  6753. function isHan(charCode) {
  6754. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6755. }
  6756. function isKatakana(charCode) {
  6757. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6758. }
  6759. function isHiragana(charCode) {
  6760. return charCode >= 0x3040 && charCode <= 0x309f;
  6761. }
  6762. function isHalfwidthKatakana(charCode) {
  6763. return charCode >= 0xff60 && charCode <= 0xff9f;
  6764. }
  6765. function isThai(charCode) {
  6766. return (charCode & 0xff80) === 0x0e00;
  6767. }
  6768. function getCharacterType(charCode) {
  6769. if (isAlphabeticalScript(charCode)) {
  6770. if (isAscii(charCode)) {
  6771. if (isAsciiSpace(charCode)) {
  6772. return CharacterType.SPACE;
  6773. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6774. return CharacterType.ALPHA_LETTER;
  6775. }
  6776. return CharacterType.PUNCT;
  6777. } else if (isThai(charCode)) {
  6778. return CharacterType.THAI_LETTER;
  6779. } else if (charCode === 0xa0) {
  6780. return CharacterType.SPACE;
  6781. }
  6782. return CharacterType.ALPHA_LETTER;
  6783. }
  6784. if (isHan(charCode)) {
  6785. return CharacterType.HAN_LETTER;
  6786. } else if (isKatakana(charCode)) {
  6787. return CharacterType.KATAKANA_LETTER;
  6788. } else if (isHiragana(charCode)) {
  6789. return CharacterType.HIRAGANA_LETTER;
  6790. } else if (isHalfwidthKatakana(charCode)) {
  6791. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6792. }
  6793. return CharacterType.ALPHA_LETTER;
  6794. }
  6795. let NormalizeWithNFKC;
  6796. function getNormalizeWithNFKC() {
  6797. NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`;
  6798. return NormalizeWithNFKC;
  6799. }
  6800. /***/ }),
  6801. /***/ 6418:
  6802. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  6803. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6804. /* harmony export */ PDFHistory: () => (/* binding */ PDFHistory)
  6805. /* harmony export */ });
  6806. /* unused harmony exports isDestArraysEqual, isDestHashesEqual */
  6807. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  6808. /* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6554);
  6809. const HASH_CHANGE_TIMEOUT = 1000;
  6810. const POSITION_UPDATED_THRESHOLD = 50;
  6811. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  6812. function getCurrentHash() {
  6813. return document.location.hash;
  6814. }
  6815. class PDFHistory {
  6816. constructor({
  6817. linkService,
  6818. eventBus
  6819. }) {
  6820. this.linkService = linkService;
  6821. this.eventBus = eventBus;
  6822. this._initialized = false;
  6823. this._fingerprint = "";
  6824. this.reset();
  6825. this._boundEvents = null;
  6826. this.eventBus._on("pagesinit", () => {
  6827. this._isPagesLoaded = false;
  6828. this.eventBus._on("pagesloaded", evt => {
  6829. this._isPagesLoaded = !!evt.pagesCount;
  6830. }, {
  6831. once: true
  6832. });
  6833. });
  6834. }
  6835. initialize({
  6836. fingerprint,
  6837. resetHistory = false,
  6838. updateUrl = false
  6839. }) {
  6840. if (!fingerprint || typeof fingerprint !== "string") {
  6841. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6842. return;
  6843. }
  6844. if (this._initialized) {
  6845. this.reset();
  6846. }
  6847. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6848. this._fingerprint = fingerprint;
  6849. this._updateUrl = updateUrl === true;
  6850. this._initialized = true;
  6851. this._bindEvents();
  6852. const state = window.history.state;
  6853. this._popStateInProgress = false;
  6854. this._blockHashChange = 0;
  6855. this._currentHash = getCurrentHash();
  6856. this._numPositionUpdates = 0;
  6857. this._uid = this._maxUid = 0;
  6858. this._destination = null;
  6859. this._position = null;
  6860. if (!this._isValidState(state, true) || resetHistory) {
  6861. const {
  6862. hash,
  6863. page,
  6864. rotation
  6865. } = this._parseCurrentHash(true);
  6866. if (!hash || reInitialized || resetHistory) {
  6867. this._pushOrReplaceState(null, true);
  6868. return;
  6869. }
  6870. this._pushOrReplaceState({
  6871. hash,
  6872. page,
  6873. rotation
  6874. }, true);
  6875. return;
  6876. }
  6877. const destination = state.destination;
  6878. this._updateInternalState(destination, state.uid, true);
  6879. if (destination.rotation !== undefined) {
  6880. this._initialRotation = destination.rotation;
  6881. }
  6882. if (destination.dest) {
  6883. this._initialBookmark = JSON.stringify(destination.dest);
  6884. this._destination.page = null;
  6885. } else if (destination.hash) {
  6886. this._initialBookmark = destination.hash;
  6887. } else if (destination.page) {
  6888. this._initialBookmark = `page=${destination.page}`;
  6889. }
  6890. }
  6891. reset() {
  6892. if (this._initialized) {
  6893. this._pageHide();
  6894. this._initialized = false;
  6895. this._unbindEvents();
  6896. }
  6897. if (this._updateViewareaTimeout) {
  6898. clearTimeout(this._updateViewareaTimeout);
  6899. this._updateViewareaTimeout = null;
  6900. }
  6901. this._initialBookmark = null;
  6902. this._initialRotation = null;
  6903. }
  6904. push({
  6905. namedDest = null,
  6906. explicitDest,
  6907. pageNumber
  6908. }) {
  6909. if (!this._initialized) {
  6910. return;
  6911. }
  6912. if (namedDest && typeof namedDest !== "string") {
  6913. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  6914. return;
  6915. } else if (!Array.isArray(explicitDest)) {
  6916. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  6917. return;
  6918. } else if (!this._isValidPage(pageNumber)) {
  6919. if (pageNumber !== null || this._destination) {
  6920. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  6921. return;
  6922. }
  6923. }
  6924. const hash = namedDest || JSON.stringify(explicitDest);
  6925. if (!hash) {
  6926. return;
  6927. }
  6928. let forceReplace = false;
  6929. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6930. if (this._destination.page) {
  6931. return;
  6932. }
  6933. forceReplace = true;
  6934. }
  6935. if (this._popStateInProgress && !forceReplace) {
  6936. return;
  6937. }
  6938. this._pushOrReplaceState({
  6939. dest: explicitDest,
  6940. hash,
  6941. page: pageNumber,
  6942. rotation: this.linkService.rotation
  6943. }, forceReplace);
  6944. if (!this._popStateInProgress) {
  6945. this._popStateInProgress = true;
  6946. Promise.resolve().then(() => {
  6947. this._popStateInProgress = false;
  6948. });
  6949. }
  6950. }
  6951. pushPage(pageNumber) {
  6952. if (!this._initialized) {
  6953. return;
  6954. }
  6955. if (!this._isValidPage(pageNumber)) {
  6956. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  6957. return;
  6958. }
  6959. if (this._destination?.page === pageNumber) {
  6960. return;
  6961. }
  6962. if (this._popStateInProgress) {
  6963. return;
  6964. }
  6965. this._pushOrReplaceState({
  6966. dest: null,
  6967. hash: `page=${pageNumber}`,
  6968. page: pageNumber,
  6969. rotation: this.linkService.rotation
  6970. });
  6971. if (!this._popStateInProgress) {
  6972. this._popStateInProgress = true;
  6973. Promise.resolve().then(() => {
  6974. this._popStateInProgress = false;
  6975. });
  6976. }
  6977. }
  6978. pushCurrentPosition() {
  6979. if (!this._initialized || this._popStateInProgress) {
  6980. return;
  6981. }
  6982. this._tryPushCurrentPosition();
  6983. }
  6984. back() {
  6985. if (!this._initialized || this._popStateInProgress) {
  6986. return;
  6987. }
  6988. const state = window.history.state;
  6989. if (this._isValidState(state) && state.uid > 0) {
  6990. window.history.back();
  6991. }
  6992. }
  6993. forward() {
  6994. if (!this._initialized || this._popStateInProgress) {
  6995. return;
  6996. }
  6997. const state = window.history.state;
  6998. if (this._isValidState(state) && state.uid < this._maxUid) {
  6999. window.history.forward();
  7000. }
  7001. }
  7002. get popStateInProgress() {
  7003. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7004. }
  7005. get initialBookmark() {
  7006. return this._initialized ? this._initialBookmark : null;
  7007. }
  7008. get initialRotation() {
  7009. return this._initialized ? this._initialRotation : null;
  7010. }
  7011. _pushOrReplaceState(destination, forceReplace = false) {
  7012. const shouldReplace = forceReplace || !this._destination;
  7013. const newState = {
  7014. fingerprint: this._fingerprint,
  7015. uid: shouldReplace ? this._uid : this._uid + 1,
  7016. destination
  7017. };
  7018. this._updateInternalState(destination, newState.uid);
  7019. let newUrl;
  7020. if (this._updateUrl && destination?.hash) {
  7021. const baseUrl = document.location.href.split("#")[0];
  7022. if (!baseUrl.startsWith("file://")) {
  7023. newUrl = `${baseUrl}#${destination.hash}`;
  7024. }
  7025. }
  7026. if (shouldReplace) {
  7027. window.history.replaceState(newState, "", newUrl);
  7028. } else {
  7029. window.history.pushState(newState, "", newUrl);
  7030. }
  7031. }
  7032. _tryPushCurrentPosition(temporary = false) {
  7033. if (!this._position) {
  7034. return;
  7035. }
  7036. let position = this._position;
  7037. if (temporary) {
  7038. position = Object.assign(Object.create(null), this._position);
  7039. position.temporary = true;
  7040. }
  7041. if (!this._destination) {
  7042. this._pushOrReplaceState(position);
  7043. return;
  7044. }
  7045. if (this._destination.temporary) {
  7046. this._pushOrReplaceState(position, true);
  7047. return;
  7048. }
  7049. if (this._destination.hash === position.hash) {
  7050. return;
  7051. }
  7052. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7053. return;
  7054. }
  7055. let forceReplace = false;
  7056. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7057. if (this._destination.dest !== undefined || !this._destination.first) {
  7058. return;
  7059. }
  7060. forceReplace = true;
  7061. }
  7062. this._pushOrReplaceState(position, forceReplace);
  7063. }
  7064. _isValidPage(val) {
  7065. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  7066. }
  7067. _isValidState(state, checkReload = false) {
  7068. if (!state) {
  7069. return false;
  7070. }
  7071. if (state.fingerprint !== this._fingerprint) {
  7072. if (checkReload) {
  7073. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7074. return false;
  7075. }
  7076. const [perfEntry] = performance.getEntriesByType("navigation");
  7077. if (perfEntry?.type !== "reload") {
  7078. return false;
  7079. }
  7080. } else {
  7081. return false;
  7082. }
  7083. }
  7084. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7085. return false;
  7086. }
  7087. if (state.destination === null || typeof state.destination !== "object") {
  7088. return false;
  7089. }
  7090. return true;
  7091. }
  7092. _updateInternalState(destination, uid, removeTemporary = false) {
  7093. if (this._updateViewareaTimeout) {
  7094. clearTimeout(this._updateViewareaTimeout);
  7095. this._updateViewareaTimeout = null;
  7096. }
  7097. if (removeTemporary && destination?.temporary) {
  7098. delete destination.temporary;
  7099. }
  7100. this._destination = destination;
  7101. this._uid = uid;
  7102. this._maxUid = Math.max(this._maxUid, uid);
  7103. this._numPositionUpdates = 0;
  7104. }
  7105. _parseCurrentHash(checkNameddest = false) {
  7106. const hash = unescape(getCurrentHash()).substring(1);
  7107. const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
  7108. const nameddest = params.get("nameddest") || "";
  7109. let page = params.get("page") | 0;
  7110. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  7111. page = null;
  7112. }
  7113. return {
  7114. hash,
  7115. page,
  7116. rotation: this.linkService.rotation
  7117. };
  7118. }
  7119. _updateViewarea({
  7120. location
  7121. }) {
  7122. if (this._updateViewareaTimeout) {
  7123. clearTimeout(this._updateViewareaTimeout);
  7124. this._updateViewareaTimeout = null;
  7125. }
  7126. this._position = {
  7127. hash: location.pdfOpenParams.substring(1),
  7128. page: this.linkService.page,
  7129. first: location.pageNumber,
  7130. rotation: location.rotation
  7131. };
  7132. if (this._popStateInProgress) {
  7133. return;
  7134. }
  7135. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7136. this._numPositionUpdates++;
  7137. }
  7138. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7139. this._updateViewareaTimeout = setTimeout(() => {
  7140. if (!this._popStateInProgress) {
  7141. this._tryPushCurrentPosition(true);
  7142. }
  7143. this._updateViewareaTimeout = null;
  7144. }, UPDATE_VIEWAREA_TIMEOUT);
  7145. }
  7146. }
  7147. _popState({
  7148. state
  7149. }) {
  7150. const newHash = getCurrentHash(),
  7151. hashChanged = this._currentHash !== newHash;
  7152. this._currentHash = newHash;
  7153. if (!state) {
  7154. this._uid++;
  7155. const {
  7156. hash,
  7157. page,
  7158. rotation
  7159. } = this._parseCurrentHash();
  7160. this._pushOrReplaceState({
  7161. hash,
  7162. page,
  7163. rotation
  7164. }, true);
  7165. return;
  7166. }
  7167. if (!this._isValidState(state)) {
  7168. return;
  7169. }
  7170. this._popStateInProgress = true;
  7171. if (hashChanged) {
  7172. this._blockHashChange++;
  7173. (0,_event_utils_js__WEBPACK_IMPORTED_MODULE_1__.waitOnEventOrTimeout)({
  7174. target: window,
  7175. name: "hashchange",
  7176. delay: HASH_CHANGE_TIMEOUT
  7177. }).then(() => {
  7178. this._blockHashChange--;
  7179. });
  7180. }
  7181. const destination = state.destination;
  7182. this._updateInternalState(destination, state.uid, true);
  7183. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(destination.rotation)) {
  7184. this.linkService.rotation = destination.rotation;
  7185. }
  7186. if (destination.dest) {
  7187. this.linkService.goToDestination(destination.dest);
  7188. } else if (destination.hash) {
  7189. this.linkService.setHash(destination.hash);
  7190. } else if (destination.page) {
  7191. this.linkService.page = destination.page;
  7192. }
  7193. Promise.resolve().then(() => {
  7194. this._popStateInProgress = false;
  7195. });
  7196. }
  7197. _pageHide() {
  7198. if (!this._destination || this._destination.temporary) {
  7199. this._tryPushCurrentPosition();
  7200. }
  7201. }
  7202. _bindEvents() {
  7203. if (this._boundEvents) {
  7204. return;
  7205. }
  7206. this._boundEvents = {
  7207. updateViewarea: this._updateViewarea.bind(this),
  7208. popState: this._popState.bind(this),
  7209. pageHide: this._pageHide.bind(this)
  7210. };
  7211. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7212. window.addEventListener("popstate", this._boundEvents.popState);
  7213. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7214. }
  7215. _unbindEvents() {
  7216. if (!this._boundEvents) {
  7217. return;
  7218. }
  7219. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7220. window.removeEventListener("popstate", this._boundEvents.popState);
  7221. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7222. this._boundEvents = null;
  7223. }
  7224. }
  7225. function isDestHashesEqual(destHash, pushHash) {
  7226. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7227. return false;
  7228. }
  7229. if (destHash === pushHash) {
  7230. return true;
  7231. }
  7232. const nameddest = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(destHash).get("nameddest");
  7233. if (nameddest === pushHash) {
  7234. return true;
  7235. }
  7236. return false;
  7237. }
  7238. function isDestArraysEqual(firstDest, secondDest) {
  7239. function isEntryEqual(first, second) {
  7240. if (typeof first !== typeof second) {
  7241. return false;
  7242. }
  7243. if (Array.isArray(first) || Array.isArray(second)) {
  7244. return false;
  7245. }
  7246. if (first !== null && typeof first === "object" && second !== null) {
  7247. if (Object.keys(first).length !== Object.keys(second).length) {
  7248. return false;
  7249. }
  7250. for (const key in first) {
  7251. if (!isEntryEqual(first[key], second[key])) {
  7252. return false;
  7253. }
  7254. }
  7255. return true;
  7256. }
  7257. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7258. }
  7259. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7260. return false;
  7261. }
  7262. if (firstDest.length !== secondDest.length) {
  7263. return false;
  7264. }
  7265. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  7266. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7267. return false;
  7268. }
  7269. }
  7270. return true;
  7271. }
  7272. /***/ }),
  7273. /***/ 3706:
  7274. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  7275. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7276. /* harmony export */ PDFLayerViewer: () => (/* binding */ PDFLayerViewer)
  7277. /* harmony export */ });
  7278. /* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9415);
  7279. class PDFLayerViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
  7280. constructor(options) {
  7281. super(options);
  7282. this.eventBus._on("optionalcontentconfigchanged", evt => {
  7283. this.#updateLayers(evt.promise);
  7284. });
  7285. this.eventBus._on("resetlayers", () => {
  7286. this.#updateLayers();
  7287. });
  7288. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  7289. }
  7290. reset() {
  7291. super.reset();
  7292. this._optionalContentConfig = null;
  7293. this._optionalContentHash = null;
  7294. }
  7295. _dispatchEvent(layersCount) {
  7296. this.eventBus.dispatch("layersloaded", {
  7297. source: this,
  7298. layersCount
  7299. });
  7300. }
  7301. _bindLink(element, {
  7302. groupId,
  7303. input
  7304. }) {
  7305. const setVisibility = () => {
  7306. this._optionalContentConfig.setVisibility(groupId, input.checked);
  7307. this._optionalContentHash = this._optionalContentConfig.getHash();
  7308. this.eventBus.dispatch("optionalcontentconfig", {
  7309. source: this,
  7310. promise: Promise.resolve(this._optionalContentConfig)
  7311. });
  7312. };
  7313. element.onclick = evt => {
  7314. if (evt.target === input) {
  7315. setVisibility();
  7316. return true;
  7317. } else if (evt.target !== element) {
  7318. return true;
  7319. }
  7320. input.checked = !input.checked;
  7321. setVisibility();
  7322. return false;
  7323. };
  7324. }
  7325. async _setNestedName(element, {
  7326. name = null
  7327. }) {
  7328. if (typeof name === "string") {
  7329. element.textContent = this._normalizeTextContent(name);
  7330. return;
  7331. }
  7332. element.textContent = await this._l10n.get("pdfjs-additional-layers");
  7333. element.style.fontStyle = "italic";
  7334. }
  7335. _addToggleButton(div, {
  7336. name = null
  7337. }) {
  7338. super._addToggleButton(div, name === null);
  7339. }
  7340. _toggleAllTreeItems() {
  7341. if (!this._optionalContentConfig) {
  7342. return;
  7343. }
  7344. super._toggleAllTreeItems();
  7345. }
  7346. render({
  7347. optionalContentConfig,
  7348. pdfDocument
  7349. }) {
  7350. if (this._optionalContentConfig) {
  7351. this.reset();
  7352. }
  7353. this._optionalContentConfig = optionalContentConfig || null;
  7354. this._pdfDocument = pdfDocument || null;
  7355. const groups = optionalContentConfig?.getOrder();
  7356. if (!groups) {
  7357. this._dispatchEvent(0);
  7358. return;
  7359. }
  7360. this._optionalContentHash = optionalContentConfig.getHash();
  7361. const fragment = document.createDocumentFragment(),
  7362. queue = [{
  7363. parent: fragment,
  7364. groups
  7365. }];
  7366. let layersCount = 0,
  7367. hasAnyNesting = false;
  7368. while (queue.length > 0) {
  7369. const levelData = queue.shift();
  7370. for (const groupId of levelData.groups) {
  7371. const div = document.createElement("div");
  7372. div.className = "treeItem";
  7373. const element = document.createElement("a");
  7374. div.append(element);
  7375. if (typeof groupId === "object") {
  7376. hasAnyNesting = true;
  7377. this._addToggleButton(div, groupId);
  7378. this._setNestedName(element, groupId);
  7379. const itemsDiv = document.createElement("div");
  7380. itemsDiv.className = "treeItems";
  7381. div.append(itemsDiv);
  7382. queue.push({
  7383. parent: itemsDiv,
  7384. groups: groupId.order
  7385. });
  7386. } else {
  7387. const group = optionalContentConfig.getGroup(groupId);
  7388. const input = document.createElement("input");
  7389. this._bindLink(element, {
  7390. groupId,
  7391. input
  7392. });
  7393. input.type = "checkbox";
  7394. input.checked = group.visible;
  7395. const label = document.createElement("label");
  7396. label.textContent = this._normalizeTextContent(group.name);
  7397. label.append(input);
  7398. element.append(label);
  7399. layersCount++;
  7400. }
  7401. levelData.parent.append(div);
  7402. }
  7403. }
  7404. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7405. }
  7406. async #updateLayers(promise = null) {
  7407. if (!this._optionalContentConfig) {
  7408. return;
  7409. }
  7410. const pdfDocument = this._pdfDocument;
  7411. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig());
  7412. if (pdfDocument !== this._pdfDocument) {
  7413. return;
  7414. }
  7415. if (promise) {
  7416. if (optionalContentConfig.getHash() === this._optionalContentHash) {
  7417. return;
  7418. }
  7419. } else {
  7420. this.eventBus.dispatch("optionalcontentconfig", {
  7421. source: this,
  7422. promise: Promise.resolve(optionalContentConfig)
  7423. });
  7424. }
  7425. this.render({
  7426. optionalContentConfig,
  7427. pdfDocument: this._pdfDocument
  7428. });
  7429. }
  7430. }
  7431. /***/ }),
  7432. /***/ 3234:
  7433. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  7434. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7435. /* harmony export */ LinkTarget: () => (/* binding */ LinkTarget),
  7436. /* harmony export */ PDFLinkService: () => (/* binding */ PDFLinkService),
  7437. /* harmony export */ SimpleLinkService: () => (/* binding */ SimpleLinkService)
  7438. /* harmony export */ });
  7439. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  7440. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  7441. const LinkTarget = {
  7442. NONE: 0,
  7443. SELF: 1,
  7444. BLANK: 2,
  7445. PARENT: 3,
  7446. TOP: 4
  7447. };
  7448. function addLinkAttributes(link, {
  7449. url,
  7450. target,
  7451. rel,
  7452. enabled = true
  7453. } = {}) {
  7454. if (!url || typeof url !== "string") {
  7455. throw new Error('A valid "url" parameter must provided.');
  7456. }
  7457. if (enabled) {
  7458. link.href = link.title = url;
  7459. } else {
  7460. link.href = "";
  7461. link.title = `Disabled: ${url}`;
  7462. link.onclick = () => {
  7463. return false;
  7464. };
  7465. }
  7466. let targetStr = "";
  7467. switch (target) {
  7468. case LinkTarget.NONE:
  7469. break;
  7470. case LinkTarget.SELF:
  7471. targetStr = "_self";
  7472. break;
  7473. case LinkTarget.BLANK:
  7474. targetStr = "_blank";
  7475. break;
  7476. case LinkTarget.PARENT:
  7477. targetStr = "_parent";
  7478. break;
  7479. case LinkTarget.TOP:
  7480. targetStr = "_top";
  7481. break;
  7482. }
  7483. link.target = targetStr;
  7484. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  7485. }
  7486. class PDFLinkService {
  7487. #pagesRefCache = new Map();
  7488. constructor({
  7489. eventBus,
  7490. externalLinkTarget = null,
  7491. externalLinkRel = null,
  7492. ignoreDestinationZoom = false
  7493. } = {}) {
  7494. this.eventBus = eventBus;
  7495. this.externalLinkTarget = externalLinkTarget;
  7496. this.externalLinkRel = externalLinkRel;
  7497. this.externalLinkEnabled = true;
  7498. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7499. this.baseUrl = null;
  7500. this.pdfDocument = null;
  7501. this.pdfViewer = null;
  7502. this.pdfHistory = null;
  7503. }
  7504. setDocument(pdfDocument, baseUrl = null) {
  7505. this.baseUrl = baseUrl;
  7506. this.pdfDocument = pdfDocument;
  7507. this.#pagesRefCache.clear();
  7508. }
  7509. setViewer(pdfViewer) {
  7510. this.pdfViewer = pdfViewer;
  7511. }
  7512. setHistory(pdfHistory) {
  7513. this.pdfHistory = pdfHistory;
  7514. }
  7515. get pagesCount() {
  7516. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7517. }
  7518. get page() {
  7519. return this.pdfViewer.currentPageNumber;
  7520. }
  7521. set page(value) {
  7522. this.pdfViewer.currentPageNumber = value;
  7523. }
  7524. get rotation() {
  7525. return this.pdfViewer.pagesRotation;
  7526. }
  7527. set rotation(value) {
  7528. this.pdfViewer.pagesRotation = value;
  7529. }
  7530. get isInPresentationMode() {
  7531. return this.pdfViewer.isInPresentationMode;
  7532. }
  7533. #goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
  7534. const destRef = explicitDest[0];
  7535. let pageNumber;
  7536. if (typeof destRef === "object" && destRef !== null) {
  7537. pageNumber = this._cachedPageNumber(destRef);
  7538. if (!pageNumber) {
  7539. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  7540. this.cachePageRef(pageIndex + 1, destRef);
  7541. this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
  7542. }).catch(() => {
  7543. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
  7544. });
  7545. return;
  7546. }
  7547. } else if (Number.isInteger(destRef)) {
  7548. pageNumber = destRef + 1;
  7549. } else {
  7550. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
  7551. return;
  7552. }
  7553. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  7554. console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
  7555. return;
  7556. }
  7557. if (this.pdfHistory) {
  7558. this.pdfHistory.pushCurrentPosition();
  7559. this.pdfHistory.push({
  7560. namedDest,
  7561. explicitDest,
  7562. pageNumber
  7563. });
  7564. }
  7565. this.pdfViewer.scrollPageIntoView({
  7566. pageNumber,
  7567. destArray: explicitDest,
  7568. ignoreDestinationZoom: this._ignoreDestinationZoom
  7569. });
  7570. }
  7571. async goToDestination(dest) {
  7572. if (!this.pdfDocument) {
  7573. return;
  7574. }
  7575. let namedDest, explicitDest;
  7576. if (typeof dest === "string") {
  7577. namedDest = dest;
  7578. explicitDest = await this.pdfDocument.getDestination(dest);
  7579. } else {
  7580. namedDest = null;
  7581. explicitDest = await dest;
  7582. }
  7583. if (!Array.isArray(explicitDest)) {
  7584. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
  7585. return;
  7586. }
  7587. this.#goToDestinationHelper(dest, namedDest, explicitDest);
  7588. }
  7589. goToPage(val) {
  7590. if (!this.pdfDocument) {
  7591. return;
  7592. }
  7593. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  7594. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7595. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  7596. return;
  7597. }
  7598. if (this.pdfHistory) {
  7599. this.pdfHistory.pushCurrentPosition();
  7600. this.pdfHistory.pushPage(pageNumber);
  7601. }
  7602. this.pdfViewer.scrollPageIntoView({
  7603. pageNumber
  7604. });
  7605. }
  7606. addLinkAttributes(link, url, newWindow = false) {
  7607. addLinkAttributes(link, {
  7608. url,
  7609. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  7610. rel: this.externalLinkRel,
  7611. enabled: this.externalLinkEnabled
  7612. });
  7613. }
  7614. getDestinationHash(dest) {
  7615. if (typeof dest === "string") {
  7616. if (dest.length > 0) {
  7617. return this.getAnchorUrl("#" + escape(dest));
  7618. }
  7619. } else if (Array.isArray(dest)) {
  7620. const str = JSON.stringify(dest);
  7621. if (str.length > 0) {
  7622. return this.getAnchorUrl("#" + escape(str));
  7623. }
  7624. }
  7625. return this.getAnchorUrl("");
  7626. }
  7627. getAnchorUrl(anchor) {
  7628. return this.baseUrl ? this.baseUrl + anchor : anchor;
  7629. }
  7630. setHash(hash) {
  7631. if (!this.pdfDocument) {
  7632. return;
  7633. }
  7634. let pageNumber, dest;
  7635. if (hash.includes("=")) {
  7636. const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
  7637. if (params.has("search")) {
  7638. const query = params.get("search").replaceAll('"', ""),
  7639. phrase = params.get("phrase") === "true";
  7640. this.eventBus.dispatch("findfromurlhash", {
  7641. source: this,
  7642. query: phrase ? query : query.match(/\S+/g)
  7643. });
  7644. }
  7645. if (params.has("page")) {
  7646. pageNumber = params.get("page") | 0 || 1;
  7647. }
  7648. if (params.has("zoom")) {
  7649. const zoomArgs = params.get("zoom").split(",");
  7650. const zoomArg = zoomArgs[0];
  7651. const zoomArgNumber = parseFloat(zoomArg);
  7652. if (!zoomArg.includes("Fit")) {
  7653. dest = [null, {
  7654. name: "XYZ"
  7655. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7656. } else if (zoomArg === "Fit" || zoomArg === "FitB") {
  7657. dest = [null, {
  7658. name: zoomArg
  7659. }];
  7660. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7661. dest = [null, {
  7662. name: zoomArg
  7663. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7664. } else if (zoomArg === "FitR") {
  7665. if (zoomArgs.length !== 5) {
  7666. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7667. } else {
  7668. dest = [null, {
  7669. name: zoomArg
  7670. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7671. }
  7672. } else {
  7673. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  7674. }
  7675. }
  7676. if (dest) {
  7677. this.pdfViewer.scrollPageIntoView({
  7678. pageNumber: pageNumber || this.page,
  7679. destArray: dest,
  7680. allowNegativeOffset: true
  7681. });
  7682. } else if (pageNumber) {
  7683. this.page = pageNumber;
  7684. }
  7685. if (params.has("pagemode")) {
  7686. this.eventBus.dispatch("pagemode", {
  7687. source: this,
  7688. mode: params.get("pagemode")
  7689. });
  7690. }
  7691. if (params.has("nameddest")) {
  7692. this.goToDestination(params.get("nameddest"));
  7693. }
  7694. return;
  7695. }
  7696. dest = unescape(hash);
  7697. try {
  7698. dest = JSON.parse(dest);
  7699. if (!Array.isArray(dest)) {
  7700. dest = dest.toString();
  7701. }
  7702. } catch {}
  7703. if (typeof dest === "string" || PDFLinkService.#isValidExplicitDestination(dest)) {
  7704. this.goToDestination(dest);
  7705. return;
  7706. }
  7707. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  7708. }
  7709. executeNamedAction(action) {
  7710. switch (action) {
  7711. case "GoBack":
  7712. this.pdfHistory?.back();
  7713. break;
  7714. case "GoForward":
  7715. this.pdfHistory?.forward();
  7716. break;
  7717. case "NextPage":
  7718. this.pdfViewer.nextPage();
  7719. break;
  7720. case "PrevPage":
  7721. this.pdfViewer.previousPage();
  7722. break;
  7723. case "LastPage":
  7724. this.page = this.pagesCount;
  7725. break;
  7726. case "FirstPage":
  7727. this.page = 1;
  7728. break;
  7729. default:
  7730. break;
  7731. }
  7732. this.eventBus.dispatch("namedaction", {
  7733. source: this,
  7734. action
  7735. });
  7736. }
  7737. async executeSetOCGState(action) {
  7738. const pdfDocument = this.pdfDocument;
  7739. const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  7740. if (pdfDocument !== this.pdfDocument) {
  7741. return;
  7742. }
  7743. let operator;
  7744. for (const elem of action.state) {
  7745. switch (elem) {
  7746. case "ON":
  7747. case "OFF":
  7748. case "Toggle":
  7749. operator = elem;
  7750. continue;
  7751. }
  7752. switch (operator) {
  7753. case "ON":
  7754. optionalContentConfig.setVisibility(elem, true);
  7755. break;
  7756. case "OFF":
  7757. optionalContentConfig.setVisibility(elem, false);
  7758. break;
  7759. case "Toggle":
  7760. const group = optionalContentConfig.getGroup(elem);
  7761. if (group) {
  7762. optionalContentConfig.setVisibility(elem, !group.visible);
  7763. }
  7764. break;
  7765. }
  7766. }
  7767. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  7768. }
  7769. cachePageRef(pageNum, pageRef) {
  7770. if (!pageRef) {
  7771. return;
  7772. }
  7773. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  7774. this.#pagesRefCache.set(refStr, pageNum);
  7775. }
  7776. _cachedPageNumber(pageRef) {
  7777. if (!pageRef) {
  7778. return null;
  7779. }
  7780. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  7781. return this.#pagesRefCache.get(refStr) || null;
  7782. }
  7783. static #isValidExplicitDestination(dest) {
  7784. if (!Array.isArray(dest)) {
  7785. return false;
  7786. }
  7787. const destLength = dest.length;
  7788. if (destLength < 2) {
  7789. return false;
  7790. }
  7791. const page = dest[0];
  7792. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7793. return false;
  7794. }
  7795. const zoom = dest[1];
  7796. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  7797. return false;
  7798. }
  7799. let allowNull = true;
  7800. switch (zoom.name) {
  7801. case "XYZ":
  7802. if (destLength !== 5) {
  7803. return false;
  7804. }
  7805. break;
  7806. case "Fit":
  7807. case "FitB":
  7808. return destLength === 2;
  7809. case "FitH":
  7810. case "FitBH":
  7811. case "FitV":
  7812. case "FitBV":
  7813. if (destLength !== 3) {
  7814. return false;
  7815. }
  7816. break;
  7817. case "FitR":
  7818. if (destLength !== 6) {
  7819. return false;
  7820. }
  7821. allowNull = false;
  7822. break;
  7823. default:
  7824. return false;
  7825. }
  7826. for (let i = 2; i < destLength; i++) {
  7827. const param = dest[i];
  7828. if (!(typeof param === "number" || allowNull && param === null)) {
  7829. return false;
  7830. }
  7831. }
  7832. return true;
  7833. }
  7834. }
  7835. class SimpleLinkService {
  7836. constructor() {
  7837. this.externalLinkEnabled = true;
  7838. }
  7839. get pagesCount() {
  7840. return 0;
  7841. }
  7842. get page() {
  7843. return 0;
  7844. }
  7845. set page(value) {}
  7846. get rotation() {
  7847. return 0;
  7848. }
  7849. set rotation(value) {}
  7850. get isInPresentationMode() {
  7851. return false;
  7852. }
  7853. async goToDestination(dest) {}
  7854. goToPage(val) {}
  7855. addLinkAttributes(link, url, newWindow = false) {
  7856. addLinkAttributes(link, {
  7857. url,
  7858. enabled: this.externalLinkEnabled
  7859. });
  7860. }
  7861. getDestinationHash(dest) {
  7862. return "#";
  7863. }
  7864. getAnchorUrl(hash) {
  7865. return "#";
  7866. }
  7867. setHash(hash) {}
  7868. executeNamedAction(action) {}
  7869. executeSetOCGState(action) {}
  7870. cachePageRef(pageNum, pageRef) {}
  7871. }
  7872. /***/ }),
  7873. /***/ 1141:
  7874. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  7875. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  7876. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7877. /* harmony export */ PDFOutlineViewer: () => (/* binding */ PDFOutlineViewer)
  7878. /* harmony export */ });
  7879. /* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9415);
  7880. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1869);
  7881. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4927);
  7882. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  7883. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  7884. class PDFOutlineViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
  7885. constructor(options) {
  7886. super(options);
  7887. this.linkService = options.linkService;
  7888. this.downloadManager = options.downloadManager;
  7889. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  7890. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  7891. this.eventBus._on("pagechanging", evt => {
  7892. this._currentPageNumber = evt.pageNumber;
  7893. });
  7894. this.eventBus._on("pagesloaded", evt => {
  7895. this._isPagesLoaded = !!evt.pagesCount;
  7896. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  7897. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  7898. }
  7899. });
  7900. this.eventBus._on("sidebarviewchanged", evt => {
  7901. this._sidebarView = evt.view;
  7902. });
  7903. }
  7904. reset() {
  7905. super.reset();
  7906. this._outline = null;
  7907. this._pageNumberToDestHashCapability = null;
  7908. this._currentPageNumber = 1;
  7909. this._isPagesLoaded = null;
  7910. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  7911. this._currentOutlineItemCapability.resolve(false);
  7912. }
  7913. this._currentOutlineItemCapability = null;
  7914. }
  7915. _dispatchEvent(outlineCount) {
  7916. this._currentOutlineItemCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability();
  7917. if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
  7918. this._currentOutlineItemCapability.resolve(false);
  7919. } else if (this._isPagesLoaded !== null) {
  7920. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  7921. }
  7922. this.eventBus.dispatch("outlineloaded", {
  7923. source: this,
  7924. outlineCount,
  7925. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  7926. });
  7927. }
  7928. _bindLink(element, {
  7929. url,
  7930. newWindow,
  7931. action,
  7932. attachment,
  7933. dest,
  7934. setOCGState
  7935. }) {
  7936. const {
  7937. linkService
  7938. } = this;
  7939. if (url) {
  7940. linkService.addLinkAttributes(element, url, newWindow);
  7941. return;
  7942. }
  7943. if (action) {
  7944. element.href = linkService.getAnchorUrl("");
  7945. element.onclick = () => {
  7946. linkService.executeNamedAction(action);
  7947. return false;
  7948. };
  7949. return;
  7950. }
  7951. if (attachment) {
  7952. element.href = linkService.getAnchorUrl("");
  7953. element.onclick = () => {
  7954. this.downloadManager.openOrDownloadData(attachment.content, attachment.filename);
  7955. return false;
  7956. };
  7957. return;
  7958. }
  7959. if (setOCGState) {
  7960. element.href = linkService.getAnchorUrl("");
  7961. element.onclick = () => {
  7962. linkService.executeSetOCGState(setOCGState);
  7963. return false;
  7964. };
  7965. return;
  7966. }
  7967. element.href = linkService.getDestinationHash(dest);
  7968. element.onclick = evt => {
  7969. this._updateCurrentTreeItem(evt.target.parentNode);
  7970. if (dest) {
  7971. linkService.goToDestination(dest);
  7972. }
  7973. return false;
  7974. };
  7975. }
  7976. _setStyles(element, {
  7977. bold,
  7978. italic
  7979. }) {
  7980. if (bold) {
  7981. element.style.fontWeight = "bold";
  7982. }
  7983. if (italic) {
  7984. element.style.fontStyle = "italic";
  7985. }
  7986. }
  7987. _addToggleButton(div, {
  7988. count,
  7989. items
  7990. }) {
  7991. let hidden = false;
  7992. if (count < 0) {
  7993. let totalCount = items.length;
  7994. if (totalCount > 0) {
  7995. const queue = [...items];
  7996. while (queue.length > 0) {
  7997. const {
  7998. count: nestedCount,
  7999. items: nestedItems
  8000. } = queue.shift();
  8001. if (nestedCount > 0 && nestedItems.length > 0) {
  8002. totalCount += nestedItems.length;
  8003. queue.push(...nestedItems);
  8004. }
  8005. }
  8006. }
  8007. if (Math.abs(count) === totalCount) {
  8008. hidden = true;
  8009. }
  8010. }
  8011. super._addToggleButton(div, hidden);
  8012. }
  8013. _toggleAllTreeItems() {
  8014. if (!this._outline) {
  8015. return;
  8016. }
  8017. super._toggleAllTreeItems();
  8018. }
  8019. render({
  8020. outline,
  8021. pdfDocument
  8022. }) {
  8023. if (this._outline) {
  8024. this.reset();
  8025. }
  8026. this._outline = outline || null;
  8027. this._pdfDocument = pdfDocument || null;
  8028. if (!outline) {
  8029. this._dispatchEvent(0);
  8030. return;
  8031. }
  8032. const fragment = document.createDocumentFragment();
  8033. const queue = [{
  8034. parent: fragment,
  8035. items: outline
  8036. }];
  8037. let outlineCount = 0,
  8038. hasAnyNesting = false;
  8039. while (queue.length > 0) {
  8040. const levelData = queue.shift();
  8041. for (const item of levelData.items) {
  8042. const div = document.createElement("div");
  8043. div.className = "treeItem";
  8044. const element = document.createElement("a");
  8045. this._bindLink(element, item);
  8046. this._setStyles(element, item);
  8047. element.textContent = this._normalizeTextContent(item.title);
  8048. div.append(element);
  8049. if (item.items.length > 0) {
  8050. hasAnyNesting = true;
  8051. this._addToggleButton(div, item);
  8052. const itemsDiv = document.createElement("div");
  8053. itemsDiv.className = "treeItems";
  8054. div.append(itemsDiv);
  8055. queue.push({
  8056. parent: itemsDiv,
  8057. items: item.items
  8058. });
  8059. }
  8060. levelData.parent.append(div);
  8061. outlineCount++;
  8062. }
  8063. }
  8064. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8065. }
  8066. async _currentOutlineItem() {
  8067. if (!this._isPagesLoaded) {
  8068. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8069. }
  8070. if (!this._outline || !this._pdfDocument) {
  8071. return;
  8072. }
  8073. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  8074. if (!pageNumberToDestHash) {
  8075. return;
  8076. }
  8077. this._updateCurrentTreeItem(null);
  8078. if (this._sidebarView !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_2__.SidebarView.OUTLINE) {
  8079. return;
  8080. }
  8081. for (let i = this._currentPageNumber; i > 0; i--) {
  8082. const destHash = pageNumberToDestHash.get(i);
  8083. if (!destHash) {
  8084. continue;
  8085. }
  8086. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  8087. if (!linkElement) {
  8088. continue;
  8089. }
  8090. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8091. break;
  8092. }
  8093. }
  8094. async _getPageNumberToDestHash(pdfDocument) {
  8095. if (this._pageNumberToDestHashCapability) {
  8096. return this._pageNumberToDestHashCapability.promise;
  8097. }
  8098. this._pageNumberToDestHashCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability();
  8099. const pageNumberToDestHash = new Map(),
  8100. pageNumberNesting = new Map();
  8101. const queue = [{
  8102. nesting: 0,
  8103. items: this._outline
  8104. }];
  8105. while (queue.length > 0) {
  8106. const levelData = queue.shift(),
  8107. currentNesting = levelData.nesting;
  8108. for (const {
  8109. dest,
  8110. items
  8111. } of levelData.items) {
  8112. let explicitDest, pageNumber;
  8113. if (typeof dest === "string") {
  8114. explicitDest = await pdfDocument.getDestination(dest);
  8115. if (pdfDocument !== this._pdfDocument) {
  8116. return null;
  8117. }
  8118. } else {
  8119. explicitDest = dest;
  8120. }
  8121. if (Array.isArray(explicitDest)) {
  8122. const [destRef] = explicitDest;
  8123. if (typeof destRef === "object" && destRef !== null) {
  8124. pageNumber = this.linkService._cachedPageNumber(destRef);
  8125. if (!pageNumber) {
  8126. try {
  8127. pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
  8128. if (pdfDocument !== this._pdfDocument) {
  8129. return null;
  8130. }
  8131. this.linkService.cachePageRef(pageNumber, destRef);
  8132. } catch {}
  8133. }
  8134. } else if (Number.isInteger(destRef)) {
  8135. pageNumber = destRef + 1;
  8136. }
  8137. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8138. const destHash = this.linkService.getDestinationHash(dest);
  8139. pageNumberToDestHash.set(pageNumber, destHash);
  8140. pageNumberNesting.set(pageNumber, currentNesting);
  8141. }
  8142. }
  8143. if (items.length > 0) {
  8144. queue.push({
  8145. nesting: currentNesting + 1,
  8146. items
  8147. });
  8148. }
  8149. }
  8150. }
  8151. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8152. return this._pageNumberToDestHashCapability.promise;
  8153. }
  8154. }
  8155. __webpack_async_result__();
  8156. } catch(e) { __webpack_async_result__(e); } });
  8157. /***/ }),
  8158. /***/ 6732:
  8159. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  8160. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  8161. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8162. /* harmony export */ PDFPageView: () => (/* binding */ PDFPageView)
  8163. /* harmony export */ });
  8164. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  8165. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  8166. /* harmony import */ var _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2640);
  8167. /* harmony import */ var _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6735);
  8168. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8961);
  8169. /* harmony import */ var _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(758);
  8170. /* harmony import */ var web_l10n_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7910);
  8171. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3234);
  8172. /* harmony import */ var _struct_tree_layer_builder_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7498);
  8173. /* harmony import */ var _text_accessibility_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(4630);
  8174. /* harmony import */ var _text_highlighter_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(4274);
  8175. /* harmony import */ var _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1013);
  8176. /* harmony import */ var _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8012);
  8177. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__, _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__, _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__, web_l10n_utils__WEBPACK_IMPORTED_MODULE_6__, _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__]);
  8178. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__, _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__, _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__, web_l10n_utils__WEBPACK_IMPORTED_MODULE_6__, _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  8179. const MAX_CANVAS_PIXELS = _app_options_js__WEBPACK_IMPORTED_MODULE_4__.compatibilityParams.maxCanvasPixels || 16777216;
  8180. const DEFAULT_LAYER_PROPERTIES = null;
  8181. class PDFPageView {
  8182. #annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  8183. #hasRestrictedScaling = false;
  8184. #layerProperties = null;
  8185. #loadingId = null;
  8186. #previousRotation = null;
  8187. #renderError = null;
  8188. #renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
  8189. #textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  8190. #useThumbnailCanvas = {
  8191. directDrawing: true,
  8192. initialOptionalContent: true,
  8193. regularAnnotations: true
  8194. };
  8195. #viewportMap = new WeakMap();
  8196. constructor(options) {
  8197. const container = options.container;
  8198. const defaultViewport = options.defaultViewport;
  8199. this.id = options.id;
  8200. this.renderingId = "page" + this.id;
  8201. this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
  8202. this.pdfPage = null;
  8203. this.pageLabel = null;
  8204. this.rotation = 0;
  8205. this.scale = options.scale || _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
  8206. this.viewport = defaultViewport;
  8207. this.pdfPageRotate = defaultViewport.rotation;
  8208. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  8209. this.#textLayerMode = options.textLayerMode ?? _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  8210. this.#annotationMode = options.annotationMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  8211. this.imageResourcesPath = options.imageResourcesPath || "";
  8212. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  8213. this.maxCanvasPixels = options.maxCanvasPixels ?? MAX_CANVAS_PIXELS;
  8214. this.pageColors = options.pageColors || null;
  8215. this.eventBus = options.eventBus;
  8216. this.renderingQueue = options.renderingQueue;
  8217. this.l10n = options.l10n || web_l10n_utils__WEBPACK_IMPORTED_MODULE_6__.NullL10n;
  8218. this.renderTask = null;
  8219. this.resume = null;
  8220. this._isStandalone = !this.renderingQueue?.hasViewer();
  8221. this._container = container;
  8222. this._annotationCanvasMap = null;
  8223. this.annotationLayer = null;
  8224. this.annotationEditorLayer = null;
  8225. this.textLayer = null;
  8226. this.zoomLayer = null;
  8227. this.xfaLayer = null;
  8228. this.structTreeLayer = null;
  8229. this.drawLayer = null;
  8230. const div = document.createElement("div");
  8231. div.className = "page";
  8232. div.setAttribute("data-page-number", this.id);
  8233. div.setAttribute("role", "region");
  8234. div.setAttribute("data-l10n-id", "pdfjs-page-landmark");
  8235. div.setAttribute("data-l10n-args", JSON.stringify({
  8236. page: this.id
  8237. }));
  8238. this.div = div;
  8239. this.#setDimensions();
  8240. container?.append(div);
  8241. if (this._isStandalone) {
  8242. container?.style.setProperty("--scale-factor", this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS);
  8243. const {
  8244. optionalContentConfigPromise
  8245. } = options;
  8246. if (optionalContentConfigPromise) {
  8247. optionalContentConfigPromise.then(optionalContentConfig => {
  8248. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  8249. return;
  8250. }
  8251. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  8252. });
  8253. }
  8254. if (this.l10n === web_l10n_utils__WEBPACK_IMPORTED_MODULE_6__.NullL10n) {
  8255. this.l10n.translate(this.div);
  8256. }
  8257. }
  8258. }
  8259. get renderingState() {
  8260. return this.#renderingState;
  8261. }
  8262. set renderingState(state) {
  8263. if (state === this.#renderingState) {
  8264. return;
  8265. }
  8266. this.#renderingState = state;
  8267. if (this.#loadingId) {
  8268. clearTimeout(this.#loadingId);
  8269. this.#loadingId = null;
  8270. }
  8271. switch (state) {
  8272. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED:
  8273. this.div.classList.remove("loading");
  8274. break;
  8275. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING:
  8276. this.div.classList.add("loadingIcon");
  8277. this.#loadingId = setTimeout(() => {
  8278. this.div.classList.add("loading");
  8279. this.#loadingId = null;
  8280. }, 0);
  8281. break;
  8282. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL:
  8283. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED:
  8284. this.div.classList.remove("loadingIcon", "loading");
  8285. break;
  8286. }
  8287. }
  8288. #setDimensions() {
  8289. const {
  8290. viewport
  8291. } = this;
  8292. if (this.pdfPage) {
  8293. if (this.#previousRotation === viewport.rotation) {
  8294. return;
  8295. }
  8296. this.#previousRotation = viewport.rotation;
  8297. }
  8298. (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.setLayerDimensions)(this.div, viewport, true, false);
  8299. }
  8300. setPdfPage(pdfPage) {
  8301. if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
  8302. this._container?.style.setProperty("--hcm-highlight-filter", pdfPage.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  8303. }
  8304. this.pdfPage = pdfPage;
  8305. this.pdfPageRotate = pdfPage.rotate;
  8306. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8307. this.viewport = pdfPage.getViewport({
  8308. scale: this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS,
  8309. rotation: totalRotation
  8310. });
  8311. this.#setDimensions();
  8312. this.reset();
  8313. }
  8314. destroy() {
  8315. this.reset();
  8316. this.pdfPage?.cleanup();
  8317. }
  8318. get _textHighlighter() {
  8319. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_textHighlighter", new _text_highlighter_js__WEBPACK_IMPORTED_MODULE_12__.TextHighlighter({
  8320. pageIndex: this.id - 1,
  8321. eventBus: this.eventBus,
  8322. findController: this.#layerProperties.findController
  8323. }));
  8324. }
  8325. async #renderAnnotationLayer() {
  8326. let error = null;
  8327. try {
  8328. await this.annotationLayer.render(this.viewport, "display");
  8329. } catch (ex) {
  8330. console.error(`#renderAnnotationLayer: "${ex}".`);
  8331. error = ex;
  8332. } finally {
  8333. this.eventBus.dispatch("annotationlayerrendered", {
  8334. source: this,
  8335. pageNumber: this.id,
  8336. error
  8337. });
  8338. }
  8339. }
  8340. async #renderAnnotationEditorLayer() {
  8341. let error = null;
  8342. try {
  8343. await this.annotationEditorLayer.render(this.viewport, "display");
  8344. } catch (ex) {
  8345. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  8346. error = ex;
  8347. } finally {
  8348. this.eventBus.dispatch("annotationeditorlayerrendered", {
  8349. source: this,
  8350. pageNumber: this.id,
  8351. error
  8352. });
  8353. }
  8354. }
  8355. async #renderDrawLayer() {
  8356. try {
  8357. await this.drawLayer.render("display");
  8358. } catch (ex) {
  8359. console.error(`#renderDrawLayer: "${ex}".`);
  8360. }
  8361. }
  8362. async #renderXfaLayer() {
  8363. let error = null;
  8364. try {
  8365. const result = await this.xfaLayer.render(this.viewport, "display");
  8366. if (result?.textDivs && this._textHighlighter) {
  8367. this.#buildXfaTextContentItems(result.textDivs);
  8368. }
  8369. } catch (ex) {
  8370. console.error(`#renderXfaLayer: "${ex}".`);
  8371. error = ex;
  8372. } finally {
  8373. if (this.xfaLayer?.div) {
  8374. this.l10n.pause();
  8375. this.div.append(this.xfaLayer.div);
  8376. this.l10n.resume();
  8377. }
  8378. this.eventBus.dispatch("xfalayerrendered", {
  8379. source: this,
  8380. pageNumber: this.id,
  8381. error
  8382. });
  8383. }
  8384. }
  8385. async #renderTextLayer() {
  8386. const {
  8387. pdfPage,
  8388. textLayer,
  8389. viewport
  8390. } = this;
  8391. if (!textLayer) {
  8392. return;
  8393. }
  8394. let error = null;
  8395. try {
  8396. if (!textLayer.renderingDone) {
  8397. const readableStream = pdfPage.streamTextContent({
  8398. includeMarkedContent: true,
  8399. disableNormalization: true
  8400. });
  8401. textLayer.setTextContentSource(readableStream);
  8402. }
  8403. await textLayer.render(viewport);
  8404. } catch (ex) {
  8405. if (ex instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AbortException) {
  8406. return;
  8407. }
  8408. console.error(`#renderTextLayer: "${ex}".`);
  8409. error = ex;
  8410. }
  8411. this.eventBus.dispatch("textlayerrendered", {
  8412. source: this,
  8413. pageNumber: this.id,
  8414. numTextDivs: textLayer.numTextDivs,
  8415. error
  8416. });
  8417. this.#renderStructTreeLayer();
  8418. }
  8419. async #renderStructTreeLayer() {
  8420. if (!this.textLayer) {
  8421. return;
  8422. }
  8423. this.structTreeLayer ||= new _struct_tree_layer_builder_js__WEBPACK_IMPORTED_MODULE_8__.StructTreeLayerBuilder();
  8424. const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
  8425. const treeDom = this.structTreeLayer?.render(tree);
  8426. if (treeDom) {
  8427. this.l10n.pause();
  8428. this.canvas?.append(treeDom);
  8429. this.l10n.resume();
  8430. }
  8431. this.structTreeLayer?.show();
  8432. }
  8433. async #buildXfaTextContentItems(textDivs) {
  8434. const text = await this.pdfPage.getTextContent();
  8435. const items = [];
  8436. for (const item of text.items) {
  8437. items.push(item.str);
  8438. }
  8439. this._textHighlighter.setTextMapping(textDivs, items);
  8440. this._textHighlighter.enable();
  8441. }
  8442. _resetZoomLayer(removeFromDOM = false) {
  8443. if (!this.zoomLayer) {
  8444. return;
  8445. }
  8446. const zoomLayerCanvas = this.zoomLayer.firstChild;
  8447. this.#viewportMap.delete(zoomLayerCanvas);
  8448. zoomLayerCanvas.width = 0;
  8449. zoomLayerCanvas.height = 0;
  8450. if (removeFromDOM) {
  8451. this.zoomLayer.remove();
  8452. }
  8453. this.zoomLayer = null;
  8454. }
  8455. reset({
  8456. keepZoomLayer = false,
  8457. keepAnnotationLayer = false,
  8458. keepAnnotationEditorLayer = false,
  8459. keepXfaLayer = false,
  8460. keepTextLayer = false
  8461. } = {}) {
  8462. this.cancelRendering({
  8463. keepAnnotationLayer,
  8464. keepAnnotationEditorLayer,
  8465. keepXfaLayer,
  8466. keepTextLayer
  8467. });
  8468. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
  8469. const div = this.div;
  8470. const childNodes = div.childNodes,
  8471. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  8472. annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
  8473. annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
  8474. xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
  8475. textLayerNode = keepTextLayer && this.textLayer?.div || null;
  8476. for (let i = childNodes.length - 1; i >= 0; i--) {
  8477. const node = childNodes[i];
  8478. switch (node) {
  8479. case zoomLayerNode:
  8480. case annotationLayerNode:
  8481. case annotationEditorLayerNode:
  8482. case xfaLayerNode:
  8483. case textLayerNode:
  8484. continue;
  8485. }
  8486. node.remove();
  8487. }
  8488. div.removeAttribute("data-loaded");
  8489. if (annotationLayerNode) {
  8490. this.annotationLayer.hide();
  8491. }
  8492. if (annotationEditorLayerNode) {
  8493. this.annotationEditorLayer.hide();
  8494. }
  8495. if (xfaLayerNode) {
  8496. this.xfaLayer.hide();
  8497. }
  8498. if (textLayerNode) {
  8499. this.textLayer.hide();
  8500. }
  8501. this.structTreeLayer?.hide();
  8502. if (!zoomLayerNode) {
  8503. if (this.canvas) {
  8504. this.#viewportMap.delete(this.canvas);
  8505. this.canvas.width = 0;
  8506. this.canvas.height = 0;
  8507. delete this.canvas;
  8508. }
  8509. this._resetZoomLayer();
  8510. }
  8511. }
  8512. update({
  8513. scale = 0,
  8514. rotation = null,
  8515. optionalContentConfigPromise = null,
  8516. drawingDelay = -1
  8517. }) {
  8518. this.scale = scale || this.scale;
  8519. if (typeof rotation === "number") {
  8520. this.rotation = rotation;
  8521. }
  8522. if (optionalContentConfigPromise instanceof Promise) {
  8523. this._optionalContentConfigPromise = optionalContentConfigPromise;
  8524. optionalContentConfigPromise.then(optionalContentConfig => {
  8525. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  8526. return;
  8527. }
  8528. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  8529. });
  8530. }
  8531. this.#useThumbnailCanvas.directDrawing = true;
  8532. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8533. this.viewport = this.viewport.clone({
  8534. scale: this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS,
  8535. rotation: totalRotation
  8536. });
  8537. this.#setDimensions();
  8538. if (this._isStandalone) {
  8539. this._container?.style.setProperty("--scale-factor", this.viewport.scale);
  8540. }
  8541. if (this.canvas) {
  8542. let onlyCssZoom = false;
  8543. if (this.#hasRestrictedScaling) {
  8544. if (this.maxCanvasPixels === 0) {
  8545. onlyCssZoom = true;
  8546. } else if (this.maxCanvasPixels > 0) {
  8547. const {
  8548. width,
  8549. height
  8550. } = this.viewport;
  8551. const {
  8552. sx,
  8553. sy
  8554. } = this.outputScale;
  8555. onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
  8556. }
  8557. }
  8558. const postponeDrawing = !onlyCssZoom && drawingDelay >= 0 && drawingDelay < 1000;
  8559. if (postponeDrawing || onlyCssZoom) {
  8560. if (postponeDrawing && this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED) {
  8561. this.cancelRendering({
  8562. keepZoomLayer: true,
  8563. keepAnnotationLayer: true,
  8564. keepAnnotationEditorLayer: true,
  8565. keepXfaLayer: true,
  8566. keepTextLayer: true,
  8567. cancelExtraDelay: drawingDelay
  8568. });
  8569. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  8570. this.#useThumbnailCanvas.directDrawing = false;
  8571. }
  8572. this.cssTransform({
  8573. target: this.canvas,
  8574. redrawAnnotationLayer: true,
  8575. redrawAnnotationEditorLayer: true,
  8576. redrawXfaLayer: true,
  8577. redrawTextLayer: !postponeDrawing,
  8578. hideTextLayer: postponeDrawing
  8579. });
  8580. if (postponeDrawing) {
  8581. return;
  8582. }
  8583. this.eventBus.dispatch("pagerendered", {
  8584. source: this,
  8585. pageNumber: this.id,
  8586. cssTransform: true,
  8587. timestamp: performance.now(),
  8588. error: this.#renderError
  8589. });
  8590. return;
  8591. }
  8592. if (!this.zoomLayer && !this.canvas.hidden) {
  8593. this.zoomLayer = this.canvas.parentNode;
  8594. this.zoomLayer.style.position = "absolute";
  8595. }
  8596. }
  8597. if (this.zoomLayer) {
  8598. this.cssTransform({
  8599. target: this.zoomLayer.firstChild
  8600. });
  8601. }
  8602. this.reset({
  8603. keepZoomLayer: true,
  8604. keepAnnotationLayer: true,
  8605. keepAnnotationEditorLayer: true,
  8606. keepXfaLayer: true,
  8607. keepTextLayer: true
  8608. });
  8609. }
  8610. cancelRendering({
  8611. keepAnnotationLayer = false,
  8612. keepAnnotationEditorLayer = false,
  8613. keepXfaLayer = false,
  8614. keepTextLayer = false,
  8615. cancelExtraDelay = 0
  8616. } = {}) {
  8617. if (this.renderTask) {
  8618. this.renderTask.cancel(cancelExtraDelay);
  8619. this.renderTask = null;
  8620. }
  8621. this.resume = null;
  8622. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  8623. this.textLayer.cancel();
  8624. this.textLayer = null;
  8625. }
  8626. if (this.structTreeLayer && !this.textLayer) {
  8627. this.structTreeLayer = null;
  8628. }
  8629. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  8630. this.annotationLayer.cancel();
  8631. this.annotationLayer = null;
  8632. this._annotationCanvasMap = null;
  8633. }
  8634. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  8635. if (this.drawLayer) {
  8636. this.drawLayer.cancel();
  8637. this.drawLayer = null;
  8638. }
  8639. this.annotationEditorLayer.cancel();
  8640. this.annotationEditorLayer = null;
  8641. }
  8642. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  8643. this.xfaLayer.cancel();
  8644. this.xfaLayer = null;
  8645. this._textHighlighter?.disable();
  8646. }
  8647. }
  8648. cssTransform({
  8649. target,
  8650. redrawAnnotationLayer = false,
  8651. redrawAnnotationEditorLayer = false,
  8652. redrawXfaLayer = false,
  8653. redrawTextLayer = false,
  8654. hideTextLayer = false
  8655. }) {
  8656. if (!target.hasAttribute("zooming")) {
  8657. target.setAttribute("zooming", true);
  8658. const {
  8659. style
  8660. } = target;
  8661. style.width = style.height = "";
  8662. }
  8663. const originalViewport = this.#viewportMap.get(target);
  8664. if (this.viewport !== originalViewport) {
  8665. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  8666. const absRotation = Math.abs(relativeRotation);
  8667. let scaleX = 1,
  8668. scaleY = 1;
  8669. if (absRotation === 90 || absRotation === 270) {
  8670. const {
  8671. width,
  8672. height
  8673. } = this.viewport;
  8674. scaleX = height / width;
  8675. scaleY = width / height;
  8676. }
  8677. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  8678. }
  8679. if (redrawAnnotationLayer && this.annotationLayer) {
  8680. this.#renderAnnotationLayer();
  8681. }
  8682. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  8683. if (this.drawLayer) {
  8684. this.#renderDrawLayer();
  8685. }
  8686. this.#renderAnnotationEditorLayer();
  8687. }
  8688. if (redrawXfaLayer && this.xfaLayer) {
  8689. this.#renderXfaLayer();
  8690. }
  8691. if (this.textLayer) {
  8692. if (hideTextLayer) {
  8693. this.textLayer.hide();
  8694. this.structTreeLayer?.hide();
  8695. } else if (redrawTextLayer) {
  8696. this.#renderTextLayer();
  8697. }
  8698. }
  8699. }
  8700. get width() {
  8701. return this.viewport.width;
  8702. }
  8703. get height() {
  8704. return this.viewport.height;
  8705. }
  8706. getPagePoint(x, y) {
  8707. return this.viewport.convertToPdfPoint(x, y);
  8708. }
  8709. async #finishRenderTask(renderTask, error = null) {
  8710. if (renderTask === this.renderTask) {
  8711. this.renderTask = null;
  8712. }
  8713. if (error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException) {
  8714. this.#renderError = null;
  8715. return;
  8716. }
  8717. this.#renderError = error;
  8718. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  8719. this._resetZoomLayer(true);
  8720. this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
  8721. this.eventBus.dispatch("pagerendered", {
  8722. source: this,
  8723. pageNumber: this.id,
  8724. cssTransform: false,
  8725. timestamp: performance.now(),
  8726. error: this.#renderError
  8727. });
  8728. if (error) {
  8729. throw error;
  8730. }
  8731. }
  8732. async draw() {
  8733. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL) {
  8734. console.error("Must be in new state before drawing");
  8735. this.reset();
  8736. }
  8737. const {
  8738. div,
  8739. l10n,
  8740. pageColors,
  8741. pdfPage,
  8742. viewport
  8743. } = this;
  8744. if (!pdfPage) {
  8745. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  8746. throw new Error("pdfPage is not loaded");
  8747. }
  8748. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING;
  8749. const canvasWrapper = document.createElement("div");
  8750. canvasWrapper.classList.add("canvasWrapper");
  8751. div.append(canvasWrapper);
  8752. if (!this.textLayer && this.#textLayerMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  8753. this._accessibilityManager ||= new _text_accessibility_js__WEBPACK_IMPORTED_MODULE_9__.TextAccessibilityManager();
  8754. this.textLayer = new _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__.TextLayerBuilder({
  8755. highlighter: this._textHighlighter,
  8756. accessibilityManager: this._accessibilityManager,
  8757. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  8758. enablePermissions: this.#textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS
  8759. });
  8760. this.textLayer.onAppend = textLayerDiv => {
  8761. this.l10n.pause();
  8762. this.div.append(textLayerDiv);
  8763. this.l10n.resume();
  8764. };
  8765. }
  8766. if (!this.annotationLayer && this.#annotationMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.DISABLE) {
  8767. const {
  8768. annotationStorage,
  8769. downloadManager,
  8770. enableScripting,
  8771. fieldObjectsPromise,
  8772. hasJSActionsPromise,
  8773. linkService
  8774. } = this.#layerProperties;
  8775. this._annotationCanvasMap ||= new Map();
  8776. this.annotationLayer = new _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__.AnnotationLayerBuilder({
  8777. pageDiv: div,
  8778. pdfPage,
  8779. annotationStorage,
  8780. imageResourcesPath: this.imageResourcesPath,
  8781. renderForms: this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS,
  8782. linkService,
  8783. downloadManager,
  8784. enableScripting,
  8785. hasJSActionsPromise,
  8786. fieldObjectsPromise,
  8787. annotationCanvasMap: this._annotationCanvasMap,
  8788. accessibilityManager: this._accessibilityManager
  8789. });
  8790. }
  8791. const renderContinueCallback = cont => {
  8792. showCanvas?.(false);
  8793. if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
  8794. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED;
  8795. this.resume = () => {
  8796. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING;
  8797. cont();
  8798. };
  8799. return;
  8800. }
  8801. cont();
  8802. };
  8803. const {
  8804. width,
  8805. height
  8806. } = viewport;
  8807. const canvas = document.createElement("canvas");
  8808. canvas.setAttribute("role", "presentation");
  8809. canvas.hidden = true;
  8810. const hasHCM = !!(pageColors?.background && pageColors?.foreground);
  8811. let showCanvas = isLastShow => {
  8812. if (!hasHCM || isLastShow) {
  8813. canvas.hidden = false;
  8814. showCanvas = null;
  8815. }
  8816. };
  8817. canvasWrapper.append(canvas);
  8818. this.canvas = canvas;
  8819. const ctx = canvas.getContext("2d", {
  8820. alpha: false
  8821. });
  8822. const outputScale = this.outputScale = new _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.OutputScale();
  8823. if (this.maxCanvasPixels === 0) {
  8824. const invScale = 1 / this.scale;
  8825. outputScale.sx *= invScale;
  8826. outputScale.sy *= invScale;
  8827. this.#hasRestrictedScaling = true;
  8828. } else if (this.maxCanvasPixels > 0) {
  8829. const pixelsInViewport = width * height;
  8830. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  8831. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  8832. outputScale.sx = maxScale;
  8833. outputScale.sy = maxScale;
  8834. this.#hasRestrictedScaling = true;
  8835. } else {
  8836. this.#hasRestrictedScaling = false;
  8837. }
  8838. }
  8839. const sfx = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.approximateFraction)(outputScale.sx);
  8840. const sfy = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.approximateFraction)(outputScale.sy);
  8841. canvas.width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(width * outputScale.sx, sfx[0]);
  8842. canvas.height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(height * outputScale.sy, sfy[0]);
  8843. const {
  8844. style
  8845. } = canvas;
  8846. style.width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(width, sfx[1]) + "px";
  8847. style.height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(height, sfy[1]) + "px";
  8848. this.#viewportMap.set(canvas, viewport);
  8849. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  8850. const renderContext = {
  8851. canvasContext: ctx,
  8852. transform,
  8853. viewport,
  8854. annotationMode: this.#annotationMode,
  8855. optionalContentConfigPromise: this._optionalContentConfigPromise,
  8856. annotationCanvasMap: this._annotationCanvasMap,
  8857. pageColors
  8858. };
  8859. const renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8860. renderTask.onContinue = renderContinueCallback;
  8861. const resultPromise = renderTask.promise.then(async () => {
  8862. showCanvas?.(true);
  8863. await this.#finishRenderTask(renderTask);
  8864. this.#renderTextLayer();
  8865. if (this.annotationLayer) {
  8866. await this.#renderAnnotationLayer();
  8867. }
  8868. const {
  8869. annotationEditorUIManager
  8870. } = this.#layerProperties;
  8871. if (!annotationEditorUIManager) {
  8872. return;
  8873. }
  8874. this.drawLayer ||= new _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__.DrawLayerBuilder({
  8875. pageIndex: this.id
  8876. });
  8877. await this.#renderDrawLayer();
  8878. this.drawLayer.setParent(canvasWrapper);
  8879. if (!this.annotationEditorLayer) {
  8880. this.annotationEditorLayer = new _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__.AnnotationEditorLayerBuilder({
  8881. uiManager: annotationEditorUIManager,
  8882. pageDiv: div,
  8883. pdfPage,
  8884. l10n,
  8885. accessibilityManager: this._accessibilityManager,
  8886. annotationLayer: this.annotationLayer?.annotationLayer,
  8887. textLayer: this.textLayer,
  8888. drawLayer: this.drawLayer.getDrawLayer()
  8889. });
  8890. }
  8891. this.#renderAnnotationEditorLayer();
  8892. }, error => {
  8893. if (!(error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException)) {
  8894. showCanvas?.(true);
  8895. }
  8896. return this.#finishRenderTask(renderTask, error);
  8897. });
  8898. if (pdfPage.isPureXfa) {
  8899. if (!this.xfaLayer) {
  8900. const {
  8901. annotationStorage,
  8902. linkService
  8903. } = this.#layerProperties;
  8904. this.xfaLayer = new _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__.XfaLayerBuilder({
  8905. pdfPage,
  8906. annotationStorage,
  8907. linkService
  8908. });
  8909. }
  8910. this.#renderXfaLayer();
  8911. }
  8912. div.setAttribute("data-loaded", true);
  8913. this.eventBus.dispatch("pagerender", {
  8914. source: this,
  8915. pageNumber: this.id
  8916. });
  8917. return resultPromise;
  8918. }
  8919. setPageLabel(label) {
  8920. this.pageLabel = typeof label === "string" ? label : null;
  8921. this.div.setAttribute("data-l10n-args", JSON.stringify({
  8922. page: this.pageLabel ?? this.id
  8923. }));
  8924. if (this.pageLabel !== null) {
  8925. this.div.setAttribute("data-page-label", this.pageLabel);
  8926. } else {
  8927. this.div.removeAttribute("data-page-label");
  8928. }
  8929. }
  8930. get thumbnailCanvas() {
  8931. const {
  8932. directDrawing,
  8933. initialOptionalContent,
  8934. regularAnnotations
  8935. } = this.#useThumbnailCanvas;
  8936. return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
  8937. }
  8938. }
  8939. __webpack_async_result__();
  8940. } catch(e) { __webpack_async_result__(e); } });
  8941. /***/ }),
  8942. /***/ 323:
  8943. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  8944. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  8945. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8946. /* harmony export */ PDFPresentationMode: () => (/* binding */ PDFPresentationMode)
  8947. /* harmony export */ });
  8948. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  8949. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1869);
  8950. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  8951. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  8952. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8953. const ACTIVE_SELECTOR = "pdfPresentationMode";
  8954. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8955. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8956. const PAGE_SWITCH_THRESHOLD = 0.1;
  8957. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8958. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8959. class PDFPresentationMode {
  8960. #state = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.UNKNOWN;
  8961. #args = null;
  8962. constructor({
  8963. container,
  8964. pdfViewer,
  8965. eventBus
  8966. }) {
  8967. this.container = container;
  8968. this.pdfViewer = pdfViewer;
  8969. this.eventBus = eventBus;
  8970. this.contextMenuOpen = false;
  8971. this.mouseScrollTimeStamp = 0;
  8972. this.mouseScrollDelta = 0;
  8973. this.touchSwipeState = null;
  8974. }
  8975. async request() {
  8976. const {
  8977. container,
  8978. pdfViewer
  8979. } = this;
  8980. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  8981. return false;
  8982. }
  8983. this.#addFullscreenChangeListeners();
  8984. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.CHANGING);
  8985. const promise = container.requestFullscreen();
  8986. this.#args = {
  8987. pageNumber: pdfViewer.currentPageNumber,
  8988. scaleValue: pdfViewer.currentScaleValue,
  8989. scrollMode: pdfViewer.scrollMode,
  8990. spreadMode: null,
  8991. annotationEditorMode: null
  8992. };
  8993. if (pdfViewer.spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  8994. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  8995. this.#args.spreadMode = pdfViewer.spreadMode;
  8996. }
  8997. if (pdfViewer.annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.DISABLE) {
  8998. this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
  8999. }
  9000. try {
  9001. await promise;
  9002. pdfViewer.focus();
  9003. return true;
  9004. } catch {
  9005. this.#removeFullscreenChangeListeners();
  9006. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL);
  9007. }
  9008. return false;
  9009. }
  9010. get active() {
  9011. return this.#state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.CHANGING || this.#state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.FULLSCREEN;
  9012. }
  9013. #mouseWheel(evt) {
  9014. if (!this.active) {
  9015. return;
  9016. }
  9017. evt.preventDefault();
  9018. const delta = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeWheelEventDelta)(evt);
  9019. const currentTime = Date.now();
  9020. const storedTime = this.mouseScrollTimeStamp;
  9021. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9022. return;
  9023. }
  9024. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9025. this.#resetMouseScrollState();
  9026. }
  9027. this.mouseScrollDelta += delta;
  9028. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9029. const totalDelta = this.mouseScrollDelta;
  9030. this.#resetMouseScrollState();
  9031. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9032. if (success) {
  9033. this.mouseScrollTimeStamp = currentTime;
  9034. }
  9035. }
  9036. }
  9037. #notifyStateChange(state) {
  9038. this.#state = state;
  9039. this.eventBus.dispatch("presentationmodechanged", {
  9040. source: this,
  9041. state
  9042. });
  9043. }
  9044. #enter() {
  9045. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.FULLSCREEN);
  9046. this.container.classList.add(ACTIVE_SELECTOR);
  9047. setTimeout(() => {
  9048. this.pdfViewer.scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE;
  9049. if (this.#args.spreadMode !== null) {
  9050. this.pdfViewer.spreadMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE;
  9051. }
  9052. this.pdfViewer.currentPageNumber = this.#args.pageNumber;
  9053. this.pdfViewer.currentScaleValue = "page-fit";
  9054. if (this.#args.annotationEditorMode !== null) {
  9055. this.pdfViewer.annotationEditorMode = {
  9056. mode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.NONE
  9057. };
  9058. }
  9059. }, 0);
  9060. this.#addWindowListeners();
  9061. this.#showControls();
  9062. this.contextMenuOpen = false;
  9063. window.getSelection().removeAllRanges();
  9064. }
  9065. #exit() {
  9066. const pageNumber = this.pdfViewer.currentPageNumber;
  9067. this.container.classList.remove(ACTIVE_SELECTOR);
  9068. setTimeout(() => {
  9069. this.#removeFullscreenChangeListeners();
  9070. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL);
  9071. this.pdfViewer.scrollMode = this.#args.scrollMode;
  9072. if (this.#args.spreadMode !== null) {
  9073. this.pdfViewer.spreadMode = this.#args.spreadMode;
  9074. }
  9075. this.pdfViewer.currentScaleValue = this.#args.scaleValue;
  9076. this.pdfViewer.currentPageNumber = pageNumber;
  9077. if (this.#args.annotationEditorMode !== null) {
  9078. this.pdfViewer.annotationEditorMode = {
  9079. mode: this.#args.annotationEditorMode
  9080. };
  9081. }
  9082. this.#args = null;
  9083. }, 0);
  9084. this.#removeWindowListeners();
  9085. this.#hideControls();
  9086. this.#resetMouseScrollState();
  9087. this.contextMenuOpen = false;
  9088. }
  9089. #mouseDown(evt) {
  9090. if (this.contextMenuOpen) {
  9091. this.contextMenuOpen = false;
  9092. evt.preventDefault();
  9093. return;
  9094. }
  9095. if (evt.button !== 0) {
  9096. return;
  9097. }
  9098. if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
  9099. return;
  9100. }
  9101. evt.preventDefault();
  9102. if (evt.shiftKey) {
  9103. this.pdfViewer.previousPage();
  9104. } else {
  9105. this.pdfViewer.nextPage();
  9106. }
  9107. }
  9108. #contextMenu() {
  9109. this.contextMenuOpen = true;
  9110. }
  9111. #showControls() {
  9112. if (this.controlsTimeout) {
  9113. clearTimeout(this.controlsTimeout);
  9114. } else {
  9115. this.container.classList.add(CONTROLS_SELECTOR);
  9116. }
  9117. this.controlsTimeout = setTimeout(() => {
  9118. this.container.classList.remove(CONTROLS_SELECTOR);
  9119. delete this.controlsTimeout;
  9120. }, DELAY_BEFORE_HIDING_CONTROLS);
  9121. }
  9122. #hideControls() {
  9123. if (!this.controlsTimeout) {
  9124. return;
  9125. }
  9126. clearTimeout(this.controlsTimeout);
  9127. this.container.classList.remove(CONTROLS_SELECTOR);
  9128. delete this.controlsTimeout;
  9129. }
  9130. #resetMouseScrollState() {
  9131. this.mouseScrollTimeStamp = 0;
  9132. this.mouseScrollDelta = 0;
  9133. }
  9134. #touchSwipe(evt) {
  9135. if (!this.active) {
  9136. return;
  9137. }
  9138. if (evt.touches.length > 1) {
  9139. this.touchSwipeState = null;
  9140. return;
  9141. }
  9142. switch (evt.type) {
  9143. case "touchstart":
  9144. this.touchSwipeState = {
  9145. startX: evt.touches[0].pageX,
  9146. startY: evt.touches[0].pageY,
  9147. endX: evt.touches[0].pageX,
  9148. endY: evt.touches[0].pageY
  9149. };
  9150. break;
  9151. case "touchmove":
  9152. if (this.touchSwipeState === null) {
  9153. return;
  9154. }
  9155. this.touchSwipeState.endX = evt.touches[0].pageX;
  9156. this.touchSwipeState.endY = evt.touches[0].pageY;
  9157. evt.preventDefault();
  9158. break;
  9159. case "touchend":
  9160. if (this.touchSwipeState === null) {
  9161. return;
  9162. }
  9163. let delta = 0;
  9164. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9165. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9166. const absAngle = Math.abs(Math.atan2(dy, dx));
  9167. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9168. delta = dx;
  9169. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9170. delta = dy;
  9171. }
  9172. if (delta > 0) {
  9173. this.pdfViewer.previousPage();
  9174. } else if (delta < 0) {
  9175. this.pdfViewer.nextPage();
  9176. }
  9177. break;
  9178. }
  9179. }
  9180. #addWindowListeners() {
  9181. this.showControlsBind = this.#showControls.bind(this);
  9182. this.mouseDownBind = this.#mouseDown.bind(this);
  9183. this.mouseWheelBind = this.#mouseWheel.bind(this);
  9184. this.resetMouseScrollStateBind = this.#resetMouseScrollState.bind(this);
  9185. this.contextMenuBind = this.#contextMenu.bind(this);
  9186. this.touchSwipeBind = this.#touchSwipe.bind(this);
  9187. window.addEventListener("mousemove", this.showControlsBind);
  9188. window.addEventListener("mousedown", this.mouseDownBind);
  9189. window.addEventListener("wheel", this.mouseWheelBind, {
  9190. passive: false
  9191. });
  9192. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9193. window.addEventListener("contextmenu", this.contextMenuBind);
  9194. window.addEventListener("touchstart", this.touchSwipeBind);
  9195. window.addEventListener("touchmove", this.touchSwipeBind);
  9196. window.addEventListener("touchend", this.touchSwipeBind);
  9197. }
  9198. #removeWindowListeners() {
  9199. window.removeEventListener("mousemove", this.showControlsBind);
  9200. window.removeEventListener("mousedown", this.mouseDownBind);
  9201. window.removeEventListener("wheel", this.mouseWheelBind, {
  9202. passive: false
  9203. });
  9204. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9205. window.removeEventListener("contextmenu", this.contextMenuBind);
  9206. window.removeEventListener("touchstart", this.touchSwipeBind);
  9207. window.removeEventListener("touchmove", this.touchSwipeBind);
  9208. window.removeEventListener("touchend", this.touchSwipeBind);
  9209. delete this.showControlsBind;
  9210. delete this.mouseDownBind;
  9211. delete this.mouseWheelBind;
  9212. delete this.resetMouseScrollStateBind;
  9213. delete this.contextMenuBind;
  9214. delete this.touchSwipeBind;
  9215. }
  9216. #fullscreenChange() {
  9217. if (document.fullscreenElement) {
  9218. this.#enter();
  9219. } else {
  9220. this.#exit();
  9221. }
  9222. }
  9223. #addFullscreenChangeListeners() {
  9224. this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
  9225. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9226. }
  9227. #removeFullscreenChangeListeners() {
  9228. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9229. delete this.fullscreenChangeBind;
  9230. }
  9231. }
  9232. __webpack_async_result__();
  9233. } catch(e) { __webpack_async_result__(e); } });
  9234. /***/ }),
  9235. /***/ 1834:
  9236. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9237. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9238. /* unused harmony export PDFPrintService */
  9239. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  9240. /* harmony import */ var _app_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(39);
  9241. /* harmony import */ var _print_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4552);
  9242. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _app_js__WEBPACK_IMPORTED_MODULE_1__, _print_utils_js__WEBPACK_IMPORTED_MODULE_2__]);
  9243. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _app_js__WEBPACK_IMPORTED_MODULE_1__, _print_utils_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  9244. let activeService = null;
  9245. let dialog = null;
  9246. let overlayManager = null;
  9247. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  9248. const scratchCanvas = activeService.scratchCanvas;
  9249. const PRINT_UNITS = printResolution / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF;
  9250. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  9251. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  9252. const ctx = scratchCanvas.getContext("2d");
  9253. ctx.save();
  9254. ctx.fillStyle = "rgb(255, 255, 255)";
  9255. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  9256. ctx.restore();
  9257. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function ([pdfPage, printAnnotationStorage]) {
  9258. const renderContext = {
  9259. canvasContext: ctx,
  9260. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  9261. viewport: pdfPage.getViewport({
  9262. scale: 1,
  9263. rotation: size.rotation
  9264. }),
  9265. intent: "print",
  9266. annotationMode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_STORAGE,
  9267. optionalContentConfigPromise,
  9268. printAnnotationStorage
  9269. };
  9270. return pdfPage.render(renderContext).promise;
  9271. });
  9272. }
  9273. class PDFPrintService {
  9274. constructor(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise = null, printAnnotationStoragePromise = null) {
  9275. this.pdfDocument = pdfDocument;
  9276. this.pagesOverview = pagesOverview;
  9277. this.printContainer = printContainer;
  9278. this._printResolution = printResolution || 150;
  9279. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  9280. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  9281. this.currentPage = -1;
  9282. this.scratchCanvas = document.createElement("canvas");
  9283. }
  9284. layout() {
  9285. this.throwIfInactive();
  9286. const body = document.querySelector("body");
  9287. body.setAttribute("data-pdfjsprinting", true);
  9288. const {
  9289. width,
  9290. height
  9291. } = this.pagesOverview[0];
  9292. const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
  9293. if (!hasEqualPageSizes) {
  9294. console.warn("Not all pages have the same size. The printed result may be incorrect!");
  9295. }
  9296. this.pageStyleSheet = document.createElement("style");
  9297. this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
  9298. body.append(this.pageStyleSheet);
  9299. }
  9300. destroy() {
  9301. if (activeService !== this) {
  9302. return;
  9303. }
  9304. this.printContainer.textContent = "";
  9305. const body = document.querySelector("body");
  9306. body.removeAttribute("data-pdfjsprinting");
  9307. if (this.pageStyleSheet) {
  9308. this.pageStyleSheet.remove();
  9309. this.pageStyleSheet = null;
  9310. }
  9311. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  9312. this.scratchCanvas = null;
  9313. activeService = null;
  9314. ensureOverlay().then(function () {
  9315. if (overlayManager.active === dialog) {
  9316. overlayManager.close(dialog);
  9317. }
  9318. });
  9319. }
  9320. renderPages() {
  9321. if (this.pdfDocument.isPureXfa) {
  9322. (0,_print_utils_js__WEBPACK_IMPORTED_MODULE_2__.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  9323. return Promise.resolve();
  9324. }
  9325. const pageCount = this.pagesOverview.length;
  9326. const renderNextPage = (resolve, reject) => {
  9327. this.throwIfInactive();
  9328. if (++this.currentPage >= pageCount) {
  9329. renderProgress(pageCount, pageCount);
  9330. resolve();
  9331. return;
  9332. }
  9333. const index = this.currentPage;
  9334. renderProgress(index, pageCount);
  9335. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  9336. renderNextPage(resolve, reject);
  9337. }, reject);
  9338. };
  9339. return new Promise(renderNextPage);
  9340. }
  9341. useRenderedPage() {
  9342. this.throwIfInactive();
  9343. const img = document.createElement("img");
  9344. const scratchCanvas = this.scratchCanvas;
  9345. if ("toBlob" in scratchCanvas) {
  9346. scratchCanvas.toBlob(function (blob) {
  9347. img.src = URL.createObjectURL(blob);
  9348. });
  9349. } else {
  9350. img.src = scratchCanvas.toDataURL();
  9351. }
  9352. const wrapper = document.createElement("div");
  9353. wrapper.className = "printedPage";
  9354. wrapper.append(img);
  9355. this.printContainer.append(wrapper);
  9356. return new Promise(function (resolve, reject) {
  9357. img.onload = resolve;
  9358. img.onerror = reject;
  9359. });
  9360. }
  9361. performPrint() {
  9362. this.throwIfInactive();
  9363. return new Promise(resolve => {
  9364. setTimeout(() => {
  9365. if (!this.active) {
  9366. resolve();
  9367. return;
  9368. }
  9369. print.call(window);
  9370. setTimeout(resolve, 20);
  9371. }, 0);
  9372. });
  9373. }
  9374. get active() {
  9375. return this === activeService;
  9376. }
  9377. throwIfInactive() {
  9378. if (!this.active) {
  9379. throw new Error("This print request was cancelled or completed.");
  9380. }
  9381. }
  9382. }
  9383. const print = window.print;
  9384. window.print = function () {
  9385. if (activeService) {
  9386. console.warn("Ignored window.print() because of a pending print job.");
  9387. return;
  9388. }
  9389. ensureOverlay().then(function () {
  9390. if (activeService) {
  9391. overlayManager.open(dialog);
  9392. }
  9393. });
  9394. try {
  9395. dispatchEvent("beforeprint");
  9396. } finally {
  9397. if (!activeService) {
  9398. console.error("Expected print service to be initialized.");
  9399. ensureOverlay().then(function () {
  9400. if (overlayManager.active === dialog) {
  9401. overlayManager.close(dialog);
  9402. }
  9403. });
  9404. return;
  9405. }
  9406. const activeServiceOnEntry = activeService;
  9407. activeService.renderPages().then(function () {
  9408. return activeServiceOnEntry.performPrint();
  9409. }).catch(function () {}).then(function () {
  9410. if (activeServiceOnEntry.active) {
  9411. abort();
  9412. }
  9413. });
  9414. }
  9415. };
  9416. function dispatchEvent(eventType) {
  9417. const event = new CustomEvent(eventType, {
  9418. bubbles: false,
  9419. cancelable: false,
  9420. detail: "custom"
  9421. });
  9422. window.dispatchEvent(event);
  9423. }
  9424. function abort() {
  9425. if (activeService) {
  9426. activeService.destroy();
  9427. dispatchEvent("afterprint");
  9428. }
  9429. }
  9430. function renderProgress(index, total) {
  9431. dialog ||= document.getElementById("printServiceDialog");
  9432. const progress = Math.round(100 * index / total);
  9433. const progressBar = dialog.querySelector("progress");
  9434. const progressPerc = dialog.querySelector(".relative-progress");
  9435. progressBar.value = progress;
  9436. progressPerc.setAttribute("data-l10n-args", JSON.stringify({
  9437. progress
  9438. }));
  9439. }
  9440. window.addEventListener("keydown", function (event) {
  9441. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  9442. window.print();
  9443. event.preventDefault();
  9444. event.stopImmediatePropagation();
  9445. }
  9446. }, true);
  9447. if ("onbeforeprint" in window) {
  9448. const stopPropagationIfNeeded = function (event) {
  9449. if (event.detail !== "custom") {
  9450. event.stopImmediatePropagation();
  9451. }
  9452. };
  9453. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  9454. window.addEventListener("afterprint", stopPropagationIfNeeded);
  9455. }
  9456. let overlayPromise;
  9457. function ensureOverlay() {
  9458. if (!overlayPromise) {
  9459. overlayManager = _app_js__WEBPACK_IMPORTED_MODULE_1__.PDFViewerApplication.overlayManager;
  9460. if (!overlayManager) {
  9461. throw new Error("The overlay manager has not yet been initialized.");
  9462. }
  9463. dialog ||= document.getElementById("printServiceDialog");
  9464. overlayPromise = overlayManager.register(dialog, true);
  9465. document.getElementById("printCancel").onclick = abort;
  9466. dialog.addEventListener("close", abort);
  9467. }
  9468. return overlayPromise;
  9469. }
  9470. _app_js__WEBPACK_IMPORTED_MODULE_1__.PDFPrintServiceFactory.instance = {
  9471. supportsPrinting: true,
  9472. createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  9473. if (activeService) {
  9474. throw new Error("The print service is created and active.");
  9475. }
  9476. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise);
  9477. return activeService;
  9478. }
  9479. };
  9480. __webpack_async_result__();
  9481. } catch(e) { __webpack_async_result__(e); } });
  9482. /***/ }),
  9483. /***/ 5119:
  9484. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9485. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9486. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9487. /* harmony export */ PDFRenderingQueue: () => (/* binding */ PDFRenderingQueue)
  9488. /* harmony export */ });
  9489. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  9490. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  9491. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  9492. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  9493. const CLEANUP_TIMEOUT = 30000;
  9494. class PDFRenderingQueue {
  9495. constructor() {
  9496. this.pdfViewer = null;
  9497. this.pdfThumbnailViewer = null;
  9498. this.onIdle = null;
  9499. this.highestPriorityPage = null;
  9500. this.idleTimeout = null;
  9501. this.printing = false;
  9502. this.isThumbnailViewEnabled = false;
  9503. Object.defineProperty(this, "hasViewer", {
  9504. value: () => !!this.pdfViewer
  9505. });
  9506. }
  9507. setViewer(pdfViewer) {
  9508. this.pdfViewer = pdfViewer;
  9509. }
  9510. setThumbnailViewer(pdfThumbnailViewer) {
  9511. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9512. }
  9513. isHighestPriority(view) {
  9514. return this.highestPriorityPage === view.renderingId;
  9515. }
  9516. renderHighestPriority(currentlyVisiblePages) {
  9517. if (this.idleTimeout) {
  9518. clearTimeout(this.idleTimeout);
  9519. this.idleTimeout = null;
  9520. }
  9521. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  9522. return;
  9523. }
  9524. if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
  9525. return;
  9526. }
  9527. if (this.printing) {
  9528. return;
  9529. }
  9530. if (this.onIdle) {
  9531. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  9532. }
  9533. }
  9534. getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
  9535. const visibleViews = visible.views,
  9536. numVisible = visibleViews.length;
  9537. if (numVisible === 0) {
  9538. return null;
  9539. }
  9540. for (let i = 0; i < numVisible; i++) {
  9541. const view = visibleViews[i].view;
  9542. if (!this.isViewFinished(view)) {
  9543. return view;
  9544. }
  9545. }
  9546. const firstId = visible.first.id,
  9547. lastId = visible.last.id;
  9548. if (lastId - firstId + 1 > numVisible) {
  9549. const visibleIds = visible.ids;
  9550. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  9551. const holeId = scrolledDown ? firstId + i : lastId - i;
  9552. if (visibleIds.has(holeId)) {
  9553. continue;
  9554. }
  9555. const holeView = views[holeId - 1];
  9556. if (!this.isViewFinished(holeView)) {
  9557. return holeView;
  9558. }
  9559. }
  9560. }
  9561. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  9562. let preRenderView = views[preRenderIndex];
  9563. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9564. return preRenderView;
  9565. }
  9566. if (preRenderExtra) {
  9567. preRenderIndex += scrolledDown ? 1 : -1;
  9568. preRenderView = views[preRenderIndex];
  9569. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9570. return preRenderView;
  9571. }
  9572. }
  9573. return null;
  9574. }
  9575. isViewFinished(view) {
  9576. return view.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  9577. }
  9578. renderView(view) {
  9579. switch (view.renderingState) {
  9580. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED:
  9581. return false;
  9582. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED:
  9583. this.highestPriorityPage = view.renderingId;
  9584. view.resume();
  9585. break;
  9586. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING:
  9587. this.highestPriorityPage = view.renderingId;
  9588. break;
  9589. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL:
  9590. this.highestPriorityPage = view.renderingId;
  9591. view.draw().finally(() => {
  9592. this.renderHighestPriority();
  9593. }).catch(reason => {
  9594. if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException) {
  9595. return;
  9596. }
  9597. console.error(`renderView: "${reason}"`);
  9598. });
  9599. break;
  9600. }
  9601. return true;
  9602. }
  9603. }
  9604. __webpack_async_result__();
  9605. } catch(e) { __webpack_async_result__(e); } });
  9606. /***/ }),
  9607. /***/ 2599:
  9608. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9609. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9610. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9611. /* harmony export */ PDFScriptingManager: () => (/* binding */ PDFScriptingManager)
  9612. /* harmony export */ });
  9613. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  9614. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1869);
  9615. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  9616. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  9617. class PDFScriptingManager {
  9618. #closeCapability = null;
  9619. #destroyCapability = null;
  9620. #docProperties = null;
  9621. #eventBus = null;
  9622. #externalServices = null;
  9623. #pdfDocument = null;
  9624. #pdfViewer = null;
  9625. #ready = false;
  9626. #scripting = null;
  9627. #willPrintCapability = null;
  9628. constructor({
  9629. eventBus,
  9630. externalServices = null,
  9631. docProperties = null
  9632. }) {
  9633. this.#eventBus = eventBus;
  9634. this.#externalServices = externalServices;
  9635. this.#docProperties = docProperties;
  9636. }
  9637. setViewer(pdfViewer) {
  9638. this.#pdfViewer = pdfViewer;
  9639. }
  9640. async setDocument(pdfDocument) {
  9641. if (this.#pdfDocument) {
  9642. await this.#destroyScripting();
  9643. }
  9644. this.#pdfDocument = pdfDocument;
  9645. if (!pdfDocument) {
  9646. return;
  9647. }
  9648. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  9649. if (!objects && !docActions) {
  9650. await this.#destroyScripting();
  9651. return;
  9652. }
  9653. if (pdfDocument !== this.#pdfDocument) {
  9654. return;
  9655. }
  9656. try {
  9657. this.#scripting = this.#initScripting();
  9658. } catch (error) {
  9659. console.error(`setDocument: "${error.message}".`);
  9660. await this.#destroyScripting();
  9661. return;
  9662. }
  9663. this._internalEvents.set("updatefromsandbox", event => {
  9664. if (event?.source === window) {
  9665. this.#updateFromSandbox(event.detail);
  9666. }
  9667. });
  9668. this._internalEvents.set("dispatcheventinsandbox", event => {
  9669. this.#scripting?.dispatchEventInSandbox(event.detail);
  9670. });
  9671. this._internalEvents.set("pagechanging", ({
  9672. pageNumber,
  9673. previous
  9674. }) => {
  9675. if (pageNumber === previous) {
  9676. return;
  9677. }
  9678. this.#dispatchPageClose(previous);
  9679. this.#dispatchPageOpen(pageNumber);
  9680. });
  9681. this._internalEvents.set("pagerendered", ({
  9682. pageNumber
  9683. }) => {
  9684. if (!this._pageOpenPending.has(pageNumber)) {
  9685. return;
  9686. }
  9687. if (pageNumber !== this.#pdfViewer.currentPageNumber) {
  9688. return;
  9689. }
  9690. this.#dispatchPageOpen(pageNumber);
  9691. });
  9692. this._internalEvents.set("pagesdestroy", async () => {
  9693. await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
  9694. await this.#scripting?.dispatchEventInSandbox({
  9695. id: "doc",
  9696. name: "WillClose"
  9697. });
  9698. this.#closeCapability?.resolve();
  9699. });
  9700. for (const [name, listener] of this._internalEvents) {
  9701. this.#eventBus._on(name, listener);
  9702. }
  9703. try {
  9704. const docProperties = await this.#docProperties(pdfDocument);
  9705. if (pdfDocument !== this.#pdfDocument) {
  9706. return;
  9707. }
  9708. await this.#scripting.createSandbox({
  9709. objects,
  9710. calculationOrder,
  9711. appInfo: {
  9712. platform: navigator.platform,
  9713. language: navigator.language
  9714. },
  9715. docInfo: {
  9716. ...docProperties,
  9717. actions: docActions
  9718. }
  9719. });
  9720. this.#eventBus.dispatch("sandboxcreated", {
  9721. source: this
  9722. });
  9723. } catch (error) {
  9724. console.error(`setDocument: "${error.message}".`);
  9725. await this.#destroyScripting();
  9726. return;
  9727. }
  9728. await this.#scripting?.dispatchEventInSandbox({
  9729. id: "doc",
  9730. name: "Open"
  9731. });
  9732. await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
  9733. Promise.resolve().then(() => {
  9734. if (pdfDocument === this.#pdfDocument) {
  9735. this.#ready = true;
  9736. }
  9737. });
  9738. }
  9739. async dispatchWillSave() {
  9740. return this.#scripting?.dispatchEventInSandbox({
  9741. id: "doc",
  9742. name: "WillSave"
  9743. });
  9744. }
  9745. async dispatchDidSave() {
  9746. return this.#scripting?.dispatchEventInSandbox({
  9747. id: "doc",
  9748. name: "DidSave"
  9749. });
  9750. }
  9751. async dispatchWillPrint() {
  9752. if (!this.#scripting) {
  9753. return;
  9754. }
  9755. await this.#willPrintCapability?.promise;
  9756. this.#willPrintCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability();
  9757. try {
  9758. await this.#scripting.dispatchEventInSandbox({
  9759. id: "doc",
  9760. name: "WillPrint"
  9761. });
  9762. } catch (ex) {
  9763. this.#willPrintCapability.resolve();
  9764. this.#willPrintCapability = null;
  9765. throw ex;
  9766. }
  9767. await this.#willPrintCapability.promise;
  9768. }
  9769. async dispatchDidPrint() {
  9770. return this.#scripting?.dispatchEventInSandbox({
  9771. id: "doc",
  9772. name: "DidPrint"
  9773. });
  9774. }
  9775. get destroyPromise() {
  9776. return this.#destroyCapability?.promise || null;
  9777. }
  9778. get ready() {
  9779. return this.#ready;
  9780. }
  9781. get _internalEvents() {
  9782. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_internalEvents", new Map());
  9783. }
  9784. get _pageOpenPending() {
  9785. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_pageOpenPending", new Set());
  9786. }
  9787. get _visitedPages() {
  9788. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_visitedPages", new Map());
  9789. }
  9790. async #updateFromSandbox(detail) {
  9791. const pdfViewer = this.#pdfViewer;
  9792. const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
  9793. const {
  9794. id,
  9795. siblings,
  9796. command,
  9797. value
  9798. } = detail;
  9799. if (!id) {
  9800. switch (command) {
  9801. case "clear":
  9802. console.clear();
  9803. break;
  9804. case "error":
  9805. console.error(value);
  9806. break;
  9807. case "layout":
  9808. if (!isInPresentationMode) {
  9809. const modes = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageLayoutToViewerModes)(value);
  9810. pdfViewer.spreadMode = modes.spreadMode;
  9811. }
  9812. break;
  9813. case "page-num":
  9814. pdfViewer.currentPageNumber = value + 1;
  9815. break;
  9816. case "print":
  9817. await pdfViewer.pagesPromise;
  9818. this.#eventBus.dispatch("print", {
  9819. source: this
  9820. });
  9821. break;
  9822. case "println":
  9823. console.log(value);
  9824. break;
  9825. case "zoom":
  9826. if (!isInPresentationMode) {
  9827. pdfViewer.currentScaleValue = value;
  9828. }
  9829. break;
  9830. case "SaveAs":
  9831. this.#eventBus.dispatch("download", {
  9832. source: this
  9833. });
  9834. break;
  9835. case "FirstPage":
  9836. pdfViewer.currentPageNumber = 1;
  9837. break;
  9838. case "LastPage":
  9839. pdfViewer.currentPageNumber = pdfViewer.pagesCount;
  9840. break;
  9841. case "NextPage":
  9842. pdfViewer.nextPage();
  9843. break;
  9844. case "PrevPage":
  9845. pdfViewer.previousPage();
  9846. break;
  9847. case "ZoomViewIn":
  9848. if (!isInPresentationMode) {
  9849. pdfViewer.increaseScale();
  9850. }
  9851. break;
  9852. case "ZoomViewOut":
  9853. if (!isInPresentationMode) {
  9854. pdfViewer.decreaseScale();
  9855. }
  9856. break;
  9857. case "WillPrintFinished":
  9858. this.#willPrintCapability?.resolve();
  9859. this.#willPrintCapability = null;
  9860. break;
  9861. }
  9862. return;
  9863. }
  9864. if (isInPresentationMode && detail.focus) {
  9865. return;
  9866. }
  9867. delete detail.id;
  9868. delete detail.siblings;
  9869. const ids = siblings ? [id, ...siblings] : [id];
  9870. for (const elementId of ids) {
  9871. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  9872. if (element) {
  9873. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  9874. detail
  9875. }));
  9876. } else {
  9877. this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
  9878. }
  9879. }
  9880. }
  9881. async #dispatchPageOpen(pageNumber, initialize = false) {
  9882. const pdfDocument = this.#pdfDocument,
  9883. visitedPages = this._visitedPages;
  9884. if (initialize) {
  9885. this.#closeCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability();
  9886. }
  9887. if (!this.#closeCapability) {
  9888. return;
  9889. }
  9890. const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
  9891. if (pageView?.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  9892. this._pageOpenPending.add(pageNumber);
  9893. return;
  9894. }
  9895. this._pageOpenPending.delete(pageNumber);
  9896. const actionsPromise = (async () => {
  9897. const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
  9898. if (pdfDocument !== this.#pdfDocument) {
  9899. return;
  9900. }
  9901. await this.#scripting?.dispatchEventInSandbox({
  9902. id: "page",
  9903. name: "PageOpen",
  9904. pageNumber,
  9905. actions
  9906. });
  9907. })();
  9908. visitedPages.set(pageNumber, actionsPromise);
  9909. }
  9910. async #dispatchPageClose(pageNumber) {
  9911. const pdfDocument = this.#pdfDocument,
  9912. visitedPages = this._visitedPages;
  9913. if (!this.#closeCapability) {
  9914. return;
  9915. }
  9916. if (this._pageOpenPending.has(pageNumber)) {
  9917. return;
  9918. }
  9919. const actionsPromise = visitedPages.get(pageNumber);
  9920. if (!actionsPromise) {
  9921. return;
  9922. }
  9923. visitedPages.set(pageNumber, null);
  9924. await actionsPromise;
  9925. if (pdfDocument !== this.#pdfDocument) {
  9926. return;
  9927. }
  9928. await this.#scripting?.dispatchEventInSandbox({
  9929. id: "page",
  9930. name: "PageClose",
  9931. pageNumber
  9932. });
  9933. }
  9934. #initScripting() {
  9935. this.#destroyCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PromiseCapability();
  9936. if (this.#scripting) {
  9937. throw new Error("#initScripting: Scripting already exists.");
  9938. }
  9939. return this.#externalServices.createScripting();
  9940. }
  9941. async #destroyScripting() {
  9942. if (!this.#scripting) {
  9943. this.#pdfDocument = null;
  9944. this.#destroyCapability?.resolve();
  9945. return;
  9946. }
  9947. if (this.#closeCapability) {
  9948. await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
  9949. setTimeout(resolve, 1000);
  9950. })]).catch(() => {});
  9951. this.#closeCapability = null;
  9952. }
  9953. this.#pdfDocument = null;
  9954. try {
  9955. await this.#scripting.destroySandbox();
  9956. } catch {}
  9957. this.#willPrintCapability?.reject(new Error("Scripting destroyed."));
  9958. this.#willPrintCapability = null;
  9959. for (const [name, listener] of this._internalEvents) {
  9960. this.#eventBus._off(name, listener);
  9961. }
  9962. this._internalEvents.clear();
  9963. this._pageOpenPending.clear();
  9964. this._visitedPages.clear();
  9965. this.#scripting = null;
  9966. this.#ready = false;
  9967. this.#destroyCapability?.resolve();
  9968. }
  9969. }
  9970. __webpack_async_result__();
  9971. } catch(e) { __webpack_async_result__(e); } });
  9972. /***/ }),
  9973. /***/ 4487:
  9974. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  9975. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9976. /* harmony export */ PDFSidebar: () => (/* binding */ PDFSidebar)
  9977. /* harmony export */ });
  9978. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  9979. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9980. const SIDEBAR_MIN_WIDTH = 200;
  9981. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9982. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9983. class PDFSidebar {
  9984. #isRTL = false;
  9985. #mouseMoveBound = this.#mouseMove.bind(this);
  9986. #mouseUpBound = this.#mouseUp.bind(this);
  9987. #outerContainerWidth = null;
  9988. #width = null;
  9989. constructor({
  9990. elements,
  9991. eventBus,
  9992. l10n
  9993. }) {
  9994. this.isOpen = false;
  9995. this.active = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  9996. this.isInitialViewSet = false;
  9997. this.isInitialEventDispatched = false;
  9998. this.onToggled = null;
  9999. this.onUpdateThumbnails = null;
  10000. this.outerContainer = elements.outerContainer;
  10001. this.sidebarContainer = elements.sidebarContainer;
  10002. this.toggleButton = elements.toggleButton;
  10003. this.resizer = elements.resizer;
  10004. this.thumbnailButton = elements.thumbnailButton;
  10005. this.outlineButton = elements.outlineButton;
  10006. this.attachmentsButton = elements.attachmentsButton;
  10007. this.layersButton = elements.layersButton;
  10008. this.thumbnailView = elements.thumbnailView;
  10009. this.outlineView = elements.outlineView;
  10010. this.attachmentsView = elements.attachmentsView;
  10011. this.layersView = elements.layersView;
  10012. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  10013. this.eventBus = eventBus;
  10014. this.#isRTL = l10n.getDirection() === "rtl";
  10015. this.#addEventListeners();
  10016. }
  10017. reset() {
  10018. this.isInitialViewSet = false;
  10019. this.isInitialEventDispatched = false;
  10020. this.#hideUINotification(true);
  10021. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
  10022. this.outlineButton.disabled = false;
  10023. this.attachmentsButton.disabled = false;
  10024. this.layersButton.disabled = false;
  10025. this._currentOutlineItemButton.disabled = true;
  10026. }
  10027. get visibleView() {
  10028. return this.isOpen ? this.active : _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE;
  10029. }
  10030. setInitialView(view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE) {
  10031. if (this.isInitialViewSet) {
  10032. return;
  10033. }
  10034. this.isInitialViewSet = true;
  10035. if (view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE || view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
  10036. this.#dispatchEvent();
  10037. return;
  10038. }
  10039. this.switchView(view, true);
  10040. if (!this.isInitialEventDispatched) {
  10041. this.#dispatchEvent();
  10042. }
  10043. }
  10044. switchView(view, forceOpen = false) {
  10045. const isViewChanged = view !== this.active;
  10046. let forceRendering = false;
  10047. switch (view) {
  10048. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE:
  10049. if (this.isOpen) {
  10050. this.close();
  10051. }
  10052. return;
  10053. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS:
  10054. if (this.isOpen && isViewChanged) {
  10055. forceRendering = true;
  10056. }
  10057. break;
  10058. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE:
  10059. if (this.outlineButton.disabled) {
  10060. return;
  10061. }
  10062. break;
  10063. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS:
  10064. if (this.attachmentsButton.disabled) {
  10065. return;
  10066. }
  10067. break;
  10068. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS:
  10069. if (this.layersButton.disabled) {
  10070. return;
  10071. }
  10072. break;
  10073. default:
  10074. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  10075. return;
  10076. }
  10077. this.active = view;
  10078. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.thumbnailButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS, this.thumbnailView);
  10079. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.outlineButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE, this.outlineView);
  10080. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.attachmentsButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS, this.attachmentsView);
  10081. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.layersButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS, this.layersView);
  10082. if (forceOpen && !this.isOpen) {
  10083. this.open();
  10084. return;
  10085. }
  10086. if (forceRendering) {
  10087. this.onUpdateThumbnails();
  10088. this.onToggled();
  10089. }
  10090. if (isViewChanged) {
  10091. this.#dispatchEvent();
  10092. }
  10093. }
  10094. open() {
  10095. if (this.isOpen) {
  10096. return;
  10097. }
  10098. this.isOpen = true;
  10099. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(this.toggleButton, true);
  10100. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  10101. if (this.active === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  10102. this.onUpdateThumbnails();
  10103. }
  10104. this.onToggled();
  10105. this.#dispatchEvent();
  10106. this.#hideUINotification();
  10107. }
  10108. close(evt = null) {
  10109. if (!this.isOpen) {
  10110. return;
  10111. }
  10112. this.isOpen = false;
  10113. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(this.toggleButton, false);
  10114. this.outerContainer.classList.add("sidebarMoving");
  10115. this.outerContainer.classList.remove("sidebarOpen");
  10116. this.onToggled();
  10117. this.#dispatchEvent();
  10118. if (evt?.detail > 0) {
  10119. this.toggleButton.blur();
  10120. }
  10121. }
  10122. toggle(evt = null) {
  10123. if (this.isOpen) {
  10124. this.close(evt);
  10125. } else {
  10126. this.open();
  10127. }
  10128. }
  10129. #dispatchEvent() {
  10130. if (this.isInitialViewSet) {
  10131. this.isInitialEventDispatched ||= true;
  10132. }
  10133. this.eventBus.dispatch("sidebarviewchanged", {
  10134. source: this,
  10135. view: this.visibleView
  10136. });
  10137. }
  10138. #showUINotification() {
  10139. this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-notification-button");
  10140. if (!this.isOpen) {
  10141. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  10142. }
  10143. }
  10144. #hideUINotification(reset = false) {
  10145. if (this.isOpen || reset) {
  10146. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  10147. }
  10148. if (reset) {
  10149. this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-button");
  10150. }
  10151. }
  10152. #addEventListeners() {
  10153. this.sidebarContainer.addEventListener("transitionend", evt => {
  10154. if (evt.target === this.sidebarContainer) {
  10155. this.outerContainer.classList.remove("sidebarMoving");
  10156. this.eventBus.dispatch("resize", {
  10157. source: this
  10158. });
  10159. }
  10160. });
  10161. this.toggleButton.addEventListener("click", evt => {
  10162. this.toggle(evt);
  10163. });
  10164. this.thumbnailButton.addEventListener("click", () => {
  10165. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
  10166. });
  10167. this.outlineButton.addEventListener("click", () => {
  10168. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE);
  10169. });
  10170. this.outlineButton.addEventListener("dblclick", () => {
  10171. this.eventBus.dispatch("toggleoutlinetree", {
  10172. source: this
  10173. });
  10174. });
  10175. this.attachmentsButton.addEventListener("click", () => {
  10176. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS);
  10177. });
  10178. this.layersButton.addEventListener("click", () => {
  10179. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS);
  10180. });
  10181. this.layersButton.addEventListener("dblclick", () => {
  10182. this.eventBus.dispatch("resetlayers", {
  10183. source: this
  10184. });
  10185. });
  10186. this._currentOutlineItemButton.addEventListener("click", () => {
  10187. this.eventBus.dispatch("currentoutlineitem", {
  10188. source: this
  10189. });
  10190. });
  10191. const onTreeLoaded = (count, button, view) => {
  10192. button.disabled = !count;
  10193. if (count) {
  10194. this.#showUINotification();
  10195. } else if (this.active === view) {
  10196. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
  10197. }
  10198. };
  10199. this.eventBus._on("outlineloaded", evt => {
  10200. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE);
  10201. evt.currentOutlineItemPromise.then(enabled => {
  10202. if (!this.isInitialViewSet) {
  10203. return;
  10204. }
  10205. this._currentOutlineItemButton.disabled = !enabled;
  10206. });
  10207. });
  10208. this.eventBus._on("attachmentsloaded", evt => {
  10209. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS);
  10210. });
  10211. this.eventBus._on("layersloaded", evt => {
  10212. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS);
  10213. });
  10214. this.eventBus._on("presentationmodechanged", evt => {
  10215. if (evt.state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL && this.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  10216. this.onUpdateThumbnails();
  10217. }
  10218. });
  10219. this.resizer.addEventListener("mousedown", evt => {
  10220. if (evt.button !== 0) {
  10221. return;
  10222. }
  10223. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10224. window.addEventListener("mousemove", this.#mouseMoveBound);
  10225. window.addEventListener("mouseup", this.#mouseUpBound);
  10226. });
  10227. this.eventBus._on("resize", evt => {
  10228. if (evt.source !== window) {
  10229. return;
  10230. }
  10231. this.#outerContainerWidth = null;
  10232. if (!this.#width) {
  10233. return;
  10234. }
  10235. if (!this.isOpen) {
  10236. this.#updateWidth(this.#width);
  10237. return;
  10238. }
  10239. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10240. const updated = this.#updateWidth(this.#width);
  10241. Promise.resolve().then(() => {
  10242. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10243. if (updated) {
  10244. this.eventBus.dispatch("resize", {
  10245. source: this
  10246. });
  10247. }
  10248. });
  10249. });
  10250. }
  10251. get outerContainerWidth() {
  10252. return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
  10253. }
  10254. #updateWidth(width = 0) {
  10255. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  10256. if (width > maxWidth) {
  10257. width = maxWidth;
  10258. }
  10259. if (width < SIDEBAR_MIN_WIDTH) {
  10260. width = SIDEBAR_MIN_WIDTH;
  10261. }
  10262. if (width === this.#width) {
  10263. return false;
  10264. }
  10265. this.#width = width;
  10266. _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  10267. return true;
  10268. }
  10269. #mouseMove(evt) {
  10270. let width = evt.clientX;
  10271. if (this.#isRTL) {
  10272. width = this.outerContainerWidth - width;
  10273. }
  10274. this.#updateWidth(width);
  10275. }
  10276. #mouseUp(evt) {
  10277. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10278. this.eventBus.dispatch("resize", {
  10279. source: this
  10280. });
  10281. window.removeEventListener("mousemove", this.#mouseMoveBound);
  10282. window.removeEventListener("mouseup", this.#mouseUpBound);
  10283. }
  10284. }
  10285. /***/ }),
  10286. /***/ 3346:
  10287. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  10288. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  10289. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10290. /* harmony export */ PDFThumbnailView: () => (/* binding */ PDFThumbnailView),
  10291. /* harmony export */ TempImageFactory: () => (/* binding */ TempImageFactory)
  10292. /* harmony export */ });
  10293. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  10294. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1869);
  10295. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  10296. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  10297. const DRAW_UPSCALE_FACTOR = 2;
  10298. const MAX_NUM_SCALING_STEPS = 3;
  10299. const THUMBNAIL_WIDTH = 98;
  10300. class TempImageFactory {
  10301. static #tempCanvas = null;
  10302. static getCanvas(width, height) {
  10303. const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
  10304. tempCanvas.width = width;
  10305. tempCanvas.height = height;
  10306. const ctx = tempCanvas.getContext("2d", {
  10307. alpha: false
  10308. });
  10309. ctx.save();
  10310. ctx.fillStyle = "rgb(255, 255, 255)";
  10311. ctx.fillRect(0, 0, width, height);
  10312. ctx.restore();
  10313. return [tempCanvas, tempCanvas.getContext("2d")];
  10314. }
  10315. static destroyCanvas() {
  10316. const tempCanvas = this.#tempCanvas;
  10317. if (tempCanvas) {
  10318. tempCanvas.width = 0;
  10319. tempCanvas.height = 0;
  10320. }
  10321. this.#tempCanvas = null;
  10322. }
  10323. }
  10324. class PDFThumbnailView {
  10325. constructor({
  10326. container,
  10327. eventBus,
  10328. id,
  10329. defaultViewport,
  10330. optionalContentConfigPromise,
  10331. linkService,
  10332. renderingQueue,
  10333. pageColors
  10334. }) {
  10335. this.id = id;
  10336. this.renderingId = "thumbnail" + id;
  10337. this.pageLabel = null;
  10338. this.pdfPage = null;
  10339. this.rotation = 0;
  10340. this.viewport = defaultViewport;
  10341. this.pdfPageRotate = defaultViewport.rotation;
  10342. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  10343. this.pageColors = pageColors || null;
  10344. this.eventBus = eventBus;
  10345. this.linkService = linkService;
  10346. this.renderingQueue = renderingQueue;
  10347. this.renderTask = null;
  10348. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL;
  10349. this.resume = null;
  10350. const anchor = document.createElement("a");
  10351. anchor.href = linkService.getAnchorUrl("#page=" + id);
  10352. anchor.setAttribute("data-l10n-id", "pdfjs-thumb-page-title");
  10353. anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10354. anchor.onclick = function () {
  10355. linkService.goToPage(id);
  10356. return false;
  10357. };
  10358. this.anchor = anchor;
  10359. const div = document.createElement("div");
  10360. div.className = "thumbnail";
  10361. div.setAttribute("data-page-number", this.id);
  10362. this.div = div;
  10363. this.#updateDims();
  10364. const img = document.createElement("div");
  10365. img.className = "thumbnailImage";
  10366. this._placeholderImg = img;
  10367. div.append(img);
  10368. anchor.append(div);
  10369. container.append(anchor);
  10370. }
  10371. #updateDims() {
  10372. const {
  10373. width,
  10374. height
  10375. } = this.viewport;
  10376. const ratio = width / height;
  10377. this.canvasWidth = THUMBNAIL_WIDTH;
  10378. this.canvasHeight = this.canvasWidth / ratio | 0;
  10379. this.scale = this.canvasWidth / width;
  10380. const {
  10381. style
  10382. } = this.div;
  10383. style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
  10384. style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
  10385. }
  10386. setPdfPage(pdfPage) {
  10387. this.pdfPage = pdfPage;
  10388. this.pdfPageRotate = pdfPage.rotate;
  10389. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10390. this.viewport = pdfPage.getViewport({
  10391. scale: 1,
  10392. rotation: totalRotation
  10393. });
  10394. this.reset();
  10395. }
  10396. reset() {
  10397. this.cancelRendering();
  10398. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL;
  10399. this.div.removeAttribute("data-loaded");
  10400. this.image?.replaceWith(this._placeholderImg);
  10401. this.#updateDims();
  10402. if (this.image) {
  10403. this.image.removeAttribute("src");
  10404. delete this.image;
  10405. }
  10406. }
  10407. update({
  10408. rotation = null
  10409. }) {
  10410. if (typeof rotation === "number") {
  10411. this.rotation = rotation;
  10412. }
  10413. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10414. this.viewport = this.viewport.clone({
  10415. scale: 1,
  10416. rotation: totalRotation
  10417. });
  10418. this.reset();
  10419. }
  10420. cancelRendering() {
  10421. if (this.renderTask) {
  10422. this.renderTask.cancel();
  10423. this.renderTask = null;
  10424. }
  10425. this.resume = null;
  10426. }
  10427. _getPageDrawContext(upscaleFactor = 1) {
  10428. const canvas = document.createElement("canvas");
  10429. const ctx = canvas.getContext("2d", {
  10430. alpha: false
  10431. });
  10432. const outputScale = new _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.OutputScale();
  10433. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  10434. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  10435. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10436. return {
  10437. ctx,
  10438. canvas,
  10439. transform
  10440. };
  10441. }
  10442. _convertCanvasToImage(canvas) {
  10443. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10444. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  10445. }
  10446. const reducedCanvas = this._reduceImage(canvas);
  10447. const image = document.createElement("img");
  10448. image.className = "thumbnailImage";
  10449. image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas");
  10450. image.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10451. image.src = reducedCanvas.toDataURL();
  10452. this.image = image;
  10453. this.div.setAttribute("data-loaded", true);
  10454. this._placeholderImg.replaceWith(image);
  10455. reducedCanvas.width = 0;
  10456. reducedCanvas.height = 0;
  10457. }
  10458. async #finishRenderTask(renderTask, canvas, error = null) {
  10459. if (renderTask === this.renderTask) {
  10460. this.renderTask = null;
  10461. }
  10462. if (error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.RenderingCancelledException) {
  10463. return;
  10464. }
  10465. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
  10466. this._convertCanvasToImage(canvas);
  10467. if (error) {
  10468. throw error;
  10469. }
  10470. }
  10471. async draw() {
  10472. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL) {
  10473. console.error("Must be in new state before drawing");
  10474. return undefined;
  10475. }
  10476. const {
  10477. pdfPage
  10478. } = this;
  10479. if (!pdfPage) {
  10480. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
  10481. throw new Error("pdfPage is not loaded");
  10482. }
  10483. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING;
  10484. const {
  10485. ctx,
  10486. canvas,
  10487. transform
  10488. } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
  10489. const drawViewport = this.viewport.clone({
  10490. scale: DRAW_UPSCALE_FACTOR * this.scale
  10491. });
  10492. const renderContinueCallback = cont => {
  10493. if (!this.renderingQueue.isHighestPriority(this)) {
  10494. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.PAUSED;
  10495. this.resume = () => {
  10496. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING;
  10497. cont();
  10498. };
  10499. return;
  10500. }
  10501. cont();
  10502. };
  10503. const renderContext = {
  10504. canvasContext: ctx,
  10505. transform,
  10506. viewport: drawViewport,
  10507. optionalContentConfigPromise: this._optionalContentConfigPromise,
  10508. pageColors: this.pageColors
  10509. };
  10510. const renderTask = this.renderTask = pdfPage.render(renderContext);
  10511. renderTask.onContinue = renderContinueCallback;
  10512. const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
  10513. resultPromise.finally(() => {
  10514. canvas.width = 0;
  10515. canvas.height = 0;
  10516. this.eventBus.dispatch("thumbnailrendered", {
  10517. source: this,
  10518. pageNumber: this.id,
  10519. pdfPage: this.pdfPage
  10520. });
  10521. });
  10522. return resultPromise;
  10523. }
  10524. setImage(pageView) {
  10525. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL) {
  10526. return;
  10527. }
  10528. const {
  10529. thumbnailCanvas: canvas,
  10530. pdfPage,
  10531. scale
  10532. } = pageView;
  10533. if (!canvas) {
  10534. return;
  10535. }
  10536. if (!this.pdfPage) {
  10537. this.setPdfPage(pdfPage);
  10538. }
  10539. if (scale < this.scale) {
  10540. return;
  10541. }
  10542. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
  10543. this._convertCanvasToImage(canvas);
  10544. }
  10545. _reduceImage(img) {
  10546. const {
  10547. ctx,
  10548. canvas
  10549. } = this._getPageDrawContext();
  10550. if (img.width <= 2 * canvas.width) {
  10551. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10552. return canvas;
  10553. }
  10554. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10555. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10556. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10557. while (reducedWidth > img.width || reducedHeight > img.height) {
  10558. reducedWidth >>= 1;
  10559. reducedHeight >>= 1;
  10560. }
  10561. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10562. while (reducedWidth > 2 * canvas.width) {
  10563. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10564. reducedWidth >>= 1;
  10565. reducedHeight >>= 1;
  10566. }
  10567. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10568. return canvas;
  10569. }
  10570. get #pageL10nArgs() {
  10571. return JSON.stringify({
  10572. page: this.pageLabel ?? this.id
  10573. });
  10574. }
  10575. setPageLabel(label) {
  10576. this.pageLabel = typeof label === "string" ? label : null;
  10577. this.anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10578. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10579. return;
  10580. }
  10581. this.image?.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10582. }
  10583. }
  10584. __webpack_async_result__();
  10585. } catch(e) { __webpack_async_result__(e); } });
  10586. /***/ }),
  10587. /***/ 3510:
  10588. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  10589. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  10590. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10591. /* harmony export */ PDFThumbnailViewer: () => (/* binding */ PDFThumbnailViewer)
  10592. /* harmony export */ });
  10593. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  10594. /* harmony import */ var _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3346);
  10595. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__]);
  10596. _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  10597. const THUMBNAIL_SCROLL_MARGIN = -19;
  10598. const THUMBNAIL_SELECTED_CLASS = "selected";
  10599. class PDFThumbnailViewer {
  10600. constructor({
  10601. container,
  10602. eventBus,
  10603. linkService,
  10604. renderingQueue,
  10605. pageColors
  10606. }) {
  10607. this.container = container;
  10608. this.eventBus = eventBus;
  10609. this.linkService = linkService;
  10610. this.renderingQueue = renderingQueue;
  10611. this.pageColors = pageColors || null;
  10612. this.scroll = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.watchScroll)(this.container, this._scrollUpdated.bind(this));
  10613. this._resetView();
  10614. }
  10615. _scrollUpdated() {
  10616. this.renderingQueue.renderHighestPriority();
  10617. }
  10618. getThumbnail(index) {
  10619. return this._thumbnails[index];
  10620. }
  10621. _getVisibleThumbs() {
  10622. return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getVisibleElements)({
  10623. scrollEl: this.container,
  10624. views: this._thumbnails
  10625. });
  10626. }
  10627. scrollThumbnailIntoView(pageNumber) {
  10628. if (!this.pdfDocument) {
  10629. return;
  10630. }
  10631. const thumbnailView = this._thumbnails[pageNumber - 1];
  10632. if (!thumbnailView) {
  10633. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  10634. return;
  10635. }
  10636. if (pageNumber !== this._currentPageNumber) {
  10637. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10638. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  10639. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10640. }
  10641. const {
  10642. first,
  10643. last,
  10644. views
  10645. } = this._getVisibleThumbs();
  10646. if (views.length > 0) {
  10647. let shouldScroll = false;
  10648. if (pageNumber <= first.id || pageNumber >= last.id) {
  10649. shouldScroll = true;
  10650. } else {
  10651. for (const {
  10652. id,
  10653. percent
  10654. } of views) {
  10655. if (id !== pageNumber) {
  10656. continue;
  10657. }
  10658. shouldScroll = percent < 100;
  10659. break;
  10660. }
  10661. }
  10662. if (shouldScroll) {
  10663. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.scrollIntoView)(thumbnailView.div, {
  10664. top: THUMBNAIL_SCROLL_MARGIN
  10665. });
  10666. }
  10667. }
  10668. this._currentPageNumber = pageNumber;
  10669. }
  10670. get pagesRotation() {
  10671. return this._pagesRotation;
  10672. }
  10673. set pagesRotation(rotation) {
  10674. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(rotation)) {
  10675. throw new Error("Invalid thumbnails rotation angle.");
  10676. }
  10677. if (!this.pdfDocument) {
  10678. return;
  10679. }
  10680. if (this._pagesRotation === rotation) {
  10681. return;
  10682. }
  10683. this._pagesRotation = rotation;
  10684. const updateArgs = {
  10685. rotation
  10686. };
  10687. for (const thumbnail of this._thumbnails) {
  10688. thumbnail.update(updateArgs);
  10689. }
  10690. }
  10691. cleanup() {
  10692. for (const thumbnail of this._thumbnails) {
  10693. if (thumbnail.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10694. thumbnail.reset();
  10695. }
  10696. }
  10697. _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__.TempImageFactory.destroyCanvas();
  10698. }
  10699. _resetView() {
  10700. this._thumbnails = [];
  10701. this._currentPageNumber = 1;
  10702. this._pageLabels = null;
  10703. this._pagesRotation = 0;
  10704. this.container.textContent = "";
  10705. }
  10706. setDocument(pdfDocument) {
  10707. if (this.pdfDocument) {
  10708. this._cancelRendering();
  10709. this._resetView();
  10710. }
  10711. this.pdfDocument = pdfDocument;
  10712. if (!pdfDocument) {
  10713. return;
  10714. }
  10715. const firstPagePromise = pdfDocument.getPage(1);
  10716. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10717. firstPagePromise.then(firstPdfPage => {
  10718. const pagesCount = pdfDocument.numPages;
  10719. const viewport = firstPdfPage.getViewport({
  10720. scale: 1
  10721. });
  10722. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10723. const thumbnail = new _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__.PDFThumbnailView({
  10724. container: this.container,
  10725. eventBus: this.eventBus,
  10726. id: pageNum,
  10727. defaultViewport: viewport.clone(),
  10728. optionalContentConfigPromise,
  10729. linkService: this.linkService,
  10730. renderingQueue: this.renderingQueue,
  10731. pageColors: this.pageColors
  10732. });
  10733. this._thumbnails.push(thumbnail);
  10734. }
  10735. this._thumbnails[0]?.setPdfPage(firstPdfPage);
  10736. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10737. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10738. }).catch(reason => {
  10739. console.error("Unable to initialize thumbnail viewer", reason);
  10740. });
  10741. }
  10742. _cancelRendering() {
  10743. for (const thumbnail of this._thumbnails) {
  10744. thumbnail.cancelRendering();
  10745. }
  10746. }
  10747. setPageLabels(labels) {
  10748. if (!this.pdfDocument) {
  10749. return;
  10750. }
  10751. if (!labels) {
  10752. this._pageLabels = null;
  10753. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10754. this._pageLabels = null;
  10755. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  10756. } else {
  10757. this._pageLabels = labels;
  10758. }
  10759. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  10760. this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
  10761. }
  10762. }
  10763. async #ensurePdfPageLoaded(thumbView) {
  10764. if (thumbView.pdfPage) {
  10765. return thumbView.pdfPage;
  10766. }
  10767. try {
  10768. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  10769. if (!thumbView.pdfPage) {
  10770. thumbView.setPdfPage(pdfPage);
  10771. }
  10772. return pdfPage;
  10773. } catch (reason) {
  10774. console.error("Unable to get page for thumb view", reason);
  10775. return null;
  10776. }
  10777. }
  10778. #getScrollAhead(visible) {
  10779. if (visible.first?.id === 1) {
  10780. return true;
  10781. } else if (visible.last?.id === this._thumbnails.length) {
  10782. return false;
  10783. }
  10784. return this.scroll.down;
  10785. }
  10786. forceRendering() {
  10787. const visibleThumbs = this._getVisibleThumbs();
  10788. const scrollAhead = this.#getScrollAhead(visibleThumbs);
  10789. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  10790. if (thumbView) {
  10791. this.#ensurePdfPageLoaded(thumbView).then(() => {
  10792. this.renderingQueue.renderView(thumbView);
  10793. });
  10794. return true;
  10795. }
  10796. return false;
  10797. }
  10798. }
  10799. __webpack_async_result__();
  10800. } catch(e) { __webpack_async_result__(e); } });
  10801. /***/ }),
  10802. /***/ 9290:
  10803. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  10804. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  10805. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10806. /* harmony export */ PDFViewer: () => (/* binding */ PDFViewer),
  10807. /* harmony export */ PagesCountLimit: () => (/* binding */ PagesCountLimit)
  10808. /* harmony export */ });
  10809. /* unused harmony export PDFPageViewBuffer */
  10810. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  10811. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  10812. /* harmony import */ var web_l10n_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7910);
  10813. /* harmony import */ var _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6732);
  10814. /* harmony import */ var _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5119);
  10815. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3234);
  10816. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_l10n_utils__WEBPACK_IMPORTED_MODULE_2__, _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__]);
  10817. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_l10n_utils__WEBPACK_IMPORTED_MODULE_2__, _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  10818. const DEFAULT_CACHE_SIZE = 10;
  10819. const PagesCountLimit = {
  10820. FORCE_SCROLL_MODE_PAGE: 15000,
  10821. FORCE_LAZY_PAGE_INIT: 7500,
  10822. PAUSE_EAGER_PAGE_INIT: 250
  10823. };
  10824. function isValidAnnotationEditorMode(mode) {
  10825. return Object.values(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType).includes(mode) && mode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  10826. }
  10827. class PDFPageViewBuffer {
  10828. #buf = new Set();
  10829. #size = 0;
  10830. constructor(size) {
  10831. this.#size = size;
  10832. }
  10833. push(view) {
  10834. const buf = this.#buf;
  10835. if (buf.has(view)) {
  10836. buf.delete(view);
  10837. }
  10838. buf.add(view);
  10839. if (buf.size > this.#size) {
  10840. this.#destroyFirstView();
  10841. }
  10842. }
  10843. resize(newSize, idsToKeep = null) {
  10844. this.#size = newSize;
  10845. const buf = this.#buf;
  10846. if (idsToKeep) {
  10847. const ii = buf.size;
  10848. let i = 1;
  10849. for (const view of buf) {
  10850. if (idsToKeep.has(view.id)) {
  10851. buf.delete(view);
  10852. buf.add(view);
  10853. }
  10854. if (++i > ii) {
  10855. break;
  10856. }
  10857. }
  10858. }
  10859. while (buf.size > this.#size) {
  10860. this.#destroyFirstView();
  10861. }
  10862. }
  10863. has(view) {
  10864. return this.#buf.has(view);
  10865. }
  10866. [Symbol.iterator]() {
  10867. return this.#buf.keys();
  10868. }
  10869. #destroyFirstView() {
  10870. const firstView = this.#buf.keys().next().value;
  10871. firstView?.destroy();
  10872. this.#buf.delete(firstView);
  10873. }
  10874. }
  10875. class PDFViewer {
  10876. #buffer = null;
  10877. #altTextManager = null;
  10878. #annotationEditorHighlightColors = null;
  10879. #annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
  10880. #annotationEditorUIManager = null;
  10881. #annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  10882. #containerTopLeft = null;
  10883. #copyCallbackBound = null;
  10884. #enablePermissions = false;
  10885. #getAllTextInProgress = false;
  10886. #hiddenCopyElement = null;
  10887. #interruptCopyCondition = false;
  10888. #previousContainerHeight = 0;
  10889. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  10890. #scrollModePageState = null;
  10891. #onVisibilityChange = null;
  10892. #scaleTimeoutId = null;
  10893. #textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  10894. constructor(options) {
  10895. const viewerVersion = '4.0.379';
  10896. if (pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version !== viewerVersion) {
  10897. throw new Error(`The API version "${pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version}" does not match the Viewer version "${viewerVersion}".`);
  10898. }
  10899. this.container = options.container;
  10900. this.viewer = options.viewer || options.container.firstElementChild;
  10901. if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
  10902. throw new Error("Invalid `container` and/or `viewer` option.");
  10903. }
  10904. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  10905. throw new Error("The `container` must be absolutely positioned.");
  10906. }
  10907. this.#resizeObserver.observe(this.container);
  10908. this.eventBus = options.eventBus;
  10909. this.linkService = options.linkService || new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.SimpleLinkService();
  10910. this.downloadManager = options.downloadManager || null;
  10911. this.findController = options.findController || null;
  10912. this.#altTextManager = options.altTextManager || null;
  10913. if (this.findController) {
  10914. this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
  10915. }
  10916. this._scriptingManager = options.scriptingManager || null;
  10917. this.#textLayerMode = options.textLayerMode ?? _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  10918. this.#annotationMode = options.annotationMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  10919. this.#annotationEditorMode = options.annotationEditorMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
  10920. this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
  10921. this.imageResourcesPath = options.imageResourcesPath || "";
  10922. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10923. this.removePageBorders = options.removePageBorders || false;
  10924. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  10925. this.maxCanvasPixels = options.maxCanvasPixels;
  10926. this.l10n = options.l10n || web_l10n_utils__WEBPACK_IMPORTED_MODULE_2__.NullL10n;
  10927. this.#enablePermissions = options.enablePermissions || false;
  10928. this.pageColors = options.pageColors || null;
  10929. this.defaultRenderingQueue = !options.renderingQueue;
  10930. if (this.defaultRenderingQueue) {
  10931. this.renderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__.PDFRenderingQueue();
  10932. this.renderingQueue.setViewer(this);
  10933. } else {
  10934. this.renderingQueue = options.renderingQueue;
  10935. }
  10936. this.scroll = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10937. this.presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.UNKNOWN;
  10938. this._onBeforeDraw = this._onAfterDraw = null;
  10939. this._resetView();
  10940. if (this.removePageBorders) {
  10941. this.viewer.classList.add("removePageBorders");
  10942. }
  10943. this.#updateContainerHeightCss();
  10944. this.eventBus._on("thumbnailrendered", ({
  10945. pageNumber,
  10946. pdfPage
  10947. }) => {
  10948. const pageView = this._pages[pageNumber - 1];
  10949. if (!this.#buffer.has(pageView)) {
  10950. pdfPage?.cleanup();
  10951. }
  10952. });
  10953. if (this.l10n === web_l10n_utils__WEBPACK_IMPORTED_MODULE_2__.NullL10n) {
  10954. this.l10n.translate(this.container);
  10955. }
  10956. }
  10957. get pagesCount() {
  10958. return this._pages.length;
  10959. }
  10960. getPageView(index) {
  10961. return this._pages[index];
  10962. }
  10963. getCachedPageViews() {
  10964. return new Set(this.#buffer);
  10965. }
  10966. get pageViewsReady() {
  10967. return this._pagesCapability.settled && this._pages.every(pageView => pageView?.pdfPage);
  10968. }
  10969. get renderForms() {
  10970. return this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  10971. }
  10972. get enableScripting() {
  10973. return !!this._scriptingManager;
  10974. }
  10975. get currentPageNumber() {
  10976. return this._currentPageNumber;
  10977. }
  10978. set currentPageNumber(val) {
  10979. if (!Number.isInteger(val)) {
  10980. throw new Error("Invalid page number.");
  10981. }
  10982. if (!this.pdfDocument) {
  10983. return;
  10984. }
  10985. if (!this._setCurrentPageNumber(val, true)) {
  10986. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  10987. }
  10988. }
  10989. _setCurrentPageNumber(val, resetCurrentPageView = false) {
  10990. if (this._currentPageNumber === val) {
  10991. if (resetCurrentPageView) {
  10992. this.#resetCurrentPageView();
  10993. }
  10994. return true;
  10995. }
  10996. if (!(0 < val && val <= this.pagesCount)) {
  10997. return false;
  10998. }
  10999. const previous = this._currentPageNumber;
  11000. this._currentPageNumber = val;
  11001. this.eventBus.dispatch("pagechanging", {
  11002. source: this,
  11003. pageNumber: val,
  11004. pageLabel: this._pageLabels?.[val - 1] ?? null,
  11005. previous
  11006. });
  11007. if (resetCurrentPageView) {
  11008. this.#resetCurrentPageView();
  11009. }
  11010. return true;
  11011. }
  11012. get currentPageLabel() {
  11013. return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
  11014. }
  11015. set currentPageLabel(val) {
  11016. if (!this.pdfDocument) {
  11017. return;
  11018. }
  11019. let page = val | 0;
  11020. if (this._pageLabels) {
  11021. const i = this._pageLabels.indexOf(val);
  11022. if (i >= 0) {
  11023. page = i + 1;
  11024. }
  11025. }
  11026. if (!this._setCurrentPageNumber(page, true)) {
  11027. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  11028. }
  11029. }
  11030. get currentScale() {
  11031. return this._currentScale !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE ? this._currentScale : _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
  11032. }
  11033. set currentScale(val) {
  11034. if (isNaN(val)) {
  11035. throw new Error("Invalid numeric scale.");
  11036. }
  11037. if (!this.pdfDocument) {
  11038. return;
  11039. }
  11040. this.#setScale(val, {
  11041. noScroll: false
  11042. });
  11043. }
  11044. get currentScaleValue() {
  11045. return this._currentScaleValue;
  11046. }
  11047. set currentScaleValue(val) {
  11048. if (!this.pdfDocument) {
  11049. return;
  11050. }
  11051. this.#setScale(val, {
  11052. noScroll: false
  11053. });
  11054. }
  11055. get pagesRotation() {
  11056. return this._pagesRotation;
  11057. }
  11058. set pagesRotation(rotation) {
  11059. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidRotation)(rotation)) {
  11060. throw new Error("Invalid pages rotation angle.");
  11061. }
  11062. if (!this.pdfDocument) {
  11063. return;
  11064. }
  11065. rotation %= 360;
  11066. if (rotation < 0) {
  11067. rotation += 360;
  11068. }
  11069. if (this._pagesRotation === rotation) {
  11070. return;
  11071. }
  11072. this._pagesRotation = rotation;
  11073. const pageNumber = this._currentPageNumber;
  11074. this.refresh(true, {
  11075. rotation
  11076. });
  11077. if (this._currentScaleValue) {
  11078. this.#setScale(this._currentScaleValue, {
  11079. noScroll: true
  11080. });
  11081. }
  11082. this.eventBus.dispatch("rotationchanging", {
  11083. source: this,
  11084. pagesRotation: rotation,
  11085. pageNumber
  11086. });
  11087. if (this.defaultRenderingQueue) {
  11088. this.update();
  11089. }
  11090. }
  11091. get firstPagePromise() {
  11092. return this.pdfDocument ? this._firstPageCapability.promise : null;
  11093. }
  11094. get onePageRendered() {
  11095. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  11096. }
  11097. get pagesPromise() {
  11098. return this.pdfDocument ? this._pagesCapability.promise : null;
  11099. }
  11100. get _layerProperties() {
  11101. const self = this;
  11102. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_layerProperties", {
  11103. get annotationEditorUIManager() {
  11104. return self.#annotationEditorUIManager;
  11105. },
  11106. get annotationStorage() {
  11107. return self.pdfDocument?.annotationStorage;
  11108. },
  11109. get downloadManager() {
  11110. return self.downloadManager;
  11111. },
  11112. get enableScripting() {
  11113. return !!self._scriptingManager;
  11114. },
  11115. get fieldObjectsPromise() {
  11116. return self.pdfDocument?.getFieldObjects();
  11117. },
  11118. get findController() {
  11119. return self.findController;
  11120. },
  11121. get hasJSActionsPromise() {
  11122. return self.pdfDocument?.hasJSActions();
  11123. },
  11124. get linkService() {
  11125. return self.linkService;
  11126. }
  11127. });
  11128. }
  11129. #initializePermissions(permissions) {
  11130. const params = {
  11131. annotationEditorMode: this.#annotationEditorMode,
  11132. annotationMode: this.#annotationMode,
  11133. textLayerMode: this.#textLayerMode
  11134. };
  11135. if (!permissions) {
  11136. return params;
  11137. }
  11138. if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.COPY) && this.#textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE) {
  11139. params.textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS;
  11140. }
  11141. if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.MODIFY_CONTENTS)) {
  11142. params.annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  11143. }
  11144. if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS) {
  11145. params.annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE;
  11146. }
  11147. return params;
  11148. }
  11149. #onePageRenderedOrForceFetch() {
  11150. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  11151. return Promise.resolve();
  11152. }
  11153. const visibilityChangePromise = new Promise(resolve => {
  11154. this.#onVisibilityChange = () => {
  11155. if (document.visibilityState !== "hidden") {
  11156. return;
  11157. }
  11158. resolve();
  11159. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11160. this.#onVisibilityChange = null;
  11161. };
  11162. document.addEventListener("visibilitychange", this.#onVisibilityChange);
  11163. });
  11164. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  11165. }
  11166. async getAllText() {
  11167. const texts = [];
  11168. const buffer = [];
  11169. for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
  11170. if (this.#interruptCopyCondition) {
  11171. return null;
  11172. }
  11173. buffer.length = 0;
  11174. const page = await this.pdfDocument.getPage(pageNum);
  11175. const {
  11176. items
  11177. } = await page.getTextContent();
  11178. for (const item of items) {
  11179. if (item.str) {
  11180. buffer.push(item.str);
  11181. }
  11182. if (item.hasEOL) {
  11183. buffer.push("\n");
  11184. }
  11185. }
  11186. texts.push((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.removeNullCharacters)(buffer.join("")));
  11187. }
  11188. return texts.join("\n");
  11189. }
  11190. #copyCallback(textLayerMode, event) {
  11191. const selection = document.getSelection();
  11192. const {
  11193. focusNode,
  11194. anchorNode
  11195. } = selection;
  11196. if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
  11197. if (this.#getAllTextInProgress || textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS) {
  11198. event.preventDefault();
  11199. event.stopPropagation();
  11200. return;
  11201. }
  11202. this.#getAllTextInProgress = true;
  11203. const savedCursor = this.container.style.cursor;
  11204. this.container.style.cursor = "wait";
  11205. const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
  11206. window.addEventListener("keydown", interruptCopy);
  11207. this.getAllText().then(async text => {
  11208. if (text !== null) {
  11209. await navigator.clipboard.writeText(text);
  11210. }
  11211. }).catch(reason => {
  11212. console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
  11213. }).finally(() => {
  11214. this.#getAllTextInProgress = false;
  11215. this.#interruptCopyCondition = false;
  11216. window.removeEventListener("keydown", interruptCopy);
  11217. this.container.style.cursor = savedCursor;
  11218. });
  11219. event.preventDefault();
  11220. event.stopPropagation();
  11221. }
  11222. }
  11223. setDocument(pdfDocument) {
  11224. if (this.pdfDocument) {
  11225. this.eventBus.dispatch("pagesdestroy", {
  11226. source: this
  11227. });
  11228. this._cancelRendering();
  11229. this._resetView();
  11230. this.findController?.setDocument(null);
  11231. this._scriptingManager?.setDocument(null);
  11232. if (this.#annotationEditorUIManager) {
  11233. this.#annotationEditorUIManager.destroy();
  11234. this.#annotationEditorUIManager = null;
  11235. }
  11236. }
  11237. this.pdfDocument = pdfDocument;
  11238. if (!pdfDocument) {
  11239. return;
  11240. }
  11241. const pagesCount = pdfDocument.numPages;
  11242. const firstPagePromise = pdfDocument.getPage(1);
  11243. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  11244. const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
  11245. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11246. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  11247. const mode = this._scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE;
  11248. this.eventBus.dispatch("scrollmodechanged", {
  11249. source: this,
  11250. mode
  11251. });
  11252. }
  11253. this._pagesCapability.promise.then(() => {
  11254. this.eventBus.dispatch("pagesloaded", {
  11255. source: this,
  11256. pagesCount
  11257. });
  11258. }, () => {});
  11259. this._onBeforeDraw = evt => {
  11260. const pageView = this._pages[evt.pageNumber - 1];
  11261. if (!pageView) {
  11262. return;
  11263. }
  11264. this.#buffer.push(pageView);
  11265. };
  11266. this.eventBus._on("pagerender", this._onBeforeDraw);
  11267. this._onAfterDraw = evt => {
  11268. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  11269. return;
  11270. }
  11271. this._onePageRenderedCapability.resolve({
  11272. timestamp: evt.timestamp
  11273. });
  11274. this.eventBus._off("pagerendered", this._onAfterDraw);
  11275. this._onAfterDraw = null;
  11276. if (this.#onVisibilityChange) {
  11277. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11278. this.#onVisibilityChange = null;
  11279. }
  11280. };
  11281. this.eventBus._on("pagerendered", this._onAfterDraw);
  11282. Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => {
  11283. if (pdfDocument !== this.pdfDocument) {
  11284. return;
  11285. }
  11286. this._firstPageCapability.resolve(firstPdfPage);
  11287. this._optionalContentConfigPromise = optionalContentConfigPromise;
  11288. const {
  11289. annotationEditorMode,
  11290. annotationMode,
  11291. textLayerMode
  11292. } = this.#initializePermissions(permissions);
  11293. if (textLayerMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.DISABLE) {
  11294. const element = this.#hiddenCopyElement = document.createElement("div");
  11295. element.id = "hiddenCopyElement";
  11296. this.viewer.before(element);
  11297. }
  11298. if (annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE) {
  11299. const mode = annotationEditorMode;
  11300. if (pdfDocument.isPureXfa) {
  11301. console.warn("Warning: XFA-editing is not implemented.");
  11302. } else if (isValidAnnotationEditorMode(mode)) {
  11303. this.#annotationEditorUIManager = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorUIManager(this.container, this.viewer, this.#altTextManager, this.eventBus, pdfDocument, this.pageColors, this.#annotationEditorHighlightColors);
  11304. this.eventBus.dispatch("annotationeditoruimanager", {
  11305. source: this,
  11306. uiManager: this.#annotationEditorUIManager
  11307. });
  11308. if (mode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE) {
  11309. this.#annotationEditorUIManager.updateMode(mode);
  11310. }
  11311. } else {
  11312. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  11313. }
  11314. }
  11315. const viewerElement = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE ? null : this.viewer;
  11316. const scale = this.currentScale;
  11317. const viewport = firstPdfPage.getViewport({
  11318. scale: scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS
  11319. });
  11320. this.viewer.style.setProperty("--scale-factor", viewport.scale);
  11321. if (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas") {
  11322. this.viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  11323. }
  11324. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11325. const pageView = new _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__.PDFPageView({
  11326. container: viewerElement,
  11327. eventBus: this.eventBus,
  11328. id: pageNum,
  11329. scale,
  11330. defaultViewport: viewport.clone(),
  11331. optionalContentConfigPromise,
  11332. renderingQueue: this.renderingQueue,
  11333. textLayerMode,
  11334. annotationMode,
  11335. imageResourcesPath: this.imageResourcesPath,
  11336. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  11337. maxCanvasPixels: this.maxCanvasPixels,
  11338. pageColors: this.pageColors,
  11339. l10n: this.l10n,
  11340. layerProperties: this._layerProperties
  11341. });
  11342. this._pages.push(pageView);
  11343. }
  11344. const firstPageView = this._pages[0];
  11345. if (firstPageView) {
  11346. firstPageView.setPdfPage(firstPdfPage);
  11347. this.linkService.cachePageRef(1, firstPdfPage.ref);
  11348. }
  11349. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  11350. this.#ensurePageViewVisible();
  11351. } else if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  11352. this._updateSpreadMode();
  11353. }
  11354. this.#onePageRenderedOrForceFetch().then(async () => {
  11355. this.findController?.setDocument(pdfDocument);
  11356. this._scriptingManager?.setDocument(pdfDocument);
  11357. if (this.#hiddenCopyElement) {
  11358. this.#copyCallbackBound = this.#copyCallback.bind(this, textLayerMode);
  11359. document.addEventListener("copy", this.#copyCallbackBound);
  11360. }
  11361. if (this.#annotationEditorUIManager) {
  11362. this.eventBus.dispatch("annotationeditormodechanged", {
  11363. source: this,
  11364. mode: this.#annotationEditorMode
  11365. });
  11366. }
  11367. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  11368. this._pagesCapability.resolve();
  11369. return;
  11370. }
  11371. let getPagesLeft = pagesCount - 1;
  11372. if (getPagesLeft <= 0) {
  11373. this._pagesCapability.resolve();
  11374. return;
  11375. }
  11376. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  11377. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  11378. const pageView = this._pages[pageNum - 1];
  11379. if (!pageView.pdfPage) {
  11380. pageView.setPdfPage(pdfPage);
  11381. }
  11382. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  11383. if (--getPagesLeft === 0) {
  11384. this._pagesCapability.resolve();
  11385. }
  11386. }, reason => {
  11387. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  11388. if (--getPagesLeft === 0) {
  11389. this._pagesCapability.resolve();
  11390. }
  11391. });
  11392. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  11393. await promise;
  11394. }
  11395. }
  11396. });
  11397. this.eventBus.dispatch("pagesinit", {
  11398. source: this
  11399. });
  11400. pdfDocument.getMetadata().then(({
  11401. info
  11402. }) => {
  11403. if (pdfDocument !== this.pdfDocument) {
  11404. return;
  11405. }
  11406. if (info.Language) {
  11407. this.viewer.lang = info.Language;
  11408. }
  11409. });
  11410. if (this.defaultRenderingQueue) {
  11411. this.update();
  11412. }
  11413. }).catch(reason => {
  11414. console.error("Unable to initialize viewer", reason);
  11415. this._pagesCapability.reject(reason);
  11416. });
  11417. }
  11418. setPageLabels(labels) {
  11419. if (!this.pdfDocument) {
  11420. return;
  11421. }
  11422. if (!labels) {
  11423. this._pageLabels = null;
  11424. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11425. this._pageLabels = null;
  11426. console.error(`setPageLabels: Invalid page labels.`);
  11427. } else {
  11428. this._pageLabels = labels;
  11429. }
  11430. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  11431. this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11432. }
  11433. }
  11434. _resetView() {
  11435. this._pages = [];
  11436. this._currentPageNumber = 1;
  11437. this._currentScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE;
  11438. this._currentScaleValue = null;
  11439. this._pageLabels = null;
  11440. this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  11441. this._location = null;
  11442. this._pagesRotation = 0;
  11443. this._optionalContentConfigPromise = null;
  11444. this._firstPageCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
  11445. this._onePageRenderedCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
  11446. this._pagesCapability = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PromiseCapability();
  11447. this._scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL;
  11448. this._previousScrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.UNKNOWN;
  11449. this._spreadMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE;
  11450. this.#scrollModePageState = {
  11451. previousPageNumber: 1,
  11452. scrollDown: true,
  11453. pages: []
  11454. };
  11455. if (this._onBeforeDraw) {
  11456. this.eventBus._off("pagerender", this._onBeforeDraw);
  11457. this._onBeforeDraw = null;
  11458. }
  11459. if (this._onAfterDraw) {
  11460. this.eventBus._off("pagerendered", this._onAfterDraw);
  11461. this._onAfterDraw = null;
  11462. }
  11463. if (this.#onVisibilityChange) {
  11464. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11465. this.#onVisibilityChange = null;
  11466. }
  11467. this.viewer.textContent = "";
  11468. this._updateScrollMode();
  11469. this.viewer.removeAttribute("lang");
  11470. if (this.#hiddenCopyElement) {
  11471. document.removeEventListener("copy", this.#copyCallbackBound);
  11472. this.#copyCallbackBound = null;
  11473. this.#hiddenCopyElement.remove();
  11474. this.#hiddenCopyElement = null;
  11475. }
  11476. }
  11477. #ensurePageViewVisible() {
  11478. if (this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  11479. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  11480. }
  11481. const pageNumber = this._currentPageNumber,
  11482. state = this.#scrollModePageState,
  11483. viewer = this.viewer;
  11484. viewer.textContent = "";
  11485. state.pages.length = 0;
  11486. if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && !this.isInPresentationMode) {
  11487. const pageView = this._pages[pageNumber - 1];
  11488. viewer.append(pageView.div);
  11489. state.pages.push(pageView);
  11490. } else {
  11491. const pageIndexSet = new Set(),
  11492. parity = this._spreadMode - 1;
  11493. if (parity === -1) {
  11494. pageIndexSet.add(pageNumber - 1);
  11495. } else if (pageNumber % 2 !== parity) {
  11496. pageIndexSet.add(pageNumber - 1);
  11497. pageIndexSet.add(pageNumber);
  11498. } else {
  11499. pageIndexSet.add(pageNumber - 2);
  11500. pageIndexSet.add(pageNumber - 1);
  11501. }
  11502. const spread = document.createElement("div");
  11503. spread.className = "spread";
  11504. if (this.isInPresentationMode) {
  11505. const dummyPage = document.createElement("div");
  11506. dummyPage.className = "dummyPage";
  11507. spread.append(dummyPage);
  11508. }
  11509. for (const i of pageIndexSet) {
  11510. const pageView = this._pages[i];
  11511. if (!pageView) {
  11512. continue;
  11513. }
  11514. spread.append(pageView.div);
  11515. state.pages.push(pageView);
  11516. }
  11517. viewer.append(spread);
  11518. }
  11519. state.scrollDown = pageNumber >= state.previousPageNumber;
  11520. state.previousPageNumber = pageNumber;
  11521. }
  11522. _scrollUpdate() {
  11523. if (this.pagesCount === 0) {
  11524. return;
  11525. }
  11526. this.update();
  11527. }
  11528. #scrollIntoView(pageView, pageSpot = null) {
  11529. const {
  11530. div,
  11531. id
  11532. } = pageView;
  11533. if (this._currentPageNumber !== id) {
  11534. this._setCurrentPageNumber(id);
  11535. }
  11536. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  11537. this.#ensurePageViewVisible();
  11538. this.update();
  11539. }
  11540. if (!pageSpot && !this.isInPresentationMode) {
  11541. const left = div.offsetLeft + div.clientLeft,
  11542. right = left + div.clientWidth;
  11543. const {
  11544. scrollLeft,
  11545. clientWidth
  11546. } = this.container;
  11547. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  11548. pageSpot = {
  11549. left: 0,
  11550. top: 0
  11551. };
  11552. }
  11553. }
  11554. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.scrollIntoView)(div, pageSpot);
  11555. if (!this._currentScaleValue && this._location) {
  11556. this._location = null;
  11557. }
  11558. }
  11559. #isSameScale(newScale) {
  11560. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  11561. }
  11562. #setScaleUpdatePages(newScale, newValue, {
  11563. noScroll = false,
  11564. preset = false,
  11565. drawingDelay = -1
  11566. }) {
  11567. this._currentScaleValue = newValue.toString();
  11568. if (this.#isSameScale(newScale)) {
  11569. if (preset) {
  11570. this.eventBus.dispatch("scalechanging", {
  11571. source: this,
  11572. scale: newScale,
  11573. presetValue: newValue
  11574. });
  11575. }
  11576. return;
  11577. }
  11578. this.viewer.style.setProperty("--scale-factor", newScale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS);
  11579. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  11580. this.refresh(true, {
  11581. scale: newScale,
  11582. drawingDelay: postponeDrawing ? drawingDelay : -1
  11583. });
  11584. if (postponeDrawing) {
  11585. this.#scaleTimeoutId = setTimeout(() => {
  11586. this.#scaleTimeoutId = null;
  11587. this.refresh();
  11588. }, drawingDelay);
  11589. }
  11590. this._currentScale = newScale;
  11591. if (!noScroll) {
  11592. let page = this._currentPageNumber,
  11593. dest;
  11594. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  11595. page = this._location.pageNumber;
  11596. dest = [null, {
  11597. name: "XYZ"
  11598. }, this._location.left, this._location.top, null];
  11599. }
  11600. this.scrollPageIntoView({
  11601. pageNumber: page,
  11602. destArray: dest,
  11603. allowNegativeOffset: true
  11604. });
  11605. }
  11606. this.eventBus.dispatch("scalechanging", {
  11607. source: this,
  11608. scale: newScale,
  11609. presetValue: preset ? newValue : undefined
  11610. });
  11611. if (this.defaultRenderingQueue) {
  11612. this.update();
  11613. }
  11614. }
  11615. get #pageWidthScaleFactor() {
  11616. if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL) {
  11617. return 2;
  11618. }
  11619. return 1;
  11620. }
  11621. #setScale(value, options) {
  11622. let scale = parseFloat(value);
  11623. if (scale > 0) {
  11624. options.preset = false;
  11625. this.#setScaleUpdatePages(scale, value, options);
  11626. } else {
  11627. const currentPage = this._pages[this._currentPageNumber - 1];
  11628. if (!currentPage) {
  11629. return;
  11630. }
  11631. let hPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SCROLLBAR_PADDING,
  11632. vPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.VERTICAL_PADDING;
  11633. if (this.isInPresentationMode) {
  11634. hPadding = vPadding = 4;
  11635. if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  11636. hPadding *= 2;
  11637. }
  11638. } else if (this.removePageBorders) {
  11639. hPadding = vPadding = 0;
  11640. } else if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL) {
  11641. [hPadding, vPadding] = [vPadding, hPadding];
  11642. }
  11643. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
  11644. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  11645. switch (value) {
  11646. case "page-actual":
  11647. scale = 1;
  11648. break;
  11649. case "page-width":
  11650. scale = pageWidthScale;
  11651. break;
  11652. case "page-height":
  11653. scale = pageHeightScale;
  11654. break;
  11655. case "page-fit":
  11656. scale = Math.min(pageWidthScale, pageHeightScale);
  11657. break;
  11658. case "auto":
  11659. const horizontalScale = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  11660. scale = Math.min(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_AUTO_SCALE, horizontalScale);
  11661. break;
  11662. default:
  11663. console.error(`#setScale: "${value}" is an unknown zoom value.`);
  11664. return;
  11665. }
  11666. options.preset = true;
  11667. this.#setScaleUpdatePages(scale, value, options);
  11668. }
  11669. }
  11670. #resetCurrentPageView() {
  11671. const pageView = this._pages[this._currentPageNumber - 1];
  11672. if (this.isInPresentationMode) {
  11673. this.#setScale(this._currentScaleValue, {
  11674. noScroll: true
  11675. });
  11676. }
  11677. this.#scrollIntoView(pageView);
  11678. }
  11679. pageLabelToPageNumber(label) {
  11680. if (!this._pageLabels) {
  11681. return null;
  11682. }
  11683. const i = this._pageLabels.indexOf(label);
  11684. if (i < 0) {
  11685. return null;
  11686. }
  11687. return i + 1;
  11688. }
  11689. scrollPageIntoView({
  11690. pageNumber,
  11691. destArray = null,
  11692. allowNegativeOffset = false,
  11693. ignoreDestinationZoom = false
  11694. }) {
  11695. if (!this.pdfDocument) {
  11696. return;
  11697. }
  11698. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  11699. if (!pageView) {
  11700. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  11701. return;
  11702. }
  11703. if (this.isInPresentationMode || !destArray) {
  11704. this._setCurrentPageNumber(pageNumber, true);
  11705. return;
  11706. }
  11707. let x = 0,
  11708. y = 0;
  11709. let width = 0,
  11710. height = 0,
  11711. widthScale,
  11712. heightScale;
  11713. const changeOrientation = pageView.rotation % 180 !== 0;
  11714. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  11715. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  11716. let scale = 0;
  11717. switch (destArray[1].name) {
  11718. case "XYZ":
  11719. x = destArray[2];
  11720. y = destArray[3];
  11721. scale = destArray[4];
  11722. x = x !== null ? x : 0;
  11723. y = y !== null ? y : pageHeight;
  11724. break;
  11725. case "Fit":
  11726. case "FitB":
  11727. scale = "page-fit";
  11728. break;
  11729. case "FitH":
  11730. case "FitBH":
  11731. y = destArray[2];
  11732. scale = "page-width";
  11733. if (y === null && this._location) {
  11734. x = this._location.left;
  11735. y = this._location.top;
  11736. } else if (typeof y !== "number" || y < 0) {
  11737. y = pageHeight;
  11738. }
  11739. break;
  11740. case "FitV":
  11741. case "FitBV":
  11742. x = destArray[2];
  11743. width = pageWidth;
  11744. height = pageHeight;
  11745. scale = "page-height";
  11746. break;
  11747. case "FitR":
  11748. x = destArray[2];
  11749. y = destArray[3];
  11750. width = destArray[4] - x;
  11751. height = destArray[5] - y;
  11752. let hPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SCROLLBAR_PADDING,
  11753. vPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.VERTICAL_PADDING;
  11754. if (this.removePageBorders) {
  11755. hPadding = vPadding = 0;
  11756. }
  11757. widthScale = (this.container.clientWidth - hPadding) / width / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  11758. heightScale = (this.container.clientHeight - vPadding) / height / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  11759. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  11760. break;
  11761. default:
  11762. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  11763. return;
  11764. }
  11765. if (!ignoreDestinationZoom) {
  11766. if (scale && scale !== this._currentScale) {
  11767. this.currentScaleValue = scale;
  11768. } else if (this._currentScale === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE) {
  11769. this.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_VALUE;
  11770. }
  11771. }
  11772. if (scale === "page-fit" && !destArray[4]) {
  11773. this.#scrollIntoView(pageView);
  11774. return;
  11775. }
  11776. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  11777. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  11778. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  11779. if (!allowNegativeOffset) {
  11780. left = Math.max(left, 0);
  11781. top = Math.max(top, 0);
  11782. }
  11783. this.#scrollIntoView(pageView, {
  11784. left,
  11785. top
  11786. });
  11787. }
  11788. _updateLocation(firstPage) {
  11789. const currentScale = this._currentScale;
  11790. const currentScaleValue = this._currentScaleValue;
  11791. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  11792. const pageNumber = firstPage.id;
  11793. const currentPageView = this._pages[pageNumber - 1];
  11794. const container = this.container;
  11795. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  11796. const intLeft = Math.round(topLeft[0]);
  11797. const intTop = Math.round(topLeft[1]);
  11798. let pdfOpenParams = `#page=${pageNumber}`;
  11799. if (!this.isInPresentationMode) {
  11800. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  11801. }
  11802. this._location = {
  11803. pageNumber,
  11804. scale: normalizedScaleValue,
  11805. top: intTop,
  11806. left: intLeft,
  11807. rotation: this._pagesRotation,
  11808. pdfOpenParams
  11809. };
  11810. }
  11811. update() {
  11812. const visible = this._getVisiblePages();
  11813. const visiblePages = visible.views,
  11814. numVisiblePages = visiblePages.length;
  11815. if (numVisiblePages === 0) {
  11816. return;
  11817. }
  11818. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11819. this.#buffer.resize(newCacheSize, visible.ids);
  11820. this.renderingQueue.renderHighestPriority(visible);
  11821. const isSimpleLayout = this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE || this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL);
  11822. const currentId = this._currentPageNumber;
  11823. let stillFullyVisible = false;
  11824. for (const page of visiblePages) {
  11825. if (page.percent < 100) {
  11826. break;
  11827. }
  11828. if (page.id === currentId && isSimpleLayout) {
  11829. stillFullyVisible = true;
  11830. break;
  11831. }
  11832. }
  11833. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  11834. this._updateLocation(visible.first);
  11835. this.eventBus.dispatch("updateviewarea", {
  11836. source: this,
  11837. location: this._location
  11838. });
  11839. }
  11840. containsElement(element) {
  11841. return this.container.contains(element);
  11842. }
  11843. focus() {
  11844. this.container.focus();
  11845. }
  11846. get _isContainerRtl() {
  11847. return getComputedStyle(this.container).direction === "rtl";
  11848. }
  11849. get isInPresentationMode() {
  11850. return this.presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN;
  11851. }
  11852. get isChangingPresentationMode() {
  11853. return this.presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.CHANGING;
  11854. }
  11855. get isHorizontalScrollbarEnabled() {
  11856. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11857. }
  11858. get isVerticalScrollbarEnabled() {
  11859. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11860. }
  11861. _getVisiblePages() {
  11862. const views = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
  11863. horizontal = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL,
  11864. rtl = horizontal && this._isContainerRtl;
  11865. return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.getVisibleElements)({
  11866. scrollEl: this.container,
  11867. views,
  11868. sortByVisibility: true,
  11869. horizontal,
  11870. rtl
  11871. });
  11872. }
  11873. cleanup() {
  11874. for (const pageView of this._pages) {
  11875. if (pageView.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED) {
  11876. pageView.reset();
  11877. }
  11878. }
  11879. }
  11880. _cancelRendering() {
  11881. for (const pageView of this._pages) {
  11882. pageView.cancelRendering();
  11883. }
  11884. }
  11885. async #ensurePdfPageLoaded(pageView) {
  11886. if (pageView.pdfPage) {
  11887. return pageView.pdfPage;
  11888. }
  11889. try {
  11890. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  11891. if (!pageView.pdfPage) {
  11892. pageView.setPdfPage(pdfPage);
  11893. }
  11894. if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
  11895. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  11896. }
  11897. return pdfPage;
  11898. } catch (reason) {
  11899. console.error("Unable to get page for page view", reason);
  11900. return null;
  11901. }
  11902. }
  11903. #getScrollAhead(visible) {
  11904. if (visible.first?.id === 1) {
  11905. return true;
  11906. } else if (visible.last?.id === this.pagesCount) {
  11907. return false;
  11908. }
  11909. switch (this._scrollMode) {
  11910. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE:
  11911. return this.#scrollModePageState.scrollDown;
  11912. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL:
  11913. return this.scroll.right;
  11914. }
  11915. return this.scroll.down;
  11916. }
  11917. forceRendering(currentlyVisiblePages) {
  11918. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11919. const scrollAhead = this.#getScrollAhead(visiblePages);
  11920. const preRenderExtra = this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL;
  11921. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  11922. if (pageView) {
  11923. this.#ensurePdfPageLoaded(pageView).then(() => {
  11924. this.renderingQueue.renderView(pageView);
  11925. });
  11926. return true;
  11927. }
  11928. return false;
  11929. }
  11930. get hasEqualPageSizes() {
  11931. const firstPageView = this._pages[0];
  11932. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  11933. const pageView = this._pages[i];
  11934. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11935. return false;
  11936. }
  11937. }
  11938. return true;
  11939. }
  11940. getPagesOverview() {
  11941. let initialOrientation;
  11942. return this._pages.map(pageView => {
  11943. const viewport = pageView.pdfPage.getViewport({
  11944. scale: 1
  11945. });
  11946. const orientation = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isPortraitOrientation)(viewport);
  11947. if (initialOrientation === undefined) {
  11948. initialOrientation = orientation;
  11949. } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
  11950. return {
  11951. width: viewport.height,
  11952. height: viewport.width,
  11953. rotation: (viewport.rotation - 90) % 360
  11954. };
  11955. }
  11956. return {
  11957. width: viewport.width,
  11958. height: viewport.height,
  11959. rotation: viewport.rotation
  11960. };
  11961. });
  11962. }
  11963. get optionalContentConfigPromise() {
  11964. if (!this.pdfDocument) {
  11965. return Promise.resolve(null);
  11966. }
  11967. if (!this._optionalContentConfigPromise) {
  11968. console.error("optionalContentConfigPromise: Not initialized yet.");
  11969. return this.pdfDocument.getOptionalContentConfig();
  11970. }
  11971. return this._optionalContentConfigPromise;
  11972. }
  11973. set optionalContentConfigPromise(promise) {
  11974. if (!(promise instanceof Promise)) {
  11975. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  11976. }
  11977. if (!this.pdfDocument) {
  11978. return;
  11979. }
  11980. if (!this._optionalContentConfigPromise) {
  11981. return;
  11982. }
  11983. this._optionalContentConfigPromise = promise;
  11984. this.refresh(false, {
  11985. optionalContentConfigPromise: promise
  11986. });
  11987. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11988. source: this,
  11989. promise
  11990. });
  11991. }
  11992. get scrollMode() {
  11993. return this._scrollMode;
  11994. }
  11995. set scrollMode(mode) {
  11996. if (this._scrollMode === mode) {
  11997. return;
  11998. }
  11999. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidScrollMode)(mode)) {
  12000. throw new Error(`Invalid scroll mode: ${mode}`);
  12001. }
  12002. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  12003. return;
  12004. }
  12005. this._previousScrollMode = this._scrollMode;
  12006. this._scrollMode = mode;
  12007. this.eventBus.dispatch("scrollmodechanged", {
  12008. source: this,
  12009. mode
  12010. });
  12011. this._updateScrollMode(this._currentPageNumber);
  12012. }
  12013. _updateScrollMode(pageNumber = null) {
  12014. const scrollMode = this._scrollMode,
  12015. viewer = this.viewer;
  12016. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL);
  12017. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.WRAPPED);
  12018. if (!this.pdfDocument || !pageNumber) {
  12019. return;
  12020. }
  12021. if (scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  12022. this.#ensurePageViewVisible();
  12023. } else if (this._previousScrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  12024. this._updateSpreadMode();
  12025. }
  12026. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  12027. this.#setScale(this._currentScaleValue, {
  12028. noScroll: true
  12029. });
  12030. }
  12031. this._setCurrentPageNumber(pageNumber, true);
  12032. this.update();
  12033. }
  12034. get spreadMode() {
  12035. return this._spreadMode;
  12036. }
  12037. set spreadMode(mode) {
  12038. if (this._spreadMode === mode) {
  12039. return;
  12040. }
  12041. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidSpreadMode)(mode)) {
  12042. throw new Error(`Invalid spread mode: ${mode}`);
  12043. }
  12044. this._spreadMode = mode;
  12045. this.eventBus.dispatch("spreadmodechanged", {
  12046. source: this,
  12047. mode
  12048. });
  12049. this._updateSpreadMode(this._currentPageNumber);
  12050. }
  12051. _updateSpreadMode(pageNumber = null) {
  12052. if (!this.pdfDocument) {
  12053. return;
  12054. }
  12055. const viewer = this.viewer,
  12056. pages = this._pages;
  12057. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  12058. this.#ensurePageViewVisible();
  12059. } else {
  12060. viewer.textContent = "";
  12061. if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  12062. for (const pageView of this._pages) {
  12063. viewer.append(pageView.div);
  12064. }
  12065. } else {
  12066. const parity = this._spreadMode - 1;
  12067. let spread = null;
  12068. for (let i = 0, ii = pages.length; i < ii; ++i) {
  12069. if (spread === null) {
  12070. spread = document.createElement("div");
  12071. spread.className = "spread";
  12072. viewer.append(spread);
  12073. } else if (i % 2 === parity) {
  12074. spread = spread.cloneNode(false);
  12075. viewer.append(spread);
  12076. }
  12077. spread.append(pages[i].div);
  12078. }
  12079. }
  12080. }
  12081. if (!pageNumber) {
  12082. return;
  12083. }
  12084. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  12085. this.#setScale(this._currentScaleValue, {
  12086. noScroll: true
  12087. });
  12088. }
  12089. this._setCurrentPageNumber(pageNumber, true);
  12090. this.update();
  12091. }
  12092. _getPageAdvance(currentPageNumber, previous = false) {
  12093. switch (this._scrollMode) {
  12094. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.WRAPPED:
  12095. {
  12096. const {
  12097. views
  12098. } = this._getVisiblePages(),
  12099. pageLayout = new Map();
  12100. for (const {
  12101. id,
  12102. y,
  12103. percent,
  12104. widthPercent
  12105. } of views) {
  12106. if (percent === 0 || widthPercent < 100) {
  12107. continue;
  12108. }
  12109. let yArray = pageLayout.get(y);
  12110. if (!yArray) {
  12111. pageLayout.set(y, yArray ||= []);
  12112. }
  12113. yArray.push(id);
  12114. }
  12115. for (const yArray of pageLayout.values()) {
  12116. const currentIndex = yArray.indexOf(currentPageNumber);
  12117. if (currentIndex === -1) {
  12118. continue;
  12119. }
  12120. const numPages = yArray.length;
  12121. if (numPages === 1) {
  12122. break;
  12123. }
  12124. if (previous) {
  12125. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  12126. const currentId = yArray[i],
  12127. expectedId = yArray[i + 1] - 1;
  12128. if (currentId < expectedId) {
  12129. return currentPageNumber - expectedId;
  12130. }
  12131. }
  12132. } else {
  12133. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  12134. const currentId = yArray[i],
  12135. expectedId = yArray[i - 1] + 1;
  12136. if (currentId > expectedId) {
  12137. return expectedId - currentPageNumber;
  12138. }
  12139. }
  12140. }
  12141. if (previous) {
  12142. const firstId = yArray[0];
  12143. if (firstId < currentPageNumber) {
  12144. return currentPageNumber - firstId + 1;
  12145. }
  12146. } else {
  12147. const lastId = yArray[numPages - 1];
  12148. if (lastId > currentPageNumber) {
  12149. return lastId - currentPageNumber + 1;
  12150. }
  12151. }
  12152. break;
  12153. }
  12154. break;
  12155. }
  12156. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL:
  12157. {
  12158. break;
  12159. }
  12160. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE:
  12161. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL:
  12162. {
  12163. if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  12164. break;
  12165. }
  12166. const parity = this._spreadMode - 1;
  12167. if (previous && currentPageNumber % 2 !== parity) {
  12168. break;
  12169. } else if (!previous && currentPageNumber % 2 === parity) {
  12170. break;
  12171. }
  12172. const {
  12173. views
  12174. } = this._getVisiblePages(),
  12175. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  12176. for (const {
  12177. id,
  12178. percent,
  12179. widthPercent
  12180. } of views) {
  12181. if (id !== expectedId) {
  12182. continue;
  12183. }
  12184. if (percent > 0 && widthPercent === 100) {
  12185. return 2;
  12186. }
  12187. break;
  12188. }
  12189. break;
  12190. }
  12191. }
  12192. return 1;
  12193. }
  12194. nextPage() {
  12195. const currentPageNumber = this._currentPageNumber,
  12196. pagesCount = this.pagesCount;
  12197. if (currentPageNumber >= pagesCount) {
  12198. return false;
  12199. }
  12200. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  12201. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  12202. return true;
  12203. }
  12204. previousPage() {
  12205. const currentPageNumber = this._currentPageNumber;
  12206. if (currentPageNumber <= 1) {
  12207. return false;
  12208. }
  12209. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  12210. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  12211. return true;
  12212. }
  12213. increaseScale({
  12214. drawingDelay,
  12215. scaleFactor,
  12216. steps
  12217. } = {}) {
  12218. if (!this.pdfDocument) {
  12219. return;
  12220. }
  12221. let newScale = this._currentScale;
  12222. if (scaleFactor > 1) {
  12223. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12224. } else {
  12225. steps ??= 1;
  12226. do {
  12227. newScale = Math.ceil((newScale * _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12228. } while (--steps > 0 && newScale < _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE);
  12229. }
  12230. this.#setScale(Math.min(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE, newScale), {
  12231. noScroll: false,
  12232. drawingDelay
  12233. });
  12234. }
  12235. decreaseScale({
  12236. drawingDelay,
  12237. scaleFactor,
  12238. steps
  12239. } = {}) {
  12240. if (!this.pdfDocument) {
  12241. return;
  12242. }
  12243. let newScale = this._currentScale;
  12244. if (scaleFactor > 0 && scaleFactor < 1) {
  12245. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12246. } else {
  12247. steps ??= 1;
  12248. do {
  12249. newScale = Math.floor((newScale / _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12250. } while (--steps > 0 && newScale > _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE);
  12251. }
  12252. this.#setScale(Math.max(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE, newScale), {
  12253. noScroll: false,
  12254. drawingDelay
  12255. });
  12256. }
  12257. #updateContainerHeightCss(height = this.container.clientHeight) {
  12258. if (height !== this.#previousContainerHeight) {
  12259. this.#previousContainerHeight = height;
  12260. _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.docStyle.setProperty("--viewer-container-height", `${height}px`);
  12261. }
  12262. }
  12263. #resizeObserverCallback(entries) {
  12264. for (const entry of entries) {
  12265. if (entry.target === this.container) {
  12266. this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
  12267. this.#containerTopLeft = null;
  12268. break;
  12269. }
  12270. }
  12271. }
  12272. get containerTopLeft() {
  12273. return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
  12274. }
  12275. get annotationEditorMode() {
  12276. return this.#annotationEditorUIManager ? this.#annotationEditorMode : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  12277. }
  12278. set annotationEditorMode({
  12279. mode,
  12280. editId = null,
  12281. isFromKeyboard = false
  12282. }) {
  12283. if (!this.#annotationEditorUIManager) {
  12284. throw new Error(`The AnnotationEditor is not enabled.`);
  12285. }
  12286. if (this.#annotationEditorMode === mode) {
  12287. return;
  12288. }
  12289. if (!isValidAnnotationEditorMode(mode)) {
  12290. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  12291. }
  12292. if (!this.pdfDocument) {
  12293. return;
  12294. }
  12295. this.#annotationEditorMode = mode;
  12296. this.eventBus.dispatch("annotationeditormodechanged", {
  12297. source: this,
  12298. mode
  12299. });
  12300. this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
  12301. }
  12302. set annotationEditorParams({
  12303. type,
  12304. value
  12305. }) {
  12306. if (!this.#annotationEditorUIManager) {
  12307. throw new Error(`The AnnotationEditor is not enabled.`);
  12308. }
  12309. this.#annotationEditorUIManager.updateParams(type, value);
  12310. }
  12311. refresh(noUpdate = false, updateArgs = Object.create(null)) {
  12312. if (!this.pdfDocument) {
  12313. return;
  12314. }
  12315. for (const pageView of this._pages) {
  12316. pageView.update(updateArgs);
  12317. }
  12318. if (this.#scaleTimeoutId !== null) {
  12319. clearTimeout(this.#scaleTimeoutId);
  12320. this.#scaleTimeoutId = null;
  12321. }
  12322. if (!noUpdate) {
  12323. this.update();
  12324. }
  12325. }
  12326. }
  12327. __webpack_async_result__();
  12328. } catch(e) { __webpack_async_result__(e); } });
  12329. /***/ }),
  12330. /***/ 1869:
  12331. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  12332. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  12333. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12334. /* harmony export */ AbortException: () => (/* binding */ AbortException),
  12335. /* harmony export */ AnnotationEditorLayer: () => (/* binding */ AnnotationEditorLayer),
  12336. /* harmony export */ AnnotationEditorParamsType: () => (/* binding */ AnnotationEditorParamsType),
  12337. /* harmony export */ AnnotationEditorType: () => (/* binding */ AnnotationEditorType),
  12338. /* harmony export */ AnnotationEditorUIManager: () => (/* binding */ AnnotationEditorUIManager),
  12339. /* harmony export */ AnnotationLayer: () => (/* binding */ AnnotationLayer),
  12340. /* harmony export */ AnnotationMode: () => (/* binding */ AnnotationMode),
  12341. /* harmony export */ ColorPicker: () => (/* binding */ ColorPicker),
  12342. /* harmony export */ DOMSVGFactory: () => (/* binding */ DOMSVGFactory),
  12343. /* harmony export */ DrawLayer: () => (/* binding */ DrawLayer),
  12344. /* harmony export */ FeatureTest: () => (/* binding */ FeatureTest),
  12345. /* harmony export */ GlobalWorkerOptions: () => (/* binding */ GlobalWorkerOptions),
  12346. /* harmony export */ InvalidPDFException: () => (/* binding */ InvalidPDFException),
  12347. /* harmony export */ MissingPDFException: () => (/* binding */ MissingPDFException),
  12348. /* harmony export */ PDFDateString: () => (/* binding */ PDFDateString),
  12349. /* harmony export */ PDFWorker: () => (/* binding */ PDFWorker),
  12350. /* harmony export */ PasswordResponses: () => (/* binding */ PasswordResponses),
  12351. /* harmony export */ PermissionFlag: () => (/* binding */ PermissionFlag),
  12352. /* harmony export */ PixelsPerInch: () => (/* binding */ PixelsPerInch),
  12353. /* harmony export */ PromiseCapability: () => (/* binding */ PromiseCapability),
  12354. /* harmony export */ RenderingCancelledException: () => (/* binding */ RenderingCancelledException),
  12355. /* harmony export */ UnexpectedResponseException: () => (/* binding */ UnexpectedResponseException),
  12356. /* harmony export */ XfaLayer: () => (/* binding */ XfaLayer),
  12357. /* harmony export */ build: () => (/* binding */ build),
  12358. /* harmony export */ createValidAbsoluteUrl: () => (/* binding */ createValidAbsoluteUrl),
  12359. /* harmony export */ fetchData: () => (/* binding */ fetchData),
  12360. /* harmony export */ getDocument: () => (/* binding */ getDocument),
  12361. /* harmony export */ getFilenameFromUrl: () => (/* binding */ getFilenameFromUrl),
  12362. /* harmony export */ getPdfFilenameFromUrl: () => (/* binding */ getPdfFilenameFromUrl),
  12363. /* harmony export */ getXfaPageViewport: () => (/* binding */ getXfaPageViewport),
  12364. /* harmony export */ isDataScheme: () => (/* binding */ isDataScheme),
  12365. /* harmony export */ isPdfFile: () => (/* binding */ isPdfFile),
  12366. /* harmony export */ noContextMenu: () => (/* binding */ noContextMenu),
  12367. /* harmony export */ normalizeUnicode: () => (/* binding */ normalizeUnicode),
  12368. /* harmony export */ renderTextLayer: () => (/* binding */ renderTextLayer),
  12369. /* harmony export */ setLayerDimensions: () => (/* binding */ setLayerDimensions),
  12370. /* harmony export */ shadow: () => (/* binding */ shadow),
  12371. /* harmony export */ updateTextLayer: () => (/* binding */ updateTextLayer),
  12372. /* harmony export */ version: () => (/* binding */ version)
  12373. /* harmony export */ });
  12374. /* unused harmony exports CMapCompressionType, ImageKind, OPS, Outliner, PDFDataRangeTransport, Util, VerbosityLevel */
  12375. if (!globalThis.pdfjsLib) {
  12376. await globalThis.pdfjsLibPromise;
  12377. }
  12378. const {
  12379. AbortException,
  12380. AnnotationEditorLayer,
  12381. AnnotationEditorParamsType,
  12382. AnnotationEditorType,
  12383. AnnotationEditorUIManager,
  12384. AnnotationLayer,
  12385. AnnotationMode,
  12386. build,
  12387. CMapCompressionType,
  12388. ColorPicker,
  12389. createValidAbsoluteUrl,
  12390. DOMSVGFactory,
  12391. DrawLayer,
  12392. FeatureTest,
  12393. fetchData,
  12394. getDocument,
  12395. getFilenameFromUrl,
  12396. getPdfFilenameFromUrl,
  12397. getXfaPageViewport,
  12398. GlobalWorkerOptions,
  12399. ImageKind,
  12400. InvalidPDFException,
  12401. isDataScheme,
  12402. isPdfFile,
  12403. MissingPDFException,
  12404. noContextMenu,
  12405. normalizeUnicode,
  12406. OPS,
  12407. Outliner,
  12408. PasswordResponses,
  12409. PDFDataRangeTransport,
  12410. PDFDateString,
  12411. PDFWorker,
  12412. PermissionFlag,
  12413. PixelsPerInch,
  12414. PromiseCapability,
  12415. RenderingCancelledException,
  12416. renderTextLayer,
  12417. setLayerDimensions,
  12418. shadow,
  12419. UnexpectedResponseException,
  12420. updateTextLayer,
  12421. Util,
  12422. VerbosityLevel,
  12423. version,
  12424. XfaLayer
  12425. } = globalThis.pdfjsLib;
  12426. __webpack_async_result__();
  12427. } catch(e) { __webpack_async_result__(e); } }, 1);
  12428. /***/ }),
  12429. /***/ 216:
  12430. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  12431. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12432. /* harmony export */ BasePreferences: () => (/* binding */ BasePreferences)
  12433. /* harmony export */ });
  12434. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8961);
  12435. class BasePreferences {
  12436. #defaults = Object.freeze({
  12437. "annotationEditorMode": 0,
  12438. "annotationMode": 2,
  12439. "cursorToolOnLoad": 0,
  12440. "defaultZoomDelay": 400,
  12441. "defaultZoomValue": "",
  12442. "disablePageLabels": false,
  12443. "enableHighlightEditor": false,
  12444. "enablePermissions": false,
  12445. "enablePrintAutoRotate": true,
  12446. "enableScripting": true,
  12447. "externalLinkTarget": 0,
  12448. "highlightEditorColors": "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
  12449. "historyUpdateUrl": false,
  12450. "ignoreDestinationZoom": false,
  12451. "forcePageColors": false,
  12452. "pageColorsBackground": "Canvas",
  12453. "pageColorsForeground": "CanvasText",
  12454. "pdfBugEnabled": false,
  12455. "sidebarViewOnLoad": -1,
  12456. "scrollModeOnLoad": -1,
  12457. "spreadModeOnLoad": -1,
  12458. "textLayerMode": 1,
  12459. "viewOnLoad": 0,
  12460. "disableAutoFetch": false,
  12461. "disableFontFace": false,
  12462. "disableRange": false,
  12463. "disableStream": false,
  12464. "enableXfa": true,
  12465. "viewerCssTheme": 0
  12466. });
  12467. #prefs = Object.create(null);
  12468. #initializedPromise = null;
  12469. constructor() {
  12470. if (this.constructor === BasePreferences) {
  12471. throw new Error("Cannot initialize BasePreferences.");
  12472. }
  12473. this.#initializedPromise = this._readFromStorage(this.#defaults).then(({
  12474. browserPrefs,
  12475. prefs
  12476. }) => {
  12477. const BROWSER_PREFS = {
  12478. "canvasMaxAreaInBytes": -1,
  12479. "isInAutomation": false,
  12480. "supportsDocumentFonts": true,
  12481. "supportsIntegratedFind": false,
  12482. "supportsMouseWheelZoomCtrlKey": true,
  12483. "supportsMouseWheelZoomMetaKey": true,
  12484. "supportsPinchToZoom": true
  12485. };
  12486. const options = Object.create(null);
  12487. for (const [name, defaultVal] of Object.entries(BROWSER_PREFS)) {
  12488. const prefVal = browserPrefs?.[name];
  12489. options[name] = typeof prefVal === typeof defaultVal ? prefVal : defaultVal;
  12490. }
  12491. for (const [name, defaultVal] of Object.entries(this.#defaults)) {
  12492. const prefVal = prefs?.[name];
  12493. options[name] = this.#prefs[name] = typeof prefVal === typeof defaultVal ? prefVal : defaultVal;
  12494. }
  12495. _app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.setAll(options, true);
  12496. });
  12497. }
  12498. async _writeToStorage(prefObj) {
  12499. throw new Error("Not implemented: _writeToStorage");
  12500. }
  12501. async _readFromStorage(prefObj) {
  12502. throw new Error("Not implemented: _readFromStorage");
  12503. }
  12504. async reset() {
  12505. await this.#initializedPromise;
  12506. const prefs = this.#prefs;
  12507. this.#prefs = Object.create(null);
  12508. return this._writeToStorage(this.#defaults).catch(reason => {
  12509. this.#prefs = prefs;
  12510. throw reason;
  12511. });
  12512. }
  12513. async set(name, value) {
  12514. await this.#initializedPromise;
  12515. const defaultValue = this.#defaults[name],
  12516. prefs = this.#prefs;
  12517. if (defaultValue === undefined) {
  12518. throw new Error(`Set preference: "${name}" is undefined.`);
  12519. } else if (value === undefined) {
  12520. throw new Error("Set preference: no value is specified.");
  12521. }
  12522. const valueType = typeof value,
  12523. defaultType = typeof defaultValue;
  12524. if (valueType !== defaultType) {
  12525. if (valueType === "number" && defaultType === "string") {
  12526. value = value.toString();
  12527. } else {
  12528. throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
  12529. }
  12530. } else if (valueType === "number" && !Number.isInteger(value)) {
  12531. throw new Error(`Set preference: "${value}" must be an integer.`);
  12532. }
  12533. this.#prefs[name] = value;
  12534. return this._writeToStorage(this.#prefs).catch(reason => {
  12535. this.#prefs = prefs;
  12536. throw reason;
  12537. });
  12538. }
  12539. async get(name) {
  12540. await this.#initializedPromise;
  12541. const defaultValue = this.#defaults[name];
  12542. if (defaultValue === undefined) {
  12543. throw new Error(`Get preference: "${name}" is undefined.`);
  12544. }
  12545. return this.#prefs[name] ?? defaultValue;
  12546. }
  12547. get initializedPromise() {
  12548. return this.#initializedPromise;
  12549. }
  12550. }
  12551. /***/ }),
  12552. /***/ 4552:
  12553. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  12554. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  12555. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12556. /* harmony export */ getXfaHtmlForPrinting: () => (/* binding */ getXfaHtmlForPrinting)
  12557. /* harmony export */ });
  12558. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  12559. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3234);
  12560. /* harmony import */ var _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8012);
  12561. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__]);
  12562. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  12563. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  12564. const xfaHtml = pdfDocument.allXfaHtml;
  12565. const linkService = new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_1__.SimpleLinkService();
  12566. const scale = Math.round(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  12567. for (const xfaPage of xfaHtml.children) {
  12568. const page = document.createElement("div");
  12569. page.className = "xfaPrintedPage";
  12570. printContainer.append(page);
  12571. const builder = new _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__.XfaLayerBuilder({
  12572. pdfPage: null,
  12573. annotationStorage: pdfDocument.annotationStorage,
  12574. linkService,
  12575. xfaHtml: xfaPage
  12576. });
  12577. const viewport = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.getXfaPageViewport)(xfaPage, {
  12578. scale
  12579. });
  12580. builder.render(viewport, "print");
  12581. page.append(builder.div);
  12582. }
  12583. }
  12584. __webpack_async_result__();
  12585. } catch(e) { __webpack_async_result__(e); } });
  12586. /***/ }),
  12587. /***/ 1544:
  12588. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  12589. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  12590. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12591. /* harmony export */ SecondaryToolbar: () => (/* binding */ SecondaryToolbar)
  12592. /* harmony export */ });
  12593. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  12594. /* harmony import */ var _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9290);
  12595. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__]);
  12596. _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  12597. class SecondaryToolbar {
  12598. #opts;
  12599. constructor(options, eventBus) {
  12600. this.#opts = options;
  12601. const buttons = [{
  12602. element: options.presentationModeButton,
  12603. eventName: "presentationmode",
  12604. close: true
  12605. }, {
  12606. element: options.printButton,
  12607. eventName: "print",
  12608. close: true
  12609. }, {
  12610. element: options.downloadButton,
  12611. eventName: "download",
  12612. close: true
  12613. }, {
  12614. element: options.viewBookmarkButton,
  12615. eventName: null,
  12616. close: true
  12617. }, {
  12618. element: options.firstPageButton,
  12619. eventName: "firstpage",
  12620. close: true
  12621. }, {
  12622. element: options.lastPageButton,
  12623. eventName: "lastpage",
  12624. close: true
  12625. }, {
  12626. element: options.pageRotateCwButton,
  12627. eventName: "rotatecw",
  12628. close: false
  12629. }, {
  12630. element: options.pageRotateCcwButton,
  12631. eventName: "rotateccw",
  12632. close: false
  12633. }, {
  12634. element: options.cursorSelectToolButton,
  12635. eventName: "switchcursortool",
  12636. eventDetails: {
  12637. tool: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT
  12638. },
  12639. close: true
  12640. }, {
  12641. element: options.cursorHandToolButton,
  12642. eventName: "switchcursortool",
  12643. eventDetails: {
  12644. tool: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND
  12645. },
  12646. close: true
  12647. }, {
  12648. element: options.scrollPageButton,
  12649. eventName: "switchscrollmode",
  12650. eventDetails: {
  12651. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE
  12652. },
  12653. close: true
  12654. }, {
  12655. element: options.scrollVerticalButton,
  12656. eventName: "switchscrollmode",
  12657. eventDetails: {
  12658. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL
  12659. },
  12660. close: true
  12661. }, {
  12662. element: options.scrollHorizontalButton,
  12663. eventName: "switchscrollmode",
  12664. eventDetails: {
  12665. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL
  12666. },
  12667. close: true
  12668. }, {
  12669. element: options.scrollWrappedButton,
  12670. eventName: "switchscrollmode",
  12671. eventDetails: {
  12672. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.WRAPPED
  12673. },
  12674. close: true
  12675. }, {
  12676. element: options.spreadNoneButton,
  12677. eventName: "switchspreadmode",
  12678. eventDetails: {
  12679. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE
  12680. },
  12681. close: true
  12682. }, {
  12683. element: options.spreadOddButton,
  12684. eventName: "switchspreadmode",
  12685. eventDetails: {
  12686. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.ODD
  12687. },
  12688. close: true
  12689. }, {
  12690. element: options.spreadEvenButton,
  12691. eventName: "switchspreadmode",
  12692. eventDetails: {
  12693. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.EVEN
  12694. },
  12695. close: true
  12696. }, {
  12697. element: options.documentPropertiesButton,
  12698. eventName: "documentproperties",
  12699. close: true
  12700. }];
  12701. buttons.push({
  12702. element: options.openFileButton,
  12703. eventName: "openfile",
  12704. close: true
  12705. });
  12706. this.eventBus = eventBus;
  12707. this.opened = false;
  12708. this.#bindListeners(buttons);
  12709. this.reset();
  12710. }
  12711. get isOpen() {
  12712. return this.opened;
  12713. }
  12714. setPageNumber(pageNumber) {
  12715. this.pageNumber = pageNumber;
  12716. this.#updateUIState();
  12717. }
  12718. setPagesCount(pagesCount) {
  12719. this.pagesCount = pagesCount;
  12720. this.#updateUIState();
  12721. }
  12722. reset() {
  12723. this.pageNumber = 0;
  12724. this.pagesCount = 0;
  12725. this.#updateUIState();
  12726. this.#scrollModeChanged({
  12727. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL
  12728. });
  12729. this.#spreadModeChanged({
  12730. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE
  12731. });
  12732. }
  12733. #updateUIState() {
  12734. const {
  12735. firstPageButton,
  12736. lastPageButton,
  12737. pageRotateCwButton,
  12738. pageRotateCcwButton
  12739. } = this.#opts;
  12740. firstPageButton.disabled = this.pageNumber <= 1;
  12741. lastPageButton.disabled = this.pageNumber >= this.pagesCount;
  12742. pageRotateCwButton.disabled = this.pagesCount === 0;
  12743. pageRotateCcwButton.disabled = this.pagesCount === 0;
  12744. }
  12745. #bindListeners(buttons) {
  12746. const {
  12747. eventBus
  12748. } = this;
  12749. const {
  12750. toggleButton
  12751. } = this.#opts;
  12752. toggleButton.addEventListener("click", this.toggle.bind(this));
  12753. for (const {
  12754. element,
  12755. eventName,
  12756. close,
  12757. eventDetails
  12758. } of buttons) {
  12759. element.addEventListener("click", evt => {
  12760. if (eventName !== null) {
  12761. eventBus.dispatch(eventName, {
  12762. source: this,
  12763. ...eventDetails
  12764. });
  12765. }
  12766. if (close) {
  12767. this.close();
  12768. }
  12769. eventBus.dispatch("reporttelemetry", {
  12770. source: this,
  12771. details: {
  12772. type: "buttons",
  12773. data: {
  12774. id: element.id
  12775. }
  12776. }
  12777. });
  12778. });
  12779. }
  12780. eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this));
  12781. eventBus._on("scrollmodechanged", this.#scrollModeChanged.bind(this));
  12782. eventBus._on("spreadmodechanged", this.#spreadModeChanged.bind(this));
  12783. }
  12784. #cursorToolChanged({
  12785. tool
  12786. }) {
  12787. const {
  12788. cursorSelectToolButton,
  12789. cursorHandToolButton
  12790. } = this.#opts;
  12791. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(cursorSelectToolButton, tool === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT);
  12792. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(cursorHandToolButton, tool === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND);
  12793. }
  12794. #scrollModeChanged({
  12795. mode
  12796. }) {
  12797. const {
  12798. scrollPageButton,
  12799. scrollVerticalButton,
  12800. scrollHorizontalButton,
  12801. scrollWrappedButton,
  12802. spreadNoneButton,
  12803. spreadOddButton,
  12804. spreadEvenButton
  12805. } = this.#opts;
  12806. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollPageButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE);
  12807. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollVerticalButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL);
  12808. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollHorizontalButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL);
  12809. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollWrappedButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.WRAPPED);
  12810. const forceScrollModePage = this.pagesCount > _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  12811. scrollPageButton.disabled = forceScrollModePage;
  12812. scrollVerticalButton.disabled = forceScrollModePage;
  12813. scrollHorizontalButton.disabled = forceScrollModePage;
  12814. scrollWrappedButton.disabled = forceScrollModePage;
  12815. const isHorizontal = mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL;
  12816. spreadNoneButton.disabled = isHorizontal;
  12817. spreadOddButton.disabled = isHorizontal;
  12818. spreadEvenButton.disabled = isHorizontal;
  12819. }
  12820. #spreadModeChanged({
  12821. mode
  12822. }) {
  12823. const {
  12824. spreadNoneButton,
  12825. spreadOddButton,
  12826. spreadEvenButton
  12827. } = this.#opts;
  12828. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadNoneButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE);
  12829. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadOddButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.ODD);
  12830. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadEvenButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.EVEN);
  12831. }
  12832. open() {
  12833. if (this.opened) {
  12834. return;
  12835. }
  12836. this.opened = true;
  12837. const {
  12838. toggleButton,
  12839. toolbar
  12840. } = this.#opts;
  12841. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(toggleButton, true, toolbar);
  12842. }
  12843. close() {
  12844. if (!this.opened) {
  12845. return;
  12846. }
  12847. this.opened = false;
  12848. const {
  12849. toggleButton,
  12850. toolbar
  12851. } = this.#opts;
  12852. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(toggleButton, false, toolbar);
  12853. }
  12854. toggle() {
  12855. if (this.opened) {
  12856. this.close();
  12857. } else {
  12858. this.open();
  12859. }
  12860. }
  12861. }
  12862. __webpack_async_result__();
  12863. } catch(e) { __webpack_async_result__(e); } });
  12864. /***/ }),
  12865. /***/ 7498:
  12866. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  12867. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12868. /* harmony export */ StructTreeLayerBuilder: () => (/* binding */ StructTreeLayerBuilder)
  12869. /* harmony export */ });
  12870. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  12871. const PDF_ROLE_TO_HTML_ROLE = {
  12872. Document: null,
  12873. DocumentFragment: null,
  12874. Part: "group",
  12875. Sect: "group",
  12876. Div: "group",
  12877. Aside: "note",
  12878. NonStruct: "none",
  12879. P: null,
  12880. H: "heading",
  12881. Title: null,
  12882. FENote: "note",
  12883. Sub: "group",
  12884. Lbl: null,
  12885. Span: null,
  12886. Em: null,
  12887. Strong: null,
  12888. Link: "link",
  12889. Annot: "note",
  12890. Form: "form",
  12891. Ruby: null,
  12892. RB: null,
  12893. RT: null,
  12894. RP: null,
  12895. Warichu: null,
  12896. WT: null,
  12897. WP: null,
  12898. L: "list",
  12899. LI: "listitem",
  12900. LBody: null,
  12901. Table: "table",
  12902. TR: "row",
  12903. TH: "columnheader",
  12904. TD: "cell",
  12905. THead: "columnheader",
  12906. TBody: null,
  12907. TFoot: null,
  12908. Caption: null,
  12909. Figure: "figure",
  12910. Formula: null,
  12911. Artifact: null
  12912. };
  12913. const HEADING_PATTERN = /^H(\d+)$/;
  12914. class StructTreeLayerBuilder {
  12915. #treeDom = undefined;
  12916. get renderingDone() {
  12917. return this.#treeDom !== undefined;
  12918. }
  12919. render(structTree) {
  12920. if (this.#treeDom !== undefined) {
  12921. return this.#treeDom;
  12922. }
  12923. const treeDom = this.#walk(structTree);
  12924. treeDom?.classList.add("structTree");
  12925. return this.#treeDom = treeDom;
  12926. }
  12927. hide() {
  12928. if (this.#treeDom && !this.#treeDom.hidden) {
  12929. this.#treeDom.hidden = true;
  12930. }
  12931. }
  12932. show() {
  12933. if (this.#treeDom?.hidden) {
  12934. this.#treeDom.hidden = false;
  12935. }
  12936. }
  12937. #setAttributes(structElement, htmlElement) {
  12938. const {
  12939. alt,
  12940. id,
  12941. lang
  12942. } = structElement;
  12943. if (alt !== undefined) {
  12944. htmlElement.setAttribute("aria-label", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(alt));
  12945. }
  12946. if (id !== undefined) {
  12947. htmlElement.setAttribute("aria-owns", id);
  12948. }
  12949. if (lang !== undefined) {
  12950. htmlElement.setAttribute("lang", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(lang, true));
  12951. }
  12952. }
  12953. #walk(node) {
  12954. if (!node) {
  12955. return null;
  12956. }
  12957. const element = document.createElement("span");
  12958. if ("role" in node) {
  12959. const {
  12960. role
  12961. } = node;
  12962. const match = role.match(HEADING_PATTERN);
  12963. if (match) {
  12964. element.setAttribute("role", "heading");
  12965. element.setAttribute("aria-level", match[1]);
  12966. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  12967. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  12968. }
  12969. }
  12970. this.#setAttributes(node, element);
  12971. if (node.children) {
  12972. if (node.children.length === 1 && "id" in node.children[0]) {
  12973. this.#setAttributes(node.children[0], element);
  12974. } else {
  12975. for (const kid of node.children) {
  12976. element.append(this.#walk(kid));
  12977. }
  12978. }
  12979. }
  12980. return element;
  12981. }
  12982. }
  12983. /***/ }),
  12984. /***/ 4630:
  12985. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  12986. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12987. /* harmony export */ TextAccessibilityManager: () => (/* binding */ TextAccessibilityManager)
  12988. /* harmony export */ });
  12989. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4927);
  12990. class TextAccessibilityManager {
  12991. #enabled = false;
  12992. #textChildren = null;
  12993. #textNodes = new Map();
  12994. #waitingElements = new Map();
  12995. setTextMapping(textDivs) {
  12996. this.#textChildren = textDivs;
  12997. }
  12998. static #compareElementPositions(e1, e2) {
  12999. const rect1 = e1.getBoundingClientRect();
  13000. const rect2 = e2.getBoundingClientRect();
  13001. if (rect1.width === 0 && rect1.height === 0) {
  13002. return +1;
  13003. }
  13004. if (rect2.width === 0 && rect2.height === 0) {
  13005. return -1;
  13006. }
  13007. const top1 = rect1.y;
  13008. const bot1 = rect1.y + rect1.height;
  13009. const mid1 = rect1.y + rect1.height / 2;
  13010. const top2 = rect2.y;
  13011. const bot2 = rect2.y + rect2.height;
  13012. const mid2 = rect2.y + rect2.height / 2;
  13013. if (mid1 <= top2 && mid2 >= bot1) {
  13014. return -1;
  13015. }
  13016. if (mid2 <= top1 && mid1 >= bot2) {
  13017. return +1;
  13018. }
  13019. const centerX1 = rect1.x + rect1.width / 2;
  13020. const centerX2 = rect2.x + rect2.width / 2;
  13021. return centerX1 - centerX2;
  13022. }
  13023. enable() {
  13024. if (this.#enabled) {
  13025. throw new Error("TextAccessibilityManager is already enabled.");
  13026. }
  13027. if (!this.#textChildren) {
  13028. throw new Error("Text divs and strings have not been set.");
  13029. }
  13030. this.#enabled = true;
  13031. this.#textChildren = this.#textChildren.slice();
  13032. this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
  13033. if (this.#textNodes.size > 0) {
  13034. const textChildren = this.#textChildren;
  13035. for (const [id, nodeIndex] of this.#textNodes) {
  13036. const element = document.getElementById(id);
  13037. if (!element) {
  13038. this.#textNodes.delete(id);
  13039. continue;
  13040. }
  13041. this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
  13042. }
  13043. }
  13044. for (const [element, isRemovable] of this.#waitingElements) {
  13045. this.addPointerInTextLayer(element, isRemovable);
  13046. }
  13047. this.#waitingElements.clear();
  13048. }
  13049. disable() {
  13050. if (!this.#enabled) {
  13051. return;
  13052. }
  13053. this.#waitingElements.clear();
  13054. this.#textChildren = null;
  13055. this.#enabled = false;
  13056. }
  13057. removePointerInTextLayer(element) {
  13058. if (!this.#enabled) {
  13059. this.#waitingElements.delete(element);
  13060. return;
  13061. }
  13062. const children = this.#textChildren;
  13063. if (!children || children.length === 0) {
  13064. return;
  13065. }
  13066. const {
  13067. id
  13068. } = element;
  13069. const nodeIndex = this.#textNodes.get(id);
  13070. if (nodeIndex === undefined) {
  13071. return;
  13072. }
  13073. const node = children[nodeIndex];
  13074. this.#textNodes.delete(id);
  13075. let owns = node.getAttribute("aria-owns");
  13076. if (owns?.includes(id)) {
  13077. owns = owns.split(" ").filter(x => x !== id).join(" ");
  13078. if (owns) {
  13079. node.setAttribute("aria-owns", owns);
  13080. } else {
  13081. node.removeAttribute("aria-owns");
  13082. node.setAttribute("role", "presentation");
  13083. }
  13084. }
  13085. }
  13086. #addIdToAriaOwns(id, node) {
  13087. const owns = node.getAttribute("aria-owns");
  13088. if (!owns?.includes(id)) {
  13089. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  13090. }
  13091. node.removeAttribute("role");
  13092. }
  13093. addPointerInTextLayer(element, isRemovable) {
  13094. const {
  13095. id
  13096. } = element;
  13097. if (!id) {
  13098. return null;
  13099. }
  13100. if (!this.#enabled) {
  13101. this.#waitingElements.set(element, isRemovable);
  13102. return null;
  13103. }
  13104. if (isRemovable) {
  13105. this.removePointerInTextLayer(element);
  13106. }
  13107. const children = this.#textChildren;
  13108. if (!children || children.length === 0) {
  13109. return null;
  13110. }
  13111. const index = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
  13112. const nodeIndex = Math.max(0, index - 1);
  13113. const child = children[nodeIndex];
  13114. this.#addIdToAriaOwns(id, child);
  13115. this.#textNodes.set(id, nodeIndex);
  13116. const parent = child.parentNode;
  13117. return parent?.classList.contains("markedContent") ? parent.id : null;
  13118. }
  13119. moveElementInDOM(container, element, contentElement, isRemovable) {
  13120. const id = this.addPointerInTextLayer(contentElement, isRemovable);
  13121. if (!container.hasChildNodes()) {
  13122. container.append(element);
  13123. return id;
  13124. }
  13125. const children = Array.from(container.childNodes).filter(node => node !== element);
  13126. if (children.length === 0) {
  13127. return id;
  13128. }
  13129. const elementToCompare = contentElement || element;
  13130. const index = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
  13131. if (index === 0) {
  13132. children[0].before(element);
  13133. } else {
  13134. children[index - 1].after(element);
  13135. }
  13136. return id;
  13137. }
  13138. }
  13139. /***/ }),
  13140. /***/ 4274:
  13141. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  13142. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13143. /* harmony export */ TextHighlighter: () => (/* binding */ TextHighlighter)
  13144. /* harmony export */ });
  13145. class TextHighlighter {
  13146. constructor({
  13147. findController,
  13148. eventBus,
  13149. pageIndex
  13150. }) {
  13151. this.findController = findController;
  13152. this.matches = [];
  13153. this.eventBus = eventBus;
  13154. this.pageIdx = pageIndex;
  13155. this._onUpdateTextLayerMatches = null;
  13156. this.textDivs = null;
  13157. this.textContentItemsStr = null;
  13158. this.enabled = false;
  13159. }
  13160. setTextMapping(divs, texts) {
  13161. this.textDivs = divs;
  13162. this.textContentItemsStr = texts;
  13163. }
  13164. enable() {
  13165. if (!this.textDivs || !this.textContentItemsStr) {
  13166. throw new Error("Text divs and strings have not been set.");
  13167. }
  13168. if (this.enabled) {
  13169. throw new Error("TextHighlighter is already enabled.");
  13170. }
  13171. this.enabled = true;
  13172. if (!this._onUpdateTextLayerMatches) {
  13173. this._onUpdateTextLayerMatches = evt => {
  13174. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  13175. this._updateMatches();
  13176. }
  13177. };
  13178. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13179. }
  13180. this._updateMatches();
  13181. }
  13182. disable() {
  13183. if (!this.enabled) {
  13184. return;
  13185. }
  13186. this.enabled = false;
  13187. if (this._onUpdateTextLayerMatches) {
  13188. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13189. this._onUpdateTextLayerMatches = null;
  13190. }
  13191. this._updateMatches(true);
  13192. }
  13193. _convertMatches(matches, matchesLength) {
  13194. if (!matches) {
  13195. return [];
  13196. }
  13197. const {
  13198. textContentItemsStr
  13199. } = this;
  13200. let i = 0,
  13201. iIndex = 0;
  13202. const end = textContentItemsStr.length - 1;
  13203. const result = [];
  13204. for (let m = 0, mm = matches.length; m < mm; m++) {
  13205. let matchIdx = matches[m];
  13206. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  13207. iIndex += textContentItemsStr[i].length;
  13208. i++;
  13209. }
  13210. if (i === textContentItemsStr.length) {
  13211. console.error("Could not find a matching mapping");
  13212. }
  13213. const match = {
  13214. begin: {
  13215. divIdx: i,
  13216. offset: matchIdx - iIndex
  13217. }
  13218. };
  13219. matchIdx += matchesLength[m];
  13220. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  13221. iIndex += textContentItemsStr[i].length;
  13222. i++;
  13223. }
  13224. match.end = {
  13225. divIdx: i,
  13226. offset: matchIdx - iIndex
  13227. };
  13228. result.push(match);
  13229. }
  13230. return result;
  13231. }
  13232. _renderMatches(matches) {
  13233. if (matches.length === 0) {
  13234. return;
  13235. }
  13236. const {
  13237. findController,
  13238. pageIdx
  13239. } = this;
  13240. const {
  13241. textContentItemsStr,
  13242. textDivs
  13243. } = this;
  13244. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  13245. const selectedMatchIdx = findController.selected.matchIdx;
  13246. const highlightAll = findController.state.highlightAll;
  13247. let prevEnd = null;
  13248. const infinity = {
  13249. divIdx: -1,
  13250. offset: undefined
  13251. };
  13252. function beginText(begin, className) {
  13253. const divIdx = begin.divIdx;
  13254. textDivs[divIdx].textContent = "";
  13255. return appendTextToDiv(divIdx, 0, begin.offset, className);
  13256. }
  13257. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  13258. let div = textDivs[divIdx];
  13259. if (div.nodeType === Node.TEXT_NODE) {
  13260. const span = document.createElement("span");
  13261. div.before(span);
  13262. span.append(div);
  13263. textDivs[divIdx] = span;
  13264. div = span;
  13265. }
  13266. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  13267. const node = document.createTextNode(content);
  13268. if (className) {
  13269. const span = document.createElement("span");
  13270. span.className = `${className} appended`;
  13271. span.append(node);
  13272. div.append(span);
  13273. return className.includes("selected") ? span.offsetLeft : 0;
  13274. }
  13275. div.append(node);
  13276. return 0;
  13277. }
  13278. let i0 = selectedMatchIdx,
  13279. i1 = i0 + 1;
  13280. if (highlightAll) {
  13281. i0 = 0;
  13282. i1 = matches.length;
  13283. } else if (!isSelectedPage) {
  13284. return;
  13285. }
  13286. let lastDivIdx = -1;
  13287. let lastOffset = -1;
  13288. for (let i = i0; i < i1; i++) {
  13289. const match = matches[i];
  13290. const begin = match.begin;
  13291. if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
  13292. continue;
  13293. }
  13294. lastDivIdx = begin.divIdx;
  13295. lastOffset = begin.offset;
  13296. const end = match.end;
  13297. const isSelected = isSelectedPage && i === selectedMatchIdx;
  13298. const highlightSuffix = isSelected ? " selected" : "";
  13299. let selectedLeft = 0;
  13300. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  13301. if (prevEnd !== null) {
  13302. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13303. }
  13304. beginText(begin);
  13305. } else {
  13306. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  13307. }
  13308. if (begin.divIdx === end.divIdx) {
  13309. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  13310. } else {
  13311. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  13312. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  13313. textDivs[n0].className = "highlight middle" + highlightSuffix;
  13314. }
  13315. beginText(end, "highlight end" + highlightSuffix);
  13316. }
  13317. prevEnd = end;
  13318. if (isSelected) {
  13319. findController.scrollMatchIntoView({
  13320. element: textDivs[begin.divIdx],
  13321. selectedLeft,
  13322. pageIndex: pageIdx,
  13323. matchIndex: selectedMatchIdx
  13324. });
  13325. }
  13326. }
  13327. if (prevEnd) {
  13328. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13329. }
  13330. }
  13331. _updateMatches(reset = false) {
  13332. if (!this.enabled && !reset) {
  13333. return;
  13334. }
  13335. const {
  13336. findController,
  13337. matches,
  13338. pageIdx
  13339. } = this;
  13340. const {
  13341. textContentItemsStr,
  13342. textDivs
  13343. } = this;
  13344. let clearedUntilDivIdx = -1;
  13345. for (const match of matches) {
  13346. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13347. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  13348. const div = textDivs[n];
  13349. div.textContent = textContentItemsStr[n];
  13350. div.className = "";
  13351. }
  13352. clearedUntilDivIdx = match.end.divIdx + 1;
  13353. }
  13354. if (!findController?.highlightMatches || reset) {
  13355. return;
  13356. }
  13357. const pageMatches = findController.pageMatches[pageIdx] || null;
  13358. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13359. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13360. this._renderMatches(this.matches);
  13361. }
  13362. }
  13363. /***/ }),
  13364. /***/ 1013:
  13365. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  13366. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  13367. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13368. /* harmony export */ TextLayerBuilder: () => (/* binding */ TextLayerBuilder)
  13369. /* harmony export */ });
  13370. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  13371. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  13372. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  13373. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  13374. class TextLayerBuilder {
  13375. #enablePermissions = false;
  13376. #rotation = 0;
  13377. #scale = 0;
  13378. #textContentSource = null;
  13379. constructor({
  13380. highlighter = null,
  13381. accessibilityManager = null,
  13382. isOffscreenCanvasSupported = true,
  13383. enablePermissions = false
  13384. }) {
  13385. this.textContentItemsStr = [];
  13386. this.renderingDone = false;
  13387. this.textDivs = [];
  13388. this.textDivProperties = new WeakMap();
  13389. this.textLayerRenderTask = null;
  13390. this.highlighter = highlighter;
  13391. this.accessibilityManager = accessibilityManager;
  13392. this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  13393. this.#enablePermissions = enablePermissions === true;
  13394. this.onAppend = null;
  13395. this.div = document.createElement("div");
  13396. this.div.className = "textLayer";
  13397. }
  13398. #finishRendering() {
  13399. this.renderingDone = true;
  13400. const endOfContent = document.createElement("div");
  13401. endOfContent.className = "endOfContent";
  13402. this.div.append(endOfContent);
  13403. this.#bindMouse();
  13404. }
  13405. get numTextDivs() {
  13406. return this.textDivs.length;
  13407. }
  13408. async render(viewport) {
  13409. if (!this.#textContentSource) {
  13410. throw new Error('No "textContentSource" parameter specified.');
  13411. }
  13412. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  13413. const {
  13414. rotation
  13415. } = viewport;
  13416. if (this.renderingDone) {
  13417. const mustRotate = rotation !== this.#rotation;
  13418. const mustRescale = scale !== this.#scale;
  13419. if (mustRotate || mustRescale) {
  13420. this.hide();
  13421. (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.updateTextLayer)({
  13422. container: this.div,
  13423. viewport,
  13424. textDivs: this.textDivs,
  13425. textDivProperties: this.textDivProperties,
  13426. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  13427. mustRescale,
  13428. mustRotate
  13429. });
  13430. this.#scale = scale;
  13431. this.#rotation = rotation;
  13432. }
  13433. this.show();
  13434. return;
  13435. }
  13436. this.cancel();
  13437. this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
  13438. this.accessibilityManager?.setTextMapping(this.textDivs);
  13439. this.textLayerRenderTask = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.renderTextLayer)({
  13440. textContentSource: this.#textContentSource,
  13441. container: this.div,
  13442. viewport,
  13443. textDivs: this.textDivs,
  13444. textDivProperties: this.textDivProperties,
  13445. textContentItemsStr: this.textContentItemsStr,
  13446. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported
  13447. });
  13448. await this.textLayerRenderTask.promise;
  13449. this.#finishRendering();
  13450. this.#scale = scale;
  13451. this.#rotation = rotation;
  13452. this.onAppend(this.div);
  13453. this.highlighter?.enable();
  13454. this.accessibilityManager?.enable();
  13455. }
  13456. hide() {
  13457. if (!this.div.hidden && this.renderingDone) {
  13458. this.highlighter?.disable();
  13459. this.div.hidden = true;
  13460. }
  13461. }
  13462. show() {
  13463. if (this.div.hidden && this.renderingDone) {
  13464. this.div.hidden = false;
  13465. this.highlighter?.enable();
  13466. }
  13467. }
  13468. cancel() {
  13469. if (this.textLayerRenderTask) {
  13470. this.textLayerRenderTask.cancel();
  13471. this.textLayerRenderTask = null;
  13472. }
  13473. this.highlighter?.disable();
  13474. this.accessibilityManager?.disable();
  13475. this.textContentItemsStr.length = 0;
  13476. this.textDivs.length = 0;
  13477. this.textDivProperties = new WeakMap();
  13478. }
  13479. setTextContentSource(source) {
  13480. this.cancel();
  13481. this.#textContentSource = source;
  13482. }
  13483. #bindMouse() {
  13484. const {
  13485. div
  13486. } = this;
  13487. div.addEventListener("mousedown", evt => {
  13488. const end = div.querySelector(".endOfContent");
  13489. if (!end) {
  13490. return;
  13491. }
  13492. let adjustTop = evt.target !== div;
  13493. adjustTop &&= getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  13494. if (adjustTop) {
  13495. const divBounds = div.getBoundingClientRect();
  13496. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  13497. end.style.top = (r * 100).toFixed(2) + "%";
  13498. }
  13499. end.classList.add("active");
  13500. });
  13501. div.addEventListener("mouseup", () => {
  13502. const end = div.querySelector(".endOfContent");
  13503. if (!end) {
  13504. return;
  13505. }
  13506. end.style.top = "";
  13507. end.classList.remove("active");
  13508. });
  13509. div.addEventListener("copy", event => {
  13510. if (!this.#enablePermissions) {
  13511. const selection = document.getSelection();
  13512. event.clipboardData.setData("text/plain", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.removeNullCharacters)((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.normalizeUnicode)(selection.toString())));
  13513. }
  13514. event.preventDefault();
  13515. event.stopPropagation();
  13516. });
  13517. }
  13518. }
  13519. __webpack_async_result__();
  13520. } catch(e) { __webpack_async_result__(e); } });
  13521. /***/ }),
  13522. /***/ 276:
  13523. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  13524. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  13525. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13526. /* harmony export */ Toolbar: () => (/* binding */ Toolbar)
  13527. /* harmony export */ });
  13528. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  13529. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4927);
  13530. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  13531. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  13532. class Toolbar {
  13533. #opts;
  13534. constructor(options, eventBus) {
  13535. this.#opts = options;
  13536. this.eventBus = eventBus;
  13537. const buttons = [{
  13538. element: options.previous,
  13539. eventName: "previouspage"
  13540. }, {
  13541. element: options.next,
  13542. eventName: "nextpage"
  13543. }, {
  13544. element: options.zoomIn,
  13545. eventName: "zoomin"
  13546. }, {
  13547. element: options.zoomOut,
  13548. eventName: "zoomout"
  13549. }, {
  13550. element: options.print,
  13551. eventName: "print"
  13552. }, {
  13553. element: options.download,
  13554. eventName: "download"
  13555. }, {
  13556. element: options.editorFreeTextButton,
  13557. eventName: "switchannotationeditormode",
  13558. eventDetails: {
  13559. get mode() {
  13560. const {
  13561. classList
  13562. } = options.editorFreeTextButton;
  13563. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.FREETEXT;
  13564. }
  13565. }
  13566. }, {
  13567. element: options.editorHighlightButton,
  13568. eventName: "switchannotationeditormode",
  13569. eventDetails: {
  13570. get mode() {
  13571. const {
  13572. classList
  13573. } = options.editorHighlightButton;
  13574. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT;
  13575. }
  13576. }
  13577. }, {
  13578. element: options.editorInkButton,
  13579. eventName: "switchannotationeditormode",
  13580. eventDetails: {
  13581. get mode() {
  13582. const {
  13583. classList
  13584. } = options.editorInkButton;
  13585. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.INK;
  13586. }
  13587. }
  13588. }, {
  13589. element: options.editorStampButton,
  13590. eventName: "switchannotationeditormode",
  13591. eventDetails: {
  13592. get mode() {
  13593. const {
  13594. classList
  13595. } = options.editorStampButton;
  13596. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.STAMP;
  13597. }
  13598. }
  13599. }];
  13600. this.#bindListeners(buttons);
  13601. if (options.editorHighlightColorPicker) {
  13602. eventBus._on("annotationeditoruimanager", ({
  13603. uiManager
  13604. }) => {
  13605. this.#setAnnotationEditorUIManager(uiManager, options.editorHighlightColorPicker);
  13606. }, {
  13607. once: true
  13608. });
  13609. }
  13610. this.reset();
  13611. }
  13612. #setAnnotationEditorUIManager(uiManager, parentContainer) {
  13613. const colorPicker = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.ColorPicker({
  13614. uiManager
  13615. });
  13616. uiManager.setMainHighlightColorPicker(colorPicker);
  13617. parentContainer.append(colorPicker.renderMainDropdown());
  13618. }
  13619. setPageNumber(pageNumber, pageLabel) {
  13620. this.pageNumber = pageNumber;
  13621. this.pageLabel = pageLabel;
  13622. this.#updateUIState(false);
  13623. }
  13624. setPagesCount(pagesCount, hasPageLabels) {
  13625. this.pagesCount = pagesCount;
  13626. this.hasPageLabels = hasPageLabels;
  13627. this.#updateUIState(true);
  13628. }
  13629. setPageScale(pageScaleValue, pageScale) {
  13630. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13631. this.pageScale = pageScale;
  13632. this.#updateUIState(false);
  13633. }
  13634. reset() {
  13635. this.pageNumber = 0;
  13636. this.pageLabel = null;
  13637. this.hasPageLabels = false;
  13638. this.pagesCount = 0;
  13639. this.pageScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_VALUE;
  13640. this.pageScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
  13641. this.#updateUIState(true);
  13642. this.updateLoadingIndicatorState();
  13643. this.#editorModeChanged({
  13644. mode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE
  13645. });
  13646. }
  13647. #bindListeners(buttons) {
  13648. const {
  13649. eventBus
  13650. } = this;
  13651. const {
  13652. pageNumber,
  13653. scaleSelect
  13654. } = this.#opts;
  13655. const self = this;
  13656. for (const {
  13657. element,
  13658. eventName,
  13659. eventDetails
  13660. } of buttons) {
  13661. element.addEventListener("click", evt => {
  13662. if (eventName !== null) {
  13663. eventBus.dispatch(eventName, {
  13664. source: this,
  13665. ...eventDetails,
  13666. isFromKeyboard: evt.detail === 0
  13667. });
  13668. }
  13669. });
  13670. }
  13671. pageNumber.addEventListener("click", function () {
  13672. this.select();
  13673. });
  13674. pageNumber.addEventListener("change", function () {
  13675. eventBus.dispatch("pagenumberchanged", {
  13676. source: self,
  13677. value: this.value
  13678. });
  13679. });
  13680. scaleSelect.addEventListener("change", function () {
  13681. if (this.value === "custom") {
  13682. return;
  13683. }
  13684. eventBus.dispatch("scalechanged", {
  13685. source: self,
  13686. value: this.value
  13687. });
  13688. });
  13689. scaleSelect.addEventListener("click", function ({
  13690. target
  13691. }) {
  13692. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  13693. this.blur();
  13694. }
  13695. });
  13696. scaleSelect.oncontextmenu = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.noContextMenu;
  13697. eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this));
  13698. }
  13699. #editorModeChanged({
  13700. mode
  13701. }) {
  13702. const {
  13703. editorFreeTextButton,
  13704. editorFreeTextParamsToolbar,
  13705. editorHighlightButton,
  13706. editorHighlightParamsToolbar,
  13707. editorInkButton,
  13708. editorInkParamsToolbar,
  13709. editorStampButton,
  13710. editorStampParamsToolbar
  13711. } = this.#opts;
  13712. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorFreeTextButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
  13713. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorHighlightButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT, editorHighlightParamsToolbar);
  13714. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorInkButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.INK, editorInkParamsToolbar);
  13715. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorStampButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.STAMP, editorStampParamsToolbar);
  13716. const isDisable = mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  13717. editorFreeTextButton.disabled = isDisable;
  13718. editorHighlightButton.disabled = isDisable;
  13719. editorInkButton.disabled = isDisable;
  13720. editorStampButton.disabled = isDisable;
  13721. }
  13722. #updateUIState(resetNumPages = false) {
  13723. const {
  13724. pageNumber,
  13725. pagesCount,
  13726. pageScaleValue,
  13727. pageScale
  13728. } = this;
  13729. const opts = this.#opts;
  13730. if (resetNumPages) {
  13731. if (this.hasPageLabels) {
  13732. opts.pageNumber.type = "text";
  13733. opts.numPages.setAttribute("data-l10n-id", "pdfjs-page-of-pages");
  13734. } else {
  13735. opts.pageNumber.type = "number";
  13736. opts.numPages.setAttribute("data-l10n-id", "pdfjs-of-pages");
  13737. opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
  13738. pagesCount
  13739. }));
  13740. }
  13741. opts.pageNumber.max = pagesCount;
  13742. }
  13743. if (this.hasPageLabels) {
  13744. opts.pageNumber.value = this.pageLabel;
  13745. opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
  13746. pageNumber,
  13747. pagesCount
  13748. }));
  13749. } else {
  13750. opts.pageNumber.value = pageNumber;
  13751. }
  13752. opts.previous.disabled = pageNumber <= 1;
  13753. opts.next.disabled = pageNumber >= pagesCount;
  13754. opts.zoomOut.disabled = pageScale <= _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE;
  13755. opts.zoomIn.disabled = pageScale >= _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE;
  13756. let predefinedValueFound = false;
  13757. for (const option of opts.scaleSelect.options) {
  13758. if (option.value !== pageScaleValue) {
  13759. option.selected = false;
  13760. continue;
  13761. }
  13762. option.selected = true;
  13763. predefinedValueFound = true;
  13764. }
  13765. if (!predefinedValueFound) {
  13766. opts.customScaleOption.selected = true;
  13767. opts.customScaleOption.setAttribute("data-l10n-args", JSON.stringify({
  13768. scale: Math.round(pageScale * 10000) / 100
  13769. }));
  13770. }
  13771. }
  13772. updateLoadingIndicatorState(loading = false) {
  13773. const {
  13774. pageNumber
  13775. } = this.#opts;
  13776. pageNumber.classList.toggle("loading", loading);
  13777. }
  13778. }
  13779. __webpack_async_result__();
  13780. } catch(e) { __webpack_async_result__(e); } });
  13781. /***/ }),
  13782. /***/ 4927:
  13783. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  13784. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13785. /* harmony export */ AutoPrintRegExp: () => (/* binding */ AutoPrintRegExp),
  13786. /* harmony export */ CursorTool: () => (/* binding */ CursorTool),
  13787. /* harmony export */ DEFAULT_SCALE: () => (/* binding */ DEFAULT_SCALE),
  13788. /* harmony export */ DEFAULT_SCALE_DELTA: () => (/* binding */ DEFAULT_SCALE_DELTA),
  13789. /* harmony export */ DEFAULT_SCALE_VALUE: () => (/* binding */ DEFAULT_SCALE_VALUE),
  13790. /* harmony export */ MAX_AUTO_SCALE: () => (/* binding */ MAX_AUTO_SCALE),
  13791. /* harmony export */ MAX_SCALE: () => (/* binding */ MAX_SCALE),
  13792. /* harmony export */ MIN_SCALE: () => (/* binding */ MIN_SCALE),
  13793. /* harmony export */ OutputScale: () => (/* binding */ OutputScale),
  13794. /* harmony export */ PresentationModeState: () => (/* binding */ PresentationModeState),
  13795. /* harmony export */ ProgressBar: () => (/* binding */ ProgressBar),
  13796. /* harmony export */ RenderingStates: () => (/* binding */ RenderingStates),
  13797. /* harmony export */ SCROLLBAR_PADDING: () => (/* binding */ SCROLLBAR_PADDING),
  13798. /* harmony export */ ScrollMode: () => (/* binding */ ScrollMode),
  13799. /* harmony export */ SidebarView: () => (/* binding */ SidebarView),
  13800. /* harmony export */ SpreadMode: () => (/* binding */ SpreadMode),
  13801. /* harmony export */ TextLayerMode: () => (/* binding */ TextLayerMode),
  13802. /* harmony export */ UNKNOWN_SCALE: () => (/* binding */ UNKNOWN_SCALE),
  13803. /* harmony export */ VERTICAL_PADDING: () => (/* binding */ VERTICAL_PADDING),
  13804. /* harmony export */ animationStarted: () => (/* binding */ animationStarted),
  13805. /* harmony export */ apiPageLayoutToViewerModes: () => (/* binding */ apiPageLayoutToViewerModes),
  13806. /* harmony export */ apiPageModeToSidebarView: () => (/* binding */ apiPageModeToSidebarView),
  13807. /* harmony export */ approximateFraction: () => (/* binding */ approximateFraction),
  13808. /* harmony export */ binarySearchFirstItem: () => (/* binding */ binarySearchFirstItem),
  13809. /* harmony export */ docStyle: () => (/* binding */ docStyle),
  13810. /* harmony export */ getActiveOrFocusedElement: () => (/* binding */ getActiveOrFocusedElement),
  13811. /* harmony export */ getPageSizeInches: () => (/* binding */ getPageSizeInches),
  13812. /* harmony export */ getVisibleElements: () => (/* binding */ getVisibleElements),
  13813. /* harmony export */ isPortraitOrientation: () => (/* binding */ isPortraitOrientation),
  13814. /* harmony export */ isValidRotation: () => (/* binding */ isValidRotation),
  13815. /* harmony export */ isValidScrollMode: () => (/* binding */ isValidScrollMode),
  13816. /* harmony export */ isValidSpreadMode: () => (/* binding */ isValidSpreadMode),
  13817. /* harmony export */ normalizeWheelEventDelta: () => (/* binding */ normalizeWheelEventDelta),
  13818. /* harmony export */ normalizeWheelEventDirection: () => (/* binding */ normalizeWheelEventDirection),
  13819. /* harmony export */ parseQueryString: () => (/* binding */ parseQueryString),
  13820. /* harmony export */ removeNullCharacters: () => (/* binding */ removeNullCharacters),
  13821. /* harmony export */ roundToDivide: () => (/* binding */ roundToDivide),
  13822. /* harmony export */ scrollIntoView: () => (/* binding */ scrollIntoView),
  13823. /* harmony export */ toggleCheckedBtn: () => (/* binding */ toggleCheckedBtn),
  13824. /* harmony export */ toggleExpandedBtn: () => (/* binding */ toggleExpandedBtn),
  13825. /* harmony export */ watchScroll: () => (/* binding */ watchScroll)
  13826. /* harmony export */ });
  13827. /* unused harmony export backtrackBeforeAllVisibleElements */
  13828. const DEFAULT_SCALE_VALUE = "auto";
  13829. const DEFAULT_SCALE = 1.0;
  13830. const DEFAULT_SCALE_DELTA = 1.1;
  13831. const MIN_SCALE = 0.1;
  13832. const MAX_SCALE = 10.0;
  13833. const UNKNOWN_SCALE = 0;
  13834. const MAX_AUTO_SCALE = 1.25;
  13835. const SCROLLBAR_PADDING = 40;
  13836. const VERTICAL_PADDING = 5;
  13837. const RenderingStates = {
  13838. INITIAL: 0,
  13839. RUNNING: 1,
  13840. PAUSED: 2,
  13841. FINISHED: 3
  13842. };
  13843. const PresentationModeState = {
  13844. UNKNOWN: 0,
  13845. NORMAL: 1,
  13846. CHANGING: 2,
  13847. FULLSCREEN: 3
  13848. };
  13849. const SidebarView = {
  13850. UNKNOWN: -1,
  13851. NONE: 0,
  13852. THUMBS: 1,
  13853. OUTLINE: 2,
  13854. ATTACHMENTS: 3,
  13855. LAYERS: 4
  13856. };
  13857. const TextLayerMode = {
  13858. DISABLE: 0,
  13859. ENABLE: 1,
  13860. ENABLE_PERMISSIONS: 2
  13861. };
  13862. const ScrollMode = {
  13863. UNKNOWN: -1,
  13864. VERTICAL: 0,
  13865. HORIZONTAL: 1,
  13866. WRAPPED: 2,
  13867. PAGE: 3
  13868. };
  13869. const SpreadMode = {
  13870. UNKNOWN: -1,
  13871. NONE: 0,
  13872. ODD: 1,
  13873. EVEN: 2
  13874. };
  13875. const CursorTool = {
  13876. SELECT: 0,
  13877. HAND: 1,
  13878. ZOOM: 2
  13879. };
  13880. const AutoPrintRegExp = /\bprint\s*\(/;
  13881. class OutputScale {
  13882. constructor() {
  13883. const pixelRatio = window.devicePixelRatio || 1;
  13884. this.sx = pixelRatio;
  13885. this.sy = pixelRatio;
  13886. }
  13887. get scaled() {
  13888. return this.sx !== 1 || this.sy !== 1;
  13889. }
  13890. }
  13891. function scrollIntoView(element, spot, scrollMatches = false) {
  13892. let parent = element.offsetParent;
  13893. if (!parent) {
  13894. console.error("offsetParent is not set -- cannot scroll");
  13895. return;
  13896. }
  13897. let offsetY = element.offsetTop + element.clientTop;
  13898. let offsetX = element.offsetLeft + element.clientLeft;
  13899. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  13900. offsetY += parent.offsetTop;
  13901. offsetX += parent.offsetLeft;
  13902. parent = parent.offsetParent;
  13903. if (!parent) {
  13904. return;
  13905. }
  13906. }
  13907. if (spot) {
  13908. if (spot.top !== undefined) {
  13909. offsetY += spot.top;
  13910. }
  13911. if (spot.left !== undefined) {
  13912. offsetX += spot.left;
  13913. parent.scrollLeft = offsetX;
  13914. }
  13915. }
  13916. parent.scrollTop = offsetY;
  13917. }
  13918. function watchScroll(viewAreaElement, callback) {
  13919. const debounceScroll = function (evt) {
  13920. if (rAF) {
  13921. return;
  13922. }
  13923. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  13924. rAF = null;
  13925. const currentX = viewAreaElement.scrollLeft;
  13926. const lastX = state.lastX;
  13927. if (currentX !== lastX) {
  13928. state.right = currentX > lastX;
  13929. }
  13930. state.lastX = currentX;
  13931. const currentY = viewAreaElement.scrollTop;
  13932. const lastY = state.lastY;
  13933. if (currentY !== lastY) {
  13934. state.down = currentY > lastY;
  13935. }
  13936. state.lastY = currentY;
  13937. callback(state);
  13938. });
  13939. };
  13940. const state = {
  13941. right: true,
  13942. down: true,
  13943. lastX: viewAreaElement.scrollLeft,
  13944. lastY: viewAreaElement.scrollTop,
  13945. _eventHandler: debounceScroll
  13946. };
  13947. let rAF = null;
  13948. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  13949. return state;
  13950. }
  13951. function parseQueryString(query) {
  13952. const params = new Map();
  13953. for (const [key, value] of new URLSearchParams(query)) {
  13954. params.set(key.toLowerCase(), value);
  13955. }
  13956. return params;
  13957. }
  13958. const InvisibleCharactersRegExp = /[\x00-\x1F]/g;
  13959. function removeNullCharacters(str, replaceInvisible = false) {
  13960. if (!InvisibleCharactersRegExp.test(str)) {
  13961. return str;
  13962. }
  13963. if (replaceInvisible) {
  13964. return str.replaceAll(InvisibleCharactersRegExp, m => {
  13965. return m === "\x00" ? "" : " ";
  13966. });
  13967. }
  13968. return str.replaceAll("\x00", "");
  13969. }
  13970. function binarySearchFirstItem(items, condition, start = 0) {
  13971. let minIndex = start;
  13972. let maxIndex = items.length - 1;
  13973. if (maxIndex < 0 || !condition(items[maxIndex])) {
  13974. return items.length;
  13975. }
  13976. if (condition(items[minIndex])) {
  13977. return minIndex;
  13978. }
  13979. while (minIndex < maxIndex) {
  13980. const currentIndex = minIndex + maxIndex >> 1;
  13981. const currentItem = items[currentIndex];
  13982. if (condition(currentItem)) {
  13983. maxIndex = currentIndex;
  13984. } else {
  13985. minIndex = currentIndex + 1;
  13986. }
  13987. }
  13988. return minIndex;
  13989. }
  13990. function approximateFraction(x) {
  13991. if (Math.floor(x) === x) {
  13992. return [x, 1];
  13993. }
  13994. const xinv = 1 / x;
  13995. const limit = 8;
  13996. if (xinv > limit) {
  13997. return [1, limit];
  13998. } else if (Math.floor(xinv) === xinv) {
  13999. return [1, xinv];
  14000. }
  14001. const x_ = x > 1 ? xinv : x;
  14002. let a = 0,
  14003. b = 1,
  14004. c = 1,
  14005. d = 1;
  14006. while (true) {
  14007. const p = a + c,
  14008. q = b + d;
  14009. if (q > limit) {
  14010. break;
  14011. }
  14012. if (x_ <= p / q) {
  14013. c = p;
  14014. d = q;
  14015. } else {
  14016. a = p;
  14017. b = q;
  14018. }
  14019. }
  14020. let result;
  14021. if (x_ - a / b < c / d - x_) {
  14022. result = x_ === x ? [a, b] : [b, a];
  14023. } else {
  14024. result = x_ === x ? [c, d] : [d, c];
  14025. }
  14026. return result;
  14027. }
  14028. function roundToDivide(x, div) {
  14029. const r = x % div;
  14030. return r === 0 ? x : Math.round(x - r + div);
  14031. }
  14032. function getPageSizeInches({
  14033. view,
  14034. userUnit,
  14035. rotate
  14036. }) {
  14037. const [x1, y1, x2, y2] = view;
  14038. const changeOrientation = rotate % 180 !== 0;
  14039. const width = (x2 - x1) / 72 * userUnit;
  14040. const height = (y2 - y1) / 72 * userUnit;
  14041. return {
  14042. width: changeOrientation ? height : width,
  14043. height: changeOrientation ? width : height
  14044. };
  14045. }
  14046. function backtrackBeforeAllVisibleElements(index, views, top) {
  14047. if (index < 2) {
  14048. return index;
  14049. }
  14050. let elt = views[index].div;
  14051. let pageTop = elt.offsetTop + elt.clientTop;
  14052. if (pageTop >= top) {
  14053. elt = views[index - 1].div;
  14054. pageTop = elt.offsetTop + elt.clientTop;
  14055. }
  14056. for (let i = index - 2; i >= 0; --i) {
  14057. elt = views[i].div;
  14058. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  14059. break;
  14060. }
  14061. index = i;
  14062. }
  14063. return index;
  14064. }
  14065. function getVisibleElements({
  14066. scrollEl,
  14067. views,
  14068. sortByVisibility = false,
  14069. horizontal = false,
  14070. rtl = false
  14071. }) {
  14072. const top = scrollEl.scrollTop,
  14073. bottom = top + scrollEl.clientHeight;
  14074. const left = scrollEl.scrollLeft,
  14075. right = left + scrollEl.clientWidth;
  14076. function isElementBottomAfterViewTop(view) {
  14077. const element = view.div;
  14078. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  14079. return elementBottom > top;
  14080. }
  14081. function isElementNextAfterViewHorizontally(view) {
  14082. const element = view.div;
  14083. const elementLeft = element.offsetLeft + element.clientLeft;
  14084. const elementRight = elementLeft + element.clientWidth;
  14085. return rtl ? elementLeft < right : elementRight > left;
  14086. }
  14087. const visible = [],
  14088. ids = new Set(),
  14089. numViews = views.length;
  14090. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  14091. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  14092. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  14093. }
  14094. let lastEdge = horizontal ? right : -1;
  14095. for (let i = firstVisibleElementInd; i < numViews; i++) {
  14096. const view = views[i],
  14097. element = view.div;
  14098. const currentWidth = element.offsetLeft + element.clientLeft;
  14099. const currentHeight = element.offsetTop + element.clientTop;
  14100. const viewWidth = element.clientWidth,
  14101. viewHeight = element.clientHeight;
  14102. const viewRight = currentWidth + viewWidth;
  14103. const viewBottom = currentHeight + viewHeight;
  14104. if (lastEdge === -1) {
  14105. if (viewBottom >= bottom) {
  14106. lastEdge = viewBottom;
  14107. }
  14108. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  14109. break;
  14110. }
  14111. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  14112. continue;
  14113. }
  14114. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  14115. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  14116. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  14117. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  14118. const percent = fractionHeight * fractionWidth * 100 | 0;
  14119. visible.push({
  14120. id: view.id,
  14121. x: currentWidth,
  14122. y: currentHeight,
  14123. view,
  14124. percent,
  14125. widthPercent: fractionWidth * 100 | 0
  14126. });
  14127. ids.add(view.id);
  14128. }
  14129. const first = visible[0],
  14130. last = visible.at(-1);
  14131. if (sortByVisibility) {
  14132. visible.sort(function (a, b) {
  14133. const pc = a.percent - b.percent;
  14134. if (Math.abs(pc) > 0.001) {
  14135. return -pc;
  14136. }
  14137. return a.id - b.id;
  14138. });
  14139. }
  14140. return {
  14141. first,
  14142. last,
  14143. views: visible,
  14144. ids
  14145. };
  14146. }
  14147. function normalizeWheelEventDirection(evt) {
  14148. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  14149. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  14150. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  14151. delta = -delta;
  14152. }
  14153. return delta;
  14154. }
  14155. function normalizeWheelEventDelta(evt) {
  14156. const deltaMode = evt.deltaMode;
  14157. let delta = normalizeWheelEventDirection(evt);
  14158. const MOUSE_PIXELS_PER_LINE = 30;
  14159. const MOUSE_LINES_PER_PAGE = 30;
  14160. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  14161. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  14162. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  14163. delta /= MOUSE_LINES_PER_PAGE;
  14164. }
  14165. return delta;
  14166. }
  14167. function isValidRotation(angle) {
  14168. return Number.isInteger(angle) && angle % 90 === 0;
  14169. }
  14170. function isValidScrollMode(mode) {
  14171. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  14172. }
  14173. function isValidSpreadMode(mode) {
  14174. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  14175. }
  14176. function isPortraitOrientation(size) {
  14177. return size.width <= size.height;
  14178. }
  14179. const animationStarted = new Promise(function (resolve) {
  14180. window.requestAnimationFrame(resolve);
  14181. });
  14182. const docStyle = document.documentElement.style;
  14183. function clamp(v, min, max) {
  14184. return Math.min(Math.max(v, min), max);
  14185. }
  14186. class ProgressBar {
  14187. #classList = null;
  14188. #disableAutoFetchTimeout = null;
  14189. #percent = 0;
  14190. #style = null;
  14191. #visible = true;
  14192. constructor(bar) {
  14193. this.#classList = bar.classList;
  14194. this.#style = bar.style;
  14195. }
  14196. get percent() {
  14197. return this.#percent;
  14198. }
  14199. set percent(val) {
  14200. this.#percent = clamp(val, 0, 100);
  14201. if (isNaN(val)) {
  14202. this.#classList.add("indeterminate");
  14203. return;
  14204. }
  14205. this.#classList.remove("indeterminate");
  14206. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  14207. }
  14208. setWidth(viewer) {
  14209. if (!viewer) {
  14210. return;
  14211. }
  14212. const container = viewer.parentNode;
  14213. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  14214. if (scrollbarWidth > 0) {
  14215. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  14216. }
  14217. }
  14218. setDisableAutoFetch(delay = 5000) {
  14219. if (isNaN(this.#percent)) {
  14220. return;
  14221. }
  14222. if (this.#disableAutoFetchTimeout) {
  14223. clearTimeout(this.#disableAutoFetchTimeout);
  14224. }
  14225. this.show();
  14226. this.#disableAutoFetchTimeout = setTimeout(() => {
  14227. this.#disableAutoFetchTimeout = null;
  14228. this.hide();
  14229. }, delay);
  14230. }
  14231. hide() {
  14232. if (!this.#visible) {
  14233. return;
  14234. }
  14235. this.#visible = false;
  14236. this.#classList.add("hidden");
  14237. }
  14238. show() {
  14239. if (this.#visible) {
  14240. return;
  14241. }
  14242. this.#visible = true;
  14243. this.#classList.remove("hidden");
  14244. }
  14245. }
  14246. function getActiveOrFocusedElement() {
  14247. let curRoot = document;
  14248. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  14249. while (curActiveOrFocused?.shadowRoot) {
  14250. curRoot = curActiveOrFocused.shadowRoot;
  14251. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  14252. }
  14253. return curActiveOrFocused;
  14254. }
  14255. function apiPageLayoutToViewerModes(layout) {
  14256. let scrollMode = ScrollMode.VERTICAL,
  14257. spreadMode = SpreadMode.NONE;
  14258. switch (layout) {
  14259. case "SinglePage":
  14260. scrollMode = ScrollMode.PAGE;
  14261. break;
  14262. case "OneColumn":
  14263. break;
  14264. case "TwoPageLeft":
  14265. scrollMode = ScrollMode.PAGE;
  14266. case "TwoColumnLeft":
  14267. spreadMode = SpreadMode.ODD;
  14268. break;
  14269. case "TwoPageRight":
  14270. scrollMode = ScrollMode.PAGE;
  14271. case "TwoColumnRight":
  14272. spreadMode = SpreadMode.EVEN;
  14273. break;
  14274. }
  14275. return {
  14276. scrollMode,
  14277. spreadMode
  14278. };
  14279. }
  14280. function apiPageModeToSidebarView(mode) {
  14281. switch (mode) {
  14282. case "UseNone":
  14283. return SidebarView.NONE;
  14284. case "UseThumbs":
  14285. return SidebarView.THUMBS;
  14286. case "UseOutlines":
  14287. return SidebarView.OUTLINE;
  14288. case "UseAttachments":
  14289. return SidebarView.ATTACHMENTS;
  14290. case "UseOC":
  14291. return SidebarView.LAYERS;
  14292. }
  14293. return SidebarView.NONE;
  14294. }
  14295. function toggleCheckedBtn(button, toggle, view = null) {
  14296. button.classList.toggle("toggled", toggle);
  14297. button.setAttribute("aria-checked", toggle);
  14298. view?.classList.toggle("hidden", !toggle);
  14299. }
  14300. function toggleExpandedBtn(button, toggle, view = null) {
  14301. button.classList.toggle("toggled", toggle);
  14302. button.setAttribute("aria-expanded", toggle);
  14303. view?.classList.toggle("hidden", !toggle);
  14304. }
  14305. /***/ }),
  14306. /***/ 1096:
  14307. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  14308. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14309. /* harmony export */ ViewHistory: () => (/* binding */ ViewHistory)
  14310. /* harmony export */ });
  14311. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  14312. class ViewHistory {
  14313. constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
  14314. this.fingerprint = fingerprint;
  14315. this.cacheSize = cacheSize;
  14316. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  14317. const database = JSON.parse(databaseStr || "{}");
  14318. let index = -1;
  14319. if (!Array.isArray(database.files)) {
  14320. database.files = [];
  14321. } else {
  14322. while (database.files.length >= this.cacheSize) {
  14323. database.files.shift();
  14324. }
  14325. for (let i = 0, ii = database.files.length; i < ii; i++) {
  14326. const branch = database.files[i];
  14327. if (branch.fingerprint === this.fingerprint) {
  14328. index = i;
  14329. break;
  14330. }
  14331. }
  14332. }
  14333. if (index === -1) {
  14334. index = database.files.push({
  14335. fingerprint: this.fingerprint
  14336. }) - 1;
  14337. }
  14338. this.file = database.files[index];
  14339. this.database = database;
  14340. });
  14341. }
  14342. async _writeToStorage() {
  14343. const databaseStr = JSON.stringify(this.database);
  14344. localStorage.setItem("pdfjs.history", databaseStr);
  14345. }
  14346. async _readFromStorage() {
  14347. return localStorage.getItem("pdfjs.history");
  14348. }
  14349. async set(name, val) {
  14350. await this._initializedPromise;
  14351. this.file[name] = val;
  14352. return this._writeToStorage();
  14353. }
  14354. async setMultiple(properties) {
  14355. await this._initializedPromise;
  14356. for (const name in properties) {
  14357. this.file[name] = properties[name];
  14358. }
  14359. return this._writeToStorage();
  14360. }
  14361. async get(name, defaultValue) {
  14362. await this._initializedPromise;
  14363. const val = this.file[name];
  14364. return val !== undefined ? val : defaultValue;
  14365. }
  14366. async getMultiple(properties) {
  14367. await this._initializedPromise;
  14368. const values = Object.create(null);
  14369. for (const name in properties) {
  14370. const val = this.file[name];
  14371. values[name] = val !== undefined ? val : properties[name];
  14372. }
  14373. return values;
  14374. }
  14375. }
  14376. /***/ }),
  14377. /***/ 6400:
  14378. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  14379. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  14380. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14381. /* harmony export */ PDFViewerApplication: () => (/* reexport safe */ _app_js__WEBPACK_IMPORTED_MODULE_5__.PDFViewerApplication),
  14382. /* harmony export */ PDFViewerApplicationConstants: () => (/* binding */ AppConstants),
  14383. /* harmony export */ PDFViewerApplicationOptions: () => (/* reexport safe */ _app_options_js__WEBPACK_IMPORTED_MODULE_3__.AppOptions)
  14384. /* harmony export */ });
  14385. /* harmony import */ var web_com__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1546);
  14386. /* harmony import */ var web_print_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1834);
  14387. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4927);
  14388. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8961);
  14389. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3234);
  14390. /* harmony import */ var _app_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(39);
  14391. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([web_com__WEBPACK_IMPORTED_MODULE_0__, web_print_service__WEBPACK_IMPORTED_MODULE_1__, _app_js__WEBPACK_IMPORTED_MODULE_5__]);
  14392. ([web_com__WEBPACK_IMPORTED_MODULE_0__, web_print_service__WEBPACK_IMPORTED_MODULE_1__, _app_js__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  14393. const pdfjsVersion = '4.0.379';
  14394. const pdfjsBuild = '9e14d04fd';
  14395. const AppConstants = {
  14396. LinkTarget: _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_4__.LinkTarget,
  14397. RenderingStates: _ui_utils_js__WEBPACK_IMPORTED_MODULE_2__.RenderingStates,
  14398. ScrollMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_2__.ScrollMode,
  14399. SpreadMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_2__.SpreadMode
  14400. };
  14401. window.PDFViewerApplication = _app_js__WEBPACK_IMPORTED_MODULE_5__.PDFViewerApplication;
  14402. window.PDFViewerApplicationConstants = AppConstants;
  14403. window.PDFViewerApplicationOptions = _app_options_js__WEBPACK_IMPORTED_MODULE_3__.AppOptions;
  14404. function getViewerConfiguration() {
  14405. return {
  14406. appContainer: document.body,
  14407. mainContainer: document.getElementById("viewerContainer"),
  14408. viewerContainer: document.getElementById("viewer"),
  14409. toolbar: {
  14410. container: document.getElementById("toolbarViewer"),
  14411. numPages: document.getElementById("numPages"),
  14412. pageNumber: document.getElementById("pageNumber"),
  14413. scaleSelect: document.getElementById("scaleSelect"),
  14414. customScaleOption: document.getElementById("customScaleOption"),
  14415. previous: document.getElementById("previous"),
  14416. next: document.getElementById("next"),
  14417. zoomIn: document.getElementById("zoomIn"),
  14418. zoomOut: document.getElementById("zoomOut"),
  14419. viewFind: document.getElementById("viewFind"),
  14420. print: document.getElementById("print"),
  14421. editorFreeTextButton: document.getElementById("editorFreeText"),
  14422. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  14423. editorHighlightButton: document.getElementById("editorHighlight"),
  14424. editorHighlightParamsToolbar: document.getElementById("editorHighlightParamsToolbar"),
  14425. editorHighlightColorPicker: document.getElementById("editorHighlightColorPicker"),
  14426. editorInkButton: document.getElementById("editorInk"),
  14427. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  14428. editorStampButton: document.getElementById("editorStamp"),
  14429. editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"),
  14430. download: document.getElementById("download")
  14431. },
  14432. secondaryToolbar: {
  14433. toolbar: document.getElementById("secondaryToolbar"),
  14434. toggleButton: document.getElementById("secondaryToolbarToggle"),
  14435. presentationModeButton: document.getElementById("presentationMode"),
  14436. openFileButton: document.getElementById("secondaryOpenFile"),
  14437. printButton: document.getElementById("secondaryPrint"),
  14438. downloadButton: document.getElementById("secondaryDownload"),
  14439. viewBookmarkButton: document.getElementById("viewBookmark"),
  14440. firstPageButton: document.getElementById("firstPage"),
  14441. lastPageButton: document.getElementById("lastPage"),
  14442. pageRotateCwButton: document.getElementById("pageRotateCw"),
  14443. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  14444. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  14445. cursorHandToolButton: document.getElementById("cursorHandTool"),
  14446. scrollPageButton: document.getElementById("scrollPage"),
  14447. scrollVerticalButton: document.getElementById("scrollVertical"),
  14448. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  14449. scrollWrappedButton: document.getElementById("scrollWrapped"),
  14450. spreadNoneButton: document.getElementById("spreadNone"),
  14451. spreadOddButton: document.getElementById("spreadOdd"),
  14452. spreadEvenButton: document.getElementById("spreadEven"),
  14453. documentPropertiesButton: document.getElementById("documentProperties")
  14454. },
  14455. sidebar: {
  14456. outerContainer: document.getElementById("outerContainer"),
  14457. sidebarContainer: document.getElementById("sidebarContainer"),
  14458. toggleButton: document.getElementById("sidebarToggle"),
  14459. resizer: document.getElementById("sidebarResizer"),
  14460. thumbnailButton: document.getElementById("viewThumbnail"),
  14461. outlineButton: document.getElementById("viewOutline"),
  14462. attachmentsButton: document.getElementById("viewAttachments"),
  14463. layersButton: document.getElementById("viewLayers"),
  14464. thumbnailView: document.getElementById("thumbnailView"),
  14465. outlineView: document.getElementById("outlineView"),
  14466. attachmentsView: document.getElementById("attachmentsView"),
  14467. layersView: document.getElementById("layersView"),
  14468. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  14469. },
  14470. findBar: {
  14471. bar: document.getElementById("findbar"),
  14472. toggleButton: document.getElementById("viewFind"),
  14473. findField: document.getElementById("findInput"),
  14474. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  14475. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  14476. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  14477. entireWordCheckbox: document.getElementById("findEntireWord"),
  14478. findMsg: document.getElementById("findMsg"),
  14479. findResultsCount: document.getElementById("findResultsCount"),
  14480. findPreviousButton: document.getElementById("findPrevious"),
  14481. findNextButton: document.getElementById("findNext")
  14482. },
  14483. passwordOverlay: {
  14484. dialog: document.getElementById("passwordDialog"),
  14485. label: document.getElementById("passwordText"),
  14486. input: document.getElementById("password"),
  14487. submitButton: document.getElementById("passwordSubmit"),
  14488. cancelButton: document.getElementById("passwordCancel")
  14489. },
  14490. documentProperties: {
  14491. dialog: document.getElementById("documentPropertiesDialog"),
  14492. closeButton: document.getElementById("documentPropertiesClose"),
  14493. fields: {
  14494. fileName: document.getElementById("fileNameField"),
  14495. fileSize: document.getElementById("fileSizeField"),
  14496. title: document.getElementById("titleField"),
  14497. author: document.getElementById("authorField"),
  14498. subject: document.getElementById("subjectField"),
  14499. keywords: document.getElementById("keywordsField"),
  14500. creationDate: document.getElementById("creationDateField"),
  14501. modificationDate: document.getElementById("modificationDateField"),
  14502. creator: document.getElementById("creatorField"),
  14503. producer: document.getElementById("producerField"),
  14504. version: document.getElementById("versionField"),
  14505. pageCount: document.getElementById("pageCountField"),
  14506. pageSize: document.getElementById("pageSizeField"),
  14507. linearized: document.getElementById("linearizedField")
  14508. }
  14509. },
  14510. altTextDialog: {
  14511. dialog: document.getElementById("altTextDialog"),
  14512. optionDescription: document.getElementById("descriptionButton"),
  14513. optionDecorative: document.getElementById("decorativeButton"),
  14514. textarea: document.getElementById("descriptionTextarea"),
  14515. cancelButton: document.getElementById("altTextCancel"),
  14516. saveButton: document.getElementById("altTextSave")
  14517. },
  14518. annotationEditorParams: {
  14519. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  14520. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  14521. editorInkColor: document.getElementById("editorInkColor"),
  14522. editorInkThickness: document.getElementById("editorInkThickness"),
  14523. editorInkOpacity: document.getElementById("editorInkOpacity"),
  14524. editorStampAddImage: document.getElementById("editorStampAddImage")
  14525. },
  14526. printContainer: document.getElementById("printContainer"),
  14527. openFileInput: document.getElementById("fileInput"),
  14528. debuggerScriptPath: "./debugger.mjs"
  14529. };
  14530. }
  14531. function webViewerLoad() {
  14532. const config = getViewerConfiguration();
  14533. const event = new CustomEvent("webviewerloaded", {
  14534. bubbles: true,
  14535. cancelable: true,
  14536. detail: {
  14537. source: window
  14538. }
  14539. });
  14540. try {
  14541. parent.document.dispatchEvent(event);
  14542. } catch (ex) {
  14543. console.error(`webviewerloaded: ${ex}`);
  14544. document.dispatchEvent(event);
  14545. }
  14546. _app_js__WEBPACK_IMPORTED_MODULE_5__.PDFViewerApplication.run(config);
  14547. }
  14548. document.blockUnblockOnload?.(true);
  14549. if (document.readyState === "interactive" || document.readyState === "complete") {
  14550. webViewerLoad();
  14551. } else {
  14552. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  14553. }
  14554. __webpack_async_result__();
  14555. } catch(e) { __webpack_async_result__(e); } });
  14556. /***/ }),
  14557. /***/ 8012:
  14558. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  14559. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  14560. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14561. /* harmony export */ XfaLayerBuilder: () => (/* binding */ XfaLayerBuilder)
  14562. /* harmony export */ });
  14563. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1869);
  14564. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  14565. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  14566. class XfaLayerBuilder {
  14567. constructor({
  14568. pdfPage,
  14569. annotationStorage = null,
  14570. linkService,
  14571. xfaHtml = null
  14572. }) {
  14573. this.pdfPage = pdfPage;
  14574. this.annotationStorage = annotationStorage;
  14575. this.linkService = linkService;
  14576. this.xfaHtml = xfaHtml;
  14577. this.div = null;
  14578. this._cancelled = false;
  14579. }
  14580. async render(viewport, intent = "display") {
  14581. if (intent === "print") {
  14582. const parameters = {
  14583. viewport: viewport.clone({
  14584. dontFlip: true
  14585. }),
  14586. div: this.div,
  14587. xfaHtml: this.xfaHtml,
  14588. annotationStorage: this.annotationStorage,
  14589. linkService: this.linkService,
  14590. intent
  14591. };
  14592. this.div = document.createElement("div");
  14593. parameters.div = this.div;
  14594. return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.render(parameters);
  14595. }
  14596. const xfaHtml = await this.pdfPage.getXfa();
  14597. if (this._cancelled || !xfaHtml) {
  14598. return {
  14599. textDivs: []
  14600. };
  14601. }
  14602. const parameters = {
  14603. viewport: viewport.clone({
  14604. dontFlip: true
  14605. }),
  14606. div: this.div,
  14607. xfaHtml,
  14608. annotationStorage: this.annotationStorage,
  14609. linkService: this.linkService,
  14610. intent
  14611. };
  14612. if (this.div) {
  14613. return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.update(parameters);
  14614. }
  14615. this.div = document.createElement("div");
  14616. parameters.div = this.div;
  14617. return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.render(parameters);
  14618. }
  14619. cancel() {
  14620. this._cancelled = true;
  14621. }
  14622. hide() {
  14623. if (!this.div) {
  14624. return;
  14625. }
  14626. this.div.hidden = true;
  14627. }
  14628. }
  14629. __webpack_async_result__();
  14630. } catch(e) { __webpack_async_result__(e); } });
  14631. /***/ })
  14632. /******/ });
  14633. /************************************************************************/
  14634. /******/ // The module cache
  14635. /******/ var __webpack_module_cache__ = {};
  14636. /******/
  14637. /******/ // The require function
  14638. /******/ function __webpack_require__(moduleId) {
  14639. /******/ // Check if module is in cache
  14640. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  14641. /******/ if (cachedModule !== undefined) {
  14642. /******/ return cachedModule.exports;
  14643. /******/ }
  14644. /******/ // Create a new module (and put it into the cache)
  14645. /******/ var module = __webpack_module_cache__[moduleId] = {
  14646. /******/ // no module.id needed
  14647. /******/ // no module.loaded needed
  14648. /******/ exports: {}
  14649. /******/ };
  14650. /******/
  14651. /******/ // Execute the module function
  14652. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  14653. /******/
  14654. /******/ // Return the exports of the module
  14655. /******/ return module.exports;
  14656. /******/ }
  14657. /******/
  14658. /************************************************************************/
  14659. /******/ /* webpack/runtime/async module */
  14660. /******/ (() => {
  14661. /******/ var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";
  14662. /******/ var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";
  14663. /******/ var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";
  14664. /******/ var resolveQueue = (queue) => {
  14665. /******/ if(queue && queue.d < 1) {
  14666. /******/ queue.d = 1;
  14667. /******/ queue.forEach((fn) => (fn.r--));
  14668. /******/ queue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));
  14669. /******/ }
  14670. /******/ }
  14671. /******/ var wrapDeps = (deps) => (deps.map((dep) => {
  14672. /******/ if(dep !== null && typeof dep === "object") {
  14673. /******/ if(dep[webpackQueues]) return dep;
  14674. /******/ if(dep.then) {
  14675. /******/ var queue = [];
  14676. /******/ queue.d = 0;
  14677. /******/ dep.then((r) => {
  14678. /******/ obj[webpackExports] = r;
  14679. /******/ resolveQueue(queue);
  14680. /******/ }, (e) => {
  14681. /******/ obj[webpackError] = e;
  14682. /******/ resolveQueue(queue);
  14683. /******/ });
  14684. /******/ var obj = {};
  14685. /******/ obj[webpackQueues] = (fn) => (fn(queue));
  14686. /******/ return obj;
  14687. /******/ }
  14688. /******/ }
  14689. /******/ var ret = {};
  14690. /******/ ret[webpackQueues] = x => {};
  14691. /******/ ret[webpackExports] = dep;
  14692. /******/ return ret;
  14693. /******/ }));
  14694. /******/ __webpack_require__.a = (module, body, hasAwait) => {
  14695. /******/ var queue;
  14696. /******/ hasAwait && ((queue = []).d = -1);
  14697. /******/ var depQueues = new Set();
  14698. /******/ var exports = module.exports;
  14699. /******/ var currentDeps;
  14700. /******/ var outerResolve;
  14701. /******/ var reject;
  14702. /******/ var promise = new Promise((resolve, rej) => {
  14703. /******/ reject = rej;
  14704. /******/ outerResolve = resolve;
  14705. /******/ });
  14706. /******/ promise[webpackExports] = exports;
  14707. /******/ promise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise["catch"](x => {}));
  14708. /******/ module.exports = promise;
  14709. /******/ body((deps) => {
  14710. /******/ currentDeps = wrapDeps(deps);
  14711. /******/ var fn;
  14712. /******/ var getResult = () => (currentDeps.map((d) => {
  14713. /******/ if(d[webpackError]) throw d[webpackError];
  14714. /******/ return d[webpackExports];
  14715. /******/ }))
  14716. /******/ var promise = new Promise((resolve) => {
  14717. /******/ fn = () => (resolve(getResult));
  14718. /******/ fn.r = 0;
  14719. /******/ var fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));
  14720. /******/ currentDeps.map((dep) => (dep[webpackQueues](fnQueue)));
  14721. /******/ });
  14722. /******/ return fn.r ? promise : getResult();
  14723. /******/ }, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));
  14724. /******/ queue && queue.d < 0 && (queue.d = 0);
  14725. /******/ };
  14726. /******/ })();
  14727. /******/
  14728. /******/ /* webpack/runtime/define property getters */
  14729. /******/ (() => {
  14730. /******/ // define getter functions for harmony exports
  14731. /******/ __webpack_require__.d = (exports, definition) => {
  14732. /******/ for(var key in definition) {
  14733. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  14734. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14735. /******/ }
  14736. /******/ }
  14737. /******/ };
  14738. /******/ })();
  14739. /******/
  14740. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  14741. /******/ (() => {
  14742. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  14743. /******/ })();
  14744. /******/
  14745. /************************************************************************/
  14746. /******/
  14747. /******/ // startup
  14748. /******/ // Load entry module and return exports
  14749. /******/ // This entry module used 'module' so it can't be inlined
  14750. /******/ var __webpack_exports__ = __webpack_require__(6400);
  14751. /******/ __webpack_exports__ = await __webpack_exports__;
  14752. /******/ var __webpack_exports__PDFViewerApplication = __webpack_exports__.PDFViewerApplication;
  14753. /******/ var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFViewerApplicationConstants;
  14754. /******/ var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions;
  14755. /******/ export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };
  14756. /******/
  14757. //# sourceMappingURL=viewer.mjs.map