viewer.mjs 566 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2024 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. /***/ 9306:
  24. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  25. var isCallable = __webpack_require__(4901);
  26. var tryToString = __webpack_require__(6823);
  27. var $TypeError = TypeError;
  28. // `Assert: IsCallable(argument) is true`
  29. module.exports = function (argument) {
  30. if (isCallable(argument)) return argument;
  31. throw new $TypeError(tryToString(argument) + ' is not a function');
  32. };
  33. /***/ }),
  34. /***/ 7080:
  35. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  36. var has = (__webpack_require__(4402).has);
  37. // Perform ? RequireInternalSlot(M, [[SetData]])
  38. module.exports = function (it) {
  39. has(it);
  40. return it;
  41. };
  42. /***/ }),
  43. /***/ 679:
  44. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  45. var isPrototypeOf = __webpack_require__(1625);
  46. var $TypeError = TypeError;
  47. module.exports = function (it, Prototype) {
  48. if (isPrototypeOf(Prototype, it)) return it;
  49. throw new $TypeError('Incorrect invocation');
  50. };
  51. /***/ }),
  52. /***/ 8551:
  53. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  54. var isObject = __webpack_require__(34);
  55. var $String = String;
  56. var $TypeError = TypeError;
  57. // `Assert: Type(argument) is Object`
  58. module.exports = function (argument) {
  59. if (isObject(argument)) return argument;
  60. throw new $TypeError($String(argument) + ' is not an object');
  61. };
  62. /***/ }),
  63. /***/ 9617:
  64. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  65. var toIndexedObject = __webpack_require__(5397);
  66. var toAbsoluteIndex = __webpack_require__(5610);
  67. var lengthOfArrayLike = __webpack_require__(6198);
  68. // `Array.prototype.{ indexOf, includes }` methods implementation
  69. var createMethod = function (IS_INCLUDES) {
  70. return function ($this, el, fromIndex) {
  71. var O = toIndexedObject($this);
  72. var length = lengthOfArrayLike(O);
  73. if (length === 0) return !IS_INCLUDES && -1;
  74. var index = toAbsoluteIndex(fromIndex, length);
  75. var value;
  76. // Array#includes uses SameValueZero equality algorithm
  77. // eslint-disable-next-line no-self-compare -- NaN check
  78. if (IS_INCLUDES && el !== el) while (length > index) {
  79. value = O[index++];
  80. // eslint-disable-next-line no-self-compare -- NaN check
  81. if (value !== value) return true;
  82. // Array#indexOf ignores holes, Array#includes - not
  83. } else for (;length > index; index++) {
  84. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  85. } return !IS_INCLUDES && -1;
  86. };
  87. };
  88. module.exports = {
  89. // `Array.prototype.includes` method
  90. // https://tc39.es/ecma262/#sec-array.prototype.includes
  91. includes: createMethod(true),
  92. // `Array.prototype.indexOf` method
  93. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  94. indexOf: createMethod(false)
  95. };
  96. /***/ }),
  97. /***/ 4527:
  98. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  99. var DESCRIPTORS = __webpack_require__(3724);
  100. var isArray = __webpack_require__(4376);
  101. var $TypeError = TypeError;
  102. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  103. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  104. // Safari < 13 does not throw an error in this case
  105. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
  106. // makes no sense without proper strict mode support
  107. if (this !== undefined) return true;
  108. try {
  109. // eslint-disable-next-line es/no-object-defineproperty -- safe
  110. Object.defineProperty([], 'length', { writable: false }).length = 1;
  111. } catch (error) {
  112. return error instanceof TypeError;
  113. }
  114. }();
  115. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  116. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  117. throw new $TypeError('Cannot set read only .length');
  118. } return O.length = length;
  119. } : function (O, length) {
  120. return O.length = length;
  121. };
  122. /***/ }),
  123. /***/ 6319:
  124. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  125. var anObject = __webpack_require__(8551);
  126. var iteratorClose = __webpack_require__(9539);
  127. // call something on iterator step with safe closing on error
  128. module.exports = function (iterator, fn, value, ENTRIES) {
  129. try {
  130. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  131. } catch (error) {
  132. iteratorClose(iterator, 'throw', error);
  133. }
  134. };
  135. /***/ }),
  136. /***/ 2195:
  137. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  138. var uncurryThis = __webpack_require__(9504);
  139. var toString = uncurryThis({}.toString);
  140. var stringSlice = uncurryThis(''.slice);
  141. module.exports = function (it) {
  142. return stringSlice(toString(it), 8, -1);
  143. };
  144. /***/ }),
  145. /***/ 6955:
  146. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  147. var TO_STRING_TAG_SUPPORT = __webpack_require__(2140);
  148. var isCallable = __webpack_require__(4901);
  149. var classofRaw = __webpack_require__(2195);
  150. var wellKnownSymbol = __webpack_require__(8227);
  151. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  152. var $Object = Object;
  153. // ES3 wrong here
  154. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
  155. // fallback for IE11 Script Access Denied error
  156. var tryGet = function (it, key) {
  157. try {
  158. return it[key];
  159. } catch (error) { /* empty */ }
  160. };
  161. // getting tag from ES6+ `Object.prototype.toString`
  162. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  163. var O, tag, result;
  164. return it === undefined ? 'Undefined' : it === null ? 'Null'
  165. // @@toStringTag case
  166. : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
  167. // builtinTag case
  168. : CORRECT_ARGUMENTS ? classofRaw(O)
  169. // ES3 arguments fallback
  170. : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  171. };
  172. /***/ }),
  173. /***/ 7740:
  174. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  175. var hasOwn = __webpack_require__(9297);
  176. var ownKeys = __webpack_require__(5031);
  177. var getOwnPropertyDescriptorModule = __webpack_require__(7347);
  178. var definePropertyModule = __webpack_require__(4913);
  179. module.exports = function (target, source, exceptions) {
  180. var keys = ownKeys(source);
  181. var defineProperty = definePropertyModule.f;
  182. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  183. for (var i = 0; i < keys.length; i++) {
  184. var key = keys[i];
  185. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  186. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  187. }
  188. }
  189. };
  190. /***/ }),
  191. /***/ 2211:
  192. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  193. var fails = __webpack_require__(9039);
  194. module.exports = !fails(function () {
  195. function F() { /* empty */ }
  196. F.prototype.constructor = null;
  197. // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
  198. return Object.getPrototypeOf(new F()) !== F.prototype;
  199. });
  200. /***/ }),
  201. /***/ 2529:
  202. /***/ ((module) => {
  203. // `CreateIterResultObject` abstract operation
  204. // https://tc39.es/ecma262/#sec-createiterresultobject
  205. module.exports = function (value, done) {
  206. return { value: value, done: done };
  207. };
  208. /***/ }),
  209. /***/ 6699:
  210. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  211. var DESCRIPTORS = __webpack_require__(3724);
  212. var definePropertyModule = __webpack_require__(4913);
  213. var createPropertyDescriptor = __webpack_require__(6980);
  214. module.exports = DESCRIPTORS ? function (object, key, value) {
  215. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  216. } : function (object, key, value) {
  217. object[key] = value;
  218. return object;
  219. };
  220. /***/ }),
  221. /***/ 6980:
  222. /***/ ((module) => {
  223. module.exports = function (bitmap, value) {
  224. return {
  225. enumerable: !(bitmap & 1),
  226. configurable: !(bitmap & 2),
  227. writable: !(bitmap & 4),
  228. value: value
  229. };
  230. };
  231. /***/ }),
  232. /***/ 4659:
  233. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  234. var DESCRIPTORS = __webpack_require__(3724);
  235. var definePropertyModule = __webpack_require__(4913);
  236. var createPropertyDescriptor = __webpack_require__(6980);
  237. module.exports = function (object, key, value) {
  238. if (DESCRIPTORS) definePropertyModule.f(object, key, createPropertyDescriptor(0, value));
  239. else object[key] = value;
  240. };
  241. /***/ }),
  242. /***/ 2106:
  243. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  244. var makeBuiltIn = __webpack_require__(283);
  245. var defineProperty = __webpack_require__(4913);
  246. module.exports = function (target, name, descriptor) {
  247. if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
  248. if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
  249. return defineProperty.f(target, name, descriptor);
  250. };
  251. /***/ }),
  252. /***/ 6840:
  253. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  254. var isCallable = __webpack_require__(4901);
  255. var definePropertyModule = __webpack_require__(4913);
  256. var makeBuiltIn = __webpack_require__(283);
  257. var defineGlobalProperty = __webpack_require__(9433);
  258. module.exports = function (O, key, value, options) {
  259. if (!options) options = {};
  260. var simple = options.enumerable;
  261. var name = options.name !== undefined ? options.name : key;
  262. if (isCallable(value)) makeBuiltIn(value, name, options);
  263. if (options.global) {
  264. if (simple) O[key] = value;
  265. else defineGlobalProperty(key, value);
  266. } else {
  267. try {
  268. if (!options.unsafe) delete O[key];
  269. else if (O[key]) simple = true;
  270. } catch (error) { /* empty */ }
  271. if (simple) O[key] = value;
  272. else definePropertyModule.f(O, key, {
  273. value: value,
  274. enumerable: false,
  275. configurable: !options.nonConfigurable,
  276. writable: !options.nonWritable
  277. });
  278. } return O;
  279. };
  280. /***/ }),
  281. /***/ 6279:
  282. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  283. var defineBuiltIn = __webpack_require__(6840);
  284. module.exports = function (target, src, options) {
  285. for (var key in src) defineBuiltIn(target, key, src[key], options);
  286. return target;
  287. };
  288. /***/ }),
  289. /***/ 9433:
  290. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  291. var globalThis = __webpack_require__(4576);
  292. // eslint-disable-next-line es/no-object-defineproperty -- safe
  293. var defineProperty = Object.defineProperty;
  294. module.exports = function (key, value) {
  295. try {
  296. defineProperty(globalThis, key, { value: value, configurable: true, writable: true });
  297. } catch (error) {
  298. globalThis[key] = value;
  299. } return value;
  300. };
  301. /***/ }),
  302. /***/ 3724:
  303. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  304. var fails = __webpack_require__(9039);
  305. // Detect IE8's incomplete defineProperty implementation
  306. module.exports = !fails(function () {
  307. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  308. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
  309. });
  310. /***/ }),
  311. /***/ 4055:
  312. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  313. var globalThis = __webpack_require__(4576);
  314. var isObject = __webpack_require__(34);
  315. var document = globalThis.document;
  316. // typeof document.createElement is 'object' in old IE
  317. var EXISTS = isObject(document) && isObject(document.createElement);
  318. module.exports = function (it) {
  319. return EXISTS ? document.createElement(it) : {};
  320. };
  321. /***/ }),
  322. /***/ 6837:
  323. /***/ ((module) => {
  324. var $TypeError = TypeError;
  325. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
  326. module.exports = function (it) {
  327. if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
  328. return it;
  329. };
  330. /***/ }),
  331. /***/ 8727:
  332. /***/ ((module) => {
  333. // IE8- don't enum bug keys
  334. module.exports = [
  335. 'constructor',
  336. 'hasOwnProperty',
  337. 'isPrototypeOf',
  338. 'propertyIsEnumerable',
  339. 'toLocaleString',
  340. 'toString',
  341. 'valueOf'
  342. ];
  343. /***/ }),
  344. /***/ 2839:
  345. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  346. var globalThis = __webpack_require__(4576);
  347. var navigator = globalThis.navigator;
  348. var userAgent = navigator && navigator.userAgent;
  349. module.exports = userAgent ? String(userAgent) : '';
  350. /***/ }),
  351. /***/ 9519:
  352. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  353. var globalThis = __webpack_require__(4576);
  354. var userAgent = __webpack_require__(2839);
  355. var process = globalThis.process;
  356. var Deno = globalThis.Deno;
  357. var versions = process && process.versions || Deno && Deno.version;
  358. var v8 = versions && versions.v8;
  359. var match, version;
  360. if (v8) {
  361. match = v8.split('.');
  362. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  363. // but their correct versions are not interesting for us
  364. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  365. }
  366. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  367. // so check `userAgent` even if `.v8` exists, but 0
  368. if (!version && userAgent) {
  369. match = userAgent.match(/Edge\/(\d+)/);
  370. if (!match || match[1] >= 74) {
  371. match = userAgent.match(/Chrome\/(\d+)/);
  372. if (match) version = +match[1];
  373. }
  374. }
  375. module.exports = version;
  376. /***/ }),
  377. /***/ 6518:
  378. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  379. var globalThis = __webpack_require__(4576);
  380. var getOwnPropertyDescriptor = (__webpack_require__(7347).f);
  381. var createNonEnumerableProperty = __webpack_require__(6699);
  382. var defineBuiltIn = __webpack_require__(6840);
  383. var defineGlobalProperty = __webpack_require__(9433);
  384. var copyConstructorProperties = __webpack_require__(7740);
  385. var isForced = __webpack_require__(2796);
  386. /*
  387. options.target - name of the target object
  388. options.global - target is the global object
  389. options.stat - export as static methods of target
  390. options.proto - export as prototype methods of target
  391. options.real - real prototype method for the `pure` version
  392. options.forced - export even if the native feature is available
  393. options.bind - bind methods to the target, required for the `pure` version
  394. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  395. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  396. options.sham - add a flag to not completely full polyfills
  397. options.enumerable - export as enumerable property
  398. options.dontCallGetSet - prevent calling a getter on target
  399. options.name - the .name of the function if it does not match the key
  400. */
  401. module.exports = function (options, source) {
  402. var TARGET = options.target;
  403. var GLOBAL = options.global;
  404. var STATIC = options.stat;
  405. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  406. if (GLOBAL) {
  407. target = globalThis;
  408. } else if (STATIC) {
  409. target = globalThis[TARGET] || defineGlobalProperty(TARGET, {});
  410. } else {
  411. target = globalThis[TARGET] && globalThis[TARGET].prototype;
  412. }
  413. if (target) for (key in source) {
  414. sourceProperty = source[key];
  415. if (options.dontCallGetSet) {
  416. descriptor = getOwnPropertyDescriptor(target, key);
  417. targetProperty = descriptor && descriptor.value;
  418. } else targetProperty = target[key];
  419. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  420. // contained in target
  421. if (!FORCED && targetProperty !== undefined) {
  422. if (typeof sourceProperty == typeof targetProperty) continue;
  423. copyConstructorProperties(sourceProperty, targetProperty);
  424. }
  425. // add a flag to not completely full polyfills
  426. if (options.sham || (targetProperty && targetProperty.sham)) {
  427. createNonEnumerableProperty(sourceProperty, 'sham', true);
  428. }
  429. defineBuiltIn(target, key, sourceProperty, options);
  430. }
  431. };
  432. /***/ }),
  433. /***/ 9039:
  434. /***/ ((module) => {
  435. module.exports = function (exec) {
  436. try {
  437. return !!exec();
  438. } catch (error) {
  439. return true;
  440. }
  441. };
  442. /***/ }),
  443. /***/ 6080:
  444. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  445. var uncurryThis = __webpack_require__(7476);
  446. var aCallable = __webpack_require__(9306);
  447. var NATIVE_BIND = __webpack_require__(616);
  448. var bind = uncurryThis(uncurryThis.bind);
  449. // optional / simple context binding
  450. module.exports = function (fn, that) {
  451. aCallable(fn);
  452. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  453. return fn.apply(that, arguments);
  454. };
  455. };
  456. /***/ }),
  457. /***/ 616:
  458. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  459. var fails = __webpack_require__(9039);
  460. module.exports = !fails(function () {
  461. // eslint-disable-next-line es/no-function-prototype-bind -- safe
  462. var test = (function () { /* empty */ }).bind();
  463. // eslint-disable-next-line no-prototype-builtins -- safe
  464. return typeof test != 'function' || test.hasOwnProperty('prototype');
  465. });
  466. /***/ }),
  467. /***/ 9565:
  468. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  469. var NATIVE_BIND = __webpack_require__(616);
  470. var call = Function.prototype.call;
  471. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  472. return call.apply(call, arguments);
  473. };
  474. /***/ }),
  475. /***/ 350:
  476. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  477. var DESCRIPTORS = __webpack_require__(3724);
  478. var hasOwn = __webpack_require__(9297);
  479. var FunctionPrototype = Function.prototype;
  480. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  481. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  482. var EXISTS = hasOwn(FunctionPrototype, 'name');
  483. // additional protection from minified / mangled / dropped function names
  484. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  485. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  486. module.exports = {
  487. EXISTS: EXISTS,
  488. PROPER: PROPER,
  489. CONFIGURABLE: CONFIGURABLE
  490. };
  491. /***/ }),
  492. /***/ 6706:
  493. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  494. var uncurryThis = __webpack_require__(9504);
  495. var aCallable = __webpack_require__(9306);
  496. module.exports = function (object, key, method) {
  497. try {
  498. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  499. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  500. } catch (error) { /* empty */ }
  501. };
  502. /***/ }),
  503. /***/ 7476:
  504. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  505. var classofRaw = __webpack_require__(2195);
  506. var uncurryThis = __webpack_require__(9504);
  507. module.exports = function (fn) {
  508. // Nashorn bug:
  509. // https://github.com/zloirock/core-js/issues/1128
  510. // https://github.com/zloirock/core-js/issues/1130
  511. if (classofRaw(fn) === 'Function') return uncurryThis(fn);
  512. };
  513. /***/ }),
  514. /***/ 9504:
  515. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  516. var NATIVE_BIND = __webpack_require__(616);
  517. var FunctionPrototype = Function.prototype;
  518. var call = FunctionPrototype.call;
  519. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  520. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  521. return function () {
  522. return call.apply(fn, arguments);
  523. };
  524. };
  525. /***/ }),
  526. /***/ 7751:
  527. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  528. var globalThis = __webpack_require__(4576);
  529. var isCallable = __webpack_require__(4901);
  530. var aFunction = function (argument) {
  531. return isCallable(argument) ? argument : undefined;
  532. };
  533. module.exports = function (namespace, method) {
  534. return arguments.length < 2 ? aFunction(globalThis[namespace]) : globalThis[namespace] && globalThis[namespace][method];
  535. };
  536. /***/ }),
  537. /***/ 1767:
  538. /***/ ((module) => {
  539. // `GetIteratorDirect(obj)` abstract operation
  540. // https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect
  541. module.exports = function (obj) {
  542. return {
  543. iterator: obj,
  544. next: obj.next,
  545. done: false
  546. };
  547. };
  548. /***/ }),
  549. /***/ 851:
  550. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  551. var classof = __webpack_require__(6955);
  552. var getMethod = __webpack_require__(5966);
  553. var isNullOrUndefined = __webpack_require__(4117);
  554. var Iterators = __webpack_require__(6269);
  555. var wellKnownSymbol = __webpack_require__(8227);
  556. var ITERATOR = wellKnownSymbol('iterator');
  557. module.exports = function (it) {
  558. if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
  559. || getMethod(it, '@@iterator')
  560. || Iterators[classof(it)];
  561. };
  562. /***/ }),
  563. /***/ 81:
  564. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  565. var call = __webpack_require__(9565);
  566. var aCallable = __webpack_require__(9306);
  567. var anObject = __webpack_require__(8551);
  568. var tryToString = __webpack_require__(6823);
  569. var getIteratorMethod = __webpack_require__(851);
  570. var $TypeError = TypeError;
  571. module.exports = function (argument, usingIterator) {
  572. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  573. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  574. throw new $TypeError(tryToString(argument) + ' is not iterable');
  575. };
  576. /***/ }),
  577. /***/ 5966:
  578. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  579. var aCallable = __webpack_require__(9306);
  580. var isNullOrUndefined = __webpack_require__(4117);
  581. // `GetMethod` abstract operation
  582. // https://tc39.es/ecma262/#sec-getmethod
  583. module.exports = function (V, P) {
  584. var func = V[P];
  585. return isNullOrUndefined(func) ? undefined : aCallable(func);
  586. };
  587. /***/ }),
  588. /***/ 3789:
  589. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  590. var aCallable = __webpack_require__(9306);
  591. var anObject = __webpack_require__(8551);
  592. var call = __webpack_require__(9565);
  593. var toIntegerOrInfinity = __webpack_require__(1291);
  594. var getIteratorDirect = __webpack_require__(1767);
  595. var INVALID_SIZE = 'Invalid size';
  596. var $RangeError = RangeError;
  597. var $TypeError = TypeError;
  598. var max = Math.max;
  599. var SetRecord = function (set, intSize) {
  600. this.set = set;
  601. this.size = max(intSize, 0);
  602. this.has = aCallable(set.has);
  603. this.keys = aCallable(set.keys);
  604. };
  605. SetRecord.prototype = {
  606. getIterator: function () {
  607. return getIteratorDirect(anObject(call(this.keys, this.set)));
  608. },
  609. includes: function (it) {
  610. return call(this.has, this.set, it);
  611. }
  612. };
  613. // `GetSetRecord` abstract operation
  614. // https://tc39.es/proposal-set-methods/#sec-getsetrecord
  615. module.exports = function (obj) {
  616. anObject(obj);
  617. var numSize = +obj.size;
  618. // NOTE: If size is undefined, then numSize will be NaN
  619. // eslint-disable-next-line no-self-compare -- NaN check
  620. if (numSize !== numSize) throw new $TypeError(INVALID_SIZE);
  621. var intSize = toIntegerOrInfinity(numSize);
  622. if (intSize < 0) throw new $RangeError(INVALID_SIZE);
  623. return new SetRecord(obj, intSize);
  624. };
  625. /***/ }),
  626. /***/ 4576:
  627. /***/ (function(module) {
  628. var check = function (it) {
  629. return it && it.Math === Math && it;
  630. };
  631. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  632. module.exports =
  633. // eslint-disable-next-line es/no-global-this -- safe
  634. check(typeof globalThis == 'object' && globalThis) ||
  635. check(typeof window == 'object' && window) ||
  636. // eslint-disable-next-line no-restricted-globals -- safe
  637. check(typeof self == 'object' && self) ||
  638. check(typeof global == 'object' && global) ||
  639. check(typeof this == 'object' && this) ||
  640. // eslint-disable-next-line no-new-func -- fallback
  641. (function () { return this; })() || Function('return this')();
  642. /***/ }),
  643. /***/ 9297:
  644. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  645. var uncurryThis = __webpack_require__(9504);
  646. var toObject = __webpack_require__(8981);
  647. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  648. // `HasOwnProperty` abstract operation
  649. // https://tc39.es/ecma262/#sec-hasownproperty
  650. // eslint-disable-next-line es/no-object-hasown -- safe
  651. module.exports = Object.hasOwn || function hasOwn(it, key) {
  652. return hasOwnProperty(toObject(it), key);
  653. };
  654. /***/ }),
  655. /***/ 421:
  656. /***/ ((module) => {
  657. module.exports = {};
  658. /***/ }),
  659. /***/ 397:
  660. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  661. var getBuiltIn = __webpack_require__(7751);
  662. module.exports = getBuiltIn('document', 'documentElement');
  663. /***/ }),
  664. /***/ 5917:
  665. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  666. var DESCRIPTORS = __webpack_require__(3724);
  667. var fails = __webpack_require__(9039);
  668. var createElement = __webpack_require__(4055);
  669. // Thanks to IE8 for its funny defineProperty
  670. module.exports = !DESCRIPTORS && !fails(function () {
  671. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  672. return Object.defineProperty(createElement('div'), 'a', {
  673. get: function () { return 7; }
  674. }).a !== 7;
  675. });
  676. /***/ }),
  677. /***/ 7055:
  678. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  679. var uncurryThis = __webpack_require__(9504);
  680. var fails = __webpack_require__(9039);
  681. var classof = __webpack_require__(2195);
  682. var $Object = Object;
  683. var split = uncurryThis(''.split);
  684. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  685. module.exports = fails(function () {
  686. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  687. // eslint-disable-next-line no-prototype-builtins -- safe
  688. return !$Object('z').propertyIsEnumerable(0);
  689. }) ? function (it) {
  690. return classof(it) === 'String' ? split(it, '') : $Object(it);
  691. } : $Object;
  692. /***/ }),
  693. /***/ 3706:
  694. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  695. var uncurryThis = __webpack_require__(9504);
  696. var isCallable = __webpack_require__(4901);
  697. var store = __webpack_require__(7629);
  698. var functionToString = uncurryThis(Function.toString);
  699. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  700. if (!isCallable(store.inspectSource)) {
  701. store.inspectSource = function (it) {
  702. return functionToString(it);
  703. };
  704. }
  705. module.exports = store.inspectSource;
  706. /***/ }),
  707. /***/ 1181:
  708. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  709. var NATIVE_WEAK_MAP = __webpack_require__(8622);
  710. var globalThis = __webpack_require__(4576);
  711. var isObject = __webpack_require__(34);
  712. var createNonEnumerableProperty = __webpack_require__(6699);
  713. var hasOwn = __webpack_require__(9297);
  714. var shared = __webpack_require__(7629);
  715. var sharedKey = __webpack_require__(6119);
  716. var hiddenKeys = __webpack_require__(421);
  717. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  718. var TypeError = globalThis.TypeError;
  719. var WeakMap = globalThis.WeakMap;
  720. var set, get, has;
  721. var enforce = function (it) {
  722. return has(it) ? get(it) : set(it, {});
  723. };
  724. var getterFor = function (TYPE) {
  725. return function (it) {
  726. var state;
  727. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  728. throw new TypeError('Incompatible receiver, ' + TYPE + ' required');
  729. } return state;
  730. };
  731. };
  732. if (NATIVE_WEAK_MAP || shared.state) {
  733. var store = shared.state || (shared.state = new WeakMap());
  734. /* eslint-disable no-self-assign -- prototype methods protection */
  735. store.get = store.get;
  736. store.has = store.has;
  737. store.set = store.set;
  738. /* eslint-enable no-self-assign -- prototype methods protection */
  739. set = function (it, metadata) {
  740. if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  741. metadata.facade = it;
  742. store.set(it, metadata);
  743. return metadata;
  744. };
  745. get = function (it) {
  746. return store.get(it) || {};
  747. };
  748. has = function (it) {
  749. return store.has(it);
  750. };
  751. } else {
  752. var STATE = sharedKey('state');
  753. hiddenKeys[STATE] = true;
  754. set = function (it, metadata) {
  755. if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  756. metadata.facade = it;
  757. createNonEnumerableProperty(it, STATE, metadata);
  758. return metadata;
  759. };
  760. get = function (it) {
  761. return hasOwn(it, STATE) ? it[STATE] : {};
  762. };
  763. has = function (it) {
  764. return hasOwn(it, STATE);
  765. };
  766. }
  767. module.exports = {
  768. set: set,
  769. get: get,
  770. has: has,
  771. enforce: enforce,
  772. getterFor: getterFor
  773. };
  774. /***/ }),
  775. /***/ 4209:
  776. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  777. var wellKnownSymbol = __webpack_require__(8227);
  778. var Iterators = __webpack_require__(6269);
  779. var ITERATOR = wellKnownSymbol('iterator');
  780. var ArrayPrototype = Array.prototype;
  781. // check on default Array iterator
  782. module.exports = function (it) {
  783. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  784. };
  785. /***/ }),
  786. /***/ 4376:
  787. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  788. var classof = __webpack_require__(2195);
  789. // `IsArray` abstract operation
  790. // https://tc39.es/ecma262/#sec-isarray
  791. // eslint-disable-next-line es/no-array-isarray -- safe
  792. module.exports = Array.isArray || function isArray(argument) {
  793. return classof(argument) === 'Array';
  794. };
  795. /***/ }),
  796. /***/ 4901:
  797. /***/ ((module) => {
  798. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
  799. var documentAll = typeof document == 'object' && document.all;
  800. // `IsCallable` abstract operation
  801. // https://tc39.es/ecma262/#sec-iscallable
  802. // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
  803. module.exports = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
  804. return typeof argument == 'function' || argument === documentAll;
  805. } : function (argument) {
  806. return typeof argument == 'function';
  807. };
  808. /***/ }),
  809. /***/ 2796:
  810. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  811. var fails = __webpack_require__(9039);
  812. var isCallable = __webpack_require__(4901);
  813. var replacement = /#|\.prototype\./;
  814. var isForced = function (feature, detection) {
  815. var value = data[normalize(feature)];
  816. return value === POLYFILL ? true
  817. : value === NATIVE ? false
  818. : isCallable(detection) ? fails(detection)
  819. : !!detection;
  820. };
  821. var normalize = isForced.normalize = function (string) {
  822. return String(string).replace(replacement, '.').toLowerCase();
  823. };
  824. var data = isForced.data = {};
  825. var NATIVE = isForced.NATIVE = 'N';
  826. var POLYFILL = isForced.POLYFILL = 'P';
  827. module.exports = isForced;
  828. /***/ }),
  829. /***/ 4117:
  830. /***/ ((module) => {
  831. // we can't use just `it == null` since of `document.all` special case
  832. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
  833. module.exports = function (it) {
  834. return it === null || it === undefined;
  835. };
  836. /***/ }),
  837. /***/ 34:
  838. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  839. var isCallable = __webpack_require__(4901);
  840. module.exports = function (it) {
  841. return typeof it == 'object' ? it !== null : isCallable(it);
  842. };
  843. /***/ }),
  844. /***/ 6395:
  845. /***/ ((module) => {
  846. module.exports = false;
  847. /***/ }),
  848. /***/ 757:
  849. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  850. var getBuiltIn = __webpack_require__(7751);
  851. var isCallable = __webpack_require__(4901);
  852. var isPrototypeOf = __webpack_require__(1625);
  853. var USE_SYMBOL_AS_UID = __webpack_require__(7040);
  854. var $Object = Object;
  855. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  856. return typeof it == 'symbol';
  857. } : function (it) {
  858. var $Symbol = getBuiltIn('Symbol');
  859. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  860. };
  861. /***/ }),
  862. /***/ 507:
  863. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  864. var call = __webpack_require__(9565);
  865. module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {
  866. var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;
  867. var next = record.next;
  868. var step, result;
  869. while (!(step = call(next, iterator)).done) {
  870. result = fn(step.value);
  871. if (result !== undefined) return result;
  872. }
  873. };
  874. /***/ }),
  875. /***/ 2652:
  876. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  877. var bind = __webpack_require__(6080);
  878. var call = __webpack_require__(9565);
  879. var anObject = __webpack_require__(8551);
  880. var tryToString = __webpack_require__(6823);
  881. var isArrayIteratorMethod = __webpack_require__(4209);
  882. var lengthOfArrayLike = __webpack_require__(6198);
  883. var isPrototypeOf = __webpack_require__(1625);
  884. var getIterator = __webpack_require__(81);
  885. var getIteratorMethod = __webpack_require__(851);
  886. var iteratorClose = __webpack_require__(9539);
  887. var $TypeError = TypeError;
  888. var Result = function (stopped, result) {
  889. this.stopped = stopped;
  890. this.result = result;
  891. };
  892. var ResultPrototype = Result.prototype;
  893. module.exports = function (iterable, unboundFunction, options) {
  894. var that = options && options.that;
  895. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  896. var IS_RECORD = !!(options && options.IS_RECORD);
  897. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  898. var INTERRUPTED = !!(options && options.INTERRUPTED);
  899. var fn = bind(unboundFunction, that);
  900. var iterator, iterFn, index, length, result, next, step;
  901. var stop = function (condition) {
  902. if (iterator) iteratorClose(iterator, 'normal', condition);
  903. return new Result(true, condition);
  904. };
  905. var callFn = function (value) {
  906. if (AS_ENTRIES) {
  907. anObject(value);
  908. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  909. } return INTERRUPTED ? fn(value, stop) : fn(value);
  910. };
  911. if (IS_RECORD) {
  912. iterator = iterable.iterator;
  913. } else if (IS_ITERATOR) {
  914. iterator = iterable;
  915. } else {
  916. iterFn = getIteratorMethod(iterable);
  917. if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable');
  918. // optimisation for array iterators
  919. if (isArrayIteratorMethod(iterFn)) {
  920. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  921. result = callFn(iterable[index]);
  922. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  923. } return new Result(false);
  924. }
  925. iterator = getIterator(iterable, iterFn);
  926. }
  927. next = IS_RECORD ? iterable.next : iterator.next;
  928. while (!(step = call(next, iterator)).done) {
  929. try {
  930. result = callFn(step.value);
  931. } catch (error) {
  932. iteratorClose(iterator, 'throw', error);
  933. }
  934. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  935. } return new Result(false);
  936. };
  937. /***/ }),
  938. /***/ 9539:
  939. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  940. var call = __webpack_require__(9565);
  941. var anObject = __webpack_require__(8551);
  942. var getMethod = __webpack_require__(5966);
  943. module.exports = function (iterator, kind, value) {
  944. var innerResult, innerError;
  945. anObject(iterator);
  946. try {
  947. innerResult = getMethod(iterator, 'return');
  948. if (!innerResult) {
  949. if (kind === 'throw') throw value;
  950. return value;
  951. }
  952. innerResult = call(innerResult, iterator);
  953. } catch (error) {
  954. innerError = true;
  955. innerResult = error;
  956. }
  957. if (kind === 'throw') throw value;
  958. if (innerError) throw innerResult;
  959. anObject(innerResult);
  960. return value;
  961. };
  962. /***/ }),
  963. /***/ 9462:
  964. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  965. var call = __webpack_require__(9565);
  966. var create = __webpack_require__(2360);
  967. var createNonEnumerableProperty = __webpack_require__(6699);
  968. var defineBuiltIns = __webpack_require__(6279);
  969. var wellKnownSymbol = __webpack_require__(8227);
  970. var InternalStateModule = __webpack_require__(1181);
  971. var getMethod = __webpack_require__(5966);
  972. var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype);
  973. var createIterResultObject = __webpack_require__(2529);
  974. var iteratorClose = __webpack_require__(9539);
  975. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  976. var ITERATOR_HELPER = 'IteratorHelper';
  977. var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator';
  978. var setInternalState = InternalStateModule.set;
  979. var createIteratorProxyPrototype = function (IS_ITERATOR) {
  980. var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER);
  981. return defineBuiltIns(create(IteratorPrototype), {
  982. next: function next() {
  983. var state = getInternalState(this);
  984. // for simplification:
  985. // for `%WrapForValidIteratorPrototype%.next` our `nextHandler` returns `IterResultObject`
  986. // for `%IteratorHelperPrototype%.next` - just a value
  987. if (IS_ITERATOR) return state.nextHandler();
  988. try {
  989. var result = state.done ? undefined : state.nextHandler();
  990. return createIterResultObject(result, state.done);
  991. } catch (error) {
  992. state.done = true;
  993. throw error;
  994. }
  995. },
  996. 'return': function () {
  997. var state = getInternalState(this);
  998. var iterator = state.iterator;
  999. state.done = true;
  1000. if (IS_ITERATOR) {
  1001. var returnMethod = getMethod(iterator, 'return');
  1002. return returnMethod ? call(returnMethod, iterator) : createIterResultObject(undefined, true);
  1003. }
  1004. if (state.inner) try {
  1005. iteratorClose(state.inner.iterator, 'normal');
  1006. } catch (error) {
  1007. return iteratorClose(iterator, 'throw', error);
  1008. }
  1009. iteratorClose(iterator, 'normal');
  1010. return createIterResultObject(undefined, true);
  1011. }
  1012. });
  1013. };
  1014. var WrapForValidIteratorPrototype = createIteratorProxyPrototype(true);
  1015. var IteratorHelperPrototype = createIteratorProxyPrototype(false);
  1016. createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG, 'Iterator Helper');
  1017. module.exports = function (nextHandler, IS_ITERATOR) {
  1018. var IteratorProxy = function Iterator(record, state) {
  1019. if (state) {
  1020. state.iterator = record.iterator;
  1021. state.next = record.next;
  1022. } else state = record;
  1023. state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER;
  1024. state.nextHandler = nextHandler;
  1025. state.counter = 0;
  1026. state.done = false;
  1027. setInternalState(this, state);
  1028. };
  1029. IteratorProxy.prototype = IS_ITERATOR ? WrapForValidIteratorPrototype : IteratorHelperPrototype;
  1030. return IteratorProxy;
  1031. };
  1032. /***/ }),
  1033. /***/ 713:
  1034. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1035. var call = __webpack_require__(9565);
  1036. var aCallable = __webpack_require__(9306);
  1037. var anObject = __webpack_require__(8551);
  1038. var getIteratorDirect = __webpack_require__(1767);
  1039. var createIteratorProxy = __webpack_require__(9462);
  1040. var callWithSafeIterationClosing = __webpack_require__(6319);
  1041. var IteratorProxy = createIteratorProxy(function () {
  1042. var iterator = this.iterator;
  1043. var result = anObject(call(this.next, iterator));
  1044. var done = this.done = !!result.done;
  1045. if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
  1046. });
  1047. // `Iterator.prototype.map` method
  1048. // https://github.com/tc39/proposal-iterator-helpers
  1049. module.exports = function map(mapper) {
  1050. anObject(this);
  1051. aCallable(mapper);
  1052. return new IteratorProxy(getIteratorDirect(this), {
  1053. mapper: mapper
  1054. });
  1055. };
  1056. /***/ }),
  1057. /***/ 7657:
  1058. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1059. var fails = __webpack_require__(9039);
  1060. var isCallable = __webpack_require__(4901);
  1061. var isObject = __webpack_require__(34);
  1062. var create = __webpack_require__(2360);
  1063. var getPrototypeOf = __webpack_require__(2787);
  1064. var defineBuiltIn = __webpack_require__(6840);
  1065. var wellKnownSymbol = __webpack_require__(8227);
  1066. var IS_PURE = __webpack_require__(6395);
  1067. var ITERATOR = wellKnownSymbol('iterator');
  1068. var BUGGY_SAFARI_ITERATORS = false;
  1069. // `%IteratorPrototype%` object
  1070. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  1071. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  1072. /* eslint-disable es/no-array-prototype-keys -- safe */
  1073. if ([].keys) {
  1074. arrayIterator = [].keys();
  1075. // Safari 8 has buggy iterators w/o `next`
  1076. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  1077. else {
  1078. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  1079. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  1080. }
  1081. }
  1082. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  1083. var test = {};
  1084. // FF44- legacy iterators case
  1085. return IteratorPrototype[ITERATOR].call(test) !== test;
  1086. });
  1087. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  1088. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  1089. // `%IteratorPrototype%[@@iterator]()` method
  1090. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  1091. if (!isCallable(IteratorPrototype[ITERATOR])) {
  1092. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  1093. return this;
  1094. });
  1095. }
  1096. module.exports = {
  1097. IteratorPrototype: IteratorPrototype,
  1098. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  1099. };
  1100. /***/ }),
  1101. /***/ 6269:
  1102. /***/ ((module) => {
  1103. module.exports = {};
  1104. /***/ }),
  1105. /***/ 6198:
  1106. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1107. var toLength = __webpack_require__(8014);
  1108. // `LengthOfArrayLike` abstract operation
  1109. // https://tc39.es/ecma262/#sec-lengthofarraylike
  1110. module.exports = function (obj) {
  1111. return toLength(obj.length);
  1112. };
  1113. /***/ }),
  1114. /***/ 283:
  1115. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1116. var uncurryThis = __webpack_require__(9504);
  1117. var fails = __webpack_require__(9039);
  1118. var isCallable = __webpack_require__(4901);
  1119. var hasOwn = __webpack_require__(9297);
  1120. var DESCRIPTORS = __webpack_require__(3724);
  1121. var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(350).CONFIGURABLE);
  1122. var inspectSource = __webpack_require__(3706);
  1123. var InternalStateModule = __webpack_require__(1181);
  1124. var enforceInternalState = InternalStateModule.enforce;
  1125. var getInternalState = InternalStateModule.get;
  1126. var $String = String;
  1127. // eslint-disable-next-line es/no-object-defineproperty -- safe
  1128. var defineProperty = Object.defineProperty;
  1129. var stringSlice = uncurryThis(''.slice);
  1130. var replace = uncurryThis(''.replace);
  1131. var join = uncurryThis([].join);
  1132. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  1133. return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
  1134. });
  1135. var TEMPLATE = String(String).split('String');
  1136. var makeBuiltIn = module.exports = function (value, name, options) {
  1137. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  1138. name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
  1139. }
  1140. if (options && options.getter) name = 'get ' + name;
  1141. if (options && options.setter) name = 'set ' + name;
  1142. if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
  1143. if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true });
  1144. else value.name = name;
  1145. }
  1146. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  1147. defineProperty(value, 'length', { value: options.arity });
  1148. }
  1149. try {
  1150. if (options && hasOwn(options, 'constructor') && options.constructor) {
  1151. if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false });
  1152. // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
  1153. } else if (value.prototype) value.prototype = undefined;
  1154. } catch (error) { /* empty */ }
  1155. var state = enforceInternalState(value);
  1156. if (!hasOwn(state, 'source')) {
  1157. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  1158. } return value;
  1159. };
  1160. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  1161. // eslint-disable-next-line no-extend-native -- required
  1162. Function.prototype.toString = makeBuiltIn(function toString() {
  1163. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1164. }, 'toString');
  1165. /***/ }),
  1166. /***/ 741:
  1167. /***/ ((module) => {
  1168. var ceil = Math.ceil;
  1169. var floor = Math.floor;
  1170. // `Math.trunc` method
  1171. // https://tc39.es/ecma262/#sec-math.trunc
  1172. // eslint-disable-next-line es/no-math-trunc -- safe
  1173. module.exports = Math.trunc || function trunc(x) {
  1174. var n = +x;
  1175. return (n > 0 ? floor : ceil)(n);
  1176. };
  1177. /***/ }),
  1178. /***/ 6043:
  1179. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1180. var aCallable = __webpack_require__(9306);
  1181. var $TypeError = TypeError;
  1182. var PromiseCapability = function (C) {
  1183. var resolve, reject;
  1184. this.promise = new C(function ($$resolve, $$reject) {
  1185. if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor');
  1186. resolve = $$resolve;
  1187. reject = $$reject;
  1188. });
  1189. this.resolve = aCallable(resolve);
  1190. this.reject = aCallable(reject);
  1191. };
  1192. // `NewPromiseCapability` abstract operation
  1193. // https://tc39.es/ecma262/#sec-newpromisecapability
  1194. module.exports.f = function (C) {
  1195. return new PromiseCapability(C);
  1196. };
  1197. /***/ }),
  1198. /***/ 2360:
  1199. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1200. /* global ActiveXObject -- old IE, WSH */
  1201. var anObject = __webpack_require__(8551);
  1202. var definePropertiesModule = __webpack_require__(6801);
  1203. var enumBugKeys = __webpack_require__(8727);
  1204. var hiddenKeys = __webpack_require__(421);
  1205. var html = __webpack_require__(397);
  1206. var documentCreateElement = __webpack_require__(4055);
  1207. var sharedKey = __webpack_require__(6119);
  1208. var GT = '>';
  1209. var LT = '<';
  1210. var PROTOTYPE = 'prototype';
  1211. var SCRIPT = 'script';
  1212. var IE_PROTO = sharedKey('IE_PROTO');
  1213. var EmptyConstructor = function () { /* empty */ };
  1214. var scriptTag = function (content) {
  1215. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  1216. };
  1217. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  1218. var NullProtoObjectViaActiveX = function (activeXDocument) {
  1219. activeXDocument.write(scriptTag(''));
  1220. activeXDocument.close();
  1221. var temp = activeXDocument.parentWindow.Object;
  1222. // eslint-disable-next-line no-useless-assignment -- avoid memory leak
  1223. activeXDocument = null;
  1224. return temp;
  1225. };
  1226. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  1227. var NullProtoObjectViaIFrame = function () {
  1228. // Thrash, waste and sodomy: IE GC bug
  1229. var iframe = documentCreateElement('iframe');
  1230. var JS = 'java' + SCRIPT + ':';
  1231. var iframeDocument;
  1232. iframe.style.display = 'none';
  1233. html.appendChild(iframe);
  1234. // https://github.com/zloirock/core-js/issues/475
  1235. iframe.src = String(JS);
  1236. iframeDocument = iframe.contentWindow.document;
  1237. iframeDocument.open();
  1238. iframeDocument.write(scriptTag('document.F=Object'));
  1239. iframeDocument.close();
  1240. return iframeDocument.F;
  1241. };
  1242. // Check for document.domain and active x support
  1243. // No need to use active x approach when document.domain is not set
  1244. // see https://github.com/es-shims/es5-shim/issues/150
  1245. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  1246. // avoid IE GC bug
  1247. var activeXDocument;
  1248. var NullProtoObject = function () {
  1249. try {
  1250. activeXDocument = new ActiveXObject('htmlfile');
  1251. } catch (error) { /* ignore */ }
  1252. NullProtoObject = typeof document != 'undefined'
  1253. ? document.domain && activeXDocument
  1254. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  1255. : NullProtoObjectViaIFrame()
  1256. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  1257. var length = enumBugKeys.length;
  1258. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  1259. return NullProtoObject();
  1260. };
  1261. hiddenKeys[IE_PROTO] = true;
  1262. // `Object.create` method
  1263. // https://tc39.es/ecma262/#sec-object.create
  1264. // eslint-disable-next-line es/no-object-create -- safe
  1265. module.exports = Object.create || function create(O, Properties) {
  1266. var result;
  1267. if (O !== null) {
  1268. EmptyConstructor[PROTOTYPE] = anObject(O);
  1269. result = new EmptyConstructor();
  1270. EmptyConstructor[PROTOTYPE] = null;
  1271. // add "__proto__" for Object.getPrototypeOf polyfill
  1272. result[IE_PROTO] = O;
  1273. } else result = NullProtoObject();
  1274. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  1275. };
  1276. /***/ }),
  1277. /***/ 6801:
  1278. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1279. var DESCRIPTORS = __webpack_require__(3724);
  1280. var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686);
  1281. var definePropertyModule = __webpack_require__(4913);
  1282. var anObject = __webpack_require__(8551);
  1283. var toIndexedObject = __webpack_require__(5397);
  1284. var objectKeys = __webpack_require__(1072);
  1285. // `Object.defineProperties` method
  1286. // https://tc39.es/ecma262/#sec-object.defineproperties
  1287. // eslint-disable-next-line es/no-object-defineproperties -- safe
  1288. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  1289. anObject(O);
  1290. var props = toIndexedObject(Properties);
  1291. var keys = objectKeys(Properties);
  1292. var length = keys.length;
  1293. var index = 0;
  1294. var key;
  1295. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  1296. return O;
  1297. };
  1298. /***/ }),
  1299. /***/ 4913:
  1300. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1301. var DESCRIPTORS = __webpack_require__(3724);
  1302. var IE8_DOM_DEFINE = __webpack_require__(5917);
  1303. var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(8686);
  1304. var anObject = __webpack_require__(8551);
  1305. var toPropertyKey = __webpack_require__(6969);
  1306. var $TypeError = TypeError;
  1307. // eslint-disable-next-line es/no-object-defineproperty -- safe
  1308. var $defineProperty = Object.defineProperty;
  1309. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  1310. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1311. var ENUMERABLE = 'enumerable';
  1312. var CONFIGURABLE = 'configurable';
  1313. var WRITABLE = 'writable';
  1314. // `Object.defineProperty` method
  1315. // https://tc39.es/ecma262/#sec-object.defineproperty
  1316. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  1317. anObject(O);
  1318. P = toPropertyKey(P);
  1319. anObject(Attributes);
  1320. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  1321. var current = $getOwnPropertyDescriptor(O, P);
  1322. if (current && current[WRITABLE]) {
  1323. O[P] = Attributes.value;
  1324. Attributes = {
  1325. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  1326. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  1327. writable: false
  1328. };
  1329. }
  1330. } return $defineProperty(O, P, Attributes);
  1331. } : $defineProperty : function defineProperty(O, P, Attributes) {
  1332. anObject(O);
  1333. P = toPropertyKey(P);
  1334. anObject(Attributes);
  1335. if (IE8_DOM_DEFINE) try {
  1336. return $defineProperty(O, P, Attributes);
  1337. } catch (error) { /* empty */ }
  1338. if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported');
  1339. if ('value' in Attributes) O[P] = Attributes.value;
  1340. return O;
  1341. };
  1342. /***/ }),
  1343. /***/ 7347:
  1344. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1345. var DESCRIPTORS = __webpack_require__(3724);
  1346. var call = __webpack_require__(9565);
  1347. var propertyIsEnumerableModule = __webpack_require__(8773);
  1348. var createPropertyDescriptor = __webpack_require__(6980);
  1349. var toIndexedObject = __webpack_require__(5397);
  1350. var toPropertyKey = __webpack_require__(6969);
  1351. var hasOwn = __webpack_require__(9297);
  1352. var IE8_DOM_DEFINE = __webpack_require__(5917);
  1353. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  1354. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1355. // `Object.getOwnPropertyDescriptor` method
  1356. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  1357. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  1358. O = toIndexedObject(O);
  1359. P = toPropertyKey(P);
  1360. if (IE8_DOM_DEFINE) try {
  1361. return $getOwnPropertyDescriptor(O, P);
  1362. } catch (error) { /* empty */ }
  1363. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  1364. };
  1365. /***/ }),
  1366. /***/ 8480:
  1367. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1368. var internalObjectKeys = __webpack_require__(1828);
  1369. var enumBugKeys = __webpack_require__(8727);
  1370. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1371. // `Object.getOwnPropertyNames` method
  1372. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  1373. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  1374. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1375. return internalObjectKeys(O, hiddenKeys);
  1376. };
  1377. /***/ }),
  1378. /***/ 3717:
  1379. /***/ ((__unused_webpack_module, exports) => {
  1380. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  1381. exports.f = Object.getOwnPropertySymbols;
  1382. /***/ }),
  1383. /***/ 2787:
  1384. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1385. var hasOwn = __webpack_require__(9297);
  1386. var isCallable = __webpack_require__(4901);
  1387. var toObject = __webpack_require__(8981);
  1388. var sharedKey = __webpack_require__(6119);
  1389. var CORRECT_PROTOTYPE_GETTER = __webpack_require__(2211);
  1390. var IE_PROTO = sharedKey('IE_PROTO');
  1391. var $Object = Object;
  1392. var ObjectPrototype = $Object.prototype;
  1393. // `Object.getPrototypeOf` method
  1394. // https://tc39.es/ecma262/#sec-object.getprototypeof
  1395. // eslint-disable-next-line es/no-object-getprototypeof -- safe
  1396. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  1397. var object = toObject(O);
  1398. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  1399. var constructor = object.constructor;
  1400. if (isCallable(constructor) && object instanceof constructor) {
  1401. return constructor.prototype;
  1402. } return object instanceof $Object ? ObjectPrototype : null;
  1403. };
  1404. /***/ }),
  1405. /***/ 1625:
  1406. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1407. var uncurryThis = __webpack_require__(9504);
  1408. module.exports = uncurryThis({}.isPrototypeOf);
  1409. /***/ }),
  1410. /***/ 1828:
  1411. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1412. var uncurryThis = __webpack_require__(9504);
  1413. var hasOwn = __webpack_require__(9297);
  1414. var toIndexedObject = __webpack_require__(5397);
  1415. var indexOf = (__webpack_require__(9617).indexOf);
  1416. var hiddenKeys = __webpack_require__(421);
  1417. var push = uncurryThis([].push);
  1418. module.exports = function (object, names) {
  1419. var O = toIndexedObject(object);
  1420. var i = 0;
  1421. var result = [];
  1422. var key;
  1423. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1424. // Don't enum bug & hidden keys
  1425. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  1426. ~indexOf(result, key) || push(result, key);
  1427. }
  1428. return result;
  1429. };
  1430. /***/ }),
  1431. /***/ 1072:
  1432. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1433. var internalObjectKeys = __webpack_require__(1828);
  1434. var enumBugKeys = __webpack_require__(8727);
  1435. // `Object.keys` method
  1436. // https://tc39.es/ecma262/#sec-object.keys
  1437. // eslint-disable-next-line es/no-object-keys -- safe
  1438. module.exports = Object.keys || function keys(O) {
  1439. return internalObjectKeys(O, enumBugKeys);
  1440. };
  1441. /***/ }),
  1442. /***/ 8773:
  1443. /***/ ((__unused_webpack_module, exports) => {
  1444. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  1445. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  1446. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1447. // Nashorn ~ JDK8 bug
  1448. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  1449. // `Object.prototype.propertyIsEnumerable` method implementation
  1450. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  1451. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  1452. var descriptor = getOwnPropertyDescriptor(this, V);
  1453. return !!descriptor && descriptor.enumerable;
  1454. } : $propertyIsEnumerable;
  1455. /***/ }),
  1456. /***/ 4270:
  1457. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1458. var call = __webpack_require__(9565);
  1459. var isCallable = __webpack_require__(4901);
  1460. var isObject = __webpack_require__(34);
  1461. var $TypeError = TypeError;
  1462. // `OrdinaryToPrimitive` abstract operation
  1463. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  1464. module.exports = function (input, pref) {
  1465. var fn, val;
  1466. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  1467. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  1468. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  1469. throw new $TypeError("Can't convert object to primitive value");
  1470. };
  1471. /***/ }),
  1472. /***/ 5031:
  1473. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1474. var getBuiltIn = __webpack_require__(7751);
  1475. var uncurryThis = __webpack_require__(9504);
  1476. var getOwnPropertyNamesModule = __webpack_require__(8480);
  1477. var getOwnPropertySymbolsModule = __webpack_require__(3717);
  1478. var anObject = __webpack_require__(8551);
  1479. var concat = uncurryThis([].concat);
  1480. // all object keys, includes non-enumerable and symbols
  1481. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1482. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1483. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1484. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1485. };
  1486. /***/ }),
  1487. /***/ 8235:
  1488. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1489. var uncurryThis = __webpack_require__(9504);
  1490. var hasOwn = __webpack_require__(9297);
  1491. var $SyntaxError = SyntaxError;
  1492. var $parseInt = parseInt;
  1493. var fromCharCode = String.fromCharCode;
  1494. var at = uncurryThis(''.charAt);
  1495. var slice = uncurryThis(''.slice);
  1496. var exec = uncurryThis(/./.exec);
  1497. var codePoints = {
  1498. '\\"': '"',
  1499. '\\\\': '\\',
  1500. '\\/': '/',
  1501. '\\b': '\b',
  1502. '\\f': '\f',
  1503. '\\n': '\n',
  1504. '\\r': '\r',
  1505. '\\t': '\t'
  1506. };
  1507. var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i;
  1508. // eslint-disable-next-line regexp/no-control-character -- safe
  1509. var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/;
  1510. module.exports = function (source, i) {
  1511. var unterminated = true;
  1512. var value = '';
  1513. while (i < source.length) {
  1514. var chr = at(source, i);
  1515. if (chr === '\\') {
  1516. var twoChars = slice(source, i, i + 2);
  1517. if (hasOwn(codePoints, twoChars)) {
  1518. value += codePoints[twoChars];
  1519. i += 2;
  1520. } else if (twoChars === '\\u') {
  1521. i += 2;
  1522. var fourHexDigits = slice(source, i, i + 4);
  1523. if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw new $SyntaxError('Bad Unicode escape at: ' + i);
  1524. value += fromCharCode($parseInt(fourHexDigits, 16));
  1525. i += 4;
  1526. } else throw new $SyntaxError('Unknown escape sequence: "' + twoChars + '"');
  1527. } else if (chr === '"') {
  1528. unterminated = false;
  1529. i++;
  1530. break;
  1531. } else {
  1532. if (exec(IS_C0_CONTROL_CODE, chr)) throw new $SyntaxError('Bad control character in string literal at: ' + i);
  1533. value += chr;
  1534. i++;
  1535. }
  1536. }
  1537. if (unterminated) throw new $SyntaxError('Unterminated string at: ' + i);
  1538. return { value: value, end: i };
  1539. };
  1540. /***/ }),
  1541. /***/ 7750:
  1542. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1543. var isNullOrUndefined = __webpack_require__(4117);
  1544. var $TypeError = TypeError;
  1545. // `RequireObjectCoercible` abstract operation
  1546. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  1547. module.exports = function (it) {
  1548. if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it);
  1549. return it;
  1550. };
  1551. /***/ }),
  1552. /***/ 9286:
  1553. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1554. var SetHelpers = __webpack_require__(4402);
  1555. var iterate = __webpack_require__(8469);
  1556. var Set = SetHelpers.Set;
  1557. var add = SetHelpers.add;
  1558. module.exports = function (set) {
  1559. var result = new Set();
  1560. iterate(set, function (it) {
  1561. add(result, it);
  1562. });
  1563. return result;
  1564. };
  1565. /***/ }),
  1566. /***/ 3440:
  1567. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1568. var aSet = __webpack_require__(7080);
  1569. var SetHelpers = __webpack_require__(4402);
  1570. var clone = __webpack_require__(9286);
  1571. var size = __webpack_require__(5170);
  1572. var getSetRecord = __webpack_require__(3789);
  1573. var iterateSet = __webpack_require__(8469);
  1574. var iterateSimple = __webpack_require__(507);
  1575. var has = SetHelpers.has;
  1576. var remove = SetHelpers.remove;
  1577. // `Set.prototype.difference` method
  1578. // https://github.com/tc39/proposal-set-methods
  1579. module.exports = function difference(other) {
  1580. var O = aSet(this);
  1581. var otherRec = getSetRecord(other);
  1582. var result = clone(O);
  1583. if (size(O) <= otherRec.size) iterateSet(O, function (e) {
  1584. if (otherRec.includes(e)) remove(result, e);
  1585. });
  1586. else iterateSimple(otherRec.getIterator(), function (e) {
  1587. if (has(O, e)) remove(result, e);
  1588. });
  1589. return result;
  1590. };
  1591. /***/ }),
  1592. /***/ 4402:
  1593. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1594. var uncurryThis = __webpack_require__(9504);
  1595. // eslint-disable-next-line es/no-set -- safe
  1596. var SetPrototype = Set.prototype;
  1597. module.exports = {
  1598. // eslint-disable-next-line es/no-set -- safe
  1599. Set: Set,
  1600. add: uncurryThis(SetPrototype.add),
  1601. has: uncurryThis(SetPrototype.has),
  1602. remove: uncurryThis(SetPrototype['delete']),
  1603. proto: SetPrototype
  1604. };
  1605. /***/ }),
  1606. /***/ 8750:
  1607. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1608. var aSet = __webpack_require__(7080);
  1609. var SetHelpers = __webpack_require__(4402);
  1610. var size = __webpack_require__(5170);
  1611. var getSetRecord = __webpack_require__(3789);
  1612. var iterateSet = __webpack_require__(8469);
  1613. var iterateSimple = __webpack_require__(507);
  1614. var Set = SetHelpers.Set;
  1615. var add = SetHelpers.add;
  1616. var has = SetHelpers.has;
  1617. // `Set.prototype.intersection` method
  1618. // https://github.com/tc39/proposal-set-methods
  1619. module.exports = function intersection(other) {
  1620. var O = aSet(this);
  1621. var otherRec = getSetRecord(other);
  1622. var result = new Set();
  1623. if (size(O) > otherRec.size) {
  1624. iterateSimple(otherRec.getIterator(), function (e) {
  1625. if (has(O, e)) add(result, e);
  1626. });
  1627. } else {
  1628. iterateSet(O, function (e) {
  1629. if (otherRec.includes(e)) add(result, e);
  1630. });
  1631. }
  1632. return result;
  1633. };
  1634. /***/ }),
  1635. /***/ 4449:
  1636. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1637. var aSet = __webpack_require__(7080);
  1638. var has = (__webpack_require__(4402).has);
  1639. var size = __webpack_require__(5170);
  1640. var getSetRecord = __webpack_require__(3789);
  1641. var iterateSet = __webpack_require__(8469);
  1642. var iterateSimple = __webpack_require__(507);
  1643. var iteratorClose = __webpack_require__(9539);
  1644. // `Set.prototype.isDisjointFrom` method
  1645. // https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom
  1646. module.exports = function isDisjointFrom(other) {
  1647. var O = aSet(this);
  1648. var otherRec = getSetRecord(other);
  1649. if (size(O) <= otherRec.size) return iterateSet(O, function (e) {
  1650. if (otherRec.includes(e)) return false;
  1651. }, true) !== false;
  1652. var iterator = otherRec.getIterator();
  1653. return iterateSimple(iterator, function (e) {
  1654. if (has(O, e)) return iteratorClose(iterator, 'normal', false);
  1655. }) !== false;
  1656. };
  1657. /***/ }),
  1658. /***/ 3838:
  1659. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1660. var aSet = __webpack_require__(7080);
  1661. var size = __webpack_require__(5170);
  1662. var iterate = __webpack_require__(8469);
  1663. var getSetRecord = __webpack_require__(3789);
  1664. // `Set.prototype.isSubsetOf` method
  1665. // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf
  1666. module.exports = function isSubsetOf(other) {
  1667. var O = aSet(this);
  1668. var otherRec = getSetRecord(other);
  1669. if (size(O) > otherRec.size) return false;
  1670. return iterate(O, function (e) {
  1671. if (!otherRec.includes(e)) return false;
  1672. }, true) !== false;
  1673. };
  1674. /***/ }),
  1675. /***/ 8527:
  1676. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1677. var aSet = __webpack_require__(7080);
  1678. var has = (__webpack_require__(4402).has);
  1679. var size = __webpack_require__(5170);
  1680. var getSetRecord = __webpack_require__(3789);
  1681. var iterateSimple = __webpack_require__(507);
  1682. var iteratorClose = __webpack_require__(9539);
  1683. // `Set.prototype.isSupersetOf` method
  1684. // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf
  1685. module.exports = function isSupersetOf(other) {
  1686. var O = aSet(this);
  1687. var otherRec = getSetRecord(other);
  1688. if (size(O) < otherRec.size) return false;
  1689. var iterator = otherRec.getIterator();
  1690. return iterateSimple(iterator, function (e) {
  1691. if (!has(O, e)) return iteratorClose(iterator, 'normal', false);
  1692. }) !== false;
  1693. };
  1694. /***/ }),
  1695. /***/ 8469:
  1696. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1697. var uncurryThis = __webpack_require__(9504);
  1698. var iterateSimple = __webpack_require__(507);
  1699. var SetHelpers = __webpack_require__(4402);
  1700. var Set = SetHelpers.Set;
  1701. var SetPrototype = SetHelpers.proto;
  1702. var forEach = uncurryThis(SetPrototype.forEach);
  1703. var keys = uncurryThis(SetPrototype.keys);
  1704. var next = keys(new Set()).next;
  1705. module.exports = function (set, fn, interruptible) {
  1706. return interruptible ? iterateSimple({ iterator: keys(set), next: next }, fn) : forEach(set, fn);
  1707. };
  1708. /***/ }),
  1709. /***/ 4916:
  1710. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1711. var getBuiltIn = __webpack_require__(7751);
  1712. var createSetLike = function (size) {
  1713. return {
  1714. size: size,
  1715. has: function () {
  1716. return false;
  1717. },
  1718. keys: function () {
  1719. return {
  1720. next: function () {
  1721. return { done: true };
  1722. }
  1723. };
  1724. }
  1725. };
  1726. };
  1727. module.exports = function (name) {
  1728. var Set = getBuiltIn('Set');
  1729. try {
  1730. new Set()[name](createSetLike(0));
  1731. try {
  1732. // late spec change, early WebKit ~ Safari 17.0 beta implementation does not pass it
  1733. // https://github.com/tc39/proposal-set-methods/pull/88
  1734. new Set()[name](createSetLike(-1));
  1735. return false;
  1736. } catch (error2) {
  1737. return true;
  1738. }
  1739. } catch (error) {
  1740. return false;
  1741. }
  1742. };
  1743. /***/ }),
  1744. /***/ 5170:
  1745. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1746. var uncurryThisAccessor = __webpack_require__(6706);
  1747. var SetHelpers = __webpack_require__(4402);
  1748. module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
  1749. return set.size;
  1750. };
  1751. /***/ }),
  1752. /***/ 3650:
  1753. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1754. var aSet = __webpack_require__(7080);
  1755. var SetHelpers = __webpack_require__(4402);
  1756. var clone = __webpack_require__(9286);
  1757. var getSetRecord = __webpack_require__(3789);
  1758. var iterateSimple = __webpack_require__(507);
  1759. var add = SetHelpers.add;
  1760. var has = SetHelpers.has;
  1761. var remove = SetHelpers.remove;
  1762. // `Set.prototype.symmetricDifference` method
  1763. // https://github.com/tc39/proposal-set-methods
  1764. module.exports = function symmetricDifference(other) {
  1765. var O = aSet(this);
  1766. var keysIter = getSetRecord(other).getIterator();
  1767. var result = clone(O);
  1768. iterateSimple(keysIter, function (e) {
  1769. if (has(O, e)) remove(result, e);
  1770. else add(result, e);
  1771. });
  1772. return result;
  1773. };
  1774. /***/ }),
  1775. /***/ 4204:
  1776. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1777. var aSet = __webpack_require__(7080);
  1778. var add = (__webpack_require__(4402).add);
  1779. var clone = __webpack_require__(9286);
  1780. var getSetRecord = __webpack_require__(3789);
  1781. var iterateSimple = __webpack_require__(507);
  1782. // `Set.prototype.union` method
  1783. // https://github.com/tc39/proposal-set-methods
  1784. module.exports = function union(other) {
  1785. var O = aSet(this);
  1786. var keysIter = getSetRecord(other).getIterator();
  1787. var result = clone(O);
  1788. iterateSimple(keysIter, function (it) {
  1789. add(result, it);
  1790. });
  1791. return result;
  1792. };
  1793. /***/ }),
  1794. /***/ 6119:
  1795. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1796. var shared = __webpack_require__(5745);
  1797. var uid = __webpack_require__(3392);
  1798. var keys = shared('keys');
  1799. module.exports = function (key) {
  1800. return keys[key] || (keys[key] = uid(key));
  1801. };
  1802. /***/ }),
  1803. /***/ 7629:
  1804. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1805. var IS_PURE = __webpack_require__(6395);
  1806. var globalThis = __webpack_require__(4576);
  1807. var defineGlobalProperty = __webpack_require__(9433);
  1808. var SHARED = '__core-js_shared__';
  1809. var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
  1810. (store.versions || (store.versions = [])).push({
  1811. version: '3.38.1',
  1812. mode: IS_PURE ? 'pure' : 'global',
  1813. copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
  1814. license: 'https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE',
  1815. source: 'https://github.com/zloirock/core-js'
  1816. });
  1817. /***/ }),
  1818. /***/ 5745:
  1819. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1820. var store = __webpack_require__(7629);
  1821. module.exports = function (key, value) {
  1822. return store[key] || (store[key] = value || {});
  1823. };
  1824. /***/ }),
  1825. /***/ 4495:
  1826. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1827. /* eslint-disable es/no-symbol -- required for testing */
  1828. var V8_VERSION = __webpack_require__(9519);
  1829. var fails = __webpack_require__(9039);
  1830. var globalThis = __webpack_require__(4576);
  1831. var $String = globalThis.String;
  1832. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  1833. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  1834. var symbol = Symbol('symbol detection');
  1835. // Chrome 38 Symbol has incorrect toString conversion
  1836. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  1837. // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
  1838. // of course, fail.
  1839. return !$String(symbol) || !(Object(symbol) instanceof Symbol) ||
  1840. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  1841. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  1842. });
  1843. /***/ }),
  1844. /***/ 5610:
  1845. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1846. var toIntegerOrInfinity = __webpack_require__(1291);
  1847. var max = Math.max;
  1848. var min = Math.min;
  1849. // Helper for a popular repeating case of the spec:
  1850. // Let integer be ? ToInteger(index).
  1851. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  1852. module.exports = function (index, length) {
  1853. var integer = toIntegerOrInfinity(index);
  1854. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1855. };
  1856. /***/ }),
  1857. /***/ 5397:
  1858. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1859. // toObject with fallback for non-array-like ES3 strings
  1860. var IndexedObject = __webpack_require__(7055);
  1861. var requireObjectCoercible = __webpack_require__(7750);
  1862. module.exports = function (it) {
  1863. return IndexedObject(requireObjectCoercible(it));
  1864. };
  1865. /***/ }),
  1866. /***/ 1291:
  1867. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1868. var trunc = __webpack_require__(741);
  1869. // `ToIntegerOrInfinity` abstract operation
  1870. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  1871. module.exports = function (argument) {
  1872. var number = +argument;
  1873. // eslint-disable-next-line no-self-compare -- NaN check
  1874. return number !== number || number === 0 ? 0 : trunc(number);
  1875. };
  1876. /***/ }),
  1877. /***/ 8014:
  1878. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1879. var toIntegerOrInfinity = __webpack_require__(1291);
  1880. var min = Math.min;
  1881. // `ToLength` abstract operation
  1882. // https://tc39.es/ecma262/#sec-tolength
  1883. module.exports = function (argument) {
  1884. var len = toIntegerOrInfinity(argument);
  1885. return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  1886. };
  1887. /***/ }),
  1888. /***/ 8981:
  1889. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1890. var requireObjectCoercible = __webpack_require__(7750);
  1891. var $Object = Object;
  1892. // `ToObject` abstract operation
  1893. // https://tc39.es/ecma262/#sec-toobject
  1894. module.exports = function (argument) {
  1895. return $Object(requireObjectCoercible(argument));
  1896. };
  1897. /***/ }),
  1898. /***/ 2777:
  1899. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1900. var call = __webpack_require__(9565);
  1901. var isObject = __webpack_require__(34);
  1902. var isSymbol = __webpack_require__(757);
  1903. var getMethod = __webpack_require__(5966);
  1904. var ordinaryToPrimitive = __webpack_require__(4270);
  1905. var wellKnownSymbol = __webpack_require__(8227);
  1906. var $TypeError = TypeError;
  1907. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  1908. // `ToPrimitive` abstract operation
  1909. // https://tc39.es/ecma262/#sec-toprimitive
  1910. module.exports = function (input, pref) {
  1911. if (!isObject(input) || isSymbol(input)) return input;
  1912. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  1913. var result;
  1914. if (exoticToPrim) {
  1915. if (pref === undefined) pref = 'default';
  1916. result = call(exoticToPrim, input, pref);
  1917. if (!isObject(result) || isSymbol(result)) return result;
  1918. throw new $TypeError("Can't convert object to primitive value");
  1919. }
  1920. if (pref === undefined) pref = 'number';
  1921. return ordinaryToPrimitive(input, pref);
  1922. };
  1923. /***/ }),
  1924. /***/ 6969:
  1925. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1926. var toPrimitive = __webpack_require__(2777);
  1927. var isSymbol = __webpack_require__(757);
  1928. // `ToPropertyKey` abstract operation
  1929. // https://tc39.es/ecma262/#sec-topropertykey
  1930. module.exports = function (argument) {
  1931. var key = toPrimitive(argument, 'string');
  1932. return isSymbol(key) ? key : key + '';
  1933. };
  1934. /***/ }),
  1935. /***/ 2140:
  1936. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1937. var wellKnownSymbol = __webpack_require__(8227);
  1938. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1939. var test = {};
  1940. test[TO_STRING_TAG] = 'z';
  1941. module.exports = String(test) === '[object z]';
  1942. /***/ }),
  1943. /***/ 655:
  1944. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1945. var classof = __webpack_require__(6955);
  1946. var $String = String;
  1947. module.exports = function (argument) {
  1948. if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
  1949. return $String(argument);
  1950. };
  1951. /***/ }),
  1952. /***/ 6823:
  1953. /***/ ((module) => {
  1954. var $String = String;
  1955. module.exports = function (argument) {
  1956. try {
  1957. return $String(argument);
  1958. } catch (error) {
  1959. return 'Object';
  1960. }
  1961. };
  1962. /***/ }),
  1963. /***/ 3392:
  1964. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1965. var uncurryThis = __webpack_require__(9504);
  1966. var id = 0;
  1967. var postfix = Math.random();
  1968. var toString = uncurryThis(1.0.toString);
  1969. module.exports = function (key) {
  1970. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  1971. };
  1972. /***/ }),
  1973. /***/ 7040:
  1974. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1975. /* eslint-disable es/no-symbol -- required for testing */
  1976. var NATIVE_SYMBOL = __webpack_require__(4495);
  1977. module.exports = NATIVE_SYMBOL
  1978. && !Symbol.sham
  1979. && typeof Symbol.iterator == 'symbol';
  1980. /***/ }),
  1981. /***/ 8686:
  1982. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1983. var DESCRIPTORS = __webpack_require__(3724);
  1984. var fails = __webpack_require__(9039);
  1985. // V8 ~ Chrome 36-
  1986. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  1987. module.exports = DESCRIPTORS && fails(function () {
  1988. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  1989. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  1990. value: 42,
  1991. writable: false
  1992. }).prototype !== 42;
  1993. });
  1994. /***/ }),
  1995. /***/ 2812:
  1996. /***/ ((module) => {
  1997. var $TypeError = TypeError;
  1998. module.exports = function (passed, required) {
  1999. if (passed < required) throw new $TypeError('Not enough arguments');
  2000. return passed;
  2001. };
  2002. /***/ }),
  2003. /***/ 8622:
  2004. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2005. var globalThis = __webpack_require__(4576);
  2006. var isCallable = __webpack_require__(4901);
  2007. var WeakMap = globalThis.WeakMap;
  2008. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  2009. /***/ }),
  2010. /***/ 8227:
  2011. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2012. var globalThis = __webpack_require__(4576);
  2013. var shared = __webpack_require__(5745);
  2014. var hasOwn = __webpack_require__(9297);
  2015. var uid = __webpack_require__(3392);
  2016. var NATIVE_SYMBOL = __webpack_require__(4495);
  2017. var USE_SYMBOL_AS_UID = __webpack_require__(7040);
  2018. var Symbol = globalThis.Symbol;
  2019. var WellKnownSymbolsStore = shared('wks');
  2020. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  2021. module.exports = function (name) {
  2022. if (!hasOwn(WellKnownSymbolsStore, name)) {
  2023. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name)
  2024. ? Symbol[name]
  2025. : createWellKnownSymbol('Symbol.' + name);
  2026. } return WellKnownSymbolsStore[name];
  2027. };
  2028. /***/ }),
  2029. /***/ 4114:
  2030. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2031. var $ = __webpack_require__(6518);
  2032. var toObject = __webpack_require__(8981);
  2033. var lengthOfArrayLike = __webpack_require__(6198);
  2034. var setArrayLength = __webpack_require__(4527);
  2035. var doesNotExceedSafeInteger = __webpack_require__(6837);
  2036. var fails = __webpack_require__(9039);
  2037. var INCORRECT_TO_LENGTH = fails(function () {
  2038. return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
  2039. });
  2040. // V8 <= 121 and Safari <= 15.4; FF < 23 throws InternalError
  2041. // https://bugs.chromium.org/p/v8/issues/detail?id=12681
  2042. var properErrorOnNonWritableLength = function () {
  2043. try {
  2044. // eslint-disable-next-line es/no-object-defineproperty -- safe
  2045. Object.defineProperty([], 'length', { writable: false }).push();
  2046. } catch (error) {
  2047. return error instanceof TypeError;
  2048. }
  2049. };
  2050. var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
  2051. // `Array.prototype.push` method
  2052. // https://tc39.es/ecma262/#sec-array.prototype.push
  2053. $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
  2054. // eslint-disable-next-line no-unused-vars -- required for `.length`
  2055. push: function push(item) {
  2056. var O = toObject(this);
  2057. var len = lengthOfArrayLike(O);
  2058. var argCount = arguments.length;
  2059. doesNotExceedSafeInteger(len + argCount);
  2060. for (var i = 0; i < argCount; i++) {
  2061. O[len] = arguments[i];
  2062. len++;
  2063. }
  2064. setArrayLength(O, len);
  2065. return len;
  2066. }
  2067. });
  2068. /***/ }),
  2069. /***/ 4628:
  2070. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2071. var $ = __webpack_require__(6518);
  2072. var newPromiseCapabilityModule = __webpack_require__(6043);
  2073. // `Promise.withResolvers` method
  2074. // https://github.com/tc39/proposal-promise-with-resolvers
  2075. $({ target: 'Promise', stat: true }, {
  2076. withResolvers: function withResolvers() {
  2077. var promiseCapability = newPromiseCapabilityModule.f(this);
  2078. return {
  2079. promise: promiseCapability.promise,
  2080. resolve: promiseCapability.resolve,
  2081. reject: promiseCapability.reject
  2082. };
  2083. }
  2084. });
  2085. /***/ }),
  2086. /***/ 7642:
  2087. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2088. var $ = __webpack_require__(6518);
  2089. var difference = __webpack_require__(3440);
  2090. var setMethodAcceptSetLike = __webpack_require__(4916);
  2091. // `Set.prototype.difference` method
  2092. // https://github.com/tc39/proposal-set-methods
  2093. $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('difference') }, {
  2094. difference: difference
  2095. });
  2096. /***/ }),
  2097. /***/ 8004:
  2098. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2099. var $ = __webpack_require__(6518);
  2100. var fails = __webpack_require__(9039);
  2101. var intersection = __webpack_require__(8750);
  2102. var setMethodAcceptSetLike = __webpack_require__(4916);
  2103. var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
  2104. // eslint-disable-next-line es/no-array-from, es/no-set -- testing
  2105. return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2';
  2106. });
  2107. // `Set.prototype.intersection` method
  2108. // https://github.com/tc39/proposal-set-methods
  2109. $({ target: 'Set', proto: true, real: true, forced: INCORRECT }, {
  2110. intersection: intersection
  2111. });
  2112. /***/ }),
  2113. /***/ 3853:
  2114. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2115. var $ = __webpack_require__(6518);
  2116. var isDisjointFrom = __webpack_require__(4449);
  2117. var setMethodAcceptSetLike = __webpack_require__(4916);
  2118. // `Set.prototype.isDisjointFrom` method
  2119. // https://github.com/tc39/proposal-set-methods
  2120. $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isDisjointFrom') }, {
  2121. isDisjointFrom: isDisjointFrom
  2122. });
  2123. /***/ }),
  2124. /***/ 5876:
  2125. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2126. var $ = __webpack_require__(6518);
  2127. var isSubsetOf = __webpack_require__(3838);
  2128. var setMethodAcceptSetLike = __webpack_require__(4916);
  2129. // `Set.prototype.isSubsetOf` method
  2130. // https://github.com/tc39/proposal-set-methods
  2131. $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSubsetOf') }, {
  2132. isSubsetOf: isSubsetOf
  2133. });
  2134. /***/ }),
  2135. /***/ 2475:
  2136. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2137. var $ = __webpack_require__(6518);
  2138. var isSupersetOf = __webpack_require__(8527);
  2139. var setMethodAcceptSetLike = __webpack_require__(4916);
  2140. // `Set.prototype.isSupersetOf` method
  2141. // https://github.com/tc39/proposal-set-methods
  2142. $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSupersetOf') }, {
  2143. isSupersetOf: isSupersetOf
  2144. });
  2145. /***/ }),
  2146. /***/ 5024:
  2147. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2148. var $ = __webpack_require__(6518);
  2149. var symmetricDifference = __webpack_require__(3650);
  2150. var setMethodAcceptSetLike = __webpack_require__(4916);
  2151. // `Set.prototype.symmetricDifference` method
  2152. // https://github.com/tc39/proposal-set-methods
  2153. $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('symmetricDifference') }, {
  2154. symmetricDifference: symmetricDifference
  2155. });
  2156. /***/ }),
  2157. /***/ 1698:
  2158. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2159. var $ = __webpack_require__(6518);
  2160. var union = __webpack_require__(4204);
  2161. var setMethodAcceptSetLike = __webpack_require__(4916);
  2162. // `Set.prototype.union` method
  2163. // https://github.com/tc39/proposal-set-methods
  2164. $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('union') }, {
  2165. union: union
  2166. });
  2167. /***/ }),
  2168. /***/ 8992:
  2169. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2170. var $ = __webpack_require__(6518);
  2171. var globalThis = __webpack_require__(4576);
  2172. var anInstance = __webpack_require__(679);
  2173. var anObject = __webpack_require__(8551);
  2174. var isCallable = __webpack_require__(4901);
  2175. var getPrototypeOf = __webpack_require__(2787);
  2176. var defineBuiltInAccessor = __webpack_require__(2106);
  2177. var createProperty = __webpack_require__(4659);
  2178. var fails = __webpack_require__(9039);
  2179. var hasOwn = __webpack_require__(9297);
  2180. var wellKnownSymbol = __webpack_require__(8227);
  2181. var IteratorPrototype = (__webpack_require__(7657).IteratorPrototype);
  2182. var DESCRIPTORS = __webpack_require__(3724);
  2183. var IS_PURE = __webpack_require__(6395);
  2184. var CONSTRUCTOR = 'constructor';
  2185. var ITERATOR = 'Iterator';
  2186. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2187. var $TypeError = TypeError;
  2188. var NativeIterator = globalThis[ITERATOR];
  2189. // FF56- have non-standard global helper `Iterator`
  2190. var FORCED = IS_PURE
  2191. || !isCallable(NativeIterator)
  2192. || NativeIterator.prototype !== IteratorPrototype
  2193. // FF44- non-standard `Iterator` passes previous tests
  2194. || !fails(function () { NativeIterator({}); });
  2195. var IteratorConstructor = function Iterator() {
  2196. anInstance(this, IteratorPrototype);
  2197. if (getPrototypeOf(this) === IteratorPrototype) throw new $TypeError('Abstract class Iterator not directly constructable');
  2198. };
  2199. var defineIteratorPrototypeAccessor = function (key, value) {
  2200. if (DESCRIPTORS) {
  2201. defineBuiltInAccessor(IteratorPrototype, key, {
  2202. configurable: true,
  2203. get: function () {
  2204. return value;
  2205. },
  2206. set: function (replacement) {
  2207. anObject(this);
  2208. if (this === IteratorPrototype) throw new $TypeError("You can't redefine this property");
  2209. if (hasOwn(this, key)) this[key] = replacement;
  2210. else createProperty(this, key, replacement);
  2211. }
  2212. });
  2213. } else IteratorPrototype[key] = value;
  2214. };
  2215. if (!hasOwn(IteratorPrototype, TO_STRING_TAG)) defineIteratorPrototypeAccessor(TO_STRING_TAG, ITERATOR);
  2216. if (FORCED || !hasOwn(IteratorPrototype, CONSTRUCTOR) || IteratorPrototype[CONSTRUCTOR] === Object) {
  2217. defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor);
  2218. }
  2219. IteratorConstructor.prototype = IteratorPrototype;
  2220. // `Iterator` constructor
  2221. // https://github.com/tc39/proposal-iterator-helpers
  2222. $({ global: true, constructor: true, forced: FORCED }, {
  2223. Iterator: IteratorConstructor
  2224. });
  2225. /***/ }),
  2226. /***/ 3215:
  2227. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2228. var $ = __webpack_require__(6518);
  2229. var iterate = __webpack_require__(2652);
  2230. var aCallable = __webpack_require__(9306);
  2231. var anObject = __webpack_require__(8551);
  2232. var getIteratorDirect = __webpack_require__(1767);
  2233. // `Iterator.prototype.every` method
  2234. // https://github.com/tc39/proposal-iterator-helpers
  2235. $({ target: 'Iterator', proto: true, real: true }, {
  2236. every: function every(predicate) {
  2237. anObject(this);
  2238. aCallable(predicate);
  2239. var record = getIteratorDirect(this);
  2240. var counter = 0;
  2241. return !iterate(record, function (value, stop) {
  2242. if (!predicate(value, counter++)) return stop();
  2243. }, { IS_RECORD: true, INTERRUPTED: true }).stopped;
  2244. }
  2245. });
  2246. /***/ }),
  2247. /***/ 4520:
  2248. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2249. var $ = __webpack_require__(6518);
  2250. var call = __webpack_require__(9565);
  2251. var aCallable = __webpack_require__(9306);
  2252. var anObject = __webpack_require__(8551);
  2253. var getIteratorDirect = __webpack_require__(1767);
  2254. var createIteratorProxy = __webpack_require__(9462);
  2255. var callWithSafeIterationClosing = __webpack_require__(6319);
  2256. var IS_PURE = __webpack_require__(6395);
  2257. var IteratorProxy = createIteratorProxy(function () {
  2258. var iterator = this.iterator;
  2259. var predicate = this.predicate;
  2260. var next = this.next;
  2261. var result, done, value;
  2262. while (true) {
  2263. result = anObject(call(next, iterator));
  2264. done = this.done = !!result.done;
  2265. if (done) return;
  2266. value = result.value;
  2267. if (callWithSafeIterationClosing(iterator, predicate, [value, this.counter++], true)) return value;
  2268. }
  2269. });
  2270. // `Iterator.prototype.filter` method
  2271. // https://github.com/tc39/proposal-iterator-helpers
  2272. $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
  2273. filter: function filter(predicate) {
  2274. anObject(this);
  2275. aCallable(predicate);
  2276. return new IteratorProxy(getIteratorDirect(this), {
  2277. predicate: predicate
  2278. });
  2279. }
  2280. });
  2281. /***/ }),
  2282. /***/ 3949:
  2283. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2284. var $ = __webpack_require__(6518);
  2285. var iterate = __webpack_require__(2652);
  2286. var aCallable = __webpack_require__(9306);
  2287. var anObject = __webpack_require__(8551);
  2288. var getIteratorDirect = __webpack_require__(1767);
  2289. // `Iterator.prototype.forEach` method
  2290. // https://github.com/tc39/proposal-iterator-helpers
  2291. $({ target: 'Iterator', proto: true, real: true }, {
  2292. forEach: function forEach(fn) {
  2293. anObject(this);
  2294. aCallable(fn);
  2295. var record = getIteratorDirect(this);
  2296. var counter = 0;
  2297. iterate(record, function (value) {
  2298. fn(value, counter++);
  2299. }, { IS_RECORD: true });
  2300. }
  2301. });
  2302. /***/ }),
  2303. /***/ 1454:
  2304. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2305. var $ = __webpack_require__(6518);
  2306. var map = __webpack_require__(713);
  2307. var IS_PURE = __webpack_require__(6395);
  2308. // `Iterator.prototype.map` method
  2309. // https://github.com/tc39/proposal-iterator-helpers
  2310. $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
  2311. map: map
  2312. });
  2313. /***/ }),
  2314. /***/ 7550:
  2315. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2316. var $ = __webpack_require__(6518);
  2317. var iterate = __webpack_require__(2652);
  2318. var aCallable = __webpack_require__(9306);
  2319. var anObject = __webpack_require__(8551);
  2320. var getIteratorDirect = __webpack_require__(1767);
  2321. // `Iterator.prototype.some` method
  2322. // https://github.com/tc39/proposal-iterator-helpers
  2323. $({ target: 'Iterator', proto: true, real: true }, {
  2324. some: function some(predicate) {
  2325. anObject(this);
  2326. aCallable(predicate);
  2327. var record = getIteratorDirect(this);
  2328. var counter = 0;
  2329. return iterate(record, function (value, stop) {
  2330. if (predicate(value, counter++)) return stop();
  2331. }, { IS_RECORD: true, INTERRUPTED: true }).stopped;
  2332. }
  2333. });
  2334. /***/ }),
  2335. /***/ 8335:
  2336. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2337. var $ = __webpack_require__(6518);
  2338. var DESCRIPTORS = __webpack_require__(3724);
  2339. var globalThis = __webpack_require__(4576);
  2340. var getBuiltIn = __webpack_require__(7751);
  2341. var uncurryThis = __webpack_require__(9504);
  2342. var call = __webpack_require__(9565);
  2343. var isCallable = __webpack_require__(4901);
  2344. var isObject = __webpack_require__(34);
  2345. var isArray = __webpack_require__(4376);
  2346. var hasOwn = __webpack_require__(9297);
  2347. var toString = __webpack_require__(655);
  2348. var lengthOfArrayLike = __webpack_require__(6198);
  2349. var createProperty = __webpack_require__(4659);
  2350. var fails = __webpack_require__(9039);
  2351. var parseJSONString = __webpack_require__(8235);
  2352. var NATIVE_SYMBOL = __webpack_require__(4495);
  2353. var JSON = globalThis.JSON;
  2354. var Number = globalThis.Number;
  2355. var SyntaxError = globalThis.SyntaxError;
  2356. var nativeParse = JSON && JSON.parse;
  2357. var enumerableOwnProperties = getBuiltIn('Object', 'keys');
  2358. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  2359. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2360. var at = uncurryThis(''.charAt);
  2361. var slice = uncurryThis(''.slice);
  2362. var exec = uncurryThis(/./.exec);
  2363. var push = uncurryThis([].push);
  2364. var IS_DIGIT = /^\d$/;
  2365. var IS_NON_ZERO_DIGIT = /^[1-9]$/;
  2366. var IS_NUMBER_START = /^[\d-]$/;
  2367. var IS_WHITESPACE = /^[\t\n\r ]$/;
  2368. var PRIMITIVE = 0;
  2369. var OBJECT = 1;
  2370. var $parse = function (source, reviver) {
  2371. source = toString(source);
  2372. var context = new Context(source, 0, '');
  2373. var root = context.parse();
  2374. var value = root.value;
  2375. var endIndex = context.skip(IS_WHITESPACE, root.end);
  2376. if (endIndex < source.length) {
  2377. throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
  2378. }
  2379. return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
  2380. };
  2381. var internalize = function (holder, name, reviver, node) {
  2382. var val = holder[name];
  2383. var unmodified = node && val === node.value;
  2384. var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
  2385. var elementRecordsLen, keys, len, i, P;
  2386. if (isObject(val)) {
  2387. var nodeIsArray = isArray(val);
  2388. var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
  2389. if (nodeIsArray) {
  2390. elementRecordsLen = nodes.length;
  2391. len = lengthOfArrayLike(val);
  2392. for (i = 0; i < len; i++) {
  2393. internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
  2394. }
  2395. } else {
  2396. keys = enumerableOwnProperties(val);
  2397. len = lengthOfArrayLike(keys);
  2398. for (i = 0; i < len; i++) {
  2399. P = keys[i];
  2400. internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
  2401. }
  2402. }
  2403. }
  2404. return call(reviver, holder, name, val, context);
  2405. };
  2406. var internalizeProperty = function (object, key, value) {
  2407. if (DESCRIPTORS) {
  2408. var descriptor = getOwnPropertyDescriptor(object, key);
  2409. if (descriptor && !descriptor.configurable) return;
  2410. }
  2411. if (value === undefined) delete object[key];
  2412. else createProperty(object, key, value);
  2413. };
  2414. var Node = function (value, end, source, nodes) {
  2415. this.value = value;
  2416. this.end = end;
  2417. this.source = source;
  2418. this.nodes = nodes;
  2419. };
  2420. var Context = function (source, index) {
  2421. this.source = source;
  2422. this.index = index;
  2423. };
  2424. // https://www.json.org/json-en.html
  2425. Context.prototype = {
  2426. fork: function (nextIndex) {
  2427. return new Context(this.source, nextIndex);
  2428. },
  2429. parse: function () {
  2430. var source = this.source;
  2431. var i = this.skip(IS_WHITESPACE, this.index);
  2432. var fork = this.fork(i);
  2433. var chr = at(source, i);
  2434. if (exec(IS_NUMBER_START, chr)) return fork.number();
  2435. switch (chr) {
  2436. case '{':
  2437. return fork.object();
  2438. case '[':
  2439. return fork.array();
  2440. case '"':
  2441. return fork.string();
  2442. case 't':
  2443. return fork.keyword(true);
  2444. case 'f':
  2445. return fork.keyword(false);
  2446. case 'n':
  2447. return fork.keyword(null);
  2448. } throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  2449. },
  2450. node: function (type, value, start, end, nodes) {
  2451. return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
  2452. },
  2453. object: function () {
  2454. var source = this.source;
  2455. var i = this.index + 1;
  2456. var expectKeypair = false;
  2457. var object = {};
  2458. var nodes = {};
  2459. while (i < source.length) {
  2460. i = this.until(['"', '}'], i);
  2461. if (at(source, i) === '}' && !expectKeypair) {
  2462. i++;
  2463. break;
  2464. }
  2465. // Parsing the key
  2466. var result = this.fork(i).string();
  2467. var key = result.value;
  2468. i = result.end;
  2469. i = this.until([':'], i) + 1;
  2470. // Parsing value
  2471. i = this.skip(IS_WHITESPACE, i);
  2472. result = this.fork(i).parse();
  2473. createProperty(nodes, key, result);
  2474. createProperty(object, key, result.value);
  2475. i = this.until([',', '}'], result.end);
  2476. var chr = at(source, i);
  2477. if (chr === ',') {
  2478. expectKeypair = true;
  2479. i++;
  2480. } else if (chr === '}') {
  2481. i++;
  2482. break;
  2483. }
  2484. }
  2485. return this.node(OBJECT, object, this.index, i, nodes);
  2486. },
  2487. array: function () {
  2488. var source = this.source;
  2489. var i = this.index + 1;
  2490. var expectElement = false;
  2491. var array = [];
  2492. var nodes = [];
  2493. while (i < source.length) {
  2494. i = this.skip(IS_WHITESPACE, i);
  2495. if (at(source, i) === ']' && !expectElement) {
  2496. i++;
  2497. break;
  2498. }
  2499. var result = this.fork(i).parse();
  2500. push(nodes, result);
  2501. push(array, result.value);
  2502. i = this.until([',', ']'], result.end);
  2503. if (at(source, i) === ',') {
  2504. expectElement = true;
  2505. i++;
  2506. } else if (at(source, i) === ']') {
  2507. i++;
  2508. break;
  2509. }
  2510. }
  2511. return this.node(OBJECT, array, this.index, i, nodes);
  2512. },
  2513. string: function () {
  2514. var index = this.index;
  2515. var parsed = parseJSONString(this.source, this.index + 1);
  2516. return this.node(PRIMITIVE, parsed.value, index, parsed.end);
  2517. },
  2518. number: function () {
  2519. var source = this.source;
  2520. var startIndex = this.index;
  2521. var i = startIndex;
  2522. if (at(source, i) === '-') i++;
  2523. if (at(source, i) === '0') i++;
  2524. else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, i + 1);
  2525. else throw new SyntaxError('Failed to parse number at: ' + i);
  2526. if (at(source, i) === '.') i = this.skip(IS_DIGIT, i + 1);
  2527. if (at(source, i) === 'e' || at(source, i) === 'E') {
  2528. i++;
  2529. if (at(source, i) === '+' || at(source, i) === '-') i++;
  2530. var exponentStartIndex = i;
  2531. i = this.skip(IS_DIGIT, i);
  2532. if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i);
  2533. }
  2534. return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
  2535. },
  2536. keyword: function (value) {
  2537. var keyword = '' + value;
  2538. var index = this.index;
  2539. var endIndex = index + keyword.length;
  2540. if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index);
  2541. return this.node(PRIMITIVE, value, index, endIndex);
  2542. },
  2543. skip: function (regex, i) {
  2544. var source = this.source;
  2545. for (; i < source.length; i++) if (!exec(regex, at(source, i))) break;
  2546. return i;
  2547. },
  2548. until: function (array, i) {
  2549. i = this.skip(IS_WHITESPACE, i);
  2550. var chr = at(this.source, i);
  2551. for (var j = 0; j < array.length; j++) if (array[j] === chr) return i;
  2552. throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  2553. }
  2554. };
  2555. var NO_SOURCE_SUPPORT = fails(function () {
  2556. var unsafeInt = '9007199254740993';
  2557. var source;
  2558. nativeParse(unsafeInt, function (key, value, context) {
  2559. source = context.source;
  2560. });
  2561. return source !== unsafeInt;
  2562. });
  2563. var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
  2564. // Safari 9 bug
  2565. return 1 / nativeParse('-0 \t') !== -Infinity;
  2566. });
  2567. // `JSON.parse` method
  2568. // https://tc39.es/ecma262/#sec-json.parse
  2569. // https://github.com/tc39/proposal-json-parse-with-source
  2570. $({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, {
  2571. parse: function parse(text, reviver) {
  2572. return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
  2573. }
  2574. });
  2575. /***/ }),
  2576. /***/ 4603:
  2577. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2578. var defineBuiltIn = __webpack_require__(6840);
  2579. var uncurryThis = __webpack_require__(9504);
  2580. var toString = __webpack_require__(655);
  2581. var validateArgumentsLength = __webpack_require__(2812);
  2582. var $URLSearchParams = URLSearchParams;
  2583. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  2584. var append = uncurryThis(URLSearchParamsPrototype.append);
  2585. var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
  2586. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  2587. var push = uncurryThis([].push);
  2588. var params = new $URLSearchParams('a=1&a=2&b=3');
  2589. params['delete']('a', 1);
  2590. // `undefined` case is a Chromium 117 bug
  2591. // https://bugs.chromium.org/p/v8/issues/detail?id=14222
  2592. params['delete']('b', undefined);
  2593. if (params + '' !== 'a=2') {
  2594. defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) {
  2595. var length = arguments.length;
  2596. var $value = length < 2 ? undefined : arguments[1];
  2597. if (length && $value === undefined) return $delete(this, name);
  2598. var entries = [];
  2599. forEach(this, function (v, k) { // also validates `this`
  2600. push(entries, { key: k, value: v });
  2601. });
  2602. validateArgumentsLength(length, 1);
  2603. var key = toString(name);
  2604. var value = toString($value);
  2605. var index = 0;
  2606. var dindex = 0;
  2607. var found = false;
  2608. var entriesLength = entries.length;
  2609. var entry;
  2610. while (index < entriesLength) {
  2611. entry = entries[index++];
  2612. if (found || entry.key === key) {
  2613. found = true;
  2614. $delete(this, entry.key);
  2615. } else dindex++;
  2616. }
  2617. while (dindex < entriesLength) {
  2618. entry = entries[dindex++];
  2619. if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
  2620. }
  2621. }, { enumerable: true, unsafe: true });
  2622. }
  2623. /***/ }),
  2624. /***/ 7566:
  2625. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2626. var defineBuiltIn = __webpack_require__(6840);
  2627. var uncurryThis = __webpack_require__(9504);
  2628. var toString = __webpack_require__(655);
  2629. var validateArgumentsLength = __webpack_require__(2812);
  2630. var $URLSearchParams = URLSearchParams;
  2631. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  2632. var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
  2633. var $has = uncurryThis(URLSearchParamsPrototype.has);
  2634. var params = new $URLSearchParams('a=1');
  2635. // `undefined` case is a Chromium 117 bug
  2636. // https://bugs.chromium.org/p/v8/issues/detail?id=14222
  2637. if (params.has('a', 2) || !params.has('a', undefined)) {
  2638. defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) {
  2639. var length = arguments.length;
  2640. var $value = length < 2 ? undefined : arguments[1];
  2641. if (length && $value === undefined) return $has(this, name);
  2642. var values = getAll(this, name); // also validates `this`
  2643. validateArgumentsLength(length, 1);
  2644. var value = toString($value);
  2645. var index = 0;
  2646. while (index < values.length) {
  2647. if (values[index++] === value) return true;
  2648. } return false;
  2649. }, { enumerable: true, unsafe: true });
  2650. }
  2651. /***/ }),
  2652. /***/ 8721:
  2653. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  2654. var DESCRIPTORS = __webpack_require__(3724);
  2655. var uncurryThis = __webpack_require__(9504);
  2656. var defineBuiltInAccessor = __webpack_require__(2106);
  2657. var URLSearchParamsPrototype = URLSearchParams.prototype;
  2658. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  2659. // `URLSearchParams.prototype.size` getter
  2660. // https://github.com/whatwg/url/pull/734
  2661. if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
  2662. defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
  2663. get: function size() {
  2664. var count = 0;
  2665. forEach(this, function () { count++; });
  2666. return count;
  2667. },
  2668. configurable: true,
  2669. enumerable: true
  2670. });
  2671. }
  2672. /***/ })
  2673. /******/ });
  2674. /************************************************************************/
  2675. /******/ // The module cache
  2676. /******/ var __webpack_module_cache__ = {};
  2677. /******/
  2678. /******/ // The require function
  2679. /******/ function __webpack_require__(moduleId) {
  2680. /******/ // Check if module is in cache
  2681. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  2682. /******/ if (cachedModule !== undefined) {
  2683. /******/ return cachedModule.exports;
  2684. /******/ }
  2685. /******/ // Create a new module (and put it into the cache)
  2686. /******/ var module = __webpack_module_cache__[moduleId] = {
  2687. /******/ // no module.id needed
  2688. /******/ // no module.loaded needed
  2689. /******/ exports: {}
  2690. /******/ };
  2691. /******/
  2692. /******/ // Execute the module function
  2693. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  2694. /******/
  2695. /******/ // Return the exports of the module
  2696. /******/ return module.exports;
  2697. /******/ }
  2698. /******/
  2699. /************************************************************************/
  2700. /******/ /* webpack/runtime/define property getters */
  2701. /******/ (() => {
  2702. /******/ // define getter functions for harmony exports
  2703. /******/ __webpack_require__.d = (exports, definition) => {
  2704. /******/ for(var key in definition) {
  2705. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  2706. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  2707. /******/ }
  2708. /******/ }
  2709. /******/ };
  2710. /******/ })();
  2711. /******/
  2712. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  2713. /******/ (() => {
  2714. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  2715. /******/ })();
  2716. /******/
  2717. /************************************************************************/
  2718. var __webpack_exports__ = {};
  2719. // EXPORTS
  2720. __webpack_require__.d(__webpack_exports__, {
  2721. PDFViewerApplication: () => (/* reexport */ PDFViewerApplication),
  2722. PDFViewerApplicationConstants: () => (/* binding */ AppConstants),
  2723. PDFViewerApplicationOptions: () => (/* reexport */ AppOptions)
  2724. });
  2725. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
  2726. var es_array_push = __webpack_require__(4114);
  2727. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.difference.v2.js
  2728. var es_set_difference_v2 = __webpack_require__(7642);
  2729. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.intersection.v2.js
  2730. var es_set_intersection_v2 = __webpack_require__(8004);
  2731. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.is-disjoint-from.v2.js
  2732. var es_set_is_disjoint_from_v2 = __webpack_require__(3853);
  2733. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.is-subset-of.v2.js
  2734. var es_set_is_subset_of_v2 = __webpack_require__(5876);
  2735. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.is-superset-of.v2.js
  2736. var es_set_is_superset_of_v2 = __webpack_require__(2475);
  2737. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.symmetric-difference.v2.js
  2738. var es_set_symmetric_difference_v2 = __webpack_require__(5024);
  2739. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.union.v2.js
  2740. var es_set_union_v2 = __webpack_require__(1698);
  2741. // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js
  2742. var web_url_search_params_delete = __webpack_require__(4603);
  2743. // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.has.js
  2744. var web_url_search_params_has = __webpack_require__(7566);
  2745. // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.size.js
  2746. var web_url_search_params_size = __webpack_require__(8721);
  2747. ;// ./web/ui_utils.js
  2748. const DEFAULT_SCALE_VALUE = "auto";
  2749. const DEFAULT_SCALE = 1.0;
  2750. const DEFAULT_SCALE_DELTA = 1.1;
  2751. const MIN_SCALE = 0.1;
  2752. const MAX_SCALE = 10.0;
  2753. const UNKNOWN_SCALE = 0;
  2754. const MAX_AUTO_SCALE = 1.25;
  2755. const SCROLLBAR_PADDING = 40;
  2756. const VERTICAL_PADDING = 5;
  2757. const RenderingStates = {
  2758. INITIAL: 0,
  2759. RUNNING: 1,
  2760. PAUSED: 2,
  2761. FINISHED: 3
  2762. };
  2763. const PresentationModeState = {
  2764. UNKNOWN: 0,
  2765. NORMAL: 1,
  2766. CHANGING: 2,
  2767. FULLSCREEN: 3
  2768. };
  2769. const SidebarView = {
  2770. UNKNOWN: -1,
  2771. NONE: 0,
  2772. THUMBS: 1,
  2773. OUTLINE: 2,
  2774. ATTACHMENTS: 3,
  2775. LAYERS: 4
  2776. };
  2777. const TextLayerMode = {
  2778. DISABLE: 0,
  2779. ENABLE: 1,
  2780. ENABLE_PERMISSIONS: 2
  2781. };
  2782. const ScrollMode = {
  2783. UNKNOWN: -1,
  2784. VERTICAL: 0,
  2785. HORIZONTAL: 1,
  2786. WRAPPED: 2,
  2787. PAGE: 3
  2788. };
  2789. const SpreadMode = {
  2790. UNKNOWN: -1,
  2791. NONE: 0,
  2792. ODD: 1,
  2793. EVEN: 2
  2794. };
  2795. const CursorTool = {
  2796. SELECT: 0,
  2797. HAND: 1,
  2798. ZOOM: 2
  2799. };
  2800. const AutoPrintRegExp = /\bprint\s*\(/;
  2801. function scrollIntoView(element, spot, scrollMatches = false) {
  2802. let parent = element.offsetParent;
  2803. if (!parent) {
  2804. console.error("offsetParent is not set -- cannot scroll");
  2805. return;
  2806. }
  2807. let offsetY = element.offsetTop + element.clientTop;
  2808. let offsetX = element.offsetLeft + element.clientLeft;
  2809. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  2810. offsetY += parent.offsetTop;
  2811. offsetX += parent.offsetLeft;
  2812. parent = parent.offsetParent;
  2813. if (!parent) {
  2814. return;
  2815. }
  2816. }
  2817. if (spot) {
  2818. if (spot.top !== undefined) {
  2819. offsetY += spot.top;
  2820. }
  2821. if (spot.left !== undefined) {
  2822. offsetX += spot.left;
  2823. parent.scrollLeft = offsetX;
  2824. }
  2825. }
  2826. parent.scrollTop = offsetY;
  2827. }
  2828. function watchScroll(viewAreaElement, callback, abortSignal = undefined) {
  2829. const debounceScroll = function (evt) {
  2830. if (rAF) {
  2831. return;
  2832. }
  2833. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  2834. rAF = null;
  2835. const currentX = viewAreaElement.scrollLeft;
  2836. const lastX = state.lastX;
  2837. if (currentX !== lastX) {
  2838. state.right = currentX > lastX;
  2839. }
  2840. state.lastX = currentX;
  2841. const currentY = viewAreaElement.scrollTop;
  2842. const lastY = state.lastY;
  2843. if (currentY !== lastY) {
  2844. state.down = currentY > lastY;
  2845. }
  2846. state.lastY = currentY;
  2847. callback(state);
  2848. });
  2849. };
  2850. const state = {
  2851. right: true,
  2852. down: true,
  2853. lastX: viewAreaElement.scrollLeft,
  2854. lastY: viewAreaElement.scrollTop,
  2855. _eventHandler: debounceScroll
  2856. };
  2857. let rAF = null;
  2858. viewAreaElement.addEventListener("scroll", debounceScroll, {
  2859. useCapture: true,
  2860. signal: abortSignal
  2861. });
  2862. abortSignal?.addEventListener("abort", () => window.cancelAnimationFrame(rAF), {
  2863. once: true
  2864. });
  2865. return state;
  2866. }
  2867. function parseQueryString(query) {
  2868. const params = new Map();
  2869. for (const [key, value] of new URLSearchParams(query)) {
  2870. params.set(key.toLowerCase(), value);
  2871. }
  2872. return params;
  2873. }
  2874. const InvisibleCharsRegExp = /[\x00-\x1F]/g;
  2875. function removeNullCharacters(str, replaceInvisible = false) {
  2876. if (!InvisibleCharsRegExp.test(str)) {
  2877. return str;
  2878. }
  2879. if (replaceInvisible) {
  2880. return str.replaceAll(InvisibleCharsRegExp, m => m === "\x00" ? "" : " ");
  2881. }
  2882. return str.replaceAll("\x00", "");
  2883. }
  2884. function binarySearchFirstItem(items, condition, start = 0) {
  2885. let minIndex = start;
  2886. let maxIndex = items.length - 1;
  2887. if (maxIndex < 0 || !condition(items[maxIndex])) {
  2888. return items.length;
  2889. }
  2890. if (condition(items[minIndex])) {
  2891. return minIndex;
  2892. }
  2893. while (minIndex < maxIndex) {
  2894. const currentIndex = minIndex + maxIndex >> 1;
  2895. const currentItem = items[currentIndex];
  2896. if (condition(currentItem)) {
  2897. maxIndex = currentIndex;
  2898. } else {
  2899. minIndex = currentIndex + 1;
  2900. }
  2901. }
  2902. return minIndex;
  2903. }
  2904. function approximateFraction(x) {
  2905. if (Math.floor(x) === x) {
  2906. return [x, 1];
  2907. }
  2908. const xinv = 1 / x;
  2909. const limit = 8;
  2910. if (xinv > limit) {
  2911. return [1, limit];
  2912. } else if (Math.floor(xinv) === xinv) {
  2913. return [1, xinv];
  2914. }
  2915. const x_ = x > 1 ? xinv : x;
  2916. let a = 0,
  2917. b = 1,
  2918. c = 1,
  2919. d = 1;
  2920. while (true) {
  2921. const p = a + c,
  2922. q = b + d;
  2923. if (q > limit) {
  2924. break;
  2925. }
  2926. if (x_ <= p / q) {
  2927. c = p;
  2928. d = q;
  2929. } else {
  2930. a = p;
  2931. b = q;
  2932. }
  2933. }
  2934. let result;
  2935. if (x_ - a / b < c / d - x_) {
  2936. result = x_ === x ? [a, b] : [b, a];
  2937. } else {
  2938. result = x_ === x ? [c, d] : [d, c];
  2939. }
  2940. return result;
  2941. }
  2942. function floorToDivide(x, div) {
  2943. return x - x % div;
  2944. }
  2945. function getPageSizeInches({
  2946. view,
  2947. userUnit,
  2948. rotate
  2949. }) {
  2950. const [x1, y1, x2, y2] = view;
  2951. const changeOrientation = rotate % 180 !== 0;
  2952. const width = (x2 - x1) / 72 * userUnit;
  2953. const height = (y2 - y1) / 72 * userUnit;
  2954. return {
  2955. width: changeOrientation ? height : width,
  2956. height: changeOrientation ? width : height
  2957. };
  2958. }
  2959. function backtrackBeforeAllVisibleElements(index, views, top) {
  2960. if (index < 2) {
  2961. return index;
  2962. }
  2963. let elt = views[index].div;
  2964. let pageTop = elt.offsetTop + elt.clientTop;
  2965. if (pageTop >= top) {
  2966. elt = views[index - 1].div;
  2967. pageTop = elt.offsetTop + elt.clientTop;
  2968. }
  2969. for (let i = index - 2; i >= 0; --i) {
  2970. elt = views[i].div;
  2971. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  2972. break;
  2973. }
  2974. index = i;
  2975. }
  2976. return index;
  2977. }
  2978. function getVisibleElements({
  2979. scrollEl,
  2980. views,
  2981. sortByVisibility = false,
  2982. horizontal = false,
  2983. rtl = false
  2984. }) {
  2985. const top = scrollEl.scrollTop,
  2986. bottom = top + scrollEl.clientHeight;
  2987. const left = scrollEl.scrollLeft,
  2988. right = left + scrollEl.clientWidth;
  2989. function isElementBottomAfterViewTop(view) {
  2990. const element = view.div;
  2991. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  2992. return elementBottom > top;
  2993. }
  2994. function isElementNextAfterViewHorizontally(view) {
  2995. const element = view.div;
  2996. const elementLeft = element.offsetLeft + element.clientLeft;
  2997. const elementRight = elementLeft + element.clientWidth;
  2998. return rtl ? elementLeft < right : elementRight > left;
  2999. }
  3000. const visible = [],
  3001. ids = new Set(),
  3002. numViews = views.length;
  3003. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  3004. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3005. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3006. }
  3007. let lastEdge = horizontal ? right : -1;
  3008. for (let i = firstVisibleElementInd; i < numViews; i++) {
  3009. const view = views[i],
  3010. element = view.div;
  3011. const currentWidth = element.offsetLeft + element.clientLeft;
  3012. const currentHeight = element.offsetTop + element.clientTop;
  3013. const viewWidth = element.clientWidth,
  3014. viewHeight = element.clientHeight;
  3015. const viewRight = currentWidth + viewWidth;
  3016. const viewBottom = currentHeight + viewHeight;
  3017. if (lastEdge === -1) {
  3018. if (viewBottom >= bottom) {
  3019. lastEdge = viewBottom;
  3020. }
  3021. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3022. break;
  3023. }
  3024. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3025. continue;
  3026. }
  3027. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3028. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3029. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  3030. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  3031. const percent = fractionHeight * fractionWidth * 100 | 0;
  3032. visible.push({
  3033. id: view.id,
  3034. x: currentWidth,
  3035. y: currentHeight,
  3036. view,
  3037. percent,
  3038. widthPercent: fractionWidth * 100 | 0
  3039. });
  3040. ids.add(view.id);
  3041. }
  3042. const first = visible[0],
  3043. last = visible.at(-1);
  3044. if (sortByVisibility) {
  3045. visible.sort(function (a, b) {
  3046. const pc = a.percent - b.percent;
  3047. if (Math.abs(pc) > 0.001) {
  3048. return -pc;
  3049. }
  3050. return a.id - b.id;
  3051. });
  3052. }
  3053. return {
  3054. first,
  3055. last,
  3056. views: visible,
  3057. ids
  3058. };
  3059. }
  3060. function normalizeWheelEventDirection(evt) {
  3061. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  3062. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  3063. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3064. delta = -delta;
  3065. }
  3066. return delta;
  3067. }
  3068. function normalizeWheelEventDelta(evt) {
  3069. const deltaMode = evt.deltaMode;
  3070. let delta = normalizeWheelEventDirection(evt);
  3071. const MOUSE_PIXELS_PER_LINE = 30;
  3072. const MOUSE_LINES_PER_PAGE = 30;
  3073. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  3074. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3075. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  3076. delta /= MOUSE_LINES_PER_PAGE;
  3077. }
  3078. return delta;
  3079. }
  3080. function isValidRotation(angle) {
  3081. return Number.isInteger(angle) && angle % 90 === 0;
  3082. }
  3083. function isValidScrollMode(mode) {
  3084. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3085. }
  3086. function isValidSpreadMode(mode) {
  3087. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3088. }
  3089. function isPortraitOrientation(size) {
  3090. return size.width <= size.height;
  3091. }
  3092. const animationStarted = new Promise(function (resolve) {
  3093. window.requestAnimationFrame(resolve);
  3094. });
  3095. const docStyle = document.documentElement.style;
  3096. function clamp(v, min, max) {
  3097. return Math.min(Math.max(v, min), max);
  3098. }
  3099. class ProgressBar {
  3100. #classList = null;
  3101. #disableAutoFetchTimeout = null;
  3102. #percent = 0;
  3103. #style = null;
  3104. #visible = true;
  3105. constructor(bar) {
  3106. this.#classList = bar.classList;
  3107. this.#style = bar.style;
  3108. }
  3109. get percent() {
  3110. return this.#percent;
  3111. }
  3112. set percent(val) {
  3113. this.#percent = clamp(val, 0, 100);
  3114. if (isNaN(val)) {
  3115. this.#classList.add("indeterminate");
  3116. return;
  3117. }
  3118. this.#classList.remove("indeterminate");
  3119. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  3120. }
  3121. setWidth(viewer) {
  3122. if (!viewer) {
  3123. return;
  3124. }
  3125. const container = viewer.parentNode;
  3126. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3127. if (scrollbarWidth > 0) {
  3128. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  3129. }
  3130. }
  3131. setDisableAutoFetch(delay = 5000) {
  3132. if (this.#percent === 100 || isNaN(this.#percent)) {
  3133. return;
  3134. }
  3135. if (this.#disableAutoFetchTimeout) {
  3136. clearTimeout(this.#disableAutoFetchTimeout);
  3137. }
  3138. this.show();
  3139. this.#disableAutoFetchTimeout = setTimeout(() => {
  3140. this.#disableAutoFetchTimeout = null;
  3141. this.hide();
  3142. }, delay);
  3143. }
  3144. hide() {
  3145. if (!this.#visible) {
  3146. return;
  3147. }
  3148. this.#visible = false;
  3149. this.#classList.add("hidden");
  3150. }
  3151. show() {
  3152. if (this.#visible) {
  3153. return;
  3154. }
  3155. this.#visible = true;
  3156. this.#classList.remove("hidden");
  3157. }
  3158. }
  3159. function getActiveOrFocusedElement() {
  3160. let curRoot = document;
  3161. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  3162. while (curActiveOrFocused?.shadowRoot) {
  3163. curRoot = curActiveOrFocused.shadowRoot;
  3164. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  3165. }
  3166. return curActiveOrFocused;
  3167. }
  3168. function apiPageLayoutToViewerModes(layout) {
  3169. let scrollMode = ScrollMode.VERTICAL,
  3170. spreadMode = SpreadMode.NONE;
  3171. switch (layout) {
  3172. case "SinglePage":
  3173. scrollMode = ScrollMode.PAGE;
  3174. break;
  3175. case "OneColumn":
  3176. break;
  3177. case "TwoPageLeft":
  3178. scrollMode = ScrollMode.PAGE;
  3179. case "TwoColumnLeft":
  3180. spreadMode = SpreadMode.ODD;
  3181. break;
  3182. case "TwoPageRight":
  3183. scrollMode = ScrollMode.PAGE;
  3184. case "TwoColumnRight":
  3185. spreadMode = SpreadMode.EVEN;
  3186. break;
  3187. }
  3188. return {
  3189. scrollMode,
  3190. spreadMode
  3191. };
  3192. }
  3193. function apiPageModeToSidebarView(mode) {
  3194. switch (mode) {
  3195. case "UseNone":
  3196. return SidebarView.NONE;
  3197. case "UseThumbs":
  3198. return SidebarView.THUMBS;
  3199. case "UseOutlines":
  3200. return SidebarView.OUTLINE;
  3201. case "UseAttachments":
  3202. return SidebarView.ATTACHMENTS;
  3203. case "UseOC":
  3204. return SidebarView.LAYERS;
  3205. }
  3206. return SidebarView.NONE;
  3207. }
  3208. function toggleCheckedBtn(button, toggle, view = null) {
  3209. button.classList.toggle("toggled", toggle);
  3210. button.setAttribute("aria-checked", toggle);
  3211. view?.classList.toggle("hidden", !toggle);
  3212. }
  3213. function toggleExpandedBtn(button, toggle, view = null) {
  3214. button.classList.toggle("toggled", toggle);
  3215. button.setAttribute("aria-expanded", toggle);
  3216. view?.classList.toggle("hidden", !toggle);
  3217. }
  3218. const calcRound = function () {
  3219. const e = document.createElement("div");
  3220. e.style.width = "round(down, calc(1.6666666666666665 * 792px), 1px)";
  3221. return e.style.width === "calc(1320px)" ? Math.fround : x => x;
  3222. }();
  3223. ;// ./web/app_options.js
  3224. {
  3225. var compatParams = new Map();
  3226. const userAgent = navigator.userAgent || "";
  3227. const platform = navigator.platform || "";
  3228. const maxTouchPoints = navigator.maxTouchPoints || 1;
  3229. const isAndroid = /Android/.test(userAgent);
  3230. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  3231. (function () {
  3232. if (isIOS || isAndroid) {
  3233. compatParams.set("maxCanvasPixels", 5242880);
  3234. }
  3235. })();
  3236. (function () {
  3237. if (isAndroid) {
  3238. compatParams.set("useSystemFonts", false);
  3239. }
  3240. })();
  3241. }
  3242. const OptionKind = {
  3243. BROWSER: 0x01,
  3244. VIEWER: 0x02,
  3245. API: 0x04,
  3246. WORKER: 0x08,
  3247. EVENT_DISPATCH: 0x10,
  3248. PREFERENCE: 0x80
  3249. };
  3250. const Type = {
  3251. BOOLEAN: 0x01,
  3252. NUMBER: 0x02,
  3253. OBJECT: 0x04,
  3254. STRING: 0x08,
  3255. UNDEFINED: 0x10
  3256. };
  3257. const defaultOptions = {
  3258. allowedGlobalEvents: {
  3259. value: null,
  3260. kind: OptionKind.BROWSER
  3261. },
  3262. canvasMaxAreaInBytes: {
  3263. value: -1,
  3264. kind: OptionKind.BROWSER + OptionKind.API
  3265. },
  3266. isInAutomation: {
  3267. value: false,
  3268. kind: OptionKind.BROWSER
  3269. },
  3270. localeProperties: {
  3271. value: {
  3272. lang: navigator.language || "en-US"
  3273. },
  3274. kind: OptionKind.BROWSER
  3275. },
  3276. nimbusDataStr: {
  3277. value: "",
  3278. kind: OptionKind.BROWSER
  3279. },
  3280. supportsCaretBrowsingMode: {
  3281. value: false,
  3282. kind: OptionKind.BROWSER
  3283. },
  3284. supportsDocumentFonts: {
  3285. value: true,
  3286. kind: OptionKind.BROWSER
  3287. },
  3288. supportsIntegratedFind: {
  3289. value: false,
  3290. kind: OptionKind.BROWSER
  3291. },
  3292. supportsMouseWheelZoomCtrlKey: {
  3293. value: true,
  3294. kind: OptionKind.BROWSER
  3295. },
  3296. supportsMouseWheelZoomMetaKey: {
  3297. value: true,
  3298. kind: OptionKind.BROWSER
  3299. },
  3300. supportsPinchToZoom: {
  3301. value: true,
  3302. kind: OptionKind.BROWSER
  3303. },
  3304. toolbarDensity: {
  3305. value: 0,
  3306. kind: OptionKind.BROWSER + OptionKind.EVENT_DISPATCH
  3307. },
  3308. altTextLearnMoreUrl: {
  3309. value: "",
  3310. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3311. },
  3312. annotationEditorMode: {
  3313. value: 0,
  3314. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3315. },
  3316. annotationMode: {
  3317. value: 2,
  3318. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3319. },
  3320. cursorToolOnLoad: {
  3321. value: 0,
  3322. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3323. },
  3324. debuggerSrc: {
  3325. value: "./debugger.mjs",
  3326. kind: OptionKind.VIEWER
  3327. },
  3328. defaultZoomDelay: {
  3329. value: 400,
  3330. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3331. },
  3332. defaultZoomValue: {
  3333. value: "",
  3334. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3335. },
  3336. disableHistory: {
  3337. value: false,
  3338. kind: OptionKind.VIEWER
  3339. },
  3340. disablePageLabels: {
  3341. value: false,
  3342. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3343. },
  3344. enableAltText: {
  3345. value: false,
  3346. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3347. },
  3348. enableAltTextModelDownload: {
  3349. value: true,
  3350. kind: OptionKind.VIEWER + OptionKind.PREFERENCE + OptionKind.EVENT_DISPATCH
  3351. },
  3352. enableGuessAltText: {
  3353. value: true,
  3354. kind: OptionKind.VIEWER + OptionKind.PREFERENCE + OptionKind.EVENT_DISPATCH
  3355. },
  3356. enableHighlightFloatingButton: {
  3357. value: false,
  3358. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3359. },
  3360. enableNewAltTextWhenAddingImage: {
  3361. value: true,
  3362. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3363. },
  3364. enablePermissions: {
  3365. value: false,
  3366. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3367. },
  3368. enablePrintAutoRotate: {
  3369. value: true,
  3370. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3371. },
  3372. enableScripting: {
  3373. value: true,
  3374. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3375. },
  3376. enableUpdatedAddImage: {
  3377. value: false,
  3378. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3379. },
  3380. externalLinkRel: {
  3381. value: "noopener noreferrer nofollow",
  3382. kind: OptionKind.VIEWER
  3383. },
  3384. externalLinkTarget: {
  3385. value: 0,
  3386. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3387. },
  3388. highlightEditorColors: {
  3389. value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
  3390. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3391. },
  3392. historyUpdateUrl: {
  3393. value: false,
  3394. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3395. },
  3396. ignoreDestinationZoom: {
  3397. value: false,
  3398. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3399. },
  3400. imageResourcesPath: {
  3401. value: "./images/",
  3402. kind: OptionKind.VIEWER
  3403. },
  3404. maxCanvasPixels: {
  3405. value: 2 ** 25,
  3406. kind: OptionKind.VIEWER
  3407. },
  3408. forcePageColors: {
  3409. value: false,
  3410. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3411. },
  3412. pageColorsBackground: {
  3413. value: "Canvas",
  3414. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3415. },
  3416. pageColorsForeground: {
  3417. value: "CanvasText",
  3418. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3419. },
  3420. pdfBugEnabled: {
  3421. value: false,
  3422. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3423. },
  3424. printResolution: {
  3425. value: 150,
  3426. kind: OptionKind.VIEWER
  3427. },
  3428. sidebarViewOnLoad: {
  3429. value: -1,
  3430. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3431. },
  3432. scrollModeOnLoad: {
  3433. value: -1,
  3434. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3435. },
  3436. spreadModeOnLoad: {
  3437. value: -1,
  3438. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3439. },
  3440. textLayerMode: {
  3441. value: 1,
  3442. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3443. },
  3444. viewOnLoad: {
  3445. value: 0,
  3446. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3447. },
  3448. cMapPacked: {
  3449. value: true,
  3450. kind: OptionKind.API
  3451. },
  3452. cMapUrl: {
  3453. value: "../web/cmaps/",
  3454. kind: OptionKind.API
  3455. },
  3456. disableAutoFetch: {
  3457. value: false,
  3458. kind: OptionKind.API + OptionKind.PREFERENCE
  3459. },
  3460. disableFontFace: {
  3461. value: false,
  3462. kind: OptionKind.API + OptionKind.PREFERENCE
  3463. },
  3464. disableRange: {
  3465. value: false,
  3466. kind: OptionKind.API + OptionKind.PREFERENCE
  3467. },
  3468. disableStream: {
  3469. value: false,
  3470. kind: OptionKind.API + OptionKind.PREFERENCE
  3471. },
  3472. docBaseUrl: {
  3473. value: "",
  3474. kind: OptionKind.API
  3475. },
  3476. enableHWA: {
  3477. value: true,
  3478. kind: OptionKind.API + OptionKind.VIEWER + OptionKind.PREFERENCE
  3479. },
  3480. enableXfa: {
  3481. value: true,
  3482. kind: OptionKind.API + OptionKind.PREFERENCE
  3483. },
  3484. fontExtraProperties: {
  3485. value: false,
  3486. kind: OptionKind.API
  3487. },
  3488. isEvalSupported: {
  3489. value: true,
  3490. kind: OptionKind.API
  3491. },
  3492. isOffscreenCanvasSupported: {
  3493. value: true,
  3494. kind: OptionKind.API
  3495. },
  3496. maxImageSize: {
  3497. value: -1,
  3498. kind: OptionKind.API
  3499. },
  3500. pdfBug: {
  3501. value: false,
  3502. kind: OptionKind.API
  3503. },
  3504. standardFontDataUrl: {
  3505. value: "../web/standard_fonts/",
  3506. kind: OptionKind.API
  3507. },
  3508. useSystemFonts: {
  3509. value: undefined,
  3510. kind: OptionKind.API,
  3511. type: Type.BOOLEAN + Type.UNDEFINED
  3512. },
  3513. verbosity: {
  3514. value: 1,
  3515. kind: OptionKind.API
  3516. },
  3517. workerPort: {
  3518. value: null,
  3519. kind: OptionKind.WORKER
  3520. },
  3521. workerSrc: {
  3522. value: "../build/pdf.worker.mjs",
  3523. kind: OptionKind.WORKER
  3524. }
  3525. };
  3526. {
  3527. defaultOptions.defaultUrl = {
  3528. value: "compress.pdf",
  3529. kind: OptionKind.VIEWER
  3530. };
  3531. defaultOptions.sandboxBundleSrc = {
  3532. value: "../build/pdf.sandbox.mjs",
  3533. kind: OptionKind.VIEWER
  3534. };
  3535. defaultOptions.viewerCssTheme = {
  3536. value: 0,
  3537. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3538. };
  3539. defaultOptions.enableFakeMLManager = {
  3540. value: true,
  3541. kind: OptionKind.VIEWER
  3542. };
  3543. }
  3544. {
  3545. defaultOptions.disablePreferences = {
  3546. value: false,
  3547. kind: OptionKind.VIEWER
  3548. };
  3549. }
  3550. class AppOptions {
  3551. static eventBus;
  3552. static #opts = new Map();
  3553. static {
  3554. for (const name in defaultOptions) {
  3555. this.#opts.set(name, defaultOptions[name].value);
  3556. }
  3557. for (const [name, value] of compatParams) {
  3558. this.#opts.set(name, value);
  3559. }
  3560. this._hasInvokedSet = false;
  3561. this._checkDisablePreferences = () => {
  3562. if (this.get("disablePreferences")) {
  3563. return true;
  3564. }
  3565. if (this._hasInvokedSet) {
  3566. console.warn("The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option to prevent that.');
  3567. }
  3568. return false;
  3569. };
  3570. }
  3571. static get(name) {
  3572. return this.#opts.get(name);
  3573. }
  3574. static getAll(kind = null, defaultOnly = false) {
  3575. const options = Object.create(null);
  3576. for (const name in defaultOptions) {
  3577. const defaultOpt = defaultOptions[name];
  3578. if (kind && !(kind & defaultOpt.kind)) {
  3579. continue;
  3580. }
  3581. options[name] = !defaultOnly ? this.#opts.get(name) : defaultOpt.value;
  3582. }
  3583. return options;
  3584. }
  3585. static set(name, value) {
  3586. this.setAll({
  3587. [name]: value
  3588. });
  3589. }
  3590. static setAll(options, prefs = false) {
  3591. this._hasInvokedSet ||= true;
  3592. let events;
  3593. for (const name in options) {
  3594. const defaultOpt = defaultOptions[name],
  3595. userOpt = options[name];
  3596. if (!defaultOpt || !(typeof userOpt === typeof defaultOpt.value || Type[(typeof userOpt).toUpperCase()] & defaultOpt.type)) {
  3597. continue;
  3598. }
  3599. const {
  3600. kind
  3601. } = defaultOpt;
  3602. if (prefs && !(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) {
  3603. continue;
  3604. }
  3605. if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
  3606. (events ||= new Map()).set(name, userOpt);
  3607. }
  3608. this.#opts.set(name, userOpt);
  3609. }
  3610. if (events) {
  3611. for (const [name, value] of events) {
  3612. this.eventBus.dispatch(name.toLowerCase(), {
  3613. source: this,
  3614. value
  3615. });
  3616. }
  3617. }
  3618. }
  3619. }
  3620. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.json.parse.js
  3621. var esnext_json_parse = __webpack_require__(8335);
  3622. ;// ./web/pdf_link_service.js
  3623. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  3624. const LinkTarget = {
  3625. NONE: 0,
  3626. SELF: 1,
  3627. BLANK: 2,
  3628. PARENT: 3,
  3629. TOP: 4
  3630. };
  3631. class PDFLinkService {
  3632. externalLinkEnabled = true;
  3633. constructor({
  3634. eventBus,
  3635. externalLinkTarget = null,
  3636. externalLinkRel = null,
  3637. ignoreDestinationZoom = false
  3638. } = {}) {
  3639. this.eventBus = eventBus;
  3640. this.externalLinkTarget = externalLinkTarget;
  3641. this.externalLinkRel = externalLinkRel;
  3642. this._ignoreDestinationZoom = ignoreDestinationZoom;
  3643. this.baseUrl = null;
  3644. this.pdfDocument = null;
  3645. this.pdfViewer = null;
  3646. this.pdfHistory = null;
  3647. }
  3648. setDocument(pdfDocument, baseUrl = null) {
  3649. this.baseUrl = baseUrl;
  3650. this.pdfDocument = pdfDocument;
  3651. }
  3652. setViewer(pdfViewer) {
  3653. this.pdfViewer = pdfViewer;
  3654. }
  3655. setHistory(pdfHistory) {
  3656. this.pdfHistory = pdfHistory;
  3657. }
  3658. get pagesCount() {
  3659. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  3660. }
  3661. get page() {
  3662. return this.pdfDocument ? this.pdfViewer.currentPageNumber : 1;
  3663. }
  3664. set page(value) {
  3665. if (this.pdfDocument) {
  3666. this.pdfViewer.currentPageNumber = value;
  3667. }
  3668. }
  3669. get rotation() {
  3670. return this.pdfDocument ? this.pdfViewer.pagesRotation : 0;
  3671. }
  3672. set rotation(value) {
  3673. if (this.pdfDocument) {
  3674. this.pdfViewer.pagesRotation = value;
  3675. }
  3676. }
  3677. get isInPresentationMode() {
  3678. return this.pdfDocument ? this.pdfViewer.isInPresentationMode : false;
  3679. }
  3680. async goToDestination(dest) {
  3681. if (!this.pdfDocument) {
  3682. return;
  3683. }
  3684. let namedDest, explicitDest, pageNumber;
  3685. if (typeof dest === "string") {
  3686. namedDest = dest;
  3687. explicitDest = await this.pdfDocument.getDestination(dest);
  3688. } else {
  3689. namedDest = null;
  3690. explicitDest = await dest;
  3691. }
  3692. if (!Array.isArray(explicitDest)) {
  3693. console.error(`goToDestination: "${explicitDest}" is not a valid destination array, for dest="${dest}".`);
  3694. return;
  3695. }
  3696. const [destRef] = explicitDest;
  3697. if (destRef && typeof destRef === "object") {
  3698. pageNumber = this.pdfDocument.cachedPageNumber(destRef);
  3699. if (!pageNumber) {
  3700. try {
  3701. pageNumber = (await this.pdfDocument.getPageIndex(destRef)) + 1;
  3702. } catch {
  3703. console.error(`goToDestination: "${destRef}" is not a valid page reference, for dest="${dest}".`);
  3704. return;
  3705. }
  3706. }
  3707. } else if (Number.isInteger(destRef)) {
  3708. pageNumber = destRef + 1;
  3709. }
  3710. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  3711. console.error(`goToDestination: "${pageNumber}" is not a valid page number, for dest="${dest}".`);
  3712. return;
  3713. }
  3714. if (this.pdfHistory) {
  3715. this.pdfHistory.pushCurrentPosition();
  3716. this.pdfHistory.push({
  3717. namedDest,
  3718. explicitDest,
  3719. pageNumber
  3720. });
  3721. }
  3722. this.pdfViewer.scrollPageIntoView({
  3723. pageNumber,
  3724. destArray: explicitDest,
  3725. ignoreDestinationZoom: this._ignoreDestinationZoom
  3726. });
  3727. }
  3728. goToPage(val) {
  3729. if (!this.pdfDocument) {
  3730. return;
  3731. }
  3732. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  3733. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  3734. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  3735. return;
  3736. }
  3737. if (this.pdfHistory) {
  3738. this.pdfHistory.pushCurrentPosition();
  3739. this.pdfHistory.pushPage(pageNumber);
  3740. }
  3741. this.pdfViewer.scrollPageIntoView({
  3742. pageNumber
  3743. });
  3744. }
  3745. addLinkAttributes(link, url, newWindow = false) {
  3746. if (!url || typeof url !== "string") {
  3747. throw new Error('A valid "url" parameter must provided.');
  3748. }
  3749. const target = newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  3750. rel = this.externalLinkRel;
  3751. if (this.externalLinkEnabled) {
  3752. link.href = link.title = url;
  3753. } else {
  3754. link.href = "";
  3755. link.title = `Disabled: ${url}`;
  3756. link.onclick = () => false;
  3757. }
  3758. let targetStr = "";
  3759. switch (target) {
  3760. case LinkTarget.NONE:
  3761. break;
  3762. case LinkTarget.SELF:
  3763. targetStr = "_self";
  3764. break;
  3765. case LinkTarget.BLANK:
  3766. targetStr = "_blank";
  3767. break;
  3768. case LinkTarget.PARENT:
  3769. targetStr = "_parent";
  3770. break;
  3771. case LinkTarget.TOP:
  3772. targetStr = "_top";
  3773. break;
  3774. }
  3775. link.target = targetStr;
  3776. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  3777. }
  3778. getDestinationHash(dest) {
  3779. if (typeof dest === "string") {
  3780. if (dest.length > 0) {
  3781. return this.getAnchorUrl("#" + escape(dest));
  3782. }
  3783. } else if (Array.isArray(dest)) {
  3784. const str = JSON.stringify(dest);
  3785. if (str.length > 0) {
  3786. return this.getAnchorUrl("#" + escape(str));
  3787. }
  3788. }
  3789. return this.getAnchorUrl("");
  3790. }
  3791. getAnchorUrl(anchor) {
  3792. return this.baseUrl ? this.baseUrl + anchor : anchor;
  3793. }
  3794. setHash(hash) {
  3795. if (!this.pdfDocument) {
  3796. return;
  3797. }
  3798. let pageNumber, dest;
  3799. if (hash.includes("=")) {
  3800. const params = parseQueryString(hash);
  3801. if (params.has("search")) {
  3802. const query = params.get("search").replaceAll('"', ""),
  3803. phrase = params.get("phrase") === "true";
  3804. this.eventBus.dispatch("findfromurlhash", {
  3805. source: this,
  3806. query: phrase ? query : query.match(/\S+/g)
  3807. });
  3808. }
  3809. if (params.has("page")) {
  3810. pageNumber = params.get("page") | 0 || 1;
  3811. }
  3812. if (params.has("zoom")) {
  3813. const zoomArgs = params.get("zoom").split(",");
  3814. const zoomArg = zoomArgs[0];
  3815. const zoomArgNumber = parseFloat(zoomArg);
  3816. if (!zoomArg.includes("Fit")) {
  3817. dest = [null, {
  3818. name: "XYZ"
  3819. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  3820. } else if (zoomArg === "Fit" || zoomArg === "FitB") {
  3821. dest = [null, {
  3822. name: zoomArg
  3823. }];
  3824. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  3825. dest = [null, {
  3826. name: zoomArg
  3827. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  3828. } else if (zoomArg === "FitR") {
  3829. if (zoomArgs.length !== 5) {
  3830. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  3831. } else {
  3832. dest = [null, {
  3833. name: zoomArg
  3834. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  3835. }
  3836. } else {
  3837. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  3838. }
  3839. }
  3840. if (dest) {
  3841. this.pdfViewer.scrollPageIntoView({
  3842. pageNumber: pageNumber || this.page,
  3843. destArray: dest,
  3844. allowNegativeOffset: true
  3845. });
  3846. } else if (pageNumber) {
  3847. this.page = pageNumber;
  3848. }
  3849. if (params.has("pagemode")) {
  3850. this.eventBus.dispatch("pagemode", {
  3851. source: this,
  3852. mode: params.get("pagemode")
  3853. });
  3854. }
  3855. if (params.has("nameddest")) {
  3856. this.goToDestination(params.get("nameddest"));
  3857. }
  3858. return;
  3859. }
  3860. dest = unescape(hash);
  3861. try {
  3862. dest = JSON.parse(dest);
  3863. if (!Array.isArray(dest)) {
  3864. dest = dest.toString();
  3865. }
  3866. } catch {}
  3867. if (typeof dest === "string" || PDFLinkService.#isValidExplicitDest(dest)) {
  3868. this.goToDestination(dest);
  3869. return;
  3870. }
  3871. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  3872. }
  3873. executeNamedAction(action) {
  3874. if (!this.pdfDocument) {
  3875. return;
  3876. }
  3877. switch (action) {
  3878. case "GoBack":
  3879. this.pdfHistory?.back();
  3880. break;
  3881. case "GoForward":
  3882. this.pdfHistory?.forward();
  3883. break;
  3884. case "NextPage":
  3885. this.pdfViewer.nextPage();
  3886. break;
  3887. case "PrevPage":
  3888. this.pdfViewer.previousPage();
  3889. break;
  3890. case "LastPage":
  3891. this.page = this.pagesCount;
  3892. break;
  3893. case "FirstPage":
  3894. this.page = 1;
  3895. break;
  3896. default:
  3897. break;
  3898. }
  3899. this.eventBus.dispatch("namedaction", {
  3900. source: this,
  3901. action
  3902. });
  3903. }
  3904. async executeSetOCGState(action) {
  3905. if (!this.pdfDocument) {
  3906. return;
  3907. }
  3908. const pdfDocument = this.pdfDocument,
  3909. optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  3910. if (pdfDocument !== this.pdfDocument) {
  3911. return;
  3912. }
  3913. optionalContentConfig.setOCGState(action);
  3914. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  3915. }
  3916. static #isValidExplicitDest(dest) {
  3917. if (!Array.isArray(dest) || dest.length < 2) {
  3918. return false;
  3919. }
  3920. const [page, zoom, ...args] = dest;
  3921. if (!(typeof page === "object" && Number.isInteger(page?.num) && Number.isInteger(page?.gen)) && !Number.isInteger(page)) {
  3922. return false;
  3923. }
  3924. if (!(typeof zoom === "object" && typeof zoom?.name === "string")) {
  3925. return false;
  3926. }
  3927. const argsLen = args.length;
  3928. let allowNull = true;
  3929. switch (zoom.name) {
  3930. case "XYZ":
  3931. if (argsLen < 2 || argsLen > 3) {
  3932. return false;
  3933. }
  3934. break;
  3935. case "Fit":
  3936. case "FitB":
  3937. return argsLen === 0;
  3938. case "FitH":
  3939. case "FitBH":
  3940. case "FitV":
  3941. case "FitBV":
  3942. if (argsLen > 1) {
  3943. return false;
  3944. }
  3945. break;
  3946. case "FitR":
  3947. if (argsLen !== 4) {
  3948. return false;
  3949. }
  3950. allowNull = false;
  3951. break;
  3952. default:
  3953. return false;
  3954. }
  3955. for (const arg of args) {
  3956. if (!(typeof arg === "number" || allowNull && arg === null)) {
  3957. return false;
  3958. }
  3959. }
  3960. return true;
  3961. }
  3962. }
  3963. class SimpleLinkService extends PDFLinkService {
  3964. setDocument(pdfDocument, baseUrl = null) {}
  3965. }
  3966. // EXTERNAL MODULE: ./node_modules/core-js/modules/es.promise.with-resolvers.js
  3967. var es_promise_with_resolvers = __webpack_require__(4628);
  3968. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.constructor.js
  3969. var esnext_iterator_constructor = __webpack_require__(8992);
  3970. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.some.js
  3971. var esnext_iterator_some = __webpack_require__(7550);
  3972. ;// ./web/pdfjs.js
  3973. const {
  3974. AbortException,
  3975. AnnotationEditorLayer,
  3976. AnnotationEditorParamsType,
  3977. AnnotationEditorType,
  3978. AnnotationEditorUIManager,
  3979. AnnotationLayer,
  3980. AnnotationMode,
  3981. build,
  3982. CMapCompressionType,
  3983. ColorPicker,
  3984. createValidAbsoluteUrl,
  3985. DOMSVGFactory,
  3986. DrawLayer,
  3987. FeatureTest,
  3988. fetchData,
  3989. getDocument,
  3990. getFilenameFromUrl,
  3991. getPdfFilenameFromUrl: pdfjs_getPdfFilenameFromUrl,
  3992. getXfaPageViewport,
  3993. GlobalWorkerOptions,
  3994. ImageKind,
  3995. InvalidPDFException,
  3996. isDataScheme,
  3997. isPdfFile,
  3998. MissingPDFException,
  3999. noContextMenu,
  4000. normalizeUnicode,
  4001. OPS,
  4002. OutputScale,
  4003. PasswordResponses,
  4004. PDFDataRangeTransport,
  4005. PDFDateString,
  4006. PDFWorker,
  4007. PermissionFlag,
  4008. PixelsPerInch,
  4009. RenderingCancelledException,
  4010. setLayerDimensions,
  4011. shadow,
  4012. TextLayer,
  4013. UnexpectedResponseException,
  4014. Util,
  4015. VerbosityLevel,
  4016. version,
  4017. XfaLayer
  4018. } = globalThis.pdfjsLib;
  4019. ;// ./web/event_utils.js
  4020. const WaitOnType = {
  4021. EVENT: "event",
  4022. TIMEOUT: "timeout"
  4023. };
  4024. async function waitOnEventOrTimeout({
  4025. target,
  4026. name,
  4027. delay = 0
  4028. }) {
  4029. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  4030. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  4031. }
  4032. const {
  4033. promise,
  4034. resolve
  4035. } = Promise.withResolvers();
  4036. const ac = new AbortController();
  4037. function handler(type) {
  4038. ac.abort();
  4039. clearTimeout(timeout);
  4040. resolve(type);
  4041. }
  4042. const evtMethod = target instanceof EventBus ? "_on" : "addEventListener";
  4043. target[evtMethod](name, handler.bind(null, WaitOnType.EVENT), {
  4044. signal: ac.signal
  4045. });
  4046. const timeout = setTimeout(handler.bind(null, WaitOnType.TIMEOUT), delay);
  4047. return promise;
  4048. }
  4049. class EventBus {
  4050. #listeners = Object.create(null);
  4051. on(eventName, listener, options = null) {
  4052. this._on(eventName, listener, {
  4053. external: true,
  4054. once: options?.once,
  4055. signal: options?.signal
  4056. });
  4057. }
  4058. off(eventName, listener, options = null) {
  4059. this._off(eventName, listener);
  4060. }
  4061. dispatch(eventName, data) {
  4062. const eventListeners = this.#listeners[eventName];
  4063. if (!eventListeners || eventListeners.length === 0) {
  4064. return;
  4065. }
  4066. let externalListeners;
  4067. for (const {
  4068. listener,
  4069. external,
  4070. once
  4071. } of eventListeners.slice(0)) {
  4072. if (once) {
  4073. this._off(eventName, listener);
  4074. }
  4075. if (external) {
  4076. (externalListeners ||= []).push(listener);
  4077. continue;
  4078. }
  4079. listener(data);
  4080. }
  4081. if (externalListeners) {
  4082. for (const listener of externalListeners) {
  4083. listener(data);
  4084. }
  4085. externalListeners = null;
  4086. }
  4087. }
  4088. _on(eventName, listener, options = null) {
  4089. let rmAbort = null;
  4090. if (options?.signal instanceof AbortSignal) {
  4091. const {
  4092. signal
  4093. } = options;
  4094. if (signal.aborted) {
  4095. console.error("Cannot use an `aborted` signal.");
  4096. return;
  4097. }
  4098. const onAbort = () => this._off(eventName, listener);
  4099. rmAbort = () => signal.removeEventListener("abort", onAbort);
  4100. signal.addEventListener("abort", onAbort);
  4101. }
  4102. const eventListeners = this.#listeners[eventName] ||= [];
  4103. eventListeners.push({
  4104. listener,
  4105. external: options?.external === true,
  4106. once: options?.once === true,
  4107. rmAbort
  4108. });
  4109. }
  4110. _off(eventName, listener, options = null) {
  4111. const eventListeners = this.#listeners[eventName];
  4112. if (!eventListeners) {
  4113. return;
  4114. }
  4115. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  4116. const evt = eventListeners[i];
  4117. if (evt.listener === listener) {
  4118. evt.rmAbort?.();
  4119. eventListeners.splice(i, 1);
  4120. return;
  4121. }
  4122. }
  4123. }
  4124. }
  4125. class FirefoxEventBus extends EventBus {
  4126. #externalServices;
  4127. #globalEventNames;
  4128. #isInAutomation;
  4129. constructor(globalEventNames, externalServices, isInAutomation) {
  4130. super();
  4131. this.#globalEventNames = globalEventNames;
  4132. this.#externalServices = externalServices;
  4133. this.#isInAutomation = isInAutomation;
  4134. }
  4135. dispatch(eventName, data) {
  4136. throw new Error("Not implemented: FirefoxEventBus.dispatch");
  4137. }
  4138. }
  4139. ;// ./web/external_services.js
  4140. class BaseExternalServices {
  4141. updateFindControlState(data) {}
  4142. updateFindMatchesCount(data) {}
  4143. initPassiveLoading() {}
  4144. reportTelemetry(data) {}
  4145. async createL10n() {
  4146. throw new Error("Not implemented: createL10n");
  4147. }
  4148. createScripting() {
  4149. throw new Error("Not implemented: createScripting");
  4150. }
  4151. updateEditorStates(data) {
  4152. throw new Error("Not implemented: updateEditorStates");
  4153. }
  4154. dispatchGlobalEvent(_event) {}
  4155. }
  4156. ;// ./web/preferences.js
  4157. class BasePreferences {
  4158. #defaults = Object.freeze({
  4159. altTextLearnMoreUrl: "",
  4160. annotationEditorMode: 0,
  4161. annotationMode: 2,
  4162. cursorToolOnLoad: 0,
  4163. defaultZoomDelay: 400,
  4164. defaultZoomValue: "",
  4165. disablePageLabels: false,
  4166. enableAltText: false,
  4167. enableAltTextModelDownload: true,
  4168. enableGuessAltText: true,
  4169. enableHighlightFloatingButton: false,
  4170. enableNewAltTextWhenAddingImage: true,
  4171. enablePermissions: false,
  4172. enablePrintAutoRotate: true,
  4173. enableScripting: true,
  4174. enableUpdatedAddImage: false,
  4175. externalLinkTarget: 0,
  4176. highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
  4177. historyUpdateUrl: false,
  4178. ignoreDestinationZoom: false,
  4179. forcePageColors: false,
  4180. pageColorsBackground: "Canvas",
  4181. pageColorsForeground: "CanvasText",
  4182. pdfBugEnabled: false,
  4183. sidebarViewOnLoad: -1,
  4184. scrollModeOnLoad: -1,
  4185. spreadModeOnLoad: -1,
  4186. textLayerMode: 1,
  4187. viewOnLoad: 0,
  4188. disableAutoFetch: false,
  4189. disableFontFace: false,
  4190. disableRange: false,
  4191. disableStream: false,
  4192. enableHWA: true,
  4193. enableXfa: true,
  4194. viewerCssTheme: 0
  4195. });
  4196. #initializedPromise = null;
  4197. constructor() {
  4198. this.#initializedPromise = this._readFromStorage(this.#defaults).then(({
  4199. browserPrefs,
  4200. prefs
  4201. }) => {
  4202. if (AppOptions._checkDisablePreferences()) {
  4203. return;
  4204. }
  4205. AppOptions.setAll({
  4206. ...browserPrefs,
  4207. ...prefs
  4208. }, true);
  4209. });
  4210. }
  4211. async _writeToStorage(prefObj) {
  4212. throw new Error("Not implemented: _writeToStorage");
  4213. }
  4214. async _readFromStorage(prefObj) {
  4215. throw new Error("Not implemented: _readFromStorage");
  4216. }
  4217. async reset() {
  4218. await this.#initializedPromise;
  4219. AppOptions.setAll(this.#defaults, true);
  4220. await this._writeToStorage(this.#defaults);
  4221. }
  4222. async set(name, value) {
  4223. await this.#initializedPromise;
  4224. AppOptions.setAll({
  4225. [name]: value
  4226. }, true);
  4227. await this._writeToStorage(AppOptions.getAll(OptionKind.PREFERENCE));
  4228. }
  4229. async get(name) {
  4230. await this.#initializedPromise;
  4231. return AppOptions.get(name);
  4232. }
  4233. get initializedPromise() {
  4234. return this.#initializedPromise;
  4235. }
  4236. }
  4237. ;// ./node_modules/@fluent/bundle/esm/types.js
  4238. class FluentType {
  4239. constructor(value) {
  4240. this.value = value;
  4241. }
  4242. valueOf() {
  4243. return this.value;
  4244. }
  4245. }
  4246. class FluentNone extends FluentType {
  4247. constructor(value = "???") {
  4248. super(value);
  4249. }
  4250. toString(scope) {
  4251. return `{${this.value}}`;
  4252. }
  4253. }
  4254. class FluentNumber extends FluentType {
  4255. constructor(value, opts = {}) {
  4256. super(value);
  4257. this.opts = opts;
  4258. }
  4259. toString(scope) {
  4260. try {
  4261. const nf = scope.memoizeIntlObject(Intl.NumberFormat, this.opts);
  4262. return nf.format(this.value);
  4263. } catch (err) {
  4264. scope.reportError(err);
  4265. return this.value.toString(10);
  4266. }
  4267. }
  4268. }
  4269. class FluentDateTime extends FluentType {
  4270. constructor(value, opts = {}) {
  4271. super(value);
  4272. this.opts = opts;
  4273. }
  4274. toString(scope) {
  4275. try {
  4276. const dtf = scope.memoizeIntlObject(Intl.DateTimeFormat, this.opts);
  4277. return dtf.format(this.value);
  4278. } catch (err) {
  4279. scope.reportError(err);
  4280. return new Date(this.value).toISOString();
  4281. }
  4282. }
  4283. }
  4284. ;// ./node_modules/@fluent/bundle/esm/resolver.js
  4285. const MAX_PLACEABLES = 100;
  4286. const FSI = "\u2068";
  4287. const PDI = "\u2069";
  4288. function match(scope, selector, key) {
  4289. if (key === selector) {
  4290. return true;
  4291. }
  4292. if (key instanceof FluentNumber && selector instanceof FluentNumber && key.value === selector.value) {
  4293. return true;
  4294. }
  4295. if (selector instanceof FluentNumber && typeof key === "string") {
  4296. let category = scope.memoizeIntlObject(Intl.PluralRules, selector.opts).select(selector.value);
  4297. if (key === category) {
  4298. return true;
  4299. }
  4300. }
  4301. return false;
  4302. }
  4303. function getDefault(scope, variants, star) {
  4304. if (variants[star]) {
  4305. return resolvePattern(scope, variants[star].value);
  4306. }
  4307. scope.reportError(new RangeError("No default"));
  4308. return new FluentNone();
  4309. }
  4310. function getArguments(scope, args) {
  4311. const positional = [];
  4312. const named = Object.create(null);
  4313. for (const arg of args) {
  4314. if (arg.type === "narg") {
  4315. named[arg.name] = resolveExpression(scope, arg.value);
  4316. } else {
  4317. positional.push(resolveExpression(scope, arg));
  4318. }
  4319. }
  4320. return {
  4321. positional,
  4322. named
  4323. };
  4324. }
  4325. function resolveExpression(scope, expr) {
  4326. switch (expr.type) {
  4327. case "str":
  4328. return expr.value;
  4329. case "num":
  4330. return new FluentNumber(expr.value, {
  4331. minimumFractionDigits: expr.precision
  4332. });
  4333. case "var":
  4334. return resolveVariableReference(scope, expr);
  4335. case "mesg":
  4336. return resolveMessageReference(scope, expr);
  4337. case "term":
  4338. return resolveTermReference(scope, expr);
  4339. case "func":
  4340. return resolveFunctionReference(scope, expr);
  4341. case "select":
  4342. return resolveSelectExpression(scope, expr);
  4343. default:
  4344. return new FluentNone();
  4345. }
  4346. }
  4347. function resolveVariableReference(scope, {
  4348. name
  4349. }) {
  4350. let arg;
  4351. if (scope.params) {
  4352. if (Object.prototype.hasOwnProperty.call(scope.params, name)) {
  4353. arg = scope.params[name];
  4354. } else {
  4355. return new FluentNone(`$${name}`);
  4356. }
  4357. } else if (scope.args && Object.prototype.hasOwnProperty.call(scope.args, name)) {
  4358. arg = scope.args[name];
  4359. } else {
  4360. scope.reportError(new ReferenceError(`Unknown variable: $${name}`));
  4361. return new FluentNone(`$${name}`);
  4362. }
  4363. if (arg instanceof FluentType) {
  4364. return arg;
  4365. }
  4366. switch (typeof arg) {
  4367. case "string":
  4368. return arg;
  4369. case "number":
  4370. return new FluentNumber(arg);
  4371. case "object":
  4372. if (arg instanceof Date) {
  4373. return new FluentDateTime(arg.getTime());
  4374. }
  4375. default:
  4376. scope.reportError(new TypeError(`Variable type not supported: $${name}, ${typeof arg}`));
  4377. return new FluentNone(`$${name}`);
  4378. }
  4379. }
  4380. function resolveMessageReference(scope, {
  4381. name,
  4382. attr
  4383. }) {
  4384. const message = scope.bundle._messages.get(name);
  4385. if (!message) {
  4386. scope.reportError(new ReferenceError(`Unknown message: ${name}`));
  4387. return new FluentNone(name);
  4388. }
  4389. if (attr) {
  4390. const attribute = message.attributes[attr];
  4391. if (attribute) {
  4392. return resolvePattern(scope, attribute);
  4393. }
  4394. scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
  4395. return new FluentNone(`${name}.${attr}`);
  4396. }
  4397. if (message.value) {
  4398. return resolvePattern(scope, message.value);
  4399. }
  4400. scope.reportError(new ReferenceError(`No value: ${name}`));
  4401. return new FluentNone(name);
  4402. }
  4403. function resolveTermReference(scope, {
  4404. name,
  4405. attr,
  4406. args
  4407. }) {
  4408. const id = `-${name}`;
  4409. const term = scope.bundle._terms.get(id);
  4410. if (!term) {
  4411. scope.reportError(new ReferenceError(`Unknown term: ${id}`));
  4412. return new FluentNone(id);
  4413. }
  4414. if (attr) {
  4415. const attribute = term.attributes[attr];
  4416. if (attribute) {
  4417. scope.params = getArguments(scope, args).named;
  4418. const resolved = resolvePattern(scope, attribute);
  4419. scope.params = null;
  4420. return resolved;
  4421. }
  4422. scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
  4423. return new FluentNone(`${id}.${attr}`);
  4424. }
  4425. scope.params = getArguments(scope, args).named;
  4426. const resolved = resolvePattern(scope, term.value);
  4427. scope.params = null;
  4428. return resolved;
  4429. }
  4430. function resolveFunctionReference(scope, {
  4431. name,
  4432. args
  4433. }) {
  4434. let func = scope.bundle._functions[name];
  4435. if (!func) {
  4436. scope.reportError(new ReferenceError(`Unknown function: ${name}()`));
  4437. return new FluentNone(`${name}()`);
  4438. }
  4439. if (typeof func !== "function") {
  4440. scope.reportError(new TypeError(`Function ${name}() is not callable`));
  4441. return new FluentNone(`${name}()`);
  4442. }
  4443. try {
  4444. let resolved = getArguments(scope, args);
  4445. return func(resolved.positional, resolved.named);
  4446. } catch (err) {
  4447. scope.reportError(err);
  4448. return new FluentNone(`${name}()`);
  4449. }
  4450. }
  4451. function resolveSelectExpression(scope, {
  4452. selector,
  4453. variants,
  4454. star
  4455. }) {
  4456. let sel = resolveExpression(scope, selector);
  4457. if (sel instanceof FluentNone) {
  4458. return getDefault(scope, variants, star);
  4459. }
  4460. for (const variant of variants) {
  4461. const key = resolveExpression(scope, variant.key);
  4462. if (match(scope, sel, key)) {
  4463. return resolvePattern(scope, variant.value);
  4464. }
  4465. }
  4466. return getDefault(scope, variants, star);
  4467. }
  4468. function resolveComplexPattern(scope, ptn) {
  4469. if (scope.dirty.has(ptn)) {
  4470. scope.reportError(new RangeError("Cyclic reference"));
  4471. return new FluentNone();
  4472. }
  4473. scope.dirty.add(ptn);
  4474. const result = [];
  4475. const useIsolating = scope.bundle._useIsolating && ptn.length > 1;
  4476. for (const elem of ptn) {
  4477. if (typeof elem === "string") {
  4478. result.push(scope.bundle._transform(elem));
  4479. continue;
  4480. }
  4481. scope.placeables++;
  4482. if (scope.placeables > MAX_PLACEABLES) {
  4483. scope.dirty.delete(ptn);
  4484. throw new RangeError(`Too many placeables expanded: ${scope.placeables}, ` + `max allowed is ${MAX_PLACEABLES}`);
  4485. }
  4486. if (useIsolating) {
  4487. result.push(FSI);
  4488. }
  4489. result.push(resolveExpression(scope, elem).toString(scope));
  4490. if (useIsolating) {
  4491. result.push(PDI);
  4492. }
  4493. }
  4494. scope.dirty.delete(ptn);
  4495. return result.join("");
  4496. }
  4497. function resolvePattern(scope, value) {
  4498. if (typeof value === "string") {
  4499. return scope.bundle._transform(value);
  4500. }
  4501. return resolveComplexPattern(scope, value);
  4502. }
  4503. ;// ./node_modules/@fluent/bundle/esm/scope.js
  4504. class Scope {
  4505. constructor(bundle, errors, args) {
  4506. this.dirty = new WeakSet();
  4507. this.params = null;
  4508. this.placeables = 0;
  4509. this.bundle = bundle;
  4510. this.errors = errors;
  4511. this.args = args;
  4512. }
  4513. reportError(error) {
  4514. if (!this.errors || !(error instanceof Error)) {
  4515. throw error;
  4516. }
  4517. this.errors.push(error);
  4518. }
  4519. memoizeIntlObject(ctor, opts) {
  4520. let cache = this.bundle._intls.get(ctor);
  4521. if (!cache) {
  4522. cache = {};
  4523. this.bundle._intls.set(ctor, cache);
  4524. }
  4525. let id = JSON.stringify(opts);
  4526. if (!cache[id]) {
  4527. cache[id] = new ctor(this.bundle.locales, opts);
  4528. }
  4529. return cache[id];
  4530. }
  4531. }
  4532. ;// ./node_modules/@fluent/bundle/esm/builtins.js
  4533. function values(opts, allowed) {
  4534. const unwrapped = Object.create(null);
  4535. for (const [name, opt] of Object.entries(opts)) {
  4536. if (allowed.includes(name)) {
  4537. unwrapped[name] = opt.valueOf();
  4538. }
  4539. }
  4540. return unwrapped;
  4541. }
  4542. const NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"];
  4543. function NUMBER(args, opts) {
  4544. let arg = args[0];
  4545. if (arg instanceof FluentNone) {
  4546. return new FluentNone(`NUMBER(${arg.valueOf()})`);
  4547. }
  4548. if (arg instanceof FluentNumber) {
  4549. return new FluentNumber(arg.valueOf(), {
  4550. ...arg.opts,
  4551. ...values(opts, NUMBER_ALLOWED)
  4552. });
  4553. }
  4554. if (arg instanceof FluentDateTime) {
  4555. return new FluentNumber(arg.valueOf(), {
  4556. ...values(opts, NUMBER_ALLOWED)
  4557. });
  4558. }
  4559. throw new TypeError("Invalid argument to NUMBER");
  4560. }
  4561. const DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"];
  4562. function DATETIME(args, opts) {
  4563. let arg = args[0];
  4564. if (arg instanceof FluentNone) {
  4565. return new FluentNone(`DATETIME(${arg.valueOf()})`);
  4566. }
  4567. if (arg instanceof FluentDateTime) {
  4568. return new FluentDateTime(arg.valueOf(), {
  4569. ...arg.opts,
  4570. ...values(opts, DATETIME_ALLOWED)
  4571. });
  4572. }
  4573. if (arg instanceof FluentNumber) {
  4574. return new FluentDateTime(arg.valueOf(), {
  4575. ...values(opts, DATETIME_ALLOWED)
  4576. });
  4577. }
  4578. throw new TypeError("Invalid argument to DATETIME");
  4579. }
  4580. ;// ./node_modules/@fluent/bundle/esm/memoizer.js
  4581. const cache = new Map();
  4582. function getMemoizerForLocale(locales) {
  4583. const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales;
  4584. let memoizer = cache.get(stringLocale);
  4585. if (memoizer === undefined) {
  4586. memoizer = new Map();
  4587. cache.set(stringLocale, memoizer);
  4588. }
  4589. return memoizer;
  4590. }
  4591. ;// ./node_modules/@fluent/bundle/esm/bundle.js
  4592. class FluentBundle {
  4593. constructor(locales, {
  4594. functions,
  4595. useIsolating = true,
  4596. transform = v => v
  4597. } = {}) {
  4598. this._terms = new Map();
  4599. this._messages = new Map();
  4600. this.locales = Array.isArray(locales) ? locales : [locales];
  4601. this._functions = {
  4602. NUMBER: NUMBER,
  4603. DATETIME: DATETIME,
  4604. ...functions
  4605. };
  4606. this._useIsolating = useIsolating;
  4607. this._transform = transform;
  4608. this._intls = getMemoizerForLocale(locales);
  4609. }
  4610. hasMessage(id) {
  4611. return this._messages.has(id);
  4612. }
  4613. getMessage(id) {
  4614. return this._messages.get(id);
  4615. }
  4616. addResource(res, {
  4617. allowOverrides = false
  4618. } = {}) {
  4619. const errors = [];
  4620. for (let i = 0; i < res.body.length; i++) {
  4621. let entry = res.body[i];
  4622. if (entry.id.startsWith("-")) {
  4623. if (allowOverrides === false && this._terms.has(entry.id)) {
  4624. errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`));
  4625. continue;
  4626. }
  4627. this._terms.set(entry.id, entry);
  4628. } else {
  4629. if (allowOverrides === false && this._messages.has(entry.id)) {
  4630. errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`));
  4631. continue;
  4632. }
  4633. this._messages.set(entry.id, entry);
  4634. }
  4635. }
  4636. return errors;
  4637. }
  4638. formatPattern(pattern, args = null, errors = null) {
  4639. if (typeof pattern === "string") {
  4640. return this._transform(pattern);
  4641. }
  4642. let scope = new Scope(this, errors, args);
  4643. try {
  4644. let value = resolveComplexPattern(scope, pattern);
  4645. return value.toString(scope);
  4646. } catch (err) {
  4647. if (scope.errors && err instanceof Error) {
  4648. scope.errors.push(err);
  4649. return new FluentNone().toString(scope);
  4650. }
  4651. throw err;
  4652. }
  4653. }
  4654. }
  4655. ;// ./node_modules/@fluent/bundle/esm/resource.js
  4656. const RE_MESSAGE_START = /^(-?[a-zA-Z][\w-]*) *= */gm;
  4657. const RE_ATTRIBUTE_START = /\.([a-zA-Z][\w-]*) *= */y;
  4658. const RE_VARIANT_START = /\*?\[/y;
  4659. const RE_NUMBER_LITERAL = /(-?[0-9]+(?:\.([0-9]+))?)/y;
  4660. const RE_IDENTIFIER = /([a-zA-Z][\w-]*)/y;
  4661. const RE_REFERENCE = /([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y;
  4662. const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/;
  4663. const RE_TEXT_RUN = /([^{}\n\r]+)/y;
  4664. const RE_STRING_RUN = /([^\\"\n\r]*)/y;
  4665. const RE_STRING_ESCAPE = /\\([\\"])/y;
  4666. const RE_UNICODE_ESCAPE = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y;
  4667. const RE_LEADING_NEWLINES = /^\n+/;
  4668. const RE_TRAILING_SPACES = / +$/;
  4669. const RE_BLANK_LINES = / *\r?\n/g;
  4670. const RE_INDENT = /( *)$/;
  4671. const TOKEN_BRACE_OPEN = /{\s*/y;
  4672. const TOKEN_BRACE_CLOSE = /\s*}/y;
  4673. const TOKEN_BRACKET_OPEN = /\[\s*/y;
  4674. const TOKEN_BRACKET_CLOSE = /\s*] */y;
  4675. const TOKEN_PAREN_OPEN = /\s*\(\s*/y;
  4676. const TOKEN_ARROW = /\s*->\s*/y;
  4677. const TOKEN_COLON = /\s*:\s*/y;
  4678. const TOKEN_COMMA = /\s*,?\s*/y;
  4679. const TOKEN_BLANK = /\s+/y;
  4680. class FluentResource {
  4681. constructor(source) {
  4682. this.body = [];
  4683. RE_MESSAGE_START.lastIndex = 0;
  4684. let cursor = 0;
  4685. while (true) {
  4686. let next = RE_MESSAGE_START.exec(source);
  4687. if (next === null) {
  4688. break;
  4689. }
  4690. cursor = RE_MESSAGE_START.lastIndex;
  4691. try {
  4692. this.body.push(parseMessage(next[1]));
  4693. } catch (err) {
  4694. if (err instanceof SyntaxError) {
  4695. continue;
  4696. }
  4697. throw err;
  4698. }
  4699. }
  4700. function test(re) {
  4701. re.lastIndex = cursor;
  4702. return re.test(source);
  4703. }
  4704. function consumeChar(char, errorClass) {
  4705. if (source[cursor] === char) {
  4706. cursor++;
  4707. return true;
  4708. }
  4709. if (errorClass) {
  4710. throw new errorClass(`Expected ${char}`);
  4711. }
  4712. return false;
  4713. }
  4714. function consumeToken(re, errorClass) {
  4715. if (test(re)) {
  4716. cursor = re.lastIndex;
  4717. return true;
  4718. }
  4719. if (errorClass) {
  4720. throw new errorClass(`Expected ${re.toString()}`);
  4721. }
  4722. return false;
  4723. }
  4724. function match(re) {
  4725. re.lastIndex = cursor;
  4726. let result = re.exec(source);
  4727. if (result === null) {
  4728. throw new SyntaxError(`Expected ${re.toString()}`);
  4729. }
  4730. cursor = re.lastIndex;
  4731. return result;
  4732. }
  4733. function match1(re) {
  4734. return match(re)[1];
  4735. }
  4736. function parseMessage(id) {
  4737. let value = parsePattern();
  4738. let attributes = parseAttributes();
  4739. if (value === null && Object.keys(attributes).length === 0) {
  4740. throw new SyntaxError("Expected message value or attributes");
  4741. }
  4742. return {
  4743. id,
  4744. value,
  4745. attributes
  4746. };
  4747. }
  4748. function parseAttributes() {
  4749. let attrs = Object.create(null);
  4750. while (test(RE_ATTRIBUTE_START)) {
  4751. let name = match1(RE_ATTRIBUTE_START);
  4752. let value = parsePattern();
  4753. if (value === null) {
  4754. throw new SyntaxError("Expected attribute value");
  4755. }
  4756. attrs[name] = value;
  4757. }
  4758. return attrs;
  4759. }
  4760. function parsePattern() {
  4761. let first;
  4762. if (test(RE_TEXT_RUN)) {
  4763. first = match1(RE_TEXT_RUN);
  4764. }
  4765. if (source[cursor] === "{" || source[cursor] === "}") {
  4766. return parsePatternElements(first ? [first] : [], Infinity);
  4767. }
  4768. let indent = parseIndent();
  4769. if (indent) {
  4770. if (first) {
  4771. return parsePatternElements([first, indent], indent.length);
  4772. }
  4773. indent.value = trim(indent.value, RE_LEADING_NEWLINES);
  4774. return parsePatternElements([indent], indent.length);
  4775. }
  4776. if (first) {
  4777. return trim(first, RE_TRAILING_SPACES);
  4778. }
  4779. return null;
  4780. }
  4781. function parsePatternElements(elements = [], commonIndent) {
  4782. while (true) {
  4783. if (test(RE_TEXT_RUN)) {
  4784. elements.push(match1(RE_TEXT_RUN));
  4785. continue;
  4786. }
  4787. if (source[cursor] === "{") {
  4788. elements.push(parsePlaceable());
  4789. continue;
  4790. }
  4791. if (source[cursor] === "}") {
  4792. throw new SyntaxError("Unbalanced closing brace");
  4793. }
  4794. let indent = parseIndent();
  4795. if (indent) {
  4796. elements.push(indent);
  4797. commonIndent = Math.min(commonIndent, indent.length);
  4798. continue;
  4799. }
  4800. break;
  4801. }
  4802. let lastIndex = elements.length - 1;
  4803. let lastElement = elements[lastIndex];
  4804. if (typeof lastElement === "string") {
  4805. elements[lastIndex] = trim(lastElement, RE_TRAILING_SPACES);
  4806. }
  4807. let baked = [];
  4808. for (let element of elements) {
  4809. if (element instanceof Indent) {
  4810. element = element.value.slice(0, element.value.length - commonIndent);
  4811. }
  4812. if (element) {
  4813. baked.push(element);
  4814. }
  4815. }
  4816. return baked;
  4817. }
  4818. function parsePlaceable() {
  4819. consumeToken(TOKEN_BRACE_OPEN, SyntaxError);
  4820. let selector = parseInlineExpression();
  4821. if (consumeToken(TOKEN_BRACE_CLOSE)) {
  4822. return selector;
  4823. }
  4824. if (consumeToken(TOKEN_ARROW)) {
  4825. let variants = parseVariants();
  4826. consumeToken(TOKEN_BRACE_CLOSE, SyntaxError);
  4827. return {
  4828. type: "select",
  4829. selector,
  4830. ...variants
  4831. };
  4832. }
  4833. throw new SyntaxError("Unclosed placeable");
  4834. }
  4835. function parseInlineExpression() {
  4836. if (source[cursor] === "{") {
  4837. return parsePlaceable();
  4838. }
  4839. if (test(RE_REFERENCE)) {
  4840. let [, sigil, name, attr = null] = match(RE_REFERENCE);
  4841. if (sigil === "$") {
  4842. return {
  4843. type: "var",
  4844. name
  4845. };
  4846. }
  4847. if (consumeToken(TOKEN_PAREN_OPEN)) {
  4848. let args = parseArguments();
  4849. if (sigil === "-") {
  4850. return {
  4851. type: "term",
  4852. name,
  4853. attr,
  4854. args
  4855. };
  4856. }
  4857. if (RE_FUNCTION_NAME.test(name)) {
  4858. return {
  4859. type: "func",
  4860. name,
  4861. args
  4862. };
  4863. }
  4864. throw new SyntaxError("Function names must be all upper-case");
  4865. }
  4866. if (sigil === "-") {
  4867. return {
  4868. type: "term",
  4869. name,
  4870. attr,
  4871. args: []
  4872. };
  4873. }
  4874. return {
  4875. type: "mesg",
  4876. name,
  4877. attr
  4878. };
  4879. }
  4880. return parseLiteral();
  4881. }
  4882. function parseArguments() {
  4883. let args = [];
  4884. while (true) {
  4885. switch (source[cursor]) {
  4886. case ")":
  4887. cursor++;
  4888. return args;
  4889. case undefined:
  4890. throw new SyntaxError("Unclosed argument list");
  4891. }
  4892. args.push(parseArgument());
  4893. consumeToken(TOKEN_COMMA);
  4894. }
  4895. }
  4896. function parseArgument() {
  4897. let expr = parseInlineExpression();
  4898. if (expr.type !== "mesg") {
  4899. return expr;
  4900. }
  4901. if (consumeToken(TOKEN_COLON)) {
  4902. return {
  4903. type: "narg",
  4904. name: expr.name,
  4905. value: parseLiteral()
  4906. };
  4907. }
  4908. return expr;
  4909. }
  4910. function parseVariants() {
  4911. let variants = [];
  4912. let count = 0;
  4913. let star;
  4914. while (test(RE_VARIANT_START)) {
  4915. if (consumeChar("*")) {
  4916. star = count;
  4917. }
  4918. let key = parseVariantKey();
  4919. let value = parsePattern();
  4920. if (value === null) {
  4921. throw new SyntaxError("Expected variant value");
  4922. }
  4923. variants[count++] = {
  4924. key,
  4925. value
  4926. };
  4927. }
  4928. if (count === 0) {
  4929. return null;
  4930. }
  4931. if (star === undefined) {
  4932. throw new SyntaxError("Expected default variant");
  4933. }
  4934. return {
  4935. variants,
  4936. star
  4937. };
  4938. }
  4939. function parseVariantKey() {
  4940. consumeToken(TOKEN_BRACKET_OPEN, SyntaxError);
  4941. let key;
  4942. if (test(RE_NUMBER_LITERAL)) {
  4943. key = parseNumberLiteral();
  4944. } else {
  4945. key = {
  4946. type: "str",
  4947. value: match1(RE_IDENTIFIER)
  4948. };
  4949. }
  4950. consumeToken(TOKEN_BRACKET_CLOSE, SyntaxError);
  4951. return key;
  4952. }
  4953. function parseLiteral() {
  4954. if (test(RE_NUMBER_LITERAL)) {
  4955. return parseNumberLiteral();
  4956. }
  4957. if (source[cursor] === '"') {
  4958. return parseStringLiteral();
  4959. }
  4960. throw new SyntaxError("Invalid expression");
  4961. }
  4962. function parseNumberLiteral() {
  4963. let [, value, fraction = ""] = match(RE_NUMBER_LITERAL);
  4964. let precision = fraction.length;
  4965. return {
  4966. type: "num",
  4967. value: parseFloat(value),
  4968. precision
  4969. };
  4970. }
  4971. function parseStringLiteral() {
  4972. consumeChar('"', SyntaxError);
  4973. let value = "";
  4974. while (true) {
  4975. value += match1(RE_STRING_RUN);
  4976. if (source[cursor] === "\\") {
  4977. value += parseEscapeSequence();
  4978. continue;
  4979. }
  4980. if (consumeChar('"')) {
  4981. return {
  4982. type: "str",
  4983. value
  4984. };
  4985. }
  4986. throw new SyntaxError("Unclosed string literal");
  4987. }
  4988. }
  4989. function parseEscapeSequence() {
  4990. if (test(RE_STRING_ESCAPE)) {
  4991. return match1(RE_STRING_ESCAPE);
  4992. }
  4993. if (test(RE_UNICODE_ESCAPE)) {
  4994. let [, codepoint4, codepoint6] = match(RE_UNICODE_ESCAPE);
  4995. let codepoint = parseInt(codepoint4 || codepoint6, 16);
  4996. return codepoint <= 0xd7ff || 0xe000 <= codepoint ? String.fromCodePoint(codepoint) : "�";
  4997. }
  4998. throw new SyntaxError("Unknown escape sequence");
  4999. }
  5000. function parseIndent() {
  5001. let start = cursor;
  5002. consumeToken(TOKEN_BLANK);
  5003. switch (source[cursor]) {
  5004. case ".":
  5005. case "[":
  5006. case "*":
  5007. case "}":
  5008. case undefined:
  5009. return false;
  5010. case "{":
  5011. return makeIndent(source.slice(start, cursor));
  5012. }
  5013. if (source[cursor - 1] === " ") {
  5014. return makeIndent(source.slice(start, cursor));
  5015. }
  5016. return false;
  5017. }
  5018. function trim(text, re) {
  5019. return text.replace(re, "");
  5020. }
  5021. function makeIndent(blank) {
  5022. let value = blank.replace(RE_BLANK_LINES, "\n");
  5023. let length = RE_INDENT.exec(blank)[1].length;
  5024. return new Indent(value, length);
  5025. }
  5026. }
  5027. }
  5028. class Indent {
  5029. constructor(value, length) {
  5030. this.value = value;
  5031. this.length = length;
  5032. }
  5033. }
  5034. ;// ./node_modules/@fluent/bundle/esm/index.js
  5035. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.map.js
  5036. var esnext_iterator_map = __webpack_require__(1454);
  5037. ;// ./node_modules/@fluent/dom/esm/overlay.js
  5038. const reOverlay = /<|&#?\w+;/;
  5039. const TEXT_LEVEL_ELEMENTS = {
  5040. "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"]
  5041. };
  5042. const LOCALIZABLE_ATTRIBUTES = {
  5043. "http://www.w3.org/1999/xhtml": {
  5044. global: ["title", "aria-label", "aria-valuetext"],
  5045. a: ["download"],
  5046. area: ["download", "alt"],
  5047. input: ["alt", "placeholder"],
  5048. menuitem: ["label"],
  5049. menu: ["label"],
  5050. optgroup: ["label"],
  5051. option: ["label"],
  5052. track: ["label"],
  5053. img: ["alt"],
  5054. textarea: ["placeholder"],
  5055. th: ["abbr"]
  5056. },
  5057. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": {
  5058. global: ["accesskey", "aria-label", "aria-valuetext", "label", "title", "tooltiptext"],
  5059. description: ["value"],
  5060. key: ["key", "keycode"],
  5061. label: ["value"],
  5062. textbox: ["placeholder", "value"]
  5063. }
  5064. };
  5065. function translateElement(element, translation) {
  5066. const {
  5067. value
  5068. } = translation;
  5069. if (typeof value === "string") {
  5070. if (element.localName === "title" && element.namespaceURI === "http://www.w3.org/1999/xhtml") {
  5071. element.textContent = value;
  5072. } else if (!reOverlay.test(value)) {
  5073. element.textContent = value;
  5074. } else {
  5075. const templateElement = element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "template");
  5076. templateElement.innerHTML = value;
  5077. overlayChildNodes(templateElement.content, element);
  5078. }
  5079. }
  5080. overlayAttributes(translation, element);
  5081. }
  5082. function overlayChildNodes(fromFragment, toElement) {
  5083. for (const childNode of fromFragment.childNodes) {
  5084. if (childNode.nodeType === childNode.TEXT_NODE) {
  5085. continue;
  5086. }
  5087. if (childNode.hasAttribute("data-l10n-name")) {
  5088. const sanitized = getNodeForNamedElement(toElement, childNode);
  5089. fromFragment.replaceChild(sanitized, childNode);
  5090. continue;
  5091. }
  5092. if (isElementAllowed(childNode)) {
  5093. const sanitized = createSanitizedElement(childNode);
  5094. fromFragment.replaceChild(sanitized, childNode);
  5095. continue;
  5096. }
  5097. 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.");
  5098. fromFragment.replaceChild(createTextNodeFromTextContent(childNode), childNode);
  5099. }
  5100. toElement.textContent = "";
  5101. toElement.appendChild(fromFragment);
  5102. }
  5103. function hasAttribute(attributes, name) {
  5104. if (!attributes) {
  5105. return false;
  5106. }
  5107. for (let attr of attributes) {
  5108. if (attr.name === name) {
  5109. return true;
  5110. }
  5111. }
  5112. return false;
  5113. }
  5114. function overlayAttributes(fromElement, toElement) {
  5115. const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null;
  5116. for (const attr of Array.from(toElement.attributes)) {
  5117. if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) {
  5118. toElement.removeAttribute(attr.name);
  5119. }
  5120. }
  5121. if (!fromElement.attributes) {
  5122. return;
  5123. }
  5124. for (const attr of Array.from(fromElement.attributes)) {
  5125. if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) {
  5126. toElement.setAttribute(attr.name, attr.value);
  5127. }
  5128. }
  5129. }
  5130. function getNodeForNamedElement(sourceElement, translatedChild) {
  5131. const childName = translatedChild.getAttribute("data-l10n-name");
  5132. const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`);
  5133. if (!sourceChild) {
  5134. console.warn(`An element named "${childName}" wasn't found in the source.`);
  5135. return createTextNodeFromTextContent(translatedChild);
  5136. }
  5137. if (sourceChild.localName !== translatedChild.localName) {
  5138. 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}).`);
  5139. return createTextNodeFromTextContent(translatedChild);
  5140. }
  5141. sourceElement.removeChild(sourceChild);
  5142. const clone = sourceChild.cloneNode(false);
  5143. return shallowPopulateUsing(translatedChild, clone);
  5144. }
  5145. function createSanitizedElement(element) {
  5146. const clone = element.ownerDocument.createElement(element.localName);
  5147. return shallowPopulateUsing(element, clone);
  5148. }
  5149. function createTextNodeFromTextContent(element) {
  5150. return element.ownerDocument.createTextNode(element.textContent);
  5151. }
  5152. function isElementAllowed(element) {
  5153. const allowed = TEXT_LEVEL_ELEMENTS[element.namespaceURI];
  5154. return allowed && allowed.includes(element.localName);
  5155. }
  5156. function isAttrNameLocalizable(name, element, explicitlyAllowed = null) {
  5157. if (explicitlyAllowed && explicitlyAllowed.includes(name)) {
  5158. return true;
  5159. }
  5160. const allowed = LOCALIZABLE_ATTRIBUTES[element.namespaceURI];
  5161. if (!allowed) {
  5162. return false;
  5163. }
  5164. const attrName = name.toLowerCase();
  5165. const elemName = element.localName;
  5166. if (allowed.global.includes(attrName)) {
  5167. return true;
  5168. }
  5169. if (!allowed[elemName]) {
  5170. return false;
  5171. }
  5172. if (allowed[elemName].includes(attrName)) {
  5173. return true;
  5174. }
  5175. if (element.namespaceURI === "http://www.w3.org/1999/xhtml" && elemName === "input" && attrName === "value") {
  5176. const type = element.type.toLowerCase();
  5177. if (type === "submit" || type === "button" || type === "reset") {
  5178. return true;
  5179. }
  5180. }
  5181. return false;
  5182. }
  5183. function shallowPopulateUsing(fromElement, toElement) {
  5184. toElement.textContent = fromElement.textContent;
  5185. overlayAttributes(fromElement, toElement);
  5186. return toElement;
  5187. }
  5188. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.filter.js
  5189. var esnext_iterator_filter = __webpack_require__(4520);
  5190. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.for-each.js
  5191. var esnext_iterator_for_each = __webpack_require__(3949);
  5192. ;// ./node_modules/cached-iterable/src/cached_iterable.mjs
  5193. class CachedIterable extends Array {
  5194. static from(iterable) {
  5195. if (iterable instanceof this) {
  5196. return iterable;
  5197. }
  5198. return new this(iterable);
  5199. }
  5200. }
  5201. ;// ./node_modules/cached-iterable/src/cached_sync_iterable.mjs
  5202. class CachedSyncIterable extends CachedIterable {
  5203. constructor(iterable) {
  5204. super();
  5205. if (Symbol.iterator in Object(iterable)) {
  5206. this.iterator = iterable[Symbol.iterator]();
  5207. } else {
  5208. throw new TypeError("Argument must implement the iteration protocol.");
  5209. }
  5210. }
  5211. [Symbol.iterator]() {
  5212. const cached = this;
  5213. let cur = 0;
  5214. return {
  5215. next() {
  5216. if (cached.length <= cur) {
  5217. cached.push(cached.iterator.next());
  5218. }
  5219. return cached[cur++];
  5220. }
  5221. };
  5222. }
  5223. touchNext(count = 1) {
  5224. let idx = 0;
  5225. while (idx++ < count) {
  5226. const last = this[this.length - 1];
  5227. if (last && last.done) {
  5228. break;
  5229. }
  5230. this.push(this.iterator.next());
  5231. }
  5232. return this[this.length - 1];
  5233. }
  5234. }
  5235. ;// ./node_modules/cached-iterable/src/cached_async_iterable.mjs
  5236. class CachedAsyncIterable extends CachedIterable {
  5237. constructor(iterable) {
  5238. super();
  5239. if (Symbol.asyncIterator in Object(iterable)) {
  5240. this.iterator = iterable[Symbol.asyncIterator]();
  5241. } else if (Symbol.iterator in Object(iterable)) {
  5242. this.iterator = iterable[Symbol.iterator]();
  5243. } else {
  5244. throw new TypeError("Argument must implement the iteration protocol.");
  5245. }
  5246. }
  5247. [Symbol.asyncIterator]() {
  5248. const cached = this;
  5249. let cur = 0;
  5250. return {
  5251. async next() {
  5252. if (cached.length <= cur) {
  5253. cached.push(cached.iterator.next());
  5254. }
  5255. return cached[cur++];
  5256. }
  5257. };
  5258. }
  5259. async touchNext(count = 1) {
  5260. let idx = 0;
  5261. while (idx++ < count) {
  5262. const last = this[this.length - 1];
  5263. if (last && (await last).done) {
  5264. break;
  5265. }
  5266. this.push(this.iterator.next());
  5267. }
  5268. return this[this.length - 1];
  5269. }
  5270. }
  5271. ;// ./node_modules/cached-iterable/src/index.mjs
  5272. ;// ./node_modules/@fluent/dom/esm/localization.js
  5273. class Localization {
  5274. constructor(resourceIds = [], generateBundles) {
  5275. this.resourceIds = resourceIds;
  5276. this.generateBundles = generateBundles;
  5277. this.onChange(true);
  5278. }
  5279. addResourceIds(resourceIds, eager = false) {
  5280. this.resourceIds.push(...resourceIds);
  5281. this.onChange(eager);
  5282. return this.resourceIds.length;
  5283. }
  5284. removeResourceIds(resourceIds) {
  5285. this.resourceIds = this.resourceIds.filter(r => !resourceIds.includes(r));
  5286. this.onChange();
  5287. return this.resourceIds.length;
  5288. }
  5289. async formatWithFallback(keys, method) {
  5290. const translations = [];
  5291. let hasAtLeastOneBundle = false;
  5292. for await (const bundle of this.bundles) {
  5293. hasAtLeastOneBundle = true;
  5294. const missingIds = keysFromBundle(method, bundle, keys, translations);
  5295. if (missingIds.size === 0) {
  5296. break;
  5297. }
  5298. if (typeof console !== "undefined") {
  5299. const locale = bundle.locales[0];
  5300. const ids = Array.from(missingIds).join(", ");
  5301. console.warn(`[fluent] Missing translations in ${locale}: ${ids}`);
  5302. }
  5303. }
  5304. if (!hasAtLeastOneBundle && typeof console !== "undefined") {
  5305. console.warn(`[fluent] Request for keys failed because no resource bundles got generated.
  5306. keys: ${JSON.stringify(keys)}.
  5307. resourceIds: ${JSON.stringify(this.resourceIds)}.`);
  5308. }
  5309. return translations;
  5310. }
  5311. formatMessages(keys) {
  5312. return this.formatWithFallback(keys, messageFromBundle);
  5313. }
  5314. formatValues(keys) {
  5315. return this.formatWithFallback(keys, valueFromBundle);
  5316. }
  5317. async formatValue(id, args) {
  5318. const [val] = await this.formatValues([{
  5319. id,
  5320. args
  5321. }]);
  5322. return val;
  5323. }
  5324. handleEvent() {
  5325. this.onChange();
  5326. }
  5327. onChange(eager = false) {
  5328. this.bundles = CachedAsyncIterable.from(this.generateBundles(this.resourceIds));
  5329. if (eager) {
  5330. this.bundles.touchNext(2);
  5331. }
  5332. }
  5333. }
  5334. function valueFromBundle(bundle, errors, message, args) {
  5335. if (message.value) {
  5336. return bundle.formatPattern(message.value, args, errors);
  5337. }
  5338. return null;
  5339. }
  5340. function messageFromBundle(bundle, errors, message, args) {
  5341. const formatted = {
  5342. value: null,
  5343. attributes: null
  5344. };
  5345. if (message.value) {
  5346. formatted.value = bundle.formatPattern(message.value, args, errors);
  5347. }
  5348. let attrNames = Object.keys(message.attributes);
  5349. if (attrNames.length > 0) {
  5350. formatted.attributes = new Array(attrNames.length);
  5351. for (let [i, name] of attrNames.entries()) {
  5352. let value = bundle.formatPattern(message.attributes[name], args, errors);
  5353. formatted.attributes[i] = {
  5354. name,
  5355. value
  5356. };
  5357. }
  5358. }
  5359. return formatted;
  5360. }
  5361. function keysFromBundle(method, bundle, keys, translations) {
  5362. const messageErrors = [];
  5363. const missingIds = new Set();
  5364. keys.forEach(({
  5365. id,
  5366. args
  5367. }, i) => {
  5368. if (translations[i] !== undefined) {
  5369. return;
  5370. }
  5371. let message = bundle.getMessage(id);
  5372. if (message) {
  5373. messageErrors.length = 0;
  5374. translations[i] = method(bundle, messageErrors, message, args);
  5375. if (messageErrors.length > 0 && typeof console !== "undefined") {
  5376. const locale = bundle.locales[0];
  5377. const errors = messageErrors.join(", ");
  5378. console.warn(`[fluent][resolver] errors in ${locale}/${id}: ${errors}.`);
  5379. }
  5380. } else {
  5381. missingIds.add(id);
  5382. }
  5383. });
  5384. return missingIds;
  5385. }
  5386. ;// ./node_modules/@fluent/dom/esm/dom_localization.js
  5387. const L10NID_ATTR_NAME = "data-l10n-id";
  5388. const L10NARGS_ATTR_NAME = "data-l10n-args";
  5389. const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`;
  5390. class DOMLocalization extends Localization {
  5391. constructor(resourceIds, generateBundles) {
  5392. super(resourceIds, generateBundles);
  5393. this.roots = new Set();
  5394. this.pendingrAF = null;
  5395. this.pendingElements = new Set();
  5396. this.windowElement = null;
  5397. this.mutationObserver = null;
  5398. this.observerConfig = {
  5399. attributes: true,
  5400. characterData: false,
  5401. childList: true,
  5402. subtree: true,
  5403. attributeFilter: [L10NID_ATTR_NAME, L10NARGS_ATTR_NAME]
  5404. };
  5405. }
  5406. onChange(eager = false) {
  5407. super.onChange(eager);
  5408. if (this.roots) {
  5409. this.translateRoots();
  5410. }
  5411. }
  5412. setAttributes(element, id, args) {
  5413. element.setAttribute(L10NID_ATTR_NAME, id);
  5414. if (args) {
  5415. element.setAttribute(L10NARGS_ATTR_NAME, JSON.stringify(args));
  5416. } else {
  5417. element.removeAttribute(L10NARGS_ATTR_NAME);
  5418. }
  5419. return element;
  5420. }
  5421. getAttributes(element) {
  5422. return {
  5423. id: element.getAttribute(L10NID_ATTR_NAME),
  5424. args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
  5425. };
  5426. }
  5427. connectRoot(newRoot) {
  5428. for (const root of this.roots) {
  5429. if (root === newRoot || root.contains(newRoot) || newRoot.contains(root)) {
  5430. throw new Error("Cannot add a root that overlaps with existing root.");
  5431. }
  5432. }
  5433. if (this.windowElement) {
  5434. if (this.windowElement !== newRoot.ownerDocument.defaultView) {
  5435. throw new Error(`Cannot connect a root:
  5436. DOMLocalization already has a root from a different window.`);
  5437. }
  5438. } else {
  5439. this.windowElement = newRoot.ownerDocument.defaultView;
  5440. this.mutationObserver = new this.windowElement.MutationObserver(mutations => this.translateMutations(mutations));
  5441. }
  5442. this.roots.add(newRoot);
  5443. this.mutationObserver.observe(newRoot, this.observerConfig);
  5444. }
  5445. disconnectRoot(root) {
  5446. this.roots.delete(root);
  5447. this.pauseObserving();
  5448. if (this.roots.size === 0) {
  5449. this.mutationObserver = null;
  5450. if (this.windowElement && this.pendingrAF) {
  5451. this.windowElement.cancelAnimationFrame(this.pendingrAF);
  5452. }
  5453. this.windowElement = null;
  5454. this.pendingrAF = null;
  5455. this.pendingElements.clear();
  5456. return true;
  5457. }
  5458. this.resumeObserving();
  5459. return false;
  5460. }
  5461. translateRoots() {
  5462. const roots = Array.from(this.roots);
  5463. return Promise.all(roots.map(root => this.translateFragment(root)));
  5464. }
  5465. pauseObserving() {
  5466. if (!this.mutationObserver) {
  5467. return;
  5468. }
  5469. this.translateMutations(this.mutationObserver.takeRecords());
  5470. this.mutationObserver.disconnect();
  5471. }
  5472. resumeObserving() {
  5473. if (!this.mutationObserver) {
  5474. return;
  5475. }
  5476. for (const root of this.roots) {
  5477. this.mutationObserver.observe(root, this.observerConfig);
  5478. }
  5479. }
  5480. translateMutations(mutations) {
  5481. for (const mutation of mutations) {
  5482. switch (mutation.type) {
  5483. case "attributes":
  5484. if (mutation.target.hasAttribute("data-l10n-id")) {
  5485. this.pendingElements.add(mutation.target);
  5486. }
  5487. break;
  5488. case "childList":
  5489. for (const addedNode of mutation.addedNodes) {
  5490. if (addedNode.nodeType === addedNode.ELEMENT_NODE) {
  5491. if (addedNode.childElementCount) {
  5492. for (const element of this.getTranslatables(addedNode)) {
  5493. this.pendingElements.add(element);
  5494. }
  5495. } else if (addedNode.hasAttribute(L10NID_ATTR_NAME)) {
  5496. this.pendingElements.add(addedNode);
  5497. }
  5498. }
  5499. }
  5500. break;
  5501. }
  5502. }
  5503. if (this.pendingElements.size > 0) {
  5504. if (this.pendingrAF === null) {
  5505. this.pendingrAF = this.windowElement.requestAnimationFrame(() => {
  5506. this.translateElements(Array.from(this.pendingElements));
  5507. this.pendingElements.clear();
  5508. this.pendingrAF = null;
  5509. });
  5510. }
  5511. }
  5512. }
  5513. translateFragment(frag) {
  5514. return this.translateElements(this.getTranslatables(frag));
  5515. }
  5516. async translateElements(elements) {
  5517. if (!elements.length) {
  5518. return undefined;
  5519. }
  5520. const keys = elements.map(this.getKeysForElement);
  5521. const translations = await this.formatMessages(keys);
  5522. return this.applyTranslations(elements, translations);
  5523. }
  5524. applyTranslations(elements, translations) {
  5525. this.pauseObserving();
  5526. for (let i = 0; i < elements.length; i++) {
  5527. if (translations[i] !== undefined) {
  5528. translateElement(elements[i], translations[i]);
  5529. }
  5530. }
  5531. this.resumeObserving();
  5532. }
  5533. getTranslatables(element) {
  5534. const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY));
  5535. if (typeof element.hasAttribute === "function" && element.hasAttribute(L10NID_ATTR_NAME)) {
  5536. nodes.push(element);
  5537. }
  5538. return nodes;
  5539. }
  5540. getKeysForElement(element) {
  5541. return {
  5542. id: element.getAttribute(L10NID_ATTR_NAME),
  5543. args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
  5544. };
  5545. }
  5546. }
  5547. ;// ./node_modules/@fluent/dom/esm/index.js
  5548. ;// ./web/l10n.js
  5549. class L10n {
  5550. #dir;
  5551. #elements = new Set();
  5552. #lang;
  5553. #l10n;
  5554. constructor({
  5555. lang,
  5556. isRTL
  5557. }, l10n = null) {
  5558. this.#lang = L10n.#fixupLangCode(lang);
  5559. this.#l10n = l10n;
  5560. this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr";
  5561. }
  5562. _setL10n(l10n) {
  5563. this.#l10n = l10n;
  5564. }
  5565. getLanguage() {
  5566. return this.#lang;
  5567. }
  5568. getDirection() {
  5569. return this.#dir;
  5570. }
  5571. async get(ids, args = null, fallback) {
  5572. if (Array.isArray(ids)) {
  5573. ids = ids.map(id => ({
  5574. id
  5575. }));
  5576. const messages = await this.#l10n.formatMessages(ids);
  5577. return messages.map(message => message.value);
  5578. }
  5579. const messages = await this.#l10n.formatMessages([{
  5580. id: ids,
  5581. args
  5582. }]);
  5583. return messages[0]?.value || fallback;
  5584. }
  5585. async translate(element) {
  5586. this.#elements.add(element);
  5587. try {
  5588. this.#l10n.connectRoot(element);
  5589. await this.#l10n.translateRoots();
  5590. } catch {}
  5591. }
  5592. async translateOnce(element) {
  5593. try {
  5594. await this.#l10n.translateElements([element]);
  5595. } catch (ex) {
  5596. console.error(`translateOnce: "${ex}".`);
  5597. }
  5598. }
  5599. async destroy() {
  5600. for (const element of this.#elements) {
  5601. this.#l10n.disconnectRoot(element);
  5602. }
  5603. this.#elements.clear();
  5604. this.#l10n.pauseObserving();
  5605. }
  5606. pause() {
  5607. this.#l10n.pauseObserving();
  5608. }
  5609. resume() {
  5610. this.#l10n.resumeObserving();
  5611. }
  5612. static #fixupLangCode(langCode) {
  5613. langCode = langCode?.toLowerCase() || "en-us";
  5614. const PARTIAL_LANG_CODES = {
  5615. en: "en-us",
  5616. es: "es-es",
  5617. fy: "fy-nl",
  5618. ga: "ga-ie",
  5619. gu: "gu-in",
  5620. hi: "hi-in",
  5621. hy: "hy-am",
  5622. nb: "nb-no",
  5623. ne: "ne-np",
  5624. nn: "nn-no",
  5625. pa: "pa-in",
  5626. pt: "pt-pt",
  5627. sv: "sv-se",
  5628. zh: "zh-cn"
  5629. };
  5630. return PARTIAL_LANG_CODES[langCode] || langCode;
  5631. }
  5632. static #isRTL(lang) {
  5633. const shortCode = lang.split("-", 1)[0];
  5634. return ["ar", "he", "fa", "ps", "ur"].includes(shortCode);
  5635. }
  5636. }
  5637. const GenericL10n = null;
  5638. ;// ./web/genericl10n.js
  5639. function createBundle(lang, text) {
  5640. const resource = new FluentResource(text);
  5641. const bundle = new FluentBundle(lang);
  5642. const errors = bundle.addResource(resource);
  5643. if (errors.length) {
  5644. console.error("L10n errors", errors);
  5645. }
  5646. return bundle;
  5647. }
  5648. class genericl10n_GenericL10n extends L10n {
  5649. constructor(lang) {
  5650. super({
  5651. lang
  5652. });
  5653. const generateBundles = !lang ? genericl10n_GenericL10n.#generateBundlesFallback.bind(genericl10n_GenericL10n, this.getLanguage()) : genericl10n_GenericL10n.#generateBundles.bind(genericl10n_GenericL10n, "en-us", this.getLanguage());
  5654. this._setL10n(new DOMLocalization([], generateBundles));
  5655. }
  5656. static async *#generateBundles(defaultLang, baseLang) {
  5657. const {
  5658. baseURL,
  5659. paths
  5660. } = await this.#getPaths();
  5661. const langs = [baseLang];
  5662. if (defaultLang !== baseLang) {
  5663. const shortLang = baseLang.split("-", 1)[0];
  5664. if (shortLang !== baseLang) {
  5665. langs.push(shortLang);
  5666. }
  5667. langs.push(defaultLang);
  5668. }
  5669. for (const lang of langs) {
  5670. const bundle = await this.#createBundle(lang, baseURL, paths);
  5671. if (bundle) {
  5672. yield bundle;
  5673. } else if (lang === "en-us") {
  5674. yield this.#createBundleFallback(lang);
  5675. }
  5676. }
  5677. }
  5678. static async #createBundle(lang, baseURL, paths) {
  5679. const path = paths[lang];
  5680. if (!path) {
  5681. return null;
  5682. }
  5683. const url = new URL(path, baseURL);
  5684. const text = await fetchData(url, "text");
  5685. return createBundle(lang, text);
  5686. }
  5687. static async #getPaths() {
  5688. try {
  5689. const {
  5690. href
  5691. } = document.querySelector(`link[type="application/l10n"]`);
  5692. const paths = await fetchData(href, "json");
  5693. return {
  5694. baseURL: href.replace(/[^/]*$/, "") || "./",
  5695. paths
  5696. };
  5697. } catch {}
  5698. return {
  5699. baseURL: "./",
  5700. paths: Object.create(null)
  5701. };
  5702. }
  5703. static async *#generateBundlesFallback(lang) {
  5704. yield this.#createBundleFallback(lang);
  5705. }
  5706. static async #createBundleFallback(lang) {
  5707. 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-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-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $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-time-string = { DATETIME($dateObj, dateStyle: \"short\", timeStyle: \"medium\") }\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-time-string = { DATETIME($dateObj, dateStyle: \"short\", timeStyle: \"medium\") }\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-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-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-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\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-top-left =\n .aria-label = Top left corner \u2014 resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle \u2014 resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner \u2014 resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right \u2014 resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner \u2014 resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle \u2014 resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner \u2014 resize\npdfjs-editor-resizer-middle-left =\n .aria-label = 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\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here\u2026\npdfjs-editor-new-alt-text-description = Short description for people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn\u2019t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading\u2026\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close";
  5708. return createBundle(lang, text);
  5709. }
  5710. }
  5711. ;// ./web/generic_scripting.js
  5712. async function docProperties(pdfDocument) {
  5713. const url = "",
  5714. baseUrl = url.split("#", 1)[0];
  5715. let {
  5716. info,
  5717. metadata,
  5718. contentDispositionFilename,
  5719. contentLength
  5720. } = await pdfDocument.getMetadata();
  5721. if (!contentLength) {
  5722. const {
  5723. length
  5724. } = await pdfDocument.getDownloadInfo();
  5725. contentLength = length;
  5726. }
  5727. return {
  5728. ...info,
  5729. baseURL: baseUrl,
  5730. filesize: contentLength,
  5731. filename: contentDispositionFilename || getPdfFilenameFromUrl(url),
  5732. metadata: metadata?.getRaw(),
  5733. authors: metadata?.get("dc:creator"),
  5734. numPages: pdfDocument.numPages,
  5735. URL: url
  5736. };
  5737. }
  5738. class GenericScripting {
  5739. constructor(sandboxBundleSrc) {
  5740. this._ready = new Promise((resolve, reject) => {
  5741. const sandbox = import(/*webpackIgnore: true*/sandboxBundleSrc);
  5742. sandbox.then(pdfjsSandbox => {
  5743. resolve(pdfjsSandbox.QuickJSSandbox());
  5744. }).catch(reject);
  5745. });
  5746. }
  5747. async createSandbox(data) {
  5748. const sandbox = await this._ready;
  5749. sandbox.create(data);
  5750. }
  5751. async dispatchEventInSandbox(event) {
  5752. const sandbox = await this._ready;
  5753. setTimeout(() => sandbox.dispatchEvent(event), 0);
  5754. }
  5755. async destroySandbox() {
  5756. const sandbox = await this._ready;
  5757. sandbox.nukeSandbox();
  5758. }
  5759. }
  5760. ;// ./web/genericcom.js
  5761. function initCom(app) {}
  5762. class Preferences extends BasePreferences {
  5763. async _writeToStorage(prefObj) {
  5764. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  5765. }
  5766. async _readFromStorage(prefObj) {
  5767. return {
  5768. prefs: JSON.parse(localStorage.getItem("pdfjs.preferences"))
  5769. };
  5770. }
  5771. }
  5772. class ExternalServices extends BaseExternalServices {
  5773. async createL10n() {
  5774. return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang);
  5775. }
  5776. createScripting() {
  5777. return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
  5778. }
  5779. }
  5780. class MLManager {
  5781. async isEnabledFor(_name) {
  5782. return false;
  5783. }
  5784. async deleteModel(_service) {
  5785. return null;
  5786. }
  5787. isReady(_name) {
  5788. return false;
  5789. }
  5790. guess(_data) {}
  5791. toggleService(_name, _enabled) {}
  5792. static getFakeMLManager(options) {
  5793. return new FakeMLManager(options);
  5794. }
  5795. }
  5796. class FakeMLManager {
  5797. eventBus = null;
  5798. hasProgress = false;
  5799. constructor({
  5800. enableGuessAltText,
  5801. enableAltTextModelDownload
  5802. }) {
  5803. this.enableGuessAltText = enableGuessAltText;
  5804. this.enableAltTextModelDownload = enableAltTextModelDownload;
  5805. }
  5806. setEventBus(eventBus, abortSignal) {
  5807. this.eventBus = eventBus;
  5808. }
  5809. async isEnabledFor(_name) {
  5810. return this.enableGuessAltText;
  5811. }
  5812. async deleteModel(_name) {
  5813. this.enableAltTextModelDownload = false;
  5814. return null;
  5815. }
  5816. async loadModel(_name) {}
  5817. async downloadModel(_name) {
  5818. this.hasProgress = true;
  5819. const {
  5820. promise,
  5821. resolve
  5822. } = Promise.withResolvers();
  5823. const total = 1e8;
  5824. const end = 1.5 * total;
  5825. const increment = 5e6;
  5826. let loaded = 0;
  5827. const id = setInterval(() => {
  5828. loaded += increment;
  5829. if (loaded <= end) {
  5830. this.eventBus.dispatch("loadaiengineprogress", {
  5831. source: this,
  5832. detail: {
  5833. total,
  5834. totalLoaded: loaded,
  5835. finished: loaded + increment >= end
  5836. }
  5837. });
  5838. return;
  5839. }
  5840. clearInterval(id);
  5841. this.hasProgress = false;
  5842. this.enableAltTextModelDownload = true;
  5843. resolve(true);
  5844. }, 900);
  5845. return promise;
  5846. }
  5847. isReady(_name) {
  5848. return this.enableAltTextModelDownload;
  5849. }
  5850. guess({
  5851. request: {
  5852. data
  5853. }
  5854. }) {
  5855. return new Promise(resolve => {
  5856. setTimeout(() => {
  5857. resolve(data ? {
  5858. output: "Fake alt text"
  5859. } : {
  5860. error: true
  5861. });
  5862. }, 3000);
  5863. });
  5864. }
  5865. toggleService(_name, enabled) {
  5866. this.enableGuessAltText = enabled;
  5867. }
  5868. }
  5869. ;// ./web/new_alt_text_manager.js
  5870. class NewAltTextManager {
  5871. #boundCancel = this.#cancel.bind(this);
  5872. #createAutomaticallyButton;
  5873. #currentEditor = null;
  5874. #cancelButton;
  5875. #descriptionContainer;
  5876. #dialog;
  5877. #disclaimer;
  5878. #downloadModel;
  5879. #downloadModelDescription;
  5880. #eventBus;
  5881. #firstTime = false;
  5882. #guessedAltText;
  5883. #hasAI = null;
  5884. #isEditing = null;
  5885. #imagePreview;
  5886. #imageData;
  5887. #isAILoading = false;
  5888. #wasAILoading = false;
  5889. #learnMore;
  5890. #notNowButton;
  5891. #overlayManager;
  5892. #textarea;
  5893. #title;
  5894. #uiManager;
  5895. #previousAltText = null;
  5896. constructor({
  5897. descriptionContainer,
  5898. dialog,
  5899. imagePreview,
  5900. cancelButton,
  5901. disclaimer,
  5902. notNowButton,
  5903. saveButton,
  5904. textarea,
  5905. learnMore,
  5906. errorCloseButton,
  5907. createAutomaticallyButton,
  5908. downloadModel,
  5909. downloadModelDescription,
  5910. title
  5911. }, overlayManager, eventBus) {
  5912. this.#cancelButton = cancelButton;
  5913. this.#createAutomaticallyButton = createAutomaticallyButton;
  5914. this.#descriptionContainer = descriptionContainer;
  5915. this.#dialog = dialog;
  5916. this.#disclaimer = disclaimer;
  5917. this.#notNowButton = notNowButton;
  5918. this.#imagePreview = imagePreview;
  5919. this.#textarea = textarea;
  5920. this.#learnMore = learnMore;
  5921. this.#title = title;
  5922. this.#downloadModel = downloadModel;
  5923. this.#downloadModelDescription = downloadModelDescription;
  5924. this.#overlayManager = overlayManager;
  5925. this.#eventBus = eventBus;
  5926. dialog.addEventListener("close", this.#close.bind(this));
  5927. dialog.addEventListener("contextmenu", event => {
  5928. if (event.target !== this.#textarea) {
  5929. event.preventDefault();
  5930. }
  5931. });
  5932. cancelButton.addEventListener("click", this.#boundCancel);
  5933. notNowButton.addEventListener("click", this.#boundCancel);
  5934. saveButton.addEventListener("click", this.#save.bind(this));
  5935. errorCloseButton.addEventListener("click", () => {
  5936. this.#toggleError(false);
  5937. });
  5938. createAutomaticallyButton.addEventListener("click", async () => {
  5939. const checked = createAutomaticallyButton.getAttribute("aria-pressed") !== "true";
  5940. this.#currentEditor._reportTelemetry({
  5941. action: "pdfjs.image.alt_text.ai_generation_check",
  5942. data: {
  5943. status: checked
  5944. }
  5945. });
  5946. if (this.#uiManager) {
  5947. this.#uiManager.setPreference("enableGuessAltText", checked);
  5948. await this.#uiManager.mlManager.toggleService("altText", checked);
  5949. }
  5950. this.#toggleGuessAltText(checked, false);
  5951. });
  5952. textarea.addEventListener("focus", () => {
  5953. this.#wasAILoading = this.#isAILoading;
  5954. this.#toggleLoading(false);
  5955. this.#toggleTitleAndDisclaimer();
  5956. });
  5957. textarea.addEventListener("blur", () => {
  5958. if (!textarea.value) {
  5959. this.#toggleLoading(this.#wasAILoading);
  5960. }
  5961. this.#toggleTitleAndDisclaimer();
  5962. });
  5963. textarea.addEventListener("input", () => {
  5964. this.#toggleTitleAndDisclaimer();
  5965. });
  5966. eventBus._on("enableguessalttext", ({
  5967. value
  5968. }) => {
  5969. this.#toggleGuessAltText(value, false);
  5970. });
  5971. this.#overlayManager.register(dialog);
  5972. this.#learnMore.addEventListener("click", () => {
  5973. this.#currentEditor._reportTelemetry({
  5974. action: "pdfjs.image.alt_text.info",
  5975. data: {
  5976. topic: "alt_text"
  5977. }
  5978. });
  5979. });
  5980. }
  5981. #toggleLoading(value) {
  5982. if (!this.#uiManager || this.#isAILoading === value) {
  5983. return;
  5984. }
  5985. this.#isAILoading = value;
  5986. this.#descriptionContainer.classList.toggle("loading", value);
  5987. }
  5988. #toggleError(value) {
  5989. if (!this.#uiManager) {
  5990. return;
  5991. }
  5992. this.#dialog.classList.toggle("error", value);
  5993. }
  5994. async #toggleGuessAltText(value, isInitial = false) {
  5995. if (!this.#uiManager) {
  5996. return;
  5997. }
  5998. this.#dialog.classList.toggle("aiDisabled", !value);
  5999. this.#createAutomaticallyButton.setAttribute("aria-pressed", value);
  6000. if (value) {
  6001. const {
  6002. altTextLearnMoreUrl
  6003. } = this.#uiManager.mlManager;
  6004. if (altTextLearnMoreUrl) {
  6005. this.#learnMore.href = altTextLearnMoreUrl;
  6006. }
  6007. this.#mlGuessAltText(isInitial);
  6008. } else {
  6009. this.#toggleLoading(false);
  6010. this.#isAILoading = false;
  6011. this.#toggleTitleAndDisclaimer();
  6012. }
  6013. }
  6014. #toggleNotNow() {
  6015. this.#notNowButton.classList.toggle("hidden", !this.#firstTime);
  6016. this.#cancelButton.classList.toggle("hidden", this.#firstTime);
  6017. }
  6018. #toggleAI(value) {
  6019. if (!this.#uiManager || this.#hasAI === value) {
  6020. return;
  6021. }
  6022. this.#hasAI = value;
  6023. this.#dialog.classList.toggle("noAi", !value);
  6024. this.#toggleTitleAndDisclaimer();
  6025. }
  6026. #toggleTitleAndDisclaimer() {
  6027. const visible = this.#isAILoading || this.#guessedAltText && this.#guessedAltText === this.#textarea.value;
  6028. this.#disclaimer.hidden = !visible;
  6029. const isEditing = this.#isAILoading || !!this.#textarea.value;
  6030. if (this.#isEditing === isEditing) {
  6031. return;
  6032. }
  6033. this.#isEditing = isEditing;
  6034. this.#title.setAttribute("data-l10n-id", isEditing ? "pdfjs-editor-new-alt-text-dialog-edit-label" : "pdfjs-editor-new-alt-text-dialog-add-label");
  6035. }
  6036. async #mlGuessAltText(isInitial) {
  6037. if (this.#isAILoading) {
  6038. return;
  6039. }
  6040. if (this.#textarea.value) {
  6041. return;
  6042. }
  6043. if (isInitial && this.#previousAltText !== null) {
  6044. return;
  6045. }
  6046. this.#guessedAltText = this.#currentEditor.guessedAltText;
  6047. if (this.#previousAltText === null && this.#guessedAltText) {
  6048. this.#addAltText(this.#guessedAltText);
  6049. return;
  6050. }
  6051. this.#toggleLoading(true);
  6052. this.#toggleTitleAndDisclaimer();
  6053. let hasError = false;
  6054. try {
  6055. const altText = await this.#currentEditor.mlGuessAltText(this.#imageData, false);
  6056. if (altText) {
  6057. this.#guessedAltText = altText;
  6058. this.#wasAILoading = this.#isAILoading;
  6059. if (this.#isAILoading) {
  6060. this.#addAltText(altText);
  6061. }
  6062. }
  6063. } catch (e) {
  6064. console.error(e);
  6065. hasError = true;
  6066. }
  6067. this.#toggleLoading(false);
  6068. this.#toggleTitleAndDisclaimer();
  6069. if (hasError && this.#uiManager) {
  6070. this.#toggleError(true);
  6071. }
  6072. }
  6073. #addAltText(altText) {
  6074. if (!this.#uiManager || this.#textarea.value) {
  6075. return;
  6076. }
  6077. this.#textarea.value = altText;
  6078. this.#toggleTitleAndDisclaimer();
  6079. }
  6080. #setProgress() {
  6081. this.#downloadModel.classList.toggle("hidden", false);
  6082. const callback = async ({
  6083. detail: {
  6084. finished,
  6085. total,
  6086. totalLoaded
  6087. }
  6088. }) => {
  6089. const ONE_MEGA_BYTES = 1e6;
  6090. totalLoaded = Math.min(0.99 * total, totalLoaded);
  6091. const totalSize = this.#downloadModelDescription.ariaValueMax = Math.round(total / ONE_MEGA_BYTES);
  6092. const downloadedSize = this.#downloadModelDescription.ariaValueNow = Math.round(totalLoaded / ONE_MEGA_BYTES);
  6093. this.#downloadModelDescription.setAttribute("data-l10n-args", JSON.stringify({
  6094. totalSize,
  6095. downloadedSize
  6096. }));
  6097. if (!finished) {
  6098. return;
  6099. }
  6100. this.#eventBus._off("loadaiengineprogress", callback);
  6101. this.#downloadModel.classList.toggle("hidden", true);
  6102. this.#toggleAI(true);
  6103. if (!this.#uiManager) {
  6104. return;
  6105. }
  6106. const {
  6107. mlManager
  6108. } = this.#uiManager;
  6109. mlManager.toggleService("altText", true);
  6110. this.#toggleGuessAltText(await mlManager.isEnabledFor("altText"), true);
  6111. };
  6112. this.#eventBus._on("loadaiengineprogress", callback);
  6113. }
  6114. async editAltText(uiManager, editor, firstTime) {
  6115. if (this.#currentEditor || !editor) {
  6116. return;
  6117. }
  6118. if (firstTime && editor.hasAltTextData()) {
  6119. editor.altTextFinish();
  6120. return;
  6121. }
  6122. this.#firstTime = firstTime;
  6123. let {
  6124. mlManager
  6125. } = uiManager;
  6126. let hasAI = !!mlManager;
  6127. this.#toggleTitleAndDisclaimer();
  6128. if (mlManager && !mlManager.isReady("altText")) {
  6129. hasAI = false;
  6130. if (mlManager.hasProgress) {
  6131. this.#setProgress();
  6132. } else {
  6133. mlManager = null;
  6134. }
  6135. } else {
  6136. this.#downloadModel.classList.toggle("hidden", true);
  6137. }
  6138. const isAltTextEnabledPromise = mlManager?.isEnabledFor("altText");
  6139. this.#currentEditor = editor;
  6140. this.#uiManager = uiManager;
  6141. this.#uiManager.removeEditListeners();
  6142. ({
  6143. altText: this.#previousAltText
  6144. } = editor.altTextData);
  6145. this.#textarea.value = this.#previousAltText ?? "";
  6146. const AI_MAX_IMAGE_DIMENSION = 224;
  6147. const MAX_PREVIEW_DIMENSION = 180;
  6148. let canvas, width, height;
  6149. if (mlManager) {
  6150. ({
  6151. canvas,
  6152. width,
  6153. height,
  6154. imageData: this.#imageData
  6155. } = editor.copyCanvas(AI_MAX_IMAGE_DIMENSION, MAX_PREVIEW_DIMENSION, true));
  6156. if (hasAI) {
  6157. this.#toggleGuessAltText(await isAltTextEnabledPromise, true);
  6158. }
  6159. } else {
  6160. ({
  6161. canvas,
  6162. width,
  6163. height
  6164. } = editor.copyCanvas(AI_MAX_IMAGE_DIMENSION, MAX_PREVIEW_DIMENSION, false));
  6165. }
  6166. canvas.setAttribute("role", "presentation");
  6167. const {
  6168. style
  6169. } = canvas;
  6170. style.width = `${width}px`;
  6171. style.height = `${height}px`;
  6172. this.#imagePreview.append(canvas);
  6173. this.#toggleNotNow();
  6174. this.#toggleAI(hasAI);
  6175. this.#toggleError(false);
  6176. try {
  6177. await this.#overlayManager.open(this.#dialog);
  6178. } catch (ex) {
  6179. this.#close();
  6180. throw ex;
  6181. }
  6182. }
  6183. #cancel() {
  6184. this.#currentEditor.altTextData = {
  6185. cancel: true
  6186. };
  6187. const altText = this.#textarea.value.trim();
  6188. this.#currentEditor._reportTelemetry({
  6189. action: "pdfjs.image.alt_text.dismiss",
  6190. data: {
  6191. alt_text_type: altText ? "present" : "empty",
  6192. flow: this.#firstTime ? "image_add" : "alt_text_edit"
  6193. }
  6194. });
  6195. this.#currentEditor._reportTelemetry({
  6196. action: "pdfjs.image.image_added",
  6197. data: {
  6198. alt_text_modal: true,
  6199. alt_text_type: "skipped"
  6200. }
  6201. });
  6202. this.#finish();
  6203. }
  6204. #finish() {
  6205. if (this.#overlayManager.active === this.#dialog) {
  6206. this.#overlayManager.close(this.#dialog);
  6207. }
  6208. }
  6209. #close() {
  6210. const canvas = this.#imagePreview.firstChild;
  6211. canvas.remove();
  6212. canvas.width = canvas.height = 0;
  6213. this.#imageData = null;
  6214. this.#toggleLoading(false);
  6215. this.#uiManager?.addEditListeners();
  6216. this.#currentEditor.altTextFinish();
  6217. this.#uiManager?.setSelected(this.#currentEditor);
  6218. this.#currentEditor = null;
  6219. this.#uiManager = null;
  6220. }
  6221. #save() {
  6222. const altText = this.#textarea.value.trim();
  6223. this.#currentEditor.altTextData = {
  6224. altText,
  6225. decorative: false
  6226. };
  6227. this.#currentEditor.altTextData.guessedAltText = this.#guessedAltText;
  6228. if (this.#guessedAltText && this.#guessedAltText !== altText) {
  6229. const guessedWords = new Set(this.#guessedAltText.split(/\s+/));
  6230. const words = new Set(altText.split(/\s+/));
  6231. this.#currentEditor._reportTelemetry({
  6232. action: "pdfjs.image.alt_text.user_edit",
  6233. data: {
  6234. total_words: guessedWords.size,
  6235. words_removed: guessedWords.difference(words).size,
  6236. words_added: words.difference(guessedWords).size
  6237. }
  6238. });
  6239. }
  6240. this.#currentEditor._reportTelemetry({
  6241. action: "pdfjs.image.image_added",
  6242. data: {
  6243. alt_text_modal: true,
  6244. alt_text_type: altText ? "present" : "empty"
  6245. }
  6246. });
  6247. this.#currentEditor._reportTelemetry({
  6248. action: "pdfjs.image.alt_text.save",
  6249. data: {
  6250. alt_text_type: altText ? "present" : "empty",
  6251. flow: this.#firstTime ? "image_add" : "alt_text_edit"
  6252. }
  6253. });
  6254. this.#finish();
  6255. }
  6256. destroy() {
  6257. this.#uiManager = null;
  6258. this.#finish();
  6259. }
  6260. }
  6261. class ImageAltTextSettings {
  6262. #aiModelSettings;
  6263. #createModelButton;
  6264. #downloadModelButton;
  6265. #dialog;
  6266. #eventBus;
  6267. #mlManager;
  6268. #overlayManager;
  6269. #showAltTextDialogButton;
  6270. constructor({
  6271. dialog,
  6272. createModelButton,
  6273. aiModelSettings,
  6274. learnMore,
  6275. closeButton,
  6276. deleteModelButton,
  6277. downloadModelButton,
  6278. showAltTextDialogButton
  6279. }, overlayManager, eventBus, mlManager) {
  6280. this.#dialog = dialog;
  6281. this.#aiModelSettings = aiModelSettings;
  6282. this.#createModelButton = createModelButton;
  6283. this.#downloadModelButton = downloadModelButton;
  6284. this.#showAltTextDialogButton = showAltTextDialogButton;
  6285. this.#overlayManager = overlayManager;
  6286. this.#eventBus = eventBus;
  6287. this.#mlManager = mlManager;
  6288. const {
  6289. altTextLearnMoreUrl
  6290. } = mlManager;
  6291. if (altTextLearnMoreUrl) {
  6292. learnMore.href = altTextLearnMoreUrl;
  6293. }
  6294. dialog.addEventListener("contextmenu", noContextMenu);
  6295. createModelButton.addEventListener("click", async e => {
  6296. const checked = this.#togglePref("enableGuessAltText", e);
  6297. await mlManager.toggleService("altText", checked);
  6298. this.#reportTelemetry({
  6299. type: "stamp",
  6300. action: "pdfjs.image.alt_text.settings_ai_generation_check",
  6301. data: {
  6302. status: checked
  6303. }
  6304. });
  6305. });
  6306. showAltTextDialogButton.addEventListener("click", e => {
  6307. const checked = this.#togglePref("enableNewAltTextWhenAddingImage", e);
  6308. this.#reportTelemetry({
  6309. type: "stamp",
  6310. action: "pdfjs.image.alt_text.settings_edit_alt_text_check",
  6311. data: {
  6312. status: checked
  6313. }
  6314. });
  6315. });
  6316. deleteModelButton.addEventListener("click", this.#delete.bind(this, true));
  6317. downloadModelButton.addEventListener("click", this.#download.bind(this, true));
  6318. closeButton.addEventListener("click", this.#finish.bind(this));
  6319. learnMore.addEventListener("click", () => {
  6320. this.#reportTelemetry({
  6321. type: "stamp",
  6322. action: "pdfjs.image.alt_text.info",
  6323. data: {
  6324. topic: "ai_generation"
  6325. }
  6326. });
  6327. });
  6328. eventBus._on("enablealttextmodeldownload", ({
  6329. value
  6330. }) => {
  6331. if (value) {
  6332. this.#download(false);
  6333. } else {
  6334. this.#delete(false);
  6335. }
  6336. });
  6337. this.#overlayManager.register(dialog);
  6338. }
  6339. #reportTelemetry(data) {
  6340. this.#eventBus.dispatch("reporttelemetry", {
  6341. source: this,
  6342. details: {
  6343. type: "editing",
  6344. data
  6345. }
  6346. });
  6347. }
  6348. async #download(isFromUI = false) {
  6349. if (isFromUI) {
  6350. this.#downloadModelButton.disabled = true;
  6351. const span = this.#downloadModelButton.firstChild;
  6352. span.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-settings-downloading-model-button");
  6353. await this.#mlManager.downloadModel("altText");
  6354. span.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-settings-download-model-button");
  6355. this.#createModelButton.disabled = false;
  6356. this.#setPref("enableGuessAltText", true);
  6357. this.#mlManager.toggleService("altText", true);
  6358. this.#setPref("enableAltTextModelDownload", true);
  6359. this.#downloadModelButton.disabled = false;
  6360. }
  6361. this.#aiModelSettings.classList.toggle("download", false);
  6362. this.#createModelButton.setAttribute("aria-pressed", true);
  6363. }
  6364. async #delete(isFromUI = false) {
  6365. if (isFromUI) {
  6366. await this.#mlManager.deleteModel("altText");
  6367. this.#setPref("enableGuessAltText", false);
  6368. this.#setPref("enableAltTextModelDownload", false);
  6369. }
  6370. this.#aiModelSettings.classList.toggle("download", true);
  6371. this.#createModelButton.disabled = true;
  6372. this.#createModelButton.setAttribute("aria-pressed", false);
  6373. }
  6374. async open({
  6375. enableGuessAltText,
  6376. enableNewAltTextWhenAddingImage
  6377. }) {
  6378. const {
  6379. enableAltTextModelDownload
  6380. } = this.#mlManager;
  6381. this.#createModelButton.disabled = !enableAltTextModelDownload;
  6382. this.#createModelButton.setAttribute("aria-pressed", enableAltTextModelDownload && enableGuessAltText);
  6383. this.#showAltTextDialogButton.setAttribute("aria-pressed", enableNewAltTextWhenAddingImage);
  6384. this.#aiModelSettings.classList.toggle("download", !enableAltTextModelDownload);
  6385. await this.#overlayManager.open(this.#dialog);
  6386. this.#reportTelemetry({
  6387. type: "stamp",
  6388. action: "pdfjs.image.alt_text.settings_displayed"
  6389. });
  6390. }
  6391. #togglePref(name, {
  6392. target
  6393. }) {
  6394. const checked = target.getAttribute("aria-pressed") !== "true";
  6395. this.#setPref(name, checked);
  6396. target.setAttribute("aria-pressed", checked);
  6397. return checked;
  6398. }
  6399. #setPref(name, value) {
  6400. this.#eventBus.dispatch("setpreference", {
  6401. source: this,
  6402. name,
  6403. value
  6404. });
  6405. }
  6406. #finish() {
  6407. if (this.#overlayManager.active === this.#dialog) {
  6408. this.#overlayManager.close(this.#dialog);
  6409. }
  6410. }
  6411. }
  6412. ;// ./web/alt_text_manager.js
  6413. class AltTextManager {
  6414. #boundUpdateUIState = this.#updateUIState.bind(this);
  6415. #boundSetPosition = this.#setPosition.bind(this);
  6416. #boundOnClick = this.#onClick.bind(this);
  6417. #currentEditor = null;
  6418. #cancelButton;
  6419. #dialog;
  6420. #eventBus;
  6421. #hasUsedPointer = false;
  6422. #optionDescription;
  6423. #optionDecorative;
  6424. #overlayManager;
  6425. #saveButton;
  6426. #textarea;
  6427. #uiManager;
  6428. #previousAltText = null;
  6429. #svgElement = null;
  6430. #rectElement = null;
  6431. #container;
  6432. #telemetryData = null;
  6433. constructor({
  6434. dialog,
  6435. optionDescription,
  6436. optionDecorative,
  6437. textarea,
  6438. cancelButton,
  6439. saveButton
  6440. }, container, overlayManager, eventBus) {
  6441. this.#dialog = dialog;
  6442. this.#optionDescription = optionDescription;
  6443. this.#optionDecorative = optionDecorative;
  6444. this.#textarea = textarea;
  6445. this.#cancelButton = cancelButton;
  6446. this.#saveButton = saveButton;
  6447. this.#overlayManager = overlayManager;
  6448. this.#eventBus = eventBus;
  6449. this.#container = container;
  6450. dialog.addEventListener("close", this.#close.bind(this));
  6451. dialog.addEventListener("contextmenu", event => {
  6452. if (event.target !== this.#textarea) {
  6453. event.preventDefault();
  6454. }
  6455. });
  6456. cancelButton.addEventListener("click", this.#finish.bind(this));
  6457. saveButton.addEventListener("click", this.#save.bind(this));
  6458. optionDescription.addEventListener("change", this.#boundUpdateUIState);
  6459. optionDecorative.addEventListener("change", this.#boundUpdateUIState);
  6460. this.#overlayManager.register(dialog);
  6461. }
  6462. get _elements() {
  6463. return shadow(this, "_elements", [this.#optionDescription, this.#optionDecorative, this.#textarea, this.#saveButton, this.#cancelButton]);
  6464. }
  6465. #createSVGElement() {
  6466. if (this.#svgElement) {
  6467. return;
  6468. }
  6469. const svgFactory = new DOMSVGFactory();
  6470. const svg = this.#svgElement = svgFactory.createElement("svg");
  6471. svg.setAttribute("width", "0");
  6472. svg.setAttribute("height", "0");
  6473. const defs = svgFactory.createElement("defs");
  6474. svg.append(defs);
  6475. const mask = svgFactory.createElement("mask");
  6476. defs.append(mask);
  6477. mask.setAttribute("id", "alttext-manager-mask");
  6478. mask.setAttribute("maskContentUnits", "objectBoundingBox");
  6479. let rect = svgFactory.createElement("rect");
  6480. mask.append(rect);
  6481. rect.setAttribute("fill", "white");
  6482. rect.setAttribute("width", "1");
  6483. rect.setAttribute("height", "1");
  6484. rect.setAttribute("x", "0");
  6485. rect.setAttribute("y", "0");
  6486. rect = this.#rectElement = svgFactory.createElement("rect");
  6487. mask.append(rect);
  6488. rect.setAttribute("fill", "black");
  6489. this.#dialog.append(svg);
  6490. }
  6491. async editAltText(uiManager, editor) {
  6492. if (this.#currentEditor || !editor) {
  6493. return;
  6494. }
  6495. this.#createSVGElement();
  6496. this.#hasUsedPointer = false;
  6497. for (const element of this._elements) {
  6498. element.addEventListener("click", this.#boundOnClick);
  6499. }
  6500. const {
  6501. altText,
  6502. decorative
  6503. } = editor.altTextData;
  6504. if (decorative === true) {
  6505. this.#optionDecorative.checked = true;
  6506. this.#optionDescription.checked = false;
  6507. } else {
  6508. this.#optionDecorative.checked = false;
  6509. this.#optionDescription.checked = true;
  6510. }
  6511. this.#previousAltText = this.#textarea.value = altText?.trim() || "";
  6512. this.#updateUIState();
  6513. this.#currentEditor = editor;
  6514. this.#uiManager = uiManager;
  6515. this.#uiManager.removeEditListeners();
  6516. this.#eventBus._on("resize", this.#boundSetPosition);
  6517. try {
  6518. await this.#overlayManager.open(this.#dialog);
  6519. this.#setPosition();
  6520. } catch (ex) {
  6521. this.#close();
  6522. throw ex;
  6523. }
  6524. }
  6525. #setPosition() {
  6526. if (!this.#currentEditor) {
  6527. return;
  6528. }
  6529. const dialog = this.#dialog;
  6530. const {
  6531. style
  6532. } = dialog;
  6533. const {
  6534. x: containerX,
  6535. y: containerY,
  6536. width: containerW,
  6537. height: containerH
  6538. } = this.#container.getBoundingClientRect();
  6539. const {
  6540. innerWidth: windowW,
  6541. innerHeight: windowH
  6542. } = window;
  6543. const {
  6544. width: dialogW,
  6545. height: dialogH
  6546. } = dialog.getBoundingClientRect();
  6547. const {
  6548. x,
  6549. y,
  6550. width,
  6551. height
  6552. } = this.#currentEditor.getClientDimensions();
  6553. const MARGIN = 10;
  6554. const isLTR = this.#uiManager.direction === "ltr";
  6555. const xs = Math.max(x, containerX);
  6556. const xe = Math.min(x + width, containerX + containerW);
  6557. const ys = Math.max(y, containerY);
  6558. const ye = Math.min(y + height, containerY + containerH);
  6559. this.#rectElement.setAttribute("width", `${(xe - xs) / windowW}`);
  6560. this.#rectElement.setAttribute("height", `${(ye - ys) / windowH}`);
  6561. this.#rectElement.setAttribute("x", `${xs / windowW}`);
  6562. this.#rectElement.setAttribute("y", `${ys / windowH}`);
  6563. let left = null;
  6564. let top = Math.max(y, 0);
  6565. top += Math.min(windowH - (top + dialogH), 0);
  6566. if (isLTR) {
  6567. if (x + width + MARGIN + dialogW < windowW) {
  6568. left = x + width + MARGIN;
  6569. } else if (x > dialogW + MARGIN) {
  6570. left = x - dialogW - MARGIN;
  6571. }
  6572. } else if (x > dialogW + MARGIN) {
  6573. left = x - dialogW - MARGIN;
  6574. } else if (x + width + MARGIN + dialogW < windowW) {
  6575. left = x + width + MARGIN;
  6576. }
  6577. if (left === null) {
  6578. top = null;
  6579. left = Math.max(x, 0);
  6580. left += Math.min(windowW - (left + dialogW), 0);
  6581. if (y > dialogH + MARGIN) {
  6582. top = y - dialogH - MARGIN;
  6583. } else if (y + height + MARGIN + dialogH < windowH) {
  6584. top = y + height + MARGIN;
  6585. }
  6586. }
  6587. if (top !== null) {
  6588. dialog.classList.add("positioned");
  6589. if (isLTR) {
  6590. style.left = `${left}px`;
  6591. } else {
  6592. style.right = `${windowW - left - dialogW}px`;
  6593. }
  6594. style.top = `${top}px`;
  6595. } else {
  6596. dialog.classList.remove("positioned");
  6597. style.left = "";
  6598. style.top = "";
  6599. }
  6600. }
  6601. #finish() {
  6602. if (this.#overlayManager.active === this.#dialog) {
  6603. this.#overlayManager.close(this.#dialog);
  6604. }
  6605. }
  6606. #close() {
  6607. this.#currentEditor._reportTelemetry(this.#telemetryData || {
  6608. action: "alt_text_cancel",
  6609. alt_text_keyboard: !this.#hasUsedPointer
  6610. });
  6611. this.#telemetryData = null;
  6612. this.#removeOnClickListeners();
  6613. this.#uiManager?.addEditListeners();
  6614. this.#eventBus._off("resize", this.#boundSetPosition);
  6615. this.#currentEditor.altTextFinish();
  6616. this.#currentEditor = null;
  6617. this.#uiManager = null;
  6618. }
  6619. #updateUIState() {
  6620. this.#textarea.disabled = this.#optionDecorative.checked;
  6621. }
  6622. #save() {
  6623. const altText = this.#textarea.value.trim();
  6624. const decorative = this.#optionDecorative.checked;
  6625. this.#currentEditor.altTextData = {
  6626. altText,
  6627. decorative
  6628. };
  6629. this.#telemetryData = {
  6630. action: "alt_text_save",
  6631. alt_text_description: !!altText,
  6632. alt_text_edit: !!this.#previousAltText && this.#previousAltText !== altText,
  6633. alt_text_decorative: decorative,
  6634. alt_text_keyboard: !this.#hasUsedPointer
  6635. };
  6636. this.#finish();
  6637. }
  6638. #onClick(evt) {
  6639. if (evt.detail === 0) {
  6640. return;
  6641. }
  6642. this.#hasUsedPointer = true;
  6643. this.#removeOnClickListeners();
  6644. }
  6645. #removeOnClickListeners() {
  6646. for (const element of this._elements) {
  6647. element.removeEventListener("click", this.#boundOnClick);
  6648. }
  6649. }
  6650. destroy() {
  6651. this.#uiManager = null;
  6652. this.#finish();
  6653. this.#svgElement?.remove();
  6654. this.#svgElement = this.#rectElement = null;
  6655. }
  6656. }
  6657. ;// ./web/annotation_editor_params.js
  6658. class AnnotationEditorParams {
  6659. constructor(options, eventBus) {
  6660. this.eventBus = eventBus;
  6661. this.#bindListeners(options);
  6662. }
  6663. #bindListeners({
  6664. editorFreeTextFontSize,
  6665. editorFreeTextColor,
  6666. editorInkColor,
  6667. editorInkThickness,
  6668. editorInkOpacity,
  6669. editorStampAddImage,
  6670. editorFreeHighlightThickness,
  6671. editorHighlightShowAll
  6672. }) {
  6673. const dispatchEvent = (typeStr, value) => {
  6674. this.eventBus.dispatch("switchannotationeditorparams", {
  6675. source: this,
  6676. type: AnnotationEditorParamsType[typeStr],
  6677. value
  6678. });
  6679. };
  6680. editorFreeTextFontSize.addEventListener("input", function () {
  6681. dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
  6682. });
  6683. editorFreeTextColor.addEventListener("input", function () {
  6684. dispatchEvent("FREETEXT_COLOR", this.value);
  6685. });
  6686. editorInkColor.addEventListener("input", function () {
  6687. dispatchEvent("INK_COLOR", this.value);
  6688. });
  6689. editorInkThickness.addEventListener("input", function () {
  6690. dispatchEvent("INK_THICKNESS", this.valueAsNumber);
  6691. });
  6692. editorInkOpacity.addEventListener("input", function () {
  6693. dispatchEvent("INK_OPACITY", this.valueAsNumber);
  6694. });
  6695. editorStampAddImage.addEventListener("click", () => {
  6696. this.eventBus.dispatch("reporttelemetry", {
  6697. source: this,
  6698. details: {
  6699. type: "editing",
  6700. data: {
  6701. action: "pdfjs.image.add_image_click"
  6702. }
  6703. }
  6704. });
  6705. dispatchEvent("CREATE");
  6706. });
  6707. editorFreeHighlightThickness.addEventListener("input", function () {
  6708. dispatchEvent("HIGHLIGHT_THICKNESS", this.valueAsNumber);
  6709. });
  6710. editorHighlightShowAll.addEventListener("click", function () {
  6711. const checked = this.getAttribute("aria-pressed") === "true";
  6712. this.setAttribute("aria-pressed", !checked);
  6713. dispatchEvent("HIGHLIGHT_SHOW_ALL", !checked);
  6714. });
  6715. this.eventBus._on("annotationeditorparamschanged", evt => {
  6716. for (const [type, value] of evt.details) {
  6717. switch (type) {
  6718. case AnnotationEditorParamsType.FREETEXT_SIZE:
  6719. editorFreeTextFontSize.value = value;
  6720. break;
  6721. case AnnotationEditorParamsType.FREETEXT_COLOR:
  6722. editorFreeTextColor.value = value;
  6723. break;
  6724. case AnnotationEditorParamsType.INK_COLOR:
  6725. editorInkColor.value = value;
  6726. break;
  6727. case AnnotationEditorParamsType.INK_THICKNESS:
  6728. editorInkThickness.value = value;
  6729. break;
  6730. case AnnotationEditorParamsType.INK_OPACITY:
  6731. editorInkOpacity.value = value;
  6732. break;
  6733. case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
  6734. editorFreeHighlightThickness.value = value;
  6735. break;
  6736. case AnnotationEditorParamsType.HIGHLIGHT_FREE:
  6737. editorFreeHighlightThickness.disabled = !value;
  6738. break;
  6739. case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
  6740. editorHighlightShowAll.setAttribute("aria-pressed", value);
  6741. break;
  6742. }
  6743. }
  6744. });
  6745. }
  6746. }
  6747. ;// ./web/caret_browsing.js
  6748. const PRECISION = 1e-1;
  6749. class CaretBrowsingMode {
  6750. #mainContainer;
  6751. #toolBarHeight = 0;
  6752. #viewerContainer;
  6753. constructor(abortSignal, mainContainer, viewerContainer, toolbarContainer) {
  6754. this.#mainContainer = mainContainer;
  6755. this.#viewerContainer = viewerContainer;
  6756. if (!toolbarContainer) {
  6757. return;
  6758. }
  6759. this.#toolBarHeight = toolbarContainer.getBoundingClientRect().height;
  6760. const toolbarObserver = new ResizeObserver(entries => {
  6761. for (const entry of entries) {
  6762. if (entry.target === toolbarContainer) {
  6763. this.#toolBarHeight = Math.floor(entry.borderBoxSize[0].blockSize);
  6764. break;
  6765. }
  6766. }
  6767. });
  6768. toolbarObserver.observe(toolbarContainer);
  6769. abortSignal.addEventListener("abort", () => toolbarObserver.disconnect(), {
  6770. once: true
  6771. });
  6772. }
  6773. #isOnSameLine(rect1, rect2) {
  6774. const top1 = rect1.y;
  6775. const bot1 = rect1.bottom;
  6776. const mid1 = rect1.y + rect1.height / 2;
  6777. const top2 = rect2.y;
  6778. const bot2 = rect2.bottom;
  6779. const mid2 = rect2.y + rect2.height / 2;
  6780. return top1 <= mid2 && mid2 <= bot1 || top2 <= mid1 && mid1 <= bot2;
  6781. }
  6782. #isUnderOver(rect, x, y, isUp) {
  6783. const midY = rect.y + rect.height / 2;
  6784. return (isUp ? y >= midY : y <= midY) && rect.x - PRECISION <= x && x <= rect.right + PRECISION;
  6785. }
  6786. #isVisible(rect) {
  6787. return rect.top >= this.#toolBarHeight && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
  6788. }
  6789. #getCaretPosition(selection, isUp) {
  6790. const {
  6791. focusNode,
  6792. focusOffset
  6793. } = selection;
  6794. const range = document.createRange();
  6795. range.setStart(focusNode, focusOffset);
  6796. range.setEnd(focusNode, focusOffset);
  6797. const rect = range.getBoundingClientRect();
  6798. return [rect.x, isUp ? rect.top : rect.bottom];
  6799. }
  6800. static #caretPositionFromPoint(x, y) {
  6801. if (!document.caretPositionFromPoint) {
  6802. const {
  6803. startContainer: offsetNode,
  6804. startOffset: offset
  6805. } = document.caretRangeFromPoint(x, y);
  6806. return {
  6807. offsetNode,
  6808. offset
  6809. };
  6810. }
  6811. return document.caretPositionFromPoint(x, y);
  6812. }
  6813. #setCaretPositionHelper(selection, caretX, select, element, rect) {
  6814. rect ||= element.getBoundingClientRect();
  6815. if (caretX <= rect.x + PRECISION) {
  6816. if (select) {
  6817. selection.extend(element.firstChild, 0);
  6818. } else {
  6819. selection.setPosition(element.firstChild, 0);
  6820. }
  6821. return;
  6822. }
  6823. if (rect.right - PRECISION <= caretX) {
  6824. const {
  6825. lastChild
  6826. } = element;
  6827. if (select) {
  6828. selection.extend(lastChild, lastChild.length);
  6829. } else {
  6830. selection.setPosition(lastChild, lastChild.length);
  6831. }
  6832. return;
  6833. }
  6834. const midY = rect.y + rect.height / 2;
  6835. let caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
  6836. let parentElement = caretPosition.offsetNode?.parentElement;
  6837. if (parentElement && parentElement !== element) {
  6838. const elementsAtPoint = document.elementsFromPoint(caretX, midY);
  6839. const savedVisibilities = [];
  6840. for (const el of elementsAtPoint) {
  6841. if (el === element) {
  6842. break;
  6843. }
  6844. const {
  6845. style
  6846. } = el;
  6847. savedVisibilities.push([el, style.visibility]);
  6848. style.visibility = "hidden";
  6849. }
  6850. caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
  6851. parentElement = caretPosition.offsetNode?.parentElement;
  6852. for (const [el, visibility] of savedVisibilities) {
  6853. el.style.visibility = visibility;
  6854. }
  6855. }
  6856. if (parentElement !== element) {
  6857. if (select) {
  6858. selection.extend(element.firstChild, 0);
  6859. } else {
  6860. selection.setPosition(element.firstChild, 0);
  6861. }
  6862. return;
  6863. }
  6864. if (select) {
  6865. selection.extend(caretPosition.offsetNode, caretPosition.offset);
  6866. } else {
  6867. selection.setPosition(caretPosition.offsetNode, caretPosition.offset);
  6868. }
  6869. }
  6870. #setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX) {
  6871. if (this.#isVisible(newLineElementRect)) {
  6872. this.#setCaretPositionHelper(selection, caretX, select, newLineElement, newLineElementRect);
  6873. return;
  6874. }
  6875. this.#mainContainer.addEventListener("scrollend", this.#setCaretPositionHelper.bind(this, selection, caretX, select, newLineElement, null), {
  6876. once: true
  6877. });
  6878. newLineElement.scrollIntoView();
  6879. }
  6880. #getNodeOnNextPage(textLayer, isUp) {
  6881. while (true) {
  6882. const page = textLayer.closest(".page");
  6883. const pageNumber = parseInt(page.getAttribute("data-page-number"));
  6884. const nextPage = isUp ? pageNumber - 1 : pageNumber + 1;
  6885. textLayer = this.#viewerContainer.querySelector(`.page[data-page-number="${nextPage}"] .textLayer`);
  6886. if (!textLayer) {
  6887. return null;
  6888. }
  6889. const walker = document.createTreeWalker(textLayer, NodeFilter.SHOW_TEXT);
  6890. const node = isUp ? walker.lastChild() : walker.firstChild();
  6891. if (node) {
  6892. return node;
  6893. }
  6894. }
  6895. }
  6896. moveCaret(isUp, select) {
  6897. const selection = document.getSelection();
  6898. if (selection.rangeCount === 0) {
  6899. return;
  6900. }
  6901. const {
  6902. focusNode
  6903. } = selection;
  6904. const focusElement = focusNode.nodeType !== Node.ELEMENT_NODE ? focusNode.parentElement : focusNode;
  6905. const root = focusElement.closest(".textLayer");
  6906. if (!root) {
  6907. return;
  6908. }
  6909. const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
  6910. walker.currentNode = focusNode;
  6911. const focusRect = focusElement.getBoundingClientRect();
  6912. let newLineElement = null;
  6913. const nodeIterator = (isUp ? walker.previousSibling : walker.nextSibling).bind(walker);
  6914. while (nodeIterator()) {
  6915. const element = walker.currentNode.parentElement;
  6916. if (!this.#isOnSameLine(focusRect, element.getBoundingClientRect())) {
  6917. newLineElement = element;
  6918. break;
  6919. }
  6920. }
  6921. if (!newLineElement) {
  6922. const node = this.#getNodeOnNextPage(root, isUp);
  6923. if (!node) {
  6924. return;
  6925. }
  6926. if (select) {
  6927. const lastNode = (isUp ? walker.firstChild() : walker.lastChild()) || focusNode;
  6928. selection.extend(lastNode, isUp ? 0 : lastNode.length);
  6929. const range = document.createRange();
  6930. range.setStart(node, isUp ? node.length : 0);
  6931. range.setEnd(node, isUp ? node.length : 0);
  6932. selection.addRange(range);
  6933. return;
  6934. }
  6935. const [caretX] = this.#getCaretPosition(selection, isUp);
  6936. const {
  6937. parentElement
  6938. } = node;
  6939. this.#setCaretPosition(select, selection, parentElement, parentElement.getBoundingClientRect(), caretX);
  6940. return;
  6941. }
  6942. const [caretX, caretY] = this.#getCaretPosition(selection, isUp);
  6943. const newLineElementRect = newLineElement.getBoundingClientRect();
  6944. if (this.#isUnderOver(newLineElementRect, caretX, caretY, isUp)) {
  6945. this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX);
  6946. return;
  6947. }
  6948. while (nodeIterator()) {
  6949. const element = walker.currentNode.parentElement;
  6950. const elementRect = element.getBoundingClientRect();
  6951. if (!this.#isOnSameLine(newLineElementRect, elementRect)) {
  6952. break;
  6953. }
  6954. if (this.#isUnderOver(elementRect, caretX, caretY, isUp)) {
  6955. this.#setCaretPosition(select, selection, element, elementRect, caretX);
  6956. return;
  6957. }
  6958. }
  6959. this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX);
  6960. }
  6961. }
  6962. ;// ./web/download_manager.js
  6963. function download(blobUrl, filename) {
  6964. const a = document.createElement("a");
  6965. if (!a.click) {
  6966. throw new Error('DownloadManager: "a.click()" is not supported.');
  6967. }
  6968. a.href = blobUrl;
  6969. a.target = "_parent";
  6970. if ("download" in a) {
  6971. a.download = filename;
  6972. }
  6973. (document.body || document.documentElement).append(a);
  6974. a.click();
  6975. a.remove();
  6976. }
  6977. class DownloadManager {
  6978. #openBlobUrls = new WeakMap();
  6979. downloadData(data, filename, contentType) {
  6980. const blobUrl = URL.createObjectURL(new Blob([data], {
  6981. type: contentType
  6982. }));
  6983. download(blobUrl, filename);
  6984. }
  6985. openOrDownloadData(data, filename, dest = null) {
  6986. const isPdfData = isPdfFile(filename);
  6987. const contentType = isPdfData ? "application/pdf" : "";
  6988. if (isPdfData) {
  6989. let blobUrl = this.#openBlobUrls.get(data);
  6990. if (!blobUrl) {
  6991. blobUrl = URL.createObjectURL(new Blob([data], {
  6992. type: contentType
  6993. }));
  6994. this.#openBlobUrls.set(data, blobUrl);
  6995. }
  6996. let viewerUrl;
  6997. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  6998. if (dest) {
  6999. viewerUrl += `#${escape(dest)}`;
  7000. }
  7001. try {
  7002. window.open(viewerUrl);
  7003. return true;
  7004. } catch (ex) {
  7005. console.error(`openOrDownloadData: ${ex}`);
  7006. URL.revokeObjectURL(blobUrl);
  7007. this.#openBlobUrls.delete(data);
  7008. }
  7009. }
  7010. this.downloadData(data, filename, contentType);
  7011. return false;
  7012. }
  7013. download(data, url, filename) {
  7014. let blobUrl;
  7015. if (data) {
  7016. blobUrl = URL.createObjectURL(new Blob([data], {
  7017. type: "application/pdf"
  7018. }));
  7019. } else {
  7020. if (!createValidAbsoluteUrl(url, "http://example.com")) {
  7021. console.error(`download - not a valid URL: ${url}`);
  7022. return;
  7023. }
  7024. blobUrl = url + "#pdfjs.action=download";
  7025. }
  7026. download(blobUrl, filename);
  7027. }
  7028. }
  7029. ;// ./web/overlay_manager.js
  7030. class OverlayManager {
  7031. #overlays = new WeakMap();
  7032. #active = null;
  7033. get active() {
  7034. return this.#active;
  7035. }
  7036. async register(dialog, canForceClose = false) {
  7037. if (typeof dialog !== "object") {
  7038. throw new Error("Not enough parameters.");
  7039. } else if (this.#overlays.has(dialog)) {
  7040. throw new Error("The overlay is already registered.");
  7041. }
  7042. this.#overlays.set(dialog, {
  7043. canForceClose
  7044. });
  7045. dialog.addEventListener("cancel", evt => {
  7046. this.#active = null;
  7047. });
  7048. }
  7049. async open(dialog) {
  7050. if (!this.#overlays.has(dialog)) {
  7051. throw new Error("The overlay does not exist.");
  7052. } else if (this.#active) {
  7053. if (this.#active === dialog) {
  7054. throw new Error("The overlay is already active.");
  7055. } else if (this.#overlays.get(dialog).canForceClose) {
  7056. await this.close();
  7057. } else {
  7058. throw new Error("Another overlay is currently active.");
  7059. }
  7060. }
  7061. this.#active = dialog;
  7062. dialog.showModal();
  7063. }
  7064. async close(dialog = this.#active) {
  7065. if (!this.#overlays.has(dialog)) {
  7066. throw new Error("The overlay does not exist.");
  7067. } else if (!this.#active) {
  7068. throw new Error("The overlay is currently not active.");
  7069. } else if (this.#active !== dialog) {
  7070. throw new Error("Another overlay is currently active.");
  7071. }
  7072. dialog.close();
  7073. this.#active = null;
  7074. }
  7075. }
  7076. ;// ./web/password_prompt.js
  7077. class PasswordPrompt {
  7078. #activeCapability = null;
  7079. #updateCallback = null;
  7080. #reason = null;
  7081. constructor(options, overlayManager, isViewerEmbedded = false) {
  7082. this.dialog = options.dialog;
  7083. this.label = options.label;
  7084. this.input = options.input;
  7085. this.submitButton = options.submitButton;
  7086. this.cancelButton = options.cancelButton;
  7087. this.overlayManager = overlayManager;
  7088. this._isViewerEmbedded = isViewerEmbedded;
  7089. this.submitButton.addEventListener("click", this.#verify.bind(this));
  7090. this.cancelButton.addEventListener("click", this.close.bind(this));
  7091. this.input.addEventListener("keydown", e => {
  7092. if (e.keyCode === 13) {
  7093. this.#verify();
  7094. }
  7095. });
  7096. this.overlayManager.register(this.dialog, true);
  7097. this.dialog.addEventListener("close", this.#cancel.bind(this));
  7098. }
  7099. async open() {
  7100. await this.#activeCapability?.promise;
  7101. this.#activeCapability = Promise.withResolvers();
  7102. try {
  7103. await this.overlayManager.open(this.dialog);
  7104. } catch (ex) {
  7105. this.#activeCapability.resolve();
  7106. throw ex;
  7107. }
  7108. const passwordIncorrect = this.#reason === PasswordResponses.INCORRECT_PASSWORD;
  7109. if (!this._isViewerEmbedded || passwordIncorrect) {
  7110. this.input.focus();
  7111. }
  7112. this.label.setAttribute("data-l10n-id", passwordIncorrect ? "pdfjs-password-invalid" : "pdfjs-password-label");
  7113. }
  7114. async close() {
  7115. if (this.overlayManager.active === this.dialog) {
  7116. this.overlayManager.close(this.dialog);
  7117. }
  7118. }
  7119. #verify() {
  7120. const password = this.input.value;
  7121. if (password?.length > 0) {
  7122. this.#invokeCallback(password);
  7123. }
  7124. }
  7125. #cancel() {
  7126. this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  7127. this.#activeCapability.resolve();
  7128. }
  7129. #invokeCallback(password) {
  7130. if (!this.#updateCallback) {
  7131. return;
  7132. }
  7133. this.close();
  7134. this.input.value = "";
  7135. this.#updateCallback(password);
  7136. this.#updateCallback = null;
  7137. }
  7138. async setUpdateCallback(updateCallback, reason) {
  7139. if (this.#activeCapability) {
  7140. await this.#activeCapability.promise;
  7141. }
  7142. this.#updateCallback = updateCallback;
  7143. this.#reason = reason;
  7144. }
  7145. }
  7146. ;// ./web/base_tree_viewer.js
  7147. const TREEITEM_OFFSET_TOP = -100;
  7148. const TREEITEM_SELECTED_CLASS = "selected";
  7149. class BaseTreeViewer {
  7150. constructor(options) {
  7151. this.container = options.container;
  7152. this.eventBus = options.eventBus;
  7153. this._l10n = options.l10n;
  7154. this.reset();
  7155. }
  7156. reset() {
  7157. this._pdfDocument = null;
  7158. this._lastToggleIsShow = true;
  7159. this._currentTreeItem = null;
  7160. this.container.textContent = "";
  7161. this.container.classList.remove("treeWithDeepNesting");
  7162. }
  7163. _dispatchEvent(count) {
  7164. throw new Error("Not implemented: _dispatchEvent");
  7165. }
  7166. _bindLink(element, params) {
  7167. throw new Error("Not implemented: _bindLink");
  7168. }
  7169. _normalizeTextContent(str) {
  7170. return removeNullCharacters(str, true) || "\u2013";
  7171. }
  7172. _addToggleButton(div, hidden = false) {
  7173. const toggler = document.createElement("div");
  7174. toggler.className = "treeItemToggler";
  7175. if (hidden) {
  7176. toggler.classList.add("treeItemsHidden");
  7177. }
  7178. toggler.onclick = evt => {
  7179. evt.stopPropagation();
  7180. toggler.classList.toggle("treeItemsHidden");
  7181. if (evt.shiftKey) {
  7182. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  7183. this._toggleTreeItem(div, shouldShowAll);
  7184. }
  7185. };
  7186. div.prepend(toggler);
  7187. }
  7188. _toggleTreeItem(root, show = false) {
  7189. this._l10n.pause();
  7190. this._lastToggleIsShow = show;
  7191. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  7192. toggler.classList.toggle("treeItemsHidden", !show);
  7193. }
  7194. this._l10n.resume();
  7195. }
  7196. _toggleAllTreeItems() {
  7197. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  7198. }
  7199. _finishRendering(fragment, count, hasAnyNesting = false) {
  7200. if (hasAnyNesting) {
  7201. this.container.classList.add("treeWithDeepNesting");
  7202. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  7203. }
  7204. this._l10n.pause();
  7205. this.container.append(fragment);
  7206. this._l10n.resume();
  7207. this._dispatchEvent(count);
  7208. }
  7209. render(params) {
  7210. throw new Error("Not implemented: render");
  7211. }
  7212. _updateCurrentTreeItem(treeItem = null) {
  7213. if (this._currentTreeItem) {
  7214. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  7215. this._currentTreeItem = null;
  7216. }
  7217. if (treeItem) {
  7218. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  7219. this._currentTreeItem = treeItem;
  7220. }
  7221. }
  7222. _scrollToCurrentTreeItem(treeItem) {
  7223. if (!treeItem) {
  7224. return;
  7225. }
  7226. this._l10n.pause();
  7227. let currentNode = treeItem.parentNode;
  7228. while (currentNode && currentNode !== this.container) {
  7229. if (currentNode.classList.contains("treeItem")) {
  7230. const toggler = currentNode.firstElementChild;
  7231. toggler?.classList.remove("treeItemsHidden");
  7232. }
  7233. currentNode = currentNode.parentNode;
  7234. }
  7235. this._l10n.resume();
  7236. this._updateCurrentTreeItem(treeItem);
  7237. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  7238. }
  7239. }
  7240. ;// ./web/pdf_attachment_viewer.js
  7241. class PDFAttachmentViewer extends BaseTreeViewer {
  7242. constructor(options) {
  7243. super(options);
  7244. this.downloadManager = options.downloadManager;
  7245. this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
  7246. }
  7247. reset(keepRenderedCapability = false) {
  7248. super.reset();
  7249. this._attachments = null;
  7250. if (!keepRenderedCapability) {
  7251. this._renderedCapability = Promise.withResolvers();
  7252. }
  7253. this._pendingDispatchEvent = false;
  7254. }
  7255. async _dispatchEvent(attachmentsCount) {
  7256. this._renderedCapability.resolve();
  7257. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  7258. this._pendingDispatchEvent = true;
  7259. await waitOnEventOrTimeout({
  7260. target: this.eventBus,
  7261. name: "annotationlayerrendered",
  7262. delay: 1000
  7263. });
  7264. if (!this._pendingDispatchEvent) {
  7265. return;
  7266. }
  7267. }
  7268. this._pendingDispatchEvent = false;
  7269. this.eventBus.dispatch("attachmentsloaded", {
  7270. source: this,
  7271. attachmentsCount
  7272. });
  7273. }
  7274. _bindLink(element, {
  7275. content,
  7276. description,
  7277. filename
  7278. }) {
  7279. if (description) {
  7280. element.title = description;
  7281. }
  7282. element.onclick = () => {
  7283. this.downloadManager.openOrDownloadData(content, filename);
  7284. return false;
  7285. };
  7286. }
  7287. render({
  7288. attachments,
  7289. keepRenderedCapability = false
  7290. }) {
  7291. if (this._attachments) {
  7292. this.reset(keepRenderedCapability);
  7293. }
  7294. this._attachments = attachments || null;
  7295. if (!attachments) {
  7296. this._dispatchEvent(0);
  7297. return;
  7298. }
  7299. const fragment = document.createDocumentFragment();
  7300. let attachmentsCount = 0;
  7301. for (const name in attachments) {
  7302. const item = attachments[name];
  7303. const div = document.createElement("div");
  7304. div.className = "treeItem";
  7305. const element = document.createElement("a");
  7306. this._bindLink(element, item);
  7307. element.textContent = this._normalizeTextContent(item.filename);
  7308. div.append(element);
  7309. fragment.append(div);
  7310. attachmentsCount++;
  7311. }
  7312. this._finishRendering(fragment, attachmentsCount);
  7313. }
  7314. #appendAttachment(item) {
  7315. const renderedPromise = this._renderedCapability.promise;
  7316. renderedPromise.then(() => {
  7317. if (renderedPromise !== this._renderedCapability.promise) {
  7318. return;
  7319. }
  7320. const attachments = this._attachments || Object.create(null);
  7321. for (const name in attachments) {
  7322. if (item.filename === name) {
  7323. return;
  7324. }
  7325. }
  7326. attachments[item.filename] = item;
  7327. this.render({
  7328. attachments,
  7329. keepRenderedCapability: true
  7330. });
  7331. });
  7332. }
  7333. }
  7334. ;// ./web/grab_to_pan.js
  7335. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  7336. class GrabToPan {
  7337. constructor({
  7338. element
  7339. }) {
  7340. this.element = element;
  7341. this.document = element.ownerDocument;
  7342. this.activate = this.activate.bind(this);
  7343. this.deactivate = this.deactivate.bind(this);
  7344. this.toggle = this.toggle.bind(this);
  7345. this._onMouseDown = this.#onMouseDown.bind(this);
  7346. this._onMouseMove = this.#onMouseMove.bind(this);
  7347. this._endPan = this.#endPan.bind(this);
  7348. const overlay = this.overlay = document.createElement("div");
  7349. overlay.className = "grab-to-pan-grabbing";
  7350. }
  7351. activate() {
  7352. if (!this.active) {
  7353. this.active = true;
  7354. this.element.addEventListener("mousedown", this._onMouseDown, true);
  7355. this.element.classList.add(CSS_CLASS_GRAB);
  7356. }
  7357. }
  7358. deactivate() {
  7359. if (this.active) {
  7360. this.active = false;
  7361. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  7362. this._endPan();
  7363. this.element.classList.remove(CSS_CLASS_GRAB);
  7364. }
  7365. }
  7366. toggle() {
  7367. if (this.active) {
  7368. this.deactivate();
  7369. } else {
  7370. this.activate();
  7371. }
  7372. }
  7373. ignoreTarget(node) {
  7374. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  7375. }
  7376. #onMouseDown(event) {
  7377. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  7378. return;
  7379. }
  7380. if (event.originalTarget) {
  7381. try {
  7382. event.originalTarget.tagName;
  7383. } catch {
  7384. return;
  7385. }
  7386. }
  7387. this.scrollLeftStart = this.element.scrollLeft;
  7388. this.scrollTopStart = this.element.scrollTop;
  7389. this.clientXStart = event.clientX;
  7390. this.clientYStart = event.clientY;
  7391. this.document.addEventListener("mousemove", this._onMouseMove, true);
  7392. this.document.addEventListener("mouseup", this._endPan, true);
  7393. this.element.addEventListener("scroll", this._endPan, true);
  7394. event.preventDefault();
  7395. event.stopPropagation();
  7396. const focusedElement = document.activeElement;
  7397. if (focusedElement && !focusedElement.contains(event.target)) {
  7398. focusedElement.blur();
  7399. }
  7400. }
  7401. #onMouseMove(event) {
  7402. this.element.removeEventListener("scroll", this._endPan, true);
  7403. if (!(event.buttons & 1)) {
  7404. this._endPan();
  7405. return;
  7406. }
  7407. const xDiff = event.clientX - this.clientXStart;
  7408. const yDiff = event.clientY - this.clientYStart;
  7409. this.element.scrollTo({
  7410. top: this.scrollTopStart - yDiff,
  7411. left: this.scrollLeftStart - xDiff,
  7412. behavior: "instant"
  7413. });
  7414. if (!this.overlay.parentNode) {
  7415. document.body.append(this.overlay);
  7416. }
  7417. }
  7418. #endPan() {
  7419. this.element.removeEventListener("scroll", this._endPan, true);
  7420. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  7421. this.document.removeEventListener("mouseup", this._endPan, true);
  7422. this.overlay.remove();
  7423. }
  7424. }
  7425. ;// ./web/pdf_cursor_tools.js
  7426. class PDFCursorTools {
  7427. #active = CursorTool.SELECT;
  7428. #prevActive = null;
  7429. constructor({
  7430. container,
  7431. eventBus,
  7432. cursorToolOnLoad = CursorTool.SELECT
  7433. }) {
  7434. this.container = container;
  7435. this.eventBus = eventBus;
  7436. this.#addEventListeners();
  7437. Promise.resolve().then(() => {
  7438. this.switchTool(cursorToolOnLoad);
  7439. });
  7440. }
  7441. get activeTool() {
  7442. return this.#active;
  7443. }
  7444. switchTool(tool) {
  7445. if (this.#prevActive !== null) {
  7446. return;
  7447. }
  7448. this.#switchTool(tool);
  7449. }
  7450. #switchTool(tool, disabled = false) {
  7451. if (tool === this.#active) {
  7452. if (this.#prevActive !== null) {
  7453. this.eventBus.dispatch("cursortoolchanged", {
  7454. source: this,
  7455. tool,
  7456. disabled
  7457. });
  7458. }
  7459. return;
  7460. }
  7461. const disableActiveTool = () => {
  7462. switch (this.#active) {
  7463. case CursorTool.SELECT:
  7464. break;
  7465. case CursorTool.HAND:
  7466. this._handTool.deactivate();
  7467. break;
  7468. case CursorTool.ZOOM:
  7469. }
  7470. };
  7471. switch (tool) {
  7472. case CursorTool.SELECT:
  7473. disableActiveTool();
  7474. break;
  7475. case CursorTool.HAND:
  7476. disableActiveTool();
  7477. this._handTool.activate();
  7478. break;
  7479. case CursorTool.ZOOM:
  7480. default:
  7481. console.error(`switchTool: "${tool}" is an unsupported value.`);
  7482. return;
  7483. }
  7484. this.#active = tool;
  7485. this.eventBus.dispatch("cursortoolchanged", {
  7486. source: this,
  7487. tool,
  7488. disabled
  7489. });
  7490. }
  7491. #addEventListeners() {
  7492. this.eventBus._on("switchcursortool", evt => {
  7493. if (!evt.reset) {
  7494. this.switchTool(evt.tool);
  7495. } else if (this.#prevActive !== null) {
  7496. annotationEditorMode = AnnotationEditorType.NONE;
  7497. presentationModeState = PresentationModeState.NORMAL;
  7498. enableActive();
  7499. }
  7500. });
  7501. let annotationEditorMode = AnnotationEditorType.NONE,
  7502. presentationModeState = PresentationModeState.NORMAL;
  7503. const disableActive = () => {
  7504. this.#prevActive ??= this.#active;
  7505. this.#switchTool(CursorTool.SELECT, true);
  7506. };
  7507. const enableActive = () => {
  7508. if (this.#prevActive !== null && annotationEditorMode === AnnotationEditorType.NONE && presentationModeState === PresentationModeState.NORMAL) {
  7509. this.#switchTool(this.#prevActive);
  7510. this.#prevActive = null;
  7511. }
  7512. };
  7513. this.eventBus._on("annotationeditormodechanged", ({
  7514. mode
  7515. }) => {
  7516. annotationEditorMode = mode;
  7517. if (mode === AnnotationEditorType.NONE) {
  7518. enableActive();
  7519. } else {
  7520. disableActive();
  7521. }
  7522. });
  7523. this.eventBus._on("presentationmodechanged", ({
  7524. state
  7525. }) => {
  7526. presentationModeState = state;
  7527. if (state === PresentationModeState.NORMAL) {
  7528. enableActive();
  7529. } else if (state === PresentationModeState.FULLSCREEN) {
  7530. disableActive();
  7531. }
  7532. });
  7533. }
  7534. get _handTool() {
  7535. return shadow(this, "_handTool", new GrabToPan({
  7536. element: this.container
  7537. }));
  7538. }
  7539. }
  7540. ;// ./web/pdf_document_properties.js
  7541. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  7542. const US_PAGE_NAMES = {
  7543. "8.5x11": "pdfjs-document-properties-page-size-name-letter",
  7544. "8.5x14": "pdfjs-document-properties-page-size-name-legal"
  7545. };
  7546. const METRIC_PAGE_NAMES = {
  7547. "297x420": "pdfjs-document-properties-page-size-name-a-three",
  7548. "210x297": "pdfjs-document-properties-page-size-name-a-four"
  7549. };
  7550. function getPageName(size, isPortrait, pageNames) {
  7551. const width = isPortrait ? size.width : size.height;
  7552. const height = isPortrait ? size.height : size.width;
  7553. return pageNames[`${width}x${height}`];
  7554. }
  7555. class PDFDocumentProperties {
  7556. #fieldData = null;
  7557. constructor({
  7558. dialog,
  7559. fields,
  7560. closeButton
  7561. }, overlayManager, eventBus, l10n, fileNameLookup) {
  7562. this.dialog = dialog;
  7563. this.fields = fields;
  7564. this.overlayManager = overlayManager;
  7565. this.l10n = l10n;
  7566. this._fileNameLookup = fileNameLookup;
  7567. this.#reset();
  7568. closeButton.addEventListener("click", this.close.bind(this));
  7569. this.overlayManager.register(this.dialog);
  7570. eventBus._on("pagechanging", evt => {
  7571. this._currentPageNumber = evt.pageNumber;
  7572. });
  7573. eventBus._on("rotationchanging", evt => {
  7574. this._pagesRotation = evt.pagesRotation;
  7575. });
  7576. }
  7577. async open() {
  7578. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  7579. const currentPageNumber = this._currentPageNumber;
  7580. const pagesRotation = this._pagesRotation;
  7581. if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
  7582. this.#updateUI();
  7583. return;
  7584. }
  7585. const {
  7586. info,
  7587. contentLength
  7588. } = await this.pdfDocument.getMetadata();
  7589. 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 => {
  7590. return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
  7591. }), this.#parseLinearization(info.IsLinearized)]);
  7592. this.#fieldData = Object.freeze({
  7593. fileName,
  7594. fileSize,
  7595. title: info.Title,
  7596. author: info.Author,
  7597. subject: info.Subject,
  7598. keywords: info.Keywords,
  7599. creationDate,
  7600. modificationDate,
  7601. creator: info.Creator,
  7602. producer: info.Producer,
  7603. version: info.PDFFormatVersion,
  7604. pageCount: this.pdfDocument.numPages,
  7605. pageSize,
  7606. linearized: isLinearized,
  7607. _currentPageNumber: currentPageNumber,
  7608. _pagesRotation: pagesRotation
  7609. });
  7610. this.#updateUI();
  7611. const {
  7612. length
  7613. } = await this.pdfDocument.getDownloadInfo();
  7614. if (contentLength === length) {
  7615. return;
  7616. }
  7617. const data = Object.assign(Object.create(null), this.#fieldData);
  7618. data.fileSize = await this.#parseFileSize(length);
  7619. this.#fieldData = Object.freeze(data);
  7620. this.#updateUI();
  7621. }
  7622. async close() {
  7623. this.overlayManager.close(this.dialog);
  7624. }
  7625. setDocument(pdfDocument) {
  7626. if (this.pdfDocument) {
  7627. this.#reset();
  7628. this.#updateUI();
  7629. }
  7630. if (!pdfDocument) {
  7631. return;
  7632. }
  7633. this.pdfDocument = pdfDocument;
  7634. this._dataAvailableCapability.resolve();
  7635. }
  7636. #reset() {
  7637. this.pdfDocument = null;
  7638. this.#fieldData = null;
  7639. this._dataAvailableCapability = Promise.withResolvers();
  7640. this._currentPageNumber = 1;
  7641. this._pagesRotation = 0;
  7642. }
  7643. #updateUI() {
  7644. if (this.#fieldData && this.overlayManager.active !== this.dialog) {
  7645. return;
  7646. }
  7647. for (const id in this.fields) {
  7648. const content = this.#fieldData?.[id];
  7649. this.fields[id].textContent = content || content === 0 ? content : "-";
  7650. }
  7651. }
  7652. async #parseFileSize(b = 0) {
  7653. const kb = b / 1024,
  7654. mb = kb / 1024;
  7655. return kb ? this.l10n.get(mb >= 1 ? "pdfjs-document-properties-size-mb" : "pdfjs-document-properties-size-kb", {
  7656. mb,
  7657. kb,
  7658. b
  7659. }) : undefined;
  7660. }
  7661. async #parsePageSize(pageSizeInches, pagesRotation) {
  7662. if (!pageSizeInches) {
  7663. return undefined;
  7664. }
  7665. if (pagesRotation % 180 !== 0) {
  7666. pageSizeInches = {
  7667. width: pageSizeInches.height,
  7668. height: pageSizeInches.width
  7669. };
  7670. }
  7671. const isPortrait = isPortraitOrientation(pageSizeInches),
  7672. nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage());
  7673. let sizeInches = {
  7674. width: Math.round(pageSizeInches.width * 100) / 100,
  7675. height: Math.round(pageSizeInches.height * 100) / 100
  7676. };
  7677. let sizeMillimeters = {
  7678. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  7679. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  7680. };
  7681. let nameId = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  7682. if (!nameId && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  7683. const exactMillimeters = {
  7684. width: pageSizeInches.width * 25.4,
  7685. height: pageSizeInches.height * 25.4
  7686. };
  7687. const intMillimeters = {
  7688. width: Math.round(sizeMillimeters.width),
  7689. height: Math.round(sizeMillimeters.height)
  7690. };
  7691. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  7692. nameId = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  7693. if (nameId) {
  7694. sizeInches = {
  7695. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  7696. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  7697. };
  7698. sizeMillimeters = intMillimeters;
  7699. }
  7700. }
  7701. }
  7702. const [{
  7703. width,
  7704. height
  7705. }, unit, name, orientation] = await Promise.all([nonMetric ? sizeInches : sizeMillimeters, this.l10n.get(nonMetric ? "pdfjs-document-properties-page-size-unit-inches" : "pdfjs-document-properties-page-size-unit-millimeters"), nameId && this.l10n.get(nameId), this.l10n.get(isPortrait ? "pdfjs-document-properties-page-size-orientation-portrait" : "pdfjs-document-properties-page-size-orientation-landscape")]);
  7706. return this.l10n.get(name ? "pdfjs-document-properties-page-size-dimension-name-string" : "pdfjs-document-properties-page-size-dimension-string", {
  7707. width,
  7708. height,
  7709. unit,
  7710. name,
  7711. orientation
  7712. });
  7713. }
  7714. async #parseDate(inputDate) {
  7715. const dateObj = PDFDateString.toDateObject(inputDate);
  7716. return dateObj ? this.l10n.get("pdfjs-document-properties-date-time-string", {
  7717. dateObj: dateObj.valueOf()
  7718. }) : undefined;
  7719. }
  7720. #parseLinearization(isLinearized) {
  7721. return this.l10n.get(isLinearized ? "pdfjs-document-properties-linearized-yes" : "pdfjs-document-properties-linearized-no");
  7722. }
  7723. }
  7724. ;// ./web/pdf_find_utils.js
  7725. const CharacterType = {
  7726. SPACE: 0,
  7727. ALPHA_LETTER: 1,
  7728. PUNCT: 2,
  7729. HAN_LETTER: 3,
  7730. KATAKANA_LETTER: 4,
  7731. HIRAGANA_LETTER: 5,
  7732. HALFWIDTH_KATAKANA_LETTER: 6,
  7733. THAI_LETTER: 7
  7734. };
  7735. function isAlphabeticalScript(charCode) {
  7736. return charCode < 0x2e80;
  7737. }
  7738. function isAscii(charCode) {
  7739. return (charCode & 0xff80) === 0;
  7740. }
  7741. function isAsciiAlpha(charCode) {
  7742. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7743. }
  7744. function isAsciiDigit(charCode) {
  7745. return charCode >= 0x30 && charCode <= 0x39;
  7746. }
  7747. function isAsciiSpace(charCode) {
  7748. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7749. }
  7750. function isHan(charCode) {
  7751. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7752. }
  7753. function isKatakana(charCode) {
  7754. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7755. }
  7756. function isHiragana(charCode) {
  7757. return charCode >= 0x3040 && charCode <= 0x309f;
  7758. }
  7759. function isHalfwidthKatakana(charCode) {
  7760. return charCode >= 0xff60 && charCode <= 0xff9f;
  7761. }
  7762. function isThai(charCode) {
  7763. return (charCode & 0xff80) === 0x0e00;
  7764. }
  7765. function getCharacterType(charCode) {
  7766. if (isAlphabeticalScript(charCode)) {
  7767. if (isAscii(charCode)) {
  7768. if (isAsciiSpace(charCode)) {
  7769. return CharacterType.SPACE;
  7770. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7771. return CharacterType.ALPHA_LETTER;
  7772. }
  7773. return CharacterType.PUNCT;
  7774. } else if (isThai(charCode)) {
  7775. return CharacterType.THAI_LETTER;
  7776. } else if (charCode === 0xa0) {
  7777. return CharacterType.SPACE;
  7778. }
  7779. return CharacterType.ALPHA_LETTER;
  7780. }
  7781. if (isHan(charCode)) {
  7782. return CharacterType.HAN_LETTER;
  7783. } else if (isKatakana(charCode)) {
  7784. return CharacterType.KATAKANA_LETTER;
  7785. } else if (isHiragana(charCode)) {
  7786. return CharacterType.HIRAGANA_LETTER;
  7787. } else if (isHalfwidthKatakana(charCode)) {
  7788. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7789. }
  7790. return CharacterType.ALPHA_LETTER;
  7791. }
  7792. let NormalizeWithNFKC;
  7793. function getNormalizeWithNFKC() {
  7794. NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`;
  7795. return NormalizeWithNFKC;
  7796. }
  7797. ;// ./web/pdf_find_controller.js
  7798. const FindState = {
  7799. FOUND: 0,
  7800. NOT_FOUND: 1,
  7801. WRAPPED: 2,
  7802. PENDING: 3
  7803. };
  7804. const FIND_TIMEOUT = 250;
  7805. const MATCH_SCROLL_OFFSET_TOP = -50;
  7806. const MATCH_SCROLL_OFFSET_LEFT = -400;
  7807. const CHARACTERS_TO_NORMALIZE = {
  7808. "\u2010": "-",
  7809. "\u2018": "'",
  7810. "\u2019": "'",
  7811. "\u201A": "'",
  7812. "\u201B": "'",
  7813. "\u201C": '"',
  7814. "\u201D": '"',
  7815. "\u201E": '"',
  7816. "\u201F": '"',
  7817. "\u00BC": "1/4",
  7818. "\u00BD": "1/2",
  7819. "\u00BE": "3/4"
  7820. };
  7821. 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]);
  7822. let DIACRITICS_EXCEPTION_STR;
  7823. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  7824. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  7825. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  7826. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  7827. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  7828. const SYLLABLES_LENGTHS = new Map();
  7829. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  7830. const NFKC_CHARS_TO_NORMALIZE = new Map();
  7831. let noSyllablesRegExp = null;
  7832. let withSyllablesRegExp = null;
  7833. function normalize(text) {
  7834. const syllablePositions = [];
  7835. let m;
  7836. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  7837. let {
  7838. index
  7839. } = m;
  7840. for (const char of m[0]) {
  7841. let len = SYLLABLES_LENGTHS.get(char);
  7842. if (!len) {
  7843. len = char.normalize("NFD").length;
  7844. SYLLABLES_LENGTHS.set(char, len);
  7845. }
  7846. syllablePositions.push([len, index++]);
  7847. }
  7848. }
  7849. let normalizationRegex;
  7850. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  7851. normalizationRegex = noSyllablesRegExp;
  7852. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  7853. normalizationRegex = withSyllablesRegExp;
  7854. } else {
  7855. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  7856. const toNormalizeWithNFKC = getNormalizeWithNFKC();
  7857. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  7858. const HKDiacritics = "(?:\u3099|\u309A)";
  7859. const CompoundWord = "\\p{Ll}-\\n\\p{Lu}";
  7860. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(${CompoundWord})|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  7861. if (syllablePositions.length === 0) {
  7862. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  7863. } else {
  7864. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  7865. }
  7866. }
  7867. const rawDiacriticsPositions = [];
  7868. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  7869. rawDiacriticsPositions.push([m[0].length, m.index]);
  7870. }
  7871. let normalized = text.normalize("NFD");
  7872. const positions = [[0, 0]];
  7873. let rawDiacriticsIndex = 0;
  7874. let syllableIndex = 0;
  7875. let shift = 0;
  7876. let shiftOrigin = 0;
  7877. let eol = 0;
  7878. let hasDiacritics = false;
  7879. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, p9, i) => {
  7880. i -= shiftOrigin;
  7881. if (p1) {
  7882. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  7883. const jj = replacement.length;
  7884. for (let j = 1; j < jj; j++) {
  7885. positions.push([i - shift + j, shift - j]);
  7886. }
  7887. shift -= jj - 1;
  7888. return replacement;
  7889. }
  7890. if (p2) {
  7891. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  7892. if (!replacement) {
  7893. replacement = p2.normalize("NFKC");
  7894. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  7895. }
  7896. const jj = replacement.length;
  7897. for (let j = 1; j < jj; j++) {
  7898. positions.push([i - shift + j, shift - j]);
  7899. }
  7900. shift -= jj - 1;
  7901. return replacement;
  7902. }
  7903. if (p3) {
  7904. hasDiacritics = true;
  7905. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7906. ++rawDiacriticsIndex;
  7907. } else {
  7908. positions.push([i - 1 - shift + 1, shift - 1]);
  7909. shift -= 1;
  7910. shiftOrigin += 1;
  7911. }
  7912. positions.push([i - shift + 1, shift]);
  7913. shiftOrigin += 1;
  7914. eol += 1;
  7915. return p3.charAt(0);
  7916. }
  7917. if (p4) {
  7918. const hasTrailingDashEOL = p4.endsWith("\n");
  7919. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  7920. hasDiacritics = true;
  7921. let jj = len;
  7922. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7923. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  7924. ++rawDiacriticsIndex;
  7925. }
  7926. for (let j = 1; j <= jj; j++) {
  7927. positions.push([i - 1 - shift + j, shift - j]);
  7928. }
  7929. shift -= jj;
  7930. shiftOrigin += jj;
  7931. if (hasTrailingDashEOL) {
  7932. i += len - 1;
  7933. positions.push([i - shift + 1, 1 + shift]);
  7934. shift += 1;
  7935. shiftOrigin += 1;
  7936. eol += 1;
  7937. return p4.slice(0, len);
  7938. }
  7939. return p4;
  7940. }
  7941. if (p5) {
  7942. positions.push([i - shift + 3, 1 + shift]);
  7943. shift += 1;
  7944. shiftOrigin += 1;
  7945. eol += 1;
  7946. return p5.replace("\n", "");
  7947. }
  7948. if (p6) {
  7949. const len = p6.length - 2;
  7950. positions.push([i - shift + len, 1 + shift]);
  7951. shift += 1;
  7952. shiftOrigin += 1;
  7953. eol += 1;
  7954. return p6.slice(0, -2);
  7955. }
  7956. if (p7) {
  7957. const len = p7.length - 1;
  7958. positions.push([i - shift + len, shift]);
  7959. shiftOrigin += 1;
  7960. eol += 1;
  7961. return p7.slice(0, -1);
  7962. }
  7963. if (p8) {
  7964. positions.push([i - shift + 1, shift - 1]);
  7965. shift -= 1;
  7966. shiftOrigin += 1;
  7967. eol += 1;
  7968. return " ";
  7969. }
  7970. if (i + eol === syllablePositions[syllableIndex]?.[1]) {
  7971. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  7972. ++syllableIndex;
  7973. for (let j = 1; j <= newCharLen; j++) {
  7974. positions.push([i - (shift - j), shift - j]);
  7975. }
  7976. shift -= newCharLen;
  7977. shiftOrigin += newCharLen;
  7978. }
  7979. return p9;
  7980. });
  7981. positions.push([normalized.length, shift]);
  7982. return [normalized, positions, hasDiacritics];
  7983. }
  7984. function getOriginalIndex(diffs, pos, len) {
  7985. if (!diffs) {
  7986. return [pos, len];
  7987. }
  7988. const start = pos;
  7989. const end = pos + len - 1;
  7990. let i = binarySearchFirstItem(diffs, x => x[0] >= start);
  7991. if (diffs[i][0] > start) {
  7992. --i;
  7993. }
  7994. let j = binarySearchFirstItem(diffs, x => x[0] >= end, i);
  7995. if (diffs[j][0] > end) {
  7996. --j;
  7997. }
  7998. const oldStart = start + diffs[i][1];
  7999. const oldEnd = end + diffs[j][1];
  8000. const oldLen = oldEnd + 1 - oldStart;
  8001. return [oldStart, oldLen];
  8002. }
  8003. class PDFFindController {
  8004. #state = null;
  8005. #updateMatchesCountOnProgress = true;
  8006. #visitedPagesCount = 0;
  8007. constructor({
  8008. linkService,
  8009. eventBus,
  8010. updateMatchesCountOnProgress = true
  8011. }) {
  8012. this._linkService = linkService;
  8013. this._eventBus = eventBus;
  8014. this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
  8015. this.onIsPageVisible = null;
  8016. this.#reset();
  8017. eventBus._on("find", this.#onFind.bind(this));
  8018. eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
  8019. }
  8020. get highlightMatches() {
  8021. return this._highlightMatches;
  8022. }
  8023. get pageMatches() {
  8024. return this._pageMatches;
  8025. }
  8026. get pageMatchesLength() {
  8027. return this._pageMatchesLength;
  8028. }
  8029. get selected() {
  8030. return this._selected;
  8031. }
  8032. get state() {
  8033. return this.#state;
  8034. }
  8035. setDocument(pdfDocument) {
  8036. if (this._pdfDocument) {
  8037. this.#reset();
  8038. }
  8039. if (!pdfDocument) {
  8040. return;
  8041. }
  8042. this._pdfDocument = pdfDocument;
  8043. this._firstPageCapability.resolve();
  8044. }
  8045. #onFind(state) {
  8046. if (!state) {
  8047. return;
  8048. }
  8049. const pdfDocument = this._pdfDocument;
  8050. const {
  8051. type
  8052. } = state;
  8053. if (this.#state === null || this.#shouldDirtyMatch(state)) {
  8054. this._dirtyMatch = true;
  8055. }
  8056. this.#state = state;
  8057. if (type !== "highlightallchange") {
  8058. this.#updateUIState(FindState.PENDING);
  8059. }
  8060. this._firstPageCapability.promise.then(() => {
  8061. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  8062. return;
  8063. }
  8064. this.#extractText();
  8065. const findbarClosed = !this._highlightMatches;
  8066. const pendingTimeout = !!this._findTimeout;
  8067. if (this._findTimeout) {
  8068. clearTimeout(this._findTimeout);
  8069. this._findTimeout = null;
  8070. }
  8071. if (!type) {
  8072. this._findTimeout = setTimeout(() => {
  8073. this.#nextMatch();
  8074. this._findTimeout = null;
  8075. }, FIND_TIMEOUT);
  8076. } else if (this._dirtyMatch) {
  8077. this.#nextMatch();
  8078. } else if (type === "again") {
  8079. this.#nextMatch();
  8080. if (findbarClosed && this.#state.highlightAll) {
  8081. this.#updateAllPages();
  8082. }
  8083. } else if (type === "highlightallchange") {
  8084. if (pendingTimeout) {
  8085. this.#nextMatch();
  8086. } else {
  8087. this._highlightMatches = true;
  8088. }
  8089. this.#updateAllPages();
  8090. } else {
  8091. this.#nextMatch();
  8092. }
  8093. });
  8094. }
  8095. scrollMatchIntoView({
  8096. element = null,
  8097. selectedLeft = 0,
  8098. pageIndex = -1,
  8099. matchIndex = -1
  8100. }) {
  8101. if (!this._scrollMatches || !element) {
  8102. return;
  8103. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  8104. return;
  8105. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  8106. return;
  8107. }
  8108. this._scrollMatches = false;
  8109. const spot = {
  8110. top: MATCH_SCROLL_OFFSET_TOP,
  8111. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  8112. };
  8113. scrollIntoView(element, spot, true);
  8114. }
  8115. #reset() {
  8116. this._highlightMatches = false;
  8117. this._scrollMatches = false;
  8118. this._pdfDocument = null;
  8119. this._pageMatches = [];
  8120. this._pageMatchesLength = [];
  8121. this.#visitedPagesCount = 0;
  8122. this.#state = null;
  8123. this._selected = {
  8124. pageIdx: -1,
  8125. matchIdx: -1
  8126. };
  8127. this._offset = {
  8128. pageIdx: null,
  8129. matchIdx: null,
  8130. wrapped: false
  8131. };
  8132. this._extractTextPromises = [];
  8133. this._pageContents = [];
  8134. this._pageDiffs = [];
  8135. this._hasDiacritics = [];
  8136. this._matchesCountTotal = 0;
  8137. this._pagesToSearch = null;
  8138. this._pendingFindMatches = new Set();
  8139. this._resumePageIdx = null;
  8140. this._dirtyMatch = false;
  8141. clearTimeout(this._findTimeout);
  8142. this._findTimeout = null;
  8143. this._firstPageCapability = Promise.withResolvers();
  8144. }
  8145. get #query() {
  8146. const {
  8147. query
  8148. } = this.#state;
  8149. if (typeof query === "string") {
  8150. if (query !== this._rawQuery) {
  8151. this._rawQuery = query;
  8152. [this._normalizedQuery] = normalize(query);
  8153. }
  8154. return this._normalizedQuery;
  8155. }
  8156. return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
  8157. }
  8158. #shouldDirtyMatch(state) {
  8159. const newQuery = state.query,
  8160. prevQuery = this.#state.query;
  8161. const newType = typeof newQuery,
  8162. prevType = typeof prevQuery;
  8163. if (newType !== prevType) {
  8164. return true;
  8165. }
  8166. if (newType === "string") {
  8167. if (newQuery !== prevQuery) {
  8168. return true;
  8169. }
  8170. } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
  8171. return true;
  8172. }
  8173. switch (state.type) {
  8174. case "again":
  8175. const pageNumber = this._selected.pageIdx + 1;
  8176. const linkService = this._linkService;
  8177. return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
  8178. case "highlightallchange":
  8179. return false;
  8180. }
  8181. return true;
  8182. }
  8183. #isEntireWord(content, startIdx, length) {
  8184. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  8185. if (match) {
  8186. const first = content.charCodeAt(startIdx);
  8187. const limit = match[1].charCodeAt(0);
  8188. if (getCharacterType(first) === getCharacterType(limit)) {
  8189. return false;
  8190. }
  8191. }
  8192. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  8193. if (match) {
  8194. const last = content.charCodeAt(startIdx + length - 1);
  8195. const limit = match[1].charCodeAt(0);
  8196. if (getCharacterType(last) === getCharacterType(limit)) {
  8197. return false;
  8198. }
  8199. }
  8200. return true;
  8201. }
  8202. #convertToRegExpString(query, hasDiacritics) {
  8203. const {
  8204. matchDiacritics
  8205. } = this.#state;
  8206. let isUnicode = false;
  8207. query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  8208. if (p1) {
  8209. return `[ ]*\\${p1}[ ]*`;
  8210. }
  8211. if (p2) {
  8212. return `[ ]*${p2}[ ]*`;
  8213. }
  8214. if (p3) {
  8215. return "[ ]+";
  8216. }
  8217. if (matchDiacritics) {
  8218. return p4 || p5;
  8219. }
  8220. if (p4) {
  8221. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  8222. }
  8223. if (hasDiacritics) {
  8224. isUnicode = true;
  8225. return `${p5}\\p{M}*`;
  8226. }
  8227. return p5;
  8228. });
  8229. const trailingSpaces = "[ ]*";
  8230. if (query.endsWith(trailingSpaces)) {
  8231. query = query.slice(0, query.length - trailingSpaces.length);
  8232. }
  8233. if (matchDiacritics) {
  8234. if (hasDiacritics) {
  8235. DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
  8236. isUnicode = true;
  8237. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  8238. }
  8239. }
  8240. return [isUnicode, query];
  8241. }
  8242. #calculateMatch(pageIndex) {
  8243. const query = this.#query;
  8244. if (query.length === 0) {
  8245. return;
  8246. }
  8247. const pageContent = this._pageContents[pageIndex];
  8248. const matcherResult = this.match(query, pageContent, pageIndex);
  8249. const matches = this._pageMatches[pageIndex] = [];
  8250. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  8251. const diffs = this._pageDiffs[pageIndex];
  8252. matcherResult?.forEach(({
  8253. index,
  8254. length
  8255. }) => {
  8256. const [matchPos, matchLen] = getOriginalIndex(diffs, index, length);
  8257. if (matchLen) {
  8258. matches.push(matchPos);
  8259. matchesLength.push(matchLen);
  8260. }
  8261. });
  8262. if (this.#state.highlightAll) {
  8263. this.#updatePage(pageIndex);
  8264. }
  8265. if (this._resumePageIdx === pageIndex) {
  8266. this._resumePageIdx = null;
  8267. this.#nextPageMatch();
  8268. }
  8269. const pageMatchesCount = matches.length;
  8270. this._matchesCountTotal += pageMatchesCount;
  8271. if (this.#updateMatchesCountOnProgress) {
  8272. if (pageMatchesCount > 0) {
  8273. this.#updateUIResultsCount();
  8274. }
  8275. } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
  8276. this.#updateUIResultsCount();
  8277. }
  8278. }
  8279. match(query, pageContent, pageIndex) {
  8280. const hasDiacritics = this._hasDiacritics[pageIndex];
  8281. let isUnicode = false;
  8282. if (typeof query === "string") {
  8283. [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
  8284. } else {
  8285. query = query.sort().reverse().map(q => {
  8286. const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
  8287. isUnicode ||= isUnicodePart;
  8288. return `(${queryPart})`;
  8289. }).join("|");
  8290. }
  8291. if (!query) {
  8292. return undefined;
  8293. }
  8294. const {
  8295. caseSensitive,
  8296. entireWord
  8297. } = this.#state;
  8298. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  8299. query = new RegExp(query, flags);
  8300. const matches = [];
  8301. let match;
  8302. while ((match = query.exec(pageContent)) !== null) {
  8303. if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
  8304. continue;
  8305. }
  8306. matches.push({
  8307. index: match.index,
  8308. length: match[0].length
  8309. });
  8310. }
  8311. return matches;
  8312. }
  8313. #extractText() {
  8314. if (this._extractTextPromises.length > 0) {
  8315. return;
  8316. }
  8317. let deferred = Promise.resolve();
  8318. const textOptions = {
  8319. disableNormalization: true
  8320. };
  8321. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  8322. const {
  8323. promise,
  8324. resolve
  8325. } = Promise.withResolvers();
  8326. this._extractTextPromises[i] = promise;
  8327. deferred = deferred.then(() => {
  8328. return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => {
  8329. const strBuf = [];
  8330. for (const textItem of textContent.items) {
  8331. strBuf.push(textItem.str);
  8332. if (textItem.hasEOL) {
  8333. strBuf.push("\n");
  8334. }
  8335. }
  8336. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  8337. resolve();
  8338. }, reason => {
  8339. console.error(`Unable to get text content for page ${i + 1}`, reason);
  8340. this._pageContents[i] = "";
  8341. this._pageDiffs[i] = null;
  8342. this._hasDiacritics[i] = false;
  8343. resolve();
  8344. });
  8345. });
  8346. }
  8347. }
  8348. #updatePage(index) {
  8349. if (this._scrollMatches && this._selected.pageIdx === index) {
  8350. this._linkService.page = index + 1;
  8351. }
  8352. this._eventBus.dispatch("updatetextlayermatches", {
  8353. source: this,
  8354. pageIndex: index
  8355. });
  8356. }
  8357. #updateAllPages() {
  8358. this._eventBus.dispatch("updatetextlayermatches", {
  8359. source: this,
  8360. pageIndex: -1
  8361. });
  8362. }
  8363. #nextMatch() {
  8364. const previous = this.#state.findPrevious;
  8365. const currentPageIndex = this._linkService.page - 1;
  8366. const numPages = this._linkService.pagesCount;
  8367. this._highlightMatches = true;
  8368. if (this._dirtyMatch) {
  8369. this._dirtyMatch = false;
  8370. this._selected.pageIdx = this._selected.matchIdx = -1;
  8371. this._offset.pageIdx = currentPageIndex;
  8372. this._offset.matchIdx = null;
  8373. this._offset.wrapped = false;
  8374. this._resumePageIdx = null;
  8375. this._pageMatches.length = 0;
  8376. this._pageMatchesLength.length = 0;
  8377. this.#visitedPagesCount = 0;
  8378. this._matchesCountTotal = 0;
  8379. this.#updateAllPages();
  8380. for (let i = 0; i < numPages; i++) {
  8381. if (this._pendingFindMatches.has(i)) {
  8382. continue;
  8383. }
  8384. this._pendingFindMatches.add(i);
  8385. this._extractTextPromises[i].then(() => {
  8386. this._pendingFindMatches.delete(i);
  8387. this.#calculateMatch(i);
  8388. });
  8389. }
  8390. }
  8391. const query = this.#query;
  8392. if (query.length === 0) {
  8393. this.#updateUIState(FindState.FOUND);
  8394. return;
  8395. }
  8396. if (this._resumePageIdx) {
  8397. return;
  8398. }
  8399. const offset = this._offset;
  8400. this._pagesToSearch = numPages;
  8401. if (offset.matchIdx !== null) {
  8402. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  8403. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  8404. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  8405. this.#updateMatch(true);
  8406. return;
  8407. }
  8408. this.#advanceOffsetPage(previous);
  8409. }
  8410. this.#nextPageMatch();
  8411. }
  8412. #matchesReady(matches) {
  8413. const offset = this._offset;
  8414. const numMatches = matches.length;
  8415. const previous = this.#state.findPrevious;
  8416. if (numMatches) {
  8417. offset.matchIdx = previous ? numMatches - 1 : 0;
  8418. this.#updateMatch(true);
  8419. return true;
  8420. }
  8421. this.#advanceOffsetPage(previous);
  8422. if (offset.wrapped) {
  8423. offset.matchIdx = null;
  8424. if (this._pagesToSearch < 0) {
  8425. this.#updateMatch(false);
  8426. return true;
  8427. }
  8428. }
  8429. return false;
  8430. }
  8431. #nextPageMatch() {
  8432. if (this._resumePageIdx !== null) {
  8433. console.error("There can only be one pending page.");
  8434. }
  8435. let matches = null;
  8436. do {
  8437. const pageIdx = this._offset.pageIdx;
  8438. matches = this._pageMatches[pageIdx];
  8439. if (!matches) {
  8440. this._resumePageIdx = pageIdx;
  8441. break;
  8442. }
  8443. } while (!this.#matchesReady(matches));
  8444. }
  8445. #advanceOffsetPage(previous) {
  8446. const offset = this._offset;
  8447. const numPages = this._linkService.pagesCount;
  8448. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  8449. offset.matchIdx = null;
  8450. this._pagesToSearch--;
  8451. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  8452. offset.pageIdx = previous ? numPages - 1 : 0;
  8453. offset.wrapped = true;
  8454. }
  8455. }
  8456. #updateMatch(found = false) {
  8457. let state = FindState.NOT_FOUND;
  8458. const wrapped = this._offset.wrapped;
  8459. this._offset.wrapped = false;
  8460. if (found) {
  8461. const previousPage = this._selected.pageIdx;
  8462. this._selected.pageIdx = this._offset.pageIdx;
  8463. this._selected.matchIdx = this._offset.matchIdx;
  8464. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  8465. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  8466. this.#updatePage(previousPage);
  8467. }
  8468. }
  8469. this.#updateUIState(state, this.#state.findPrevious);
  8470. if (this._selected.pageIdx !== -1) {
  8471. this._scrollMatches = true;
  8472. this.#updatePage(this._selected.pageIdx);
  8473. }
  8474. }
  8475. #onFindBarClose(evt) {
  8476. const pdfDocument = this._pdfDocument;
  8477. this._firstPageCapability.promise.then(() => {
  8478. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  8479. return;
  8480. }
  8481. if (this._findTimeout) {
  8482. clearTimeout(this._findTimeout);
  8483. this._findTimeout = null;
  8484. }
  8485. if (this._resumePageIdx) {
  8486. this._resumePageIdx = null;
  8487. this._dirtyMatch = true;
  8488. }
  8489. this.#updateUIState(FindState.FOUND);
  8490. this._highlightMatches = false;
  8491. this.#updateAllPages();
  8492. });
  8493. }
  8494. #requestMatchesCount() {
  8495. const {
  8496. pageIdx,
  8497. matchIdx
  8498. } = this._selected;
  8499. let current = 0,
  8500. total = this._matchesCountTotal;
  8501. if (matchIdx !== -1) {
  8502. for (let i = 0; i < pageIdx; i++) {
  8503. current += this._pageMatches[i]?.length || 0;
  8504. }
  8505. current += matchIdx + 1;
  8506. }
  8507. if (current < 1 || current > total) {
  8508. current = total = 0;
  8509. }
  8510. return {
  8511. current,
  8512. total
  8513. };
  8514. }
  8515. #updateUIResultsCount() {
  8516. this._eventBus.dispatch("updatefindmatchescount", {
  8517. source: this,
  8518. matchesCount: this.#requestMatchesCount()
  8519. });
  8520. }
  8521. #updateUIState(state, previous = false) {
  8522. if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
  8523. return;
  8524. }
  8525. this._eventBus.dispatch("updatefindcontrolstate", {
  8526. source: this,
  8527. state,
  8528. previous,
  8529. entireWord: this.#state?.entireWord ?? null,
  8530. matchesCount: this.#requestMatchesCount(),
  8531. rawQuery: this.#state?.query ?? null
  8532. });
  8533. }
  8534. }
  8535. ;// ./web/pdf_find_bar.js
  8536. const MATCHES_COUNT_LIMIT = 1000;
  8537. class PDFFindBar {
  8538. #mainContainer;
  8539. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  8540. constructor(options, mainContainer, eventBus) {
  8541. this.opened = false;
  8542. this.bar = options.bar;
  8543. this.toggleButton = options.toggleButton;
  8544. this.findField = options.findField;
  8545. this.highlightAll = options.highlightAllCheckbox;
  8546. this.caseSensitive = options.caseSensitiveCheckbox;
  8547. this.matchDiacritics = options.matchDiacriticsCheckbox;
  8548. this.entireWord = options.entireWordCheckbox;
  8549. this.findMsg = options.findMsg;
  8550. this.findResultsCount = options.findResultsCount;
  8551. this.findPreviousButton = options.findPreviousButton;
  8552. this.findNextButton = options.findNextButton;
  8553. this.eventBus = eventBus;
  8554. this.#mainContainer = mainContainer;
  8555. this.toggleButton.addEventListener("click", () => {
  8556. this.toggle();
  8557. });
  8558. this.findField.addEventListener("input", () => {
  8559. this.dispatchEvent("");
  8560. });
  8561. this.bar.addEventListener("keydown", e => {
  8562. switch (e.keyCode) {
  8563. case 13:
  8564. if (e.target === this.findField) {
  8565. this.dispatchEvent("again", e.shiftKey);
  8566. }
  8567. break;
  8568. case 27:
  8569. this.close();
  8570. break;
  8571. }
  8572. });
  8573. this.findPreviousButton.addEventListener("click", () => {
  8574. this.dispatchEvent("again", true);
  8575. });
  8576. this.findNextButton.addEventListener("click", () => {
  8577. this.dispatchEvent("again", false);
  8578. });
  8579. this.highlightAll.addEventListener("click", () => {
  8580. this.dispatchEvent("highlightallchange");
  8581. });
  8582. this.caseSensitive.addEventListener("click", () => {
  8583. this.dispatchEvent("casesensitivitychange");
  8584. });
  8585. this.entireWord.addEventListener("click", () => {
  8586. this.dispatchEvent("entirewordchange");
  8587. });
  8588. this.matchDiacritics.addEventListener("click", () => {
  8589. this.dispatchEvent("diacriticmatchingchange");
  8590. });
  8591. }
  8592. reset() {
  8593. this.updateUIState();
  8594. }
  8595. dispatchEvent(type, findPrev = false) {
  8596. this.eventBus.dispatch("find", {
  8597. source: this,
  8598. type,
  8599. query: this.findField.value,
  8600. caseSensitive: this.caseSensitive.checked,
  8601. entireWord: this.entireWord.checked,
  8602. highlightAll: this.highlightAll.checked,
  8603. findPrevious: findPrev,
  8604. matchDiacritics: this.matchDiacritics.checked
  8605. });
  8606. }
  8607. updateUIState(state, previous, matchesCount) {
  8608. const {
  8609. findField,
  8610. findMsg
  8611. } = this;
  8612. let findMsgId = "",
  8613. status = "";
  8614. switch (state) {
  8615. case FindState.FOUND:
  8616. break;
  8617. case FindState.PENDING:
  8618. status = "pending";
  8619. break;
  8620. case FindState.NOT_FOUND:
  8621. findMsgId = "pdfjs-find-not-found";
  8622. status = "notFound";
  8623. break;
  8624. case FindState.WRAPPED:
  8625. findMsgId = previous ? "pdfjs-find-reached-top" : "pdfjs-find-reached-bottom";
  8626. break;
  8627. }
  8628. findField.setAttribute("data-status", status);
  8629. findField.setAttribute("aria-invalid", state === FindState.NOT_FOUND);
  8630. findMsg.setAttribute("data-status", status);
  8631. if (findMsgId) {
  8632. findMsg.setAttribute("data-l10n-id", findMsgId);
  8633. } else {
  8634. findMsg.removeAttribute("data-l10n-id");
  8635. findMsg.textContent = "";
  8636. }
  8637. this.updateResultsCount(matchesCount);
  8638. }
  8639. updateResultsCount({
  8640. current = 0,
  8641. total = 0
  8642. } = {}) {
  8643. const {
  8644. findResultsCount
  8645. } = this;
  8646. if (total > 0) {
  8647. const limit = MATCHES_COUNT_LIMIT;
  8648. findResultsCount.setAttribute("data-l10n-id", total > limit ? "pdfjs-find-match-count-limit" : "pdfjs-find-match-count");
  8649. findResultsCount.setAttribute("data-l10n-args", JSON.stringify({
  8650. limit,
  8651. current,
  8652. total
  8653. }));
  8654. } else {
  8655. findResultsCount.removeAttribute("data-l10n-id");
  8656. findResultsCount.textContent = "";
  8657. }
  8658. }
  8659. open() {
  8660. if (!this.opened) {
  8661. this.#resizeObserver.observe(this.#mainContainer);
  8662. this.#resizeObserver.observe(this.bar);
  8663. this.opened = true;
  8664. toggleExpandedBtn(this.toggleButton, true, this.bar);
  8665. }
  8666. this.findField.select();
  8667. this.findField.focus();
  8668. }
  8669. close() {
  8670. if (!this.opened) {
  8671. return;
  8672. }
  8673. this.#resizeObserver.disconnect();
  8674. this.opened = false;
  8675. toggleExpandedBtn(this.toggleButton, false, this.bar);
  8676. this.eventBus.dispatch("findbarclose", {
  8677. source: this
  8678. });
  8679. }
  8680. toggle() {
  8681. if (this.opened) {
  8682. this.close();
  8683. } else {
  8684. this.open();
  8685. }
  8686. }
  8687. #resizeObserverCallback() {
  8688. const {
  8689. bar
  8690. } = this;
  8691. bar.classList.remove("wrapContainers");
  8692. const findbarHeight = bar.clientHeight;
  8693. const inputContainerHeight = bar.firstElementChild.clientHeight;
  8694. if (findbarHeight > inputContainerHeight) {
  8695. bar.classList.add("wrapContainers");
  8696. }
  8697. }
  8698. }
  8699. ;// ./web/pdf_history.js
  8700. const HASH_CHANGE_TIMEOUT = 1000;
  8701. const POSITION_UPDATED_THRESHOLD = 50;
  8702. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  8703. function getCurrentHash() {
  8704. return document.location.hash;
  8705. }
  8706. class PDFHistory {
  8707. #eventAbortController = null;
  8708. constructor({
  8709. linkService,
  8710. eventBus
  8711. }) {
  8712. this.linkService = linkService;
  8713. this.eventBus = eventBus;
  8714. this._initialized = false;
  8715. this._fingerprint = "";
  8716. this.reset();
  8717. this.eventBus._on("pagesinit", () => {
  8718. this._isPagesLoaded = false;
  8719. this.eventBus._on("pagesloaded", evt => {
  8720. this._isPagesLoaded = !!evt.pagesCount;
  8721. }, {
  8722. once: true
  8723. });
  8724. });
  8725. }
  8726. initialize({
  8727. fingerprint,
  8728. resetHistory = false,
  8729. updateUrl = false
  8730. }) {
  8731. if (!fingerprint || typeof fingerprint !== "string") {
  8732. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  8733. return;
  8734. }
  8735. if (this._initialized) {
  8736. this.reset();
  8737. }
  8738. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  8739. this._fingerprint = fingerprint;
  8740. this._updateUrl = updateUrl === true;
  8741. this._initialized = true;
  8742. this.#bindEvents();
  8743. const state = window.history.state;
  8744. this._popStateInProgress = false;
  8745. this._blockHashChange = 0;
  8746. this._currentHash = getCurrentHash();
  8747. this._numPositionUpdates = 0;
  8748. this._uid = this._maxUid = 0;
  8749. this._destination = null;
  8750. this._position = null;
  8751. if (!this.#isValidState(state, true) || resetHistory) {
  8752. const {
  8753. hash,
  8754. page,
  8755. rotation
  8756. } = this.#parseCurrentHash(true);
  8757. if (!hash || reInitialized || resetHistory) {
  8758. this.#pushOrReplaceState(null, true);
  8759. return;
  8760. }
  8761. this.#pushOrReplaceState({
  8762. hash,
  8763. page,
  8764. rotation
  8765. }, true);
  8766. return;
  8767. }
  8768. const destination = state.destination;
  8769. this.#updateInternalState(destination, state.uid, true);
  8770. if (destination.rotation !== undefined) {
  8771. this._initialRotation = destination.rotation;
  8772. }
  8773. if (destination.dest) {
  8774. this._initialBookmark = JSON.stringify(destination.dest);
  8775. this._destination.page = null;
  8776. } else if (destination.hash) {
  8777. this._initialBookmark = destination.hash;
  8778. } else if (destination.page) {
  8779. this._initialBookmark = `page=${destination.page}`;
  8780. }
  8781. }
  8782. reset() {
  8783. if (this._initialized) {
  8784. this.#pageHide();
  8785. this._initialized = false;
  8786. this.#unbindEvents();
  8787. }
  8788. if (this._updateViewareaTimeout) {
  8789. clearTimeout(this._updateViewareaTimeout);
  8790. this._updateViewareaTimeout = null;
  8791. }
  8792. this._initialBookmark = null;
  8793. this._initialRotation = null;
  8794. }
  8795. push({
  8796. namedDest = null,
  8797. explicitDest,
  8798. pageNumber
  8799. }) {
  8800. if (!this._initialized) {
  8801. return;
  8802. }
  8803. if (namedDest && typeof namedDest !== "string") {
  8804. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  8805. return;
  8806. } else if (!Array.isArray(explicitDest)) {
  8807. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  8808. return;
  8809. } else if (!this.#isValidPage(pageNumber)) {
  8810. if (pageNumber !== null || this._destination) {
  8811. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  8812. return;
  8813. }
  8814. }
  8815. const hash = namedDest || JSON.stringify(explicitDest);
  8816. if (!hash) {
  8817. return;
  8818. }
  8819. let forceReplace = false;
  8820. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  8821. if (this._destination.page) {
  8822. return;
  8823. }
  8824. forceReplace = true;
  8825. }
  8826. if (this._popStateInProgress && !forceReplace) {
  8827. return;
  8828. }
  8829. this.#pushOrReplaceState({
  8830. dest: explicitDest,
  8831. hash,
  8832. page: pageNumber,
  8833. rotation: this.linkService.rotation
  8834. }, forceReplace);
  8835. if (!this._popStateInProgress) {
  8836. this._popStateInProgress = true;
  8837. Promise.resolve().then(() => {
  8838. this._popStateInProgress = false;
  8839. });
  8840. }
  8841. }
  8842. pushPage(pageNumber) {
  8843. if (!this._initialized) {
  8844. return;
  8845. }
  8846. if (!this.#isValidPage(pageNumber)) {
  8847. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  8848. return;
  8849. }
  8850. if (this._destination?.page === pageNumber) {
  8851. return;
  8852. }
  8853. if (this._popStateInProgress) {
  8854. return;
  8855. }
  8856. this.#pushOrReplaceState({
  8857. dest: null,
  8858. hash: `page=${pageNumber}`,
  8859. page: pageNumber,
  8860. rotation: this.linkService.rotation
  8861. });
  8862. if (!this._popStateInProgress) {
  8863. this._popStateInProgress = true;
  8864. Promise.resolve().then(() => {
  8865. this._popStateInProgress = false;
  8866. });
  8867. }
  8868. }
  8869. pushCurrentPosition() {
  8870. if (!this._initialized || this._popStateInProgress) {
  8871. return;
  8872. }
  8873. this.#tryPushCurrentPosition();
  8874. }
  8875. back() {
  8876. if (!this._initialized || this._popStateInProgress) {
  8877. return;
  8878. }
  8879. const state = window.history.state;
  8880. if (this.#isValidState(state) && state.uid > 0) {
  8881. window.history.back();
  8882. }
  8883. }
  8884. forward() {
  8885. if (!this._initialized || this._popStateInProgress) {
  8886. return;
  8887. }
  8888. const state = window.history.state;
  8889. if (this.#isValidState(state) && state.uid < this._maxUid) {
  8890. window.history.forward();
  8891. }
  8892. }
  8893. get popStateInProgress() {
  8894. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  8895. }
  8896. get initialBookmark() {
  8897. return this._initialized ? this._initialBookmark : null;
  8898. }
  8899. get initialRotation() {
  8900. return this._initialized ? this._initialRotation : null;
  8901. }
  8902. #pushOrReplaceState(destination, forceReplace = false) {
  8903. const shouldReplace = forceReplace || !this._destination;
  8904. const newState = {
  8905. fingerprint: this._fingerprint,
  8906. uid: shouldReplace ? this._uid : this._uid + 1,
  8907. destination
  8908. };
  8909. this.#updateInternalState(destination, newState.uid);
  8910. let newUrl;
  8911. if (this._updateUrl && destination?.hash) {
  8912. const baseUrl = document.location.href.split("#", 1)[0];
  8913. if (!baseUrl.startsWith("file://")) {
  8914. newUrl = `${baseUrl}#${destination.hash}`;
  8915. }
  8916. }
  8917. if (shouldReplace) {
  8918. window.history.replaceState(newState, "", newUrl);
  8919. } else {
  8920. window.history.pushState(newState, "", newUrl);
  8921. }
  8922. }
  8923. #tryPushCurrentPosition(temporary = false) {
  8924. if (!this._position) {
  8925. return;
  8926. }
  8927. let position = this._position;
  8928. if (temporary) {
  8929. position = Object.assign(Object.create(null), this._position);
  8930. position.temporary = true;
  8931. }
  8932. if (!this._destination) {
  8933. this.#pushOrReplaceState(position);
  8934. return;
  8935. }
  8936. if (this._destination.temporary) {
  8937. this.#pushOrReplaceState(position, true);
  8938. return;
  8939. }
  8940. if (this._destination.hash === position.hash) {
  8941. return;
  8942. }
  8943. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  8944. return;
  8945. }
  8946. let forceReplace = false;
  8947. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  8948. if (this._destination.dest !== undefined || !this._destination.first) {
  8949. return;
  8950. }
  8951. forceReplace = true;
  8952. }
  8953. this.#pushOrReplaceState(position, forceReplace);
  8954. }
  8955. #isValidPage(val) {
  8956. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  8957. }
  8958. #isValidState(state, checkReload = false) {
  8959. if (!state) {
  8960. return false;
  8961. }
  8962. if (state.fingerprint !== this._fingerprint) {
  8963. if (checkReload) {
  8964. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  8965. return false;
  8966. }
  8967. const [perfEntry] = performance.getEntriesByType("navigation");
  8968. if (perfEntry?.type !== "reload") {
  8969. return false;
  8970. }
  8971. } else {
  8972. return false;
  8973. }
  8974. }
  8975. if (!Number.isInteger(state.uid) || state.uid < 0) {
  8976. return false;
  8977. }
  8978. if (state.destination === null || typeof state.destination !== "object") {
  8979. return false;
  8980. }
  8981. return true;
  8982. }
  8983. #updateInternalState(destination, uid, removeTemporary = false) {
  8984. if (this._updateViewareaTimeout) {
  8985. clearTimeout(this._updateViewareaTimeout);
  8986. this._updateViewareaTimeout = null;
  8987. }
  8988. if (removeTemporary && destination?.temporary) {
  8989. delete destination.temporary;
  8990. }
  8991. this._destination = destination;
  8992. this._uid = uid;
  8993. this._maxUid = Math.max(this._maxUid, uid);
  8994. this._numPositionUpdates = 0;
  8995. }
  8996. #parseCurrentHash(checkNameddest = false) {
  8997. const hash = unescape(getCurrentHash()).substring(1);
  8998. const params = parseQueryString(hash);
  8999. const nameddest = params.get("nameddest") || "";
  9000. let page = params.get("page") | 0;
  9001. if (!this.#isValidPage(page) || checkNameddest && nameddest.length > 0) {
  9002. page = null;
  9003. }
  9004. return {
  9005. hash,
  9006. page,
  9007. rotation: this.linkService.rotation
  9008. };
  9009. }
  9010. #updateViewarea({
  9011. location
  9012. }) {
  9013. if (this._updateViewareaTimeout) {
  9014. clearTimeout(this._updateViewareaTimeout);
  9015. this._updateViewareaTimeout = null;
  9016. }
  9017. this._position = {
  9018. hash: location.pdfOpenParams.substring(1),
  9019. page: this.linkService.page,
  9020. first: location.pageNumber,
  9021. rotation: location.rotation
  9022. };
  9023. if (this._popStateInProgress) {
  9024. return;
  9025. }
  9026. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  9027. this._numPositionUpdates++;
  9028. }
  9029. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  9030. this._updateViewareaTimeout = setTimeout(() => {
  9031. if (!this._popStateInProgress) {
  9032. this.#tryPushCurrentPosition(true);
  9033. }
  9034. this._updateViewareaTimeout = null;
  9035. }, UPDATE_VIEWAREA_TIMEOUT);
  9036. }
  9037. }
  9038. #popState({
  9039. state
  9040. }) {
  9041. const newHash = getCurrentHash(),
  9042. hashChanged = this._currentHash !== newHash;
  9043. this._currentHash = newHash;
  9044. if (!state) {
  9045. this._uid++;
  9046. const {
  9047. hash,
  9048. page,
  9049. rotation
  9050. } = this.#parseCurrentHash();
  9051. this.#pushOrReplaceState({
  9052. hash,
  9053. page,
  9054. rotation
  9055. }, true);
  9056. return;
  9057. }
  9058. if (!this.#isValidState(state)) {
  9059. return;
  9060. }
  9061. this._popStateInProgress = true;
  9062. if (hashChanged) {
  9063. this._blockHashChange++;
  9064. waitOnEventOrTimeout({
  9065. target: window,
  9066. name: "hashchange",
  9067. delay: HASH_CHANGE_TIMEOUT
  9068. }).then(() => {
  9069. this._blockHashChange--;
  9070. });
  9071. }
  9072. const destination = state.destination;
  9073. this.#updateInternalState(destination, state.uid, true);
  9074. if (isValidRotation(destination.rotation)) {
  9075. this.linkService.rotation = destination.rotation;
  9076. }
  9077. if (destination.dest) {
  9078. this.linkService.goToDestination(destination.dest);
  9079. } else if (destination.hash) {
  9080. this.linkService.setHash(destination.hash);
  9081. } else if (destination.page) {
  9082. this.linkService.page = destination.page;
  9083. }
  9084. Promise.resolve().then(() => {
  9085. this._popStateInProgress = false;
  9086. });
  9087. }
  9088. #pageHide() {
  9089. if (!this._destination || this._destination.temporary) {
  9090. this.#tryPushCurrentPosition();
  9091. }
  9092. }
  9093. #bindEvents() {
  9094. if (this.#eventAbortController) {
  9095. return;
  9096. }
  9097. this.#eventAbortController = new AbortController();
  9098. const {
  9099. signal
  9100. } = this.#eventAbortController;
  9101. this.eventBus._on("updateviewarea", this.#updateViewarea.bind(this), {
  9102. signal
  9103. });
  9104. window.addEventListener("popstate", this.#popState.bind(this), {
  9105. signal
  9106. });
  9107. window.addEventListener("pagehide", this.#pageHide.bind(this), {
  9108. signal
  9109. });
  9110. }
  9111. #unbindEvents() {
  9112. this.#eventAbortController?.abort();
  9113. this.#eventAbortController = null;
  9114. }
  9115. }
  9116. function isDestHashesEqual(destHash, pushHash) {
  9117. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  9118. return false;
  9119. }
  9120. if (destHash === pushHash) {
  9121. return true;
  9122. }
  9123. const nameddest = parseQueryString(destHash).get("nameddest");
  9124. if (nameddest === pushHash) {
  9125. return true;
  9126. }
  9127. return false;
  9128. }
  9129. function isDestArraysEqual(firstDest, secondDest) {
  9130. function isEntryEqual(first, second) {
  9131. if (typeof first !== typeof second) {
  9132. return false;
  9133. }
  9134. if (Array.isArray(first) || Array.isArray(second)) {
  9135. return false;
  9136. }
  9137. if (first !== null && typeof first === "object" && second !== null) {
  9138. if (Object.keys(first).length !== Object.keys(second).length) {
  9139. return false;
  9140. }
  9141. for (const key in first) {
  9142. if (!isEntryEqual(first[key], second[key])) {
  9143. return false;
  9144. }
  9145. }
  9146. return true;
  9147. }
  9148. return first === second || Number.isNaN(first) && Number.isNaN(second);
  9149. }
  9150. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  9151. return false;
  9152. }
  9153. if (firstDest.length !== secondDest.length) {
  9154. return false;
  9155. }
  9156. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  9157. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  9158. return false;
  9159. }
  9160. }
  9161. return true;
  9162. }
  9163. ;// ./web/pdf_layer_viewer.js
  9164. class PDFLayerViewer extends BaseTreeViewer {
  9165. constructor(options) {
  9166. super(options);
  9167. this.eventBus._on("optionalcontentconfigchanged", evt => {
  9168. this.#updateLayers(evt.promise);
  9169. });
  9170. this.eventBus._on("resetlayers", () => {
  9171. this.#updateLayers();
  9172. });
  9173. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  9174. }
  9175. reset() {
  9176. super.reset();
  9177. this._optionalContentConfig = null;
  9178. this._optionalContentVisibility?.clear();
  9179. this._optionalContentVisibility = null;
  9180. }
  9181. _dispatchEvent(layersCount) {
  9182. this.eventBus.dispatch("layersloaded", {
  9183. source: this,
  9184. layersCount
  9185. });
  9186. }
  9187. _bindLink(element, {
  9188. groupId,
  9189. input
  9190. }) {
  9191. const setVisibility = () => {
  9192. const visible = input.checked;
  9193. this._optionalContentConfig.setVisibility(groupId, visible);
  9194. const cached = this._optionalContentVisibility.get(groupId);
  9195. if (cached) {
  9196. cached.visible = visible;
  9197. }
  9198. this.eventBus.dispatch("optionalcontentconfig", {
  9199. source: this,
  9200. promise: Promise.resolve(this._optionalContentConfig)
  9201. });
  9202. };
  9203. element.onclick = evt => {
  9204. if (evt.target === input) {
  9205. setVisibility();
  9206. return true;
  9207. } else if (evt.target !== element) {
  9208. return true;
  9209. }
  9210. input.checked = !input.checked;
  9211. setVisibility();
  9212. return false;
  9213. };
  9214. }
  9215. _setNestedName(element, {
  9216. name = null
  9217. }) {
  9218. if (typeof name === "string") {
  9219. element.textContent = this._normalizeTextContent(name);
  9220. return;
  9221. }
  9222. element.setAttribute("data-l10n-id", "pdfjs-additional-layers");
  9223. element.style.fontStyle = "italic";
  9224. this._l10n.translateOnce(element);
  9225. }
  9226. _addToggleButton(div, {
  9227. name = null
  9228. }) {
  9229. super._addToggleButton(div, name === null);
  9230. }
  9231. _toggleAllTreeItems() {
  9232. if (!this._optionalContentConfig) {
  9233. return;
  9234. }
  9235. super._toggleAllTreeItems();
  9236. }
  9237. render({
  9238. optionalContentConfig,
  9239. pdfDocument
  9240. }) {
  9241. if (this._optionalContentConfig) {
  9242. this.reset();
  9243. }
  9244. this._optionalContentConfig = optionalContentConfig || null;
  9245. this._pdfDocument = pdfDocument || null;
  9246. const groups = optionalContentConfig?.getOrder();
  9247. if (!groups) {
  9248. this._dispatchEvent(0);
  9249. return;
  9250. }
  9251. this._optionalContentVisibility = new Map();
  9252. const fragment = document.createDocumentFragment(),
  9253. queue = [{
  9254. parent: fragment,
  9255. groups
  9256. }];
  9257. let layersCount = 0,
  9258. hasAnyNesting = false;
  9259. while (queue.length > 0) {
  9260. const levelData = queue.shift();
  9261. for (const groupId of levelData.groups) {
  9262. const div = document.createElement("div");
  9263. div.className = "treeItem";
  9264. const element = document.createElement("a");
  9265. div.append(element);
  9266. if (typeof groupId === "object") {
  9267. hasAnyNesting = true;
  9268. this._addToggleButton(div, groupId);
  9269. this._setNestedName(element, groupId);
  9270. const itemsDiv = document.createElement("div");
  9271. itemsDiv.className = "treeItems";
  9272. div.append(itemsDiv);
  9273. queue.push({
  9274. parent: itemsDiv,
  9275. groups: groupId.order
  9276. });
  9277. } else {
  9278. const group = optionalContentConfig.getGroup(groupId);
  9279. const input = document.createElement("input");
  9280. this._bindLink(element, {
  9281. groupId,
  9282. input
  9283. });
  9284. input.type = "checkbox";
  9285. input.checked = group.visible;
  9286. this._optionalContentVisibility.set(groupId, {
  9287. input,
  9288. visible: input.checked
  9289. });
  9290. const label = document.createElement("label");
  9291. label.textContent = this._normalizeTextContent(group.name);
  9292. label.append(input);
  9293. element.append(label);
  9294. layersCount++;
  9295. }
  9296. levelData.parent.append(div);
  9297. }
  9298. }
  9299. this._finishRendering(fragment, layersCount, hasAnyNesting);
  9300. }
  9301. async #updateLayers(promise = null) {
  9302. if (!this._optionalContentConfig) {
  9303. return;
  9304. }
  9305. const pdfDocument = this._pdfDocument;
  9306. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig({
  9307. intent: "display"
  9308. }));
  9309. if (pdfDocument !== this._pdfDocument) {
  9310. return;
  9311. }
  9312. if (promise) {
  9313. for (const [groupId, cached] of this._optionalContentVisibility) {
  9314. const group = optionalContentConfig.getGroup(groupId);
  9315. if (group && cached.visible !== group.visible) {
  9316. cached.input.checked = cached.visible = !cached.visible;
  9317. }
  9318. }
  9319. return;
  9320. }
  9321. this.eventBus.dispatch("optionalcontentconfig", {
  9322. source: this,
  9323. promise: Promise.resolve(optionalContentConfig)
  9324. });
  9325. this.render({
  9326. optionalContentConfig,
  9327. pdfDocument: this._pdfDocument
  9328. });
  9329. }
  9330. }
  9331. ;// ./web/pdf_outline_viewer.js
  9332. class PDFOutlineViewer extends BaseTreeViewer {
  9333. constructor(options) {
  9334. super(options);
  9335. this.linkService = options.linkService;
  9336. this.downloadManager = options.downloadManager;
  9337. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  9338. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  9339. this.eventBus._on("pagechanging", evt => {
  9340. this._currentPageNumber = evt.pageNumber;
  9341. });
  9342. this.eventBus._on("pagesloaded", evt => {
  9343. this._isPagesLoaded = !!evt.pagesCount;
  9344. this._currentOutlineItemCapability?.resolve(this._isPagesLoaded);
  9345. });
  9346. this.eventBus._on("sidebarviewchanged", evt => {
  9347. this._sidebarView = evt.view;
  9348. });
  9349. }
  9350. reset() {
  9351. super.reset();
  9352. this._outline = null;
  9353. this._pageNumberToDestHashCapability = null;
  9354. this._currentPageNumber = 1;
  9355. this._isPagesLoaded = null;
  9356. this._currentOutlineItemCapability?.resolve(false);
  9357. this._currentOutlineItemCapability = null;
  9358. }
  9359. _dispatchEvent(outlineCount) {
  9360. this._currentOutlineItemCapability = Promise.withResolvers();
  9361. if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
  9362. this._currentOutlineItemCapability.resolve(false);
  9363. } else if (this._isPagesLoaded !== null) {
  9364. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  9365. }
  9366. this.eventBus.dispatch("outlineloaded", {
  9367. source: this,
  9368. outlineCount,
  9369. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  9370. });
  9371. }
  9372. _bindLink(element, {
  9373. url,
  9374. newWindow,
  9375. action,
  9376. attachment,
  9377. dest,
  9378. setOCGState
  9379. }) {
  9380. const {
  9381. linkService
  9382. } = this;
  9383. if (url) {
  9384. linkService.addLinkAttributes(element, url, newWindow);
  9385. return;
  9386. }
  9387. if (action) {
  9388. element.href = linkService.getAnchorUrl("");
  9389. element.onclick = () => {
  9390. linkService.executeNamedAction(action);
  9391. return false;
  9392. };
  9393. return;
  9394. }
  9395. if (attachment) {
  9396. element.href = linkService.getAnchorUrl("");
  9397. element.onclick = () => {
  9398. this.downloadManager.openOrDownloadData(attachment.content, attachment.filename);
  9399. return false;
  9400. };
  9401. return;
  9402. }
  9403. if (setOCGState) {
  9404. element.href = linkService.getAnchorUrl("");
  9405. element.onclick = () => {
  9406. linkService.executeSetOCGState(setOCGState);
  9407. return false;
  9408. };
  9409. return;
  9410. }
  9411. element.href = linkService.getDestinationHash(dest);
  9412. element.onclick = evt => {
  9413. this._updateCurrentTreeItem(evt.target.parentNode);
  9414. if (dest) {
  9415. linkService.goToDestination(dest);
  9416. }
  9417. return false;
  9418. };
  9419. }
  9420. _setStyles(element, {
  9421. bold,
  9422. italic
  9423. }) {
  9424. if (bold) {
  9425. element.style.fontWeight = "bold";
  9426. }
  9427. if (italic) {
  9428. element.style.fontStyle = "italic";
  9429. }
  9430. }
  9431. _addToggleButton(div, {
  9432. count,
  9433. items
  9434. }) {
  9435. let hidden = false;
  9436. if (count < 0) {
  9437. let totalCount = items.length;
  9438. if (totalCount > 0) {
  9439. const queue = [...items];
  9440. while (queue.length > 0) {
  9441. const {
  9442. count: nestedCount,
  9443. items: nestedItems
  9444. } = queue.shift();
  9445. if (nestedCount > 0 && nestedItems.length > 0) {
  9446. totalCount += nestedItems.length;
  9447. queue.push(...nestedItems);
  9448. }
  9449. }
  9450. }
  9451. if (Math.abs(count) === totalCount) {
  9452. hidden = true;
  9453. }
  9454. }
  9455. super._addToggleButton(div, hidden);
  9456. }
  9457. _toggleAllTreeItems() {
  9458. if (!this._outline) {
  9459. return;
  9460. }
  9461. super._toggleAllTreeItems();
  9462. }
  9463. render({
  9464. outline,
  9465. pdfDocument
  9466. }) {
  9467. if (this._outline) {
  9468. this.reset();
  9469. }
  9470. this._outline = outline || null;
  9471. this._pdfDocument = pdfDocument || null;
  9472. if (!outline) {
  9473. this._dispatchEvent(0);
  9474. return;
  9475. }
  9476. const fragment = document.createDocumentFragment();
  9477. const queue = [{
  9478. parent: fragment,
  9479. items: outline
  9480. }];
  9481. let outlineCount = 0,
  9482. hasAnyNesting = false;
  9483. while (queue.length > 0) {
  9484. const levelData = queue.shift();
  9485. for (const item of levelData.items) {
  9486. const div = document.createElement("div");
  9487. div.className = "treeItem";
  9488. const element = document.createElement("a");
  9489. this._bindLink(element, item);
  9490. this._setStyles(element, item);
  9491. element.textContent = this._normalizeTextContent(item.title);
  9492. div.append(element);
  9493. if (item.items.length > 0) {
  9494. hasAnyNesting = true;
  9495. this._addToggleButton(div, item);
  9496. const itemsDiv = document.createElement("div");
  9497. itemsDiv.className = "treeItems";
  9498. div.append(itemsDiv);
  9499. queue.push({
  9500. parent: itemsDiv,
  9501. items: item.items
  9502. });
  9503. }
  9504. levelData.parent.append(div);
  9505. outlineCount++;
  9506. }
  9507. }
  9508. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  9509. }
  9510. async _currentOutlineItem() {
  9511. if (!this._isPagesLoaded) {
  9512. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  9513. }
  9514. if (!this._outline || !this._pdfDocument) {
  9515. return;
  9516. }
  9517. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  9518. if (!pageNumberToDestHash) {
  9519. return;
  9520. }
  9521. this._updateCurrentTreeItem(null);
  9522. if (this._sidebarView !== SidebarView.OUTLINE) {
  9523. return;
  9524. }
  9525. for (let i = this._currentPageNumber; i > 0; i--) {
  9526. const destHash = pageNumberToDestHash.get(i);
  9527. if (!destHash) {
  9528. continue;
  9529. }
  9530. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  9531. if (!linkElement) {
  9532. continue;
  9533. }
  9534. this._scrollToCurrentTreeItem(linkElement.parentNode);
  9535. break;
  9536. }
  9537. }
  9538. async _getPageNumberToDestHash(pdfDocument) {
  9539. if (this._pageNumberToDestHashCapability) {
  9540. return this._pageNumberToDestHashCapability.promise;
  9541. }
  9542. this._pageNumberToDestHashCapability = Promise.withResolvers();
  9543. const pageNumberToDestHash = new Map(),
  9544. pageNumberNesting = new Map();
  9545. const queue = [{
  9546. nesting: 0,
  9547. items: this._outline
  9548. }];
  9549. while (queue.length > 0) {
  9550. const levelData = queue.shift(),
  9551. currentNesting = levelData.nesting;
  9552. for (const {
  9553. dest,
  9554. items
  9555. } of levelData.items) {
  9556. let explicitDest, pageNumber;
  9557. if (typeof dest === "string") {
  9558. explicitDest = await pdfDocument.getDestination(dest);
  9559. if (pdfDocument !== this._pdfDocument) {
  9560. return null;
  9561. }
  9562. } else {
  9563. explicitDest = dest;
  9564. }
  9565. if (Array.isArray(explicitDest)) {
  9566. const [destRef] = explicitDest;
  9567. if (destRef && typeof destRef === "object") {
  9568. pageNumber = pdfDocument.cachedPageNumber(destRef);
  9569. } else if (Number.isInteger(destRef)) {
  9570. pageNumber = destRef + 1;
  9571. }
  9572. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  9573. const destHash = this.linkService.getDestinationHash(dest);
  9574. pageNumberToDestHash.set(pageNumber, destHash);
  9575. pageNumberNesting.set(pageNumber, currentNesting);
  9576. }
  9577. }
  9578. if (items.length > 0) {
  9579. queue.push({
  9580. nesting: currentNesting + 1,
  9581. items
  9582. });
  9583. }
  9584. }
  9585. }
  9586. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  9587. return this._pageNumberToDestHashCapability.promise;
  9588. }
  9589. }
  9590. ;// ./web/pdf_presentation_mode.js
  9591. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  9592. const ACTIVE_SELECTOR = "pdfPresentationMode";
  9593. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  9594. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  9595. const PAGE_SWITCH_THRESHOLD = 0.1;
  9596. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  9597. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  9598. class PDFPresentationMode {
  9599. #state = PresentationModeState.UNKNOWN;
  9600. #args = null;
  9601. #fullscreenChangeAbortController = null;
  9602. #windowAbortController = null;
  9603. constructor({
  9604. container,
  9605. pdfViewer,
  9606. eventBus
  9607. }) {
  9608. this.container = container;
  9609. this.pdfViewer = pdfViewer;
  9610. this.eventBus = eventBus;
  9611. this.contextMenuOpen = false;
  9612. this.mouseScrollTimeStamp = 0;
  9613. this.mouseScrollDelta = 0;
  9614. this.touchSwipeState = null;
  9615. }
  9616. async request() {
  9617. const {
  9618. container,
  9619. pdfViewer
  9620. } = this;
  9621. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  9622. return false;
  9623. }
  9624. this.#addFullscreenChangeListeners();
  9625. this.#notifyStateChange(PresentationModeState.CHANGING);
  9626. const promise = container.requestFullscreen();
  9627. this.#args = {
  9628. pageNumber: pdfViewer.currentPageNumber,
  9629. scaleValue: pdfViewer.currentScaleValue,
  9630. scrollMode: pdfViewer.scrollMode,
  9631. spreadMode: null,
  9632. annotationEditorMode: null
  9633. };
  9634. if (pdfViewer.spreadMode !== SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  9635. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  9636. this.#args.spreadMode = pdfViewer.spreadMode;
  9637. }
  9638. if (pdfViewer.annotationEditorMode !== AnnotationEditorType.DISABLE) {
  9639. this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
  9640. }
  9641. try {
  9642. await promise;
  9643. pdfViewer.focus();
  9644. return true;
  9645. } catch {
  9646. this.#removeFullscreenChangeListeners();
  9647. this.#notifyStateChange(PresentationModeState.NORMAL);
  9648. }
  9649. return false;
  9650. }
  9651. get active() {
  9652. return this.#state === PresentationModeState.CHANGING || this.#state === PresentationModeState.FULLSCREEN;
  9653. }
  9654. #mouseWheel(evt) {
  9655. if (!this.active) {
  9656. return;
  9657. }
  9658. evt.preventDefault();
  9659. const delta = normalizeWheelEventDelta(evt);
  9660. const currentTime = Date.now();
  9661. const storedTime = this.mouseScrollTimeStamp;
  9662. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9663. return;
  9664. }
  9665. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9666. this.#resetMouseScrollState();
  9667. }
  9668. this.mouseScrollDelta += delta;
  9669. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9670. const totalDelta = this.mouseScrollDelta;
  9671. this.#resetMouseScrollState();
  9672. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9673. if (success) {
  9674. this.mouseScrollTimeStamp = currentTime;
  9675. }
  9676. }
  9677. }
  9678. #notifyStateChange(state) {
  9679. this.#state = state;
  9680. this.eventBus.dispatch("presentationmodechanged", {
  9681. source: this,
  9682. state
  9683. });
  9684. }
  9685. #enter() {
  9686. this.#notifyStateChange(PresentationModeState.FULLSCREEN);
  9687. this.container.classList.add(ACTIVE_SELECTOR);
  9688. setTimeout(() => {
  9689. this.pdfViewer.scrollMode = ScrollMode.PAGE;
  9690. if (this.#args.spreadMode !== null) {
  9691. this.pdfViewer.spreadMode = SpreadMode.NONE;
  9692. }
  9693. this.pdfViewer.currentPageNumber = this.#args.pageNumber;
  9694. this.pdfViewer.currentScaleValue = "page-fit";
  9695. if (this.#args.annotationEditorMode !== null) {
  9696. this.pdfViewer.annotationEditorMode = {
  9697. mode: AnnotationEditorType.NONE
  9698. };
  9699. }
  9700. }, 0);
  9701. this.#addWindowListeners();
  9702. this.#showControls();
  9703. this.contextMenuOpen = false;
  9704. document.getSelection().empty();
  9705. }
  9706. #exit() {
  9707. const pageNumber = this.pdfViewer.currentPageNumber;
  9708. this.container.classList.remove(ACTIVE_SELECTOR);
  9709. setTimeout(() => {
  9710. this.#removeFullscreenChangeListeners();
  9711. this.#notifyStateChange(PresentationModeState.NORMAL);
  9712. this.pdfViewer.scrollMode = this.#args.scrollMode;
  9713. if (this.#args.spreadMode !== null) {
  9714. this.pdfViewer.spreadMode = this.#args.spreadMode;
  9715. }
  9716. this.pdfViewer.currentScaleValue = this.#args.scaleValue;
  9717. this.pdfViewer.currentPageNumber = pageNumber;
  9718. if (this.#args.annotationEditorMode !== null) {
  9719. this.pdfViewer.annotationEditorMode = {
  9720. mode: this.#args.annotationEditorMode
  9721. };
  9722. }
  9723. this.#args = null;
  9724. }, 0);
  9725. this.#removeWindowListeners();
  9726. this.#hideControls();
  9727. this.#resetMouseScrollState();
  9728. this.contextMenuOpen = false;
  9729. }
  9730. #mouseDown(evt) {
  9731. if (this.contextMenuOpen) {
  9732. this.contextMenuOpen = false;
  9733. evt.preventDefault();
  9734. return;
  9735. }
  9736. if (evt.button !== 0) {
  9737. return;
  9738. }
  9739. if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
  9740. return;
  9741. }
  9742. evt.preventDefault();
  9743. if (evt.shiftKey) {
  9744. this.pdfViewer.previousPage();
  9745. } else {
  9746. this.pdfViewer.nextPage();
  9747. }
  9748. }
  9749. #contextMenu() {
  9750. this.contextMenuOpen = true;
  9751. }
  9752. #showControls() {
  9753. if (this.controlsTimeout) {
  9754. clearTimeout(this.controlsTimeout);
  9755. } else {
  9756. this.container.classList.add(CONTROLS_SELECTOR);
  9757. }
  9758. this.controlsTimeout = setTimeout(() => {
  9759. this.container.classList.remove(CONTROLS_SELECTOR);
  9760. delete this.controlsTimeout;
  9761. }, DELAY_BEFORE_HIDING_CONTROLS);
  9762. }
  9763. #hideControls() {
  9764. if (!this.controlsTimeout) {
  9765. return;
  9766. }
  9767. clearTimeout(this.controlsTimeout);
  9768. this.container.classList.remove(CONTROLS_SELECTOR);
  9769. delete this.controlsTimeout;
  9770. }
  9771. #resetMouseScrollState() {
  9772. this.mouseScrollTimeStamp = 0;
  9773. this.mouseScrollDelta = 0;
  9774. }
  9775. #touchSwipe(evt) {
  9776. if (!this.active) {
  9777. return;
  9778. }
  9779. if (evt.touches.length > 1) {
  9780. this.touchSwipeState = null;
  9781. return;
  9782. }
  9783. switch (evt.type) {
  9784. case "touchstart":
  9785. this.touchSwipeState = {
  9786. startX: evt.touches[0].pageX,
  9787. startY: evt.touches[0].pageY,
  9788. endX: evt.touches[0].pageX,
  9789. endY: evt.touches[0].pageY
  9790. };
  9791. break;
  9792. case "touchmove":
  9793. if (this.touchSwipeState === null) {
  9794. return;
  9795. }
  9796. this.touchSwipeState.endX = evt.touches[0].pageX;
  9797. this.touchSwipeState.endY = evt.touches[0].pageY;
  9798. evt.preventDefault();
  9799. break;
  9800. case "touchend":
  9801. if (this.touchSwipeState === null) {
  9802. return;
  9803. }
  9804. let delta = 0;
  9805. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9806. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9807. const absAngle = Math.abs(Math.atan2(dy, dx));
  9808. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9809. delta = dx;
  9810. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9811. delta = dy;
  9812. }
  9813. if (delta > 0) {
  9814. this.pdfViewer.previousPage();
  9815. } else if (delta < 0) {
  9816. this.pdfViewer.nextPage();
  9817. }
  9818. break;
  9819. }
  9820. }
  9821. #addWindowListeners() {
  9822. if (this.#windowAbortController) {
  9823. return;
  9824. }
  9825. this.#windowAbortController = new AbortController();
  9826. const {
  9827. signal
  9828. } = this.#windowAbortController;
  9829. const touchSwipeBind = this.#touchSwipe.bind(this);
  9830. window.addEventListener("mousemove", this.#showControls.bind(this), {
  9831. signal
  9832. });
  9833. window.addEventListener("mousedown", this.#mouseDown.bind(this), {
  9834. signal
  9835. });
  9836. window.addEventListener("wheel", this.#mouseWheel.bind(this), {
  9837. passive: false,
  9838. signal
  9839. });
  9840. window.addEventListener("keydown", this.#resetMouseScrollState.bind(this), {
  9841. signal
  9842. });
  9843. window.addEventListener("contextmenu", this.#contextMenu.bind(this), {
  9844. signal
  9845. });
  9846. window.addEventListener("touchstart", touchSwipeBind, {
  9847. signal
  9848. });
  9849. window.addEventListener("touchmove", touchSwipeBind, {
  9850. signal
  9851. });
  9852. window.addEventListener("touchend", touchSwipeBind, {
  9853. signal
  9854. });
  9855. }
  9856. #removeWindowListeners() {
  9857. this.#windowAbortController?.abort();
  9858. this.#windowAbortController = null;
  9859. }
  9860. #addFullscreenChangeListeners() {
  9861. if (this.#fullscreenChangeAbortController) {
  9862. return;
  9863. }
  9864. this.#fullscreenChangeAbortController = new AbortController();
  9865. window.addEventListener("fullscreenchange", () => {
  9866. if (document.fullscreenElement) {
  9867. this.#enter();
  9868. } else {
  9869. this.#exit();
  9870. }
  9871. }, {
  9872. signal: this.#fullscreenChangeAbortController.signal
  9873. });
  9874. }
  9875. #removeFullscreenChangeListeners() {
  9876. this.#fullscreenChangeAbortController?.abort();
  9877. this.#fullscreenChangeAbortController = null;
  9878. }
  9879. }
  9880. // EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.every.js
  9881. var esnext_iterator_every = __webpack_require__(3215);
  9882. ;// ./web/xfa_layer_builder.js
  9883. class XfaLayerBuilder {
  9884. constructor({
  9885. pdfPage,
  9886. annotationStorage = null,
  9887. linkService,
  9888. xfaHtml = null
  9889. }) {
  9890. this.pdfPage = pdfPage;
  9891. this.annotationStorage = annotationStorage;
  9892. this.linkService = linkService;
  9893. this.xfaHtml = xfaHtml;
  9894. this.div = null;
  9895. this._cancelled = false;
  9896. }
  9897. async render(viewport, intent = "display") {
  9898. if (intent === "print") {
  9899. const parameters = {
  9900. viewport: viewport.clone({
  9901. dontFlip: true
  9902. }),
  9903. div: this.div,
  9904. xfaHtml: this.xfaHtml,
  9905. annotationStorage: this.annotationStorage,
  9906. linkService: this.linkService,
  9907. intent
  9908. };
  9909. this.div = document.createElement("div");
  9910. parameters.div = this.div;
  9911. return XfaLayer.render(parameters);
  9912. }
  9913. const xfaHtml = await this.pdfPage.getXfa();
  9914. if (this._cancelled || !xfaHtml) {
  9915. return {
  9916. textDivs: []
  9917. };
  9918. }
  9919. const parameters = {
  9920. viewport: viewport.clone({
  9921. dontFlip: true
  9922. }),
  9923. div: this.div,
  9924. xfaHtml,
  9925. annotationStorage: this.annotationStorage,
  9926. linkService: this.linkService,
  9927. intent
  9928. };
  9929. if (this.div) {
  9930. return XfaLayer.update(parameters);
  9931. }
  9932. this.div = document.createElement("div");
  9933. parameters.div = this.div;
  9934. return XfaLayer.render(parameters);
  9935. }
  9936. cancel() {
  9937. this._cancelled = true;
  9938. }
  9939. hide() {
  9940. if (!this.div) {
  9941. return;
  9942. }
  9943. this.div.hidden = true;
  9944. }
  9945. }
  9946. ;// ./web/print_utils.js
  9947. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  9948. const xfaHtml = pdfDocument.allXfaHtml;
  9949. const linkService = new SimpleLinkService();
  9950. const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  9951. for (const xfaPage of xfaHtml.children) {
  9952. const page = document.createElement("div");
  9953. page.className = "xfaPrintedPage";
  9954. printContainer.append(page);
  9955. const builder = new XfaLayerBuilder({
  9956. pdfPage: null,
  9957. annotationStorage: pdfDocument.annotationStorage,
  9958. linkService,
  9959. xfaHtml: xfaPage
  9960. });
  9961. const viewport = getXfaPageViewport(xfaPage, {
  9962. scale
  9963. });
  9964. builder.render(viewport, "print");
  9965. page.append(builder.div);
  9966. }
  9967. }
  9968. ;// ./web/pdf_print_service.js
  9969. let activeService = null;
  9970. let dialog = null;
  9971. let overlayManager = null;
  9972. let viewerApp = {
  9973. initialized: false
  9974. };
  9975. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  9976. const scratchCanvas = activeService.scratchCanvas;
  9977. const PRINT_UNITS = printResolution / PixelsPerInch.PDF;
  9978. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  9979. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  9980. const ctx = scratchCanvas.getContext("2d");
  9981. ctx.save();
  9982. ctx.fillStyle = "rgb(255, 255, 255)";
  9983. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  9984. ctx.restore();
  9985. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function ([pdfPage, printAnnotationStorage]) {
  9986. const renderContext = {
  9987. canvasContext: ctx,
  9988. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  9989. viewport: pdfPage.getViewport({
  9990. scale: 1,
  9991. rotation: size.rotation
  9992. }),
  9993. intent: "print",
  9994. annotationMode: AnnotationMode.ENABLE_STORAGE,
  9995. optionalContentConfigPromise,
  9996. printAnnotationStorage
  9997. };
  9998. const renderTask = pdfPage.render(renderContext);
  9999. return renderTask.promise.catch(reason => {
  10000. if (!(reason instanceof RenderingCancelledException)) {
  10001. console.error(reason);
  10002. }
  10003. throw reason;
  10004. });
  10005. });
  10006. }
  10007. class PDFPrintService {
  10008. constructor({
  10009. pdfDocument,
  10010. pagesOverview,
  10011. printContainer,
  10012. printResolution,
  10013. printAnnotationStoragePromise = null
  10014. }) {
  10015. this.pdfDocument = pdfDocument;
  10016. this.pagesOverview = pagesOverview;
  10017. this.printContainer = printContainer;
  10018. this._printResolution = printResolution || 150;
  10019. this._optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
  10020. intent: "print"
  10021. });
  10022. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  10023. this.currentPage = -1;
  10024. this.scratchCanvas = document.createElement("canvas");
  10025. }
  10026. layout() {
  10027. this.throwIfInactive();
  10028. const body = document.querySelector("body");
  10029. body.setAttribute("data-pdfjsprinting", true);
  10030. const {
  10031. width,
  10032. height
  10033. } = this.pagesOverview[0];
  10034. const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
  10035. if (!hasEqualPageSizes) {
  10036. console.warn("Not all pages have the same size. The printed result may be incorrect!");
  10037. }
  10038. this.pageStyleSheet = document.createElement("style");
  10039. this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
  10040. body.append(this.pageStyleSheet);
  10041. }
  10042. destroy() {
  10043. if (activeService !== this) {
  10044. return;
  10045. }
  10046. this.printContainer.textContent = "";
  10047. const body = document.querySelector("body");
  10048. body.removeAttribute("data-pdfjsprinting");
  10049. if (this.pageStyleSheet) {
  10050. this.pageStyleSheet.remove();
  10051. this.pageStyleSheet = null;
  10052. }
  10053. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  10054. this.scratchCanvas = null;
  10055. activeService = null;
  10056. ensureOverlay().then(function () {
  10057. if (overlayManager.active === dialog) {
  10058. overlayManager.close(dialog);
  10059. }
  10060. });
  10061. }
  10062. renderPages() {
  10063. if (this.pdfDocument.isPureXfa) {
  10064. getXfaHtmlForPrinting(this.printContainer, this.pdfDocument);
  10065. return Promise.resolve();
  10066. }
  10067. const pageCount = this.pagesOverview.length;
  10068. const renderNextPage = (resolve, reject) => {
  10069. this.throwIfInactive();
  10070. if (++this.currentPage >= pageCount) {
  10071. renderProgress(pageCount, pageCount);
  10072. resolve();
  10073. return;
  10074. }
  10075. const index = this.currentPage;
  10076. renderProgress(index, pageCount);
  10077. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  10078. renderNextPage(resolve, reject);
  10079. }, reject);
  10080. };
  10081. return new Promise(renderNextPage);
  10082. }
  10083. useRenderedPage() {
  10084. this.throwIfInactive();
  10085. const img = document.createElement("img");
  10086. this.scratchCanvas.toBlob(blob => {
  10087. img.src = URL.createObjectURL(blob);
  10088. });
  10089. const wrapper = document.createElement("div");
  10090. wrapper.className = "printedPage";
  10091. wrapper.append(img);
  10092. this.printContainer.append(wrapper);
  10093. const {
  10094. promise,
  10095. resolve,
  10096. reject
  10097. } = Promise.withResolvers();
  10098. img.onload = resolve;
  10099. img.onerror = reject;
  10100. promise.catch(() => {}).then(() => {
  10101. URL.revokeObjectURL(img.src);
  10102. });
  10103. return promise;
  10104. }
  10105. performPrint() {
  10106. this.throwIfInactive();
  10107. return new Promise(resolve => {
  10108. setTimeout(() => {
  10109. if (!this.active) {
  10110. resolve();
  10111. return;
  10112. }
  10113. print.call(window);
  10114. setTimeout(resolve, 20);
  10115. }, 0);
  10116. });
  10117. }
  10118. get active() {
  10119. return this === activeService;
  10120. }
  10121. throwIfInactive() {
  10122. if (!this.active) {
  10123. throw new Error("This print request was cancelled or completed.");
  10124. }
  10125. }
  10126. }
  10127. const print = window.print;
  10128. window.print = function () {
  10129. if (activeService) {
  10130. console.warn("Ignored window.print() because of a pending print job.");
  10131. return;
  10132. }
  10133. ensureOverlay().then(function () {
  10134. if (activeService) {
  10135. overlayManager.open(dialog);
  10136. }
  10137. });
  10138. try {
  10139. dispatchEvent("beforeprint");
  10140. } finally {
  10141. if (!activeService) {
  10142. console.error("Expected print service to be initialized.");
  10143. ensureOverlay().then(function () {
  10144. if (overlayManager.active === dialog) {
  10145. overlayManager.close(dialog);
  10146. }
  10147. });
  10148. return;
  10149. }
  10150. const activeServiceOnEntry = activeService;
  10151. activeService.renderPages().then(function () {
  10152. return activeServiceOnEntry.performPrint();
  10153. }).catch(function () {}).then(function () {
  10154. if (activeServiceOnEntry.active) {
  10155. abort();
  10156. }
  10157. });
  10158. }
  10159. };
  10160. function dispatchEvent(eventType) {
  10161. const event = new CustomEvent(eventType, {
  10162. bubbles: false,
  10163. cancelable: false,
  10164. detail: "custom"
  10165. });
  10166. window.dispatchEvent(event);
  10167. }
  10168. function abort() {
  10169. if (activeService) {
  10170. activeService.destroy();
  10171. dispatchEvent("afterprint");
  10172. }
  10173. }
  10174. function renderProgress(index, total) {
  10175. dialog ||= document.getElementById("printServiceDialog");
  10176. const progress = Math.round(100 * index / total);
  10177. const progressBar = dialog.querySelector("progress");
  10178. const progressPerc = dialog.querySelector(".relative-progress");
  10179. progressBar.value = progress;
  10180. progressPerc.setAttribute("data-l10n-args", JSON.stringify({
  10181. progress
  10182. }));
  10183. }
  10184. window.addEventListener("keydown", function (event) {
  10185. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  10186. window.print();
  10187. event.preventDefault();
  10188. event.stopImmediatePropagation();
  10189. }
  10190. }, true);
  10191. if ("onbeforeprint" in window) {
  10192. const stopPropagationIfNeeded = function (event) {
  10193. if (event.detail !== "custom") {
  10194. event.stopImmediatePropagation();
  10195. }
  10196. };
  10197. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  10198. window.addEventListener("afterprint", stopPropagationIfNeeded);
  10199. }
  10200. let overlayPromise;
  10201. function ensureOverlay() {
  10202. if (!overlayPromise) {
  10203. overlayManager = viewerApp.overlayManager;
  10204. if (!overlayManager) {
  10205. throw new Error("The overlay manager has not yet been initialized.");
  10206. }
  10207. dialog ||= document.getElementById("printServiceDialog");
  10208. overlayPromise = overlayManager.register(dialog, true);
  10209. document.getElementById("printCancel").onclick = abort;
  10210. dialog.addEventListener("close", abort);
  10211. }
  10212. return overlayPromise;
  10213. }
  10214. class PDFPrintServiceFactory {
  10215. static initGlobals(app) {
  10216. viewerApp = app;
  10217. }
  10218. static get supportsPrinting() {
  10219. return shadow(this, "supportsPrinting", true);
  10220. }
  10221. static createPrintService(params) {
  10222. if (activeService) {
  10223. throw new Error("The print service is created and active.");
  10224. }
  10225. return activeService = new PDFPrintService(params);
  10226. }
  10227. }
  10228. ;// ./web/pdf_rendering_queue.js
  10229. const CLEANUP_TIMEOUT = 30000;
  10230. class PDFRenderingQueue {
  10231. constructor() {
  10232. this.pdfViewer = null;
  10233. this.pdfThumbnailViewer = null;
  10234. this.onIdle = null;
  10235. this.highestPriorityPage = null;
  10236. this.idleTimeout = null;
  10237. this.printing = false;
  10238. this.isThumbnailViewEnabled = false;
  10239. Object.defineProperty(this, "hasViewer", {
  10240. value: () => !!this.pdfViewer
  10241. });
  10242. }
  10243. setViewer(pdfViewer) {
  10244. this.pdfViewer = pdfViewer;
  10245. }
  10246. setThumbnailViewer(pdfThumbnailViewer) {
  10247. this.pdfThumbnailViewer = pdfThumbnailViewer;
  10248. }
  10249. isHighestPriority(view) {
  10250. return this.highestPriorityPage === view.renderingId;
  10251. }
  10252. renderHighestPriority(currentlyVisiblePages) {
  10253. if (this.idleTimeout) {
  10254. clearTimeout(this.idleTimeout);
  10255. this.idleTimeout = null;
  10256. }
  10257. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  10258. return;
  10259. }
  10260. if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
  10261. return;
  10262. }
  10263. if (this.printing) {
  10264. return;
  10265. }
  10266. if (this.onIdle) {
  10267. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  10268. }
  10269. }
  10270. getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
  10271. const visibleViews = visible.views,
  10272. numVisible = visibleViews.length;
  10273. if (numVisible === 0) {
  10274. return null;
  10275. }
  10276. for (let i = 0; i < numVisible; i++) {
  10277. const view = visibleViews[i].view;
  10278. if (!this.isViewFinished(view)) {
  10279. return view;
  10280. }
  10281. }
  10282. const firstId = visible.first.id,
  10283. lastId = visible.last.id;
  10284. if (lastId - firstId + 1 > numVisible) {
  10285. const visibleIds = visible.ids;
  10286. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  10287. const holeId = scrolledDown ? firstId + i : lastId - i;
  10288. if (visibleIds.has(holeId)) {
  10289. continue;
  10290. }
  10291. const holeView = views[holeId - 1];
  10292. if (!this.isViewFinished(holeView)) {
  10293. return holeView;
  10294. }
  10295. }
  10296. }
  10297. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  10298. let preRenderView = views[preRenderIndex];
  10299. if (preRenderView && !this.isViewFinished(preRenderView)) {
  10300. return preRenderView;
  10301. }
  10302. if (preRenderExtra) {
  10303. preRenderIndex += scrolledDown ? 1 : -1;
  10304. preRenderView = views[preRenderIndex];
  10305. if (preRenderView && !this.isViewFinished(preRenderView)) {
  10306. return preRenderView;
  10307. }
  10308. }
  10309. return null;
  10310. }
  10311. isViewFinished(view) {
  10312. return view.renderingState === RenderingStates.FINISHED;
  10313. }
  10314. renderView(view) {
  10315. switch (view.renderingState) {
  10316. case RenderingStates.FINISHED:
  10317. return false;
  10318. case RenderingStates.PAUSED:
  10319. this.highestPriorityPage = view.renderingId;
  10320. view.resume();
  10321. break;
  10322. case RenderingStates.RUNNING:
  10323. this.highestPriorityPage = view.renderingId;
  10324. break;
  10325. case RenderingStates.INITIAL:
  10326. this.highestPriorityPage = view.renderingId;
  10327. view.draw().finally(() => {
  10328. this.renderHighestPriority();
  10329. }).catch(reason => {
  10330. if (reason instanceof RenderingCancelledException) {
  10331. return;
  10332. }
  10333. console.error(`renderView: "${reason}"`);
  10334. });
  10335. break;
  10336. }
  10337. return true;
  10338. }
  10339. }
  10340. ;// ./web/pdf_scripting_manager.js
  10341. class PDFScriptingManager {
  10342. #closeCapability = null;
  10343. #destroyCapability = null;
  10344. #docProperties = null;
  10345. #eventAbortController = null;
  10346. #eventBus = null;
  10347. #externalServices = null;
  10348. #pdfDocument = null;
  10349. #pdfViewer = null;
  10350. #ready = false;
  10351. #scripting = null;
  10352. #willPrintCapability = null;
  10353. constructor({
  10354. eventBus,
  10355. externalServices = null,
  10356. docProperties = null
  10357. }) {
  10358. this.#eventBus = eventBus;
  10359. this.#externalServices = externalServices;
  10360. this.#docProperties = docProperties;
  10361. }
  10362. setViewer(pdfViewer) {
  10363. this.#pdfViewer = pdfViewer;
  10364. }
  10365. async setDocument(pdfDocument) {
  10366. if (this.#pdfDocument) {
  10367. await this.#destroyScripting();
  10368. }
  10369. this.#pdfDocument = pdfDocument;
  10370. if (!pdfDocument) {
  10371. return;
  10372. }
  10373. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  10374. if (!objects && !docActions) {
  10375. await this.#destroyScripting();
  10376. return;
  10377. }
  10378. if (pdfDocument !== this.#pdfDocument) {
  10379. return;
  10380. }
  10381. try {
  10382. this.#scripting = this.#initScripting();
  10383. } catch (error) {
  10384. console.error(`setDocument: "${error.message}".`);
  10385. await this.#destroyScripting();
  10386. return;
  10387. }
  10388. const eventBus = this.#eventBus;
  10389. this.#eventAbortController = new AbortController();
  10390. const {
  10391. signal
  10392. } = this.#eventAbortController;
  10393. eventBus._on("updatefromsandbox", event => {
  10394. if (event?.source === window) {
  10395. this.#updateFromSandbox(event.detail);
  10396. }
  10397. }, {
  10398. signal
  10399. });
  10400. eventBus._on("dispatcheventinsandbox", event => {
  10401. this.#scripting?.dispatchEventInSandbox(event.detail);
  10402. }, {
  10403. signal
  10404. });
  10405. eventBus._on("pagechanging", ({
  10406. pageNumber,
  10407. previous
  10408. }) => {
  10409. if (pageNumber === previous) {
  10410. return;
  10411. }
  10412. this.#dispatchPageClose(previous);
  10413. this.#dispatchPageOpen(pageNumber);
  10414. }, {
  10415. signal
  10416. });
  10417. eventBus._on("pagerendered", ({
  10418. pageNumber
  10419. }) => {
  10420. if (!this._pageOpenPending.has(pageNumber)) {
  10421. return;
  10422. }
  10423. if (pageNumber !== this.#pdfViewer.currentPageNumber) {
  10424. return;
  10425. }
  10426. this.#dispatchPageOpen(pageNumber);
  10427. }, {
  10428. signal
  10429. });
  10430. eventBus._on("pagesdestroy", async () => {
  10431. await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
  10432. await this.#scripting?.dispatchEventInSandbox({
  10433. id: "doc",
  10434. name: "WillClose"
  10435. });
  10436. this.#closeCapability?.resolve();
  10437. }, {
  10438. signal
  10439. });
  10440. try {
  10441. const docProperties = await this.#docProperties(pdfDocument);
  10442. if (pdfDocument !== this.#pdfDocument) {
  10443. return;
  10444. }
  10445. await this.#scripting.createSandbox({
  10446. objects,
  10447. calculationOrder,
  10448. appInfo: {
  10449. platform: navigator.platform,
  10450. language: navigator.language
  10451. },
  10452. docInfo: {
  10453. ...docProperties,
  10454. actions: docActions
  10455. }
  10456. });
  10457. eventBus.dispatch("sandboxcreated", {
  10458. source: this
  10459. });
  10460. } catch (error) {
  10461. console.error(`setDocument: "${error.message}".`);
  10462. await this.#destroyScripting();
  10463. return;
  10464. }
  10465. await this.#scripting?.dispatchEventInSandbox({
  10466. id: "doc",
  10467. name: "Open"
  10468. });
  10469. await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
  10470. Promise.resolve().then(() => {
  10471. if (pdfDocument === this.#pdfDocument) {
  10472. this.#ready = true;
  10473. }
  10474. });
  10475. }
  10476. async dispatchWillSave() {
  10477. return this.#scripting?.dispatchEventInSandbox({
  10478. id: "doc",
  10479. name: "WillSave"
  10480. });
  10481. }
  10482. async dispatchDidSave() {
  10483. return this.#scripting?.dispatchEventInSandbox({
  10484. id: "doc",
  10485. name: "DidSave"
  10486. });
  10487. }
  10488. async dispatchWillPrint() {
  10489. if (!this.#scripting) {
  10490. return;
  10491. }
  10492. await this.#willPrintCapability?.promise;
  10493. this.#willPrintCapability = Promise.withResolvers();
  10494. try {
  10495. await this.#scripting.dispatchEventInSandbox({
  10496. id: "doc",
  10497. name: "WillPrint"
  10498. });
  10499. } catch (ex) {
  10500. this.#willPrintCapability.resolve();
  10501. this.#willPrintCapability = null;
  10502. throw ex;
  10503. }
  10504. await this.#willPrintCapability.promise;
  10505. }
  10506. async dispatchDidPrint() {
  10507. return this.#scripting?.dispatchEventInSandbox({
  10508. id: "doc",
  10509. name: "DidPrint"
  10510. });
  10511. }
  10512. get destroyPromise() {
  10513. return this.#destroyCapability?.promise || null;
  10514. }
  10515. get ready() {
  10516. return this.#ready;
  10517. }
  10518. get _pageOpenPending() {
  10519. return shadow(this, "_pageOpenPending", new Set());
  10520. }
  10521. get _visitedPages() {
  10522. return shadow(this, "_visitedPages", new Map());
  10523. }
  10524. async #updateFromSandbox(detail) {
  10525. const pdfViewer = this.#pdfViewer;
  10526. const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
  10527. const {
  10528. id,
  10529. siblings,
  10530. command,
  10531. value
  10532. } = detail;
  10533. if (!id) {
  10534. switch (command) {
  10535. case "clear":
  10536. console.clear();
  10537. break;
  10538. case "error":
  10539. console.error(value);
  10540. break;
  10541. case "layout":
  10542. if (!isInPresentationMode) {
  10543. const modes = apiPageLayoutToViewerModes(value);
  10544. pdfViewer.spreadMode = modes.spreadMode;
  10545. }
  10546. break;
  10547. case "page-num":
  10548. pdfViewer.currentPageNumber = value + 1;
  10549. break;
  10550. case "print":
  10551. await pdfViewer.pagesPromise;
  10552. this.#eventBus.dispatch("print", {
  10553. source: this
  10554. });
  10555. break;
  10556. case "println":
  10557. console.log(value);
  10558. break;
  10559. case "zoom":
  10560. if (!isInPresentationMode) {
  10561. pdfViewer.currentScaleValue = value;
  10562. }
  10563. break;
  10564. case "SaveAs":
  10565. this.#eventBus.dispatch("download", {
  10566. source: this
  10567. });
  10568. break;
  10569. case "FirstPage":
  10570. pdfViewer.currentPageNumber = 1;
  10571. break;
  10572. case "LastPage":
  10573. pdfViewer.currentPageNumber = pdfViewer.pagesCount;
  10574. break;
  10575. case "NextPage":
  10576. pdfViewer.nextPage();
  10577. break;
  10578. case "PrevPage":
  10579. pdfViewer.previousPage();
  10580. break;
  10581. case "ZoomViewIn":
  10582. if (!isInPresentationMode) {
  10583. pdfViewer.increaseScale();
  10584. }
  10585. break;
  10586. case "ZoomViewOut":
  10587. if (!isInPresentationMode) {
  10588. pdfViewer.decreaseScale();
  10589. }
  10590. break;
  10591. case "WillPrintFinished":
  10592. this.#willPrintCapability?.resolve();
  10593. this.#willPrintCapability = null;
  10594. break;
  10595. }
  10596. return;
  10597. }
  10598. if (isInPresentationMode && detail.focus) {
  10599. return;
  10600. }
  10601. delete detail.id;
  10602. delete detail.siblings;
  10603. const ids = siblings ? [id, ...siblings] : [id];
  10604. for (const elementId of ids) {
  10605. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  10606. if (element) {
  10607. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  10608. detail
  10609. }));
  10610. } else {
  10611. this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
  10612. }
  10613. }
  10614. }
  10615. async #dispatchPageOpen(pageNumber, initialize = false) {
  10616. const pdfDocument = this.#pdfDocument,
  10617. visitedPages = this._visitedPages;
  10618. if (initialize) {
  10619. this.#closeCapability = Promise.withResolvers();
  10620. }
  10621. if (!this.#closeCapability) {
  10622. return;
  10623. }
  10624. const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
  10625. if (pageView?.renderingState !== RenderingStates.FINISHED) {
  10626. this._pageOpenPending.add(pageNumber);
  10627. return;
  10628. }
  10629. this._pageOpenPending.delete(pageNumber);
  10630. const actionsPromise = (async () => {
  10631. const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
  10632. if (pdfDocument !== this.#pdfDocument) {
  10633. return;
  10634. }
  10635. await this.#scripting?.dispatchEventInSandbox({
  10636. id: "page",
  10637. name: "PageOpen",
  10638. pageNumber,
  10639. actions
  10640. });
  10641. })();
  10642. visitedPages.set(pageNumber, actionsPromise);
  10643. }
  10644. async #dispatchPageClose(pageNumber) {
  10645. const pdfDocument = this.#pdfDocument,
  10646. visitedPages = this._visitedPages;
  10647. if (!this.#closeCapability) {
  10648. return;
  10649. }
  10650. if (this._pageOpenPending.has(pageNumber)) {
  10651. return;
  10652. }
  10653. const actionsPromise = visitedPages.get(pageNumber);
  10654. if (!actionsPromise) {
  10655. return;
  10656. }
  10657. visitedPages.set(pageNumber, null);
  10658. await actionsPromise;
  10659. if (pdfDocument !== this.#pdfDocument) {
  10660. return;
  10661. }
  10662. await this.#scripting?.dispatchEventInSandbox({
  10663. id: "page",
  10664. name: "PageClose",
  10665. pageNumber
  10666. });
  10667. }
  10668. #initScripting() {
  10669. this.#destroyCapability = Promise.withResolvers();
  10670. if (this.#scripting) {
  10671. throw new Error("#initScripting: Scripting already exists.");
  10672. }
  10673. return this.#externalServices.createScripting();
  10674. }
  10675. async #destroyScripting() {
  10676. if (!this.#scripting) {
  10677. this.#pdfDocument = null;
  10678. this.#destroyCapability?.resolve();
  10679. return;
  10680. }
  10681. if (this.#closeCapability) {
  10682. await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
  10683. setTimeout(resolve, 1000);
  10684. })]).catch(() => {});
  10685. this.#closeCapability = null;
  10686. }
  10687. this.#pdfDocument = null;
  10688. try {
  10689. await this.#scripting.destroySandbox();
  10690. } catch {}
  10691. this.#willPrintCapability?.reject(new Error("Scripting destroyed."));
  10692. this.#willPrintCapability = null;
  10693. this.#eventAbortController?.abort();
  10694. this.#eventAbortController = null;
  10695. this._pageOpenPending.clear();
  10696. this._visitedPages.clear();
  10697. this.#scripting = null;
  10698. this.#ready = false;
  10699. this.#destroyCapability?.resolve();
  10700. }
  10701. }
  10702. ;// ./web/pdf_sidebar.js
  10703. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  10704. const SIDEBAR_MIN_WIDTH = 200;
  10705. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  10706. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  10707. class PDFSidebar {
  10708. #isRTL = false;
  10709. #mouseAC = null;
  10710. #outerContainerWidth = null;
  10711. #width = null;
  10712. constructor({
  10713. elements,
  10714. eventBus,
  10715. l10n
  10716. }) {
  10717. this.isOpen = false;
  10718. this.active = SidebarView.THUMBS;
  10719. this.isInitialViewSet = false;
  10720. this.isInitialEventDispatched = false;
  10721. this.onToggled = null;
  10722. this.onUpdateThumbnails = null;
  10723. this.outerContainer = elements.outerContainer;
  10724. this.sidebarContainer = elements.sidebarContainer;
  10725. this.toggleButton = elements.toggleButton;
  10726. this.resizer = elements.resizer;
  10727. this.thumbnailButton = elements.thumbnailButton;
  10728. this.outlineButton = elements.outlineButton;
  10729. this.attachmentsButton = elements.attachmentsButton;
  10730. this.layersButton = elements.layersButton;
  10731. this.thumbnailView = elements.thumbnailView;
  10732. this.outlineView = elements.outlineView;
  10733. this.attachmentsView = elements.attachmentsView;
  10734. this.layersView = elements.layersView;
  10735. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  10736. this.eventBus = eventBus;
  10737. this.#isRTL = l10n.getDirection() === "rtl";
  10738. this.#addEventListeners();
  10739. }
  10740. reset() {
  10741. this.isInitialViewSet = false;
  10742. this.isInitialEventDispatched = false;
  10743. this.#hideUINotification(true);
  10744. this.switchView(SidebarView.THUMBS);
  10745. this.outlineButton.disabled = false;
  10746. this.attachmentsButton.disabled = false;
  10747. this.layersButton.disabled = false;
  10748. this._currentOutlineItemButton.disabled = true;
  10749. }
  10750. get visibleView() {
  10751. return this.isOpen ? this.active : SidebarView.NONE;
  10752. }
  10753. setInitialView(view = SidebarView.NONE) {
  10754. if (this.isInitialViewSet) {
  10755. return;
  10756. }
  10757. this.isInitialViewSet = true;
  10758. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  10759. this.#dispatchEvent();
  10760. return;
  10761. }
  10762. this.switchView(view, true);
  10763. if (!this.isInitialEventDispatched) {
  10764. this.#dispatchEvent();
  10765. }
  10766. }
  10767. switchView(view, forceOpen = false) {
  10768. const isViewChanged = view !== this.active;
  10769. let forceRendering = false;
  10770. switch (view) {
  10771. case SidebarView.NONE:
  10772. if (this.isOpen) {
  10773. this.close();
  10774. }
  10775. return;
  10776. case SidebarView.THUMBS:
  10777. if (this.isOpen && isViewChanged) {
  10778. forceRendering = true;
  10779. }
  10780. break;
  10781. case SidebarView.OUTLINE:
  10782. if (this.outlineButton.disabled) {
  10783. return;
  10784. }
  10785. break;
  10786. case SidebarView.ATTACHMENTS:
  10787. if (this.attachmentsButton.disabled) {
  10788. return;
  10789. }
  10790. break;
  10791. case SidebarView.LAYERS:
  10792. if (this.layersButton.disabled) {
  10793. return;
  10794. }
  10795. break;
  10796. default:
  10797. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  10798. return;
  10799. }
  10800. this.active = view;
  10801. toggleCheckedBtn(this.thumbnailButton, view === SidebarView.THUMBS, this.thumbnailView);
  10802. toggleCheckedBtn(this.outlineButton, view === SidebarView.OUTLINE, this.outlineView);
  10803. toggleCheckedBtn(this.attachmentsButton, view === SidebarView.ATTACHMENTS, this.attachmentsView);
  10804. toggleCheckedBtn(this.layersButton, view === SidebarView.LAYERS, this.layersView);
  10805. if (forceOpen && !this.isOpen) {
  10806. this.open();
  10807. return;
  10808. }
  10809. if (forceRendering) {
  10810. this.onUpdateThumbnails();
  10811. this.onToggled();
  10812. }
  10813. if (isViewChanged) {
  10814. this.#dispatchEvent();
  10815. }
  10816. }
  10817. open() {
  10818. if (this.isOpen) {
  10819. return;
  10820. }
  10821. this.isOpen = true;
  10822. toggleExpandedBtn(this.toggleButton, true);
  10823. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  10824. if (this.active === SidebarView.THUMBS) {
  10825. this.onUpdateThumbnails();
  10826. }
  10827. this.onToggled();
  10828. this.#dispatchEvent();
  10829. this.#hideUINotification();
  10830. }
  10831. close(evt = null) {
  10832. if (!this.isOpen) {
  10833. return;
  10834. }
  10835. this.isOpen = false;
  10836. toggleExpandedBtn(this.toggleButton, false);
  10837. this.outerContainer.classList.add("sidebarMoving");
  10838. this.outerContainer.classList.remove("sidebarOpen");
  10839. this.onToggled();
  10840. this.#dispatchEvent();
  10841. if (evt?.detail > 0) {
  10842. this.toggleButton.blur();
  10843. }
  10844. }
  10845. toggle(evt = null) {
  10846. if (this.isOpen) {
  10847. this.close(evt);
  10848. } else {
  10849. this.open();
  10850. }
  10851. }
  10852. #dispatchEvent() {
  10853. if (this.isInitialViewSet) {
  10854. this.isInitialEventDispatched ||= true;
  10855. }
  10856. this.eventBus.dispatch("sidebarviewchanged", {
  10857. source: this,
  10858. view: this.visibleView
  10859. });
  10860. }
  10861. #showUINotification() {
  10862. this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-notification-button");
  10863. if (!this.isOpen) {
  10864. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  10865. }
  10866. }
  10867. #hideUINotification(reset = false) {
  10868. if (this.isOpen || reset) {
  10869. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  10870. }
  10871. if (reset) {
  10872. this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-button");
  10873. }
  10874. }
  10875. #addEventListeners() {
  10876. const {
  10877. eventBus,
  10878. outerContainer
  10879. } = this;
  10880. this.sidebarContainer.addEventListener("transitionend", evt => {
  10881. if (evt.target === this.sidebarContainer) {
  10882. outerContainer.classList.remove("sidebarMoving");
  10883. eventBus.dispatch("resize", {
  10884. source: this
  10885. });
  10886. }
  10887. });
  10888. this.toggleButton.addEventListener("click", evt => {
  10889. this.toggle(evt);
  10890. });
  10891. this.thumbnailButton.addEventListener("click", () => {
  10892. this.switchView(SidebarView.THUMBS);
  10893. });
  10894. this.outlineButton.addEventListener("click", () => {
  10895. this.switchView(SidebarView.OUTLINE);
  10896. });
  10897. this.outlineButton.addEventListener("dblclick", () => {
  10898. eventBus.dispatch("toggleoutlinetree", {
  10899. source: this
  10900. });
  10901. });
  10902. this.attachmentsButton.addEventListener("click", () => {
  10903. this.switchView(SidebarView.ATTACHMENTS);
  10904. });
  10905. this.layersButton.addEventListener("click", () => {
  10906. this.switchView(SidebarView.LAYERS);
  10907. });
  10908. this.layersButton.addEventListener("dblclick", () => {
  10909. eventBus.dispatch("resetlayers", {
  10910. source: this
  10911. });
  10912. });
  10913. this._currentOutlineItemButton.addEventListener("click", () => {
  10914. eventBus.dispatch("currentoutlineitem", {
  10915. source: this
  10916. });
  10917. });
  10918. const onTreeLoaded = (count, button, view) => {
  10919. button.disabled = !count;
  10920. if (count) {
  10921. this.#showUINotification();
  10922. } else if (this.active === view) {
  10923. this.switchView(SidebarView.THUMBS);
  10924. }
  10925. };
  10926. eventBus._on("outlineloaded", evt => {
  10927. onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE);
  10928. evt.currentOutlineItemPromise.then(enabled => {
  10929. if (!this.isInitialViewSet) {
  10930. return;
  10931. }
  10932. this._currentOutlineItemButton.disabled = !enabled;
  10933. });
  10934. });
  10935. eventBus._on("attachmentsloaded", evt => {
  10936. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS);
  10937. });
  10938. eventBus._on("layersloaded", evt => {
  10939. onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS);
  10940. });
  10941. eventBus._on("presentationmodechanged", evt => {
  10942. if (evt.state === PresentationModeState.NORMAL && this.visibleView === SidebarView.THUMBS) {
  10943. this.onUpdateThumbnails();
  10944. }
  10945. });
  10946. this.resizer.addEventListener("mousedown", evt => {
  10947. if (evt.button !== 0) {
  10948. return;
  10949. }
  10950. outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10951. this.#mouseAC = new AbortController();
  10952. const opts = {
  10953. signal: this.#mouseAC.signal
  10954. };
  10955. window.addEventListener("mousemove", this.#mouseMove.bind(this), opts);
  10956. window.addEventListener("mouseup", this.#mouseUp.bind(this), opts);
  10957. window.addEventListener("blur", this.#mouseUp.bind(this), opts);
  10958. });
  10959. eventBus._on("resize", evt => {
  10960. if (evt.source !== window) {
  10961. return;
  10962. }
  10963. this.#outerContainerWidth = null;
  10964. if (!this.#width) {
  10965. return;
  10966. }
  10967. if (!this.isOpen) {
  10968. this.#updateWidth(this.#width);
  10969. return;
  10970. }
  10971. outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10972. const updated = this.#updateWidth(this.#width);
  10973. Promise.resolve().then(() => {
  10974. outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10975. if (updated) {
  10976. eventBus.dispatch("resize", {
  10977. source: this
  10978. });
  10979. }
  10980. });
  10981. });
  10982. }
  10983. get outerContainerWidth() {
  10984. return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
  10985. }
  10986. #updateWidth(width = 0) {
  10987. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  10988. if (width > maxWidth) {
  10989. width = maxWidth;
  10990. }
  10991. if (width < SIDEBAR_MIN_WIDTH) {
  10992. width = SIDEBAR_MIN_WIDTH;
  10993. }
  10994. if (width === this.#width) {
  10995. return false;
  10996. }
  10997. this.#width = width;
  10998. docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  10999. return true;
  11000. }
  11001. #mouseMove(evt) {
  11002. let width = evt.clientX;
  11003. if (this.#isRTL) {
  11004. width = this.outerContainerWidth - width;
  11005. }
  11006. this.#updateWidth(width);
  11007. }
  11008. #mouseUp(evt) {
  11009. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  11010. this.eventBus.dispatch("resize", {
  11011. source: this
  11012. });
  11013. this.#mouseAC?.abort();
  11014. this.#mouseAC = null;
  11015. }
  11016. }
  11017. ;// ./web/pdf_thumbnail_view.js
  11018. const DRAW_UPSCALE_FACTOR = 2;
  11019. const MAX_NUM_SCALING_STEPS = 3;
  11020. const THUMBNAIL_WIDTH = 98;
  11021. class TempImageFactory {
  11022. static #tempCanvas = null;
  11023. static getCanvas(width, height) {
  11024. const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
  11025. tempCanvas.width = width;
  11026. tempCanvas.height = height;
  11027. const ctx = tempCanvas.getContext("2d", {
  11028. alpha: false
  11029. });
  11030. ctx.save();
  11031. ctx.fillStyle = "rgb(255, 255, 255)";
  11032. ctx.fillRect(0, 0, width, height);
  11033. ctx.restore();
  11034. return [tempCanvas, tempCanvas.getContext("2d")];
  11035. }
  11036. static destroyCanvas() {
  11037. const tempCanvas = this.#tempCanvas;
  11038. if (tempCanvas) {
  11039. tempCanvas.width = 0;
  11040. tempCanvas.height = 0;
  11041. }
  11042. this.#tempCanvas = null;
  11043. }
  11044. }
  11045. class PDFThumbnailView {
  11046. constructor({
  11047. container,
  11048. eventBus,
  11049. id,
  11050. defaultViewport,
  11051. optionalContentConfigPromise,
  11052. linkService,
  11053. renderingQueue,
  11054. pageColors,
  11055. enableHWA
  11056. }) {
  11057. this.id = id;
  11058. this.renderingId = "thumbnail" + id;
  11059. this.pageLabel = null;
  11060. this.pdfPage = null;
  11061. this.rotation = 0;
  11062. this.viewport = defaultViewport;
  11063. this.pdfPageRotate = defaultViewport.rotation;
  11064. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  11065. this.pageColors = pageColors || null;
  11066. this.enableHWA = enableHWA || false;
  11067. this.eventBus = eventBus;
  11068. this.linkService = linkService;
  11069. this.renderingQueue = renderingQueue;
  11070. this.renderTask = null;
  11071. this.renderingState = RenderingStates.INITIAL;
  11072. this.resume = null;
  11073. const anchor = document.createElement("a");
  11074. anchor.href = linkService.getAnchorUrl("#page=" + id);
  11075. anchor.setAttribute("data-l10n-id", "pdfjs-thumb-page-title");
  11076. anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
  11077. anchor.onclick = function () {
  11078. linkService.goToPage(id);
  11079. return false;
  11080. };
  11081. this.anchor = anchor;
  11082. const div = document.createElement("div");
  11083. div.className = "thumbnail";
  11084. div.setAttribute("data-page-number", this.id);
  11085. this.div = div;
  11086. this.#updateDims();
  11087. const img = document.createElement("div");
  11088. img.className = "thumbnailImage";
  11089. this._placeholderImg = img;
  11090. div.append(img);
  11091. anchor.append(div);
  11092. container.append(anchor);
  11093. }
  11094. #updateDims() {
  11095. const {
  11096. width,
  11097. height
  11098. } = this.viewport;
  11099. const ratio = width / height;
  11100. this.canvasWidth = THUMBNAIL_WIDTH;
  11101. this.canvasHeight = this.canvasWidth / ratio | 0;
  11102. this.scale = this.canvasWidth / width;
  11103. const {
  11104. style
  11105. } = this.div;
  11106. style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
  11107. style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
  11108. }
  11109. setPdfPage(pdfPage) {
  11110. this.pdfPage = pdfPage;
  11111. this.pdfPageRotate = pdfPage.rotate;
  11112. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11113. this.viewport = pdfPage.getViewport({
  11114. scale: 1,
  11115. rotation: totalRotation
  11116. });
  11117. this.reset();
  11118. }
  11119. reset() {
  11120. this.cancelRendering();
  11121. this.renderingState = RenderingStates.INITIAL;
  11122. this.div.removeAttribute("data-loaded");
  11123. this.image?.replaceWith(this._placeholderImg);
  11124. this.#updateDims();
  11125. if (this.image) {
  11126. this.image.removeAttribute("src");
  11127. delete this.image;
  11128. }
  11129. }
  11130. update({
  11131. rotation = null
  11132. }) {
  11133. if (typeof rotation === "number") {
  11134. this.rotation = rotation;
  11135. }
  11136. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11137. this.viewport = this.viewport.clone({
  11138. scale: 1,
  11139. rotation: totalRotation
  11140. });
  11141. this.reset();
  11142. }
  11143. cancelRendering() {
  11144. if (this.renderTask) {
  11145. this.renderTask.cancel();
  11146. this.renderTask = null;
  11147. }
  11148. this.resume = null;
  11149. }
  11150. #getPageDrawContext(upscaleFactor = 1, enableHWA = this.enableHWA) {
  11151. const canvas = document.createElement("canvas");
  11152. const ctx = canvas.getContext("2d", {
  11153. alpha: false,
  11154. willReadFrequently: !enableHWA
  11155. });
  11156. const outputScale = new OutputScale();
  11157. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  11158. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  11159. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  11160. return {
  11161. ctx,
  11162. canvas,
  11163. transform
  11164. };
  11165. }
  11166. #convertCanvasToImage(canvas) {
  11167. if (this.renderingState !== RenderingStates.FINISHED) {
  11168. throw new Error("#convertCanvasToImage: Rendering has not finished.");
  11169. }
  11170. const reducedCanvas = this.#reduceImage(canvas);
  11171. const image = document.createElement("img");
  11172. image.className = "thumbnailImage";
  11173. image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas");
  11174. image.setAttribute("data-l10n-args", this.#pageL10nArgs);
  11175. image.src = reducedCanvas.toDataURL();
  11176. this.image = image;
  11177. this.div.setAttribute("data-loaded", true);
  11178. this._placeholderImg.replaceWith(image);
  11179. reducedCanvas.width = 0;
  11180. reducedCanvas.height = 0;
  11181. }
  11182. async #finishRenderTask(renderTask, canvas, error = null) {
  11183. if (renderTask === this.renderTask) {
  11184. this.renderTask = null;
  11185. }
  11186. if (error instanceof RenderingCancelledException) {
  11187. return;
  11188. }
  11189. this.renderingState = RenderingStates.FINISHED;
  11190. this.#convertCanvasToImage(canvas);
  11191. if (error) {
  11192. throw error;
  11193. }
  11194. }
  11195. async draw() {
  11196. if (this.renderingState !== RenderingStates.INITIAL) {
  11197. console.error("Must be in new state before drawing");
  11198. return undefined;
  11199. }
  11200. const {
  11201. pdfPage
  11202. } = this;
  11203. if (!pdfPage) {
  11204. this.renderingState = RenderingStates.FINISHED;
  11205. throw new Error("pdfPage is not loaded");
  11206. }
  11207. this.renderingState = RenderingStates.RUNNING;
  11208. const {
  11209. ctx,
  11210. canvas,
  11211. transform
  11212. } = this.#getPageDrawContext(DRAW_UPSCALE_FACTOR);
  11213. const drawViewport = this.viewport.clone({
  11214. scale: DRAW_UPSCALE_FACTOR * this.scale
  11215. });
  11216. const renderContinueCallback = cont => {
  11217. if (!this.renderingQueue.isHighestPriority(this)) {
  11218. this.renderingState = RenderingStates.PAUSED;
  11219. this.resume = () => {
  11220. this.renderingState = RenderingStates.RUNNING;
  11221. cont();
  11222. };
  11223. return;
  11224. }
  11225. cont();
  11226. };
  11227. const renderContext = {
  11228. canvasContext: ctx,
  11229. transform,
  11230. viewport: drawViewport,
  11231. optionalContentConfigPromise: this._optionalContentConfigPromise,
  11232. pageColors: this.pageColors
  11233. };
  11234. const renderTask = this.renderTask = pdfPage.render(renderContext);
  11235. renderTask.onContinue = renderContinueCallback;
  11236. const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
  11237. resultPromise.finally(() => {
  11238. canvas.width = 0;
  11239. canvas.height = 0;
  11240. this.eventBus.dispatch("thumbnailrendered", {
  11241. source: this,
  11242. pageNumber: this.id,
  11243. pdfPage: this.pdfPage
  11244. });
  11245. });
  11246. return resultPromise;
  11247. }
  11248. setImage(pageView) {
  11249. if (this.renderingState !== RenderingStates.INITIAL) {
  11250. return;
  11251. }
  11252. const {
  11253. thumbnailCanvas: canvas,
  11254. pdfPage,
  11255. scale
  11256. } = pageView;
  11257. if (!canvas) {
  11258. return;
  11259. }
  11260. if (!this.pdfPage) {
  11261. this.setPdfPage(pdfPage);
  11262. }
  11263. if (scale < this.scale) {
  11264. return;
  11265. }
  11266. this.renderingState = RenderingStates.FINISHED;
  11267. this.#convertCanvasToImage(canvas);
  11268. }
  11269. #reduceImage(img) {
  11270. const {
  11271. ctx,
  11272. canvas
  11273. } = this.#getPageDrawContext(1, true);
  11274. if (img.width <= 2 * canvas.width) {
  11275. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  11276. return canvas;
  11277. }
  11278. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  11279. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  11280. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  11281. while (reducedWidth > img.width || reducedHeight > img.height) {
  11282. reducedWidth >>= 1;
  11283. reducedHeight >>= 1;
  11284. }
  11285. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  11286. while (reducedWidth > 2 * canvas.width) {
  11287. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  11288. reducedWidth >>= 1;
  11289. reducedHeight >>= 1;
  11290. }
  11291. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  11292. return canvas;
  11293. }
  11294. get #pageL10nArgs() {
  11295. return JSON.stringify({
  11296. page: this.pageLabel ?? this.id
  11297. });
  11298. }
  11299. setPageLabel(label) {
  11300. this.pageLabel = typeof label === "string" ? label : null;
  11301. this.anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
  11302. if (this.renderingState !== RenderingStates.FINISHED) {
  11303. return;
  11304. }
  11305. this.image?.setAttribute("data-l10n-args", this.#pageL10nArgs);
  11306. }
  11307. }
  11308. ;// ./web/pdf_thumbnail_viewer.js
  11309. const THUMBNAIL_SCROLL_MARGIN = -19;
  11310. const THUMBNAIL_SELECTED_CLASS = "selected";
  11311. class PDFThumbnailViewer {
  11312. constructor({
  11313. container,
  11314. eventBus,
  11315. linkService,
  11316. renderingQueue,
  11317. pageColors,
  11318. abortSignal,
  11319. enableHWA
  11320. }) {
  11321. this.container = container;
  11322. this.eventBus = eventBus;
  11323. this.linkService = linkService;
  11324. this.renderingQueue = renderingQueue;
  11325. this.pageColors = pageColors || null;
  11326. this.enableHWA = enableHWA || false;
  11327. this.scroll = watchScroll(this.container, this.#scrollUpdated.bind(this), abortSignal);
  11328. this.#resetView();
  11329. }
  11330. #scrollUpdated() {
  11331. this.renderingQueue.renderHighestPriority();
  11332. }
  11333. getThumbnail(index) {
  11334. return this._thumbnails[index];
  11335. }
  11336. #getVisibleThumbs() {
  11337. return getVisibleElements({
  11338. scrollEl: this.container,
  11339. views: this._thumbnails
  11340. });
  11341. }
  11342. scrollThumbnailIntoView(pageNumber) {
  11343. if (!this.pdfDocument) {
  11344. return;
  11345. }
  11346. const thumbnailView = this._thumbnails[pageNumber - 1];
  11347. if (!thumbnailView) {
  11348. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  11349. return;
  11350. }
  11351. if (pageNumber !== this._currentPageNumber) {
  11352. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  11353. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  11354. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  11355. }
  11356. const {
  11357. first,
  11358. last,
  11359. views
  11360. } = this.#getVisibleThumbs();
  11361. if (views.length > 0) {
  11362. let shouldScroll = false;
  11363. if (pageNumber <= first.id || pageNumber >= last.id) {
  11364. shouldScroll = true;
  11365. } else {
  11366. for (const {
  11367. id,
  11368. percent
  11369. } of views) {
  11370. if (id !== pageNumber) {
  11371. continue;
  11372. }
  11373. shouldScroll = percent < 100;
  11374. break;
  11375. }
  11376. }
  11377. if (shouldScroll) {
  11378. scrollIntoView(thumbnailView.div, {
  11379. top: THUMBNAIL_SCROLL_MARGIN
  11380. });
  11381. }
  11382. }
  11383. this._currentPageNumber = pageNumber;
  11384. }
  11385. get pagesRotation() {
  11386. return this._pagesRotation;
  11387. }
  11388. set pagesRotation(rotation) {
  11389. if (!isValidRotation(rotation)) {
  11390. throw new Error("Invalid thumbnails rotation angle.");
  11391. }
  11392. if (!this.pdfDocument) {
  11393. return;
  11394. }
  11395. if (this._pagesRotation === rotation) {
  11396. return;
  11397. }
  11398. this._pagesRotation = rotation;
  11399. const updateArgs = {
  11400. rotation
  11401. };
  11402. for (const thumbnail of this._thumbnails) {
  11403. thumbnail.update(updateArgs);
  11404. }
  11405. }
  11406. cleanup() {
  11407. for (const thumbnail of this._thumbnails) {
  11408. if (thumbnail.renderingState !== RenderingStates.FINISHED) {
  11409. thumbnail.reset();
  11410. }
  11411. }
  11412. TempImageFactory.destroyCanvas();
  11413. }
  11414. #resetView() {
  11415. this._thumbnails = [];
  11416. this._currentPageNumber = 1;
  11417. this._pageLabels = null;
  11418. this._pagesRotation = 0;
  11419. this.container.textContent = "";
  11420. }
  11421. setDocument(pdfDocument) {
  11422. if (this.pdfDocument) {
  11423. this.#cancelRendering();
  11424. this.#resetView();
  11425. }
  11426. this.pdfDocument = pdfDocument;
  11427. if (!pdfDocument) {
  11428. return;
  11429. }
  11430. const firstPagePromise = pdfDocument.getPage(1);
  11431. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
  11432. intent: "display"
  11433. });
  11434. firstPagePromise.then(firstPdfPage => {
  11435. const pagesCount = pdfDocument.numPages;
  11436. const viewport = firstPdfPage.getViewport({
  11437. scale: 1
  11438. });
  11439. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11440. const thumbnail = new PDFThumbnailView({
  11441. container: this.container,
  11442. eventBus: this.eventBus,
  11443. id: pageNum,
  11444. defaultViewport: viewport.clone(),
  11445. optionalContentConfigPromise,
  11446. linkService: this.linkService,
  11447. renderingQueue: this.renderingQueue,
  11448. pageColors: this.pageColors,
  11449. enableHWA: this.enableHWA
  11450. });
  11451. this._thumbnails.push(thumbnail);
  11452. }
  11453. this._thumbnails[0]?.setPdfPage(firstPdfPage);
  11454. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  11455. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  11456. }).catch(reason => {
  11457. console.error("Unable to initialize thumbnail viewer", reason);
  11458. });
  11459. }
  11460. #cancelRendering() {
  11461. for (const thumbnail of this._thumbnails) {
  11462. thumbnail.cancelRendering();
  11463. }
  11464. }
  11465. setPageLabels(labels) {
  11466. if (!this.pdfDocument) {
  11467. return;
  11468. }
  11469. if (!labels) {
  11470. this._pageLabels = null;
  11471. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11472. this._pageLabels = null;
  11473. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  11474. } else {
  11475. this._pageLabels = labels;
  11476. }
  11477. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  11478. this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11479. }
  11480. }
  11481. async #ensurePdfPageLoaded(thumbView) {
  11482. if (thumbView.pdfPage) {
  11483. return thumbView.pdfPage;
  11484. }
  11485. try {
  11486. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  11487. if (!thumbView.pdfPage) {
  11488. thumbView.setPdfPage(pdfPage);
  11489. }
  11490. return pdfPage;
  11491. } catch (reason) {
  11492. console.error("Unable to get page for thumb view", reason);
  11493. return null;
  11494. }
  11495. }
  11496. #getScrollAhead(visible) {
  11497. if (visible.first?.id === 1) {
  11498. return true;
  11499. } else if (visible.last?.id === this._thumbnails.length) {
  11500. return false;
  11501. }
  11502. return this.scroll.down;
  11503. }
  11504. forceRendering() {
  11505. const visibleThumbs = this.#getVisibleThumbs();
  11506. const scrollAhead = this.#getScrollAhead(visibleThumbs);
  11507. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  11508. if (thumbView) {
  11509. this.#ensurePdfPageLoaded(thumbView).then(() => {
  11510. this.renderingQueue.renderView(thumbView);
  11511. });
  11512. return true;
  11513. }
  11514. return false;
  11515. }
  11516. }
  11517. ;// ./web/annotation_editor_layer_builder.js
  11518. class AnnotationEditorLayerBuilder {
  11519. #annotationLayer = null;
  11520. #drawLayer = null;
  11521. #onAppend = null;
  11522. #structTreeLayer = null;
  11523. #textLayer = null;
  11524. #uiManager;
  11525. constructor(options) {
  11526. this.pdfPage = options.pdfPage;
  11527. this.accessibilityManager = options.accessibilityManager;
  11528. this.l10n = options.l10n;
  11529. this.l10n ||= new genericl10n_GenericL10n();
  11530. this.annotationEditorLayer = null;
  11531. this.div = null;
  11532. this._cancelled = false;
  11533. this.#uiManager = options.uiManager;
  11534. this.#annotationLayer = options.annotationLayer || null;
  11535. this.#textLayer = options.textLayer || null;
  11536. this.#drawLayer = options.drawLayer || null;
  11537. this.#onAppend = options.onAppend || null;
  11538. this.#structTreeLayer = options.structTreeLayer || null;
  11539. }
  11540. async render(viewport, intent = "display") {
  11541. if (intent !== "display") {
  11542. return;
  11543. }
  11544. if (this._cancelled) {
  11545. return;
  11546. }
  11547. const clonedViewport = viewport.clone({
  11548. dontFlip: true
  11549. });
  11550. if (this.div) {
  11551. this.annotationEditorLayer.update({
  11552. viewport: clonedViewport
  11553. });
  11554. this.show();
  11555. return;
  11556. }
  11557. const div = this.div = document.createElement("div");
  11558. div.className = "annotationEditorLayer";
  11559. div.hidden = true;
  11560. div.dir = this.#uiManager.direction;
  11561. this.#onAppend?.(div);
  11562. this.annotationEditorLayer = new AnnotationEditorLayer({
  11563. uiManager: this.#uiManager,
  11564. div,
  11565. structTreeLayer: this.#structTreeLayer,
  11566. accessibilityManager: this.accessibilityManager,
  11567. pageIndex: this.pdfPage.pageNumber - 1,
  11568. l10n: this.l10n,
  11569. viewport: clonedViewport,
  11570. annotationLayer: this.#annotationLayer,
  11571. textLayer: this.#textLayer,
  11572. drawLayer: this.#drawLayer
  11573. });
  11574. const parameters = {
  11575. viewport: clonedViewport,
  11576. div,
  11577. annotations: null,
  11578. intent
  11579. };
  11580. this.annotationEditorLayer.render(parameters);
  11581. this.show();
  11582. }
  11583. cancel() {
  11584. this._cancelled = true;
  11585. if (!this.div) {
  11586. return;
  11587. }
  11588. this.annotationEditorLayer.destroy();
  11589. }
  11590. hide() {
  11591. if (!this.div) {
  11592. return;
  11593. }
  11594. this.div.hidden = true;
  11595. }
  11596. show() {
  11597. if (!this.div || this.annotationEditorLayer.isInvisible) {
  11598. return;
  11599. }
  11600. this.div.hidden = false;
  11601. }
  11602. }
  11603. ;// ./web/annotation_layer_builder.js
  11604. class AnnotationLayerBuilder {
  11605. #onAppend = null;
  11606. #eventAbortController = null;
  11607. constructor({
  11608. pdfPage,
  11609. linkService,
  11610. downloadManager,
  11611. annotationStorage = null,
  11612. imageResourcesPath = "",
  11613. renderForms = true,
  11614. enableScripting = false,
  11615. hasJSActionsPromise = null,
  11616. fieldObjectsPromise = null,
  11617. annotationCanvasMap = null,
  11618. accessibilityManager = null,
  11619. annotationEditorUIManager = null,
  11620. onAppend = null
  11621. }) {
  11622. this.pdfPage = pdfPage;
  11623. this.linkService = linkService;
  11624. this.downloadManager = downloadManager;
  11625. this.imageResourcesPath = imageResourcesPath;
  11626. this.renderForms = renderForms;
  11627. this.annotationStorage = annotationStorage;
  11628. this.enableScripting = enableScripting;
  11629. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  11630. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  11631. this._annotationCanvasMap = annotationCanvasMap;
  11632. this._accessibilityManager = accessibilityManager;
  11633. this._annotationEditorUIManager = annotationEditorUIManager;
  11634. this.#onAppend = onAppend;
  11635. this.annotationLayer = null;
  11636. this.div = null;
  11637. this._cancelled = false;
  11638. this._eventBus = linkService.eventBus;
  11639. }
  11640. async render(viewport, options, intent = "display") {
  11641. if (this.div) {
  11642. if (this._cancelled || !this.annotationLayer) {
  11643. return;
  11644. }
  11645. this.annotationLayer.update({
  11646. viewport: viewport.clone({
  11647. dontFlip: true
  11648. })
  11649. });
  11650. return;
  11651. }
  11652. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  11653. intent
  11654. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  11655. if (this._cancelled) {
  11656. return;
  11657. }
  11658. const div = this.div = document.createElement("div");
  11659. div.className = "annotationLayer";
  11660. this.#onAppend?.(div);
  11661. if (annotations.length === 0) {
  11662. this.hide();
  11663. return;
  11664. }
  11665. this.annotationLayer = new AnnotationLayer({
  11666. div,
  11667. accessibilityManager: this._accessibilityManager,
  11668. annotationCanvasMap: this._annotationCanvasMap,
  11669. annotationEditorUIManager: this._annotationEditorUIManager,
  11670. page: this.pdfPage,
  11671. viewport: viewport.clone({
  11672. dontFlip: true
  11673. }),
  11674. structTreeLayer: options?.structTreeLayer || null
  11675. });
  11676. await this.annotationLayer.render({
  11677. annotations,
  11678. imageResourcesPath: this.imageResourcesPath,
  11679. renderForms: this.renderForms,
  11680. linkService: this.linkService,
  11681. downloadManager: this.downloadManager,
  11682. annotationStorage: this.annotationStorage,
  11683. enableScripting: this.enableScripting,
  11684. hasJSActions,
  11685. fieldObjects
  11686. });
  11687. if (this.linkService.isInPresentationMode) {
  11688. this.#updatePresentationModeState(PresentationModeState.FULLSCREEN);
  11689. }
  11690. if (!this.#eventAbortController) {
  11691. this.#eventAbortController = new AbortController();
  11692. this._eventBus?._on("presentationmodechanged", evt => {
  11693. this.#updatePresentationModeState(evt.state);
  11694. }, {
  11695. signal: this.#eventAbortController.signal
  11696. });
  11697. }
  11698. }
  11699. cancel() {
  11700. this._cancelled = true;
  11701. this.#eventAbortController?.abort();
  11702. this.#eventAbortController = null;
  11703. }
  11704. hide() {
  11705. if (!this.div) {
  11706. return;
  11707. }
  11708. this.div.hidden = true;
  11709. }
  11710. hasEditableAnnotations() {
  11711. return !!this.annotationLayer?.hasEditableAnnotations();
  11712. }
  11713. #updatePresentationModeState(state) {
  11714. if (!this.div) {
  11715. return;
  11716. }
  11717. let disableFormElements = false;
  11718. switch (state) {
  11719. case PresentationModeState.FULLSCREEN:
  11720. disableFormElements = true;
  11721. break;
  11722. case PresentationModeState.NORMAL:
  11723. break;
  11724. default:
  11725. return;
  11726. }
  11727. for (const section of this.div.childNodes) {
  11728. if (section.hasAttribute("data-internal-link")) {
  11729. continue;
  11730. }
  11731. section.inert = disableFormElements;
  11732. }
  11733. }
  11734. }
  11735. ;// ./web/draw_layer_builder.js
  11736. class DrawLayerBuilder {
  11737. #drawLayer = null;
  11738. constructor(options) {
  11739. this.pageIndex = options.pageIndex;
  11740. }
  11741. async render(intent = "display") {
  11742. if (intent !== "display" || this.#drawLayer || this._cancelled) {
  11743. return;
  11744. }
  11745. this.#drawLayer = new DrawLayer({
  11746. pageIndex: this.pageIndex
  11747. });
  11748. }
  11749. cancel() {
  11750. this._cancelled = true;
  11751. if (!this.#drawLayer) {
  11752. return;
  11753. }
  11754. this.#drawLayer.destroy();
  11755. this.#drawLayer = null;
  11756. }
  11757. setParent(parent) {
  11758. this.#drawLayer?.setParent(parent);
  11759. }
  11760. getDrawLayer() {
  11761. return this.#drawLayer;
  11762. }
  11763. }
  11764. ;// ./web/struct_tree_layer_builder.js
  11765. const PDF_ROLE_TO_HTML_ROLE = {
  11766. Document: null,
  11767. DocumentFragment: null,
  11768. Part: "group",
  11769. Sect: "group",
  11770. Div: "group",
  11771. Aside: "note",
  11772. NonStruct: "none",
  11773. P: null,
  11774. H: "heading",
  11775. Title: null,
  11776. FENote: "note",
  11777. Sub: "group",
  11778. Lbl: null,
  11779. Span: null,
  11780. Em: null,
  11781. Strong: null,
  11782. Link: "link",
  11783. Annot: "note",
  11784. Form: "form",
  11785. Ruby: null,
  11786. RB: null,
  11787. RT: null,
  11788. RP: null,
  11789. Warichu: null,
  11790. WT: null,
  11791. WP: null,
  11792. L: "list",
  11793. LI: "listitem",
  11794. LBody: null,
  11795. Table: "table",
  11796. TR: "row",
  11797. TH: "columnheader",
  11798. TD: "cell",
  11799. THead: "columnheader",
  11800. TBody: null,
  11801. TFoot: null,
  11802. Caption: null,
  11803. Figure: "figure",
  11804. Formula: null,
  11805. Artifact: null
  11806. };
  11807. const HEADING_PATTERN = /^H(\d+)$/;
  11808. class StructTreeLayerBuilder {
  11809. #promise;
  11810. #treeDom = null;
  11811. #treePromise;
  11812. #elementAttributes = new Map();
  11813. #rawDims;
  11814. #elementsToAddToTextLayer = null;
  11815. constructor(pdfPage, rawDims) {
  11816. this.#promise = pdfPage.getStructTree();
  11817. this.#rawDims = rawDims;
  11818. }
  11819. async render() {
  11820. if (this.#treePromise) {
  11821. return this.#treePromise;
  11822. }
  11823. const {
  11824. promise,
  11825. resolve,
  11826. reject
  11827. } = Promise.withResolvers();
  11828. this.#treePromise = promise;
  11829. try {
  11830. this.#treeDom = this.#walk(await this.#promise);
  11831. } catch (ex) {
  11832. reject(ex);
  11833. }
  11834. this.#promise = null;
  11835. this.#treeDom?.classList.add("structTree");
  11836. resolve(this.#treeDom);
  11837. return promise;
  11838. }
  11839. async getAriaAttributes(annotationId) {
  11840. await this.render();
  11841. return this.#elementAttributes.get(annotationId);
  11842. }
  11843. hide() {
  11844. if (this.#treeDom && !this.#treeDom.hidden) {
  11845. this.#treeDom.hidden = true;
  11846. }
  11847. }
  11848. show() {
  11849. if (this.#treeDom?.hidden) {
  11850. this.#treeDom.hidden = false;
  11851. }
  11852. }
  11853. #setAttributes(structElement, htmlElement) {
  11854. const {
  11855. alt,
  11856. id,
  11857. lang
  11858. } = structElement;
  11859. if (alt !== undefined) {
  11860. let added = false;
  11861. const label = removeNullCharacters(alt);
  11862. for (const child of structElement.children) {
  11863. if (child.type === "annotation") {
  11864. let attrs = this.#elementAttributes.get(child.id);
  11865. if (!attrs) {
  11866. attrs = new Map();
  11867. this.#elementAttributes.set(child.id, attrs);
  11868. }
  11869. attrs.set("aria-label", label);
  11870. added = true;
  11871. }
  11872. }
  11873. if (!added) {
  11874. htmlElement.setAttribute("aria-label", label);
  11875. }
  11876. }
  11877. if (id !== undefined) {
  11878. htmlElement.setAttribute("aria-owns", id);
  11879. }
  11880. if (lang !== undefined) {
  11881. htmlElement.setAttribute("lang", removeNullCharacters(lang, true));
  11882. }
  11883. }
  11884. #addImageInTextLayer(node, element) {
  11885. const {
  11886. alt,
  11887. bbox,
  11888. children
  11889. } = node;
  11890. const child = children?.[0];
  11891. if (!this.#rawDims || !alt || !bbox || child?.type !== "content") {
  11892. return false;
  11893. }
  11894. const {
  11895. id
  11896. } = child;
  11897. if (!id) {
  11898. return false;
  11899. }
  11900. element.setAttribute("aria-owns", id);
  11901. const img = document.createElement("span");
  11902. (this.#elementsToAddToTextLayer ||= new Map()).set(id, img);
  11903. img.setAttribute("role", "img");
  11904. img.setAttribute("aria-label", removeNullCharacters(alt));
  11905. const {
  11906. pageHeight,
  11907. pageX,
  11908. pageY
  11909. } = this.#rawDims;
  11910. const calc = "calc(var(--scale-factor)*";
  11911. const {
  11912. style
  11913. } = img;
  11914. style.width = `${calc}${bbox[2] - bbox[0]}px)`;
  11915. style.height = `${calc}${bbox[3] - bbox[1]}px)`;
  11916. style.left = `${calc}${bbox[0] - pageX}px)`;
  11917. style.top = `${calc}${pageHeight - bbox[3] + pageY}px)`;
  11918. return true;
  11919. }
  11920. addElementsToTextLayer() {
  11921. if (!this.#elementsToAddToTextLayer) {
  11922. return;
  11923. }
  11924. for (const [id, img] of this.#elementsToAddToTextLayer) {
  11925. document.getElementById(id)?.append(img);
  11926. }
  11927. this.#elementsToAddToTextLayer.clear();
  11928. this.#elementsToAddToTextLayer = null;
  11929. }
  11930. #walk(node) {
  11931. if (!node) {
  11932. return null;
  11933. }
  11934. const element = document.createElement("span");
  11935. if ("role" in node) {
  11936. const {
  11937. role
  11938. } = node;
  11939. const match = role.match(HEADING_PATTERN);
  11940. if (match) {
  11941. element.setAttribute("role", "heading");
  11942. element.setAttribute("aria-level", match[1]);
  11943. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  11944. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  11945. }
  11946. if (role === "Figure" && this.#addImageInTextLayer(node, element)) {
  11947. return element;
  11948. }
  11949. }
  11950. this.#setAttributes(node, element);
  11951. if (node.children) {
  11952. if (node.children.length === 1 && "id" in node.children[0]) {
  11953. this.#setAttributes(node.children[0], element);
  11954. } else {
  11955. for (const kid of node.children) {
  11956. element.append(this.#walk(kid));
  11957. }
  11958. }
  11959. }
  11960. return element;
  11961. }
  11962. }
  11963. ;// ./web/text_accessibility.js
  11964. class TextAccessibilityManager {
  11965. #enabled = false;
  11966. #textChildren = null;
  11967. #textNodes = new Map();
  11968. #waitingElements = new Map();
  11969. setTextMapping(textDivs) {
  11970. this.#textChildren = textDivs;
  11971. }
  11972. static #compareElementPositions(e1, e2) {
  11973. const rect1 = e1.getBoundingClientRect();
  11974. const rect2 = e2.getBoundingClientRect();
  11975. if (rect1.width === 0 && rect1.height === 0) {
  11976. return +1;
  11977. }
  11978. if (rect2.width === 0 && rect2.height === 0) {
  11979. return -1;
  11980. }
  11981. const top1 = rect1.y;
  11982. const bot1 = rect1.y + rect1.height;
  11983. const mid1 = rect1.y + rect1.height / 2;
  11984. const top2 = rect2.y;
  11985. const bot2 = rect2.y + rect2.height;
  11986. const mid2 = rect2.y + rect2.height / 2;
  11987. if (mid1 <= top2 && mid2 >= bot1) {
  11988. return -1;
  11989. }
  11990. if (mid2 <= top1 && mid1 >= bot2) {
  11991. return +1;
  11992. }
  11993. const centerX1 = rect1.x + rect1.width / 2;
  11994. const centerX2 = rect2.x + rect2.width / 2;
  11995. return centerX1 - centerX2;
  11996. }
  11997. enable() {
  11998. if (this.#enabled) {
  11999. throw new Error("TextAccessibilityManager is already enabled.");
  12000. }
  12001. if (!this.#textChildren) {
  12002. throw new Error("Text divs and strings have not been set.");
  12003. }
  12004. this.#enabled = true;
  12005. this.#textChildren = this.#textChildren.slice();
  12006. this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
  12007. if (this.#textNodes.size > 0) {
  12008. const textChildren = this.#textChildren;
  12009. for (const [id, nodeIndex] of this.#textNodes) {
  12010. const element = document.getElementById(id);
  12011. if (!element) {
  12012. this.#textNodes.delete(id);
  12013. continue;
  12014. }
  12015. this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
  12016. }
  12017. }
  12018. for (const [element, isRemovable] of this.#waitingElements) {
  12019. this.addPointerInTextLayer(element, isRemovable);
  12020. }
  12021. this.#waitingElements.clear();
  12022. }
  12023. disable() {
  12024. if (!this.#enabled) {
  12025. return;
  12026. }
  12027. this.#waitingElements.clear();
  12028. this.#textChildren = null;
  12029. this.#enabled = false;
  12030. }
  12031. removePointerInTextLayer(element) {
  12032. if (!this.#enabled) {
  12033. this.#waitingElements.delete(element);
  12034. return;
  12035. }
  12036. const children = this.#textChildren;
  12037. if (!children || children.length === 0) {
  12038. return;
  12039. }
  12040. const {
  12041. id
  12042. } = element;
  12043. const nodeIndex = this.#textNodes.get(id);
  12044. if (nodeIndex === undefined) {
  12045. return;
  12046. }
  12047. const node = children[nodeIndex];
  12048. this.#textNodes.delete(id);
  12049. let owns = node.getAttribute("aria-owns");
  12050. if (owns?.includes(id)) {
  12051. owns = owns.split(" ").filter(x => x !== id).join(" ");
  12052. if (owns) {
  12053. node.setAttribute("aria-owns", owns);
  12054. } else {
  12055. node.removeAttribute("aria-owns");
  12056. node.setAttribute("role", "presentation");
  12057. }
  12058. }
  12059. }
  12060. #addIdToAriaOwns(id, node) {
  12061. const owns = node.getAttribute("aria-owns");
  12062. if (!owns?.includes(id)) {
  12063. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  12064. }
  12065. node.removeAttribute("role");
  12066. }
  12067. addPointerInTextLayer(element, isRemovable) {
  12068. const {
  12069. id
  12070. } = element;
  12071. if (!id) {
  12072. return null;
  12073. }
  12074. if (!this.#enabled) {
  12075. this.#waitingElements.set(element, isRemovable);
  12076. return null;
  12077. }
  12078. if (isRemovable) {
  12079. this.removePointerInTextLayer(element);
  12080. }
  12081. const children = this.#textChildren;
  12082. if (!children || children.length === 0) {
  12083. return null;
  12084. }
  12085. const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
  12086. const nodeIndex = Math.max(0, index - 1);
  12087. const child = children[nodeIndex];
  12088. this.#addIdToAriaOwns(id, child);
  12089. this.#textNodes.set(id, nodeIndex);
  12090. const parent = child.parentNode;
  12091. return parent?.classList.contains("markedContent") ? parent.id : null;
  12092. }
  12093. moveElementInDOM(container, element, contentElement, isRemovable) {
  12094. const id = this.addPointerInTextLayer(contentElement, isRemovable);
  12095. if (!container.hasChildNodes()) {
  12096. container.append(element);
  12097. return id;
  12098. }
  12099. const children = Array.from(container.childNodes).filter(node => node !== element);
  12100. if (children.length === 0) {
  12101. return id;
  12102. }
  12103. const elementToCompare = contentElement || element;
  12104. const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
  12105. if (index === 0) {
  12106. children[0].before(element);
  12107. } else {
  12108. children[index - 1].after(element);
  12109. }
  12110. return id;
  12111. }
  12112. }
  12113. ;// ./web/text_highlighter.js
  12114. class TextHighlighter {
  12115. #eventAbortController = null;
  12116. constructor({
  12117. findController,
  12118. eventBus,
  12119. pageIndex
  12120. }) {
  12121. this.findController = findController;
  12122. this.matches = [];
  12123. this.eventBus = eventBus;
  12124. this.pageIdx = pageIndex;
  12125. this.textDivs = null;
  12126. this.textContentItemsStr = null;
  12127. this.enabled = false;
  12128. }
  12129. setTextMapping(divs, texts) {
  12130. this.textDivs = divs;
  12131. this.textContentItemsStr = texts;
  12132. }
  12133. enable() {
  12134. if (!this.textDivs || !this.textContentItemsStr) {
  12135. throw new Error("Text divs and strings have not been set.");
  12136. }
  12137. if (this.enabled) {
  12138. throw new Error("TextHighlighter is already enabled.");
  12139. }
  12140. this.enabled = true;
  12141. if (!this.#eventAbortController) {
  12142. this.#eventAbortController = new AbortController();
  12143. this.eventBus._on("updatetextlayermatches", evt => {
  12144. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  12145. this._updateMatches();
  12146. }
  12147. }, {
  12148. signal: this.#eventAbortController.signal
  12149. });
  12150. }
  12151. this._updateMatches();
  12152. }
  12153. disable() {
  12154. if (!this.enabled) {
  12155. return;
  12156. }
  12157. this.enabled = false;
  12158. this.#eventAbortController?.abort();
  12159. this.#eventAbortController = null;
  12160. this._updateMatches(true);
  12161. }
  12162. _convertMatches(matches, matchesLength) {
  12163. if (!matches) {
  12164. return [];
  12165. }
  12166. const {
  12167. textContentItemsStr
  12168. } = this;
  12169. let i = 0,
  12170. iIndex = 0;
  12171. const end = textContentItemsStr.length - 1;
  12172. const result = [];
  12173. for (let m = 0, mm = matches.length; m < mm; m++) {
  12174. let matchIdx = matches[m];
  12175. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  12176. iIndex += textContentItemsStr[i].length;
  12177. i++;
  12178. }
  12179. if (i === textContentItemsStr.length) {
  12180. console.error("Could not find a matching mapping");
  12181. }
  12182. const match = {
  12183. begin: {
  12184. divIdx: i,
  12185. offset: matchIdx - iIndex
  12186. }
  12187. };
  12188. matchIdx += matchesLength[m];
  12189. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  12190. iIndex += textContentItemsStr[i].length;
  12191. i++;
  12192. }
  12193. match.end = {
  12194. divIdx: i,
  12195. offset: matchIdx - iIndex
  12196. };
  12197. result.push(match);
  12198. }
  12199. return result;
  12200. }
  12201. _renderMatches(matches) {
  12202. if (matches.length === 0) {
  12203. return;
  12204. }
  12205. const {
  12206. findController,
  12207. pageIdx
  12208. } = this;
  12209. const {
  12210. textContentItemsStr,
  12211. textDivs
  12212. } = this;
  12213. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  12214. const selectedMatchIdx = findController.selected.matchIdx;
  12215. const highlightAll = findController.state.highlightAll;
  12216. let prevEnd = null;
  12217. const infinity = {
  12218. divIdx: -1,
  12219. offset: undefined
  12220. };
  12221. function beginText(begin, className) {
  12222. const divIdx = begin.divIdx;
  12223. textDivs[divIdx].textContent = "";
  12224. return appendTextToDiv(divIdx, 0, begin.offset, className);
  12225. }
  12226. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12227. let div = textDivs[divIdx];
  12228. if (div.nodeType === Node.TEXT_NODE) {
  12229. const span = document.createElement("span");
  12230. div.before(span);
  12231. span.append(div);
  12232. textDivs[divIdx] = span;
  12233. div = span;
  12234. }
  12235. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  12236. const node = document.createTextNode(content);
  12237. if (className) {
  12238. const span = document.createElement("span");
  12239. span.className = `${className} appended`;
  12240. span.append(node);
  12241. div.append(span);
  12242. return className.includes("selected") ? span.offsetLeft : 0;
  12243. }
  12244. div.append(node);
  12245. return 0;
  12246. }
  12247. let i0 = selectedMatchIdx,
  12248. i1 = i0 + 1;
  12249. if (highlightAll) {
  12250. i0 = 0;
  12251. i1 = matches.length;
  12252. } else if (!isSelectedPage) {
  12253. return;
  12254. }
  12255. let lastDivIdx = -1;
  12256. let lastOffset = -1;
  12257. for (let i = i0; i < i1; i++) {
  12258. const match = matches[i];
  12259. const begin = match.begin;
  12260. if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
  12261. continue;
  12262. }
  12263. lastDivIdx = begin.divIdx;
  12264. lastOffset = begin.offset;
  12265. const end = match.end;
  12266. const isSelected = isSelectedPage && i === selectedMatchIdx;
  12267. const highlightSuffix = isSelected ? " selected" : "";
  12268. let selectedLeft = 0;
  12269. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12270. if (prevEnd !== null) {
  12271. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12272. }
  12273. beginText(begin);
  12274. } else {
  12275. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12276. }
  12277. if (begin.divIdx === end.divIdx) {
  12278. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  12279. } else {
  12280. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  12281. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  12282. textDivs[n0].className = "highlight middle" + highlightSuffix;
  12283. }
  12284. beginText(end, "highlight end" + highlightSuffix);
  12285. }
  12286. prevEnd = end;
  12287. if (isSelected) {
  12288. findController.scrollMatchIntoView({
  12289. element: textDivs[begin.divIdx],
  12290. selectedLeft,
  12291. pageIndex: pageIdx,
  12292. matchIndex: selectedMatchIdx
  12293. });
  12294. }
  12295. }
  12296. if (prevEnd) {
  12297. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12298. }
  12299. }
  12300. _updateMatches(reset = false) {
  12301. if (!this.enabled && !reset) {
  12302. return;
  12303. }
  12304. const {
  12305. findController,
  12306. matches,
  12307. pageIdx
  12308. } = this;
  12309. const {
  12310. textContentItemsStr,
  12311. textDivs
  12312. } = this;
  12313. let clearedUntilDivIdx = -1;
  12314. for (const match of matches) {
  12315. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12316. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  12317. const div = textDivs[n];
  12318. div.textContent = textContentItemsStr[n];
  12319. div.className = "";
  12320. }
  12321. clearedUntilDivIdx = match.end.divIdx + 1;
  12322. }
  12323. if (!findController?.highlightMatches || reset) {
  12324. return;
  12325. }
  12326. const pageMatches = findController.pageMatches[pageIdx] || null;
  12327. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  12328. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12329. this._renderMatches(this.matches);
  12330. }
  12331. }
  12332. ;// ./web/text_layer_builder.js
  12333. class TextLayerBuilder {
  12334. #enablePermissions = false;
  12335. #onAppend = null;
  12336. #renderingDone = false;
  12337. #textLayer = null;
  12338. static #textLayers = new Map();
  12339. static #selectionChangeAbortController = null;
  12340. constructor({
  12341. pdfPage,
  12342. highlighter = null,
  12343. accessibilityManager = null,
  12344. enablePermissions = false,
  12345. onAppend = null
  12346. }) {
  12347. this.pdfPage = pdfPage;
  12348. this.highlighter = highlighter;
  12349. this.accessibilityManager = accessibilityManager;
  12350. this.#enablePermissions = enablePermissions === true;
  12351. this.#onAppend = onAppend;
  12352. this.div = document.createElement("div");
  12353. this.div.tabIndex = 0;
  12354. this.div.className = "textLayer";
  12355. }
  12356. async render(viewport, textContentParams = null) {
  12357. if (this.#renderingDone && this.#textLayer) {
  12358. this.#textLayer.update({
  12359. viewport,
  12360. onBefore: this.hide.bind(this)
  12361. });
  12362. this.show();
  12363. return;
  12364. }
  12365. this.cancel();
  12366. this.#textLayer = new TextLayer({
  12367. textContentSource: this.pdfPage.streamTextContent(textContentParams || {
  12368. includeMarkedContent: true,
  12369. disableNormalization: true
  12370. }),
  12371. container: this.div,
  12372. viewport
  12373. });
  12374. const {
  12375. textDivs,
  12376. textContentItemsStr
  12377. } = this.#textLayer;
  12378. this.highlighter?.setTextMapping(textDivs, textContentItemsStr);
  12379. this.accessibilityManager?.setTextMapping(textDivs);
  12380. await this.#textLayer.render();
  12381. this.#renderingDone = true;
  12382. const endOfContent = document.createElement("div");
  12383. endOfContent.className = "endOfContent";
  12384. this.div.append(endOfContent);
  12385. this.#bindMouse(endOfContent);
  12386. this.#onAppend?.(this.div);
  12387. this.highlighter?.enable();
  12388. this.accessibilityManager?.enable();
  12389. }
  12390. hide() {
  12391. if (!this.div.hidden && this.#renderingDone) {
  12392. this.highlighter?.disable();
  12393. this.div.hidden = true;
  12394. }
  12395. }
  12396. show() {
  12397. if (this.div.hidden && this.#renderingDone) {
  12398. this.div.hidden = false;
  12399. this.highlighter?.enable();
  12400. }
  12401. }
  12402. cancel() {
  12403. this.#textLayer?.cancel();
  12404. this.#textLayer = null;
  12405. this.highlighter?.disable();
  12406. this.accessibilityManager?.disable();
  12407. TextLayerBuilder.#removeGlobalSelectionListener(this.div);
  12408. }
  12409. #bindMouse(end) {
  12410. const {
  12411. div
  12412. } = this;
  12413. div.addEventListener("mousedown", () => {
  12414. div.classList.add("selecting");
  12415. });
  12416. div.addEventListener("copy", event => {
  12417. if (!this.#enablePermissions) {
  12418. const selection = document.getSelection();
  12419. event.clipboardData.setData("text/plain", removeNullCharacters(normalizeUnicode(selection.toString())));
  12420. }
  12421. event.preventDefault();
  12422. event.stopPropagation();
  12423. });
  12424. TextLayerBuilder.#textLayers.set(div, end);
  12425. TextLayerBuilder.#enableGlobalSelectionListener();
  12426. }
  12427. static #removeGlobalSelectionListener(textLayerDiv) {
  12428. this.#textLayers.delete(textLayerDiv);
  12429. if (this.#textLayers.size === 0) {
  12430. this.#selectionChangeAbortController?.abort();
  12431. this.#selectionChangeAbortController = null;
  12432. }
  12433. }
  12434. static #enableGlobalSelectionListener() {
  12435. if (this.#selectionChangeAbortController) {
  12436. return;
  12437. }
  12438. this.#selectionChangeAbortController = new AbortController();
  12439. const {
  12440. signal
  12441. } = this.#selectionChangeAbortController;
  12442. const reset = (end, textLayer) => {
  12443. textLayer.append(end);
  12444. end.style.width = "";
  12445. end.style.height = "";
  12446. textLayer.classList.remove("selecting");
  12447. };
  12448. let isPointerDown = false;
  12449. document.addEventListener("pointerdown", () => {
  12450. isPointerDown = true;
  12451. }, {
  12452. signal
  12453. });
  12454. document.addEventListener("pointerup", () => {
  12455. isPointerDown = false;
  12456. this.#textLayers.forEach(reset);
  12457. }, {
  12458. signal
  12459. });
  12460. window.addEventListener("blur", () => {
  12461. isPointerDown = false;
  12462. this.#textLayers.forEach(reset);
  12463. }, {
  12464. signal
  12465. });
  12466. document.addEventListener("keyup", () => {
  12467. if (!isPointerDown) {
  12468. this.#textLayers.forEach(reset);
  12469. }
  12470. }, {
  12471. signal
  12472. });
  12473. var isFirefox, prevRange;
  12474. document.addEventListener("selectionchange", () => {
  12475. const selection = document.getSelection();
  12476. if (selection.rangeCount === 0) {
  12477. this.#textLayers.forEach(reset);
  12478. return;
  12479. }
  12480. const activeTextLayers = new Set();
  12481. for (let i = 0; i < selection.rangeCount; i++) {
  12482. const range = selection.getRangeAt(i);
  12483. for (const textLayerDiv of this.#textLayers.keys()) {
  12484. if (!activeTextLayers.has(textLayerDiv) && range.intersectsNode(textLayerDiv)) {
  12485. activeTextLayers.add(textLayerDiv);
  12486. }
  12487. }
  12488. }
  12489. for (const [textLayerDiv, endDiv] of this.#textLayers) {
  12490. if (activeTextLayers.has(textLayerDiv)) {
  12491. textLayerDiv.classList.add("selecting");
  12492. } else {
  12493. reset(endDiv, textLayerDiv);
  12494. }
  12495. }
  12496. isFirefox ??= getComputedStyle(this.#textLayers.values().next().value).getPropertyValue("-moz-user-select") === "none";
  12497. if (isFirefox) {
  12498. return;
  12499. }
  12500. const range = selection.getRangeAt(0);
  12501. const modifyStart = prevRange && (range.compareBoundaryPoints(Range.END_TO_END, prevRange) === 0 || range.compareBoundaryPoints(Range.START_TO_END, prevRange) === 0);
  12502. let anchor = modifyStart ? range.startContainer : range.endContainer;
  12503. if (anchor.nodeType === Node.TEXT_NODE) {
  12504. anchor = anchor.parentNode;
  12505. }
  12506. const parentTextLayer = anchor.parentElement.closest(".textLayer");
  12507. const endDiv = this.#textLayers.get(parentTextLayer);
  12508. if (endDiv) {
  12509. endDiv.style.width = parentTextLayer.style.width;
  12510. endDiv.style.height = parentTextLayer.style.height;
  12511. anchor.parentElement.insertBefore(endDiv, modifyStart ? anchor : anchor.nextSibling);
  12512. }
  12513. prevRange = range.cloneRange();
  12514. }, {
  12515. signal
  12516. });
  12517. }
  12518. }
  12519. ;// ./web/pdf_page_view.js
  12520. const DEFAULT_LAYER_PROPERTIES = null;
  12521. const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]);
  12522. class PDFPageView {
  12523. #annotationMode = AnnotationMode.ENABLE_FORMS;
  12524. #enableHWA = false;
  12525. #hasRestrictedScaling = false;
  12526. #isEditing = false;
  12527. #layerProperties = null;
  12528. #loadingId = null;
  12529. #previousRotation = null;
  12530. #scaleRoundX = 1;
  12531. #scaleRoundY = 1;
  12532. #renderError = null;
  12533. #renderingState = RenderingStates.INITIAL;
  12534. #textLayerMode = TextLayerMode.ENABLE;
  12535. #useThumbnailCanvas = {
  12536. directDrawing: true,
  12537. initialOptionalContent: true,
  12538. regularAnnotations: true
  12539. };
  12540. #viewportMap = new WeakMap();
  12541. #layers = [null, null, null, null];
  12542. constructor(options) {
  12543. const container = options.container;
  12544. const defaultViewport = options.defaultViewport;
  12545. this.id = options.id;
  12546. this.renderingId = "page" + this.id;
  12547. this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
  12548. this.pdfPage = null;
  12549. this.pageLabel = null;
  12550. this.rotation = 0;
  12551. this.scale = options.scale || DEFAULT_SCALE;
  12552. this.viewport = defaultViewport;
  12553. this.pdfPageRotate = defaultViewport.rotation;
  12554. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  12555. this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE;
  12556. this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS;
  12557. this.imageResourcesPath = options.imageResourcesPath || "";
  12558. this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels");
  12559. this.pageColors = options.pageColors || null;
  12560. this.#enableHWA = options.enableHWA || false;
  12561. this.eventBus = options.eventBus;
  12562. this.renderingQueue = options.renderingQueue;
  12563. this.l10n = options.l10n;
  12564. this.l10n ||= new genericl10n_GenericL10n();
  12565. this.renderTask = null;
  12566. this.resume = null;
  12567. this._isStandalone = !this.renderingQueue?.hasViewer();
  12568. this._container = container;
  12569. this._annotationCanvasMap = null;
  12570. this.annotationLayer = null;
  12571. this.annotationEditorLayer = null;
  12572. this.textLayer = null;
  12573. this.zoomLayer = null;
  12574. this.xfaLayer = null;
  12575. this.structTreeLayer = null;
  12576. this.drawLayer = null;
  12577. const div = document.createElement("div");
  12578. div.className = "page";
  12579. div.setAttribute("data-page-number", this.id);
  12580. div.setAttribute("role", "region");
  12581. div.setAttribute("data-l10n-id", "pdfjs-page-landmark");
  12582. div.setAttribute("data-l10n-args", JSON.stringify({
  12583. page: this.id
  12584. }));
  12585. this.div = div;
  12586. this.#setDimensions();
  12587. container?.append(div);
  12588. if (this._isStandalone) {
  12589. container?.style.setProperty("--scale-factor", this.scale * PixelsPerInch.PDF_TO_CSS_UNITS);
  12590. if (this.pageColors?.background) {
  12591. container?.style.setProperty("--page-bg-color", this.pageColors.background);
  12592. }
  12593. const {
  12594. optionalContentConfigPromise
  12595. } = options;
  12596. if (optionalContentConfigPromise) {
  12597. optionalContentConfigPromise.then(optionalContentConfig => {
  12598. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12599. return;
  12600. }
  12601. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12602. });
  12603. }
  12604. if (!options.l10n) {
  12605. this.l10n.translate(this.div);
  12606. }
  12607. }
  12608. }
  12609. #addLayer(div, name) {
  12610. const pos = LAYERS_ORDER.get(name);
  12611. const oldDiv = this.#layers[pos];
  12612. this.#layers[pos] = div;
  12613. if (oldDiv) {
  12614. oldDiv.replaceWith(div);
  12615. return;
  12616. }
  12617. for (let i = pos - 1; i >= 0; i--) {
  12618. const layer = this.#layers[i];
  12619. if (layer) {
  12620. layer.after(div);
  12621. return;
  12622. }
  12623. }
  12624. this.div.prepend(div);
  12625. }
  12626. get renderingState() {
  12627. return this.#renderingState;
  12628. }
  12629. set renderingState(state) {
  12630. if (state === this.#renderingState) {
  12631. return;
  12632. }
  12633. this.#renderingState = state;
  12634. if (this.#loadingId) {
  12635. clearTimeout(this.#loadingId);
  12636. this.#loadingId = null;
  12637. }
  12638. switch (state) {
  12639. case RenderingStates.PAUSED:
  12640. this.div.classList.remove("loading");
  12641. break;
  12642. case RenderingStates.RUNNING:
  12643. this.div.classList.add("loadingIcon");
  12644. this.#loadingId = setTimeout(() => {
  12645. this.div.classList.add("loading");
  12646. this.#loadingId = null;
  12647. }, 0);
  12648. break;
  12649. case RenderingStates.INITIAL:
  12650. case RenderingStates.FINISHED:
  12651. this.div.classList.remove("loadingIcon", "loading");
  12652. break;
  12653. }
  12654. }
  12655. #setDimensions() {
  12656. const {
  12657. viewport
  12658. } = this;
  12659. if (this.pdfPage) {
  12660. if (this.#previousRotation === viewport.rotation) {
  12661. return;
  12662. }
  12663. this.#previousRotation = viewport.rotation;
  12664. }
  12665. setLayerDimensions(this.div, viewport, true, false);
  12666. }
  12667. setPdfPage(pdfPage) {
  12668. if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
  12669. this._container?.style.setProperty("--hcm-highlight-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
  12670. this._container?.style.setProperty("--hcm-highlight-selected-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "Highlight"));
  12671. }
  12672. this.pdfPage = pdfPage;
  12673. this.pdfPageRotate = pdfPage.rotate;
  12674. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12675. this.viewport = pdfPage.getViewport({
  12676. scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS,
  12677. rotation: totalRotation
  12678. });
  12679. this.#setDimensions();
  12680. this.reset();
  12681. }
  12682. destroy() {
  12683. this.reset();
  12684. this.pdfPage?.cleanup();
  12685. }
  12686. hasEditableAnnotations() {
  12687. return !!this.annotationLayer?.hasEditableAnnotations();
  12688. }
  12689. get _textHighlighter() {
  12690. return shadow(this, "_textHighlighter", new TextHighlighter({
  12691. pageIndex: this.id - 1,
  12692. eventBus: this.eventBus,
  12693. findController: this.#layerProperties.findController
  12694. }));
  12695. }
  12696. #dispatchLayerRendered(name, error) {
  12697. this.eventBus.dispatch(name, {
  12698. source: this,
  12699. pageNumber: this.id,
  12700. error
  12701. });
  12702. }
  12703. async #renderAnnotationLayer() {
  12704. let error = null;
  12705. try {
  12706. await this.annotationLayer.render(this.viewport, {
  12707. structTreeLayer: this.structTreeLayer
  12708. }, "display");
  12709. } catch (ex) {
  12710. console.error(`#renderAnnotationLayer: "${ex}".`);
  12711. error = ex;
  12712. } finally {
  12713. this.#dispatchLayerRendered("annotationlayerrendered", error);
  12714. }
  12715. }
  12716. async #renderAnnotationEditorLayer() {
  12717. let error = null;
  12718. try {
  12719. await this.annotationEditorLayer.render(this.viewport, "display");
  12720. } catch (ex) {
  12721. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  12722. error = ex;
  12723. } finally {
  12724. this.#dispatchLayerRendered("annotationeditorlayerrendered", error);
  12725. }
  12726. }
  12727. async #renderDrawLayer() {
  12728. try {
  12729. await this.drawLayer.render("display");
  12730. } catch (ex) {
  12731. console.error(`#renderDrawLayer: "${ex}".`);
  12732. }
  12733. }
  12734. async #renderXfaLayer() {
  12735. let error = null;
  12736. try {
  12737. const result = await this.xfaLayer.render(this.viewport, "display");
  12738. if (result?.textDivs && this._textHighlighter) {
  12739. this.#buildXfaTextContentItems(result.textDivs);
  12740. }
  12741. } catch (ex) {
  12742. console.error(`#renderXfaLayer: "${ex}".`);
  12743. error = ex;
  12744. } finally {
  12745. if (this.xfaLayer?.div) {
  12746. this.l10n.pause();
  12747. this.#addLayer(this.xfaLayer.div, "xfaLayer");
  12748. this.l10n.resume();
  12749. }
  12750. this.#dispatchLayerRendered("xfalayerrendered", error);
  12751. }
  12752. }
  12753. async #renderTextLayer() {
  12754. if (!this.textLayer) {
  12755. return;
  12756. }
  12757. let error = null;
  12758. try {
  12759. await this.textLayer.render(this.viewport);
  12760. } catch (ex) {
  12761. if (ex instanceof AbortException) {
  12762. return;
  12763. }
  12764. console.error(`#renderTextLayer: "${ex}".`);
  12765. error = ex;
  12766. }
  12767. this.#dispatchLayerRendered("textlayerrendered", error);
  12768. this.#renderStructTreeLayer();
  12769. }
  12770. async #renderStructTreeLayer() {
  12771. if (!this.textLayer) {
  12772. return;
  12773. }
  12774. const treeDom = await this.structTreeLayer?.render();
  12775. if (treeDom) {
  12776. this.l10n.pause();
  12777. this.structTreeLayer?.addElementsToTextLayer();
  12778. if (this.canvas && treeDom.parentNode !== this.canvas) {
  12779. this.canvas.append(treeDom);
  12780. }
  12781. this.l10n.resume();
  12782. }
  12783. this.structTreeLayer?.show();
  12784. }
  12785. async #buildXfaTextContentItems(textDivs) {
  12786. const text = await this.pdfPage.getTextContent();
  12787. const items = [];
  12788. for (const item of text.items) {
  12789. items.push(item.str);
  12790. }
  12791. this._textHighlighter.setTextMapping(textDivs, items);
  12792. this._textHighlighter.enable();
  12793. }
  12794. _resetZoomLayer(removeFromDOM = false) {
  12795. if (!this.zoomLayer) {
  12796. return;
  12797. }
  12798. const zoomLayerCanvas = this.zoomLayer.firstChild;
  12799. this.#viewportMap.delete(zoomLayerCanvas);
  12800. zoomLayerCanvas.width = 0;
  12801. zoomLayerCanvas.height = 0;
  12802. if (removeFromDOM) {
  12803. this.zoomLayer.remove();
  12804. }
  12805. this.zoomLayer = null;
  12806. }
  12807. reset({
  12808. keepZoomLayer = false,
  12809. keepAnnotationLayer = false,
  12810. keepAnnotationEditorLayer = false,
  12811. keepXfaLayer = false,
  12812. keepTextLayer = false
  12813. } = {}) {
  12814. this.cancelRendering({
  12815. keepAnnotationLayer,
  12816. keepAnnotationEditorLayer,
  12817. keepXfaLayer,
  12818. keepTextLayer
  12819. });
  12820. this.renderingState = RenderingStates.INITIAL;
  12821. const div = this.div;
  12822. const childNodes = div.childNodes,
  12823. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  12824. annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
  12825. annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
  12826. xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
  12827. textLayerNode = keepTextLayer && this.textLayer?.div || null;
  12828. for (let i = childNodes.length - 1; i >= 0; i--) {
  12829. const node = childNodes[i];
  12830. switch (node) {
  12831. case zoomLayerNode:
  12832. case annotationLayerNode:
  12833. case annotationEditorLayerNode:
  12834. case xfaLayerNode:
  12835. case textLayerNode:
  12836. continue;
  12837. }
  12838. node.remove();
  12839. const layerIndex = this.#layers.indexOf(node);
  12840. if (layerIndex >= 0) {
  12841. this.#layers[layerIndex] = null;
  12842. }
  12843. }
  12844. div.removeAttribute("data-loaded");
  12845. if (annotationLayerNode) {
  12846. this.annotationLayer.hide();
  12847. }
  12848. if (annotationEditorLayerNode) {
  12849. this.annotationEditorLayer.hide();
  12850. }
  12851. if (xfaLayerNode) {
  12852. this.xfaLayer.hide();
  12853. }
  12854. if (textLayerNode) {
  12855. this.textLayer.hide();
  12856. }
  12857. this.structTreeLayer?.hide();
  12858. if (!zoomLayerNode) {
  12859. if (this.canvas) {
  12860. this.#viewportMap.delete(this.canvas);
  12861. this.canvas.width = 0;
  12862. this.canvas.height = 0;
  12863. delete this.canvas;
  12864. }
  12865. this._resetZoomLayer();
  12866. }
  12867. }
  12868. toggleEditingMode(isEditing) {
  12869. if (!this.hasEditableAnnotations()) {
  12870. return;
  12871. }
  12872. this.#isEditing = isEditing;
  12873. this.reset({
  12874. keepZoomLayer: true,
  12875. keepAnnotationLayer: true,
  12876. keepAnnotationEditorLayer: true,
  12877. keepXfaLayer: true,
  12878. keepTextLayer: true
  12879. });
  12880. }
  12881. update({
  12882. scale = 0,
  12883. rotation = null,
  12884. optionalContentConfigPromise = null,
  12885. drawingDelay = -1
  12886. }) {
  12887. this.scale = scale || this.scale;
  12888. if (typeof rotation === "number") {
  12889. this.rotation = rotation;
  12890. }
  12891. if (optionalContentConfigPromise instanceof Promise) {
  12892. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12893. optionalContentConfigPromise.then(optionalContentConfig => {
  12894. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12895. return;
  12896. }
  12897. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12898. });
  12899. }
  12900. this.#useThumbnailCanvas.directDrawing = true;
  12901. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12902. this.viewport = this.viewport.clone({
  12903. scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS,
  12904. rotation: totalRotation
  12905. });
  12906. this.#setDimensions();
  12907. if (this._isStandalone) {
  12908. this._container?.style.setProperty("--scale-factor", this.viewport.scale);
  12909. }
  12910. if (this.canvas) {
  12911. let onlyCssZoom = false;
  12912. if (this.#hasRestrictedScaling) {
  12913. if (this.maxCanvasPixels === 0) {
  12914. onlyCssZoom = true;
  12915. } else if (this.maxCanvasPixels > 0) {
  12916. const {
  12917. width,
  12918. height
  12919. } = this.viewport;
  12920. const {
  12921. sx,
  12922. sy
  12923. } = this.outputScale;
  12924. onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
  12925. }
  12926. }
  12927. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  12928. if (postponeDrawing || onlyCssZoom) {
  12929. if (postponeDrawing && !onlyCssZoom && this.renderingState !== RenderingStates.FINISHED) {
  12930. this.cancelRendering({
  12931. keepZoomLayer: true,
  12932. keepAnnotationLayer: true,
  12933. keepAnnotationEditorLayer: true,
  12934. keepXfaLayer: true,
  12935. keepTextLayer: true,
  12936. cancelExtraDelay: drawingDelay
  12937. });
  12938. this.renderingState = RenderingStates.FINISHED;
  12939. this.#useThumbnailCanvas.directDrawing = false;
  12940. }
  12941. this.cssTransform({
  12942. target: this.canvas,
  12943. redrawAnnotationLayer: true,
  12944. redrawAnnotationEditorLayer: true,
  12945. redrawXfaLayer: true,
  12946. redrawTextLayer: !postponeDrawing,
  12947. hideTextLayer: postponeDrawing
  12948. });
  12949. if (postponeDrawing) {
  12950. return;
  12951. }
  12952. this.eventBus.dispatch("pagerendered", {
  12953. source: this,
  12954. pageNumber: this.id,
  12955. cssTransform: true,
  12956. timestamp: performance.now(),
  12957. error: this.#renderError
  12958. });
  12959. return;
  12960. }
  12961. if (!this.zoomLayer && !this.canvas.hidden) {
  12962. this.zoomLayer = this.canvas.parentNode;
  12963. this.zoomLayer.style.position = "absolute";
  12964. }
  12965. }
  12966. if (this.zoomLayer) {
  12967. this.cssTransform({
  12968. target: this.zoomLayer.firstChild
  12969. });
  12970. }
  12971. this.reset({
  12972. keepZoomLayer: true,
  12973. keepAnnotationLayer: true,
  12974. keepAnnotationEditorLayer: true,
  12975. keepXfaLayer: true,
  12976. keepTextLayer: true
  12977. });
  12978. }
  12979. cancelRendering({
  12980. keepAnnotationLayer = false,
  12981. keepAnnotationEditorLayer = false,
  12982. keepXfaLayer = false,
  12983. keepTextLayer = false,
  12984. cancelExtraDelay = 0
  12985. } = {}) {
  12986. if (this.renderTask) {
  12987. this.renderTask.cancel(cancelExtraDelay);
  12988. this.renderTask = null;
  12989. }
  12990. this.resume = null;
  12991. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  12992. this.textLayer.cancel();
  12993. this.textLayer = null;
  12994. }
  12995. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  12996. this.annotationLayer.cancel();
  12997. this.annotationLayer = null;
  12998. this._annotationCanvasMap = null;
  12999. }
  13000. if (this.structTreeLayer && !this.textLayer) {
  13001. this.structTreeLayer = null;
  13002. }
  13003. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  13004. if (this.drawLayer) {
  13005. this.drawLayer.cancel();
  13006. this.drawLayer = null;
  13007. }
  13008. this.annotationEditorLayer.cancel();
  13009. this.annotationEditorLayer = null;
  13010. }
  13011. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  13012. this.xfaLayer.cancel();
  13013. this.xfaLayer = null;
  13014. this._textHighlighter?.disable();
  13015. }
  13016. }
  13017. cssTransform({
  13018. target,
  13019. redrawAnnotationLayer = false,
  13020. redrawAnnotationEditorLayer = false,
  13021. redrawXfaLayer = false,
  13022. redrawTextLayer = false,
  13023. hideTextLayer = false
  13024. }) {
  13025. if (!target.hasAttribute("zooming")) {
  13026. target.setAttribute("zooming", true);
  13027. const {
  13028. style
  13029. } = target;
  13030. style.width = style.height = "";
  13031. }
  13032. const originalViewport = this.#viewportMap.get(target);
  13033. if (this.viewport !== originalViewport) {
  13034. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  13035. const absRotation = Math.abs(relativeRotation);
  13036. let scaleX = 1,
  13037. scaleY = 1;
  13038. if (absRotation === 90 || absRotation === 270) {
  13039. const {
  13040. width,
  13041. height
  13042. } = this.viewport;
  13043. scaleX = height / width;
  13044. scaleY = width / height;
  13045. }
  13046. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  13047. }
  13048. if (redrawAnnotationLayer && this.annotationLayer) {
  13049. this.#renderAnnotationLayer();
  13050. }
  13051. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  13052. if (this.drawLayer) {
  13053. this.#renderDrawLayer();
  13054. }
  13055. this.#renderAnnotationEditorLayer();
  13056. }
  13057. if (redrawXfaLayer && this.xfaLayer) {
  13058. this.#renderXfaLayer();
  13059. }
  13060. if (this.textLayer) {
  13061. if (hideTextLayer) {
  13062. this.textLayer.hide();
  13063. this.structTreeLayer?.hide();
  13064. } else if (redrawTextLayer) {
  13065. this.#renderTextLayer();
  13066. }
  13067. }
  13068. }
  13069. get width() {
  13070. return this.viewport.width;
  13071. }
  13072. get height() {
  13073. return this.viewport.height;
  13074. }
  13075. getPagePoint(x, y) {
  13076. return this.viewport.convertToPdfPoint(x, y);
  13077. }
  13078. async #finishRenderTask(renderTask, error = null) {
  13079. if (renderTask === this.renderTask) {
  13080. this.renderTask = null;
  13081. }
  13082. if (error instanceof RenderingCancelledException) {
  13083. this.#renderError = null;
  13084. return;
  13085. }
  13086. this.#renderError = error;
  13087. this.renderingState = RenderingStates.FINISHED;
  13088. this._resetZoomLayer(true);
  13089. this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
  13090. this.eventBus.dispatch("pagerendered", {
  13091. source: this,
  13092. pageNumber: this.id,
  13093. cssTransform: false,
  13094. timestamp: performance.now(),
  13095. error: this.#renderError
  13096. });
  13097. if (error) {
  13098. throw error;
  13099. }
  13100. }
  13101. async draw() {
  13102. if (this.renderingState !== RenderingStates.INITIAL) {
  13103. console.error("Must be in new state before drawing");
  13104. this.reset();
  13105. }
  13106. const {
  13107. div,
  13108. l10n,
  13109. pageColors,
  13110. pdfPage,
  13111. viewport
  13112. } = this;
  13113. if (!pdfPage) {
  13114. this.renderingState = RenderingStates.FINISHED;
  13115. throw new Error("pdfPage is not loaded");
  13116. }
  13117. this.renderingState = RenderingStates.RUNNING;
  13118. const canvasWrapper = document.createElement("div");
  13119. canvasWrapper.classList.add("canvasWrapper");
  13120. this.#addLayer(canvasWrapper, "canvasWrapper");
  13121. if (!this.textLayer && this.#textLayerMode !== TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  13122. this._accessibilityManager ||= new TextAccessibilityManager();
  13123. this.textLayer = new TextLayerBuilder({
  13124. pdfPage,
  13125. highlighter: this._textHighlighter,
  13126. accessibilityManager: this._accessibilityManager,
  13127. enablePermissions: this.#textLayerMode === TextLayerMode.ENABLE_PERMISSIONS,
  13128. onAppend: textLayerDiv => {
  13129. this.l10n.pause();
  13130. this.#addLayer(textLayerDiv, "textLayer");
  13131. this.l10n.resume();
  13132. }
  13133. });
  13134. }
  13135. if (!this.annotationLayer && this.#annotationMode !== AnnotationMode.DISABLE) {
  13136. const {
  13137. annotationStorage,
  13138. annotationEditorUIManager,
  13139. downloadManager,
  13140. enableScripting,
  13141. fieldObjectsPromise,
  13142. hasJSActionsPromise,
  13143. linkService
  13144. } = this.#layerProperties;
  13145. this._annotationCanvasMap ||= new Map();
  13146. this.annotationLayer = new AnnotationLayerBuilder({
  13147. pdfPage,
  13148. annotationStorage,
  13149. imageResourcesPath: this.imageResourcesPath,
  13150. renderForms: this.#annotationMode === AnnotationMode.ENABLE_FORMS,
  13151. linkService,
  13152. downloadManager,
  13153. enableScripting,
  13154. hasJSActionsPromise,
  13155. fieldObjectsPromise,
  13156. annotationCanvasMap: this._annotationCanvasMap,
  13157. accessibilityManager: this._accessibilityManager,
  13158. annotationEditorUIManager,
  13159. onAppend: annotationLayerDiv => {
  13160. this.#addLayer(annotationLayerDiv, "annotationLayer");
  13161. }
  13162. });
  13163. }
  13164. const renderContinueCallback = cont => {
  13165. showCanvas?.(false);
  13166. if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
  13167. this.renderingState = RenderingStates.PAUSED;
  13168. this.resume = () => {
  13169. this.renderingState = RenderingStates.RUNNING;
  13170. cont();
  13171. };
  13172. return;
  13173. }
  13174. cont();
  13175. };
  13176. const {
  13177. width,
  13178. height
  13179. } = viewport;
  13180. const canvas = document.createElement("canvas");
  13181. canvas.setAttribute("role", "presentation");
  13182. canvas.hidden = true;
  13183. const hasHCM = !!(pageColors?.background && pageColors?.foreground);
  13184. let showCanvas = isLastShow => {
  13185. if (!hasHCM || isLastShow) {
  13186. canvas.hidden = false;
  13187. showCanvas = null;
  13188. }
  13189. };
  13190. canvasWrapper.append(canvas);
  13191. this.canvas = canvas;
  13192. const ctx = canvas.getContext("2d", {
  13193. alpha: false,
  13194. willReadFrequently: !this.#enableHWA
  13195. });
  13196. const outputScale = this.outputScale = new OutputScale();
  13197. if (this.maxCanvasPixels === 0) {
  13198. const invScale = 1 / this.scale;
  13199. outputScale.sx *= invScale;
  13200. outputScale.sy *= invScale;
  13201. this.#hasRestrictedScaling = true;
  13202. } else if (this.maxCanvasPixels > 0) {
  13203. const pixelsInViewport = width * height;
  13204. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  13205. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  13206. outputScale.sx = maxScale;
  13207. outputScale.sy = maxScale;
  13208. this.#hasRestrictedScaling = true;
  13209. } else {
  13210. this.#hasRestrictedScaling = false;
  13211. }
  13212. }
  13213. const sfx = approximateFraction(outputScale.sx);
  13214. const sfy = approximateFraction(outputScale.sy);
  13215. const canvasWidth = canvas.width = floorToDivide(calcRound(width * outputScale.sx), sfx[0]);
  13216. const canvasHeight = canvas.height = floorToDivide(calcRound(height * outputScale.sy), sfy[0]);
  13217. const pageWidth = floorToDivide(calcRound(width), sfx[1]);
  13218. const pageHeight = floorToDivide(calcRound(height), sfy[1]);
  13219. outputScale.sx = canvasWidth / pageWidth;
  13220. outputScale.sy = canvasHeight / pageHeight;
  13221. if (this.#scaleRoundX !== sfx[1]) {
  13222. div.style.setProperty("--scale-round-x", `${sfx[1]}px`);
  13223. this.#scaleRoundX = sfx[1];
  13224. }
  13225. if (this.#scaleRoundY !== sfy[1]) {
  13226. div.style.setProperty("--scale-round-y", `${sfy[1]}px`);
  13227. this.#scaleRoundY = sfy[1];
  13228. }
  13229. this.#viewportMap.set(canvas, viewport);
  13230. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  13231. const renderContext = {
  13232. canvasContext: ctx,
  13233. transform,
  13234. viewport,
  13235. annotationMode: this.#annotationMode,
  13236. optionalContentConfigPromise: this._optionalContentConfigPromise,
  13237. annotationCanvasMap: this._annotationCanvasMap,
  13238. pageColors,
  13239. isEditing: this.#isEditing
  13240. };
  13241. const renderTask = this.renderTask = pdfPage.render(renderContext);
  13242. renderTask.onContinue = renderContinueCallback;
  13243. const resultPromise = renderTask.promise.then(async () => {
  13244. showCanvas?.(true);
  13245. await this.#finishRenderTask(renderTask);
  13246. this.structTreeLayer ||= new StructTreeLayerBuilder(pdfPage, viewport.rawDims);
  13247. this.#renderTextLayer();
  13248. if (this.annotationLayer) {
  13249. await this.#renderAnnotationLayer();
  13250. }
  13251. const {
  13252. annotationEditorUIManager
  13253. } = this.#layerProperties;
  13254. if (!annotationEditorUIManager) {
  13255. return;
  13256. }
  13257. this.drawLayer ||= new DrawLayerBuilder({
  13258. pageIndex: this.id
  13259. });
  13260. await this.#renderDrawLayer();
  13261. this.drawLayer.setParent(canvasWrapper);
  13262. this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({
  13263. uiManager: annotationEditorUIManager,
  13264. pdfPage,
  13265. l10n,
  13266. structTreeLayer: this.structTreeLayer,
  13267. accessibilityManager: this._accessibilityManager,
  13268. annotationLayer: this.annotationLayer?.annotationLayer,
  13269. textLayer: this.textLayer,
  13270. drawLayer: this.drawLayer.getDrawLayer(),
  13271. onAppend: annotationEditorLayerDiv => {
  13272. this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer");
  13273. }
  13274. });
  13275. this.#renderAnnotationEditorLayer();
  13276. }, error => {
  13277. if (!(error instanceof RenderingCancelledException)) {
  13278. showCanvas?.(true);
  13279. }
  13280. return this.#finishRenderTask(renderTask, error);
  13281. });
  13282. if (pdfPage.isPureXfa) {
  13283. if (!this.xfaLayer) {
  13284. const {
  13285. annotationStorage,
  13286. linkService
  13287. } = this.#layerProperties;
  13288. this.xfaLayer = new XfaLayerBuilder({
  13289. pdfPage,
  13290. annotationStorage,
  13291. linkService
  13292. });
  13293. }
  13294. this.#renderXfaLayer();
  13295. }
  13296. div.setAttribute("data-loaded", true);
  13297. this.eventBus.dispatch("pagerender", {
  13298. source: this,
  13299. pageNumber: this.id
  13300. });
  13301. return resultPromise;
  13302. }
  13303. setPageLabel(label) {
  13304. this.pageLabel = typeof label === "string" ? label : null;
  13305. this.div.setAttribute("data-l10n-args", JSON.stringify({
  13306. page: this.pageLabel ?? this.id
  13307. }));
  13308. if (this.pageLabel !== null) {
  13309. this.div.setAttribute("data-page-label", this.pageLabel);
  13310. } else {
  13311. this.div.removeAttribute("data-page-label");
  13312. }
  13313. }
  13314. get thumbnailCanvas() {
  13315. const {
  13316. directDrawing,
  13317. initialOptionalContent,
  13318. regularAnnotations
  13319. } = this.#useThumbnailCanvas;
  13320. return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
  13321. }
  13322. }
  13323. ;// ./web/pdf_viewer.js
  13324. const DEFAULT_CACHE_SIZE = 10;
  13325. const PagesCountLimit = {
  13326. FORCE_SCROLL_MODE_PAGE: 10000,
  13327. FORCE_LAZY_PAGE_INIT: 5000,
  13328. PAUSE_EAGER_PAGE_INIT: 250
  13329. };
  13330. function isValidAnnotationEditorMode(mode) {
  13331. return Object.values(AnnotationEditorType).includes(mode) && mode !== AnnotationEditorType.DISABLE;
  13332. }
  13333. class PDFPageViewBuffer {
  13334. #buf = new Set();
  13335. #size = 0;
  13336. constructor(size) {
  13337. this.#size = size;
  13338. }
  13339. push(view) {
  13340. const buf = this.#buf;
  13341. if (buf.has(view)) {
  13342. buf.delete(view);
  13343. }
  13344. buf.add(view);
  13345. if (buf.size > this.#size) {
  13346. this.#destroyFirstView();
  13347. }
  13348. }
  13349. resize(newSize, idsToKeep = null) {
  13350. this.#size = newSize;
  13351. const buf = this.#buf;
  13352. if (idsToKeep) {
  13353. const ii = buf.size;
  13354. let i = 1;
  13355. for (const view of buf) {
  13356. if (idsToKeep.has(view.id)) {
  13357. buf.delete(view);
  13358. buf.add(view);
  13359. }
  13360. if (++i > ii) {
  13361. break;
  13362. }
  13363. }
  13364. }
  13365. while (buf.size > this.#size) {
  13366. this.#destroyFirstView();
  13367. }
  13368. }
  13369. has(view) {
  13370. return this.#buf.has(view);
  13371. }
  13372. [Symbol.iterator]() {
  13373. return this.#buf.keys();
  13374. }
  13375. #destroyFirstView() {
  13376. const firstView = this.#buf.keys().next().value;
  13377. firstView?.destroy();
  13378. this.#buf.delete(firstView);
  13379. }
  13380. }
  13381. class PDFViewer {
  13382. #buffer = null;
  13383. #altTextManager = null;
  13384. #annotationEditorHighlightColors = null;
  13385. #annotationEditorMode = AnnotationEditorType.NONE;
  13386. #annotationEditorUIManager = null;
  13387. #annotationMode = AnnotationMode.ENABLE_FORMS;
  13388. #containerTopLeft = null;
  13389. #enableHWA = false;
  13390. #enableHighlightFloatingButton = false;
  13391. #enablePermissions = false;
  13392. #enableUpdatedAddImage = false;
  13393. #enableNewAltTextWhenAddingImage = false;
  13394. #eventAbortController = null;
  13395. #mlManager = null;
  13396. #switchAnnotationEditorModeAC = null;
  13397. #switchAnnotationEditorModeTimeoutId = null;
  13398. #getAllTextInProgress = false;
  13399. #hiddenCopyElement = null;
  13400. #interruptCopyCondition = false;
  13401. #previousContainerHeight = 0;
  13402. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  13403. #scrollModePageState = null;
  13404. #scaleTimeoutId = null;
  13405. #textLayerMode = TextLayerMode.ENABLE;
  13406. constructor(options) {
  13407. const viewerVersion = "4.7.76";
  13408. if (version !== viewerVersion) {
  13409. throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
  13410. }
  13411. this.container = options.container;
  13412. this.viewer = options.viewer || options.container.firstElementChild;
  13413. if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
  13414. throw new Error("Invalid `container` and/or `viewer` option.");
  13415. }
  13416. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  13417. throw new Error("The `container` must be absolutely positioned.");
  13418. }
  13419. this.#resizeObserver.observe(this.container);
  13420. this.eventBus = options.eventBus;
  13421. this.linkService = options.linkService || new SimpleLinkService();
  13422. this.downloadManager = options.downloadManager || null;
  13423. this.findController = options.findController || null;
  13424. this.#altTextManager = options.altTextManager || null;
  13425. if (this.findController) {
  13426. this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
  13427. }
  13428. this._scriptingManager = options.scriptingManager || null;
  13429. this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE;
  13430. this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS;
  13431. this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE;
  13432. this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
  13433. this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
  13434. this.#enableUpdatedAddImage = options.enableUpdatedAddImage === true;
  13435. this.#enableNewAltTextWhenAddingImage = options.enableNewAltTextWhenAddingImage === true;
  13436. this.imageResourcesPath = options.imageResourcesPath || "";
  13437. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  13438. this.removePageBorders = options.removePageBorders || false;
  13439. this.maxCanvasPixels = options.maxCanvasPixels;
  13440. this.l10n = options.l10n;
  13441. this.l10n ||= new genericl10n_GenericL10n();
  13442. this.#enablePermissions = options.enablePermissions || false;
  13443. this.pageColors = options.pageColors || null;
  13444. this.#mlManager = options.mlManager || null;
  13445. this.#enableHWA = options.enableHWA || false;
  13446. this.defaultRenderingQueue = !options.renderingQueue;
  13447. if (this.defaultRenderingQueue) {
  13448. this.renderingQueue = new PDFRenderingQueue();
  13449. this.renderingQueue.setViewer(this);
  13450. } else {
  13451. this.renderingQueue = options.renderingQueue;
  13452. }
  13453. const {
  13454. abortSignal
  13455. } = options;
  13456. abortSignal?.addEventListener("abort", () => {
  13457. this.#resizeObserver.disconnect();
  13458. this.#resizeObserver = null;
  13459. }, {
  13460. once: true
  13461. });
  13462. this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this), abortSignal);
  13463. this.presentationModeState = PresentationModeState.UNKNOWN;
  13464. this._resetView();
  13465. if (this.removePageBorders) {
  13466. this.viewer.classList.add("removePageBorders");
  13467. }
  13468. this.#updateContainerHeightCss();
  13469. this.eventBus._on("thumbnailrendered", ({
  13470. pageNumber,
  13471. pdfPage
  13472. }) => {
  13473. const pageView = this._pages[pageNumber - 1];
  13474. if (!this.#buffer.has(pageView)) {
  13475. pdfPage?.cleanup();
  13476. }
  13477. });
  13478. if (!options.l10n) {
  13479. this.l10n.translate(this.container);
  13480. }
  13481. }
  13482. get pagesCount() {
  13483. return this._pages.length;
  13484. }
  13485. getPageView(index) {
  13486. return this._pages[index];
  13487. }
  13488. getCachedPageViews() {
  13489. return new Set(this.#buffer);
  13490. }
  13491. get pageViewsReady() {
  13492. return this._pages.every(pageView => pageView?.pdfPage);
  13493. }
  13494. get renderForms() {
  13495. return this.#annotationMode === AnnotationMode.ENABLE_FORMS;
  13496. }
  13497. get enableScripting() {
  13498. return !!this._scriptingManager;
  13499. }
  13500. get currentPageNumber() {
  13501. return this._currentPageNumber;
  13502. }
  13503. set currentPageNumber(val) {
  13504. if (!Number.isInteger(val)) {
  13505. throw new Error("Invalid page number.");
  13506. }
  13507. if (!this.pdfDocument) {
  13508. return;
  13509. }
  13510. if (!this._setCurrentPageNumber(val, true)) {
  13511. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  13512. }
  13513. }
  13514. _setCurrentPageNumber(val, resetCurrentPageView = false) {
  13515. if (this._currentPageNumber === val) {
  13516. if (resetCurrentPageView) {
  13517. this.#resetCurrentPageView();
  13518. }
  13519. return true;
  13520. }
  13521. if (!(0 < val && val <= this.pagesCount)) {
  13522. return false;
  13523. }
  13524. const previous = this._currentPageNumber;
  13525. this._currentPageNumber = val;
  13526. this.eventBus.dispatch("pagechanging", {
  13527. source: this,
  13528. pageNumber: val,
  13529. pageLabel: this._pageLabels?.[val - 1] ?? null,
  13530. previous
  13531. });
  13532. if (resetCurrentPageView) {
  13533. this.#resetCurrentPageView();
  13534. }
  13535. return true;
  13536. }
  13537. get currentPageLabel() {
  13538. return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
  13539. }
  13540. set currentPageLabel(val) {
  13541. if (!this.pdfDocument) {
  13542. return;
  13543. }
  13544. let page = val | 0;
  13545. if (this._pageLabels) {
  13546. const i = this._pageLabels.indexOf(val);
  13547. if (i >= 0) {
  13548. page = i + 1;
  13549. }
  13550. }
  13551. if (!this._setCurrentPageNumber(page, true)) {
  13552. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  13553. }
  13554. }
  13555. get currentScale() {
  13556. return this._currentScale !== UNKNOWN_SCALE ? this._currentScale : DEFAULT_SCALE;
  13557. }
  13558. set currentScale(val) {
  13559. if (isNaN(val)) {
  13560. throw new Error("Invalid numeric scale.");
  13561. }
  13562. if (!this.pdfDocument) {
  13563. return;
  13564. }
  13565. this.#setScale(val, {
  13566. noScroll: false
  13567. });
  13568. }
  13569. get currentScaleValue() {
  13570. return this._currentScaleValue;
  13571. }
  13572. set currentScaleValue(val) {
  13573. if (!this.pdfDocument) {
  13574. return;
  13575. }
  13576. this.#setScale(val, {
  13577. noScroll: false
  13578. });
  13579. }
  13580. get pagesRotation() {
  13581. return this._pagesRotation;
  13582. }
  13583. set pagesRotation(rotation) {
  13584. if (!isValidRotation(rotation)) {
  13585. throw new Error("Invalid pages rotation angle.");
  13586. }
  13587. if (!this.pdfDocument) {
  13588. return;
  13589. }
  13590. rotation %= 360;
  13591. if (rotation < 0) {
  13592. rotation += 360;
  13593. }
  13594. if (this._pagesRotation === rotation) {
  13595. return;
  13596. }
  13597. this._pagesRotation = rotation;
  13598. const pageNumber = this._currentPageNumber;
  13599. this.refresh(true, {
  13600. rotation
  13601. });
  13602. if (this._currentScaleValue) {
  13603. this.#setScale(this._currentScaleValue, {
  13604. noScroll: true
  13605. });
  13606. }
  13607. this.eventBus.dispatch("rotationchanging", {
  13608. source: this,
  13609. pagesRotation: rotation,
  13610. pageNumber
  13611. });
  13612. if (this.defaultRenderingQueue) {
  13613. this.update();
  13614. }
  13615. }
  13616. get firstPagePromise() {
  13617. return this.pdfDocument ? this._firstPageCapability.promise : null;
  13618. }
  13619. get onePageRendered() {
  13620. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  13621. }
  13622. get pagesPromise() {
  13623. return this.pdfDocument ? this._pagesCapability.promise : null;
  13624. }
  13625. get _layerProperties() {
  13626. const self = this;
  13627. return shadow(this, "_layerProperties", {
  13628. get annotationEditorUIManager() {
  13629. return self.#annotationEditorUIManager;
  13630. },
  13631. get annotationStorage() {
  13632. return self.pdfDocument?.annotationStorage;
  13633. },
  13634. get downloadManager() {
  13635. return self.downloadManager;
  13636. },
  13637. get enableScripting() {
  13638. return !!self._scriptingManager;
  13639. },
  13640. get fieldObjectsPromise() {
  13641. return self.pdfDocument?.getFieldObjects();
  13642. },
  13643. get findController() {
  13644. return self.findController;
  13645. },
  13646. get hasJSActionsPromise() {
  13647. return self.pdfDocument?.hasJSActions();
  13648. },
  13649. get linkService() {
  13650. return self.linkService;
  13651. }
  13652. });
  13653. }
  13654. #initializePermissions(permissions) {
  13655. const params = {
  13656. annotationEditorMode: this.#annotationEditorMode,
  13657. annotationMode: this.#annotationMode,
  13658. textLayerMode: this.#textLayerMode
  13659. };
  13660. if (!permissions) {
  13661. return params;
  13662. }
  13663. if (!permissions.includes(PermissionFlag.COPY) && this.#textLayerMode === TextLayerMode.ENABLE) {
  13664. params.textLayerMode = TextLayerMode.ENABLE_PERMISSIONS;
  13665. }
  13666. if (!permissions.includes(PermissionFlag.MODIFY_CONTENTS)) {
  13667. params.annotationEditorMode = AnnotationEditorType.DISABLE;
  13668. }
  13669. if (!permissions.includes(PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === AnnotationMode.ENABLE_FORMS) {
  13670. params.annotationMode = AnnotationMode.ENABLE;
  13671. }
  13672. return params;
  13673. }
  13674. async #onePageRenderedOrForceFetch(signal) {
  13675. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  13676. return;
  13677. }
  13678. const hiddenCapability = Promise.withResolvers();
  13679. function onVisibilityChange() {
  13680. if (document.visibilityState === "hidden") {
  13681. hiddenCapability.resolve();
  13682. }
  13683. }
  13684. document.addEventListener("visibilitychange", onVisibilityChange, {
  13685. signal
  13686. });
  13687. await Promise.race([this._onePageRenderedCapability.promise, hiddenCapability.promise]);
  13688. document.removeEventListener("visibilitychange", onVisibilityChange);
  13689. }
  13690. async getAllText() {
  13691. const texts = [];
  13692. const buffer = [];
  13693. for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
  13694. if (this.#interruptCopyCondition) {
  13695. return null;
  13696. }
  13697. buffer.length = 0;
  13698. const page = await this.pdfDocument.getPage(pageNum);
  13699. const {
  13700. items
  13701. } = await page.getTextContent();
  13702. for (const item of items) {
  13703. if (item.str) {
  13704. buffer.push(item.str);
  13705. }
  13706. if (item.hasEOL) {
  13707. buffer.push("\n");
  13708. }
  13709. }
  13710. texts.push(removeNullCharacters(buffer.join("")));
  13711. }
  13712. return texts.join("\n");
  13713. }
  13714. #copyCallback(textLayerMode, event) {
  13715. const selection = document.getSelection();
  13716. const {
  13717. focusNode,
  13718. anchorNode
  13719. } = selection;
  13720. if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
  13721. if (this.#getAllTextInProgress || textLayerMode === TextLayerMode.ENABLE_PERMISSIONS) {
  13722. event.preventDefault();
  13723. event.stopPropagation();
  13724. return;
  13725. }
  13726. this.#getAllTextInProgress = true;
  13727. const {
  13728. classList
  13729. } = this.viewer;
  13730. classList.add("copyAll");
  13731. const ac = new AbortController();
  13732. window.addEventListener("keydown", ev => this.#interruptCopyCondition = ev.key === "Escape", {
  13733. signal: ac.signal
  13734. });
  13735. this.getAllText().then(async text => {
  13736. if (text !== null) {
  13737. await navigator.clipboard.writeText(text);
  13738. }
  13739. }).catch(reason => {
  13740. console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
  13741. }).finally(() => {
  13742. this.#getAllTextInProgress = false;
  13743. this.#interruptCopyCondition = false;
  13744. ac.abort();
  13745. classList.remove("copyAll");
  13746. });
  13747. event.preventDefault();
  13748. event.stopPropagation();
  13749. }
  13750. }
  13751. setDocument(pdfDocument) {
  13752. if (this.pdfDocument) {
  13753. this.eventBus.dispatch("pagesdestroy", {
  13754. source: this
  13755. });
  13756. this._cancelRendering();
  13757. this._resetView();
  13758. this.findController?.setDocument(null);
  13759. this._scriptingManager?.setDocument(null);
  13760. this.#annotationEditorUIManager?.destroy();
  13761. this.#annotationEditorUIManager = null;
  13762. }
  13763. this.pdfDocument = pdfDocument;
  13764. if (!pdfDocument) {
  13765. return;
  13766. }
  13767. const pagesCount = pdfDocument.numPages;
  13768. const firstPagePromise = pdfDocument.getPage(1);
  13769. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
  13770. intent: "display"
  13771. });
  13772. const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
  13773. const {
  13774. eventBus,
  13775. pageColors,
  13776. viewer
  13777. } = this;
  13778. this.#eventAbortController = new AbortController();
  13779. const {
  13780. signal
  13781. } = this.#eventAbortController;
  13782. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  13783. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  13784. const mode = this._scrollMode = ScrollMode.PAGE;
  13785. eventBus.dispatch("scrollmodechanged", {
  13786. source: this,
  13787. mode
  13788. });
  13789. }
  13790. this._pagesCapability.promise.then(() => {
  13791. eventBus.dispatch("pagesloaded", {
  13792. source: this,
  13793. pagesCount
  13794. });
  13795. }, () => {});
  13796. const onBeforeDraw = evt => {
  13797. const pageView = this._pages[evt.pageNumber - 1];
  13798. if (!pageView) {
  13799. return;
  13800. }
  13801. this.#buffer.push(pageView);
  13802. };
  13803. eventBus._on("pagerender", onBeforeDraw, {
  13804. signal
  13805. });
  13806. const onAfterDraw = evt => {
  13807. if (evt.cssTransform) {
  13808. return;
  13809. }
  13810. this._onePageRenderedCapability.resolve({
  13811. timestamp: evt.timestamp
  13812. });
  13813. eventBus._off("pagerendered", onAfterDraw);
  13814. };
  13815. eventBus._on("pagerendered", onAfterDraw, {
  13816. signal
  13817. });
  13818. Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => {
  13819. if (pdfDocument !== this.pdfDocument) {
  13820. return;
  13821. }
  13822. this._firstPageCapability.resolve(firstPdfPage);
  13823. this._optionalContentConfigPromise = optionalContentConfigPromise;
  13824. const {
  13825. annotationEditorMode,
  13826. annotationMode,
  13827. textLayerMode
  13828. } = this.#initializePermissions(permissions);
  13829. if (textLayerMode !== TextLayerMode.DISABLE) {
  13830. const element = this.#hiddenCopyElement = document.createElement("div");
  13831. element.id = "hiddenCopyElement";
  13832. viewer.before(element);
  13833. }
  13834. if (typeof AbortSignal.any === "function" && annotationEditorMode !== AnnotationEditorType.DISABLE) {
  13835. const mode = annotationEditorMode;
  13836. if (pdfDocument.isPureXfa) {
  13837. console.warn("Warning: XFA-editing is not implemented.");
  13838. } else if (isValidAnnotationEditorMode(mode)) {
  13839. this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#enableUpdatedAddImage, this.#enableNewAltTextWhenAddingImage, this.#mlManager);
  13840. eventBus.dispatch("annotationeditoruimanager", {
  13841. source: this,
  13842. uiManager: this.#annotationEditorUIManager
  13843. });
  13844. if (mode !== AnnotationEditorType.NONE) {
  13845. if (mode === AnnotationEditorType.STAMP) {
  13846. this.#mlManager?.loadModel("altText");
  13847. }
  13848. this.#annotationEditorUIManager.updateMode(mode);
  13849. }
  13850. } else {
  13851. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  13852. }
  13853. }
  13854. const viewerElement = this._scrollMode === ScrollMode.PAGE ? null : viewer;
  13855. const scale = this.currentScale;
  13856. const viewport = firstPdfPage.getViewport({
  13857. scale: scale * PixelsPerInch.PDF_TO_CSS_UNITS
  13858. });
  13859. viewer.style.setProperty("--scale-factor", viewport.scale);
  13860. if (pageColors?.background) {
  13861. viewer.style.setProperty("--page-bg-color", pageColors.background);
  13862. }
  13863. if (pageColors?.foreground === "CanvasText" || pageColors?.background === "Canvas") {
  13864. viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
  13865. viewer.style.setProperty("--hcm-highlight-selected-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "ButtonText"));
  13866. }
  13867. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  13868. const pageView = new PDFPageView({
  13869. container: viewerElement,
  13870. eventBus,
  13871. id: pageNum,
  13872. scale,
  13873. defaultViewport: viewport.clone(),
  13874. optionalContentConfigPromise,
  13875. renderingQueue: this.renderingQueue,
  13876. textLayerMode,
  13877. annotationMode,
  13878. imageResourcesPath: this.imageResourcesPath,
  13879. maxCanvasPixels: this.maxCanvasPixels,
  13880. pageColors,
  13881. l10n: this.l10n,
  13882. layerProperties: this._layerProperties,
  13883. enableHWA: this.#enableHWA
  13884. });
  13885. this._pages.push(pageView);
  13886. }
  13887. this._pages[0]?.setPdfPage(firstPdfPage);
  13888. if (this._scrollMode === ScrollMode.PAGE) {
  13889. this.#ensurePageViewVisible();
  13890. } else if (this._spreadMode !== SpreadMode.NONE) {
  13891. this._updateSpreadMode();
  13892. }
  13893. this.#onePageRenderedOrForceFetch(signal).then(async () => {
  13894. if (pdfDocument !== this.pdfDocument) {
  13895. return;
  13896. }
  13897. this.findController?.setDocument(pdfDocument);
  13898. this._scriptingManager?.setDocument(pdfDocument);
  13899. if (this.#hiddenCopyElement) {
  13900. document.addEventListener("copy", this.#copyCallback.bind(this, textLayerMode), {
  13901. signal
  13902. });
  13903. }
  13904. if (this.#annotationEditorUIManager) {
  13905. eventBus.dispatch("annotationeditormodechanged", {
  13906. source: this,
  13907. mode: this.#annotationEditorMode
  13908. });
  13909. }
  13910. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  13911. this._pagesCapability.resolve();
  13912. return;
  13913. }
  13914. let getPagesLeft = pagesCount - 1;
  13915. if (getPagesLeft <= 0) {
  13916. this._pagesCapability.resolve();
  13917. return;
  13918. }
  13919. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  13920. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  13921. const pageView = this._pages[pageNum - 1];
  13922. if (!pageView.pdfPage) {
  13923. pageView.setPdfPage(pdfPage);
  13924. }
  13925. if (--getPagesLeft === 0) {
  13926. this._pagesCapability.resolve();
  13927. }
  13928. }, reason => {
  13929. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  13930. if (--getPagesLeft === 0) {
  13931. this._pagesCapability.resolve();
  13932. }
  13933. });
  13934. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  13935. await promise;
  13936. }
  13937. }
  13938. });
  13939. eventBus.dispatch("pagesinit", {
  13940. source: this
  13941. });
  13942. pdfDocument.getMetadata().then(({
  13943. info
  13944. }) => {
  13945. if (pdfDocument !== this.pdfDocument) {
  13946. return;
  13947. }
  13948. if (info.Language) {
  13949. viewer.lang = info.Language;
  13950. }
  13951. });
  13952. if (this.defaultRenderingQueue) {
  13953. this.update();
  13954. }
  13955. }).catch(reason => {
  13956. console.error("Unable to initialize viewer", reason);
  13957. this._pagesCapability.reject(reason);
  13958. });
  13959. }
  13960. setPageLabels(labels) {
  13961. if (!this.pdfDocument) {
  13962. return;
  13963. }
  13964. if (!labels) {
  13965. this._pageLabels = null;
  13966. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  13967. this._pageLabels = null;
  13968. console.error(`setPageLabels: Invalid page labels.`);
  13969. } else {
  13970. this._pageLabels = labels;
  13971. }
  13972. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  13973. this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
  13974. }
  13975. }
  13976. _resetView() {
  13977. this._pages = [];
  13978. this._currentPageNumber = 1;
  13979. this._currentScale = UNKNOWN_SCALE;
  13980. this._currentScaleValue = null;
  13981. this._pageLabels = null;
  13982. this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  13983. this._location = null;
  13984. this._pagesRotation = 0;
  13985. this._optionalContentConfigPromise = null;
  13986. this._firstPageCapability = Promise.withResolvers();
  13987. this._onePageRenderedCapability = Promise.withResolvers();
  13988. this._pagesCapability = Promise.withResolvers();
  13989. this._scrollMode = ScrollMode.VERTICAL;
  13990. this._previousScrollMode = ScrollMode.UNKNOWN;
  13991. this._spreadMode = SpreadMode.NONE;
  13992. this.#scrollModePageState = {
  13993. previousPageNumber: 1,
  13994. scrollDown: true,
  13995. pages: []
  13996. };
  13997. this.#eventAbortController?.abort();
  13998. this.#eventAbortController = null;
  13999. this.viewer.textContent = "";
  14000. this._updateScrollMode();
  14001. this.viewer.removeAttribute("lang");
  14002. this.#hiddenCopyElement?.remove();
  14003. this.#hiddenCopyElement = null;
  14004. this.#cleanupSwitchAnnotationEditorMode();
  14005. }
  14006. #ensurePageViewVisible() {
  14007. if (this._scrollMode !== ScrollMode.PAGE) {
  14008. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  14009. }
  14010. const pageNumber = this._currentPageNumber,
  14011. state = this.#scrollModePageState,
  14012. viewer = this.viewer;
  14013. viewer.textContent = "";
  14014. state.pages.length = 0;
  14015. if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) {
  14016. const pageView = this._pages[pageNumber - 1];
  14017. viewer.append(pageView.div);
  14018. state.pages.push(pageView);
  14019. } else {
  14020. const pageIndexSet = new Set(),
  14021. parity = this._spreadMode - 1;
  14022. if (parity === -1) {
  14023. pageIndexSet.add(pageNumber - 1);
  14024. } else if (pageNumber % 2 !== parity) {
  14025. pageIndexSet.add(pageNumber - 1);
  14026. pageIndexSet.add(pageNumber);
  14027. } else {
  14028. pageIndexSet.add(pageNumber - 2);
  14029. pageIndexSet.add(pageNumber - 1);
  14030. }
  14031. const spread = document.createElement("div");
  14032. spread.className = "spread";
  14033. if (this.isInPresentationMode) {
  14034. const dummyPage = document.createElement("div");
  14035. dummyPage.className = "dummyPage";
  14036. spread.append(dummyPage);
  14037. }
  14038. for (const i of pageIndexSet) {
  14039. const pageView = this._pages[i];
  14040. if (!pageView) {
  14041. continue;
  14042. }
  14043. spread.append(pageView.div);
  14044. state.pages.push(pageView);
  14045. }
  14046. viewer.append(spread);
  14047. }
  14048. state.scrollDown = pageNumber >= state.previousPageNumber;
  14049. state.previousPageNumber = pageNumber;
  14050. }
  14051. _scrollUpdate() {
  14052. if (this.pagesCount === 0) {
  14053. return;
  14054. }
  14055. this.update();
  14056. }
  14057. #scrollIntoView(pageView, pageSpot = null) {
  14058. const {
  14059. div,
  14060. id
  14061. } = pageView;
  14062. if (this._currentPageNumber !== id) {
  14063. this._setCurrentPageNumber(id);
  14064. }
  14065. if (this._scrollMode === ScrollMode.PAGE) {
  14066. this.#ensurePageViewVisible();
  14067. this.update();
  14068. }
  14069. if (!pageSpot && !this.isInPresentationMode) {
  14070. const left = div.offsetLeft + div.clientLeft,
  14071. right = left + div.clientWidth;
  14072. const {
  14073. scrollLeft,
  14074. clientWidth
  14075. } = this.container;
  14076. if (this._scrollMode === ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  14077. pageSpot = {
  14078. left: 0,
  14079. top: 0
  14080. };
  14081. }
  14082. }
  14083. scrollIntoView(div, pageSpot);
  14084. if (!this._currentScaleValue && this._location) {
  14085. this._location = null;
  14086. }
  14087. }
  14088. #isSameScale(newScale) {
  14089. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  14090. }
  14091. #setScaleUpdatePages(newScale, newValue, {
  14092. noScroll = false,
  14093. preset = false,
  14094. drawingDelay = -1,
  14095. origin = null
  14096. }) {
  14097. this._currentScaleValue = newValue.toString();
  14098. if (this.#isSameScale(newScale)) {
  14099. if (preset) {
  14100. this.eventBus.dispatch("scalechanging", {
  14101. source: this,
  14102. scale: newScale,
  14103. presetValue: newValue
  14104. });
  14105. }
  14106. return;
  14107. }
  14108. this.viewer.style.setProperty("--scale-factor", newScale * PixelsPerInch.PDF_TO_CSS_UNITS);
  14109. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  14110. this.refresh(true, {
  14111. scale: newScale,
  14112. drawingDelay: postponeDrawing ? drawingDelay : -1
  14113. });
  14114. if (postponeDrawing) {
  14115. this.#scaleTimeoutId = setTimeout(() => {
  14116. this.#scaleTimeoutId = null;
  14117. this.refresh();
  14118. }, drawingDelay);
  14119. }
  14120. const previousScale = this._currentScale;
  14121. this._currentScale = newScale;
  14122. if (!noScroll) {
  14123. let page = this._currentPageNumber,
  14124. dest;
  14125. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  14126. page = this._location.pageNumber;
  14127. dest = [null, {
  14128. name: "XYZ"
  14129. }, this._location.left, this._location.top, null];
  14130. }
  14131. this.scrollPageIntoView({
  14132. pageNumber: page,
  14133. destArray: dest,
  14134. allowNegativeOffset: true
  14135. });
  14136. if (Array.isArray(origin)) {
  14137. const scaleDiff = newScale / previousScale - 1;
  14138. const [top, left] = this.containerTopLeft;
  14139. this.container.scrollLeft += (origin[0] - left) * scaleDiff;
  14140. this.container.scrollTop += (origin[1] - top) * scaleDiff;
  14141. }
  14142. }
  14143. this.eventBus.dispatch("scalechanging", {
  14144. source: this,
  14145. scale: newScale,
  14146. presetValue: preset ? newValue : undefined
  14147. });
  14148. if (this.defaultRenderingQueue) {
  14149. this.update();
  14150. }
  14151. }
  14152. get #pageWidthScaleFactor() {
  14153. if (this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL) {
  14154. return 2;
  14155. }
  14156. return 1;
  14157. }
  14158. #setScale(value, options) {
  14159. let scale = parseFloat(value);
  14160. if (scale > 0) {
  14161. options.preset = false;
  14162. this.#setScaleUpdatePages(scale, value, options);
  14163. } else {
  14164. const currentPage = this._pages[this._currentPageNumber - 1];
  14165. if (!currentPage) {
  14166. return;
  14167. }
  14168. let hPadding = SCROLLBAR_PADDING,
  14169. vPadding = VERTICAL_PADDING;
  14170. if (this.isInPresentationMode) {
  14171. hPadding = vPadding = 4;
  14172. if (this._spreadMode !== SpreadMode.NONE) {
  14173. hPadding *= 2;
  14174. }
  14175. } else if (this.removePageBorders) {
  14176. hPadding = vPadding = 0;
  14177. } else if (this._scrollMode === ScrollMode.HORIZONTAL) {
  14178. [hPadding, vPadding] = [vPadding, hPadding];
  14179. }
  14180. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
  14181. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  14182. switch (value) {
  14183. case "page-actual":
  14184. scale = 1;
  14185. break;
  14186. case "page-width":
  14187. scale = pageWidthScale;
  14188. break;
  14189. case "page-height":
  14190. scale = pageHeightScale;
  14191. break;
  14192. case "page-fit":
  14193. scale = Math.min(pageWidthScale, pageHeightScale);
  14194. break;
  14195. case "auto":
  14196. const horizontalScale = isPortraitOrientation(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  14197. scale = Math.min(MAX_AUTO_SCALE, horizontalScale);
  14198. break;
  14199. default:
  14200. console.error(`#setScale: "${value}" is an unknown zoom value.`);
  14201. return;
  14202. }
  14203. options.preset = true;
  14204. this.#setScaleUpdatePages(scale, value, options);
  14205. }
  14206. }
  14207. #resetCurrentPageView() {
  14208. const pageView = this._pages[this._currentPageNumber - 1];
  14209. if (this.isInPresentationMode) {
  14210. this.#setScale(this._currentScaleValue, {
  14211. noScroll: true
  14212. });
  14213. }
  14214. this.#scrollIntoView(pageView);
  14215. }
  14216. pageLabelToPageNumber(label) {
  14217. if (!this._pageLabels) {
  14218. return null;
  14219. }
  14220. const i = this._pageLabels.indexOf(label);
  14221. if (i < 0) {
  14222. return null;
  14223. }
  14224. return i + 1;
  14225. }
  14226. scrollPageIntoView({
  14227. pageNumber,
  14228. destArray = null,
  14229. allowNegativeOffset = false,
  14230. ignoreDestinationZoom = false
  14231. }) {
  14232. if (!this.pdfDocument) {
  14233. return;
  14234. }
  14235. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  14236. if (!pageView) {
  14237. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  14238. return;
  14239. }
  14240. if (this.isInPresentationMode || !destArray) {
  14241. this._setCurrentPageNumber(pageNumber, true);
  14242. return;
  14243. }
  14244. let x = 0,
  14245. y = 0;
  14246. let width = 0,
  14247. height = 0,
  14248. widthScale,
  14249. heightScale;
  14250. const changeOrientation = pageView.rotation % 180 !== 0;
  14251. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / PixelsPerInch.PDF_TO_CSS_UNITS;
  14252. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / PixelsPerInch.PDF_TO_CSS_UNITS;
  14253. let scale = 0;
  14254. switch (destArray[1].name) {
  14255. case "XYZ":
  14256. x = destArray[2];
  14257. y = destArray[3];
  14258. scale = destArray[4];
  14259. x = x !== null ? x : 0;
  14260. y = y !== null ? y : pageHeight;
  14261. break;
  14262. case "Fit":
  14263. case "FitB":
  14264. scale = "page-fit";
  14265. break;
  14266. case "FitH":
  14267. case "FitBH":
  14268. y = destArray[2];
  14269. scale = "page-width";
  14270. if (y === null && this._location) {
  14271. x = this._location.left;
  14272. y = this._location.top;
  14273. } else if (typeof y !== "number" || y < 0) {
  14274. y = pageHeight;
  14275. }
  14276. break;
  14277. case "FitV":
  14278. case "FitBV":
  14279. x = destArray[2];
  14280. width = pageWidth;
  14281. height = pageHeight;
  14282. scale = "page-height";
  14283. break;
  14284. case "FitR":
  14285. x = destArray[2];
  14286. y = destArray[3];
  14287. width = destArray[4] - x;
  14288. height = destArray[5] - y;
  14289. let hPadding = SCROLLBAR_PADDING,
  14290. vPadding = VERTICAL_PADDING;
  14291. if (this.removePageBorders) {
  14292. hPadding = vPadding = 0;
  14293. }
  14294. widthScale = (this.container.clientWidth - hPadding) / width / PixelsPerInch.PDF_TO_CSS_UNITS;
  14295. heightScale = (this.container.clientHeight - vPadding) / height / PixelsPerInch.PDF_TO_CSS_UNITS;
  14296. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  14297. break;
  14298. default:
  14299. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  14300. return;
  14301. }
  14302. if (!ignoreDestinationZoom) {
  14303. if (scale && scale !== this._currentScale) {
  14304. this.currentScaleValue = scale;
  14305. } else if (this._currentScale === UNKNOWN_SCALE) {
  14306. this.currentScaleValue = DEFAULT_SCALE_VALUE;
  14307. }
  14308. }
  14309. if (scale === "page-fit" && !destArray[4]) {
  14310. this.#scrollIntoView(pageView);
  14311. return;
  14312. }
  14313. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  14314. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  14315. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  14316. if (!allowNegativeOffset) {
  14317. left = Math.max(left, 0);
  14318. top = Math.max(top, 0);
  14319. }
  14320. this.#scrollIntoView(pageView, {
  14321. left,
  14322. top
  14323. });
  14324. }
  14325. _updateLocation(firstPage) {
  14326. const currentScale = this._currentScale;
  14327. const currentScaleValue = this._currentScaleValue;
  14328. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  14329. const pageNumber = firstPage.id;
  14330. const currentPageView = this._pages[pageNumber - 1];
  14331. const container = this.container;
  14332. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  14333. const intLeft = Math.round(topLeft[0]);
  14334. const intTop = Math.round(topLeft[1]);
  14335. let pdfOpenParams = `#page=${pageNumber}`;
  14336. if (!this.isInPresentationMode) {
  14337. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  14338. }
  14339. this._location = {
  14340. pageNumber,
  14341. scale: normalizedScaleValue,
  14342. top: intTop,
  14343. left: intLeft,
  14344. rotation: this._pagesRotation,
  14345. pdfOpenParams
  14346. };
  14347. }
  14348. update() {
  14349. const visible = this._getVisiblePages();
  14350. const visiblePages = visible.views,
  14351. numVisiblePages = visiblePages.length;
  14352. if (numVisiblePages === 0) {
  14353. return;
  14354. }
  14355. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  14356. this.#buffer.resize(newCacheSize, visible.ids);
  14357. this.renderingQueue.renderHighestPriority(visible);
  14358. const isSimpleLayout = this._spreadMode === SpreadMode.NONE && (this._scrollMode === ScrollMode.PAGE || this._scrollMode === ScrollMode.VERTICAL);
  14359. const currentId = this._currentPageNumber;
  14360. let stillFullyVisible = false;
  14361. for (const page of visiblePages) {
  14362. if (page.percent < 100) {
  14363. break;
  14364. }
  14365. if (page.id === currentId && isSimpleLayout) {
  14366. stillFullyVisible = true;
  14367. break;
  14368. }
  14369. }
  14370. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  14371. this._updateLocation(visible.first);
  14372. this.eventBus.dispatch("updateviewarea", {
  14373. source: this,
  14374. location: this._location
  14375. });
  14376. }
  14377. #switchToEditAnnotationMode() {
  14378. const visible = this._getVisiblePages();
  14379. const pagesToRefresh = [];
  14380. const {
  14381. ids,
  14382. views
  14383. } = visible;
  14384. for (const page of views) {
  14385. const {
  14386. view
  14387. } = page;
  14388. if (!view.hasEditableAnnotations()) {
  14389. ids.delete(view.id);
  14390. continue;
  14391. }
  14392. pagesToRefresh.push(page);
  14393. }
  14394. if (pagesToRefresh.length === 0) {
  14395. return null;
  14396. }
  14397. this.renderingQueue.renderHighestPriority({
  14398. first: pagesToRefresh[0],
  14399. last: pagesToRefresh.at(-1),
  14400. views: pagesToRefresh,
  14401. ids
  14402. });
  14403. return ids;
  14404. }
  14405. containsElement(element) {
  14406. return this.container.contains(element);
  14407. }
  14408. focus() {
  14409. this.container.focus();
  14410. }
  14411. get _isContainerRtl() {
  14412. return getComputedStyle(this.container).direction === "rtl";
  14413. }
  14414. get isInPresentationMode() {
  14415. return this.presentationModeState === PresentationModeState.FULLSCREEN;
  14416. }
  14417. get isChangingPresentationMode() {
  14418. return this.presentationModeState === PresentationModeState.CHANGING;
  14419. }
  14420. get isHorizontalScrollbarEnabled() {
  14421. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  14422. }
  14423. get isVerticalScrollbarEnabled() {
  14424. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  14425. }
  14426. _getVisiblePages() {
  14427. const views = this._scrollMode === ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
  14428. horizontal = this._scrollMode === ScrollMode.HORIZONTAL,
  14429. rtl = horizontal && this._isContainerRtl;
  14430. return getVisibleElements({
  14431. scrollEl: this.container,
  14432. views,
  14433. sortByVisibility: true,
  14434. horizontal,
  14435. rtl
  14436. });
  14437. }
  14438. cleanup() {
  14439. for (const pageView of this._pages) {
  14440. if (pageView.renderingState !== RenderingStates.FINISHED) {
  14441. pageView.reset();
  14442. }
  14443. }
  14444. }
  14445. _cancelRendering() {
  14446. for (const pageView of this._pages) {
  14447. pageView.cancelRendering();
  14448. }
  14449. }
  14450. async #ensurePdfPageLoaded(pageView) {
  14451. if (pageView.pdfPage) {
  14452. return pageView.pdfPage;
  14453. }
  14454. try {
  14455. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  14456. if (!pageView.pdfPage) {
  14457. pageView.setPdfPage(pdfPage);
  14458. }
  14459. return pdfPage;
  14460. } catch (reason) {
  14461. console.error("Unable to get page for page view", reason);
  14462. return null;
  14463. }
  14464. }
  14465. #getScrollAhead(visible) {
  14466. if (visible.first?.id === 1) {
  14467. return true;
  14468. } else if (visible.last?.id === this.pagesCount) {
  14469. return false;
  14470. }
  14471. switch (this._scrollMode) {
  14472. case ScrollMode.PAGE:
  14473. return this.#scrollModePageState.scrollDown;
  14474. case ScrollMode.HORIZONTAL:
  14475. return this.scroll.right;
  14476. }
  14477. return this.scroll.down;
  14478. }
  14479. forceRendering(currentlyVisiblePages) {
  14480. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  14481. const scrollAhead = this.#getScrollAhead(visiblePages);
  14482. const preRenderExtra = this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL;
  14483. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  14484. if (pageView) {
  14485. this.#ensurePdfPageLoaded(pageView).then(() => {
  14486. this.renderingQueue.renderView(pageView);
  14487. });
  14488. return true;
  14489. }
  14490. return false;
  14491. }
  14492. get hasEqualPageSizes() {
  14493. const firstPageView = this._pages[0];
  14494. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  14495. const pageView = this._pages[i];
  14496. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  14497. return false;
  14498. }
  14499. }
  14500. return true;
  14501. }
  14502. getPagesOverview() {
  14503. let initialOrientation;
  14504. return this._pages.map(pageView => {
  14505. const viewport = pageView.pdfPage.getViewport({
  14506. scale: 1
  14507. });
  14508. const orientation = isPortraitOrientation(viewport);
  14509. if (initialOrientation === undefined) {
  14510. initialOrientation = orientation;
  14511. } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
  14512. return {
  14513. width: viewport.height,
  14514. height: viewport.width,
  14515. rotation: (viewport.rotation - 90) % 360
  14516. };
  14517. }
  14518. return {
  14519. width: viewport.width,
  14520. height: viewport.height,
  14521. rotation: viewport.rotation
  14522. };
  14523. });
  14524. }
  14525. get optionalContentConfigPromise() {
  14526. if (!this.pdfDocument) {
  14527. return Promise.resolve(null);
  14528. }
  14529. if (!this._optionalContentConfigPromise) {
  14530. console.error("optionalContentConfigPromise: Not initialized yet.");
  14531. return this.pdfDocument.getOptionalContentConfig({
  14532. intent: "display"
  14533. });
  14534. }
  14535. return this._optionalContentConfigPromise;
  14536. }
  14537. set optionalContentConfigPromise(promise) {
  14538. if (!(promise instanceof Promise)) {
  14539. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  14540. }
  14541. if (!this.pdfDocument) {
  14542. return;
  14543. }
  14544. if (!this._optionalContentConfigPromise) {
  14545. return;
  14546. }
  14547. this._optionalContentConfigPromise = promise;
  14548. this.refresh(false, {
  14549. optionalContentConfigPromise: promise
  14550. });
  14551. this.eventBus.dispatch("optionalcontentconfigchanged", {
  14552. source: this,
  14553. promise
  14554. });
  14555. }
  14556. get scrollMode() {
  14557. return this._scrollMode;
  14558. }
  14559. set scrollMode(mode) {
  14560. if (this._scrollMode === mode) {
  14561. return;
  14562. }
  14563. if (!isValidScrollMode(mode)) {
  14564. throw new Error(`Invalid scroll mode: ${mode}`);
  14565. }
  14566. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  14567. return;
  14568. }
  14569. this._previousScrollMode = this._scrollMode;
  14570. this._scrollMode = mode;
  14571. this.eventBus.dispatch("scrollmodechanged", {
  14572. source: this,
  14573. mode
  14574. });
  14575. this._updateScrollMode(this._currentPageNumber);
  14576. }
  14577. _updateScrollMode(pageNumber = null) {
  14578. const scrollMode = this._scrollMode,
  14579. viewer = this.viewer;
  14580. viewer.classList.toggle("scrollHorizontal", scrollMode === ScrollMode.HORIZONTAL);
  14581. viewer.classList.toggle("scrollWrapped", scrollMode === ScrollMode.WRAPPED);
  14582. if (!this.pdfDocument || !pageNumber) {
  14583. return;
  14584. }
  14585. if (scrollMode === ScrollMode.PAGE) {
  14586. this.#ensurePageViewVisible();
  14587. } else if (this._previousScrollMode === ScrollMode.PAGE) {
  14588. this._updateSpreadMode();
  14589. }
  14590. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  14591. this.#setScale(this._currentScaleValue, {
  14592. noScroll: true
  14593. });
  14594. }
  14595. this._setCurrentPageNumber(pageNumber, true);
  14596. this.update();
  14597. }
  14598. get spreadMode() {
  14599. return this._spreadMode;
  14600. }
  14601. set spreadMode(mode) {
  14602. if (this._spreadMode === mode) {
  14603. return;
  14604. }
  14605. if (!isValidSpreadMode(mode)) {
  14606. throw new Error(`Invalid spread mode: ${mode}`);
  14607. }
  14608. this._spreadMode = mode;
  14609. this.eventBus.dispatch("spreadmodechanged", {
  14610. source: this,
  14611. mode
  14612. });
  14613. this._updateSpreadMode(this._currentPageNumber);
  14614. }
  14615. _updateSpreadMode(pageNumber = null) {
  14616. if (!this.pdfDocument) {
  14617. return;
  14618. }
  14619. const viewer = this.viewer,
  14620. pages = this._pages;
  14621. if (this._scrollMode === ScrollMode.PAGE) {
  14622. this.#ensurePageViewVisible();
  14623. } else {
  14624. viewer.textContent = "";
  14625. if (this._spreadMode === SpreadMode.NONE) {
  14626. for (const pageView of this._pages) {
  14627. viewer.append(pageView.div);
  14628. }
  14629. } else {
  14630. const parity = this._spreadMode - 1;
  14631. let spread = null;
  14632. for (let i = 0, ii = pages.length; i < ii; ++i) {
  14633. if (spread === null) {
  14634. spread = document.createElement("div");
  14635. spread.className = "spread";
  14636. viewer.append(spread);
  14637. } else if (i % 2 === parity) {
  14638. spread = spread.cloneNode(false);
  14639. viewer.append(spread);
  14640. }
  14641. spread.append(pages[i].div);
  14642. }
  14643. }
  14644. }
  14645. if (!pageNumber) {
  14646. return;
  14647. }
  14648. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  14649. this.#setScale(this._currentScaleValue, {
  14650. noScroll: true
  14651. });
  14652. }
  14653. this._setCurrentPageNumber(pageNumber, true);
  14654. this.update();
  14655. }
  14656. _getPageAdvance(currentPageNumber, previous = false) {
  14657. switch (this._scrollMode) {
  14658. case ScrollMode.WRAPPED:
  14659. {
  14660. const {
  14661. views
  14662. } = this._getVisiblePages(),
  14663. pageLayout = new Map();
  14664. for (const {
  14665. id,
  14666. y,
  14667. percent,
  14668. widthPercent
  14669. } of views) {
  14670. if (percent === 0 || widthPercent < 100) {
  14671. continue;
  14672. }
  14673. let yArray = pageLayout.get(y);
  14674. if (!yArray) {
  14675. pageLayout.set(y, yArray ||= []);
  14676. }
  14677. yArray.push(id);
  14678. }
  14679. for (const yArray of pageLayout.values()) {
  14680. const currentIndex = yArray.indexOf(currentPageNumber);
  14681. if (currentIndex === -1) {
  14682. continue;
  14683. }
  14684. const numPages = yArray.length;
  14685. if (numPages === 1) {
  14686. break;
  14687. }
  14688. if (previous) {
  14689. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  14690. const currentId = yArray[i],
  14691. expectedId = yArray[i + 1] - 1;
  14692. if (currentId < expectedId) {
  14693. return currentPageNumber - expectedId;
  14694. }
  14695. }
  14696. } else {
  14697. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  14698. const currentId = yArray[i],
  14699. expectedId = yArray[i - 1] + 1;
  14700. if (currentId > expectedId) {
  14701. return expectedId - currentPageNumber;
  14702. }
  14703. }
  14704. }
  14705. if (previous) {
  14706. const firstId = yArray[0];
  14707. if (firstId < currentPageNumber) {
  14708. return currentPageNumber - firstId + 1;
  14709. }
  14710. } else {
  14711. const lastId = yArray[numPages - 1];
  14712. if (lastId > currentPageNumber) {
  14713. return lastId - currentPageNumber + 1;
  14714. }
  14715. }
  14716. break;
  14717. }
  14718. break;
  14719. }
  14720. case ScrollMode.HORIZONTAL:
  14721. {
  14722. break;
  14723. }
  14724. case ScrollMode.PAGE:
  14725. case ScrollMode.VERTICAL:
  14726. {
  14727. if (this._spreadMode === SpreadMode.NONE) {
  14728. break;
  14729. }
  14730. const parity = this._spreadMode - 1;
  14731. if (previous && currentPageNumber % 2 !== parity) {
  14732. break;
  14733. } else if (!previous && currentPageNumber % 2 === parity) {
  14734. break;
  14735. }
  14736. const {
  14737. views
  14738. } = this._getVisiblePages(),
  14739. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  14740. for (const {
  14741. id,
  14742. percent,
  14743. widthPercent
  14744. } of views) {
  14745. if (id !== expectedId) {
  14746. continue;
  14747. }
  14748. if (percent > 0 && widthPercent === 100) {
  14749. return 2;
  14750. }
  14751. break;
  14752. }
  14753. break;
  14754. }
  14755. }
  14756. return 1;
  14757. }
  14758. nextPage() {
  14759. const currentPageNumber = this._currentPageNumber,
  14760. pagesCount = this.pagesCount;
  14761. if (currentPageNumber >= pagesCount) {
  14762. return false;
  14763. }
  14764. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  14765. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  14766. return true;
  14767. }
  14768. previousPage() {
  14769. const currentPageNumber = this._currentPageNumber;
  14770. if (currentPageNumber <= 1) {
  14771. return false;
  14772. }
  14773. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  14774. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  14775. return true;
  14776. }
  14777. updateScale({
  14778. drawingDelay,
  14779. scaleFactor = null,
  14780. steps = null,
  14781. origin
  14782. }) {
  14783. if (steps === null && scaleFactor === null) {
  14784. throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");
  14785. }
  14786. if (!this.pdfDocument) {
  14787. return;
  14788. }
  14789. let newScale = this._currentScale;
  14790. if (scaleFactor > 0 && scaleFactor !== 1) {
  14791. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  14792. } else if (steps) {
  14793. const delta = steps > 0 ? DEFAULT_SCALE_DELTA : 1 / DEFAULT_SCALE_DELTA;
  14794. const round = steps > 0 ? Math.ceil : Math.floor;
  14795. steps = Math.abs(steps);
  14796. do {
  14797. newScale = round((newScale * delta).toFixed(2) * 10) / 10;
  14798. } while (--steps > 0);
  14799. }
  14800. newScale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, newScale));
  14801. this.#setScale(newScale, {
  14802. noScroll: false,
  14803. drawingDelay,
  14804. origin
  14805. });
  14806. }
  14807. increaseScale(options = {}) {
  14808. this.updateScale({
  14809. ...options,
  14810. steps: options.steps ?? 1
  14811. });
  14812. }
  14813. decreaseScale(options = {}) {
  14814. this.updateScale({
  14815. ...options,
  14816. steps: -(options.steps ?? 1)
  14817. });
  14818. }
  14819. #updateContainerHeightCss(height = this.container.clientHeight) {
  14820. if (height !== this.#previousContainerHeight) {
  14821. this.#previousContainerHeight = height;
  14822. docStyle.setProperty("--viewer-container-height", `${height}px`);
  14823. }
  14824. }
  14825. #resizeObserverCallback(entries) {
  14826. for (const entry of entries) {
  14827. if (entry.target === this.container) {
  14828. this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
  14829. this.#containerTopLeft = null;
  14830. break;
  14831. }
  14832. }
  14833. }
  14834. get containerTopLeft() {
  14835. return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
  14836. }
  14837. #cleanupSwitchAnnotationEditorMode() {
  14838. this.#switchAnnotationEditorModeAC?.abort();
  14839. this.#switchAnnotationEditorModeAC = null;
  14840. if (this.#switchAnnotationEditorModeTimeoutId !== null) {
  14841. clearTimeout(this.#switchAnnotationEditorModeTimeoutId);
  14842. this.#switchAnnotationEditorModeTimeoutId = null;
  14843. }
  14844. }
  14845. get annotationEditorMode() {
  14846. return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE;
  14847. }
  14848. set annotationEditorMode({
  14849. mode,
  14850. editId = null,
  14851. isFromKeyboard = false
  14852. }) {
  14853. if (!this.#annotationEditorUIManager) {
  14854. throw new Error(`The AnnotationEditor is not enabled.`);
  14855. }
  14856. if (this.#annotationEditorMode === mode) {
  14857. return;
  14858. }
  14859. if (!isValidAnnotationEditorMode(mode)) {
  14860. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  14861. }
  14862. if (!this.pdfDocument) {
  14863. return;
  14864. }
  14865. if (mode === AnnotationEditorType.STAMP) {
  14866. this.#mlManager?.loadModel("altText");
  14867. }
  14868. const {
  14869. eventBus
  14870. } = this;
  14871. const updater = () => {
  14872. this.#cleanupSwitchAnnotationEditorMode();
  14873. this.#annotationEditorMode = mode;
  14874. this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
  14875. eventBus.dispatch("annotationeditormodechanged", {
  14876. source: this,
  14877. mode
  14878. });
  14879. };
  14880. if (mode === AnnotationEditorType.NONE || this.#annotationEditorMode === AnnotationEditorType.NONE) {
  14881. const isEditing = mode !== AnnotationEditorType.NONE;
  14882. if (!isEditing) {
  14883. this.pdfDocument.annotationStorage.resetModifiedIds();
  14884. }
  14885. for (const pageView of this._pages) {
  14886. pageView.toggleEditingMode(isEditing);
  14887. }
  14888. const idsToRefresh = this.#switchToEditAnnotationMode();
  14889. if (isEditing && idsToRefresh) {
  14890. this.#cleanupSwitchAnnotationEditorMode();
  14891. this.#switchAnnotationEditorModeAC = new AbortController();
  14892. const signal = AbortSignal.any([this.#eventAbortController.signal, this.#switchAnnotationEditorModeAC.signal]);
  14893. eventBus._on("pagerendered", ({
  14894. pageNumber
  14895. }) => {
  14896. idsToRefresh.delete(pageNumber);
  14897. if (idsToRefresh.size === 0) {
  14898. this.#switchAnnotationEditorModeTimeoutId = setTimeout(updater, 0);
  14899. }
  14900. }, {
  14901. signal
  14902. });
  14903. return;
  14904. }
  14905. }
  14906. updater();
  14907. }
  14908. refresh(noUpdate = false, updateArgs = Object.create(null)) {
  14909. if (!this.pdfDocument) {
  14910. return;
  14911. }
  14912. for (const pageView of this._pages) {
  14913. pageView.update(updateArgs);
  14914. }
  14915. if (this.#scaleTimeoutId !== null) {
  14916. clearTimeout(this.#scaleTimeoutId);
  14917. this.#scaleTimeoutId = null;
  14918. }
  14919. if (!noUpdate) {
  14920. this.update();
  14921. }
  14922. }
  14923. }
  14924. ;// ./web/secondary_toolbar.js
  14925. class SecondaryToolbar {
  14926. #opts;
  14927. constructor(options, eventBus) {
  14928. this.#opts = options;
  14929. const buttons = [{
  14930. element: options.presentationModeButton,
  14931. eventName: "presentationmode",
  14932. close: true
  14933. }, {
  14934. element: options.printButton,
  14935. eventName: "print",
  14936. close: true
  14937. }, {
  14938. element: options.downloadButton,
  14939. eventName: "download",
  14940. close: true
  14941. }, {
  14942. element: options.viewBookmarkButton,
  14943. eventName: null,
  14944. close: true
  14945. }, {
  14946. element: options.firstPageButton,
  14947. eventName: "firstpage",
  14948. close: true
  14949. }, {
  14950. element: options.lastPageButton,
  14951. eventName: "lastpage",
  14952. close: true
  14953. }, {
  14954. element: options.pageRotateCwButton,
  14955. eventName: "rotatecw",
  14956. close: false
  14957. }, {
  14958. element: options.pageRotateCcwButton,
  14959. eventName: "rotateccw",
  14960. close: false
  14961. }, {
  14962. element: options.cursorSelectToolButton,
  14963. eventName: "switchcursortool",
  14964. eventDetails: {
  14965. tool: CursorTool.SELECT
  14966. },
  14967. close: true
  14968. }, {
  14969. element: options.cursorHandToolButton,
  14970. eventName: "switchcursortool",
  14971. eventDetails: {
  14972. tool: CursorTool.HAND
  14973. },
  14974. close: true
  14975. }, {
  14976. element: options.scrollPageButton,
  14977. eventName: "switchscrollmode",
  14978. eventDetails: {
  14979. mode: ScrollMode.PAGE
  14980. },
  14981. close: true
  14982. }, {
  14983. element: options.scrollVerticalButton,
  14984. eventName: "switchscrollmode",
  14985. eventDetails: {
  14986. mode: ScrollMode.VERTICAL
  14987. },
  14988. close: true
  14989. }, {
  14990. element: options.scrollHorizontalButton,
  14991. eventName: "switchscrollmode",
  14992. eventDetails: {
  14993. mode: ScrollMode.HORIZONTAL
  14994. },
  14995. close: true
  14996. }, {
  14997. element: options.scrollWrappedButton,
  14998. eventName: "switchscrollmode",
  14999. eventDetails: {
  15000. mode: ScrollMode.WRAPPED
  15001. },
  15002. close: true
  15003. }, {
  15004. element: options.spreadNoneButton,
  15005. eventName: "switchspreadmode",
  15006. eventDetails: {
  15007. mode: SpreadMode.NONE
  15008. },
  15009. close: true
  15010. }, {
  15011. element: options.spreadOddButton,
  15012. eventName: "switchspreadmode",
  15013. eventDetails: {
  15014. mode: SpreadMode.ODD
  15015. },
  15016. close: true
  15017. }, {
  15018. element: options.spreadEvenButton,
  15019. eventName: "switchspreadmode",
  15020. eventDetails: {
  15021. mode: SpreadMode.EVEN
  15022. },
  15023. close: true
  15024. }, {
  15025. element: options.imageAltTextSettingsButton,
  15026. eventName: "imagealttextsettings",
  15027. close: true
  15028. }, {
  15029. element: options.documentPropertiesButton,
  15030. eventName: "documentproperties",
  15031. close: true
  15032. }];
  15033. buttons.push({
  15034. element: options.openFileButton,
  15035. eventName: "openfile",
  15036. close: true
  15037. });
  15038. this.eventBus = eventBus;
  15039. this.opened = false;
  15040. this.#bindListeners(buttons);
  15041. this.reset();
  15042. }
  15043. get isOpen() {
  15044. return this.opened;
  15045. }
  15046. setPageNumber(pageNumber) {
  15047. this.pageNumber = pageNumber;
  15048. this.#updateUIState();
  15049. }
  15050. setPagesCount(pagesCount) {
  15051. this.pagesCount = pagesCount;
  15052. this.#updateUIState();
  15053. }
  15054. reset() {
  15055. this.pageNumber = 0;
  15056. this.pagesCount = 0;
  15057. this.#updateUIState();
  15058. this.eventBus.dispatch("switchcursortool", {
  15059. source: this,
  15060. reset: true
  15061. });
  15062. this.#scrollModeChanged({
  15063. mode: ScrollMode.VERTICAL
  15064. });
  15065. this.#spreadModeChanged({
  15066. mode: SpreadMode.NONE
  15067. });
  15068. }
  15069. #updateUIState() {
  15070. const {
  15071. firstPageButton,
  15072. lastPageButton,
  15073. pageRotateCwButton,
  15074. pageRotateCcwButton
  15075. } = this.#opts;
  15076. firstPageButton.disabled = this.pageNumber <= 1;
  15077. lastPageButton.disabled = this.pageNumber >= this.pagesCount;
  15078. pageRotateCwButton.disabled = this.pagesCount === 0;
  15079. pageRotateCcwButton.disabled = this.pagesCount === 0;
  15080. }
  15081. #bindListeners(buttons) {
  15082. const {
  15083. eventBus
  15084. } = this;
  15085. const {
  15086. toggleButton
  15087. } = this.#opts;
  15088. toggleButton.addEventListener("click", this.toggle.bind(this));
  15089. for (const {
  15090. element,
  15091. eventName,
  15092. close,
  15093. eventDetails
  15094. } of buttons) {
  15095. element.addEventListener("click", evt => {
  15096. if (eventName !== null) {
  15097. eventBus.dispatch(eventName, {
  15098. source: this,
  15099. ...eventDetails
  15100. });
  15101. }
  15102. if (close) {
  15103. this.close();
  15104. }
  15105. eventBus.dispatch("reporttelemetry", {
  15106. source: this,
  15107. details: {
  15108. type: "buttons",
  15109. data: {
  15110. id: element.id
  15111. }
  15112. }
  15113. });
  15114. });
  15115. }
  15116. eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this));
  15117. eventBus._on("scrollmodechanged", this.#scrollModeChanged.bind(this));
  15118. eventBus._on("spreadmodechanged", this.#spreadModeChanged.bind(this));
  15119. }
  15120. #cursorToolChanged({
  15121. tool,
  15122. disabled
  15123. }) {
  15124. const {
  15125. cursorSelectToolButton,
  15126. cursorHandToolButton
  15127. } = this.#opts;
  15128. toggleCheckedBtn(cursorSelectToolButton, tool === CursorTool.SELECT);
  15129. toggleCheckedBtn(cursorHandToolButton, tool === CursorTool.HAND);
  15130. cursorSelectToolButton.disabled = disabled;
  15131. cursorHandToolButton.disabled = disabled;
  15132. }
  15133. #scrollModeChanged({
  15134. mode
  15135. }) {
  15136. const {
  15137. scrollPageButton,
  15138. scrollVerticalButton,
  15139. scrollHorizontalButton,
  15140. scrollWrappedButton,
  15141. spreadNoneButton,
  15142. spreadOddButton,
  15143. spreadEvenButton
  15144. } = this.#opts;
  15145. toggleCheckedBtn(scrollPageButton, mode === ScrollMode.PAGE);
  15146. toggleCheckedBtn(scrollVerticalButton, mode === ScrollMode.VERTICAL);
  15147. toggleCheckedBtn(scrollHorizontalButton, mode === ScrollMode.HORIZONTAL);
  15148. toggleCheckedBtn(scrollWrappedButton, mode === ScrollMode.WRAPPED);
  15149. const forceScrollModePage = this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  15150. scrollPageButton.disabled = forceScrollModePage;
  15151. scrollVerticalButton.disabled = forceScrollModePage;
  15152. scrollHorizontalButton.disabled = forceScrollModePage;
  15153. scrollWrappedButton.disabled = forceScrollModePage;
  15154. const isHorizontal = mode === ScrollMode.HORIZONTAL;
  15155. spreadNoneButton.disabled = isHorizontal;
  15156. spreadOddButton.disabled = isHorizontal;
  15157. spreadEvenButton.disabled = isHorizontal;
  15158. }
  15159. #spreadModeChanged({
  15160. mode
  15161. }) {
  15162. const {
  15163. spreadNoneButton,
  15164. spreadOddButton,
  15165. spreadEvenButton
  15166. } = this.#opts;
  15167. toggleCheckedBtn(spreadNoneButton, mode === SpreadMode.NONE);
  15168. toggleCheckedBtn(spreadOddButton, mode === SpreadMode.ODD);
  15169. toggleCheckedBtn(spreadEvenButton, mode === SpreadMode.EVEN);
  15170. }
  15171. open() {
  15172. if (this.opened) {
  15173. return;
  15174. }
  15175. this.opened = true;
  15176. const {
  15177. toggleButton,
  15178. toolbar
  15179. } = this.#opts;
  15180. toggleExpandedBtn(toggleButton, true, toolbar);
  15181. }
  15182. close() {
  15183. if (!this.opened) {
  15184. return;
  15185. }
  15186. this.opened = false;
  15187. const {
  15188. toggleButton,
  15189. toolbar
  15190. } = this.#opts;
  15191. toggleExpandedBtn(toggleButton, false, toolbar);
  15192. }
  15193. toggle() {
  15194. if (this.opened) {
  15195. this.close();
  15196. } else {
  15197. this.open();
  15198. }
  15199. }
  15200. }
  15201. ;// ./web/toolbar.js
  15202. class Toolbar {
  15203. #opts;
  15204. constructor(options, eventBus, toolbarDensity = 0) {
  15205. this.#opts = options;
  15206. this.eventBus = eventBus;
  15207. const buttons = [{
  15208. element: options.previous,
  15209. eventName: "previouspage"
  15210. }, {
  15211. element: options.next,
  15212. eventName: "nextpage"
  15213. }, {
  15214. element: options.zoomIn,
  15215. eventName: "zoomin"
  15216. }, {
  15217. element: options.zoomOut,
  15218. eventName: "zoomout"
  15219. }, {
  15220. element: options.print,
  15221. eventName: "print"
  15222. }, {
  15223. element: options.download,
  15224. eventName: "download"
  15225. }, {
  15226. element: options.editorFreeTextButton,
  15227. eventName: "switchannotationeditormode",
  15228. eventDetails: {
  15229. get mode() {
  15230. const {
  15231. classList
  15232. } = options.editorFreeTextButton;
  15233. return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.FREETEXT;
  15234. }
  15235. }
  15236. }, {
  15237. element: options.editorHighlightButton,
  15238. eventName: "switchannotationeditormode",
  15239. eventDetails: {
  15240. get mode() {
  15241. const {
  15242. classList
  15243. } = options.editorHighlightButton;
  15244. return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.HIGHLIGHT;
  15245. }
  15246. }
  15247. }, {
  15248. element: options.editorInkButton,
  15249. eventName: "switchannotationeditormode",
  15250. eventDetails: {
  15251. get mode() {
  15252. const {
  15253. classList
  15254. } = options.editorInkButton;
  15255. return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.INK;
  15256. }
  15257. }
  15258. }, {
  15259. element: options.editorStampButton,
  15260. eventName: "switchannotationeditormode",
  15261. eventDetails: {
  15262. get mode() {
  15263. const {
  15264. classList
  15265. } = options.editorStampButton;
  15266. return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.STAMP;
  15267. }
  15268. },
  15269. telemetry: {
  15270. type: "editing",
  15271. data: {
  15272. action: "pdfjs.image.icon_click"
  15273. }
  15274. }
  15275. }];
  15276. this.#bindListeners(buttons);
  15277. this.#updateToolbarDensity({
  15278. value: toolbarDensity
  15279. });
  15280. this.reset();
  15281. }
  15282. #updateToolbarDensity({
  15283. value
  15284. }) {
  15285. let name = "normal";
  15286. switch (value) {
  15287. case 1:
  15288. name = "compact";
  15289. break;
  15290. case 2:
  15291. name = "touch";
  15292. break;
  15293. }
  15294. document.documentElement.setAttribute("data-toolbar-density", name);
  15295. }
  15296. #setAnnotationEditorUIManager(uiManager, parentContainer) {
  15297. const colorPicker = new ColorPicker({
  15298. uiManager
  15299. });
  15300. uiManager.setMainHighlightColorPicker(colorPicker);
  15301. parentContainer.append(colorPicker.renderMainDropdown());
  15302. }
  15303. setPageNumber(pageNumber, pageLabel) {
  15304. this.pageNumber = pageNumber;
  15305. this.pageLabel = pageLabel;
  15306. this.#updateUIState(false);
  15307. }
  15308. setPagesCount(pagesCount, hasPageLabels) {
  15309. this.pagesCount = pagesCount;
  15310. this.hasPageLabels = hasPageLabels;
  15311. this.#updateUIState(true);
  15312. }
  15313. setPageScale(pageScaleValue, pageScale) {
  15314. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  15315. this.pageScale = pageScale;
  15316. this.#updateUIState(false);
  15317. }
  15318. reset() {
  15319. this.pageNumber = 0;
  15320. this.pageLabel = null;
  15321. this.hasPageLabels = false;
  15322. this.pagesCount = 0;
  15323. this.pageScaleValue = DEFAULT_SCALE_VALUE;
  15324. this.pageScale = DEFAULT_SCALE;
  15325. this.#updateUIState(true);
  15326. this.updateLoadingIndicatorState();
  15327. this.#editorModeChanged({
  15328. mode: AnnotationEditorType.DISABLE
  15329. });
  15330. }
  15331. #bindListeners(buttons) {
  15332. const {
  15333. eventBus
  15334. } = this;
  15335. const {
  15336. editorHighlightColorPicker,
  15337. editorHighlightButton,
  15338. pageNumber,
  15339. scaleSelect
  15340. } = this.#opts;
  15341. const self = this;
  15342. for (const {
  15343. element,
  15344. eventName,
  15345. eventDetails,
  15346. telemetry
  15347. } of buttons) {
  15348. element.addEventListener("click", evt => {
  15349. if (eventName !== null) {
  15350. eventBus.dispatch(eventName, {
  15351. source: this,
  15352. ...eventDetails,
  15353. isFromKeyboard: evt.detail === 0
  15354. });
  15355. }
  15356. if (telemetry) {
  15357. eventBus.dispatch("reporttelemetry", {
  15358. source: this,
  15359. details: telemetry
  15360. });
  15361. }
  15362. });
  15363. }
  15364. pageNumber.addEventListener("click", function () {
  15365. this.select();
  15366. });
  15367. pageNumber.addEventListener("change", function () {
  15368. eventBus.dispatch("pagenumberchanged", {
  15369. source: self,
  15370. value: this.value
  15371. });
  15372. });
  15373. scaleSelect.addEventListener("change", function () {
  15374. if (this.value === "custom") {
  15375. return;
  15376. }
  15377. eventBus.dispatch("scalechanged", {
  15378. source: self,
  15379. value: this.value
  15380. });
  15381. });
  15382. scaleSelect.addEventListener("click", function ({
  15383. target
  15384. }) {
  15385. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  15386. this.blur();
  15387. }
  15388. });
  15389. scaleSelect.oncontextmenu = noContextMenu;
  15390. eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this));
  15391. eventBus._on("showannotationeditorui", ({
  15392. mode
  15393. }) => {
  15394. switch (mode) {
  15395. case AnnotationEditorType.HIGHLIGHT:
  15396. editorHighlightButton.click();
  15397. break;
  15398. }
  15399. });
  15400. eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
  15401. if (editorHighlightColorPicker) {
  15402. eventBus._on("annotationeditoruimanager", ({
  15403. uiManager
  15404. }) => {
  15405. this.#setAnnotationEditorUIManager(uiManager, editorHighlightColorPicker);
  15406. }, {
  15407. once: true
  15408. });
  15409. }
  15410. }
  15411. #editorModeChanged({
  15412. mode
  15413. }) {
  15414. const {
  15415. editorFreeTextButton,
  15416. editorFreeTextParamsToolbar,
  15417. editorHighlightButton,
  15418. editorHighlightParamsToolbar,
  15419. editorInkButton,
  15420. editorInkParamsToolbar,
  15421. editorStampButton,
  15422. editorStampParamsToolbar
  15423. } = this.#opts;
  15424. toggleExpandedBtn(editorFreeTextButton, mode === AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
  15425. toggleExpandedBtn(editorHighlightButton, mode === AnnotationEditorType.HIGHLIGHT, editorHighlightParamsToolbar);
  15426. toggleExpandedBtn(editorInkButton, mode === AnnotationEditorType.INK, editorInkParamsToolbar);
  15427. toggleExpandedBtn(editorStampButton, mode === AnnotationEditorType.STAMP, editorStampParamsToolbar);
  15428. const isDisable = mode === AnnotationEditorType.DISABLE;
  15429. editorFreeTextButton.disabled = isDisable;
  15430. editorHighlightButton.disabled = isDisable;
  15431. editorInkButton.disabled = isDisable;
  15432. editorStampButton.disabled = isDisable;
  15433. }
  15434. #updateUIState(resetNumPages = false) {
  15435. const {
  15436. pageNumber,
  15437. pagesCount,
  15438. pageScaleValue,
  15439. pageScale
  15440. } = this;
  15441. const opts = this.#opts;
  15442. if (resetNumPages) {
  15443. if (this.hasPageLabels) {
  15444. opts.pageNumber.type = "text";
  15445. opts.numPages.setAttribute("data-l10n-id", "pdfjs-page-of-pages");
  15446. } else {
  15447. opts.pageNumber.type = "number";
  15448. opts.numPages.setAttribute("data-l10n-id", "pdfjs-of-pages");
  15449. opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
  15450. pagesCount
  15451. }));
  15452. }
  15453. opts.pageNumber.max = pagesCount;
  15454. }
  15455. if (this.hasPageLabels) {
  15456. opts.pageNumber.value = this.pageLabel;
  15457. opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
  15458. pageNumber,
  15459. pagesCount
  15460. }));
  15461. } else {
  15462. opts.pageNumber.value = pageNumber;
  15463. }
  15464. opts.previous.disabled = pageNumber <= 1;
  15465. opts.next.disabled = pageNumber >= pagesCount;
  15466. opts.zoomOut.disabled = pageScale <= MIN_SCALE;
  15467. opts.zoomIn.disabled = pageScale >= MAX_SCALE;
  15468. let predefinedValueFound = false;
  15469. for (const option of opts.scaleSelect.options) {
  15470. if (option.value !== pageScaleValue) {
  15471. option.selected = false;
  15472. continue;
  15473. }
  15474. option.selected = true;
  15475. predefinedValueFound = true;
  15476. }
  15477. if (!predefinedValueFound) {
  15478. opts.customScaleOption.selected = true;
  15479. opts.customScaleOption.setAttribute("data-l10n-args", JSON.stringify({
  15480. scale: Math.round(pageScale * 10000) / 100
  15481. }));
  15482. }
  15483. }
  15484. updateLoadingIndicatorState(loading = false) {
  15485. const {
  15486. pageNumber
  15487. } = this.#opts;
  15488. pageNumber.classList.toggle("loading", loading);
  15489. }
  15490. }
  15491. ;// ./web/view_history.js
  15492. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  15493. class ViewHistory {
  15494. constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
  15495. this.fingerprint = fingerprint;
  15496. this.cacheSize = cacheSize;
  15497. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  15498. const database = JSON.parse(databaseStr || "{}");
  15499. let index = -1;
  15500. if (!Array.isArray(database.files)) {
  15501. database.files = [];
  15502. } else {
  15503. while (database.files.length >= this.cacheSize) {
  15504. database.files.shift();
  15505. }
  15506. for (let i = 0, ii = database.files.length; i < ii; i++) {
  15507. const branch = database.files[i];
  15508. if (branch.fingerprint === this.fingerprint) {
  15509. index = i;
  15510. break;
  15511. }
  15512. }
  15513. }
  15514. if (index === -1) {
  15515. index = database.files.push({
  15516. fingerprint: this.fingerprint
  15517. }) - 1;
  15518. }
  15519. this.file = database.files[index];
  15520. this.database = database;
  15521. });
  15522. }
  15523. async _writeToStorage() {
  15524. const databaseStr = JSON.stringify(this.database);
  15525. localStorage.setItem("pdfjs.history", databaseStr);
  15526. }
  15527. async _readFromStorage() {
  15528. return localStorage.getItem("pdfjs.history");
  15529. }
  15530. async set(name, val) {
  15531. await this._initializedPromise;
  15532. this.file[name] = val;
  15533. return this._writeToStorage();
  15534. }
  15535. async setMultiple(properties) {
  15536. await this._initializedPromise;
  15537. for (const name in properties) {
  15538. this.file[name] = properties[name];
  15539. }
  15540. return this._writeToStorage();
  15541. }
  15542. async get(name, defaultValue) {
  15543. await this._initializedPromise;
  15544. const val = this.file[name];
  15545. return val !== undefined ? val : defaultValue;
  15546. }
  15547. async getMultiple(properties) {
  15548. await this._initializedPromise;
  15549. const values = Object.create(null);
  15550. for (const name in properties) {
  15551. const val = this.file[name];
  15552. values[name] = val !== undefined ? val : properties[name];
  15553. }
  15554. return values;
  15555. }
  15556. }
  15557. ;// ./web/app.js
  15558. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  15559. const ViewOnLoad = {
  15560. UNKNOWN: -1,
  15561. PREVIOUS: 0,
  15562. INITIAL: 1
  15563. };
  15564. const PDFViewerApplication = {
  15565. initialBookmark: document.location.hash.substring(1),
  15566. _initializedCapability: {
  15567. ...Promise.withResolvers(),
  15568. settled: false
  15569. },
  15570. appConfig: null,
  15571. pdfDocument: null,
  15572. pdfLoadingTask: null,
  15573. printService: null,
  15574. pdfViewer: null,
  15575. pdfThumbnailViewer: null,
  15576. pdfRenderingQueue: null,
  15577. pdfPresentationMode: null,
  15578. pdfDocumentProperties: null,
  15579. pdfLinkService: null,
  15580. pdfHistory: null,
  15581. pdfSidebar: null,
  15582. pdfOutlineViewer: null,
  15583. pdfAttachmentViewer: null,
  15584. pdfLayerViewer: null,
  15585. pdfCursorTools: null,
  15586. pdfScriptingManager: null,
  15587. store: null,
  15588. downloadManager: null,
  15589. overlayManager: null,
  15590. preferences: new Preferences(),
  15591. toolbar: null,
  15592. secondaryToolbar: null,
  15593. eventBus: null,
  15594. l10n: null,
  15595. annotationEditorParams: null,
  15596. imageAltTextSettings: null,
  15597. isInitialViewSet: false,
  15598. isViewerEmbedded: window.parent !== window,
  15599. url: "",
  15600. baseUrl: "",
  15601. mlManager: null,
  15602. _downloadUrl: "",
  15603. _eventBusAbortController: null,
  15604. _windowAbortController: null,
  15605. _globalAbortController: new AbortController(),
  15606. documentInfo: null,
  15607. metadata: null,
  15608. _contentDispositionFilename: null,
  15609. _contentLength: null,
  15610. _saveInProgress: false,
  15611. _wheelUnusedTicks: 0,
  15612. _wheelUnusedFactor: 1,
  15613. _touchUnusedTicks: 0,
  15614. _touchUnusedFactor: 1,
  15615. _PDFBug: null,
  15616. _hasAnnotationEditors: false,
  15617. _title: document.title,
  15618. _printAnnotationStoragePromise: null,
  15619. _touchInfo: null,
  15620. _isCtrlKeyDown: false,
  15621. _caretBrowsing: null,
  15622. _isScrolling: false,
  15623. async initialize(appConfig) {
  15624. this.appConfig = appConfig;
  15625. try {
  15626. await this.preferences.initializedPromise;
  15627. } catch (ex) {
  15628. console.error(`initialize: "${ex.message}".`);
  15629. }
  15630. if (AppOptions.get("pdfBugEnabled")) {
  15631. await this._parseHashParams();
  15632. }
  15633. let mode;
  15634. switch (AppOptions.get("viewerCssTheme")) {
  15635. case 1:
  15636. mode = "is-light";
  15637. break;
  15638. case 2:
  15639. mode = "is-dark";
  15640. break;
  15641. }
  15642. if (mode) {
  15643. document.documentElement.classList.add(mode);
  15644. }
  15645. this.l10n = await this.externalServices.createL10n();
  15646. document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
  15647. this.l10n.translate(appConfig.appContainer || document.documentElement);
  15648. if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) {
  15649. AppOptions.set("externalLinkTarget", LinkTarget.TOP);
  15650. }
  15651. await this._initializeViewerComponents();
  15652. this.bindEvents();
  15653. this.bindWindowEvents();
  15654. this._initializedCapability.settled = true;
  15655. this._initializedCapability.resolve();
  15656. },
  15657. async _parseHashParams() {
  15658. const hash = document.location.hash.substring(1);
  15659. if (!hash) {
  15660. return;
  15661. }
  15662. const {
  15663. mainContainer,
  15664. viewerContainer
  15665. } = this.appConfig,
  15666. params = parseQueryString(hash);
  15667. const loadPDFBug = async () => {
  15668. if (this._PDFBug) {
  15669. return;
  15670. }
  15671. const {
  15672. PDFBug
  15673. } = await import(/*webpackIgnore: true*/AppOptions.get("debuggerSrc"));
  15674. this._PDFBug = PDFBug;
  15675. };
  15676. if (params.get("disableworker") === "true") {
  15677. try {
  15678. GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
  15679. await import(/*webpackIgnore: true*/PDFWorker.workerSrc);
  15680. } catch (ex) {
  15681. console.error(`_parseHashParams: "${ex.message}".`);
  15682. }
  15683. }
  15684. if (params.has("textlayer")) {
  15685. switch (params.get("textlayer")) {
  15686. case "off":
  15687. AppOptions.set("textLayerMode", TextLayerMode.DISABLE);
  15688. break;
  15689. case "visible":
  15690. case "shadow":
  15691. case "hover":
  15692. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  15693. try {
  15694. await loadPDFBug();
  15695. this._PDFBug.loadCSS();
  15696. } catch (ex) {
  15697. console.error(`_parseHashParams: "${ex.message}".`);
  15698. }
  15699. break;
  15700. }
  15701. }
  15702. if (params.has("pdfbug")) {
  15703. AppOptions.setAll({
  15704. pdfBug: true,
  15705. fontExtraProperties: true
  15706. });
  15707. const enabled = params.get("pdfbug").split(",");
  15708. try {
  15709. await loadPDFBug();
  15710. this._PDFBug.init(mainContainer, enabled);
  15711. } catch (ex) {
  15712. console.error(`_parseHashParams: "${ex.message}".`);
  15713. }
  15714. }
  15715. if (params.has("locale")) {
  15716. AppOptions.set("localeProperties", {
  15717. lang: params.get("locale")
  15718. });
  15719. }
  15720. const opts = {
  15721. disableAutoFetch: x => x === "true",
  15722. disableFontFace: x => x === "true",
  15723. disableHistory: x => x === "true",
  15724. disableRange: x => x === "true",
  15725. disableStream: x => x === "true",
  15726. verbosity: x => x | 0
  15727. };
  15728. for (const name in opts) {
  15729. const check = opts[name],
  15730. key = name.toLowerCase();
  15731. if (params.has(key)) {
  15732. AppOptions.set(name, check(params.get(key)));
  15733. }
  15734. }
  15735. },
  15736. async _initializeViewerComponents() {
  15737. const {
  15738. appConfig,
  15739. externalServices,
  15740. l10n
  15741. } = this;
  15742. const eventBus = new EventBus();
  15743. this.eventBus = AppOptions.eventBus = eventBus;
  15744. this.mlManager?.setEventBus(eventBus, this._globalAbortController.signal);
  15745. this.overlayManager = new OverlayManager();
  15746. const pdfRenderingQueue = new PDFRenderingQueue();
  15747. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  15748. this.pdfRenderingQueue = pdfRenderingQueue;
  15749. const pdfLinkService = new PDFLinkService({
  15750. eventBus,
  15751. externalLinkTarget: AppOptions.get("externalLinkTarget"),
  15752. externalLinkRel: AppOptions.get("externalLinkRel"),
  15753. ignoreDestinationZoom: AppOptions.get("ignoreDestinationZoom")
  15754. });
  15755. this.pdfLinkService = pdfLinkService;
  15756. const downloadManager = this.downloadManager = new DownloadManager();
  15757. const findController = new PDFFindController({
  15758. linkService: pdfLinkService,
  15759. eventBus,
  15760. updateMatchesCountOnProgress: true
  15761. });
  15762. this.findController = findController;
  15763. const pdfScriptingManager = new PDFScriptingManager({
  15764. eventBus,
  15765. externalServices,
  15766. docProperties: this._scriptingDocProperties.bind(this)
  15767. });
  15768. this.pdfScriptingManager = pdfScriptingManager;
  15769. const container = appConfig.mainContainer,
  15770. viewer = appConfig.viewerContainer;
  15771. const annotationEditorMode = AppOptions.get("annotationEditorMode");
  15772. const pageColors = AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  15773. background: AppOptions.get("pageColorsBackground"),
  15774. foreground: AppOptions.get("pageColorsForeground")
  15775. } : null;
  15776. let altTextManager;
  15777. if (AppOptions.get("enableUpdatedAddImage")) {
  15778. altTextManager = appConfig.newAltTextDialog ? new NewAltTextManager(appConfig.newAltTextDialog, this.overlayManager, eventBus) : null;
  15779. } else {
  15780. altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
  15781. }
  15782. const enableHWA = AppOptions.get("enableHWA");
  15783. const pdfViewer = new PDFViewer({
  15784. container,
  15785. viewer,
  15786. eventBus,
  15787. renderingQueue: pdfRenderingQueue,
  15788. linkService: pdfLinkService,
  15789. downloadManager,
  15790. altTextManager,
  15791. findController,
  15792. scriptingManager: AppOptions.get("enableScripting") && pdfScriptingManager,
  15793. l10n,
  15794. textLayerMode: AppOptions.get("textLayerMode"),
  15795. annotationMode: AppOptions.get("annotationMode"),
  15796. annotationEditorMode,
  15797. annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"),
  15798. enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"),
  15799. enableUpdatedAddImage: AppOptions.get("enableUpdatedAddImage"),
  15800. enableNewAltTextWhenAddingImage: AppOptions.get("enableNewAltTextWhenAddingImage"),
  15801. imageResourcesPath: AppOptions.get("imageResourcesPath"),
  15802. enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
  15803. maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
  15804. enablePermissions: AppOptions.get("enablePermissions"),
  15805. pageColors,
  15806. mlManager: this.mlManager,
  15807. abortSignal: this._globalAbortController.signal,
  15808. enableHWA
  15809. });
  15810. this.pdfViewer = pdfViewer;
  15811. pdfRenderingQueue.setViewer(pdfViewer);
  15812. pdfLinkService.setViewer(pdfViewer);
  15813. pdfScriptingManager.setViewer(pdfViewer);
  15814. if (appConfig.sidebar?.thumbnailView) {
  15815. this.pdfThumbnailViewer = new PDFThumbnailViewer({
  15816. container: appConfig.sidebar.thumbnailView,
  15817. eventBus,
  15818. renderingQueue: pdfRenderingQueue,
  15819. linkService: pdfLinkService,
  15820. pageColors,
  15821. abortSignal: this._globalAbortController.signal,
  15822. enableHWA
  15823. });
  15824. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  15825. }
  15826. if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) {
  15827. this.pdfHistory = new PDFHistory({
  15828. linkService: pdfLinkService,
  15829. eventBus
  15830. });
  15831. pdfLinkService.setHistory(this.pdfHistory);
  15832. }
  15833. if (!this.supportsIntegratedFind && appConfig.findBar) {
  15834. this.findBar = new PDFFindBar(appConfig.findBar, appConfig.principalContainer, eventBus);
  15835. }
  15836. if (appConfig.annotationEditorParams) {
  15837. if (typeof AbortSignal.any === "function" && annotationEditorMode !== AnnotationEditorType.DISABLE) {
  15838. this.annotationEditorParams = new AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  15839. } else {
  15840. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  15841. document.getElementById(id)?.classList.add("hidden");
  15842. }
  15843. }
  15844. }
  15845. if (this.mlManager && appConfig.secondaryToolbar?.imageAltTextSettingsButton) {
  15846. this.imageAltTextSettings = new ImageAltTextSettings(appConfig.altTextSettingsDialog, this.overlayManager, eventBus, this.mlManager);
  15847. }
  15848. if (appConfig.documentProperties) {
  15849. this.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
  15850. }
  15851. if (appConfig.secondaryToolbar?.cursorHandToolButton) {
  15852. this.pdfCursorTools = new PDFCursorTools({
  15853. container,
  15854. eventBus,
  15855. cursorToolOnLoad: AppOptions.get("cursorToolOnLoad")
  15856. });
  15857. }
  15858. if (appConfig.toolbar) {
  15859. this.toolbar = new Toolbar(appConfig.toolbar, eventBus, AppOptions.get("toolbarDensity"));
  15860. }
  15861. if (appConfig.secondaryToolbar) {
  15862. if (AppOptions.get("enableAltText")) {
  15863. appConfig.secondaryToolbar.imageAltTextSettingsButton?.classList.remove("hidden");
  15864. appConfig.secondaryToolbar.imageAltTextSettingsSeparator?.classList.remove("hidden");
  15865. }
  15866. this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
  15867. }
  15868. if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
  15869. this.pdfPresentationMode = new PDFPresentationMode({
  15870. container,
  15871. pdfViewer,
  15872. eventBus
  15873. });
  15874. }
  15875. if (appConfig.passwordOverlay) {
  15876. this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.isViewerEmbedded);
  15877. }
  15878. if (appConfig.sidebar?.outlineView) {
  15879. this.pdfOutlineViewer = new PDFOutlineViewer({
  15880. container: appConfig.sidebar.outlineView,
  15881. eventBus,
  15882. l10n,
  15883. linkService: pdfLinkService,
  15884. downloadManager
  15885. });
  15886. }
  15887. if (appConfig.sidebar?.attachmentsView) {
  15888. this.pdfAttachmentViewer = new PDFAttachmentViewer({
  15889. container: appConfig.sidebar.attachmentsView,
  15890. eventBus,
  15891. l10n,
  15892. downloadManager
  15893. });
  15894. }
  15895. if (appConfig.sidebar?.layersView) {
  15896. this.pdfLayerViewer = new PDFLayerViewer({
  15897. container: appConfig.sidebar.layersView,
  15898. eventBus,
  15899. l10n
  15900. });
  15901. }
  15902. if (appConfig.sidebar) {
  15903. this.pdfSidebar = new PDFSidebar({
  15904. elements: appConfig.sidebar,
  15905. eventBus,
  15906. l10n
  15907. });
  15908. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  15909. this.pdfSidebar.onUpdateThumbnails = () => {
  15910. for (const pageView of pdfViewer.getCachedPageViews()) {
  15911. if (pageView.renderingState === RenderingStates.FINISHED) {
  15912. this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
  15913. }
  15914. }
  15915. this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  15916. };
  15917. }
  15918. },
  15919. async run(config) {
  15920. await this.initialize(config);
  15921. const {
  15922. appConfig,
  15923. eventBus
  15924. } = this;
  15925. let file;
  15926. const queryString = document.location.search.substring(1);
  15927. const params = parseQueryString(queryString);
  15928. file = params.get("file") ?? AppOptions.get("defaultUrl");
  15929. validateFileURL(file);
  15930. const fileInput = this._openFileInput = document.createElement("input");
  15931. fileInput.id = "fileInput";
  15932. fileInput.hidden = true;
  15933. fileInput.type = "file";
  15934. fileInput.value = null;
  15935. document.body.append(fileInput);
  15936. fileInput.addEventListener("change", function (evt) {
  15937. const {
  15938. files
  15939. } = evt.target;
  15940. if (!files || files.length === 0) {
  15941. return;
  15942. }
  15943. eventBus.dispatch("fileinputchange", {
  15944. source: this,
  15945. fileInput: evt.target
  15946. });
  15947. });
  15948. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  15949. for (const item of evt.dataTransfer.items) {
  15950. if (item.type === "application/pdf") {
  15951. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  15952. evt.preventDefault();
  15953. evt.stopPropagation();
  15954. return;
  15955. }
  15956. }
  15957. });
  15958. appConfig.mainContainer.addEventListener("drop", function (evt) {
  15959. if (evt.dataTransfer.files?.[0].type !== "application/pdf") {
  15960. return;
  15961. }
  15962. evt.preventDefault();
  15963. evt.stopPropagation();
  15964. eventBus.dispatch("fileinputchange", {
  15965. source: this,
  15966. fileInput: evt.dataTransfer
  15967. });
  15968. });
  15969. if (!AppOptions.get("supportsDocumentFonts")) {
  15970. AppOptions.set("disableFontFace", true);
  15971. this.l10n.get("pdfjs-web-fonts-disabled").then(msg => {
  15972. console.warn(msg);
  15973. });
  15974. }
  15975. if (!this.supportsPrinting) {
  15976. appConfig.toolbar?.print?.classList.add("hidden");
  15977. appConfig.secondaryToolbar?.printButton.classList.add("hidden");
  15978. }
  15979. if (!this.supportsFullscreen) {
  15980. appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
  15981. }
  15982. if (this.supportsIntegratedFind) {
  15983. appConfig.findBar?.toggleButton?.classList.add("hidden");
  15984. }
  15985. if (file) {
  15986. this.open({
  15987. url: file
  15988. });
  15989. } else {
  15990. this._hideViewBookmark();
  15991. }
  15992. },
  15993. get externalServices() {
  15994. return shadow(this, "externalServices", new ExternalServices());
  15995. },
  15996. get initialized() {
  15997. return this._initializedCapability.settled;
  15998. },
  15999. get initializedPromise() {
  16000. return this._initializedCapability.promise;
  16001. },
  16002. updateZoom(steps, scaleFactor, origin) {
  16003. if (this.pdfViewer.isInPresentationMode) {
  16004. return;
  16005. }
  16006. this.pdfViewer.updateScale({
  16007. drawingDelay: AppOptions.get("defaultZoomDelay"),
  16008. steps,
  16009. scaleFactor,
  16010. origin
  16011. });
  16012. },
  16013. zoomIn() {
  16014. this.updateZoom(1);
  16015. },
  16016. zoomOut() {
  16017. this.updateZoom(-1);
  16018. },
  16019. zoomReset() {
  16020. if (this.pdfViewer.isInPresentationMode) {
  16021. return;
  16022. }
  16023. this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
  16024. },
  16025. get pagesCount() {
  16026. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  16027. },
  16028. get page() {
  16029. return this.pdfViewer.currentPageNumber;
  16030. },
  16031. set page(val) {
  16032. this.pdfViewer.currentPageNumber = val;
  16033. },
  16034. get supportsPrinting() {
  16035. return PDFPrintServiceFactory.supportsPrinting;
  16036. },
  16037. get supportsFullscreen() {
  16038. return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
  16039. },
  16040. get supportsPinchToZoom() {
  16041. return shadow(this, "supportsPinchToZoom", AppOptions.get("supportsPinchToZoom"));
  16042. },
  16043. get supportsIntegratedFind() {
  16044. return shadow(this, "supportsIntegratedFind", AppOptions.get("supportsIntegratedFind"));
  16045. },
  16046. get loadingBar() {
  16047. const barElement = document.getElementById("loadingBar");
  16048. const bar = barElement ? new ProgressBar(barElement) : null;
  16049. return shadow(this, "loadingBar", bar);
  16050. },
  16051. get supportsMouseWheelZoomCtrlKey() {
  16052. return shadow(this, "supportsMouseWheelZoomCtrlKey", AppOptions.get("supportsMouseWheelZoomCtrlKey"));
  16053. },
  16054. get supportsMouseWheelZoomMetaKey() {
  16055. return shadow(this, "supportsMouseWheelZoomMetaKey", AppOptions.get("supportsMouseWheelZoomMetaKey"));
  16056. },
  16057. get supportsCaretBrowsingMode() {
  16058. return AppOptions.get("supportsCaretBrowsingMode");
  16059. },
  16060. moveCaret(isUp, select) {
  16061. this._caretBrowsing ||= new CaretBrowsingMode(this._globalAbortController.signal, this.appConfig.mainContainer, this.appConfig.viewerContainer, this.appConfig.toolbar?.container);
  16062. this._caretBrowsing.moveCaret(isUp, select);
  16063. },
  16064. setTitleUsingUrl(url = "", downloadUrl = null) {
  16065. this.url = url;
  16066. this.baseUrl = url.split("#", 1)[0];
  16067. if (downloadUrl) {
  16068. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0];
  16069. }
  16070. if (isDataScheme(url)) {
  16071. this._hideViewBookmark();
  16072. }
  16073. let title = pdfjs_getPdfFilenameFromUrl(url, "");
  16074. if (!title) {
  16075. try {
  16076. title = decodeURIComponent(getFilenameFromUrl(url));
  16077. } catch {}
  16078. }
  16079. this.setTitle(title || url);
  16080. },
  16081. setTitle(title = this._title) {
  16082. this._title = title;
  16083. if (this.isViewerEmbedded) {
  16084. return;
  16085. }
  16086. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  16087. document.title = `${editorIndicator ? "* " : ""}${title}`;
  16088. },
  16089. get _docFilename() {
  16090. return this._contentDispositionFilename || pdfjs_getPdfFilenameFromUrl(this.url);
  16091. },
  16092. _hideViewBookmark() {
  16093. const {
  16094. secondaryToolbar
  16095. } = this.appConfig;
  16096. secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
  16097. if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
  16098. document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
  16099. }
  16100. },
  16101. async close() {
  16102. this._unblockDocumentLoadEvent();
  16103. this._hideViewBookmark();
  16104. if (!this.pdfLoadingTask) {
  16105. return;
  16106. }
  16107. if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
  16108. try {
  16109. await this.save();
  16110. } catch {}
  16111. }
  16112. const promises = [];
  16113. promises.push(this.pdfLoadingTask.destroy());
  16114. this.pdfLoadingTask = null;
  16115. if (this.pdfDocument) {
  16116. this.pdfDocument = null;
  16117. this.pdfThumbnailViewer?.setDocument(null);
  16118. this.pdfViewer.setDocument(null);
  16119. this.pdfLinkService.setDocument(null);
  16120. this.pdfDocumentProperties?.setDocument(null);
  16121. }
  16122. this.pdfLinkService.externalLinkEnabled = true;
  16123. this.store = null;
  16124. this.isInitialViewSet = false;
  16125. this.url = "";
  16126. this.baseUrl = "";
  16127. this._downloadUrl = "";
  16128. this.documentInfo = null;
  16129. this.metadata = null;
  16130. this._contentDispositionFilename = null;
  16131. this._contentLength = null;
  16132. this._saveInProgress = false;
  16133. this._hasAnnotationEditors = false;
  16134. promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
  16135. this.setTitle();
  16136. this.pdfSidebar?.reset();
  16137. this.pdfOutlineViewer?.reset();
  16138. this.pdfAttachmentViewer?.reset();
  16139. this.pdfLayerViewer?.reset();
  16140. this.pdfHistory?.reset();
  16141. this.findBar?.reset();
  16142. this.toolbar?.reset();
  16143. this.secondaryToolbar?.reset();
  16144. this._PDFBug?.cleanup();
  16145. await Promise.all(promises);
  16146. },
  16147. async open(args) {
  16148. if (this.pdfLoadingTask) {
  16149. await this.close();
  16150. }
  16151. const workerParams = AppOptions.getAll(OptionKind.WORKER);
  16152. Object.assign(GlobalWorkerOptions, workerParams);
  16153. if (args.url) {
  16154. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  16155. }
  16156. const apiParams = AppOptions.getAll(OptionKind.API);
  16157. const loadingTask = getDocument({
  16158. ...apiParams,
  16159. ...args
  16160. });
  16161. this.pdfLoadingTask = loadingTask;
  16162. loadingTask.onPassword = (updateCallback, reason) => {
  16163. if (this.isViewerEmbedded) {
  16164. this._unblockDocumentLoadEvent();
  16165. }
  16166. this.pdfLinkService.externalLinkEnabled = false;
  16167. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  16168. this.passwordPrompt.open();
  16169. };
  16170. loadingTask.onProgress = ({
  16171. loaded,
  16172. total
  16173. }) => {
  16174. this.progress(loaded / total);
  16175. };
  16176. return loadingTask.promise.then(pdfDocument => {
  16177. this.load(pdfDocument);
  16178. }, reason => {
  16179. if (loadingTask !== this.pdfLoadingTask) {
  16180. return undefined;
  16181. }
  16182. let key = "pdfjs-loading-error";
  16183. if (reason instanceof InvalidPDFException) {
  16184. key = "pdfjs-invalid-file-error";
  16185. } else if (reason instanceof MissingPDFException) {
  16186. key = "pdfjs-missing-file-error";
  16187. } else if (reason instanceof UnexpectedResponseException) {
  16188. key = "pdfjs-unexpected-response-error";
  16189. }
  16190. return this._documentError(key, {
  16191. message: reason.message
  16192. }).then(() => {
  16193. throw reason;
  16194. });
  16195. });
  16196. },
  16197. async download() {
  16198. let data;
  16199. try {
  16200. data = await this.pdfDocument.getData();
  16201. } catch {}
  16202. this.downloadManager.download(data, this._downloadUrl, this._docFilename);
  16203. },
  16204. async save() {
  16205. if (this._saveInProgress) {
  16206. return;
  16207. }
  16208. this._saveInProgress = true;
  16209. await this.pdfScriptingManager.dispatchWillSave();
  16210. try {
  16211. const data = await this.pdfDocument.saveDocument();
  16212. this.downloadManager.download(data, this._downloadUrl, this._docFilename);
  16213. } catch (reason) {
  16214. console.error(`Error when saving the document: ${reason.message}`);
  16215. await this.download();
  16216. } finally {
  16217. await this.pdfScriptingManager.dispatchDidSave();
  16218. this._saveInProgress = false;
  16219. }
  16220. if (this._hasAnnotationEditors) {
  16221. this.externalServices.reportTelemetry({
  16222. type: "editing",
  16223. data: {
  16224. type: "save",
  16225. stats: this.pdfDocument?.annotationStorage.editorStats
  16226. }
  16227. });
  16228. }
  16229. },
  16230. async downloadOrSave() {
  16231. const {
  16232. classList
  16233. } = this.appConfig.appContainer;
  16234. classList.add("wait");
  16235. await (this.pdfDocument?.annotationStorage.size > 0 ? this.save() : this.download());
  16236. classList.remove("wait");
  16237. },
  16238. async _documentError(key, moreInfo = null) {
  16239. this._unblockDocumentLoadEvent();
  16240. const message = await this._otherError(key || "pdfjs-loading-error", moreInfo);
  16241. this.eventBus.dispatch("documenterror", {
  16242. source: this,
  16243. message,
  16244. reason: moreInfo?.message ?? null
  16245. });
  16246. },
  16247. async _otherError(key, moreInfo = null) {
  16248. const message = await this.l10n.get(key);
  16249. const moreInfoText = [`PDF.js v${version || "?"} (build: ${build || "?"})`];
  16250. if (moreInfo) {
  16251. moreInfoText.push(`Message: ${moreInfo.message}`);
  16252. if (moreInfo.stack) {
  16253. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  16254. } else {
  16255. if (moreInfo.filename) {
  16256. moreInfoText.push(`File: ${moreInfo.filename}`);
  16257. }
  16258. if (moreInfo.lineNumber) {
  16259. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  16260. }
  16261. }
  16262. }
  16263. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  16264. return message;
  16265. },
  16266. progress(level) {
  16267. const percent = Math.round(level * 100);
  16268. if (!this.loadingBar || percent <= this.loadingBar.percent) {
  16269. return;
  16270. }
  16271. this.loadingBar.percent = percent;
  16272. if (this.pdfDocument?.loadingParams.disableAutoFetch ?? AppOptions.get("disableAutoFetch")) {
  16273. this.loadingBar.setDisableAutoFetch();
  16274. }
  16275. },
  16276. load(pdfDocument) {
  16277. this.pdfDocument = pdfDocument;
  16278. pdfDocument.getDownloadInfo().then(({
  16279. length
  16280. }) => {
  16281. this._contentLength = length;
  16282. this.loadingBar?.hide();
  16283. firstPagePromise.then(() => {
  16284. this.eventBus.dispatch("documentloaded", {
  16285. source: this
  16286. });
  16287. });
  16288. });
  16289. const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
  16290. const pageModePromise = pdfDocument.getPageMode().catch(() => {});
  16291. const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
  16292. this.toolbar?.setPagesCount(pdfDocument.numPages, false);
  16293. this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
  16294. this.pdfLinkService.setDocument(pdfDocument);
  16295. this.pdfDocumentProperties?.setDocument(pdfDocument);
  16296. const pdfViewer = this.pdfViewer;
  16297. pdfViewer.setDocument(pdfDocument);
  16298. const {
  16299. firstPagePromise,
  16300. onePageRendered,
  16301. pagesPromise
  16302. } = pdfViewer;
  16303. this.pdfThumbnailViewer?.setDocument(pdfDocument);
  16304. const storedPromise = (this.store = new ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  16305. page: null,
  16306. zoom: DEFAULT_SCALE_VALUE,
  16307. scrollLeft: "0",
  16308. scrollTop: "0",
  16309. rotation: null,
  16310. sidebarView: SidebarView.UNKNOWN,
  16311. scrollMode: ScrollMode.UNKNOWN,
  16312. spreadMode: SpreadMode.UNKNOWN
  16313. }).catch(() => {});
  16314. firstPagePromise.then(pdfPage => {
  16315. this.loadingBar?.setWidth(this.appConfig.viewerContainer);
  16316. this._initializeAnnotationStorageCallbacks(pdfDocument);
  16317. Promise.all([animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => {
  16318. const viewOnLoad = AppOptions.get("viewOnLoad");
  16319. this._initializePdfHistory({
  16320. fingerprint: pdfDocument.fingerprints[0],
  16321. viewOnLoad,
  16322. initialDest: openAction?.dest
  16323. });
  16324. const initialBookmark = this.initialBookmark;
  16325. const zoom = AppOptions.get("defaultZoomValue");
  16326. let hash = zoom ? `zoom=${zoom}` : null;
  16327. let rotation = null;
  16328. let sidebarView = AppOptions.get("sidebarViewOnLoad");
  16329. let scrollMode = AppOptions.get("scrollModeOnLoad");
  16330. let spreadMode = AppOptions.get("spreadModeOnLoad");
  16331. if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  16332. hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  16333. rotation = parseInt(stored.rotation, 10);
  16334. if (sidebarView === SidebarView.UNKNOWN) {
  16335. sidebarView = stored.sidebarView | 0;
  16336. }
  16337. if (scrollMode === ScrollMode.UNKNOWN) {
  16338. scrollMode = stored.scrollMode | 0;
  16339. }
  16340. if (spreadMode === SpreadMode.UNKNOWN) {
  16341. spreadMode = stored.spreadMode | 0;
  16342. }
  16343. }
  16344. if (pageMode && sidebarView === SidebarView.UNKNOWN) {
  16345. sidebarView = apiPageModeToSidebarView(pageMode);
  16346. }
  16347. if (pageLayout && scrollMode === ScrollMode.UNKNOWN && spreadMode === SpreadMode.UNKNOWN) {
  16348. const modes = apiPageLayoutToViewerModes(pageLayout);
  16349. spreadMode = modes.spreadMode;
  16350. }
  16351. this.setInitialView(hash, {
  16352. rotation,
  16353. sidebarView,
  16354. scrollMode,
  16355. spreadMode
  16356. });
  16357. this.eventBus.dispatch("documentinit", {
  16358. source: this
  16359. });
  16360. if (!this.isViewerEmbedded) {
  16361. pdfViewer.focus();
  16362. }
  16363. await Promise.race([pagesPromise, new Promise(resolve => {
  16364. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  16365. })]);
  16366. if (!initialBookmark && !hash) {
  16367. return;
  16368. }
  16369. if (pdfViewer.hasEqualPageSizes) {
  16370. return;
  16371. }
  16372. this.initialBookmark = initialBookmark;
  16373. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  16374. this.setInitialView(hash);
  16375. }).catch(() => {
  16376. this.setInitialView();
  16377. }).then(function () {
  16378. pdfViewer.update();
  16379. });
  16380. });
  16381. pagesPromise.then(() => {
  16382. this._unblockDocumentLoadEvent();
  16383. this._initializeAutoPrint(pdfDocument, openActionPromise);
  16384. }, reason => {
  16385. this._documentError("pdfjs-loading-error", {
  16386. message: reason.message
  16387. });
  16388. });
  16389. onePageRendered.then(data => {
  16390. this.externalServices.reportTelemetry({
  16391. type: "pageInfo",
  16392. timestamp: data.timestamp
  16393. });
  16394. if (this.pdfOutlineViewer) {
  16395. pdfDocument.getOutline().then(outline => {
  16396. if (pdfDocument !== this.pdfDocument) {
  16397. return;
  16398. }
  16399. this.pdfOutlineViewer.render({
  16400. outline,
  16401. pdfDocument
  16402. });
  16403. });
  16404. }
  16405. if (this.pdfAttachmentViewer) {
  16406. pdfDocument.getAttachments().then(attachments => {
  16407. if (pdfDocument !== this.pdfDocument) {
  16408. return;
  16409. }
  16410. this.pdfAttachmentViewer.render({
  16411. attachments
  16412. });
  16413. });
  16414. }
  16415. if (this.pdfLayerViewer) {
  16416. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  16417. if (pdfDocument !== this.pdfDocument) {
  16418. return;
  16419. }
  16420. this.pdfLayerViewer.render({
  16421. optionalContentConfig,
  16422. pdfDocument
  16423. });
  16424. });
  16425. }
  16426. });
  16427. this._initializePageLabels(pdfDocument);
  16428. this._initializeMetadata(pdfDocument);
  16429. },
  16430. async _scriptingDocProperties(pdfDocument) {
  16431. if (!this.documentInfo) {
  16432. await new Promise(resolve => {
  16433. this.eventBus._on("metadataloaded", resolve, {
  16434. once: true
  16435. });
  16436. });
  16437. if (pdfDocument !== this.pdfDocument) {
  16438. return null;
  16439. }
  16440. }
  16441. if (!this._contentLength) {
  16442. await new Promise(resolve => {
  16443. this.eventBus._on("documentloaded", resolve, {
  16444. once: true
  16445. });
  16446. });
  16447. if (pdfDocument !== this.pdfDocument) {
  16448. return null;
  16449. }
  16450. }
  16451. return {
  16452. ...this.documentInfo,
  16453. baseURL: this.baseUrl,
  16454. filesize: this._contentLength,
  16455. filename: this._docFilename,
  16456. metadata: this.metadata?.getRaw(),
  16457. authors: this.metadata?.get("dc:creator"),
  16458. numPages: this.pagesCount,
  16459. URL: this.url
  16460. };
  16461. },
  16462. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  16463. const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]);
  16464. if (pdfDocument !== this.pdfDocument) {
  16465. return;
  16466. }
  16467. let triggerAutoPrint = openAction?.action === "Print";
  16468. if (jsActions) {
  16469. console.warn("Warning: JavaScript support is not enabled");
  16470. for (const name in jsActions) {
  16471. if (triggerAutoPrint) {
  16472. break;
  16473. }
  16474. switch (name) {
  16475. case "WillClose":
  16476. case "WillSave":
  16477. case "DidSave":
  16478. case "WillPrint":
  16479. case "DidPrint":
  16480. continue;
  16481. }
  16482. triggerAutoPrint = jsActions[name].some(js => AutoPrintRegExp.test(js));
  16483. }
  16484. }
  16485. if (triggerAutoPrint) {
  16486. this.triggerPrinting();
  16487. }
  16488. },
  16489. async _initializeMetadata(pdfDocument) {
  16490. const {
  16491. info,
  16492. metadata,
  16493. contentDispositionFilename,
  16494. contentLength
  16495. } = await pdfDocument.getMetadata();
  16496. if (pdfDocument !== this.pdfDocument) {
  16497. return;
  16498. }
  16499. this.documentInfo = info;
  16500. this.metadata = metadata;
  16501. this._contentDispositionFilename ??= contentDispositionFilename;
  16502. this._contentLength ??= contentLength;
  16503. console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${version || "?"} [${build || "?"}])`);
  16504. let pdfTitle = info.Title;
  16505. const metadataTitle = metadata?.get("dc:title");
  16506. if (metadataTitle) {
  16507. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  16508. pdfTitle = metadataTitle;
  16509. }
  16510. }
  16511. if (pdfTitle) {
  16512. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  16513. } else if (this._contentDispositionFilename) {
  16514. this.setTitle(this._contentDispositionFilename);
  16515. }
  16516. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  16517. if (pdfDocument.loadingParams.enableXfa) {
  16518. console.warn("Warning: XFA Foreground documents are not supported");
  16519. } else {
  16520. console.warn("Warning: XFA support is not enabled");
  16521. }
  16522. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  16523. console.warn("Warning: Interactive form support is not enabled");
  16524. }
  16525. if (info.IsSignaturesPresent) {
  16526. console.warn("Warning: Digital signatures validation is not supported");
  16527. }
  16528. this.eventBus.dispatch("metadataloaded", {
  16529. source: this
  16530. });
  16531. },
  16532. async _initializePageLabels(pdfDocument) {
  16533. const labels = await pdfDocument.getPageLabels();
  16534. if (pdfDocument !== this.pdfDocument) {
  16535. return;
  16536. }
  16537. if (!labels || AppOptions.get("disablePageLabels")) {
  16538. return;
  16539. }
  16540. const numLabels = labels.length;
  16541. let standardLabels = 0,
  16542. emptyLabels = 0;
  16543. for (let i = 0; i < numLabels; i++) {
  16544. const label = labels[i];
  16545. if (label === (i + 1).toString()) {
  16546. standardLabels++;
  16547. } else if (label === "") {
  16548. emptyLabels++;
  16549. } else {
  16550. break;
  16551. }
  16552. }
  16553. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  16554. return;
  16555. }
  16556. const {
  16557. pdfViewer,
  16558. pdfThumbnailViewer,
  16559. toolbar
  16560. } = this;
  16561. pdfViewer.setPageLabels(labels);
  16562. pdfThumbnailViewer?.setPageLabels(labels);
  16563. toolbar?.setPagesCount(numLabels, true);
  16564. toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  16565. },
  16566. _initializePdfHistory({
  16567. fingerprint,
  16568. viewOnLoad,
  16569. initialDest = null
  16570. }) {
  16571. if (!this.pdfHistory) {
  16572. return;
  16573. }
  16574. this.pdfHistory.initialize({
  16575. fingerprint,
  16576. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  16577. updateUrl: AppOptions.get("historyUpdateUrl")
  16578. });
  16579. if (this.pdfHistory.initialBookmark) {
  16580. this.initialBookmark = this.pdfHistory.initialBookmark;
  16581. this.initialRotation = this.pdfHistory.initialRotation;
  16582. }
  16583. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  16584. this.initialBookmark = JSON.stringify(initialDest);
  16585. this.pdfHistory.push({
  16586. explicitDest: initialDest,
  16587. pageNumber: null
  16588. });
  16589. }
  16590. },
  16591. _initializeAnnotationStorageCallbacks(pdfDocument) {
  16592. if (pdfDocument !== this.pdfDocument) {
  16593. return;
  16594. }
  16595. const {
  16596. annotationStorage
  16597. } = pdfDocument;
  16598. annotationStorage.onSetModified = () => {
  16599. window.addEventListener("beforeunload", beforeUnload);
  16600. this._annotationStorageModified = true;
  16601. };
  16602. annotationStorage.onResetModified = () => {
  16603. window.removeEventListener("beforeunload", beforeUnload);
  16604. delete this._annotationStorageModified;
  16605. };
  16606. annotationStorage.onAnnotationEditor = typeStr => {
  16607. this._hasAnnotationEditors = !!typeStr;
  16608. this.setTitle();
  16609. };
  16610. },
  16611. setInitialView(storedHash, {
  16612. rotation,
  16613. sidebarView,
  16614. scrollMode,
  16615. spreadMode
  16616. } = {}) {
  16617. const setRotation = angle => {
  16618. if (isValidRotation(angle)) {
  16619. this.pdfViewer.pagesRotation = angle;
  16620. }
  16621. };
  16622. const setViewerModes = (scroll, spread) => {
  16623. if (isValidScrollMode(scroll)) {
  16624. this.pdfViewer.scrollMode = scroll;
  16625. }
  16626. if (isValidSpreadMode(spread)) {
  16627. this.pdfViewer.spreadMode = spread;
  16628. }
  16629. };
  16630. this.isInitialViewSet = true;
  16631. this.pdfSidebar?.setInitialView(sidebarView);
  16632. setViewerModes(scrollMode, spreadMode);
  16633. if (this.initialBookmark) {
  16634. setRotation(this.initialRotation);
  16635. delete this.initialRotation;
  16636. this.pdfLinkService.setHash(this.initialBookmark);
  16637. this.initialBookmark = null;
  16638. } else if (storedHash) {
  16639. setRotation(rotation);
  16640. this.pdfLinkService.setHash(storedHash);
  16641. }
  16642. this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  16643. this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
  16644. if (!this.pdfViewer.currentScaleValue) {
  16645. this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
  16646. }
  16647. },
  16648. _cleanup() {
  16649. if (!this.pdfDocument) {
  16650. return;
  16651. }
  16652. this.pdfViewer.cleanup();
  16653. this.pdfThumbnailViewer?.cleanup();
  16654. this.pdfDocument.cleanup(AppOptions.get("fontExtraProperties"));
  16655. },
  16656. forceRendering() {
  16657. this.pdfRenderingQueue.printing = !!this.printService;
  16658. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === SidebarView.THUMBS;
  16659. this.pdfRenderingQueue.renderHighestPriority();
  16660. },
  16661. beforePrint() {
  16662. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => this.pdfDocument?.annotationStorage.print);
  16663. if (this.printService) {
  16664. return;
  16665. }
  16666. if (!this.supportsPrinting) {
  16667. this._otherError("pdfjs-printing-not-supported");
  16668. return;
  16669. }
  16670. if (!this.pdfViewer.pageViewsReady) {
  16671. this.l10n.get("pdfjs-printing-not-ready").then(msg => {
  16672. window.alert(msg);
  16673. });
  16674. return;
  16675. }
  16676. this.printService = PDFPrintServiceFactory.createPrintService({
  16677. pdfDocument: this.pdfDocument,
  16678. pagesOverview: this.pdfViewer.getPagesOverview(),
  16679. printContainer: this.appConfig.printContainer,
  16680. printResolution: AppOptions.get("printResolution"),
  16681. printAnnotationStoragePromise: this._printAnnotationStoragePromise
  16682. });
  16683. this.forceRendering();
  16684. this.setTitle();
  16685. this.printService.layout();
  16686. if (this._hasAnnotationEditors) {
  16687. this.externalServices.reportTelemetry({
  16688. type: "editing",
  16689. data: {
  16690. type: "print",
  16691. stats: this.pdfDocument?.annotationStorage.editorStats
  16692. }
  16693. });
  16694. }
  16695. },
  16696. afterPrint() {
  16697. if (this._printAnnotationStoragePromise) {
  16698. this._printAnnotationStoragePromise.then(() => {
  16699. this.pdfScriptingManager.dispatchDidPrint();
  16700. });
  16701. this._printAnnotationStoragePromise = null;
  16702. }
  16703. if (this.printService) {
  16704. this.printService.destroy();
  16705. this.printService = null;
  16706. this.pdfDocument?.annotationStorage.resetModified();
  16707. }
  16708. this.forceRendering();
  16709. this.setTitle();
  16710. },
  16711. rotatePages(delta) {
  16712. this.pdfViewer.pagesRotation += delta;
  16713. },
  16714. requestPresentationMode() {
  16715. this.pdfPresentationMode?.request();
  16716. },
  16717. triggerPrinting() {
  16718. if (this.supportsPrinting) {
  16719. window.print();
  16720. }
  16721. },
  16722. bindEvents() {
  16723. if (this._eventBusAbortController) {
  16724. return;
  16725. }
  16726. this._eventBusAbortController = new AbortController();
  16727. const {
  16728. eventBus,
  16729. externalServices,
  16730. pdfDocumentProperties,
  16731. pdfViewer,
  16732. preferences,
  16733. _eventBusAbortController: {
  16734. signal
  16735. }
  16736. } = this;
  16737. eventBus._on("resize", onResize.bind(this), {
  16738. signal
  16739. });
  16740. eventBus._on("hashchange", onHashchange.bind(this), {
  16741. signal
  16742. });
  16743. eventBus._on("beforeprint", this.beforePrint.bind(this), {
  16744. signal
  16745. });
  16746. eventBus._on("afterprint", this.afterPrint.bind(this), {
  16747. signal
  16748. });
  16749. eventBus._on("pagerender", onPageRender.bind(this), {
  16750. signal
  16751. });
  16752. eventBus._on("pagerendered", onPageRendered.bind(this), {
  16753. signal
  16754. });
  16755. eventBus._on("updateviewarea", onUpdateViewarea.bind(this), {
  16756. signal
  16757. });
  16758. eventBus._on("pagechanging", onPageChanging.bind(this), {
  16759. signal
  16760. });
  16761. eventBus._on("scalechanging", onScaleChanging.bind(this), {
  16762. signal
  16763. });
  16764. eventBus._on("rotationchanging", onRotationChanging.bind(this), {
  16765. signal
  16766. });
  16767. eventBus._on("sidebarviewchanged", onSidebarViewChanged.bind(this), {
  16768. signal
  16769. });
  16770. eventBus._on("pagemode", onPageMode.bind(this), {
  16771. signal
  16772. });
  16773. eventBus._on("namedaction", onNamedAction.bind(this), {
  16774. signal
  16775. });
  16776. eventBus._on("presentationmodechanged", evt => pdfViewer.presentationModeState = evt.state, {
  16777. signal
  16778. });
  16779. eventBus._on("presentationmode", this.requestPresentationMode.bind(this), {
  16780. signal
  16781. });
  16782. eventBus._on("switchannotationeditormode", evt => pdfViewer.annotationEditorMode = evt, {
  16783. signal
  16784. });
  16785. eventBus._on("print", this.triggerPrinting.bind(this), {
  16786. signal
  16787. });
  16788. eventBus._on("download", this.downloadOrSave.bind(this), {
  16789. signal
  16790. });
  16791. eventBus._on("firstpage", () => this.page = 1, {
  16792. signal
  16793. });
  16794. eventBus._on("lastpage", () => this.page = this.pagesCount, {
  16795. signal
  16796. });
  16797. eventBus._on("nextpage", () => pdfViewer.nextPage(), {
  16798. signal
  16799. });
  16800. eventBus._on("previouspage", () => pdfViewer.previousPage(), {
  16801. signal
  16802. });
  16803. eventBus._on("zoomin", this.zoomIn.bind(this), {
  16804. signal
  16805. });
  16806. eventBus._on("zoomout", this.zoomOut.bind(this), {
  16807. signal
  16808. });
  16809. eventBus._on("zoomreset", this.zoomReset.bind(this), {
  16810. signal
  16811. });
  16812. eventBus._on("pagenumberchanged", onPageNumberChanged.bind(this), {
  16813. signal
  16814. });
  16815. eventBus._on("scalechanged", evt => pdfViewer.currentScaleValue = evt.value, {
  16816. signal
  16817. });
  16818. eventBus._on("rotatecw", this.rotatePages.bind(this, 90), {
  16819. signal
  16820. });
  16821. eventBus._on("rotateccw", this.rotatePages.bind(this, -90), {
  16822. signal
  16823. });
  16824. eventBus._on("optionalcontentconfig", evt => pdfViewer.optionalContentConfigPromise = evt.promise, {
  16825. signal
  16826. });
  16827. eventBus._on("switchscrollmode", evt => pdfViewer.scrollMode = evt.mode, {
  16828. signal
  16829. });
  16830. eventBus._on("scrollmodechanged", onViewerModesChanged.bind(this, "scrollMode"), {
  16831. signal
  16832. });
  16833. eventBus._on("switchspreadmode", evt => pdfViewer.spreadMode = evt.mode, {
  16834. signal
  16835. });
  16836. eventBus._on("spreadmodechanged", onViewerModesChanged.bind(this, "spreadMode"), {
  16837. signal
  16838. });
  16839. eventBus._on("imagealttextsettings", onImageAltTextSettings.bind(this), {
  16840. signal
  16841. });
  16842. eventBus._on("documentproperties", () => pdfDocumentProperties?.open(), {
  16843. signal
  16844. });
  16845. eventBus._on("findfromurlhash", onFindFromUrlHash.bind(this), {
  16846. signal
  16847. });
  16848. eventBus._on("updatefindmatchescount", onUpdateFindMatchesCount.bind(this), {
  16849. signal
  16850. });
  16851. eventBus._on("updatefindcontrolstate", onUpdateFindControlState.bind(this), {
  16852. signal
  16853. });
  16854. eventBus._on("fileinputchange", onFileInputChange.bind(this), {
  16855. signal
  16856. });
  16857. eventBus._on("openfile", onOpenFile.bind(this), {
  16858. signal
  16859. });
  16860. },
  16861. bindWindowEvents() {
  16862. if (this._windowAbortController) {
  16863. return;
  16864. }
  16865. this._windowAbortController = new AbortController();
  16866. const {
  16867. eventBus,
  16868. appConfig: {
  16869. mainContainer
  16870. },
  16871. pdfViewer,
  16872. _windowAbortController: {
  16873. signal
  16874. }
  16875. } = this;
  16876. function addWindowResolutionChange(evt = null) {
  16877. if (evt) {
  16878. pdfViewer.refresh();
  16879. }
  16880. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  16881. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  16882. once: true,
  16883. signal
  16884. });
  16885. }
  16886. addWindowResolutionChange();
  16887. window.addEventListener("wheel", onWheel.bind(this), {
  16888. passive: false,
  16889. signal
  16890. });
  16891. window.addEventListener("touchstart", onTouchStart.bind(this), {
  16892. passive: false,
  16893. signal
  16894. });
  16895. window.addEventListener("touchmove", onTouchMove.bind(this), {
  16896. passive: false,
  16897. signal
  16898. });
  16899. window.addEventListener("touchend", onTouchEnd.bind(this), {
  16900. passive: false,
  16901. signal
  16902. });
  16903. window.addEventListener("click", onClick.bind(this), {
  16904. signal
  16905. });
  16906. window.addEventListener("keydown", onKeyDown.bind(this), {
  16907. signal
  16908. });
  16909. window.addEventListener("keyup", onKeyUp.bind(this), {
  16910. signal
  16911. });
  16912. window.addEventListener("resize", () => eventBus.dispatch("resize", {
  16913. source: window
  16914. }), {
  16915. signal
  16916. });
  16917. window.addEventListener("hashchange", () => {
  16918. eventBus.dispatch("hashchange", {
  16919. source: window,
  16920. hash: document.location.hash.substring(1)
  16921. });
  16922. }, {
  16923. signal
  16924. });
  16925. window.addEventListener("beforeprint", () => eventBus.dispatch("beforeprint", {
  16926. source: window
  16927. }), {
  16928. signal
  16929. });
  16930. window.addEventListener("afterprint", () => eventBus.dispatch("afterprint", {
  16931. source: window
  16932. }), {
  16933. signal
  16934. });
  16935. window.addEventListener("updatefromsandbox", evt => {
  16936. eventBus.dispatch("updatefromsandbox", {
  16937. source: window,
  16938. detail: evt.detail
  16939. });
  16940. }, {
  16941. signal
  16942. });
  16943. if (!("onscrollend" in document.documentElement)) {
  16944. return;
  16945. }
  16946. ({
  16947. scrollTop: this._lastScrollTop,
  16948. scrollLeft: this._lastScrollLeft
  16949. } = mainContainer);
  16950. const scrollend = () => {
  16951. ({
  16952. scrollTop: this._lastScrollTop,
  16953. scrollLeft: this._lastScrollLeft
  16954. } = mainContainer);
  16955. this._isScrolling = false;
  16956. mainContainer.addEventListener("scroll", scroll, {
  16957. passive: true,
  16958. signal
  16959. });
  16960. mainContainer.removeEventListener("scrollend", scrollend);
  16961. mainContainer.removeEventListener("blur", scrollend);
  16962. };
  16963. const scroll = () => {
  16964. if (this._isCtrlKeyDown) {
  16965. return;
  16966. }
  16967. if (this._lastScrollTop === mainContainer.scrollTop && this._lastScrollLeft === mainContainer.scrollLeft) {
  16968. return;
  16969. }
  16970. mainContainer.removeEventListener("scroll", scroll, {
  16971. passive: true
  16972. });
  16973. this._isScrolling = true;
  16974. mainContainer.addEventListener("scrollend", scrollend, {
  16975. signal
  16976. });
  16977. mainContainer.addEventListener("blur", scrollend, {
  16978. signal
  16979. });
  16980. };
  16981. mainContainer.addEventListener("scroll", scroll, {
  16982. passive: true,
  16983. signal
  16984. });
  16985. },
  16986. unbindEvents() {
  16987. this._eventBusAbortController?.abort();
  16988. this._eventBusAbortController = null;
  16989. },
  16990. unbindWindowEvents() {
  16991. this._windowAbortController?.abort();
  16992. this._windowAbortController = null;
  16993. },
  16994. async testingClose() {
  16995. this.unbindEvents();
  16996. this.unbindWindowEvents();
  16997. this._globalAbortController?.abort();
  16998. this._globalAbortController = null;
  16999. this.findBar?.close();
  17000. await Promise.all([this.l10n?.destroy(), this.close()]);
  17001. },
  17002. _accumulateTicks(ticks, prop) {
  17003. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  17004. this[prop] = 0;
  17005. }
  17006. this[prop] += ticks;
  17007. const wholeTicks = Math.trunc(this[prop]);
  17008. this[prop] -= wholeTicks;
  17009. return wholeTicks;
  17010. },
  17011. _accumulateFactor(previousScale, factor, prop) {
  17012. if (factor === 1) {
  17013. return 1;
  17014. }
  17015. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  17016. this[prop] = 1;
  17017. }
  17018. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  17019. this[prop] = factor / newFactor;
  17020. return newFactor;
  17021. },
  17022. _unblockDocumentLoadEvent() {
  17023. document.blockUnblockOnload?.(false);
  17024. this._unblockDocumentLoadEvent = () => {};
  17025. },
  17026. get scriptingReady() {
  17027. return this.pdfScriptingManager.ready;
  17028. }
  17029. };
  17030. initCom(PDFViewerApplication);
  17031. {
  17032. PDFPrintServiceFactory.initGlobals(PDFViewerApplication);
  17033. }
  17034. {
  17035. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  17036. var validateFileURL = function (file) {
  17037. if (!file) {
  17038. return;
  17039. }
  17040. try {
  17041. const viewerOrigin = new URL(window.location.href).origin || "null";
  17042. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  17043. return;
  17044. }
  17045. const fileOrigin = new URL(file, window.location.href).origin;
  17046. if (fileOrigin !== viewerOrigin) {
  17047. throw new Error("file origin does not match viewer's");
  17048. }
  17049. } catch (ex) {
  17050. PDFViewerApplication._documentError("pdfjs-loading-error", {
  17051. message: ex.message
  17052. });
  17053. throw ex;
  17054. }
  17055. };
  17056. var onFileInputChange = function (evt) {
  17057. if (this.pdfViewer?.isInPresentationMode) {
  17058. return;
  17059. }
  17060. const file = evt.fileInput.files[0];
  17061. this.open({
  17062. url: URL.createObjectURL(file),
  17063. originalUrl: file.name
  17064. });
  17065. };
  17066. var onOpenFile = function (evt) {
  17067. this._openFileInput?.click();
  17068. };
  17069. }
  17070. function onPageRender({
  17071. pageNumber
  17072. }) {
  17073. if (pageNumber === this.page) {
  17074. this.toolbar?.updateLoadingIndicatorState(true);
  17075. }
  17076. }
  17077. function onPageRendered({
  17078. pageNumber,
  17079. error
  17080. }) {
  17081. if (pageNumber === this.page) {
  17082. this.toolbar?.updateLoadingIndicatorState(false);
  17083. }
  17084. if (this.pdfSidebar?.visibleView === SidebarView.THUMBS) {
  17085. const pageView = this.pdfViewer.getPageView(pageNumber - 1);
  17086. const thumbnailView = this.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
  17087. if (pageView) {
  17088. thumbnailView?.setImage(pageView);
  17089. }
  17090. }
  17091. if (error) {
  17092. this._otherError("pdfjs-rendering-error", error);
  17093. }
  17094. }
  17095. function onPageMode({
  17096. mode
  17097. }) {
  17098. let view;
  17099. switch (mode) {
  17100. case "thumbs":
  17101. view = SidebarView.THUMBS;
  17102. break;
  17103. case "bookmarks":
  17104. case "outline":
  17105. view = SidebarView.OUTLINE;
  17106. break;
  17107. case "attachments":
  17108. view = SidebarView.ATTACHMENTS;
  17109. break;
  17110. case "layers":
  17111. view = SidebarView.LAYERS;
  17112. break;
  17113. case "none":
  17114. view = SidebarView.NONE;
  17115. break;
  17116. default:
  17117. console.error('Invalid "pagemode" hash parameter: ' + mode);
  17118. return;
  17119. }
  17120. this.pdfSidebar?.switchView(view, true);
  17121. }
  17122. function onNamedAction(evt) {
  17123. switch (evt.action) {
  17124. case "GoToPage":
  17125. this.appConfig.toolbar?.pageNumber.select();
  17126. break;
  17127. case "Find":
  17128. if (!this.supportsIntegratedFind) {
  17129. this.findBar?.toggle();
  17130. }
  17131. break;
  17132. case "Print":
  17133. this.triggerPrinting();
  17134. break;
  17135. case "SaveAs":
  17136. this.downloadOrSave();
  17137. break;
  17138. }
  17139. }
  17140. function onSidebarViewChanged({
  17141. view
  17142. }) {
  17143. this.pdfRenderingQueue.isThumbnailViewEnabled = view === SidebarView.THUMBS;
  17144. if (this.isInitialViewSet) {
  17145. this.store?.set("sidebarView", view).catch(() => {});
  17146. }
  17147. }
  17148. function onUpdateViewarea({
  17149. location
  17150. }) {
  17151. if (this.isInitialViewSet) {
  17152. this.store?.setMultiple({
  17153. page: location.pageNumber,
  17154. zoom: location.scale,
  17155. scrollLeft: location.left,
  17156. scrollTop: location.top,
  17157. rotation: location.rotation
  17158. }).catch(() => {});
  17159. }
  17160. if (this.appConfig.secondaryToolbar) {
  17161. this.appConfig.secondaryToolbar.viewBookmarkButton.href = this.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  17162. }
  17163. }
  17164. function onViewerModesChanged(name, evt) {
  17165. if (this.isInitialViewSet && !this.pdfViewer.isInPresentationMode) {
  17166. this.store?.set(name, evt.mode).catch(() => {});
  17167. }
  17168. }
  17169. function onResize() {
  17170. const {
  17171. pdfDocument,
  17172. pdfViewer,
  17173. pdfRenderingQueue
  17174. } = this;
  17175. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  17176. return;
  17177. }
  17178. if (!pdfDocument) {
  17179. return;
  17180. }
  17181. const currentScaleValue = pdfViewer.currentScaleValue;
  17182. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  17183. pdfViewer.currentScaleValue = currentScaleValue;
  17184. }
  17185. pdfViewer.update();
  17186. }
  17187. function onHashchange(evt) {
  17188. const hash = evt.hash;
  17189. if (!hash) {
  17190. return;
  17191. }
  17192. if (!this.isInitialViewSet) {
  17193. this.initialBookmark = hash;
  17194. } else if (!this.pdfHistory?.popStateInProgress) {
  17195. this.pdfLinkService.setHash(hash);
  17196. }
  17197. }
  17198. function onPageNumberChanged(evt) {
  17199. const {
  17200. pdfViewer
  17201. } = this;
  17202. if (evt.value !== "") {
  17203. this.pdfLinkService.goToPage(evt.value);
  17204. }
  17205. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  17206. this.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  17207. }
  17208. }
  17209. function onImageAltTextSettings() {
  17210. this.imageAltTextSettings?.open({
  17211. enableGuessAltText: AppOptions.get("enableGuessAltText"),
  17212. enableNewAltTextWhenAddingImage: AppOptions.get("enableNewAltTextWhenAddingImage")
  17213. });
  17214. }
  17215. function onFindFromUrlHash(evt) {
  17216. this.eventBus.dispatch("find", {
  17217. source: evt.source,
  17218. type: "",
  17219. query: evt.query,
  17220. caseSensitive: false,
  17221. entireWord: false,
  17222. highlightAll: true,
  17223. findPrevious: false,
  17224. matchDiacritics: true
  17225. });
  17226. }
  17227. function onUpdateFindMatchesCount({
  17228. matchesCount
  17229. }) {
  17230. if (this.supportsIntegratedFind) {
  17231. this.externalServices.updateFindMatchesCount(matchesCount);
  17232. } else {
  17233. this.findBar?.updateResultsCount(matchesCount);
  17234. }
  17235. }
  17236. function onUpdateFindControlState({
  17237. state,
  17238. previous,
  17239. entireWord,
  17240. matchesCount,
  17241. rawQuery
  17242. }) {
  17243. if (this.supportsIntegratedFind) {
  17244. this.externalServices.updateFindControlState({
  17245. result: state,
  17246. findPrevious: previous,
  17247. entireWord,
  17248. matchesCount,
  17249. rawQuery
  17250. });
  17251. } else {
  17252. this.findBar?.updateUIState(state, previous, matchesCount);
  17253. }
  17254. }
  17255. function onScaleChanging(evt) {
  17256. this.toolbar?.setPageScale(evt.presetValue, evt.scale);
  17257. this.pdfViewer.update();
  17258. }
  17259. function onRotationChanging(evt) {
  17260. if (this.pdfThumbnailViewer) {
  17261. this.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  17262. }
  17263. this.forceRendering();
  17264. this.pdfViewer.currentPageNumber = evt.pageNumber;
  17265. }
  17266. function onPageChanging({
  17267. pageNumber,
  17268. pageLabel
  17269. }) {
  17270. this.toolbar?.setPageNumber(pageNumber, pageLabel);
  17271. this.secondaryToolbar?.setPageNumber(pageNumber);
  17272. if (this.pdfSidebar?.visibleView === SidebarView.THUMBS) {
  17273. this.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
  17274. }
  17275. const currentPage = this.pdfViewer.getPageView(pageNumber - 1);
  17276. this.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === RenderingStates.RUNNING);
  17277. }
  17278. function onWheel(evt) {
  17279. const {
  17280. pdfViewer,
  17281. supportsMouseWheelZoomCtrlKey,
  17282. supportsMouseWheelZoomMetaKey,
  17283. supportsPinchToZoom
  17284. } = this;
  17285. if (pdfViewer.isInPresentationMode) {
  17286. return;
  17287. }
  17288. const deltaMode = evt.deltaMode;
  17289. let scaleFactor = Math.exp(-evt.deltaY / 100);
  17290. const isBuiltInMac = false;
  17291. const isPinchToZoom = evt.ctrlKey && !this._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  17292. const origin = [evt.clientX, evt.clientY];
  17293. if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
  17294. evt.preventDefault();
  17295. if (this._isScrolling || document.visibilityState === "hidden" || this.overlayManager.active) {
  17296. return;
  17297. }
  17298. if (isPinchToZoom && supportsPinchToZoom) {
  17299. scaleFactor = this._accumulateFactor(pdfViewer.currentScale, scaleFactor, "_wheelUnusedFactor");
  17300. this.updateZoom(null, scaleFactor, origin);
  17301. } else {
  17302. const delta = normalizeWheelEventDirection(evt);
  17303. let ticks = 0;
  17304. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  17305. ticks = Math.abs(delta) >= 1 ? Math.sign(delta) : this._accumulateTicks(delta, "_wheelUnusedTicks");
  17306. } else {
  17307. const PIXELS_PER_LINE_SCALE = 30;
  17308. ticks = this._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  17309. }
  17310. this.updateZoom(ticks, null, origin);
  17311. }
  17312. }
  17313. }
  17314. function onTouchStart(evt) {
  17315. if (this.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  17316. return;
  17317. }
  17318. evt.preventDefault();
  17319. if (evt.touches.length !== 2 || this.overlayManager.active) {
  17320. this._touchInfo = null;
  17321. return;
  17322. }
  17323. let [touch0, touch1] = evt.touches;
  17324. if (touch0.identifier > touch1.identifier) {
  17325. [touch0, touch1] = [touch1, touch0];
  17326. }
  17327. this._touchInfo = {
  17328. touch0X: touch0.pageX,
  17329. touch0Y: touch0.pageY,
  17330. touch1X: touch1.pageX,
  17331. touch1Y: touch1.pageY
  17332. };
  17333. }
  17334. function onTouchMove(evt) {
  17335. if (!this._touchInfo || evt.touches.length !== 2) {
  17336. return;
  17337. }
  17338. const {
  17339. pdfViewer,
  17340. _touchInfo,
  17341. supportsPinchToZoom
  17342. } = this;
  17343. let [touch0, touch1] = evt.touches;
  17344. if (touch0.identifier > touch1.identifier) {
  17345. [touch0, touch1] = [touch1, touch0];
  17346. }
  17347. const {
  17348. pageX: page0X,
  17349. pageY: page0Y
  17350. } = touch0;
  17351. const {
  17352. pageX: page1X,
  17353. pageY: page1Y
  17354. } = touch1;
  17355. const {
  17356. touch0X: pTouch0X,
  17357. touch0Y: pTouch0Y,
  17358. touch1X: pTouch1X,
  17359. touch1Y: pTouch1Y
  17360. } = _touchInfo;
  17361. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  17362. return;
  17363. }
  17364. _touchInfo.touch0X = page0X;
  17365. _touchInfo.touch0Y = page0Y;
  17366. _touchInfo.touch1X = page1X;
  17367. _touchInfo.touch1Y = page1Y;
  17368. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  17369. const v1X = pTouch1X - page0X;
  17370. const v1Y = pTouch1Y - page0Y;
  17371. const v2X = page1X - page0X;
  17372. const v2Y = page1Y - page0Y;
  17373. const det = v1X * v2Y - v1Y * v2X;
  17374. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  17375. return;
  17376. }
  17377. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  17378. const v1X = pTouch0X - page1X;
  17379. const v1Y = pTouch0Y - page1Y;
  17380. const v2X = page0X - page1X;
  17381. const v2Y = page0Y - page1Y;
  17382. const det = v1X * v2Y - v1Y * v2X;
  17383. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  17384. return;
  17385. }
  17386. } else {
  17387. const diff0X = page0X - pTouch0X;
  17388. const diff1X = page1X - pTouch1X;
  17389. const diff0Y = page0Y - pTouch0Y;
  17390. const diff1Y = page1Y - pTouch1Y;
  17391. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  17392. if (dotProduct >= 0) {
  17393. return;
  17394. }
  17395. }
  17396. evt.preventDefault();
  17397. const origin = [(page0X + page1X) / 2, (page0Y + page1Y) / 2];
  17398. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  17399. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  17400. if (supportsPinchToZoom) {
  17401. const newScaleFactor = this._accumulateFactor(pdfViewer.currentScale, distance / pDistance, "_touchUnusedFactor");
  17402. this.updateZoom(null, newScaleFactor, origin);
  17403. } else {
  17404. const PIXELS_PER_LINE_SCALE = 30;
  17405. const ticks = this._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  17406. this.updateZoom(ticks, null, origin);
  17407. }
  17408. }
  17409. function onTouchEnd(evt) {
  17410. if (!this._touchInfo) {
  17411. return;
  17412. }
  17413. evt.preventDefault();
  17414. this._touchInfo = null;
  17415. this._touchUnusedTicks = 0;
  17416. this._touchUnusedFactor = 1;
  17417. }
  17418. function onClick(evt) {
  17419. if (!this.secondaryToolbar?.isOpen) {
  17420. return;
  17421. }
  17422. const appConfig = this.appConfig;
  17423. if (this.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && !appConfig.secondaryToolbar?.toggleButton.contains(evt.target)) {
  17424. this.secondaryToolbar.close();
  17425. }
  17426. }
  17427. function onKeyUp(evt) {
  17428. if (evt.key === "Control") {
  17429. this._isCtrlKeyDown = false;
  17430. }
  17431. }
  17432. function onKeyDown(evt) {
  17433. this._isCtrlKeyDown = evt.key === "Control";
  17434. if (this.overlayManager.active) {
  17435. return;
  17436. }
  17437. const {
  17438. eventBus,
  17439. pdfViewer
  17440. } = this;
  17441. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  17442. let handled = false,
  17443. ensureViewerFocused = false;
  17444. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  17445. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  17446. switch (evt.keyCode) {
  17447. case 70:
  17448. if (!this.supportsIntegratedFind && !evt.shiftKey) {
  17449. this.findBar?.open();
  17450. handled = true;
  17451. }
  17452. break;
  17453. case 71:
  17454. if (!this.supportsIntegratedFind) {
  17455. const {
  17456. state
  17457. } = this.findController;
  17458. if (state) {
  17459. const newState = {
  17460. source: window,
  17461. type: "again",
  17462. findPrevious: cmd === 5 || cmd === 12
  17463. };
  17464. eventBus.dispatch("find", {
  17465. ...state,
  17466. ...newState
  17467. });
  17468. }
  17469. handled = true;
  17470. }
  17471. break;
  17472. case 61:
  17473. case 107:
  17474. case 187:
  17475. case 171:
  17476. this.zoomIn();
  17477. handled = true;
  17478. break;
  17479. case 173:
  17480. case 109:
  17481. case 189:
  17482. this.zoomOut();
  17483. handled = true;
  17484. break;
  17485. case 48:
  17486. case 96:
  17487. if (!isViewerInPresentationMode) {
  17488. setTimeout(() => {
  17489. this.zoomReset();
  17490. });
  17491. handled = false;
  17492. }
  17493. break;
  17494. case 38:
  17495. if (isViewerInPresentationMode || this.page > 1) {
  17496. this.page = 1;
  17497. handled = true;
  17498. ensureViewerFocused = true;
  17499. }
  17500. break;
  17501. case 40:
  17502. if (isViewerInPresentationMode || this.page < this.pagesCount) {
  17503. this.page = this.pagesCount;
  17504. handled = true;
  17505. ensureViewerFocused = true;
  17506. }
  17507. break;
  17508. }
  17509. }
  17510. if (cmd === 1 || cmd === 8) {
  17511. switch (evt.keyCode) {
  17512. case 83:
  17513. eventBus.dispatch("download", {
  17514. source: window
  17515. });
  17516. handled = true;
  17517. break;
  17518. case 79:
  17519. {
  17520. eventBus.dispatch("openfile", {
  17521. source: window
  17522. });
  17523. handled = true;
  17524. }
  17525. break;
  17526. }
  17527. }
  17528. if (cmd === 3 || cmd === 10) {
  17529. switch (evt.keyCode) {
  17530. case 80:
  17531. this.requestPresentationMode();
  17532. handled = true;
  17533. this.externalServices.reportTelemetry({
  17534. type: "buttons",
  17535. data: {
  17536. id: "presentationModeKeyboard"
  17537. }
  17538. });
  17539. break;
  17540. case 71:
  17541. if (this.appConfig.toolbar) {
  17542. this.appConfig.toolbar.pageNumber.select();
  17543. handled = true;
  17544. }
  17545. break;
  17546. }
  17547. }
  17548. if (handled) {
  17549. if (ensureViewerFocused && !isViewerInPresentationMode) {
  17550. pdfViewer.focus();
  17551. }
  17552. evt.preventDefault();
  17553. return;
  17554. }
  17555. const curElement = getActiveOrFocusedElement();
  17556. const curElementTagName = curElement?.tagName.toUpperCase();
  17557. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElementTagName === "BUTTON" && (evt.keyCode === 13 || evt.keyCode === 32) || curElement?.isContentEditable) {
  17558. if (evt.keyCode !== 27) {
  17559. return;
  17560. }
  17561. }
  17562. if (cmd === 0) {
  17563. let turnPage = 0,
  17564. turnOnlyIfPageFit = false;
  17565. switch (evt.keyCode) {
  17566. case 38:
  17567. if (this.supportsCaretBrowsingMode) {
  17568. this.moveCaret(true, false);
  17569. handled = true;
  17570. break;
  17571. }
  17572. case 33:
  17573. if (pdfViewer.isVerticalScrollbarEnabled) {
  17574. turnOnlyIfPageFit = true;
  17575. }
  17576. turnPage = -1;
  17577. break;
  17578. case 8:
  17579. if (!isViewerInPresentationMode) {
  17580. turnOnlyIfPageFit = true;
  17581. }
  17582. turnPage = -1;
  17583. break;
  17584. case 37:
  17585. if (this.supportsCaretBrowsingMode) {
  17586. return;
  17587. }
  17588. if (pdfViewer.isHorizontalScrollbarEnabled) {
  17589. turnOnlyIfPageFit = true;
  17590. }
  17591. case 75:
  17592. case 80:
  17593. turnPage = -1;
  17594. break;
  17595. case 27:
  17596. if (this.secondaryToolbar?.isOpen) {
  17597. this.secondaryToolbar.close();
  17598. handled = true;
  17599. }
  17600. if (!this.supportsIntegratedFind && this.findBar?.opened) {
  17601. this.findBar.close();
  17602. handled = true;
  17603. }
  17604. break;
  17605. case 40:
  17606. if (this.supportsCaretBrowsingMode) {
  17607. this.moveCaret(false, false);
  17608. handled = true;
  17609. break;
  17610. }
  17611. case 34:
  17612. if (pdfViewer.isVerticalScrollbarEnabled) {
  17613. turnOnlyIfPageFit = true;
  17614. }
  17615. turnPage = 1;
  17616. break;
  17617. case 13:
  17618. case 32:
  17619. if (!isViewerInPresentationMode) {
  17620. turnOnlyIfPageFit = true;
  17621. }
  17622. turnPage = 1;
  17623. break;
  17624. case 39:
  17625. if (this.supportsCaretBrowsingMode) {
  17626. return;
  17627. }
  17628. if (pdfViewer.isHorizontalScrollbarEnabled) {
  17629. turnOnlyIfPageFit = true;
  17630. }
  17631. case 74:
  17632. case 78:
  17633. turnPage = 1;
  17634. break;
  17635. case 36:
  17636. if (isViewerInPresentationMode || this.page > 1) {
  17637. this.page = 1;
  17638. handled = true;
  17639. ensureViewerFocused = true;
  17640. }
  17641. break;
  17642. case 35:
  17643. if (isViewerInPresentationMode || this.page < this.pagesCount) {
  17644. this.page = this.pagesCount;
  17645. handled = true;
  17646. ensureViewerFocused = true;
  17647. }
  17648. break;
  17649. case 83:
  17650. this.pdfCursorTools?.switchTool(CursorTool.SELECT);
  17651. break;
  17652. case 72:
  17653. this.pdfCursorTools?.switchTool(CursorTool.HAND);
  17654. break;
  17655. case 82:
  17656. this.rotatePages(90);
  17657. break;
  17658. case 115:
  17659. this.pdfSidebar?.toggle();
  17660. break;
  17661. }
  17662. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  17663. if (turnPage > 0) {
  17664. pdfViewer.nextPage();
  17665. } else {
  17666. pdfViewer.previousPage();
  17667. }
  17668. handled = true;
  17669. }
  17670. }
  17671. if (cmd === 4) {
  17672. switch (evt.keyCode) {
  17673. case 13:
  17674. case 32:
  17675. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  17676. break;
  17677. }
  17678. pdfViewer.previousPage();
  17679. handled = true;
  17680. break;
  17681. case 38:
  17682. this.moveCaret(true, true);
  17683. handled = true;
  17684. break;
  17685. case 40:
  17686. this.moveCaret(false, true);
  17687. handled = true;
  17688. break;
  17689. case 82:
  17690. this.rotatePages(-90);
  17691. break;
  17692. }
  17693. }
  17694. if (!handled && !isViewerInPresentationMode) {
  17695. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  17696. ensureViewerFocused = true;
  17697. }
  17698. }
  17699. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  17700. pdfViewer.focus();
  17701. }
  17702. if (handled) {
  17703. evt.preventDefault();
  17704. }
  17705. }
  17706. function beforeUnload(evt) {
  17707. evt.preventDefault();
  17708. evt.returnValue = "";
  17709. return false;
  17710. }
  17711. ;// ./web/viewer.js
  17712. const pdfjsVersion = "4.7.76";
  17713. const pdfjsBuild = "8b73b828b";
  17714. const AppConstants = {
  17715. LinkTarget: LinkTarget,
  17716. RenderingStates: RenderingStates,
  17717. ScrollMode: ScrollMode,
  17718. SpreadMode: SpreadMode
  17719. };
  17720. window.PDFViewerApplication = PDFViewerApplication;
  17721. window.PDFViewerApplicationConstants = AppConstants;
  17722. window.PDFViewerApplicationOptions = AppOptions;
  17723. function getViewerConfiguration() {
  17724. return {
  17725. appContainer: document.body,
  17726. principalContainer: document.getElementById("mainContainer"),
  17727. mainContainer: document.getElementById("viewerContainer"),
  17728. viewerContainer: document.getElementById("viewer"),
  17729. toolbar: {
  17730. container: document.getElementById("toolbarContainer"),
  17731. numPages: document.getElementById("numPages"),
  17732. pageNumber: document.getElementById("pageNumber"),
  17733. scaleSelect: document.getElementById("scaleSelect"),
  17734. customScaleOption: document.getElementById("customScaleOption"),
  17735. previous: document.getElementById("previous"),
  17736. next: document.getElementById("next"),
  17737. zoomIn: document.getElementById("zoomInButton"),
  17738. zoomOut: document.getElementById("zoomOutButton"),
  17739. print: document.getElementById("printButton"),
  17740. editorFreeTextButton: document.getElementById("editorFreeTextButton"),
  17741. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  17742. editorHighlightButton: document.getElementById("editorHighlightButton"),
  17743. editorHighlightParamsToolbar: document.getElementById("editorHighlightParamsToolbar"),
  17744. editorHighlightColorPicker: document.getElementById("editorHighlightColorPicker"),
  17745. editorInkButton: document.getElementById("editorInkButton"),
  17746. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  17747. editorStampButton: document.getElementById("editorStampButton"),
  17748. editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"),
  17749. download: document.getElementById("downloadButton")
  17750. },
  17751. secondaryToolbar: {
  17752. toolbar: document.getElementById("secondaryToolbar"),
  17753. toggleButton: document.getElementById("secondaryToolbarToggleButton"),
  17754. presentationModeButton: document.getElementById("presentationMode"),
  17755. openFileButton: document.getElementById("secondaryOpenFile"),
  17756. printButton: document.getElementById("secondaryPrint"),
  17757. downloadButton: document.getElementById("secondaryDownload"),
  17758. viewBookmarkButton: document.getElementById("viewBookmark"),
  17759. firstPageButton: document.getElementById("firstPage"),
  17760. lastPageButton: document.getElementById("lastPage"),
  17761. pageRotateCwButton: document.getElementById("pageRotateCw"),
  17762. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  17763. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  17764. cursorHandToolButton: document.getElementById("cursorHandTool"),
  17765. scrollPageButton: document.getElementById("scrollPage"),
  17766. scrollVerticalButton: document.getElementById("scrollVertical"),
  17767. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  17768. scrollWrappedButton: document.getElementById("scrollWrapped"),
  17769. spreadNoneButton: document.getElementById("spreadNone"),
  17770. spreadOddButton: document.getElementById("spreadOdd"),
  17771. spreadEvenButton: document.getElementById("spreadEven"),
  17772. imageAltTextSettingsButton: document.getElementById("imageAltTextSettings"),
  17773. imageAltTextSettingsSeparator: document.getElementById("imageAltTextSettingsSeparator"),
  17774. documentPropertiesButton: document.getElementById("documentProperties")
  17775. },
  17776. sidebar: {
  17777. outerContainer: document.getElementById("outerContainer"),
  17778. sidebarContainer: document.getElementById("sidebarContainer"),
  17779. toggleButton: document.getElementById("sidebarToggleButton"),
  17780. resizer: document.getElementById("sidebarResizer"),
  17781. thumbnailButton: document.getElementById("viewThumbnail"),
  17782. outlineButton: document.getElementById("viewOutline"),
  17783. attachmentsButton: document.getElementById("viewAttachments"),
  17784. layersButton: document.getElementById("viewLayers"),
  17785. thumbnailView: document.getElementById("thumbnailView"),
  17786. outlineView: document.getElementById("outlineView"),
  17787. attachmentsView: document.getElementById("attachmentsView"),
  17788. layersView: document.getElementById("layersView"),
  17789. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  17790. },
  17791. findBar: {
  17792. bar: document.getElementById("findbar"),
  17793. toggleButton: document.getElementById("viewFindButton"),
  17794. findField: document.getElementById("findInput"),
  17795. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  17796. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  17797. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  17798. entireWordCheckbox: document.getElementById("findEntireWord"),
  17799. findMsg: document.getElementById("findMsg"),
  17800. findResultsCount: document.getElementById("findResultsCount"),
  17801. findPreviousButton: document.getElementById("findPreviousButton"),
  17802. findNextButton: document.getElementById("findNextButton")
  17803. },
  17804. passwordOverlay: {
  17805. dialog: document.getElementById("passwordDialog"),
  17806. label: document.getElementById("passwordText"),
  17807. input: document.getElementById("password"),
  17808. submitButton: document.getElementById("passwordSubmit"),
  17809. cancelButton: document.getElementById("passwordCancel")
  17810. },
  17811. documentProperties: {
  17812. dialog: document.getElementById("documentPropertiesDialog"),
  17813. closeButton: document.getElementById("documentPropertiesClose"),
  17814. fields: {
  17815. fileName: document.getElementById("fileNameField"),
  17816. fileSize: document.getElementById("fileSizeField"),
  17817. title: document.getElementById("titleField"),
  17818. author: document.getElementById("authorField"),
  17819. subject: document.getElementById("subjectField"),
  17820. keywords: document.getElementById("keywordsField"),
  17821. creationDate: document.getElementById("creationDateField"),
  17822. modificationDate: document.getElementById("modificationDateField"),
  17823. creator: document.getElementById("creatorField"),
  17824. producer: document.getElementById("producerField"),
  17825. version: document.getElementById("versionField"),
  17826. pageCount: document.getElementById("pageCountField"),
  17827. pageSize: document.getElementById("pageSizeField"),
  17828. linearized: document.getElementById("linearizedField")
  17829. }
  17830. },
  17831. altTextDialog: {
  17832. dialog: document.getElementById("altTextDialog"),
  17833. optionDescription: document.getElementById("descriptionButton"),
  17834. optionDecorative: document.getElementById("decorativeButton"),
  17835. textarea: document.getElementById("descriptionTextarea"),
  17836. cancelButton: document.getElementById("altTextCancel"),
  17837. saveButton: document.getElementById("altTextSave")
  17838. },
  17839. newAltTextDialog: {
  17840. dialog: document.getElementById("newAltTextDialog"),
  17841. title: document.getElementById("newAltTextTitle"),
  17842. descriptionContainer: document.getElementById("newAltTextDescriptionContainer"),
  17843. textarea: document.getElementById("newAltTextDescriptionTextarea"),
  17844. disclaimer: document.getElementById("newAltTextDisclaimer"),
  17845. learnMore: document.getElementById("newAltTextLearnMore"),
  17846. imagePreview: document.getElementById("newAltTextImagePreview"),
  17847. createAutomatically: document.getElementById("newAltTextCreateAutomatically"),
  17848. createAutomaticallyButton: document.getElementById("newAltTextCreateAutomaticallyButton"),
  17849. downloadModel: document.getElementById("newAltTextDownloadModel"),
  17850. downloadModelDescription: document.getElementById("newAltTextDownloadModelDescription"),
  17851. error: document.getElementById("newAltTextError"),
  17852. errorCloseButton: document.getElementById("newAltTextCloseButton"),
  17853. cancelButton: document.getElementById("newAltTextCancel"),
  17854. notNowButton: document.getElementById("newAltTextNotNow"),
  17855. saveButton: document.getElementById("newAltTextSave")
  17856. },
  17857. altTextSettingsDialog: {
  17858. dialog: document.getElementById("altTextSettingsDialog"),
  17859. createModelButton: document.getElementById("createModelButton"),
  17860. aiModelSettings: document.getElementById("aiModelSettings"),
  17861. learnMore: document.getElementById("altTextSettingsLearnMore"),
  17862. deleteModelButton: document.getElementById("deleteModelButton"),
  17863. downloadModelButton: document.getElementById("downloadModelButton"),
  17864. showAltTextDialogButton: document.getElementById("showAltTextDialogButton"),
  17865. altTextSettingsCloseButton: document.getElementById("altTextSettingsCloseButton"),
  17866. closeButton: document.getElementById("altTextSettingsCloseButton")
  17867. },
  17868. annotationEditorParams: {
  17869. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  17870. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  17871. editorInkColor: document.getElementById("editorInkColor"),
  17872. editorInkThickness: document.getElementById("editorInkThickness"),
  17873. editorInkOpacity: document.getElementById("editorInkOpacity"),
  17874. editorStampAddImage: document.getElementById("editorStampAddImage"),
  17875. editorFreeHighlightThickness: document.getElementById("editorFreeHighlightThickness"),
  17876. editorHighlightShowAll: document.getElementById("editorHighlightShowAll")
  17877. },
  17878. printContainer: document.getElementById("printContainer")
  17879. };
  17880. }
  17881. function webViewerLoad() {
  17882. const config = getViewerConfiguration();
  17883. const event = new CustomEvent("webviewerloaded", {
  17884. bubbles: true,
  17885. cancelable: true,
  17886. detail: {
  17887. source: window
  17888. }
  17889. });
  17890. try {
  17891. parent.document.dispatchEvent(event);
  17892. } catch (ex) {
  17893. console.error(`webviewerloaded: ${ex}`);
  17894. document.dispatchEvent(event);
  17895. }
  17896. PDFViewerApplication.run(config);
  17897. }
  17898. document.blockUnblockOnload?.(true);
  17899. if (document.readyState === "interactive" || document.readyState === "complete") {
  17900. webViewerLoad();
  17901. } else {
  17902. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  17903. }
  17904. var __webpack_exports__PDFViewerApplication = __webpack_exports__.PDFViewerApplication;
  17905. var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFViewerApplicationConstants;
  17906. var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions;
  17907. export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };
  17908. //# sourceMappingURL=viewer.mjs.map