viewer.mjs 516 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. /******/ var __webpack_modules__ = ({
  23. /***/ 588:
  24. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  25. // EXPORTS
  26. __webpack_require__.d(__webpack_exports__, {
  27. FluentBundle: () => (/* reexport */ FluentBundle),
  28. FluentResource: () => (/* reexport */ FluentResource)
  29. });
  30. // UNUSED EXPORTS: FluentDateTime, FluentNone, FluentNumber, FluentType
  31. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/types.js
  32. class FluentType {
  33. constructor(value) {
  34. this.value = value;
  35. }
  36. valueOf() {
  37. return this.value;
  38. }
  39. }
  40. class FluentNone extends FluentType {
  41. constructor(value = "???") {
  42. super(value);
  43. }
  44. toString(scope) {
  45. return `{${this.value}}`;
  46. }
  47. }
  48. class FluentNumber extends FluentType {
  49. constructor(value, opts = {}) {
  50. super(value);
  51. this.opts = opts;
  52. }
  53. toString(scope) {
  54. try {
  55. const nf = scope.memoizeIntlObject(Intl.NumberFormat, this.opts);
  56. return nf.format(this.value);
  57. } catch (err) {
  58. scope.reportError(err);
  59. return this.value.toString(10);
  60. }
  61. }
  62. }
  63. class FluentDateTime extends FluentType {
  64. constructor(value, opts = {}) {
  65. super(value);
  66. this.opts = opts;
  67. }
  68. toString(scope) {
  69. try {
  70. const dtf = scope.memoizeIntlObject(Intl.DateTimeFormat, this.opts);
  71. return dtf.format(this.value);
  72. } catch (err) {
  73. scope.reportError(err);
  74. return new Date(this.value).toISOString();
  75. }
  76. }
  77. }
  78. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resolver.js
  79. const MAX_PLACEABLES = 100;
  80. const FSI = "\u2068";
  81. const PDI = "\u2069";
  82. function match(scope, selector, key) {
  83. if (key === selector) {
  84. return true;
  85. }
  86. if (key instanceof FluentNumber && selector instanceof FluentNumber && key.value === selector.value) {
  87. return true;
  88. }
  89. if (selector instanceof FluentNumber && typeof key === "string") {
  90. let category = scope.memoizeIntlObject(Intl.PluralRules, selector.opts).select(selector.value);
  91. if (key === category) {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. function getDefault(scope, variants, star) {
  98. if (variants[star]) {
  99. return resolvePattern(scope, variants[star].value);
  100. }
  101. scope.reportError(new RangeError("No default"));
  102. return new FluentNone();
  103. }
  104. function getArguments(scope, args) {
  105. const positional = [];
  106. const named = Object.create(null);
  107. for (const arg of args) {
  108. if (arg.type === "narg") {
  109. named[arg.name] = resolveExpression(scope, arg.value);
  110. } else {
  111. positional.push(resolveExpression(scope, arg));
  112. }
  113. }
  114. return {
  115. positional,
  116. named
  117. };
  118. }
  119. function resolveExpression(scope, expr) {
  120. switch (expr.type) {
  121. case "str":
  122. return expr.value;
  123. case "num":
  124. return new FluentNumber(expr.value, {
  125. minimumFractionDigits: expr.precision
  126. });
  127. case "var":
  128. return resolveVariableReference(scope, expr);
  129. case "mesg":
  130. return resolveMessageReference(scope, expr);
  131. case "term":
  132. return resolveTermReference(scope, expr);
  133. case "func":
  134. return resolveFunctionReference(scope, expr);
  135. case "select":
  136. return resolveSelectExpression(scope, expr);
  137. default:
  138. return new FluentNone();
  139. }
  140. }
  141. function resolveVariableReference(scope, {
  142. name
  143. }) {
  144. let arg;
  145. if (scope.params) {
  146. if (Object.prototype.hasOwnProperty.call(scope.params, name)) {
  147. arg = scope.params[name];
  148. } else {
  149. return new FluentNone(`$${name}`);
  150. }
  151. } else if (scope.args && Object.prototype.hasOwnProperty.call(scope.args, name)) {
  152. arg = scope.args[name];
  153. } else {
  154. scope.reportError(new ReferenceError(`Unknown variable: $${name}`));
  155. return new FluentNone(`$${name}`);
  156. }
  157. if (arg instanceof FluentType) {
  158. return arg;
  159. }
  160. switch (typeof arg) {
  161. case "string":
  162. return arg;
  163. case "number":
  164. return new FluentNumber(arg);
  165. case "object":
  166. if (arg instanceof Date) {
  167. return new FluentDateTime(arg.getTime());
  168. }
  169. default:
  170. scope.reportError(new TypeError(`Variable type not supported: $${name}, ${typeof arg}`));
  171. return new FluentNone(`$${name}`);
  172. }
  173. }
  174. function resolveMessageReference(scope, {
  175. name,
  176. attr
  177. }) {
  178. const message = scope.bundle._messages.get(name);
  179. if (!message) {
  180. scope.reportError(new ReferenceError(`Unknown message: ${name}`));
  181. return new FluentNone(name);
  182. }
  183. if (attr) {
  184. const attribute = message.attributes[attr];
  185. if (attribute) {
  186. return resolvePattern(scope, attribute);
  187. }
  188. scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
  189. return new FluentNone(`${name}.${attr}`);
  190. }
  191. if (message.value) {
  192. return resolvePattern(scope, message.value);
  193. }
  194. scope.reportError(new ReferenceError(`No value: ${name}`));
  195. return new FluentNone(name);
  196. }
  197. function resolveTermReference(scope, {
  198. name,
  199. attr,
  200. args
  201. }) {
  202. const id = `-${name}`;
  203. const term = scope.bundle._terms.get(id);
  204. if (!term) {
  205. scope.reportError(new ReferenceError(`Unknown term: ${id}`));
  206. return new FluentNone(id);
  207. }
  208. if (attr) {
  209. const attribute = term.attributes[attr];
  210. if (attribute) {
  211. scope.params = getArguments(scope, args).named;
  212. const resolved = resolvePattern(scope, attribute);
  213. scope.params = null;
  214. return resolved;
  215. }
  216. scope.reportError(new ReferenceError(`Unknown attribute: ${attr}`));
  217. return new FluentNone(`${id}.${attr}`);
  218. }
  219. scope.params = getArguments(scope, args).named;
  220. const resolved = resolvePattern(scope, term.value);
  221. scope.params = null;
  222. return resolved;
  223. }
  224. function resolveFunctionReference(scope, {
  225. name,
  226. args
  227. }) {
  228. let func = scope.bundle._functions[name];
  229. if (!func) {
  230. scope.reportError(new ReferenceError(`Unknown function: ${name}()`));
  231. return new FluentNone(`${name}()`);
  232. }
  233. if (typeof func !== "function") {
  234. scope.reportError(new TypeError(`Function ${name}() is not callable`));
  235. return new FluentNone(`${name}()`);
  236. }
  237. try {
  238. let resolved = getArguments(scope, args);
  239. return func(resolved.positional, resolved.named);
  240. } catch (err) {
  241. scope.reportError(err);
  242. return new FluentNone(`${name}()`);
  243. }
  244. }
  245. function resolveSelectExpression(scope, {
  246. selector,
  247. variants,
  248. star
  249. }) {
  250. let sel = resolveExpression(scope, selector);
  251. if (sel instanceof FluentNone) {
  252. return getDefault(scope, variants, star);
  253. }
  254. for (const variant of variants) {
  255. const key = resolveExpression(scope, variant.key);
  256. if (match(scope, sel, key)) {
  257. return resolvePattern(scope, variant.value);
  258. }
  259. }
  260. return getDefault(scope, variants, star);
  261. }
  262. function resolveComplexPattern(scope, ptn) {
  263. if (scope.dirty.has(ptn)) {
  264. scope.reportError(new RangeError("Cyclic reference"));
  265. return new FluentNone();
  266. }
  267. scope.dirty.add(ptn);
  268. const result = [];
  269. const useIsolating = scope.bundle._useIsolating && ptn.length > 1;
  270. for (const elem of ptn) {
  271. if (typeof elem === "string") {
  272. result.push(scope.bundle._transform(elem));
  273. continue;
  274. }
  275. scope.placeables++;
  276. if (scope.placeables > MAX_PLACEABLES) {
  277. scope.dirty.delete(ptn);
  278. throw new RangeError(`Too many placeables expanded: ${scope.placeables}, ` + `max allowed is ${MAX_PLACEABLES}`);
  279. }
  280. if (useIsolating) {
  281. result.push(FSI);
  282. }
  283. result.push(resolveExpression(scope, elem).toString(scope));
  284. if (useIsolating) {
  285. result.push(PDI);
  286. }
  287. }
  288. scope.dirty.delete(ptn);
  289. return result.join("");
  290. }
  291. function resolvePattern(scope, value) {
  292. if (typeof value === "string") {
  293. return scope.bundle._transform(value);
  294. }
  295. return resolveComplexPattern(scope, value);
  296. }
  297. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/scope.js
  298. class Scope {
  299. constructor(bundle, errors, args) {
  300. this.dirty = new WeakSet();
  301. this.params = null;
  302. this.placeables = 0;
  303. this.bundle = bundle;
  304. this.errors = errors;
  305. this.args = args;
  306. }
  307. reportError(error) {
  308. if (!this.errors || !(error instanceof Error)) {
  309. throw error;
  310. }
  311. this.errors.push(error);
  312. }
  313. memoizeIntlObject(ctor, opts) {
  314. let cache = this.bundle._intls.get(ctor);
  315. if (!cache) {
  316. cache = {};
  317. this.bundle._intls.set(ctor, cache);
  318. }
  319. let id = JSON.stringify(opts);
  320. if (!cache[id]) {
  321. cache[id] = new ctor(this.bundle.locales, opts);
  322. }
  323. return cache[id];
  324. }
  325. }
  326. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/builtins.js
  327. function values(opts, allowed) {
  328. const unwrapped = Object.create(null);
  329. for (const [name, opt] of Object.entries(opts)) {
  330. if (allowed.includes(name)) {
  331. unwrapped[name] = opt.valueOf();
  332. }
  333. }
  334. return unwrapped;
  335. }
  336. const NUMBER_ALLOWED = ["unitDisplay", "currencyDisplay", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"];
  337. function NUMBER(args, opts) {
  338. let arg = args[0];
  339. if (arg instanceof FluentNone) {
  340. return new FluentNone(`NUMBER(${arg.valueOf()})`);
  341. }
  342. if (arg instanceof FluentNumber) {
  343. return new FluentNumber(arg.valueOf(), {
  344. ...arg.opts,
  345. ...values(opts, NUMBER_ALLOWED)
  346. });
  347. }
  348. if (arg instanceof FluentDateTime) {
  349. return new FluentNumber(arg.valueOf(), {
  350. ...values(opts, NUMBER_ALLOWED)
  351. });
  352. }
  353. throw new TypeError("Invalid argument to NUMBER");
  354. }
  355. const DATETIME_ALLOWED = ["dateStyle", "timeStyle", "fractionalSecondDigits", "dayPeriod", "hour12", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"];
  356. function DATETIME(args, opts) {
  357. let arg = args[0];
  358. if (arg instanceof FluentNone) {
  359. return new FluentNone(`DATETIME(${arg.valueOf()})`);
  360. }
  361. if (arg instanceof FluentDateTime) {
  362. return new FluentDateTime(arg.valueOf(), {
  363. ...arg.opts,
  364. ...values(opts, DATETIME_ALLOWED)
  365. });
  366. }
  367. if (arg instanceof FluentNumber) {
  368. return new FluentDateTime(arg.valueOf(), {
  369. ...values(opts, DATETIME_ALLOWED)
  370. });
  371. }
  372. throw new TypeError("Invalid argument to DATETIME");
  373. }
  374. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/memoizer.js
  375. const cache = new Map();
  376. function getMemoizerForLocale(locales) {
  377. const stringLocale = Array.isArray(locales) ? locales.join(" ") : locales;
  378. let memoizer = cache.get(stringLocale);
  379. if (memoizer === undefined) {
  380. memoizer = new Map();
  381. cache.set(stringLocale, memoizer);
  382. }
  383. return memoizer;
  384. }
  385. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/bundle.js
  386. class FluentBundle {
  387. constructor(locales, {
  388. functions,
  389. useIsolating = true,
  390. transform = v => v
  391. } = {}) {
  392. this._terms = new Map();
  393. this._messages = new Map();
  394. this.locales = Array.isArray(locales) ? locales : [locales];
  395. this._functions = {
  396. NUMBER: NUMBER,
  397. DATETIME: DATETIME,
  398. ...functions
  399. };
  400. this._useIsolating = useIsolating;
  401. this._transform = transform;
  402. this._intls = getMemoizerForLocale(locales);
  403. }
  404. hasMessage(id) {
  405. return this._messages.has(id);
  406. }
  407. getMessage(id) {
  408. return this._messages.get(id);
  409. }
  410. addResource(res, {
  411. allowOverrides = false
  412. } = {}) {
  413. const errors = [];
  414. for (let i = 0; i < res.body.length; i++) {
  415. let entry = res.body[i];
  416. if (entry.id.startsWith("-")) {
  417. if (allowOverrides === false && this._terms.has(entry.id)) {
  418. errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`));
  419. continue;
  420. }
  421. this._terms.set(entry.id, entry);
  422. } else {
  423. if (allowOverrides === false && this._messages.has(entry.id)) {
  424. errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`));
  425. continue;
  426. }
  427. this._messages.set(entry.id, entry);
  428. }
  429. }
  430. return errors;
  431. }
  432. formatPattern(pattern, args = null, errors = null) {
  433. if (typeof pattern === "string") {
  434. return this._transform(pattern);
  435. }
  436. let scope = new Scope(this, errors, args);
  437. try {
  438. let value = resolveComplexPattern(scope, pattern);
  439. return value.toString(scope);
  440. } catch (err) {
  441. if (scope.errors && err instanceof Error) {
  442. scope.errors.push(err);
  443. return new FluentNone().toString(scope);
  444. }
  445. throw err;
  446. }
  447. }
  448. }
  449. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/resource.js
  450. const RE_MESSAGE_START = /^(-?[a-zA-Z][\w-]*) *= */gm;
  451. const RE_ATTRIBUTE_START = /\.([a-zA-Z][\w-]*) *= */y;
  452. const RE_VARIANT_START = /\*?\[/y;
  453. const RE_NUMBER_LITERAL = /(-?[0-9]+(?:\.([0-9]+))?)/y;
  454. const RE_IDENTIFIER = /([a-zA-Z][\w-]*)/y;
  455. const RE_REFERENCE = /([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y;
  456. const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/;
  457. const RE_TEXT_RUN = /([^{}\n\r]+)/y;
  458. const RE_STRING_RUN = /([^\\"\n\r]*)/y;
  459. const RE_STRING_ESCAPE = /\\([\\"])/y;
  460. const RE_UNICODE_ESCAPE = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y;
  461. const RE_LEADING_NEWLINES = /^\n+/;
  462. const RE_TRAILING_SPACES = / +$/;
  463. const RE_BLANK_LINES = / *\r?\n/g;
  464. const RE_INDENT = /( *)$/;
  465. const TOKEN_BRACE_OPEN = /{\s*/y;
  466. const TOKEN_BRACE_CLOSE = /\s*}/y;
  467. const TOKEN_BRACKET_OPEN = /\[\s*/y;
  468. const TOKEN_BRACKET_CLOSE = /\s*] */y;
  469. const TOKEN_PAREN_OPEN = /\s*\(\s*/y;
  470. const TOKEN_ARROW = /\s*->\s*/y;
  471. const TOKEN_COLON = /\s*:\s*/y;
  472. const TOKEN_COMMA = /\s*,?\s*/y;
  473. const TOKEN_BLANK = /\s+/y;
  474. class FluentResource {
  475. constructor(source) {
  476. this.body = [];
  477. RE_MESSAGE_START.lastIndex = 0;
  478. let cursor = 0;
  479. while (true) {
  480. let next = RE_MESSAGE_START.exec(source);
  481. if (next === null) {
  482. break;
  483. }
  484. cursor = RE_MESSAGE_START.lastIndex;
  485. try {
  486. this.body.push(parseMessage(next[1]));
  487. } catch (err) {
  488. if (err instanceof SyntaxError) {
  489. continue;
  490. }
  491. throw err;
  492. }
  493. }
  494. function test(re) {
  495. re.lastIndex = cursor;
  496. return re.test(source);
  497. }
  498. function consumeChar(char, errorClass) {
  499. if (source[cursor] === char) {
  500. cursor++;
  501. return true;
  502. }
  503. if (errorClass) {
  504. throw new errorClass(`Expected ${char}`);
  505. }
  506. return false;
  507. }
  508. function consumeToken(re, errorClass) {
  509. if (test(re)) {
  510. cursor = re.lastIndex;
  511. return true;
  512. }
  513. if (errorClass) {
  514. throw new errorClass(`Expected ${re.toString()}`);
  515. }
  516. return false;
  517. }
  518. function match(re) {
  519. re.lastIndex = cursor;
  520. let result = re.exec(source);
  521. if (result === null) {
  522. throw new SyntaxError(`Expected ${re.toString()}`);
  523. }
  524. cursor = re.lastIndex;
  525. return result;
  526. }
  527. function match1(re) {
  528. return match(re)[1];
  529. }
  530. function parseMessage(id) {
  531. let value = parsePattern();
  532. let attributes = parseAttributes();
  533. if (value === null && Object.keys(attributes).length === 0) {
  534. throw new SyntaxError("Expected message value or attributes");
  535. }
  536. return {
  537. id,
  538. value,
  539. attributes
  540. };
  541. }
  542. function parseAttributes() {
  543. let attrs = Object.create(null);
  544. while (test(RE_ATTRIBUTE_START)) {
  545. let name = match1(RE_ATTRIBUTE_START);
  546. let value = parsePattern();
  547. if (value === null) {
  548. throw new SyntaxError("Expected attribute value");
  549. }
  550. attrs[name] = value;
  551. }
  552. return attrs;
  553. }
  554. function parsePattern() {
  555. let first;
  556. if (test(RE_TEXT_RUN)) {
  557. first = match1(RE_TEXT_RUN);
  558. }
  559. if (source[cursor] === "{" || source[cursor] === "}") {
  560. return parsePatternElements(first ? [first] : [], Infinity);
  561. }
  562. let indent = parseIndent();
  563. if (indent) {
  564. if (first) {
  565. return parsePatternElements([first, indent], indent.length);
  566. }
  567. indent.value = trim(indent.value, RE_LEADING_NEWLINES);
  568. return parsePatternElements([indent], indent.length);
  569. }
  570. if (first) {
  571. return trim(first, RE_TRAILING_SPACES);
  572. }
  573. return null;
  574. }
  575. function parsePatternElements(elements = [], commonIndent) {
  576. while (true) {
  577. if (test(RE_TEXT_RUN)) {
  578. elements.push(match1(RE_TEXT_RUN));
  579. continue;
  580. }
  581. if (source[cursor] === "{") {
  582. elements.push(parsePlaceable());
  583. continue;
  584. }
  585. if (source[cursor] === "}") {
  586. throw new SyntaxError("Unbalanced closing brace");
  587. }
  588. let indent = parseIndent();
  589. if (indent) {
  590. elements.push(indent);
  591. commonIndent = Math.min(commonIndent, indent.length);
  592. continue;
  593. }
  594. break;
  595. }
  596. let lastIndex = elements.length - 1;
  597. let lastElement = elements[lastIndex];
  598. if (typeof lastElement === "string") {
  599. elements[lastIndex] = trim(lastElement, RE_TRAILING_SPACES);
  600. }
  601. let baked = [];
  602. for (let element of elements) {
  603. if (element instanceof Indent) {
  604. element = element.value.slice(0, element.value.length - commonIndent);
  605. }
  606. if (element) {
  607. baked.push(element);
  608. }
  609. }
  610. return baked;
  611. }
  612. function parsePlaceable() {
  613. consumeToken(TOKEN_BRACE_OPEN, SyntaxError);
  614. let selector = parseInlineExpression();
  615. if (consumeToken(TOKEN_BRACE_CLOSE)) {
  616. return selector;
  617. }
  618. if (consumeToken(TOKEN_ARROW)) {
  619. let variants = parseVariants();
  620. consumeToken(TOKEN_BRACE_CLOSE, SyntaxError);
  621. return {
  622. type: "select",
  623. selector,
  624. ...variants
  625. };
  626. }
  627. throw new SyntaxError("Unclosed placeable");
  628. }
  629. function parseInlineExpression() {
  630. if (source[cursor] === "{") {
  631. return parsePlaceable();
  632. }
  633. if (test(RE_REFERENCE)) {
  634. let [, sigil, name, attr = null] = match(RE_REFERENCE);
  635. if (sigil === "$") {
  636. return {
  637. type: "var",
  638. name
  639. };
  640. }
  641. if (consumeToken(TOKEN_PAREN_OPEN)) {
  642. let args = parseArguments();
  643. if (sigil === "-") {
  644. return {
  645. type: "term",
  646. name,
  647. attr,
  648. args
  649. };
  650. }
  651. if (RE_FUNCTION_NAME.test(name)) {
  652. return {
  653. type: "func",
  654. name,
  655. args
  656. };
  657. }
  658. throw new SyntaxError("Function names must be all upper-case");
  659. }
  660. if (sigil === "-") {
  661. return {
  662. type: "term",
  663. name,
  664. attr,
  665. args: []
  666. };
  667. }
  668. return {
  669. type: "mesg",
  670. name,
  671. attr
  672. };
  673. }
  674. return parseLiteral();
  675. }
  676. function parseArguments() {
  677. let args = [];
  678. while (true) {
  679. switch (source[cursor]) {
  680. case ")":
  681. cursor++;
  682. return args;
  683. case undefined:
  684. throw new SyntaxError("Unclosed argument list");
  685. }
  686. args.push(parseArgument());
  687. consumeToken(TOKEN_COMMA);
  688. }
  689. }
  690. function parseArgument() {
  691. let expr = parseInlineExpression();
  692. if (expr.type !== "mesg") {
  693. return expr;
  694. }
  695. if (consumeToken(TOKEN_COLON)) {
  696. return {
  697. type: "narg",
  698. name: expr.name,
  699. value: parseLiteral()
  700. };
  701. }
  702. return expr;
  703. }
  704. function parseVariants() {
  705. let variants = [];
  706. let count = 0;
  707. let star;
  708. while (test(RE_VARIANT_START)) {
  709. if (consumeChar("*")) {
  710. star = count;
  711. }
  712. let key = parseVariantKey();
  713. let value = parsePattern();
  714. if (value === null) {
  715. throw new SyntaxError("Expected variant value");
  716. }
  717. variants[count++] = {
  718. key,
  719. value
  720. };
  721. }
  722. if (count === 0) {
  723. return null;
  724. }
  725. if (star === undefined) {
  726. throw new SyntaxError("Expected default variant");
  727. }
  728. return {
  729. variants,
  730. star
  731. };
  732. }
  733. function parseVariantKey() {
  734. consumeToken(TOKEN_BRACKET_OPEN, SyntaxError);
  735. let key;
  736. if (test(RE_NUMBER_LITERAL)) {
  737. key = parseNumberLiteral();
  738. } else {
  739. key = {
  740. type: "str",
  741. value: match1(RE_IDENTIFIER)
  742. };
  743. }
  744. consumeToken(TOKEN_BRACKET_CLOSE, SyntaxError);
  745. return key;
  746. }
  747. function parseLiteral() {
  748. if (test(RE_NUMBER_LITERAL)) {
  749. return parseNumberLiteral();
  750. }
  751. if (source[cursor] === '"') {
  752. return parseStringLiteral();
  753. }
  754. throw new SyntaxError("Invalid expression");
  755. }
  756. function parseNumberLiteral() {
  757. let [, value, fraction = ""] = match(RE_NUMBER_LITERAL);
  758. let precision = fraction.length;
  759. return {
  760. type: "num",
  761. value: parseFloat(value),
  762. precision
  763. };
  764. }
  765. function parseStringLiteral() {
  766. consumeChar('"', SyntaxError);
  767. let value = "";
  768. while (true) {
  769. value += match1(RE_STRING_RUN);
  770. if (source[cursor] === "\\") {
  771. value += parseEscapeSequence();
  772. continue;
  773. }
  774. if (consumeChar('"')) {
  775. return {
  776. type: "str",
  777. value
  778. };
  779. }
  780. throw new SyntaxError("Unclosed string literal");
  781. }
  782. }
  783. function parseEscapeSequence() {
  784. if (test(RE_STRING_ESCAPE)) {
  785. return match1(RE_STRING_ESCAPE);
  786. }
  787. if (test(RE_UNICODE_ESCAPE)) {
  788. let [, codepoint4, codepoint6] = match(RE_UNICODE_ESCAPE);
  789. let codepoint = parseInt(codepoint4 || codepoint6, 16);
  790. return codepoint <= 0xd7ff || 0xe000 <= codepoint ? String.fromCodePoint(codepoint) : "锟�";
  791. }
  792. throw new SyntaxError("Unknown escape sequence");
  793. }
  794. function parseIndent() {
  795. let start = cursor;
  796. consumeToken(TOKEN_BLANK);
  797. switch (source[cursor]) {
  798. case ".":
  799. case "[":
  800. case "*":
  801. case "}":
  802. case undefined:
  803. return false;
  804. case "{":
  805. return makeIndent(source.slice(start, cursor));
  806. }
  807. if (source[cursor - 1] === " ") {
  808. return makeIndent(source.slice(start, cursor));
  809. }
  810. return false;
  811. }
  812. function trim(text, re) {
  813. return text.replace(re, "");
  814. }
  815. function makeIndent(blank) {
  816. let value = blank.replace(RE_BLANK_LINES, "\n");
  817. let length = RE_INDENT.exec(blank)[1].length;
  818. return new Indent(value, length);
  819. }
  820. }
  821. }
  822. class Indent {
  823. constructor(value, length) {
  824. this.value = value;
  825. this.length = length;
  826. }
  827. }
  828. ;// CONCATENATED MODULE: ./node_modules/@fluent/bundle/esm/index.js
  829. /***/ }),
  830. /***/ 5273:
  831. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  832. // EXPORTS
  833. __webpack_require__.d(__webpack_exports__, {
  834. DOMLocalization: () => (/* reexport */ DOMLocalization)
  835. });
  836. // UNUSED EXPORTS: Localization
  837. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/overlay.js
  838. const reOverlay = /<|&#?\w+;/;
  839. const TEXT_LEVEL_ELEMENTS = {
  840. "http://www.w3.org/1999/xhtml": ["em", "strong", "small", "s", "cite", "q", "dfn", "abbr", "data", "time", "code", "var", "samp", "kbd", "sub", "sup", "i", "b", "u", "mark", "bdi", "bdo", "span", "br", "wbr"]
  841. };
  842. const LOCALIZABLE_ATTRIBUTES = {
  843. "http://www.w3.org/1999/xhtml": {
  844. global: ["title", "aria-label", "aria-valuetext"],
  845. a: ["download"],
  846. area: ["download", "alt"],
  847. input: ["alt", "placeholder"],
  848. menuitem: ["label"],
  849. menu: ["label"],
  850. optgroup: ["label"],
  851. option: ["label"],
  852. track: ["label"],
  853. img: ["alt"],
  854. textarea: ["placeholder"],
  855. th: ["abbr"]
  856. },
  857. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": {
  858. global: ["accesskey", "aria-label", "aria-valuetext", "label", "title", "tooltiptext"],
  859. description: ["value"],
  860. key: ["key", "keycode"],
  861. label: ["value"],
  862. textbox: ["placeholder", "value"]
  863. }
  864. };
  865. function translateElement(element, translation) {
  866. const {
  867. value
  868. } = translation;
  869. if (typeof value === "string") {
  870. if (element.localName === "title" && element.namespaceURI === "http://www.w3.org/1999/xhtml") {
  871. element.textContent = value;
  872. } else if (!reOverlay.test(value)) {
  873. element.textContent = value;
  874. } else {
  875. const templateElement = element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "template");
  876. templateElement.innerHTML = value;
  877. overlayChildNodes(templateElement.content, element);
  878. }
  879. }
  880. overlayAttributes(translation, element);
  881. }
  882. function overlayChildNodes(fromFragment, toElement) {
  883. for (const childNode of fromFragment.childNodes) {
  884. if (childNode.nodeType === childNode.TEXT_NODE) {
  885. continue;
  886. }
  887. if (childNode.hasAttribute("data-l10n-name")) {
  888. const sanitized = getNodeForNamedElement(toElement, childNode);
  889. fromFragment.replaceChild(sanitized, childNode);
  890. continue;
  891. }
  892. if (isElementAllowed(childNode)) {
  893. const sanitized = createSanitizedElement(childNode);
  894. fromFragment.replaceChild(sanitized, childNode);
  895. continue;
  896. }
  897. console.warn(`An element of forbidden type "${childNode.localName}" was found in ` + "the translation. Only safe text-level elements and elements with " + "data-l10n-name are allowed.");
  898. fromFragment.replaceChild(createTextNodeFromTextContent(childNode), childNode);
  899. }
  900. toElement.textContent = "";
  901. toElement.appendChild(fromFragment);
  902. }
  903. function hasAttribute(attributes, name) {
  904. if (!attributes) {
  905. return false;
  906. }
  907. for (let attr of attributes) {
  908. if (attr.name === name) {
  909. return true;
  910. }
  911. }
  912. return false;
  913. }
  914. function overlayAttributes(fromElement, toElement) {
  915. const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null;
  916. for (const attr of Array.from(toElement.attributes)) {
  917. if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) {
  918. toElement.removeAttribute(attr.name);
  919. }
  920. }
  921. if (!fromElement.attributes) {
  922. return;
  923. }
  924. for (const attr of Array.from(fromElement.attributes)) {
  925. if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) {
  926. toElement.setAttribute(attr.name, attr.value);
  927. }
  928. }
  929. }
  930. function getNodeForNamedElement(sourceElement, translatedChild) {
  931. const childName = translatedChild.getAttribute("data-l10n-name");
  932. const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`);
  933. if (!sourceChild) {
  934. console.warn(`An element named "${childName}" wasn't found in the source.`);
  935. return createTextNodeFromTextContent(translatedChild);
  936. }
  937. if (sourceChild.localName !== translatedChild.localName) {
  938. console.warn(`An element named "${childName}" was found in the translation ` + `but its type ${translatedChild.localName} didn't match the ` + `element found in the source (${sourceChild.localName}).`);
  939. return createTextNodeFromTextContent(translatedChild);
  940. }
  941. sourceElement.removeChild(sourceChild);
  942. const clone = sourceChild.cloneNode(false);
  943. return shallowPopulateUsing(translatedChild, clone);
  944. }
  945. function createSanitizedElement(element) {
  946. const clone = element.ownerDocument.createElement(element.localName);
  947. return shallowPopulateUsing(element, clone);
  948. }
  949. function createTextNodeFromTextContent(element) {
  950. return element.ownerDocument.createTextNode(element.textContent);
  951. }
  952. function isElementAllowed(element) {
  953. const allowed = TEXT_LEVEL_ELEMENTS[element.namespaceURI];
  954. return allowed && allowed.includes(element.localName);
  955. }
  956. function isAttrNameLocalizable(name, element, explicitlyAllowed = null) {
  957. if (explicitlyAllowed && explicitlyAllowed.includes(name)) {
  958. return true;
  959. }
  960. const allowed = LOCALIZABLE_ATTRIBUTES[element.namespaceURI];
  961. if (!allowed) {
  962. return false;
  963. }
  964. const attrName = name.toLowerCase();
  965. const elemName = element.localName;
  966. if (allowed.global.includes(attrName)) {
  967. return true;
  968. }
  969. if (!allowed[elemName]) {
  970. return false;
  971. }
  972. if (allowed[elemName].includes(attrName)) {
  973. return true;
  974. }
  975. if (element.namespaceURI === "http://www.w3.org/1999/xhtml" && elemName === "input" && attrName === "value") {
  976. const type = element.type.toLowerCase();
  977. if (type === "submit" || type === "button" || type === "reset") {
  978. return true;
  979. }
  980. }
  981. return false;
  982. }
  983. function shallowPopulateUsing(fromElement, toElement) {
  984. toElement.textContent = fromElement.textContent;
  985. overlayAttributes(fromElement, toElement);
  986. return toElement;
  987. }
  988. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_iterable.mjs
  989. class CachedIterable extends Array {
  990. static from(iterable) {
  991. if (iterable instanceof this) {
  992. return iterable;
  993. }
  994. return new this(iterable);
  995. }
  996. }
  997. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_sync_iterable.mjs
  998. class CachedSyncIterable extends CachedIterable {
  999. constructor(iterable) {
  1000. super();
  1001. if (Symbol.iterator in Object(iterable)) {
  1002. this.iterator = iterable[Symbol.iterator]();
  1003. } else {
  1004. throw new TypeError("Argument must implement the iteration protocol.");
  1005. }
  1006. }
  1007. [Symbol.iterator]() {
  1008. const cached = this;
  1009. let cur = 0;
  1010. return {
  1011. next() {
  1012. if (cached.length <= cur) {
  1013. cached.push(cached.iterator.next());
  1014. }
  1015. return cached[cur++];
  1016. }
  1017. };
  1018. }
  1019. touchNext(count = 1) {
  1020. let idx = 0;
  1021. while (idx++ < count) {
  1022. const last = this[this.length - 1];
  1023. if (last && last.done) {
  1024. break;
  1025. }
  1026. this.push(this.iterator.next());
  1027. }
  1028. return this[this.length - 1];
  1029. }
  1030. }
  1031. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/cached_async_iterable.mjs
  1032. class CachedAsyncIterable extends CachedIterable {
  1033. constructor(iterable) {
  1034. super();
  1035. if (Symbol.asyncIterator in Object(iterable)) {
  1036. this.iterator = iterable[Symbol.asyncIterator]();
  1037. } else if (Symbol.iterator in Object(iterable)) {
  1038. this.iterator = iterable[Symbol.iterator]();
  1039. } else {
  1040. throw new TypeError("Argument must implement the iteration protocol.");
  1041. }
  1042. }
  1043. [Symbol.asyncIterator]() {
  1044. const cached = this;
  1045. let cur = 0;
  1046. return {
  1047. async next() {
  1048. if (cached.length <= cur) {
  1049. cached.push(cached.iterator.next());
  1050. }
  1051. return cached[cur++];
  1052. }
  1053. };
  1054. }
  1055. async touchNext(count = 1) {
  1056. let idx = 0;
  1057. while (idx++ < count) {
  1058. const last = this[this.length - 1];
  1059. if (last && (await last).done) {
  1060. break;
  1061. }
  1062. this.push(this.iterator.next());
  1063. }
  1064. return this[this.length - 1];
  1065. }
  1066. }
  1067. ;// CONCATENATED MODULE: ./node_modules/cached-iterable/src/index.mjs
  1068. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/localization.js
  1069. class Localization {
  1070. constructor(resourceIds = [], generateBundles) {
  1071. this.resourceIds = resourceIds;
  1072. this.generateBundles = generateBundles;
  1073. this.onChange(true);
  1074. }
  1075. addResourceIds(resourceIds, eager = false) {
  1076. this.resourceIds.push(...resourceIds);
  1077. this.onChange(eager);
  1078. return this.resourceIds.length;
  1079. }
  1080. removeResourceIds(resourceIds) {
  1081. this.resourceIds = this.resourceIds.filter(r => !resourceIds.includes(r));
  1082. this.onChange();
  1083. return this.resourceIds.length;
  1084. }
  1085. async formatWithFallback(keys, method) {
  1086. const translations = [];
  1087. let hasAtLeastOneBundle = false;
  1088. for await (const bundle of this.bundles) {
  1089. hasAtLeastOneBundle = true;
  1090. const missingIds = keysFromBundle(method, bundle, keys, translations);
  1091. if (missingIds.size === 0) {
  1092. break;
  1093. }
  1094. if (typeof console !== "undefined") {
  1095. const locale = bundle.locales[0];
  1096. const ids = Array.from(missingIds).join(", ");
  1097. console.warn(`[fluent] Missing translations in ${locale}: ${ids}`);
  1098. }
  1099. }
  1100. if (!hasAtLeastOneBundle && typeof console !== "undefined") {
  1101. console.warn(`[fluent] Request for keys failed because no resource bundles got generated.
  1102. keys: ${JSON.stringify(keys)}.
  1103. resourceIds: ${JSON.stringify(this.resourceIds)}.`);
  1104. }
  1105. return translations;
  1106. }
  1107. formatMessages(keys) {
  1108. return this.formatWithFallback(keys, messageFromBundle);
  1109. }
  1110. formatValues(keys) {
  1111. return this.formatWithFallback(keys, valueFromBundle);
  1112. }
  1113. async formatValue(id, args) {
  1114. const [val] = await this.formatValues([{
  1115. id,
  1116. args
  1117. }]);
  1118. return val;
  1119. }
  1120. handleEvent() {
  1121. this.onChange();
  1122. }
  1123. onChange(eager = false) {
  1124. this.bundles = CachedAsyncIterable.from(this.generateBundles(this.resourceIds));
  1125. if (eager) {
  1126. this.bundles.touchNext(2);
  1127. }
  1128. }
  1129. }
  1130. function valueFromBundle(bundle, errors, message, args) {
  1131. if (message.value) {
  1132. return bundle.formatPattern(message.value, args, errors);
  1133. }
  1134. return null;
  1135. }
  1136. function messageFromBundle(bundle, errors, message, args) {
  1137. const formatted = {
  1138. value: null,
  1139. attributes: null
  1140. };
  1141. if (message.value) {
  1142. formatted.value = bundle.formatPattern(message.value, args, errors);
  1143. }
  1144. let attrNames = Object.keys(message.attributes);
  1145. if (attrNames.length > 0) {
  1146. formatted.attributes = new Array(attrNames.length);
  1147. for (let [i, name] of attrNames.entries()) {
  1148. let value = bundle.formatPattern(message.attributes[name], args, errors);
  1149. formatted.attributes[i] = {
  1150. name,
  1151. value
  1152. };
  1153. }
  1154. }
  1155. return formatted;
  1156. }
  1157. function keysFromBundle(method, bundle, keys, translations) {
  1158. const messageErrors = [];
  1159. const missingIds = new Set();
  1160. keys.forEach(({
  1161. id,
  1162. args
  1163. }, i) => {
  1164. if (translations[i] !== undefined) {
  1165. return;
  1166. }
  1167. let message = bundle.getMessage(id);
  1168. if (message) {
  1169. messageErrors.length = 0;
  1170. translations[i] = method(bundle, messageErrors, message, args);
  1171. if (messageErrors.length > 0 && typeof console !== "undefined") {
  1172. const locale = bundle.locales[0];
  1173. const errors = messageErrors.join(", ");
  1174. console.warn(`[fluent][resolver] errors in ${locale}/${id}: ${errors}.`);
  1175. }
  1176. } else {
  1177. missingIds.add(id);
  1178. }
  1179. });
  1180. return missingIds;
  1181. }
  1182. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/dom_localization.js
  1183. const L10NID_ATTR_NAME = "data-l10n-id";
  1184. const L10NARGS_ATTR_NAME = "data-l10n-args";
  1185. const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`;
  1186. class DOMLocalization extends Localization {
  1187. constructor(resourceIds, generateBundles) {
  1188. super(resourceIds, generateBundles);
  1189. this.roots = new Set();
  1190. this.pendingrAF = null;
  1191. this.pendingElements = new Set();
  1192. this.windowElement = null;
  1193. this.mutationObserver = null;
  1194. this.observerConfig = {
  1195. attributes: true,
  1196. characterData: false,
  1197. childList: true,
  1198. subtree: true,
  1199. attributeFilter: [L10NID_ATTR_NAME, L10NARGS_ATTR_NAME]
  1200. };
  1201. }
  1202. onChange(eager = false) {
  1203. super.onChange(eager);
  1204. if (this.roots) {
  1205. this.translateRoots();
  1206. }
  1207. }
  1208. setAttributes(element, id, args) {
  1209. element.setAttribute(L10NID_ATTR_NAME, id);
  1210. if (args) {
  1211. element.setAttribute(L10NARGS_ATTR_NAME, JSON.stringify(args));
  1212. } else {
  1213. element.removeAttribute(L10NARGS_ATTR_NAME);
  1214. }
  1215. return element;
  1216. }
  1217. getAttributes(element) {
  1218. return {
  1219. id: element.getAttribute(L10NID_ATTR_NAME),
  1220. args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
  1221. };
  1222. }
  1223. connectRoot(newRoot) {
  1224. for (const root of this.roots) {
  1225. if (root === newRoot || root.contains(newRoot) || newRoot.contains(root)) {
  1226. throw new Error("Cannot add a root that overlaps with existing root.");
  1227. }
  1228. }
  1229. if (this.windowElement) {
  1230. if (this.windowElement !== newRoot.ownerDocument.defaultView) {
  1231. throw new Error(`Cannot connect a root:
  1232. DOMLocalization already has a root from a different window.`);
  1233. }
  1234. } else {
  1235. this.windowElement = newRoot.ownerDocument.defaultView;
  1236. this.mutationObserver = new this.windowElement.MutationObserver(mutations => this.translateMutations(mutations));
  1237. }
  1238. this.roots.add(newRoot);
  1239. this.mutationObserver.observe(newRoot, this.observerConfig);
  1240. }
  1241. disconnectRoot(root) {
  1242. this.roots.delete(root);
  1243. this.pauseObserving();
  1244. if (this.roots.size === 0) {
  1245. this.mutationObserver = null;
  1246. this.windowElement = null;
  1247. this.pendingrAF = null;
  1248. this.pendingElements.clear();
  1249. return true;
  1250. }
  1251. this.resumeObserving();
  1252. return false;
  1253. }
  1254. translateRoots() {
  1255. const roots = Array.from(this.roots);
  1256. return Promise.all(roots.map(root => this.translateFragment(root)));
  1257. }
  1258. pauseObserving() {
  1259. if (!this.mutationObserver) {
  1260. return;
  1261. }
  1262. this.translateMutations(this.mutationObserver.takeRecords());
  1263. this.mutationObserver.disconnect();
  1264. }
  1265. resumeObserving() {
  1266. if (!this.mutationObserver) {
  1267. return;
  1268. }
  1269. for (const root of this.roots) {
  1270. this.mutationObserver.observe(root, this.observerConfig);
  1271. }
  1272. }
  1273. translateMutations(mutations) {
  1274. for (const mutation of mutations) {
  1275. switch (mutation.type) {
  1276. case "attributes":
  1277. if (mutation.target.hasAttribute("data-l10n-id")) {
  1278. this.pendingElements.add(mutation.target);
  1279. }
  1280. break;
  1281. case "childList":
  1282. for (const addedNode of mutation.addedNodes) {
  1283. if (addedNode.nodeType === addedNode.ELEMENT_NODE) {
  1284. if (addedNode.childElementCount) {
  1285. for (const element of this.getTranslatables(addedNode)) {
  1286. this.pendingElements.add(element);
  1287. }
  1288. } else if (addedNode.hasAttribute(L10NID_ATTR_NAME)) {
  1289. this.pendingElements.add(addedNode);
  1290. }
  1291. }
  1292. }
  1293. break;
  1294. }
  1295. }
  1296. if (this.pendingElements.size > 0) {
  1297. if (this.pendingrAF === null) {
  1298. this.pendingrAF = this.windowElement.requestAnimationFrame(() => {
  1299. this.translateElements(Array.from(this.pendingElements));
  1300. this.pendingElements.clear();
  1301. this.pendingrAF = null;
  1302. });
  1303. }
  1304. }
  1305. }
  1306. translateFragment(frag) {
  1307. return this.translateElements(this.getTranslatables(frag));
  1308. }
  1309. async translateElements(elements) {
  1310. if (!elements.length) {
  1311. return undefined;
  1312. }
  1313. const keys = elements.map(this.getKeysForElement);
  1314. const translations = await this.formatMessages(keys);
  1315. return this.applyTranslations(elements, translations);
  1316. }
  1317. applyTranslations(elements, translations) {
  1318. this.pauseObserving();
  1319. for (let i = 0; i < elements.length; i++) {
  1320. if (translations[i] !== undefined) {
  1321. translateElement(elements[i], translations[i]);
  1322. }
  1323. }
  1324. this.resumeObserving();
  1325. }
  1326. getTranslatables(element) {
  1327. const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY));
  1328. if (typeof element.hasAttribute === "function" && element.hasAttribute(L10NID_ATTR_NAME)) {
  1329. nodes.push(element);
  1330. }
  1331. return nodes;
  1332. }
  1333. getKeysForElement(element) {
  1334. return {
  1335. id: element.getAttribute(L10NID_ATTR_NAME),
  1336. args: JSON.parse(element.getAttribute(L10NARGS_ATTR_NAME) || null)
  1337. };
  1338. }
  1339. }
  1340. ;// CONCATENATED MODULE: ./node_modules/@fluent/dom/esm/index.js
  1341. /***/ }),
  1342. /***/ 259:
  1343. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1344. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1345. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1346. /* harmony export */ AltTextManager: () => (/* binding */ AltTextManager)
  1347. /* harmony export */ });
  1348. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  1349. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  1350. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1351. class AltTextManager {
  1352. #boundUpdateUIState = this.#updateUIState.bind(this);
  1353. #boundSetPosition = this.#setPosition.bind(this);
  1354. #boundOnClick = this.#onClick.bind(this);
  1355. #currentEditor = null;
  1356. #cancelButton;
  1357. #dialog;
  1358. #eventBus;
  1359. #hasUsedPointer = false;
  1360. #optionDescription;
  1361. #optionDecorative;
  1362. #overlayManager;
  1363. #saveButton;
  1364. #textarea;
  1365. #uiManager;
  1366. #previousAltText = null;
  1367. #svgElement = null;
  1368. #rectElement = null;
  1369. #container;
  1370. #telemetryData = null;
  1371. constructor({
  1372. dialog,
  1373. optionDescription,
  1374. optionDecorative,
  1375. textarea,
  1376. cancelButton,
  1377. saveButton
  1378. }, container, overlayManager, eventBus) {
  1379. this.#dialog = dialog;
  1380. this.#optionDescription = optionDescription;
  1381. this.#optionDecorative = optionDecorative;
  1382. this.#textarea = textarea;
  1383. this.#cancelButton = cancelButton;
  1384. this.#saveButton = saveButton;
  1385. this.#overlayManager = overlayManager;
  1386. this.#eventBus = eventBus;
  1387. this.#container = container;
  1388. dialog.addEventListener("close", this.#close.bind(this));
  1389. dialog.addEventListener("contextmenu", event => {
  1390. if (event.target !== this.#textarea) {
  1391. event.preventDefault();
  1392. }
  1393. });
  1394. cancelButton.addEventListener("click", this.#finish.bind(this));
  1395. saveButton.addEventListener("click", this.#save.bind(this));
  1396. optionDescription.addEventListener("change", this.#boundUpdateUIState);
  1397. optionDecorative.addEventListener("change", this.#boundUpdateUIState);
  1398. this.#overlayManager.register(dialog);
  1399. }
  1400. get _elements() {
  1401. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_elements", [this.#optionDescription, this.#optionDecorative, this.#textarea, this.#saveButton, this.#cancelButton]);
  1402. }
  1403. #createSVGElement() {
  1404. if (this.#svgElement) {
  1405. return;
  1406. }
  1407. const svgFactory = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.DOMSVGFactory();
  1408. const svg = this.#svgElement = svgFactory.createElement("svg");
  1409. svg.setAttribute("width", "0");
  1410. svg.setAttribute("height", "0");
  1411. const defs = svgFactory.createElement("defs");
  1412. svg.append(defs);
  1413. const mask = svgFactory.createElement("mask");
  1414. defs.append(mask);
  1415. mask.setAttribute("id", "alttext-manager-mask");
  1416. mask.setAttribute("maskContentUnits", "objectBoundingBox");
  1417. let rect = svgFactory.createElement("rect");
  1418. mask.append(rect);
  1419. rect.setAttribute("fill", "white");
  1420. rect.setAttribute("width", "1");
  1421. rect.setAttribute("height", "1");
  1422. rect.setAttribute("x", "0");
  1423. rect.setAttribute("y", "0");
  1424. rect = this.#rectElement = svgFactory.createElement("rect");
  1425. mask.append(rect);
  1426. rect.setAttribute("fill", "black");
  1427. this.#dialog.append(svg);
  1428. }
  1429. async editAltText(uiManager, editor) {
  1430. if (this.#currentEditor || !editor) {
  1431. return;
  1432. }
  1433. this.#createSVGElement();
  1434. this.#hasUsedPointer = false;
  1435. for (const element of this._elements) {
  1436. element.addEventListener("click", this.#boundOnClick);
  1437. }
  1438. const {
  1439. altText,
  1440. decorative
  1441. } = editor.altTextData;
  1442. if (decorative === true) {
  1443. this.#optionDecorative.checked = true;
  1444. this.#optionDescription.checked = false;
  1445. } else {
  1446. this.#optionDecorative.checked = false;
  1447. this.#optionDescription.checked = true;
  1448. }
  1449. this.#previousAltText = this.#textarea.value = altText?.trim() || "";
  1450. this.#updateUIState();
  1451. this.#currentEditor = editor;
  1452. this.#uiManager = uiManager;
  1453. this.#uiManager.removeEditListeners();
  1454. this.#eventBus._on("resize", this.#boundSetPosition);
  1455. try {
  1456. await this.#overlayManager.open(this.#dialog);
  1457. this.#setPosition();
  1458. } catch (ex) {
  1459. this.#close();
  1460. throw ex;
  1461. }
  1462. }
  1463. #setPosition() {
  1464. if (!this.#currentEditor) {
  1465. return;
  1466. }
  1467. const dialog = this.#dialog;
  1468. const {
  1469. style
  1470. } = dialog;
  1471. const {
  1472. x: containerX,
  1473. y: containerY,
  1474. width: containerW,
  1475. height: containerH
  1476. } = this.#container.getBoundingClientRect();
  1477. const {
  1478. innerWidth: windowW,
  1479. innerHeight: windowH
  1480. } = window;
  1481. const {
  1482. width: dialogW,
  1483. height: dialogH
  1484. } = dialog.getBoundingClientRect();
  1485. const {
  1486. x,
  1487. y,
  1488. width,
  1489. height
  1490. } = this.#currentEditor.getClientDimensions();
  1491. const MARGIN = 10;
  1492. const isLTR = this.#uiManager.direction === "ltr";
  1493. const xs = Math.max(x, containerX);
  1494. const xe = Math.min(x + width, containerX + containerW);
  1495. const ys = Math.max(y, containerY);
  1496. const ye = Math.min(y + height, containerY + containerH);
  1497. this.#rectElement.setAttribute("width", `${(xe - xs) / windowW}`);
  1498. this.#rectElement.setAttribute("height", `${(ye - ys) / windowH}`);
  1499. this.#rectElement.setAttribute("x", `${xs / windowW}`);
  1500. this.#rectElement.setAttribute("y", `${ys / windowH}`);
  1501. let left = null;
  1502. let top = Math.max(y, 0);
  1503. top += Math.min(windowH - (top + dialogH), 0);
  1504. if (isLTR) {
  1505. if (x + width + MARGIN + dialogW < windowW) {
  1506. left = x + width + MARGIN;
  1507. } else if (x > dialogW + MARGIN) {
  1508. left = x - dialogW - MARGIN;
  1509. }
  1510. } else if (x > dialogW + MARGIN) {
  1511. left = x - dialogW - MARGIN;
  1512. } else if (x + width + MARGIN + dialogW < windowW) {
  1513. left = x + width + MARGIN;
  1514. }
  1515. if (left === null) {
  1516. top = null;
  1517. left = Math.max(x, 0);
  1518. left += Math.min(windowW - (left + dialogW), 0);
  1519. if (y > dialogH + MARGIN) {
  1520. top = y - dialogH - MARGIN;
  1521. } else if (y + height + MARGIN + dialogH < windowH) {
  1522. top = y + height + MARGIN;
  1523. }
  1524. }
  1525. if (top !== null) {
  1526. dialog.classList.add("positioned");
  1527. if (isLTR) {
  1528. style.left = `${left}px`;
  1529. } else {
  1530. style.right = `${windowW - left - dialogW}px`;
  1531. }
  1532. style.top = `${top}px`;
  1533. } else {
  1534. dialog.classList.remove("positioned");
  1535. style.left = "";
  1536. style.top = "";
  1537. }
  1538. }
  1539. #finish() {
  1540. if (this.#overlayManager.active === this.#dialog) {
  1541. this.#overlayManager.close(this.#dialog);
  1542. }
  1543. }
  1544. #close() {
  1545. this.#currentEditor._reportTelemetry(this.#telemetryData || {
  1546. action: "alt_text_cancel",
  1547. alt_text_keyboard: !this.#hasUsedPointer
  1548. });
  1549. this.#telemetryData = null;
  1550. this.#removeOnClickListeners();
  1551. this.#uiManager?.addEditListeners();
  1552. this.#eventBus._off("resize", this.#boundSetPosition);
  1553. this.#currentEditor.altTextFinish();
  1554. this.#currentEditor = null;
  1555. this.#uiManager = null;
  1556. }
  1557. #updateUIState() {
  1558. this.#textarea.disabled = this.#optionDecorative.checked;
  1559. }
  1560. #save() {
  1561. const altText = this.#textarea.value.trim();
  1562. const decorative = this.#optionDecorative.checked;
  1563. this.#currentEditor.altTextData = {
  1564. altText,
  1565. decorative
  1566. };
  1567. this.#telemetryData = {
  1568. action: "alt_text_save",
  1569. alt_text_description: !!altText,
  1570. alt_text_edit: !!this.#previousAltText && this.#previousAltText !== altText,
  1571. alt_text_decorative: decorative,
  1572. alt_text_keyboard: !this.#hasUsedPointer
  1573. };
  1574. this.#finish();
  1575. }
  1576. #onClick(evt) {
  1577. if (evt.detail === 0) {
  1578. return;
  1579. }
  1580. this.#hasUsedPointer = true;
  1581. this.#removeOnClickListeners();
  1582. }
  1583. #removeOnClickListeners() {
  1584. for (const element of this._elements) {
  1585. element.removeEventListener("click", this.#boundOnClick);
  1586. }
  1587. }
  1588. destroy() {
  1589. this.#uiManager = null;
  1590. this.#finish();
  1591. this.#svgElement?.remove();
  1592. this.#svgElement = this.#rectElement = null;
  1593. }
  1594. }
  1595. __webpack_async_result__();
  1596. } catch(e) { __webpack_async_result__(e); } });
  1597. /***/ }),
  1598. /***/ 283:
  1599. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1600. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1601. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1602. /* harmony export */ AnnotationEditorLayerBuilder: () => (/* binding */ AnnotationEditorLayerBuilder)
  1603. /* harmony export */ });
  1604. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  1605. /* harmony import */ var web_null_l10n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(410);
  1606. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_1__]);
  1607. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  1608. class AnnotationEditorLayerBuilder {
  1609. #annotationLayer = null;
  1610. #drawLayer = null;
  1611. #onAppend = null;
  1612. #textLayer = null;
  1613. #uiManager;
  1614. constructor(options) {
  1615. this.pdfPage = options.pdfPage;
  1616. this.accessibilityManager = options.accessibilityManager;
  1617. this.l10n = options.l10n;
  1618. this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_1__.GenericL10n();
  1619. this.annotationEditorLayer = null;
  1620. this.div = null;
  1621. this._cancelled = false;
  1622. this.#uiManager = options.uiManager;
  1623. this.#annotationLayer = options.annotationLayer || null;
  1624. this.#textLayer = options.textLayer || null;
  1625. this.#drawLayer = options.drawLayer || null;
  1626. this.#onAppend = options.onAppend || null;
  1627. }
  1628. async render(viewport, intent = "display") {
  1629. if (intent !== "display") {
  1630. return;
  1631. }
  1632. if (this._cancelled) {
  1633. return;
  1634. }
  1635. const clonedViewport = viewport.clone({
  1636. dontFlip: true
  1637. });
  1638. if (this.div) {
  1639. this.annotationEditorLayer.update({
  1640. viewport: clonedViewport
  1641. });
  1642. this.show();
  1643. return;
  1644. }
  1645. const div = this.div = document.createElement("div");
  1646. div.className = "annotationEditorLayer";
  1647. div.hidden = true;
  1648. div.dir = this.#uiManager.direction;
  1649. this.#onAppend?.(div);
  1650. this.annotationEditorLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorLayer({
  1651. uiManager: this.#uiManager,
  1652. div,
  1653. accessibilityManager: this.accessibilityManager,
  1654. pageIndex: this.pdfPage.pageNumber - 1,
  1655. l10n: this.l10n,
  1656. viewport: clonedViewport,
  1657. annotationLayer: this.#annotationLayer,
  1658. textLayer: this.#textLayer,
  1659. drawLayer: this.#drawLayer
  1660. });
  1661. const parameters = {
  1662. viewport: clonedViewport,
  1663. div,
  1664. annotations: null,
  1665. intent
  1666. };
  1667. this.annotationEditorLayer.render(parameters);
  1668. this.show();
  1669. }
  1670. cancel() {
  1671. this._cancelled = true;
  1672. if (!this.div) {
  1673. return;
  1674. }
  1675. this.annotationEditorLayer.destroy();
  1676. }
  1677. hide() {
  1678. if (!this.div) {
  1679. return;
  1680. }
  1681. this.div.hidden = true;
  1682. }
  1683. show() {
  1684. if (!this.div || this.annotationEditorLayer.isInvisible) {
  1685. return;
  1686. }
  1687. this.div.hidden = false;
  1688. }
  1689. }
  1690. __webpack_async_result__();
  1691. } catch(e) { __webpack_async_result__(e); } });
  1692. /***/ }),
  1693. /***/ 226:
  1694. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1695. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1696. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1697. /* harmony export */ AnnotationEditorParams: () => (/* binding */ AnnotationEditorParams)
  1698. /* harmony export */ });
  1699. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  1700. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  1701. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1702. class AnnotationEditorParams {
  1703. constructor(options, eventBus) {
  1704. this.eventBus = eventBus;
  1705. this.#bindListeners(options);
  1706. }
  1707. #bindListeners({
  1708. editorFreeTextFontSize,
  1709. editorFreeTextColor,
  1710. editorInkColor,
  1711. editorInkThickness,
  1712. editorInkOpacity,
  1713. editorStampAddImage,
  1714. editorFreeHighlightThickness,
  1715. editorHighlightShowAll
  1716. }) {
  1717. const dispatchEvent = (typeStr, value) => {
  1718. this.eventBus.dispatch("switchannotationeditorparams", {
  1719. source: this,
  1720. type: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType[typeStr],
  1721. value
  1722. });
  1723. };
  1724. editorFreeTextFontSize.addEventListener("input", function () {
  1725. dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
  1726. });
  1727. editorFreeTextColor.addEventListener("input", function () {
  1728. dispatchEvent("FREETEXT_COLOR", this.value);
  1729. });
  1730. editorInkColor.addEventListener("input", function () {
  1731. dispatchEvent("INK_COLOR", this.value);
  1732. });
  1733. editorInkThickness.addEventListener("input", function () {
  1734. dispatchEvent("INK_THICKNESS", this.valueAsNumber);
  1735. });
  1736. editorInkOpacity.addEventListener("input", function () {
  1737. dispatchEvent("INK_OPACITY", this.valueAsNumber);
  1738. });
  1739. editorStampAddImage.addEventListener("click", () => {
  1740. dispatchEvent("CREATE");
  1741. });
  1742. editorFreeHighlightThickness.addEventListener("input", function () {
  1743. dispatchEvent("HIGHLIGHT_THICKNESS", this.valueAsNumber);
  1744. });
  1745. editorHighlightShowAll.addEventListener("click", function () {
  1746. const checked = this.getAttribute("aria-pressed") === "true";
  1747. this.setAttribute("aria-pressed", !checked);
  1748. dispatchEvent("HIGHLIGHT_SHOW_ALL", !checked);
  1749. });
  1750. this.eventBus._on("annotationeditorparamschanged", evt => {
  1751. for (const [type, value] of evt.details) {
  1752. switch (type) {
  1753. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.FREETEXT_SIZE:
  1754. editorFreeTextFontSize.value = value;
  1755. break;
  1756. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.FREETEXT_COLOR:
  1757. editorFreeTextColor.value = value;
  1758. break;
  1759. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_COLOR:
  1760. editorInkColor.value = value;
  1761. break;
  1762. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_THICKNESS:
  1763. editorInkThickness.value = value;
  1764. break;
  1765. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.INK_OPACITY:
  1766. editorInkOpacity.value = value;
  1767. break;
  1768. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
  1769. editorFreeHighlightThickness.value = value;
  1770. break;
  1771. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_FREE:
  1772. editorFreeHighlightThickness.disabled = !value;
  1773. break;
  1774. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
  1775. editorHighlightShowAll.setAttribute("aria-pressed", value);
  1776. break;
  1777. }
  1778. }
  1779. });
  1780. }
  1781. }
  1782. __webpack_async_result__();
  1783. } catch(e) { __webpack_async_result__(e); } });
  1784. /***/ }),
  1785. /***/ 2707:
  1786. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1787. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1788. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1789. /* harmony export */ AnnotationLayerBuilder: () => (/* binding */ AnnotationLayerBuilder)
  1790. /* harmony export */ });
  1791. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  1792. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  1793. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  1794. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1795. class AnnotationLayerBuilder {
  1796. #onAppend = null;
  1797. #eventAbortController = null;
  1798. constructor({
  1799. pdfPage,
  1800. linkService,
  1801. downloadManager,
  1802. annotationStorage = null,
  1803. imageResourcesPath = "",
  1804. renderForms = true,
  1805. enableScripting = false,
  1806. hasJSActionsPromise = null,
  1807. fieldObjectsPromise = null,
  1808. annotationCanvasMap = null,
  1809. accessibilityManager = null,
  1810. annotationEditorUIManager = null,
  1811. onAppend = null
  1812. }) {
  1813. this.pdfPage = pdfPage;
  1814. this.linkService = linkService;
  1815. this.downloadManager = downloadManager;
  1816. this.imageResourcesPath = imageResourcesPath;
  1817. this.renderForms = renderForms;
  1818. this.annotationStorage = annotationStorage;
  1819. this.enableScripting = enableScripting;
  1820. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  1821. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  1822. this._annotationCanvasMap = annotationCanvasMap;
  1823. this._accessibilityManager = accessibilityManager;
  1824. this._annotationEditorUIManager = annotationEditorUIManager;
  1825. this.#onAppend = onAppend;
  1826. this.annotationLayer = null;
  1827. this.div = null;
  1828. this._cancelled = false;
  1829. this._eventBus = linkService.eventBus;
  1830. }
  1831. async render(viewport, intent = "display") {
  1832. if (this.div) {
  1833. if (this._cancelled || !this.annotationLayer) {
  1834. return;
  1835. }
  1836. this.annotationLayer.update({
  1837. viewport: viewport.clone({
  1838. dontFlip: true
  1839. })
  1840. });
  1841. return;
  1842. }
  1843. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  1844. intent
  1845. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  1846. if (this._cancelled) {
  1847. return;
  1848. }
  1849. const div = this.div = document.createElement("div");
  1850. div.className = "annotationLayer";
  1851. this.#onAppend?.(div);
  1852. window.parent.postMessage({status: 'loaded'}, '*');
  1853. if (annotations.length === 0) {
  1854. // [Custom] always turn the annotationLayer on
  1855. // this.hide();
  1856. return;
  1857. }
  1858. this.annotationLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationLayer({
  1859. div,
  1860. accessibilityManager: this._accessibilityManager,
  1861. annotationCanvasMap: this._annotationCanvasMap,
  1862. annotationEditorUIManager: this._annotationEditorUIManager,
  1863. page: this.pdfPage,
  1864. viewport: viewport.clone({
  1865. dontFlip: true
  1866. })
  1867. });
  1868. await this.annotationLayer.render({
  1869. annotations,
  1870. imageResourcesPath: this.imageResourcesPath,
  1871. renderForms: this.renderForms,
  1872. linkService: this.linkService,
  1873. downloadManager: this.downloadManager,
  1874. annotationStorage: this.annotationStorage,
  1875. enableScripting: this.enableScripting,
  1876. hasJSActions,
  1877. fieldObjects
  1878. });
  1879. if (this.linkService.isInPresentationMode) {
  1880. this.#updatePresentationModeState(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN);
  1881. }
  1882. if (!this.#eventAbortController) {
  1883. this.#eventAbortController = new AbortController();
  1884. this._eventBus?._on("presentationmodechanged", evt => {
  1885. this.#updatePresentationModeState(evt.state);
  1886. }, {
  1887. signal: this.#eventAbortController.signal
  1888. });
  1889. }
  1890. // [custom-annotationLayer]
  1891. // console.log('test-custom-annotationLayer', window?.PDFViewerApplication?.pdfViewer?._pages?.length)
  1892. window?.PDFViewerApplication?.pdfViewer?._pages?.forEach((i,index) => {
  1893. window.parent.postMessage({pageNum: index}, '*');
  1894. })
  1895. }
  1896. cancel() {
  1897. this._cancelled = true;
  1898. this.#eventAbortController?.abort();
  1899. this.#eventAbortController = null;
  1900. }
  1901. hide() {
  1902. if (!this.div) {
  1903. return;
  1904. }
  1905. this.div.hidden = true;
  1906. }
  1907. #updatePresentationModeState(state) {
  1908. if (!this.div) {
  1909. return;
  1910. }
  1911. let disableFormElements = false;
  1912. switch (state) {
  1913. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN:
  1914. disableFormElements = true;
  1915. break;
  1916. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL:
  1917. break;
  1918. default:
  1919. return;
  1920. }
  1921. for (const section of this.div.childNodes) {
  1922. if (section.hasAttribute("data-internal-link")) {
  1923. continue;
  1924. }
  1925. section.inert = disableFormElements;
  1926. }
  1927. }
  1928. }
  1929. __webpack_async_result__();
  1930. } catch(e) { __webpack_async_result__(e); } });
  1931. /***/ }),
  1932. /***/ 1621:
  1933. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  1934. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1935. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1936. /* harmony export */ PDFViewerApplication: () => (/* binding */ PDFViewerApplication)
  1937. /* harmony export */ });
  1938. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  1939. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
  1940. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9840);
  1941. /* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5656);
  1942. /* harmony import */ var web_external_services__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6750);
  1943. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(787);
  1944. /* harmony import */ var web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(259);
  1945. /* harmony import */ var web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(226);
  1946. /* harmony import */ var _caret_browsing_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(3973);
  1947. /* harmony import */ var web_download_manager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1544);
  1948. /* harmony import */ var _overlay_manager_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(6174);
  1949. /* harmony import */ var _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2690);
  1950. /* harmony import */ var web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(9251);
  1951. /* harmony import */ var web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(5993);
  1952. /* harmony import */ var web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(164);
  1953. /* harmony import */ var web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(2226);
  1954. /* harmony import */ var _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(9814);
  1955. /* harmony import */ var _pdf_history_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(8543);
  1956. /* harmony import */ var web_pdf_layer_viewer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(4275);
  1957. /* harmony import */ var web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(5514);
  1958. /* harmony import */ var web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(8917);
  1959. /* harmony import */ var web_print_service__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(1144);
  1960. /* harmony import */ var _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(6615);
  1961. /* harmony import */ var _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(5942);
  1962. /* harmony import */ var web_pdf_sidebar__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(2275);
  1963. /* harmony import */ var web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(8280);
  1964. /* harmony import */ var _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(6285);
  1965. /* harmony import */ var web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(1900);
  1966. /* harmony import */ var web_toolbar__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(6297);
  1967. /* harmony import */ var _view_history_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(9226);
  1968. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, web_external_services__WEBPACK_IMPORTED_MODULE_4__, web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__, web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__, web_download_manager__WEBPACK_IMPORTED_MODULE_8__, _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__, web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__, web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__, web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__, web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__, web_print_service__WEBPACK_IMPORTED_MODULE_19__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__, _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__, web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__, _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__, web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__, web_toolbar__WEBPACK_IMPORTED_MODULE_26__]);
  1969. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__, web_external_services__WEBPACK_IMPORTED_MODULE_4__, web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__, web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__, web_download_manager__WEBPACK_IMPORTED_MODULE_8__, _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__, web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__, web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__, web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__, web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__, web_print_service__WEBPACK_IMPORTED_MODULE_19__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__, _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__, web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__, _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__, web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__, web_toolbar__WEBPACK_IMPORTED_MODULE_26__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  1970. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  1971. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  1972. const ViewOnLoad = {
  1973. UNKNOWN: -1,
  1974. PREVIOUS: 0,
  1975. INITIAL: 1
  1976. };
  1977. const PDFViewerApplication = {
  1978. initialBookmark: document.location.hash.substring(1),
  1979. _initializedCapability: {
  1980. ...Promise.withResolvers(),
  1981. settled: false
  1982. },
  1983. appConfig: null,
  1984. pdfDocument: null,
  1985. pdfLoadingTask: null,
  1986. printService: null,
  1987. pdfViewer: null,
  1988. pdfThumbnailViewer: null,
  1989. pdfRenderingQueue: null,
  1990. pdfPresentationMode: null,
  1991. pdfDocumentProperties: null,
  1992. pdfLinkService: null,
  1993. pdfHistory: null,
  1994. pdfSidebar: null,
  1995. pdfOutlineViewer: null,
  1996. pdfAttachmentViewer: null,
  1997. pdfLayerViewer: null,
  1998. pdfCursorTools: null,
  1999. pdfScriptingManager: null,
  2000. store: null,
  2001. downloadManager: null,
  2002. overlayManager: null,
  2003. preferences: null,
  2004. toolbar: null,
  2005. secondaryToolbar: null,
  2006. eventBus: null,
  2007. l10n: null,
  2008. annotationEditorParams: null,
  2009. isInitialViewSet: false,
  2010. downloadComplete: false,
  2011. isViewerEmbedded: window.parent !== window,
  2012. url: "",
  2013. baseUrl: "",
  2014. _downloadUrl: "",
  2015. _eventBusAbortController: null,
  2016. _windowAbortController: null,
  2017. documentInfo: null,
  2018. metadata: null,
  2019. _contentDispositionFilename: null,
  2020. _contentLength: null,
  2021. _saveInProgress: false,
  2022. _wheelUnusedTicks: 0,
  2023. _wheelUnusedFactor: 1,
  2024. _touchUnusedTicks: 0,
  2025. _touchUnusedFactor: 1,
  2026. _PDFBug: null,
  2027. _hasAnnotationEditors: false,
  2028. _title: document.title,
  2029. _printAnnotationStoragePromise: null,
  2030. _touchInfo: null,
  2031. _isCtrlKeyDown: false,
  2032. _nimbusDataPromise: null,
  2033. _caretBrowsing: null,
  2034. _isScrolling: false,
  2035. async initialize(appConfig) {
  2036. let l10nPromise;
  2037. this.appConfig = appConfig;
  2038. try {
  2039. await this.preferences.initializedPromise;
  2040. } catch (ex) {
  2041. console.error(`initialize: "${ex.message}".`);
  2042. }
  2043. if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pdfBugEnabled")) {
  2044. await this._parseHashParams();
  2045. }
  2046. let mode;
  2047. switch (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("viewerCssTheme")) {
  2048. case 1:
  2049. mode = "is-light";
  2050. break;
  2051. case 2:
  2052. mode = "is-dark";
  2053. break;
  2054. }
  2055. if (mode) {
  2056. document.documentElement.classList.add(mode);
  2057. }
  2058. l10nPromise = this.externalServices.createL10n();
  2059. this.l10n = await l10nPromise;
  2060. document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
  2061. this.l10n.translate(appConfig.appContainer || document.documentElement);
  2062. if (this.isViewerEmbedded && _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkTarget") === _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.LinkTarget.NONE) {
  2063. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("externalLinkTarget", _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.LinkTarget.TOP);
  2064. }
  2065. await this._initializeViewerComponents();
  2066. this.bindEvents();
  2067. this.bindWindowEvents();
  2068. this._initializedCapability.settled = true;
  2069. this._initializedCapability.resolve();
  2070. },
  2071. async _parseHashParams() {
  2072. const hash = document.location.hash.substring(1);
  2073. if (!hash) {
  2074. return;
  2075. }
  2076. const {
  2077. mainContainer,
  2078. viewerContainer
  2079. } = this.appConfig,
  2080. params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
  2081. if (params.get("disableworker") === "true") {
  2082. try {
  2083. await loadFakeWorker();
  2084. } catch (ex) {
  2085. console.error(`_parseHashParams: "${ex.message}".`);
  2086. }
  2087. }
  2088. if (params.has("disablerange")) {
  2089. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableRange", params.get("disablerange") === "true");
  2090. }
  2091. if (params.has("disablestream")) {
  2092. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableStream", params.get("disablestream") === "true");
  2093. }
  2094. if (params.has("disableautofetch")) {
  2095. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  2096. }
  2097. if (params.has("disablefontface")) {
  2098. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  2099. }
  2100. if (params.has("disablehistory")) {
  2101. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  2102. }
  2103. if (params.has("verbosity")) {
  2104. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("verbosity", params.get("verbosity") | 0);
  2105. }
  2106. if (params.has("textlayer")) {
  2107. switch (params.get("textlayer")) {
  2108. case "off":
  2109. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("textLayerMode", _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.TextLayerMode.DISABLE);
  2110. break;
  2111. case "visible":
  2112. case "shadow":
  2113. case "hover":
  2114. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  2115. try {
  2116. await loadPDFBug(this);
  2117. this._PDFBug.loadCSS();
  2118. } catch (ex) {
  2119. console.error(`_parseHashParams: "${ex.message}".`);
  2120. }
  2121. break;
  2122. }
  2123. }
  2124. if (params.has("pdfbug")) {
  2125. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("pdfBug", true);
  2126. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("fontExtraProperties", true);
  2127. const enabled = params.get("pdfbug").split(",");
  2128. try {
  2129. await loadPDFBug(this);
  2130. this._PDFBug.init(mainContainer, enabled);
  2131. } catch (ex) {
  2132. console.error(`_parseHashParams: "${ex.message}".`);
  2133. }
  2134. }
  2135. if (params.has("locale")) {
  2136. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("locale", params.get("locale"));
  2137. }
  2138. },
  2139. async _initializeViewerComponents() {
  2140. const {
  2141. appConfig,
  2142. externalServices,
  2143. l10n
  2144. } = this;
  2145. const eventBus = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("isInAutomation") ? new _event_utils_js__WEBPACK_IMPORTED_MODULE_3__.AutomationEventBus() : new _event_utils_js__WEBPACK_IMPORTED_MODULE_3__.EventBus();
  2146. this.eventBus = eventBus;
  2147. this.overlayManager = new _overlay_manager_js__WEBPACK_IMPORTED_MODULE_27__.OverlayManager();
  2148. const pdfRenderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_20__.PDFRenderingQueue();
  2149. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  2150. this.pdfRenderingQueue = pdfRenderingQueue;
  2151. const pdfLinkService = new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.PDFLinkService({
  2152. eventBus,
  2153. externalLinkTarget: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkTarget"),
  2154. externalLinkRel: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("externalLinkRel"),
  2155. ignoreDestinationZoom: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("ignoreDestinationZoom")
  2156. });
  2157. this.pdfLinkService = pdfLinkService;
  2158. const downloadManager = this.downloadManager = new web_download_manager__WEBPACK_IMPORTED_MODULE_8__.DownloadManager();
  2159. const findController = new _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_14__.PDFFindController({
  2160. linkService: pdfLinkService,
  2161. eventBus,
  2162. updateMatchesCountOnProgress: true
  2163. });
  2164. this.findController = findController;
  2165. const pdfScriptingManager = new _pdf_scripting_manager_js__WEBPACK_IMPORTED_MODULE_21__.PDFScriptingManager({
  2166. eventBus,
  2167. externalServices,
  2168. docProperties: this._scriptingDocProperties.bind(this)
  2169. });
  2170. this.pdfScriptingManager = pdfScriptingManager;
  2171. const container = appConfig.mainContainer,
  2172. viewer = appConfig.viewerContainer;
  2173. const annotationEditorMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("annotationEditorMode");
  2174. const pageColors = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  2175. background: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageColorsBackground"),
  2176. foreground: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pageColorsForeground")
  2177. } : null;
  2178. const altTextManager = appConfig.altTextDialog ? new web_alt_text_manager__WEBPACK_IMPORTED_MODULE_6__.AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
  2179. // pdf的dom初始化配置的在这里
  2180. const pdfViewer = new _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_24__.PDFViewer({
  2181. container,
  2182. viewer,
  2183. eventBus,
  2184. renderingQueue: pdfRenderingQueue,
  2185. linkService: pdfLinkService,
  2186. downloadManager,
  2187. altTextManager,
  2188. findController,
  2189. scriptingManager: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableScripting") && pdfScriptingManager,
  2190. l10n,
  2191. textLayerMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("textLayerMode"),
  2192. annotationMode: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("annotationMode"),
  2193. annotationEditorMode,
  2194. annotationEditorHighlightColors: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("highlightEditorColors"),
  2195. enableHighlightFloatingButton: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableHighlightFloatingButton"),
  2196. imageResourcesPath: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("imageResourcesPath"),
  2197. enablePrintAutoRotate: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePrintAutoRotate"),
  2198. maxCanvasPixels: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("maxCanvasPixels"),
  2199. enablePermissions: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePermissions"),
  2200. pageColors,
  2201. mlManager: this.mlManager
  2202. });
  2203. this.pdfViewer = pdfViewer;
  2204. pdfRenderingQueue.setViewer(pdfViewer);
  2205. pdfLinkService.setViewer(pdfViewer);
  2206. pdfScriptingManager.setViewer(pdfViewer);
  2207. if (appConfig.sidebar?.thumbnailView) {
  2208. this.pdfThumbnailViewer = new web_pdf_thumbnail_viewer__WEBPACK_IMPORTED_MODULE_23__.PDFThumbnailViewer({
  2209. container: appConfig.sidebar.thumbnailView,
  2210. eventBus,
  2211. renderingQueue: pdfRenderingQueue,
  2212. linkService: pdfLinkService,
  2213. pageColors
  2214. });
  2215. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  2216. }
  2217. if (!this.isViewerEmbedded && !_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disableHistory")) {
  2218. this.pdfHistory = new _pdf_history_js__WEBPACK_IMPORTED_MODULE_15__.PDFHistory({
  2219. linkService: pdfLinkService,
  2220. eventBus
  2221. });
  2222. pdfLinkService.setHistory(this.pdfHistory);
  2223. }
  2224. if (!this.supportsIntegratedFind && appConfig.findBar) {
  2225. this.findBar = new web_pdf_find_bar__WEBPACK_IMPORTED_MODULE_13__.PDFFindBar(appConfig.findBar, eventBus);
  2226. }
  2227. if (appConfig.annotationEditorParams) {
  2228. if (annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.DISABLE) {
  2229. if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableStampEditor")) {
  2230. // 需要隐藏添加hidden即可
  2231. appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
  2232. }
  2233. const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
  2234. if (editorHighlightButton && _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableHighlightEditor")) {
  2235. editorHighlightButton.hidden = false;
  2236. }
  2237. this.annotationEditorParams = new web_annotation_editor_params__WEBPACK_IMPORTED_MODULE_7__.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  2238. } else {
  2239. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  2240. document.getElementById(id)?.classList.add("hidden");
  2241. }
  2242. }
  2243. }
  2244. if (appConfig.documentProperties) {
  2245. // [custom] 初始化的时候给odl-dom添加title
  2246. this.pdfDocumentProperties = new web_pdf_document_properties__WEBPACK_IMPORTED_MODULE_12__.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
  2247. }
  2248. if (appConfig.secondaryToolbar?.cursorHandToolButton) {
  2249. this.pdfCursorTools = new web_pdf_cursor_tools__WEBPACK_IMPORTED_MODULE_11__.PDFCursorTools({
  2250. container,
  2251. eventBus,
  2252. cursorToolOnLoad: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("cursorToolOnLoad")
  2253. });
  2254. }
  2255. if (appConfig.toolbar) {
  2256. this.toolbar = new web_toolbar__WEBPACK_IMPORTED_MODULE_26__.Toolbar(appConfig.toolbar, eventBus);
  2257. }
  2258. if (appConfig.secondaryToolbar) {
  2259. this.secondaryToolbar = new web_secondary_toolbar__WEBPACK_IMPORTED_MODULE_25__.SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
  2260. }
  2261. if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
  2262. this.pdfPresentationMode = new web_pdf_presentation_mode__WEBPACK_IMPORTED_MODULE_18__.PDFPresentationMode({
  2263. container,
  2264. pdfViewer,
  2265. eventBus
  2266. });
  2267. }
  2268. if (appConfig.passwordOverlay) {
  2269. this.passwordPrompt = new _password_prompt_js__WEBPACK_IMPORTED_MODULE_9__.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.isViewerEmbedded);
  2270. }
  2271. // console.log('test-appConfig.sidebar', appConfig.sidebar)
  2272. if (appConfig.sidebar?.outlineView) {
  2273. this.pdfOutlineViewer = new web_pdf_outline_viewer__WEBPACK_IMPORTED_MODULE_17__.PDFOutlineViewer({
  2274. container: appConfig.sidebar.outlineView,
  2275. eventBus,
  2276. l10n,
  2277. linkService: pdfLinkService,
  2278. downloadManager
  2279. });
  2280. }
  2281. if (appConfig.sidebar?.attachmentsView) {
  2282. this.pdfAttachmentViewer = new web_pdf_attachment_viewer__WEBPACK_IMPORTED_MODULE_10__.PDFAttachmentViewer({
  2283. container: appConfig.sidebar.attachmentsView,
  2284. eventBus,
  2285. l10n,
  2286. downloadManager
  2287. });
  2288. }
  2289. if (appConfig.sidebar?.layersView) {
  2290. this.pdfLayerViewer = new web_pdf_layer_viewer__WEBPACK_IMPORTED_MODULE_16__.PDFLayerViewer({
  2291. container: appConfig.sidebar.layersView,
  2292. eventBus,
  2293. l10n
  2294. });
  2295. }
  2296. if (appConfig.sidebar) {
  2297. this.pdfSidebar = new web_pdf_sidebar__WEBPACK_IMPORTED_MODULE_22__.PDFSidebar({
  2298. elements: appConfig.sidebar,
  2299. eventBus,
  2300. l10n
  2301. });
  2302. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  2303. this.pdfSidebar.onUpdateThumbnails = () => {
  2304. for (const pageView of pdfViewer.getCachedPageViews()) {
  2305. if (pageView.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  2306. this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
  2307. }
  2308. }
  2309. this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  2310. };
  2311. }
  2312. },
  2313. async run(config) {
  2314. this.preferences = new web_external_services__WEBPACK_IMPORTED_MODULE_4__.Preferences();
  2315. await this.initialize(config);
  2316. const {
  2317. appConfig,
  2318. eventBus
  2319. } = this;
  2320. let file;
  2321. const queryString = document.location.search.substring(1);
  2322. const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(queryString);
  2323. // TODO这里添加url
  2324. file = params.get("file") ?? _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultUrl");
  2325. validateFileURL(file);
  2326. const fileInput = this._openFileInput = document.createElement("input");
  2327. fileInput.id = "fileInput";
  2328. fileInput.hidden = true;
  2329. fileInput.type = "file";
  2330. fileInput.value = null;
  2331. document.body.append(fileInput);
  2332. fileInput.addEventListener("change", function (evt) {
  2333. const {
  2334. files
  2335. } = evt.target;
  2336. if (!files || files.length === 0) {
  2337. return;
  2338. }
  2339. console.log('test-file-open',files)
  2340. eventBus.dispatch("fileinputchange", {
  2341. source: this,
  2342. fileInput: evt.target
  2343. });
  2344. });
  2345. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2346. evt.preventDefault();
  2347. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  2348. });
  2349. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2350. evt.preventDefault();
  2351. const {
  2352. files
  2353. } = evt.dataTransfer;
  2354. if (!files || files.length === 0) {
  2355. return;
  2356. }
  2357. eventBus.dispatch("fileinputchange", {
  2358. source: this,
  2359. fileInput: evt.dataTransfer
  2360. });
  2361. });
  2362. if (!_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsDocumentFonts")) {
  2363. _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.set("disableFontFace", true);
  2364. this.l10n.get("pdfjs-web-fonts-disabled").then(msg => {
  2365. console.warn(msg);
  2366. });
  2367. }
  2368. if (!this.supportsPrinting) {
  2369. appConfig.toolbar?.print?.classList.add("hidden");
  2370. appConfig.secondaryToolbar?.printButton.classList.add("hidden");
  2371. }
  2372. if (!this.supportsFullscreen) {
  2373. appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
  2374. }
  2375. if (this.supportsIntegratedFind) {
  2376. appConfig.toolbar?.viewFind?.classList.add("hidden");
  2377. }
  2378. if (file) {
  2379. this.open({
  2380. url: file
  2381. });
  2382. } else {
  2383. this._hideViewBookmark();
  2384. }
  2385. },
  2386. get externalServices() {
  2387. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "externalServices", new web_external_services__WEBPACK_IMPORTED_MODULE_4__.ExternalServices());
  2388. },
  2389. get mlManager() {
  2390. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "mlManager", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableML") === true ? new web_external_services__WEBPACK_IMPORTED_MODULE_4__.MLManager() : null);
  2391. },
  2392. get initialized() {
  2393. return this._initializedCapability.settled;
  2394. },
  2395. get initializedPromise() {
  2396. return this._initializedCapability.promise;
  2397. },
  2398. zoomIn(steps, scaleFactor) {
  2399. if (this.pdfViewer.isInPresentationMode) {
  2400. return;
  2401. }
  2402. this.pdfViewer.increaseScale({
  2403. drawingDelay: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomDelay"),
  2404. steps,
  2405. scaleFactor
  2406. });
  2407. },
  2408. zoomOut(steps, scaleFactor) {
  2409. if (this.pdfViewer.isInPresentationMode) {
  2410. return;
  2411. }
  2412. this.pdfViewer.decreaseScale({
  2413. drawingDelay: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomDelay"),
  2414. steps,
  2415. scaleFactor
  2416. });
  2417. },
  2418. zoomReset() {
  2419. if (this.pdfViewer.isInPresentationMode) {
  2420. return;
  2421. }
  2422. this.pdfViewer.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE;
  2423. },
  2424. get pagesCount() {
  2425. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  2426. },
  2427. get page() {
  2428. return this.pdfViewer.currentPageNumber;
  2429. },
  2430. set page(val) {
  2431. this.pdfViewer.currentPageNumber = val;
  2432. },
  2433. get supportsPrinting() {
  2434. return web_print_service__WEBPACK_IMPORTED_MODULE_19__.PDFPrintServiceFactory.supportsPrinting;
  2435. },
  2436. get supportsFullscreen() {
  2437. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  2438. },
  2439. get supportsPinchToZoom() {
  2440. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsPinchToZoom", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsPinchToZoom"));
  2441. },
  2442. get supportsIntegratedFind() {
  2443. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsIntegratedFind", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsIntegratedFind"));
  2444. },
  2445. get loadingBar() {
  2446. const barElement = document.getElementById("loadingBar");
  2447. const bar = barElement ? new _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ProgressBar(barElement) : null;
  2448. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "loadingBar", bar);
  2449. },
  2450. get supportsMouseWheelZoomCtrlKey() {
  2451. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsMouseWheelZoomCtrlKey", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsMouseWheelZoomCtrlKey"));
  2452. },
  2453. get supportsMouseWheelZoomMetaKey() {
  2454. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "supportsMouseWheelZoomMetaKey", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsMouseWheelZoomMetaKey"));
  2455. },
  2456. get supportsCaretBrowsingMode() {
  2457. return _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("supportsCaretBrowsingMode");
  2458. },
  2459. moveCaret(isUp, select) {
  2460. this._caretBrowsing ||= new _caret_browsing_js__WEBPACK_IMPORTED_MODULE_28__.CaretBrowsingMode(this.appConfig.mainContainer, this.appConfig.viewerContainer, this.appConfig.toolbar?.container);
  2461. this._caretBrowsing.moveCaret(isUp, select);
  2462. },
  2463. setTitleUsingUrl(url = "", downloadUrl = null) {
  2464. this.url = url;
  2465. this.baseUrl = url.split("#", 1)[0];
  2466. if (downloadUrl) {
  2467. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0];
  2468. }
  2469. if ((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.isDataScheme)(url)) {
  2470. this._hideViewBookmark();
  2471. }
  2472. let title = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getPdfFilenameFromUrl)(url, "");
  2473. if (!title) {
  2474. try {
  2475. title = decodeURIComponent((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getFilenameFromUrl)(url)) || url;
  2476. } catch {
  2477. title = url;
  2478. }
  2479. }
  2480. this.setTitle(title);
  2481. },
  2482. setTitle(title = this._title) {
  2483. this._title = title;
  2484. if (this.isViewerEmbedded) {
  2485. return;
  2486. }
  2487. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  2488. document.title = `${editorIndicator ? "* " : ""}${title}`;
  2489. },
  2490. get _docFilename() {
  2491. return this._contentDispositionFilename || (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getPdfFilenameFromUrl)(this.url);
  2492. },
  2493. _hideViewBookmark() {
  2494. const {
  2495. secondaryToolbar
  2496. } = this.appConfig;
  2497. secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
  2498. if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
  2499. document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
  2500. }
  2501. },
  2502. async close() {
  2503. this._unblockDocumentLoadEvent();
  2504. this._hideViewBookmark();
  2505. if (!this.pdfLoadingTask) {
  2506. return;
  2507. }
  2508. if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
  2509. try {
  2510. await this.save();
  2511. } catch {}
  2512. }
  2513. const promises = [];
  2514. promises.push(this.pdfLoadingTask.destroy());
  2515. this.pdfLoadingTask = null;
  2516. if (this.pdfDocument) {
  2517. this.pdfDocument = null;
  2518. this.pdfThumbnailViewer?.setDocument(null);
  2519. this.pdfViewer.setDocument(null);
  2520. this.pdfLinkService.setDocument(null);
  2521. this.pdfDocumentProperties?.setDocument(null);
  2522. }
  2523. this.pdfLinkService.externalLinkEnabled = true;
  2524. this.store = null;
  2525. this.isInitialViewSet = false;
  2526. this.downloadComplete = false;
  2527. this.url = "";
  2528. this.baseUrl = "";
  2529. this._downloadUrl = "";
  2530. this.documentInfo = null;
  2531. this.metadata = null;
  2532. this._contentDispositionFilename = null;
  2533. this._contentLength = null;
  2534. this._saveInProgress = false;
  2535. this._hasAnnotationEditors = false;
  2536. promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
  2537. this.setTitle();
  2538. this.pdfSidebar?.reset();
  2539. this.pdfOutlineViewer?.reset();
  2540. this.pdfAttachmentViewer?.reset();
  2541. this.pdfLayerViewer?.reset();
  2542. this.pdfHistory?.reset();
  2543. this.findBar?.reset();
  2544. this.toolbar?.reset();
  2545. this.secondaryToolbar?.reset();
  2546. this._PDFBug?.cleanup();
  2547. await Promise.all(promises);
  2548. },
  2549. async open(args) {
  2550. // TIP: 打开pdf并且进行解析的逻辑
  2551. if (this.pdfLoadingTask) {
  2552. await this.close();
  2553. }
  2554. // console.log('test-pdf', this)
  2555. const workerParams = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.getAll(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.OptionKind.WORKER);
  2556. Object.assign(pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions, workerParams);
  2557. if (args.url) {
  2558. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  2559. }
  2560. const apiParams = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.getAll(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.OptionKind.API);
  2561. const loadingTask = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getDocument)({
  2562. ...apiParams,
  2563. ...args
  2564. });
  2565. this.pdfLoadingTask = loadingTask;
  2566. loadingTask.onPassword = (updateCallback, reason) => {
  2567. if (this.isViewerEmbedded) {
  2568. this._unblockDocumentLoadEvent();
  2569. }
  2570. this.pdfLinkService.externalLinkEnabled = false;
  2571. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2572. this.passwordPrompt.open();
  2573. };
  2574. loadingTask.onProgress = ({
  2575. loaded,
  2576. total
  2577. }) => {
  2578. this.progress(loaded / total);
  2579. };
  2580. return loadingTask.promise.then(pdfDocument => {
  2581. // [Custom] desc: aƒdd loaded listen
  2582. // console.log('test-loaded')
  2583. this.load(pdfDocument);
  2584. }, reason => {
  2585. if (loadingTask !== this.pdfLoadingTask) {
  2586. return undefined;
  2587. }
  2588. let key = "pdfjs-loading-error";
  2589. if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.InvalidPDFException) {
  2590. key = "pdfjs-invalid-file-error";
  2591. } else if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.MissingPDFException) {
  2592. key = "pdfjs-missing-file-error";
  2593. } else if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.UnexpectedResponseException) {
  2594. key = "pdfjs-unexpected-response-error";
  2595. }
  2596. return this._documentError(key, {
  2597. message: reason.message
  2598. }).then(() => {
  2599. throw reason;
  2600. });
  2601. });
  2602. },
  2603. _ensureDownloadComplete() {
  2604. if (this.pdfDocument && this.downloadComplete) {
  2605. return;
  2606. }
  2607. throw new Error("PDF document not downloaded.");
  2608. },
  2609. async download(options = {}) {
  2610. const url = this._downloadUrl,
  2611. filename = this._docFilename;
  2612. try {
  2613. this._ensureDownloadComplete();
  2614. const data = await this.pdfDocument.getData();
  2615. const blob = new Blob([data], {
  2616. type: "application/pdf"
  2617. });
  2618. await this.downloadManager.download(blob, url, filename, options);
  2619. } catch {
  2620. await this.downloadManager.downloadUrl(url, filename, options);
  2621. }
  2622. },
  2623. async save(options = {}) {
  2624. if (this._saveInProgress) {
  2625. return;
  2626. }
  2627. this._saveInProgress = true;
  2628. await this.pdfScriptingManager.dispatchWillSave();
  2629. const url = this._downloadUrl,
  2630. filename = this._docFilename;
  2631. try {
  2632. this._ensureDownloadComplete();
  2633. const data = await this.pdfDocument.saveDocument();
  2634. const blob = new Blob([data], {
  2635. type: "application/pdf"
  2636. });
  2637. await this.downloadManager.download(blob, url, filename, options);
  2638. } catch (reason) {
  2639. console.error(`Error when saving the document: ${reason.message}`);
  2640. await this.download(options);
  2641. } finally {
  2642. await this.pdfScriptingManager.dispatchDidSave();
  2643. this._saveInProgress = false;
  2644. }
  2645. if (this._hasAnnotationEditors) {
  2646. this.externalServices.reportTelemetry({
  2647. type: "editing",
  2648. data: {
  2649. type: "save",
  2650. stats: this.pdfDocument?.annotationStorage.editorStats
  2651. }
  2652. });
  2653. }
  2654. },
  2655. downloadOrSave(options = {}) {
  2656. if (this.pdfDocument?.annotationStorage.size > 0) {
  2657. this.save(options);
  2658. } else {
  2659. this.download(options);
  2660. }
  2661. },
  2662. async _documentError(key, moreInfo = null) {
  2663. this._unblockDocumentLoadEvent();
  2664. const message = await this._otherError(key || "pdfjs-loading-error", moreInfo);
  2665. this.eventBus.dispatch("documenterror", {
  2666. source: this,
  2667. message,
  2668. reason: moreInfo?.message ?? null
  2669. });
  2670. },
  2671. async _otherError(key, moreInfo = null) {
  2672. const message = await this.l10n.get(key);
  2673. const moreInfoText = [`PDF.js v${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} (build: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"})`];
  2674. if (moreInfo) {
  2675. moreInfoText.push(`Message: ${moreInfo.message}`);
  2676. if (moreInfo.stack) {
  2677. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  2678. } else {
  2679. if (moreInfo.filename) {
  2680. moreInfoText.push(`File: ${moreInfo.filename}`);
  2681. }
  2682. if (moreInfo.lineNumber) {
  2683. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  2684. }
  2685. }
  2686. }
  2687. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  2688. return message;
  2689. },
  2690. progress(level) {
  2691. if (!this.loadingBar || this.downloadComplete) {
  2692. return;
  2693. }
  2694. const percent = Math.round(level * 100);
  2695. if (percent <= this.loadingBar.percent) {
  2696. return;
  2697. }
  2698. this.loadingBar.percent = percent;
  2699. if (this.pdfDocument?.loadingParams.disableAutoFetch ?? _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disableAutoFetch")) {
  2700. this.loadingBar.setDisableAutoFetch();
  2701. }
  2702. },
  2703. load(pdfDocument) {
  2704. this.pdfDocument = pdfDocument;
  2705. pdfDocument.getDownloadInfo().then(({
  2706. length
  2707. }) => {
  2708. this._contentLength = length;
  2709. this.downloadComplete = true;
  2710. this.loadingBar?.hide();
  2711. firstPagePromise.then(() => {
  2712. this.eventBus.dispatch("documentloaded", {
  2713. source: this
  2714. });
  2715. });
  2716. });
  2717. const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
  2718. const pageModePromise = pdfDocument.getPageMode().catch(() => {});
  2719. const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
  2720. this.toolbar?.setPagesCount(pdfDocument.numPages, false);
  2721. this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
  2722. this.pdfLinkService.setDocument(pdfDocument);
  2723. this.pdfDocumentProperties?.setDocument(pdfDocument);
  2724. const pdfViewer = this.pdfViewer;
  2725. pdfViewer.setDocument(pdfDocument);
  2726. const {
  2727. firstPagePromise,
  2728. onePageRendered,
  2729. pagesPromise
  2730. } = pdfViewer;
  2731. this.pdfThumbnailViewer?.setDocument(pdfDocument);
  2732. const storedPromise = (this.store = new _view_history_js__WEBPACK_IMPORTED_MODULE_29__.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  2733. page: null,
  2734. zoom: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE,
  2735. scrollLeft: "0",
  2736. scrollTop: "0",
  2737. rotation: null,
  2738. sidebarView: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN,
  2739. scrollMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN,
  2740. spreadMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN
  2741. }).catch(() => {});
  2742. firstPagePromise.then(pdfPage => {
  2743. this.loadingBar?.setWidth(this.appConfig.viewerContainer);
  2744. this._initializeAnnotationStorageCallbacks(pdfDocument);
  2745. Promise.all([_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => {
  2746. const viewOnLoad = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("viewOnLoad");
  2747. this._initializePdfHistory({
  2748. fingerprint: pdfDocument.fingerprints[0],
  2749. viewOnLoad,
  2750. initialDest: openAction?.dest
  2751. });
  2752. const initialBookmark = this.initialBookmark;
  2753. const zoom = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("defaultZoomValue");
  2754. let hash = zoom ? `zoom=${zoom}` : null;
  2755. let rotation = null;
  2756. let sidebarView = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("sidebarViewOnLoad");
  2757. let scrollMode = 3 || _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("scrollModeOnLoad");
  2758. let spreadMode = _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("spreadModeOnLoad");
  2759. console.log('test-page-mode', sidebarView, scrollMode, spreadMode, stored.page)
  2760. if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  2761. // [custom]
  2762. // hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  2763. hash = `page=${0}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  2764. rotation = parseInt(stored.rotation, 10);
  2765. if (sidebarView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
  2766. sidebarView = stored.sidebarView | 0;
  2767. }
  2768. if (scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN) {
  2769. scrollMode = stored.scrollMode | 0;
  2770. }
  2771. if (spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN) {
  2772. spreadMode = stored.spreadMode | 0;
  2773. }
  2774. }
  2775. if (pageMode && sidebarView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
  2776. sidebarView = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageModeToSidebarView)(pageMode);
  2777. }
  2778. if (pageLayout && scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.UNKNOWN && spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.UNKNOWN) {
  2779. const modes = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageLayoutToViewerModes)(pageLayout);
  2780. spreadMode = modes.spreadMode;
  2781. }
  2782. // TIP: 屏蔽上述scrollMode逻辑强制设置scrollMode 为3
  2783. // custom scrollMode
  2784. // console.log('test-dd', evt.pageNumber)
  2785. scrollMode = 2
  2786. spreadMode = 0
  2787. this.setInitialView(hash, {
  2788. rotation,
  2789. sidebarView,
  2790. scrollMode,
  2791. spreadMode
  2792. });
  2793. this.eventBus.dispatch("documentinit", {
  2794. source: this
  2795. });
  2796. if (!this.isViewerEmbedded) {
  2797. pdfViewer.focus();
  2798. }
  2799. await Promise.race([pagesPromise, new Promise(resolve => {
  2800. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  2801. })]);
  2802. if (!initialBookmark && !hash) {
  2803. return;
  2804. }
  2805. if (pdfViewer.hasEqualPageSizes) {
  2806. return;
  2807. }
  2808. this.initialBookmark = initialBookmark;
  2809. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  2810. this.setInitialView(hash);
  2811. }).catch(() => {
  2812. this.setInitialView();
  2813. }).then(function () {
  2814. pdfViewer.update();
  2815. });
  2816. });
  2817. pagesPromise.then(() => {
  2818. this._unblockDocumentLoadEvent();
  2819. this._initializeAutoPrint(pdfDocument, openActionPromise);
  2820. }, reason => {
  2821. this._documentError("pdfjs-loading-error", {
  2822. message: reason.message
  2823. });
  2824. });
  2825. onePageRendered.then(data => {
  2826. this.externalServices.reportTelemetry({
  2827. type: "pageInfo",
  2828. timestamp: data.timestamp
  2829. });
  2830. if (this.pdfOutlineViewer) {
  2831. pdfDocument.getOutline().then(outline => {
  2832. if (pdfDocument !== this.pdfDocument) {
  2833. return;
  2834. }
  2835. this.pdfOutlineViewer.render({
  2836. outline,
  2837. pdfDocument
  2838. });
  2839. });
  2840. }
  2841. if (this.pdfAttachmentViewer) {
  2842. pdfDocument.getAttachments().then(attachments => {
  2843. if (pdfDocument !== this.pdfDocument) {
  2844. return;
  2845. }
  2846. this.pdfAttachmentViewer.render({
  2847. attachments
  2848. });
  2849. });
  2850. }
  2851. if (this.pdfLayerViewer) {
  2852. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  2853. if (pdfDocument !== this.pdfDocument) {
  2854. return;
  2855. }
  2856. this.pdfLayerViewer.render({
  2857. optionalContentConfig,
  2858. pdfDocument
  2859. });
  2860. });
  2861. }
  2862. });
  2863. this._initializePageLabels(pdfDocument);
  2864. this._initializeMetadata(pdfDocument);
  2865. },
  2866. async _scriptingDocProperties(pdfDocument) {
  2867. if (!this.documentInfo) {
  2868. await new Promise(resolve => {
  2869. this.eventBus._on("metadataloaded", resolve, {
  2870. once: true
  2871. });
  2872. });
  2873. if (pdfDocument !== this.pdfDocument) {
  2874. return null;
  2875. }
  2876. }
  2877. if (!this._contentLength) {
  2878. await new Promise(resolve => {
  2879. this.eventBus._on("documentloaded", resolve, {
  2880. once: true
  2881. });
  2882. });
  2883. if (pdfDocument !== this.pdfDocument) {
  2884. return null;
  2885. }
  2886. }
  2887. return {
  2888. ...this.documentInfo,
  2889. baseURL: this.baseUrl,
  2890. filesize: this._contentLength,
  2891. filename: this._docFilename,
  2892. metadata: this.metadata?.getRaw(),
  2893. authors: this.metadata?.get("dc:creator"),
  2894. numPages: this.pagesCount,
  2895. URL: this.url
  2896. };
  2897. },
  2898. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  2899. const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]);
  2900. if (pdfDocument !== this.pdfDocument) {
  2901. return;
  2902. }
  2903. let triggerAutoPrint = openAction?.action === "Print";
  2904. if (jsActions) {
  2905. console.warn("Warning: JavaScript support is not enabled");
  2906. for (const name in jsActions) {
  2907. if (triggerAutoPrint) {
  2908. break;
  2909. }
  2910. switch (name) {
  2911. case "WillClose":
  2912. case "WillSave":
  2913. case "DidSave":
  2914. case "WillPrint":
  2915. case "DidPrint":
  2916. continue;
  2917. }
  2918. triggerAutoPrint = jsActions[name].some(js => _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.AutoPrintRegExp.test(js));
  2919. }
  2920. }
  2921. if (triggerAutoPrint) {
  2922. this.triggerPrinting();
  2923. }
  2924. },
  2925. async _initializeMetadata(pdfDocument) {
  2926. const {
  2927. info,
  2928. metadata,
  2929. contentDispositionFilename,
  2930. contentLength
  2931. } = await pdfDocument.getMetadata();
  2932. if (pdfDocument !== this.pdfDocument) {
  2933. return;
  2934. }
  2935. this.documentInfo = info;
  2936. this.metadata = metadata;
  2937. this._contentDispositionFilename ??= contentDispositionFilename;
  2938. this._contentLength ??= contentLength;
  2939. // TIP:赋予title的逻辑
  2940. // console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} [${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"}])`);
  2941. let pdfTitle = info.Title;
  2942. const metadataTitle = metadata?.get("dc:title");
  2943. if (metadataTitle) {
  2944. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2945. pdfTitle = metadataTitle;
  2946. }
  2947. }
  2948. if (pdfTitle) {
  2949. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  2950. } else if (this._contentDispositionFilename) {
  2951. this.setTitle(this._contentDispositionFilename);
  2952. }
  2953. // [Custom] desc: use title from postMessage
  2954. // const odlPdfTitle = document.getElementById("odl-pdf-title");
  2955. // odlPdfTitle.innerText = this._contentDispositionFilename || this._title;
  2956. // odlPdfTitle.setAttribute('title', this._contentDispositionFilename || this._title);
  2957. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  2958. if (pdfDocument.loadingParams.enableXfa) {
  2959. console.warn("Warning: XFA Foreground documents are not supported");
  2960. } else {
  2961. console.warn("Warning: XFA support is not enabled");
  2962. }
  2963. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  2964. console.warn("Warning: Interactive form support is not enabled");
  2965. }
  2966. if (info.IsSignaturesPresent) {
  2967. console.warn("Warning: Digital signatures validation is not supported");
  2968. }
  2969. this.eventBus.dispatch("metadataloaded", {
  2970. source: this
  2971. });
  2972. },
  2973. async _initializePageLabels(pdfDocument) {
  2974. const labels = await pdfDocument.getPageLabels();
  2975. if (pdfDocument !== this.pdfDocument) {
  2976. return;
  2977. }
  2978. if (!labels || _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("disablePageLabels")) {
  2979. return;
  2980. }
  2981. const numLabels = labels.length;
  2982. let standardLabels = 0,
  2983. emptyLabels = 0;
  2984. for (let i = 0; i < numLabels; i++) {
  2985. const label = labels[i];
  2986. if (label === (i + 1).toString()) {
  2987. standardLabels++;
  2988. } else if (label === "") {
  2989. emptyLabels++;
  2990. } else {
  2991. break;
  2992. }
  2993. }
  2994. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  2995. return;
  2996. }
  2997. const {
  2998. pdfViewer,
  2999. pdfThumbnailViewer,
  3000. toolbar
  3001. } = this;
  3002. pdfViewer.setPageLabels(labels);
  3003. pdfThumbnailViewer?.setPageLabels(labels);
  3004. toolbar?.setPagesCount(numLabels, true);
  3005. toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3006. },
  3007. _initializePdfHistory({
  3008. fingerprint,
  3009. viewOnLoad,
  3010. initialDest = null
  3011. }) {
  3012. if (!this.pdfHistory) {
  3013. return;
  3014. }
  3015. this.pdfHistory.initialize({
  3016. fingerprint,
  3017. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  3018. updateUrl: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("historyUpdateUrl")
  3019. });
  3020. if (this.pdfHistory.initialBookmark) {
  3021. this.initialBookmark = this.pdfHistory.initialBookmark;
  3022. this.initialRotation = this.pdfHistory.initialRotation;
  3023. }
  3024. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  3025. this.initialBookmark = JSON.stringify(initialDest);
  3026. this.pdfHistory.push({
  3027. explicitDest: initialDest,
  3028. pageNumber: null
  3029. });
  3030. }
  3031. },
  3032. _initializeAnnotationStorageCallbacks(pdfDocument) {
  3033. if (pdfDocument !== this.pdfDocument) {
  3034. return;
  3035. }
  3036. const {
  3037. annotationStorage
  3038. } = pdfDocument;
  3039. annotationStorage.onSetModified = () => {
  3040. window.addEventListener("beforeunload", beforeUnload);
  3041. this._annotationStorageModified = true;
  3042. };
  3043. annotationStorage.onResetModified = () => {
  3044. window.removeEventListener("beforeunload", beforeUnload);
  3045. delete this._annotationStorageModified;
  3046. };
  3047. annotationStorage.onAnnotationEditor = typeStr => {
  3048. this._hasAnnotationEditors = !!typeStr;
  3049. this.setTitle();
  3050. };
  3051. },
  3052. setInitialView(storedHash, {
  3053. rotation,
  3054. sidebarView,
  3055. scrollMode,
  3056. spreadMode
  3057. } = {}) {
  3058. const setRotation = angle => {
  3059. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(angle)) {
  3060. this.pdfViewer.pagesRotation = angle;
  3061. }
  3062. };
  3063. const setViewerModes = (scroll, spread) => {
  3064. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidScrollMode)(scroll)) {
  3065. this.pdfViewer.scrollMode = scroll;
  3066. }
  3067. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidSpreadMode)(spread)) {
  3068. this.pdfViewer.spreadMode = spread;
  3069. }
  3070. };
  3071. this.isInitialViewSet = true;
  3072. this.pdfSidebar?.setInitialView(sidebarView);
  3073. setViewerModes(scrollMode, spreadMode);
  3074. if (this.initialBookmark) {
  3075. setRotation(this.initialRotation);
  3076. delete this.initialRotation;
  3077. this.pdfLinkService.setHash(this.initialBookmark);
  3078. this.initialBookmark = null;
  3079. } else if (storedHash) {
  3080. setRotation(rotation);
  3081. this.pdfLinkService.setHash(storedHash);
  3082. }
  3083. this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  3084. this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
  3085. if (!this.pdfViewer.currentScaleValue) {
  3086. this.pdfViewer.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SCALE_VALUE;
  3087. }
  3088. },
  3089. _cleanup() {
  3090. if (!this.pdfDocument) {
  3091. return;
  3092. }
  3093. this.pdfViewer.cleanup();
  3094. this.pdfThumbnailViewer?.cleanup();
  3095. this.pdfDocument.cleanup(_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("fontExtraProperties"));
  3096. },
  3097. forceRendering() {
  3098. this.pdfRenderingQueue.printing = !!this.printService;
  3099. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  3100. this.pdfRenderingQueue.renderHighestPriority();
  3101. },
  3102. beforePrint() {
  3103. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => this.pdfDocument?.annotationStorage.print);
  3104. if (this.printService) {
  3105. return;
  3106. }
  3107. if (!this.supportsPrinting) {
  3108. this._otherError("pdfjs-printing-not-supported");
  3109. return;
  3110. }
  3111. if (!this.pdfViewer.pageViewsReady) {
  3112. this.l10n.get("pdfjs-printing-not-ready").then(msg => {
  3113. window.alert(msg);
  3114. });
  3115. return;
  3116. }
  3117. this.printService = web_print_service__WEBPACK_IMPORTED_MODULE_19__.PDFPrintServiceFactory.createPrintService({
  3118. pdfDocument: this.pdfDocument,
  3119. pagesOverview: this.pdfViewer.getPagesOverview(),
  3120. printContainer: this.appConfig.printContainer,
  3121. printResolution: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("printResolution"),
  3122. printAnnotationStoragePromise: this._printAnnotationStoragePromise
  3123. });
  3124. this.forceRendering();
  3125. this.setTitle();
  3126. this.printService.layout();
  3127. if (this._hasAnnotationEditors) {
  3128. this.externalServices.reportTelemetry({
  3129. type: "editing",
  3130. data: {
  3131. type: "print",
  3132. stats: this.pdfDocument?.annotationStorage.editorStats
  3133. }
  3134. });
  3135. }
  3136. },
  3137. afterPrint() {
  3138. if (this._printAnnotationStoragePromise) {
  3139. this._printAnnotationStoragePromise.then(() => {
  3140. this.pdfScriptingManager.dispatchDidPrint();
  3141. });
  3142. this._printAnnotationStoragePromise = null;
  3143. }
  3144. if (this.printService) {
  3145. this.printService.destroy();
  3146. this.printService = null;
  3147. this.pdfDocument?.annotationStorage.resetModified();
  3148. }
  3149. this.forceRendering();
  3150. this.setTitle();
  3151. },
  3152. rotatePages(delta) {
  3153. this.pdfViewer.pagesRotation += delta;
  3154. },
  3155. requestPresentationMode() {
  3156. this.pdfPresentationMode?.request();
  3157. },
  3158. triggerPrinting() {
  3159. if (!this.supportsPrinting) {
  3160. return;
  3161. }
  3162. window.print();
  3163. },
  3164. bindEvents() {
  3165. if (this._eventBusAbortController) {
  3166. return;
  3167. }
  3168. this._eventBusAbortController = new AbortController();
  3169. const {
  3170. eventBus,
  3171. _eventBusAbortController: {
  3172. signal
  3173. }
  3174. } = this;
  3175. eventBus._on("resize", webViewerResize, {
  3176. signal
  3177. });
  3178. eventBus._on("hashchange", webViewerHashchange, {
  3179. signal
  3180. });
  3181. eventBus._on("beforeprint", this.beforePrint.bind(this), {
  3182. signal
  3183. });
  3184. eventBus._on("afterprint", this.afterPrint.bind(this), {
  3185. signal
  3186. });
  3187. eventBus._on("pagerender", webViewerPageRender, {
  3188. signal
  3189. });
  3190. eventBus._on("pagerendered", webViewerPageRendered, {
  3191. signal
  3192. });
  3193. eventBus._on("updateviewarea", webViewerUpdateViewarea, {
  3194. signal
  3195. });
  3196. eventBus._on("pagechanging", webViewerPageChanging, {
  3197. signal
  3198. });
  3199. eventBus._on("scalechanging", webViewerScaleChanging, {
  3200. signal
  3201. });
  3202. eventBus._on("rotationchanging", webViewerRotationChanging, {
  3203. signal
  3204. });
  3205. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged, {
  3206. signal
  3207. });
  3208. eventBus._on("pagemode", webViewerPageMode, {
  3209. signal
  3210. });
  3211. eventBus._on("namedaction", webViewerNamedAction, {
  3212. signal
  3213. });
  3214. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged, {
  3215. signal
  3216. });
  3217. eventBus._on("presentationmode", webViewerPresentationMode, {
  3218. signal
  3219. });
  3220. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode, {
  3221. signal
  3222. });
  3223. eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams, {
  3224. signal
  3225. });
  3226. eventBus._on("print", webViewerPrint, {
  3227. signal
  3228. });
  3229. eventBus._on("download", webViewerDownload, {
  3230. signal
  3231. });
  3232. eventBus._on("firstpage", webViewerFirstPage, {
  3233. signal
  3234. });
  3235. eventBus._on("lastpage", webViewerLastPage, {
  3236. signal
  3237. });
  3238. eventBus._on("nextpage", webViewerNextPage, {
  3239. signal
  3240. });
  3241. eventBus._on("previouspage", webViewerPreviousPage, {
  3242. signal
  3243. });
  3244. eventBus._on("zoomin", webViewerZoomIn, {
  3245. signal
  3246. });
  3247. eventBus._on("zoomout", webViewerZoomOut, {
  3248. signal
  3249. });
  3250. eventBus._on("zoomreset", webViewerZoomReset, {
  3251. signal
  3252. });
  3253. eventBus._on("pagenumberchanged", webViewerPageNumberChanged, {
  3254. signal
  3255. });
  3256. eventBus._on("scalechanged", webViewerScaleChanged, {
  3257. signal
  3258. });
  3259. eventBus._on("rotatecw", webViewerRotateCw, {
  3260. signal
  3261. });
  3262. eventBus._on("rotateccw", webViewerRotateCcw, {
  3263. signal
  3264. });
  3265. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig, {
  3266. signal
  3267. });
  3268. eventBus._on("switchscrollmode", webViewerSwitchScrollMode, {
  3269. signal
  3270. });
  3271. eventBus._on("scrollmodechanged", webViewerScrollModeChanged, {
  3272. signal
  3273. });
  3274. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode, {
  3275. signal
  3276. });
  3277. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged, {
  3278. signal
  3279. });
  3280. eventBus._on("documentproperties", webViewerDocumentProperties, {
  3281. signal
  3282. });
  3283. eventBus._on("findfromurlhash", webViewerFindFromUrlHash, {
  3284. signal
  3285. });
  3286. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount, {
  3287. signal
  3288. });
  3289. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState, {
  3290. signal
  3291. });
  3292. if (_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("pdfBug")) {
  3293. eventBus._on("pagerendered", reportPageStatsPDFBug, {
  3294. signal
  3295. });
  3296. eventBus._on("pagechanging", reportPageStatsPDFBug, {
  3297. signal
  3298. });
  3299. }
  3300. eventBus._on("fileinputchange", webViewerFileInputChange, {
  3301. signal
  3302. });
  3303. eventBus._on("openfile", webViewerOpenFile, {
  3304. signal
  3305. });
  3306. },
  3307. bindWindowEvents() {
  3308. if (this._windowAbortController) {
  3309. return;
  3310. }
  3311. this._windowAbortController = new AbortController();
  3312. const {
  3313. eventBus,
  3314. appConfig: {
  3315. mainContainer
  3316. },
  3317. _windowAbortController: {
  3318. signal
  3319. }
  3320. } = this;
  3321. function addWindowResolutionChange(evt = null) {
  3322. if (evt) {
  3323. webViewerResolutionChange(evt);
  3324. }
  3325. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  3326. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  3327. once: true,
  3328. signal
  3329. });
  3330. }
  3331. addWindowResolutionChange();
  3332. window.addEventListener("visibilitychange", webViewerVisibilityChange, {
  3333. signal
  3334. });
  3335. window.addEventListener("wheel", webViewerWheel, {
  3336. passive: false,
  3337. signal
  3338. });
  3339. window.addEventListener("touchstart", webViewerTouchStart, {
  3340. passive: false,
  3341. signal
  3342. });
  3343. window.addEventListener("touchmove", webViewerTouchMove, {
  3344. passive: false,
  3345. signal
  3346. });
  3347. window.addEventListener("touchend", webViewerTouchEnd, {
  3348. passive: false,
  3349. signal
  3350. });
  3351. window.addEventListener("click", webViewerClick, {
  3352. signal
  3353. });
  3354. window.addEventListener("keydown", webViewerKeyDown, {
  3355. signal
  3356. });
  3357. window.addEventListener("keyup", webViewerKeyUp, {
  3358. signal
  3359. });
  3360. window.addEventListener("resize", () => {
  3361. eventBus.dispatch("resize", {
  3362. source: window
  3363. });
  3364. }, {
  3365. signal
  3366. });
  3367. window.addEventListener("hashchange", () => {
  3368. eventBus.dispatch("hashchange", {
  3369. source: window,
  3370. hash: document.location.hash.substring(1)
  3371. });
  3372. }, {
  3373. signal
  3374. });
  3375. window.addEventListener("beforeprint", () => {
  3376. eventBus.dispatch("beforeprint", {
  3377. source: window
  3378. });
  3379. }, {
  3380. signal
  3381. });
  3382. window.addEventListener("afterprint", () => {
  3383. eventBus.dispatch("afterprint", {
  3384. source: window
  3385. });
  3386. }, {
  3387. signal
  3388. });
  3389. window.addEventListener("updatefromsandbox", event => {
  3390. eventBus.dispatch("updatefromsandbox", {
  3391. source: window,
  3392. detail: event.detail
  3393. });
  3394. }, {
  3395. signal
  3396. });
  3397. if (!("onscrollend" in document.documentElement)) {
  3398. return;
  3399. }
  3400. ({
  3401. scrollTop: this._lastScrollTop,
  3402. scrollLeft: this._lastScrollLeft
  3403. } = mainContainer);
  3404. const scrollend = () => {
  3405. ({
  3406. scrollTop: this._lastScrollTop,
  3407. scrollLeft: this._lastScrollLeft
  3408. } = mainContainer);
  3409. this._isScrolling = false;
  3410. mainContainer.addEventListener("scroll", scroll, {
  3411. passive: true,
  3412. signal
  3413. });
  3414. mainContainer.removeEventListener("scrollend", scrollend, {
  3415. signal
  3416. });
  3417. mainContainer.removeEventListener("blur", scrollend, {
  3418. signal
  3419. });
  3420. };
  3421. const scroll = () => {
  3422. if (this._isCtrlKeyDown) {
  3423. return;
  3424. }
  3425. if (this._lastScrollTop === mainContainer.scrollTop && this._lastScrollLeft === mainContainer.scrollLeft) {
  3426. return;
  3427. }
  3428. mainContainer.removeEventListener("scroll", scroll, {
  3429. passive: true,
  3430. signal
  3431. });
  3432. this._isScrolling = true;
  3433. mainContainer.addEventListener("scrollend", scrollend, {
  3434. signal
  3435. });
  3436. mainContainer.addEventListener("blur", scrollend, {
  3437. signal
  3438. });
  3439. };
  3440. mainContainer.addEventListener("scroll", scroll, {
  3441. passive: true,
  3442. signal
  3443. });
  3444. },
  3445. unbindEvents() {
  3446. this._eventBusAbortController?.abort();
  3447. this._eventBusAbortController = null;
  3448. },
  3449. unbindWindowEvents() {
  3450. this._windowAbortController?.abort();
  3451. this._windowAbortController = null;
  3452. },
  3453. _accumulateTicks(ticks, prop) {
  3454. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  3455. this[prop] = 0;
  3456. }
  3457. this[prop] += ticks;
  3458. const wholeTicks = Math.trunc(this[prop]);
  3459. this[prop] -= wholeTicks;
  3460. return wholeTicks;
  3461. },
  3462. _accumulateFactor(previousScale, factor, prop) {
  3463. if (factor === 1) {
  3464. return 1;
  3465. }
  3466. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  3467. this[prop] = 1;
  3468. }
  3469. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  3470. this[prop] = factor / newFactor;
  3471. return newFactor;
  3472. },
  3473. _centerAtPos(previousScale, x, y) {
  3474. const {
  3475. pdfViewer
  3476. } = this;
  3477. const scaleDiff = pdfViewer.currentScale / previousScale - 1;
  3478. if (scaleDiff !== 0) {
  3479. const [top, left] = pdfViewer.containerTopLeft;
  3480. pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
  3481. pdfViewer.container.scrollTop += (y - top) * scaleDiff;
  3482. }
  3483. },
  3484. _unblockDocumentLoadEvent() {
  3485. document.blockUnblockOnload?.(false);
  3486. this._unblockDocumentLoadEvent = () => {};
  3487. },
  3488. get scriptingReady() {
  3489. return this.pdfScriptingManager.ready;
  3490. }
  3491. };
  3492. (0,web_external_services__WEBPACK_IMPORTED_MODULE_4__.initCom)(PDFViewerApplication);
  3493. {
  3494. web_print_service__WEBPACK_IMPORTED_MODULE_19__.PDFPrintServiceFactory.initGlobals(PDFViewerApplication);
  3495. }
  3496. {
  3497. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  3498. var validateFileURL = function (file) {
  3499. if (!file) {
  3500. return;
  3501. }
  3502. try {
  3503. const viewerOrigin = new URL(window.location.href).origin || "null";
  3504. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  3505. return;
  3506. }
  3507. const fileOrigin = new URL(file, window.location.href).origin;
  3508. if (fileOrigin !== viewerOrigin) {
  3509. // throw new Error("file origin does not match viewer's");
  3510. }
  3511. } catch (ex) {
  3512. PDFViewerApplication._documentError("pdfjs-loading-error", {
  3513. message: ex.message
  3514. });
  3515. throw ex;
  3516. }
  3517. };
  3518. }
  3519. async function loadFakeWorker() {
  3520. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.GlobalWorkerOptions.workerSrc ||= _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("workerSrc");
  3521. await import( /*webpackIgnore: true*/pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PDFWorker.workerSrc);
  3522. }
  3523. async function loadPDFBug(self) {
  3524. const {
  3525. PDFBug
  3526. } = await import( /*webpackIgnore: true*/_app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("debuggerSrc"));
  3527. self._PDFBug = PDFBug;
  3528. }
  3529. function reportPageStatsPDFBug({
  3530. pageNumber
  3531. }) {
  3532. if (!globalThis.Stats?.enabled) {
  3533. return;
  3534. }
  3535. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3536. globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
  3537. }
  3538. function webViewerPageRender({
  3539. pageNumber
  3540. }) {
  3541. if (pageNumber === PDFViewerApplication.page) {
  3542. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true);
  3543. }
  3544. // console.log('test-loaded-page')
  3545. }
  3546. function webViewerPageRendered({
  3547. pageNumber,
  3548. error
  3549. }) {
  3550. if (pageNumber === PDFViewerApplication.page) {
  3551. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false);
  3552. }
  3553. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  3554. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3555. const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
  3556. if (pageView) {
  3557. thumbnailView?.setImage(pageView);
  3558. }
  3559. }
  3560. if (error) {
  3561. PDFViewerApplication._otherError("pdfjs-rendering-error", error);
  3562. }
  3563. }
  3564. function webViewerPageMode({
  3565. mode
  3566. }) {
  3567. let view;
  3568. switch (mode) {
  3569. case "thumbs":
  3570. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  3571. break;
  3572. case "bookmarks":
  3573. case "outline":
  3574. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE;
  3575. break;
  3576. case "attachments":
  3577. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS;
  3578. break;
  3579. case "layers":
  3580. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS;
  3581. break;
  3582. case "none":
  3583. view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE;
  3584. break;
  3585. default:
  3586. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3587. return;
  3588. }
  3589. PDFViewerApplication.pdfSidebar?.switchView(view, true);
  3590. }
  3591. function webViewerNamedAction(evt) {
  3592. switch (evt.action) {
  3593. case "GoToPage":
  3594. PDFViewerApplication.appConfig.toolbar?.pageNumber.select();
  3595. break;
  3596. case "Find":
  3597. if (!PDFViewerApplication.supportsIntegratedFind) {
  3598. PDFViewerApplication.findBar?.toggle();
  3599. }
  3600. break;
  3601. case "Print":
  3602. PDFViewerApplication.triggerPrinting();
  3603. break;
  3604. case "SaveAs":
  3605. PDFViewerApplication.downloadOrSave();
  3606. break;
  3607. }
  3608. }
  3609. function webViewerPresentationModeChanged(evt) {
  3610. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3611. }
  3612. function webViewerSidebarViewChanged({
  3613. view
  3614. }) {
  3615. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  3616. if (PDFViewerApplication.isInitialViewSet) {
  3617. PDFViewerApplication.store?.set("sidebarView", view).catch(() => {});
  3618. }
  3619. }
  3620. function webViewerUpdateViewarea({
  3621. location
  3622. }) {
  3623. if (PDFViewerApplication.isInitialViewSet) {
  3624. PDFViewerApplication.store?.setMultiple({
  3625. page: location.pageNumber,
  3626. zoom: location.scale,
  3627. scrollLeft: location.left,
  3628. scrollTop: location.top,
  3629. rotation: location.rotation
  3630. }).catch(() => {});
  3631. }
  3632. if (PDFViewerApplication.appConfig.secondaryToolbar) {
  3633. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3634. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3635. }
  3636. }
  3637. function webViewerScrollModeChanged(evt) {
  3638. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3639. PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {});
  3640. }
  3641. }
  3642. function webViewerSpreadModeChanged(evt) {
  3643. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3644. PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
  3645. }
  3646. }
  3647. function webViewerResize() {
  3648. const {
  3649. pdfDocument,
  3650. pdfViewer,
  3651. pdfRenderingQueue
  3652. } = PDFViewerApplication;
  3653. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  3654. return;
  3655. }
  3656. if (!pdfDocument) {
  3657. return;
  3658. }
  3659. const currentScaleValue = pdfViewer.currentScaleValue;
  3660. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  3661. pdfViewer.currentScaleValue = currentScaleValue;
  3662. }
  3663. pdfViewer.update();
  3664. }
  3665. function webViewerHashchange(evt) {
  3666. const hash = evt.hash;
  3667. if (!hash) {
  3668. return;
  3669. }
  3670. if (!PDFViewerApplication.isInitialViewSet) {
  3671. PDFViewerApplication.initialBookmark = hash;
  3672. } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
  3673. PDFViewerApplication.pdfLinkService.setHash(hash);
  3674. }
  3675. }
  3676. {
  3677. var webViewerFileInputChange = function (evt) {
  3678. if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
  3679. return;
  3680. }
  3681. const file = evt.fileInput.files[0];
  3682. PDFViewerApplication.open({
  3683. url: URL.createObjectURL(file),
  3684. originalUrl: file.name
  3685. });
  3686. };
  3687. var webViewerOpenFile = function (evt) {
  3688. PDFViewerApplication._openFileInput?.click();
  3689. };
  3690. }
  3691. function webViewerPresentationMode() {
  3692. PDFViewerApplication.requestPresentationMode();
  3693. }
  3694. function webViewerSwitchAnnotationEditorMode(evt) {
  3695. PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
  3696. }
  3697. function webViewerSwitchAnnotationEditorParams(evt) {
  3698. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  3699. }
  3700. function webViewerPrint() {
  3701. PDFViewerApplication.triggerPrinting();
  3702. }
  3703. function webViewerDownload() {
  3704. PDFViewerApplication.downloadOrSave();
  3705. }
  3706. function webViewerFirstPage() {
  3707. PDFViewerApplication.page = 1;
  3708. }
  3709. function webViewerLastPage() {
  3710. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3711. }
  3712. function webViewerNextPage() {
  3713. PDFViewerApplication.pdfViewer.nextPage();
  3714. }
  3715. function webViewerPreviousPage() {
  3716. PDFViewerApplication.pdfViewer.previousPage();
  3717. }
  3718. function webViewerZoomIn() {
  3719. PDFViewerApplication.zoomIn();
  3720. }
  3721. function webViewerZoomOut() {
  3722. PDFViewerApplication.zoomOut();
  3723. }
  3724. function webViewerZoomReset() {
  3725. PDFViewerApplication.zoomReset();
  3726. }
  3727. function webViewerPageNumberChanged(evt) {
  3728. const pdfViewer = PDFViewerApplication.pdfViewer;
  3729. if (evt.value !== "") {
  3730. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3731. }
  3732. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3733. PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3734. }
  3735. }
  3736. function webViewerScaleChanged(evt) {
  3737. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3738. }
  3739. function webViewerRotateCw() {
  3740. PDFViewerApplication.rotatePages(90);
  3741. }
  3742. function webViewerRotateCcw() {
  3743. PDFViewerApplication.rotatePages(-90);
  3744. }
  3745. function webViewerOptionalContentConfig(evt) {
  3746. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3747. }
  3748. function webViewerSwitchScrollMode(evt) {
  3749. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3750. }
  3751. function webViewerSwitchSpreadMode(evt) {
  3752. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3753. }
  3754. function webViewerDocumentProperties() {
  3755. PDFViewerApplication.pdfDocumentProperties?.open();
  3756. }
  3757. function webViewerFindFromUrlHash(evt) {
  3758. PDFViewerApplication.eventBus.dispatch("find", {
  3759. source: evt.source,
  3760. type: "",
  3761. query: evt.query,
  3762. caseSensitive: false,
  3763. entireWord: false,
  3764. highlightAll: true,
  3765. findPrevious: false,
  3766. matchDiacritics: true
  3767. });
  3768. }
  3769. function webViewerUpdateFindMatchesCount({
  3770. matchesCount
  3771. }) {
  3772. if (PDFViewerApplication.supportsIntegratedFind) {
  3773. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3774. } else {
  3775. PDFViewerApplication.findBar?.updateResultsCount(matchesCount);
  3776. }
  3777. }
  3778. function webViewerUpdateFindControlState({
  3779. state,
  3780. previous,
  3781. matchesCount,
  3782. rawQuery
  3783. }) {
  3784. if (PDFViewerApplication.supportsIntegratedFind) {
  3785. PDFViewerApplication.externalServices.updateFindControlState({
  3786. result: state,
  3787. findPrevious: previous,
  3788. matchesCount,
  3789. rawQuery
  3790. });
  3791. } else {
  3792. PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount);
  3793. }
  3794. }
  3795. function webViewerScaleChanging(evt) {
  3796. PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale);
  3797. PDFViewerApplication.pdfViewer.update();
  3798. }
  3799. function webViewerRotationChanging(evt) {
  3800. if (PDFViewerApplication.pdfThumbnailViewer) {
  3801. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3802. }
  3803. PDFViewerApplication.forceRendering();
  3804. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3805. }
  3806. function webViewerPageChanging({
  3807. pageNumber,
  3808. pageLabel
  3809. }) {
  3810. PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel);
  3811. PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber);
  3812. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  3813. PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
  3814. }
  3815. const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3816. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING);
  3817. }
  3818. function webViewerResolutionChange(evt) {
  3819. PDFViewerApplication.pdfViewer.refresh();
  3820. }
  3821. function webViewerVisibilityChange(evt) {
  3822. if (document.visibilityState === "visible") {
  3823. setZoomDisabledTimeout();
  3824. }
  3825. }
  3826. let zoomDisabledTimeout = null;
  3827. function setZoomDisabledTimeout() {
  3828. if (zoomDisabledTimeout) {
  3829. clearTimeout(zoomDisabledTimeout);
  3830. }
  3831. zoomDisabledTimeout = setTimeout(function () {
  3832. zoomDisabledTimeout = null;
  3833. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3834. }
  3835. function webViewerWheel(evt) {
  3836. const {
  3837. pdfViewer,
  3838. supportsMouseWheelZoomCtrlKey,
  3839. supportsMouseWheelZoomMetaKey,
  3840. supportsPinchToZoom
  3841. } = PDFViewerApplication;
  3842. if (pdfViewer.isInPresentationMode) {
  3843. return;
  3844. }
  3845. const deltaMode = evt.deltaMode;
  3846. let scaleFactor = Math.exp(-evt.deltaY / 100);
  3847. const isBuiltInMac = false;
  3848. const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  3849. if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
  3850. evt.preventDefault();
  3851. if (PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
  3852. return;
  3853. }
  3854. const previousScale = pdfViewer.currentScale;
  3855. if (isPinchToZoom && supportsPinchToZoom) {
  3856. scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
  3857. if (scaleFactor < 1) {
  3858. PDFViewerApplication.zoomOut(null, scaleFactor);
  3859. } else if (scaleFactor > 1) {
  3860. PDFViewerApplication.zoomIn(null, scaleFactor);
  3861. } else {
  3862. return;
  3863. }
  3864. } else {
  3865. const delta = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeWheelEventDirection)(evt);
  3866. let ticks = 0;
  3867. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3868. if (Math.abs(delta) >= 1) {
  3869. ticks = Math.sign(delta);
  3870. } else {
  3871. ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
  3872. }
  3873. } else {
  3874. const PIXELS_PER_LINE_SCALE = 30;
  3875. ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  3876. }
  3877. if (ticks < 0) {
  3878. PDFViewerApplication.zoomOut(-ticks);
  3879. } else if (ticks > 0) {
  3880. PDFViewerApplication.zoomIn(ticks);
  3881. } else {
  3882. return;
  3883. }
  3884. }
  3885. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
  3886. }
  3887. }
  3888. function webViewerTouchStart(evt) {
  3889. if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  3890. return;
  3891. }
  3892. evt.preventDefault();
  3893. if (evt.touches.length !== 2 || PDFViewerApplication.overlayManager.active) {
  3894. PDFViewerApplication._touchInfo = null;
  3895. return;
  3896. }
  3897. let [touch0, touch1] = evt.touches;
  3898. if (touch0.identifier > touch1.identifier) {
  3899. [touch0, touch1] = [touch1, touch0];
  3900. }
  3901. PDFViewerApplication._touchInfo = {
  3902. touch0X: touch0.pageX,
  3903. touch0Y: touch0.pageY,
  3904. touch1X: touch1.pageX,
  3905. touch1Y: touch1.pageY
  3906. };
  3907. }
  3908. function webViewerTouchMove(evt) {
  3909. if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
  3910. return;
  3911. }
  3912. const {
  3913. pdfViewer,
  3914. _touchInfo,
  3915. supportsPinchToZoom
  3916. } = PDFViewerApplication;
  3917. let [touch0, touch1] = evt.touches;
  3918. if (touch0.identifier > touch1.identifier) {
  3919. [touch0, touch1] = [touch1, touch0];
  3920. }
  3921. const {
  3922. pageX: page0X,
  3923. pageY: page0Y
  3924. } = touch0;
  3925. const {
  3926. pageX: page1X,
  3927. pageY: page1Y
  3928. } = touch1;
  3929. const {
  3930. touch0X: pTouch0X,
  3931. touch0Y: pTouch0Y,
  3932. touch1X: pTouch1X,
  3933. touch1Y: pTouch1Y
  3934. } = _touchInfo;
  3935. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  3936. return;
  3937. }
  3938. _touchInfo.touch0X = page0X;
  3939. _touchInfo.touch0Y = page0Y;
  3940. _touchInfo.touch1X = page1X;
  3941. _touchInfo.touch1Y = page1Y;
  3942. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  3943. const v1X = pTouch1X - page0X;
  3944. const v1Y = pTouch1Y - page0Y;
  3945. const v2X = page1X - page0X;
  3946. const v2Y = page1Y - page0Y;
  3947. const det = v1X * v2Y - v1Y * v2X;
  3948. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3949. return;
  3950. }
  3951. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  3952. const v1X = pTouch0X - page1X;
  3953. const v1Y = pTouch0Y - page1Y;
  3954. const v2X = page0X - page1X;
  3955. const v2Y = page0Y - page1Y;
  3956. const det = v1X * v2Y - v1Y * v2X;
  3957. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3958. return;
  3959. }
  3960. } else {
  3961. const diff0X = page0X - pTouch0X;
  3962. const diff1X = page1X - pTouch1X;
  3963. const diff0Y = page0Y - pTouch0Y;
  3964. const diff1Y = page1Y - pTouch1Y;
  3965. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  3966. if (dotProduct >= 0) {
  3967. return;
  3968. }
  3969. }
  3970. evt.preventDefault();
  3971. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  3972. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  3973. const previousScale = pdfViewer.currentScale;
  3974. if (supportsPinchToZoom) {
  3975. const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
  3976. if (newScaleFactor < 1) {
  3977. PDFViewerApplication.zoomOut(null, newScaleFactor);
  3978. } else if (newScaleFactor > 1) {
  3979. PDFViewerApplication.zoomIn(null, newScaleFactor);
  3980. } else {
  3981. return;
  3982. }
  3983. } else {
  3984. const PIXELS_PER_LINE_SCALE = 30;
  3985. const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  3986. if (ticks < 0) {
  3987. PDFViewerApplication.zoomOut(-ticks);
  3988. } else if (ticks > 0) {
  3989. PDFViewerApplication.zoomIn(ticks);
  3990. } else {
  3991. return;
  3992. }
  3993. }
  3994. PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
  3995. }
  3996. function webViewerTouchEnd(evt) {
  3997. if (!PDFViewerApplication._touchInfo) {
  3998. return;
  3999. }
  4000. evt.preventDefault();
  4001. PDFViewerApplication._touchInfo = null;
  4002. PDFViewerApplication._touchUnusedTicks = 0;
  4003. PDFViewerApplication._touchUnusedFactor = 1;
  4004. }
  4005. function webViewerClick(evt) {
  4006. if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
  4007. return;
  4008. }
  4009. const appConfig = PDFViewerApplication.appConfig;
  4010. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
  4011. PDFViewerApplication.secondaryToolbar.close();
  4012. }
  4013. }
  4014. function webViewerKeyUp(evt) {
  4015. if (evt.key === "Control") {
  4016. PDFViewerApplication._isCtrlKeyDown = false;
  4017. }
  4018. }
  4019. function webViewerKeyDown(evt) {
  4020. PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
  4021. if (PDFViewerApplication.overlayManager.active) {
  4022. return;
  4023. }
  4024. const {
  4025. eventBus,
  4026. pdfViewer
  4027. } = PDFViewerApplication;
  4028. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  4029. let handled = false,
  4030. ensureViewerFocused = false;
  4031. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  4032. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  4033. switch (evt.keyCode) {
  4034. case 70:
  4035. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  4036. PDFViewerApplication.findBar?.open();
  4037. handled = true;
  4038. }
  4039. break;
  4040. case 71:
  4041. if (!PDFViewerApplication.supportsIntegratedFind) {
  4042. const {
  4043. state
  4044. } = PDFViewerApplication.findController;
  4045. if (state) {
  4046. const newState = {
  4047. source: window,
  4048. type: "again",
  4049. findPrevious: cmd === 5 || cmd === 12
  4050. };
  4051. eventBus.dispatch("find", {
  4052. ...state,
  4053. ...newState
  4054. });
  4055. }
  4056. handled = true;
  4057. }
  4058. break;
  4059. case 61:
  4060. case 107:
  4061. case 187:
  4062. case 171:
  4063. PDFViewerApplication.zoomIn();
  4064. handled = true;
  4065. break;
  4066. case 173:
  4067. case 109:
  4068. case 189:
  4069. PDFViewerApplication.zoomOut();
  4070. handled = true;
  4071. break;
  4072. case 48:
  4073. case 96:
  4074. if (!isViewerInPresentationMode) {
  4075. setTimeout(function () {
  4076. PDFViewerApplication.zoomReset();
  4077. });
  4078. handled = false;
  4079. }
  4080. break;
  4081. case 38:
  4082. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  4083. PDFViewerApplication.page = 1;
  4084. handled = true;
  4085. ensureViewerFocused = true;
  4086. }
  4087. break;
  4088. case 40:
  4089. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  4090. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  4091. handled = true;
  4092. ensureViewerFocused = true;
  4093. }
  4094. break;
  4095. }
  4096. }
  4097. if (cmd === 1 || cmd === 8) {
  4098. switch (evt.keyCode) {
  4099. case 83:
  4100. eventBus.dispatch("download", {
  4101. source: window
  4102. });
  4103. handled = true;
  4104. break;
  4105. case 79:
  4106. {
  4107. eventBus.dispatch("openfile", {
  4108. source: window
  4109. });
  4110. handled = true;
  4111. }
  4112. break;
  4113. }
  4114. }
  4115. if (cmd === 3 || cmd === 10) {
  4116. switch (evt.keyCode) {
  4117. case 80:
  4118. PDFViewerApplication.requestPresentationMode();
  4119. handled = true;
  4120. PDFViewerApplication.externalServices.reportTelemetry({
  4121. type: "buttons",
  4122. data: {
  4123. id: "presentationModeKeyboard"
  4124. }
  4125. });
  4126. break;
  4127. case 71:
  4128. if (PDFViewerApplication.appConfig.toolbar) {
  4129. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  4130. handled = true;
  4131. }
  4132. break;
  4133. }
  4134. }
  4135. if (handled) {
  4136. if (ensureViewerFocused && !isViewerInPresentationMode) {
  4137. pdfViewer.focus();
  4138. }
  4139. evt.preventDefault();
  4140. return;
  4141. }
  4142. const curElement = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getActiveOrFocusedElement)();
  4143. const curElementTagName = curElement?.tagName.toUpperCase();
  4144. // [custom-input]
  4145. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElementTagName === "BUTTON" && (evt.keyCode === 13 || evt.keyCode === 32) || curElement?.isContentEditable) {
  4146. if (evt.keyCode !== 27) {
  4147. return;
  4148. }
  4149. }
  4150. if (cmd === 0) {
  4151. let turnPage = 0,
  4152. turnOnlyIfPageFit = false;
  4153. switch (evt.keyCode) {
  4154. case 38:
  4155. if (PDFViewerApplication.supportsCaretBrowsingMode) {
  4156. PDFViewerApplication.moveCaret(true, false);
  4157. handled = true;
  4158. break;
  4159. }
  4160. case 33:
  4161. if (pdfViewer.isVerticalScrollbarEnabled) {
  4162. turnOnlyIfPageFit = true;
  4163. }
  4164. turnPage = -1;
  4165. break;
  4166. case 8:
  4167. if (!isViewerInPresentationMode) {
  4168. turnOnlyIfPageFit = true;
  4169. }
  4170. turnPage = -1;
  4171. break;
  4172. case 37:
  4173. if (PDFViewerApplication.supportsCaretBrowsingMode) {
  4174. return;
  4175. }
  4176. if (pdfViewer.isHorizontalScrollbarEnabled) {
  4177. turnOnlyIfPageFit = true;
  4178. }
  4179. case 75:
  4180. case 80:
  4181. turnPage = -1;
  4182. break;
  4183. case 27:
  4184. if (PDFViewerApplication.secondaryToolbar?.isOpen) {
  4185. PDFViewerApplication.secondaryToolbar.close();
  4186. handled = true;
  4187. }
  4188. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) {
  4189. PDFViewerApplication.findBar.close();
  4190. handled = true;
  4191. }
  4192. break;
  4193. case 40:
  4194. if (PDFViewerApplication.supportsCaretBrowsingMode) {
  4195. PDFViewerApplication.moveCaret(false, false);
  4196. handled = true;
  4197. break;
  4198. }
  4199. case 34:
  4200. if (pdfViewer.isVerticalScrollbarEnabled) {
  4201. turnOnlyIfPageFit = true;
  4202. }
  4203. turnPage = 1;
  4204. break;
  4205. case 13:
  4206. case 32:
  4207. if (!isViewerInPresentationMode) {
  4208. turnOnlyIfPageFit = true;
  4209. }
  4210. turnPage = 1;
  4211. break;
  4212. case 39:
  4213. if (PDFViewerApplication.supportsCaretBrowsingMode) {
  4214. return;
  4215. }
  4216. if (pdfViewer.isHorizontalScrollbarEnabled) {
  4217. turnOnlyIfPageFit = true;
  4218. }
  4219. case 74:
  4220. case 78:
  4221. turnPage = 1;
  4222. break;
  4223. case 36:
  4224. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  4225. PDFViewerApplication.page = 1;
  4226. handled = true;
  4227. ensureViewerFocused = true;
  4228. }
  4229. break;
  4230. case 35:
  4231. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  4232. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  4233. handled = true;
  4234. ensureViewerFocused = true;
  4235. }
  4236. break;
  4237. case 83:
  4238. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT);
  4239. break;
  4240. case 72:
  4241. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND);
  4242. break;
  4243. case 82:
  4244. PDFViewerApplication.rotatePages(90);
  4245. break;
  4246. case 115:
  4247. PDFViewerApplication.pdfSidebar?.toggle();
  4248. break;
  4249. }
  4250. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  4251. if (turnPage > 0) {
  4252. pdfViewer.nextPage();
  4253. } else {
  4254. pdfViewer.previousPage();
  4255. }
  4256. handled = true;
  4257. }
  4258. }
  4259. if (cmd === 4) {
  4260. switch (evt.keyCode) {
  4261. case 13:
  4262. case 32:
  4263. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  4264. break;
  4265. }
  4266. pdfViewer.previousPage();
  4267. handled = true;
  4268. break;
  4269. case 38:
  4270. PDFViewerApplication.moveCaret(true, true);
  4271. handled = true;
  4272. break;
  4273. case 40:
  4274. PDFViewerApplication.moveCaret(false, true);
  4275. handled = true;
  4276. break;
  4277. case 82:
  4278. PDFViewerApplication.rotatePages(-90);
  4279. break;
  4280. }
  4281. }
  4282. if (!handled && !isViewerInPresentationMode) {
  4283. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  4284. ensureViewerFocused = true;
  4285. }
  4286. }
  4287. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  4288. pdfViewer.focus();
  4289. }
  4290. if (handled) {
  4291. evt.preventDefault();
  4292. }
  4293. }
  4294. function beforeUnload(evt) {
  4295. evt.preventDefault();
  4296. evt.returnValue = "";
  4297. return false;
  4298. }
  4299. function webViewerAnnotationEditorStatesChanged(data) {
  4300. PDFViewerApplication.externalServices.updateEditorStates(data);
  4301. }
  4302. function webViewerReportTelemetry({
  4303. details
  4304. }) {
  4305. PDFViewerApplication.externalServices.reportTelemetry(details);
  4306. }
  4307. __webpack_async_result__();
  4308. } catch(e) { __webpack_async_result__(e); } });
  4309. /***/ }),
  4310. /***/ 9840:
  4311. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  4312. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4313. /* harmony export */ AppOptions: () => (/* binding */ AppOptions),
  4314. /* harmony export */ OptionKind: () => (/* binding */ OptionKind)
  4315. /* harmony export */ });
  4316. {
  4317. var compatibilityParams = Object.create(null);
  4318. const userAgent = navigator.userAgent || "";
  4319. const platform = navigator.platform || "";
  4320. const maxTouchPoints = navigator.maxTouchPoints || 1;
  4321. const isAndroid = /Android/.test(userAgent);
  4322. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4323. (function checkCanvasSizeLimitation() {
  4324. if (isIOS || isAndroid) {
  4325. compatibilityParams.maxCanvasPixels = 5242880;
  4326. }
  4327. })();
  4328. }
  4329. const OptionKind = {
  4330. BROWSER: 0x01,
  4331. VIEWER: 0x02,
  4332. API: 0x04,
  4333. WORKER: 0x08,
  4334. PREFERENCE: 0x80
  4335. };
  4336. const defaultOptions = {
  4337. canvasMaxAreaInBytes: {
  4338. value: -1,
  4339. kind: OptionKind.BROWSER + OptionKind.API
  4340. },
  4341. isInAutomation: {
  4342. value: false,
  4343. kind: OptionKind.BROWSER
  4344. },
  4345. supportsCaretBrowsingMode: {
  4346. value: false,
  4347. kind: OptionKind.BROWSER
  4348. },
  4349. supportsDocumentFonts: {
  4350. value: true,
  4351. kind: OptionKind.BROWSER
  4352. },
  4353. supportsIntegratedFind: {
  4354. value: false,
  4355. kind: OptionKind.BROWSER
  4356. },
  4357. supportsMouseWheelZoomCtrlKey: {
  4358. value: true,
  4359. kind: OptionKind.BROWSER
  4360. },
  4361. supportsMouseWheelZoomMetaKey: {
  4362. value: true,
  4363. kind: OptionKind.BROWSER
  4364. },
  4365. supportsPinchToZoom: {
  4366. value: true,
  4367. kind: OptionKind.BROWSER
  4368. },
  4369. annotationEditorMode: {
  4370. value: 0,
  4371. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4372. },
  4373. annotationMode: {
  4374. value: 2,
  4375. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4376. },
  4377. cursorToolOnLoad: {
  4378. value: 0,
  4379. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4380. },
  4381. debuggerSrc: {
  4382. value: "./debugger.mjs",
  4383. kind: OptionKind.VIEWER
  4384. },
  4385. defaultZoomDelay: {
  4386. value: 400,
  4387. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4388. },
  4389. defaultZoomValue: {
  4390. value: "",
  4391. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4392. },
  4393. disableHistory: {
  4394. value: false,
  4395. kind: OptionKind.VIEWER
  4396. },
  4397. disablePageLabels: {
  4398. value: false,
  4399. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4400. },
  4401. enableHighlightEditor: {
  4402. value: false,
  4403. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4404. },
  4405. enableHighlightFloatingButton: {
  4406. value: false,
  4407. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4408. },
  4409. enableML: {
  4410. value: false,
  4411. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4412. },
  4413. enablePermissions: {
  4414. value: false,
  4415. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4416. },
  4417. enablePrintAutoRotate: {
  4418. value: true,
  4419. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4420. },
  4421. enableScripting: {
  4422. value: true,
  4423. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4424. },
  4425. enableStampEditor: {
  4426. value: true,
  4427. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4428. },
  4429. externalLinkRel: {
  4430. value: "noopener noreferrer nofollow",
  4431. kind: OptionKind.VIEWER
  4432. },
  4433. externalLinkTarget: {
  4434. value: 0,
  4435. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4436. },
  4437. highlightEditorColors: {
  4438. value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
  4439. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4440. },
  4441. historyUpdateUrl: {
  4442. value: false,
  4443. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4444. },
  4445. ignoreDestinationZoom: {
  4446. value: false,
  4447. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4448. },
  4449. imageResourcesPath: {
  4450. value: "./images/",
  4451. kind: OptionKind.VIEWER
  4452. },
  4453. maxCanvasPixels: {
  4454. value: 2 ** 25,
  4455. kind: OptionKind.VIEWER
  4456. },
  4457. forcePageColors: {
  4458. value: false,
  4459. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4460. },
  4461. pageColorsBackground: {
  4462. value: "Canvas",
  4463. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4464. },
  4465. pageColorsForeground: {
  4466. value: "CanvasText",
  4467. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4468. },
  4469. pdfBugEnabled: {
  4470. value: false,
  4471. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4472. },
  4473. printResolution: {
  4474. value: 150,
  4475. kind: OptionKind.VIEWER
  4476. },
  4477. sidebarViewOnLoad: {
  4478. value: -1,
  4479. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4480. },
  4481. scrollModeOnLoad: {
  4482. value: -1,
  4483. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4484. },
  4485. spreadModeOnLoad: {
  4486. value: -1,
  4487. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4488. },
  4489. textLayerMode: {
  4490. value: 1,
  4491. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4492. },
  4493. viewOnLoad: {
  4494. value: 0,
  4495. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4496. },
  4497. cMapPacked: {
  4498. value: true,
  4499. kind: OptionKind.API
  4500. },
  4501. cMapUrl: {
  4502. value: "../web/cmaps/",
  4503. kind: OptionKind.API
  4504. },
  4505. disableAutoFetch: {
  4506. value: false,
  4507. kind: OptionKind.API + OptionKind.PREFERENCE
  4508. },
  4509. disableFontFace: {
  4510. value: false,
  4511. kind: OptionKind.API + OptionKind.PREFERENCE
  4512. },
  4513. disableRange: {
  4514. value: false,
  4515. kind: OptionKind.API + OptionKind.PREFERENCE
  4516. },
  4517. disableStream: {
  4518. value: false,
  4519. kind: OptionKind.API + OptionKind.PREFERENCE
  4520. },
  4521. docBaseUrl: {
  4522. value: "",
  4523. kind: OptionKind.API
  4524. },
  4525. enableXfa: {
  4526. value: true,
  4527. kind: OptionKind.API + OptionKind.PREFERENCE
  4528. },
  4529. fontExtraProperties: {
  4530. value: false,
  4531. kind: OptionKind.API
  4532. },
  4533. isEvalSupported: {
  4534. value: true,
  4535. kind: OptionKind.API
  4536. },
  4537. isOffscreenCanvasSupported: {
  4538. value: true,
  4539. kind: OptionKind.API
  4540. },
  4541. maxImageSize: {
  4542. value: -1,
  4543. kind: OptionKind.API
  4544. },
  4545. pdfBug: {
  4546. value: false,
  4547. kind: OptionKind.API
  4548. },
  4549. standardFontDataUrl: {
  4550. value: "../web/standard_fonts/",
  4551. kind: OptionKind.API
  4552. },
  4553. verbosity: {
  4554. value: 1,
  4555. kind: OptionKind.API
  4556. },
  4557. workerPort: {
  4558. value: null,
  4559. kind: OptionKind.WORKER
  4560. },
  4561. workerSrc: {
  4562. value: "../build/pdf.worker.mjs",
  4563. kind: OptionKind.WORKER
  4564. }
  4565. };
  4566. {
  4567. defaultOptions.defaultUrl = {
  4568. value: "",
  4569. kind: OptionKind.VIEWER
  4570. };
  4571. defaultOptions.sandboxBundleSrc = {
  4572. value: "../build/pdf.sandbox.mjs",
  4573. kind: OptionKind.VIEWER
  4574. };
  4575. defaultOptions.viewerCssTheme = {
  4576. value: 0,
  4577. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4578. };
  4579. }
  4580. {
  4581. defaultOptions.disablePreferences = {
  4582. value: false,
  4583. kind: OptionKind.VIEWER
  4584. };
  4585. defaultOptions.locale = {
  4586. value: navigator.language || "en-US",
  4587. kind: OptionKind.VIEWER
  4588. };
  4589. }
  4590. const userOptions = Object.create(null);
  4591. {
  4592. for (const name in compatibilityParams) {
  4593. userOptions[name] = compatibilityParams[name];
  4594. }
  4595. }
  4596. class AppOptions {
  4597. constructor() {
  4598. throw new Error("Cannot initialize AppOptions.");
  4599. }
  4600. static get(name) {
  4601. return userOptions[name] ?? defaultOptions[name]?.value ?? undefined;
  4602. }
  4603. static getAll(kind = null, defaultOnly = false) {
  4604. const options = Object.create(null);
  4605. for (const name in defaultOptions) {
  4606. const defaultOption = defaultOptions[name];
  4607. if (kind && !(kind & defaultOption.kind)) {
  4608. continue;
  4609. }
  4610. options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value;
  4611. }
  4612. return options;
  4613. }
  4614. static set(name, value) {
  4615. userOptions[name] = value;
  4616. }
  4617. static setAll(options, init = false) {
  4618. if (init) {
  4619. if (this.get("disablePreferences")) {
  4620. return;
  4621. }
  4622. for (const name in userOptions) {
  4623. if (compatibilityParams[name] !== undefined) {
  4624. continue;
  4625. }
  4626. console.warn("setAll: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  4627. break;
  4628. }
  4629. }
  4630. for (const name in options) {
  4631. userOptions[name] = options[name];
  4632. }
  4633. }
  4634. static remove(name) {
  4635. delete userOptions[name];
  4636. const val = compatibilityParams[name];
  4637. if (val !== undefined) {
  4638. userOptions[name] = val;
  4639. }
  4640. }
  4641. }
  4642. /***/ }),
  4643. /***/ 2961:
  4644. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  4645. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4646. /* harmony export */ BaseTreeViewer: () => (/* binding */ BaseTreeViewer)
  4647. /* harmony export */ });
  4648. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  4649. const TREEITEM_OFFSET_TOP = -100;
  4650. const TREEITEM_SELECTED_CLASS = "selected";
  4651. class BaseTreeViewer {
  4652. constructor(options) {
  4653. if (this.constructor === BaseTreeViewer) {
  4654. throw new Error("Cannot initialize BaseTreeViewer.");
  4655. }
  4656. this.container = options.container;
  4657. this.eventBus = options.eventBus;
  4658. this._l10n = options.l10n;
  4659. this.reset();
  4660. }
  4661. reset() {
  4662. this._pdfDocument = null;
  4663. this._lastToggleIsShow = true;
  4664. this._currentTreeItem = null;
  4665. this.container.textContent = "";
  4666. this.container.classList.remove("treeWithDeepNesting");
  4667. }
  4668. _dispatchEvent(count) {
  4669. throw new Error("Not implemented: _dispatchEvent");
  4670. }
  4671. _bindLink(element, params) {
  4672. throw new Error("Not implemented: _bindLink");
  4673. }
  4674. _normalizeTextContent(str) {
  4675. return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(str, true) || "\u2013";
  4676. }
  4677. _addToggleButton(div, hidden = false) {
  4678. const toggler = document.createElement("div");
  4679. toggler.className = "treeItemToggler";
  4680. if (hidden) {
  4681. toggler.classList.add("treeItemsHidden");
  4682. }
  4683. toggler.onclick = evt => {
  4684. evt.stopPropagation();
  4685. toggler.classList.toggle("treeItemsHidden");
  4686. if (evt.shiftKey) {
  4687. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  4688. this._toggleTreeItem(div, shouldShowAll);
  4689. }
  4690. };
  4691. div.prepend(toggler);
  4692. }
  4693. _toggleTreeItem(root, show = false) {
  4694. this._l10n.pause();
  4695. this._lastToggleIsShow = show;
  4696. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  4697. toggler.classList.toggle("treeItemsHidden", !show);
  4698. }
  4699. this._l10n.resume();
  4700. }
  4701. _toggleAllTreeItems() {
  4702. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  4703. }
  4704. _finishRendering(fragment, count, hasAnyNesting = false) {
  4705. if (hasAnyNesting) {
  4706. this.container.classList.add("treeWithDeepNesting");
  4707. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  4708. }
  4709. this._l10n.pause();
  4710. this.container.append(fragment);
  4711. this._l10n.resume();
  4712. this._dispatchEvent(count);
  4713. }
  4714. render(params) {
  4715. throw new Error("Not implemented: render");
  4716. }
  4717. _updateCurrentTreeItem(treeItem = null) {
  4718. if (this._currentTreeItem) {
  4719. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  4720. this._currentTreeItem = null;
  4721. }
  4722. if (treeItem) {
  4723. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  4724. this._currentTreeItem = treeItem;
  4725. }
  4726. }
  4727. _scrollToCurrentTreeItem(treeItem) {
  4728. if (!treeItem) {
  4729. return;
  4730. }
  4731. this._l10n.pause();
  4732. let currentNode = treeItem.parentNode;
  4733. while (currentNode && currentNode !== this.container) {
  4734. if (currentNode.classList.contains("treeItem")) {
  4735. const toggler = currentNode.firstElementChild;
  4736. toggler?.classList.remove("treeItemsHidden");
  4737. }
  4738. currentNode = currentNode.parentNode;
  4739. }
  4740. this._l10n.resume();
  4741. this._updateCurrentTreeItem(treeItem);
  4742. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  4743. }
  4744. }
  4745. /***/ }),
  4746. /***/ 3973:
  4747. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  4748. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4749. /* harmony export */ CaretBrowsingMode: () => (/* binding */ CaretBrowsingMode)
  4750. /* harmony export */ });
  4751. const PRECISION = 1e-1;
  4752. class CaretBrowsingMode {
  4753. #mainContainer;
  4754. #toolBarHeight;
  4755. #viewerContainer;
  4756. constructor(mainContainer, viewerContainer, toolbarContainer) {
  4757. this.#mainContainer = mainContainer;
  4758. this.#viewerContainer = viewerContainer;
  4759. this.#toolBarHeight = toolbarContainer?.getBoundingClientRect().height ?? 0;
  4760. }
  4761. #isOnSameLine(rect1, rect2) {
  4762. const top1 = rect1.y;
  4763. const bot1 = rect1.bottom;
  4764. const mid1 = rect1.y + rect1.height / 2;
  4765. const top2 = rect2.y;
  4766. const bot2 = rect2.bottom;
  4767. const mid2 = rect2.y + rect2.height / 2;
  4768. return top1 <= mid2 && mid2 <= bot1 || top2 <= mid1 && mid1 <= bot2;
  4769. }
  4770. #isUnderOver(rect, x, y, isUp) {
  4771. const midY = rect.y + rect.height / 2;
  4772. return (isUp ? y >= midY : y <= midY) && rect.x - PRECISION <= x && x <= rect.right + PRECISION;
  4773. }
  4774. #isVisible(rect) {
  4775. return rect.top >= this.#toolBarHeight && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
  4776. }
  4777. #getCaretPosition(selection, isUp) {
  4778. const {
  4779. focusNode,
  4780. focusOffset
  4781. } = selection;
  4782. const range = document.createRange();
  4783. range.setStart(focusNode, focusOffset);
  4784. range.setEnd(focusNode, focusOffset);
  4785. const rect = range.getBoundingClientRect();
  4786. return [rect.x, isUp ? rect.top : rect.bottom];
  4787. }
  4788. static #caretPositionFromPoint(x, y) {
  4789. if (!document.caretPositionFromPoint) {
  4790. const {
  4791. startContainer: offsetNode,
  4792. startOffset: offset
  4793. } = document.caretRangeFromPoint(x, y);
  4794. return {
  4795. offsetNode,
  4796. offset
  4797. };
  4798. }
  4799. return document.caretPositionFromPoint(x, y);
  4800. }
  4801. #setCaretPositionHelper(selection, caretX, select, element, rect) {
  4802. rect ||= element.getBoundingClientRect();
  4803. if (caretX <= rect.x + PRECISION) {
  4804. if (select) {
  4805. selection.extend(element.firstChild, 0);
  4806. } else {
  4807. selection.setPosition(element.firstChild, 0);
  4808. }
  4809. return;
  4810. }
  4811. if (rect.right - PRECISION <= caretX) {
  4812. const {
  4813. lastChild
  4814. } = element;
  4815. if (select) {
  4816. selection.extend(lastChild, lastChild.length);
  4817. } else {
  4818. selection.setPosition(lastChild, lastChild.length);
  4819. }
  4820. return;
  4821. }
  4822. const midY = rect.y + rect.height / 2;
  4823. let caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
  4824. let parentElement = caretPosition.offsetNode?.parentElement;
  4825. if (parentElement && parentElement !== element) {
  4826. const elementsAtPoint = document.elementsFromPoint(caretX, midY);
  4827. const savedVisibilities = [];
  4828. for (const el of elementsAtPoint) {
  4829. if (el === element) {
  4830. break;
  4831. }
  4832. const {
  4833. style
  4834. } = el;
  4835. savedVisibilities.push([el, style.visibility]);
  4836. style.visibility = "hidden";
  4837. }
  4838. caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
  4839. parentElement = caretPosition.offsetNode?.parentElement;
  4840. for (const [el, visibility] of savedVisibilities) {
  4841. el.style.visibility = visibility;
  4842. }
  4843. }
  4844. if (parentElement !== element) {
  4845. if (select) {
  4846. selection.extend(element.firstChild, 0);
  4847. } else {
  4848. selection.setPosition(element.firstChild, 0);
  4849. }
  4850. return;
  4851. }
  4852. if (select) {
  4853. selection.extend(caretPosition.offsetNode, caretPosition.offset);
  4854. } else {
  4855. selection.setPosition(caretPosition.offsetNode, caretPosition.offset);
  4856. }
  4857. }
  4858. #setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX) {
  4859. if (this.#isVisible(newLineElementRect)) {
  4860. this.#setCaretPositionHelper(selection, caretX, select, newLineElement, newLineElementRect);
  4861. return;
  4862. }
  4863. this.#mainContainer.addEventListener("scrollend", this.#setCaretPositionHelper.bind(this, selection, caretX, select, newLineElement, null), {
  4864. once: true
  4865. });
  4866. newLineElement.scrollIntoView();
  4867. }
  4868. #getNodeOnNextPage(textLayer, isUp) {
  4869. while (true) {
  4870. const page = textLayer.closest(".page");
  4871. const pageNumber = parseInt(page.getAttribute("data-page-number"));
  4872. const nextPage = isUp ? pageNumber - 1 : pageNumber + 1;
  4873. textLayer = this.#viewerContainer.querySelector(`.page[data-page-number="${nextPage}"] .textLayer`);
  4874. if (!textLayer) {
  4875. return null;
  4876. }
  4877. const walker = document.createTreeWalker(textLayer, NodeFilter.SHOW_TEXT);
  4878. const node = isUp ? walker.lastChild() : walker.firstChild();
  4879. if (node) {
  4880. return node;
  4881. }
  4882. }
  4883. }
  4884. moveCaret(isUp, select) {
  4885. const selection = document.getSelection();
  4886. if (selection.rangeCount === 0) {
  4887. return;
  4888. }
  4889. const {
  4890. focusNode
  4891. } = selection;
  4892. const focusElement = focusNode.nodeType !== Node.ELEMENT_NODE ? focusNode.parentElement : focusNode;
  4893. const root = focusElement.closest(".textLayer");
  4894. if (!root) {
  4895. return;
  4896. }
  4897. const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
  4898. walker.currentNode = focusNode;
  4899. const focusRect = focusElement.getBoundingClientRect();
  4900. let newLineElement = null;
  4901. const nodeIterator = (isUp ? walker.previousSibling : walker.nextSibling).bind(walker);
  4902. while (nodeIterator()) {
  4903. const element = walker.currentNode.parentElement;
  4904. if (!this.#isOnSameLine(focusRect, element.getBoundingClientRect())) {
  4905. newLineElement = element;
  4906. break;
  4907. }
  4908. }
  4909. if (!newLineElement) {
  4910. const node = this.#getNodeOnNextPage(root, isUp);
  4911. if (!node) {
  4912. return;
  4913. }
  4914. if (select) {
  4915. const lastNode = (isUp ? walker.firstChild() : walker.lastChild()) || focusNode;
  4916. selection.extend(lastNode, isUp ? 0 : lastNode.length);
  4917. const range = document.createRange();
  4918. range.setStart(node, isUp ? node.length : 0);
  4919. range.setEnd(node, isUp ? node.length : 0);
  4920. selection.addRange(range);
  4921. return;
  4922. }
  4923. const [caretX] = this.#getCaretPosition(selection, isUp);
  4924. const {
  4925. parentElement
  4926. } = node;
  4927. this.#setCaretPosition(select, selection, parentElement, parentElement.getBoundingClientRect(), caretX);
  4928. return;
  4929. }
  4930. const [caretX, caretY] = this.#getCaretPosition(selection, isUp);
  4931. const newLineElementRect = newLineElement.getBoundingClientRect();
  4932. if (this.#isUnderOver(newLineElementRect, caretX, caretY, isUp)) {
  4933. this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX);
  4934. return;
  4935. }
  4936. while (nodeIterator()) {
  4937. const element = walker.currentNode.parentElement;
  4938. const elementRect = element.getBoundingClientRect();
  4939. if (!this.#isOnSameLine(newLineElementRect, elementRect)) {
  4940. break;
  4941. }
  4942. if (this.#isUnderOver(elementRect, caretX, caretY, isUp)) {
  4943. this.#setCaretPosition(select, selection, element, elementRect, caretX);
  4944. return;
  4945. }
  4946. }
  4947. this.#setCaretPosition(select, selection, newLineElement, newLineElementRect, caretX);
  4948. }
  4949. }
  4950. /***/ }),
  4951. /***/ 1544:
  4952. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  4953. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  4954. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4955. /* harmony export */ DownloadManager: () => (/* binding */ DownloadManager)
  4956. /* harmony export */ });
  4957. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  4958. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  4959. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  4960. function download(blobUrl, filename) {
  4961. const a = document.createElement("a");
  4962. if (!a.click) {
  4963. throw new Error('DownloadManager: "a.click()" is not supported.');
  4964. }
  4965. a.href = blobUrl;
  4966. a.target = "_parent";
  4967. if ("download" in a) {
  4968. a.download = filename;
  4969. }
  4970. (document.body || document.documentElement).append(a);
  4971. a.click();
  4972. a.remove();
  4973. }
  4974. class DownloadManager {
  4975. #openBlobUrls = new WeakMap();
  4976. downloadUrl(url, filename, _options) {
  4977. if (!(0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.createValidAbsoluteUrl)(url, "http://example.com")) {
  4978. console.error(`downloadUrl - not a valid URL: ${url}`);
  4979. return;
  4980. }
  4981. download(url + "#pdfjs.action=download", filename);
  4982. }
  4983. downloadData(data, filename, contentType) {
  4984. const blobUrl = URL.createObjectURL(new Blob([data], {
  4985. type: contentType
  4986. }));
  4987. download(blobUrl, filename);
  4988. }
  4989. openOrDownloadData(data, filename, dest = null) {
  4990. const isPdfData = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.isPdfFile)(filename);
  4991. const contentType = isPdfData ? "application/pdf" : "";
  4992. if (isPdfData) {
  4993. let blobUrl = this.#openBlobUrls.get(data);
  4994. if (!blobUrl) {
  4995. blobUrl = URL.createObjectURL(new Blob([data], {
  4996. type: contentType
  4997. }));
  4998. this.#openBlobUrls.set(data, blobUrl);
  4999. }
  5000. let viewerUrl;
  5001. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5002. if (dest) {
  5003. viewerUrl += `#${escape(dest)}`;
  5004. }
  5005. try {
  5006. window.open(viewerUrl);
  5007. return true;
  5008. } catch (ex) {
  5009. console.error(`openOrDownloadData: ${ex}`);
  5010. URL.revokeObjectURL(blobUrl);
  5011. this.#openBlobUrls.delete(data);
  5012. }
  5013. }
  5014. this.downloadData(data, filename, contentType);
  5015. return false;
  5016. }
  5017. download(blob, url, filename, _options) {
  5018. const blobUrl = URL.createObjectURL(blob);
  5019. download(blobUrl, filename);
  5020. }
  5021. }
  5022. __webpack_async_result__();
  5023. } catch(e) { __webpack_async_result__(e); } });
  5024. /***/ }),
  5025. /***/ 3088:
  5026. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5027. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5028. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5029. /* harmony export */ DrawLayerBuilder: () => (/* binding */ DrawLayerBuilder)
  5030. /* harmony export */ });
  5031. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  5032. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5033. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5034. class DrawLayerBuilder {
  5035. #drawLayer = null;
  5036. constructor(options) {
  5037. this.pageIndex = options.pageIndex;
  5038. }
  5039. async render(intent = "display") {
  5040. if (intent !== "display" || this.#drawLayer || this._cancelled) {
  5041. return;
  5042. }
  5043. this.#drawLayer = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.DrawLayer({
  5044. pageIndex: this.pageIndex
  5045. });
  5046. }
  5047. cancel() {
  5048. this._cancelled = true;
  5049. if (!this.#drawLayer) {
  5050. return;
  5051. }
  5052. this.#drawLayer.destroy();
  5053. this.#drawLayer = null;
  5054. }
  5055. setParent(parent) {
  5056. this.#drawLayer?.setParent(parent);
  5057. }
  5058. getDrawLayer() {
  5059. return this.#drawLayer;
  5060. }
  5061. }
  5062. __webpack_async_result__();
  5063. } catch(e) { __webpack_async_result__(e); } });
  5064. /***/ }),
  5065. /***/ 5656:
  5066. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5067. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5068. /* harmony export */ AutomationEventBus: () => (/* binding */ AutomationEventBus),
  5069. /* harmony export */ EventBus: () => (/* binding */ EventBus),
  5070. /* harmony export */ waitOnEventOrTimeout: () => (/* binding */ waitOnEventOrTimeout)
  5071. /* harmony export */ });
  5072. /* unused harmony export WaitOnType */
  5073. const WaitOnType = {
  5074. EVENT: "event",
  5075. TIMEOUT: "timeout"
  5076. };
  5077. async function waitOnEventOrTimeout({
  5078. target,
  5079. name,
  5080. delay = 0
  5081. }) {
  5082. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  5083. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  5084. }
  5085. const {
  5086. promise,
  5087. resolve
  5088. } = Promise.withResolvers();
  5089. const ac = new AbortController();
  5090. function handler(type) {
  5091. ac.abort();
  5092. clearTimeout(timeout);
  5093. resolve(type);
  5094. }
  5095. const evtMethod = target instanceof EventBus ? "_on" : "addEventListener";
  5096. target[evtMethod](name, handler.bind(null, WaitOnType.EVENT), {
  5097. signal: ac.signal
  5098. });
  5099. const timeout = setTimeout(handler.bind(null, WaitOnType.TIMEOUT), delay);
  5100. return promise;
  5101. }
  5102. class EventBus {
  5103. #listeners = Object.create(null);
  5104. on(eventName, listener, options = null) {
  5105. this._on(eventName, listener, {
  5106. external: true,
  5107. once: options?.once,
  5108. signal: options?.signal
  5109. });
  5110. }
  5111. off(eventName, listener, options = null) {
  5112. this._off(eventName, listener);
  5113. }
  5114. dispatch(eventName, data) {
  5115. const eventListeners = this.#listeners[eventName];
  5116. if (!eventListeners || eventListeners.length === 0) {
  5117. return;
  5118. }
  5119. let externalListeners;
  5120. for (const {
  5121. listener,
  5122. external,
  5123. once
  5124. } of eventListeners.slice(0)) {
  5125. if (once) {
  5126. this._off(eventName, listener);
  5127. }
  5128. if (external) {
  5129. (externalListeners ||= []).push(listener);
  5130. continue;
  5131. }
  5132. listener(data);
  5133. }
  5134. if (externalListeners) {
  5135. for (const listener of externalListeners) {
  5136. listener(data);
  5137. }
  5138. externalListeners = null;
  5139. }
  5140. }
  5141. _on(eventName, listener, options = null) {
  5142. let rmAbort = null;
  5143. if (options?.signal instanceof AbortSignal) {
  5144. const {
  5145. signal
  5146. } = options;
  5147. if (signal.aborted) {
  5148. console.error("Cannot use an `aborted` signal.");
  5149. return;
  5150. }
  5151. const onAbort = () => this._off(eventName, listener);
  5152. rmAbort = () => signal.removeEventListener("abort", onAbort);
  5153. signal.addEventListener("abort", onAbort);
  5154. }
  5155. const eventListeners = this.#listeners[eventName] ||= [];
  5156. eventListeners.push({
  5157. listener,
  5158. external: options?.external === true,
  5159. once: options?.once === true,
  5160. rmAbort
  5161. });
  5162. }
  5163. _off(eventName, listener, options = null) {
  5164. const eventListeners = this.#listeners[eventName];
  5165. if (!eventListeners) {
  5166. return;
  5167. }
  5168. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  5169. const evt = eventListeners[i];
  5170. if (evt.listener === listener) {
  5171. evt.rmAbort?.();
  5172. eventListeners.splice(i, 1);
  5173. return;
  5174. }
  5175. }
  5176. }
  5177. }
  5178. class AutomationEventBus extends EventBus {
  5179. dispatch(eventName, data) {
  5180. throw new Error("Not implemented: AutomationEventBus.dispatch");
  5181. }
  5182. }
  5183. /***/ }),
  5184. /***/ 4290:
  5185. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5186. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5187. /* harmony export */ BaseExternalServices: () => (/* binding */ BaseExternalServices)
  5188. /* harmony export */ });
  5189. class BaseExternalServices {
  5190. constructor() {
  5191. if (this.constructor === BaseExternalServices) {
  5192. throw new Error("Cannot initialize BaseExternalServices.");
  5193. }
  5194. }
  5195. updateFindControlState(data) {}
  5196. updateFindMatchesCount(data) {}
  5197. initPassiveLoading() {}
  5198. reportTelemetry(data) {}
  5199. async createL10n() {
  5200. throw new Error("Not implemented: createL10n");
  5201. }
  5202. createScripting() {
  5203. throw new Error("Not implemented: createScripting");
  5204. }
  5205. updateEditorStates(data) {
  5206. throw new Error("Not implemented: updateEditorStates");
  5207. }
  5208. async getNimbusExperimentData() {}
  5209. }
  5210. /***/ }),
  5211. /***/ 289:
  5212. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5213. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5214. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5215. /* harmony export */ GenericScripting: () => (/* binding */ GenericScripting)
  5216. /* harmony export */ });
  5217. /* unused harmony export docProperties */
  5218. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  5219. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5220. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5221. async function docProperties(pdfDocument) {
  5222. const url = "",
  5223. baseUrl = url.split("#", 1)[0];
  5224. let {
  5225. info,
  5226. metadata,
  5227. contentDispositionFilename,
  5228. contentLength
  5229. } = await pdfDocument.getMetadata();
  5230. if (!contentLength) {
  5231. const {
  5232. length
  5233. } = await pdfDocument.getDownloadInfo();
  5234. contentLength = length;
  5235. }
  5236. return {
  5237. ...info,
  5238. baseURL: baseUrl,
  5239. filesize: contentLength,
  5240. filename: contentDispositionFilename || getPdfFilenameFromUrl(url),
  5241. metadata: metadata?.getRaw(),
  5242. authors: metadata?.get("dc:creator"),
  5243. numPages: pdfDocument.numPages,
  5244. URL: url
  5245. };
  5246. }
  5247. class GenericScripting {
  5248. constructor(sandboxBundleSrc) {
  5249. this._ready = new Promise((resolve, reject) => {
  5250. const sandbox = import( /*webpackIgnore: true*/sandboxBundleSrc);
  5251. sandbox.then(pdfjsSandbox => {
  5252. resolve(pdfjsSandbox.QuickJSSandbox());
  5253. }).catch(reject);
  5254. });
  5255. }
  5256. async createSandbox(data) {
  5257. const sandbox = await this._ready;
  5258. sandbox.create(data);
  5259. }
  5260. async dispatchEventInSandbox(event) {
  5261. const sandbox = await this._ready;
  5262. setTimeout(() => sandbox.dispatchEvent(event), 0);
  5263. }
  5264. async destroySandbox() {
  5265. const sandbox = await this._ready;
  5266. sandbox.nukeSandbox();
  5267. }
  5268. }
  5269. __webpack_async_result__();
  5270. } catch(e) { __webpack_async_result__(e); } });
  5271. /***/ }),
  5272. /***/ 6750:
  5273. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5274. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5275. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5276. /* harmony export */ ExternalServices: () => (/* binding */ ExternalServices),
  5277. /* harmony export */ MLManager: () => (/* binding */ MLManager),
  5278. /* harmony export */ Preferences: () => (/* binding */ Preferences),
  5279. /* harmony export */ initCom: () => (/* binding */ initCom)
  5280. /* harmony export */ });
  5281. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9840);
  5282. /* harmony import */ var _external_services_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4290);
  5283. /* harmony import */ var _preferences_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8224);
  5284. /* harmony import */ var _genericl10n_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(410);
  5285. /* harmony import */ var _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(289);
  5286. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_genericl10n_js__WEBPACK_IMPORTED_MODULE_2__, _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__]);
  5287. ([_genericl10n_js__WEBPACK_IMPORTED_MODULE_2__, _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  5288. function initCom(app) {}
  5289. class Preferences extends _preferences_js__WEBPACK_IMPORTED_MODULE_1__.BasePreferences {
  5290. async _writeToStorage(prefObj) {
  5291. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  5292. }
  5293. async _readFromStorage(prefObj) {
  5294. return {
  5295. prefs: JSON.parse(localStorage.getItem("pdfjs.preferences"))
  5296. };
  5297. }
  5298. }
  5299. class ExternalServices extends _external_services_js__WEBPACK_IMPORTED_MODULE_4__.BaseExternalServices {
  5300. async createL10n() {
  5301. return new _genericl10n_js__WEBPACK_IMPORTED_MODULE_2__.GenericL10n(_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("locale"));
  5302. }
  5303. createScripting() {
  5304. return new _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__.GenericScripting(_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("sandboxBundleSrc"));
  5305. }
  5306. }
  5307. class MLManager {
  5308. async guess() {
  5309. return null;
  5310. }
  5311. }
  5312. __webpack_async_result__();
  5313. } catch(e) { __webpack_async_result__(e); } });
  5314. /***/ }),
  5315. /***/ 410:
  5316. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5317. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5318. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5319. /* harmony export */ GenericL10n: () => (/* binding */ GenericL10n)
  5320. /* harmony export */ });
  5321. /* harmony import */ var fluent_bundle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(588);
  5322. /* harmony import */ var fluent_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5273);
  5323. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2603);
  5324. /* harmony import */ var _l10n_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4693);
  5325. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__]);
  5326. pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5327. function createBundle(lang, text) {
  5328. const resource = new fluent_bundle__WEBPACK_IMPORTED_MODULE_0__.FluentResource(text);
  5329. const bundle = new fluent_bundle__WEBPACK_IMPORTED_MODULE_0__.FluentBundle(lang);
  5330. const errors = bundle.addResource(resource);
  5331. if (errors.length) {
  5332. console.error("L10n errors", errors);
  5333. }
  5334. return bundle;
  5335. }
  5336. class GenericL10n extends _l10n_js__WEBPACK_IMPORTED_MODULE_3__.L10n {
  5337. constructor(lang) {
  5338. super({
  5339. lang
  5340. });
  5341. const generateBundles = !lang ? GenericL10n.#generateBundlesFallback.bind(GenericL10n, this.getLanguage()) : GenericL10n.#generateBundles.bind(GenericL10n, "en-us", this.getLanguage());
  5342. this._setL10n(new fluent_dom__WEBPACK_IMPORTED_MODULE_1__.DOMLocalization([], generateBundles));
  5343. }
  5344. static async *#generateBundles(defaultLang, baseLang) {
  5345. const {
  5346. baseURL,
  5347. paths
  5348. } = await this.#getPaths();
  5349. const langs = [baseLang];
  5350. if (defaultLang !== baseLang) {
  5351. const shortLang = baseLang.split("-", 1)[0];
  5352. if (shortLang !== baseLang) {
  5353. langs.push(shortLang);
  5354. }
  5355. langs.push(defaultLang);
  5356. }
  5357. for (const lang of langs) {
  5358. const bundle = await this.#createBundle(lang, baseURL, paths);
  5359. if (bundle) {
  5360. yield bundle;
  5361. }
  5362. if (lang === "en-us") {
  5363. yield this.#createBundleFallback(lang);
  5364. }
  5365. }
  5366. }
  5367. static async #createBundle(lang, baseURL, paths) {
  5368. const path = paths[lang];
  5369. if (!path) {
  5370. return null;
  5371. }
  5372. const url = new URL(path, baseURL);
  5373. const text = await (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.fetchData)(url, "text");
  5374. return createBundle(lang, text);
  5375. }
  5376. static async #getPaths() {
  5377. try {
  5378. const {
  5379. href
  5380. } = document.querySelector(`link[type="application/l10n"]`);
  5381. const paths = await (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_2__.fetchData)(href, "json");
  5382. return {
  5383. baseURL: href.replace(/[^/]*$/, "") || "./",
  5384. paths
  5385. };
  5386. } catch {}
  5387. return {
  5388. baseURL: "./",
  5389. paths: Object.create(null)
  5390. };
  5391. }
  5392. static async *#generateBundlesFallback(lang) {
  5393. yield this.#createBundleFallback(lang);
  5394. }
  5395. static async #createBundleFallback(lang) {
  5396. 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 = / { $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-kb = { $size_kb } KB ({ $size_b } bytes)\npdfjs-document-properties-mb = { $size_mb } MB ({ $size_b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-string = { $date }, { $time }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xD7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xD7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-string = { $date }, { $time }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-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-label-top-left = Top left corner \u2014 resize\npdfjs-editor-resizer-label-top-middle = Top middle \u2014 resize\npdfjs-editor-resizer-label-top-right = Top right corner \u2014 resize\npdfjs-editor-resizer-label-middle-right = Middle right \u2014 resize\npdfjs-editor-resizer-label-bottom-right = Bottom right corner \u2014 resize\npdfjs-editor-resizer-label-bottom-middle = Bottom middle \u2014 resize\npdfjs-editor-resizer-label-bottom-left = Bottom left corner \u2014 resize\npdfjs-editor-resizer-label-middle-left = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all";
  5397. return createBundle(lang, text);
  5398. }
  5399. }
  5400. __webpack_async_result__();
  5401. } catch(e) { __webpack_async_result__(e); } });
  5402. /***/ }),
  5403. /***/ 2640:
  5404. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5405. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5406. /* harmony export */ GrabToPan: () => (/* binding */ GrabToPan)
  5407. /* harmony export */ });
  5408. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  5409. class GrabToPan {
  5410. constructor({
  5411. element
  5412. }) {
  5413. this.element = element;
  5414. this.document = element.ownerDocument;
  5415. this.activate = this.activate.bind(this);
  5416. this.deactivate = this.deactivate.bind(this);
  5417. this.toggle = this.toggle.bind(this);
  5418. this._onMouseDown = this.#onMouseDown.bind(this);
  5419. this._onMouseMove = this.#onMouseMove.bind(this);
  5420. this._endPan = this.#endPan.bind(this);
  5421. const overlay = this.overlay = document.createElement("div");
  5422. overlay.className = "grab-to-pan-grabbing";
  5423. }
  5424. activate() {
  5425. if (!this.active) {
  5426. this.active = true;
  5427. this.element.addEventListener("mousedown", this._onMouseDown, true);
  5428. this.element.classList.add(CSS_CLASS_GRAB);
  5429. }
  5430. }
  5431. deactivate() {
  5432. if (this.active) {
  5433. this.active = false;
  5434. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  5435. this._endPan();
  5436. this.element.classList.remove(CSS_CLASS_GRAB);
  5437. }
  5438. }
  5439. toggle() {
  5440. if (this.active) {
  5441. this.deactivate();
  5442. } else {
  5443. this.activate();
  5444. }
  5445. }
  5446. ignoreTarget(node) {
  5447. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  5448. }
  5449. #onMouseDown(event) {
  5450. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  5451. return;
  5452. }
  5453. if (event.originalTarget) {
  5454. try {
  5455. event.originalTarget.tagName;
  5456. } catch {
  5457. return;
  5458. }
  5459. }
  5460. this.scrollLeftStart = this.element.scrollLeft;
  5461. this.scrollTopStart = this.element.scrollTop;
  5462. this.clientXStart = event.clientX;
  5463. this.clientYStart = event.clientY;
  5464. this.document.addEventListener("mousemove", this._onMouseMove, true);
  5465. this.document.addEventListener("mouseup", this._endPan, true);
  5466. this.element.addEventListener("scroll", this._endPan, true);
  5467. event.preventDefault();
  5468. event.stopPropagation();
  5469. const focusedElement = document.activeElement;
  5470. if (focusedElement && !focusedElement.contains(event.target)) {
  5471. focusedElement.blur();
  5472. }
  5473. }
  5474. #onMouseMove(event) {
  5475. this.element.removeEventListener("scroll", this._endPan, true);
  5476. if (!(event.buttons & 1)) {
  5477. this._endPan();
  5478. return;
  5479. }
  5480. const xDiff = event.clientX - this.clientXStart;
  5481. const yDiff = event.clientY - this.clientYStart;
  5482. this.element.scrollTo({
  5483. top: this.scrollTopStart - yDiff,
  5484. left: this.scrollLeftStart - xDiff,
  5485. behavior: "instant"
  5486. });
  5487. if (!this.overlay.parentNode) {
  5488. document.body.append(this.overlay);
  5489. }
  5490. }
  5491. #endPan() {
  5492. this.element.removeEventListener("scroll", this._endPan, true);
  5493. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  5494. this.document.removeEventListener("mouseup", this._endPan, true);
  5495. this.overlay.remove();
  5496. }
  5497. }
  5498. /***/ }),
  5499. /***/ 4693:
  5500. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5501. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5502. /* harmony export */ L10n: () => (/* binding */ L10n)
  5503. /* harmony export */ });
  5504. /* unused harmony export GenericL10n */
  5505. class L10n {
  5506. #dir;
  5507. #lang;
  5508. #l10n;
  5509. constructor({
  5510. lang,
  5511. isRTL
  5512. }, l10n = null) {
  5513. this.#lang = L10n.#fixupLangCode(lang);
  5514. this.#l10n = l10n;
  5515. this.#dir = isRTL ?? L10n.#isRTL(this.#lang) ? "rtl" : "ltr";
  5516. }
  5517. _setL10n(l10n) {
  5518. this.#l10n = l10n;
  5519. }
  5520. getLanguage() {
  5521. return this.#lang;
  5522. }
  5523. getDirection() {
  5524. return this.#dir;
  5525. }
  5526. async get(ids, args = null, fallback) {
  5527. if (Array.isArray(ids)) {
  5528. ids = ids.map(id => ({
  5529. id
  5530. }));
  5531. const messages = await this.#l10n.formatMessages(ids);
  5532. return messages.map(message => message.value);
  5533. }
  5534. const messages = await this.#l10n.formatMessages([{
  5535. id: ids,
  5536. args
  5537. }]);
  5538. return messages?.[0].value || fallback;
  5539. }
  5540. async translate(element) {
  5541. try {
  5542. this.#l10n.connectRoot(element);
  5543. await this.#l10n.translateRoots();
  5544. } catch {}
  5545. }
  5546. pause() {
  5547. this.#l10n.pauseObserving();
  5548. }
  5549. resume() {
  5550. this.#l10n.resumeObserving();
  5551. }
  5552. static #fixupLangCode(langCode) {
  5553. langCode = langCode?.toLowerCase() || "en-us";
  5554. const PARTIAL_LANG_CODES = {
  5555. en: "en-us",
  5556. es: "es-es",
  5557. fy: "fy-nl",
  5558. ga: "ga-ie",
  5559. gu: "gu-in",
  5560. hi: "hi-in",
  5561. hy: "hy-am",
  5562. nb: "nb-no",
  5563. ne: "ne-np",
  5564. nn: "nn-no",
  5565. pa: "pa-in",
  5566. pt: "pt-pt",
  5567. sv: "sv-se",
  5568. zh: "zh-cn"
  5569. };
  5570. return PARTIAL_LANG_CODES[langCode] || langCode;
  5571. }
  5572. static #isRTL(lang) {
  5573. const shortCode = lang.split("-", 1)[0];
  5574. return ["ar", "he", "fa", "ps", "ur"].includes(shortCode);
  5575. }
  5576. }
  5577. const GenericL10n = null;
  5578. /***/ }),
  5579. /***/ 6174:
  5580. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  5581. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5582. /* harmony export */ OverlayManager: () => (/* binding */ OverlayManager)
  5583. /* harmony export */ });
  5584. class OverlayManager {
  5585. #overlays = new WeakMap();
  5586. #active = null;
  5587. get active() {
  5588. return this.#active;
  5589. }
  5590. async register(dialog, canForceClose = false) {
  5591. if (typeof dialog !== "object") {
  5592. throw new Error("Not enough parameters.");
  5593. } else if (this.#overlays.has(dialog)) {
  5594. throw new Error("The overlay is already registered.");
  5595. }
  5596. this.#overlays.set(dialog, {
  5597. canForceClose
  5598. });
  5599. dialog.addEventListener("cancel", evt => {
  5600. this.#active = null;
  5601. });
  5602. }
  5603. async open(dialog) {
  5604. if (!this.#overlays.has(dialog)) {
  5605. throw new Error("The overlay does not exist.");
  5606. } else if (this.#active) {
  5607. if (this.#active === dialog) {
  5608. throw new Error("The overlay is already active.");
  5609. } else if (this.#overlays.get(dialog).canForceClose) {
  5610. await this.close();
  5611. } else {
  5612. throw new Error("Another overlay is currently active.");
  5613. }
  5614. }
  5615. this.#active = dialog;
  5616. dialog.showModal();
  5617. }
  5618. async close(dialog = this.#active) {
  5619. if (!this.#overlays.has(dialog)) {
  5620. throw new Error("The overlay does not exist.");
  5621. } else if (!this.#active) {
  5622. throw new Error("The overlay is currently not active.");
  5623. } else if (this.#active !== dialog) {
  5624. throw new Error("Another overlay is currently active.");
  5625. }
  5626. dialog.close();
  5627. this.#active = null;
  5628. }
  5629. }
  5630. /***/ }),
  5631. /***/ 2690:
  5632. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5633. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5634. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5635. /* harmony export */ PasswordPrompt: () => (/* binding */ PasswordPrompt)
  5636. /* harmony export */ });
  5637. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  5638. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5639. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5640. class PasswordPrompt {
  5641. #activeCapability = null;
  5642. #updateCallback = null;
  5643. #reason = null;
  5644. constructor(options, overlayManager, isViewerEmbedded = false) {
  5645. this.dialog = options.dialog;
  5646. this.label = options.label;
  5647. this.input = options.input;
  5648. this.submitButton = options.submitButton;
  5649. this.cancelButton = options.cancelButton;
  5650. this.overlayManager = overlayManager;
  5651. this._isViewerEmbedded = isViewerEmbedded;
  5652. this.submitButton.addEventListener("click", this.#verify.bind(this));
  5653. this.cancelButton.addEventListener("click", this.close.bind(this));
  5654. this.input.addEventListener("keydown", e => {
  5655. if (e.keyCode === 13) {
  5656. this.#verify();
  5657. }
  5658. });
  5659. this.overlayManager.register(this.dialog, true);
  5660. this.dialog.addEventListener("close", this.#cancel.bind(this));
  5661. }
  5662. async open() {
  5663. await this.#activeCapability?.promise;
  5664. this.#activeCapability = Promise.withResolvers();
  5665. try {
  5666. await this.overlayManager.open(this.dialog);
  5667. } catch (ex) {
  5668. this.#activeCapability.resolve();
  5669. throw ex;
  5670. }
  5671. const passwordIncorrect = this.#reason === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PasswordResponses.INCORRECT_PASSWORD;
  5672. if (!this._isViewerEmbedded || passwordIncorrect) {
  5673. this.input.focus();
  5674. }
  5675. this.label.setAttribute("data-l10n-id", `pdfjs-password-${passwordIncorrect ? "invalid" : "label"}`);
  5676. }
  5677. async close() {
  5678. if (this.overlayManager.active === this.dialog) {
  5679. this.overlayManager.close(this.dialog);
  5680. }
  5681. }
  5682. #verify() {
  5683. const password = this.input.value;
  5684. if (password?.length > 0) {
  5685. this.#invokeCallback(password);
  5686. }
  5687. }
  5688. #cancel() {
  5689. this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  5690. this.#activeCapability.resolve();
  5691. }
  5692. #invokeCallback(password) {
  5693. if (!this.#updateCallback) {
  5694. return;
  5695. }
  5696. this.close();
  5697. this.input.value = "";
  5698. this.#updateCallback(password);
  5699. this.#updateCallback = null;
  5700. }
  5701. async setUpdateCallback(updateCallback, reason) {
  5702. if (this.#activeCapability) {
  5703. await this.#activeCapability.promise;
  5704. }
  5705. this.#updateCallback = updateCallback;
  5706. this.#reason = reason;
  5707. }
  5708. }
  5709. __webpack_async_result__();
  5710. } catch(e) { __webpack_async_result__(e); } });
  5711. /***/ }),
  5712. /***/ 9251:
  5713. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5714. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5715. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5716. /* harmony export */ PDFAttachmentViewer: () => (/* binding */ PDFAttachmentViewer)
  5717. /* harmony export */ });
  5718. /* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961);
  5719. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
  5720. /* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5656);
  5721. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  5722. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5723. class PDFAttachmentViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
  5724. constructor(options) {
  5725. super(options);
  5726. this.downloadManager = options.downloadManager;
  5727. this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
  5728. }
  5729. reset(keepRenderedCapability = false) {
  5730. super.reset();
  5731. this._attachments = null;
  5732. if (!keepRenderedCapability) {
  5733. this._renderedCapability = Promise.withResolvers();
  5734. }
  5735. this._pendingDispatchEvent = false;
  5736. }
  5737. async _dispatchEvent(attachmentsCount) {
  5738. this._renderedCapability.resolve();
  5739. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  5740. this._pendingDispatchEvent = true;
  5741. await (0,_event_utils_js__WEBPACK_IMPORTED_MODULE_2__.waitOnEventOrTimeout)({
  5742. target: this.eventBus,
  5743. name: "annotationlayerrendered",
  5744. delay: 1000
  5745. });
  5746. if (!this._pendingDispatchEvent) {
  5747. return;
  5748. }
  5749. }
  5750. this._pendingDispatchEvent = false;
  5751. this.eventBus.dispatch("attachmentsloaded", {
  5752. source: this,
  5753. attachmentsCount
  5754. });
  5755. }
  5756. _bindLink(element, {
  5757. content,
  5758. filename
  5759. }) {
  5760. element.onclick = () => {
  5761. this.downloadManager.openOrDownloadData(content, filename);
  5762. return false;
  5763. };
  5764. }
  5765. render({
  5766. attachments,
  5767. keepRenderedCapability = false
  5768. }) {
  5769. if (this._attachments) {
  5770. this.reset(keepRenderedCapability);
  5771. }
  5772. this._attachments = attachments || null;
  5773. if (!attachments) {
  5774. this._dispatchEvent(0);
  5775. return;
  5776. }
  5777. const fragment = document.createDocumentFragment();
  5778. let attachmentsCount = 0;
  5779. for (const name in attachments) {
  5780. const item = attachments[name];
  5781. const content = item.content,
  5782. filename = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.getFilenameFromUrl)(item.filename, true);
  5783. const div = document.createElement("div");
  5784. div.className = "treeItem";
  5785. const element = document.createElement("a");
  5786. this._bindLink(element, {
  5787. content,
  5788. filename
  5789. });
  5790. element.textContent = this._normalizeTextContent(filename);
  5791. div.append(element);
  5792. fragment.append(div);
  5793. attachmentsCount++;
  5794. }
  5795. this._finishRendering(fragment, attachmentsCount);
  5796. }
  5797. #appendAttachment({
  5798. filename,
  5799. content
  5800. }) {
  5801. const renderedPromise = this._renderedCapability.promise;
  5802. renderedPromise.then(() => {
  5803. if (renderedPromise !== this._renderedCapability.promise) {
  5804. return;
  5805. }
  5806. const attachments = this._attachments || Object.create(null);
  5807. for (const name in attachments) {
  5808. if (filename === name) {
  5809. return;
  5810. }
  5811. }
  5812. attachments[filename] = {
  5813. filename,
  5814. content
  5815. };
  5816. this.render({
  5817. attachments,
  5818. keepRenderedCapability: true
  5819. });
  5820. });
  5821. }
  5822. }
  5823. __webpack_async_result__();
  5824. } catch(e) { __webpack_async_result__(e); } });
  5825. /***/ }),
  5826. /***/ 5993:
  5827. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5828. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5829. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5830. /* harmony export */ PDFCursorTools: () => (/* binding */ PDFCursorTools)
  5831. /* harmony export */ });
  5832. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  5833. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  5834. /* harmony import */ var _grab_to_pan_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2640);
  5835. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  5836. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5837. class PDFCursorTools {
  5838. #active = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT;
  5839. #prevActive = null;
  5840. constructor({
  5841. container,
  5842. eventBus,
  5843. cursorToolOnLoad = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT
  5844. }) {
  5845. this.container = container;
  5846. this.eventBus = eventBus;
  5847. this.#addEventListeners();
  5848. Promise.resolve().then(() => {
  5849. this.switchTool(cursorToolOnLoad);
  5850. });
  5851. }
  5852. get activeTool() {
  5853. return this.#active;
  5854. }
  5855. switchTool(tool) {
  5856. if (this.#prevActive !== null) {
  5857. return;
  5858. }
  5859. if (tool === this.#active) {
  5860. return;
  5861. }
  5862. const disableActiveTool = () => {
  5863. switch (this.#active) {
  5864. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT:
  5865. break;
  5866. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.HAND:
  5867. this._handTool.deactivate();
  5868. break;
  5869. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.ZOOM:
  5870. }
  5871. };
  5872. switch (tool) {
  5873. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT:
  5874. disableActiveTool();
  5875. break;
  5876. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.HAND:
  5877. disableActiveTool();
  5878. this._handTool.activate();
  5879. break;
  5880. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.ZOOM:
  5881. default:
  5882. console.error(`switchTool: "${tool}" is an unsupported value.`);
  5883. return;
  5884. }
  5885. this.#active = tool;
  5886. this.eventBus.dispatch("cursortoolchanged", {
  5887. source: this,
  5888. tool
  5889. });
  5890. }
  5891. #addEventListeners() {
  5892. this.eventBus._on("switchcursortool", evt => {
  5893. if (!evt.reset) {
  5894. this.switchTool(evt.tool);
  5895. } else if (this.#prevActive !== null) {
  5896. annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
  5897. presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL;
  5898. enableActive();
  5899. }
  5900. });
  5901. let annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE,
  5902. presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL;
  5903. const disableActive = () => {
  5904. const prevActive = this.#active;
  5905. this.switchTool(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.CursorTool.SELECT);
  5906. this.#prevActive ??= prevActive;
  5907. };
  5908. const enableActive = () => {
  5909. const prevActive = this.#prevActive;
  5910. if (prevActive !== null && annotationEditorMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE && presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL) {
  5911. this.#prevActive = null;
  5912. this.switchTool(prevActive);
  5913. }
  5914. };
  5915. this.eventBus._on("annotationeditormodechanged", ({
  5916. mode
  5917. }) => {
  5918. annotationEditorMode = mode;
  5919. if (mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE) {
  5920. enableActive();
  5921. } else {
  5922. disableActive();
  5923. }
  5924. });
  5925. this.eventBus._on("presentationmodechanged", ({
  5926. state
  5927. }) => {
  5928. presentationModeState = state;
  5929. if (state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.NORMAL) {
  5930. enableActive();
  5931. } else if (state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN) {
  5932. disableActive();
  5933. }
  5934. });
  5935. }
  5936. get _handTool() {
  5937. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_handTool", new _grab_to_pan_js__WEBPACK_IMPORTED_MODULE_2__.GrabToPan({
  5938. element: this.container
  5939. }));
  5940. }
  5941. }
  5942. __webpack_async_result__();
  5943. } catch(e) { __webpack_async_result__(e); } });
  5944. /***/ }),
  5945. /***/ 164:
  5946. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  5947. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  5948. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5949. /* harmony export */ PDFDocumentProperties: () => (/* binding */ PDFDocumentProperties)
  5950. /* harmony export */ });
  5951. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  5952. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
  5953. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  5954. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  5955. const DEFAULT_FIELD_CONTENT = "-";
  5956. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5957. const US_PAGE_NAMES = {
  5958. "8.5x11": "letter",
  5959. "8.5x14": "legal"
  5960. };
  5961. const METRIC_PAGE_NAMES = {
  5962. "297x420": "a-three",
  5963. "210x297": "a-four"
  5964. };
  5965. function getPageName(size, isPortrait, pageNames) {
  5966. const width = isPortrait ? size.width : size.height;
  5967. const height = isPortrait ? size.height : size.width;
  5968. return pageNames[`${width}x${height}`];
  5969. }
  5970. class PDFDocumentProperties {
  5971. #fieldData = null;
  5972. constructor({
  5973. dialog,
  5974. fields,
  5975. closeButton
  5976. }, overlayManager, eventBus, l10n, fileNameLookup) {
  5977. this.dialog = dialog;
  5978. this.fields = fields;
  5979. this.overlayManager = overlayManager;
  5980. this.l10n = l10n;
  5981. this._fileNameLookup = fileNameLookup;
  5982. this.#reset();
  5983. closeButton.addEventListener("click", this.close.bind(this));
  5984. this.overlayManager.register(this.dialog);
  5985. eventBus._on("pagechanging", evt => {
  5986. this._currentPageNumber = evt.pageNumber;
  5987. // console.log('test-number-message-send', evt.pageNumber,window.renderExtractLayer);
  5988. window.parent.postMessage({pageNum: evt.pageNumber}, '*');
  5989. });
  5990. eventBus._on("rotationchanging", evt => {
  5991. this._pagesRotation = evt.pagesRotation;
  5992. });
  5993. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
  5994. }
  5995. async open() {
  5996. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  5997. const currentPageNumber = this._currentPageNumber;
  5998. const pagesRotation = this._pagesRotation;
  5999. if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
  6000. this.#updateUI();
  6001. return;
  6002. }
  6003. const {
  6004. info,
  6005. contentLength
  6006. } = await this.pdfDocument.getMetadata();
  6007. 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 => {
  6008. return this.#parsePageSize((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getPageSizeInches)(pdfPage), pagesRotation);
  6009. }), this.#parseLinearization(info.IsLinearized)]);
  6010. this.#fieldData = Object.freeze({
  6011. fileName,
  6012. fileSize,
  6013. title: info.Title,
  6014. author: info.Author,
  6015. subject: info.Subject,
  6016. keywords: info.Keywords,
  6017. creationDate,
  6018. modificationDate,
  6019. creator: info.Creator,
  6020. producer: info.Producer,
  6021. version: info.PDFFormatVersion,
  6022. pageCount: this.pdfDocument.numPages,
  6023. pageSize,
  6024. linearized: isLinearized,
  6025. _currentPageNumber: currentPageNumber,
  6026. _pagesRotation: pagesRotation
  6027. });
  6028. this.#updateUI();
  6029. const {
  6030. length
  6031. } = await this.pdfDocument.getDownloadInfo();
  6032. if (contentLength === length) {
  6033. return;
  6034. }
  6035. const data = Object.assign(Object.create(null), this.#fieldData);
  6036. data.fileSize = await this.#parseFileSize(length);
  6037. this.#fieldData = Object.freeze(data);
  6038. this.#updateUI();
  6039. }
  6040. async close() {
  6041. this.overlayManager.close(this.dialog);
  6042. }
  6043. setDocument(pdfDocument) {
  6044. if (this.pdfDocument) {
  6045. this.#reset();
  6046. this.#updateUI(true);
  6047. }
  6048. if (!pdfDocument) {
  6049. return;
  6050. }
  6051. this.pdfDocument = pdfDocument;
  6052. this._dataAvailableCapability.resolve();
  6053. }
  6054. #reset() {
  6055. this.pdfDocument = null;
  6056. this.#fieldData = null;
  6057. this._dataAvailableCapability = Promise.withResolvers();
  6058. this._currentPageNumber = 1;
  6059. this._pagesRotation = 0;
  6060. }
  6061. #updateUI(reset = false) {
  6062. if (reset || !this.#fieldData) {
  6063. for (const id in this.fields) {
  6064. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6065. }
  6066. return;
  6067. }
  6068. if (this.overlayManager.active !== this.dialog) {
  6069. return;
  6070. }
  6071. for (const id in this.fields) {
  6072. const content = this.#fieldData[id];
  6073. this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6074. }
  6075. }
  6076. async #parseFileSize(fileSize = 0) {
  6077. const kb = fileSize / 1024,
  6078. mb = kb / 1024;
  6079. if (!kb) {
  6080. return undefined;
  6081. }
  6082. return this.l10n.get(`pdfjs-document-properties-${mb >= 1 ? "mb" : "kb"}`, {
  6083. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  6084. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  6085. size_b: fileSize.toLocaleString()
  6086. });
  6087. }
  6088. async #parsePageSize(pageSizeInches, pagesRotation) {
  6089. if (!pageSizeInches) {
  6090. return undefined;
  6091. }
  6092. if (pagesRotation % 180 !== 0) {
  6093. pageSizeInches = {
  6094. width: pageSizeInches.height,
  6095. height: pageSizeInches.width
  6096. };
  6097. }
  6098. const isPortrait = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isPortraitOrientation)(pageSizeInches);
  6099. let sizeInches = {
  6100. width: Math.round(pageSizeInches.width * 100) / 100,
  6101. height: Math.round(pageSizeInches.height * 100) / 100
  6102. };
  6103. let sizeMillimeters = {
  6104. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6105. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6106. };
  6107. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6108. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6109. const exactMillimeters = {
  6110. width: pageSizeInches.width * 25.4,
  6111. height: pageSizeInches.height * 25.4
  6112. };
  6113. const intMillimeters = {
  6114. width: Math.round(sizeMillimeters.width),
  6115. height: Math.round(sizeMillimeters.height)
  6116. };
  6117. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6118. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6119. if (rawName) {
  6120. sizeInches = {
  6121. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6122. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6123. };
  6124. sizeMillimeters = intMillimeters;
  6125. }
  6126. }
  6127. }
  6128. const [{
  6129. width,
  6130. height
  6131. }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`pdfjs-document-properties-page-size-unit-${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`pdfjs-document-properties-page-size-name-${rawName}`), this.l10n.get(`pdfjs-document-properties-page-size-orientation-${isPortrait ? "portrait" : "landscape"}`)]);
  6132. return this.l10n.get(`pdfjs-document-properties-page-size-dimension-${name ? "name-" : ""}string`, {
  6133. width: width.toLocaleString(),
  6134. height: height.toLocaleString(),
  6135. unit,
  6136. name,
  6137. orientation
  6138. });
  6139. }
  6140. async #parseDate(inputDate) {
  6141. const dateObject = pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.PDFDateString.toDateObject(inputDate);
  6142. if (!dateObject) {
  6143. return undefined;
  6144. }
  6145. return this.l10n.get("pdfjs-document-properties-date-string", {
  6146. date: dateObject.toLocaleDateString(),
  6147. time: dateObject.toLocaleTimeString()
  6148. });
  6149. }
  6150. #parseLinearization(isLinearized) {
  6151. return this.l10n.get(`pdfjs-document-properties-linearized-${isLinearized ? "yes" : "no"}`);
  6152. }
  6153. }
  6154. __webpack_async_result__();
  6155. } catch(e) { __webpack_async_result__(e); } });
  6156. /***/ }),
  6157. /***/ 2226:
  6158. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  6159. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6160. /* harmony export */ PDFFindBar: () => (/* binding */ PDFFindBar)
  6161. /* harmony export */ });
  6162. /* harmony import */ var _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9814);
  6163. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  6164. const MATCHES_COUNT_LIMIT = 1000;
  6165. class PDFFindBar {
  6166. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  6167. constructor(options, eventBus) {
  6168. this.opened = false;
  6169. this.bar = options.bar;
  6170. this.toggleButton = options.toggleButton;
  6171. this.findField = options.findField;
  6172. this.highlightAll = options.highlightAllCheckbox;
  6173. this.caseSensitive = options.caseSensitiveCheckbox;
  6174. this.matchDiacritics = options.matchDiacriticsCheckbox;
  6175. this.entireWord = options.entireWordCheckbox;
  6176. this.findMsg = options.findMsg;
  6177. this.findResultsCount = options.findResultsCount;
  6178. this.findPreviousButton = options.findPreviousButton;
  6179. this.findNextButton = options.findNextButton;
  6180. this.eventBus = eventBus;
  6181. this.toggleButton.addEventListener("click", () => {
  6182. this.toggle();
  6183. });
  6184. this.findField.addEventListener("input", () => {
  6185. this.dispatchEvent("");
  6186. });
  6187. this.bar.addEventListener("keydown", e => {
  6188. switch (e.keyCode) {
  6189. case 13:
  6190. if (e.target === this.findField) {
  6191. this.dispatchEvent("again", e.shiftKey);
  6192. }
  6193. break;
  6194. case 27:
  6195. this.close();
  6196. break;
  6197. }
  6198. });
  6199. this.findPreviousButton.addEventListener("click", () => {
  6200. this.dispatchEvent("again", true);
  6201. });
  6202. this.findNextButton.addEventListener("click", () => {
  6203. this.dispatchEvent("again", false);
  6204. });
  6205. this.highlightAll.addEventListener("click", () => {
  6206. this.dispatchEvent("highlightallchange");
  6207. });
  6208. this.caseSensitive.addEventListener("click", () => {
  6209. this.dispatchEvent("casesensitivitychange");
  6210. });
  6211. this.entireWord.addEventListener("click", () => {
  6212. this.dispatchEvent("entirewordchange");
  6213. });
  6214. this.matchDiacritics.addEventListener("click", () => {
  6215. this.dispatchEvent("diacriticmatchingchange");
  6216. });
  6217. }
  6218. reset() {
  6219. this.updateUIState();
  6220. }
  6221. dispatchEvent(type, findPrev = false) {
  6222. this.eventBus.dispatch("find", {
  6223. source: this,
  6224. type,
  6225. query: this.findField.value,
  6226. caseSensitive: this.caseSensitive.checked,
  6227. entireWord: this.entireWord.checked,
  6228. highlightAll: this.highlightAll.checked,
  6229. findPrevious: findPrev,
  6230. matchDiacritics: this.matchDiacritics.checked
  6231. });
  6232. }
  6233. updateUIState(state, previous, matchesCount) {
  6234. const {
  6235. findField,
  6236. findMsg
  6237. } = this;
  6238. let findMsgId = "",
  6239. status = "";
  6240. switch (state) {
  6241. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.FOUND:
  6242. break;
  6243. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.PENDING:
  6244. status = "pending";
  6245. break;
  6246. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.NOT_FOUND:
  6247. findMsgId = "pdfjs-find-not-found";
  6248. status = "notFound";
  6249. break;
  6250. case _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.WRAPPED:
  6251. findMsgId = `pdfjs-find-reached-${previous ? "top" : "bottom"}`;
  6252. break;
  6253. }
  6254. findField.setAttribute("data-status", status);
  6255. findField.setAttribute("aria-invalid", state === _pdf_find_controller_js__WEBPACK_IMPORTED_MODULE_0__.FindState.NOT_FOUND);
  6256. findMsg.setAttribute("data-status", status);
  6257. if (findMsgId) {
  6258. findMsg.setAttribute("data-l10n-id", findMsgId);
  6259. } else {
  6260. findMsg.removeAttribute("data-l10n-id");
  6261. findMsg.textContent = "";
  6262. }
  6263. this.updateResultsCount(matchesCount);
  6264. }
  6265. updateResultsCount({
  6266. current = 0,
  6267. total = 0
  6268. } = {}) {
  6269. const {
  6270. findResultsCount
  6271. } = this;
  6272. if (total > 0) {
  6273. const limit = MATCHES_COUNT_LIMIT;
  6274. findResultsCount.setAttribute("data-l10n-id", `pdfjs-find-match-count${total > limit ? "-limit" : ""}`);
  6275. findResultsCount.setAttribute("data-l10n-args", JSON.stringify({
  6276. limit,
  6277. current,
  6278. total
  6279. }));
  6280. } else {
  6281. findResultsCount.removeAttribute("data-l10n-id");
  6282. findResultsCount.textContent = "";
  6283. }
  6284. }
  6285. open() {
  6286. if (!this.opened) {
  6287. this.#resizeObserver.observe(this.bar.parentNode);
  6288. this.#resizeObserver.observe(this.bar);
  6289. this.opened = true;
  6290. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleExpandedBtn)(this.toggleButton, true, this.bar);
  6291. }
  6292. this.findField.select();
  6293. this.findField.focus();
  6294. }
  6295. close() {
  6296. if (!this.opened) {
  6297. return;
  6298. }
  6299. this.#resizeObserver.disconnect();
  6300. this.opened = false;
  6301. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleExpandedBtn)(this.toggleButton, false, this.bar);
  6302. this.eventBus.dispatch("findbarclose", {
  6303. source: this
  6304. });
  6305. }
  6306. toggle() {
  6307. if (this.opened) {
  6308. this.close();
  6309. } else {
  6310. this.open();
  6311. }
  6312. }
  6313. #resizeObserverCallback(entries) {
  6314. const {
  6315. bar
  6316. } = this;
  6317. bar.classList.remove("wrapContainers");
  6318. const findbarHeight = bar.clientHeight;
  6319. const inputContainerHeight = bar.firstElementChild.clientHeight;
  6320. if (findbarHeight > inputContainerHeight) {
  6321. bar.classList.add("wrapContainers");
  6322. }
  6323. }
  6324. }
  6325. /***/ }),
  6326. /***/ 9814:
  6327. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  6328. // EXPORTS
  6329. __webpack_require__.d(__webpack_exports__, {
  6330. FindState: () => (/* binding */ FindState),
  6331. PDFFindController: () => (/* binding */ PDFFindController)
  6332. });
  6333. // EXTERNAL MODULE: ./web/ui_utils.js
  6334. var ui_utils = __webpack_require__(7256);
  6335. ;// CONCATENATED MODULE: ./web/pdf_find_utils.js
  6336. const CharacterType = {
  6337. SPACE: 0,
  6338. ALPHA_LETTER: 1,
  6339. PUNCT: 2,
  6340. HAN_LETTER: 3,
  6341. KATAKANA_LETTER: 4,
  6342. HIRAGANA_LETTER: 5,
  6343. HALFWIDTH_KATAKANA_LETTER: 6,
  6344. THAI_LETTER: 7
  6345. };
  6346. function isAlphabeticalScript(charCode) {
  6347. return charCode < 0x2e80;
  6348. }
  6349. function isAscii(charCode) {
  6350. return (charCode & 0xff80) === 0;
  6351. }
  6352. function isAsciiAlpha(charCode) {
  6353. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6354. }
  6355. function isAsciiDigit(charCode) {
  6356. return charCode >= 0x30 && charCode <= 0x39;
  6357. }
  6358. function isAsciiSpace(charCode) {
  6359. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6360. }
  6361. function isHan(charCode) {
  6362. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6363. }
  6364. function isKatakana(charCode) {
  6365. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6366. }
  6367. function isHiragana(charCode) {
  6368. return charCode >= 0x3040 && charCode <= 0x309f;
  6369. }
  6370. function isHalfwidthKatakana(charCode) {
  6371. return charCode >= 0xff60 && charCode <= 0xff9f;
  6372. }
  6373. function isThai(charCode) {
  6374. return (charCode & 0xff80) === 0x0e00;
  6375. }
  6376. function getCharacterType(charCode) {
  6377. if (isAlphabeticalScript(charCode)) {
  6378. if (isAscii(charCode)) {
  6379. if (isAsciiSpace(charCode)) {
  6380. return CharacterType.SPACE;
  6381. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6382. return CharacterType.ALPHA_LETTER;
  6383. }
  6384. return CharacterType.PUNCT;
  6385. } else if (isThai(charCode)) {
  6386. return CharacterType.THAI_LETTER;
  6387. } else if (charCode === 0xa0) {
  6388. return CharacterType.SPACE;
  6389. }
  6390. return CharacterType.ALPHA_LETTER;
  6391. }
  6392. if (isHan(charCode)) {
  6393. return CharacterType.HAN_LETTER;
  6394. } else if (isKatakana(charCode)) {
  6395. return CharacterType.KATAKANA_LETTER;
  6396. } else if (isHiragana(charCode)) {
  6397. return CharacterType.HIRAGANA_LETTER;
  6398. } else if (isHalfwidthKatakana(charCode)) {
  6399. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6400. }
  6401. return CharacterType.ALPHA_LETTER;
  6402. }
  6403. let NormalizeWithNFKC;
  6404. function getNormalizeWithNFKC() {
  6405. NormalizeWithNFKC ||= `聽篓陋炉虏-碌赂-潞录-戮牟-某目-艀艍趴莿-菍潜-浅拾-矢藰-藵藸-摔痛秃途蝿-螀螄蠍-蠔习-喜洗-系瞎謬俚-俑啷�-啷熰-唰澿啜赤ǘ喋�-喋涏喹�-喹澿赋嗪赤粶-嗷澿紝嘟冟綅嘟掄綏嘟溹僵醿坚船-岽窗-岽横醇-岬嶀祻-岬蹈岫�-岫酷簹-岷涐奖峤翅降峤丰焦峤会浇峋会窘-峥佱繅峥嬦繊-峥忈繐峥涐繚-峥熱浚峥凯-峥抗峥会拷-峥锯€€-鈥娾€戔€椻€�-鈥︹€€�-鈥粹€�-鈥封€尖€锯亣-鈦夆仐鈦熲伆-鈦扁伌-鈧庘倫-鈧溾偍鈩€-鈩冣剠-鈩団剦-鈩撯剷-鈩栤剻-鈩濃劆-鈩⑩劋鈩︹劏鈩�-鈩劘-鈩扁劤-鈩光劵-鈪€鈪�-鈪夆厫-鈪库唹鈭�-鈭埊-鈭扳尒-鈱憼-鈸▽猢�-猢垛珳獗�-獗解弹夂熲怀饧€-饪曘€€銆躲€�-銆恒倹-銈溿偀銉裤劚-銌庛啋-銌熴垁-銏炪垹-銐囥墣-銐俱妧-銖筷殰-隁濌澃隉�-隉搓煾-隉龟瓬-戥熽铯€-铷嶏◥铷掞〞-铷烇铷ē-铷︼í-铹┌-铽欙瑎-铿嗭瑩-铿楋瑵铿�-铿讹-铿硷锃€-锃侊瓋-锃勶瓎-锂憋瘬-锎斤祼-锒忥稈-锓囷钒-锓硷笎-锔欙赴-锕勶箛-锕掞箶-锕︼龚-锕拱-锕诧勾锕�-锘硷紒-锞撅總-锟囷繆-锟忥繏-锟楋繗-锟滐繝-锟`;
  6406. return NormalizeWithNFKC;
  6407. }
  6408. ;// CONCATENATED MODULE: ./web/pdf_find_controller.js
  6409. const FindState = {
  6410. FOUND: 0,
  6411. NOT_FOUND: 1,
  6412. WRAPPED: 2,
  6413. PENDING: 3
  6414. };
  6415. const FIND_TIMEOUT = 250;
  6416. const MATCH_SCROLL_OFFSET_TOP = -50;
  6417. const MATCH_SCROLL_OFFSET_LEFT = -400;
  6418. const CHARACTERS_TO_NORMALIZE = {
  6419. "\u2010": "-",
  6420. "\u2018": "'",
  6421. "\u2019": "'",
  6422. "\u201A": "'",
  6423. "\u201B": "'",
  6424. "\u201C": '"',
  6425. "\u201D": '"',
  6426. "\u201E": '"',
  6427. "\u201F": '"',
  6428. "\u00BC": "1/4",
  6429. "\u00BD": "1/2",
  6430. "\u00BE": "3/4"
  6431. };
  6432. 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]);
  6433. let DIACRITICS_EXCEPTION_STR;
  6434. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  6435. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  6436. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  6437. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  6438. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  6439. const SYLLABLES_LENGTHS = new Map();
  6440. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  6441. const NFKC_CHARS_TO_NORMALIZE = new Map();
  6442. let noSyllablesRegExp = null;
  6443. let withSyllablesRegExp = null;
  6444. function normalize(text) {
  6445. const syllablePositions = [];
  6446. let m;
  6447. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  6448. let {
  6449. index
  6450. } = m;
  6451. for (const char of m[0]) {
  6452. let len = SYLLABLES_LENGTHS.get(char);
  6453. if (!len) {
  6454. len = char.normalize("NFD").length;
  6455. SYLLABLES_LENGTHS.set(char, len);
  6456. }
  6457. syllablePositions.push([len, index++]);
  6458. }
  6459. }
  6460. let normalizationRegex;
  6461. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  6462. normalizationRegex = noSyllablesRegExp;
  6463. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  6464. normalizationRegex = withSyllablesRegExp;
  6465. } else {
  6466. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6467. const toNormalizeWithNFKC = getNormalizeWithNFKC();
  6468. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  6469. const HKDiacritics = "(?:\u3099|\u309A)";
  6470. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  6471. if (syllablePositions.length === 0) {
  6472. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  6473. } else {
  6474. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  6475. }
  6476. }
  6477. const rawDiacriticsPositions = [];
  6478. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  6479. rawDiacriticsPositions.push([m[0].length, m.index]);
  6480. }
  6481. let normalized = text.normalize("NFD");
  6482. const positions = [[0, 0]];
  6483. let rawDiacriticsIndex = 0;
  6484. let syllableIndex = 0;
  6485. let shift = 0;
  6486. let shiftOrigin = 0;
  6487. let eol = 0;
  6488. let hasDiacritics = false;
  6489. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
  6490. i -= shiftOrigin;
  6491. if (p1) {
  6492. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  6493. const jj = replacement.length;
  6494. for (let j = 1; j < jj; j++) {
  6495. positions.push([i - shift + j, shift - j]);
  6496. }
  6497. shift -= jj - 1;
  6498. return replacement;
  6499. }
  6500. if (p2) {
  6501. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  6502. if (!replacement) {
  6503. replacement = p2.normalize("NFKC");
  6504. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  6505. }
  6506. const jj = replacement.length;
  6507. for (let j = 1; j < jj; j++) {
  6508. positions.push([i - shift + j, shift - j]);
  6509. }
  6510. shift -= jj - 1;
  6511. return replacement;
  6512. }
  6513. if (p3) {
  6514. hasDiacritics = true;
  6515. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  6516. ++rawDiacriticsIndex;
  6517. } else {
  6518. positions.push([i - 1 - shift + 1, shift - 1]);
  6519. shift -= 1;
  6520. shiftOrigin += 1;
  6521. }
  6522. positions.push([i - shift + 1, shift]);
  6523. shiftOrigin += 1;
  6524. eol += 1;
  6525. return p3.charAt(0);
  6526. }
  6527. if (p4) {
  6528. const hasTrailingDashEOL = p4.endsWith("\n");
  6529. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  6530. hasDiacritics = true;
  6531. let jj = len;
  6532. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  6533. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  6534. ++rawDiacriticsIndex;
  6535. }
  6536. for (let j = 1; j <= jj; j++) {
  6537. positions.push([i - 1 - shift + j, shift - j]);
  6538. }
  6539. shift -= jj;
  6540. shiftOrigin += jj;
  6541. if (hasTrailingDashEOL) {
  6542. i += len - 1;
  6543. positions.push([i - shift + 1, 1 + shift]);
  6544. shift += 1;
  6545. shiftOrigin += 1;
  6546. eol += 1;
  6547. return p4.slice(0, len);
  6548. }
  6549. return p4;
  6550. }
  6551. if (p5) {
  6552. const len = p5.length - 2;
  6553. positions.push([i - shift + len, 1 + shift]);
  6554. shift += 1;
  6555. shiftOrigin += 1;
  6556. eol += 1;
  6557. return p5.slice(0, -2);
  6558. }
  6559. if (p6) {
  6560. const len = p6.length - 1;
  6561. positions.push([i - shift + len, shift]);
  6562. shiftOrigin += 1;
  6563. eol += 1;
  6564. return p6.slice(0, -1);
  6565. }
  6566. if (p7) {
  6567. positions.push([i - shift + 1, shift - 1]);
  6568. shift -= 1;
  6569. shiftOrigin += 1;
  6570. eol += 1;
  6571. return " ";
  6572. }
  6573. if (i + eol === syllablePositions[syllableIndex]?.[1]) {
  6574. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  6575. ++syllableIndex;
  6576. for (let j = 1; j <= newCharLen; j++) {
  6577. positions.push([i - (shift - j), shift - j]);
  6578. }
  6579. shift -= newCharLen;
  6580. shiftOrigin += newCharLen;
  6581. }
  6582. return p8;
  6583. });
  6584. positions.push([normalized.length, shift]);
  6585. return [normalized, positions, hasDiacritics];
  6586. }
  6587. function getOriginalIndex(diffs, pos, len) {
  6588. if (!diffs) {
  6589. return [pos, len];
  6590. }
  6591. const start = pos;
  6592. const end = pos + len - 1;
  6593. let i = (0,ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
  6594. if (diffs[i][0] > start) {
  6595. --i;
  6596. }
  6597. let j = (0,ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  6598. if (diffs[j][0] > end) {
  6599. --j;
  6600. }
  6601. const oldStart = start + diffs[i][1];
  6602. const oldEnd = end + diffs[j][1];
  6603. const oldLen = oldEnd + 1 - oldStart;
  6604. return [oldStart, oldLen];
  6605. }
  6606. class PDFFindController {
  6607. #state = null;
  6608. #updateMatchesCountOnProgress = true;
  6609. #visitedPagesCount = 0;
  6610. constructor({
  6611. linkService,
  6612. eventBus,
  6613. updateMatchesCountOnProgress = true
  6614. }) {
  6615. this._linkService = linkService;
  6616. this._eventBus = eventBus;
  6617. this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
  6618. this.onIsPageVisible = null;
  6619. this.#reset();
  6620. eventBus._on("find", this.#onFind.bind(this));
  6621. eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
  6622. }
  6623. get highlightMatches() {
  6624. return this._highlightMatches;
  6625. }
  6626. get pageMatches() {
  6627. return this._pageMatches;
  6628. }
  6629. get pageMatchesLength() {
  6630. return this._pageMatchesLength;
  6631. }
  6632. get selected() {
  6633. return this._selected;
  6634. }
  6635. get state() {
  6636. return this.#state;
  6637. }
  6638. setDocument(pdfDocument) {
  6639. if (this._pdfDocument) {
  6640. this.#reset();
  6641. }
  6642. if (!pdfDocument) {
  6643. return;
  6644. }
  6645. this._pdfDocument = pdfDocument;
  6646. this._firstPageCapability.resolve();
  6647. }
  6648. #onFind(state) {
  6649. if (!state) {
  6650. return;
  6651. }
  6652. const pdfDocument = this._pdfDocument;
  6653. const {
  6654. type
  6655. } = state;
  6656. if (this.#state === null || this.#shouldDirtyMatch(state)) {
  6657. this._dirtyMatch = true;
  6658. }
  6659. this.#state = state;
  6660. if (type !== "highlightallchange") {
  6661. this.#updateUIState(FindState.PENDING);
  6662. }
  6663. this._firstPageCapability.promise.then(() => {
  6664. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  6665. return;
  6666. }
  6667. this.#extractText();
  6668. const findbarClosed = !this._highlightMatches;
  6669. const pendingTimeout = !!this._findTimeout;
  6670. if (this._findTimeout) {
  6671. clearTimeout(this._findTimeout);
  6672. this._findTimeout = null;
  6673. }
  6674. if (!type) {
  6675. this._findTimeout = setTimeout(() => {
  6676. this.#nextMatch();
  6677. this._findTimeout = null;
  6678. }, FIND_TIMEOUT);
  6679. } else if (this._dirtyMatch) {
  6680. this.#nextMatch();
  6681. } else if (type === "again") {
  6682. this.#nextMatch();
  6683. if (findbarClosed && this.#state.highlightAll) {
  6684. this.#updateAllPages();
  6685. }
  6686. } else if (type === "highlightallchange") {
  6687. if (pendingTimeout) {
  6688. this.#nextMatch();
  6689. } else {
  6690. this._highlightMatches = true;
  6691. }
  6692. this.#updateAllPages();
  6693. } else {
  6694. this.#nextMatch();
  6695. }
  6696. });
  6697. }
  6698. scrollMatchIntoView({
  6699. element = null,
  6700. selectedLeft = 0,
  6701. pageIndex = -1,
  6702. matchIndex = -1
  6703. }) {
  6704. if (!this._scrollMatches || !element) {
  6705. return;
  6706. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6707. return;
  6708. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6709. return;
  6710. }
  6711. this._scrollMatches = false;
  6712. const spot = {
  6713. top: MATCH_SCROLL_OFFSET_TOP,
  6714. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  6715. };
  6716. (0,ui_utils.scrollIntoView)(element, spot, true);
  6717. }
  6718. #reset() {
  6719. this._highlightMatches = false;
  6720. this._scrollMatches = false;
  6721. this._pdfDocument = null;
  6722. this._pageMatches = [];
  6723. this._pageMatchesLength = [];
  6724. this.#visitedPagesCount = 0;
  6725. this.#state = null;
  6726. this._selected = {
  6727. pageIdx: -1,
  6728. matchIdx: -1
  6729. };
  6730. this._offset = {
  6731. pageIdx: null,
  6732. matchIdx: null,
  6733. wrapped: false
  6734. };
  6735. this._extractTextPromises = [];
  6736. this._pageContents = [];
  6737. this._pageDiffs = [];
  6738. this._hasDiacritics = [];
  6739. this._matchesCountTotal = 0;
  6740. this._pagesToSearch = null;
  6741. this._pendingFindMatches = new Set();
  6742. this._resumePageIdx = null;
  6743. this._dirtyMatch = false;
  6744. clearTimeout(this._findTimeout);
  6745. this._findTimeout = null;
  6746. this._firstPageCapability = Promise.withResolvers();
  6747. }
  6748. get #query() {
  6749. const {
  6750. query
  6751. } = this.#state;
  6752. if (typeof query === "string") {
  6753. if (query !== this._rawQuery) {
  6754. this._rawQuery = query;
  6755. [this._normalizedQuery] = normalize(query);
  6756. }
  6757. return this._normalizedQuery;
  6758. }
  6759. return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
  6760. }
  6761. #shouldDirtyMatch(state) {
  6762. const newQuery = state.query,
  6763. prevQuery = this.#state.query;
  6764. const newType = typeof newQuery,
  6765. prevType = typeof prevQuery;
  6766. if (newType !== prevType) {
  6767. return true;
  6768. }
  6769. if (newType === "string") {
  6770. if (newQuery !== prevQuery) {
  6771. return true;
  6772. }
  6773. } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
  6774. return true;
  6775. }
  6776. switch (state.type) {
  6777. case "again":
  6778. const pageNumber = this._selected.pageIdx + 1;
  6779. const linkService = this._linkService;
  6780. return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
  6781. case "highlightallchange":
  6782. return false;
  6783. }
  6784. return true;
  6785. }
  6786. #isEntireWord(content, startIdx, length) {
  6787. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  6788. if (match) {
  6789. const first = content.charCodeAt(startIdx);
  6790. const limit = match[1].charCodeAt(0);
  6791. if (getCharacterType(first) === getCharacterType(limit)) {
  6792. return false;
  6793. }
  6794. }
  6795. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  6796. if (match) {
  6797. const last = content.charCodeAt(startIdx + length - 1);
  6798. const limit = match[1].charCodeAt(0);
  6799. if (getCharacterType(last) === getCharacterType(limit)) {
  6800. return false;
  6801. }
  6802. }
  6803. return true;
  6804. }
  6805. #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
  6806. const matches = this._pageMatches[pageIndex] = [];
  6807. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  6808. if (!query) {
  6809. return;
  6810. }
  6811. const diffs = this._pageDiffs[pageIndex];
  6812. let match;
  6813. while ((match = query.exec(pageContent)) !== null) {
  6814. if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
  6815. continue;
  6816. }
  6817. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  6818. if (matchLen) {
  6819. matches.push(matchPos);
  6820. matchesLength.push(matchLen);
  6821. }
  6822. }
  6823. }
  6824. #convertToRegExpString(query, hasDiacritics) {
  6825. const {
  6826. matchDiacritics
  6827. } = this.#state;
  6828. let isUnicode = false;
  6829. query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  6830. if (p1) {
  6831. return `[ ]*\\${p1}[ ]*`;
  6832. }
  6833. if (p2) {
  6834. return `[ ]*${p2}[ ]*`;
  6835. }
  6836. if (p3) {
  6837. return "[ ]+";
  6838. }
  6839. if (matchDiacritics) {
  6840. return p4 || p5;
  6841. }
  6842. if (p4) {
  6843. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  6844. }
  6845. if (hasDiacritics) {
  6846. isUnicode = true;
  6847. return `${p5}\\p{M}*`;
  6848. }
  6849. return p5;
  6850. });
  6851. const trailingSpaces = "[ ]*";
  6852. if (query.endsWith(trailingSpaces)) {
  6853. query = query.slice(0, query.length - trailingSpaces.length);
  6854. }
  6855. if (matchDiacritics) {
  6856. if (hasDiacritics) {
  6857. DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
  6858. isUnicode = true;
  6859. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  6860. }
  6861. }
  6862. return [isUnicode, query];
  6863. }
  6864. #calculateMatch(pageIndex) {
  6865. let query = this.#query;
  6866. if (query.length === 0) {
  6867. return;
  6868. }
  6869. const {
  6870. caseSensitive,
  6871. entireWord
  6872. } = this.#state;
  6873. const pageContent = this._pageContents[pageIndex];
  6874. const hasDiacritics = this._hasDiacritics[pageIndex];
  6875. let isUnicode = false;
  6876. if (typeof query === "string") {
  6877. [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
  6878. } else {
  6879. query = query.sort().reverse().map(q => {
  6880. const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
  6881. isUnicode ||= isUnicodePart;
  6882. return `(${queryPart})`;
  6883. }).join("|");
  6884. }
  6885. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  6886. query = query ? new RegExp(query, flags) : null;
  6887. this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
  6888. if (this.#state.highlightAll) {
  6889. this.#updatePage(pageIndex);
  6890. }
  6891. if (this._resumePageIdx === pageIndex) {
  6892. this._resumePageIdx = null;
  6893. this.#nextPageMatch();
  6894. }
  6895. const pageMatchesCount = this._pageMatches[pageIndex].length;
  6896. this._matchesCountTotal += pageMatchesCount;
  6897. if (this.#updateMatchesCountOnProgress) {
  6898. if (pageMatchesCount > 0) {
  6899. this.#updateUIResultsCount();
  6900. }
  6901. } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
  6902. this.#updateUIResultsCount();
  6903. }
  6904. }
  6905. #extractText() {
  6906. if (this._extractTextPromises.length > 0) {
  6907. return;
  6908. }
  6909. let deferred = Promise.resolve();
  6910. const textOptions = {
  6911. disableNormalization: true
  6912. };
  6913. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6914. const {
  6915. promise,
  6916. resolve
  6917. } = Promise.withResolvers();
  6918. this._extractTextPromises[i] = promise;
  6919. deferred = deferred.then(() => {
  6920. return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => {
  6921. const strBuf = [];
  6922. for (const textItem of textContent.items) {
  6923. strBuf.push(textItem.str);
  6924. if (textItem.hasEOL) {
  6925. strBuf.push("\n");
  6926. }
  6927. }
  6928. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  6929. resolve();
  6930. }, reason => {
  6931. console.error(`Unable to get text content for page ${i + 1}`, reason);
  6932. this._pageContents[i] = "";
  6933. this._pageDiffs[i] = null;
  6934. this._hasDiacritics[i] = false;
  6935. resolve();
  6936. });
  6937. });
  6938. }
  6939. }
  6940. #updatePage(index) {
  6941. if (this._scrollMatches && this._selected.pageIdx === index) {
  6942. this._linkService.page = index + 1;
  6943. }
  6944. this._eventBus.dispatch("updatetextlayermatches", {
  6945. source: this,
  6946. pageIndex: index
  6947. });
  6948. }
  6949. #updateAllPages() {
  6950. this._eventBus.dispatch("updatetextlayermatches", {
  6951. source: this,
  6952. pageIndex: -1
  6953. });
  6954. }
  6955. #nextMatch() {
  6956. const previous = this.#state.findPrevious;
  6957. const currentPageIndex = this._linkService.page - 1;
  6958. const numPages = this._linkService.pagesCount;
  6959. this._highlightMatches = true;
  6960. if (this._dirtyMatch) {
  6961. this._dirtyMatch = false;
  6962. this._selected.pageIdx = this._selected.matchIdx = -1;
  6963. this._offset.pageIdx = currentPageIndex;
  6964. this._offset.matchIdx = null;
  6965. this._offset.wrapped = false;
  6966. this._resumePageIdx = null;
  6967. this._pageMatches.length = 0;
  6968. this._pageMatchesLength.length = 0;
  6969. this.#visitedPagesCount = 0;
  6970. this._matchesCountTotal = 0;
  6971. this.#updateAllPages();
  6972. for (let i = 0; i < numPages; i++) {
  6973. if (this._pendingFindMatches.has(i)) {
  6974. continue;
  6975. }
  6976. this._pendingFindMatches.add(i);
  6977. this._extractTextPromises[i].then(() => {
  6978. this._pendingFindMatches.delete(i);
  6979. this.#calculateMatch(i);
  6980. });
  6981. }
  6982. }
  6983. const query = this.#query;
  6984. if (query.length === 0) {
  6985. this.#updateUIState(FindState.FOUND);
  6986. return;
  6987. }
  6988. if (this._resumePageIdx) {
  6989. return;
  6990. }
  6991. const offset = this._offset;
  6992. this._pagesToSearch = numPages;
  6993. if (offset.matchIdx !== null) {
  6994. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  6995. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6996. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6997. this.#updateMatch(true);
  6998. return;
  6999. }
  7000. this.#advanceOffsetPage(previous);
  7001. }
  7002. this.#nextPageMatch();
  7003. }
  7004. #matchesReady(matches) {
  7005. const offset = this._offset;
  7006. const numMatches = matches.length;
  7007. const previous = this.#state.findPrevious;
  7008. if (numMatches) {
  7009. offset.matchIdx = previous ? numMatches - 1 : 0;
  7010. this.#updateMatch(true);
  7011. return true;
  7012. }
  7013. this.#advanceOffsetPage(previous);
  7014. if (offset.wrapped) {
  7015. offset.matchIdx = null;
  7016. if (this._pagesToSearch < 0) {
  7017. this.#updateMatch(false);
  7018. return true;
  7019. }
  7020. }
  7021. return false;
  7022. }
  7023. #nextPageMatch() {
  7024. if (this._resumePageIdx !== null) {
  7025. console.error("There can only be one pending page.");
  7026. }
  7027. let matches = null;
  7028. do {
  7029. const pageIdx = this._offset.pageIdx;
  7030. matches = this._pageMatches[pageIdx];
  7031. if (!matches) {
  7032. this._resumePageIdx = pageIdx;
  7033. break;
  7034. }
  7035. } while (!this.#matchesReady(matches));
  7036. }
  7037. #advanceOffsetPage(previous) {
  7038. const offset = this._offset;
  7039. const numPages = this._linkService.pagesCount;
  7040. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7041. offset.matchIdx = null;
  7042. this._pagesToSearch--;
  7043. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7044. offset.pageIdx = previous ? numPages - 1 : 0;
  7045. offset.wrapped = true;
  7046. }
  7047. }
  7048. #updateMatch(found = false) {
  7049. let state = FindState.NOT_FOUND;
  7050. const wrapped = this._offset.wrapped;
  7051. this._offset.wrapped = false;
  7052. if (found) {
  7053. const previousPage = this._selected.pageIdx;
  7054. this._selected.pageIdx = this._offset.pageIdx;
  7055. this._selected.matchIdx = this._offset.matchIdx;
  7056. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7057. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  7058. this.#updatePage(previousPage);
  7059. }
  7060. }
  7061. this.#updateUIState(state, this.#state.findPrevious);
  7062. if (this._selected.pageIdx !== -1) {
  7063. this._scrollMatches = true;
  7064. this.#updatePage(this._selected.pageIdx);
  7065. }
  7066. }
  7067. #onFindBarClose(evt) {
  7068. const pdfDocument = this._pdfDocument;
  7069. this._firstPageCapability.promise.then(() => {
  7070. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7071. return;
  7072. }
  7073. if (this._findTimeout) {
  7074. clearTimeout(this._findTimeout);
  7075. this._findTimeout = null;
  7076. }
  7077. if (this._resumePageIdx) {
  7078. this._resumePageIdx = null;
  7079. this._dirtyMatch = true;
  7080. }
  7081. this.#updateUIState(FindState.FOUND);
  7082. this._highlightMatches = false;
  7083. this.#updateAllPages();
  7084. });
  7085. }
  7086. #requestMatchesCount() {
  7087. const {
  7088. pageIdx,
  7089. matchIdx
  7090. } = this._selected;
  7091. let current = 0,
  7092. total = this._matchesCountTotal;
  7093. if (matchIdx !== -1) {
  7094. for (let i = 0; i < pageIdx; i++) {
  7095. current += this._pageMatches[i]?.length || 0;
  7096. }
  7097. current += matchIdx + 1;
  7098. }
  7099. if (current < 1 || current > total) {
  7100. current = total = 0;
  7101. }
  7102. return {
  7103. current,
  7104. total
  7105. };
  7106. }
  7107. #updateUIResultsCount() {
  7108. this._eventBus.dispatch("updatefindmatchescount", {
  7109. source: this,
  7110. matchesCount: this.#requestMatchesCount()
  7111. });
  7112. }
  7113. #updateUIState(state, previous = false) {
  7114. if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
  7115. return;
  7116. }
  7117. this._eventBus.dispatch("updatefindcontrolstate", {
  7118. source: this,
  7119. state,
  7120. previous,
  7121. matchesCount: this.#requestMatchesCount(),
  7122. rawQuery: this.#state?.query ?? null
  7123. });
  7124. }
  7125. }
  7126. /***/ }),
  7127. /***/ 8543:
  7128. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  7129. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7130. /* harmony export */ PDFHistory: () => (/* binding */ PDFHistory)
  7131. /* harmony export */ });
  7132. /* unused harmony exports isDestArraysEqual, isDestHashesEqual */
  7133. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  7134. /* harmony import */ var _event_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5656);
  7135. const HASH_CHANGE_TIMEOUT = 1000;
  7136. const POSITION_UPDATED_THRESHOLD = 50;
  7137. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  7138. function getCurrentHash() {
  7139. return document.location.hash;
  7140. }
  7141. class PDFHistory {
  7142. #eventAbortController = null;
  7143. constructor({
  7144. linkService,
  7145. eventBus
  7146. }) {
  7147. this.linkService = linkService;
  7148. this.eventBus = eventBus;
  7149. this._initialized = false;
  7150. this._fingerprint = "";
  7151. this.reset();
  7152. this.eventBus._on("pagesinit", () => {
  7153. this._isPagesLoaded = false;
  7154. this.eventBus._on("pagesloaded", evt => {
  7155. this._isPagesLoaded = !!evt.pagesCount;
  7156. }, {
  7157. once: true
  7158. });
  7159. });
  7160. }
  7161. initialize({
  7162. fingerprint,
  7163. resetHistory = false,
  7164. updateUrl = false
  7165. }) {
  7166. if (!fingerprint || typeof fingerprint !== "string") {
  7167. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  7168. return;
  7169. }
  7170. if (this._initialized) {
  7171. this.reset();
  7172. }
  7173. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  7174. this._fingerprint = fingerprint;
  7175. this._updateUrl = updateUrl === true;
  7176. this._initialized = true;
  7177. this.#bindEvents();
  7178. const state = window.history.state;
  7179. this._popStateInProgress = false;
  7180. this._blockHashChange = 0;
  7181. this._currentHash = getCurrentHash();
  7182. this._numPositionUpdates = 0;
  7183. this._uid = this._maxUid = 0;
  7184. this._destination = null;
  7185. this._position = null;
  7186. if (!this.#isValidState(state, true) || resetHistory) {
  7187. const {
  7188. hash,
  7189. page,
  7190. rotation
  7191. } = this.#parseCurrentHash(true);
  7192. if (!hash || reInitialized || resetHistory) {
  7193. this.#pushOrReplaceState(null, true);
  7194. return;
  7195. }
  7196. this.#pushOrReplaceState({
  7197. hash,
  7198. page,
  7199. rotation
  7200. }, true);
  7201. return;
  7202. }
  7203. const destination = state.destination;
  7204. this.#updateInternalState(destination, state.uid, true);
  7205. if (destination.rotation !== undefined) {
  7206. this._initialRotation = destination.rotation;
  7207. }
  7208. if (destination.dest) {
  7209. this._initialBookmark = JSON.stringify(destination.dest);
  7210. this._destination.page = null;
  7211. } else if (destination.hash) {
  7212. this._initialBookmark = destination.hash;
  7213. } else if (destination.page) {
  7214. this._initialBookmark = `page=${destination.page}`;
  7215. }
  7216. }
  7217. reset() {
  7218. if (this._initialized) {
  7219. this.#pageHide();
  7220. this._initialized = false;
  7221. this.#unbindEvents();
  7222. }
  7223. if (this._updateViewareaTimeout) {
  7224. clearTimeout(this._updateViewareaTimeout);
  7225. this._updateViewareaTimeout = null;
  7226. }
  7227. this._initialBookmark = null;
  7228. this._initialRotation = null;
  7229. }
  7230. push({
  7231. namedDest = null,
  7232. explicitDest,
  7233. pageNumber
  7234. }) {
  7235. if (!this._initialized) {
  7236. return;
  7237. }
  7238. if (namedDest && typeof namedDest !== "string") {
  7239. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  7240. return;
  7241. } else if (!Array.isArray(explicitDest)) {
  7242. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  7243. return;
  7244. } else if (!this.#isValidPage(pageNumber)) {
  7245. if (pageNumber !== null || this._destination) {
  7246. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  7247. return;
  7248. }
  7249. }
  7250. const hash = namedDest || JSON.stringify(explicitDest);
  7251. if (!hash) {
  7252. return;
  7253. }
  7254. let forceReplace = false;
  7255. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  7256. if (this._destination.page) {
  7257. return;
  7258. }
  7259. forceReplace = true;
  7260. }
  7261. if (this._popStateInProgress && !forceReplace) {
  7262. return;
  7263. }
  7264. this.#pushOrReplaceState({
  7265. dest: explicitDest,
  7266. hash,
  7267. page: pageNumber,
  7268. rotation: this.linkService.rotation
  7269. }, forceReplace);
  7270. if (!this._popStateInProgress) {
  7271. this._popStateInProgress = true;
  7272. Promise.resolve().then(() => {
  7273. this._popStateInProgress = false;
  7274. });
  7275. }
  7276. }
  7277. pushPage(pageNumber) {
  7278. if (!this._initialized) {
  7279. return;
  7280. }
  7281. if (!this.#isValidPage(pageNumber)) {
  7282. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  7283. return;
  7284. }
  7285. if (this._destination?.page === pageNumber) {
  7286. return;
  7287. }
  7288. if (this._popStateInProgress) {
  7289. return;
  7290. }
  7291. this.#pushOrReplaceState({
  7292. dest: null,
  7293. hash: `page=${pageNumber}`,
  7294. page: pageNumber,
  7295. rotation: this.linkService.rotation
  7296. });
  7297. if (!this._popStateInProgress) {
  7298. this._popStateInProgress = true;
  7299. Promise.resolve().then(() => {
  7300. this._popStateInProgress = false;
  7301. });
  7302. }
  7303. }
  7304. pushCurrentPosition() {
  7305. if (!this._initialized || this._popStateInProgress) {
  7306. return;
  7307. }
  7308. this.#tryPushCurrentPosition();
  7309. }
  7310. back() {
  7311. if (!this._initialized || this._popStateInProgress) {
  7312. return;
  7313. }
  7314. const state = window.history.state;
  7315. if (this.#isValidState(state) && state.uid > 0) {
  7316. window.history.back();
  7317. }
  7318. }
  7319. forward() {
  7320. if (!this._initialized || this._popStateInProgress) {
  7321. return;
  7322. }
  7323. const state = window.history.state;
  7324. if (this.#isValidState(state) && state.uid < this._maxUid) {
  7325. window.history.forward();
  7326. }
  7327. }
  7328. get popStateInProgress() {
  7329. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7330. }
  7331. get initialBookmark() {
  7332. return this._initialized ? this._initialBookmark : null;
  7333. }
  7334. get initialRotation() {
  7335. return this._initialized ? this._initialRotation : null;
  7336. }
  7337. #pushOrReplaceState(destination, forceReplace = false) {
  7338. const shouldReplace = forceReplace || !this._destination;
  7339. const newState = {
  7340. fingerprint: this._fingerprint,
  7341. uid: shouldReplace ? this._uid : this._uid + 1,
  7342. destination
  7343. };
  7344. this.#updateInternalState(destination, newState.uid);
  7345. let newUrl;
  7346. if (this._updateUrl && destination?.hash) {
  7347. const baseUrl = document.location.href.split("#", 1)[0];
  7348. if (!baseUrl.startsWith("file://")) {
  7349. newUrl = `${baseUrl}#${destination.hash}`;
  7350. }
  7351. }
  7352. if (shouldReplace) {
  7353. window.history.replaceState(newState, "", newUrl);
  7354. } else {
  7355. window.history.pushState(newState, "", newUrl);
  7356. }
  7357. }
  7358. #tryPushCurrentPosition(temporary = false) {
  7359. if (!this._position) {
  7360. return;
  7361. }
  7362. let position = this._position;
  7363. if (temporary) {
  7364. position = Object.assign(Object.create(null), this._position);
  7365. position.temporary = true;
  7366. }
  7367. if (!this._destination) {
  7368. this.#pushOrReplaceState(position);
  7369. return;
  7370. }
  7371. if (this._destination.temporary) {
  7372. this.#pushOrReplaceState(position, true);
  7373. return;
  7374. }
  7375. if (this._destination.hash === position.hash) {
  7376. return;
  7377. }
  7378. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7379. return;
  7380. }
  7381. let forceReplace = false;
  7382. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7383. if (this._destination.dest !== undefined || !this._destination.first) {
  7384. return;
  7385. }
  7386. forceReplace = true;
  7387. }
  7388. this.#pushOrReplaceState(position, forceReplace);
  7389. }
  7390. #isValidPage(val) {
  7391. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  7392. }
  7393. #isValidState(state, checkReload = false) {
  7394. if (!state) {
  7395. return false;
  7396. }
  7397. if (state.fingerprint !== this._fingerprint) {
  7398. if (checkReload) {
  7399. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7400. return false;
  7401. }
  7402. const [perfEntry] = performance.getEntriesByType("navigation");
  7403. if (perfEntry?.type !== "reload") {
  7404. return false;
  7405. }
  7406. } else {
  7407. return false;
  7408. }
  7409. }
  7410. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7411. return false;
  7412. }
  7413. if (state.destination === null || typeof state.destination !== "object") {
  7414. return false;
  7415. }
  7416. return true;
  7417. }
  7418. #updateInternalState(destination, uid, removeTemporary = false) {
  7419. if (this._updateViewareaTimeout) {
  7420. clearTimeout(this._updateViewareaTimeout);
  7421. this._updateViewareaTimeout = null;
  7422. }
  7423. if (removeTemporary && destination?.temporary) {
  7424. delete destination.temporary;
  7425. }
  7426. this._destination = destination;
  7427. this._uid = uid;
  7428. this._maxUid = Math.max(this._maxUid, uid);
  7429. this._numPositionUpdates = 0;
  7430. }
  7431. #parseCurrentHash(checkNameddest = false) {
  7432. const hash = unescape(getCurrentHash()).substring(1);
  7433. const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
  7434. const nameddest = params.get("nameddest") || "";
  7435. let page = params.get("page") | 0;
  7436. if (!this.#isValidPage(page) || checkNameddest && nameddest.length > 0) {
  7437. page = null;
  7438. }
  7439. return {
  7440. hash,
  7441. page,
  7442. rotation: this.linkService.rotation
  7443. };
  7444. }
  7445. #updateViewarea({
  7446. location
  7447. }) {
  7448. if (this._updateViewareaTimeout) {
  7449. clearTimeout(this._updateViewareaTimeout);
  7450. this._updateViewareaTimeout = null;
  7451. }
  7452. this._position = {
  7453. hash: location.pdfOpenParams.substring(1),
  7454. page: this.linkService.page,
  7455. first: location.pageNumber,
  7456. rotation: location.rotation
  7457. };
  7458. if (this._popStateInProgress) {
  7459. return;
  7460. }
  7461. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7462. this._numPositionUpdates++;
  7463. }
  7464. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7465. this._updateViewareaTimeout = setTimeout(() => {
  7466. if (!this._popStateInProgress) {
  7467. this.#tryPushCurrentPosition(true);
  7468. }
  7469. this._updateViewareaTimeout = null;
  7470. }, UPDATE_VIEWAREA_TIMEOUT);
  7471. }
  7472. }
  7473. #popState({
  7474. state
  7475. }) {
  7476. const newHash = getCurrentHash(),
  7477. hashChanged = this._currentHash !== newHash;
  7478. this._currentHash = newHash;
  7479. if (!state) {
  7480. this._uid++;
  7481. const {
  7482. hash,
  7483. page,
  7484. rotation
  7485. } = this.#parseCurrentHash();
  7486. this.#pushOrReplaceState({
  7487. hash,
  7488. page,
  7489. rotation
  7490. }, true);
  7491. return;
  7492. }
  7493. if (!this.#isValidState(state)) {
  7494. return;
  7495. }
  7496. this._popStateInProgress = true;
  7497. if (hashChanged) {
  7498. this._blockHashChange++;
  7499. (0,_event_utils_js__WEBPACK_IMPORTED_MODULE_1__.waitOnEventOrTimeout)({
  7500. target: window,
  7501. name: "hashchange",
  7502. delay: HASH_CHANGE_TIMEOUT
  7503. }).then(() => {
  7504. this._blockHashChange--;
  7505. });
  7506. }
  7507. const destination = state.destination;
  7508. this.#updateInternalState(destination, state.uid, true);
  7509. if ((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(destination.rotation)) {
  7510. this.linkService.rotation = destination.rotation;
  7511. }
  7512. if (destination.dest) {
  7513. this.linkService.goToDestination(destination.dest);
  7514. } else if (destination.hash) {
  7515. this.linkService.setHash(destination.hash);
  7516. } else if (destination.page) {
  7517. this.linkService.page = destination.page;
  7518. }
  7519. Promise.resolve().then(() => {
  7520. this._popStateInProgress = false;
  7521. });
  7522. }
  7523. #pageHide() {
  7524. if (!this._destination || this._destination.temporary) {
  7525. this.#tryPushCurrentPosition();
  7526. }
  7527. }
  7528. #bindEvents() {
  7529. if (this.#eventAbortController) {
  7530. return;
  7531. }
  7532. this.#eventAbortController = new AbortController();
  7533. const {
  7534. signal
  7535. } = this.#eventAbortController;
  7536. this.eventBus._on("updateviewarea", this.#updateViewarea.bind(this), {
  7537. signal
  7538. });
  7539. window.addEventListener("popstate", this.#popState.bind(this), {
  7540. signal
  7541. });
  7542. window.addEventListener("pagehide", this.#pageHide.bind(this), {
  7543. signal
  7544. });
  7545. }
  7546. #unbindEvents() {
  7547. this.#eventAbortController?.abort();
  7548. this.#eventAbortController = null;
  7549. }
  7550. }
  7551. function isDestHashesEqual(destHash, pushHash) {
  7552. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7553. return false;
  7554. }
  7555. if (destHash === pushHash) {
  7556. return true;
  7557. }
  7558. const nameddest = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(destHash).get("nameddest");
  7559. if (nameddest === pushHash) {
  7560. return true;
  7561. }
  7562. return false;
  7563. }
  7564. function isDestArraysEqual(firstDest, secondDest) {
  7565. function isEntryEqual(first, second) {
  7566. if (typeof first !== typeof second) {
  7567. return false;
  7568. }
  7569. if (Array.isArray(first) || Array.isArray(second)) {
  7570. return false;
  7571. }
  7572. if (first !== null && typeof first === "object" && second !== null) {
  7573. if (Object.keys(first).length !== Object.keys(second).length) {
  7574. return false;
  7575. }
  7576. for (const key in first) {
  7577. if (!isEntryEqual(first[key], second[key])) {
  7578. return false;
  7579. }
  7580. }
  7581. return true;
  7582. }
  7583. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7584. }
  7585. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7586. return false;
  7587. }
  7588. if (firstDest.length !== secondDest.length) {
  7589. return false;
  7590. }
  7591. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  7592. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7593. return false;
  7594. }
  7595. }
  7596. return true;
  7597. }
  7598. /***/ }),
  7599. /***/ 4275:
  7600. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  7601. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7602. /* harmony export */ PDFLayerViewer: () => (/* binding */ PDFLayerViewer)
  7603. /* harmony export */ });
  7604. /* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961);
  7605. class PDFLayerViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
  7606. constructor(options) {
  7607. super(options);
  7608. this.eventBus._on("optionalcontentconfigchanged", evt => {
  7609. this.#updateLayers(evt.promise);
  7610. });
  7611. this.eventBus._on("resetlayers", () => {
  7612. this.#updateLayers();
  7613. });
  7614. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  7615. }
  7616. reset() {
  7617. super.reset();
  7618. this._optionalContentConfig = null;
  7619. this._optionalContentHash = null;
  7620. }
  7621. _dispatchEvent(layersCount) {
  7622. this.eventBus.dispatch("layersloaded", {
  7623. source: this,
  7624. layersCount
  7625. });
  7626. }
  7627. _bindLink(element, {
  7628. groupId,
  7629. input
  7630. }) {
  7631. const setVisibility = () => {
  7632. this._optionalContentConfig.setVisibility(groupId, input.checked);
  7633. this._optionalContentHash = this._optionalContentConfig.getHash();
  7634. this.eventBus.dispatch("optionalcontentconfig", {
  7635. source: this,
  7636. promise: Promise.resolve(this._optionalContentConfig)
  7637. });
  7638. };
  7639. element.onclick = evt => {
  7640. if (evt.target === input) {
  7641. setVisibility();
  7642. return true;
  7643. } else if (evt.target !== element) {
  7644. return true;
  7645. }
  7646. input.checked = !input.checked;
  7647. setVisibility();
  7648. return false;
  7649. };
  7650. }
  7651. async _setNestedName(element, {
  7652. name = null
  7653. }) {
  7654. if (typeof name === "string") {
  7655. element.textContent = this._normalizeTextContent(name);
  7656. return;
  7657. }
  7658. element.textContent = await this._l10n.get("pdfjs-additional-layers");
  7659. element.style.fontStyle = "italic";
  7660. }
  7661. _addToggleButton(div, {
  7662. name = null
  7663. }) {
  7664. super._addToggleButton(div, name === null);
  7665. }
  7666. _toggleAllTreeItems() {
  7667. if (!this._optionalContentConfig) {
  7668. return;
  7669. }
  7670. super._toggleAllTreeItems();
  7671. }
  7672. render({
  7673. optionalContentConfig,
  7674. pdfDocument
  7675. }) {
  7676. if (this._optionalContentConfig) {
  7677. this.reset();
  7678. }
  7679. this._optionalContentConfig = optionalContentConfig || null;
  7680. this._pdfDocument = pdfDocument || null;
  7681. const groups = optionalContentConfig?.getOrder();
  7682. if (!groups) {
  7683. this._dispatchEvent(0);
  7684. return;
  7685. }
  7686. this._optionalContentHash = optionalContentConfig.getHash();
  7687. const fragment = document.createDocumentFragment(),
  7688. queue = [{
  7689. parent: fragment,
  7690. groups
  7691. }];
  7692. let layersCount = 0,
  7693. hasAnyNesting = false;
  7694. while (queue.length > 0) {
  7695. const levelData = queue.shift();
  7696. for (const groupId of levelData.groups) {
  7697. const div = document.createElement("div");
  7698. div.className = "treeItem";
  7699. const element = document.createElement("a");
  7700. div.append(element);
  7701. if (typeof groupId === "object") {
  7702. hasAnyNesting = true;
  7703. this._addToggleButton(div, groupId);
  7704. this._setNestedName(element, groupId);
  7705. const itemsDiv = document.createElement("div");
  7706. itemsDiv.className = "treeItems";
  7707. div.append(itemsDiv);
  7708. queue.push({
  7709. parent: itemsDiv,
  7710. groups: groupId.order
  7711. });
  7712. } else {
  7713. const group = optionalContentConfig.getGroup(groupId);
  7714. const input = document.createElement("input");
  7715. this._bindLink(element, {
  7716. groupId,
  7717. input
  7718. });
  7719. input.type = "checkbox";
  7720. input.checked = group.visible;
  7721. const label = document.createElement("label");
  7722. label.textContent = this._normalizeTextContent(group.name);
  7723. label.append(input);
  7724. element.append(label);
  7725. layersCount++;
  7726. }
  7727. levelData.parent.append(div);
  7728. }
  7729. }
  7730. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7731. }
  7732. async #updateLayers(promise = null) {
  7733. if (!this._optionalContentConfig) {
  7734. return;
  7735. }
  7736. const pdfDocument = this._pdfDocument;
  7737. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig({
  7738. intent: "display"
  7739. }));
  7740. if (pdfDocument !== this._pdfDocument) {
  7741. return;
  7742. }
  7743. if (promise) {
  7744. if (optionalContentConfig.getHash() === this._optionalContentHash) {
  7745. return;
  7746. }
  7747. } else {
  7748. this.eventBus.dispatch("optionalcontentconfig", {
  7749. source: this,
  7750. promise: Promise.resolve(optionalContentConfig)
  7751. });
  7752. }
  7753. this.render({
  7754. optionalContentConfig,
  7755. pdfDocument: this._pdfDocument
  7756. });
  7757. }
  7758. }
  7759. /***/ }),
  7760. /***/ 787:
  7761. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  7762. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7763. /* harmony export */ LinkTarget: () => (/* binding */ LinkTarget),
  7764. /* harmony export */ PDFLinkService: () => (/* binding */ PDFLinkService),
  7765. /* harmony export */ SimpleLinkService: () => (/* binding */ SimpleLinkService)
  7766. /* harmony export */ });
  7767. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  7768. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  7769. const LinkTarget = {
  7770. NONE: 0,
  7771. SELF: 1,
  7772. BLANK: 2,
  7773. PARENT: 3,
  7774. TOP: 4
  7775. };
  7776. class PDFLinkService {
  7777. externalLinkEnabled = true;
  7778. constructor({
  7779. eventBus,
  7780. externalLinkTarget = null,
  7781. externalLinkRel = null,
  7782. ignoreDestinationZoom = false
  7783. } = {}) {
  7784. this.eventBus = eventBus;
  7785. this.externalLinkTarget = externalLinkTarget;
  7786. this.externalLinkRel = externalLinkRel;
  7787. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7788. this.baseUrl = null;
  7789. this.pdfDocument = null;
  7790. this.pdfViewer = null;
  7791. this.pdfHistory = null;
  7792. }
  7793. setDocument(pdfDocument, baseUrl = null) {
  7794. this.baseUrl = baseUrl;
  7795. this.pdfDocument = pdfDocument;
  7796. }
  7797. setViewer(pdfViewer) {
  7798. this.pdfViewer = pdfViewer;
  7799. }
  7800. setHistory(pdfHistory) {
  7801. this.pdfHistory = pdfHistory;
  7802. }
  7803. get pagesCount() {
  7804. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7805. }
  7806. get page() {
  7807. return this.pdfDocument ? this.pdfViewer.currentPageNumber : 1;
  7808. }
  7809. set page(value) {
  7810. if (this.pdfDocument) {
  7811. this.pdfViewer.currentPageNumber = value;
  7812. }
  7813. }
  7814. get rotation() {
  7815. return this.pdfDocument ? this.pdfViewer.pagesRotation : 0;
  7816. }
  7817. set rotation(value) {
  7818. if (this.pdfDocument) {
  7819. this.pdfViewer.pagesRotation = value;
  7820. }
  7821. }
  7822. get isInPresentationMode() {
  7823. return this.pdfDocument ? this.pdfViewer.isInPresentationMode : false;
  7824. }
  7825. async goToDestination(dest) {
  7826. if (!this.pdfDocument) {
  7827. return;
  7828. }
  7829. let namedDest, explicitDest, pageNumber;
  7830. if (typeof dest === "string") {
  7831. namedDest = dest;
  7832. explicitDest = await this.pdfDocument.getDestination(dest);
  7833. } else {
  7834. namedDest = null;
  7835. explicitDest = await dest;
  7836. }
  7837. if (!Array.isArray(explicitDest)) {
  7838. console.error(`goToDestination: "${explicitDest}" is not a valid destination array, for dest="${dest}".`);
  7839. return;
  7840. }
  7841. const [destRef] = explicitDest;
  7842. if (destRef && typeof destRef === "object") {
  7843. pageNumber = this.pdfDocument.cachedPageNumber(destRef);
  7844. if (!pageNumber) {
  7845. try {
  7846. pageNumber = (await this.pdfDocument.getPageIndex(destRef)) + 1;
  7847. } catch {
  7848. console.error(`goToDestination: "${destRef}" is not a valid page reference, for dest="${dest}".`);
  7849. return;
  7850. }
  7851. }
  7852. } else if (Number.isInteger(destRef)) {
  7853. pageNumber = destRef + 1;
  7854. }
  7855. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  7856. console.error(`goToDestination: "${pageNumber}" is not a valid page number, for dest="${dest}".`);
  7857. return;
  7858. }
  7859. if (this.pdfHistory) {
  7860. this.pdfHistory.pushCurrentPosition();
  7861. this.pdfHistory.push({
  7862. namedDest,
  7863. explicitDest,
  7864. pageNumber
  7865. });
  7866. }
  7867. this.pdfViewer.scrollPageIntoView({
  7868. pageNumber,
  7869. destArray: explicitDest,
  7870. ignoreDestinationZoom: this._ignoreDestinationZoom
  7871. });
  7872. }
  7873. goToPage(val) {
  7874. if (!this.pdfDocument) {
  7875. return;
  7876. }
  7877. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  7878. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7879. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  7880. return;
  7881. }
  7882. if (this.pdfHistory) {
  7883. this.pdfHistory.pushCurrentPosition();
  7884. this.pdfHistory.pushPage(pageNumber);
  7885. }
  7886. this.pdfViewer.scrollPageIntoView({
  7887. pageNumber
  7888. });
  7889. }
  7890. addLinkAttributes(link, url, newWindow = false) {
  7891. if (!url || typeof url !== "string") {
  7892. throw new Error('A valid "url" parameter must provided.');
  7893. }
  7894. const target = newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  7895. rel = this.externalLinkRel;
  7896. if (this.externalLinkEnabled) {
  7897. link.href = link.title = url;
  7898. } else {
  7899. link.href = "";
  7900. link.title = `Disabled: ${url}`;
  7901. link.onclick = () => false;
  7902. }
  7903. let targetStr = "";
  7904. switch (target) {
  7905. case LinkTarget.NONE:
  7906. break;
  7907. case LinkTarget.SELF:
  7908. targetStr = "_self";
  7909. break;
  7910. case LinkTarget.BLANK:
  7911. targetStr = "_blank";
  7912. break;
  7913. case LinkTarget.PARENT:
  7914. targetStr = "_parent";
  7915. break;
  7916. case LinkTarget.TOP:
  7917. targetStr = "_top";
  7918. break;
  7919. }
  7920. link.target = targetStr;
  7921. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  7922. }
  7923. getDestinationHash(dest) {
  7924. if (typeof dest === "string") {
  7925. if (dest.length > 0) {
  7926. return this.getAnchorUrl("#" + escape(dest));
  7927. }
  7928. } else if (Array.isArray(dest)) {
  7929. const str = JSON.stringify(dest);
  7930. if (str.length > 0) {
  7931. return this.getAnchorUrl("#" + escape(str));
  7932. }
  7933. }
  7934. return this.getAnchorUrl("");
  7935. }
  7936. getAnchorUrl(anchor) {
  7937. return this.baseUrl ? this.baseUrl + anchor : anchor;
  7938. }
  7939. setHash(hash) {
  7940. if (!this.pdfDocument) {
  7941. return;
  7942. }
  7943. let pageNumber, dest;
  7944. if (hash.includes("=")) {
  7945. const params = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.parseQueryString)(hash);
  7946. if (params.has("search")) {
  7947. const query = params.get("search").replaceAll('"', ""),
  7948. phrase = params.get("phrase") === "true";
  7949. this.eventBus.dispatch("findfromurlhash", {
  7950. source: this,
  7951. query: phrase ? query : query.match(/\S+/g)
  7952. });
  7953. }
  7954. if (params.has("page")) {
  7955. pageNumber = params.get("page") | 0 || 1;
  7956. }
  7957. if (params.has("zoom")) {
  7958. const zoomArgs = params.get("zoom").split(",");
  7959. const zoomArg = zoomArgs[0];
  7960. const zoomArgNumber = parseFloat(zoomArg);
  7961. if (!zoomArg.includes("Fit")) {
  7962. dest = [null, {
  7963. name: "XYZ"
  7964. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7965. } else if (zoomArg === "Fit" || zoomArg === "FitB") {
  7966. dest = [null, {
  7967. name: zoomArg
  7968. }];
  7969. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7970. dest = [null, {
  7971. name: zoomArg
  7972. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7973. } else if (zoomArg === "FitR") {
  7974. if (zoomArgs.length !== 5) {
  7975. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7976. } else {
  7977. dest = [null, {
  7978. name: zoomArg
  7979. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7980. }
  7981. } else {
  7982. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  7983. }
  7984. }
  7985. if (dest) {
  7986. this.pdfViewer.scrollPageIntoView({
  7987. pageNumber: pageNumber || this.page,
  7988. destArray: dest,
  7989. allowNegativeOffset: true
  7990. });
  7991. } else if (pageNumber) {
  7992. this.page = pageNumber;
  7993. }
  7994. if (params.has("pagemode")) {
  7995. this.eventBus.dispatch("pagemode", {
  7996. source: this,
  7997. mode: params.get("pagemode")
  7998. });
  7999. }
  8000. if (params.has("nameddest")) {
  8001. this.goToDestination(params.get("nameddest"));
  8002. }
  8003. return;
  8004. }
  8005. dest = unescape(hash);
  8006. try {
  8007. dest = JSON.parse(dest);
  8008. if (!Array.isArray(dest)) {
  8009. dest = dest.toString();
  8010. }
  8011. } catch {}
  8012. if (typeof dest === "string" || PDFLinkService.#isValidExplicitDest(dest)) {
  8013. this.goToDestination(dest);
  8014. return;
  8015. }
  8016. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  8017. }
  8018. executeNamedAction(action) {
  8019. if (!this.pdfDocument) {
  8020. return;
  8021. }
  8022. switch (action) {
  8023. case "GoBack":
  8024. this.pdfHistory?.back();
  8025. break;
  8026. case "GoForward":
  8027. this.pdfHistory?.forward();
  8028. break;
  8029. case "NextPage":
  8030. this.pdfViewer.nextPage();
  8031. break;
  8032. case "PrevPage":
  8033. this.pdfViewer.previousPage();
  8034. break;
  8035. case "LastPage":
  8036. this.page = this.pagesCount;
  8037. break;
  8038. case "FirstPage":
  8039. this.page = 1;
  8040. break;
  8041. default:
  8042. break;
  8043. }
  8044. this.eventBus.dispatch("namedaction", {
  8045. source: this,
  8046. action
  8047. });
  8048. }
  8049. async executeSetOCGState(action) {
  8050. if (!this.pdfDocument) {
  8051. return;
  8052. }
  8053. const pdfDocument = this.pdfDocument,
  8054. optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  8055. if (pdfDocument !== this.pdfDocument) {
  8056. return;
  8057. }
  8058. optionalContentConfig.setOCGState(action);
  8059. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  8060. }
  8061. static #isValidExplicitDest(dest) {
  8062. if (!Array.isArray(dest) || dest.length < 2) {
  8063. return false;
  8064. }
  8065. const [page, zoom, ...args] = dest;
  8066. if (!(typeof page === "object" && Number.isInteger(page?.num) && Number.isInteger(page?.gen)) && !Number.isInteger(page)) {
  8067. return false;
  8068. }
  8069. if (!(typeof zoom === "object" && typeof zoom?.name === "string")) {
  8070. return false;
  8071. }
  8072. let allowNull = true;
  8073. switch (zoom.name) {
  8074. case "XYZ":
  8075. if (args.length !== 3) {
  8076. return false;
  8077. }
  8078. break;
  8079. case "Fit":
  8080. case "FitB":
  8081. return args.length === 0;
  8082. case "FitH":
  8083. case "FitBH":
  8084. case "FitV":
  8085. case "FitBV":
  8086. if (args.length !== 1) {
  8087. return false;
  8088. }
  8089. break;
  8090. case "FitR":
  8091. if (args.length !== 4) {
  8092. return false;
  8093. }
  8094. allowNull = false;
  8095. break;
  8096. default:
  8097. return false;
  8098. }
  8099. for (const arg of args) {
  8100. if (!(typeof arg === "number" || allowNull && arg === null)) {
  8101. return false;
  8102. }
  8103. }
  8104. return true;
  8105. }
  8106. }
  8107. class SimpleLinkService extends PDFLinkService {
  8108. setDocument(pdfDocument, baseUrl = null) {}
  8109. }
  8110. /***/ }),
  8111. /***/ 5514:
  8112. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  8113. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8114. /* harmony export */ PDFOutlineViewer: () => (/* binding */ PDFOutlineViewer)
  8115. /* harmony export */ });
  8116. /* harmony import */ var _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961);
  8117. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  8118. class PDFOutlineViewer extends _base_tree_viewer_js__WEBPACK_IMPORTED_MODULE_0__.BaseTreeViewer {
  8119. constructor(options) {
  8120. super(options);
  8121. this.linkService = options.linkService;
  8122. this.downloadManager = options.downloadManager;
  8123. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  8124. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  8125. this.eventBus._on("pagechanging", evt => {
  8126. this._currentPageNumber = evt.pageNumber;
  8127. });
  8128. this.eventBus._on("pagesloaded", evt => {
  8129. this._isPagesLoaded = !!evt.pagesCount;
  8130. this._currentOutlineItemCapability?.resolve(this._isPagesLoaded);
  8131. });
  8132. this.eventBus._on("sidebarviewchanged", evt => {
  8133. this._sidebarView = evt.view;
  8134. });
  8135. }
  8136. reset() {
  8137. super.reset();
  8138. this._outline = null;
  8139. this._pageNumberToDestHashCapability = null;
  8140. this._currentPageNumber = 1;
  8141. this._isPagesLoaded = null;
  8142. this._currentOutlineItemCapability?.resolve(false);
  8143. this._currentOutlineItemCapability = null;
  8144. }
  8145. _dispatchEvent(outlineCount) {
  8146. this._currentOutlineItemCapability = Promise.withResolvers();
  8147. if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
  8148. this._currentOutlineItemCapability.resolve(false);
  8149. } else if (this._isPagesLoaded !== null) {
  8150. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8151. }
  8152. this.eventBus.dispatch("outlineloaded", {
  8153. source: this,
  8154. outlineCount,
  8155. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  8156. });
  8157. }
  8158. _bindLink(element, {
  8159. url,
  8160. newWindow,
  8161. action,
  8162. attachment,
  8163. dest,
  8164. setOCGState
  8165. }) {
  8166. const {
  8167. linkService
  8168. } = this;
  8169. if (url) {
  8170. linkService.addLinkAttributes(element, url, newWindow);
  8171. return;
  8172. }
  8173. if (action) {
  8174. element.href = linkService.getAnchorUrl("");
  8175. element.onclick = () => {
  8176. linkService.executeNamedAction(action);
  8177. return false;
  8178. };
  8179. return;
  8180. }
  8181. if (attachment) {
  8182. element.href = linkService.getAnchorUrl("");
  8183. element.onclick = () => {
  8184. this.downloadManager.openOrDownloadData(attachment.content, attachment.filename);
  8185. return false;
  8186. };
  8187. return;
  8188. }
  8189. if (setOCGState) {
  8190. element.href = linkService.getAnchorUrl("");
  8191. element.onclick = () => {
  8192. linkService.executeSetOCGState(setOCGState);
  8193. return false;
  8194. };
  8195. return;
  8196. }
  8197. element.href = linkService.getDestinationHash(dest);
  8198. element.onclick = evt => {
  8199. this._updateCurrentTreeItem(evt.target.parentNode);
  8200. if (dest) {
  8201. linkService.goToDestination(dest);
  8202. }
  8203. return false;
  8204. };
  8205. }
  8206. _setStyles(element, {
  8207. bold,
  8208. italic
  8209. }) {
  8210. if (bold) {
  8211. element.style.fontWeight = "bold";
  8212. }
  8213. if (italic) {
  8214. element.style.fontStyle = "italic";
  8215. }
  8216. }
  8217. _addToggleButton(div, {
  8218. count,
  8219. items
  8220. }) {
  8221. let hidden = false;
  8222. if (count < 0) {
  8223. let totalCount = items.length;
  8224. if (totalCount > 0) {
  8225. const queue = [...items];
  8226. while (queue.length > 0) {
  8227. const {
  8228. count: nestedCount,
  8229. items: nestedItems
  8230. } = queue.shift();
  8231. if (nestedCount > 0 && nestedItems.length > 0) {
  8232. totalCount += nestedItems.length;
  8233. queue.push(...nestedItems);
  8234. }
  8235. }
  8236. }
  8237. if (Math.abs(count) === totalCount) {
  8238. hidden = true;
  8239. }
  8240. }
  8241. super._addToggleButton(div, hidden);
  8242. }
  8243. _toggleAllTreeItems() {
  8244. if (!this._outline) {
  8245. return;
  8246. }
  8247. super._toggleAllTreeItems();
  8248. }
  8249. render({
  8250. outline,
  8251. pdfDocument
  8252. }) {
  8253. if (this._outline) {
  8254. this.reset();
  8255. }
  8256. this._outline = outline || null;
  8257. this._pdfDocument = pdfDocument || null;
  8258. if (!outline) {
  8259. this._dispatchEvent(0);
  8260. return;
  8261. }
  8262. const fragment = document.createDocumentFragment();
  8263. const queue = [{
  8264. parent: fragment,
  8265. items: outline
  8266. }];
  8267. let outlineCount = 0,
  8268. hasAnyNesting = false;
  8269. while (queue.length > 0) {
  8270. const levelData = queue.shift();
  8271. for (const item of levelData.items) {
  8272. const div = document.createElement("div");
  8273. div.className = "treeItem";
  8274. const element = document.createElement("a");
  8275. this._bindLink(element, item);
  8276. this._setStyles(element, item);
  8277. element.textContent = this._normalizeTextContent(item.title);
  8278. div.append(element);
  8279. if (item.items.length > 0) {
  8280. hasAnyNesting = true;
  8281. this._addToggleButton(div, item);
  8282. const itemsDiv = document.createElement("div");
  8283. itemsDiv.className = "treeItems";
  8284. div.append(itemsDiv);
  8285. queue.push({
  8286. parent: itemsDiv,
  8287. items: item.items
  8288. });
  8289. }
  8290. levelData.parent.append(div);
  8291. outlineCount++;
  8292. }
  8293. }
  8294. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8295. }
  8296. async _currentOutlineItem() {
  8297. if (!this._isPagesLoaded) {
  8298. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8299. }
  8300. if (!this._outline || !this._pdfDocument) {
  8301. return;
  8302. }
  8303. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  8304. if (!pageNumberToDestHash) {
  8305. return;
  8306. }
  8307. this._updateCurrentTreeItem(null);
  8308. if (this._sidebarView !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SidebarView.OUTLINE) {
  8309. return;
  8310. }
  8311. for (let i = this._currentPageNumber; i > 0; i--) {
  8312. const destHash = pageNumberToDestHash.get(i);
  8313. if (!destHash) {
  8314. continue;
  8315. }
  8316. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  8317. if (!linkElement) {
  8318. continue;
  8319. }
  8320. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8321. break;
  8322. }
  8323. }
  8324. async _getPageNumberToDestHash(pdfDocument) {
  8325. if (this._pageNumberToDestHashCapability) {
  8326. return this._pageNumberToDestHashCapability.promise;
  8327. }
  8328. this._pageNumberToDestHashCapability = Promise.withResolvers();
  8329. const pageNumberToDestHash = new Map(),
  8330. pageNumberNesting = new Map();
  8331. const queue = [{
  8332. nesting: 0,
  8333. items: this._outline
  8334. }];
  8335. while (queue.length > 0) {
  8336. const levelData = queue.shift(),
  8337. currentNesting = levelData.nesting;
  8338. for (const {
  8339. dest,
  8340. items
  8341. } of levelData.items) {
  8342. let explicitDest, pageNumber;
  8343. if (typeof dest === "string") {
  8344. explicitDest = await pdfDocument.getDestination(dest);
  8345. if (pdfDocument !== this._pdfDocument) {
  8346. return null;
  8347. }
  8348. } else {
  8349. explicitDest = dest;
  8350. }
  8351. if (Array.isArray(explicitDest)) {
  8352. const [destRef] = explicitDest;
  8353. if (destRef && typeof destRef === "object") {
  8354. pageNumber = pdfDocument.cachedPageNumber(destRef);
  8355. } else if (Number.isInteger(destRef)) {
  8356. pageNumber = destRef + 1;
  8357. }
  8358. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8359. const destHash = this.linkService.getDestinationHash(dest);
  8360. pageNumberToDestHash.set(pageNumber, destHash);
  8361. pageNumberNesting.set(pageNumber, currentNesting);
  8362. }
  8363. }
  8364. if (items.length > 0) {
  8365. queue.push({
  8366. nesting: currentNesting + 1,
  8367. items
  8368. });
  8369. }
  8370. }
  8371. }
  8372. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8373. return this._pageNumberToDestHashCapability.promise;
  8374. }
  8375. }
  8376. /***/ }),
  8377. /***/ 9966:
  8378. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  8379. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  8380. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8381. /* harmony export */ PDFPageView: () => (/* binding */ PDFPageView)
  8382. /* harmony export */ });
  8383. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  8384. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  8385. /* harmony import */ var _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(283);
  8386. /* harmony import */ var _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2707);
  8387. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9840);
  8388. /* harmony import */ var _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3088);
  8389. /* harmony import */ var web_null_l10n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(410);
  8390. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(787);
  8391. /* harmony import */ var _struct_tree_layer_builder_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6698);
  8392. /* harmony import */ var _text_accessibility_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5860);
  8393. /* harmony import */ var _text_highlighter_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(2027);
  8394. /* harmony import */ var _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(7765);
  8395. /* harmony import */ var _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2973);
  8396. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__, _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__, _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__, web_null_l10n__WEBPACK_IMPORTED_MODULE_6__, _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__]);
  8397. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__, _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__, _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__, web_null_l10n__WEBPACK_IMPORTED_MODULE_6__, _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  8398. const DEFAULT_LAYER_PROPERTIES = null;
  8399. const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]);
  8400. class PDFPageView {
  8401. #annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  8402. #hasRestrictedScaling = false;
  8403. #layerProperties = null;
  8404. #loadingId = null;
  8405. #previousRotation = null;
  8406. #renderError = null;
  8407. #renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
  8408. #textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  8409. #useThumbnailCanvas = {
  8410. directDrawing: true,
  8411. initialOptionalContent: true,
  8412. regularAnnotations: true
  8413. };
  8414. #viewportMap = new WeakMap();
  8415. #layers = [null, null, null, null];
  8416. constructor(options) {
  8417. const container = options.container;
  8418. const defaultViewport = options.defaultViewport;
  8419. this.id = options.id;
  8420. this.renderingId = "page" + this.id;
  8421. this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
  8422. this.pdfPage = null;
  8423. this.pageLabel = null;
  8424. this.rotation = 0;
  8425. this.scale = options.scale || _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
  8426. this.viewport = defaultViewport;
  8427. this.pdfPageRotate = defaultViewport.rotation;
  8428. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  8429. this.#textLayerMode = options.textLayerMode ?? _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  8430. this.#annotationMode = options.annotationMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  8431. this.imageResourcesPath = options.imageResourcesPath || "";
  8432. this.maxCanvasPixels = options.maxCanvasPixels ?? _app_options_js__WEBPACK_IMPORTED_MODULE_4__.AppOptions.get("maxCanvasPixels");
  8433. this.pageColors = options.pageColors || null;
  8434. this.eventBus = options.eventBus;
  8435. this.renderingQueue = options.renderingQueue;
  8436. this.l10n = options.l10n;
  8437. this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_6__.GenericL10n();
  8438. this.renderTask = null;
  8439. this.resume = null;
  8440. this._isStandalone = !this.renderingQueue?.hasViewer();
  8441. this._container = container;
  8442. this._annotationCanvasMap = null;
  8443. this.annotationLayer = null;
  8444. this.annotationEditorLayer = null;
  8445. this.textLayer = null;
  8446. this.zoomLayer = null;
  8447. this.xfaLayer = null;
  8448. this.structTreeLayer = null;
  8449. this.drawLayer = null;
  8450. const div = document.createElement("div");
  8451. div.className = "page";
  8452. div.setAttribute("data-page-number", this.id);
  8453. div.setAttribute("role", "region");
  8454. div.setAttribute("data-l10n-id", "pdfjs-page-landmark");
  8455. div.setAttribute("data-l10n-args", JSON.stringify({
  8456. page: this.id
  8457. }));
  8458. this.div = div;
  8459. this.#setDimensions();
  8460. container?.append(div);
  8461. if (this._isStandalone) {
  8462. container?.style.setProperty("--scale-factor", this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS);
  8463. const {
  8464. optionalContentConfigPromise
  8465. } = options;
  8466. if (optionalContentConfigPromise) {
  8467. optionalContentConfigPromise.then(optionalContentConfig => {
  8468. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  8469. return;
  8470. }
  8471. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  8472. });
  8473. }
  8474. if (!options.l10n) {
  8475. this.l10n.translate(this.div);
  8476. }
  8477. }
  8478. }
  8479. #addLayer(div, name) {
  8480. const pos = LAYERS_ORDER.get(name);
  8481. const oldDiv = this.#layers[pos];
  8482. this.#layers[pos] = div;
  8483. if (oldDiv) {
  8484. oldDiv.replaceWith(div);
  8485. return;
  8486. }
  8487. for (let i = pos - 1; i >= 0; i--) {
  8488. const layer = this.#layers[i];
  8489. if (layer) {
  8490. layer.after(div);
  8491. return;
  8492. }
  8493. }
  8494. this.div.prepend(div);
  8495. }
  8496. get renderingState() {
  8497. return this.#renderingState;
  8498. }
  8499. set renderingState(state) {
  8500. if (state === this.#renderingState) {
  8501. return;
  8502. }
  8503. this.#renderingState = state;
  8504. if (this.#loadingId) {
  8505. clearTimeout(this.#loadingId);
  8506. this.#loadingId = null;
  8507. }
  8508. switch (state) {
  8509. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED:
  8510. this.div.classList.remove("loading");
  8511. break;
  8512. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING:
  8513. this.div.classList.add("loadingIcon");
  8514. this.#loadingId = setTimeout(() => {
  8515. this.div.classList.add("loading");
  8516. this.#loadingId = null;
  8517. }, 0);
  8518. break;
  8519. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL:
  8520. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED:
  8521. this.div.classList.remove("loadingIcon", "loading");
  8522. break;
  8523. }
  8524. }
  8525. #setDimensions() {
  8526. const {
  8527. viewport
  8528. } = this;
  8529. if (this.pdfPage) {
  8530. if (this.#previousRotation === viewport.rotation) {
  8531. return;
  8532. }
  8533. this.#previousRotation = viewport.rotation;
  8534. }
  8535. (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.setLayerDimensions)(this.div, viewport, true, false);
  8536. }
  8537. setPdfPage(pdfPage) {
  8538. if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
  8539. this._container?.style.setProperty("--hcm-highlight-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
  8540. this._container?.style.setProperty("--hcm-highlight-selected-filter", pdfPage.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "Highlight"));
  8541. }
  8542. this.pdfPage = pdfPage;
  8543. this.pdfPageRotate = pdfPage.rotate;
  8544. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8545. this.viewport = pdfPage.getViewport({
  8546. scale: this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS,
  8547. rotation: totalRotation
  8548. });
  8549. this.#setDimensions();
  8550. this.reset();
  8551. }
  8552. destroy() {
  8553. this.reset();
  8554. this.pdfPage?.cleanup();
  8555. }
  8556. get _textHighlighter() {
  8557. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_textHighlighter", new _text_highlighter_js__WEBPACK_IMPORTED_MODULE_12__.TextHighlighter({
  8558. pageIndex: this.id - 1,
  8559. eventBus: this.eventBus,
  8560. findController: this.#layerProperties.findController
  8561. }));
  8562. }
  8563. async #renderAnnotationLayer() {
  8564. let error = null;
  8565. try {
  8566. await this.annotationLayer.render(this.viewport, "display");
  8567. } catch (ex) {
  8568. console.error(`#renderAnnotationLayer: "${ex}".`);
  8569. error = ex;
  8570. } finally {
  8571. this.eventBus.dispatch("annotationlayerrendered", {
  8572. source: this,
  8573. pageNumber: this.id,
  8574. error
  8575. });
  8576. }
  8577. }
  8578. async #renderAnnotationEditorLayer() {
  8579. let error = null;
  8580. try {
  8581. await this.annotationEditorLayer.render(this.viewport, "display");
  8582. } catch (ex) {
  8583. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  8584. error = ex;
  8585. } finally {
  8586. this.eventBus.dispatch("annotationeditorlayerrendered", {
  8587. source: this,
  8588. pageNumber: this.id,
  8589. error
  8590. });
  8591. // [Custom] annotationLayer有时候会重建,所以多一层postMesseage保证朦层渲染
  8592. window.parent.postMessage({pageNum: this.id - 1}, '*');
  8593. }
  8594. }
  8595. async #renderDrawLayer() {
  8596. try {
  8597. await this.drawLayer.render("display");
  8598. } catch (ex) {
  8599. console.error(`#renderDrawLayer: "${ex}".`);
  8600. }
  8601. }
  8602. async #renderXfaLayer() {
  8603. let error = null;
  8604. try {
  8605. const result = await this.xfaLayer.render(this.viewport, "display");
  8606. if (result?.textDivs && this._textHighlighter) {
  8607. this.#buildXfaTextContentItems(result.textDivs);
  8608. }
  8609. } catch (ex) {
  8610. console.error(`#renderXfaLayer: "${ex}".`);
  8611. error = ex;
  8612. } finally {
  8613. if (this.xfaLayer?.div) {
  8614. this.l10n.pause();
  8615. this.#addLayer(this.xfaLayer.div, "xfaLayer");
  8616. this.l10n.resume();
  8617. }
  8618. this.eventBus.dispatch("xfalayerrendered", {
  8619. source: this,
  8620. pageNumber: this.id,
  8621. error
  8622. });
  8623. }
  8624. }
  8625. async #renderTextLayer() {
  8626. const {
  8627. pdfPage,
  8628. textLayer,
  8629. viewport
  8630. } = this;
  8631. if (!textLayer) {
  8632. return;
  8633. }
  8634. let error = null;
  8635. try {
  8636. if (!textLayer.renderingDone) {
  8637. const readableStream = pdfPage.streamTextContent({
  8638. includeMarkedContent: true,
  8639. disableNormalization: true
  8640. });
  8641. textLayer.setTextContentSource(readableStream);
  8642. }
  8643. await textLayer.render(viewport);
  8644. } catch (ex) {
  8645. if (ex instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AbortException) {
  8646. return;
  8647. }
  8648. console.error(`#renderTextLayer: "${ex}".`);
  8649. error = ex;
  8650. }
  8651. this.eventBus.dispatch("textlayerrendered", {
  8652. source: this,
  8653. pageNumber: this.id,
  8654. numTextDivs: textLayer.numTextDivs,
  8655. error
  8656. });
  8657. this.#renderStructTreeLayer();
  8658. }
  8659. async #renderStructTreeLayer() {
  8660. if (!this.textLayer) {
  8661. return;
  8662. }
  8663. this.structTreeLayer ||= new _struct_tree_layer_builder_js__WEBPACK_IMPORTED_MODULE_8__.StructTreeLayerBuilder();
  8664. const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
  8665. const treeDom = this.structTreeLayer?.render(tree);
  8666. if (treeDom) {
  8667. this.l10n.pause();
  8668. this.canvas?.append(treeDom);
  8669. this.l10n.resume();
  8670. }
  8671. this.structTreeLayer?.show();
  8672. }
  8673. async #buildXfaTextContentItems(textDivs) {
  8674. const text = await this.pdfPage.getTextContent();
  8675. const items = [];
  8676. for (const item of text.items) {
  8677. items.push(item.str);
  8678. }
  8679. this._textHighlighter.setTextMapping(textDivs, items);
  8680. this._textHighlighter.enable();
  8681. }
  8682. _resetZoomLayer(removeFromDOM = false) {
  8683. if (!this.zoomLayer) {
  8684. return;
  8685. }
  8686. const zoomLayerCanvas = this.zoomLayer.firstChild;
  8687. this.#viewportMap.delete(zoomLayerCanvas);
  8688. zoomLayerCanvas.width = 0;
  8689. zoomLayerCanvas.height = 0;
  8690. if (removeFromDOM) {
  8691. this.zoomLayer.remove();
  8692. }
  8693. this.zoomLayer = null;
  8694. }
  8695. reset({
  8696. keepZoomLayer = false,
  8697. keepAnnotationLayer = false,
  8698. keepAnnotationEditorLayer = false,
  8699. keepXfaLayer = false,
  8700. keepTextLayer = false
  8701. } = {}) {
  8702. this.cancelRendering({
  8703. keepAnnotationLayer,
  8704. keepAnnotationEditorLayer,
  8705. keepXfaLayer,
  8706. keepTextLayer
  8707. });
  8708. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL;
  8709. const div = this.div;
  8710. const childNodes = div.childNodes,
  8711. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  8712. annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
  8713. annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
  8714. xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
  8715. textLayerNode = keepTextLayer && this.textLayer?.div || null;
  8716. for (let i = childNodes.length - 1; i >= 0; i--) {
  8717. const node = childNodes[i];
  8718. switch (node) {
  8719. case zoomLayerNode:
  8720. case annotationLayerNode:
  8721. case annotationEditorLayerNode:
  8722. case xfaLayerNode:
  8723. case textLayerNode:
  8724. continue;
  8725. }
  8726. node.remove();
  8727. const layerIndex = this.#layers.indexOf(node);
  8728. if (layerIndex >= 0) {
  8729. this.#layers[layerIndex] = null;
  8730. }
  8731. }
  8732. div.removeAttribute("data-loaded");
  8733. if (annotationLayerNode) {
  8734. // this.annotationLayer.hide();
  8735. }
  8736. if (annotationEditorLayerNode) {
  8737. this.annotationEditorLayer.hide();
  8738. }
  8739. if (xfaLayerNode) {
  8740. this.xfaLayer.hide();
  8741. }
  8742. if (textLayerNode) {
  8743. this.textLayer.hide();
  8744. }
  8745. this.structTreeLayer?.hide();
  8746. if (!zoomLayerNode) {
  8747. if (this.canvas) {
  8748. this.#viewportMap.delete(this.canvas);
  8749. this.canvas.width = 0;
  8750. this.canvas.height = 0;
  8751. delete this.canvas;
  8752. }
  8753. this._resetZoomLayer();
  8754. }
  8755. }
  8756. update({
  8757. scale = 0,
  8758. rotation = null,
  8759. optionalContentConfigPromise = null,
  8760. drawingDelay = -1
  8761. }) {
  8762. this.scale = scale || this.scale;
  8763. if (typeof rotation === "number") {
  8764. this.rotation = rotation;
  8765. }
  8766. if (optionalContentConfigPromise instanceof Promise) {
  8767. this._optionalContentConfigPromise = optionalContentConfigPromise;
  8768. optionalContentConfigPromise.then(optionalContentConfig => {
  8769. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  8770. return;
  8771. }
  8772. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  8773. });
  8774. }
  8775. this.#useThumbnailCanvas.directDrawing = true;
  8776. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8777. this.viewport = this.viewport.clone({
  8778. scale: this.scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS,
  8779. rotation: totalRotation
  8780. });
  8781. this.#setDimensions();
  8782. if (this._isStandalone) {
  8783. this._container?.style.setProperty("--scale-factor", this.viewport.scale);
  8784. }
  8785. if (this.canvas) {
  8786. let onlyCssZoom = false;
  8787. if (this.#hasRestrictedScaling) {
  8788. if (this.maxCanvasPixels === 0) {
  8789. onlyCssZoom = true;
  8790. } else if (this.maxCanvasPixels > 0) {
  8791. const {
  8792. width,
  8793. height
  8794. } = this.viewport;
  8795. const {
  8796. sx,
  8797. sy
  8798. } = this.outputScale;
  8799. onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
  8800. }
  8801. }
  8802. const postponeDrawing = !onlyCssZoom && drawingDelay >= 0 && drawingDelay < 1000;
  8803. if (postponeDrawing || onlyCssZoom) {
  8804. if (postponeDrawing && this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED) {
  8805. this.cancelRendering({
  8806. keepZoomLayer: true,
  8807. keepAnnotationLayer: true,
  8808. keepAnnotationEditorLayer: true,
  8809. keepXfaLayer: true,
  8810. keepTextLayer: true,
  8811. cancelExtraDelay: drawingDelay
  8812. });
  8813. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  8814. this.#useThumbnailCanvas.directDrawing = false;
  8815. }
  8816. this.cssTransform({
  8817. target: this.canvas,
  8818. redrawAnnotationLayer: true,
  8819. redrawAnnotationEditorLayer: true,
  8820. redrawXfaLayer: true,
  8821. redrawTextLayer: !postponeDrawing,
  8822. hideTextLayer: postponeDrawing
  8823. });
  8824. if (postponeDrawing) {
  8825. return;
  8826. }
  8827. this.eventBus.dispatch("pagerendered", {
  8828. source: this,
  8829. pageNumber: this.id,
  8830. cssTransform: true,
  8831. timestamp: performance.now(),
  8832. error: this.#renderError
  8833. });
  8834. return;
  8835. }
  8836. if (!this.zoomLayer && !this.canvas.hidden) {
  8837. this.zoomLayer = this.canvas.parentNode;
  8838. this.zoomLayer.style.position = "absolute";
  8839. }
  8840. }
  8841. if (this.zoomLayer) {
  8842. this.cssTransform({
  8843. target: this.zoomLayer.firstChild
  8844. });
  8845. }
  8846. this.reset({
  8847. keepZoomLayer: true,
  8848. keepAnnotationLayer: true,
  8849. keepAnnotationEditorLayer: true,
  8850. keepXfaLayer: true,
  8851. keepTextLayer: true
  8852. });
  8853. }
  8854. cancelRendering({
  8855. keepAnnotationLayer = false,
  8856. keepAnnotationEditorLayer = false,
  8857. keepXfaLayer = false,
  8858. keepTextLayer = false,
  8859. cancelExtraDelay = 0
  8860. } = {}) {
  8861. if (this.renderTask) {
  8862. this.renderTask.cancel(cancelExtraDelay);
  8863. this.renderTask = null;
  8864. }
  8865. this.resume = null;
  8866. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  8867. this.textLayer.cancel();
  8868. this.textLayer = null;
  8869. }
  8870. if (this.structTreeLayer && !this.textLayer) {
  8871. this.structTreeLayer = null;
  8872. }
  8873. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  8874. this.annotationLayer.cancel();
  8875. this.annotationLayer = null;
  8876. this._annotationCanvasMap = null;
  8877. }
  8878. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  8879. if (this.drawLayer) {
  8880. this.drawLayer.cancel();
  8881. this.drawLayer = null;
  8882. }
  8883. this.annotationEditorLayer.cancel();
  8884. this.annotationEditorLayer = null;
  8885. }
  8886. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  8887. this.xfaLayer.cancel();
  8888. this.xfaLayer = null;
  8889. this._textHighlighter?.disable();
  8890. }
  8891. }
  8892. cssTransform({
  8893. target,
  8894. redrawAnnotationLayer = false,
  8895. redrawAnnotationEditorLayer = false,
  8896. redrawXfaLayer = false,
  8897. redrawTextLayer = false,
  8898. hideTextLayer = false
  8899. }) {
  8900. if (!target.hasAttribute("zooming")) {
  8901. target.setAttribute("zooming", true);
  8902. const {
  8903. style
  8904. } = target;
  8905. style.width = style.height = "";
  8906. }
  8907. const originalViewport = this.#viewportMap.get(target);
  8908. if (this.viewport !== originalViewport) {
  8909. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  8910. const absRotation = Math.abs(relativeRotation);
  8911. let scaleX = 1,
  8912. scaleY = 1;
  8913. if (absRotation === 90 || absRotation === 270) {
  8914. const {
  8915. width,
  8916. height
  8917. } = this.viewport;
  8918. scaleX = height / width;
  8919. scaleY = width / height;
  8920. }
  8921. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  8922. }
  8923. if (redrawAnnotationLayer && this.annotationLayer) {
  8924. this.#renderAnnotationLayer();
  8925. }
  8926. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  8927. if (this.drawLayer) {
  8928. this.#renderDrawLayer();
  8929. }
  8930. this.#renderAnnotationEditorLayer();
  8931. }
  8932. if (redrawXfaLayer && this.xfaLayer) {
  8933. this.#renderXfaLayer();
  8934. }
  8935. if (this.textLayer) {
  8936. if (hideTextLayer) {
  8937. this.textLayer.hide();
  8938. this.structTreeLayer?.hide();
  8939. } else if (redrawTextLayer) {
  8940. this.#renderTextLayer();
  8941. }
  8942. }
  8943. }
  8944. get width() {
  8945. return this.viewport.width;
  8946. }
  8947. get height() {
  8948. return this.viewport.height;
  8949. }
  8950. getPagePoint(x, y) {
  8951. return this.viewport.convertToPdfPoint(x, y);
  8952. }
  8953. async #finishRenderTask(renderTask, error = null) {
  8954. if (renderTask === this.renderTask) {
  8955. this.renderTask = null;
  8956. }
  8957. if (error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException) {
  8958. this.#renderError = null;
  8959. return;
  8960. }
  8961. this.#renderError = error;
  8962. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  8963. this._resetZoomLayer(true);
  8964. this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
  8965. this.eventBus.dispatch("pagerendered", {
  8966. source: this,
  8967. pageNumber: this.id,
  8968. cssTransform: false,
  8969. timestamp: performance.now(),
  8970. error: this.#renderError
  8971. });
  8972. if (error) {
  8973. throw error;
  8974. }
  8975. }
  8976. async draw() {
  8977. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL) {
  8978. console.error("Must be in new state before drawing");
  8979. this.reset();
  8980. }
  8981. const {
  8982. div,
  8983. l10n,
  8984. pageColors,
  8985. pdfPage,
  8986. viewport
  8987. } = this;
  8988. if (!pdfPage) {
  8989. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  8990. throw new Error("pdfPage is not loaded");
  8991. }
  8992. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING;
  8993. const canvasWrapper = document.createElement("div");
  8994. canvasWrapper.classList.add("canvasWrapper");
  8995. canvasWrapper.setAttribute("aria-hidden", true);
  8996. this.#addLayer(canvasWrapper, "canvasWrapper");
  8997. if (!this.textLayer && this.#textLayerMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  8998. this._accessibilityManager ||= new _text_accessibility_js__WEBPACK_IMPORTED_MODULE_9__.TextAccessibilityManager();
  8999. this.textLayer = new _text_layer_builder_js__WEBPACK_IMPORTED_MODULE_10__.TextLayerBuilder({
  9000. highlighter: this._textHighlighter,
  9001. accessibilityManager: this._accessibilityManager,
  9002. enablePermissions: this.#textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS,
  9003. onAppend: textLayerDiv => {
  9004. this.l10n.pause();
  9005. this.#addLayer(textLayerDiv, "textLayer");
  9006. this.l10n.resume();
  9007. }
  9008. });
  9009. }
  9010. if (!this.annotationLayer && this.#annotationMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.DISABLE) {
  9011. const {
  9012. annotationStorage,
  9013. annotationEditorUIManager,
  9014. downloadManager,
  9015. enableScripting,
  9016. fieldObjectsPromise,
  9017. hasJSActionsPromise,
  9018. linkService
  9019. } = this.#layerProperties;
  9020. this._annotationCanvasMap ||= new Map();
  9021. this.annotationLayer = new _annotation_layer_builder_js__WEBPACK_IMPORTED_MODULE_3__.AnnotationLayerBuilder({
  9022. pdfPage,
  9023. annotationStorage,
  9024. imageResourcesPath: this.imageResourcesPath,
  9025. renderForms: this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS,
  9026. linkService,
  9027. downloadManager,
  9028. enableScripting,
  9029. hasJSActionsPromise,
  9030. fieldObjectsPromise,
  9031. annotationCanvasMap: this._annotationCanvasMap,
  9032. accessibilityManager: this._accessibilityManager,
  9033. annotationEditorUIManager,
  9034. onAppend: annotationLayerDiv => {
  9035. this.#addLayer(annotationLayerDiv, "annotationLayer");
  9036. }
  9037. });
  9038. }
  9039. const renderContinueCallback = cont => {
  9040. showCanvas?.(false);
  9041. if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
  9042. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED;
  9043. this.resume = () => {
  9044. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING;
  9045. cont();
  9046. };
  9047. return;
  9048. }
  9049. cont();
  9050. };
  9051. const {
  9052. width,
  9053. height
  9054. } = viewport;
  9055. const canvas = document.createElement("canvas");
  9056. canvas.setAttribute("role", "presentation");
  9057. canvas.hidden = true;
  9058. const hasHCM = !!(pageColors?.background && pageColors?.foreground);
  9059. let showCanvas = isLastShow => {
  9060. if (!hasHCM || isLastShow) {
  9061. canvas.hidden = false;
  9062. showCanvas = null;
  9063. }
  9064. };
  9065. canvasWrapper.append(canvas);
  9066. this.canvas = canvas;
  9067. const ctx = canvas.getContext("2d", {
  9068. alpha: false
  9069. });
  9070. const outputScale = this.outputScale = new _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.OutputScale();
  9071. if (this.maxCanvasPixels === 0) {
  9072. const invScale = 1 / this.scale;
  9073. outputScale.sx *= invScale;
  9074. outputScale.sy *= invScale;
  9075. this.#hasRestrictedScaling = true;
  9076. } else if (this.maxCanvasPixels > 0) {
  9077. const pixelsInViewport = width * height;
  9078. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  9079. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  9080. outputScale.sx = maxScale;
  9081. outputScale.sy = maxScale;
  9082. this.#hasRestrictedScaling = true;
  9083. } else {
  9084. this.#hasRestrictedScaling = false;
  9085. }
  9086. }
  9087. const sfx = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.approximateFraction)(outputScale.sx);
  9088. const sfy = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.approximateFraction)(outputScale.sy);
  9089. canvas.width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(width * outputScale.sx, sfx[0]);
  9090. canvas.height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(height * outputScale.sy, sfy[0]);
  9091. const {
  9092. style
  9093. } = canvas;
  9094. style.width = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(width, sfx[1]) + "px";
  9095. style.height = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.roundToDivide)(height, sfy[1]) + "px";
  9096. this.#viewportMap.set(canvas, viewport);
  9097. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  9098. const renderContext = {
  9099. canvasContext: ctx,
  9100. transform,
  9101. viewport,
  9102. annotationMode: this.#annotationMode,
  9103. optionalContentConfigPromise: this._optionalContentConfigPromise,
  9104. annotationCanvasMap: this._annotationCanvasMap,
  9105. pageColors
  9106. };
  9107. const renderTask = this.renderTask = this.pdfPage.render(renderContext);
  9108. renderTask.onContinue = renderContinueCallback;
  9109. const resultPromise = renderTask.promise.then(async () => {
  9110. showCanvas?.(true);
  9111. await this.#finishRenderTask(renderTask);
  9112. this.#renderTextLayer();
  9113. if (this.annotationLayer) {
  9114. await this.#renderAnnotationLayer();
  9115. }
  9116. const {
  9117. annotationEditorUIManager
  9118. } = this.#layerProperties;
  9119. if (!annotationEditorUIManager) {
  9120. return;
  9121. }
  9122. this.drawLayer ||= new _draw_layer_builder_js__WEBPACK_IMPORTED_MODULE_5__.DrawLayerBuilder({
  9123. pageIndex: this.id
  9124. });
  9125. await this.#renderDrawLayer();
  9126. this.drawLayer.setParent(canvasWrapper);
  9127. if (!this.annotationEditorLayer) {
  9128. // console.log('test-drawer', this.drawLayer.getDrawLayer())
  9129. this.annotationEditorLayer = new _annotation_editor_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__.AnnotationEditorLayerBuilder({
  9130. uiManager: annotationEditorUIManager,
  9131. pdfPage,
  9132. l10n,
  9133. accessibilityManager: this._accessibilityManager,
  9134. annotationLayer: this.annotationLayer?.annotationLayer,
  9135. textLayer: this.textLayer,
  9136. drawLayer: this.drawLayer.getDrawLayer(),
  9137. // drawLayer:null,
  9138. onAppend: annotationEditorLayerDiv => {
  9139. this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer");
  9140. }
  9141. });
  9142. }
  9143. this.#renderAnnotationEditorLayer();
  9144. }, error => {
  9145. if (!(error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException)) {
  9146. showCanvas?.(true);
  9147. }
  9148. return this.#finishRenderTask(renderTask, error);
  9149. });
  9150. if (pdfPage.isPureXfa) {
  9151. if (!this.xfaLayer) {
  9152. const {
  9153. annotationStorage,
  9154. linkService
  9155. } = this.#layerProperties;
  9156. this.xfaLayer = new _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_11__.XfaLayerBuilder({
  9157. pdfPage,
  9158. annotationStorage,
  9159. linkService
  9160. });
  9161. }
  9162. this.#renderXfaLayer();
  9163. }
  9164. div.setAttribute("data-loaded", true);
  9165. this.eventBus.dispatch("pagerender", {
  9166. source: this,
  9167. pageNumber: this.id
  9168. });
  9169. return resultPromise;
  9170. }
  9171. setPageLabel(label) {
  9172. this.pageLabel = typeof label === "string" ? label : null;
  9173. this.div.setAttribute("data-l10n-args", JSON.stringify({
  9174. page: this.pageLabel ?? this.id
  9175. }));
  9176. if (this.pageLabel !== null) {
  9177. this.div.setAttribute("data-page-label", this.pageLabel);
  9178. } else {
  9179. this.div.removeAttribute("data-page-label");
  9180. }
  9181. }
  9182. get thumbnailCanvas() {
  9183. const {
  9184. directDrawing,
  9185. initialOptionalContent,
  9186. regularAnnotations
  9187. } = this.#useThumbnailCanvas;
  9188. return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
  9189. }
  9190. }
  9191. __webpack_async_result__();
  9192. } catch(e) { __webpack_async_result__(e); } });
  9193. /***/ }),
  9194. /***/ 8917:
  9195. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9196. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9197. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9198. /* harmony export */ PDFPresentationMode: () => (/* binding */ PDFPresentationMode)
  9199. /* harmony export */ });
  9200. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  9201. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
  9202. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  9203. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  9204. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  9205. const ACTIVE_SELECTOR = "pdfPresentationMode";
  9206. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  9207. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  9208. const PAGE_SWITCH_THRESHOLD = 0.1;
  9209. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  9210. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  9211. class PDFPresentationMode {
  9212. #state = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.UNKNOWN;
  9213. #args = null;
  9214. #fullscreenChangeAbortController = null;
  9215. #windowAbortController = null;
  9216. constructor({
  9217. container,
  9218. pdfViewer,
  9219. eventBus
  9220. }) {
  9221. this.container = container;
  9222. this.pdfViewer = pdfViewer;
  9223. this.eventBus = eventBus;
  9224. this.contextMenuOpen = false;
  9225. this.mouseScrollTimeStamp = 0;
  9226. this.mouseScrollDelta = 0;
  9227. this.touchSwipeState = null;
  9228. }
  9229. async request() {
  9230. const {
  9231. container,
  9232. pdfViewer
  9233. } = this;
  9234. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  9235. return false;
  9236. }
  9237. this.#addFullscreenChangeListeners();
  9238. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.CHANGING);
  9239. const promise = container.requestFullscreen();
  9240. this.#args = {
  9241. pageNumber: pdfViewer.currentPageNumber,
  9242. scaleValue: pdfViewer.currentScaleValue,
  9243. scrollMode: pdfViewer.scrollMode,
  9244. spreadMode: null,
  9245. annotationEditorMode: null
  9246. };
  9247. if (pdfViewer.spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  9248. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  9249. this.#args.spreadMode = pdfViewer.spreadMode;
  9250. }
  9251. if (pdfViewer.annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.DISABLE) {
  9252. this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
  9253. }
  9254. try {
  9255. await promise;
  9256. pdfViewer.focus();
  9257. return true;
  9258. } catch {
  9259. this.#removeFullscreenChangeListeners();
  9260. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL);
  9261. }
  9262. return false;
  9263. }
  9264. get active() {
  9265. return this.#state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.CHANGING || this.#state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.FULLSCREEN;
  9266. }
  9267. #mouseWheel(evt) {
  9268. if (!this.active) {
  9269. return;
  9270. }
  9271. evt.preventDefault();
  9272. const delta = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.normalizeWheelEventDelta)(evt);
  9273. const currentTime = Date.now();
  9274. const storedTime = this.mouseScrollTimeStamp;
  9275. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9276. return;
  9277. }
  9278. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9279. this.#resetMouseScrollState();
  9280. }
  9281. this.mouseScrollDelta += delta;
  9282. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9283. const totalDelta = this.mouseScrollDelta;
  9284. this.#resetMouseScrollState();
  9285. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9286. if (success) {
  9287. this.mouseScrollTimeStamp = currentTime;
  9288. }
  9289. }
  9290. }
  9291. #notifyStateChange(state) {
  9292. this.#state = state;
  9293. this.eventBus.dispatch("presentationmodechanged", {
  9294. source: this,
  9295. state
  9296. });
  9297. }
  9298. #enter() {
  9299. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.FULLSCREEN);
  9300. this.container.classList.add(ACTIVE_SELECTOR);
  9301. setTimeout(() => {
  9302. this.pdfViewer.scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE;
  9303. if (this.#args.spreadMode !== null) {
  9304. this.pdfViewer.spreadMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE;
  9305. }
  9306. this.pdfViewer.currentPageNumber = this.#args.pageNumber;
  9307. this.pdfViewer.currentScaleValue = "page-fit";
  9308. if (this.#args.annotationEditorMode !== null) {
  9309. this.pdfViewer.annotationEditorMode = {
  9310. mode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.AnnotationEditorType.NONE
  9311. };
  9312. }
  9313. }, 0);
  9314. this.#addWindowListeners();
  9315. this.#showControls();
  9316. this.contextMenuOpen = false;
  9317. document.getSelection().empty();
  9318. }
  9319. #exit() {
  9320. const pageNumber = this.pdfViewer.currentPageNumber;
  9321. this.container.classList.remove(ACTIVE_SELECTOR);
  9322. setTimeout(() => {
  9323. this.#removeFullscreenChangeListeners();
  9324. this.#notifyStateChange(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL);
  9325. this.pdfViewer.scrollMode = this.#args.scrollMode;
  9326. if (this.#args.spreadMode !== null) {
  9327. this.pdfViewer.spreadMode = this.#args.spreadMode;
  9328. }
  9329. this.pdfViewer.currentScaleValue = this.#args.scaleValue;
  9330. this.pdfViewer.currentPageNumber = pageNumber;
  9331. if (this.#args.annotationEditorMode !== null) {
  9332. this.pdfViewer.annotationEditorMode = {
  9333. mode: this.#args.annotationEditorMode
  9334. };
  9335. }
  9336. this.#args = null;
  9337. }, 0);
  9338. this.#removeWindowListeners();
  9339. this.#hideControls();
  9340. this.#resetMouseScrollState();
  9341. this.contextMenuOpen = false;
  9342. }
  9343. #mouseDown(evt) {
  9344. if (this.contextMenuOpen) {
  9345. this.contextMenuOpen = false;
  9346. evt.preventDefault();
  9347. return;
  9348. }
  9349. if (evt.button !== 0) {
  9350. return;
  9351. }
  9352. if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
  9353. return;
  9354. }
  9355. evt.preventDefault();
  9356. if (evt.shiftKey) {
  9357. this.pdfViewer.previousPage();
  9358. } else {
  9359. this.pdfViewer.nextPage();
  9360. }
  9361. }
  9362. #contextMenu() {
  9363. this.contextMenuOpen = true;
  9364. }
  9365. #showControls() {
  9366. if (this.controlsTimeout) {
  9367. clearTimeout(this.controlsTimeout);
  9368. } else {
  9369. this.container.classList.add(CONTROLS_SELECTOR);
  9370. }
  9371. this.controlsTimeout = setTimeout(() => {
  9372. this.container.classList.remove(CONTROLS_SELECTOR);
  9373. delete this.controlsTimeout;
  9374. }, DELAY_BEFORE_HIDING_CONTROLS);
  9375. }
  9376. #hideControls() {
  9377. if (!this.controlsTimeout) {
  9378. return;
  9379. }
  9380. clearTimeout(this.controlsTimeout);
  9381. this.container.classList.remove(CONTROLS_SELECTOR);
  9382. delete this.controlsTimeout;
  9383. }
  9384. #resetMouseScrollState() {
  9385. this.mouseScrollTimeStamp = 0;
  9386. this.mouseScrollDelta = 0;
  9387. }
  9388. #touchSwipe(evt) {
  9389. if (!this.active) {
  9390. return;
  9391. }
  9392. if (evt.touches.length > 1) {
  9393. this.touchSwipeState = null;
  9394. return;
  9395. }
  9396. switch (evt.type) {
  9397. case "touchstart":
  9398. this.touchSwipeState = {
  9399. startX: evt.touches[0].pageX,
  9400. startY: evt.touches[0].pageY,
  9401. endX: evt.touches[0].pageX,
  9402. endY: evt.touches[0].pageY
  9403. };
  9404. break;
  9405. case "touchmove":
  9406. if (this.touchSwipeState === null) {
  9407. return;
  9408. }
  9409. this.touchSwipeState.endX = evt.touches[0].pageX;
  9410. this.touchSwipeState.endY = evt.touches[0].pageY;
  9411. evt.preventDefault();
  9412. break;
  9413. case "touchend":
  9414. if (this.touchSwipeState === null) {
  9415. return;
  9416. }
  9417. let delta = 0;
  9418. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9419. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9420. const absAngle = Math.abs(Math.atan2(dy, dx));
  9421. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9422. delta = dx;
  9423. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9424. delta = dy;
  9425. }
  9426. if (delta > 0) {
  9427. this.pdfViewer.previousPage();
  9428. } else if (delta < 0) {
  9429. this.pdfViewer.nextPage();
  9430. }
  9431. break;
  9432. }
  9433. }
  9434. #addWindowListeners() {
  9435. if (this.#windowAbortController) {
  9436. return;
  9437. }
  9438. this.#windowAbortController = new AbortController();
  9439. const {
  9440. signal
  9441. } = this.#windowAbortController;
  9442. const touchSwipeBind = this.#touchSwipe.bind(this);
  9443. window.addEventListener("mousemove", this.#showControls.bind(this), {
  9444. signal
  9445. });
  9446. window.addEventListener("mousedown", this.#mouseDown.bind(this), {
  9447. signal
  9448. });
  9449. window.addEventListener("wheel", this.#mouseWheel.bind(this), {
  9450. passive: false,
  9451. signal
  9452. });
  9453. window.addEventListener("keydown", this.#resetMouseScrollState.bind(this), {
  9454. signal
  9455. });
  9456. window.addEventListener("contextmenu", this.#contextMenu.bind(this), {
  9457. signal
  9458. });
  9459. window.addEventListener("touchstart", touchSwipeBind, {
  9460. signal
  9461. });
  9462. window.addEventListener("touchmove", touchSwipeBind, {
  9463. signal
  9464. });
  9465. window.addEventListener("touchend", touchSwipeBind, {
  9466. signal
  9467. });
  9468. }
  9469. #removeWindowListeners() {
  9470. this.#windowAbortController?.abort();
  9471. this.#windowAbortController = null;
  9472. }
  9473. #addFullscreenChangeListeners() {
  9474. if (this.#fullscreenChangeAbortController) {
  9475. return;
  9476. }
  9477. this.#fullscreenChangeAbortController = new AbortController();
  9478. window.addEventListener("fullscreenchange", () => {
  9479. if (document.fullscreenElement) {
  9480. this.#enter();
  9481. } else {
  9482. this.#exit();
  9483. }
  9484. }, {
  9485. signal: this.#fullscreenChangeAbortController.signal
  9486. });
  9487. }
  9488. #removeFullscreenChangeListeners() {
  9489. this.#fullscreenChangeAbortController?.abort();
  9490. this.#fullscreenChangeAbortController = null;
  9491. }
  9492. }
  9493. __webpack_async_result__();
  9494. } catch(e) { __webpack_async_result__(e); } });
  9495. /***/ }),
  9496. /***/ 1144:
  9497. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9498. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9499. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9500. /* harmony export */ PDFPrintServiceFactory: () => (/* binding */ PDFPrintServiceFactory)
  9501. /* harmony export */ });
  9502. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  9503. /* harmony import */ var _print_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(659);
  9504. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _print_utils_js__WEBPACK_IMPORTED_MODULE_1__]);
  9505. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _print_utils_js__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  9506. let activeService = null;
  9507. let dialog = null;
  9508. let overlayManager = null;
  9509. let viewerApp = {
  9510. initialized: false
  9511. };
  9512. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  9513. const scratchCanvas = activeService.scratchCanvas;
  9514. const PRINT_UNITS = printResolution / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF;
  9515. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  9516. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  9517. const ctx = scratchCanvas.getContext("2d");
  9518. ctx.save();
  9519. ctx.fillStyle = "rgb(255, 255, 255)";
  9520. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  9521. ctx.restore();
  9522. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function ([pdfPage, printAnnotationStorage]) {
  9523. const renderContext = {
  9524. canvasContext: ctx,
  9525. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  9526. viewport: pdfPage.getViewport({
  9527. scale: 1,
  9528. rotation: size.rotation
  9529. }),
  9530. intent: "print",
  9531. annotationMode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_STORAGE,
  9532. optionalContentConfigPromise,
  9533. printAnnotationStorage
  9534. };
  9535. const renderTask = pdfPage.render(renderContext);
  9536. return renderTask.promise.catch(reason => {
  9537. if (!(reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException)) {
  9538. console.error(reason);
  9539. }
  9540. throw reason;
  9541. });
  9542. });
  9543. }
  9544. class PDFPrintService {
  9545. constructor({
  9546. pdfDocument,
  9547. pagesOverview,
  9548. printContainer,
  9549. printResolution,
  9550. printAnnotationStoragePromise = null
  9551. }) {
  9552. this.pdfDocument = pdfDocument;
  9553. this.pagesOverview = pagesOverview;
  9554. this.printContainer = printContainer;
  9555. this._printResolution = printResolution || 150;
  9556. this._optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
  9557. intent: "print"
  9558. });
  9559. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  9560. this.currentPage = -1;
  9561. this.scratchCanvas = document.createElement("canvas");
  9562. }
  9563. layout() {
  9564. this.throwIfInactive();
  9565. const body = document.querySelector("body");
  9566. body.setAttribute("data-pdfjsprinting", true);
  9567. const {
  9568. width,
  9569. height
  9570. } = this.pagesOverview[0];
  9571. const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
  9572. if (!hasEqualPageSizes) {
  9573. console.warn("Not all pages have the same size. The printed result may be incorrect!");
  9574. }
  9575. this.pageStyleSheet = document.createElement("style");
  9576. this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
  9577. body.append(this.pageStyleSheet);
  9578. }
  9579. destroy() {
  9580. if (activeService !== this) {
  9581. return;
  9582. }
  9583. this.printContainer.textContent = "";
  9584. const body = document.querySelector("body");
  9585. body.removeAttribute("data-pdfjsprinting");
  9586. if (this.pageStyleSheet) {
  9587. this.pageStyleSheet.remove();
  9588. this.pageStyleSheet = null;
  9589. }
  9590. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  9591. this.scratchCanvas = null;
  9592. activeService = null;
  9593. ensureOverlay().then(function () {
  9594. if (overlayManager.active === dialog) {
  9595. overlayManager.close(dialog);
  9596. }
  9597. });
  9598. }
  9599. renderPages() {
  9600. if (this.pdfDocument.isPureXfa) {
  9601. (0,_print_utils_js__WEBPACK_IMPORTED_MODULE_1__.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  9602. return Promise.resolve();
  9603. }
  9604. const pageCount = this.pagesOverview.length;
  9605. const renderNextPage = (resolve, reject) => {
  9606. this.throwIfInactive();
  9607. if (++this.currentPage >= pageCount) {
  9608. renderProgress(pageCount, pageCount);
  9609. resolve();
  9610. return;
  9611. }
  9612. const index = this.currentPage;
  9613. renderProgress(index, pageCount);
  9614. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  9615. renderNextPage(resolve, reject);
  9616. }, reject);
  9617. };
  9618. return new Promise(renderNextPage);
  9619. }
  9620. useRenderedPage() {
  9621. this.throwIfInactive();
  9622. const img = document.createElement("img");
  9623. const scratchCanvas = this.scratchCanvas;
  9624. if ("toBlob" in scratchCanvas) {
  9625. scratchCanvas.toBlob(function (blob) {
  9626. img.src = URL.createObjectURL(blob);
  9627. });
  9628. } else {
  9629. img.src = scratchCanvas.toDataURL();
  9630. }
  9631. const wrapper = document.createElement("div");
  9632. wrapper.className = "printedPage";
  9633. wrapper.append(img);
  9634. this.printContainer.append(wrapper);
  9635. return new Promise(function (resolve, reject) {
  9636. img.onload = resolve;
  9637. img.onerror = reject;
  9638. });
  9639. }
  9640. performPrint() {
  9641. this.throwIfInactive();
  9642. return new Promise(resolve => {
  9643. setTimeout(() => {
  9644. if (!this.active) {
  9645. resolve();
  9646. return;
  9647. }
  9648. print.call(window);
  9649. setTimeout(resolve, 20);
  9650. }, 0);
  9651. });
  9652. }
  9653. get active() {
  9654. return this === activeService;
  9655. }
  9656. throwIfInactive() {
  9657. if (!this.active) {
  9658. throw new Error("This print request was cancelled or completed.");
  9659. }
  9660. }
  9661. }
  9662. const print = window.print;
  9663. window.print = function () {
  9664. if (activeService) {
  9665. console.warn("Ignored window.print() because of a pending print job.");
  9666. return;
  9667. }
  9668. ensureOverlay().then(function () {
  9669. if (activeService) {
  9670. overlayManager.open(dialog);
  9671. }
  9672. });
  9673. try {
  9674. dispatchEvent("beforeprint");
  9675. } finally {
  9676. if (!activeService) {
  9677. console.error("Expected print service to be initialized.");
  9678. ensureOverlay().then(function () {
  9679. if (overlayManager.active === dialog) {
  9680. overlayManager.close(dialog);
  9681. }
  9682. });
  9683. return;
  9684. }
  9685. const activeServiceOnEntry = activeService;
  9686. activeService.renderPages().then(function () {
  9687. return activeServiceOnEntry.performPrint();
  9688. }).catch(function () {}).then(function () {
  9689. if (activeServiceOnEntry.active) {
  9690. abort();
  9691. }
  9692. });
  9693. }
  9694. };
  9695. function dispatchEvent(eventType) {
  9696. const event = new CustomEvent(eventType, {
  9697. bubbles: false,
  9698. cancelable: false,
  9699. detail: "custom"
  9700. });
  9701. window.dispatchEvent(event);
  9702. }
  9703. function abort() {
  9704. if (activeService) {
  9705. activeService.destroy();
  9706. dispatchEvent("afterprint");
  9707. }
  9708. }
  9709. function renderProgress(index, total) {
  9710. dialog ||= document.getElementById("printServiceDialog");
  9711. const progress = Math.round(100 * index / total);
  9712. const progressBar = dialog.querySelector("progress");
  9713. const progressPerc = dialog.querySelector(".relative-progress");
  9714. progressBar.value = progress;
  9715. progressPerc.setAttribute("data-l10n-args", JSON.stringify({
  9716. progress
  9717. }));
  9718. }
  9719. window.addEventListener("keydown", function (event) {
  9720. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  9721. window.print();
  9722. event.preventDefault();
  9723. event.stopImmediatePropagation();
  9724. }
  9725. }, true);
  9726. if ("onbeforeprint" in window) {
  9727. const stopPropagationIfNeeded = function (event) {
  9728. if (event.detail !== "custom") {
  9729. event.stopImmediatePropagation();
  9730. }
  9731. };
  9732. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  9733. window.addEventListener("afterprint", stopPropagationIfNeeded);
  9734. }
  9735. let overlayPromise;
  9736. function ensureOverlay() {
  9737. if (!overlayPromise) {
  9738. overlayManager = viewerApp.overlayManager;
  9739. if (!overlayManager) {
  9740. throw new Error("The overlay manager has not yet been initialized.");
  9741. }
  9742. dialog ||= document.getElementById("printServiceDialog");
  9743. overlayPromise = overlayManager.register(dialog, true);
  9744. document.getElementById("printCancel").onclick = abort;
  9745. dialog.addEventListener("close", abort);
  9746. }
  9747. return overlayPromise;
  9748. }
  9749. class PDFPrintServiceFactory {
  9750. static initGlobals(app) {
  9751. viewerApp = app;
  9752. }
  9753. static get supportsPrinting() {
  9754. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "supportsPrinting", true);
  9755. }
  9756. static createPrintService(params) {
  9757. if (activeService) {
  9758. throw new Error("The print service is created and active.");
  9759. }
  9760. return activeService = new PDFPrintService(params);
  9761. }
  9762. }
  9763. __webpack_async_result__();
  9764. } catch(e) { __webpack_async_result__(e); } });
  9765. /***/ }),
  9766. /***/ 6615:
  9767. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9768. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9769. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9770. /* harmony export */ PDFRenderingQueue: () => (/* binding */ PDFRenderingQueue)
  9771. /* harmony export */ });
  9772. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  9773. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  9774. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  9775. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  9776. const CLEANUP_TIMEOUT = 30000;
  9777. class PDFRenderingQueue {
  9778. constructor() {
  9779. this.pdfViewer = null;
  9780. this.pdfThumbnailViewer = null;
  9781. this.onIdle = null;
  9782. this.highestPriorityPage = null;
  9783. this.idleTimeout = null;
  9784. this.printing = false;
  9785. this.isThumbnailViewEnabled = false;
  9786. Object.defineProperty(this, "hasViewer", {
  9787. value: () => !!this.pdfViewer
  9788. });
  9789. }
  9790. setViewer(pdfViewer) {
  9791. this.pdfViewer = pdfViewer;
  9792. }
  9793. setThumbnailViewer(pdfThumbnailViewer) {
  9794. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9795. }
  9796. isHighestPriority(view) {
  9797. return this.highestPriorityPage === view.renderingId;
  9798. }
  9799. renderHighestPriority(currentlyVisiblePages) {
  9800. if (this.idleTimeout) {
  9801. clearTimeout(this.idleTimeout);
  9802. this.idleTimeout = null;
  9803. }
  9804. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  9805. return;
  9806. }
  9807. if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
  9808. return;
  9809. }
  9810. if (this.printing) {
  9811. return;
  9812. }
  9813. if (this.onIdle) {
  9814. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  9815. }
  9816. }
  9817. getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
  9818. const visibleViews = visible.views,
  9819. numVisible = visibleViews.length;
  9820. if (numVisible === 0) {
  9821. return null;
  9822. }
  9823. for (let i = 0; i < numVisible; i++) {
  9824. const view = visibleViews[i].view;
  9825. if (!this.isViewFinished(view)) {
  9826. return view;
  9827. }
  9828. }
  9829. const firstId = visible.first.id,
  9830. lastId = visible.last.id;
  9831. if (lastId - firstId + 1 > numVisible) {
  9832. const visibleIds = visible.ids;
  9833. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  9834. const holeId = scrolledDown ? firstId + i : lastId - i;
  9835. if (visibleIds.has(holeId)) {
  9836. continue;
  9837. }
  9838. const holeView = views[holeId - 1];
  9839. if (!this.isViewFinished(holeView)) {
  9840. return holeView;
  9841. }
  9842. }
  9843. }
  9844. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  9845. let preRenderView = views[preRenderIndex];
  9846. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9847. return preRenderView;
  9848. }
  9849. if (preRenderExtra) {
  9850. preRenderIndex += scrolledDown ? 1 : -1;
  9851. preRenderView = views[preRenderIndex];
  9852. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9853. return preRenderView;
  9854. }
  9855. }
  9856. return null;
  9857. }
  9858. isViewFinished(view) {
  9859. return view.renderingState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED;
  9860. }
  9861. renderView(view) {
  9862. switch (view.renderingState) {
  9863. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED:
  9864. return false;
  9865. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.PAUSED:
  9866. this.highestPriorityPage = view.renderingId;
  9867. view.resume();
  9868. break;
  9869. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.RUNNING:
  9870. this.highestPriorityPage = view.renderingId;
  9871. break;
  9872. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.INITIAL:
  9873. this.highestPriorityPage = view.renderingId;
  9874. view.draw().finally(() => {
  9875. this.renderHighestPriority();
  9876. }).catch(reason => {
  9877. if (reason instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.RenderingCancelledException) {
  9878. return;
  9879. }
  9880. console.error(`renderView: "${reason}"`);
  9881. });
  9882. break;
  9883. }
  9884. return true;
  9885. }
  9886. }
  9887. __webpack_async_result__();
  9888. } catch(e) { __webpack_async_result__(e); } });
  9889. /***/ }),
  9890. /***/ 5942:
  9891. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  9892. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  9893. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9894. /* harmony export */ PDFScriptingManager: () => (/* binding */ PDFScriptingManager)
  9895. /* harmony export */ });
  9896. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  9897. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
  9898. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  9899. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  9900. class PDFScriptingManager {
  9901. #closeCapability = null;
  9902. #destroyCapability = null;
  9903. #docProperties = null;
  9904. #eventAbortController = null;
  9905. #eventBus = null;
  9906. #externalServices = null;
  9907. #pdfDocument = null;
  9908. #pdfViewer = null;
  9909. #ready = false;
  9910. #scripting = null;
  9911. #willPrintCapability = null;
  9912. constructor({
  9913. eventBus,
  9914. externalServices = null,
  9915. docProperties = null
  9916. }) {
  9917. this.#eventBus = eventBus;
  9918. this.#externalServices = externalServices;
  9919. this.#docProperties = docProperties;
  9920. }
  9921. setViewer(pdfViewer) {
  9922. this.#pdfViewer = pdfViewer;
  9923. }
  9924. async setDocument(pdfDocument) {
  9925. if (this.#pdfDocument) {
  9926. await this.#destroyScripting();
  9927. }
  9928. this.#pdfDocument = pdfDocument;
  9929. if (!pdfDocument) {
  9930. return;
  9931. }
  9932. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  9933. if (!objects && !docActions) {
  9934. await this.#destroyScripting();
  9935. return;
  9936. }
  9937. if (pdfDocument !== this.#pdfDocument) {
  9938. return;
  9939. }
  9940. try {
  9941. this.#scripting = this.#initScripting();
  9942. } catch (error) {
  9943. console.error(`setDocument: "${error.message}".`);
  9944. await this.#destroyScripting();
  9945. return;
  9946. }
  9947. const eventBus = this.#eventBus;
  9948. this.#eventAbortController = new AbortController();
  9949. const {
  9950. signal
  9951. } = this.#eventAbortController;
  9952. eventBus._on("updatefromsandbox", event => {
  9953. if (event?.source === window) {
  9954. this.#updateFromSandbox(event.detail);
  9955. }
  9956. }, {
  9957. signal
  9958. });
  9959. eventBus._on("dispatcheventinsandbox", event => {
  9960. this.#scripting?.dispatchEventInSandbox(event.detail);
  9961. }, {
  9962. signal
  9963. });
  9964. eventBus._on("pagechanging", ({
  9965. pageNumber,
  9966. previous
  9967. }) => {
  9968. if (pageNumber === previous) {
  9969. return;
  9970. }
  9971. this.#dispatchPageClose(previous);
  9972. this.#dispatchPageOpen(pageNumber);
  9973. }, {
  9974. signal
  9975. });
  9976. eventBus._on("pagerendered", ({
  9977. pageNumber
  9978. }) => {
  9979. if (!this._pageOpenPending.has(pageNumber)) {
  9980. return;
  9981. }
  9982. if (pageNumber !== this.#pdfViewer.currentPageNumber) {
  9983. return;
  9984. }
  9985. this.#dispatchPageOpen(pageNumber);
  9986. }, {
  9987. signal
  9988. });
  9989. eventBus._on("pagesdestroy", async () => {
  9990. await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
  9991. await this.#scripting?.dispatchEventInSandbox({
  9992. id: "doc",
  9993. name: "WillClose"
  9994. });
  9995. this.#closeCapability?.resolve();
  9996. }, {
  9997. signal
  9998. });
  9999. try {
  10000. const docProperties = await this.#docProperties(pdfDocument);
  10001. if (pdfDocument !== this.#pdfDocument) {
  10002. return;
  10003. }
  10004. await this.#scripting.createSandbox({
  10005. objects,
  10006. calculationOrder,
  10007. appInfo: {
  10008. platform: navigator.platform,
  10009. language: navigator.language
  10010. },
  10011. docInfo: {
  10012. ...docProperties,
  10013. actions: docActions
  10014. }
  10015. });
  10016. eventBus.dispatch("sandboxcreated", {
  10017. source: this
  10018. });
  10019. } catch (error) {
  10020. console.error(`setDocument: "${error.message}".`);
  10021. await this.#destroyScripting();
  10022. return;
  10023. }
  10024. await this.#scripting?.dispatchEventInSandbox({
  10025. id: "doc",
  10026. name: "Open"
  10027. });
  10028. await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
  10029. Promise.resolve().then(() => {
  10030. if (pdfDocument === this.#pdfDocument) {
  10031. this.#ready = true;
  10032. }
  10033. });
  10034. }
  10035. async dispatchWillSave() {
  10036. return this.#scripting?.dispatchEventInSandbox({
  10037. id: "doc",
  10038. name: "WillSave"
  10039. });
  10040. }
  10041. async dispatchDidSave() {
  10042. return this.#scripting?.dispatchEventInSandbox({
  10043. id: "doc",
  10044. name: "DidSave"
  10045. });
  10046. }
  10047. async dispatchWillPrint() {
  10048. if (!this.#scripting) {
  10049. return;
  10050. }
  10051. await this.#willPrintCapability?.promise;
  10052. this.#willPrintCapability = Promise.withResolvers();
  10053. try {
  10054. await this.#scripting.dispatchEventInSandbox({
  10055. id: "doc",
  10056. name: "WillPrint"
  10057. });
  10058. } catch (ex) {
  10059. this.#willPrintCapability.resolve();
  10060. this.#willPrintCapability = null;
  10061. throw ex;
  10062. }
  10063. await this.#willPrintCapability.promise;
  10064. }
  10065. async dispatchDidPrint() {
  10066. return this.#scripting?.dispatchEventInSandbox({
  10067. id: "doc",
  10068. name: "DidPrint"
  10069. });
  10070. }
  10071. get destroyPromise() {
  10072. return this.#destroyCapability?.promise || null;
  10073. }
  10074. get ready() {
  10075. return this.#ready;
  10076. }
  10077. get _pageOpenPending() {
  10078. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_pageOpenPending", new Set());
  10079. }
  10080. get _visitedPages() {
  10081. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "_visitedPages", new Map());
  10082. }
  10083. async #updateFromSandbox(detail) {
  10084. const pdfViewer = this.#pdfViewer;
  10085. const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
  10086. const {
  10087. id,
  10088. siblings,
  10089. command,
  10090. value
  10091. } = detail;
  10092. if (!id) {
  10093. switch (command) {
  10094. case "clear":
  10095. console.clear();
  10096. break;
  10097. case "error":
  10098. console.error(value);
  10099. break;
  10100. case "layout":
  10101. if (!isInPresentationMode) {
  10102. const modes = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.apiPageLayoutToViewerModes)(value);
  10103. pdfViewer.spreadMode = modes.spreadMode;
  10104. }
  10105. break;
  10106. case "page-num":
  10107. pdfViewer.currentPageNumber = value + 1;
  10108. break;
  10109. case "print":
  10110. await pdfViewer.pagesPromise;
  10111. this.#eventBus.dispatch("print", {
  10112. source: this
  10113. });
  10114. break;
  10115. case "println":
  10116. console.log(value);
  10117. break;
  10118. case "zoom":
  10119. if (!isInPresentationMode) {
  10120. pdfViewer.currentScaleValue = value;
  10121. }
  10122. break;
  10123. case "SaveAs":
  10124. this.#eventBus.dispatch("download", {
  10125. source: this
  10126. });
  10127. break;
  10128. case "FirstPage":
  10129. pdfViewer.currentPageNumber = 1;
  10130. break;
  10131. case "LastPage":
  10132. pdfViewer.currentPageNumber = pdfViewer.pagesCount;
  10133. break;
  10134. case "NextPage":
  10135. pdfViewer.nextPage();
  10136. break;
  10137. case "PrevPage":
  10138. pdfViewer.previousPage();
  10139. break;
  10140. case "ZoomViewIn":
  10141. if (!isInPresentationMode) {
  10142. pdfViewer.increaseScale();
  10143. }
  10144. break;
  10145. case "ZoomViewOut":
  10146. if (!isInPresentationMode) {
  10147. pdfViewer.decreaseScale();
  10148. }
  10149. break;
  10150. case "WillPrintFinished":
  10151. this.#willPrintCapability?.resolve();
  10152. this.#willPrintCapability = null;
  10153. break;
  10154. }
  10155. return;
  10156. }
  10157. if (isInPresentationMode && detail.focus) {
  10158. return;
  10159. }
  10160. delete detail.id;
  10161. delete detail.siblings;
  10162. const ids = siblings ? [id, ...siblings] : [id];
  10163. for (const elementId of ids) {
  10164. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  10165. if (element) {
  10166. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  10167. detail
  10168. }));
  10169. } else {
  10170. this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
  10171. }
  10172. }
  10173. }
  10174. async #dispatchPageOpen(pageNumber, initialize = false) {
  10175. const pdfDocument = this.#pdfDocument,
  10176. visitedPages = this._visitedPages;
  10177. if (initialize) {
  10178. this.#closeCapability = Promise.withResolvers();
  10179. }
  10180. if (!this.#closeCapability) {
  10181. return;
  10182. }
  10183. const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
  10184. if (pageView?.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10185. this._pageOpenPending.add(pageNumber);
  10186. return;
  10187. }
  10188. this._pageOpenPending.delete(pageNumber);
  10189. const actionsPromise = (async () => {
  10190. const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
  10191. if (pdfDocument !== this.#pdfDocument) {
  10192. return;
  10193. }
  10194. await this.#scripting?.dispatchEventInSandbox({
  10195. id: "page",
  10196. name: "PageOpen",
  10197. pageNumber,
  10198. actions
  10199. });
  10200. })();
  10201. visitedPages.set(pageNumber, actionsPromise);
  10202. }
  10203. async #dispatchPageClose(pageNumber) {
  10204. const pdfDocument = this.#pdfDocument,
  10205. visitedPages = this._visitedPages;
  10206. if (!this.#closeCapability) {
  10207. return;
  10208. }
  10209. if (this._pageOpenPending.has(pageNumber)) {
  10210. return;
  10211. }
  10212. const actionsPromise = visitedPages.get(pageNumber);
  10213. if (!actionsPromise) {
  10214. return;
  10215. }
  10216. visitedPages.set(pageNumber, null);
  10217. await actionsPromise;
  10218. if (pdfDocument !== this.#pdfDocument) {
  10219. return;
  10220. }
  10221. await this.#scripting?.dispatchEventInSandbox({
  10222. id: "page",
  10223. name: "PageClose",
  10224. pageNumber
  10225. });
  10226. }
  10227. #initScripting() {
  10228. this.#destroyCapability = Promise.withResolvers();
  10229. if (this.#scripting) {
  10230. throw new Error("#initScripting: Scripting already exists.");
  10231. }
  10232. return this.#externalServices.createScripting();
  10233. }
  10234. async #destroyScripting() {
  10235. if (!this.#scripting) {
  10236. this.#pdfDocument = null;
  10237. this.#destroyCapability?.resolve();
  10238. return;
  10239. }
  10240. if (this.#closeCapability) {
  10241. await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
  10242. setTimeout(resolve, 1000);
  10243. })]).catch(() => {});
  10244. this.#closeCapability = null;
  10245. }
  10246. this.#pdfDocument = null;
  10247. try {
  10248. await this.#scripting.destroySandbox();
  10249. } catch {}
  10250. this.#willPrintCapability?.reject(new Error("Scripting destroyed."));
  10251. this.#willPrintCapability = null;
  10252. this.#eventAbortController?.abort();
  10253. this.#eventAbortController = null;
  10254. this._pageOpenPending.clear();
  10255. this._visitedPages.clear();
  10256. this.#scripting = null;
  10257. this.#ready = false;
  10258. this.#destroyCapability?.resolve();
  10259. }
  10260. }
  10261. __webpack_async_result__();
  10262. } catch(e) { __webpack_async_result__(e); } });
  10263. /***/ }),
  10264. /***/ 2275:
  10265. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  10266. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10267. /* harmony export */ PDFSidebar: () => (/* binding */ PDFSidebar)
  10268. /* harmony export */ });
  10269. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  10270. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  10271. const SIDEBAR_MIN_WIDTH = 200;
  10272. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  10273. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  10274. class PDFSidebar {
  10275. #isRTL = false;
  10276. #mouseMoveBound = this.#mouseMove.bind(this);
  10277. #mouseUpBound = this.#mouseUp.bind(this);
  10278. #outerContainerWidth = null;
  10279. #width = null;
  10280. constructor({
  10281. elements,
  10282. eventBus,
  10283. l10n
  10284. }) {
  10285. this.isOpen = false;
  10286. this.active = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS;
  10287. this.isInitialViewSet = false;
  10288. this.isInitialEventDispatched = false;
  10289. this.onToggled = null;
  10290. this.onUpdateThumbnails = null;
  10291. this.outerContainer = elements.outerContainer;
  10292. this.sidebarContainer = elements.sidebarContainer;
  10293. this.toggleButton = elements.toggleButton;
  10294. this.resizer = elements.resizer;
  10295. this.thumbnailButton = elements.thumbnailButton;
  10296. this.outlineButton = elements.outlineButton;
  10297. this.attachmentsButton = elements.attachmentsButton;
  10298. this.layersButton = elements.layersButton;
  10299. this.thumbnailView = elements.thumbnailView;
  10300. this.outlineView = elements.outlineView;
  10301. this.attachmentsView = elements.attachmentsView;
  10302. this.layersView = elements.layersView;
  10303. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  10304. this.eventBus = eventBus;
  10305. this.#isRTL = l10n.getDirection() === "rtl";
  10306. this.#addEventListeners();
  10307. }
  10308. reset() {
  10309. this.isInitialViewSet = false;
  10310. this.isInitialEventDispatched = false;
  10311. this.#hideUINotification(true);
  10312. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
  10313. this.outlineButton.disabled = false;
  10314. this.attachmentsButton.disabled = false;
  10315. this.layersButton.disabled = false;
  10316. this._currentOutlineItemButton.disabled = true;
  10317. }
  10318. get visibleView() {
  10319. return this.isOpen ? this.active : _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE;
  10320. }
  10321. setInitialView(view = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE) {
  10322. if (this.isInitialViewSet) {
  10323. return;
  10324. }
  10325. this.isInitialViewSet = true;
  10326. if (view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE || view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.UNKNOWN) {
  10327. this.#dispatchEvent();
  10328. return;
  10329. }
  10330. // [Custom] desc: do not open the siderBar when init the view
  10331. // this.switchView(view, true);
  10332. if (!this.isInitialEventDispatched) {
  10333. this.#dispatchEvent();
  10334. }
  10335. }
  10336. switchView(view, forceOpen = false) {
  10337. const isViewChanged = view !== this.active;
  10338. let forceRendering = false;
  10339. switch (view) {
  10340. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.NONE:
  10341. if (this.isOpen) {
  10342. this.close();
  10343. }
  10344. return;
  10345. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS:
  10346. if (this.isOpen && isViewChanged) {
  10347. forceRendering = true;
  10348. }
  10349. break;
  10350. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE:
  10351. if (this.outlineButton.disabled) {
  10352. return;
  10353. }
  10354. break;
  10355. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS:
  10356. if (this.attachmentsButton.disabled) {
  10357. return;
  10358. }
  10359. break;
  10360. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS:
  10361. if (this.layersButton.disabled) {
  10362. return;
  10363. }
  10364. break;
  10365. default:
  10366. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  10367. return;
  10368. }
  10369. this.active = view;
  10370. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.thumbnailButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS, this.thumbnailView);
  10371. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.outlineButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE, this.outlineView);
  10372. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.attachmentsButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS, this.attachmentsView);
  10373. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(this.layersButton, view === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS, this.layersView);
  10374. if (forceOpen && !this.isOpen) {
  10375. this.open();
  10376. return;
  10377. }
  10378. if (forceRendering) {
  10379. this.onUpdateThumbnails();
  10380. this.onToggled();
  10381. }
  10382. if (isViewChanged) {
  10383. this.#dispatchEvent();
  10384. }
  10385. }
  10386. open() {
  10387. if (this.isOpen) {
  10388. return;
  10389. }
  10390. this.isOpen = true;
  10391. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(this.toggleButton, true);
  10392. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  10393. if (this.active === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  10394. this.onUpdateThumbnails();
  10395. }
  10396. this.onToggled();
  10397. this.#dispatchEvent();
  10398. this.#hideUINotification();
  10399. }
  10400. close(evt = null) {
  10401. if (!this.isOpen) {
  10402. return;
  10403. }
  10404. this.isOpen = false;
  10405. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(this.toggleButton, false);
  10406. this.outerContainer.classList.add("sidebarMoving");
  10407. this.outerContainer.classList.remove("sidebarOpen");
  10408. this.onToggled();
  10409. this.#dispatchEvent();
  10410. if (evt?.detail > 0) {
  10411. this.toggleButton.blur();
  10412. }
  10413. }
  10414. toggle(evt = null) {
  10415. if (this.isOpen) {
  10416. this.close(evt);
  10417. } else {
  10418. this.open();
  10419. }
  10420. }
  10421. #dispatchEvent() {
  10422. if (this.isInitialViewSet) {
  10423. this.isInitialEventDispatched ||= true;
  10424. }
  10425. this.eventBus.dispatch("sidebarviewchanged", {
  10426. source: this,
  10427. view: this.visibleView
  10428. });
  10429. }
  10430. #showUINotification() {
  10431. this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-notification-button");
  10432. if (!this.isOpen) {
  10433. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  10434. }
  10435. }
  10436. #hideUINotification(reset = false) {
  10437. if (this.isOpen || reset) {
  10438. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  10439. }
  10440. if (reset) {
  10441. this.toggleButton.setAttribute("data-l10n-id", "pdfjs-toggle-sidebar-button");
  10442. }
  10443. }
  10444. #addEventListeners() {
  10445. this.sidebarContainer.addEventListener("transitionend", evt => {
  10446. if (evt.target === this.sidebarContainer) {
  10447. this.outerContainer.classList.remove("sidebarMoving");
  10448. this.eventBus.dispatch("resize", {
  10449. source: this
  10450. });
  10451. }
  10452. });
  10453. this.toggleButton.addEventListener("click", evt => {
  10454. this.toggle(evt);
  10455. });
  10456. this.thumbnailButton.addEventListener("click", () => {
  10457. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
  10458. });
  10459. this.outlineButton.addEventListener("click", () => {
  10460. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE);
  10461. });
  10462. this.outlineButton.addEventListener("dblclick", () => {
  10463. this.eventBus.dispatch("toggleoutlinetree", {
  10464. source: this
  10465. });
  10466. });
  10467. this.attachmentsButton.addEventListener("click", () => {
  10468. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS);
  10469. });
  10470. this.layersButton.addEventListener("click", () => {
  10471. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS);
  10472. });
  10473. this.layersButton.addEventListener("dblclick", () => {
  10474. this.eventBus.dispatch("resetlayers", {
  10475. source: this
  10476. });
  10477. });
  10478. this._currentOutlineItemButton.addEventListener("click", () => {
  10479. this.eventBus.dispatch("currentoutlineitem", {
  10480. source: this
  10481. });
  10482. });
  10483. const onTreeLoaded = (count, button, view) => {
  10484. button.disabled = !count;
  10485. if (count) {
  10486. this.#showUINotification();
  10487. } else if (this.active === view) {
  10488. this.switchView(_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS);
  10489. }
  10490. };
  10491. this.eventBus._on("outlineloaded", evt => {
  10492. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.OUTLINE);
  10493. evt.currentOutlineItemPromise.then(enabled => {
  10494. if (!this.isInitialViewSet) {
  10495. return;
  10496. }
  10497. this._currentOutlineItemButton.disabled = !enabled;
  10498. });
  10499. });
  10500. this.eventBus._on("attachmentsloaded", evt => {
  10501. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.ATTACHMENTS);
  10502. });
  10503. this.eventBus._on("layersloaded", evt => {
  10504. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.LAYERS);
  10505. });
  10506. this.eventBus._on("presentationmodechanged", evt => {
  10507. if (evt.state === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.PresentationModeState.NORMAL && this.visibleView === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SidebarView.THUMBS) {
  10508. this.onUpdateThumbnails();
  10509. }
  10510. });
  10511. this.resizer.addEventListener("mousedown", evt => {
  10512. if (evt.button !== 0) {
  10513. return;
  10514. }
  10515. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10516. window.addEventListener("mousemove", this.#mouseMoveBound);
  10517. window.addEventListener("mouseup", this.#mouseUpBound);
  10518. });
  10519. this.eventBus._on("resize", evt => {
  10520. if (evt.source !== window) {
  10521. return;
  10522. }
  10523. this.#outerContainerWidth = null;
  10524. if (!this.#width) {
  10525. return;
  10526. }
  10527. if (!this.isOpen) {
  10528. this.#updateWidth(this.#width);
  10529. return;
  10530. }
  10531. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10532. const updated = this.#updateWidth(this.#width);
  10533. Promise.resolve().then(() => {
  10534. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10535. if (updated) {
  10536. this.eventBus.dispatch("resize", {
  10537. source: this
  10538. });
  10539. }
  10540. });
  10541. });
  10542. }
  10543. get outerContainerWidth() {
  10544. return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
  10545. }
  10546. #updateWidth(width = 0) {
  10547. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  10548. if (width > maxWidth) {
  10549. width = maxWidth;
  10550. }
  10551. if (width < SIDEBAR_MIN_WIDTH) {
  10552. width = SIDEBAR_MIN_WIDTH;
  10553. }
  10554. if (width === this.#width) {
  10555. return false;
  10556. }
  10557. this.#width = width;
  10558. _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  10559. return true;
  10560. }
  10561. #mouseMove(evt) {
  10562. let width = evt.clientX;
  10563. if (this.#isRTL) {
  10564. width = this.outerContainerWidth - width;
  10565. }
  10566. this.#updateWidth(width);
  10567. }
  10568. #mouseUp(evt) {
  10569. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10570. this.eventBus.dispatch("resize", {
  10571. source: this
  10572. });
  10573. window.removeEventListener("mousemove", this.#mouseMoveBound);
  10574. window.removeEventListener("mouseup", this.#mouseUpBound);
  10575. }
  10576. }
  10577. /***/ }),
  10578. /***/ 1123:
  10579. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  10580. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  10581. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10582. /* harmony export */ PDFThumbnailView: () => (/* binding */ PDFThumbnailView),
  10583. /* harmony export */ TempImageFactory: () => (/* binding */ TempImageFactory)
  10584. /* harmony export */ });
  10585. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  10586. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2603);
  10587. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__]);
  10588. pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  10589. const DRAW_UPSCALE_FACTOR = 2;
  10590. const MAX_NUM_SCALING_STEPS = 3;
  10591. const THUMBNAIL_WIDTH = 90;
  10592. class TempImageFactory {
  10593. static #tempCanvas = null;
  10594. static getCanvas(width, height) {
  10595. const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
  10596. tempCanvas.width = width;
  10597. tempCanvas.height = height;
  10598. const ctx = tempCanvas.getContext("2d", {
  10599. alpha: false
  10600. });
  10601. ctx.save();
  10602. ctx.fillStyle = "rgb(255, 255, 255)";
  10603. ctx.fillRect(0, 0, width, height);
  10604. ctx.restore();
  10605. return [tempCanvas, tempCanvas.getContext("2d")];
  10606. }
  10607. static destroyCanvas() {
  10608. const tempCanvas = this.#tempCanvas;
  10609. if (tempCanvas) {
  10610. tempCanvas.width = 0;
  10611. tempCanvas.height = 0;
  10612. }
  10613. this.#tempCanvas = null;
  10614. }
  10615. }
  10616. class PDFThumbnailView {
  10617. constructor({
  10618. container,
  10619. eventBus,
  10620. id,
  10621. defaultViewport,
  10622. optionalContentConfigPromise,
  10623. linkService,
  10624. renderingQueue,
  10625. pageColors
  10626. }) {
  10627. this.id = id;
  10628. this.renderingId = "thumbnail" + id;
  10629. this.pageLabel = null;
  10630. this.pdfPage = null;
  10631. this.rotation = 0;
  10632. this.viewport = defaultViewport;
  10633. this.pdfPageRotate = defaultViewport.rotation;
  10634. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  10635. this.pageColors = pageColors || null;
  10636. this.eventBus = eventBus;
  10637. this.linkService = linkService;
  10638. this.renderingQueue = renderingQueue;
  10639. this.renderTask = null;
  10640. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL;
  10641. this.resume = null;
  10642. this.oldNumHeight = 20;
  10643. const anchor = document.createElement("a");
  10644. anchor.href = linkService.getAnchorUrl("#page=" + id);
  10645. anchor.setAttribute("data-l10n-id", "pdfjs-thumb-page-title");
  10646. anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10647. anchor.onclick = function () {
  10648. linkService.goToPage(id);
  10649. return false;
  10650. };
  10651. this.anchor = anchor;
  10652. const div = document.createElement("div");
  10653. div.className = "thumbnail";
  10654. div.setAttribute("data-page-number", this.id);
  10655. this.div = div;
  10656. this.#updateDims();
  10657. const img = document.createElement("div");
  10658. img.className = "thumbnailImage";
  10659. this._placeholderImg = img;
  10660. div.append(img);
  10661. anchor.append(div);
  10662. container.append(anchor);
  10663. const odlImageNum = document.createElement("div");
  10664. odlImageNum.classList.add(window.odlCustomSiderDomList.odl_imageNum);
  10665. // console.log('test-this', this)
  10666. odlImageNum.innerText = this.id
  10667. anchor.append(odlImageNum)
  10668. }
  10669. #updateDims() {
  10670. const {
  10671. width,
  10672. height
  10673. } = this.viewport;
  10674. const ratio = width / height;
  10675. this.canvasWidth = THUMBNAIL_WIDTH;
  10676. this.canvasHeight = this.canvasWidth / ratio | 0;
  10677. this.scale = this.canvasWidth / width;
  10678. const {
  10679. style
  10680. } = this.div;
  10681. // console.log('test-canvas', this.canvasWidth, this.canvasHeight, THUMBNAIL_WIDTH);
  10682. style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
  10683. style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
  10684. }
  10685. setPdfPage(pdfPage) {
  10686. this.pdfPage = pdfPage;
  10687. this.pdfPageRotate = pdfPage.rotate;
  10688. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10689. this.viewport = pdfPage.getViewport({
  10690. scale: 1,
  10691. rotation: totalRotation
  10692. });
  10693. this.reset();
  10694. }
  10695. reset() {
  10696. this.cancelRendering();
  10697. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL;
  10698. this.div.removeAttribute("data-loaded");
  10699. this.image?.replaceWith(this._placeholderImg);
  10700. this.#updateDims();
  10701. if (this.image) {
  10702. this.image.removeAttribute("src");
  10703. delete this.image;
  10704. }
  10705. }
  10706. update({
  10707. rotation = null
  10708. }) {
  10709. if (typeof rotation === "number") {
  10710. this.rotation = rotation;
  10711. }
  10712. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10713. this.viewport = this.viewport.clone({
  10714. scale: 1,
  10715. rotation: totalRotation
  10716. });
  10717. this.reset();
  10718. }
  10719. cancelRendering() {
  10720. if (this.renderTask) {
  10721. this.renderTask.cancel();
  10722. this.renderTask = null;
  10723. }
  10724. this.resume = null;
  10725. }
  10726. #getPageDrawContext(upscaleFactor = 1) {
  10727. const canvas = document.createElement("canvas");
  10728. const ctx = canvas.getContext("2d", {
  10729. alpha: false
  10730. });
  10731. const outputScale = new _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.OutputScale();
  10732. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  10733. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  10734. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10735. return {
  10736. ctx,
  10737. canvas,
  10738. transform
  10739. };
  10740. }
  10741. #convertCanvasToImage(canvas) {
  10742. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10743. throw new Error("#convertCanvasToImage: Rendering has not finished.");
  10744. }
  10745. const reducedCanvas = this.#reduceImage(canvas);
  10746. const image = document.createElement("img");
  10747. image.className = "thumbnailImage";
  10748. image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas");
  10749. image.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10750. image.src = reducedCanvas.toDataURL();
  10751. this.image = image;
  10752. this.div.setAttribute("data-loaded", true);
  10753. this._placeholderImg.replaceWith(image);
  10754. reducedCanvas.width = 0;
  10755. reducedCanvas.height = 0;
  10756. }
  10757. async #finishRenderTask(renderTask, canvas, error = null) {
  10758. if (renderTask === this.renderTask) {
  10759. this.renderTask = null;
  10760. }
  10761. if (error instanceof pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.RenderingCancelledException) {
  10762. return;
  10763. }
  10764. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
  10765. this.#convertCanvasToImage(canvas);
  10766. if (error) {
  10767. throw error;
  10768. }
  10769. }
  10770. async draw() {
  10771. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL) {
  10772. console.error("Must be in new state before drawing");
  10773. return undefined;
  10774. }
  10775. const {
  10776. pdfPage
  10777. } = this;
  10778. if (!pdfPage) {
  10779. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
  10780. throw new Error("pdfPage is not loaded");
  10781. }
  10782. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING;
  10783. const {
  10784. ctx,
  10785. canvas,
  10786. transform
  10787. } = this.#getPageDrawContext(DRAW_UPSCALE_FACTOR);
  10788. const drawViewport = this.viewport.clone({
  10789. scale: DRAW_UPSCALE_FACTOR * this.scale
  10790. });
  10791. const renderContinueCallback = cont => {
  10792. if (!this.renderingQueue.isHighestPriority(this)) {
  10793. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.PAUSED;
  10794. this.resume = () => {
  10795. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.RUNNING;
  10796. cont();
  10797. };
  10798. return;
  10799. }
  10800. cont();
  10801. };
  10802. const renderContext = {
  10803. canvasContext: ctx,
  10804. transform,
  10805. viewport: drawViewport,
  10806. optionalContentConfigPromise: this._optionalContentConfigPromise,
  10807. pageColors: this.pageColors
  10808. };
  10809. const renderTask = this.renderTask = pdfPage.render(renderContext);
  10810. renderTask.onContinue = renderContinueCallback;
  10811. const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
  10812. resultPromise.finally(() => {
  10813. canvas.width = 0;
  10814. canvas.height = 0;
  10815. this.eventBus.dispatch("thumbnailrendered", {
  10816. source: this,
  10817. pageNumber: this.id,
  10818. pdfPage: this.pdfPage
  10819. });
  10820. });
  10821. return resultPromise;
  10822. }
  10823. setImage(pageView) {
  10824. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.INITIAL) {
  10825. return;
  10826. }
  10827. const {
  10828. thumbnailCanvas: canvas,
  10829. pdfPage,
  10830. scale
  10831. } = pageView;
  10832. if (!canvas) {
  10833. return;
  10834. }
  10835. if (!this.pdfPage) {
  10836. this.setPdfPage(pdfPage);
  10837. }
  10838. if (scale < this.scale) {
  10839. return;
  10840. }
  10841. this.renderingState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED;
  10842. this.#convertCanvasToImage(canvas);
  10843. }
  10844. #reduceImage(img) {
  10845. const {
  10846. ctx,
  10847. canvas
  10848. } = this.#getPageDrawContext();
  10849. if (img.width <= 2 * canvas.width) {
  10850. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10851. return canvas;
  10852. }
  10853. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10854. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10855. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10856. while (reducedWidth > img.width || reducedHeight > img.height) {
  10857. reducedWidth >>= 1;
  10858. reducedHeight >>= 1;
  10859. }
  10860. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10861. while (reducedWidth > 2 * canvas.width) {
  10862. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10863. reducedWidth >>= 1;
  10864. reducedHeight >>= 1;
  10865. }
  10866. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10867. return canvas;
  10868. }
  10869. get #pageL10nArgs() {
  10870. return JSON.stringify({
  10871. page: this.pageLabel ?? this.id
  10872. });
  10873. }
  10874. setPageLabel(label) {
  10875. this.pageLabel = typeof label === "string" ? label : null;
  10876. this.anchor.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10877. if (this.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10878. return;
  10879. }
  10880. this.image?.setAttribute("data-l10n-args", this.#pageL10nArgs);
  10881. }
  10882. }
  10883. __webpack_async_result__();
  10884. } catch(e) { __webpack_async_result__(e); } });
  10885. /***/ }),
  10886. /***/ 8280:
  10887. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  10888. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  10889. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10890. /* harmony export */ PDFThumbnailViewer: () => (/* binding */ PDFThumbnailViewer)
  10891. /* harmony export */ });
  10892. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  10893. /* harmony import */ var _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1123);
  10894. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__]);
  10895. _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  10896. const THUMBNAIL_SCROLL_MARGIN = -19;
  10897. const THUMBNAIL_SELECTED_CLASS = "selected";
  10898. const ODL_THUMBNAIL_SELECTED_CLASS = "odl_selected";
  10899. class PDFThumbnailViewer {
  10900. constructor({
  10901. container,
  10902. eventBus,
  10903. linkService,
  10904. renderingQueue,
  10905. pageColors
  10906. }) {
  10907. this.container = container;
  10908. this.eventBus = eventBus;
  10909. this.linkService = linkService;
  10910. this.renderingQueue = renderingQueue;
  10911. this.pageColors = pageColors || null;
  10912. this.scroll = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.watchScroll)(this.container, this.#scrollUpdated.bind(this));
  10913. this.#resetView();
  10914. }
  10915. #scrollUpdated() {
  10916. this.renderingQueue.renderHighestPriority();
  10917. }
  10918. getThumbnail(index) {
  10919. return this._thumbnails[index];
  10920. }
  10921. #getVisibleThumbs() {
  10922. return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.getVisibleElements)({
  10923. scrollEl: this.container,
  10924. views: this._thumbnails
  10925. });
  10926. }
  10927. scrollThumbnailIntoView(pageNumber) {
  10928. if (!this.pdfDocument) {
  10929. return;
  10930. }
  10931. const thumbnailView = this._thumbnails[pageNumber - 1];
  10932. if (!thumbnailView) {
  10933. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  10934. return;
  10935. }
  10936. if (pageNumber !== this._currentPageNumber) {
  10937. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10938. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  10939. prevThumbnailView.div.parentNode.classList.remove(ODL_THUMBNAIL_SELECTED_CLASS)
  10940. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10941. thumbnailView.div.parentNode.classList.add(ODL_THUMBNAIL_SELECTED_CLASS)
  10942. }
  10943. const {
  10944. first,
  10945. last,
  10946. views
  10947. } = this.#getVisibleThumbs();
  10948. if (views.length > 0) {
  10949. let shouldScroll = false;
  10950. if (pageNumber <= first.id || pageNumber >= last.id) {
  10951. shouldScroll = true;
  10952. } else {
  10953. for (const {
  10954. id,
  10955. percent
  10956. } of views) {
  10957. if (id !== pageNumber) {
  10958. continue;
  10959. }
  10960. shouldScroll = percent < 100;
  10961. break;
  10962. }
  10963. }
  10964. if (shouldScroll) {
  10965. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.scrollIntoView)(thumbnailView.div, {
  10966. top: THUMBNAIL_SCROLL_MARGIN
  10967. });
  10968. }
  10969. }
  10970. this._currentPageNumber = pageNumber;
  10971. }
  10972. get pagesRotation() {
  10973. return this._pagesRotation;
  10974. }
  10975. set pagesRotation(rotation) {
  10976. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidRotation)(rotation)) {
  10977. throw new Error("Invalid thumbnails rotation angle.");
  10978. }
  10979. if (!this.pdfDocument) {
  10980. return;
  10981. }
  10982. if (this._pagesRotation === rotation) {
  10983. return;
  10984. }
  10985. this._pagesRotation = rotation;
  10986. const updateArgs = {
  10987. rotation
  10988. };
  10989. for (const thumbnail of this._thumbnails) {
  10990. thumbnail.update(updateArgs);
  10991. }
  10992. }
  10993. cleanup() {
  10994. for (const thumbnail of this._thumbnails) {
  10995. if (thumbnail.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates.FINISHED) {
  10996. thumbnail.reset();
  10997. }
  10998. }
  10999. _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__.TempImageFactory.destroyCanvas();
  11000. }
  11001. #resetView() {
  11002. this._thumbnails = [];
  11003. this._currentPageNumber = 1;
  11004. this._pageLabels = null;
  11005. this._pagesRotation = 0;
  11006. this.container.textContent = "";
  11007. }
  11008. setDocument(pdfDocument) {
  11009. if (this.pdfDocument) {
  11010. this.#cancelRendering();
  11011. this.#resetView();
  11012. }
  11013. this.pdfDocument = pdfDocument;
  11014. if (!pdfDocument) {
  11015. return;
  11016. }
  11017. const firstPagePromise = pdfDocument.getPage(1);
  11018. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
  11019. intent: "display"
  11020. });
  11021. firstPagePromise.then(firstPdfPage => {
  11022. const pagesCount = pdfDocument.numPages;
  11023. const viewport = firstPdfPage.getViewport({
  11024. scale: 1
  11025. });
  11026. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11027. const thumbnail = new _pdf_thumbnail_view_js__WEBPACK_IMPORTED_MODULE_1__.PDFThumbnailView({
  11028. container: this.container,
  11029. eventBus: this.eventBus,
  11030. id: pageNum,
  11031. defaultViewport: viewport.clone(),
  11032. optionalContentConfigPromise,
  11033. linkService: this.linkService,
  11034. renderingQueue: this.renderingQueue,
  11035. pageColors: this.pageColors
  11036. });
  11037. this._thumbnails.push(thumbnail);
  11038. }
  11039. this._thumbnails[0]?.setPdfPage(firstPdfPage);
  11040. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  11041. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  11042. }).catch(reason => {
  11043. console.error("Unable to initialize thumbnail viewer", reason);
  11044. });
  11045. }
  11046. #cancelRendering() {
  11047. for (const thumbnail of this._thumbnails) {
  11048. thumbnail.cancelRendering();
  11049. }
  11050. }
  11051. setPageLabels(labels) {
  11052. if (!this.pdfDocument) {
  11053. return;
  11054. }
  11055. if (!labels) {
  11056. this._pageLabels = null;
  11057. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11058. this._pageLabels = null;
  11059. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  11060. } else {
  11061. this._pageLabels = labels;
  11062. }
  11063. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  11064. this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11065. }
  11066. }
  11067. async #ensurePdfPageLoaded(thumbView) {
  11068. if (thumbView.pdfPage) {
  11069. return thumbView.pdfPage;
  11070. }
  11071. try {
  11072. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  11073. if (!thumbView.pdfPage) {
  11074. thumbView.setPdfPage(pdfPage);
  11075. }
  11076. return pdfPage;
  11077. } catch (reason) {
  11078. console.error("Unable to get page for thumb view", reason);
  11079. return null;
  11080. }
  11081. }
  11082. #getScrollAhead(visible) {
  11083. if (visible.first?.id === 1) {
  11084. return true;
  11085. } else if (visible.last?.id === this._thumbnails.length) {
  11086. return false;
  11087. }
  11088. return this.scroll.down;
  11089. }
  11090. forceRendering() {
  11091. const visibleThumbs = this.#getVisibleThumbs();
  11092. const scrollAhead = this.#getScrollAhead(visibleThumbs);
  11093. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  11094. // 有缓存 thumbView null 所以返回false, 不强制更新
  11095. if (thumbView) {
  11096. this.#ensurePdfPageLoaded(thumbView).then(() => {
  11097. this.renderingQueue.renderView(thumbView);
  11098. });
  11099. return true;
  11100. }
  11101. return false;
  11102. }
  11103. }
  11104. __webpack_async_result__();
  11105. } catch(e) { __webpack_async_result__(e); } });
  11106. /***/ }),
  11107. /***/ 6285:
  11108. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  11109. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  11110. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  11111. /* harmony export */ PDFViewer: () => (/* binding */ PDFViewer),
  11112. /* harmony export */ PagesCountLimit: () => (/* binding */ PagesCountLimit)
  11113. /* harmony export */ });
  11114. /* unused harmony export PDFPageViewBuffer */
  11115. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  11116. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  11117. /* harmony import */ var web_null_l10n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(410);
  11118. /* harmony import */ var _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9966);
  11119. /* harmony import */ var _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6615);
  11120. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(787);
  11121. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_2__, _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__]);
  11122. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, web_null_l10n__WEBPACK_IMPORTED_MODULE_2__, _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__, _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  11123. const DEFAULT_CACHE_SIZE = 10;
  11124. const PagesCountLimit = {
  11125. FORCE_SCROLL_MODE_PAGE: 15000,
  11126. FORCE_LAZY_PAGE_INIT: 7500,
  11127. PAUSE_EAGER_PAGE_INIT: 250
  11128. };
  11129. function isValidAnnotationEditorMode(mode) {
  11130. return Object.values(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType).includes(mode) && mode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  11131. }
  11132. class PDFPageViewBuffer {
  11133. #buf = new Set();
  11134. #size = 0;
  11135. constructor(size) {
  11136. this.#size = size;
  11137. }
  11138. push(view) {
  11139. const buf = this.#buf;
  11140. if (buf.has(view)) {
  11141. buf.delete(view);
  11142. }
  11143. buf.add(view);
  11144. if (buf.size > this.#size) {
  11145. this.#destroyFirstView();
  11146. }
  11147. }
  11148. resize(newSize, idsToKeep = null) {
  11149. this.#size = newSize;
  11150. const buf = this.#buf;
  11151. if (idsToKeep) {
  11152. const ii = buf.size;
  11153. let i = 1;
  11154. for (const view of buf) {
  11155. if (idsToKeep.has(view.id)) {
  11156. buf.delete(view);
  11157. buf.add(view);
  11158. }
  11159. if (++i > ii) {
  11160. break;
  11161. }
  11162. }
  11163. }
  11164. while (buf.size > this.#size) {
  11165. this.#destroyFirstView();
  11166. }
  11167. }
  11168. has(view) {
  11169. return this.#buf.has(view);
  11170. }
  11171. [Symbol.iterator]() {
  11172. return this.#buf.keys();
  11173. }
  11174. #destroyFirstView() {
  11175. const firstView = this.#buf.keys().next().value;
  11176. firstView?.destroy();
  11177. this.#buf.delete(firstView);
  11178. }
  11179. }
  11180. class PDFViewer {
  11181. #buffer = null;
  11182. #altTextManager = null;
  11183. #annotationEditorHighlightColors = null;
  11184. #annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
  11185. #annotationEditorUIManager = null;
  11186. #annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  11187. #containerTopLeft = null;
  11188. #copyCallbackBound = null;
  11189. #enableHighlightFloatingButton = false;
  11190. #enablePermissions = false;
  11191. #mlManager = null;
  11192. #getAllTextInProgress = false;
  11193. #hiddenCopyElement = null;
  11194. #interruptCopyCondition = false;
  11195. #previousContainerHeight = 0;
  11196. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  11197. #scrollModePageState = null;
  11198. #onVisibilityChange = null;
  11199. #scaleTimeoutId = null;
  11200. #textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  11201. constructor(options) {
  11202. const viewerVersion = "4.2.67";
  11203. if (pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version !== viewerVersion) {
  11204. throw new Error(`The API version "${pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version}" does not match the Viewer version "${viewerVersion}".`);
  11205. }
  11206. this.container = options.container;
  11207. this.viewer = options.viewer || options.container.firstElementChild;
  11208. if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
  11209. throw new Error("Invalid `container` and/or `viewer` option.");
  11210. }
  11211. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  11212. throw new Error("The `container` must be absolutely positioned.");
  11213. }
  11214. this.#resizeObserver.observe(this.container);
  11215. this.eventBus = options.eventBus;
  11216. this.linkService = options.linkService || new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_5__.SimpleLinkService();
  11217. this.downloadManager = options.downloadManager || null;
  11218. this.findController = options.findController || null;
  11219. this.#altTextManager = options.altTextManager || null;
  11220. if (this.findController) {
  11221. this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
  11222. }
  11223. this._scriptingManager = options.scriptingManager || null;
  11224. this.#textLayerMode = options.textLayerMode ?? _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE;
  11225. this.#annotationMode = options.annotationMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  11226. this.#annotationEditorMode = options.annotationEditorMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
  11227. this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
  11228. this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
  11229. this.imageResourcesPath = options.imageResourcesPath || "";
  11230. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  11231. this.removePageBorders = options.removePageBorders || false;
  11232. this.maxCanvasPixels = options.maxCanvasPixels;
  11233. this.l10n = options.l10n;
  11234. this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_2__.GenericL10n();
  11235. this.#enablePermissions = options.enablePermissions || false;
  11236. this.pageColors = options.pageColors || null;
  11237. this.#mlManager = options.mlManager || null;
  11238. this.defaultRenderingQueue = !options.renderingQueue;
  11239. if (this.defaultRenderingQueue) {
  11240. this.renderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__.PDFRenderingQueue();
  11241. this.renderingQueue.setViewer(this);
  11242. } else {
  11243. this.renderingQueue = options.renderingQueue;
  11244. }
  11245. this.scroll = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.watchScroll)(this.container, this._scrollUpdate.bind(this));
  11246. this.presentationModeState = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.UNKNOWN;
  11247. this._onBeforeDraw = this._onAfterDraw = null;
  11248. this._resetView();
  11249. if (this.removePageBorders) {
  11250. this.viewer.classList.add("removePageBorders");
  11251. }
  11252. this.#updateContainerHeightCss();
  11253. this.eventBus._on("thumbnailrendered", ({
  11254. pageNumber,
  11255. pdfPage
  11256. }) => {
  11257. const pageView = this._pages[pageNumber - 1];
  11258. if (!this.#buffer.has(pageView)) {
  11259. pdfPage?.cleanup();
  11260. }
  11261. });
  11262. if (!options.l10n) {
  11263. this.l10n.translate(this.container);
  11264. }
  11265. }
  11266. get pagesCount() {
  11267. return this._pages.length;
  11268. }
  11269. getPageView(index) {
  11270. return this._pages[index];
  11271. }
  11272. getCachedPageViews() {
  11273. return new Set(this.#buffer);
  11274. }
  11275. get pageViewsReady() {
  11276. return this._pages.every(pageView => pageView?.pdfPage);
  11277. }
  11278. get renderForms() {
  11279. return this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS;
  11280. }
  11281. get enableScripting() {
  11282. return !!this._scriptingManager;
  11283. }
  11284. get currentPageNumber() {
  11285. return this._currentPageNumber;
  11286. }
  11287. set currentPageNumber(val) {
  11288. if (!Number.isInteger(val)) {
  11289. throw new Error("Invalid page number.");
  11290. }
  11291. if (!this.pdfDocument) {
  11292. return;
  11293. }
  11294. // console.log('test-setCurrent-1')
  11295. // [custom] desc: 上面按钮切换pageNumber
  11296. if (!this._setCurrentPageNumber(val, true)) {
  11297. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  11298. }
  11299. }
  11300. _setCurrentPageNumber(val, resetCurrentPageView = false) {
  11301. if (this._currentPageNumber === val) {
  11302. if (resetCurrentPageView) {
  11303. this.#resetCurrentPageView();
  11304. }
  11305. return true;
  11306. }
  11307. if (!(0 < val && val <= this.pagesCount)) {
  11308. return false;
  11309. }
  11310. const previous = this._currentPageNumber;
  11311. this._currentPageNumber = val;
  11312. this.eventBus.dispatch("pagechanging", {
  11313. source: this,
  11314. pageNumber: val,
  11315. pageLabel: this._pageLabels?.[val - 1] ?? null,
  11316. previous
  11317. });
  11318. if (resetCurrentPageView) {
  11319. this.#resetCurrentPageView();
  11320. }
  11321. return true;
  11322. }
  11323. get currentPageLabel() {
  11324. return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
  11325. }
  11326. set currentPageLabel(val) {
  11327. if (!this.pdfDocument) {
  11328. return;
  11329. }
  11330. let page = val | 0;
  11331. if (this._pageLabels) {
  11332. const i = this._pageLabels.indexOf(val);
  11333. if (i >= 0) {
  11334. page = i + 1;
  11335. }
  11336. }
  11337. if (!this._setCurrentPageNumber(page, true)) {
  11338. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  11339. }
  11340. }
  11341. get currentScale() {
  11342. return this._currentScale !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE ? this._currentScale : _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
  11343. }
  11344. set currentScale(val) {
  11345. if (isNaN(val)) {
  11346. throw new Error("Invalid numeric scale.");
  11347. }
  11348. if (!this.pdfDocument) {
  11349. return;
  11350. }
  11351. this.#setScale(val, {
  11352. noScroll: false
  11353. });
  11354. }
  11355. get currentScaleValue() {
  11356. return this._currentScaleValue;
  11357. }
  11358. set currentScaleValue(val) {
  11359. if (!this.pdfDocument) {
  11360. return;
  11361. }
  11362. this.#setScale(val, {
  11363. noScroll: false
  11364. });
  11365. }
  11366. get pagesRotation() {
  11367. return this._pagesRotation;
  11368. }
  11369. set pagesRotation(rotation) {
  11370. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidRotation)(rotation)) {
  11371. throw new Error("Invalid pages rotation angle.");
  11372. }
  11373. if (!this.pdfDocument) {
  11374. return;
  11375. }
  11376. rotation %= 360;
  11377. if (rotation < 0) {
  11378. rotation += 360;
  11379. }
  11380. if (this._pagesRotation === rotation) {
  11381. return;
  11382. }
  11383. this._pagesRotation = rotation;
  11384. const pageNumber = this._currentPageNumber;
  11385. this.refresh(true, {
  11386. rotation
  11387. });
  11388. if (this._currentScaleValue) {
  11389. this.#setScale(this._currentScaleValue, {
  11390. noScroll: true
  11391. });
  11392. }
  11393. this.eventBus.dispatch("rotationchanging", {
  11394. source: this,
  11395. pagesRotation: rotation,
  11396. pageNumber
  11397. });
  11398. if (this.defaultRenderingQueue) {
  11399. this.update();
  11400. }
  11401. }
  11402. get firstPagePromise() {
  11403. return this.pdfDocument ? this._firstPageCapability.promise : null;
  11404. }
  11405. get onePageRendered() {
  11406. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  11407. }
  11408. get pagesPromise() {
  11409. return this.pdfDocument ? this._pagesCapability.promise : null;
  11410. }
  11411. get _layerProperties() {
  11412. const self = this;
  11413. return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.shadow)(this, "_layerProperties", {
  11414. get annotationEditorUIManager() {
  11415. return self.#annotationEditorUIManager;
  11416. },
  11417. get annotationStorage() {
  11418. return self.pdfDocument?.annotationStorage;
  11419. },
  11420. get downloadManager() {
  11421. return self.downloadManager;
  11422. },
  11423. get enableScripting() {
  11424. return !!self._scriptingManager;
  11425. },
  11426. get fieldObjectsPromise() {
  11427. return self.pdfDocument?.getFieldObjects();
  11428. },
  11429. get findController() {
  11430. return self.findController;
  11431. },
  11432. get hasJSActionsPromise() {
  11433. return self.pdfDocument?.hasJSActions();
  11434. },
  11435. get linkService() {
  11436. return self.linkService;
  11437. }
  11438. });
  11439. }
  11440. #initializePermissions(permissions) {
  11441. const params = {
  11442. annotationEditorMode: this.#annotationEditorMode,
  11443. annotationMode: this.#annotationMode,
  11444. textLayerMode: this.#textLayerMode
  11445. };
  11446. if (!permissions) {
  11447. return params;
  11448. }
  11449. if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.COPY) && this.#textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE) {
  11450. params.textLayerMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS;
  11451. }
  11452. if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.MODIFY_CONTENTS)) {
  11453. params.annotationEditorMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  11454. }
  11455. if (!permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE_FORMS) {
  11456. params.annotationMode = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationMode.ENABLE;
  11457. }
  11458. return params;
  11459. }
  11460. async #onePageRenderedOrForceFetch() {
  11461. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  11462. return;
  11463. }
  11464. const visibilityChangePromise = new Promise(resolve => {
  11465. this.#onVisibilityChange = () => {
  11466. if (document.visibilityState !== "hidden") {
  11467. return;
  11468. }
  11469. resolve();
  11470. };
  11471. document.addEventListener("visibilitychange", this.#onVisibilityChange);
  11472. });
  11473. await Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  11474. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11475. this.#onVisibilityChange = null;
  11476. }
  11477. async getAllText() {
  11478. const texts = [];
  11479. const buffer = [];
  11480. for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
  11481. if (this.#interruptCopyCondition) {
  11482. return null;
  11483. }
  11484. buffer.length = 0;
  11485. const page = await this.pdfDocument.getPage(pageNum);
  11486. const {
  11487. items
  11488. } = await page.getTextContent();
  11489. for (const item of items) {
  11490. if (item.str) {
  11491. buffer.push(item.str);
  11492. }
  11493. if (item.hasEOL) {
  11494. buffer.push("\n");
  11495. }
  11496. }
  11497. texts.push((0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.removeNullCharacters)(buffer.join("")));
  11498. }
  11499. return texts.join("\n");
  11500. }
  11501. #copyCallback(textLayerMode, event) {
  11502. const selection = document.getSelection();
  11503. const {
  11504. focusNode,
  11505. anchorNode
  11506. } = selection;
  11507. if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
  11508. if (this.#getAllTextInProgress || textLayerMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.ENABLE_PERMISSIONS) {
  11509. event.preventDefault();
  11510. event.stopPropagation();
  11511. return;
  11512. }
  11513. this.#getAllTextInProgress = true;
  11514. const savedCursor = this.container.style.cursor;
  11515. this.container.style.cursor = "wait";
  11516. const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
  11517. window.addEventListener("keydown", interruptCopy);
  11518. this.getAllText().then(async text => {
  11519. if (text !== null) {
  11520. await navigator.clipboard.writeText(text);
  11521. }
  11522. }).catch(reason => {
  11523. console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
  11524. }).finally(() => {
  11525. this.#getAllTextInProgress = false;
  11526. this.#interruptCopyCondition = false;
  11527. window.removeEventListener("keydown", interruptCopy);
  11528. this.container.style.cursor = savedCursor;
  11529. });
  11530. event.preventDefault();
  11531. event.stopPropagation();
  11532. }
  11533. }
  11534. setDocument(pdfDocument) {
  11535. if (this.pdfDocument) {
  11536. this.eventBus.dispatch("pagesdestroy", {
  11537. source: this
  11538. });
  11539. this._cancelRendering();
  11540. this._resetView();
  11541. this.findController?.setDocument(null);
  11542. this._scriptingManager?.setDocument(null);
  11543. if (this.#annotationEditorUIManager) {
  11544. this.#annotationEditorUIManager.destroy();
  11545. this.#annotationEditorUIManager = null;
  11546. }
  11547. }
  11548. this.pdfDocument = pdfDocument;
  11549. if (!pdfDocument) {
  11550. return;
  11551. }
  11552. const pagesCount = pdfDocument.numPages;
  11553. const firstPagePromise = pdfDocument.getPage(1);
  11554. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
  11555. intent: "display"
  11556. });
  11557. const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
  11558. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11559. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  11560. const mode = this._scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE;
  11561. this.eventBus.dispatch("scrollmodechanged", {
  11562. source: this,
  11563. mode
  11564. });
  11565. }
  11566. this._pagesCapability.promise.then(() => {
  11567. this.eventBus.dispatch("pagesloaded", {
  11568. source: this,
  11569. pagesCount
  11570. });
  11571. }, () => {});
  11572. this._onBeforeDraw = evt => {
  11573. const pageView = this._pages[evt.pageNumber - 1];
  11574. if (!pageView) {
  11575. return;
  11576. }
  11577. this.#buffer.push(pageView);
  11578. };
  11579. this.eventBus._on("pagerender", this._onBeforeDraw);
  11580. this._onAfterDraw = evt => {
  11581. if (evt.cssTransform) {
  11582. return;
  11583. }
  11584. this._onePageRenderedCapability.resolve({
  11585. timestamp: evt.timestamp
  11586. });
  11587. this.eventBus._off("pagerendered", this._onAfterDraw);
  11588. this._onAfterDraw = null;
  11589. };
  11590. this.eventBus._on("pagerendered", this._onAfterDraw);
  11591. Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => {
  11592. if (pdfDocument !== this.pdfDocument) {
  11593. return;
  11594. }
  11595. this._firstPageCapability.resolve(firstPdfPage);
  11596. this._optionalContentConfigPromise = optionalContentConfigPromise;
  11597. const {
  11598. annotationEditorMode,
  11599. annotationMode,
  11600. textLayerMode
  11601. } = this.#initializePermissions(permissions);
  11602. if (textLayerMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.TextLayerMode.DISABLE) {
  11603. const element = this.#hiddenCopyElement = document.createElement("div");
  11604. element.id = "hiddenCopyElement";
  11605. this.viewer.before(element);
  11606. }
  11607. if (annotationEditorMode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE) {
  11608. const mode = annotationEditorMode;
  11609. if (pdfDocument.isPureXfa) {
  11610. console.warn("Warning: XFA-editing is not implemented.");
  11611. } else if (isValidAnnotationEditorMode(mode)) {
  11612. this.#annotationEditorUIManager = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorUIManager(this.container, this.viewer, this.#altTextManager, this.eventBus, pdfDocument, this.pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#mlManager);
  11613. this.eventBus.dispatch("annotationeditoruimanager", {
  11614. source: this,
  11615. uiManager: this.#annotationEditorUIManager
  11616. });
  11617. if (mode !== pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE) {
  11618. this.#annotationEditorUIManager.updateMode(mode);
  11619. }
  11620. } else {
  11621. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  11622. }
  11623. }
  11624. const viewerElement = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE ? null : this.viewer;
  11625. const scale = this.currentScale;
  11626. const viewport = firstPdfPage.getViewport({
  11627. scale: scale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS
  11628. });
  11629. this.viewer.style.setProperty("--scale-factor", viewport.scale);
  11630. if (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas") {
  11631. this.viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
  11632. this.viewer.style.setProperty("--hcm-highlight-selected-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "ButtonText"));
  11633. }
  11634. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11635. const pageView = new _pdf_page_view_js__WEBPACK_IMPORTED_MODULE_3__.PDFPageView({
  11636. container: viewerElement,
  11637. eventBus: this.eventBus,
  11638. id: pageNum,
  11639. scale,
  11640. defaultViewport: viewport.clone(),
  11641. optionalContentConfigPromise,
  11642. renderingQueue: this.renderingQueue,
  11643. textLayerMode,
  11644. annotationMode,
  11645. imageResourcesPath: this.imageResourcesPath,
  11646. maxCanvasPixels: this.maxCanvasPixels,
  11647. pageColors: this.pageColors,
  11648. l10n: this.l10n,
  11649. layerProperties: this._layerProperties
  11650. });
  11651. this._pages.push(pageView);
  11652. }
  11653. this._pages[0]?.setPdfPage(firstPdfPage);
  11654. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  11655. this.#ensurePageViewVisible();
  11656. } else if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  11657. this._updateSpreadMode();
  11658. }
  11659. this.#onePageRenderedOrForceFetch().then(async () => {
  11660. this.findController?.setDocument(pdfDocument);
  11661. this._scriptingManager?.setDocument(pdfDocument);
  11662. if (this.#hiddenCopyElement) {
  11663. this.#copyCallbackBound = this.#copyCallback.bind(this, textLayerMode);
  11664. document.addEventListener("copy", this.#copyCallbackBound);
  11665. }
  11666. if (this.#annotationEditorUIManager) {
  11667. this.eventBus.dispatch("annotationeditormodechanged", {
  11668. source: this,
  11669. mode: this.#annotationEditorMode
  11670. });
  11671. }
  11672. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  11673. this._pagesCapability.resolve();
  11674. return;
  11675. }
  11676. let getPagesLeft = pagesCount - 1;
  11677. if (getPagesLeft <= 0) {
  11678. this._pagesCapability.resolve();
  11679. return;
  11680. }
  11681. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  11682. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  11683. const pageView = this._pages[pageNum - 1];
  11684. if (!pageView.pdfPage) {
  11685. pageView.setPdfPage(pdfPage);
  11686. }
  11687. if (--getPagesLeft === 0) {
  11688. this._pagesCapability.resolve();
  11689. }
  11690. }, reason => {
  11691. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  11692. if (--getPagesLeft === 0) {
  11693. this._pagesCapability.resolve();
  11694. }
  11695. });
  11696. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  11697. await promise;
  11698. }
  11699. }
  11700. });
  11701. this.eventBus.dispatch("pagesinit", {
  11702. source: this
  11703. });
  11704. pdfDocument.getMetadata().then(({
  11705. info
  11706. }) => {
  11707. if (pdfDocument !== this.pdfDocument) {
  11708. return;
  11709. }
  11710. if (info.Language) {
  11711. this.viewer.lang = info.Language;
  11712. }
  11713. });
  11714. if (this.defaultRenderingQueue) {
  11715. this.update();
  11716. }
  11717. }).catch(reason => {
  11718. console.error("Unable to initialize viewer", reason);
  11719. this._pagesCapability.reject(reason);
  11720. });
  11721. }
  11722. setPageLabels(labels) {
  11723. if (!this.pdfDocument) {
  11724. return;
  11725. }
  11726. if (!labels) {
  11727. this._pageLabels = null;
  11728. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11729. this._pageLabels = null;
  11730. console.error(`setPageLabels: Invalid page labels.`);
  11731. } else {
  11732. this._pageLabels = labels;
  11733. }
  11734. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  11735. this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11736. }
  11737. }
  11738. _resetView() {
  11739. this._pages = [];
  11740. this._currentPageNumber = 1;
  11741. this._currentScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE;
  11742. this._currentScaleValue = null;
  11743. this._pageLabels = null;
  11744. this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  11745. this._location = null;
  11746. this._pagesRotation = 0;
  11747. this._optionalContentConfigPromise = null;
  11748. this._firstPageCapability = Promise.withResolvers();
  11749. this._onePageRenderedCapability = Promise.withResolvers();
  11750. this._pagesCapability = Promise.withResolvers();
  11751. this._scrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL;
  11752. this._previousScrollMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.UNKNOWN;
  11753. this._spreadMode = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE;
  11754. this.#scrollModePageState = {
  11755. previousPageNumber: 1,
  11756. scrollDown: true,
  11757. pages: []
  11758. };
  11759. if (this._onBeforeDraw) {
  11760. this.eventBus._off("pagerender", this._onBeforeDraw);
  11761. this._onBeforeDraw = null;
  11762. }
  11763. if (this._onAfterDraw) {
  11764. this.eventBus._off("pagerendered", this._onAfterDraw);
  11765. this._onAfterDraw = null;
  11766. }
  11767. if (this.#onVisibilityChange) {
  11768. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11769. this.#onVisibilityChange = null;
  11770. }
  11771. this.viewer.textContent = "";
  11772. this._updateScrollMode();
  11773. this.viewer.removeAttribute("lang");
  11774. if (this.#hiddenCopyElement) {
  11775. document.removeEventListener("copy", this.#copyCallbackBound);
  11776. this.#copyCallbackBound = null;
  11777. this.#hiddenCopyElement.remove();
  11778. this.#hiddenCopyElement = null;
  11779. }
  11780. }
  11781. #ensurePageViewVisible() {
  11782. if (this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  11783. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  11784. }
  11785. const pageNumber = this._currentPageNumber,
  11786. state = this.#scrollModePageState,
  11787. viewer = this.viewer;
  11788. viewer.textContent = "";
  11789. state.pages.length = 0;
  11790. if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && !this.isInPresentationMode) {
  11791. const pageView = this._pages[pageNumber - 1];
  11792. viewer.append(pageView.div);
  11793. state.pages.push(pageView);
  11794. } else {
  11795. const pageIndexSet = new Set(),
  11796. parity = this._spreadMode - 1;
  11797. if (parity === -1) {
  11798. pageIndexSet.add(pageNumber - 1);
  11799. } else if (pageNumber % 2 !== parity) {
  11800. pageIndexSet.add(pageNumber - 1);
  11801. pageIndexSet.add(pageNumber);
  11802. } else {
  11803. pageIndexSet.add(pageNumber - 2);
  11804. pageIndexSet.add(pageNumber - 1);
  11805. }
  11806. const spread = document.createElement("div");
  11807. spread.className = "spread";
  11808. if (this.isInPresentationMode) {
  11809. const dummyPage = document.createElement("div");
  11810. dummyPage.className = "dummyPage";
  11811. spread.append(dummyPage);
  11812. }
  11813. for (const i of pageIndexSet) {
  11814. const pageView = this._pages[i];
  11815. if (!pageView) {
  11816. continue;
  11817. }
  11818. spread.append(pageView.div);
  11819. state.pages.push(pageView);
  11820. }
  11821. viewer.append(spread);
  11822. }
  11823. state.scrollDown = pageNumber >= state.previousPageNumber;
  11824. state.previousPageNumber = pageNumber;
  11825. }
  11826. _scrollUpdate() {
  11827. if (this.pagesCount === 0) {
  11828. return;
  11829. }
  11830. this.update();
  11831. }
  11832. #scrollIntoView(pageView, pageSpot = null) {
  11833. const {
  11834. div,
  11835. id
  11836. } = pageView;
  11837. if (this._currentPageNumber !== id) {
  11838. this._setCurrentPageNumber(id);
  11839. }
  11840. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  11841. this.#ensurePageViewVisible();
  11842. this.update();
  11843. }
  11844. if (!pageSpot && !this.isInPresentationMode) {
  11845. const left = div.offsetLeft + div.clientLeft,
  11846. right = left + div.clientWidth;
  11847. const {
  11848. scrollLeft,
  11849. clientWidth
  11850. } = this.container;
  11851. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  11852. pageSpot = {
  11853. left: 0,
  11854. top: 0
  11855. };
  11856. }
  11857. }
  11858. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.scrollIntoView)(div, pageSpot);
  11859. if (!this._currentScaleValue && this._location) {
  11860. this._location = null;
  11861. }
  11862. }
  11863. #isSameScale(newScale) {
  11864. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  11865. }
  11866. #setScaleUpdatePages(newScale, newValue, {
  11867. noScroll = false,
  11868. preset = false,
  11869. drawingDelay = -1
  11870. }) {
  11871. this._currentScaleValue = newValue.toString();
  11872. if (this.#isSameScale(newScale)) {
  11873. if (preset) {
  11874. this.eventBus.dispatch("scalechanging", {
  11875. source: this,
  11876. scale: newScale,
  11877. presetValue: newValue
  11878. });
  11879. }
  11880. return;
  11881. }
  11882. this.viewer.style.setProperty("--scale-factor", newScale * pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS);
  11883. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  11884. this.refresh(true, {
  11885. scale: newScale,
  11886. drawingDelay: postponeDrawing ? drawingDelay : -1
  11887. });
  11888. if (postponeDrawing) {
  11889. this.#scaleTimeoutId = setTimeout(() => {
  11890. this.#scaleTimeoutId = null;
  11891. this.refresh();
  11892. }, drawingDelay);
  11893. }
  11894. this._currentScale = newScale;
  11895. if (!noScroll) {
  11896. let page = this._currentPageNumber,
  11897. dest;
  11898. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  11899. page = this._location.pageNumber;
  11900. dest = [null, {
  11901. name: "XYZ"
  11902. }, this._location.left, this._location.top, null];
  11903. }
  11904. this.scrollPageIntoView({
  11905. pageNumber: page,
  11906. destArray: dest,
  11907. allowNegativeOffset: true
  11908. });
  11909. }
  11910. this.eventBus.dispatch("scalechanging", {
  11911. source: this,
  11912. scale: newScale,
  11913. presetValue: preset ? newValue : undefined
  11914. });
  11915. if (this.defaultRenderingQueue) {
  11916. this.update();
  11917. }
  11918. }
  11919. get #pageWidthScaleFactor() {
  11920. if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL) {
  11921. return 2;
  11922. }
  11923. return 1;
  11924. }
  11925. #setScale(value, options) {
  11926. let scale = parseFloat(value);
  11927. if (scale > 0) {
  11928. options.preset = false;
  11929. this.#setScaleUpdatePages(scale, value, options);
  11930. } else {
  11931. const currentPage = this._pages[this._currentPageNumber - 1];
  11932. if (!currentPage) {
  11933. return;
  11934. }
  11935. let hPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SCROLLBAR_PADDING,
  11936. vPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.VERTICAL_PADDING;
  11937. if (this.isInPresentationMode) {
  11938. hPadding = vPadding = 4;
  11939. if (this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  11940. hPadding *= 2;
  11941. }
  11942. } else if (this.removePageBorders) {
  11943. hPadding = vPadding = 0;
  11944. } else if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL) {
  11945. [hPadding, vPadding] = [vPadding, hPadding];
  11946. }
  11947. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
  11948. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  11949. switch (value) {
  11950. case "page-actual":
  11951. scale = 1;
  11952. break;
  11953. case "page-width":
  11954. scale = pageWidthScale;
  11955. break;
  11956. case "page-height":
  11957. scale = pageHeightScale;
  11958. break;
  11959. case "page-fit":
  11960. scale = Math.min(pageWidthScale, pageHeightScale);
  11961. break;
  11962. case "auto":
  11963. const horizontalScale = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  11964. scale = Math.min(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_AUTO_SCALE, horizontalScale);
  11965. break;
  11966. default:
  11967. console.error(`#setScale: "${value}" is an unknown zoom value.`);
  11968. return;
  11969. }
  11970. options.preset = true;
  11971. this.#setScaleUpdatePages(scale, value, options);
  11972. }
  11973. }
  11974. #resetCurrentPageView() {
  11975. const pageView = this._pages[this._currentPageNumber - 1];
  11976. if (this.isInPresentationMode) {
  11977. this.#setScale(this._currentScaleValue, {
  11978. noScroll: true
  11979. });
  11980. }
  11981. this.#scrollIntoView(pageView);
  11982. }
  11983. pageLabelToPageNumber(label) {
  11984. if (!this._pageLabels) {
  11985. return null;
  11986. }
  11987. const i = this._pageLabels.indexOf(label);
  11988. if (i < 0) {
  11989. return null;
  11990. }
  11991. return i + 1;
  11992. }
  11993. scrollPageIntoView({
  11994. pageNumber,
  11995. destArray = null,
  11996. allowNegativeOffset = false,
  11997. ignoreDestinationZoom = false
  11998. }) {
  11999. if (!this.pdfDocument) {
  12000. return;
  12001. }
  12002. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  12003. if (!pageView) {
  12004. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  12005. return;
  12006. }
  12007. if (this.isInPresentationMode || !destArray) {
  12008. // [custom] 图片视图切换 pageNumber
  12009. // console.log('test-setCurrent-2', pageNumber, destArray, this.isInPresentationMode)
  12010. this._setCurrentPageNumber(pageNumber, true);
  12011. return;
  12012. }
  12013. let x = 0,
  12014. y = 0;
  12015. let width = 0,
  12016. height = 0,
  12017. widthScale,
  12018. heightScale;
  12019. const changeOrientation = pageView.rotation % 180 !== 0;
  12020. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  12021. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  12022. let scale = 0;
  12023. switch (destArray[1].name) {
  12024. case "XYZ":
  12025. x = destArray[2];
  12026. y = destArray[3];
  12027. scale = destArray[4];
  12028. x = x !== null ? x : 0;
  12029. y = y !== null ? y : pageHeight;
  12030. break;
  12031. case "Fit":
  12032. case "FitB":
  12033. scale = "page-fit";
  12034. break;
  12035. case "FitH":
  12036. case "FitBH":
  12037. y = destArray[2];
  12038. scale = "page-width";
  12039. if (y === null && this._location) {
  12040. x = this._location.left;
  12041. y = this._location.top;
  12042. } else if (typeof y !== "number" || y < 0) {
  12043. y = pageHeight;
  12044. }
  12045. break;
  12046. case "FitV":
  12047. case "FitBV":
  12048. x = destArray[2];
  12049. width = pageWidth;
  12050. height = pageHeight;
  12051. scale = "page-height";
  12052. break;
  12053. case "FitR":
  12054. x = destArray[2];
  12055. y = destArray[3];
  12056. width = destArray[4] - x;
  12057. height = destArray[5] - y;
  12058. let hPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SCROLLBAR_PADDING,
  12059. vPadding = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.VERTICAL_PADDING;
  12060. if (this.removePageBorders) {
  12061. hPadding = vPadding = 0;
  12062. }
  12063. widthScale = (this.container.clientWidth - hPadding) / width / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  12064. heightScale = (this.container.clientHeight - vPadding) / height / pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS;
  12065. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  12066. break;
  12067. default:
  12068. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  12069. return;
  12070. }
  12071. if (!ignoreDestinationZoom) {
  12072. if (scale && scale !== this._currentScale) {
  12073. this.currentScaleValue = scale;
  12074. } else if (this._currentScale === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.UNKNOWN_SCALE) {
  12075. this.currentScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_VALUE;
  12076. }
  12077. }
  12078. if (scale === "page-fit" && !destArray[4]) {
  12079. this.#scrollIntoView(pageView);
  12080. return;
  12081. }
  12082. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  12083. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  12084. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  12085. if (!allowNegativeOffset) {
  12086. left = Math.max(left, 0);
  12087. top = Math.max(top, 0);
  12088. }
  12089. this.#scrollIntoView(pageView, {
  12090. left,
  12091. top
  12092. });
  12093. }
  12094. _updateLocation(firstPage) {
  12095. const currentScale = this._currentScale;
  12096. const currentScaleValue = this._currentScaleValue;
  12097. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  12098. const pageNumber = firstPage.id;
  12099. const currentPageView = this._pages[pageNumber - 1];
  12100. const container = this.container;
  12101. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  12102. const intLeft = Math.round(topLeft[0]);
  12103. const intTop = Math.round(topLeft[1]);
  12104. let pdfOpenParams = `#page=${pageNumber}`;
  12105. if (!this.isInPresentationMode) {
  12106. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  12107. }
  12108. this._location = {
  12109. pageNumber,
  12110. scale: normalizedScaleValue,
  12111. top: intTop,
  12112. left: intLeft,
  12113. rotation: this._pagesRotation,
  12114. pdfOpenParams
  12115. };
  12116. }
  12117. update() {
  12118. const visible = this._getVisiblePages();
  12119. const visiblePages = visible.views,
  12120. numVisiblePages = visiblePages.length;
  12121. if (numVisiblePages === 0) {
  12122. return;
  12123. }
  12124. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  12125. this.#buffer.resize(newCacheSize, visible.ids);
  12126. this.renderingQueue.renderHighestPriority(visible);
  12127. const isSimpleLayout = this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE || this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL);
  12128. const currentId = this._currentPageNumber;
  12129. let stillFullyVisible = false;
  12130. for (const page of visiblePages) {
  12131. if (page.percent < 100) {
  12132. break;
  12133. }
  12134. if (page.id === currentId && isSimpleLayout) {
  12135. stillFullyVisible = true;
  12136. break;
  12137. }
  12138. }
  12139. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  12140. this._updateLocation(visible.first);
  12141. this.eventBus.dispatch("updateviewarea", {
  12142. source: this,
  12143. location: this._location
  12144. });
  12145. }
  12146. containsElement(element) {
  12147. return this.container.contains(element);
  12148. }
  12149. focus() {
  12150. this.container.focus();
  12151. }
  12152. get _isContainerRtl() {
  12153. return getComputedStyle(this.container).direction === "rtl";
  12154. }
  12155. get isInPresentationMode() {
  12156. return this.presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.FULLSCREEN;
  12157. }
  12158. get isChangingPresentationMode() {
  12159. return this.presentationModeState === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.PresentationModeState.CHANGING;
  12160. }
  12161. get isHorizontalScrollbarEnabled() {
  12162. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  12163. }
  12164. get isVerticalScrollbarEnabled() {
  12165. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  12166. }
  12167. _getVisiblePages() {
  12168. const views = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
  12169. horizontal = this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL,
  12170. rtl = horizontal && this._isContainerRtl;
  12171. // console.log('test-views',views,horizontal, rtl )
  12172. return (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.getVisibleElements)({
  12173. scrollEl: this.container,
  12174. views,
  12175. sortByVisibility: true,
  12176. horizontal,
  12177. rtl
  12178. });
  12179. }
  12180. cleanup() {
  12181. for (const pageView of this._pages) {
  12182. if (pageView.renderingState !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.RenderingStates.FINISHED) {
  12183. pageView.reset();
  12184. }
  12185. }
  12186. }
  12187. _cancelRendering() {
  12188. for (const pageView of this._pages) {
  12189. pageView.cancelRendering();
  12190. }
  12191. }
  12192. async #ensurePdfPageLoaded(pageView) {
  12193. if (pageView.pdfPage) {
  12194. return pageView.pdfPage;
  12195. }
  12196. try {
  12197. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  12198. if (!pageView.pdfPage) {
  12199. pageView.setPdfPage(pdfPage);
  12200. }
  12201. return pdfPage;
  12202. } catch (reason) {
  12203. console.error("Unable to get page for page view", reason);
  12204. return null;
  12205. }
  12206. }
  12207. #getScrollAhead(visible) {
  12208. if (visible.first?.id === 1) {
  12209. return true;
  12210. } else if (visible.last?.id === this.pagesCount) {
  12211. return false;
  12212. }
  12213. switch (this._scrollMode) {
  12214. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE:
  12215. return this.#scrollModePageState.scrollDown;
  12216. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL:
  12217. return this.scroll.right;
  12218. }
  12219. return this.scroll.down;
  12220. }
  12221. forceRendering(currentlyVisiblePages) {
  12222. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  12223. const scrollAhead = this.#getScrollAhead(visiblePages);
  12224. const preRenderExtra = this._spreadMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE && this._scrollMode !== _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL;
  12225. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  12226. if (pageView) {
  12227. this.#ensurePdfPageLoaded(pageView).then(() => {
  12228. this.renderingQueue.renderView(pageView);
  12229. });
  12230. return true;
  12231. }
  12232. return false;
  12233. }
  12234. get hasEqualPageSizes() {
  12235. const firstPageView = this._pages[0];
  12236. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  12237. const pageView = this._pages[i];
  12238. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  12239. return false;
  12240. }
  12241. }
  12242. return true;
  12243. }
  12244. getPagesOverview() {
  12245. let initialOrientation;
  12246. return this._pages.map(pageView => {
  12247. const viewport = pageView.pdfPage.getViewport({
  12248. scale: 1
  12249. });
  12250. const orientation = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isPortraitOrientation)(viewport);
  12251. if (initialOrientation === undefined) {
  12252. initialOrientation = orientation;
  12253. } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
  12254. return {
  12255. width: viewport.height,
  12256. height: viewport.width,
  12257. rotation: (viewport.rotation - 90) % 360
  12258. };
  12259. }
  12260. return {
  12261. width: viewport.width,
  12262. height: viewport.height,
  12263. rotation: viewport.rotation
  12264. };
  12265. });
  12266. }
  12267. get optionalContentConfigPromise() {
  12268. if (!this.pdfDocument) {
  12269. return Promise.resolve(null);
  12270. }
  12271. if (!this._optionalContentConfigPromise) {
  12272. console.error("optionalContentConfigPromise: Not initialized yet.");
  12273. return this.pdfDocument.getOptionalContentConfig({
  12274. intent: "display"
  12275. });
  12276. }
  12277. return this._optionalContentConfigPromise;
  12278. }
  12279. set optionalContentConfigPromise(promise) {
  12280. if (!(promise instanceof Promise)) {
  12281. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  12282. }
  12283. if (!this.pdfDocument) {
  12284. return;
  12285. }
  12286. if (!this._optionalContentConfigPromise) {
  12287. return;
  12288. }
  12289. this._optionalContentConfigPromise = promise;
  12290. this.refresh(false, {
  12291. optionalContentConfigPromise: promise
  12292. });
  12293. this.eventBus.dispatch("optionalcontentconfigchanged", {
  12294. source: this,
  12295. promise
  12296. });
  12297. }
  12298. get scrollMode() {
  12299. return this._scrollMode;
  12300. }
  12301. set scrollMode(mode) {
  12302. if (this._scrollMode === mode) {
  12303. return;
  12304. }
  12305. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidScrollMode)(mode)) {
  12306. throw new Error(`Invalid scroll mode: ${mode}`);
  12307. }
  12308. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  12309. return;
  12310. }
  12311. this._previousScrollMode = this._scrollMode;
  12312. this._scrollMode = mode;
  12313. this.eventBus.dispatch("scrollmodechanged", {
  12314. source: this,
  12315. mode
  12316. });
  12317. this._updateScrollMode(this._currentPageNumber);
  12318. }
  12319. _updateScrollMode(pageNumber = null) {
  12320. const scrollMode = this._scrollMode,
  12321. viewer = this.viewer;
  12322. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL);
  12323. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.WRAPPED);
  12324. if (!this.pdfDocument || !pageNumber) {
  12325. return;
  12326. }
  12327. if (scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  12328. this.#ensurePageViewVisible();
  12329. } else if (this._previousScrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  12330. this._updateSpreadMode();
  12331. }
  12332. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  12333. this.#setScale(this._currentScaleValue, {
  12334. noScroll: true
  12335. });
  12336. }
  12337. this._setCurrentPageNumber(pageNumber, true);
  12338. this.update();
  12339. }
  12340. get spreadMode() {
  12341. return this._spreadMode;
  12342. }
  12343. set spreadMode(mode) {
  12344. if (this._spreadMode === mode) {
  12345. return;
  12346. }
  12347. if (!(0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidSpreadMode)(mode)) {
  12348. throw new Error(`Invalid spread mode: ${mode}`);
  12349. }
  12350. this._spreadMode = mode;
  12351. this.eventBus.dispatch("spreadmodechanged", {
  12352. source: this,
  12353. mode
  12354. });
  12355. this._updateSpreadMode(this._currentPageNumber);
  12356. }
  12357. _updateSpreadMode(pageNumber = null) {
  12358. if (!this.pdfDocument) {
  12359. return;
  12360. }
  12361. const viewer = this.viewer,
  12362. pages = this._pages;
  12363. if (this._scrollMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE) {
  12364. this.#ensurePageViewVisible();
  12365. } else {
  12366. viewer.textContent = "";
  12367. if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  12368. for (const pageView of this._pages) {
  12369. viewer.append(pageView.div);
  12370. }
  12371. } else {
  12372. const parity = this._spreadMode - 1;
  12373. let spread = null;
  12374. for (let i = 0, ii = pages.length; i < ii; ++i) {
  12375. if (spread === null) {
  12376. spread = document.createElement("div");
  12377. spread.className = "spread";
  12378. viewer.append(spread);
  12379. } else if (i % 2 === parity) {
  12380. spread = spread.cloneNode(false);
  12381. viewer.append(spread);
  12382. }
  12383. spread.append(pages[i].div);
  12384. }
  12385. }
  12386. }
  12387. if (!pageNumber) {
  12388. return;
  12389. }
  12390. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  12391. this.#setScale(this._currentScaleValue, {
  12392. noScroll: true
  12393. });
  12394. }
  12395. this._setCurrentPageNumber(pageNumber, true);
  12396. this.update();
  12397. }
  12398. _getPageAdvance(currentPageNumber, previous = false) {
  12399. switch (this._scrollMode) {
  12400. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.WRAPPED:
  12401. {
  12402. const {
  12403. views
  12404. } = this._getVisiblePages(),
  12405. pageLayout = new Map();
  12406. for (const {
  12407. id,
  12408. y,
  12409. percent,
  12410. widthPercent
  12411. } of views) {
  12412. if (percent === 0 || widthPercent < 100) {
  12413. continue;
  12414. }
  12415. let yArray = pageLayout.get(y);
  12416. if (!yArray) {
  12417. pageLayout.set(y, yArray ||= []);
  12418. }
  12419. yArray.push(id);
  12420. }
  12421. for (const yArray of pageLayout.values()) {
  12422. const currentIndex = yArray.indexOf(currentPageNumber);
  12423. if (currentIndex === -1) {
  12424. continue;
  12425. }
  12426. const numPages = yArray.length;
  12427. if (numPages === 1) {
  12428. break;
  12429. }
  12430. if (previous) {
  12431. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  12432. const currentId = yArray[i],
  12433. expectedId = yArray[i + 1] - 1;
  12434. if (currentId < expectedId) {
  12435. return currentPageNumber - expectedId;
  12436. }
  12437. }
  12438. } else {
  12439. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  12440. const currentId = yArray[i],
  12441. expectedId = yArray[i - 1] + 1;
  12442. if (currentId > expectedId) {
  12443. return expectedId - currentPageNumber;
  12444. }
  12445. }
  12446. }
  12447. if (previous) {
  12448. const firstId = yArray[0];
  12449. if (firstId < currentPageNumber) {
  12450. return currentPageNumber - firstId + 1;
  12451. }
  12452. } else {
  12453. const lastId = yArray[numPages - 1];
  12454. if (lastId > currentPageNumber) {
  12455. return lastId - currentPageNumber + 1;
  12456. }
  12457. }
  12458. break;
  12459. }
  12460. break;
  12461. }
  12462. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.HORIZONTAL:
  12463. {
  12464. break;
  12465. }
  12466. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.PAGE:
  12467. case _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.ScrollMode.VERTICAL:
  12468. {
  12469. if (this._spreadMode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.SpreadMode.NONE) {
  12470. break;
  12471. }
  12472. const parity = this._spreadMode - 1;
  12473. if (previous && currentPageNumber % 2 !== parity) {
  12474. break;
  12475. } else if (!previous && currentPageNumber % 2 === parity) {
  12476. break;
  12477. }
  12478. const {
  12479. views
  12480. } = this._getVisiblePages(),
  12481. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  12482. for (const {
  12483. id,
  12484. percent,
  12485. widthPercent
  12486. } of views) {
  12487. if (id !== expectedId) {
  12488. continue;
  12489. }
  12490. if (percent > 0 && widthPercent === 100) {
  12491. return 2;
  12492. }
  12493. break;
  12494. }
  12495. break;
  12496. }
  12497. }
  12498. return 1;
  12499. }
  12500. nextPage() {
  12501. const currentPageNumber = this._currentPageNumber,
  12502. pagesCount = this.pagesCount;
  12503. if (currentPageNumber >= pagesCount) {
  12504. return false;
  12505. }
  12506. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  12507. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  12508. return true;
  12509. }
  12510. previousPage() {
  12511. const currentPageNumber = this._currentPageNumber;
  12512. if (currentPageNumber <= 1) {
  12513. return false;
  12514. }
  12515. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  12516. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  12517. return true;
  12518. }
  12519. increaseScale({
  12520. drawingDelay,
  12521. scaleFactor,
  12522. steps
  12523. } = {}) {
  12524. if (!this.pdfDocument) {
  12525. return;
  12526. }
  12527. let newScale = this._currentScale;
  12528. if (scaleFactor > 1) {
  12529. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12530. } else {
  12531. steps ??= 1;
  12532. do {
  12533. newScale = Math.ceil((newScale * _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12534. } while (--steps > 0 && newScale < _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE);
  12535. }
  12536. this.#setScale(Math.min(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE, newScale), {
  12537. noScroll: false,
  12538. drawingDelay
  12539. });
  12540. }
  12541. decreaseScale({
  12542. drawingDelay,
  12543. scaleFactor,
  12544. steps
  12545. } = {}) {
  12546. if (!this.pdfDocument) {
  12547. return;
  12548. }
  12549. let newScale = this._currentScale;
  12550. if (scaleFactor > 0 && scaleFactor < 1) {
  12551. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12552. } else {
  12553. steps ??= 1;
  12554. do {
  12555. newScale = Math.floor((newScale / _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12556. } while (--steps > 0 && newScale > _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE);
  12557. }
  12558. this.#setScale(Math.max(_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE, newScale), {
  12559. noScroll: false,
  12560. drawingDelay
  12561. });
  12562. }
  12563. #updateContainerHeightCss(height = this.container.clientHeight) {
  12564. if (height !== this.#previousContainerHeight) {
  12565. this.#previousContainerHeight = height;
  12566. _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.docStyle.setProperty("--viewer-container-height", `${height}px`);
  12567. }
  12568. }
  12569. #resizeObserverCallback(entries) {
  12570. for (const entry of entries) {
  12571. if (entry.target === this.container) {
  12572. this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
  12573. this.#containerTopLeft = null;
  12574. break;
  12575. }
  12576. }
  12577. }
  12578. get containerTopLeft() {
  12579. return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
  12580. }
  12581. get annotationEditorMode() {
  12582. return this.#annotationEditorUIManager ? this.#annotationEditorMode : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  12583. }
  12584. set annotationEditorMode({
  12585. mode,
  12586. editId = null,
  12587. isFromKeyboard = false
  12588. }) {
  12589. if (!this.#annotationEditorUIManager) {
  12590. throw new Error(`The AnnotationEditor is not enabled.`);
  12591. }
  12592. if (this.#annotationEditorMode === mode) {
  12593. return;
  12594. }
  12595. if (!isValidAnnotationEditorMode(mode)) {
  12596. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  12597. }
  12598. if (!this.pdfDocument) {
  12599. return;
  12600. }
  12601. this.#annotationEditorMode = mode;
  12602. this.eventBus.dispatch("annotationeditormodechanged", {
  12603. source: this,
  12604. mode
  12605. });
  12606. this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
  12607. }
  12608. set annotationEditorParams({
  12609. type,
  12610. value
  12611. }) {
  12612. if (!this.#annotationEditorUIManager) {
  12613. throw new Error(`The AnnotationEditor is not enabled.`);
  12614. }
  12615. this.#annotationEditorUIManager.updateParams(type, value);
  12616. }
  12617. refresh(noUpdate = false, updateArgs = Object.create(null)) {
  12618. if (!this.pdfDocument) {
  12619. return;
  12620. }
  12621. for (const pageView of this._pages) {
  12622. pageView.update(updateArgs);
  12623. }
  12624. if (this.#scaleTimeoutId !== null) {
  12625. clearTimeout(this.#scaleTimeoutId);
  12626. this.#scaleTimeoutId = null;
  12627. }
  12628. if (!noUpdate) {
  12629. this.update();
  12630. }
  12631. }
  12632. }
  12633. __webpack_async_result__();
  12634. } catch(e) { __webpack_async_result__(e); } });
  12635. /***/ }),
  12636. /***/ 2603:
  12637. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  12638. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  12639. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12640. /* harmony export */ AbortException: () => (/* binding */ AbortException),
  12641. /* harmony export */ AnnotationEditorLayer: () => (/* binding */ AnnotationEditorLayer),
  12642. /* harmony export */ AnnotationEditorParamsType: () => (/* binding */ AnnotationEditorParamsType),
  12643. /* harmony export */ AnnotationEditorType: () => (/* binding */ AnnotationEditorType),
  12644. /* harmony export */ AnnotationEditorUIManager: () => (/* binding */ AnnotationEditorUIManager),
  12645. /* harmony export */ AnnotationLayer: () => (/* binding */ AnnotationLayer),
  12646. /* harmony export */ AnnotationMode: () => (/* binding */ AnnotationMode),
  12647. /* harmony export */ ColorPicker: () => (/* binding */ ColorPicker),
  12648. /* harmony export */ DOMSVGFactory: () => (/* binding */ DOMSVGFactory),
  12649. /* harmony export */ DrawLayer: () => (/* binding */ DrawLayer),
  12650. /* harmony export */ GlobalWorkerOptions: () => (/* binding */ GlobalWorkerOptions),
  12651. /* harmony export */ InvalidPDFException: () => (/* binding */ InvalidPDFException),
  12652. /* harmony export */ MissingPDFException: () => (/* binding */ MissingPDFException),
  12653. /* harmony export */ PDFDateString: () => (/* binding */ PDFDateString),
  12654. /* harmony export */ PDFWorker: () => (/* binding */ PDFWorker),
  12655. /* harmony export */ PasswordResponses: () => (/* binding */ PasswordResponses),
  12656. /* harmony export */ PermissionFlag: () => (/* binding */ PermissionFlag),
  12657. /* harmony export */ PixelsPerInch: () => (/* binding */ PixelsPerInch),
  12658. /* harmony export */ RenderingCancelledException: () => (/* binding */ RenderingCancelledException),
  12659. /* harmony export */ UnexpectedResponseException: () => (/* binding */ UnexpectedResponseException),
  12660. /* harmony export */ XfaLayer: () => (/* binding */ XfaLayer),
  12661. /* harmony export */ build: () => (/* binding */ build),
  12662. /* harmony export */ createValidAbsoluteUrl: () => (/* binding */ createValidAbsoluteUrl),
  12663. /* harmony export */ fetchData: () => (/* binding */ fetchData),
  12664. /* harmony export */ getDocument: () => (/* binding */ getDocument),
  12665. /* harmony export */ getFilenameFromUrl: () => (/* binding */ getFilenameFromUrl),
  12666. /* harmony export */ getPdfFilenameFromUrl: () => (/* binding */ getPdfFilenameFromUrl),
  12667. /* harmony export */ getXfaPageViewport: () => (/* binding */ getXfaPageViewport),
  12668. /* harmony export */ isDataScheme: () => (/* binding */ isDataScheme),
  12669. /* harmony export */ isPdfFile: () => (/* binding */ isPdfFile),
  12670. /* harmony export */ noContextMenu: () => (/* binding */ noContextMenu),
  12671. /* harmony export */ normalizeUnicode: () => (/* binding */ normalizeUnicode),
  12672. /* harmony export */ renderTextLayer: () => (/* binding */ renderTextLayer),
  12673. /* harmony export */ setLayerDimensions: () => (/* binding */ setLayerDimensions),
  12674. /* harmony export */ shadow: () => (/* binding */ shadow),
  12675. /* harmony export */ updateTextLayer: () => (/* binding */ updateTextLayer),
  12676. /* harmony export */ version: () => (/* binding */ version)
  12677. /* harmony export */ });
  12678. /* unused harmony exports CMapCompressionType, FeatureTest, ImageKind, OPS, Outliner, PDFDataRangeTransport, Util, VerbosityLevel */
  12679. if (!globalThis.pdfjsLib) {
  12680. await globalThis.pdfjsLibPromise;
  12681. }
  12682. const {
  12683. AbortException,
  12684. AnnotationEditorLayer,
  12685. AnnotationEditorParamsType,
  12686. AnnotationEditorType,
  12687. AnnotationEditorUIManager,
  12688. AnnotationLayer,
  12689. AnnotationMode,
  12690. build,
  12691. CMapCompressionType,
  12692. ColorPicker,
  12693. createValidAbsoluteUrl,
  12694. DOMSVGFactory,
  12695. DrawLayer,
  12696. FeatureTest,
  12697. fetchData,
  12698. getDocument,
  12699. getFilenameFromUrl,
  12700. getPdfFilenameFromUrl,
  12701. getXfaPageViewport,
  12702. GlobalWorkerOptions,
  12703. ImageKind,
  12704. InvalidPDFException,
  12705. isDataScheme,
  12706. isPdfFile,
  12707. MissingPDFException,
  12708. noContextMenu,
  12709. normalizeUnicode,
  12710. OPS,
  12711. Outliner,
  12712. PasswordResponses,
  12713. PDFDataRangeTransport,
  12714. PDFDateString,
  12715. PDFWorker,
  12716. PermissionFlag,
  12717. PixelsPerInch,
  12718. RenderingCancelledException,
  12719. renderTextLayer,
  12720. setLayerDimensions,
  12721. shadow,
  12722. UnexpectedResponseException,
  12723. updateTextLayer,
  12724. Util,
  12725. VerbosityLevel,
  12726. version,
  12727. XfaLayer
  12728. } = globalThis.pdfjsLib;
  12729. __webpack_async_result__();
  12730. } catch(e) { __webpack_async_result__(e); } }, 1);
  12731. /***/ }),
  12732. /***/ 8224:
  12733. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  12734. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12735. /* harmony export */ BasePreferences: () => (/* binding */ BasePreferences)
  12736. /* harmony export */ });
  12737. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9840);
  12738. class BasePreferences {
  12739. #browserDefaults = Object.freeze({
  12740. canvasMaxAreaInBytes: -1,
  12741. isInAutomation: false,
  12742. supportsCaretBrowsingMode: false,
  12743. supportsDocumentFonts: true,
  12744. supportsIntegratedFind: false,
  12745. supportsMouseWheelZoomCtrlKey: true,
  12746. supportsMouseWheelZoomMetaKey: true,
  12747. supportsPinchToZoom: true
  12748. });
  12749. #defaults = Object.freeze({
  12750. annotationEditorMode: 0,
  12751. annotationMode: 2,
  12752. cursorToolOnLoad: 0,
  12753. defaultZoomDelay: 400,
  12754. defaultZoomValue: "",
  12755. disablePageLabels: false,
  12756. enableHighlightEditor: false,
  12757. enableHighlightFloatingButton: false,
  12758. enableML: false,
  12759. enablePermissions: false,
  12760. enablePrintAutoRotate: true,
  12761. enableScripting: true,
  12762. enableStampEditor: true,
  12763. externalLinkTarget: 0,
  12764. highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
  12765. historyUpdateUrl: false,
  12766. ignoreDestinationZoom: false,
  12767. forcePageColors: false,
  12768. pageColorsBackground: "Canvas",
  12769. pageColorsForeground: "CanvasText",
  12770. pdfBugEnabled: false,
  12771. sidebarViewOnLoad: -1,
  12772. scrollModeOnLoad: -1,
  12773. spreadModeOnLoad: -1,
  12774. textLayerMode: 1,
  12775. viewOnLoad: 0,
  12776. disableAutoFetch: false,
  12777. disableFontFace: false,
  12778. disableRange: false,
  12779. disableStream: false,
  12780. enableXfa: true,
  12781. viewerCssTheme: 0
  12782. });
  12783. #prefs = Object.create(null);
  12784. #initializedPromise = null;
  12785. constructor() {
  12786. if (this.constructor === BasePreferences) {
  12787. throw new Error("Cannot initialize BasePreferences.");
  12788. }
  12789. this.#initializedPromise = this._readFromStorage(this.#defaults).then(({
  12790. browserPrefs,
  12791. prefs
  12792. }) => {
  12793. const options = Object.create(null);
  12794. for (const [name, val] of Object.entries(this.#browserDefaults)) {
  12795. const prefVal = browserPrefs?.[name];
  12796. options[name] = typeof prefVal === typeof val ? prefVal : val;
  12797. }
  12798. for (const [name, val] of Object.entries(this.#defaults)) {
  12799. const prefVal = prefs?.[name];
  12800. options[name] = this.#prefs[name] = typeof prefVal === typeof val ? prefVal : val;
  12801. }
  12802. _app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.setAll(options, true);
  12803. });
  12804. }
  12805. async _writeToStorage(prefObj) {
  12806. throw new Error("Not implemented: _writeToStorage");
  12807. }
  12808. async _readFromStorage(prefObj) {
  12809. throw new Error("Not implemented: _readFromStorage");
  12810. }
  12811. #updatePref({
  12812. name,
  12813. value
  12814. }) {
  12815. throw new Error("Not implemented: #updatePref");
  12816. }
  12817. async reset() {
  12818. await this.#initializedPromise;
  12819. const oldPrefs = structuredClone(this.#prefs);
  12820. this.#prefs = Object.create(null);
  12821. try {
  12822. await this._writeToStorage(this.#defaults);
  12823. } catch (reason) {
  12824. this.#prefs = oldPrefs;
  12825. throw reason;
  12826. }
  12827. }
  12828. async set(name, value) {
  12829. await this.#initializedPromise;
  12830. const defaultValue = this.#defaults[name],
  12831. oldPrefs = structuredClone(this.#prefs);
  12832. if (defaultValue === undefined) {
  12833. throw new Error(`Set preference: "${name}" is undefined.`);
  12834. } else if (value === undefined) {
  12835. throw new Error("Set preference: no value is specified.");
  12836. }
  12837. const valueType = typeof value,
  12838. defaultType = typeof defaultValue;
  12839. if (valueType !== defaultType) {
  12840. if (valueType === "number" && defaultType === "string") {
  12841. value = value.toString();
  12842. } else {
  12843. throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
  12844. }
  12845. } else if (valueType === "number" && !Number.isInteger(value)) {
  12846. throw new Error(`Set preference: "${value}" must be an integer.`);
  12847. }
  12848. this.#prefs[name] = value;
  12849. try {
  12850. await this._writeToStorage(this.#prefs);
  12851. } catch (reason) {
  12852. this.#prefs = oldPrefs;
  12853. throw reason;
  12854. }
  12855. }
  12856. async get(name) {
  12857. await this.#initializedPromise;
  12858. const defaultValue = this.#defaults[name];
  12859. if (defaultValue === undefined) {
  12860. throw new Error(`Get preference: "${name}" is undefined.`);
  12861. }
  12862. return this.#prefs[name] ?? defaultValue;
  12863. }
  12864. get initializedPromise() {
  12865. return this.#initializedPromise;
  12866. }
  12867. }
  12868. /***/ }),
  12869. /***/ 659:
  12870. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  12871. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  12872. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12873. /* harmony export */ getXfaHtmlForPrinting: () => (/* binding */ getXfaHtmlForPrinting)
  12874. /* harmony export */ });
  12875. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  12876. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(787);
  12877. /* harmony import */ var _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2973);
  12878. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__]);
  12879. ([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__, _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  12880. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  12881. const xfaHtml = pdfDocument.allXfaHtml;
  12882. const linkService = new _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_1__.SimpleLinkService();
  12883. const scale = Math.round(pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  12884. for (const xfaPage of xfaHtml.children) {
  12885. const page = document.createElement("div");
  12886. page.className = "xfaPrintedPage";
  12887. printContainer.append(page);
  12888. const builder = new _xfa_layer_builder_js__WEBPACK_IMPORTED_MODULE_2__.XfaLayerBuilder({
  12889. pdfPage: null,
  12890. annotationStorage: pdfDocument.annotationStorage,
  12891. linkService,
  12892. xfaHtml: xfaPage
  12893. });
  12894. const viewport = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.getXfaPageViewport)(xfaPage, {
  12895. scale
  12896. });
  12897. builder.render(viewport, "print");
  12898. page.append(builder.div);
  12899. }
  12900. }
  12901. __webpack_async_result__();
  12902. } catch(e) { __webpack_async_result__(e); } });
  12903. /***/ }),
  12904. /***/ 1900:
  12905. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  12906. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  12907. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  12908. /* harmony export */ SecondaryToolbar: () => (/* binding */ SecondaryToolbar)
  12909. /* harmony export */ });
  12910. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  12911. /* harmony import */ var _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6285);
  12912. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__]);
  12913. _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  12914. class SecondaryToolbar {
  12915. #opts;
  12916. constructor(options, eventBus) {
  12917. this.#opts = options;
  12918. const buttons = [{
  12919. element: options.presentationModeButton,
  12920. eventName: "presentationmode",
  12921. close: true
  12922. }, {
  12923. element: options.printButton,
  12924. eventName: "print",
  12925. close: true
  12926. }, {
  12927. element: options.downloadButton,
  12928. eventName: "download",
  12929. close: true
  12930. }, {
  12931. element: options.viewBookmarkButton,
  12932. eventName: null,
  12933. close: true
  12934. }, {
  12935. element: options.firstPageButton,
  12936. eventName: "firstpage",
  12937. close: true
  12938. }, {
  12939. element: options.lastPageButton,
  12940. eventName: "lastpage",
  12941. close: true
  12942. }, {
  12943. element: options.pageRotateCwButton,
  12944. eventName: "rotatecw",
  12945. close: false
  12946. }, {
  12947. element: options.pageRotateCcwButton,
  12948. eventName: "rotateccw",
  12949. close: false
  12950. }, {
  12951. element: options.cursorSelectToolButton,
  12952. eventName: "switchcursortool",
  12953. eventDetails: {
  12954. tool: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT
  12955. },
  12956. close: true
  12957. }, {
  12958. element: options.cursorHandToolButton,
  12959. eventName: "switchcursortool",
  12960. eventDetails: {
  12961. tool: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND
  12962. },
  12963. close: true
  12964. }, {
  12965. element: options.scrollPageButton,
  12966. eventName: "switchscrollmode",
  12967. eventDetails: {
  12968. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE
  12969. },
  12970. close: true
  12971. }, {
  12972. element: options.scrollVerticalButton,
  12973. eventName: "switchscrollmode",
  12974. eventDetails: {
  12975. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL
  12976. },
  12977. close: true
  12978. }, {
  12979. element: options.scrollHorizontalButton,
  12980. eventName: "switchscrollmode",
  12981. eventDetails: {
  12982. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL
  12983. },
  12984. close: true
  12985. }, {
  12986. element: options.scrollWrappedButton,
  12987. eventName: "switchscrollmode",
  12988. eventDetails: {
  12989. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.WRAPPED
  12990. },
  12991. close: true
  12992. }, {
  12993. element: options.spreadNoneButton,
  12994. eventName: "switchspreadmode",
  12995. eventDetails: {
  12996. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE
  12997. },
  12998. close: true
  12999. }, {
  13000. element: options.spreadOddButton,
  13001. eventName: "switchspreadmode",
  13002. eventDetails: {
  13003. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.ODD
  13004. },
  13005. close: true
  13006. }, {
  13007. element: options.spreadEvenButton,
  13008. eventName: "switchspreadmode",
  13009. eventDetails: {
  13010. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.EVEN
  13011. },
  13012. close: true
  13013. }, {
  13014. element: options.documentPropertiesButton,
  13015. eventName: "documentproperties",
  13016. close: true
  13017. }];
  13018. buttons.push({
  13019. element: options.openFileButton,
  13020. eventName: "openfile",
  13021. close: true
  13022. });
  13023. this.eventBus = eventBus;
  13024. this.opened = false;
  13025. this.#bindListeners(buttons);
  13026. this.reset();
  13027. }
  13028. get isOpen() {
  13029. return this.opened;
  13030. }
  13031. setPageNumber(pageNumber) {
  13032. this.pageNumber = pageNumber;
  13033. this.#updateUIState();
  13034. }
  13035. setPagesCount(pagesCount) {
  13036. this.pagesCount = pagesCount;
  13037. this.#updateUIState();
  13038. }
  13039. reset() {
  13040. this.pageNumber = 0;
  13041. this.pagesCount = 0;
  13042. this.#updateUIState();
  13043. this.eventBus.dispatch("switchcursortool", {
  13044. source: this,
  13045. reset: true
  13046. });
  13047. this.#scrollModeChanged({
  13048. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL
  13049. });
  13050. this.#spreadModeChanged({
  13051. mode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE
  13052. });
  13053. }
  13054. #updateUIState() {
  13055. const {
  13056. firstPageButton,
  13057. lastPageButton,
  13058. pageRotateCwButton,
  13059. pageRotateCcwButton
  13060. } = this.#opts;
  13061. firstPageButton.disabled = this.pageNumber <= 1;
  13062. lastPageButton.disabled = this.pageNumber >= this.pagesCount;
  13063. pageRotateCwButton.disabled = this.pagesCount === 0;
  13064. pageRotateCcwButton.disabled = this.pagesCount === 0;
  13065. }
  13066. #bindListeners(buttons) {
  13067. const {
  13068. eventBus
  13069. } = this;
  13070. const {
  13071. toggleButton
  13072. } = this.#opts;
  13073. toggleButton.addEventListener("click", this.toggle.bind(this));
  13074. for (const {
  13075. element,
  13076. eventName,
  13077. close,
  13078. eventDetails
  13079. } of buttons) {
  13080. element.addEventListener("click", evt => {
  13081. if (eventName !== null) {
  13082. eventBus.dispatch(eventName, {
  13083. source: this,
  13084. ...eventDetails
  13085. });
  13086. }
  13087. if (close) {
  13088. this.close();
  13089. }
  13090. eventBus.dispatch("reporttelemetry", {
  13091. source: this,
  13092. details: {
  13093. type: "buttons",
  13094. data: {
  13095. id: element.id
  13096. }
  13097. }
  13098. });
  13099. });
  13100. }
  13101. eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this));
  13102. eventBus._on("scrollmodechanged", this.#scrollModeChanged.bind(this));
  13103. eventBus._on("spreadmodechanged", this.#spreadModeChanged.bind(this));
  13104. }
  13105. #cursorToolChanged({
  13106. tool
  13107. }) {
  13108. const {
  13109. cursorSelectToolButton,
  13110. cursorHandToolButton
  13111. } = this.#opts;
  13112. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(cursorSelectToolButton, tool === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.SELECT);
  13113. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(cursorHandToolButton, tool === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.CursorTool.HAND);
  13114. }
  13115. #scrollModeChanged({
  13116. mode
  13117. }) {
  13118. const {
  13119. scrollPageButton,
  13120. scrollVerticalButton,
  13121. scrollHorizontalButton,
  13122. scrollWrappedButton,
  13123. spreadNoneButton,
  13124. spreadOddButton,
  13125. spreadEvenButton
  13126. } = this.#opts;
  13127. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollPageButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.PAGE);
  13128. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollVerticalButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.VERTICAL);
  13129. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollHorizontalButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL);
  13130. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(scrollWrappedButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.WRAPPED);
  13131. const forceScrollModePage = this.pagesCount > _pdf_viewer_js__WEBPACK_IMPORTED_MODULE_1__.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  13132. scrollPageButton.disabled = forceScrollModePage;
  13133. scrollVerticalButton.disabled = forceScrollModePage;
  13134. scrollHorizontalButton.disabled = forceScrollModePage;
  13135. scrollWrappedButton.disabled = forceScrollModePage;
  13136. const isHorizontal = mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.ScrollMode.HORIZONTAL;
  13137. spreadNoneButton.disabled = isHorizontal;
  13138. spreadOddButton.disabled = isHorizontal;
  13139. spreadEvenButton.disabled = isHorizontal;
  13140. }
  13141. #spreadModeChanged({
  13142. mode
  13143. }) {
  13144. const {
  13145. spreadNoneButton,
  13146. spreadOddButton,
  13147. spreadEvenButton
  13148. } = this.#opts;
  13149. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadNoneButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.NONE);
  13150. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadOddButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.ODD);
  13151. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCheckedBtn)(spreadEvenButton, mode === _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode.EVEN);
  13152. }
  13153. open() {
  13154. if (this.opened) {
  13155. return;
  13156. }
  13157. this.opened = true;
  13158. const {
  13159. toggleButton,
  13160. toolbar
  13161. } = this.#opts;
  13162. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(toggleButton, true, toolbar);
  13163. }
  13164. close() {
  13165. if (!this.opened) {
  13166. return;
  13167. }
  13168. this.opened = false;
  13169. const {
  13170. toggleButton,
  13171. toolbar
  13172. } = this.#opts;
  13173. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleExpandedBtn)(toggleButton, false, toolbar);
  13174. }
  13175. toggle() {
  13176. if (this.opened) {
  13177. this.close();
  13178. } else {
  13179. this.open();
  13180. }
  13181. }
  13182. }
  13183. __webpack_async_result__();
  13184. } catch(e) { __webpack_async_result__(e); } });
  13185. /***/ }),
  13186. /***/ 6698:
  13187. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  13188. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13189. /* harmony export */ StructTreeLayerBuilder: () => (/* binding */ StructTreeLayerBuilder)
  13190. /* harmony export */ });
  13191. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  13192. const PDF_ROLE_TO_HTML_ROLE = {
  13193. Document: null,
  13194. DocumentFragment: null,
  13195. Part: "group",
  13196. Sect: "group",
  13197. Div: "group",
  13198. Aside: "note",
  13199. NonStruct: "none",
  13200. P: null,
  13201. H: "heading",
  13202. Title: null,
  13203. FENote: "note",
  13204. Sub: "group",
  13205. Lbl: null,
  13206. Span: null,
  13207. Em: null,
  13208. Strong: null,
  13209. Link: "link",
  13210. Annot: "note",
  13211. Form: "form",
  13212. Ruby: null,
  13213. RB: null,
  13214. RT: null,
  13215. RP: null,
  13216. Warichu: null,
  13217. WT: null,
  13218. WP: null,
  13219. L: "list",
  13220. LI: "listitem",
  13221. LBody: null,
  13222. Table: "table",
  13223. TR: "row",
  13224. TH: "columnheader",
  13225. TD: "cell",
  13226. THead: "columnheader",
  13227. TBody: null,
  13228. TFoot: null,
  13229. Caption: null,
  13230. Figure: "figure",
  13231. Formula: null,
  13232. Artifact: null
  13233. };
  13234. const HEADING_PATTERN = /^H(\d+)$/;
  13235. class StructTreeLayerBuilder {
  13236. #treeDom = undefined;
  13237. get renderingDone() {
  13238. return this.#treeDom !== undefined;
  13239. }
  13240. render(structTree) {
  13241. if (this.#treeDom !== undefined) {
  13242. return this.#treeDom;
  13243. }
  13244. const treeDom = this.#walk(structTree);
  13245. treeDom?.classList.add("structTree");
  13246. return this.#treeDom = treeDom;
  13247. }
  13248. hide() {
  13249. if (this.#treeDom && !this.#treeDom.hidden) {
  13250. this.#treeDom.hidden = true;
  13251. }
  13252. }
  13253. show() {
  13254. if (this.#treeDom?.hidden) {
  13255. this.#treeDom.hidden = false;
  13256. }
  13257. }
  13258. #setAttributes(structElement, htmlElement) {
  13259. const {
  13260. alt,
  13261. id,
  13262. lang
  13263. } = structElement;
  13264. if (alt !== undefined) {
  13265. htmlElement.setAttribute("aria-label", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(alt));
  13266. }
  13267. if (id !== undefined) {
  13268. htmlElement.setAttribute("aria-owns", id);
  13269. }
  13270. if (lang !== undefined) {
  13271. htmlElement.setAttribute("lang", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.removeNullCharacters)(lang, true));
  13272. }
  13273. }
  13274. #walk(node) {
  13275. if (!node) {
  13276. return null;
  13277. }
  13278. const element = document.createElement("span");
  13279. if ("role" in node) {
  13280. const {
  13281. role
  13282. } = node;
  13283. const match = role.match(HEADING_PATTERN);
  13284. if (match) {
  13285. element.setAttribute("role", "heading");
  13286. element.setAttribute("aria-level", match[1]);
  13287. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  13288. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  13289. }
  13290. }
  13291. this.#setAttributes(node, element);
  13292. if (node.children) {
  13293. if (node.children.length === 1 && "id" in node.children[0]) {
  13294. this.#setAttributes(node.children[0], element);
  13295. } else {
  13296. for (const kid of node.children) {
  13297. element.append(this.#walk(kid));
  13298. }
  13299. }
  13300. }
  13301. return element;
  13302. }
  13303. }
  13304. /***/ }),
  13305. /***/ 5860:
  13306. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  13307. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13308. /* harmony export */ TextAccessibilityManager: () => (/* binding */ TextAccessibilityManager)
  13309. /* harmony export */ });
  13310. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  13311. class TextAccessibilityManager {
  13312. #enabled = false;
  13313. #textChildren = null;
  13314. #textNodes = new Map();
  13315. #waitingElements = new Map();
  13316. setTextMapping(textDivs) {
  13317. this.#textChildren = textDivs;
  13318. }
  13319. static #compareElementPositions(e1, e2) {
  13320. const rect1 = e1.getBoundingClientRect();
  13321. const rect2 = e2.getBoundingClientRect();
  13322. if (rect1.width === 0 && rect1.height === 0) {
  13323. return +1;
  13324. }
  13325. if (rect2.width === 0 && rect2.height === 0) {
  13326. return -1;
  13327. }
  13328. const top1 = rect1.y;
  13329. const bot1 = rect1.y + rect1.height;
  13330. const mid1 = rect1.y + rect1.height / 2;
  13331. const top2 = rect2.y;
  13332. const bot2 = rect2.y + rect2.height;
  13333. const mid2 = rect2.y + rect2.height / 2;
  13334. if (mid1 <= top2 && mid2 >= bot1) {
  13335. return -1;
  13336. }
  13337. if (mid2 <= top1 && mid1 >= bot2) {
  13338. return +1;
  13339. }
  13340. const centerX1 = rect1.x + rect1.width / 2;
  13341. const centerX2 = rect2.x + rect2.width / 2;
  13342. return centerX1 - centerX2;
  13343. }
  13344. enable() {
  13345. if (this.#enabled) {
  13346. throw new Error("TextAccessibilityManager is already enabled.");
  13347. }
  13348. if (!this.#textChildren) {
  13349. throw new Error("Text divs and strings have not been set.");
  13350. }
  13351. this.#enabled = true;
  13352. this.#textChildren = this.#textChildren.slice();
  13353. this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
  13354. if (this.#textNodes.size > 0) {
  13355. const textChildren = this.#textChildren;
  13356. for (const [id, nodeIndex] of this.#textNodes) {
  13357. const element = document.getElementById(id);
  13358. if (!element) {
  13359. this.#textNodes.delete(id);
  13360. continue;
  13361. }
  13362. this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
  13363. }
  13364. }
  13365. for (const [element, isRemovable] of this.#waitingElements) {
  13366. this.addPointerInTextLayer(element, isRemovable);
  13367. }
  13368. this.#waitingElements.clear();
  13369. }
  13370. disable() {
  13371. if (!this.#enabled) {
  13372. return;
  13373. }
  13374. this.#waitingElements.clear();
  13375. this.#textChildren = null;
  13376. this.#enabled = false;
  13377. }
  13378. removePointerInTextLayer(element) {
  13379. if (!this.#enabled) {
  13380. this.#waitingElements.delete(element);
  13381. return;
  13382. }
  13383. const children = this.#textChildren;
  13384. if (!children || children.length === 0) {
  13385. return;
  13386. }
  13387. const {
  13388. id
  13389. } = element;
  13390. const nodeIndex = this.#textNodes.get(id);
  13391. if (nodeIndex === undefined) {
  13392. return;
  13393. }
  13394. const node = children[nodeIndex];
  13395. this.#textNodes.delete(id);
  13396. let owns = node.getAttribute("aria-owns");
  13397. if (owns?.includes(id)) {
  13398. owns = owns.split(" ").filter(x => x !== id).join(" ");
  13399. if (owns) {
  13400. node.setAttribute("aria-owns", owns);
  13401. } else {
  13402. node.removeAttribute("aria-owns");
  13403. node.setAttribute("role", "presentation");
  13404. }
  13405. }
  13406. }
  13407. #addIdToAriaOwns(id, node) {
  13408. const owns = node.getAttribute("aria-owns");
  13409. if (!owns?.includes(id)) {
  13410. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  13411. }
  13412. node.removeAttribute("role");
  13413. }
  13414. addPointerInTextLayer(element, isRemovable) {
  13415. const {
  13416. id
  13417. } = element;
  13418. if (!id) {
  13419. return null;
  13420. }
  13421. if (!this.#enabled) {
  13422. this.#waitingElements.set(element, isRemovable);
  13423. return null;
  13424. }
  13425. if (isRemovable) {
  13426. this.removePointerInTextLayer(element);
  13427. }
  13428. const children = this.#textChildren;
  13429. if (!children || children.length === 0) {
  13430. return null;
  13431. }
  13432. const index = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
  13433. const nodeIndex = Math.max(0, index - 1);
  13434. const child = children[nodeIndex];
  13435. this.#addIdToAriaOwns(id, child);
  13436. this.#textNodes.set(id, nodeIndex);
  13437. const parent = child.parentNode;
  13438. return parent?.classList.contains("markedContent") ? parent.id : null;
  13439. }
  13440. moveElementInDOM(container, element, contentElement, isRemovable) {
  13441. const id = this.addPointerInTextLayer(contentElement, isRemovable);
  13442. if (!container.hasChildNodes()) {
  13443. container.append(element);
  13444. return id;
  13445. }
  13446. const children = Array.from(container.childNodes).filter(node => node !== element);
  13447. if (children.length === 0) {
  13448. return id;
  13449. }
  13450. const elementToCompare = contentElement || element;
  13451. const index = (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
  13452. if (index === 0) {
  13453. children[0].before(element);
  13454. } else {
  13455. children[index - 1].after(element);
  13456. }
  13457. return id;
  13458. }
  13459. }
  13460. /***/ }),
  13461. /***/ 2027:
  13462. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  13463. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13464. /* harmony export */ TextHighlighter: () => (/* binding */ TextHighlighter)
  13465. /* harmony export */ });
  13466. class TextHighlighter {
  13467. #eventAbortController = null;
  13468. constructor({
  13469. findController,
  13470. eventBus,
  13471. pageIndex
  13472. }) {
  13473. this.findController = findController;
  13474. this.matches = [];
  13475. this.eventBus = eventBus;
  13476. this.pageIdx = pageIndex;
  13477. this.textDivs = null;
  13478. this.textContentItemsStr = null;
  13479. this.enabled = false;
  13480. }
  13481. setTextMapping(divs, texts) {
  13482. this.textDivs = divs;
  13483. this.textContentItemsStr = texts;
  13484. }
  13485. enable() {
  13486. if (!this.textDivs || !this.textContentItemsStr) {
  13487. throw new Error("Text divs and strings have not been set.");
  13488. }
  13489. if (this.enabled) {
  13490. throw new Error("TextHighlighter is already enabled.");
  13491. }
  13492. this.enabled = true;
  13493. if (!this.#eventAbortController) {
  13494. this.#eventAbortController = new AbortController();
  13495. this.eventBus._on("updatetextlayermatches", evt => {
  13496. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  13497. this._updateMatches();
  13498. }
  13499. }, {
  13500. signal: this.#eventAbortController.signal
  13501. });
  13502. }
  13503. this._updateMatches();
  13504. }
  13505. disable() {
  13506. if (!this.enabled) {
  13507. return;
  13508. }
  13509. this.enabled = false;
  13510. this.#eventAbortController?.abort();
  13511. this.#eventAbortController = null;
  13512. this._updateMatches(true);
  13513. }
  13514. _convertMatches(matches, matchesLength) {
  13515. if (!matches) {
  13516. return [];
  13517. }
  13518. const {
  13519. textContentItemsStr
  13520. } = this;
  13521. let i = 0,
  13522. iIndex = 0;
  13523. const end = textContentItemsStr.length - 1;
  13524. const result = [];
  13525. for (let m = 0, mm = matches.length; m < mm; m++) {
  13526. let matchIdx = matches[m];
  13527. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  13528. iIndex += textContentItemsStr[i].length;
  13529. i++;
  13530. }
  13531. if (i === textContentItemsStr.length) {
  13532. console.error("Could not find a matching mapping");
  13533. }
  13534. const match = {
  13535. begin: {
  13536. divIdx: i,
  13537. offset: matchIdx - iIndex
  13538. }
  13539. };
  13540. matchIdx += matchesLength[m];
  13541. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  13542. iIndex += textContentItemsStr[i].length;
  13543. i++;
  13544. }
  13545. match.end = {
  13546. divIdx: i,
  13547. offset: matchIdx - iIndex
  13548. };
  13549. result.push(match);
  13550. }
  13551. return result;
  13552. }
  13553. _renderMatches(matches) {
  13554. if (matches.length === 0) {
  13555. return;
  13556. }
  13557. const {
  13558. findController,
  13559. pageIdx
  13560. } = this;
  13561. const {
  13562. textContentItemsStr,
  13563. textDivs
  13564. } = this;
  13565. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  13566. const selectedMatchIdx = findController.selected.matchIdx;
  13567. const highlightAll = findController.state.highlightAll;
  13568. let prevEnd = null;
  13569. const infinity = {
  13570. divIdx: -1,
  13571. offset: undefined
  13572. };
  13573. function beginText(begin, className) {
  13574. const divIdx = begin.divIdx;
  13575. textDivs[divIdx].textContent = "";
  13576. return appendTextToDiv(divIdx, 0, begin.offset, className);
  13577. }
  13578. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  13579. let div = textDivs[divIdx];
  13580. if (div.nodeType === Node.TEXT_NODE) {
  13581. const span = document.createElement("span");
  13582. div.before(span);
  13583. span.append(div);
  13584. textDivs[divIdx] = span;
  13585. div = span;
  13586. }
  13587. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  13588. const node = document.createTextNode(content);
  13589. if (className) {
  13590. const span = document.createElement("span");
  13591. span.className = `${className} appended`;
  13592. span.append(node);
  13593. div.append(span);
  13594. return className.includes("selected") ? span.offsetLeft : 0;
  13595. }
  13596. div.append(node);
  13597. return 0;
  13598. }
  13599. let i0 = selectedMatchIdx,
  13600. i1 = i0 + 1;
  13601. if (highlightAll) {
  13602. i0 = 0;
  13603. i1 = matches.length;
  13604. } else if (!isSelectedPage) {
  13605. return;
  13606. }
  13607. let lastDivIdx = -1;
  13608. let lastOffset = -1;
  13609. for (let i = i0; i < i1; i++) {
  13610. const match = matches[i];
  13611. const begin = match.begin;
  13612. if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
  13613. continue;
  13614. }
  13615. lastDivIdx = begin.divIdx;
  13616. lastOffset = begin.offset;
  13617. const end = match.end;
  13618. const isSelected = isSelectedPage && i === selectedMatchIdx;
  13619. const highlightSuffix = isSelected ? " selected" : "";
  13620. let selectedLeft = 0;
  13621. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  13622. if (prevEnd !== null) {
  13623. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13624. }
  13625. beginText(begin);
  13626. } else {
  13627. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  13628. }
  13629. if (begin.divIdx === end.divIdx) {
  13630. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  13631. } else {
  13632. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  13633. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  13634. textDivs[n0].className = "highlight middle" + highlightSuffix;
  13635. }
  13636. beginText(end, "highlight end" + highlightSuffix);
  13637. }
  13638. prevEnd = end;
  13639. if (isSelected) {
  13640. findController.scrollMatchIntoView({
  13641. element: textDivs[begin.divIdx],
  13642. selectedLeft,
  13643. pageIndex: pageIdx,
  13644. matchIndex: selectedMatchIdx
  13645. });
  13646. }
  13647. }
  13648. if (prevEnd) {
  13649. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13650. }
  13651. }
  13652. _updateMatches(reset = false) {
  13653. if (!this.enabled && !reset) {
  13654. return;
  13655. }
  13656. const {
  13657. findController,
  13658. matches,
  13659. pageIdx
  13660. } = this;
  13661. const {
  13662. textContentItemsStr,
  13663. textDivs
  13664. } = this;
  13665. let clearedUntilDivIdx = -1;
  13666. for (const match of matches) {
  13667. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13668. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  13669. const div = textDivs[n];
  13670. div.textContent = textContentItemsStr[n];
  13671. div.className = "";
  13672. }
  13673. clearedUntilDivIdx = match.end.divIdx + 1;
  13674. }
  13675. if (!findController?.highlightMatches || reset) {
  13676. return;
  13677. }
  13678. const pageMatches = findController.pageMatches[pageIdx] || null;
  13679. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13680. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13681. this._renderMatches(this.matches);
  13682. }
  13683. }
  13684. /***/ }),
  13685. /***/ 7765:
  13686. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  13687. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  13688. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13689. /* harmony export */ TextLayerBuilder: () => (/* binding */ TextLayerBuilder)
  13690. /* harmony export */ });
  13691. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  13692. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  13693. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  13694. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  13695. class TextLayerBuilder {
  13696. #enablePermissions = false;
  13697. #onAppend = null;
  13698. #rotation = 0;
  13699. #scale = 0;
  13700. #textContentSource = null;
  13701. constructor({
  13702. highlighter = null,
  13703. accessibilityManager = null,
  13704. enablePermissions = false,
  13705. onAppend = null
  13706. }) {
  13707. this.textContentItemsStr = [];
  13708. this.renderingDone = false;
  13709. this.textDivs = [];
  13710. this.textDivProperties = new WeakMap();
  13711. this.textLayerRenderTask = null;
  13712. this.highlighter = highlighter;
  13713. this.accessibilityManager = accessibilityManager;
  13714. this.#enablePermissions = enablePermissions === true;
  13715. this.#onAppend = onAppend;
  13716. this.div = document.createElement("div");
  13717. this.div.tabIndex = 0;
  13718. this.div.className = "textLayer";
  13719. }
  13720. #finishRendering() {
  13721. this.renderingDone = true;
  13722. const endOfContent = document.createElement("div");
  13723. endOfContent.className = "endOfContent";
  13724. this.div.append(endOfContent);
  13725. this.#bindMouse();
  13726. }
  13727. get numTextDivs() {
  13728. return this.textDivs.length;
  13729. }
  13730. async render(viewport) {
  13731. if (!this.#textContentSource) {
  13732. throw new Error('No "textContentSource" parameter specified.');
  13733. }
  13734. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  13735. const {
  13736. rotation
  13737. } = viewport;
  13738. if (this.renderingDone) {
  13739. const mustRotate = rotation !== this.#rotation;
  13740. const mustRescale = scale !== this.#scale;
  13741. if (mustRotate || mustRescale) {
  13742. this.hide();
  13743. (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.updateTextLayer)({
  13744. container: this.div,
  13745. viewport,
  13746. textDivs: this.textDivs,
  13747. textDivProperties: this.textDivProperties,
  13748. mustRescale,
  13749. mustRotate
  13750. });
  13751. this.#scale = scale;
  13752. this.#rotation = rotation;
  13753. }
  13754. this.show();
  13755. return;
  13756. }
  13757. this.cancel();
  13758. this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
  13759. this.accessibilityManager?.setTextMapping(this.textDivs);
  13760. this.textLayerRenderTask = (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.renderTextLayer)({
  13761. textContentSource: this.#textContentSource,
  13762. container: this.div,
  13763. viewport,
  13764. textDivs: this.textDivs,
  13765. textDivProperties: this.textDivProperties,
  13766. textContentItemsStr: this.textContentItemsStr
  13767. });
  13768. await this.textLayerRenderTask.promise;
  13769. this.#finishRendering();
  13770. this.#scale = scale;
  13771. this.#rotation = rotation;
  13772. this.#onAppend?.(this.div);
  13773. this.highlighter?.enable();
  13774. this.accessibilityManager?.enable();
  13775. }
  13776. hide() {
  13777. if (!this.div.hidden && this.renderingDone) {
  13778. this.highlighter?.disable();
  13779. this.div.hidden = true;
  13780. }
  13781. }
  13782. show() {
  13783. if (this.div.hidden && this.renderingDone) {
  13784. this.div.hidden = false;
  13785. this.highlighter?.enable();
  13786. }
  13787. }
  13788. cancel() {
  13789. if (this.textLayerRenderTask) {
  13790. this.textLayerRenderTask.cancel();
  13791. this.textLayerRenderTask = null;
  13792. }
  13793. this.highlighter?.disable();
  13794. this.accessibilityManager?.disable();
  13795. this.textContentItemsStr.length = 0;
  13796. this.textDivs.length = 0;
  13797. this.textDivProperties = new WeakMap();
  13798. }
  13799. setTextContentSource(source) {
  13800. this.cancel();
  13801. this.#textContentSource = source;
  13802. }
  13803. #bindMouse() {
  13804. const {
  13805. div
  13806. } = this;
  13807. div.addEventListener("mousedown", evt => {
  13808. const end = div.querySelector(".endOfContent");
  13809. if (!end) {
  13810. return;
  13811. }
  13812. let adjustTop = evt.target !== div;
  13813. adjustTop &&= getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  13814. if (adjustTop) {
  13815. const divBounds = div.getBoundingClientRect();
  13816. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  13817. end.style.top = (r * 100).toFixed(2) + "%";
  13818. }
  13819. end.classList.add("active");
  13820. });
  13821. div.addEventListener("mouseup", () => {
  13822. const end = div.querySelector(".endOfContent");
  13823. if (!end) {
  13824. return;
  13825. }
  13826. end.style.top = "";
  13827. end.classList.remove("active");
  13828. });
  13829. div.addEventListener("copy", event => {
  13830. if (!this.#enablePermissions) {
  13831. const selection = document.getSelection();
  13832. event.clipboardData.setData("text/plain", (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.removeNullCharacters)((0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.normalizeUnicode)(selection.toString())));
  13833. }
  13834. event.preventDefault();
  13835. event.stopPropagation();
  13836. });
  13837. }
  13838. }
  13839. __webpack_async_result__();
  13840. } catch(e) { __webpack_async_result__(e); } });
  13841. /***/ }),
  13842. /***/ 6297:
  13843. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  13844. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  13845. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13846. /* harmony export */ Toolbar: () => (/* binding */ Toolbar)
  13847. /* harmony export */ });
  13848. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  13849. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7256);
  13850. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  13851. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  13852. class Toolbar {
  13853. #opts;
  13854. constructor(options, eventBus) {
  13855. // console.log('test-option', options)
  13856. this.#opts = options;
  13857. this.eventBus = eventBus;
  13858. const buttons = [{
  13859. element: options.previous,
  13860. eventName: "previouspage"
  13861. }, {
  13862. element: options.next,
  13863. eventName: "nextpage"
  13864. }, {
  13865. element: options.zoomIn,
  13866. eventName: "zoomin"
  13867. }, {
  13868. element: options.zoomOut,
  13869. eventName: "zoomout"
  13870. }, {
  13871. element: options.print,
  13872. eventName: "print"
  13873. }, {
  13874. element: options.download,
  13875. eventName: "download"
  13876. }, {
  13877. element: options.editorFreeTextButton,
  13878. eventName: "switchannotationeditormode",
  13879. eventDetails: {
  13880. get mode() {
  13881. const {
  13882. classList
  13883. } = options.editorFreeTextButton;
  13884. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.FREETEXT;
  13885. }
  13886. }
  13887. }, {
  13888. element: options.editorHighlightButton,
  13889. eventName: "switchannotationeditormode",
  13890. eventDetails: {
  13891. get mode() {
  13892. const {
  13893. classList
  13894. } = options.editorHighlightButton;
  13895. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT;
  13896. }
  13897. }
  13898. }, {
  13899. element: options.editorInkButton,
  13900. eventName: "switchannotationeditormode",
  13901. eventDetails: {
  13902. get mode() {
  13903. const {
  13904. classList
  13905. } = options.editorInkButton;
  13906. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.INK;
  13907. }
  13908. }
  13909. }, {
  13910. element: options.editorStampButton,
  13911. eventName: "switchannotationeditormode",
  13912. eventDetails: {
  13913. get mode() {
  13914. const {
  13915. classList
  13916. } = options.editorStampButton;
  13917. return classList.contains("toggled") ? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE : pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.STAMP;
  13918. }
  13919. }
  13920. }];
  13921. this.#bindListeners(buttons);
  13922. if (options.editorHighlightColorPicker) {
  13923. eventBus._on("annotationeditoruimanager", ({
  13924. uiManager
  13925. }) => {
  13926. this.#setAnnotationEditorUIManager(uiManager, options.editorHighlightColorPicker);
  13927. }, {
  13928. once: true
  13929. });
  13930. }
  13931. eventBus._on("showannotationeditorui", ({
  13932. mode
  13933. }) => {
  13934. switch (mode) {
  13935. case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT:
  13936. options.editorHighlightButton.click();
  13937. break;
  13938. }
  13939. });
  13940. this.reset();
  13941. }
  13942. #setAnnotationEditorUIManager(uiManager, parentContainer) {
  13943. const colorPicker = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.ColorPicker({
  13944. uiManager
  13945. });
  13946. uiManager.setMainHighlightColorPicker(colorPicker);
  13947. parentContainer.append(colorPicker.renderMainDropdown());
  13948. }
  13949. setPageNumber(pageNumber, pageLabel) {
  13950. this.pageNumber = pageNumber;
  13951. this.pageLabel = pageLabel;
  13952. this.#updateUIState(false);
  13953. }
  13954. setPagesCount(pagesCount, hasPageLabels) {
  13955. this.pagesCount = pagesCount;
  13956. this.hasPageLabels = hasPageLabels;
  13957. this.#updateUIState(true);
  13958. }
  13959. setPageScale(pageScaleValue, pageScale) {
  13960. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13961. this.pageScale = pageScale;
  13962. this.#updateUIState(false);
  13963. }
  13964. reset() {
  13965. this.pageNumber = 0;
  13966. this.pageLabel = null;
  13967. this.hasPageLabels = false;
  13968. this.pagesCount = 0;
  13969. this.pageScaleValue = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE_VALUE;
  13970. this.pageScale = _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SCALE;
  13971. this.#updateUIState(true);
  13972. this.updateLoadingIndicatorState();
  13973. this.#editorModeChanged({
  13974. mode: pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE
  13975. });
  13976. }
  13977. #bindListeners(buttons) {
  13978. const {
  13979. eventBus
  13980. } = this;
  13981. const {
  13982. pageNumber,
  13983. scaleSelect
  13984. } = this.#opts;
  13985. const self = this;
  13986. for (const {
  13987. element,
  13988. eventName,
  13989. eventDetails
  13990. } of buttons) {
  13991. element.addEventListener("click", evt => {
  13992. if (eventName !== null) {
  13993. eventBus.dispatch(eventName, {
  13994. source: this,
  13995. ...eventDetails,
  13996. isFromKeyboard: evt.detail === 0
  13997. });
  13998. }
  13999. });
  14000. }
  14001. pageNumber.addEventListener("click", function () {
  14002. this.select();
  14003. });
  14004. pageNumber.addEventListener("change", function () {
  14005. eventBus.dispatch("pagenumberchanged", {
  14006. source: self,
  14007. value: this.value
  14008. });
  14009. });
  14010. scaleSelect.addEventListener("change", function () {
  14011. if (this.value === "custom") {
  14012. return;
  14013. }
  14014. eventBus.dispatch("scalechanged", {
  14015. source: self,
  14016. value: this.value
  14017. });
  14018. });
  14019. scaleSelect.addEventListener("click", function ({
  14020. target
  14021. }) {
  14022. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  14023. this.blur();
  14024. }
  14025. });
  14026. scaleSelect.oncontextmenu = pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.noContextMenu;
  14027. eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this));
  14028. }
  14029. #editorModeChanged({
  14030. mode
  14031. }) {
  14032. const {
  14033. editorFreeTextButton,
  14034. editorFreeTextParamsToolbar,
  14035. editorHighlightButton,
  14036. editorHighlightParamsToolbar,
  14037. editorInkButton,
  14038. editorInkParamsToolbar,
  14039. editorStampButton,
  14040. editorStampParamsToolbar
  14041. } = this.#opts;
  14042. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorFreeTextButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
  14043. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorHighlightButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT, editorHighlightParamsToolbar);
  14044. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorInkButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.INK, editorInkParamsToolbar);
  14045. (0,_ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.toggleCheckedBtn)(editorStampButton, mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.STAMP, editorStampParamsToolbar);
  14046. const isDisable = mode === pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.DISABLE;
  14047. editorFreeTextButton.disabled = isDisable;
  14048. editorHighlightButton.disabled = isDisable;
  14049. editorInkButton.disabled = isDisable;
  14050. editorStampButton.disabled = isDisable;
  14051. }
  14052. #updateUIState(resetNumPages = false) {
  14053. const {
  14054. pageNumber,
  14055. pagesCount,
  14056. pageScaleValue,
  14057. pageScale
  14058. } = this;
  14059. const opts = this.#opts;
  14060. if (resetNumPages) {
  14061. if (this.hasPageLabels) {
  14062. opts.pageNumber.type = "text";
  14063. opts.numPages.setAttribute("data-l10n-id", "pdfjs-page-of-pages");
  14064. } else {
  14065. opts.pageNumber.type = "number";
  14066. opts.numPages.setAttribute("data-l10n-id", "pdfjs-of-pages");
  14067. opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
  14068. pagesCount
  14069. }));
  14070. }
  14071. opts.pageNumber.max = pagesCount;
  14072. }
  14073. if (this.hasPageLabels) {
  14074. opts.pageNumber.value = this.pageLabel;
  14075. opts.numPages.setAttribute("data-l10n-args", JSON.stringify({
  14076. pageNumber,
  14077. pagesCount
  14078. }));
  14079. } else {
  14080. // console.log('test-pageNumber-dd', pageNumber)
  14081. // [custome] 比page Changing 更精确
  14082. window.parent.postMessage({pageNumDetail: pageNumber}, '*');
  14083. opts.pageNumber.value = pageNumber;
  14084. }
  14085. opts.previous.disabled = pageNumber <= 1;
  14086. opts.next.disabled = pageNumber >= pagesCount;
  14087. opts.zoomOut.disabled = pageScale <= _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MIN_SCALE;
  14088. opts.zoomIn.disabled = pageScale >= _ui_utils_js__WEBPACK_IMPORTED_MODULE_1__.MAX_SCALE;
  14089. let predefinedValueFound = false;
  14090. for (const option of opts.scaleSelect.options) {
  14091. if (option.value !== pageScaleValue) {
  14092. option.selected = false;
  14093. continue;
  14094. }
  14095. option.selected = true;
  14096. predefinedValueFound = true;
  14097. }
  14098. if (!predefinedValueFound) {
  14099. opts.customScaleOption.selected = true;
  14100. opts.customScaleOption.setAttribute("data-l10n-args", JSON.stringify({
  14101. scale: Math.round(pageScale * 10000) / 100
  14102. }));
  14103. }
  14104. if(opts?.odlScale) {
  14105. opts.odlScale.innerText = `${ Math.round(pageScale * 10000) / 100}%`
  14106. }
  14107. }
  14108. updateLoadingIndicatorState(loading = false) {
  14109. const {
  14110. pageNumber
  14111. } = this.#opts;
  14112. pageNumber.classList.toggle("loading", loading);
  14113. }
  14114. }
  14115. __webpack_async_result__();
  14116. } catch(e) { __webpack_async_result__(e); } });
  14117. /***/ }),
  14118. /***/ 7256:
  14119. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  14120. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14121. /* harmony export */ AutoPrintRegExp: () => (/* binding */ AutoPrintRegExp),
  14122. /* harmony export */ CursorTool: () => (/* binding */ CursorTool),
  14123. /* harmony export */ DEFAULT_SCALE: () => (/* binding */ DEFAULT_SCALE),
  14124. /* harmony export */ DEFAULT_SCALE_DELTA: () => (/* binding */ DEFAULT_SCALE_DELTA),
  14125. /* harmony export */ DEFAULT_SCALE_VALUE: () => (/* binding */ DEFAULT_SCALE_VALUE),
  14126. /* harmony export */ MAX_AUTO_SCALE: () => (/* binding */ MAX_AUTO_SCALE),
  14127. /* harmony export */ MAX_SCALE: () => (/* binding */ MAX_SCALE),
  14128. /* harmony export */ MIN_SCALE: () => (/* binding */ MIN_SCALE),
  14129. /* harmony export */ OutputScale: () => (/* binding */ OutputScale),
  14130. /* harmony export */ PresentationModeState: () => (/* binding */ PresentationModeState),
  14131. /* harmony export */ ProgressBar: () => (/* binding */ ProgressBar),
  14132. /* harmony export */ RenderingStates: () => (/* binding */ RenderingStates),
  14133. /* harmony export */ SCROLLBAR_PADDING: () => (/* binding */ SCROLLBAR_PADDING),
  14134. /* harmony export */ ScrollMode: () => (/* binding */ ScrollMode),
  14135. /* harmony export */ SidebarView: () => (/* binding */ SidebarView),
  14136. /* harmony export */ SpreadMode: () => (/* binding */ SpreadMode),
  14137. /* harmony export */ TextLayerMode: () => (/* binding */ TextLayerMode),
  14138. /* harmony export */ UNKNOWN_SCALE: () => (/* binding */ UNKNOWN_SCALE),
  14139. /* harmony export */ VERTICAL_PADDING: () => (/* binding */ VERTICAL_PADDING),
  14140. /* harmony export */ animationStarted: () => (/* binding */ animationStarted),
  14141. /* harmony export */ apiPageLayoutToViewerModes: () => (/* binding */ apiPageLayoutToViewerModes),
  14142. /* harmony export */ apiPageModeToSidebarView: () => (/* binding */ apiPageModeToSidebarView),
  14143. /* harmony export */ approximateFraction: () => (/* binding */ approximateFraction),
  14144. /* harmony export */ binarySearchFirstItem: () => (/* binding */ binarySearchFirstItem),
  14145. /* harmony export */ docStyle: () => (/* binding */ docStyle),
  14146. /* harmony export */ getActiveOrFocusedElement: () => (/* binding */ getActiveOrFocusedElement),
  14147. /* harmony export */ getPageSizeInches: () => (/* binding */ getPageSizeInches),
  14148. /* harmony export */ getVisibleElements: () => (/* binding */ getVisibleElements),
  14149. /* harmony export */ isPortraitOrientation: () => (/* binding */ isPortraitOrientation),
  14150. /* harmony export */ isValidRotation: () => (/* binding */ isValidRotation),
  14151. /* harmony export */ isValidScrollMode: () => (/* binding */ isValidScrollMode),
  14152. /* harmony export */ isValidSpreadMode: () => (/* binding */ isValidSpreadMode),
  14153. /* harmony export */ normalizeWheelEventDelta: () => (/* binding */ normalizeWheelEventDelta),
  14154. /* harmony export */ normalizeWheelEventDirection: () => (/* binding */ normalizeWheelEventDirection),
  14155. /* harmony export */ parseQueryString: () => (/* binding */ parseQueryString),
  14156. /* harmony export */ removeNullCharacters: () => (/* binding */ removeNullCharacters),
  14157. /* harmony export */ roundToDivide: () => (/* binding */ roundToDivide),
  14158. /* harmony export */ scrollIntoView: () => (/* binding */ scrollIntoView),
  14159. /* harmony export */ toggleCheckedBtn: () => (/* binding */ toggleCheckedBtn),
  14160. /* harmony export */ toggleExpandedBtn: () => (/* binding */ toggleExpandedBtn),
  14161. /* harmony export */ watchScroll: () => (/* binding */ watchScroll)
  14162. /* harmony export */ });
  14163. /* unused harmony export backtrackBeforeAllVisibleElements */
  14164. const DEFAULT_SCALE_VALUE = "auto";
  14165. const DEFAULT_SCALE = 1.0;
  14166. const DEFAULT_SCALE_DELTA = 1.1;
  14167. const MIN_SCALE = 0.1;
  14168. const MAX_SCALE = 10.0;
  14169. const UNKNOWN_SCALE = 0;
  14170. const MAX_AUTO_SCALE = 1.25;
  14171. const SCROLLBAR_PADDING = 40;
  14172. const VERTICAL_PADDING = 5;
  14173. const RenderingStates = {
  14174. INITIAL: 0,
  14175. RUNNING: 1,
  14176. PAUSED: 2,
  14177. FINISHED: 3
  14178. };
  14179. const PresentationModeState = {
  14180. UNKNOWN: 0,
  14181. NORMAL: 1,
  14182. CHANGING: 2,
  14183. FULLSCREEN: 3
  14184. };
  14185. const SidebarView = {
  14186. UNKNOWN: -1,
  14187. NONE: 0,
  14188. THUMBS: 1,
  14189. OUTLINE: 2,
  14190. ATTACHMENTS: 3,
  14191. LAYERS: 4
  14192. };
  14193. const TextLayerMode = {
  14194. DISABLE: 0,
  14195. ENABLE: 1,
  14196. ENABLE_PERMISSIONS: 2
  14197. };
  14198. const ScrollMode = {
  14199. UNKNOWN: -1,
  14200. VERTICAL: 0,
  14201. HORIZONTAL: 1,
  14202. WRAPPED: 2,
  14203. PAGE: 3
  14204. };
  14205. const SpreadMode = {
  14206. UNKNOWN: -1,
  14207. NONE: 0,
  14208. ODD: 1,
  14209. EVEN: 2
  14210. };
  14211. const CursorTool = {
  14212. SELECT: 0,
  14213. HAND: 1,
  14214. ZOOM: 2
  14215. };
  14216. const AutoPrintRegExp = /\bprint\s*\(/;
  14217. class OutputScale {
  14218. constructor() {
  14219. const pixelRatio = window.devicePixelRatio || 1;
  14220. this.sx = pixelRatio;
  14221. this.sy = pixelRatio;
  14222. }
  14223. get scaled() {
  14224. return this.sx !== 1 || this.sy !== 1;
  14225. }
  14226. }
  14227. function scrollIntoView(element, spot, scrollMatches = false) {
  14228. let parent = element.offsetParent;
  14229. if (!parent) {
  14230. console.error("offsetParent is not set -- cannot scroll");
  14231. return;
  14232. }
  14233. let offsetY = element.offsetTop + element.clientTop;
  14234. let offsetX = element.offsetLeft + element.clientLeft;
  14235. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  14236. offsetY += parent.offsetTop;
  14237. offsetX += parent.offsetLeft;
  14238. parent = parent.offsetParent;
  14239. if (!parent) {
  14240. return;
  14241. }
  14242. }
  14243. if (spot) {
  14244. if (spot.top !== undefined) {
  14245. offsetY += spot.top;
  14246. }
  14247. if (spot.left !== undefined) {
  14248. offsetX += spot.left;
  14249. parent.scrollLeft = offsetX;
  14250. }
  14251. }
  14252. parent.scrollTop = offsetY;
  14253. }
  14254. function watchScroll(viewAreaElement, callback) {
  14255. const debounceScroll = function (evt) {
  14256. if (rAF) {
  14257. return;
  14258. }
  14259. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  14260. rAF = null;
  14261. const currentX = viewAreaElement.scrollLeft;
  14262. const lastX = state.lastX;
  14263. if (currentX !== lastX) {
  14264. state.right = currentX > lastX;
  14265. }
  14266. state.lastX = currentX;
  14267. const currentY = viewAreaElement.scrollTop;
  14268. const lastY = state.lastY;
  14269. if (currentY !== lastY) {
  14270. state.down = currentY > lastY;
  14271. }
  14272. state.lastY = currentY;
  14273. callback(state);
  14274. });
  14275. };
  14276. const state = {
  14277. right: true,
  14278. down: true,
  14279. lastX: viewAreaElement.scrollLeft,
  14280. lastY: viewAreaElement.scrollTop,
  14281. _eventHandler: debounceScroll
  14282. };
  14283. let rAF = null;
  14284. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  14285. return state;
  14286. }
  14287. function parseQueryString(query) {
  14288. const params = new Map();
  14289. for (const [key, value] of new URLSearchParams(query)) {
  14290. params.set(key.toLowerCase(), value);
  14291. }
  14292. return params;
  14293. }
  14294. const InvisibleCharsRegExp = /[\x00-\x1F]/g;
  14295. function removeNullCharacters(str, replaceInvisible = false) {
  14296. if (!InvisibleCharsRegExp.test(str)) {
  14297. return str;
  14298. }
  14299. if (replaceInvisible) {
  14300. return str.replaceAll(InvisibleCharsRegExp, m => m === "\x00" ? "" : " ");
  14301. }
  14302. return str.replaceAll("\x00", "");
  14303. }
  14304. function binarySearchFirstItem(items, condition, start = 0) {
  14305. let minIndex = start;
  14306. let maxIndex = items.length - 1;
  14307. if (maxIndex < 0 || !condition(items[maxIndex])) {
  14308. return items.length;
  14309. }
  14310. if (condition(items[minIndex])) {
  14311. return minIndex;
  14312. }
  14313. while (minIndex < maxIndex) {
  14314. const currentIndex = minIndex + maxIndex >> 1;
  14315. const currentItem = items[currentIndex];
  14316. if (condition(currentItem)) {
  14317. maxIndex = currentIndex;
  14318. } else {
  14319. minIndex = currentIndex + 1;
  14320. }
  14321. }
  14322. return minIndex;
  14323. }
  14324. function approximateFraction(x) {
  14325. if (Math.floor(x) === x) {
  14326. return [x, 1];
  14327. }
  14328. const xinv = 1 / x;
  14329. const limit = 8;
  14330. if (xinv > limit) {
  14331. return [1, limit];
  14332. } else if (Math.floor(xinv) === xinv) {
  14333. return [1, xinv];
  14334. }
  14335. const x_ = x > 1 ? xinv : x;
  14336. let a = 0,
  14337. b = 1,
  14338. c = 1,
  14339. d = 1;
  14340. while (true) {
  14341. const p = a + c,
  14342. q = b + d;
  14343. if (q > limit) {
  14344. break;
  14345. }
  14346. if (x_ <= p / q) {
  14347. c = p;
  14348. d = q;
  14349. } else {
  14350. a = p;
  14351. b = q;
  14352. }
  14353. }
  14354. let result;
  14355. if (x_ - a / b < c / d - x_) {
  14356. result = x_ === x ? [a, b] : [b, a];
  14357. } else {
  14358. result = x_ === x ? [c, d] : [d, c];
  14359. }
  14360. return result;
  14361. }
  14362. function roundToDivide(x, div) {
  14363. const r = x % div;
  14364. return r === 0 ? x : Math.round(x - r + div);
  14365. }
  14366. function getPageSizeInches({
  14367. view,
  14368. userUnit,
  14369. rotate
  14370. }) {
  14371. const [x1, y1, x2, y2] = view;
  14372. const changeOrientation = rotate % 180 !== 0;
  14373. const width = (x2 - x1) / 72 * userUnit;
  14374. const height = (y2 - y1) / 72 * userUnit;
  14375. return {
  14376. width: changeOrientation ? height : width,
  14377. height: changeOrientation ? width : height
  14378. };
  14379. }
  14380. function backtrackBeforeAllVisibleElements(index, views, top) {
  14381. if (index < 2) {
  14382. return index;
  14383. }
  14384. let elt = views[index].div;
  14385. let pageTop = elt.offsetTop + elt.clientTop;
  14386. if (pageTop >= top) {
  14387. elt = views[index - 1].div;
  14388. pageTop = elt.offsetTop + elt.clientTop;
  14389. }
  14390. for (let i = index - 2; i >= 0; --i) {
  14391. elt = views[i].div;
  14392. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  14393. break;
  14394. }
  14395. index = i;
  14396. }
  14397. return index;
  14398. }
  14399. function getVisibleElements({
  14400. scrollEl,
  14401. views,
  14402. sortByVisibility = false,
  14403. horizontal = false,
  14404. rtl = false
  14405. }) {
  14406. const top = scrollEl.scrollTop,
  14407. bottom = top + scrollEl.clientHeight;
  14408. const left = scrollEl.scrollLeft,
  14409. right = left + scrollEl.clientWidth;
  14410. function isElementBottomAfterViewTop(view) {
  14411. const element = view.div;
  14412. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  14413. return elementBottom > top;
  14414. }
  14415. function isElementNextAfterViewHorizontally(view) {
  14416. const element = view.div;
  14417. const elementLeft = element.offsetLeft + element.clientLeft;
  14418. const elementRight = elementLeft + element.clientWidth;
  14419. return rtl ? elementLeft < right : elementRight > left;
  14420. }
  14421. const visible = [],
  14422. ids = new Set(),
  14423. numViews = views.length;
  14424. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  14425. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  14426. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  14427. }
  14428. let lastEdge = horizontal ? right : -1;
  14429. for (let i = firstVisibleElementInd; i < numViews; i++) {
  14430. const view = views[i],
  14431. element = view.div;
  14432. const currentWidth = element.offsetLeft + element.clientLeft;
  14433. const currentHeight = element.offsetTop + element.clientTop;
  14434. const viewWidth = element.clientWidth,
  14435. viewHeight = element.clientHeight;
  14436. const viewRight = currentWidth + viewWidth;
  14437. const viewBottom = currentHeight + viewHeight;
  14438. if (lastEdge === -1) {
  14439. if (viewBottom >= bottom) {
  14440. lastEdge = viewBottom;
  14441. }
  14442. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  14443. break;
  14444. }
  14445. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  14446. continue;
  14447. }
  14448. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  14449. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  14450. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  14451. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  14452. const percent = fractionHeight * fractionWidth * 100 | 0;
  14453. visible.push({
  14454. id: view.id,
  14455. x: currentWidth,
  14456. y: currentHeight,
  14457. view,
  14458. percent,
  14459. widthPercent: fractionWidth * 100 | 0
  14460. });
  14461. ids.add(view.id);
  14462. }
  14463. const first = visible[0],
  14464. last = visible.at(-1);
  14465. if (sortByVisibility) {
  14466. visible.sort(function (a, b) {
  14467. const pc = a.percent - b.percent;
  14468. if (Math.abs(pc) > 0.001) {
  14469. return -pc;
  14470. }
  14471. return a.id - b.id;
  14472. });
  14473. }
  14474. return {
  14475. first,
  14476. last,
  14477. views: visible,
  14478. ids
  14479. };
  14480. }
  14481. function normalizeWheelEventDirection(evt) {
  14482. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  14483. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  14484. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  14485. delta = -delta;
  14486. }
  14487. return delta;
  14488. }
  14489. function normalizeWheelEventDelta(evt) {
  14490. const deltaMode = evt.deltaMode;
  14491. let delta = normalizeWheelEventDirection(evt);
  14492. const MOUSE_PIXELS_PER_LINE = 30;
  14493. const MOUSE_LINES_PER_PAGE = 30;
  14494. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  14495. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  14496. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  14497. delta /= MOUSE_LINES_PER_PAGE;
  14498. }
  14499. return delta;
  14500. }
  14501. function isValidRotation(angle) {
  14502. return Number.isInteger(angle) && angle % 90 === 0;
  14503. }
  14504. function isValidScrollMode(mode) {
  14505. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  14506. }
  14507. function isValidSpreadMode(mode) {
  14508. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  14509. }
  14510. function isPortraitOrientation(size) {
  14511. return size.width <= size.height;
  14512. }
  14513. const animationStarted = new Promise(function (resolve) {
  14514. window.requestAnimationFrame(resolve);
  14515. });
  14516. const docStyle = document.documentElement.style;
  14517. function clamp(v, min, max) {
  14518. return Math.min(Math.max(v, min), max);
  14519. }
  14520. class ProgressBar {
  14521. #classList = null;
  14522. #disableAutoFetchTimeout = null;
  14523. #percent = 0;
  14524. #style = null;
  14525. #visible = true;
  14526. constructor(bar) {
  14527. this.#classList = bar.classList;
  14528. this.#style = bar.style;
  14529. }
  14530. get percent() {
  14531. return this.#percent;
  14532. }
  14533. set percent(val) {
  14534. this.#percent = clamp(val, 0, 100);
  14535. if (isNaN(val)) {
  14536. this.#classList.add("indeterminate");
  14537. return;
  14538. }
  14539. this.#classList.remove("indeterminate");
  14540. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  14541. }
  14542. setWidth(viewer) {
  14543. if (!viewer) {
  14544. return;
  14545. }
  14546. const container = viewer.parentNode;
  14547. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  14548. if (scrollbarWidth > 0) {
  14549. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  14550. }
  14551. }
  14552. setDisableAutoFetch(delay = 5000) {
  14553. if (isNaN(this.#percent)) {
  14554. return;
  14555. }
  14556. if (this.#disableAutoFetchTimeout) {
  14557. clearTimeout(this.#disableAutoFetchTimeout);
  14558. }
  14559. this.show();
  14560. this.#disableAutoFetchTimeout = setTimeout(() => {
  14561. this.#disableAutoFetchTimeout = null;
  14562. this.hide();
  14563. }, delay);
  14564. }
  14565. hide() {
  14566. if (!this.#visible) {
  14567. return;
  14568. }
  14569. this.#visible = false;
  14570. this.#classList.add("hidden");
  14571. }
  14572. show() {
  14573. if (this.#visible) {
  14574. return;
  14575. }
  14576. this.#visible = true;
  14577. this.#classList.remove("hidden");
  14578. }
  14579. }
  14580. function getActiveOrFocusedElement() {
  14581. let curRoot = document;
  14582. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  14583. while (curActiveOrFocused?.shadowRoot) {
  14584. curRoot = curActiveOrFocused.shadowRoot;
  14585. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  14586. }
  14587. return curActiveOrFocused;
  14588. }
  14589. function apiPageLayoutToViewerModes(layout) {
  14590. let scrollMode = ScrollMode.VERTICAL,
  14591. spreadMode = SpreadMode.NONE;
  14592. switch (layout) {
  14593. case "SinglePage":
  14594. scrollMode = ScrollMode.PAGE;
  14595. break;
  14596. case "OneColumn":
  14597. break;
  14598. case "TwoPageLeft":
  14599. scrollMode = ScrollMode.PAGE;
  14600. case "TwoColumnLeft":
  14601. spreadMode = SpreadMode.ODD;
  14602. break;
  14603. case "TwoPageRight":
  14604. scrollMode = ScrollMode.PAGE;
  14605. case "TwoColumnRight":
  14606. spreadMode = SpreadMode.EVEN;
  14607. break;
  14608. }
  14609. return {
  14610. scrollMode,
  14611. spreadMode
  14612. };
  14613. }
  14614. function apiPageModeToSidebarView(mode) {
  14615. switch (mode) {
  14616. case "UseNone":
  14617. return SidebarView.NONE;
  14618. case "UseThumbs":
  14619. return SidebarView.THUMBS;
  14620. case "UseOutlines":
  14621. return SidebarView.OUTLINE;
  14622. case "UseAttachments":
  14623. return SidebarView.ATTACHMENTS;
  14624. case "UseOC":
  14625. return SidebarView.LAYERS;
  14626. }
  14627. return SidebarView.NONE;
  14628. }
  14629. function toggleCheckedBtn(button, toggle, view = null) {
  14630. button.classList.toggle("toggled", toggle);
  14631. button.setAttribute("aria-checked", toggle);
  14632. view?.classList.toggle("hidden", !toggle);
  14633. }
  14634. function toggleExpandedBtn(button, toggle, view = null) {
  14635. button.classList.toggle("toggled", toggle);
  14636. button.setAttribute("aria-expanded", toggle);
  14637. view?.classList.toggle("hidden", !toggle);
  14638. }
  14639. /***/ }),
  14640. /***/ 9226:
  14641. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  14642. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14643. /* harmony export */ ViewHistory: () => (/* binding */ ViewHistory)
  14644. /* harmony export */ });
  14645. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  14646. class ViewHistory {
  14647. constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
  14648. this.fingerprint = fingerprint;
  14649. this.cacheSize = cacheSize;
  14650. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  14651. const database = JSON.parse(databaseStr || "{}");
  14652. let index = -1;
  14653. if (!Array.isArray(database.files)) {
  14654. database.files = [];
  14655. } else {
  14656. while (database.files.length >= this.cacheSize) {
  14657. database.files.shift();
  14658. }
  14659. for (let i = 0, ii = database.files.length; i < ii; i++) {
  14660. const branch = database.files[i];
  14661. if (branch.fingerprint === this.fingerprint) {
  14662. index = i;
  14663. break;
  14664. }
  14665. }
  14666. }
  14667. if (index === -1) {
  14668. index = database.files.push({
  14669. fingerprint: this.fingerprint
  14670. }) - 1;
  14671. }
  14672. this.file = database.files[index];
  14673. this.database = database;
  14674. });
  14675. }
  14676. async _writeToStorage() {
  14677. const databaseStr = JSON.stringify(this.database);
  14678. localStorage.setItem("pdfjs.history", databaseStr);
  14679. }
  14680. async _readFromStorage() {
  14681. // 屏蔽本地存储的pageNum字段 [custom]
  14682. const history = localStorage.getItem("pdfjs.history");
  14683. return !!history ? {...history} : {};
  14684. }
  14685. async set(name, val) {
  14686. await this._initializedPromise;
  14687. this.file[name] = val;
  14688. return this._writeToStorage();
  14689. }
  14690. async setMultiple(properties) {
  14691. await this._initializedPromise;
  14692. for (const name in properties) {
  14693. this.file[name] = properties[name];
  14694. }
  14695. return this._writeToStorage();
  14696. }
  14697. async get(name, defaultValue) {
  14698. await this._initializedPromise;
  14699. const val = this.file[name];
  14700. return val !== undefined ? val : defaultValue;
  14701. }
  14702. async getMultiple(properties) {
  14703. await this._initializedPromise;
  14704. const values = Object.create(null);
  14705. for (const name in properties) {
  14706. const val = this.file[name];
  14707. values[name] = val !== undefined ? val : properties[name];
  14708. }
  14709. return values;
  14710. }
  14711. }
  14712. /***/ }),
  14713. /***/ 2030:
  14714. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  14715. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  14716. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14717. /* harmony export */ PDFViewerApplication: () => (/* reexport safe */ _app_js__WEBPACK_IMPORTED_MODULE_3__.PDFViewerApplication),
  14718. /* harmony export */ PDFViewerApplicationConstants: () => (/* binding */ AppConstants),
  14719. /* harmony export */ PDFViewerApplicationOptions: () => (/* reexport safe */ _app_options_js__WEBPACK_IMPORTED_MODULE_1__.AppOptions)
  14720. /* harmony export */ });
  14721. /* harmony import */ var _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7256);
  14722. /* harmony import */ var _app_options_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9840);
  14723. /* harmony import */ var _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(787);
  14724. /* harmony import */ var _app_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1621);
  14725. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_app_js__WEBPACK_IMPORTED_MODULE_3__]);
  14726. _app_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  14727. const pdfjsVersion = "4.2.67";
  14728. const pdfjsBuild = "49b388101";
  14729. const AppConstants = {
  14730. LinkTarget: _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__.LinkTarget,
  14731. RenderingStates: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates,
  14732. // 初始化模式设置为3
  14733. ScrollMode: 3,
  14734. SpreadMode: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.SpreadMode
  14735. };
  14736. // console.log('test-init')
  14737. window.PDFViewerApplication = _app_js__WEBPACK_IMPORTED_MODULE_3__.PDFViewerApplication;
  14738. window.PDFViewerApplicationConstants = AppConstants;
  14739. window.PDFViewerApplicationOptions = _app_options_js__WEBPACK_IMPORTED_MODULE_1__.AppOptions;
  14740. function getViewerConfiguration() {
  14741. const odlCustomToolBarDomList = window.getOdlViewDom ? window.getOdlViewDom(window.odlIdDomToolbarList) : {};
  14742. const odlCustomSiderDomList = window.getOdlViewDom ? window.getOdlViewDom(window.odlCustomSiderDomList) : {};
  14743. return {
  14744. appContainer: document.body,
  14745. mainContainer: document.getElementById("viewerContainer"),
  14746. viewerContainer: document.getElementById("viewer"),
  14747. toolbar: {
  14748. container: document.getElementById("toolbarViewer"),
  14749. numPages: document.getElementById("numPages"),
  14750. pageNumber: document.getElementById("pageNumber"),
  14751. scaleSelect: document.getElementById("scaleSelect"),
  14752. customScaleOption: document.getElementById("customScaleOption"),
  14753. previous: document.getElementById("previous"),
  14754. next: document.getElementById("next"),
  14755. zoomIn: document.getElementById("zoomIn"),
  14756. zoomOut: document.getElementById("zoomOut"),
  14757. viewFind: document.getElementById("viewFind"),
  14758. print: document.getElementById("print"),
  14759. editorFreeTextButton: document.getElementById("editorFreeText"),
  14760. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  14761. editorHighlightButton: document.getElementById("editorHighlight"),
  14762. editorHighlightParamsToolbar: document.getElementById("editorHighlightParamsToolbar"),
  14763. editorHighlightColorPicker: document.getElementById("editorHighlightColorPicker"),
  14764. editorInkButton: document.getElementById("editorInk"),
  14765. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  14766. editorStampButton: document.getElementById("editorStamp"),
  14767. editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"),
  14768. download: document.getElementById("download"),
  14769. ...odlCustomToolBarDomList,
  14770. },
  14771. secondaryToolbar: {
  14772. toolbar: document.getElementById("secondaryToolbar"),
  14773. toggleButton: document.getElementById("secondaryToolbarToggle"),
  14774. presentationModeButton: document.getElementById("presentationMode"),
  14775. openFileButton: document.getElementById("secondaryOpenFile"),
  14776. printButton: document.getElementById("secondaryPrint"),
  14777. downloadButton: document.getElementById("secondaryDownload"),
  14778. viewBookmarkButton: document.getElementById("viewBookmark"),
  14779. firstPageButton: document.getElementById("firstPage"),
  14780. lastPageButton: document.getElementById("lastPage"),
  14781. pageRotateCwButton: document.getElementById("pageRotateCw"),
  14782. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  14783. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  14784. cursorHandToolButton: document.getElementById("cursorHandTool"),
  14785. scrollPageButton: document.getElementById("scrollPage"),
  14786. scrollVerticalButton: document.getElementById("scrollVertical"),
  14787. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  14788. scrollWrappedButton: document.getElementById("scrollWrapped"),
  14789. spreadNoneButton: document.getElementById("spreadNone"),
  14790. spreadOddButton: document.getElementById("spreadOdd"),
  14791. spreadEvenButton: document.getElementById("spreadEven"),
  14792. documentPropertiesButton: document.getElementById("documentProperties")
  14793. },
  14794. sidebar: {
  14795. outerContainer: document.getElementById("outerContainer"),
  14796. sidebarContainer: document.getElementById("sidebarContainer"),
  14797. toggleButton: document.getElementById("sidebarToggle"),
  14798. resizer: document.getElementById("sidebarResizer"),
  14799. thumbnailButton: document.getElementById("viewThumbnail"),
  14800. outlineButton: document.getElementById("viewOutline"),
  14801. attachmentsButton: document.getElementById("viewAttachments"),
  14802. layersButton: document.getElementById("viewLayers"),
  14803. thumbnailView: document.getElementById("thumbnailView"),
  14804. outlineView: document.getElementById("outlineView"),
  14805. attachmentsView: document.getElementById("attachmentsView"),
  14806. layersView: document.getElementById("layersView"),
  14807. currentOutlineItemButton: document.getElementById("currentOutlineItem"),
  14808. ...odlCustomSiderDomList
  14809. },
  14810. findBar: {
  14811. bar: document.getElementById("findbar"),
  14812. toggleButton: document.getElementById("viewFind"),
  14813. findField: document.getElementById("findInput"),
  14814. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  14815. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  14816. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  14817. entireWordCheckbox: document.getElementById("findEntireWord"),
  14818. findMsg: document.getElementById("findMsg"),
  14819. findResultsCount: document.getElementById("findResultsCount"),
  14820. findPreviousButton: document.getElementById("findPrevious"),
  14821. findNextButton: document.getElementById("findNext")
  14822. },
  14823. passwordOverlay: {
  14824. dialog: document.getElementById("passwordDialog"),
  14825. label: document.getElementById("passwordText"),
  14826. input: document.getElementById("password"),
  14827. submitButton: document.getElementById("passwordSubmit"),
  14828. cancelButton: document.getElementById("passwordCancel")
  14829. },
  14830. documentProperties: {
  14831. dialog: document.getElementById("documentPropertiesDialog"),
  14832. closeButton: document.getElementById("documentPropertiesClose"),
  14833. fields: {
  14834. fileName: document.getElementById("fileNameField"),
  14835. fileSize: document.getElementById("fileSizeField"),
  14836. title: document.getElementById("titleField"),
  14837. author: document.getElementById("authorField"),
  14838. subject: document.getElementById("subjectField"),
  14839. keywords: document.getElementById("keywordsField"),
  14840. creationDate: document.getElementById("creationDateField"),
  14841. modificationDate: document.getElementById("modificationDateField"),
  14842. creator: document.getElementById("creatorField"),
  14843. producer: document.getElementById("producerField"),
  14844. version: document.getElementById("versionField"),
  14845. pageCount: document.getElementById("pageCountField"),
  14846. pageSize: document.getElementById("pageSizeField"),
  14847. linearized: document.getElementById("linearizedField")
  14848. }
  14849. },
  14850. altTextDialog: {
  14851. dialog: document.getElementById("altTextDialog"),
  14852. optionDescription: document.getElementById("descriptionButton"),
  14853. optionDecorative: document.getElementById("decorativeButton"),
  14854. textarea: document.getElementById("descriptionTextarea"),
  14855. cancelButton: document.getElementById("altTextCancel"),
  14856. saveButton: document.getElementById("altTextSave")
  14857. },
  14858. annotationEditorParams: {
  14859. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  14860. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  14861. editorInkColor: document.getElementById("editorInkColor"),
  14862. editorInkThickness: document.getElementById("editorInkThickness"),
  14863. editorInkOpacity: document.getElementById("editorInkOpacity"),
  14864. editorStampAddImage: document.getElementById("editorStampAddImage"),
  14865. editorFreeHighlightThickness: document.getElementById("editorFreeHighlightThickness"),
  14866. editorHighlightShowAll: document.getElementById("editorHighlightShowAll")
  14867. },
  14868. printContainer: document.getElementById("printContainer")
  14869. };
  14870. }
  14871. function webViewerLoad() {
  14872. const config = getViewerConfiguration();
  14873. const event = new CustomEvent("webviewerloaded", {
  14874. bubbles: true,
  14875. cancelable: true,
  14876. detail: {
  14877. source: window
  14878. }
  14879. });
  14880. try {
  14881. parent.document.dispatchEvent(event);
  14882. } catch (ex) {
  14883. console.error(`webviewerloaded: ${ex}`);
  14884. document.dispatchEvent(event);
  14885. }
  14886. _app_js__WEBPACK_IMPORTED_MODULE_3__.PDFViewerApplication.run(config);
  14887. }
  14888. document.blockUnblockOnload?.(true);
  14889. if (document.readyState === "interactive" || document.readyState === "complete") {
  14890. webViewerLoad();
  14891. } else {
  14892. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  14893. }
  14894. __webpack_async_result__();
  14895. } catch(e) { __webpack_async_result__(e); } });
  14896. /***/ }),
  14897. /***/ 2973:
  14898. /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
  14899. __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  14900. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14901. /* harmony export */ XfaLayerBuilder: () => (/* binding */ XfaLayerBuilder)
  14902. /* harmony export */ });
  14903. /* harmony import */ var pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2603);
  14904. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__]);
  14905. pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  14906. class XfaLayerBuilder {
  14907. constructor({
  14908. pdfPage,
  14909. annotationStorage = null,
  14910. linkService,
  14911. xfaHtml = null
  14912. }) {
  14913. this.pdfPage = pdfPage;
  14914. this.annotationStorage = annotationStorage;
  14915. this.linkService = linkService;
  14916. this.xfaHtml = xfaHtml;
  14917. this.div = null;
  14918. this._cancelled = false;
  14919. }
  14920. async render(viewport, intent = "display") {
  14921. if (intent === "print") {
  14922. const parameters = {
  14923. viewport: viewport.clone({
  14924. dontFlip: true
  14925. }),
  14926. div: this.div,
  14927. xfaHtml: this.xfaHtml,
  14928. annotationStorage: this.annotationStorage,
  14929. linkService: this.linkService,
  14930. intent
  14931. };
  14932. this.div = document.createElement("div");
  14933. parameters.div = this.div;
  14934. return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.render(parameters);
  14935. }
  14936. const xfaHtml = await this.pdfPage.getXfa();
  14937. if (this._cancelled || !xfaHtml) {
  14938. return {
  14939. textDivs: []
  14940. };
  14941. }
  14942. const parameters = {
  14943. viewport: viewport.clone({
  14944. dontFlip: true
  14945. }),
  14946. div: this.div,
  14947. xfaHtml,
  14948. annotationStorage: this.annotationStorage,
  14949. linkService: this.linkService,
  14950. intent
  14951. };
  14952. if (this.div) {
  14953. return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.update(parameters);
  14954. }
  14955. this.div = document.createElement("div");
  14956. parameters.div = this.div;
  14957. return pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.XfaLayer.render(parameters);
  14958. }
  14959. cancel() {
  14960. this._cancelled = true;
  14961. }
  14962. hide() {
  14963. if (!this.div) {
  14964. return;
  14965. }
  14966. this.div.hidden = true;
  14967. }
  14968. }
  14969. __webpack_async_result__();
  14970. } catch(e) { __webpack_async_result__(e); } });
  14971. /***/ })
  14972. /******/ });
  14973. /************************************************************************/
  14974. /******/ // The module cache
  14975. /******/ var __webpack_module_cache__ = {};
  14976. /******/
  14977. /******/ // The require function
  14978. /******/ function __webpack_require__(moduleId) {
  14979. /******/ // Check if module is in cache
  14980. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  14981. /******/ if (cachedModule !== undefined) {
  14982. /******/ return cachedModule.exports;
  14983. /******/ }
  14984. /******/ // Create a new module (and put it into the cache)
  14985. /******/ var module = __webpack_module_cache__[moduleId] = {
  14986. /******/ // no module.id needed
  14987. /******/ // no module.loaded needed
  14988. /******/ exports: {}
  14989. /******/ };
  14990. /******/
  14991. /******/ // Execute the module function
  14992. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  14993. /******/
  14994. /******/ // Return the exports of the module
  14995. /******/ return module.exports;
  14996. /******/ }
  14997. /******/
  14998. /************************************************************************/
  14999. /******/ /* webpack/runtime/async module */
  15000. /******/ (() => {
  15001. /******/ var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";
  15002. /******/ var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";
  15003. /******/ var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";
  15004. /******/ var resolveQueue = (queue) => {
  15005. /******/ if(queue && queue.d < 1) {
  15006. /******/ queue.d = 1;
  15007. /******/ queue.forEach((fn) => (fn.r--));
  15008. /******/ queue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));
  15009. /******/ }
  15010. /******/ }
  15011. /******/ var wrapDeps = (deps) => (deps.map((dep) => {
  15012. /******/ if(dep !== null && typeof dep === "object") {
  15013. /******/ if(dep[webpackQueues]) return dep;
  15014. /******/ if(dep.then) {
  15015. /******/ var queue = [];
  15016. /******/ queue.d = 0;
  15017. /******/ dep.then((r) => {
  15018. /******/ obj[webpackExports] = r;
  15019. /******/ resolveQueue(queue);
  15020. /******/ }, (e) => {
  15021. /******/ obj[webpackError] = e;
  15022. /******/ resolveQueue(queue);
  15023. /******/ });
  15024. /******/ var obj = {};
  15025. /******/ obj[webpackQueues] = (fn) => (fn(queue));
  15026. /******/ return obj;
  15027. /******/ }
  15028. /******/ }
  15029. /******/ var ret = {};
  15030. /******/ ret[webpackQueues] = x => {};
  15031. /******/ ret[webpackExports] = dep;
  15032. /******/ return ret;
  15033. /******/ }));
  15034. /******/ __webpack_require__.a = (module, body, hasAwait) => {
  15035. /******/ var queue;
  15036. /******/ hasAwait && ((queue = []).d = -1);
  15037. /******/ var depQueues = new Set();
  15038. /******/ var exports = module.exports;
  15039. /******/ var currentDeps;
  15040. /******/ var outerResolve;
  15041. /******/ var reject;
  15042. /******/ var promise = new Promise((resolve, rej) => {
  15043. /******/ reject = rej;
  15044. /******/ outerResolve = resolve;
  15045. /******/ });
  15046. /******/ promise[webpackExports] = exports;
  15047. /******/ promise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise["catch"](x => {}));
  15048. /******/ module.exports = promise;
  15049. /******/ body((deps) => {
  15050. /******/ currentDeps = wrapDeps(deps);
  15051. /******/ var fn;
  15052. /******/ var getResult = () => (currentDeps.map((d) => {
  15053. /******/ if(d[webpackError]) throw d[webpackError];
  15054. /******/ return d[webpackExports];
  15055. /******/ }))
  15056. /******/ var promise = new Promise((resolve) => {
  15057. /******/ fn = () => (resolve(getResult));
  15058. /******/ fn.r = 0;
  15059. /******/ var fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));
  15060. /******/ currentDeps.map((dep) => (dep[webpackQueues](fnQueue)));
  15061. /******/ });
  15062. /******/ return fn.r ? promise : getResult();
  15063. /******/ }, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));
  15064. /******/ queue && queue.d < 0 && (queue.d = 0);
  15065. /******/ };
  15066. /******/ })();
  15067. /******/
  15068. /******/ /* webpack/runtime/define property getters */
  15069. /******/ (() => {
  15070. /******/ // define getter functions for harmony exports
  15071. /******/ __webpack_require__.d = (exports, definition) => {
  15072. /******/ for(var key in definition) {
  15073. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  15074. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  15075. /******/ }
  15076. /******/ }
  15077. /******/ };
  15078. /******/ })();
  15079. /******/
  15080. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  15081. /******/ (() => {
  15082. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  15083. /******/ })();
  15084. /******/
  15085. /************************************************************************/
  15086. /******/
  15087. /******/ // startup
  15088. /******/ // Load entry module and return exports
  15089. /******/ // This entry module used 'module' so it can't be inlined
  15090. /******/ var __webpack_exports__ = __webpack_require__(2030);
  15091. /******/ __webpack_exports__ = await __webpack_exports__;
  15092. /******/ var __webpack_exports__PDFViewerApplication = __webpack_exports__.PDFViewerApplication;
  15093. /******/ var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFViewerApplicationConstants;
  15094. /******/ var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions;
  15095. /******/ export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };
  15096. /******/
  15097. //# sourceMappingURL=viewer.mjs.map