viewer.js 499 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665
  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. /******/ (() => { // webpackBootstrap
  23. /******/ "use strict";
  24. /******/ var __webpack_modules__ = ([
  25. /* 0 */,
  26. /* 1 */
  27. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28. Object.defineProperty(exports, "__esModule", ({
  29. value: true
  30. }));
  31. exports.GenericCom = void 0;
  32. __webpack_require__(2);
  33. var _app = __webpack_require__(75);
  34. var _preferences = __webpack_require__(159);
  35. var _download_manager = __webpack_require__(160);
  36. var _genericl10n = __webpack_require__(161);
  37. var _generic_scripting = __webpack_require__(163);
  38. ;
  39. const GenericCom = {};
  40. exports.GenericCom = GenericCom;
  41. class GenericPreferences extends _preferences.BasePreferences {
  42. async _writeToStorage(prefObj) {
  43. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  44. }
  45. async _readFromStorage(prefObj) {
  46. return JSON.parse(localStorage.getItem("pdfjs.preferences"));
  47. }
  48. }
  49. class GenericExternalServices extends _app.DefaultExternalServices {
  50. static createDownloadManager() {
  51. return new _download_manager.DownloadManager();
  52. }
  53. static createPreferences() {
  54. return new GenericPreferences();
  55. }
  56. static createL10n(_ref) {
  57. let {
  58. locale = "en-US"
  59. } = _ref;
  60. return new _genericl10n.GenericL10n(locale);
  61. }
  62. static createScripting(_ref2) {
  63. let {
  64. sandboxBundleSrc
  65. } = _ref2;
  66. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  67. }
  68. }
  69. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  70. /***/ }),
  71. /* 2 */
  72. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  73. var $ = __webpack_require__(3);
  74. var DESCRIPTORS = __webpack_require__(6);
  75. var global = __webpack_require__(4);
  76. var getBuiltIn = __webpack_require__(24);
  77. var uncurryThis = __webpack_require__(14);
  78. var call = __webpack_require__(8);
  79. var isCallable = __webpack_require__(21);
  80. var isObject = __webpack_require__(20);
  81. var isArray = __webpack_require__(69);
  82. var hasOwn = __webpack_require__(39);
  83. var toString = __webpack_require__(70);
  84. var lengthOfArrayLike = __webpack_require__(64);
  85. var createProperty = __webpack_require__(73);
  86. var fails = __webpack_require__(7);
  87. var parseJSONString = __webpack_require__(74);
  88. var NATIVE_SYMBOL = __webpack_require__(27);
  89. var JSON = global.JSON;
  90. var Number = global.Number;
  91. var SyntaxError = global.SyntaxError;
  92. var nativeParse = JSON && JSON.parse;
  93. var enumerableOwnProperties = getBuiltIn('Object', 'keys');
  94. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  95. var at = uncurryThis(''.charAt);
  96. var slice = uncurryThis(''.slice);
  97. var exec = uncurryThis(/./.exec);
  98. var push = uncurryThis([].push);
  99. var IS_DIGIT = /^\d$/;
  100. var IS_NON_ZERO_DIGIT = /^[1-9]$/;
  101. var IS_NUMBER_START = /^(-|\d)$/;
  102. var IS_WHITESPACE = /^[\t\n\r ]$/;
  103. var PRIMITIVE = 0;
  104. var OBJECT = 1;
  105. var $parse = function (source, reviver) {
  106. source = toString(source);
  107. var context = new Context(source, 0, '');
  108. var root = context.parse();
  109. var value = root.value;
  110. var endIndex = context.skip(IS_WHITESPACE, root.end);
  111. if (endIndex < source.length) {
  112. throw SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
  113. }
  114. return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
  115. };
  116. var internalize = function (holder, name, reviver, node) {
  117. var val = holder[name];
  118. var unmodified = node && val === node.value;
  119. var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
  120. var elementRecordsLen, keys, len, i, P;
  121. if (isObject(val)) {
  122. var nodeIsArray = isArray(val);
  123. var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
  124. if (nodeIsArray) {
  125. elementRecordsLen = nodes.length;
  126. len = lengthOfArrayLike(val);
  127. for (i = 0; i < len; i++) {
  128. internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
  129. }
  130. } else {
  131. keys = enumerableOwnProperties(val);
  132. len = lengthOfArrayLike(keys);
  133. for (i = 0; i < len; i++) {
  134. P = keys[i];
  135. internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
  136. }
  137. }
  138. }
  139. return call(reviver, holder, name, val, context);
  140. };
  141. var internalizeProperty = function (object, key, value) {
  142. if (DESCRIPTORS) {
  143. var descriptor = getOwnPropertyDescriptor(object, key);
  144. if (descriptor && !descriptor.configurable)
  145. return;
  146. }
  147. if (value === undefined)
  148. delete object[key];
  149. else
  150. createProperty(object, key, value);
  151. };
  152. var Node = function (value, end, source, nodes) {
  153. this.value = value;
  154. this.end = end;
  155. this.source = source;
  156. this.nodes = nodes;
  157. };
  158. var Context = function (source, index) {
  159. this.source = source;
  160. this.index = index;
  161. };
  162. Context.prototype = {
  163. fork: function (nextIndex) {
  164. return new Context(this.source, nextIndex);
  165. },
  166. parse: function () {
  167. var source = this.source;
  168. var i = this.skip(IS_WHITESPACE, this.index);
  169. var fork = this.fork(i);
  170. var chr = at(source, i);
  171. if (exec(IS_NUMBER_START, chr))
  172. return fork.number();
  173. switch (chr) {
  174. case '{':
  175. return fork.object();
  176. case '[':
  177. return fork.array();
  178. case '"':
  179. return fork.string();
  180. case 't':
  181. return fork.keyword(true);
  182. case 'f':
  183. return fork.keyword(false);
  184. case 'n':
  185. return fork.keyword(null);
  186. }
  187. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  188. },
  189. node: function (type, value, start, end, nodes) {
  190. return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
  191. },
  192. object: function () {
  193. var source = this.source;
  194. var i = this.index + 1;
  195. var expectKeypair = false;
  196. var object = {};
  197. var nodes = {};
  198. while (i < source.length) {
  199. i = this.until([
  200. '"',
  201. '}'
  202. ], i);
  203. if (at(source, i) === '}' && !expectKeypair) {
  204. i++;
  205. break;
  206. }
  207. var result = this.fork(i).string();
  208. var key = result.value;
  209. i = result.end;
  210. i = this.until([':'], i) + 1;
  211. i = this.skip(IS_WHITESPACE, i);
  212. result = this.fork(i).parse();
  213. createProperty(nodes, key, result);
  214. createProperty(object, key, result.value);
  215. i = this.until([
  216. ',',
  217. '}'
  218. ], result.end);
  219. var chr = at(source, i);
  220. if (chr === ',') {
  221. expectKeypair = true;
  222. i++;
  223. } else if (chr === '}') {
  224. i++;
  225. break;
  226. }
  227. }
  228. return this.node(OBJECT, object, this.index, i, nodes);
  229. },
  230. array: function () {
  231. var source = this.source;
  232. var i = this.index + 1;
  233. var expectElement = false;
  234. var array = [];
  235. var nodes = [];
  236. while (i < source.length) {
  237. i = this.skip(IS_WHITESPACE, i);
  238. if (at(source, i) === ']' && !expectElement) {
  239. i++;
  240. break;
  241. }
  242. var result = this.fork(i).parse();
  243. push(nodes, result);
  244. push(array, result.value);
  245. i = this.until([
  246. ',',
  247. ']'
  248. ], result.end);
  249. if (at(source, i) === ',') {
  250. expectElement = true;
  251. i++;
  252. } else if (at(source, i) === ']') {
  253. i++;
  254. break;
  255. }
  256. }
  257. return this.node(OBJECT, array, this.index, i, nodes);
  258. },
  259. string: function () {
  260. var index = this.index;
  261. var parsed = parseJSONString(this.source, this.index + 1);
  262. return this.node(PRIMITIVE, parsed.value, index, parsed.end);
  263. },
  264. number: function () {
  265. var source = this.source;
  266. var startIndex = this.index;
  267. var i = startIndex;
  268. if (at(source, i) === '-')
  269. i++;
  270. if (at(source, i) === '0')
  271. i++;
  272. else if (exec(IS_NON_ZERO_DIGIT, at(source, i)))
  273. i = this.skip(IS_DIGIT, ++i);
  274. else
  275. throw SyntaxError('Failed to parse number at: ' + i);
  276. if (at(source, i) === '.')
  277. i = this.skip(IS_DIGIT, ++i);
  278. if (at(source, i) === 'e' || at(source, i) === 'E') {
  279. i++;
  280. if (at(source, i) === '+' || at(source, i) === '-')
  281. i++;
  282. var exponentStartIndex = i;
  283. i = this.skip(IS_DIGIT, i);
  284. if (exponentStartIndex === i)
  285. throw SyntaxError("Failed to parse number's exponent value at: " + i);
  286. }
  287. return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
  288. },
  289. keyword: function (value) {
  290. var keyword = '' + value;
  291. var index = this.index;
  292. var endIndex = index + keyword.length;
  293. if (slice(this.source, index, endIndex) !== keyword)
  294. throw SyntaxError('Failed to parse value at: ' + index);
  295. return this.node(PRIMITIVE, value, index, endIndex);
  296. },
  297. skip: function (regex, i) {
  298. var source = this.source;
  299. for (; i < source.length; i++)
  300. if (!exec(regex, at(source, i)))
  301. break;
  302. return i;
  303. },
  304. until: function (array, i) {
  305. i = this.skip(IS_WHITESPACE, i);
  306. var chr = at(this.source, i);
  307. for (var j = 0; j < array.length; j++)
  308. if (array[j] === chr)
  309. return i;
  310. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  311. }
  312. };
  313. var NO_SOURCE_SUPPORT = fails(function () {
  314. var unsafeInt = '9007199254740993';
  315. var source;
  316. nativeParse(unsafeInt, function (key, value, context) {
  317. source = context.source;
  318. });
  319. return source !== unsafeInt;
  320. });
  321. var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
  322. return 1 / nativeParse('-0 \t') !== -Infinity;
  323. });
  324. $({
  325. target: 'JSON',
  326. stat: true,
  327. forced: NO_SOURCE_SUPPORT
  328. }, {
  329. parse: function parse(text, reviver) {
  330. return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
  331. }
  332. });
  333. /***/ }),
  334. /* 3 */
  335. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  336. var global = __webpack_require__(4);
  337. var getOwnPropertyDescriptor = (__webpack_require__(5).f);
  338. var createNonEnumerableProperty = __webpack_require__(44);
  339. var defineBuiltIn = __webpack_require__(48);
  340. var defineGlobalProperty = __webpack_require__(38);
  341. var copyConstructorProperties = __webpack_require__(56);
  342. var isForced = __webpack_require__(68);
  343. module.exports = function (options, source) {
  344. var TARGET = options.target;
  345. var GLOBAL = options.global;
  346. var STATIC = options.stat;
  347. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  348. if (GLOBAL) {
  349. target = global;
  350. } else if (STATIC) {
  351. target = global[TARGET] || defineGlobalProperty(TARGET, {});
  352. } else {
  353. target = (global[TARGET] || {}).prototype;
  354. }
  355. if (target)
  356. for (key in source) {
  357. sourceProperty = source[key];
  358. if (options.dontCallGetSet) {
  359. descriptor = getOwnPropertyDescriptor(target, key);
  360. targetProperty = descriptor && descriptor.value;
  361. } else
  362. targetProperty = target[key];
  363. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  364. if (!FORCED && targetProperty !== undefined) {
  365. if (typeof sourceProperty == typeof targetProperty)
  366. continue;
  367. copyConstructorProperties(sourceProperty, targetProperty);
  368. }
  369. if (options.sham || targetProperty && targetProperty.sham) {
  370. createNonEnumerableProperty(sourceProperty, 'sham', true);
  371. }
  372. defineBuiltIn(target, key, sourceProperty, options);
  373. }
  374. };
  375. /***/ }),
  376. /* 4 */
  377. /***/ (function(module) {
  378. var check = function (it) {
  379. return it && it.Math === Math && it;
  380. };
  381. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  382. return this;
  383. }()) || this || Function('return this')();
  384. /***/ }),
  385. /* 5 */
  386. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  387. var DESCRIPTORS = __webpack_require__(6);
  388. var call = __webpack_require__(8);
  389. var propertyIsEnumerableModule = __webpack_require__(10);
  390. var createPropertyDescriptor = __webpack_require__(11);
  391. var toIndexedObject = __webpack_require__(12);
  392. var toPropertyKey = __webpack_require__(18);
  393. var hasOwn = __webpack_require__(39);
  394. var IE8_DOM_DEFINE = __webpack_require__(42);
  395. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  396. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  397. O = toIndexedObject(O);
  398. P = toPropertyKey(P);
  399. if (IE8_DOM_DEFINE)
  400. try {
  401. return $getOwnPropertyDescriptor(O, P);
  402. } catch (error) {
  403. }
  404. if (hasOwn(O, P))
  405. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  406. };
  407. /***/ }),
  408. /* 6 */
  409. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  410. var fails = __webpack_require__(7);
  411. module.exports = !fails(function () {
  412. return Object.defineProperty({}, 1, {
  413. get: function () {
  414. return 7;
  415. }
  416. })[1] !== 7;
  417. });
  418. /***/ }),
  419. /* 7 */
  420. /***/ ((module) => {
  421. module.exports = function (exec) {
  422. try {
  423. return !!exec();
  424. } catch (error) {
  425. return true;
  426. }
  427. };
  428. /***/ }),
  429. /* 8 */
  430. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  431. var NATIVE_BIND = __webpack_require__(9);
  432. var call = Function.prototype.call;
  433. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  434. return call.apply(call, arguments);
  435. };
  436. /***/ }),
  437. /* 9 */
  438. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  439. var fails = __webpack_require__(7);
  440. module.exports = !fails(function () {
  441. var test = function () {
  442. }.bind();
  443. return typeof test != 'function' || test.hasOwnProperty('prototype');
  444. });
  445. /***/ }),
  446. /* 10 */
  447. /***/ ((__unused_webpack_module, exports) => {
  448. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  449. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  450. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  451. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  452. var descriptor = getOwnPropertyDescriptor(this, V);
  453. return !!descriptor && descriptor.enumerable;
  454. } : $propertyIsEnumerable;
  455. /***/ }),
  456. /* 11 */
  457. /***/ ((module) => {
  458. module.exports = function (bitmap, value) {
  459. return {
  460. enumerable: !(bitmap & 1),
  461. configurable: !(bitmap & 2),
  462. writable: !(bitmap & 4),
  463. value: value
  464. };
  465. };
  466. /***/ }),
  467. /* 12 */
  468. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  469. var IndexedObject = __webpack_require__(13);
  470. var requireObjectCoercible = __webpack_require__(16);
  471. module.exports = function (it) {
  472. return IndexedObject(requireObjectCoercible(it));
  473. };
  474. /***/ }),
  475. /* 13 */
  476. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  477. var uncurryThis = __webpack_require__(14);
  478. var fails = __webpack_require__(7);
  479. var classof = __webpack_require__(15);
  480. var $Object = Object;
  481. var split = uncurryThis(''.split);
  482. module.exports = fails(function () {
  483. return !$Object('z').propertyIsEnumerable(0);
  484. }) ? function (it) {
  485. return classof(it) === 'String' ? split(it, '') : $Object(it);
  486. } : $Object;
  487. /***/ }),
  488. /* 14 */
  489. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  490. var NATIVE_BIND = __webpack_require__(9);
  491. var FunctionPrototype = Function.prototype;
  492. var call = FunctionPrototype.call;
  493. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  494. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  495. return function () {
  496. return call.apply(fn, arguments);
  497. };
  498. };
  499. /***/ }),
  500. /* 15 */
  501. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  502. var uncurryThis = __webpack_require__(14);
  503. var toString = uncurryThis({}.toString);
  504. var stringSlice = uncurryThis(''.slice);
  505. module.exports = function (it) {
  506. return stringSlice(toString(it), 8, -1);
  507. };
  508. /***/ }),
  509. /* 16 */
  510. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  511. var isNullOrUndefined = __webpack_require__(17);
  512. var $TypeError = TypeError;
  513. module.exports = function (it) {
  514. if (isNullOrUndefined(it))
  515. throw $TypeError("Can't call method on " + it);
  516. return it;
  517. };
  518. /***/ }),
  519. /* 17 */
  520. /***/ ((module) => {
  521. module.exports = function (it) {
  522. return it === null || it === undefined;
  523. };
  524. /***/ }),
  525. /* 18 */
  526. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  527. var toPrimitive = __webpack_require__(19);
  528. var isSymbol = __webpack_require__(23);
  529. module.exports = function (argument) {
  530. var key = toPrimitive(argument, 'string');
  531. return isSymbol(key) ? key : key + '';
  532. };
  533. /***/ }),
  534. /* 19 */
  535. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  536. var call = __webpack_require__(8);
  537. var isObject = __webpack_require__(20);
  538. var isSymbol = __webpack_require__(23);
  539. var getMethod = __webpack_require__(30);
  540. var ordinaryToPrimitive = __webpack_require__(33);
  541. var wellKnownSymbol = __webpack_require__(34);
  542. var $TypeError = TypeError;
  543. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  544. module.exports = function (input, pref) {
  545. if (!isObject(input) || isSymbol(input))
  546. return input;
  547. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  548. var result;
  549. if (exoticToPrim) {
  550. if (pref === undefined)
  551. pref = 'default';
  552. result = call(exoticToPrim, input, pref);
  553. if (!isObject(result) || isSymbol(result))
  554. return result;
  555. throw $TypeError("Can't convert object to primitive value");
  556. }
  557. if (pref === undefined)
  558. pref = 'number';
  559. return ordinaryToPrimitive(input, pref);
  560. };
  561. /***/ }),
  562. /* 20 */
  563. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  564. var isCallable = __webpack_require__(21);
  565. var $documentAll = __webpack_require__(22);
  566. var documentAll = $documentAll.all;
  567. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  568. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  569. } : function (it) {
  570. return typeof it == 'object' ? it !== null : isCallable(it);
  571. };
  572. /***/ }),
  573. /* 21 */
  574. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  575. var $documentAll = __webpack_require__(22);
  576. var documentAll = $documentAll.all;
  577. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  578. return typeof argument == 'function' || argument === documentAll;
  579. } : function (argument) {
  580. return typeof argument == 'function';
  581. };
  582. /***/ }),
  583. /* 22 */
  584. /***/ ((module) => {
  585. var documentAll = typeof document == 'object' && document.all;
  586. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  587. module.exports = {
  588. all: documentAll,
  589. IS_HTMLDDA: IS_HTMLDDA
  590. };
  591. /***/ }),
  592. /* 23 */
  593. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  594. var getBuiltIn = __webpack_require__(24);
  595. var isCallable = __webpack_require__(21);
  596. var isPrototypeOf = __webpack_require__(25);
  597. var USE_SYMBOL_AS_UID = __webpack_require__(26);
  598. var $Object = Object;
  599. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  600. return typeof it == 'symbol';
  601. } : function (it) {
  602. var $Symbol = getBuiltIn('Symbol');
  603. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  604. };
  605. /***/ }),
  606. /* 24 */
  607. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  608. var global = __webpack_require__(4);
  609. var isCallable = __webpack_require__(21);
  610. var aFunction = function (argument) {
  611. return isCallable(argument) ? argument : undefined;
  612. };
  613. module.exports = function (namespace, method) {
  614. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  615. };
  616. /***/ }),
  617. /* 25 */
  618. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  619. var uncurryThis = __webpack_require__(14);
  620. module.exports = uncurryThis({}.isPrototypeOf);
  621. /***/ }),
  622. /* 26 */
  623. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  624. var NATIVE_SYMBOL = __webpack_require__(27);
  625. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  626. /***/ }),
  627. /* 27 */
  628. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  629. var V8_VERSION = __webpack_require__(28);
  630. var fails = __webpack_require__(7);
  631. var global = __webpack_require__(4);
  632. var $String = global.String;
  633. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  634. var symbol = Symbol('symbol detection');
  635. return !$String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  636. });
  637. /***/ }),
  638. /* 28 */
  639. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  640. var global = __webpack_require__(4);
  641. var userAgent = __webpack_require__(29);
  642. var process = global.process;
  643. var Deno = global.Deno;
  644. var versions = process && process.versions || Deno && Deno.version;
  645. var v8 = versions && versions.v8;
  646. var match, version;
  647. if (v8) {
  648. match = v8.split('.');
  649. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  650. }
  651. if (!version && userAgent) {
  652. match = userAgent.match(/Edge\/(\d+)/);
  653. if (!match || match[1] >= 74) {
  654. match = userAgent.match(/Chrome\/(\d+)/);
  655. if (match)
  656. version = +match[1];
  657. }
  658. }
  659. module.exports = version;
  660. /***/ }),
  661. /* 29 */
  662. /***/ ((module) => {
  663. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  664. /***/ }),
  665. /* 30 */
  666. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  667. var aCallable = __webpack_require__(31);
  668. var isNullOrUndefined = __webpack_require__(17);
  669. module.exports = function (V, P) {
  670. var func = V[P];
  671. return isNullOrUndefined(func) ? undefined : aCallable(func);
  672. };
  673. /***/ }),
  674. /* 31 */
  675. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  676. var isCallable = __webpack_require__(21);
  677. var tryToString = __webpack_require__(32);
  678. var $TypeError = TypeError;
  679. module.exports = function (argument) {
  680. if (isCallable(argument))
  681. return argument;
  682. throw $TypeError(tryToString(argument) + ' is not a function');
  683. };
  684. /***/ }),
  685. /* 32 */
  686. /***/ ((module) => {
  687. var $String = String;
  688. module.exports = function (argument) {
  689. try {
  690. return $String(argument);
  691. } catch (error) {
  692. return 'Object';
  693. }
  694. };
  695. /***/ }),
  696. /* 33 */
  697. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  698. var call = __webpack_require__(8);
  699. var isCallable = __webpack_require__(21);
  700. var isObject = __webpack_require__(20);
  701. var $TypeError = TypeError;
  702. module.exports = function (input, pref) {
  703. var fn, val;
  704. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  705. return val;
  706. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  707. return val;
  708. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  709. return val;
  710. throw $TypeError("Can't convert object to primitive value");
  711. };
  712. /***/ }),
  713. /* 34 */
  714. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  715. var global = __webpack_require__(4);
  716. var shared = __webpack_require__(35);
  717. var hasOwn = __webpack_require__(39);
  718. var uid = __webpack_require__(41);
  719. var NATIVE_SYMBOL = __webpack_require__(27);
  720. var USE_SYMBOL_AS_UID = __webpack_require__(26);
  721. var Symbol = global.Symbol;
  722. var WellKnownSymbolsStore = shared('wks');
  723. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  724. module.exports = function (name) {
  725. if (!hasOwn(WellKnownSymbolsStore, name)) {
  726. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) ? Symbol[name] : createWellKnownSymbol('Symbol.' + name);
  727. }
  728. return WellKnownSymbolsStore[name];
  729. };
  730. /***/ }),
  731. /* 35 */
  732. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  733. var IS_PURE = __webpack_require__(36);
  734. var store = __webpack_require__(37);
  735. (module.exports = function (key, value) {
  736. return store[key] || (store[key] = value !== undefined ? value : {});
  737. })('versions', []).push({
  738. version: '3.32.1',
  739. mode: IS_PURE ? 'pure' : 'global',
  740. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  741. license: 'https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE',
  742. source: 'https://github.com/zloirock/core-js'
  743. });
  744. /***/ }),
  745. /* 36 */
  746. /***/ ((module) => {
  747. module.exports = false;
  748. /***/ }),
  749. /* 37 */
  750. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  751. var global = __webpack_require__(4);
  752. var defineGlobalProperty = __webpack_require__(38);
  753. var SHARED = '__core-js_shared__';
  754. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  755. module.exports = store;
  756. /***/ }),
  757. /* 38 */
  758. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  759. var global = __webpack_require__(4);
  760. var defineProperty = Object.defineProperty;
  761. module.exports = function (key, value) {
  762. try {
  763. defineProperty(global, key, {
  764. value: value,
  765. configurable: true,
  766. writable: true
  767. });
  768. } catch (error) {
  769. global[key] = value;
  770. }
  771. return value;
  772. };
  773. /***/ }),
  774. /* 39 */
  775. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  776. var uncurryThis = __webpack_require__(14);
  777. var toObject = __webpack_require__(40);
  778. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  779. module.exports = Object.hasOwn || function hasOwn(it, key) {
  780. return hasOwnProperty(toObject(it), key);
  781. };
  782. /***/ }),
  783. /* 40 */
  784. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  785. var requireObjectCoercible = __webpack_require__(16);
  786. var $Object = Object;
  787. module.exports = function (argument) {
  788. return $Object(requireObjectCoercible(argument));
  789. };
  790. /***/ }),
  791. /* 41 */
  792. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  793. var uncurryThis = __webpack_require__(14);
  794. var id = 0;
  795. var postfix = Math.random();
  796. var toString = uncurryThis(1.0.toString);
  797. module.exports = function (key) {
  798. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  799. };
  800. /***/ }),
  801. /* 42 */
  802. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  803. var DESCRIPTORS = __webpack_require__(6);
  804. var fails = __webpack_require__(7);
  805. var createElement = __webpack_require__(43);
  806. module.exports = !DESCRIPTORS && !fails(function () {
  807. return Object.defineProperty(createElement('div'), 'a', {
  808. get: function () {
  809. return 7;
  810. }
  811. }).a !== 7;
  812. });
  813. /***/ }),
  814. /* 43 */
  815. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  816. var global = __webpack_require__(4);
  817. var isObject = __webpack_require__(20);
  818. var document = global.document;
  819. var EXISTS = isObject(document) && isObject(document.createElement);
  820. module.exports = function (it) {
  821. return EXISTS ? document.createElement(it) : {};
  822. };
  823. /***/ }),
  824. /* 44 */
  825. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  826. var DESCRIPTORS = __webpack_require__(6);
  827. var definePropertyModule = __webpack_require__(45);
  828. var createPropertyDescriptor = __webpack_require__(11);
  829. module.exports = DESCRIPTORS ? function (object, key, value) {
  830. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  831. } : function (object, key, value) {
  832. object[key] = value;
  833. return object;
  834. };
  835. /***/ }),
  836. /* 45 */
  837. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  838. var DESCRIPTORS = __webpack_require__(6);
  839. var IE8_DOM_DEFINE = __webpack_require__(42);
  840. var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(46);
  841. var anObject = __webpack_require__(47);
  842. var toPropertyKey = __webpack_require__(18);
  843. var $TypeError = TypeError;
  844. var $defineProperty = Object.defineProperty;
  845. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  846. var ENUMERABLE = 'enumerable';
  847. var CONFIGURABLE = 'configurable';
  848. var WRITABLE = 'writable';
  849. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  850. anObject(O);
  851. P = toPropertyKey(P);
  852. anObject(Attributes);
  853. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  854. var current = $getOwnPropertyDescriptor(O, P);
  855. if (current && current[WRITABLE]) {
  856. O[P] = Attributes.value;
  857. Attributes = {
  858. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  859. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  860. writable: false
  861. };
  862. }
  863. }
  864. return $defineProperty(O, P, Attributes);
  865. } : $defineProperty : function defineProperty(O, P, Attributes) {
  866. anObject(O);
  867. P = toPropertyKey(P);
  868. anObject(Attributes);
  869. if (IE8_DOM_DEFINE)
  870. try {
  871. return $defineProperty(O, P, Attributes);
  872. } catch (error) {
  873. }
  874. if ('get' in Attributes || 'set' in Attributes)
  875. throw $TypeError('Accessors not supported');
  876. if ('value' in Attributes)
  877. O[P] = Attributes.value;
  878. return O;
  879. };
  880. /***/ }),
  881. /* 46 */
  882. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  883. var DESCRIPTORS = __webpack_require__(6);
  884. var fails = __webpack_require__(7);
  885. module.exports = DESCRIPTORS && fails(function () {
  886. return Object.defineProperty(function () {
  887. }, 'prototype', {
  888. value: 42,
  889. writable: false
  890. }).prototype !== 42;
  891. });
  892. /***/ }),
  893. /* 47 */
  894. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  895. var isObject = __webpack_require__(20);
  896. var $String = String;
  897. var $TypeError = TypeError;
  898. module.exports = function (argument) {
  899. if (isObject(argument))
  900. return argument;
  901. throw $TypeError($String(argument) + ' is not an object');
  902. };
  903. /***/ }),
  904. /* 48 */
  905. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  906. var isCallable = __webpack_require__(21);
  907. var definePropertyModule = __webpack_require__(45);
  908. var makeBuiltIn = __webpack_require__(49);
  909. var defineGlobalProperty = __webpack_require__(38);
  910. module.exports = function (O, key, value, options) {
  911. if (!options)
  912. options = {};
  913. var simple = options.enumerable;
  914. var name = options.name !== undefined ? options.name : key;
  915. if (isCallable(value))
  916. makeBuiltIn(value, name, options);
  917. if (options.global) {
  918. if (simple)
  919. O[key] = value;
  920. else
  921. defineGlobalProperty(key, value);
  922. } else {
  923. try {
  924. if (!options.unsafe)
  925. delete O[key];
  926. else if (O[key])
  927. simple = true;
  928. } catch (error) {
  929. }
  930. if (simple)
  931. O[key] = value;
  932. else
  933. definePropertyModule.f(O, key, {
  934. value: value,
  935. enumerable: false,
  936. configurable: !options.nonConfigurable,
  937. writable: !options.nonWritable
  938. });
  939. }
  940. return O;
  941. };
  942. /***/ }),
  943. /* 49 */
  944. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  945. var uncurryThis = __webpack_require__(14);
  946. var fails = __webpack_require__(7);
  947. var isCallable = __webpack_require__(21);
  948. var hasOwn = __webpack_require__(39);
  949. var DESCRIPTORS = __webpack_require__(6);
  950. var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(50).CONFIGURABLE);
  951. var inspectSource = __webpack_require__(51);
  952. var InternalStateModule = __webpack_require__(52);
  953. var enforceInternalState = InternalStateModule.enforce;
  954. var getInternalState = InternalStateModule.get;
  955. var $String = String;
  956. var defineProperty = Object.defineProperty;
  957. var stringSlice = uncurryThis(''.slice);
  958. var replace = uncurryThis(''.replace);
  959. var join = uncurryThis([].join);
  960. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  961. return defineProperty(function () {
  962. }, 'length', { value: 8 }).length !== 8;
  963. });
  964. var TEMPLATE = String(String).split('String');
  965. var makeBuiltIn = module.exports = function (value, name, options) {
  966. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  967. name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
  968. }
  969. if (options && options.getter)
  970. name = 'get ' + name;
  971. if (options && options.setter)
  972. name = 'set ' + name;
  973. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  974. if (DESCRIPTORS)
  975. defineProperty(value, 'name', {
  976. value: name,
  977. configurable: true
  978. });
  979. else
  980. value.name = name;
  981. }
  982. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  983. defineProperty(value, 'length', { value: options.arity });
  984. }
  985. try {
  986. if (options && hasOwn(options, 'constructor') && options.constructor) {
  987. if (DESCRIPTORS)
  988. defineProperty(value, 'prototype', { writable: false });
  989. } else if (value.prototype)
  990. value.prototype = undefined;
  991. } catch (error) {
  992. }
  993. var state = enforceInternalState(value);
  994. if (!hasOwn(state, 'source')) {
  995. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  996. }
  997. return value;
  998. };
  999. Function.prototype.toString = makeBuiltIn(function toString() {
  1000. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1001. }, 'toString');
  1002. /***/ }),
  1003. /* 50 */
  1004. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1005. var DESCRIPTORS = __webpack_require__(6);
  1006. var hasOwn = __webpack_require__(39);
  1007. var FunctionPrototype = Function.prototype;
  1008. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1009. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1010. var PROPER = EXISTS && function something() {
  1011. }.name === 'something';
  1012. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1013. module.exports = {
  1014. EXISTS: EXISTS,
  1015. PROPER: PROPER,
  1016. CONFIGURABLE: CONFIGURABLE
  1017. };
  1018. /***/ }),
  1019. /* 51 */
  1020. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1021. var uncurryThis = __webpack_require__(14);
  1022. var isCallable = __webpack_require__(21);
  1023. var store = __webpack_require__(37);
  1024. var functionToString = uncurryThis(Function.toString);
  1025. if (!isCallable(store.inspectSource)) {
  1026. store.inspectSource = function (it) {
  1027. return functionToString(it);
  1028. };
  1029. }
  1030. module.exports = store.inspectSource;
  1031. /***/ }),
  1032. /* 52 */
  1033. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1034. var NATIVE_WEAK_MAP = __webpack_require__(53);
  1035. var global = __webpack_require__(4);
  1036. var isObject = __webpack_require__(20);
  1037. var createNonEnumerableProperty = __webpack_require__(44);
  1038. var hasOwn = __webpack_require__(39);
  1039. var shared = __webpack_require__(37);
  1040. var sharedKey = __webpack_require__(54);
  1041. var hiddenKeys = __webpack_require__(55);
  1042. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1043. var TypeError = global.TypeError;
  1044. var WeakMap = global.WeakMap;
  1045. var set, get, has;
  1046. var enforce = function (it) {
  1047. return has(it) ? get(it) : set(it, {});
  1048. };
  1049. var getterFor = function (TYPE) {
  1050. return function (it) {
  1051. var state;
  1052. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1053. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1054. }
  1055. return state;
  1056. };
  1057. };
  1058. if (NATIVE_WEAK_MAP || shared.state) {
  1059. var store = shared.state || (shared.state = new WeakMap());
  1060. store.get = store.get;
  1061. store.has = store.has;
  1062. store.set = store.set;
  1063. set = function (it, metadata) {
  1064. if (store.has(it))
  1065. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1066. metadata.facade = it;
  1067. store.set(it, metadata);
  1068. return metadata;
  1069. };
  1070. get = function (it) {
  1071. return store.get(it) || {};
  1072. };
  1073. has = function (it) {
  1074. return store.has(it);
  1075. };
  1076. } else {
  1077. var STATE = sharedKey('state');
  1078. hiddenKeys[STATE] = true;
  1079. set = function (it, metadata) {
  1080. if (hasOwn(it, STATE))
  1081. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1082. metadata.facade = it;
  1083. createNonEnumerableProperty(it, STATE, metadata);
  1084. return metadata;
  1085. };
  1086. get = function (it) {
  1087. return hasOwn(it, STATE) ? it[STATE] : {};
  1088. };
  1089. has = function (it) {
  1090. return hasOwn(it, STATE);
  1091. };
  1092. }
  1093. module.exports = {
  1094. set: set,
  1095. get: get,
  1096. has: has,
  1097. enforce: enforce,
  1098. getterFor: getterFor
  1099. };
  1100. /***/ }),
  1101. /* 53 */
  1102. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1103. var global = __webpack_require__(4);
  1104. var isCallable = __webpack_require__(21);
  1105. var WeakMap = global.WeakMap;
  1106. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  1107. /***/ }),
  1108. /* 54 */
  1109. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1110. var shared = __webpack_require__(35);
  1111. var uid = __webpack_require__(41);
  1112. var keys = shared('keys');
  1113. module.exports = function (key) {
  1114. return keys[key] || (keys[key] = uid(key));
  1115. };
  1116. /***/ }),
  1117. /* 55 */
  1118. /***/ ((module) => {
  1119. module.exports = {};
  1120. /***/ }),
  1121. /* 56 */
  1122. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1123. var hasOwn = __webpack_require__(39);
  1124. var ownKeys = __webpack_require__(57);
  1125. var getOwnPropertyDescriptorModule = __webpack_require__(5);
  1126. var definePropertyModule = __webpack_require__(45);
  1127. module.exports = function (target, source, exceptions) {
  1128. var keys = ownKeys(source);
  1129. var defineProperty = definePropertyModule.f;
  1130. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1131. for (var i = 0; i < keys.length; i++) {
  1132. var key = keys[i];
  1133. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  1134. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1135. }
  1136. }
  1137. };
  1138. /***/ }),
  1139. /* 57 */
  1140. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1141. var getBuiltIn = __webpack_require__(24);
  1142. var uncurryThis = __webpack_require__(14);
  1143. var getOwnPropertyNamesModule = __webpack_require__(58);
  1144. var getOwnPropertySymbolsModule = __webpack_require__(67);
  1145. var anObject = __webpack_require__(47);
  1146. var concat = uncurryThis([].concat);
  1147. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1148. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1149. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1150. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1151. };
  1152. /***/ }),
  1153. /* 58 */
  1154. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1155. var internalObjectKeys = __webpack_require__(59);
  1156. var enumBugKeys = __webpack_require__(66);
  1157. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1158. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1159. return internalObjectKeys(O, hiddenKeys);
  1160. };
  1161. /***/ }),
  1162. /* 59 */
  1163. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1164. var uncurryThis = __webpack_require__(14);
  1165. var hasOwn = __webpack_require__(39);
  1166. var toIndexedObject = __webpack_require__(12);
  1167. var indexOf = (__webpack_require__(60).indexOf);
  1168. var hiddenKeys = __webpack_require__(55);
  1169. var push = uncurryThis([].push);
  1170. module.exports = function (object, names) {
  1171. var O = toIndexedObject(object);
  1172. var i = 0;
  1173. var result = [];
  1174. var key;
  1175. for (key in O)
  1176. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1177. while (names.length > i)
  1178. if (hasOwn(O, key = names[i++])) {
  1179. ~indexOf(result, key) || push(result, key);
  1180. }
  1181. return result;
  1182. };
  1183. /***/ }),
  1184. /* 60 */
  1185. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1186. var toIndexedObject = __webpack_require__(12);
  1187. var toAbsoluteIndex = __webpack_require__(61);
  1188. var lengthOfArrayLike = __webpack_require__(64);
  1189. var createMethod = function (IS_INCLUDES) {
  1190. return function ($this, el, fromIndex) {
  1191. var O = toIndexedObject($this);
  1192. var length = lengthOfArrayLike(O);
  1193. var index = toAbsoluteIndex(fromIndex, length);
  1194. var value;
  1195. if (IS_INCLUDES && el !== el)
  1196. while (length > index) {
  1197. value = O[index++];
  1198. if (value !== value)
  1199. return true;
  1200. }
  1201. else
  1202. for (; length > index; index++) {
  1203. if ((IS_INCLUDES || index in O) && O[index] === el)
  1204. return IS_INCLUDES || index || 0;
  1205. }
  1206. return !IS_INCLUDES && -1;
  1207. };
  1208. };
  1209. module.exports = {
  1210. includes: createMethod(true),
  1211. indexOf: createMethod(false)
  1212. };
  1213. /***/ }),
  1214. /* 61 */
  1215. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1216. var toIntegerOrInfinity = __webpack_require__(62);
  1217. var max = Math.max;
  1218. var min = Math.min;
  1219. module.exports = function (index, length) {
  1220. var integer = toIntegerOrInfinity(index);
  1221. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1222. };
  1223. /***/ }),
  1224. /* 62 */
  1225. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1226. var trunc = __webpack_require__(63);
  1227. module.exports = function (argument) {
  1228. var number = +argument;
  1229. return number !== number || number === 0 ? 0 : trunc(number);
  1230. };
  1231. /***/ }),
  1232. /* 63 */
  1233. /***/ ((module) => {
  1234. var ceil = Math.ceil;
  1235. var floor = Math.floor;
  1236. module.exports = Math.trunc || function trunc(x) {
  1237. var n = +x;
  1238. return (n > 0 ? floor : ceil)(n);
  1239. };
  1240. /***/ }),
  1241. /* 64 */
  1242. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1243. var toLength = __webpack_require__(65);
  1244. module.exports = function (obj) {
  1245. return toLength(obj.length);
  1246. };
  1247. /***/ }),
  1248. /* 65 */
  1249. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1250. var toIntegerOrInfinity = __webpack_require__(62);
  1251. var min = Math.min;
  1252. module.exports = function (argument) {
  1253. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1254. };
  1255. /***/ }),
  1256. /* 66 */
  1257. /***/ ((module) => {
  1258. module.exports = [
  1259. 'constructor',
  1260. 'hasOwnProperty',
  1261. 'isPrototypeOf',
  1262. 'propertyIsEnumerable',
  1263. 'toLocaleString',
  1264. 'toString',
  1265. 'valueOf'
  1266. ];
  1267. /***/ }),
  1268. /* 67 */
  1269. /***/ ((__unused_webpack_module, exports) => {
  1270. exports.f = Object.getOwnPropertySymbols;
  1271. /***/ }),
  1272. /* 68 */
  1273. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1274. var fails = __webpack_require__(7);
  1275. var isCallable = __webpack_require__(21);
  1276. var replacement = /#|\.prototype\./;
  1277. var isForced = function (feature, detection) {
  1278. var value = data[normalize(feature)];
  1279. return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1280. };
  1281. var normalize = isForced.normalize = function (string) {
  1282. return String(string).replace(replacement, '.').toLowerCase();
  1283. };
  1284. var data = isForced.data = {};
  1285. var NATIVE = isForced.NATIVE = 'N';
  1286. var POLYFILL = isForced.POLYFILL = 'P';
  1287. module.exports = isForced;
  1288. /***/ }),
  1289. /* 69 */
  1290. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1291. var classof = __webpack_require__(15);
  1292. module.exports = Array.isArray || function isArray(argument) {
  1293. return classof(argument) === 'Array';
  1294. };
  1295. /***/ }),
  1296. /* 70 */
  1297. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1298. var classof = __webpack_require__(71);
  1299. var $String = String;
  1300. module.exports = function (argument) {
  1301. if (classof(argument) === 'Symbol')
  1302. throw TypeError('Cannot convert a Symbol value to a string');
  1303. return $String(argument);
  1304. };
  1305. /***/ }),
  1306. /* 71 */
  1307. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1308. var TO_STRING_TAG_SUPPORT = __webpack_require__(72);
  1309. var isCallable = __webpack_require__(21);
  1310. var classofRaw = __webpack_require__(15);
  1311. var wellKnownSymbol = __webpack_require__(34);
  1312. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1313. var $Object = Object;
  1314. var CORRECT_ARGUMENTS = classofRaw((function () {
  1315. return arguments;
  1316. }())) === 'Arguments';
  1317. var tryGet = function (it, key) {
  1318. try {
  1319. return it[key];
  1320. } catch (error) {
  1321. }
  1322. };
  1323. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  1324. var O, tag, result;
  1325. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  1326. };
  1327. /***/ }),
  1328. /* 72 */
  1329. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1330. var wellKnownSymbol = __webpack_require__(34);
  1331. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1332. var test = {};
  1333. test[TO_STRING_TAG] = 'z';
  1334. module.exports = String(test) === '[object z]';
  1335. /***/ }),
  1336. /* 73 */
  1337. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1338. var toPropertyKey = __webpack_require__(18);
  1339. var definePropertyModule = __webpack_require__(45);
  1340. var createPropertyDescriptor = __webpack_require__(11);
  1341. module.exports = function (object, key, value) {
  1342. var propertyKey = toPropertyKey(key);
  1343. if (propertyKey in object)
  1344. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  1345. else
  1346. object[propertyKey] = value;
  1347. };
  1348. /***/ }),
  1349. /* 74 */
  1350. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1351. var uncurryThis = __webpack_require__(14);
  1352. var hasOwn = __webpack_require__(39);
  1353. var $SyntaxError = SyntaxError;
  1354. var $parseInt = parseInt;
  1355. var fromCharCode = String.fromCharCode;
  1356. var at = uncurryThis(''.charAt);
  1357. var slice = uncurryThis(''.slice);
  1358. var exec = uncurryThis(/./.exec);
  1359. var codePoints = {
  1360. '\\"': '"',
  1361. '\\\\': '\\',
  1362. '\\/': '/',
  1363. '\\b': '\b',
  1364. '\\f': '\f',
  1365. '\\n': '\n',
  1366. '\\r': '\r',
  1367. '\\t': '\t'
  1368. };
  1369. var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i;
  1370. var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/;
  1371. module.exports = function (source, i) {
  1372. var unterminated = true;
  1373. var value = '';
  1374. while (i < source.length) {
  1375. var chr = at(source, i);
  1376. if (chr === '\\') {
  1377. var twoChars = slice(source, i, i + 2);
  1378. if (hasOwn(codePoints, twoChars)) {
  1379. value += codePoints[twoChars];
  1380. i += 2;
  1381. } else if (twoChars === '\\u') {
  1382. i += 2;
  1383. var fourHexDigits = slice(source, i, i + 4);
  1384. if (!exec(IS_4_HEX_DIGITS, fourHexDigits))
  1385. throw $SyntaxError('Bad Unicode escape at: ' + i);
  1386. value += fromCharCode($parseInt(fourHexDigits, 16));
  1387. i += 4;
  1388. } else
  1389. throw $SyntaxError('Unknown escape sequence: "' + twoChars + '"');
  1390. } else if (chr === '"') {
  1391. unterminated = false;
  1392. i++;
  1393. break;
  1394. } else {
  1395. if (exec(IS_C0_CONTROL_CODE, chr))
  1396. throw $SyntaxError('Bad control character in string literal at: ' + i);
  1397. value += chr;
  1398. i++;
  1399. }
  1400. }
  1401. if (unterminated)
  1402. throw $SyntaxError('Unterminated string at: ' + i);
  1403. return {
  1404. value: value,
  1405. end: i
  1406. };
  1407. };
  1408. /***/ }),
  1409. /* 75 */
  1410. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1411. Object.defineProperty(exports, "__esModule", ({
  1412. value: true
  1413. }));
  1414. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  1415. __webpack_require__(76);
  1416. __webpack_require__(89);
  1417. __webpack_require__(92);
  1418. __webpack_require__(94);
  1419. __webpack_require__(95);
  1420. var _ui_utils = __webpack_require__(97);
  1421. var _pdfjsLib = __webpack_require__(122);
  1422. var _app_options = __webpack_require__(123);
  1423. var _event_utils = __webpack_require__(124);
  1424. var _pdf_link_service = __webpack_require__(125);
  1425. var _webAnnotation_editor_params = __webpack_require__(126);
  1426. var _overlay_manager = __webpack_require__(127);
  1427. var _password_prompt = __webpack_require__(128);
  1428. var _webPdf_attachment_viewer = __webpack_require__(129);
  1429. var _webPdf_cursor_tools = __webpack_require__(131);
  1430. var _webPdf_document_properties = __webpack_require__(133);
  1431. var _webPdf_find_bar = __webpack_require__(134);
  1432. var _pdf_find_controller = __webpack_require__(135);
  1433. var _pdf_history = __webpack_require__(137);
  1434. var _webPdf_layer_viewer = __webpack_require__(138);
  1435. var _webPdf_outline_viewer = __webpack_require__(139);
  1436. var _webPdf_presentation_mode = __webpack_require__(140);
  1437. var _pdf_rendering_queue = __webpack_require__(141);
  1438. var _pdf_scripting_manager = __webpack_require__(142);
  1439. var _webPdf_sidebar = __webpack_require__(143);
  1440. var _webPdf_thumbnail_viewer = __webpack_require__(144);
  1441. var _pdf_viewer = __webpack_require__(146);
  1442. var _webSecondary_toolbar = __webpack_require__(156);
  1443. var _webToolbar = __webpack_require__(157);
  1444. var _view_history = __webpack_require__(158);
  1445. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  1446. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  1447. const ViewOnLoad = {
  1448. UNKNOWN: -1,
  1449. PREVIOUS: 0,
  1450. INITIAL: 1
  1451. };
  1452. const ViewerCssTheme = {
  1453. AUTOMATIC: 0,
  1454. LIGHT: 1,
  1455. DARK: 2
  1456. };
  1457. class DefaultExternalServices {
  1458. constructor() {
  1459. throw new Error("Cannot initialize DefaultExternalServices.");
  1460. }
  1461. static updateFindControlState(data) {}
  1462. static updateFindMatchesCount(data) {}
  1463. static initPassiveLoading(callbacks) {}
  1464. static reportTelemetry(data) {}
  1465. static createDownloadManager() {
  1466. throw new Error("Not implemented: createDownloadManager");
  1467. }
  1468. static createPreferences() {
  1469. throw new Error("Not implemented: createPreferences");
  1470. }
  1471. static createL10n(options) {
  1472. throw new Error("Not implemented: createL10n");
  1473. }
  1474. static createScripting(options) {
  1475. throw new Error("Not implemented: createScripting");
  1476. }
  1477. static get supportsPinchToZoom() {
  1478. return (0, _pdfjsLib.shadow)(this, "supportsPinchToZoom", true);
  1479. }
  1480. static get supportsIntegratedFind() {
  1481. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  1482. }
  1483. static get supportsDocumentFonts() {
  1484. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  1485. }
  1486. static get supportedMouseWheelZoomModifierKeys() {
  1487. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  1488. ctrlKey: true,
  1489. metaKey: true
  1490. });
  1491. }
  1492. static get isInAutomation() {
  1493. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  1494. }
  1495. static updateEditorStates(data) {
  1496. throw new Error("Not implemented: updateEditorStates");
  1497. }
  1498. static get canvasMaxAreaInBytes() {
  1499. return (0, _pdfjsLib.shadow)(this, "canvasMaxAreaInBytes", -1);
  1500. }
  1501. static getNimbusExperimentData() {
  1502. return (0, _pdfjsLib.shadow)(this, "getNimbusExperimentData", Promise.resolve(null));
  1503. }
  1504. }
  1505. exports.DefaultExternalServices = DefaultExternalServices;
  1506. const PDFViewerApplication = {
  1507. initialBookmark: document.location.hash.substring(1),
  1508. _initializedCapability: new _pdfjsLib.PromiseCapability(),
  1509. appConfig: null,
  1510. pdfDocument: null,
  1511. pdfLoadingTask: null,
  1512. printService: null,
  1513. pdfViewer: null,
  1514. pdfThumbnailViewer: null,
  1515. pdfRenderingQueue: null,
  1516. pdfPresentationMode: null,
  1517. pdfDocumentProperties: null,
  1518. pdfLinkService: null,
  1519. pdfHistory: null,
  1520. pdfSidebar: null,
  1521. pdfOutlineViewer: null,
  1522. pdfAttachmentViewer: null,
  1523. pdfLayerViewer: null,
  1524. pdfCursorTools: null,
  1525. pdfScriptingManager: null,
  1526. store: null,
  1527. downloadManager: null,
  1528. overlayManager: null,
  1529. preferences: null,
  1530. toolbar: null,
  1531. secondaryToolbar: null,
  1532. eventBus: null,
  1533. l10n: null,
  1534. annotationEditorParams: null,
  1535. isInitialViewSet: false,
  1536. downloadComplete: false,
  1537. isViewerEmbedded: window.parent !== window,
  1538. url: "",
  1539. baseUrl: "",
  1540. _downloadUrl: "",
  1541. externalServices: DefaultExternalServices,
  1542. _boundEvents: Object.create(null),
  1543. documentInfo: null,
  1544. metadata: null,
  1545. _contentDispositionFilename: null,
  1546. _contentLength: null,
  1547. _saveInProgress: false,
  1548. _wheelUnusedTicks: 0,
  1549. _wheelUnusedFactor: 1,
  1550. _touchUnusedTicks: 0,
  1551. _touchUnusedFactor: 1,
  1552. _PDFBug: null,
  1553. _hasAnnotationEditors: false,
  1554. _title: document.title,
  1555. _printAnnotationStoragePromise: null,
  1556. _touchInfo: null,
  1557. _isCtrlKeyDown: false,
  1558. _nimbusDataPromise: null,
  1559. async initialize(appConfig) {
  1560. this.preferences = this.externalServices.createPreferences();
  1561. this.appConfig = appConfig;
  1562. await this._initializeOptions();
  1563. this._forceCssTheme();
  1564. await this._initializeL10n();
  1565. if (this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf_link_service.LinkTarget.NONE) {
  1566. _app_options.AppOptions.set("externalLinkTarget", _pdf_link_service.LinkTarget.TOP);
  1567. }
  1568. await this._initializeViewerComponents();
  1569. this.bindEvents();
  1570. this.bindWindowEvents();
  1571. const appContainer = appConfig.appContainer || document.documentElement;
  1572. this.l10n.translate(appContainer).then(() => {
  1573. this.eventBus.dispatch("localized", {
  1574. source: this
  1575. });
  1576. });
  1577. this._initializedCapability.resolve();
  1578. },
  1579. async _initializeOptions() {
  1580. if (_app_options.AppOptions.get("disablePreferences")) {
  1581. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  1582. await this._parseHashParams();
  1583. }
  1584. return;
  1585. }
  1586. if (_app_options.AppOptions._hasUserOptions()) {
  1587. console.warn("_initializeOptions: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  1588. }
  1589. try {
  1590. _app_options.AppOptions.setAll(await this.preferences.getAll());
  1591. } catch (reason) {
  1592. console.error(`_initializeOptions: "${reason.message}".`);
  1593. }
  1594. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  1595. await this._parseHashParams();
  1596. }
  1597. },
  1598. async _parseHashParams() {
  1599. const hash = document.location.hash.substring(1);
  1600. if (!hash) {
  1601. return;
  1602. }
  1603. const {
  1604. mainContainer,
  1605. viewerContainer
  1606. } = this.appConfig,
  1607. params = (0, _ui_utils.parseQueryString)(hash);
  1608. if (params.get("disableworker") === "true") {
  1609. try {
  1610. await loadFakeWorker();
  1611. } catch (ex) {
  1612. console.error(`_parseHashParams: "${ex.message}".`);
  1613. }
  1614. }
  1615. if (params.has("disablerange")) {
  1616. _app_options.AppOptions.set("disableRange", params.get("disablerange") === "true");
  1617. }
  1618. if (params.has("disablestream")) {
  1619. _app_options.AppOptions.set("disableStream", params.get("disablestream") === "true");
  1620. }
  1621. if (params.has("disableautofetch")) {
  1622. _app_options.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  1623. }
  1624. if (params.has("disablefontface")) {
  1625. _app_options.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  1626. }
  1627. if (params.has("disablehistory")) {
  1628. _app_options.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  1629. }
  1630. if (params.has("verbosity")) {
  1631. _app_options.AppOptions.set("verbosity", params.get("verbosity") | 0);
  1632. }
  1633. if (params.has("textlayer")) {
  1634. switch (params.get("textlayer")) {
  1635. case "off":
  1636. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  1637. break;
  1638. case "visible":
  1639. case "shadow":
  1640. case "hover":
  1641. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  1642. try {
  1643. await loadPDFBug(this);
  1644. this._PDFBug.loadCSS();
  1645. } catch (ex) {
  1646. console.error(`_parseHashParams: "${ex.message}".`);
  1647. }
  1648. break;
  1649. }
  1650. }
  1651. if (params.has("pdfbug")) {
  1652. _app_options.AppOptions.set("pdfBug", true);
  1653. _app_options.AppOptions.set("fontExtraProperties", true);
  1654. const enabled = params.get("pdfbug").split(",");
  1655. try {
  1656. await loadPDFBug(this);
  1657. this._PDFBug.init(mainContainer, enabled);
  1658. } catch (ex) {
  1659. console.error(`_parseHashParams: "${ex.message}".`);
  1660. }
  1661. }
  1662. if (params.has("locale")) {
  1663. _app_options.AppOptions.set("locale", params.get("locale"));
  1664. }
  1665. },
  1666. async _initializeL10n() {
  1667. this.l10n = this.externalServices.createL10n({
  1668. locale: _app_options.AppOptions.get("locale")
  1669. });
  1670. const dir = await this.l10n.getDirection();
  1671. document.getElementsByTagName("html")[0].dir = dir;
  1672. },
  1673. _forceCssTheme() {
  1674. const cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  1675. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  1676. return;
  1677. }
  1678. try {
  1679. const styleSheet = document.styleSheets[0];
  1680. const cssRules = styleSheet?.cssRules || [];
  1681. for (let i = 0, ii = cssRules.length; i < ii; i++) {
  1682. const rule = cssRules[i];
  1683. if (rule instanceof CSSMediaRule && rule.media?.[0] === "(prefers-color-scheme: dark)") {
  1684. if (cssTheme === ViewerCssTheme.LIGHT) {
  1685. styleSheet.deleteRule(i);
  1686. return;
  1687. }
  1688. const darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  1689. if (darkRules?.[1]) {
  1690. styleSheet.deleteRule(i);
  1691. styleSheet.insertRule(darkRules[1], i);
  1692. }
  1693. return;
  1694. }
  1695. }
  1696. } catch (reason) {
  1697. console.error(`_forceCssTheme: "${reason?.message}".`);
  1698. }
  1699. },
  1700. async _initializeViewerComponents() {
  1701. const {
  1702. appConfig,
  1703. externalServices,
  1704. l10n
  1705. } = this;
  1706. const eventBus = externalServices.isInAutomation ? new _event_utils.AutomationEventBus() : new _event_utils.EventBus();
  1707. this.eventBus = eventBus;
  1708. this.overlayManager = new _overlay_manager.OverlayManager();
  1709. const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  1710. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  1711. this.pdfRenderingQueue = pdfRenderingQueue;
  1712. const pdfLinkService = new _pdf_link_service.PDFLinkService({
  1713. eventBus,
  1714. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  1715. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  1716. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  1717. });
  1718. this.pdfLinkService = pdfLinkService;
  1719. const downloadManager = externalServices.createDownloadManager();
  1720. this.downloadManager = downloadManager;
  1721. const findController = new _pdf_find_controller.PDFFindController({
  1722. linkService: pdfLinkService,
  1723. eventBus,
  1724. updateMatchesCountOnProgress: true
  1725. });
  1726. this.findController = findController;
  1727. const pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  1728. eventBus,
  1729. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc"),
  1730. externalServices,
  1731. docProperties: this._scriptingDocProperties.bind(this)
  1732. });
  1733. this.pdfScriptingManager = pdfScriptingManager;
  1734. const container = appConfig.mainContainer,
  1735. viewer = appConfig.viewerContainer;
  1736. const annotationEditorMode = _app_options.AppOptions.get("annotationEditorMode");
  1737. const isOffscreenCanvasSupported = _app_options.AppOptions.get("isOffscreenCanvasSupported") && _pdfjsLib.FeatureTest.isOffscreenCanvasSupported;
  1738. const pageColors = _app_options.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  1739. background: _app_options.AppOptions.get("pageColorsBackground"),
  1740. foreground: _app_options.AppOptions.get("pageColorsForeground")
  1741. } : null;
  1742. const pdfViewer = new _pdf_viewer.PDFViewer({
  1743. container,
  1744. viewer,
  1745. eventBus,
  1746. renderingQueue: pdfRenderingQueue,
  1747. linkService: pdfLinkService,
  1748. downloadManager,
  1749. findController,
  1750. scriptingManager: _app_options.AppOptions.get("enableScripting") && pdfScriptingManager,
  1751. l10n,
  1752. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  1753. annotationMode: _app_options.AppOptions.get("annotationMode"),
  1754. annotationEditorMode,
  1755. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  1756. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  1757. isOffscreenCanvasSupported,
  1758. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  1759. enablePermissions: _app_options.AppOptions.get("enablePermissions"),
  1760. pageColors
  1761. });
  1762. this.pdfViewer = pdfViewer;
  1763. pdfRenderingQueue.setViewer(pdfViewer);
  1764. pdfLinkService.setViewer(pdfViewer);
  1765. pdfScriptingManager.setViewer(pdfViewer);
  1766. if (appConfig.sidebar?.thumbnailView) {
  1767. this.pdfThumbnailViewer = new _webPdf_thumbnail_viewer.PDFThumbnailViewer({
  1768. container: appConfig.sidebar.thumbnailView,
  1769. eventBus,
  1770. renderingQueue: pdfRenderingQueue,
  1771. linkService: pdfLinkService,
  1772. l10n,
  1773. pageColors
  1774. });
  1775. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  1776. }
  1777. if (!this.isViewerEmbedded && !_app_options.AppOptions.get("disableHistory")) {
  1778. this.pdfHistory = new _pdf_history.PDFHistory({
  1779. linkService: pdfLinkService,
  1780. eventBus
  1781. });
  1782. pdfLinkService.setHistory(this.pdfHistory);
  1783. }
  1784. if (!this.supportsIntegratedFind && appConfig.findBar) {
  1785. this.findBar = new _webPdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, l10n);
  1786. }
  1787. if (appConfig.annotationEditorParams) {
  1788. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  1789. if (_app_options.AppOptions.get("enableStampEditor") && isOffscreenCanvasSupported) {
  1790. appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
  1791. }
  1792. this.annotationEditorParams = new _webAnnotation_editor_params.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  1793. } else {
  1794. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  1795. document.getElementById(id)?.classList.add("hidden");
  1796. }
  1797. }
  1798. }
  1799. if (appConfig.documentProperties) {
  1800. this.pdfDocumentProperties = new _webPdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
  1801. }
  1802. if (appConfig.secondaryToolbar?.cursorHandToolButton) {
  1803. this.pdfCursorTools = new _webPdf_cursor_tools.PDFCursorTools({
  1804. container,
  1805. eventBus,
  1806. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  1807. });
  1808. }
  1809. if (appConfig.toolbar) {
  1810. this.toolbar = new _webToolbar.Toolbar(appConfig.toolbar, eventBus, l10n);
  1811. }
  1812. if (appConfig.secondaryToolbar) {
  1813. this.secondaryToolbar = new _webSecondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, eventBus, externalServices);
  1814. }
  1815. if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
  1816. this.pdfPresentationMode = new _webPdf_presentation_mode.PDFPresentationMode({
  1817. container,
  1818. pdfViewer,
  1819. eventBus
  1820. });
  1821. }
  1822. if (appConfig.passwordOverlay) {
  1823. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, l10n, this.isViewerEmbedded);
  1824. }
  1825. if (appConfig.sidebar?.outlineView) {
  1826. this.pdfOutlineViewer = new _webPdf_outline_viewer.PDFOutlineViewer({
  1827. container: appConfig.sidebar.outlineView,
  1828. eventBus,
  1829. linkService: pdfLinkService,
  1830. downloadManager
  1831. });
  1832. }
  1833. if (appConfig.sidebar?.attachmentsView) {
  1834. this.pdfAttachmentViewer = new _webPdf_attachment_viewer.PDFAttachmentViewer({
  1835. container: appConfig.sidebar.attachmentsView,
  1836. eventBus,
  1837. downloadManager
  1838. });
  1839. }
  1840. if (appConfig.sidebar?.layersView) {
  1841. this.pdfLayerViewer = new _webPdf_layer_viewer.PDFLayerViewer({
  1842. container: appConfig.sidebar.layersView,
  1843. eventBus,
  1844. l10n
  1845. });
  1846. }
  1847. if (appConfig.sidebar) {
  1848. this.pdfSidebar = new _webPdf_sidebar.PDFSidebar({
  1849. elements: appConfig.sidebar,
  1850. eventBus,
  1851. l10n
  1852. });
  1853. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  1854. this.pdfSidebar.onUpdateThumbnails = () => {
  1855. for (const pageView of pdfViewer.getCachedPageViews()) {
  1856. if (pageView.renderingState === _ui_utils.RenderingStates.FINISHED) {
  1857. this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
  1858. }
  1859. }
  1860. this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  1861. };
  1862. }
  1863. },
  1864. async run(config) {
  1865. await this.initialize(config);
  1866. const {
  1867. appConfig,
  1868. eventBus
  1869. } = this;
  1870. let file;
  1871. const queryString = document.location.search.substring(1);
  1872. const params = (0, _ui_utils.parseQueryString)(queryString);
  1873. file = params.get("file") ?? _app_options.AppOptions.get("defaultUrl");
  1874. validateFileURL(file);
  1875. const fileInput = appConfig.openFileInput;
  1876. fileInput.value = null;
  1877. fileInput.addEventListener("change", function (evt) {
  1878. const {
  1879. files
  1880. } = evt.target;
  1881. if (!files || files.length === 0) {
  1882. return;
  1883. }
  1884. eventBus.dispatch("fileinputchange", {
  1885. source: this,
  1886. fileInput: evt.target
  1887. });
  1888. });
  1889. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1890. evt.preventDefault();
  1891. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  1892. });
  1893. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1894. evt.preventDefault();
  1895. const {
  1896. files
  1897. } = evt.dataTransfer;
  1898. if (!files || files.length === 0) {
  1899. return;
  1900. }
  1901. eventBus.dispatch("fileinputchange", {
  1902. source: this,
  1903. fileInput: evt.dataTransfer
  1904. });
  1905. });
  1906. if (!this.supportsDocumentFonts) {
  1907. _app_options.AppOptions.set("disableFontFace", true);
  1908. this.l10n.get("web_fonts_disabled").then(msg => {
  1909. console.warn(msg);
  1910. });
  1911. }
  1912. if (!this.supportsPrinting) {
  1913. appConfig.toolbar?.print?.classList.add("hidden");
  1914. appConfig.secondaryToolbar?.printButton.classList.add("hidden");
  1915. }
  1916. if (!this.supportsFullscreen) {
  1917. appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
  1918. }
  1919. if (this.supportsIntegratedFind) {
  1920. appConfig.toolbar?.viewFind?.classList.add("hidden");
  1921. }
  1922. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1923. if (evt.target === this) {
  1924. eventBus.dispatch("resize", {
  1925. source: this
  1926. });
  1927. }
  1928. }, true);
  1929. if (file) {
  1930. this.open({
  1931. url: file
  1932. });
  1933. } else {
  1934. this._hideViewBookmark();
  1935. }
  1936. },
  1937. get initialized() {
  1938. return this._initializedCapability.settled;
  1939. },
  1940. get initializedPromise() {
  1941. return this._initializedCapability.promise;
  1942. },
  1943. zoomIn(steps, scaleFactor) {
  1944. if (this.pdfViewer.isInPresentationMode) {
  1945. return;
  1946. }
  1947. this.pdfViewer.increaseScale({
  1948. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  1949. steps,
  1950. scaleFactor
  1951. });
  1952. },
  1953. zoomOut(steps, scaleFactor) {
  1954. if (this.pdfViewer.isInPresentationMode) {
  1955. return;
  1956. }
  1957. this.pdfViewer.decreaseScale({
  1958. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  1959. steps,
  1960. scaleFactor
  1961. });
  1962. },
  1963. zoomReset() {
  1964. if (this.pdfViewer.isInPresentationMode) {
  1965. return;
  1966. }
  1967. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1968. },
  1969. get pagesCount() {
  1970. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1971. },
  1972. get page() {
  1973. return this.pdfViewer.currentPageNumber;
  1974. },
  1975. set page(val) {
  1976. this.pdfViewer.currentPageNumber = val;
  1977. },
  1978. get supportsPrinting() {
  1979. return PDFPrintServiceFactory.instance.supportsPrinting;
  1980. },
  1981. get supportsFullscreen() {
  1982. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  1983. },
  1984. get supportsPinchToZoom() {
  1985. return this.externalServices.supportsPinchToZoom;
  1986. },
  1987. get supportsIntegratedFind() {
  1988. return this.externalServices.supportsIntegratedFind;
  1989. },
  1990. get supportsDocumentFonts() {
  1991. return this.externalServices.supportsDocumentFonts;
  1992. },
  1993. get loadingBar() {
  1994. const barElement = document.getElementById("loadingBar");
  1995. const bar = barElement ? new _ui_utils.ProgressBar(barElement) : null;
  1996. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1997. },
  1998. get supportedMouseWheelZoomModifierKeys() {
  1999. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  2000. },
  2001. initPassiveLoading(file) {
  2002. throw new Error("Not implemented: initPassiveLoading");
  2003. },
  2004. setTitleUsingUrl() {
  2005. let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  2006. let downloadUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2007. this.url = url;
  2008. this.baseUrl = url.split("#")[0];
  2009. if (downloadUrl) {
  2010. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#")[0];
  2011. }
  2012. if ((0, _pdfjsLib.isDataScheme)(url)) {
  2013. this._hideViewBookmark();
  2014. }
  2015. let title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  2016. if (!title) {
  2017. try {
  2018. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  2019. } catch {
  2020. title = url;
  2021. }
  2022. }
  2023. this.setTitle(title);
  2024. },
  2025. setTitle() {
  2026. let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._title;
  2027. this._title = title;
  2028. if (this.isViewerEmbedded) {
  2029. return;
  2030. }
  2031. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  2032. document.title = `${editorIndicator ? "* " : ""}${title}`;
  2033. },
  2034. get _docFilename() {
  2035. return this._contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url);
  2036. },
  2037. _hideViewBookmark() {
  2038. const {
  2039. secondaryToolbar
  2040. } = this.appConfig;
  2041. secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
  2042. if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
  2043. document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
  2044. }
  2045. },
  2046. async close() {
  2047. this._unblockDocumentLoadEvent();
  2048. this._hideViewBookmark();
  2049. if (!this.pdfLoadingTask) {
  2050. return;
  2051. }
  2052. if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
  2053. try {
  2054. await this.save();
  2055. } catch {}
  2056. }
  2057. const promises = [];
  2058. promises.push(this.pdfLoadingTask.destroy());
  2059. this.pdfLoadingTask = null;
  2060. if (this.pdfDocument) {
  2061. this.pdfDocument = null;
  2062. this.pdfThumbnailViewer?.setDocument(null);
  2063. this.pdfViewer.setDocument(null);
  2064. this.pdfLinkService.setDocument(null);
  2065. this.pdfDocumentProperties?.setDocument(null);
  2066. }
  2067. this.pdfLinkService.externalLinkEnabled = true;
  2068. this.store = null;
  2069. this.isInitialViewSet = false;
  2070. this.downloadComplete = false;
  2071. this.url = "";
  2072. this.baseUrl = "";
  2073. this._downloadUrl = "";
  2074. this.documentInfo = null;
  2075. this.metadata = null;
  2076. this._contentDispositionFilename = null;
  2077. this._contentLength = null;
  2078. this._saveInProgress = false;
  2079. this._hasAnnotationEditors = false;
  2080. promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
  2081. this.setTitle();
  2082. this.pdfSidebar?.reset();
  2083. this.pdfOutlineViewer?.reset();
  2084. this.pdfAttachmentViewer?.reset();
  2085. this.pdfLayerViewer?.reset();
  2086. this.pdfHistory?.reset();
  2087. this.findBar?.reset();
  2088. this.toolbar?.reset();
  2089. this.secondaryToolbar?.reset();
  2090. this._PDFBug?.cleanup();
  2091. await Promise.all(promises);
  2092. },
  2093. async open(args) {
  2094. let deprecatedArgs = false;
  2095. if (typeof args === "string") {
  2096. args = {
  2097. url: args
  2098. };
  2099. deprecatedArgs = true;
  2100. } else if (args?.byteLength) {
  2101. args = {
  2102. data: args
  2103. };
  2104. deprecatedArgs = true;
  2105. }
  2106. if (deprecatedArgs) {
  2107. console.error("The `PDFViewerApplication.open` signature was updated, please use an object instead.");
  2108. }
  2109. if (this.pdfLoadingTask) {
  2110. await this.close();
  2111. }
  2112. const workerParams = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  2113. Object.assign(_pdfjsLib.GlobalWorkerOptions, workerParams);
  2114. if (args.url) {
  2115. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  2116. }
  2117. const apiParams = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  2118. const params = {
  2119. canvasMaxAreaInBytes: this.externalServices.canvasMaxAreaInBytes,
  2120. ...apiParams,
  2121. ...args
  2122. };
  2123. const loadingTask = (0, _pdfjsLib.getDocument)(params);
  2124. this.pdfLoadingTask = loadingTask;
  2125. loadingTask.onPassword = (updateCallback, reason) => {
  2126. if (this.isViewerEmbedded) {
  2127. this._unblockDocumentLoadEvent();
  2128. }
  2129. this.pdfLinkService.externalLinkEnabled = false;
  2130. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2131. this.passwordPrompt.open();
  2132. };
  2133. loadingTask.onProgress = _ref => {
  2134. let {
  2135. loaded,
  2136. total
  2137. } = _ref;
  2138. this.progress(loaded / total);
  2139. };
  2140. return loadingTask.promise.then(pdfDocument => {
  2141. this.load(pdfDocument);
  2142. }, reason => {
  2143. if (loadingTask !== this.pdfLoadingTask) {
  2144. return undefined;
  2145. }
  2146. let key = "loading_error";
  2147. if (reason instanceof _pdfjsLib.InvalidPDFException) {
  2148. key = "invalid_file_error";
  2149. } else if (reason instanceof _pdfjsLib.MissingPDFException) {
  2150. key = "missing_file_error";
  2151. } else if (reason instanceof _pdfjsLib.UnexpectedResponseException) {
  2152. key = "unexpected_response_error";
  2153. }
  2154. return this.l10n.get(key).then(msg => {
  2155. this._documentError(msg, {
  2156. message: reason?.message
  2157. });
  2158. throw reason;
  2159. });
  2160. });
  2161. },
  2162. _ensureDownloadComplete() {
  2163. if (this.pdfDocument && this.downloadComplete) {
  2164. return;
  2165. }
  2166. throw new Error("PDF document not downloaded.");
  2167. },
  2168. async download() {
  2169. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2170. const url = this._downloadUrl,
  2171. filename = this._docFilename;
  2172. try {
  2173. this._ensureDownloadComplete();
  2174. const data = await this.pdfDocument.getData();
  2175. const blob = new Blob([data], {
  2176. type: "application/pdf"
  2177. });
  2178. await this.downloadManager.download(blob, url, filename, options);
  2179. } catch {
  2180. await this.downloadManager.downloadUrl(url, filename, options);
  2181. }
  2182. },
  2183. async save() {
  2184. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2185. if (this._saveInProgress) {
  2186. return;
  2187. }
  2188. this._saveInProgress = true;
  2189. await this.pdfScriptingManager.dispatchWillSave();
  2190. const url = this._downloadUrl,
  2191. filename = this._docFilename;
  2192. try {
  2193. this._ensureDownloadComplete();
  2194. const data = await this.pdfDocument.saveDocument();
  2195. const blob = new Blob([data], {
  2196. type: "application/pdf"
  2197. });
  2198. await this.downloadManager.download(blob, url, filename, options);
  2199. } catch (reason) {
  2200. console.error(`Error when saving the document: ${reason.message}`);
  2201. await this.download(options);
  2202. } finally {
  2203. await this.pdfScriptingManager.dispatchDidSave();
  2204. this._saveInProgress = false;
  2205. }
  2206. if (this._hasAnnotationEditors) {
  2207. this.externalServices.reportTelemetry({
  2208. type: "editing",
  2209. data: {
  2210. type: "save"
  2211. }
  2212. });
  2213. }
  2214. },
  2215. downloadOrSave() {
  2216. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2217. if (this.pdfDocument?.annotationStorage.size > 0) {
  2218. this.save(options);
  2219. } else {
  2220. this.download(options);
  2221. }
  2222. },
  2223. openInExternalApp() {
  2224. this.downloadOrSave({
  2225. openInExternalApp: true
  2226. });
  2227. },
  2228. _documentError(message) {
  2229. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2230. this._unblockDocumentLoadEvent();
  2231. this._otherError(message, moreInfo);
  2232. this.eventBus.dispatch("documenterror", {
  2233. source: this,
  2234. message,
  2235. reason: moreInfo?.message ?? null
  2236. });
  2237. },
  2238. _otherError(message) {
  2239. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2240. const moreInfoText = [`PDF.js v${_pdfjsLib.version || "?"} (build: ${_pdfjsLib.build || "?"})`];
  2241. if (moreInfo) {
  2242. moreInfoText.push(`Message: ${moreInfo.message}`);
  2243. if (moreInfo.stack) {
  2244. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  2245. } else {
  2246. if (moreInfo.filename) {
  2247. moreInfoText.push(`File: ${moreInfo.filename}`);
  2248. }
  2249. if (moreInfo.lineNumber) {
  2250. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  2251. }
  2252. }
  2253. }
  2254. window.parent.postMessage({
  2255. type: "error",
  2256. msg: `${message}`
  2257. })
  2258. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  2259. },
  2260. progress(level) {
  2261. if (!this.loadingBar || this.downloadComplete) {
  2262. return;
  2263. }
  2264. const percent = Math.round(level * 100);
  2265. if (percent <= this.loadingBar.percent) {
  2266. return;
  2267. }
  2268. this.loadingBar.percent = percent;
  2269. if (this.pdfDocument?.loadingParams.disableAutoFetch ?? _app_options.AppOptions.get("disableAutoFetch")) {
  2270. this.loadingBar.setDisableAutoFetch();
  2271. }
  2272. },
  2273. load(pdfDocument) {
  2274. this.pdfDocument = pdfDocument;
  2275. pdfDocument.getDownloadInfo().then(_ref2 => {
  2276. let {
  2277. length
  2278. } = _ref2;
  2279. this._contentLength = length;
  2280. this.downloadComplete = true;
  2281. this.loadingBar?.hide();
  2282. firstPagePromise.then(() => {
  2283. this.eventBus.dispatch("documentloaded", {
  2284. source: this
  2285. });
  2286. });
  2287. });
  2288. const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
  2289. const pageModePromise = pdfDocument.getPageMode().catch(() => {});
  2290. const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
  2291. this.toolbar?.setPagesCount(pdfDocument.numPages, false);
  2292. this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
  2293. this.pdfLinkService.setDocument(pdfDocument);
  2294. this.pdfDocumentProperties?.setDocument(pdfDocument);
  2295. const pdfViewer = this.pdfViewer;
  2296. pdfViewer.setDocument(pdfDocument);
  2297. const {
  2298. firstPagePromise,
  2299. onePageRendered,
  2300. pagesPromise
  2301. } = pdfViewer;
  2302. this.pdfThumbnailViewer?.setDocument(pdfDocument);
  2303. const storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  2304. page: null,
  2305. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  2306. scrollLeft: "0",
  2307. scrollTop: "0",
  2308. rotation: null,
  2309. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  2310. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  2311. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  2312. }).catch(() => {});
  2313. firstPagePromise.then(pdfPage => {
  2314. this.loadingBar?.setWidth(this.appConfig.viewerContainer);
  2315. this._initializeAnnotationStorageCallbacks(pdfDocument);
  2316. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async _ref3 => {
  2317. let [timeStamp, stored, pageLayout, pageMode, openAction] = _ref3;
  2318. const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  2319. this._initializePdfHistory({
  2320. fingerprint: pdfDocument.fingerprints[0],
  2321. viewOnLoad,
  2322. initialDest: openAction?.dest
  2323. });
  2324. const initialBookmark = this.initialBookmark;
  2325. const zoom = _app_options.AppOptions.get("defaultZoomValue");
  2326. let hash = zoom ? `zoom=${zoom}` : null;
  2327. let rotation = null;
  2328. let sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  2329. let scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  2330. let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  2331. if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  2332. hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  2333. rotation = parseInt(stored.rotation, 10);
  2334. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  2335. sidebarView = stored.sidebarView | 0;
  2336. }
  2337. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  2338. scrollMode = stored.scrollMode | 0;
  2339. }
  2340. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  2341. spreadMode = stored.spreadMode | 0;
  2342. }
  2343. }
  2344. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  2345. sidebarView = (0, _ui_utils.apiPageModeToSidebarView)(pageMode);
  2346. }
  2347. if (pageLayout && scrollMode === _ui_utils.ScrollMode.UNKNOWN && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  2348. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(pageLayout);
  2349. spreadMode = modes.spreadMode;
  2350. }
  2351. this.setInitialView(hash, {
  2352. rotation,
  2353. sidebarView,
  2354. scrollMode,
  2355. spreadMode
  2356. });
  2357. this.eventBus.dispatch("documentinit", {
  2358. source: this
  2359. });
  2360. if (!this.isViewerEmbedded) {
  2361. pdfViewer.focus();
  2362. }
  2363. await Promise.race([pagesPromise, new Promise(resolve => {
  2364. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  2365. })]);
  2366. if (!initialBookmark && !hash) {
  2367. return;
  2368. }
  2369. if (pdfViewer.hasEqualPageSizes) {
  2370. return;
  2371. }
  2372. this.initialBookmark = initialBookmark;
  2373. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  2374. this.setInitialView(hash);
  2375. }).catch(() => {
  2376. this.setInitialView();
  2377. }).then(function () {
  2378. pdfViewer.update();
  2379. });
  2380. });
  2381. pagesPromise.then(() => {
  2382. this._unblockDocumentLoadEvent();
  2383. this._initializeAutoPrint(pdfDocument, openActionPromise);
  2384. }, reason => {
  2385. this.l10n.get("loading_error").then(msg => {
  2386. this._documentError(msg, {
  2387. message: reason?.message
  2388. });
  2389. });
  2390. });
  2391. onePageRendered.then(data => {
  2392. this.externalServices.reportTelemetry({
  2393. type: "pageInfo",
  2394. timestamp: data.timestamp
  2395. });
  2396. if (this.pdfOutlineViewer) {
  2397. pdfDocument.getOutline().then(outline => {
  2398. if (pdfDocument !== this.pdfDocument) {
  2399. return;
  2400. }
  2401. this.pdfOutlineViewer.render({
  2402. outline,
  2403. pdfDocument
  2404. });
  2405. });
  2406. }
  2407. if (this.pdfAttachmentViewer) {
  2408. pdfDocument.getAttachments().then(attachments => {
  2409. if (pdfDocument !== this.pdfDocument) {
  2410. return;
  2411. }
  2412. this.pdfAttachmentViewer.render({
  2413. attachments
  2414. });
  2415. });
  2416. }
  2417. if (this.pdfLayerViewer) {
  2418. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  2419. if (pdfDocument !== this.pdfDocument) {
  2420. return;
  2421. }
  2422. this.pdfLayerViewer.render({
  2423. optionalContentConfig,
  2424. pdfDocument
  2425. });
  2426. });
  2427. }
  2428. });
  2429. this._initializePageLabels(pdfDocument);
  2430. this._initializeMetadata(pdfDocument);
  2431. },
  2432. async _scriptingDocProperties(pdfDocument) {
  2433. if (!this.documentInfo) {
  2434. await new Promise(resolve => {
  2435. this.eventBus._on("metadataloaded", resolve, {
  2436. once: true
  2437. });
  2438. });
  2439. if (pdfDocument !== this.pdfDocument) {
  2440. return null;
  2441. }
  2442. }
  2443. if (!this._contentLength) {
  2444. await new Promise(resolve => {
  2445. this.eventBus._on("documentloaded", resolve, {
  2446. once: true
  2447. });
  2448. });
  2449. if (pdfDocument !== this.pdfDocument) {
  2450. return null;
  2451. }
  2452. }
  2453. return {
  2454. ...this.documentInfo,
  2455. baseURL: this.baseUrl,
  2456. filesize: this._contentLength,
  2457. filename: this._docFilename,
  2458. metadata: this.metadata?.getRaw(),
  2459. authors: this.metadata?.get("dc:creator"),
  2460. numPages: this.pagesCount,
  2461. URL: this.url
  2462. };
  2463. },
  2464. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  2465. const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]);
  2466. if (pdfDocument !== this.pdfDocument) {
  2467. return;
  2468. }
  2469. let triggerAutoPrint = openAction?.action === "Print";
  2470. if (jsActions) {
  2471. console.warn("Warning: JavaScript support is not enabled");
  2472. for (const name in jsActions) {
  2473. if (triggerAutoPrint) {
  2474. break;
  2475. }
  2476. switch (name) {
  2477. case "WillClose":
  2478. case "WillSave":
  2479. case "DidSave":
  2480. case "WillPrint":
  2481. case "DidPrint":
  2482. continue;
  2483. }
  2484. triggerAutoPrint = jsActions[name].some(js => _ui_utils.AutoPrintRegExp.test(js));
  2485. }
  2486. }
  2487. if (triggerAutoPrint) {
  2488. this.triggerPrinting();
  2489. }
  2490. },
  2491. async _initializeMetadata(pdfDocument) {
  2492. const {
  2493. info,
  2494. metadata,
  2495. contentDispositionFilename,
  2496. contentLength
  2497. } = await pdfDocument.getMetadata();
  2498. if (pdfDocument !== this.pdfDocument) {
  2499. return;
  2500. }
  2501. this.documentInfo = info;
  2502. this.metadata = metadata;
  2503. this._contentDispositionFilename ??= contentDispositionFilename;
  2504. this._contentLength ??= contentLength;
  2505. console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${_pdfjsLib.version || "?"} [${_pdfjsLib.build || "?"}])`);
  2506. let pdfTitle = info.Title;
  2507. const metadataTitle = metadata?.get("dc:title");
  2508. if (metadataTitle) {
  2509. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2510. pdfTitle = metadataTitle;
  2511. }
  2512. }
  2513. if (pdfTitle) {
  2514. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  2515. } else if (this._contentDispositionFilename) {
  2516. this.setTitle(this._contentDispositionFilename);
  2517. }
  2518. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  2519. if (pdfDocument.loadingParams.enableXfa) {
  2520. console.warn("Warning: XFA Foreground documents are not supported");
  2521. } else {
  2522. console.warn("Warning: XFA support is not enabled");
  2523. }
  2524. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  2525. console.warn("Warning: Interactive form support is not enabled");
  2526. }
  2527. if (info.IsSignaturesPresent) {
  2528. console.warn("Warning: Digital signatures validation is not supported");
  2529. }
  2530. this.eventBus.dispatch("metadataloaded", {
  2531. source: this
  2532. });
  2533. },
  2534. async _initializePageLabels(pdfDocument) {
  2535. const labels = await pdfDocument.getPageLabels();
  2536. if (pdfDocument !== this.pdfDocument) {
  2537. return;
  2538. }
  2539. if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
  2540. return;
  2541. }
  2542. const numLabels = labels.length;
  2543. let standardLabels = 0,
  2544. emptyLabels = 0;
  2545. for (let i = 0; i < numLabels; i++) {
  2546. const label = labels[i];
  2547. if (label === (i + 1).toString()) {
  2548. standardLabels++;
  2549. } else if (label === "") {
  2550. emptyLabels++;
  2551. } else {
  2552. break;
  2553. }
  2554. }
  2555. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  2556. return;
  2557. }
  2558. const {
  2559. pdfViewer,
  2560. pdfThumbnailViewer,
  2561. toolbar
  2562. } = this;
  2563. pdfViewer.setPageLabels(labels);
  2564. pdfThumbnailViewer?.setPageLabels(labels);
  2565. toolbar?.setPagesCount(numLabels, true);
  2566. toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2567. },
  2568. _initializePdfHistory(_ref4) {
  2569. let {
  2570. fingerprint,
  2571. viewOnLoad,
  2572. initialDest = null
  2573. } = _ref4;
  2574. if (!this.pdfHistory) {
  2575. return;
  2576. }
  2577. this.pdfHistory.initialize({
  2578. fingerprint,
  2579. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2580. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2581. });
  2582. if (this.pdfHistory.initialBookmark) {
  2583. this.initialBookmark = this.pdfHistory.initialBookmark;
  2584. this.initialRotation = this.pdfHistory.initialRotation;
  2585. }
  2586. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2587. this.initialBookmark = JSON.stringify(initialDest);
  2588. this.pdfHistory.push({
  2589. explicitDest: initialDest,
  2590. pageNumber: null
  2591. });
  2592. }
  2593. },
  2594. _initializeAnnotationStorageCallbacks(pdfDocument) {
  2595. if (pdfDocument !== this.pdfDocument) {
  2596. return;
  2597. }
  2598. const {
  2599. annotationStorage
  2600. } = pdfDocument;
  2601. annotationStorage.onSetModified = () => {
  2602. window.addEventListener("beforeunload", beforeUnload);
  2603. this._annotationStorageModified = true;
  2604. };
  2605. annotationStorage.onResetModified = () => {
  2606. window.removeEventListener("beforeunload", beforeUnload);
  2607. delete this._annotationStorageModified;
  2608. };
  2609. annotationStorage.onAnnotationEditor = typeStr => {
  2610. this._hasAnnotationEditors = !!typeStr;
  2611. this.setTitle();
  2612. if (typeStr) {
  2613. this.externalServices.reportTelemetry({
  2614. type: "editing",
  2615. data: {
  2616. type: typeStr
  2617. }
  2618. });
  2619. }
  2620. };
  2621. },
  2622. setInitialView(storedHash) {
  2623. let {
  2624. rotation,
  2625. sidebarView,
  2626. scrollMode,
  2627. spreadMode
  2628. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2629. const setRotation = angle => {
  2630. if ((0, _ui_utils.isValidRotation)(angle)) {
  2631. this.pdfViewer.pagesRotation = angle;
  2632. }
  2633. };
  2634. const setViewerModes = (scroll, spread) => {
  2635. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2636. this.pdfViewer.scrollMode = scroll;
  2637. }
  2638. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2639. this.pdfViewer.spreadMode = spread;
  2640. }
  2641. };
  2642. this.isInitialViewSet = true;
  2643. this.pdfSidebar?.setInitialView(sidebarView);
  2644. setViewerModes(scrollMode, spreadMode);
  2645. if (this.initialBookmark) {
  2646. setRotation(this.initialRotation);
  2647. delete this.initialRotation;
  2648. this.pdfLinkService.setHash(this.initialBookmark);
  2649. this.initialBookmark = null;
  2650. } else if (storedHash) {
  2651. setRotation(rotation);
  2652. this.pdfLinkService.setHash(storedHash);
  2653. }
  2654. this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2655. this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
  2656. if (!this.pdfViewer.currentScaleValue) {
  2657. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2658. }
  2659. },
  2660. _cleanup() {
  2661. if (!this.pdfDocument) {
  2662. return;
  2663. }
  2664. this.pdfViewer.cleanup();
  2665. this.pdfThumbnailViewer?.cleanup();
  2666. this.pdfDocument.cleanup();
  2667. },
  2668. forceRendering() {
  2669. this.pdfRenderingQueue.printing = !!this.printService;
  2670. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS;
  2671. this.pdfRenderingQueue.renderHighestPriority();
  2672. },
  2673. beforePrint() {
  2674. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => {
  2675. return this.pdfDocument?.annotationStorage.print;
  2676. });
  2677. if (this.printService) {
  2678. return;
  2679. }
  2680. if (!this.supportsPrinting) {
  2681. this.l10n.get("printing_not_supported").then(msg => {
  2682. this._otherError(msg);
  2683. });
  2684. return;
  2685. }
  2686. if (!this.pdfViewer.pageViewsReady) {
  2687. this.l10n.get("printing_not_ready").then(msg => {
  2688. window.alert(msg);
  2689. });
  2690. return;
  2691. }
  2692. const pagesOverview = this.pdfViewer.getPagesOverview();
  2693. const printContainer = this.appConfig.printContainer;
  2694. const printResolution = _app_options.AppOptions.get("printResolution");
  2695. const optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2696. const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this._printAnnotationStoragePromise, this.l10n);
  2697. this.printService = printService;
  2698. this.forceRendering();
  2699. this.setTitle();
  2700. printService.layout();
  2701. if (this._hasAnnotationEditors) {
  2702. this.externalServices.reportTelemetry({
  2703. type: "editing",
  2704. data: {
  2705. type: "print"
  2706. }
  2707. });
  2708. }
  2709. },
  2710. afterPrint() {
  2711. if (this._printAnnotationStoragePromise) {
  2712. this._printAnnotationStoragePromise.then(() => {
  2713. this.pdfScriptingManager.dispatchDidPrint();
  2714. });
  2715. this._printAnnotationStoragePromise = null;
  2716. }
  2717. if (this.printService) {
  2718. this.printService.destroy();
  2719. this.printService = null;
  2720. this.pdfDocument?.annotationStorage.resetModified();
  2721. }
  2722. this.forceRendering();
  2723. this.setTitle();
  2724. },
  2725. rotatePages(delta) {
  2726. this.pdfViewer.pagesRotation += delta;
  2727. },
  2728. requestPresentationMode() {
  2729. this.pdfPresentationMode?.request();
  2730. },
  2731. triggerPrinting() {
  2732. if (!this.supportsPrinting) {
  2733. return;
  2734. }
  2735. window.print();
  2736. },
  2737. bindEvents() {
  2738. const {
  2739. eventBus,
  2740. _boundEvents
  2741. } = this;
  2742. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2743. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2744. eventBus._on("resize", webViewerResize);
  2745. eventBus._on("hashchange", webViewerHashchange);
  2746. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2747. eventBus._on("afterprint", _boundEvents.afterPrint);
  2748. eventBus._on("pagerender", webViewerPageRender);
  2749. eventBus._on("pagerendered", webViewerPageRendered);
  2750. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2751. eventBus._on("pagechanging", webViewerPageChanging);
  2752. eventBus._on("scalechanging", webViewerScaleChanging);
  2753. eventBus._on("rotationchanging", webViewerRotationChanging);
  2754. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2755. eventBus._on("pagemode", webViewerPageMode);
  2756. eventBus._on("namedaction", webViewerNamedAction);
  2757. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2758. eventBus._on("presentationmode", webViewerPresentationMode);
  2759. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode);
  2760. eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams);
  2761. eventBus._on("print", webViewerPrint);
  2762. eventBus._on("download", webViewerDownload);
  2763. eventBus._on("openinexternalapp", webViewerOpenInExternalApp);
  2764. eventBus._on("firstpage", webViewerFirstPage);
  2765. eventBus._on("lastpage", webViewerLastPage);
  2766. eventBus._on("nextpage", webViewerNextPage);
  2767. eventBus._on("previouspage", webViewerPreviousPage);
  2768. eventBus._on("zoomin", webViewerZoomIn);
  2769. eventBus._on("zoomout", webViewerZoomOut);
  2770. eventBus._on("zoomreset", webViewerZoomReset);
  2771. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2772. eventBus._on("scalechanged", webViewerScaleChanged);
  2773. eventBus._on("rotatecw", webViewerRotateCw);
  2774. eventBus._on("rotateccw", webViewerRotateCcw);
  2775. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2776. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2777. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2778. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2779. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2780. eventBus._on("documentproperties", webViewerDocumentProperties);
  2781. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2782. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2783. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2784. if (_app_options.AppOptions.get("pdfBug")) {
  2785. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2786. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2787. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2788. }
  2789. eventBus._on("fileinputchange", webViewerFileInputChange);
  2790. eventBus._on("openfile", webViewerOpenFile);
  2791. },
  2792. bindWindowEvents() {
  2793. const {
  2794. eventBus,
  2795. _boundEvents
  2796. } = this;
  2797. function addWindowResolutionChange() {
  2798. let evt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  2799. if (evt) {
  2800. webViewerResolutionChange(evt);
  2801. }
  2802. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  2803. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  2804. once: true
  2805. });
  2806. _boundEvents.removeWindowResolutionChange ||= function () {
  2807. mediaQueryList.removeEventListener("change", addWindowResolutionChange);
  2808. _boundEvents.removeWindowResolutionChange = null;
  2809. };
  2810. }
  2811. addWindowResolutionChange();
  2812. _boundEvents.windowResize = () => {
  2813. eventBus.dispatch("resize", {
  2814. source: window
  2815. });
  2816. };
  2817. _boundEvents.windowHashChange = () => {
  2818. eventBus.dispatch("hashchange", {
  2819. source: window,
  2820. hash: document.location.hash.substring(1)
  2821. });
  2822. };
  2823. _boundEvents.windowBeforePrint = () => {
  2824. eventBus.dispatch("beforeprint", {
  2825. source: window
  2826. });
  2827. };
  2828. _boundEvents.windowAfterPrint = () => {
  2829. eventBus.dispatch("afterprint", {
  2830. source: window
  2831. });
  2832. };
  2833. _boundEvents.windowUpdateFromSandbox = event => {
  2834. eventBus.dispatch("updatefromsandbox", {
  2835. source: window,
  2836. detail: event.detail
  2837. });
  2838. };
  2839. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2840. window.addEventListener("wheel", webViewerWheel, {
  2841. passive: false
  2842. });
  2843. window.addEventListener("touchstart", webViewerTouchStart, {
  2844. passive: false
  2845. });
  2846. window.addEventListener("touchmove", webViewerTouchMove, {
  2847. passive: false
  2848. });
  2849. window.addEventListener("touchend", webViewerTouchEnd, {
  2850. passive: false
  2851. });
  2852. window.addEventListener("click", webViewerClick);
  2853. window.addEventListener("keydown", webViewerKeyDown);
  2854. window.addEventListener("keyup", webViewerKeyUp);
  2855. window.addEventListener("resize", _boundEvents.windowResize);
  2856. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2857. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2858. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2859. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2860. },
  2861. unbindEvents() {
  2862. const {
  2863. eventBus,
  2864. _boundEvents
  2865. } = this;
  2866. eventBus._off("resize", webViewerResize);
  2867. eventBus._off("hashchange", webViewerHashchange);
  2868. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2869. eventBus._off("afterprint", _boundEvents.afterPrint);
  2870. eventBus._off("pagerender", webViewerPageRender);
  2871. eventBus._off("pagerendered", webViewerPageRendered);
  2872. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2873. eventBus._off("pagechanging", webViewerPageChanging);
  2874. eventBus._off("scalechanging", webViewerScaleChanging);
  2875. eventBus._off("rotationchanging", webViewerRotationChanging);
  2876. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2877. eventBus._off("pagemode", webViewerPageMode);
  2878. eventBus._off("namedaction", webViewerNamedAction);
  2879. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2880. eventBus._off("presentationmode", webViewerPresentationMode);
  2881. eventBus._off("print", webViewerPrint);
  2882. eventBus._off("download", webViewerDownload);
  2883. eventBus._off("openinexternalapp", webViewerOpenInExternalApp);
  2884. eventBus._off("firstpage", webViewerFirstPage);
  2885. eventBus._off("lastpage", webViewerLastPage);
  2886. eventBus._off("nextpage", webViewerNextPage);
  2887. eventBus._off("previouspage", webViewerPreviousPage);
  2888. eventBus._off("zoomin", webViewerZoomIn);
  2889. eventBus._off("zoomout", webViewerZoomOut);
  2890. eventBus._off("zoomreset", webViewerZoomReset);
  2891. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2892. eventBus._off("scalechanged", webViewerScaleChanged);
  2893. eventBus._off("rotatecw", webViewerRotateCw);
  2894. eventBus._off("rotateccw", webViewerRotateCcw);
  2895. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2896. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2897. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2898. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2899. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2900. eventBus._off("documentproperties", webViewerDocumentProperties);
  2901. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2902. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2903. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2904. if (_boundEvents.reportPageStatsPDFBug) {
  2905. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2906. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2907. _boundEvents.reportPageStatsPDFBug = null;
  2908. }
  2909. eventBus._off("fileinputchange", webViewerFileInputChange);
  2910. eventBus._off("openfile", webViewerOpenFile);
  2911. _boundEvents.beforePrint = null;
  2912. _boundEvents.afterPrint = null;
  2913. },
  2914. unbindWindowEvents() {
  2915. const {
  2916. _boundEvents
  2917. } = this;
  2918. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2919. window.removeEventListener("wheel", webViewerWheel, {
  2920. passive: false
  2921. });
  2922. window.removeEventListener("touchstart", webViewerTouchStart, {
  2923. passive: false
  2924. });
  2925. window.removeEventListener("touchmove", webViewerTouchMove, {
  2926. passive: false
  2927. });
  2928. window.removeEventListener("touchend", webViewerTouchEnd, {
  2929. passive: false
  2930. });
  2931. window.removeEventListener("click", webViewerClick);
  2932. window.removeEventListener("keydown", webViewerKeyDown);
  2933. window.removeEventListener("keyup", webViewerKeyUp);
  2934. window.removeEventListener("resize", _boundEvents.windowResize);
  2935. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2936. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2937. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2938. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2939. _boundEvents.removeWindowResolutionChange?.();
  2940. _boundEvents.windowResize = null;
  2941. _boundEvents.windowHashChange = null;
  2942. _boundEvents.windowBeforePrint = null;
  2943. _boundEvents.windowAfterPrint = null;
  2944. _boundEvents.windowUpdateFromSandbox = null;
  2945. },
  2946. _accumulateTicks(ticks, prop) {
  2947. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  2948. this[prop] = 0;
  2949. }
  2950. this[prop] += ticks;
  2951. const wholeTicks = Math.trunc(this[prop]);
  2952. this[prop] -= wholeTicks;
  2953. return wholeTicks;
  2954. },
  2955. _accumulateFactor(previousScale, factor, prop) {
  2956. if (factor === 1) {
  2957. return 1;
  2958. }
  2959. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  2960. this[prop] = 1;
  2961. }
  2962. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  2963. this[prop] = factor / newFactor;
  2964. return newFactor;
  2965. },
  2966. _centerAtPos(previousScale, x, y) {
  2967. const {
  2968. pdfViewer
  2969. } = this;
  2970. const scaleDiff = pdfViewer.currentScale / previousScale - 1;
  2971. if (scaleDiff !== 0) {
  2972. const [top, left] = pdfViewer.containerTopLeft;
  2973. pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
  2974. pdfViewer.container.scrollTop += (y - top) * scaleDiff;
  2975. }
  2976. },
  2977. _unblockDocumentLoadEvent() {
  2978. document.blockUnblockOnload?.(false);
  2979. this._unblockDocumentLoadEvent = () => {};
  2980. },
  2981. get scriptingReady() {
  2982. return this.pdfScriptingManager.ready;
  2983. }
  2984. };
  2985. exports.PDFViewerApplication = PDFViewerApplication;
  2986. {
  2987. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2988. var validateFileURL = function (file) {
  2989. if (!file) {
  2990. return;
  2991. }
  2992. try {
  2993. const viewerOrigin = new URL(window.location.href).origin || "null";
  2994. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2995. return;
  2996. }
  2997. const fileOrigin = new URL(file, window.location.href).origin;
  2998. /*if (fileOrigin !== viewerOrigin) {
  2999. throw new Error("file origin does not match viewer's");
  3000. }*/
  3001. } catch (ex) {
  3002. PDFViewerApplication.l10n.get("loading_error").then(msg => {
  3003. PDFViewerApplication._documentError(msg, {
  3004. message: ex?.message
  3005. });
  3006. });
  3007. throw ex;
  3008. }
  3009. };
  3010. }
  3011. async function loadFakeWorker() {
  3012. _pdfjsLib.GlobalWorkerOptions.workerSrc ||= _app_options.AppOptions.get("workerSrc");
  3013. await (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.workerSrc);
  3014. }
  3015. async function loadPDFBug(self) {
  3016. const {
  3017. debuggerScriptPath
  3018. } = self.appConfig;
  3019. const {
  3020. PDFBug
  3021. } = await import(debuggerScriptPath);
  3022. self._PDFBug = PDFBug;
  3023. }
  3024. function reportPageStatsPDFBug(_ref5) {
  3025. let {
  3026. pageNumber
  3027. } = _ref5;
  3028. if (!globalThis.Stats?.enabled) {
  3029. return;
  3030. }
  3031. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3032. globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
  3033. }
  3034. function webViewerPageRender(_ref6) {
  3035. let {
  3036. pageNumber
  3037. } = _ref6;
  3038. if (pageNumber === PDFViewerApplication.page) {
  3039. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true);
  3040. }
  3041. }
  3042. function webViewerPageRendered(_ref7) {
  3043. let {
  3044. pageNumber,
  3045. error
  3046. } = _ref7;
  3047. if (pageNumber === PDFViewerApplication.page) {
  3048. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false);
  3049. }
  3050. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS) {
  3051. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3052. const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
  3053. if (pageView) {
  3054. thumbnailView?.setImage(pageView);
  3055. }
  3056. }
  3057. if (error) {
  3058. PDFViewerApplication.l10n.get("rendering_error").then(msg => {
  3059. PDFViewerApplication._otherError(msg, error);
  3060. });
  3061. }
  3062. }
  3063. function webViewerPageMode(_ref8) {
  3064. let {
  3065. mode
  3066. } = _ref8;
  3067. let view;
  3068. switch (mode) {
  3069. case "thumbs":
  3070. view = _ui_utils.SidebarView.THUMBS;
  3071. break;
  3072. case "bookmarks":
  3073. case "outline":
  3074. view = _ui_utils.SidebarView.OUTLINE;
  3075. break;
  3076. case "attachments":
  3077. view = _ui_utils.SidebarView.ATTACHMENTS;
  3078. break;
  3079. case "layers":
  3080. view = _ui_utils.SidebarView.LAYERS;
  3081. break;
  3082. case "none":
  3083. view = _ui_utils.SidebarView.NONE;
  3084. break;
  3085. default:
  3086. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3087. return;
  3088. }
  3089. PDFViewerApplication.pdfSidebar?.switchView(view, true);
  3090. }
  3091. function webViewerNamedAction(evt) {
  3092. switch (evt.action) {
  3093. case "GoToPage":
  3094. PDFViewerApplication.appConfig.toolbar?.pageNumber.select();
  3095. break;
  3096. case "Find":
  3097. if (!PDFViewerApplication.supportsIntegratedFind) {
  3098. PDFViewerApplication?.findBar.toggle();
  3099. }
  3100. break;
  3101. case "Print":
  3102. PDFViewerApplication.triggerPrinting();
  3103. break;
  3104. case "SaveAs":
  3105. PDFViewerApplication.downloadOrSave();
  3106. break;
  3107. }
  3108. }
  3109. function webViewerPresentationModeChanged(evt) {
  3110. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3111. }
  3112. function webViewerSidebarViewChanged(_ref9) {
  3113. let {
  3114. view
  3115. } = _ref9;
  3116. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils.SidebarView.THUMBS;
  3117. if (PDFViewerApplication.isInitialViewSet) {
  3118. PDFViewerApplication.store?.set("sidebarView", view).catch(() => {});
  3119. }
  3120. }
  3121. function webViewerUpdateViewarea(_ref10) {
  3122. let {
  3123. location
  3124. } = _ref10;
  3125. if (PDFViewerApplication.isInitialViewSet) {
  3126. PDFViewerApplication.store?.setMultiple({
  3127. page: location.pageNumber,
  3128. zoom: location.scale,
  3129. scrollLeft: location.left,
  3130. scrollTop: location.top,
  3131. rotation: location.rotation
  3132. }).catch(() => {});
  3133. }
  3134. if (PDFViewerApplication.appConfig.secondaryToolbar) {
  3135. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3136. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3137. }
  3138. }
  3139. function webViewerScrollModeChanged(evt) {
  3140. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3141. PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {});
  3142. }
  3143. }
  3144. function webViewerSpreadModeChanged(evt) {
  3145. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3146. PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
  3147. }
  3148. }
  3149. function webViewerResize() {
  3150. const {
  3151. pdfDocument,
  3152. pdfViewer,
  3153. pdfRenderingQueue
  3154. } = PDFViewerApplication;
  3155. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  3156. return;
  3157. }
  3158. if (!pdfDocument) {
  3159. return;
  3160. }
  3161. const currentScaleValue = pdfViewer.currentScaleValue;
  3162. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  3163. pdfViewer.currentScaleValue = currentScaleValue;
  3164. }
  3165. pdfViewer.update();
  3166. }
  3167. function webViewerHashchange(evt) {
  3168. const hash = evt.hash;
  3169. if (!hash) {
  3170. return;
  3171. }
  3172. if (!PDFViewerApplication.isInitialViewSet) {
  3173. PDFViewerApplication.initialBookmark = hash;
  3174. } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
  3175. PDFViewerApplication.pdfLinkService.setHash(hash);
  3176. }
  3177. }
  3178. {
  3179. var webViewerFileInputChange = function (evt) {
  3180. if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
  3181. return;
  3182. }
  3183. const file = evt.fileInput.files[0];
  3184. PDFViewerApplication.open({
  3185. url: URL.createObjectURL(file),
  3186. originalUrl: file.name
  3187. });
  3188. };
  3189. var webViewerOpenFile = function (evt) {
  3190. const fileInput = PDFViewerApplication.appConfig.openFileInput;
  3191. fileInput.click();
  3192. };
  3193. }
  3194. function webViewerPresentationMode() {
  3195. PDFViewerApplication.requestPresentationMode();
  3196. }
  3197. function webViewerSwitchAnnotationEditorMode(evt) {
  3198. PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
  3199. }
  3200. function webViewerSwitchAnnotationEditorParams(evt) {
  3201. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  3202. }
  3203. function webViewerPrint() {
  3204. PDFViewerApplication.triggerPrinting();
  3205. }
  3206. function webViewerDownload() {
  3207. PDFViewerApplication.downloadOrSave();
  3208. }
  3209. function webViewerOpenInExternalApp() {
  3210. PDFViewerApplication.openInExternalApp();
  3211. }
  3212. function webViewerFirstPage() {
  3213. PDFViewerApplication.page = 1;
  3214. }
  3215. function webViewerLastPage() {
  3216. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3217. }
  3218. function webViewerNextPage() {
  3219. PDFViewerApplication.pdfViewer.nextPage();
  3220. }
  3221. function webViewerPreviousPage() {
  3222. PDFViewerApplication.pdfViewer.previousPage();
  3223. }
  3224. function webViewerZoomIn() {
  3225. PDFViewerApplication.zoomIn();
  3226. }
  3227. function webViewerZoomOut() {
  3228. PDFViewerApplication.zoomOut();
  3229. }
  3230. function webViewerZoomReset() {
  3231. PDFViewerApplication.zoomReset();
  3232. }
  3233. function webViewerPageNumberChanged(evt) {
  3234. const pdfViewer = PDFViewerApplication.pdfViewer;
  3235. if (evt.value !== "") {
  3236. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3237. }
  3238. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3239. PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3240. }
  3241. }
  3242. function webViewerScaleChanged(evt) {
  3243. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3244. }
  3245. function webViewerRotateCw() {
  3246. PDFViewerApplication.rotatePages(90);
  3247. }
  3248. function webViewerRotateCcw() {
  3249. PDFViewerApplication.rotatePages(-90);
  3250. }
  3251. function webViewerOptionalContentConfig(evt) {
  3252. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3253. }
  3254. function webViewerSwitchScrollMode(evt) {
  3255. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3256. }
  3257. function webViewerSwitchSpreadMode(evt) {
  3258. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3259. }
  3260. function webViewerDocumentProperties() {
  3261. PDFViewerApplication.pdfDocumentProperties?.open();
  3262. }
  3263. function webViewerFindFromUrlHash(evt) {
  3264. PDFViewerApplication.eventBus.dispatch("find", {
  3265. source: evt.source,
  3266. type: "",
  3267. query: evt.query,
  3268. caseSensitive: false,
  3269. entireWord: false,
  3270. highlightAll: true,
  3271. findPrevious: false,
  3272. matchDiacritics: true
  3273. });
  3274. }
  3275. function webViewerUpdateFindMatchesCount(_ref11) {
  3276. let {
  3277. matchesCount
  3278. } = _ref11;
  3279. if (PDFViewerApplication.supportsIntegratedFind) {
  3280. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3281. } else {
  3282. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3283. }
  3284. }
  3285. function webViewerUpdateFindControlState(_ref12) {
  3286. let {
  3287. state,
  3288. previous,
  3289. matchesCount,
  3290. rawQuery
  3291. } = _ref12;
  3292. if (PDFViewerApplication.supportsIntegratedFind) {
  3293. PDFViewerApplication.externalServices.updateFindControlState({
  3294. result: state,
  3295. findPrevious: previous,
  3296. matchesCount,
  3297. rawQuery
  3298. });
  3299. } else {
  3300. PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount);
  3301. }
  3302. }
  3303. function webViewerScaleChanging(evt) {
  3304. PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale);
  3305. PDFViewerApplication.pdfViewer.update();
  3306. }
  3307. function webViewerRotationChanging(evt) {
  3308. if (PDFViewerApplication.pdfThumbnailViewer) {
  3309. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3310. }
  3311. PDFViewerApplication.forceRendering();
  3312. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3313. }
  3314. function webViewerPageChanging(_ref13) {
  3315. let {
  3316. pageNumber,
  3317. pageLabel
  3318. } = _ref13;
  3319. PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel);
  3320. PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber);
  3321. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS) {
  3322. PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
  3323. }
  3324. const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3325. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === _ui_utils.RenderingStates.RUNNING);
  3326. }
  3327. function webViewerResolutionChange(evt) {
  3328. PDFViewerApplication.pdfViewer.refresh();
  3329. }
  3330. function webViewerVisibilityChange(evt) {
  3331. if (document.visibilityState === "visible") {
  3332. setZoomDisabledTimeout();
  3333. }
  3334. }
  3335. let zoomDisabledTimeout = null;
  3336. function setZoomDisabledTimeout() {
  3337. if (zoomDisabledTimeout) {
  3338. clearTimeout(zoomDisabledTimeout);
  3339. }
  3340. zoomDisabledTimeout = setTimeout(function () {
  3341. zoomDisabledTimeout = null;
  3342. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3343. }
  3344. function webViewerWheel(evt) {
  3345. const {
  3346. pdfViewer,
  3347. supportedMouseWheelZoomModifierKeys,
  3348. supportsPinchToZoom
  3349. } = PDFViewerApplication;
  3350. if (pdfViewer.isInPresentationMode) {
  3351. return;
  3352. }
  3353. const deltaMode = evt.deltaMode;
  3354. let scaleFactor = Math.exp(-evt.deltaY / 100);
  3355. const isBuiltInMac = false;
  3356. const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  3357. if (isPinchToZoom || evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  3358. evt.preventDefault();
  3359. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3360. return;
  3361. }
  3362. const previousScale = pdfViewer.currentScale;
  3363. if (isPinchToZoom && supportsPinchToZoom) {
  3364. scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
  3365. if (scaleFactor < 1) {
  3366. PDFViewerApplication.zoomOut(null, scaleFactor);
  3367. } else if (scaleFactor > 1) {
  3368. PDFViewerApplication.zoomIn(null, scaleFactor);
  3369. } else {
  3370. return;
  3371. }
  3372. } else {
  3373. const delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3374. let ticks = 0;
  3375. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3376. if (Math.abs(delta) >= 1) {
  3377. ticks = Math.sign(delta);
  3378. } else {
  3379. ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
  3380. }
  3381. } else {
  3382. const PIXELS_PER_LINE_SCALE = 30;
  3383. ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  3384. }
  3385. if (ticks < 0) {
  3386. PDFViewerApplication.zoomOut(-ticks);
  3387. } else if (ticks > 0) {
  3388. PDFViewerApplication.zoomIn(ticks);
  3389. } else {
  3390. return;
  3391. }
  3392. }
  3393. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
  3394. } else {
  3395. setZoomDisabledTimeout();
  3396. }
  3397. }
  3398. function webViewerTouchStart(evt) {
  3399. if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  3400. return;
  3401. }
  3402. evt.preventDefault();
  3403. if (evt.touches.length !== 2) {
  3404. PDFViewerApplication._touchInfo = null;
  3405. return;
  3406. }
  3407. let [touch0, touch1] = evt.touches;
  3408. if (touch0.identifier > touch1.identifier) {
  3409. [touch0, touch1] = [touch1, touch0];
  3410. }
  3411. PDFViewerApplication._touchInfo = {
  3412. touch0X: touch0.pageX,
  3413. touch0Y: touch0.pageY,
  3414. touch1X: touch1.pageX,
  3415. touch1Y: touch1.pageY
  3416. };
  3417. }
  3418. function webViewerTouchMove(evt) {
  3419. if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
  3420. return;
  3421. }
  3422. const {
  3423. pdfViewer,
  3424. _touchInfo,
  3425. supportsPinchToZoom
  3426. } = PDFViewerApplication;
  3427. let [touch0, touch1] = evt.touches;
  3428. if (touch0.identifier > touch1.identifier) {
  3429. [touch0, touch1] = [touch1, touch0];
  3430. }
  3431. const {
  3432. pageX: page0X,
  3433. pageY: page0Y
  3434. } = touch0;
  3435. const {
  3436. pageX: page1X,
  3437. pageY: page1Y
  3438. } = touch1;
  3439. const {
  3440. touch0X: pTouch0X,
  3441. touch0Y: pTouch0Y,
  3442. touch1X: pTouch1X,
  3443. touch1Y: pTouch1Y
  3444. } = _touchInfo;
  3445. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  3446. return;
  3447. }
  3448. _touchInfo.touch0X = page0X;
  3449. _touchInfo.touch0Y = page0Y;
  3450. _touchInfo.touch1X = page1X;
  3451. _touchInfo.touch1Y = page1Y;
  3452. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  3453. const v1X = pTouch1X - page0X;
  3454. const v1Y = pTouch1Y - page0Y;
  3455. const v2X = page1X - page0X;
  3456. const v2Y = page1Y - page0Y;
  3457. const det = v1X * v2Y - v1Y * v2X;
  3458. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3459. return;
  3460. }
  3461. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  3462. const v1X = pTouch0X - page1X;
  3463. const v1Y = pTouch0Y - page1Y;
  3464. const v2X = page0X - page1X;
  3465. const v2Y = page0Y - page1Y;
  3466. const det = v1X * v2Y - v1Y * v2X;
  3467. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3468. return;
  3469. }
  3470. } else {
  3471. const diff0X = page0X - pTouch0X;
  3472. const diff1X = page1X - pTouch1X;
  3473. const diff0Y = page0Y - pTouch0Y;
  3474. const diff1Y = page1Y - pTouch1Y;
  3475. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  3476. if (dotProduct >= 0) {
  3477. return;
  3478. }
  3479. }
  3480. evt.preventDefault();
  3481. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  3482. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  3483. const previousScale = pdfViewer.currentScale;
  3484. if (supportsPinchToZoom) {
  3485. const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
  3486. if (newScaleFactor < 1) {
  3487. PDFViewerApplication.zoomOut(null, newScaleFactor);
  3488. } else if (newScaleFactor > 1) {
  3489. PDFViewerApplication.zoomIn(null, newScaleFactor);
  3490. } else {
  3491. return;
  3492. }
  3493. } else {
  3494. const PIXELS_PER_LINE_SCALE = 30;
  3495. const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  3496. if (ticks < 0) {
  3497. PDFViewerApplication.zoomOut(-ticks);
  3498. } else if (ticks > 0) {
  3499. PDFViewerApplication.zoomIn(ticks);
  3500. } else {
  3501. return;
  3502. }
  3503. }
  3504. PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
  3505. }
  3506. function webViewerTouchEnd(evt) {
  3507. if (!PDFViewerApplication._touchInfo) {
  3508. return;
  3509. }
  3510. evt.preventDefault();
  3511. PDFViewerApplication._touchInfo = null;
  3512. PDFViewerApplication._touchUnusedTicks = 0;
  3513. PDFViewerApplication._touchUnusedFactor = 1;
  3514. }
  3515. function webViewerClick(evt) {
  3516. if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
  3517. return;
  3518. }
  3519. const appConfig = PDFViewerApplication.appConfig;
  3520. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
  3521. PDFViewerApplication.secondaryToolbar.close();
  3522. }
  3523. }
  3524. function webViewerKeyUp(evt) {
  3525. if (evt.key === "Control") {
  3526. PDFViewerApplication._isCtrlKeyDown = false;
  3527. }
  3528. }
  3529. function webViewerKeyDown(evt) {
  3530. PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
  3531. if (PDFViewerApplication.overlayManager.active) {
  3532. return;
  3533. }
  3534. const {
  3535. eventBus,
  3536. pdfViewer
  3537. } = PDFViewerApplication;
  3538. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  3539. let handled = false,
  3540. ensureViewerFocused = false;
  3541. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3542. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3543. switch (evt.keyCode) {
  3544. case 70:
  3545. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3546. PDFViewerApplication.findBar?.open();
  3547. handled = true;
  3548. }
  3549. break;
  3550. case 71:
  3551. if (!PDFViewerApplication.supportsIntegratedFind) {
  3552. const {
  3553. state
  3554. } = PDFViewerApplication.findController;
  3555. if (state) {
  3556. const newState = {
  3557. source: window,
  3558. type: "again",
  3559. findPrevious: cmd === 5 || cmd === 12
  3560. };
  3561. eventBus.dispatch("find", {
  3562. ...state,
  3563. ...newState
  3564. });
  3565. }
  3566. handled = true;
  3567. }
  3568. break;
  3569. case 61:
  3570. case 107:
  3571. case 187:
  3572. case 171:
  3573. PDFViewerApplication.zoomIn();
  3574. handled = true;
  3575. break;
  3576. case 173:
  3577. case 109:
  3578. case 189:
  3579. PDFViewerApplication.zoomOut();
  3580. handled = true;
  3581. break;
  3582. case 48:
  3583. case 96:
  3584. if (!isViewerInPresentationMode) {
  3585. setTimeout(function () {
  3586. PDFViewerApplication.zoomReset();
  3587. });
  3588. handled = false;
  3589. }
  3590. break;
  3591. case 38:
  3592. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3593. PDFViewerApplication.page = 1;
  3594. handled = true;
  3595. ensureViewerFocused = true;
  3596. }
  3597. break;
  3598. case 40:
  3599. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3600. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3601. handled = true;
  3602. ensureViewerFocused = true;
  3603. }
  3604. break;
  3605. }
  3606. }
  3607. if (cmd === 1 || cmd === 8) {
  3608. switch (evt.keyCode) {
  3609. case 83:
  3610. eventBus.dispatch("download", {
  3611. source: window
  3612. });
  3613. handled = true;
  3614. break;
  3615. case 79:
  3616. {
  3617. eventBus.dispatch("openfile", {
  3618. source: window
  3619. });
  3620. handled = true;
  3621. }
  3622. break;
  3623. }
  3624. }
  3625. if (cmd === 3 || cmd === 10) {
  3626. switch (evt.keyCode) {
  3627. case 80:
  3628. PDFViewerApplication.requestPresentationMode();
  3629. handled = true;
  3630. PDFViewerApplication.externalServices.reportTelemetry({
  3631. type: "buttons",
  3632. data: {
  3633. id: "presentationModeKeyboard"
  3634. }
  3635. });
  3636. break;
  3637. case 71:
  3638. if (PDFViewerApplication.appConfig.toolbar) {
  3639. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3640. handled = true;
  3641. }
  3642. break;
  3643. }
  3644. }
  3645. if (handled) {
  3646. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3647. pdfViewer.focus();
  3648. }
  3649. evt.preventDefault();
  3650. return;
  3651. }
  3652. const curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3653. const curElementTagName = curElement?.tagName.toUpperCase();
  3654. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement?.isContentEditable) {
  3655. if (evt.keyCode !== 27) {
  3656. return;
  3657. }
  3658. }
  3659. if (cmd === 0) {
  3660. let turnPage = 0,
  3661. turnOnlyIfPageFit = false;
  3662. switch (evt.keyCode) {
  3663. case 38:
  3664. case 33:
  3665. if (pdfViewer.isVerticalScrollbarEnabled) {
  3666. turnOnlyIfPageFit = true;
  3667. }
  3668. turnPage = -1;
  3669. break;
  3670. case 8:
  3671. if (!isViewerInPresentationMode) {
  3672. turnOnlyIfPageFit = true;
  3673. }
  3674. turnPage = -1;
  3675. break;
  3676. case 37:
  3677. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3678. turnOnlyIfPageFit = true;
  3679. }
  3680. case 75:
  3681. case 80:
  3682. turnPage = -1;
  3683. break;
  3684. case 27:
  3685. if (PDFViewerApplication.secondaryToolbar?.isOpen) {
  3686. PDFViewerApplication.secondaryToolbar.close();
  3687. handled = true;
  3688. }
  3689. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) {
  3690. PDFViewerApplication.findBar.close();
  3691. handled = true;
  3692. }
  3693. break;
  3694. case 40:
  3695. case 34:
  3696. if (pdfViewer.isVerticalScrollbarEnabled) {
  3697. turnOnlyIfPageFit = true;
  3698. }
  3699. turnPage = 1;
  3700. break;
  3701. case 13:
  3702. case 32:
  3703. if (!isViewerInPresentationMode) {
  3704. turnOnlyIfPageFit = true;
  3705. }
  3706. turnPage = 1;
  3707. break;
  3708. case 39:
  3709. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3710. turnOnlyIfPageFit = true;
  3711. }
  3712. case 74:
  3713. case 78:
  3714. turnPage = 1;
  3715. break;
  3716. case 36:
  3717. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3718. PDFViewerApplication.page = 1;
  3719. handled = true;
  3720. ensureViewerFocused = true;
  3721. }
  3722. break;
  3723. case 35:
  3724. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3725. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3726. handled = true;
  3727. ensureViewerFocused = true;
  3728. }
  3729. break;
  3730. case 83:
  3731. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils.CursorTool.SELECT);
  3732. break;
  3733. case 72:
  3734. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils.CursorTool.HAND);
  3735. break;
  3736. case 82:
  3737. PDFViewerApplication.rotatePages(90);
  3738. break;
  3739. case 115:
  3740. PDFViewerApplication.pdfSidebar?.toggle();
  3741. break;
  3742. }
  3743. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  3744. if (turnPage > 0) {
  3745. pdfViewer.nextPage();
  3746. } else {
  3747. pdfViewer.previousPage();
  3748. }
  3749. handled = true;
  3750. }
  3751. }
  3752. if (cmd === 4) {
  3753. switch (evt.keyCode) {
  3754. case 13:
  3755. case 32:
  3756. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  3757. break;
  3758. }
  3759. pdfViewer.previousPage();
  3760. handled = true;
  3761. break;
  3762. case 82:
  3763. PDFViewerApplication.rotatePages(-90);
  3764. break;
  3765. }
  3766. }
  3767. if (!handled && !isViewerInPresentationMode) {
  3768. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3769. ensureViewerFocused = true;
  3770. }
  3771. }
  3772. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3773. pdfViewer.focus();
  3774. }
  3775. if (handled) {
  3776. evt.preventDefault();
  3777. }
  3778. }
  3779. function beforeUnload(evt) {
  3780. evt.preventDefault();
  3781. evt.returnValue = "";
  3782. return false;
  3783. }
  3784. function webViewerAnnotationEditorStatesChanged(data) {
  3785. PDFViewerApplication.externalServices.updateEditorStates(data);
  3786. }
  3787. const PDFPrintServiceFactory = {
  3788. instance: {
  3789. supportsPrinting: false,
  3790. createPrintService() {
  3791. throw new Error("Not implemented: createPrintService");
  3792. }
  3793. }
  3794. };
  3795. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3796. /***/ }),
  3797. /* 76 */
  3798. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  3799. var $ = __webpack_require__(3);
  3800. var global = __webpack_require__(4);
  3801. var apply = __webpack_require__(77);
  3802. var wrapErrorConstructorWithCause = __webpack_require__(78);
  3803. var WEB_ASSEMBLY = 'WebAssembly';
  3804. var WebAssembly = global[WEB_ASSEMBLY];
  3805. var FORCED = Error('e', { cause: 7 }).cause !== 7;
  3806. var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  3807. var O = {};
  3808. O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);
  3809. $({
  3810. global: true,
  3811. constructor: true,
  3812. arity: 1,
  3813. forced: FORCED
  3814. }, O);
  3815. };
  3816. var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  3817. if (WebAssembly && WebAssembly[ERROR_NAME]) {
  3818. var O = {};
  3819. O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);
  3820. $({
  3821. target: WEB_ASSEMBLY,
  3822. stat: true,
  3823. constructor: true,
  3824. arity: 1,
  3825. forced: FORCED
  3826. }, O);
  3827. }
  3828. };
  3829. exportGlobalErrorCauseWrapper('Error', function (init) {
  3830. return function Error(message) {
  3831. return apply(init, this, arguments);
  3832. };
  3833. });
  3834. exportGlobalErrorCauseWrapper('EvalError', function (init) {
  3835. return function EvalError(message) {
  3836. return apply(init, this, arguments);
  3837. };
  3838. });
  3839. exportGlobalErrorCauseWrapper('RangeError', function (init) {
  3840. return function RangeError(message) {
  3841. return apply(init, this, arguments);
  3842. };
  3843. });
  3844. exportGlobalErrorCauseWrapper('ReferenceError', function (init) {
  3845. return function ReferenceError(message) {
  3846. return apply(init, this, arguments);
  3847. };
  3848. });
  3849. exportGlobalErrorCauseWrapper('SyntaxError', function (init) {
  3850. return function SyntaxError(message) {
  3851. return apply(init, this, arguments);
  3852. };
  3853. });
  3854. exportGlobalErrorCauseWrapper('TypeError', function (init) {
  3855. return function TypeError(message) {
  3856. return apply(init, this, arguments);
  3857. };
  3858. });
  3859. exportGlobalErrorCauseWrapper('URIError', function (init) {
  3860. return function URIError(message) {
  3861. return apply(init, this, arguments);
  3862. };
  3863. });
  3864. exportWebAssemblyErrorCauseWrapper('CompileError', function (init) {
  3865. return function CompileError(message) {
  3866. return apply(init, this, arguments);
  3867. };
  3868. });
  3869. exportWebAssemblyErrorCauseWrapper('LinkError', function (init) {
  3870. return function LinkError(message) {
  3871. return apply(init, this, arguments);
  3872. };
  3873. });
  3874. exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
  3875. return function RuntimeError(message) {
  3876. return apply(init, this, arguments);
  3877. };
  3878. });
  3879. /***/ }),
  3880. /* 77 */
  3881. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3882. var NATIVE_BIND = __webpack_require__(9);
  3883. var FunctionPrototype = Function.prototype;
  3884. var apply = FunctionPrototype.apply;
  3885. var call = FunctionPrototype.call;
  3886. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  3887. return call.apply(apply, arguments);
  3888. });
  3889. /***/ }),
  3890. /* 78 */
  3891. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3892. var getBuiltIn = __webpack_require__(24);
  3893. var hasOwn = __webpack_require__(39);
  3894. var createNonEnumerableProperty = __webpack_require__(44);
  3895. var isPrototypeOf = __webpack_require__(25);
  3896. var setPrototypeOf = __webpack_require__(79);
  3897. var copyConstructorProperties = __webpack_require__(56);
  3898. var proxyAccessor = __webpack_require__(82);
  3899. var inheritIfRequired = __webpack_require__(83);
  3900. var normalizeStringArgument = __webpack_require__(84);
  3901. var installErrorCause = __webpack_require__(85);
  3902. var installErrorStack = __webpack_require__(86);
  3903. var DESCRIPTORS = __webpack_require__(6);
  3904. var IS_PURE = __webpack_require__(36);
  3905. module.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) {
  3906. var STACK_TRACE_LIMIT = 'stackTraceLimit';
  3907. var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1;
  3908. var path = FULL_NAME.split('.');
  3909. var ERROR_NAME = path[path.length - 1];
  3910. var OriginalError = getBuiltIn.apply(null, path);
  3911. if (!OriginalError)
  3912. return;
  3913. var OriginalErrorPrototype = OriginalError.prototype;
  3914. if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause'))
  3915. delete OriginalErrorPrototype.cause;
  3916. if (!FORCED)
  3917. return OriginalError;
  3918. var BaseError = getBuiltIn('Error');
  3919. var WrappedError = wrapper(function (a, b) {
  3920. var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined);
  3921. var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError();
  3922. if (message !== undefined)
  3923. createNonEnumerableProperty(result, 'message', message);
  3924. installErrorStack(result, WrappedError, result.stack, 2);
  3925. if (this && isPrototypeOf(OriginalErrorPrototype, this))
  3926. inheritIfRequired(result, this, WrappedError);
  3927. if (arguments.length > OPTIONS_POSITION)
  3928. installErrorCause(result, arguments[OPTIONS_POSITION]);
  3929. return result;
  3930. });
  3931. WrappedError.prototype = OriginalErrorPrototype;
  3932. if (ERROR_NAME !== 'Error') {
  3933. if (setPrototypeOf)
  3934. setPrototypeOf(WrappedError, BaseError);
  3935. else
  3936. copyConstructorProperties(WrappedError, BaseError, { name: true });
  3937. } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) {
  3938. proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT);
  3939. proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace');
  3940. }
  3941. copyConstructorProperties(WrappedError, OriginalError);
  3942. if (!IS_PURE)
  3943. try {
  3944. if (OriginalErrorPrototype.name !== ERROR_NAME) {
  3945. createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME);
  3946. }
  3947. OriginalErrorPrototype.constructor = WrappedError;
  3948. } catch (error) {
  3949. }
  3950. return WrappedError;
  3951. };
  3952. /***/ }),
  3953. /* 79 */
  3954. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3955. var uncurryThisAccessor = __webpack_require__(80);
  3956. var anObject = __webpack_require__(47);
  3957. var aPossiblePrototype = __webpack_require__(81);
  3958. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  3959. var CORRECT_SETTER = false;
  3960. var test = {};
  3961. var setter;
  3962. try {
  3963. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  3964. setter(test, []);
  3965. CORRECT_SETTER = test instanceof Array;
  3966. } catch (error) {
  3967. }
  3968. return function setPrototypeOf(O, proto) {
  3969. anObject(O);
  3970. aPossiblePrototype(proto);
  3971. if (CORRECT_SETTER)
  3972. setter(O, proto);
  3973. else
  3974. O.__proto__ = proto;
  3975. return O;
  3976. };
  3977. }()) : undefined);
  3978. /***/ }),
  3979. /* 80 */
  3980. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3981. var uncurryThis = __webpack_require__(14);
  3982. var aCallable = __webpack_require__(31);
  3983. module.exports = function (object, key, method) {
  3984. try {
  3985. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  3986. } catch (error) {
  3987. }
  3988. };
  3989. /***/ }),
  3990. /* 81 */
  3991. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3992. var isCallable = __webpack_require__(21);
  3993. var $String = String;
  3994. var $TypeError = TypeError;
  3995. module.exports = function (argument) {
  3996. if (typeof argument == 'object' || isCallable(argument))
  3997. return argument;
  3998. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  3999. };
  4000. /***/ }),
  4001. /* 82 */
  4002. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4003. var defineProperty = (__webpack_require__(45).f);
  4004. module.exports = function (Target, Source, key) {
  4005. key in Target || defineProperty(Target, key, {
  4006. configurable: true,
  4007. get: function () {
  4008. return Source[key];
  4009. },
  4010. set: function (it) {
  4011. Source[key] = it;
  4012. }
  4013. });
  4014. };
  4015. /***/ }),
  4016. /* 83 */
  4017. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4018. var isCallable = __webpack_require__(21);
  4019. var isObject = __webpack_require__(20);
  4020. var setPrototypeOf = __webpack_require__(79);
  4021. module.exports = function ($this, dummy, Wrapper) {
  4022. var NewTarget, NewTargetPrototype;
  4023. if (setPrototypeOf && isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  4024. setPrototypeOf($this, NewTargetPrototype);
  4025. return $this;
  4026. };
  4027. /***/ }),
  4028. /* 84 */
  4029. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4030. var toString = __webpack_require__(70);
  4031. module.exports = function (argument, $default) {
  4032. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  4033. };
  4034. /***/ }),
  4035. /* 85 */
  4036. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4037. var isObject = __webpack_require__(20);
  4038. var createNonEnumerableProperty = __webpack_require__(44);
  4039. module.exports = function (O, options) {
  4040. if (isObject(options) && 'cause' in options) {
  4041. createNonEnumerableProperty(O, 'cause', options.cause);
  4042. }
  4043. };
  4044. /***/ }),
  4045. /* 86 */
  4046. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4047. var createNonEnumerableProperty = __webpack_require__(44);
  4048. var clearErrorStack = __webpack_require__(87);
  4049. var ERROR_STACK_INSTALLABLE = __webpack_require__(88);
  4050. var captureStackTrace = Error.captureStackTrace;
  4051. module.exports = function (error, C, stack, dropEntries) {
  4052. if (ERROR_STACK_INSTALLABLE) {
  4053. if (captureStackTrace)
  4054. captureStackTrace(error, C);
  4055. else
  4056. createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  4057. }
  4058. };
  4059. /***/ }),
  4060. /* 87 */
  4061. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4062. var uncurryThis = __webpack_require__(14);
  4063. var $Error = Error;
  4064. var replace = uncurryThis(''.replace);
  4065. var TEST = function (arg) {
  4066. return String($Error(arg).stack);
  4067. }('zxcasd');
  4068. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  4069. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  4070. module.exports = function (stack, dropEntries) {
  4071. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  4072. while (dropEntries--)
  4073. stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  4074. }
  4075. return stack;
  4076. };
  4077. /***/ }),
  4078. /* 88 */
  4079. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4080. var fails = __webpack_require__(7);
  4081. var createPropertyDescriptor = __webpack_require__(11);
  4082. module.exports = !fails(function () {
  4083. var error = Error('a');
  4084. if (!('stack' in error))
  4085. return true;
  4086. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  4087. return error.stack !== 7;
  4088. });
  4089. /***/ }),
  4090. /* 89 */
  4091. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4092. var $ = __webpack_require__(3);
  4093. var toObject = __webpack_require__(40);
  4094. var lengthOfArrayLike = __webpack_require__(64);
  4095. var setArrayLength = __webpack_require__(90);
  4096. var doesNotExceedSafeInteger = __webpack_require__(91);
  4097. var fails = __webpack_require__(7);
  4098. var INCORRECT_TO_LENGTH = fails(function () {
  4099. return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
  4100. });
  4101. var properErrorOnNonWritableLength = function () {
  4102. try {
  4103. Object.defineProperty([], 'length', { writable: false }).push();
  4104. } catch (error) {
  4105. return error instanceof TypeError;
  4106. }
  4107. };
  4108. var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
  4109. $({
  4110. target: 'Array',
  4111. proto: true,
  4112. arity: 1,
  4113. forced: FORCED
  4114. }, {
  4115. push: function push(item) {
  4116. var O = toObject(this);
  4117. var len = lengthOfArrayLike(O);
  4118. var argCount = arguments.length;
  4119. doesNotExceedSafeInteger(len + argCount);
  4120. for (var i = 0; i < argCount; i++) {
  4121. O[len] = arguments[i];
  4122. len++;
  4123. }
  4124. setArrayLength(O, len);
  4125. return len;
  4126. }
  4127. });
  4128. /***/ }),
  4129. /* 90 */
  4130. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4131. var DESCRIPTORS = __webpack_require__(6);
  4132. var isArray = __webpack_require__(69);
  4133. var $TypeError = TypeError;
  4134. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  4135. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !(function () {
  4136. if (this !== undefined)
  4137. return true;
  4138. try {
  4139. Object.defineProperty([], 'length', { writable: false }).length = 1;
  4140. } catch (error) {
  4141. return error instanceof TypeError;
  4142. }
  4143. }());
  4144. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  4145. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  4146. throw $TypeError('Cannot set read only .length');
  4147. }
  4148. return O.length = length;
  4149. } : function (O, length) {
  4150. return O.length = length;
  4151. };
  4152. /***/ }),
  4153. /* 91 */
  4154. /***/ ((module) => {
  4155. var $TypeError = TypeError;
  4156. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  4157. module.exports = function (it) {
  4158. if (it > MAX_SAFE_INTEGER)
  4159. throw $TypeError('Maximum allowed index exceeded');
  4160. return it;
  4161. };
  4162. /***/ }),
  4163. /* 92 */
  4164. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4165. var defineBuiltIn = __webpack_require__(48);
  4166. var uncurryThis = __webpack_require__(14);
  4167. var toString = __webpack_require__(70);
  4168. var validateArgumentsLength = __webpack_require__(93);
  4169. var $URLSearchParams = URLSearchParams;
  4170. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4171. var append = uncurryThis(URLSearchParamsPrototype.append);
  4172. var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
  4173. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4174. var push = uncurryThis([].push);
  4175. var params = new $URLSearchParams('a=1&a=2&b=3');
  4176. params['delete']('a', 1);
  4177. params['delete']('b', undefined);
  4178. if (params + '' !== 'a=2') {
  4179. defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name) {
  4180. var length = arguments.length;
  4181. var $value = length < 2 ? undefined : arguments[1];
  4182. if (length && $value === undefined)
  4183. return $delete(this, name);
  4184. var entries = [];
  4185. forEach(this, function (v, k) {
  4186. push(entries, {
  4187. key: k,
  4188. value: v
  4189. });
  4190. });
  4191. validateArgumentsLength(length, 1);
  4192. var key = toString(name);
  4193. var value = toString($value);
  4194. var index = 0;
  4195. var dindex = 0;
  4196. var found = false;
  4197. var entriesLength = entries.length;
  4198. var entry;
  4199. while (index < entriesLength) {
  4200. entry = entries[index++];
  4201. if (found || entry.key === key) {
  4202. found = true;
  4203. $delete(this, entry.key);
  4204. } else
  4205. dindex++;
  4206. }
  4207. while (dindex < entriesLength) {
  4208. entry = entries[dindex++];
  4209. if (!(entry.key === key && entry.value === value))
  4210. append(this, entry.key, entry.value);
  4211. }
  4212. }, {
  4213. enumerable: true,
  4214. unsafe: true
  4215. });
  4216. }
  4217. /***/ }),
  4218. /* 93 */
  4219. /***/ ((module) => {
  4220. var $TypeError = TypeError;
  4221. module.exports = function (passed, required) {
  4222. if (passed < required)
  4223. throw $TypeError('Not enough arguments');
  4224. return passed;
  4225. };
  4226. /***/ }),
  4227. /* 94 */
  4228. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4229. var defineBuiltIn = __webpack_require__(48);
  4230. var uncurryThis = __webpack_require__(14);
  4231. var toString = __webpack_require__(70);
  4232. var validateArgumentsLength = __webpack_require__(93);
  4233. var $URLSearchParams = URLSearchParams;
  4234. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4235. var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
  4236. var $has = uncurryThis(URLSearchParamsPrototype.has);
  4237. var params = new $URLSearchParams('a=1');
  4238. if (params.has('a', 2) || !params.has('a', undefined)) {
  4239. defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name) {
  4240. var length = arguments.length;
  4241. var $value = length < 2 ? undefined : arguments[1];
  4242. if (length && $value === undefined)
  4243. return $has(this, name);
  4244. var values = getAll(this, name);
  4245. validateArgumentsLength(length, 1);
  4246. var value = toString($value);
  4247. var index = 0;
  4248. while (index < values.length) {
  4249. if (values[index++] === value)
  4250. return true;
  4251. }
  4252. return false;
  4253. }, {
  4254. enumerable: true,
  4255. unsafe: true
  4256. });
  4257. }
  4258. /***/ }),
  4259. /* 95 */
  4260. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4261. var DESCRIPTORS = __webpack_require__(6);
  4262. var uncurryThis = __webpack_require__(14);
  4263. var defineBuiltInAccessor = __webpack_require__(96);
  4264. var URLSearchParamsPrototype = URLSearchParams.prototype;
  4265. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4266. if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
  4267. defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
  4268. get: function size() {
  4269. var count = 0;
  4270. forEach(this, function () {
  4271. count++;
  4272. });
  4273. return count;
  4274. },
  4275. configurable: true,
  4276. enumerable: true
  4277. });
  4278. }
  4279. /***/ }),
  4280. /* 96 */
  4281. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4282. var makeBuiltIn = __webpack_require__(49);
  4283. var defineProperty = __webpack_require__(45);
  4284. module.exports = function (target, name, descriptor) {
  4285. if (descriptor.get)
  4286. makeBuiltIn(descriptor.get, name, { getter: true });
  4287. if (descriptor.set)
  4288. makeBuiltIn(descriptor.set, name, { setter: true });
  4289. return defineProperty.f(target, name, descriptor);
  4290. };
  4291. /***/ }),
  4292. /* 97 */
  4293. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4294. Object.defineProperty(exports, "__esModule", ({
  4295. value: true
  4296. }));
  4297. exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RenderingStates = exports.ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.CursorTool = exports.AutoPrintRegExp = void 0;
  4298. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  4299. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  4300. exports.approximateFraction = approximateFraction;
  4301. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4302. exports.binarySearchFirstItem = binarySearchFirstItem;
  4303. exports.docStyle = void 0;
  4304. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4305. exports.getPageSizeInches = getPageSizeInches;
  4306. exports.getVisibleElements = getVisibleElements;
  4307. exports.isPortraitOrientation = isPortraitOrientation;
  4308. exports.isValidRotation = isValidRotation;
  4309. exports.isValidScrollMode = isValidScrollMode;
  4310. exports.isValidSpreadMode = isValidSpreadMode;
  4311. exports.noContextMenuHandler = noContextMenuHandler;
  4312. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4313. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4314. exports.parseQueryString = parseQueryString;
  4315. exports.removeNullCharacters = removeNullCharacters;
  4316. exports.roundToDivide = roundToDivide;
  4317. exports.scrollIntoView = scrollIntoView;
  4318. exports.toggleCheckedBtn = toggleCheckedBtn;
  4319. exports.toggleExpandedBtn = toggleExpandedBtn;
  4320. exports.watchScroll = watchScroll;
  4321. __webpack_require__(92);
  4322. __webpack_require__(94);
  4323. __webpack_require__(95);
  4324. __webpack_require__(98);
  4325. __webpack_require__(109);
  4326. __webpack_require__(111);
  4327. __webpack_require__(114);
  4328. __webpack_require__(116);
  4329. __webpack_require__(118);
  4330. __webpack_require__(120);
  4331. __webpack_require__(89);
  4332. const DEFAULT_SCALE_VALUE = "auto";
  4333. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4334. const DEFAULT_SCALE = 1.0;
  4335. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4336. const DEFAULT_SCALE_DELTA = 1.1;
  4337. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  4338. const MIN_SCALE = 0.1;
  4339. exports.MIN_SCALE = MIN_SCALE;
  4340. const MAX_SCALE = 10.0;
  4341. exports.MAX_SCALE = MAX_SCALE;
  4342. const UNKNOWN_SCALE = 0;
  4343. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4344. const MAX_AUTO_SCALE = 1.25;
  4345. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4346. const SCROLLBAR_PADDING = 40;
  4347. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4348. const VERTICAL_PADDING = 5;
  4349. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4350. const RenderingStates = {
  4351. INITIAL: 0,
  4352. RUNNING: 1,
  4353. PAUSED: 2,
  4354. FINISHED: 3
  4355. };
  4356. exports.RenderingStates = RenderingStates;
  4357. const PresentationModeState = {
  4358. UNKNOWN: 0,
  4359. NORMAL: 1,
  4360. CHANGING: 2,
  4361. FULLSCREEN: 3
  4362. };
  4363. exports.PresentationModeState = PresentationModeState;
  4364. const SidebarView = {
  4365. UNKNOWN: -1,
  4366. NONE: 0,
  4367. THUMBS: 1,
  4368. OUTLINE: 2,
  4369. ATTACHMENTS: 3,
  4370. LAYERS: 4
  4371. };
  4372. exports.SidebarView = SidebarView;
  4373. const TextLayerMode = {
  4374. DISABLE: 0,
  4375. ENABLE: 1,
  4376. ENABLE_PERMISSIONS: 2
  4377. };
  4378. exports.TextLayerMode = TextLayerMode;
  4379. const ScrollMode = {
  4380. UNKNOWN: -1,
  4381. VERTICAL: 0,
  4382. HORIZONTAL: 1,
  4383. WRAPPED: 2,
  4384. PAGE: 3
  4385. };
  4386. exports.ScrollMode = ScrollMode;
  4387. const SpreadMode = {
  4388. UNKNOWN: -1,
  4389. NONE: 0,
  4390. ODD: 1,
  4391. EVEN: 2
  4392. };
  4393. exports.SpreadMode = SpreadMode;
  4394. const CursorTool = {
  4395. SELECT: 0,
  4396. HAND: 1,
  4397. ZOOM: 2
  4398. };
  4399. exports.CursorTool = CursorTool;
  4400. const AutoPrintRegExp = /\bprint\s*\(/;
  4401. exports.AutoPrintRegExp = AutoPrintRegExp;
  4402. class OutputScale {
  4403. constructor() {
  4404. const pixelRatio = window.devicePixelRatio || 1;
  4405. this.sx = pixelRatio;
  4406. this.sy = pixelRatio;
  4407. }
  4408. get scaled() {
  4409. return this.sx !== 1 || this.sy !== 1;
  4410. }
  4411. }
  4412. exports.OutputScale = OutputScale;
  4413. function scrollIntoView(element, spot) {
  4414. let scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4415. let parent = element.offsetParent;
  4416. if (!parent) {
  4417. console.error("offsetParent is not set -- cannot scroll");
  4418. return;
  4419. }
  4420. let offsetY = element.offsetTop + element.clientTop;
  4421. let offsetX = element.offsetLeft + element.clientLeft;
  4422. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  4423. offsetY += parent.offsetTop;
  4424. offsetX += parent.offsetLeft;
  4425. parent = parent.offsetParent;
  4426. if (!parent) {
  4427. return;
  4428. }
  4429. }
  4430. if (spot) {
  4431. if (spot.top !== undefined) {
  4432. offsetY += spot.top;
  4433. }
  4434. if (spot.left !== undefined) {
  4435. offsetX += spot.left;
  4436. parent.scrollLeft = offsetX;
  4437. }
  4438. }
  4439. parent.scrollTop = offsetY;
  4440. }
  4441. function watchScroll(viewAreaElement, callback) {
  4442. const debounceScroll = function (evt) {
  4443. if (rAF) {
  4444. return;
  4445. }
  4446. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4447. rAF = null;
  4448. const currentX = viewAreaElement.scrollLeft;
  4449. const lastX = state.lastX;
  4450. if (currentX !== lastX) {
  4451. state.right = currentX > lastX;
  4452. }
  4453. state.lastX = currentX;
  4454. const currentY = viewAreaElement.scrollTop;
  4455. const lastY = state.lastY;
  4456. if (currentY !== lastY) {
  4457. state.down = currentY > lastY;
  4458. }
  4459. state.lastY = currentY;
  4460. callback(state);
  4461. });
  4462. };
  4463. const state = {
  4464. right: true,
  4465. down: true,
  4466. lastX: viewAreaElement.scrollLeft,
  4467. lastY: viewAreaElement.scrollTop,
  4468. _eventHandler: debounceScroll
  4469. };
  4470. let rAF = null;
  4471. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4472. return state;
  4473. }
  4474. function parseQueryString(query) {
  4475. const params = new Map();
  4476. for (const [key, value] of new URLSearchParams(query)) {
  4477. params.set(key.toLowerCase(), value);
  4478. }
  4479. return params;
  4480. }
  4481. const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  4482. function removeNullCharacters(str) {
  4483. let replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4484. if (typeof str !== "string") {
  4485. console.error(`The argument must be a string.`);
  4486. return str;
  4487. }
  4488. if (replaceInvisible) {
  4489. str = str.replaceAll(InvisibleCharactersRegExp, " ");
  4490. }
  4491. return str.replaceAll("\x00", "");
  4492. }
  4493. function binarySearchFirstItem(items, condition) {
  4494. let start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  4495. let minIndex = start;
  4496. let maxIndex = items.length - 1;
  4497. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4498. return items.length;
  4499. }
  4500. if (condition(items[minIndex])) {
  4501. return minIndex;
  4502. }
  4503. while (minIndex < maxIndex) {
  4504. const currentIndex = minIndex + maxIndex >> 1;
  4505. const currentItem = items[currentIndex];
  4506. if (condition(currentItem)) {
  4507. maxIndex = currentIndex;
  4508. } else {
  4509. minIndex = currentIndex + 1;
  4510. }
  4511. }
  4512. return minIndex;
  4513. }
  4514. function approximateFraction(x) {
  4515. if (Math.floor(x) === x) {
  4516. return [x, 1];
  4517. }
  4518. const xinv = 1 / x;
  4519. const limit = 8;
  4520. if (xinv > limit) {
  4521. return [1, limit];
  4522. } else if (Math.floor(xinv) === xinv) {
  4523. return [1, xinv];
  4524. }
  4525. const x_ = x > 1 ? xinv : x;
  4526. let a = 0,
  4527. b = 1,
  4528. c = 1,
  4529. d = 1;
  4530. while (true) {
  4531. const p = a + c,
  4532. q = b + d;
  4533. if (q > limit) {
  4534. break;
  4535. }
  4536. if (x_ <= p / q) {
  4537. c = p;
  4538. d = q;
  4539. } else {
  4540. a = p;
  4541. b = q;
  4542. }
  4543. }
  4544. let result;
  4545. if (x_ - a / b < c / d - x_) {
  4546. result = x_ === x ? [a, b] : [b, a];
  4547. } else {
  4548. result = x_ === x ? [c, d] : [d, c];
  4549. }
  4550. return result;
  4551. }
  4552. function roundToDivide(x, div) {
  4553. const r = x % div;
  4554. return r === 0 ? x : Math.round(x - r + div);
  4555. }
  4556. function getPageSizeInches(_ref) {
  4557. let {
  4558. view,
  4559. userUnit,
  4560. rotate
  4561. } = _ref;
  4562. const [x1, y1, x2, y2] = view;
  4563. const changeOrientation = rotate % 180 !== 0;
  4564. const width = (x2 - x1) / 72 * userUnit;
  4565. const height = (y2 - y1) / 72 * userUnit;
  4566. return {
  4567. width: changeOrientation ? height : width,
  4568. height: changeOrientation ? width : height
  4569. };
  4570. }
  4571. function backtrackBeforeAllVisibleElements(index, views, top) {
  4572. if (index < 2) {
  4573. return index;
  4574. }
  4575. let elt = views[index].div;
  4576. let pageTop = elt.offsetTop + elt.clientTop;
  4577. if (pageTop >= top) {
  4578. elt = views[index - 1].div;
  4579. pageTop = elt.offsetTop + elt.clientTop;
  4580. }
  4581. for (let i = index - 2; i >= 0; --i) {
  4582. elt = views[i].div;
  4583. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  4584. break;
  4585. }
  4586. index = i;
  4587. }
  4588. return index;
  4589. }
  4590. function getVisibleElements(_ref2) {
  4591. let {
  4592. scrollEl,
  4593. views,
  4594. sortByVisibility = false,
  4595. horizontal = false,
  4596. rtl = false
  4597. } = _ref2;
  4598. const top = scrollEl.scrollTop,
  4599. bottom = top + scrollEl.clientHeight;
  4600. const left = scrollEl.scrollLeft,
  4601. right = left + scrollEl.clientWidth;
  4602. function isElementBottomAfterViewTop(view) {
  4603. const element = view.div;
  4604. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  4605. return elementBottom > top;
  4606. }
  4607. function isElementNextAfterViewHorizontally(view) {
  4608. const element = view.div;
  4609. const elementLeft = element.offsetLeft + element.clientLeft;
  4610. const elementRight = elementLeft + element.clientWidth;
  4611. return rtl ? elementLeft < right : elementRight > left;
  4612. }
  4613. const visible = [],
  4614. ids = new Set(),
  4615. numViews = views.length;
  4616. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  4617. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  4618. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  4619. }
  4620. let lastEdge = horizontal ? right : -1;
  4621. for (let i = firstVisibleElementInd; i < numViews; i++) {
  4622. const view = views[i],
  4623. element = view.div;
  4624. const currentWidth = element.offsetLeft + element.clientLeft;
  4625. const currentHeight = element.offsetTop + element.clientTop;
  4626. const viewWidth = element.clientWidth,
  4627. viewHeight = element.clientHeight;
  4628. const viewRight = currentWidth + viewWidth;
  4629. const viewBottom = currentHeight + viewHeight;
  4630. if (lastEdge === -1) {
  4631. if (viewBottom >= bottom) {
  4632. lastEdge = viewBottom;
  4633. }
  4634. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  4635. break;
  4636. }
  4637. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  4638. continue;
  4639. }
  4640. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  4641. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  4642. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  4643. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  4644. const percent = fractionHeight * fractionWidth * 100 | 0;
  4645. visible.push({
  4646. id: view.id,
  4647. x: currentWidth,
  4648. y: currentHeight,
  4649. view,
  4650. percent,
  4651. widthPercent: fractionWidth * 100 | 0
  4652. });
  4653. ids.add(view.id);
  4654. }
  4655. const first = visible[0],
  4656. last = visible.at(-1);
  4657. if (sortByVisibility) {
  4658. visible.sort(function (a, b) {
  4659. const pc = a.percent - b.percent;
  4660. if (Math.abs(pc) > 0.001) {
  4661. return -pc;
  4662. }
  4663. return a.id - b.id;
  4664. });
  4665. }
  4666. return {
  4667. first,
  4668. last,
  4669. views: visible,
  4670. ids
  4671. };
  4672. }
  4673. function noContextMenuHandler(evt) {
  4674. evt.preventDefault();
  4675. }
  4676. function normalizeWheelEventDirection(evt) {
  4677. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  4678. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  4679. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  4680. delta = -delta;
  4681. }
  4682. return delta;
  4683. }
  4684. function normalizeWheelEventDelta(evt) {
  4685. const deltaMode = evt.deltaMode;
  4686. let delta = normalizeWheelEventDirection(evt);
  4687. const MOUSE_PIXELS_PER_LINE = 30;
  4688. const MOUSE_LINES_PER_PAGE = 30;
  4689. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  4690. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  4691. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  4692. delta /= MOUSE_LINES_PER_PAGE;
  4693. }
  4694. return delta;
  4695. }
  4696. function isValidRotation(angle) {
  4697. return Number.isInteger(angle) && angle % 90 === 0;
  4698. }
  4699. function isValidScrollMode(mode) {
  4700. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  4701. }
  4702. function isValidSpreadMode(mode) {
  4703. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  4704. }
  4705. function isPortraitOrientation(size) {
  4706. return size.width <= size.height;
  4707. }
  4708. const animationStarted = new Promise(function (resolve) {
  4709. window.requestAnimationFrame(resolve);
  4710. });
  4711. exports.animationStarted = animationStarted;
  4712. const docStyle = document.documentElement.style;
  4713. exports.docStyle = docStyle;
  4714. function clamp(v, min, max) {
  4715. return Math.min(Math.max(v, min), max);
  4716. }
  4717. class ProgressBar {
  4718. #classList = null;
  4719. #disableAutoFetchTimeout = null;
  4720. #percent = 0;
  4721. #style = null;
  4722. #visible = true;
  4723. constructor(bar) {
  4724. this.#classList = bar.classList;
  4725. this.#style = bar.style;
  4726. }
  4727. get percent() {
  4728. return this.#percent;
  4729. }
  4730. set percent(val) {
  4731. this.#percent = clamp(val, 0, 100);
  4732. if (isNaN(val)) {
  4733. this.#classList.add("indeterminate");
  4734. return;
  4735. }
  4736. this.#classList.remove("indeterminate");
  4737. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  4738. }
  4739. setWidth(viewer) {
  4740. if (!viewer) {
  4741. return;
  4742. }
  4743. const container = viewer.parentNode;
  4744. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4745. if (scrollbarWidth > 0) {
  4746. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  4747. }
  4748. }
  4749. setDisableAutoFetch() {
  4750. let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 5000;
  4751. if (isNaN(this.#percent)) {
  4752. return;
  4753. }
  4754. if (this.#disableAutoFetchTimeout) {
  4755. clearTimeout(this.#disableAutoFetchTimeout);
  4756. }
  4757. this.show();
  4758. this.#disableAutoFetchTimeout = setTimeout(() => {
  4759. this.#disableAutoFetchTimeout = null;
  4760. this.hide();
  4761. }, delay);
  4762. }
  4763. hide() {
  4764. if (!this.#visible) {
  4765. return;
  4766. }
  4767. this.#visible = false;
  4768. this.#classList.add("hidden");
  4769. }
  4770. show() {
  4771. if (this.#visible) {
  4772. return;
  4773. }
  4774. this.#visible = true;
  4775. this.#classList.remove("hidden");
  4776. }
  4777. }
  4778. exports.ProgressBar = ProgressBar;
  4779. function getActiveOrFocusedElement() {
  4780. let curRoot = document;
  4781. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4782. while (curActiveOrFocused?.shadowRoot) {
  4783. curRoot = curActiveOrFocused.shadowRoot;
  4784. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4785. }
  4786. return curActiveOrFocused;
  4787. }
  4788. function apiPageLayoutToViewerModes(layout) {
  4789. let scrollMode = ScrollMode.VERTICAL,
  4790. spreadMode = SpreadMode.NONE;
  4791. switch (layout) {
  4792. case "SinglePage":
  4793. scrollMode = ScrollMode.PAGE;
  4794. break;
  4795. case "OneColumn":
  4796. break;
  4797. case "TwoPageLeft":
  4798. scrollMode = ScrollMode.PAGE;
  4799. case "TwoColumnLeft":
  4800. spreadMode = SpreadMode.ODD;
  4801. break;
  4802. case "TwoPageRight":
  4803. scrollMode = ScrollMode.PAGE;
  4804. case "TwoColumnRight":
  4805. spreadMode = SpreadMode.EVEN;
  4806. break;
  4807. }
  4808. return {
  4809. scrollMode,
  4810. spreadMode
  4811. };
  4812. }
  4813. function apiPageModeToSidebarView(mode) {
  4814. switch (mode) {
  4815. case "UseNone":
  4816. return SidebarView.NONE;
  4817. case "UseThumbs":
  4818. return SidebarView.THUMBS;
  4819. case "UseOutlines":
  4820. return SidebarView.OUTLINE;
  4821. case "UseAttachments":
  4822. return SidebarView.ATTACHMENTS;
  4823. case "UseOC":
  4824. return SidebarView.LAYERS;
  4825. }
  4826. return SidebarView.NONE;
  4827. }
  4828. function toggleCheckedBtn(button, toggle) {
  4829. let view = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4830. button.classList.toggle("toggled", toggle);
  4831. button.setAttribute("aria-checked", toggle);
  4832. view?.classList.toggle("hidden", !toggle);
  4833. }
  4834. function toggleExpandedBtn(button, toggle) {
  4835. let view = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4836. button.classList.toggle("toggled", toggle);
  4837. button.setAttribute("aria-expanded", toggle);
  4838. view?.classList.toggle("hidden", !toggle);
  4839. }
  4840. /***/ }),
  4841. /* 98 */
  4842. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4843. var $ = __webpack_require__(3);
  4844. var difference = __webpack_require__(99);
  4845. var setMethodAcceptSetLike = __webpack_require__(108);
  4846. $({
  4847. target: 'Set',
  4848. proto: true,
  4849. real: true,
  4850. forced: !setMethodAcceptSetLike('difference')
  4851. }, { difference: difference });
  4852. /***/ }),
  4853. /* 99 */
  4854. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4855. var aSet = __webpack_require__(100);
  4856. var SetHelpers = __webpack_require__(101);
  4857. var clone = __webpack_require__(102);
  4858. var size = __webpack_require__(105);
  4859. var getSetRecord = __webpack_require__(106);
  4860. var iterateSet = __webpack_require__(103);
  4861. var iterateSimple = __webpack_require__(104);
  4862. var has = SetHelpers.has;
  4863. var remove = SetHelpers.remove;
  4864. module.exports = function difference(other) {
  4865. var O = aSet(this);
  4866. var otherRec = getSetRecord(other);
  4867. var result = clone(O);
  4868. if (size(O) <= otherRec.size)
  4869. iterateSet(O, function (e) {
  4870. if (otherRec.includes(e))
  4871. remove(result, e);
  4872. });
  4873. else
  4874. iterateSimple(otherRec.getIterator(), function (e) {
  4875. if (has(O, e))
  4876. remove(result, e);
  4877. });
  4878. return result;
  4879. };
  4880. /***/ }),
  4881. /* 100 */
  4882. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4883. var has = (__webpack_require__(101).has);
  4884. module.exports = function (it) {
  4885. has(it);
  4886. return it;
  4887. };
  4888. /***/ }),
  4889. /* 101 */
  4890. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4891. var uncurryThis = __webpack_require__(14);
  4892. var SetPrototype = Set.prototype;
  4893. module.exports = {
  4894. Set: Set,
  4895. add: uncurryThis(SetPrototype.add),
  4896. has: uncurryThis(SetPrototype.has),
  4897. remove: uncurryThis(SetPrototype['delete']),
  4898. proto: SetPrototype
  4899. };
  4900. /***/ }),
  4901. /* 102 */
  4902. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4903. var SetHelpers = __webpack_require__(101);
  4904. var iterate = __webpack_require__(103);
  4905. var Set = SetHelpers.Set;
  4906. var add = SetHelpers.add;
  4907. module.exports = function (set) {
  4908. var result = new Set();
  4909. iterate(set, function (it) {
  4910. add(result, it);
  4911. });
  4912. return result;
  4913. };
  4914. /***/ }),
  4915. /* 103 */
  4916. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4917. var uncurryThis = __webpack_require__(14);
  4918. var iterateSimple = __webpack_require__(104);
  4919. var SetHelpers = __webpack_require__(101);
  4920. var Set = SetHelpers.Set;
  4921. var SetPrototype = SetHelpers.proto;
  4922. var forEach = uncurryThis(SetPrototype.forEach);
  4923. var keys = uncurryThis(SetPrototype.keys);
  4924. var next = keys(new Set()).next;
  4925. module.exports = function (set, fn, interruptible) {
  4926. return interruptible ? iterateSimple({
  4927. iterator: keys(set),
  4928. next: next
  4929. }, fn) : forEach(set, fn);
  4930. };
  4931. /***/ }),
  4932. /* 104 */
  4933. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4934. var call = __webpack_require__(8);
  4935. module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {
  4936. var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;
  4937. var next = record.next;
  4938. var step, result;
  4939. while (!(step = call(next, iterator)).done) {
  4940. result = fn(step.value);
  4941. if (result !== undefined)
  4942. return result;
  4943. }
  4944. };
  4945. /***/ }),
  4946. /* 105 */
  4947. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4948. var uncurryThisAccessor = __webpack_require__(80);
  4949. var SetHelpers = __webpack_require__(101);
  4950. module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
  4951. return set.size;
  4952. };
  4953. /***/ }),
  4954. /* 106 */
  4955. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4956. var aCallable = __webpack_require__(31);
  4957. var anObject = __webpack_require__(47);
  4958. var call = __webpack_require__(8);
  4959. var toIntegerOrInfinity = __webpack_require__(62);
  4960. var getIteratorDirect = __webpack_require__(107);
  4961. var INVALID_SIZE = 'Invalid size';
  4962. var $RangeError = RangeError;
  4963. var $TypeError = TypeError;
  4964. var max = Math.max;
  4965. var SetRecord = function (set, size, has, keys) {
  4966. this.set = set;
  4967. this.size = size;
  4968. this.has = has;
  4969. this.keys = keys;
  4970. };
  4971. SetRecord.prototype = {
  4972. getIterator: function () {
  4973. return getIteratorDirect(anObject(call(this.keys, this.set)));
  4974. },
  4975. includes: function (it) {
  4976. return call(this.has, this.set, it);
  4977. }
  4978. };
  4979. module.exports = function (obj) {
  4980. anObject(obj);
  4981. var numSize = +obj.size;
  4982. if (numSize !== numSize)
  4983. throw $TypeError(INVALID_SIZE);
  4984. var intSize = toIntegerOrInfinity(numSize);
  4985. if (intSize < 0)
  4986. throw $RangeError(INVALID_SIZE);
  4987. return new SetRecord(obj, max(intSize, 0), aCallable(obj.has), aCallable(obj.keys));
  4988. };
  4989. /***/ }),
  4990. /* 107 */
  4991. /***/ ((module) => {
  4992. module.exports = function (obj) {
  4993. return {
  4994. iterator: obj,
  4995. next: obj.next,
  4996. done: false
  4997. };
  4998. };
  4999. /***/ }),
  5000. /* 108 */
  5001. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5002. var getBuiltIn = __webpack_require__(24);
  5003. var createSetLike = function (size) {
  5004. return {
  5005. size: size,
  5006. has: function () {
  5007. return false;
  5008. },
  5009. keys: function () {
  5010. return {
  5011. next: function () {
  5012. return { done: true };
  5013. }
  5014. };
  5015. }
  5016. };
  5017. };
  5018. module.exports = function (name) {
  5019. var Set = getBuiltIn('Set');
  5020. try {
  5021. new Set()[name](createSetLike(0));
  5022. try {
  5023. new Set()[name](createSetLike(-1));
  5024. return false;
  5025. } catch (error2) {
  5026. return true;
  5027. }
  5028. } catch (error) {
  5029. return false;
  5030. }
  5031. };
  5032. /***/ }),
  5033. /* 109 */
  5034. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5035. var $ = __webpack_require__(3);
  5036. var fails = __webpack_require__(7);
  5037. var intersection = __webpack_require__(110);
  5038. var setMethodAcceptSetLike = __webpack_require__(108);
  5039. var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
  5040. return Array.from(new Set([
  5041. 1,
  5042. 2,
  5043. 3
  5044. ]).intersection(new Set([
  5045. 3,
  5046. 2
  5047. ]))) !== '3,2';
  5048. });
  5049. $({
  5050. target: 'Set',
  5051. proto: true,
  5052. real: true,
  5053. forced: INCORRECT
  5054. }, { intersection: intersection });
  5055. /***/ }),
  5056. /* 110 */
  5057. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5058. var aSet = __webpack_require__(100);
  5059. var SetHelpers = __webpack_require__(101);
  5060. var size = __webpack_require__(105);
  5061. var getSetRecord = __webpack_require__(106);
  5062. var iterateSet = __webpack_require__(103);
  5063. var iterateSimple = __webpack_require__(104);
  5064. var Set = SetHelpers.Set;
  5065. var add = SetHelpers.add;
  5066. var has = SetHelpers.has;
  5067. module.exports = function intersection(other) {
  5068. var O = aSet(this);
  5069. var otherRec = getSetRecord(other);
  5070. var result = new Set();
  5071. if (size(O) > otherRec.size) {
  5072. iterateSimple(otherRec.getIterator(), function (e) {
  5073. if (has(O, e))
  5074. add(result, e);
  5075. });
  5076. } else {
  5077. iterateSet(O, function (e) {
  5078. if (otherRec.includes(e))
  5079. add(result, e);
  5080. });
  5081. }
  5082. return result;
  5083. };
  5084. /***/ }),
  5085. /* 111 */
  5086. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5087. var $ = __webpack_require__(3);
  5088. var isDisjointFrom = __webpack_require__(112);
  5089. var setMethodAcceptSetLike = __webpack_require__(108);
  5090. $({
  5091. target: 'Set',
  5092. proto: true,
  5093. real: true,
  5094. forced: !setMethodAcceptSetLike('isDisjointFrom')
  5095. }, { isDisjointFrom: isDisjointFrom });
  5096. /***/ }),
  5097. /* 112 */
  5098. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5099. var aSet = __webpack_require__(100);
  5100. var has = (__webpack_require__(101).has);
  5101. var size = __webpack_require__(105);
  5102. var getSetRecord = __webpack_require__(106);
  5103. var iterateSet = __webpack_require__(103);
  5104. var iterateSimple = __webpack_require__(104);
  5105. var iteratorClose = __webpack_require__(113);
  5106. module.exports = function isDisjointFrom(other) {
  5107. var O = aSet(this);
  5108. var otherRec = getSetRecord(other);
  5109. if (size(O) <= otherRec.size)
  5110. return iterateSet(O, function (e) {
  5111. if (otherRec.includes(e))
  5112. return false;
  5113. }, true) !== false;
  5114. var iterator = otherRec.getIterator();
  5115. return iterateSimple(iterator, function (e) {
  5116. if (has(O, e))
  5117. return iteratorClose(iterator, 'normal', false);
  5118. }) !== false;
  5119. };
  5120. /***/ }),
  5121. /* 113 */
  5122. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5123. var call = __webpack_require__(8);
  5124. var anObject = __webpack_require__(47);
  5125. var getMethod = __webpack_require__(30);
  5126. module.exports = function (iterator, kind, value) {
  5127. var innerResult, innerError;
  5128. anObject(iterator);
  5129. try {
  5130. innerResult = getMethod(iterator, 'return');
  5131. if (!innerResult) {
  5132. if (kind === 'throw')
  5133. throw value;
  5134. return value;
  5135. }
  5136. innerResult = call(innerResult, iterator);
  5137. } catch (error) {
  5138. innerError = true;
  5139. innerResult = error;
  5140. }
  5141. if (kind === 'throw')
  5142. throw value;
  5143. if (innerError)
  5144. throw innerResult;
  5145. anObject(innerResult);
  5146. return value;
  5147. };
  5148. /***/ }),
  5149. /* 114 */
  5150. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5151. var $ = __webpack_require__(3);
  5152. var isSubsetOf = __webpack_require__(115);
  5153. var setMethodAcceptSetLike = __webpack_require__(108);
  5154. $({
  5155. target: 'Set',
  5156. proto: true,
  5157. real: true,
  5158. forced: !setMethodAcceptSetLike('isSubsetOf')
  5159. }, { isSubsetOf: isSubsetOf });
  5160. /***/ }),
  5161. /* 115 */
  5162. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5163. var aSet = __webpack_require__(100);
  5164. var size = __webpack_require__(105);
  5165. var iterate = __webpack_require__(103);
  5166. var getSetRecord = __webpack_require__(106);
  5167. module.exports = function isSubsetOf(other) {
  5168. var O = aSet(this);
  5169. var otherRec = getSetRecord(other);
  5170. if (size(O) > otherRec.size)
  5171. return false;
  5172. return iterate(O, function (e) {
  5173. if (!otherRec.includes(e))
  5174. return false;
  5175. }, true) !== false;
  5176. };
  5177. /***/ }),
  5178. /* 116 */
  5179. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5180. var $ = __webpack_require__(3);
  5181. var isSupersetOf = __webpack_require__(117);
  5182. var setMethodAcceptSetLike = __webpack_require__(108);
  5183. $({
  5184. target: 'Set',
  5185. proto: true,
  5186. real: true,
  5187. forced: !setMethodAcceptSetLike('isSupersetOf')
  5188. }, { isSupersetOf: isSupersetOf });
  5189. /***/ }),
  5190. /* 117 */
  5191. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5192. var aSet = __webpack_require__(100);
  5193. var has = (__webpack_require__(101).has);
  5194. var size = __webpack_require__(105);
  5195. var getSetRecord = __webpack_require__(106);
  5196. var iterateSimple = __webpack_require__(104);
  5197. var iteratorClose = __webpack_require__(113);
  5198. module.exports = function isSupersetOf(other) {
  5199. var O = aSet(this);
  5200. var otherRec = getSetRecord(other);
  5201. if (size(O) < otherRec.size)
  5202. return false;
  5203. var iterator = otherRec.getIterator();
  5204. return iterateSimple(iterator, function (e) {
  5205. if (!has(O, e))
  5206. return iteratorClose(iterator, 'normal', false);
  5207. }) !== false;
  5208. };
  5209. /***/ }),
  5210. /* 118 */
  5211. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5212. var $ = __webpack_require__(3);
  5213. var symmetricDifference = __webpack_require__(119);
  5214. var setMethodAcceptSetLike = __webpack_require__(108);
  5215. $({
  5216. target: 'Set',
  5217. proto: true,
  5218. real: true,
  5219. forced: !setMethodAcceptSetLike('symmetricDifference')
  5220. }, { symmetricDifference: symmetricDifference });
  5221. /***/ }),
  5222. /* 119 */
  5223. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5224. var aSet = __webpack_require__(100);
  5225. var SetHelpers = __webpack_require__(101);
  5226. var clone = __webpack_require__(102);
  5227. var getSetRecord = __webpack_require__(106);
  5228. var iterateSimple = __webpack_require__(104);
  5229. var add = SetHelpers.add;
  5230. var has = SetHelpers.has;
  5231. var remove = SetHelpers.remove;
  5232. module.exports = function symmetricDifference(other) {
  5233. var O = aSet(this);
  5234. var keysIter = getSetRecord(other).getIterator();
  5235. var result = clone(O);
  5236. iterateSimple(keysIter, function (e) {
  5237. if (has(O, e))
  5238. remove(result, e);
  5239. else
  5240. add(result, e);
  5241. });
  5242. return result;
  5243. };
  5244. /***/ }),
  5245. /* 120 */
  5246. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5247. var $ = __webpack_require__(3);
  5248. var union = __webpack_require__(121);
  5249. var setMethodAcceptSetLike = __webpack_require__(108);
  5250. $({
  5251. target: 'Set',
  5252. proto: true,
  5253. real: true,
  5254. forced: !setMethodAcceptSetLike('union')
  5255. }, { union: union });
  5256. /***/ }),
  5257. /* 121 */
  5258. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5259. var aSet = __webpack_require__(100);
  5260. var add = (__webpack_require__(101).add);
  5261. var clone = __webpack_require__(102);
  5262. var getSetRecord = __webpack_require__(106);
  5263. var iterateSimple = __webpack_require__(104);
  5264. module.exports = function union(other) {
  5265. var O = aSet(this);
  5266. var keysIter = getSetRecord(other).getIterator();
  5267. var result = clone(O);
  5268. iterateSimple(keysIter, function (it) {
  5269. add(result, it);
  5270. });
  5271. return result;
  5272. };
  5273. /***/ }),
  5274. /* 122 */
  5275. /***/ ((module) => {
  5276. module.exports = globalThis.pdfjsLib;
  5277. /***/ }),
  5278. /* 123 */
  5279. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5280. Object.defineProperty(exports, "__esModule", ({
  5281. value: true
  5282. }));
  5283. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  5284. __webpack_require__(76);
  5285. const compatibilityParams = Object.create(null);
  5286. exports.compatibilityParams = compatibilityParams;
  5287. {
  5288. const userAgent = navigator.userAgent || "";
  5289. const platform = navigator.platform || "";
  5290. const maxTouchPoints = navigator.maxTouchPoints || 1;
  5291. const isAndroid = /Android/.test(userAgent);
  5292. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  5293. (function checkCanvasSizeLimitation() {
  5294. if (isIOS || isAndroid) {
  5295. compatibilityParams.maxCanvasPixels = 5242880;
  5296. }
  5297. })();
  5298. }
  5299. const OptionKind = {
  5300. VIEWER: 0x02,
  5301. API: 0x04,
  5302. WORKER: 0x08,
  5303. PREFERENCE: 0x80
  5304. };
  5305. exports.OptionKind = OptionKind;
  5306. const defaultOptions = {
  5307. annotationEditorMode: {
  5308. value: 0,
  5309. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5310. },
  5311. annotationMode: {
  5312. value: 2,
  5313. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5314. },
  5315. cursorToolOnLoad: {
  5316. value: 0,
  5317. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5318. },
  5319. defaultZoomDelay: {
  5320. value: 400,
  5321. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5322. },
  5323. defaultZoomValue: {
  5324. value: "",
  5325. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5326. },
  5327. disableHistory: {
  5328. value: false,
  5329. kind: OptionKind.VIEWER
  5330. },
  5331. disablePageLabels: {
  5332. value: false,
  5333. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5334. },
  5335. enablePermissions: {
  5336. value: false,
  5337. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5338. },
  5339. enablePrintAutoRotate: {
  5340. value: true,
  5341. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5342. },
  5343. enableScripting: {
  5344. value: true,
  5345. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5346. },
  5347. enableStampEditor: {
  5348. value: true,
  5349. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5350. },
  5351. externalLinkRel: {
  5352. value: "noopener noreferrer nofollow",
  5353. kind: OptionKind.VIEWER
  5354. },
  5355. externalLinkTarget: {
  5356. value: 0,
  5357. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5358. },
  5359. historyUpdateUrl: {
  5360. value: false,
  5361. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5362. },
  5363. ignoreDestinationZoom: {
  5364. value: false,
  5365. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5366. },
  5367. imageResourcesPath: {
  5368. value: "./images/",
  5369. kind: OptionKind.VIEWER
  5370. },
  5371. maxCanvasPixels: {
  5372. value: 16777216,
  5373. kind: OptionKind.VIEWER
  5374. },
  5375. forcePageColors: {
  5376. value: false,
  5377. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5378. },
  5379. pageColorsBackground: {
  5380. value: "Canvas",
  5381. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5382. },
  5383. pageColorsForeground: {
  5384. value: "CanvasText",
  5385. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5386. },
  5387. pdfBugEnabled: {
  5388. value: false,
  5389. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5390. },
  5391. printResolution: {
  5392. value: 150,
  5393. kind: OptionKind.VIEWER
  5394. },
  5395. sidebarViewOnLoad: {
  5396. value: -1,
  5397. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5398. },
  5399. scrollModeOnLoad: {
  5400. value: -1,
  5401. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5402. },
  5403. spreadModeOnLoad: {
  5404. value: -1,
  5405. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5406. },
  5407. textLayerMode: {
  5408. value: 1,
  5409. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5410. },
  5411. viewerCssTheme: {
  5412. value: 0,
  5413. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5414. },
  5415. viewOnLoad: {
  5416. value: 0,
  5417. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5418. },
  5419. cMapPacked: {
  5420. value: true,
  5421. kind: OptionKind.API
  5422. },
  5423. cMapUrl: {
  5424. value: "../web/cmaps/",
  5425. kind: OptionKind.API
  5426. },
  5427. disableAutoFetch: {
  5428. value: false,
  5429. kind: OptionKind.API + OptionKind.PREFERENCE
  5430. },
  5431. disableFontFace: {
  5432. value: false,
  5433. kind: OptionKind.API + OptionKind.PREFERENCE
  5434. },
  5435. disableRange: {
  5436. value: false,
  5437. kind: OptionKind.API + OptionKind.PREFERENCE
  5438. },
  5439. disableStream: {
  5440. value: false,
  5441. kind: OptionKind.API + OptionKind.PREFERENCE
  5442. },
  5443. docBaseUrl: {
  5444. value: "",
  5445. kind: OptionKind.API
  5446. },
  5447. enableXfa: {
  5448. value: true,
  5449. kind: OptionKind.API + OptionKind.PREFERENCE
  5450. },
  5451. fontExtraProperties: {
  5452. value: false,
  5453. kind: OptionKind.API
  5454. },
  5455. isEvalSupported: {
  5456. value: true,
  5457. kind: OptionKind.API
  5458. },
  5459. isOffscreenCanvasSupported: {
  5460. value: true,
  5461. kind: OptionKind.API
  5462. },
  5463. maxImageSize: {
  5464. value: -1,
  5465. kind: OptionKind.API
  5466. },
  5467. pdfBug: {
  5468. value: false,
  5469. kind: OptionKind.API
  5470. },
  5471. standardFontDataUrl: {
  5472. value: "../web/standard_fonts/",
  5473. kind: OptionKind.API
  5474. },
  5475. verbosity: {
  5476. value: 1,
  5477. kind: OptionKind.API
  5478. },
  5479. workerPort: {
  5480. value: null,
  5481. kind: OptionKind.WORKER
  5482. },
  5483. workerSrc: {
  5484. value: "../build/pdf.worker.js",
  5485. kind: OptionKind.WORKER
  5486. }
  5487. };
  5488. {
  5489. defaultOptions.defaultUrl = {
  5490. value: "compressed.tracemonkey-pldi-09.pdf",
  5491. kind: OptionKind.VIEWER
  5492. };
  5493. defaultOptions.disablePreferences = {
  5494. value: false,
  5495. kind: OptionKind.VIEWER
  5496. };
  5497. defaultOptions.locale = {
  5498. value: navigator.language || "en-US",
  5499. kind: OptionKind.VIEWER
  5500. };
  5501. defaultOptions.sandboxBundleSrc = {
  5502. value: "../build/pdf.sandbox.js",
  5503. kind: OptionKind.VIEWER
  5504. };
  5505. }
  5506. const userOptions = Object.create(null);
  5507. class AppOptions {
  5508. constructor() {
  5509. throw new Error("Cannot initialize AppOptions.");
  5510. }
  5511. static get(name) {
  5512. const userOption = userOptions[name];
  5513. if (userOption !== undefined) {
  5514. return userOption;
  5515. }
  5516. const defaultOption = defaultOptions[name];
  5517. if (defaultOption !== undefined) {
  5518. return compatibilityParams[name] ?? defaultOption.value;
  5519. }
  5520. return undefined;
  5521. }
  5522. static getAll() {
  5523. let kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5524. const options = Object.create(null);
  5525. for (const name in defaultOptions) {
  5526. const defaultOption = defaultOptions[name];
  5527. if (kind) {
  5528. if ((kind & defaultOption.kind) === 0) {
  5529. continue;
  5530. }
  5531. if (kind === OptionKind.PREFERENCE) {
  5532. const value = defaultOption.value,
  5533. valueType = typeof value;
  5534. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  5535. options[name] = value;
  5536. continue;
  5537. }
  5538. throw new Error(`Invalid type for preference: ${name}`);
  5539. }
  5540. }
  5541. const userOption = userOptions[name];
  5542. options[name] = userOption !== undefined ? userOption : compatibilityParams[name] ?? defaultOption.value;
  5543. }
  5544. return options;
  5545. }
  5546. static set(name, value) {
  5547. userOptions[name] = value;
  5548. }
  5549. static setAll(options) {
  5550. for (const name in options) {
  5551. userOptions[name] = options[name];
  5552. }
  5553. }
  5554. static remove(name) {
  5555. delete userOptions[name];
  5556. }
  5557. }
  5558. exports.AppOptions = AppOptions;
  5559. {
  5560. AppOptions._hasUserOptions = function () {
  5561. return Object.keys(userOptions).length > 0;
  5562. };
  5563. }
  5564. /***/ }),
  5565. /* 124 */
  5566. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5567. Object.defineProperty(exports, "__esModule", ({
  5568. value: true
  5569. }));
  5570. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  5571. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  5572. __webpack_require__(76);
  5573. __webpack_require__(89);
  5574. const WaitOnType = {
  5575. EVENT: "event",
  5576. TIMEOUT: "timeout"
  5577. };
  5578. exports.WaitOnType = WaitOnType;
  5579. function waitOnEventOrTimeout(_ref) {
  5580. let {
  5581. target,
  5582. name,
  5583. delay = 0
  5584. } = _ref;
  5585. return new Promise(function (resolve, reject) {
  5586. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  5587. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  5588. }
  5589. function handler(type) {
  5590. if (target instanceof EventBus) {
  5591. target._off(name, eventHandler);
  5592. } else {
  5593. target.removeEventListener(name, eventHandler);
  5594. }
  5595. if (timeout) {
  5596. clearTimeout(timeout);
  5597. }
  5598. resolve(type);
  5599. }
  5600. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  5601. if (target instanceof EventBus) {
  5602. target._on(name, eventHandler);
  5603. } else {
  5604. target.addEventListener(name, eventHandler);
  5605. }
  5606. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  5607. const timeout = setTimeout(timeoutHandler, delay);
  5608. });
  5609. }
  5610. class EventBus {
  5611. #listeners = Object.create(null);
  5612. on(eventName, listener) {
  5613. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5614. this._on(eventName, listener, {
  5615. external: true,
  5616. once: options?.once
  5617. });
  5618. }
  5619. off(eventName, listener) {
  5620. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5621. this._off(eventName, listener, {
  5622. external: true,
  5623. once: options?.once
  5624. });
  5625. }
  5626. dispatch(eventName, data) {
  5627. const eventListeners = this.#listeners[eventName];
  5628. if (!eventListeners || eventListeners.length === 0) {
  5629. return;
  5630. }
  5631. let externalListeners;
  5632. for (const {
  5633. listener,
  5634. external,
  5635. once
  5636. } of eventListeners.slice(0)) {
  5637. if (once) {
  5638. this._off(eventName, listener);
  5639. }
  5640. if (external) {
  5641. (externalListeners ||= []).push(listener);
  5642. continue;
  5643. }
  5644. listener(data);
  5645. }
  5646. if (externalListeners) {
  5647. for (const listener of externalListeners) {
  5648. listener(data);
  5649. }
  5650. externalListeners = null;
  5651. }
  5652. }
  5653. _on(eventName, listener) {
  5654. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5655. const eventListeners = this.#listeners[eventName] ||= [];
  5656. eventListeners.push({
  5657. listener,
  5658. external: options?.external === true,
  5659. once: options?.once === true
  5660. });
  5661. }
  5662. _off(eventName, listener) {
  5663. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5664. const eventListeners = this.#listeners[eventName];
  5665. if (!eventListeners) {
  5666. return;
  5667. }
  5668. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  5669. if (eventListeners[i].listener === listener) {
  5670. eventListeners.splice(i, 1);
  5671. return;
  5672. }
  5673. }
  5674. }
  5675. }
  5676. exports.EventBus = EventBus;
  5677. class AutomationEventBus extends EventBus {
  5678. dispatch(eventName, data) {
  5679. throw new Error("Not implemented: AutomationEventBus.dispatch");
  5680. }
  5681. }
  5682. exports.AutomationEventBus = AutomationEventBus;
  5683. /***/ }),
  5684. /* 125 */
  5685. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5686. Object.defineProperty(exports, "__esModule", ({
  5687. value: true
  5688. }));
  5689. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  5690. __webpack_require__(76);
  5691. __webpack_require__(89);
  5692. __webpack_require__(2);
  5693. var _ui_utils = __webpack_require__(97);
  5694. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  5695. const LinkTarget = {
  5696. NONE: 0,
  5697. SELF: 1,
  5698. BLANK: 2,
  5699. PARENT: 3,
  5700. TOP: 4
  5701. };
  5702. exports.LinkTarget = LinkTarget;
  5703. function addLinkAttributes(link) {
  5704. let {
  5705. url,
  5706. target,
  5707. rel,
  5708. enabled = true
  5709. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5710. if (!url || typeof url !== "string") {
  5711. throw new Error('A valid "url" parameter must provided.');
  5712. }
  5713. const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  5714. if (enabled) {
  5715. link.href = link.title = urlNullRemoved;
  5716. } else {
  5717. link.href = "";
  5718. link.title = `Disabled: ${urlNullRemoved}`;
  5719. link.onclick = () => {
  5720. return false;
  5721. };
  5722. }
  5723. let targetStr = "";
  5724. switch (target) {
  5725. case LinkTarget.NONE:
  5726. break;
  5727. case LinkTarget.SELF:
  5728. targetStr = "_self";
  5729. break;
  5730. case LinkTarget.BLANK:
  5731. targetStr = "_blank";
  5732. break;
  5733. case LinkTarget.PARENT:
  5734. targetStr = "_parent";
  5735. break;
  5736. case LinkTarget.TOP:
  5737. targetStr = "_top";
  5738. break;
  5739. }
  5740. link.target = targetStr;
  5741. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  5742. }
  5743. class PDFLinkService {
  5744. #pagesRefCache = new Map();
  5745. constructor() {
  5746. let {
  5747. eventBus,
  5748. externalLinkTarget = null,
  5749. externalLinkRel = null,
  5750. ignoreDestinationZoom = false
  5751. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5752. this.eventBus = eventBus;
  5753. this.externalLinkTarget = externalLinkTarget;
  5754. this.externalLinkRel = externalLinkRel;
  5755. this.externalLinkEnabled = true;
  5756. this._ignoreDestinationZoom = ignoreDestinationZoom;
  5757. this.baseUrl = null;
  5758. this.pdfDocument = null;
  5759. this.pdfViewer = null;
  5760. this.pdfHistory = null;
  5761. }
  5762. setDocument(pdfDocument) {
  5763. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5764. this.baseUrl = baseUrl;
  5765. this.pdfDocument = pdfDocument;
  5766. this.#pagesRefCache.clear();
  5767. }
  5768. setViewer(pdfViewer) {
  5769. this.pdfViewer = pdfViewer;
  5770. }
  5771. setHistory(pdfHistory) {
  5772. this.pdfHistory = pdfHistory;
  5773. }
  5774. get pagesCount() {
  5775. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  5776. }
  5777. get page() {
  5778. return this.pdfViewer.currentPageNumber;
  5779. }
  5780. set page(value) {
  5781. this.pdfViewer.currentPageNumber = value;
  5782. }
  5783. get rotation() {
  5784. return this.pdfViewer.pagesRotation;
  5785. }
  5786. set rotation(value) {
  5787. this.pdfViewer.pagesRotation = value;
  5788. }
  5789. get isInPresentationMode() {
  5790. return this.pdfViewer.isInPresentationMode;
  5791. }
  5792. #goToDestinationHelper(rawDest) {
  5793. let namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5794. let explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  5795. const destRef = explicitDest[0];
  5796. let pageNumber;
  5797. if (typeof destRef === "object" && destRef !== null) {
  5798. pageNumber = this._cachedPageNumber(destRef);
  5799. if (!pageNumber) {
  5800. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  5801. this.cachePageRef(pageIndex + 1, destRef);
  5802. this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
  5803. }).catch(() => {
  5804. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
  5805. });
  5806. return;
  5807. }
  5808. } else if (Number.isInteger(destRef)) {
  5809. pageNumber = destRef + 1;
  5810. } else {
  5811. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
  5812. return;
  5813. }
  5814. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  5815. console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
  5816. return;
  5817. }
  5818. if (this.pdfHistory) {
  5819. this.pdfHistory.pushCurrentPosition();
  5820. this.pdfHistory.push({
  5821. namedDest,
  5822. explicitDest,
  5823. pageNumber
  5824. });
  5825. }
  5826. this.pdfViewer.scrollPageIntoView({
  5827. pageNumber,
  5828. destArray: explicitDest,
  5829. ignoreDestinationZoom: this._ignoreDestinationZoom
  5830. });
  5831. }
  5832. async goToDestination(dest) {
  5833. if (!this.pdfDocument) {
  5834. return;
  5835. }
  5836. let namedDest, explicitDest;
  5837. if (typeof dest === "string") {
  5838. namedDest = dest;
  5839. explicitDest = await this.pdfDocument.getDestination(dest);
  5840. } else {
  5841. namedDest = null;
  5842. explicitDest = await dest;
  5843. }
  5844. if (!Array.isArray(explicitDest)) {
  5845. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
  5846. return;
  5847. }
  5848. this.#goToDestinationHelper(dest, namedDest, explicitDest);
  5849. }
  5850. goToPage(val) {
  5851. if (!this.pdfDocument) {
  5852. return;
  5853. }
  5854. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  5855. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  5856. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  5857. return;
  5858. }
  5859. if (this.pdfHistory) {
  5860. this.pdfHistory.pushCurrentPosition();
  5861. this.pdfHistory.pushPage(pageNumber);
  5862. }
  5863. this.pdfViewer.scrollPageIntoView({
  5864. pageNumber
  5865. });
  5866. }
  5867. addLinkAttributes(link, url) {
  5868. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5869. addLinkAttributes(link, {
  5870. url,
  5871. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  5872. rel: this.externalLinkRel,
  5873. enabled: this.externalLinkEnabled
  5874. });
  5875. }
  5876. getDestinationHash(dest) {
  5877. if (typeof dest === "string") {
  5878. if (dest.length > 0) {
  5879. return this.getAnchorUrl("#" + escape(dest));
  5880. }
  5881. } else if (Array.isArray(dest)) {
  5882. const str = JSON.stringify(dest);
  5883. if (str.length > 0) {
  5884. return this.getAnchorUrl("#" + escape(str));
  5885. }
  5886. }
  5887. return this.getAnchorUrl("");
  5888. }
  5889. getAnchorUrl(anchor) {
  5890. return this.baseUrl ? this.baseUrl + anchor : anchor;
  5891. }
  5892. setHash(hash) {
  5893. if (!this.pdfDocument) {
  5894. return;
  5895. }
  5896. let pageNumber, dest;
  5897. if (hash.includes("=")) {
  5898. const params = (0, _ui_utils.parseQueryString)(hash);
  5899. if (params.has("search")) {
  5900. const query = params.get("search").replaceAll('"', ""),
  5901. phrase = params.get("phrase") === "true";
  5902. this.eventBus.dispatch("findfromurlhash", {
  5903. source: this,
  5904. query: phrase ? query : query.match(/\S+/g)
  5905. });
  5906. }
  5907. if (params.has("page")) {
  5908. pageNumber = params.get("page") | 0 || 1;
  5909. }
  5910. if (params.has("zoom")) {
  5911. const zoomArgs = params.get("zoom").split(",");
  5912. const zoomArg = zoomArgs[0];
  5913. const zoomArgNumber = parseFloat(zoomArg);
  5914. if (!zoomArg.includes("Fit")) {
  5915. dest = [null, {
  5916. name: "XYZ"
  5917. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  5918. } else if (zoomArg === "Fit" || zoomArg === "FitB") {
  5919. dest = [null, {
  5920. name: zoomArg
  5921. }];
  5922. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  5923. dest = [null, {
  5924. name: zoomArg
  5925. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  5926. } else if (zoomArg === "FitR") {
  5927. if (zoomArgs.length !== 5) {
  5928. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  5929. } else {
  5930. dest = [null, {
  5931. name: zoomArg
  5932. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  5933. }
  5934. } else {
  5935. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  5936. }
  5937. }
  5938. if (dest) {
  5939. this.pdfViewer.scrollPageIntoView({
  5940. pageNumber: pageNumber || this.page,
  5941. destArray: dest,
  5942. allowNegativeOffset: true
  5943. });
  5944. } else if (pageNumber) {
  5945. this.page = pageNumber;
  5946. }
  5947. if (params.has("pagemode")) {
  5948. this.eventBus.dispatch("pagemode", {
  5949. source: this,
  5950. mode: params.get("pagemode")
  5951. });
  5952. }
  5953. if (params.has("nameddest")) {
  5954. this.goToDestination(params.get("nameddest"));
  5955. }
  5956. } else {
  5957. dest = unescape(hash);
  5958. try {
  5959. dest = JSON.parse(dest);
  5960. if (!Array.isArray(dest)) {
  5961. dest = dest.toString();
  5962. }
  5963. } catch {}
  5964. if (typeof dest === "string" || PDFLinkService.#isValidExplicitDestination(dest)) {
  5965. this.goToDestination(dest);
  5966. return;
  5967. }
  5968. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  5969. }
  5970. }
  5971. executeNamedAction(action) {
  5972. switch (action) {
  5973. case "GoBack":
  5974. this.pdfHistory?.back();
  5975. break;
  5976. case "GoForward":
  5977. this.pdfHistory?.forward();
  5978. break;
  5979. case "NextPage":
  5980. this.pdfViewer.nextPage();
  5981. break;
  5982. case "PrevPage":
  5983. this.pdfViewer.previousPage();
  5984. break;
  5985. case "LastPage":
  5986. this.page = this.pagesCount;
  5987. break;
  5988. case "FirstPage":
  5989. this.page = 1;
  5990. break;
  5991. default:
  5992. break;
  5993. }
  5994. this.eventBus.dispatch("namedaction", {
  5995. source: this,
  5996. action
  5997. });
  5998. }
  5999. async executeSetOCGState(action) {
  6000. const pdfDocument = this.pdfDocument;
  6001. const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  6002. if (pdfDocument !== this.pdfDocument) {
  6003. return;
  6004. }
  6005. let operator;
  6006. for (const elem of action.state) {
  6007. switch (elem) {
  6008. case "ON":
  6009. case "OFF":
  6010. case "Toggle":
  6011. operator = elem;
  6012. continue;
  6013. }
  6014. switch (operator) {
  6015. case "ON":
  6016. optionalContentConfig.setVisibility(elem, true);
  6017. break;
  6018. case "OFF":
  6019. optionalContentConfig.setVisibility(elem, false);
  6020. break;
  6021. case "Toggle":
  6022. const group = optionalContentConfig.getGroup(elem);
  6023. if (group) {
  6024. optionalContentConfig.setVisibility(elem, !group.visible);
  6025. }
  6026. break;
  6027. }
  6028. }
  6029. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  6030. }
  6031. cachePageRef(pageNum, pageRef) {
  6032. if (!pageRef) {
  6033. return;
  6034. }
  6035. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  6036. this.#pagesRefCache.set(refStr, pageNum);
  6037. }
  6038. _cachedPageNumber(pageRef) {
  6039. if (!pageRef) {
  6040. return null;
  6041. }
  6042. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  6043. return this.#pagesRefCache.get(refStr) || null;
  6044. }
  6045. static #isValidExplicitDestination(dest) {
  6046. if (!Array.isArray(dest)) {
  6047. return false;
  6048. }
  6049. const destLength = dest.length;
  6050. if (destLength < 2) {
  6051. return false;
  6052. }
  6053. const page = dest[0];
  6054. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6055. return false;
  6056. }
  6057. const zoom = dest[1];
  6058. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  6059. return false;
  6060. }
  6061. let allowNull = true;
  6062. switch (zoom.name) {
  6063. case "XYZ":
  6064. if (destLength !== 5) {
  6065. return false;
  6066. }
  6067. break;
  6068. case "Fit":
  6069. case "FitB":
  6070. return destLength === 2;
  6071. case "FitH":
  6072. case "FitBH":
  6073. case "FitV":
  6074. case "FitBV":
  6075. if (destLength !== 3) {
  6076. return false;
  6077. }
  6078. break;
  6079. case "FitR":
  6080. if (destLength !== 6) {
  6081. return false;
  6082. }
  6083. allowNull = false;
  6084. break;
  6085. default:
  6086. return false;
  6087. }
  6088. for (let i = 2; i < destLength; i++) {
  6089. const param = dest[i];
  6090. if (!(typeof param === "number" || allowNull && param === null)) {
  6091. return false;
  6092. }
  6093. }
  6094. return true;
  6095. }
  6096. }
  6097. exports.PDFLinkService = PDFLinkService;
  6098. class SimpleLinkService {
  6099. constructor() {
  6100. this.externalLinkEnabled = true;
  6101. }
  6102. get pagesCount() {
  6103. return 0;
  6104. }
  6105. get page() {
  6106. return 0;
  6107. }
  6108. set page(value) {}
  6109. get rotation() {
  6110. return 0;
  6111. }
  6112. set rotation(value) {}
  6113. get isInPresentationMode() {
  6114. return false;
  6115. }
  6116. async goToDestination(dest) {}
  6117. goToPage(val) {}
  6118. addLinkAttributes(link, url) {
  6119. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6120. addLinkAttributes(link, {
  6121. url,
  6122. enabled: this.externalLinkEnabled
  6123. });
  6124. }
  6125. getDestinationHash(dest) {
  6126. return "#";
  6127. }
  6128. getAnchorUrl(hash) {
  6129. return "#";
  6130. }
  6131. setHash(hash) {}
  6132. executeNamedAction(action) {}
  6133. executeSetOCGState(action) {}
  6134. cachePageRef(pageNum, pageRef) {}
  6135. }
  6136. exports.SimpleLinkService = SimpleLinkService;
  6137. /***/ }),
  6138. /* 126 */
  6139. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6140. Object.defineProperty(exports, "__esModule", ({
  6141. value: true
  6142. }));
  6143. exports.AnnotationEditorParams = void 0;
  6144. var _pdfjsLib = __webpack_require__(122);
  6145. class AnnotationEditorParams {
  6146. constructor(options, eventBus) {
  6147. this.eventBus = eventBus;
  6148. this.#bindListeners(options);
  6149. }
  6150. #bindListeners(_ref) {
  6151. let {
  6152. editorFreeTextFontSize,
  6153. editorFreeTextColor,
  6154. editorInkColor,
  6155. editorInkThickness,
  6156. editorInkOpacity,
  6157. editorStampAddImage
  6158. } = _ref;
  6159. const dispatchEvent = (typeStr, value) => {
  6160. this.eventBus.dispatch("switchannotationeditorparams", {
  6161. source: this,
  6162. type: _pdfjsLib.AnnotationEditorParamsType[typeStr],
  6163. value
  6164. });
  6165. };
  6166. editorFreeTextFontSize.addEventListener("input", function () {
  6167. dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
  6168. });
  6169. editorFreeTextColor.addEventListener("input", function () {
  6170. dispatchEvent("FREETEXT_COLOR", this.value);
  6171. });
  6172. editorInkColor.addEventListener("input", function () {
  6173. dispatchEvent("INK_COLOR", this.value);
  6174. });
  6175. editorInkThickness.addEventListener("input", function () {
  6176. dispatchEvent("INK_THICKNESS", this.valueAsNumber);
  6177. });
  6178. editorInkOpacity.addEventListener("input", function () {
  6179. dispatchEvent("INK_OPACITY", this.valueAsNumber);
  6180. });
  6181. editorStampAddImage.addEventListener("click", () => {
  6182. dispatchEvent("CREATE");
  6183. });
  6184. this.eventBus._on("annotationeditorparamschanged", evt => {
  6185. for (const [type, value] of evt.details) {
  6186. switch (type) {
  6187. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE:
  6188. editorFreeTextFontSize.value = value;
  6189. break;
  6190. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR:
  6191. editorFreeTextColor.value = value;
  6192. break;
  6193. case _pdfjsLib.AnnotationEditorParamsType.INK_COLOR:
  6194. editorInkColor.value = value;
  6195. break;
  6196. case _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS:
  6197. editorInkThickness.value = value;
  6198. break;
  6199. case _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY:
  6200. editorInkOpacity.value = value;
  6201. break;
  6202. }
  6203. }
  6204. });
  6205. }
  6206. }
  6207. exports.AnnotationEditorParams = AnnotationEditorParams;
  6208. /***/ }),
  6209. /* 127 */
  6210. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6211. Object.defineProperty(exports, "__esModule", ({
  6212. value: true
  6213. }));
  6214. exports.OverlayManager = void 0;
  6215. __webpack_require__(76);
  6216. class OverlayManager {
  6217. #overlays = new WeakMap();
  6218. #active = null;
  6219. get active() {
  6220. return this.#active;
  6221. }
  6222. async register(dialog) {
  6223. let canForceClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6224. if (typeof dialog !== "object") {
  6225. throw new Error("Not enough parameters.");
  6226. } else if (this.#overlays.has(dialog)) {
  6227. throw new Error("The overlay is already registered.");
  6228. }
  6229. this.#overlays.set(dialog, {
  6230. canForceClose
  6231. });
  6232. dialog.addEventListener("cancel", evt => {
  6233. this.#active = null;
  6234. });
  6235. }
  6236. async open(dialog) {
  6237. if (!this.#overlays.has(dialog)) {
  6238. throw new Error("The overlay does not exist.");
  6239. } else if (this.#active) {
  6240. if (this.#active === dialog) {
  6241. throw new Error("The overlay is already active.");
  6242. } else if (this.#overlays.get(dialog).canForceClose) {
  6243. await this.close();
  6244. } else {
  6245. throw new Error("Another overlay is currently active.");
  6246. }
  6247. }
  6248. this.#active = dialog;
  6249. dialog.showModal();
  6250. }
  6251. async close() {
  6252. let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.#active;
  6253. if (!this.#overlays.has(dialog)) {
  6254. throw new Error("The overlay does not exist.");
  6255. } else if (!this.#active) {
  6256. throw new Error("The overlay is currently not active.");
  6257. } else if (this.#active !== dialog) {
  6258. throw new Error("Another overlay is currently active.");
  6259. }
  6260. dialog.close();
  6261. this.#active = null;
  6262. }
  6263. }
  6264. exports.OverlayManager = OverlayManager;
  6265. /***/ }),
  6266. /* 128 */
  6267. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6268. Object.defineProperty(exports, "__esModule", ({
  6269. value: true
  6270. }));
  6271. exports.PasswordPrompt = void 0;
  6272. __webpack_require__(76);
  6273. var _pdfjsLib = __webpack_require__(122);
  6274. class PasswordPrompt {
  6275. #activeCapability = null;
  6276. #updateCallback = null;
  6277. #reason = null;
  6278. constructor(options, overlayManager, l10n) {
  6279. let isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6280. this.dialog = options.dialog;
  6281. this.label = options.label;
  6282. this.input = options.input;
  6283. this.submitButton = options.submitButton;
  6284. this.cancelButton = options.cancelButton;
  6285. this.overlayManager = overlayManager;
  6286. this.l10n = l10n;
  6287. this._isViewerEmbedded = isViewerEmbedded;
  6288. this.submitButton.addEventListener("click", this.#verify.bind(this));
  6289. this.cancelButton.addEventListener("click", this.close.bind(this));
  6290. this.input.addEventListener("keydown", e => {
  6291. if (e.keyCode === 13) {
  6292. this.#verify();
  6293. }
  6294. });
  6295. this.overlayManager.register(this.dialog, true);
  6296. this.dialog.addEventListener("close", this.#cancel.bind(this));
  6297. }
  6298. async open() {
  6299. if (this.#activeCapability) {
  6300. await this.#activeCapability.promise;
  6301. }
  6302. this.#activeCapability = new _pdfjsLib.PromiseCapability();
  6303. try {
  6304. await this.overlayManager.open(this.dialog);
  6305. } catch (ex) {
  6306. this.#activeCapability.resolve();
  6307. throw ex;
  6308. }
  6309. const passwordIncorrect = this.#reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
  6310. if (!this._isViewerEmbedded || passwordIncorrect) {
  6311. this.input.focus();
  6312. }
  6313. this.label.textContent = await this.l10n.get(`password_${passwordIncorrect ? "invalid" : "label"}`);
  6314. }
  6315. async close() {
  6316. if (this.overlayManager.active === this.dialog) {
  6317. this.overlayManager.close(this.dialog);
  6318. }
  6319. }
  6320. #verify() {
  6321. const password = this.input.value;
  6322. if (password?.length > 0) {
  6323. this.#invokeCallback(password);
  6324. }
  6325. }
  6326. #cancel() {
  6327. this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  6328. this.#activeCapability.resolve();
  6329. }
  6330. #invokeCallback(password) {
  6331. if (!this.#updateCallback) {
  6332. return;
  6333. }
  6334. this.close();
  6335. this.input.value = "";
  6336. this.#updateCallback(password);
  6337. this.#updateCallback = null;
  6338. }
  6339. async setUpdateCallback(updateCallback, reason) {
  6340. if (this.#activeCapability) {
  6341. await this.#activeCapability.promise;
  6342. }
  6343. this.#updateCallback = updateCallback;
  6344. this.#reason = reason;
  6345. }
  6346. }
  6347. exports.PasswordPrompt = PasswordPrompt;
  6348. /***/ }),
  6349. /* 129 */
  6350. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6351. Object.defineProperty(exports, "__esModule", ({
  6352. value: true
  6353. }));
  6354. exports.PDFAttachmentViewer = void 0;
  6355. var _pdfjsLib = __webpack_require__(122);
  6356. var _base_tree_viewer = __webpack_require__(130);
  6357. var _event_utils = __webpack_require__(124);
  6358. class PDFAttachmentViewer extends _base_tree_viewer.BaseTreeViewer {
  6359. constructor(options) {
  6360. super(options);
  6361. this.downloadManager = options.downloadManager;
  6362. this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
  6363. }
  6364. reset() {
  6365. let keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6366. super.reset();
  6367. this._attachments = null;
  6368. if (!keepRenderedCapability) {
  6369. this._renderedCapability = new _pdfjsLib.PromiseCapability();
  6370. }
  6371. this._pendingDispatchEvent = false;
  6372. }
  6373. async _dispatchEvent(attachmentsCount) {
  6374. this._renderedCapability.resolve();
  6375. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  6376. this._pendingDispatchEvent = true;
  6377. await (0, _event_utils.waitOnEventOrTimeout)({
  6378. target: this.eventBus,
  6379. name: "annotationlayerrendered",
  6380. delay: 1000
  6381. });
  6382. if (!this._pendingDispatchEvent) {
  6383. return;
  6384. }
  6385. }
  6386. this._pendingDispatchEvent = false;
  6387. this.eventBus.dispatch("attachmentsloaded", {
  6388. source: this,
  6389. attachmentsCount
  6390. });
  6391. }
  6392. _bindLink(element, _ref) {
  6393. let {
  6394. content,
  6395. filename
  6396. } = _ref;
  6397. element.onclick = () => {
  6398. this.downloadManager.openOrDownloadData(element, content, filename);
  6399. return false;
  6400. };
  6401. }
  6402. render(_ref2) {
  6403. let {
  6404. attachments,
  6405. keepRenderedCapability = false
  6406. } = _ref2;
  6407. if (this._attachments) {
  6408. this.reset(keepRenderedCapability);
  6409. }
  6410. this._attachments = attachments || null;
  6411. if (!attachments) {
  6412. this._dispatchEvent(0);
  6413. return;
  6414. }
  6415. const fragment = document.createDocumentFragment();
  6416. let attachmentsCount = 0;
  6417. for (const name in attachments) {
  6418. const item = attachments[name];
  6419. const content = item.content,
  6420. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename, true);
  6421. const div = document.createElement("div");
  6422. div.className = "treeItem";
  6423. const element = document.createElement("a");
  6424. this._bindLink(element, {
  6425. content,
  6426. filename
  6427. });
  6428. element.textContent = this._normalizeTextContent(filename);
  6429. div.append(element);
  6430. fragment.append(div);
  6431. attachmentsCount++;
  6432. }
  6433. this._finishRendering(fragment, attachmentsCount);
  6434. }
  6435. #appendAttachment(_ref3) {
  6436. let {
  6437. filename,
  6438. content
  6439. } = _ref3;
  6440. const renderedPromise = this._renderedCapability.promise;
  6441. renderedPromise.then(() => {
  6442. if (renderedPromise !== this._renderedCapability.promise) {
  6443. return;
  6444. }
  6445. const attachments = this._attachments || Object.create(null);
  6446. for (const name in attachments) {
  6447. if (filename === name) {
  6448. return;
  6449. }
  6450. }
  6451. attachments[filename] = {
  6452. filename,
  6453. content
  6454. };
  6455. this.render({
  6456. attachments,
  6457. keepRenderedCapability: true
  6458. });
  6459. });
  6460. }
  6461. }
  6462. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  6463. /***/ }),
  6464. /* 130 */
  6465. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6466. Object.defineProperty(exports, "__esModule", ({
  6467. value: true
  6468. }));
  6469. exports.BaseTreeViewer = void 0;
  6470. __webpack_require__(76);
  6471. var _ui_utils = __webpack_require__(97);
  6472. const TREEITEM_OFFSET_TOP = -100;
  6473. const TREEITEM_SELECTED_CLASS = "selected";
  6474. class BaseTreeViewer {
  6475. constructor(options) {
  6476. if (this.constructor === BaseTreeViewer) {
  6477. throw new Error("Cannot initialize BaseTreeViewer.");
  6478. }
  6479. this.container = options.container;
  6480. this.eventBus = options.eventBus;
  6481. this.reset();
  6482. }
  6483. reset() {
  6484. this._pdfDocument = null;
  6485. this._lastToggleIsShow = true;
  6486. this._currentTreeItem = null;
  6487. this.container.textContent = "";
  6488. this.container.classList.remove("treeWithDeepNesting");
  6489. }
  6490. _dispatchEvent(count) {
  6491. throw new Error("Not implemented: _dispatchEvent");
  6492. }
  6493. _bindLink(element, params) {
  6494. throw new Error("Not implemented: _bindLink");
  6495. }
  6496. _normalizeTextContent(str) {
  6497. return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013";
  6498. }
  6499. _addToggleButton(div) {
  6500. let hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6501. const toggler = document.createElement("div");
  6502. toggler.className = "treeItemToggler";
  6503. if (hidden) {
  6504. toggler.classList.add("treeItemsHidden");
  6505. }
  6506. toggler.onclick = evt => {
  6507. evt.stopPropagation();
  6508. toggler.classList.toggle("treeItemsHidden");
  6509. if (evt.shiftKey) {
  6510. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  6511. this._toggleTreeItem(div, shouldShowAll);
  6512. }
  6513. };
  6514. div.prepend(toggler);
  6515. }
  6516. _toggleTreeItem(root) {
  6517. let show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6518. this._lastToggleIsShow = show;
  6519. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  6520. toggler.classList.toggle("treeItemsHidden", !show);
  6521. }
  6522. }
  6523. _toggleAllTreeItems() {
  6524. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  6525. }
  6526. _finishRendering(fragment, count) {
  6527. let hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6528. if (hasAnyNesting) {
  6529. this.container.classList.add("treeWithDeepNesting");
  6530. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  6531. }
  6532. this.container.append(fragment);
  6533. this._dispatchEvent(count);
  6534. }
  6535. render(params) {
  6536. throw new Error("Not implemented: render");
  6537. }
  6538. _updateCurrentTreeItem() {
  6539. let treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6540. if (this._currentTreeItem) {
  6541. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  6542. this._currentTreeItem = null;
  6543. }
  6544. if (treeItem) {
  6545. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  6546. this._currentTreeItem = treeItem;
  6547. }
  6548. }
  6549. _scrollToCurrentTreeItem(treeItem) {
  6550. if (!treeItem) {
  6551. return;
  6552. }
  6553. let currentNode = treeItem.parentNode;
  6554. while (currentNode && currentNode !== this.container) {
  6555. if (currentNode.classList.contains("treeItem")) {
  6556. const toggler = currentNode.firstElementChild;
  6557. toggler?.classList.remove("treeItemsHidden");
  6558. }
  6559. currentNode = currentNode.parentNode;
  6560. }
  6561. this._updateCurrentTreeItem(treeItem);
  6562. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  6563. }
  6564. }
  6565. exports.BaseTreeViewer = BaseTreeViewer;
  6566. /***/ }),
  6567. /* 131 */
  6568. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6569. Object.defineProperty(exports, "__esModule", ({
  6570. value: true
  6571. }));
  6572. exports.PDFCursorTools = void 0;
  6573. var _pdfjsLib = __webpack_require__(122);
  6574. var _ui_utils = __webpack_require__(97);
  6575. var _grab_to_pan = __webpack_require__(132);
  6576. class PDFCursorTools {
  6577. #active = _ui_utils.CursorTool.SELECT;
  6578. #prevActive = null;
  6579. constructor(_ref) {
  6580. let {
  6581. container,
  6582. eventBus,
  6583. cursorToolOnLoad = _ui_utils.CursorTool.SELECT
  6584. } = _ref;
  6585. this.container = container;
  6586. this.eventBus = eventBus;
  6587. this.#addEventListeners();
  6588. Promise.resolve().then(() => {
  6589. this.switchTool(cursorToolOnLoad);
  6590. });
  6591. }
  6592. get activeTool() {
  6593. return this.#active;
  6594. }
  6595. switchTool(tool) {
  6596. if (this.#prevActive !== null) {
  6597. return;
  6598. }
  6599. if (tool === this.#active) {
  6600. return;
  6601. }
  6602. const disableActiveTool = () => {
  6603. switch (this.#active) {
  6604. case _ui_utils.CursorTool.SELECT:
  6605. break;
  6606. case _ui_utils.CursorTool.HAND:
  6607. this._handTool.deactivate();
  6608. break;
  6609. case _ui_utils.CursorTool.ZOOM:
  6610. }
  6611. };
  6612. switch (tool) {
  6613. case _ui_utils.CursorTool.SELECT:
  6614. disableActiveTool();
  6615. break;
  6616. case _ui_utils.CursorTool.HAND:
  6617. disableActiveTool();
  6618. this._handTool.activate();
  6619. break;
  6620. case _ui_utils.CursorTool.ZOOM:
  6621. default:
  6622. console.error(`switchTool: "${tool}" is an unsupported value.`);
  6623. return;
  6624. }
  6625. this.#active = tool;
  6626. this.eventBus.dispatch("cursortoolchanged", {
  6627. source: this,
  6628. tool
  6629. });
  6630. }
  6631. #addEventListeners() {
  6632. this.eventBus._on("switchcursortool", evt => {
  6633. this.switchTool(evt.tool);
  6634. });
  6635. let annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE,
  6636. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  6637. const disableActive = () => {
  6638. const prevActive = this.#active;
  6639. this.switchTool(_ui_utils.CursorTool.SELECT);
  6640. this.#prevActive ??= prevActive;
  6641. };
  6642. const enableActive = () => {
  6643. const prevActive = this.#prevActive;
  6644. if (prevActive !== null && annotationEditorMode === _pdfjsLib.AnnotationEditorType.NONE && presentationModeState === _ui_utils.PresentationModeState.NORMAL) {
  6645. this.#prevActive = null;
  6646. this.switchTool(prevActive);
  6647. }
  6648. };
  6649. this.eventBus._on("secondarytoolbarreset", evt => {
  6650. if (this.#prevActive !== null) {
  6651. annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  6652. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  6653. enableActive();
  6654. }
  6655. });
  6656. this.eventBus._on("annotationeditormodechanged", _ref2 => {
  6657. let {
  6658. mode
  6659. } = _ref2;
  6660. annotationEditorMode = mode;
  6661. if (mode === _pdfjsLib.AnnotationEditorType.NONE) {
  6662. enableActive();
  6663. } else {
  6664. disableActive();
  6665. }
  6666. });
  6667. this.eventBus._on("presentationmodechanged", _ref3 => {
  6668. let {
  6669. state
  6670. } = _ref3;
  6671. presentationModeState = state;
  6672. if (state === _ui_utils.PresentationModeState.NORMAL) {
  6673. enableActive();
  6674. } else if (state === _ui_utils.PresentationModeState.FULLSCREEN) {
  6675. disableActive();
  6676. }
  6677. });
  6678. }
  6679. get _handTool() {
  6680. return (0, _pdfjsLib.shadow)(this, "_handTool", new _grab_to_pan.GrabToPan({
  6681. element: this.container
  6682. }));
  6683. }
  6684. }
  6685. exports.PDFCursorTools = PDFCursorTools;
  6686. /***/ }),
  6687. /* 132 */
  6688. /***/ ((__unused_webpack_module, exports) => {
  6689. Object.defineProperty(exports, "__esModule", ({
  6690. value: true
  6691. }));
  6692. exports.GrabToPan = void 0;
  6693. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  6694. class GrabToPan {
  6695. constructor(_ref) {
  6696. let {
  6697. element
  6698. } = _ref;
  6699. this.element = element;
  6700. this.document = element.ownerDocument;
  6701. this.activate = this.activate.bind(this);
  6702. this.deactivate = this.deactivate.bind(this);
  6703. this.toggle = this.toggle.bind(this);
  6704. this._onMouseDown = this.#onMouseDown.bind(this);
  6705. this._onMouseMove = this.#onMouseMove.bind(this);
  6706. this._endPan = this.#endPan.bind(this);
  6707. const overlay = this.overlay = document.createElement("div");
  6708. overlay.className = "grab-to-pan-grabbing";
  6709. }
  6710. activate() {
  6711. if (!this.active) {
  6712. this.active = true;
  6713. this.element.addEventListener("mousedown", this._onMouseDown, true);
  6714. this.element.classList.add(CSS_CLASS_GRAB);
  6715. }
  6716. }
  6717. deactivate() {
  6718. if (this.active) {
  6719. this.active = false;
  6720. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  6721. this._endPan();
  6722. this.element.classList.remove(CSS_CLASS_GRAB);
  6723. }
  6724. }
  6725. toggle() {
  6726. if (this.active) {
  6727. this.deactivate();
  6728. } else {
  6729. this.activate();
  6730. }
  6731. }
  6732. ignoreTarget(node) {
  6733. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  6734. }
  6735. #onMouseDown(event) {
  6736. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  6737. return;
  6738. }
  6739. if (event.originalTarget) {
  6740. try {
  6741. event.originalTarget.tagName;
  6742. } catch {
  6743. return;
  6744. }
  6745. }
  6746. this.scrollLeftStart = this.element.scrollLeft;
  6747. this.scrollTopStart = this.element.scrollTop;
  6748. this.clientXStart = event.clientX;
  6749. this.clientYStart = event.clientY;
  6750. this.document.addEventListener("mousemove", this._onMouseMove, true);
  6751. this.document.addEventListener("mouseup", this._endPan, true);
  6752. this.element.addEventListener("scroll", this._endPan, true);
  6753. event.preventDefault();
  6754. event.stopPropagation();
  6755. const focusedElement = document.activeElement;
  6756. if (focusedElement && !focusedElement.contains(event.target)) {
  6757. focusedElement.blur();
  6758. }
  6759. }
  6760. #onMouseMove(event) {
  6761. this.element.removeEventListener("scroll", this._endPan, true);
  6762. if (!(event.buttons & 1)) {
  6763. this._endPan();
  6764. return;
  6765. }
  6766. const xDiff = event.clientX - this.clientXStart;
  6767. const yDiff = event.clientY - this.clientYStart;
  6768. this.element.scrollTo({
  6769. top: this.scrollTopStart - yDiff,
  6770. left: this.scrollLeftStart - xDiff,
  6771. behavior: "instant"
  6772. });
  6773. if (!this.overlay.parentNode) {
  6774. document.body.append(this.overlay);
  6775. }
  6776. }
  6777. #endPan() {
  6778. this.element.removeEventListener("scroll", this._endPan, true);
  6779. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  6780. this.document.removeEventListener("mouseup", this._endPan, true);
  6781. this.overlay.remove();
  6782. }
  6783. }
  6784. exports.GrabToPan = GrabToPan;
  6785. /***/ }),
  6786. /* 133 */
  6787. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6788. Object.defineProperty(exports, "__esModule", ({
  6789. value: true
  6790. }));
  6791. exports.PDFDocumentProperties = void 0;
  6792. var _ui_utils = __webpack_require__(97);
  6793. var _pdfjsLib = __webpack_require__(122);
  6794. const DEFAULT_FIELD_CONTENT = "-";
  6795. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  6796. const US_PAGE_NAMES = {
  6797. "8.5x11": "Letter",
  6798. "8.5x14": "Legal"
  6799. };
  6800. const METRIC_PAGE_NAMES = {
  6801. "297x420": "A3",
  6802. "210x297": "A4"
  6803. };
  6804. function getPageName(size, isPortrait, pageNames) {
  6805. const width = isPortrait ? size.width : size.height;
  6806. const height = isPortrait ? size.height : size.width;
  6807. return pageNames[`${width}x${height}`];
  6808. }
  6809. class PDFDocumentProperties {
  6810. #fieldData = null;
  6811. constructor(_ref, overlayManager, eventBus, l10n, fileNameLookup) {
  6812. let {
  6813. dialog,
  6814. fields,
  6815. closeButton
  6816. } = _ref;
  6817. this.dialog = dialog;
  6818. this.fields = fields;
  6819. this.overlayManager = overlayManager;
  6820. this.l10n = l10n;
  6821. this._fileNameLookup = fileNameLookup;
  6822. this.#reset();
  6823. closeButton.addEventListener("click", this.close.bind(this));
  6824. this.overlayManager.register(this.dialog);
  6825. eventBus._on("pagechanging", evt => {
  6826. this._currentPageNumber = evt.pageNumber;
  6827. });
  6828. eventBus._on("rotationchanging", evt => {
  6829. this._pagesRotation = evt.pagesRotation;
  6830. });
  6831. this._isNonMetricLocale = true;
  6832. l10n.getLanguage().then(locale => {
  6833. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  6834. });
  6835. }
  6836. async open() {
  6837. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  6838. const currentPageNumber = this._currentPageNumber;
  6839. const pagesRotation = this._pagesRotation;
  6840. if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
  6841. this.#updateUI();
  6842. return;
  6843. }
  6844. const {
  6845. info,
  6846. contentLength
  6847. } = await this.pdfDocument.getMetadata();
  6848. 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 => {
  6849. return this.#parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  6850. }), this.#parseLinearization(info.IsLinearized)]);
  6851. this.#fieldData = Object.freeze({
  6852. fileName,
  6853. fileSize,
  6854. title: info.Title,
  6855. author: info.Author,
  6856. subject: info.Subject,
  6857. keywords: info.Keywords,
  6858. creationDate,
  6859. modificationDate,
  6860. creator: info.Creator,
  6861. producer: info.Producer,
  6862. version: info.PDFFormatVersion,
  6863. pageCount: this.pdfDocument.numPages,
  6864. pageSize,
  6865. linearized: isLinearized,
  6866. _currentPageNumber: currentPageNumber,
  6867. _pagesRotation: pagesRotation
  6868. });
  6869. this.#updateUI();
  6870. const {
  6871. length
  6872. } = await this.pdfDocument.getDownloadInfo();
  6873. if (contentLength === length) {
  6874. return;
  6875. }
  6876. const data = Object.assign(Object.create(null), this.#fieldData);
  6877. data.fileSize = await this.#parseFileSize(length);
  6878. this.#fieldData = Object.freeze(data);
  6879. this.#updateUI();
  6880. }
  6881. async close() {
  6882. this.overlayManager.close(this.dialog);
  6883. }
  6884. setDocument(pdfDocument) {
  6885. if (this.pdfDocument) {
  6886. this.#reset();
  6887. this.#updateUI(true);
  6888. }
  6889. if (!pdfDocument) {
  6890. return;
  6891. }
  6892. this.pdfDocument = pdfDocument;
  6893. this._dataAvailableCapability.resolve();
  6894. }
  6895. #reset() {
  6896. this.pdfDocument = null;
  6897. this.#fieldData = null;
  6898. this._dataAvailableCapability = new _pdfjsLib.PromiseCapability();
  6899. this._currentPageNumber = 1;
  6900. this._pagesRotation = 0;
  6901. }
  6902. #updateUI() {
  6903. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6904. if (reset || !this.#fieldData) {
  6905. for (const id in this.fields) {
  6906. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6907. }
  6908. return;
  6909. }
  6910. if (this.overlayManager.active !== this.dialog) {
  6911. return;
  6912. }
  6913. for (const id in this.fields) {
  6914. const content = this.#fieldData[id];
  6915. this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6916. }
  6917. }
  6918. async #parseFileSize() {
  6919. let fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  6920. const kb = fileSize / 1024,
  6921. mb = kb / 1024;
  6922. if (!kb) {
  6923. return undefined;
  6924. }
  6925. return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
  6926. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  6927. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  6928. size_b: fileSize.toLocaleString()
  6929. });
  6930. }
  6931. async #parsePageSize(pageSizeInches, pagesRotation) {
  6932. if (!pageSizeInches) {
  6933. return undefined;
  6934. }
  6935. if (pagesRotation % 180 !== 0) {
  6936. pageSizeInches = {
  6937. width: pageSizeInches.height,
  6938. height: pageSizeInches.width
  6939. };
  6940. }
  6941. const isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6942. let sizeInches = {
  6943. width: Math.round(pageSizeInches.width * 100) / 100,
  6944. height: Math.round(pageSizeInches.height * 100) / 100
  6945. };
  6946. let sizeMillimeters = {
  6947. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6948. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6949. };
  6950. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6951. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6952. const exactMillimeters = {
  6953. width: pageSizeInches.width * 25.4,
  6954. height: pageSizeInches.height * 25.4
  6955. };
  6956. const intMillimeters = {
  6957. width: Math.round(sizeMillimeters.width),
  6958. height: Math.round(sizeMillimeters.height)
  6959. };
  6960. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6961. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6962. if (rawName) {
  6963. sizeInches = {
  6964. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6965. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6966. };
  6967. sizeMillimeters = intMillimeters;
  6968. }
  6969. }
  6970. }
  6971. const [{
  6972. width,
  6973. height
  6974. }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`document_properties_page_size_unit_${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`document_properties_page_size_name_${rawName.toLowerCase()}`), this.l10n.get(`document_properties_page_size_orientation_${isPortrait ? "portrait" : "landscape"}`)]);
  6975. return this.l10n.get(`document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
  6976. width: width.toLocaleString(),
  6977. height: height.toLocaleString(),
  6978. unit,
  6979. name,
  6980. orientation
  6981. });
  6982. }
  6983. async #parseDate(inputDate) {
  6984. const dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  6985. if (!dateObject) {
  6986. return undefined;
  6987. }
  6988. return this.l10n.get("document_properties_date_string", {
  6989. date: dateObject.toLocaleDateString(),
  6990. time: dateObject.toLocaleTimeString()
  6991. });
  6992. }
  6993. #parseLinearization(isLinearized) {
  6994. return this.l10n.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
  6995. }
  6996. }
  6997. exports.PDFDocumentProperties = PDFDocumentProperties;
  6998. /***/ }),
  6999. /* 134 */
  7000. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7001. Object.defineProperty(exports, "__esModule", ({
  7002. value: true
  7003. }));
  7004. exports.PDFFindBar = void 0;
  7005. var _pdf_find_controller = __webpack_require__(135);
  7006. var _ui_utils = __webpack_require__(97);
  7007. const MATCHES_COUNT_LIMIT = 1000;
  7008. class PDFFindBar {
  7009. constructor(options, eventBus, l10n) {
  7010. this.opened = false;
  7011. this.bar = options.bar;
  7012. this.toggleButton = options.toggleButton;
  7013. this.findField = options.findField;
  7014. this.highlightAll = options.highlightAllCheckbox;
  7015. this.caseSensitive = options.caseSensitiveCheckbox;
  7016. this.matchDiacritics = options.matchDiacriticsCheckbox;
  7017. this.entireWord = options.entireWordCheckbox;
  7018. this.findMsg = options.findMsg;
  7019. this.findResultsCount = options.findResultsCount;
  7020. this.findPreviousButton = options.findPreviousButton;
  7021. this.findNextButton = options.findNextButton;
  7022. this.eventBus = eventBus;
  7023. this.l10n = l10n;
  7024. this.toggleButton.addEventListener("click", () => {
  7025. this.toggle();
  7026. });
  7027. this.findField.addEventListener("input", () => {
  7028. this.dispatchEvent("");
  7029. });
  7030. this.bar.addEventListener("keydown", e => {
  7031. switch (e.keyCode) {
  7032. case 13:
  7033. if (e.target === this.findField) {
  7034. this.dispatchEvent("again", e.shiftKey);
  7035. }
  7036. break;
  7037. case 27:
  7038. this.close();
  7039. break;
  7040. }
  7041. });
  7042. this.findPreviousButton.addEventListener("click", () => {
  7043. this.dispatchEvent("again", true);
  7044. });
  7045. this.findNextButton.addEventListener("click", () => {
  7046. this.dispatchEvent("again", false);
  7047. });
  7048. this.highlightAll.addEventListener("click", () => {
  7049. this.dispatchEvent("highlightallchange");
  7050. });
  7051. this.caseSensitive.addEventListener("click", () => {
  7052. this.dispatchEvent("casesensitivitychange");
  7053. });
  7054. this.entireWord.addEventListener("click", () => {
  7055. this.dispatchEvent("entirewordchange");
  7056. });
  7057. this.matchDiacritics.addEventListener("click", () => {
  7058. this.dispatchEvent("diacriticmatchingchange");
  7059. });
  7060. this.eventBus._on("resize", this.#adjustWidth.bind(this));
  7061. }
  7062. reset() {
  7063. this.updateUIState();
  7064. }
  7065. dispatchEvent(type) {
  7066. let findPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7067. this.eventBus.dispatch("find", {
  7068. source: this,
  7069. type,
  7070. query: this.findField.value,
  7071. caseSensitive: this.caseSensitive.checked,
  7072. entireWord: this.entireWord.checked,
  7073. highlightAll: this.highlightAll.checked,
  7074. findPrevious: findPrev,
  7075. matchDiacritics: this.matchDiacritics.checked
  7076. });
  7077. }
  7078. updateUIState(state, previous, matchesCount) {
  7079. let findMsg = Promise.resolve("");
  7080. let status = "";
  7081. switch (state) {
  7082. case _pdf_find_controller.FindState.FOUND:
  7083. break;
  7084. case _pdf_find_controller.FindState.PENDING:
  7085. status = "pending";
  7086. break;
  7087. case _pdf_find_controller.FindState.NOT_FOUND:
  7088. findMsg = this.l10n.get("find_not_found");
  7089. status = "notFound";
  7090. break;
  7091. case _pdf_find_controller.FindState.WRAPPED:
  7092. findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
  7093. break;
  7094. }
  7095. this.findField.setAttribute("data-status", status);
  7096. this.findField.setAttribute("aria-invalid", state === _pdf_find_controller.FindState.NOT_FOUND);
  7097. findMsg.then(msg => {
  7098. this.findMsg.setAttribute("data-status", status);
  7099. this.findMsg.textContent = msg;
  7100. this.#adjustWidth();
  7101. });
  7102. this.updateResultsCount(matchesCount);
  7103. }
  7104. updateResultsCount() {
  7105. let {
  7106. current = 0,
  7107. total = 0
  7108. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7109. const limit = MATCHES_COUNT_LIMIT;
  7110. let matchCountMsg = Promise.resolve("");
  7111. if (total > 0) {
  7112. if (total > limit) {
  7113. let key = "find_match_count_limit";
  7114. matchCountMsg = this.l10n.get(key, {
  7115. limit
  7116. });
  7117. } else {
  7118. let key = "find_match_count";
  7119. matchCountMsg = this.l10n.get(key, {
  7120. current,
  7121. total
  7122. });
  7123. }
  7124. }
  7125. matchCountMsg.then(msg => {
  7126. this.findResultsCount.textContent = msg;
  7127. this.#adjustWidth();
  7128. });
  7129. }
  7130. open() {
  7131. if (!this.opened) {
  7132. this.opened = true;
  7133. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true, this.bar);
  7134. }
  7135. this.findField.select();
  7136. this.findField.focus();
  7137. this.#adjustWidth();
  7138. }
  7139. close() {
  7140. if (!this.opened) {
  7141. return;
  7142. }
  7143. this.opened = false;
  7144. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false, this.bar);
  7145. this.eventBus.dispatch("findbarclose", {
  7146. source: this
  7147. });
  7148. }
  7149. toggle() {
  7150. if (this.opened) {
  7151. this.close();
  7152. } else {
  7153. this.open();
  7154. }
  7155. }
  7156. #adjustWidth() {
  7157. if (!this.opened) {
  7158. return;
  7159. }
  7160. this.bar.classList.remove("wrapContainers");
  7161. const findbarHeight = this.bar.clientHeight;
  7162. const inputContainerHeight = this.bar.firstElementChild.clientHeight;
  7163. if (findbarHeight > inputContainerHeight) {
  7164. this.bar.classList.add("wrapContainers");
  7165. }
  7166. }
  7167. }
  7168. exports.PDFFindBar = PDFFindBar;
  7169. /***/ }),
  7170. /* 135 */
  7171. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7172. Object.defineProperty(exports, "__esModule", ({
  7173. value: true
  7174. }));
  7175. exports.PDFFindController = exports.FindState = void 0;
  7176. __webpack_require__(98);
  7177. __webpack_require__(109);
  7178. __webpack_require__(111);
  7179. __webpack_require__(114);
  7180. __webpack_require__(116);
  7181. __webpack_require__(118);
  7182. __webpack_require__(120);
  7183. __webpack_require__(89);
  7184. var _ui_utils = __webpack_require__(97);
  7185. var _pdf_find_utils = __webpack_require__(136);
  7186. var _pdfjsLib = __webpack_require__(122);
  7187. const FindState = {
  7188. FOUND: 0,
  7189. NOT_FOUND: 1,
  7190. WRAPPED: 2,
  7191. PENDING: 3
  7192. };
  7193. exports.FindState = FindState;
  7194. const FIND_TIMEOUT = 250;
  7195. const MATCH_SCROLL_OFFSET_TOP = -50;
  7196. const MATCH_SCROLL_OFFSET_LEFT = -400;
  7197. const CHARACTERS_TO_NORMALIZE = {
  7198. "\u2010": "-",
  7199. "\u2018": "'",
  7200. "\u2019": "'",
  7201. "\u201A": "'",
  7202. "\u201B": "'",
  7203. "\u201C": '"',
  7204. "\u201D": '"',
  7205. "\u201E": '"',
  7206. "\u201F": '"',
  7207. "\u00BC": "1/4",
  7208. "\u00BD": "1/2",
  7209. "\u00BE": "3/4"
  7210. };
  7211. 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]);
  7212. let DIACRITICS_EXCEPTION_STR;
  7213. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  7214. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  7215. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  7216. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  7217. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  7218. const SYLLABLES_LENGTHS = new Map();
  7219. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  7220. const NFKC_CHARS_TO_NORMALIZE = new Map();
  7221. let noSyllablesRegExp = null;
  7222. let withSyllablesRegExp = null;
  7223. function normalize(text) {
  7224. const syllablePositions = [];
  7225. let m;
  7226. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  7227. let {
  7228. index
  7229. } = m;
  7230. for (const char of m[0]) {
  7231. let len = SYLLABLES_LENGTHS.get(char);
  7232. if (!len) {
  7233. len = char.normalize("NFD").length;
  7234. SYLLABLES_LENGTHS.set(char, len);
  7235. }
  7236. syllablePositions.push([len, index++]);
  7237. }
  7238. }
  7239. let normalizationRegex;
  7240. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  7241. normalizationRegex = noSyllablesRegExp;
  7242. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  7243. normalizationRegex = withSyllablesRegExp;
  7244. } else {
  7245. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  7246. const toNormalizeWithNFKC = (0, _pdf_find_utils.getNormalizeWithNFKC)();
  7247. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  7248. const HKDiacritics = "(?:\u3099|\u309A)";
  7249. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  7250. if (syllablePositions.length === 0) {
  7251. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  7252. } else {
  7253. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  7254. }
  7255. }
  7256. const rawDiacriticsPositions = [];
  7257. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  7258. rawDiacriticsPositions.push([m[0].length, m.index]);
  7259. }
  7260. let normalized = text.normalize("NFD");
  7261. const positions = [[0, 0]];
  7262. let rawDiacriticsIndex = 0;
  7263. let syllableIndex = 0;
  7264. let shift = 0;
  7265. let shiftOrigin = 0;
  7266. let eol = 0;
  7267. let hasDiacritics = false;
  7268. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
  7269. i -= shiftOrigin;
  7270. if (p1) {
  7271. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  7272. const jj = replacement.length;
  7273. for (let j = 1; j < jj; j++) {
  7274. positions.push([i - shift + j, shift - j]);
  7275. }
  7276. shift -= jj - 1;
  7277. return replacement;
  7278. }
  7279. if (p2) {
  7280. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  7281. if (!replacement) {
  7282. replacement = p2.normalize("NFKC");
  7283. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  7284. }
  7285. const jj = replacement.length;
  7286. for (let j = 1; j < jj; j++) {
  7287. positions.push([i - shift + j, shift - j]);
  7288. }
  7289. shift -= jj - 1;
  7290. return replacement;
  7291. }
  7292. if (p3) {
  7293. hasDiacritics = true;
  7294. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7295. ++rawDiacriticsIndex;
  7296. } else {
  7297. positions.push([i - 1 - shift + 1, shift - 1]);
  7298. shift -= 1;
  7299. shiftOrigin += 1;
  7300. }
  7301. positions.push([i - shift + 1, shift]);
  7302. shiftOrigin += 1;
  7303. eol += 1;
  7304. return p3.charAt(0);
  7305. }
  7306. if (p4) {
  7307. const hasTrailingDashEOL = p4.endsWith("\n");
  7308. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  7309. hasDiacritics = true;
  7310. let jj = len;
  7311. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7312. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  7313. ++rawDiacriticsIndex;
  7314. }
  7315. for (let j = 1; j <= jj; j++) {
  7316. positions.push([i - 1 - shift + j, shift - j]);
  7317. }
  7318. shift -= jj;
  7319. shiftOrigin += jj;
  7320. if (hasTrailingDashEOL) {
  7321. i += len - 1;
  7322. positions.push([i - shift + 1, 1 + shift]);
  7323. shift += 1;
  7324. shiftOrigin += 1;
  7325. eol += 1;
  7326. return p4.slice(0, len);
  7327. }
  7328. return p4;
  7329. }
  7330. if (p5) {
  7331. const len = p5.length - 2;
  7332. positions.push([i - shift + len, 1 + shift]);
  7333. shift += 1;
  7334. shiftOrigin += 1;
  7335. eol += 1;
  7336. return p5.slice(0, -2);
  7337. }
  7338. if (p6) {
  7339. const len = p6.length - 1;
  7340. positions.push([i - shift + len, shift]);
  7341. shiftOrigin += 1;
  7342. eol += 1;
  7343. return p6.slice(0, -1);
  7344. }
  7345. if (p7) {
  7346. positions.push([i - shift + 1, shift - 1]);
  7347. shift -= 1;
  7348. shiftOrigin += 1;
  7349. eol += 1;
  7350. return " ";
  7351. }
  7352. if (i + eol === syllablePositions[syllableIndex]?.[1]) {
  7353. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  7354. ++syllableIndex;
  7355. for (let j = 1; j <= newCharLen; j++) {
  7356. positions.push([i - (shift - j), shift - j]);
  7357. }
  7358. shift -= newCharLen;
  7359. shiftOrigin += newCharLen;
  7360. }
  7361. return p8;
  7362. });
  7363. positions.push([normalized.length, shift]);
  7364. return [normalized, positions, hasDiacritics];
  7365. }
  7366. function getOriginalIndex(diffs, pos, len) {
  7367. if (!diffs) {
  7368. return [pos, len];
  7369. }
  7370. const start = pos;
  7371. const end = pos + len - 1;
  7372. let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
  7373. if (diffs[i][0] > start) {
  7374. --i;
  7375. }
  7376. let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  7377. if (diffs[j][0] > end) {
  7378. --j;
  7379. }
  7380. const oldStart = start + diffs[i][1];
  7381. const oldEnd = end + diffs[j][1];
  7382. const oldLen = oldEnd + 1 - oldStart;
  7383. return [oldStart, oldLen];
  7384. }
  7385. class PDFFindController {
  7386. #state = null;
  7387. #updateMatchesCountOnProgress = true;
  7388. #visitedPagesCount = 0;
  7389. constructor(_ref) {
  7390. let {
  7391. linkService,
  7392. eventBus,
  7393. updateMatchesCountOnProgress = true
  7394. } = _ref;
  7395. this._linkService = linkService;
  7396. this._eventBus = eventBus;
  7397. this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
  7398. this.onIsPageVisible = null;
  7399. this.#reset();
  7400. eventBus._on("find", this.#onFind.bind(this));
  7401. eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
  7402. }
  7403. get highlightMatches() {
  7404. return this._highlightMatches;
  7405. }
  7406. get pageMatches() {
  7407. return this._pageMatches;
  7408. }
  7409. get pageMatchesLength() {
  7410. return this._pageMatchesLength;
  7411. }
  7412. get selected() {
  7413. return this._selected;
  7414. }
  7415. get state() {
  7416. return this.#state;
  7417. }
  7418. setDocument(pdfDocument) {
  7419. if (this._pdfDocument) {
  7420. this.#reset();
  7421. }
  7422. if (!pdfDocument) {
  7423. return;
  7424. }
  7425. this._pdfDocument = pdfDocument;
  7426. this._firstPageCapability.resolve();
  7427. }
  7428. #onFind(state) {
  7429. if (!state) {
  7430. return;
  7431. }
  7432. if (state.phraseSearch === false) {
  7433. console.error("The `phraseSearch`-parameter was removed, please provide " + "an Array of strings in the `query`-parameter instead.");
  7434. if (typeof state.query === "string") {
  7435. state.query = state.query.match(/\S+/g);
  7436. }
  7437. }
  7438. const pdfDocument = this._pdfDocument;
  7439. const {
  7440. type
  7441. } = state;
  7442. if (this.#state === null || this.#shouldDirtyMatch(state)) {
  7443. this._dirtyMatch = true;
  7444. }
  7445. this.#state = state;
  7446. if (type !== "highlightallchange") {
  7447. this.#updateUIState(FindState.PENDING);
  7448. }
  7449. this._firstPageCapability.promise.then(() => {
  7450. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7451. return;
  7452. }
  7453. this.#extractText();
  7454. const findbarClosed = !this._highlightMatches;
  7455. const pendingTimeout = !!this._findTimeout;
  7456. if (this._findTimeout) {
  7457. clearTimeout(this._findTimeout);
  7458. this._findTimeout = null;
  7459. }
  7460. if (!type) {
  7461. this._findTimeout = setTimeout(() => {
  7462. this.#nextMatch();
  7463. this._findTimeout = null;
  7464. }, FIND_TIMEOUT);
  7465. } else if (this._dirtyMatch) {
  7466. this.#nextMatch();
  7467. } else if (type === "again") {
  7468. this.#nextMatch();
  7469. if (findbarClosed && this.#state.highlightAll) {
  7470. this.#updateAllPages();
  7471. }
  7472. } else if (type === "highlightallchange") {
  7473. if (pendingTimeout) {
  7474. this.#nextMatch();
  7475. } else {
  7476. this._highlightMatches = true;
  7477. }
  7478. this.#updateAllPages();
  7479. } else {
  7480. this.#nextMatch();
  7481. }
  7482. });
  7483. }
  7484. scrollMatchIntoView(_ref2) {
  7485. let {
  7486. element = null,
  7487. selectedLeft = 0,
  7488. pageIndex = -1,
  7489. matchIndex = -1
  7490. } = _ref2;
  7491. if (!this._scrollMatches || !element) {
  7492. return;
  7493. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  7494. return;
  7495. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  7496. return;
  7497. }
  7498. this._scrollMatches = false;
  7499. const spot = {
  7500. top: MATCH_SCROLL_OFFSET_TOP,
  7501. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  7502. };
  7503. (0, _ui_utils.scrollIntoView)(element, spot, true);
  7504. }
  7505. #reset() {
  7506. this._highlightMatches = false;
  7507. this._scrollMatches = false;
  7508. this._pdfDocument = null;
  7509. this._pageMatches = [];
  7510. this._pageMatchesLength = [];
  7511. this.#visitedPagesCount = 0;
  7512. this.#state = null;
  7513. this._selected = {
  7514. pageIdx: -1,
  7515. matchIdx: -1
  7516. };
  7517. this._offset = {
  7518. pageIdx: null,
  7519. matchIdx: null,
  7520. wrapped: false
  7521. };
  7522. this._extractTextPromises = [];
  7523. this._pageContents = [];
  7524. this._pageDiffs = [];
  7525. this._hasDiacritics = [];
  7526. this._matchesCountTotal = 0;
  7527. this._pagesToSearch = null;
  7528. this._pendingFindMatches = new Set();
  7529. this._resumePageIdx = null;
  7530. this._dirtyMatch = false;
  7531. clearTimeout(this._findTimeout);
  7532. this._findTimeout = null;
  7533. this._firstPageCapability = new _pdfjsLib.PromiseCapability();
  7534. }
  7535. get #query() {
  7536. const {
  7537. query
  7538. } = this.#state;
  7539. if (typeof query === "string") {
  7540. if (query !== this._rawQuery) {
  7541. this._rawQuery = query;
  7542. [this._normalizedQuery] = normalize(query);
  7543. }
  7544. return this._normalizedQuery;
  7545. }
  7546. return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
  7547. }
  7548. #shouldDirtyMatch(state) {
  7549. const newQuery = state.query,
  7550. prevQuery = this.#state.query;
  7551. const newType = typeof newQuery,
  7552. prevType = typeof prevQuery;
  7553. if (newType !== prevType) {
  7554. return true;
  7555. }
  7556. if (newType === "string") {
  7557. if (newQuery !== prevQuery) {
  7558. return true;
  7559. }
  7560. } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
  7561. return true;
  7562. }
  7563. switch (state.type) {
  7564. case "again":
  7565. const pageNumber = this._selected.pageIdx + 1;
  7566. const linkService = this._linkService;
  7567. return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
  7568. case "highlightallchange":
  7569. return false;
  7570. }
  7571. return true;
  7572. }
  7573. #isEntireWord(content, startIdx, length) {
  7574. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  7575. if (match) {
  7576. const first = content.charCodeAt(startIdx);
  7577. const limit = match[1].charCodeAt(0);
  7578. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7579. return false;
  7580. }
  7581. }
  7582. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  7583. if (match) {
  7584. const last = content.charCodeAt(startIdx + length - 1);
  7585. const limit = match[1].charCodeAt(0);
  7586. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7587. return false;
  7588. }
  7589. }
  7590. return true;
  7591. }
  7592. #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
  7593. const matches = this._pageMatches[pageIndex] = [];
  7594. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  7595. if (!query) {
  7596. return;
  7597. }
  7598. const diffs = this._pageDiffs[pageIndex];
  7599. let match;
  7600. while ((match = query.exec(pageContent)) !== null) {
  7601. if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
  7602. continue;
  7603. }
  7604. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  7605. if (matchLen) {
  7606. matches.push(matchPos);
  7607. matchesLength.push(matchLen);
  7608. }
  7609. }
  7610. }
  7611. #convertToRegExpString(query, hasDiacritics) {
  7612. const {
  7613. matchDiacritics
  7614. } = this.#state;
  7615. let isUnicode = false;
  7616. query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  7617. if (p1) {
  7618. return `[ ]*\\${p1}[ ]*`;
  7619. }
  7620. if (p2) {
  7621. return `[ ]*${p2}[ ]*`;
  7622. }
  7623. if (p3) {
  7624. return "[ ]+";
  7625. }
  7626. if (matchDiacritics) {
  7627. return p4 || p5;
  7628. }
  7629. if (p4) {
  7630. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  7631. }
  7632. if (hasDiacritics) {
  7633. isUnicode = true;
  7634. return `${p5}\\p{M}*`;
  7635. }
  7636. return p5;
  7637. });
  7638. const trailingSpaces = "[ ]*";
  7639. if (query.endsWith(trailingSpaces)) {
  7640. query = query.slice(0, query.length - trailingSpaces.length);
  7641. }
  7642. if (matchDiacritics) {
  7643. if (hasDiacritics) {
  7644. DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
  7645. isUnicode = true;
  7646. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  7647. }
  7648. }
  7649. return [isUnicode, query];
  7650. }
  7651. #calculateMatch(pageIndex) {
  7652. let query = this.#query;
  7653. if (query.length === 0) {
  7654. return;
  7655. }
  7656. const {
  7657. caseSensitive,
  7658. entireWord
  7659. } = this.#state;
  7660. const pageContent = this._pageContents[pageIndex];
  7661. const hasDiacritics = this._hasDiacritics[pageIndex];
  7662. let isUnicode = false;
  7663. if (typeof query === "string") {
  7664. [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
  7665. } else {
  7666. query = query.sort().reverse().map(q => {
  7667. const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
  7668. isUnicode ||= isUnicodePart;
  7669. return `(${queryPart})`;
  7670. }).join("|");
  7671. }
  7672. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  7673. query = query ? new RegExp(query, flags) : null;
  7674. this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
  7675. if (this.#state.highlightAll) {
  7676. this.#updatePage(pageIndex);
  7677. }
  7678. if (this._resumePageIdx === pageIndex) {
  7679. this._resumePageIdx = null;
  7680. this.#nextPageMatch();
  7681. }
  7682. const pageMatchesCount = this._pageMatches[pageIndex].length;
  7683. this._matchesCountTotal += pageMatchesCount;
  7684. if (this.#updateMatchesCountOnProgress) {
  7685. if (pageMatchesCount > 0) {
  7686. this.#updateUIResultsCount();
  7687. }
  7688. } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
  7689. this.#updateUIResultsCount();
  7690. }
  7691. }
  7692. #extractText() {
  7693. if (this._extractTextPromises.length > 0) {
  7694. return;
  7695. }
  7696. let promise = Promise.resolve();
  7697. const textOptions = {
  7698. disableNormalization: true
  7699. };
  7700. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  7701. const extractTextCapability = new _pdfjsLib.PromiseCapability();
  7702. this._extractTextPromises[i] = extractTextCapability.promise;
  7703. promise = promise.then(() => {
  7704. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  7705. return pdfPage.getTextContent(textOptions);
  7706. }).then(textContent => {
  7707. const strBuf = [];
  7708. for (const textItem of textContent.items) {
  7709. strBuf.push(textItem.str);
  7710. if (textItem.hasEOL) {
  7711. strBuf.push("\n");
  7712. }
  7713. }
  7714. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  7715. extractTextCapability.resolve();
  7716. }, reason => {
  7717. console.error(`Unable to get text content for page ${i + 1}`, reason);
  7718. this._pageContents[i] = "";
  7719. this._pageDiffs[i] = null;
  7720. this._hasDiacritics[i] = false;
  7721. extractTextCapability.resolve();
  7722. });
  7723. });
  7724. }
  7725. }
  7726. #updatePage(index) {
  7727. if (this._scrollMatches && this._selected.pageIdx === index) {
  7728. this._linkService.page = index + 1;
  7729. }
  7730. this._eventBus.dispatch("updatetextlayermatches", {
  7731. source: this,
  7732. pageIndex: index
  7733. });
  7734. }
  7735. #updateAllPages() {
  7736. this._eventBus.dispatch("updatetextlayermatches", {
  7737. source: this,
  7738. pageIndex: -1
  7739. });
  7740. }
  7741. #nextMatch() {
  7742. const previous = this.#state.findPrevious;
  7743. const currentPageIndex = this._linkService.page - 1;
  7744. const numPages = this._linkService.pagesCount;
  7745. this._highlightMatches = true;
  7746. if (this._dirtyMatch) {
  7747. this._dirtyMatch = false;
  7748. this._selected.pageIdx = this._selected.matchIdx = -1;
  7749. this._offset.pageIdx = currentPageIndex;
  7750. this._offset.matchIdx = null;
  7751. this._offset.wrapped = false;
  7752. this._resumePageIdx = null;
  7753. this._pageMatches.length = 0;
  7754. this._pageMatchesLength.length = 0;
  7755. this.#visitedPagesCount = 0;
  7756. this._matchesCountTotal = 0;
  7757. this.#updateAllPages();
  7758. for (let i = 0; i < numPages; i++) {
  7759. if (this._pendingFindMatches.has(i)) {
  7760. continue;
  7761. }
  7762. this._pendingFindMatches.add(i);
  7763. this._extractTextPromises[i].then(() => {
  7764. this._pendingFindMatches.delete(i);
  7765. this.#calculateMatch(i);
  7766. });
  7767. }
  7768. }
  7769. const query = this.#query;
  7770. if (query.length === 0) {
  7771. this.#updateUIState(FindState.FOUND);
  7772. return;
  7773. }
  7774. if (this._resumePageIdx) {
  7775. return;
  7776. }
  7777. const offset = this._offset;
  7778. this._pagesToSearch = numPages;
  7779. if (offset.matchIdx !== null) {
  7780. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  7781. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  7782. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  7783. this.#updateMatch(true);
  7784. return;
  7785. }
  7786. this.#advanceOffsetPage(previous);
  7787. }
  7788. this.#nextPageMatch();
  7789. }
  7790. #matchesReady(matches) {
  7791. const offset = this._offset;
  7792. const numMatches = matches.length;
  7793. const previous = this.#state.findPrevious;
  7794. if (numMatches) {
  7795. offset.matchIdx = previous ? numMatches - 1 : 0;
  7796. this.#updateMatch(true);
  7797. return true;
  7798. }
  7799. this.#advanceOffsetPage(previous);
  7800. if (offset.wrapped) {
  7801. offset.matchIdx = null;
  7802. if (this._pagesToSearch < 0) {
  7803. this.#updateMatch(false);
  7804. return true;
  7805. }
  7806. }
  7807. return false;
  7808. }
  7809. #nextPageMatch() {
  7810. if (this._resumePageIdx !== null) {
  7811. console.error("There can only be one pending page.");
  7812. }
  7813. let matches = null;
  7814. do {
  7815. const pageIdx = this._offset.pageIdx;
  7816. matches = this._pageMatches[pageIdx];
  7817. if (!matches) {
  7818. this._resumePageIdx = pageIdx;
  7819. break;
  7820. }
  7821. } while (!this.#matchesReady(matches));
  7822. }
  7823. #advanceOffsetPage(previous) {
  7824. const offset = this._offset;
  7825. const numPages = this._linkService.pagesCount;
  7826. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7827. offset.matchIdx = null;
  7828. this._pagesToSearch--;
  7829. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7830. offset.pageIdx = previous ? numPages - 1 : 0;
  7831. offset.wrapped = true;
  7832. }
  7833. }
  7834. #updateMatch() {
  7835. let found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7836. let state = FindState.NOT_FOUND;
  7837. const wrapped = this._offset.wrapped;
  7838. this._offset.wrapped = false;
  7839. if (found) {
  7840. const previousPage = this._selected.pageIdx;
  7841. this._selected.pageIdx = this._offset.pageIdx;
  7842. this._selected.matchIdx = this._offset.matchIdx;
  7843. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7844. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  7845. this.#updatePage(previousPage);
  7846. }
  7847. }
  7848. this.#updateUIState(state, this.#state.findPrevious);
  7849. if (this._selected.pageIdx !== -1) {
  7850. this._scrollMatches = true;
  7851. this.#updatePage(this._selected.pageIdx);
  7852. }
  7853. }
  7854. #onFindBarClose(evt) {
  7855. const pdfDocument = this._pdfDocument;
  7856. this._firstPageCapability.promise.then(() => {
  7857. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7858. return;
  7859. }
  7860. if (this._findTimeout) {
  7861. clearTimeout(this._findTimeout);
  7862. this._findTimeout = null;
  7863. }
  7864. if (this._resumePageIdx) {
  7865. this._resumePageIdx = null;
  7866. this._dirtyMatch = true;
  7867. }
  7868. this.#updateUIState(FindState.FOUND);
  7869. this._highlightMatches = false;
  7870. this.#updateAllPages();
  7871. });
  7872. }
  7873. #requestMatchesCount() {
  7874. const {
  7875. pageIdx,
  7876. matchIdx
  7877. } = this._selected;
  7878. let current = 0,
  7879. total = this._matchesCountTotal;
  7880. if (matchIdx !== -1) {
  7881. for (let i = 0; i < pageIdx; i++) {
  7882. current += this._pageMatches[i]?.length || 0;
  7883. }
  7884. current += matchIdx + 1;
  7885. }
  7886. if (current < 1 || current > total) {
  7887. current = total = 0;
  7888. }
  7889. return {
  7890. current,
  7891. total
  7892. };
  7893. }
  7894. #updateUIResultsCount() {
  7895. this._eventBus.dispatch("updatefindmatchescount", {
  7896. source: this,
  7897. matchesCount: this.#requestMatchesCount()
  7898. });
  7899. }
  7900. #updateUIState(state) {
  7901. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7902. if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
  7903. return;
  7904. }
  7905. this._eventBus.dispatch("updatefindcontrolstate", {
  7906. source: this,
  7907. state,
  7908. previous,
  7909. matchesCount: this.#requestMatchesCount(),
  7910. rawQuery: this.#state?.query ?? null
  7911. });
  7912. }
  7913. }
  7914. exports.PDFFindController = PDFFindController;
  7915. /***/ }),
  7916. /* 136 */
  7917. /***/ ((__unused_webpack_module, exports) => {
  7918. Object.defineProperty(exports, "__esModule", ({
  7919. value: true
  7920. }));
  7921. exports.CharacterType = void 0;
  7922. exports.getCharacterType = getCharacterType;
  7923. exports.getNormalizeWithNFKC = getNormalizeWithNFKC;
  7924. const CharacterType = {
  7925. SPACE: 0,
  7926. ALPHA_LETTER: 1,
  7927. PUNCT: 2,
  7928. HAN_LETTER: 3,
  7929. KATAKANA_LETTER: 4,
  7930. HIRAGANA_LETTER: 5,
  7931. HALFWIDTH_KATAKANA_LETTER: 6,
  7932. THAI_LETTER: 7
  7933. };
  7934. exports.CharacterType = CharacterType;
  7935. function isAlphabeticalScript(charCode) {
  7936. return charCode < 0x2e80;
  7937. }
  7938. function isAscii(charCode) {
  7939. return (charCode & 0xff80) === 0;
  7940. }
  7941. function isAsciiAlpha(charCode) {
  7942. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7943. }
  7944. function isAsciiDigit(charCode) {
  7945. return charCode >= 0x30 && charCode <= 0x39;
  7946. }
  7947. function isAsciiSpace(charCode) {
  7948. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7949. }
  7950. function isHan(charCode) {
  7951. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7952. }
  7953. function isKatakana(charCode) {
  7954. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7955. }
  7956. function isHiragana(charCode) {
  7957. return charCode >= 0x3040 && charCode <= 0x309f;
  7958. }
  7959. function isHalfwidthKatakana(charCode) {
  7960. return charCode >= 0xff60 && charCode <= 0xff9f;
  7961. }
  7962. function isThai(charCode) {
  7963. return (charCode & 0xff80) === 0x0e00;
  7964. }
  7965. function getCharacterType(charCode) {
  7966. if (isAlphabeticalScript(charCode)) {
  7967. if (isAscii(charCode)) {
  7968. if (isAsciiSpace(charCode)) {
  7969. return CharacterType.SPACE;
  7970. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7971. return CharacterType.ALPHA_LETTER;
  7972. }
  7973. return CharacterType.PUNCT;
  7974. } else if (isThai(charCode)) {
  7975. return CharacterType.THAI_LETTER;
  7976. } else if (charCode === 0xa0) {
  7977. return CharacterType.SPACE;
  7978. }
  7979. return CharacterType.ALPHA_LETTER;
  7980. }
  7981. if (isHan(charCode)) {
  7982. return CharacterType.HAN_LETTER;
  7983. } else if (isKatakana(charCode)) {
  7984. return CharacterType.KATAKANA_LETTER;
  7985. } else if (isHiragana(charCode)) {
  7986. return CharacterType.HIRAGANA_LETTER;
  7987. } else if (isHalfwidthKatakana(charCode)) {
  7988. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7989. }
  7990. return CharacterType.ALPHA_LETTER;
  7991. }
  7992. let NormalizeWithNFKC;
  7993. function getNormalizeWithNFKC() {
  7994. NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`;
  7995. return NormalizeWithNFKC;
  7996. }
  7997. /***/ }),
  7998. /* 137 */
  7999. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8000. Object.defineProperty(exports, "__esModule", ({
  8001. value: true
  8002. }));
  8003. exports.PDFHistory = void 0;
  8004. exports.isDestArraysEqual = isDestArraysEqual;
  8005. exports.isDestHashesEqual = isDestHashesEqual;
  8006. var _ui_utils = __webpack_require__(97);
  8007. var _event_utils = __webpack_require__(124);
  8008. const HASH_CHANGE_TIMEOUT = 1000;
  8009. const POSITION_UPDATED_THRESHOLD = 50;
  8010. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  8011. function getCurrentHash() {
  8012. return document.location.hash;
  8013. }
  8014. class PDFHistory {
  8015. constructor(_ref) {
  8016. let {
  8017. linkService,
  8018. eventBus
  8019. } = _ref;
  8020. this.linkService = linkService;
  8021. this.eventBus = eventBus;
  8022. this._initialized = false;
  8023. this._fingerprint = "";
  8024. this.reset();
  8025. this._boundEvents = null;
  8026. this.eventBus._on("pagesinit", () => {
  8027. this._isPagesLoaded = false;
  8028. this.eventBus._on("pagesloaded", evt => {
  8029. this._isPagesLoaded = !!evt.pagesCount;
  8030. }, {
  8031. once: true
  8032. });
  8033. });
  8034. }
  8035. initialize(_ref2) {
  8036. let {
  8037. fingerprint,
  8038. resetHistory = false,
  8039. updateUrl = false
  8040. } = _ref2;
  8041. if (!fingerprint || typeof fingerprint !== "string") {
  8042. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  8043. return;
  8044. }
  8045. if (this._initialized) {
  8046. this.reset();
  8047. }
  8048. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  8049. this._fingerprint = fingerprint;
  8050. this._updateUrl = updateUrl === true;
  8051. this._initialized = true;
  8052. this._bindEvents();
  8053. const state = window.history.state;
  8054. this._popStateInProgress = false;
  8055. this._blockHashChange = 0;
  8056. this._currentHash = getCurrentHash();
  8057. this._numPositionUpdates = 0;
  8058. this._uid = this._maxUid = 0;
  8059. this._destination = null;
  8060. this._position = null;
  8061. if (!this._isValidState(state, true) || resetHistory) {
  8062. const {
  8063. hash,
  8064. page,
  8065. rotation
  8066. } = this._parseCurrentHash(true);
  8067. if (!hash || reInitialized || resetHistory) {
  8068. this._pushOrReplaceState(null, true);
  8069. return;
  8070. }
  8071. this._pushOrReplaceState({
  8072. hash,
  8073. page,
  8074. rotation
  8075. }, true);
  8076. return;
  8077. }
  8078. const destination = state.destination;
  8079. this._updateInternalState(destination, state.uid, true);
  8080. if (destination.rotation !== undefined) {
  8081. this._initialRotation = destination.rotation;
  8082. }
  8083. if (destination.dest) {
  8084. this._initialBookmark = JSON.stringify(destination.dest);
  8085. this._destination.page = null;
  8086. } else if (destination.hash) {
  8087. this._initialBookmark = destination.hash;
  8088. } else if (destination.page) {
  8089. this._initialBookmark = `page=${destination.page}`;
  8090. }
  8091. }
  8092. reset() {
  8093. if (this._initialized) {
  8094. this._pageHide();
  8095. this._initialized = false;
  8096. this._unbindEvents();
  8097. }
  8098. if (this._updateViewareaTimeout) {
  8099. clearTimeout(this._updateViewareaTimeout);
  8100. this._updateViewareaTimeout = null;
  8101. }
  8102. this._initialBookmark = null;
  8103. this._initialRotation = null;
  8104. }
  8105. push(_ref3) {
  8106. let {
  8107. namedDest = null,
  8108. explicitDest,
  8109. pageNumber
  8110. } = _ref3;
  8111. if (!this._initialized) {
  8112. return;
  8113. }
  8114. if (namedDest && typeof namedDest !== "string") {
  8115. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  8116. return;
  8117. } else if (!Array.isArray(explicitDest)) {
  8118. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  8119. return;
  8120. } else if (!this._isValidPage(pageNumber)) {
  8121. if (pageNumber !== null || this._destination) {
  8122. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  8123. return;
  8124. }
  8125. }
  8126. const hash = namedDest || JSON.stringify(explicitDest);
  8127. if (!hash) {
  8128. return;
  8129. }
  8130. let forceReplace = false;
  8131. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  8132. if (this._destination.page) {
  8133. return;
  8134. }
  8135. forceReplace = true;
  8136. }
  8137. if (this._popStateInProgress && !forceReplace) {
  8138. return;
  8139. }
  8140. this._pushOrReplaceState({
  8141. dest: explicitDest,
  8142. hash,
  8143. page: pageNumber,
  8144. rotation: this.linkService.rotation
  8145. }, forceReplace);
  8146. if (!this._popStateInProgress) {
  8147. this._popStateInProgress = true;
  8148. Promise.resolve().then(() => {
  8149. this._popStateInProgress = false;
  8150. });
  8151. }
  8152. }
  8153. pushPage(pageNumber) {
  8154. if (!this._initialized) {
  8155. return;
  8156. }
  8157. if (!this._isValidPage(pageNumber)) {
  8158. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  8159. return;
  8160. }
  8161. if (this._destination?.page === pageNumber) {
  8162. return;
  8163. }
  8164. if (this._popStateInProgress) {
  8165. return;
  8166. }
  8167. this._pushOrReplaceState({
  8168. dest: null,
  8169. hash: `page=${pageNumber}`,
  8170. page: pageNumber,
  8171. rotation: this.linkService.rotation
  8172. });
  8173. if (!this._popStateInProgress) {
  8174. this._popStateInProgress = true;
  8175. Promise.resolve().then(() => {
  8176. this._popStateInProgress = false;
  8177. });
  8178. }
  8179. }
  8180. pushCurrentPosition() {
  8181. if (!this._initialized || this._popStateInProgress) {
  8182. return;
  8183. }
  8184. this._tryPushCurrentPosition();
  8185. }
  8186. back() {
  8187. if (!this._initialized || this._popStateInProgress) {
  8188. return;
  8189. }
  8190. const state = window.history.state;
  8191. if (this._isValidState(state) && state.uid > 0) {
  8192. window.history.back();
  8193. }
  8194. }
  8195. forward() {
  8196. if (!this._initialized || this._popStateInProgress) {
  8197. return;
  8198. }
  8199. const state = window.history.state;
  8200. if (this._isValidState(state) && state.uid < this._maxUid) {
  8201. window.history.forward();
  8202. }
  8203. }
  8204. get popStateInProgress() {
  8205. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  8206. }
  8207. get initialBookmark() {
  8208. return this._initialized ? this._initialBookmark : null;
  8209. }
  8210. get initialRotation() {
  8211. return this._initialized ? this._initialRotation : null;
  8212. }
  8213. _pushOrReplaceState(destination) {
  8214. let forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8215. const shouldReplace = forceReplace || !this._destination;
  8216. const newState = {
  8217. fingerprint: this._fingerprint,
  8218. uid: shouldReplace ? this._uid : this._uid + 1,
  8219. destination
  8220. };
  8221. this._updateInternalState(destination, newState.uid);
  8222. let newUrl;
  8223. if (this._updateUrl && destination?.hash) {
  8224. const baseUrl = document.location.href.split("#")[0];
  8225. if (!baseUrl.startsWith("file://")) {
  8226. newUrl = `${baseUrl}#${destination.hash}`;
  8227. }
  8228. }
  8229. if (shouldReplace) {
  8230. window.history.replaceState(newState, "", newUrl);
  8231. } else {
  8232. window.history.pushState(newState, "", newUrl);
  8233. }
  8234. }
  8235. _tryPushCurrentPosition() {
  8236. let temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8237. if (!this._position) {
  8238. return;
  8239. }
  8240. let position = this._position;
  8241. if (temporary) {
  8242. position = Object.assign(Object.create(null), this._position);
  8243. position.temporary = true;
  8244. }
  8245. if (!this._destination) {
  8246. this._pushOrReplaceState(position);
  8247. return;
  8248. }
  8249. if (this._destination.temporary) {
  8250. this._pushOrReplaceState(position, true);
  8251. return;
  8252. }
  8253. if (this._destination.hash === position.hash) {
  8254. return;
  8255. }
  8256. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  8257. return;
  8258. }
  8259. let forceReplace = false;
  8260. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  8261. if (this._destination.dest !== undefined || !this._destination.first) {
  8262. return;
  8263. }
  8264. forceReplace = true;
  8265. }
  8266. this._pushOrReplaceState(position, forceReplace);
  8267. }
  8268. _isValidPage(val) {
  8269. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  8270. }
  8271. _isValidState(state) {
  8272. let checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8273. if (!state) {
  8274. return false;
  8275. }
  8276. if (state.fingerprint !== this._fingerprint) {
  8277. if (checkReload) {
  8278. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  8279. return false;
  8280. }
  8281. const [perfEntry] = performance.getEntriesByType("navigation");
  8282. if (perfEntry?.type !== "reload") {
  8283. return false;
  8284. }
  8285. } else {
  8286. return false;
  8287. }
  8288. }
  8289. if (!Number.isInteger(state.uid) || state.uid < 0) {
  8290. return false;
  8291. }
  8292. if (state.destination === null || typeof state.destination !== "object") {
  8293. return false;
  8294. }
  8295. return true;
  8296. }
  8297. _updateInternalState(destination, uid) {
  8298. let removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8299. if (this._updateViewareaTimeout) {
  8300. clearTimeout(this._updateViewareaTimeout);
  8301. this._updateViewareaTimeout = null;
  8302. }
  8303. if (removeTemporary && destination?.temporary) {
  8304. delete destination.temporary;
  8305. }
  8306. this._destination = destination;
  8307. this._uid = uid;
  8308. this._maxUid = Math.max(this._maxUid, uid);
  8309. this._numPositionUpdates = 0;
  8310. }
  8311. _parseCurrentHash() {
  8312. let checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8313. const hash = unescape(getCurrentHash()).substring(1);
  8314. const params = (0, _ui_utils.parseQueryString)(hash);
  8315. const nameddest = params.get("nameddest") || "";
  8316. let page = params.get("page") | 0;
  8317. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  8318. page = null;
  8319. }
  8320. return {
  8321. hash,
  8322. page,
  8323. rotation: this.linkService.rotation
  8324. };
  8325. }
  8326. _updateViewarea(_ref4) {
  8327. let {
  8328. location
  8329. } = _ref4;
  8330. if (this._updateViewareaTimeout) {
  8331. clearTimeout(this._updateViewareaTimeout);
  8332. this._updateViewareaTimeout = null;
  8333. }
  8334. this._position = {
  8335. hash: location.pdfOpenParams.substring(1),
  8336. page: this.linkService.page,
  8337. first: location.pageNumber,
  8338. rotation: location.rotation
  8339. };
  8340. if (this._popStateInProgress) {
  8341. return;
  8342. }
  8343. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  8344. this._numPositionUpdates++;
  8345. }
  8346. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  8347. this._updateViewareaTimeout = setTimeout(() => {
  8348. if (!this._popStateInProgress) {
  8349. this._tryPushCurrentPosition(true);
  8350. }
  8351. this._updateViewareaTimeout = null;
  8352. }, UPDATE_VIEWAREA_TIMEOUT);
  8353. }
  8354. }
  8355. _popState(_ref5) {
  8356. let {
  8357. state
  8358. } = _ref5;
  8359. const newHash = getCurrentHash(),
  8360. hashChanged = this._currentHash !== newHash;
  8361. this._currentHash = newHash;
  8362. if (!state) {
  8363. this._uid++;
  8364. const {
  8365. hash,
  8366. page,
  8367. rotation
  8368. } = this._parseCurrentHash();
  8369. this._pushOrReplaceState({
  8370. hash,
  8371. page,
  8372. rotation
  8373. }, true);
  8374. return;
  8375. }
  8376. if (!this._isValidState(state)) {
  8377. return;
  8378. }
  8379. this._popStateInProgress = true;
  8380. if (hashChanged) {
  8381. this._blockHashChange++;
  8382. (0, _event_utils.waitOnEventOrTimeout)({
  8383. target: window,
  8384. name: "hashchange",
  8385. delay: HASH_CHANGE_TIMEOUT
  8386. }).then(() => {
  8387. this._blockHashChange--;
  8388. });
  8389. }
  8390. const destination = state.destination;
  8391. this._updateInternalState(destination, state.uid, true);
  8392. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  8393. this.linkService.rotation = destination.rotation;
  8394. }
  8395. if (destination.dest) {
  8396. this.linkService.goToDestination(destination.dest);
  8397. } else if (destination.hash) {
  8398. this.linkService.setHash(destination.hash);
  8399. } else if (destination.page) {
  8400. this.linkService.page = destination.page;
  8401. }
  8402. Promise.resolve().then(() => {
  8403. this._popStateInProgress = false;
  8404. });
  8405. }
  8406. _pageHide() {
  8407. if (!this._destination || this._destination.temporary) {
  8408. this._tryPushCurrentPosition();
  8409. }
  8410. }
  8411. _bindEvents() {
  8412. if (this._boundEvents) {
  8413. return;
  8414. }
  8415. this._boundEvents = {
  8416. updateViewarea: this._updateViewarea.bind(this),
  8417. popState: this._popState.bind(this),
  8418. pageHide: this._pageHide.bind(this)
  8419. };
  8420. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  8421. window.addEventListener("popstate", this._boundEvents.popState);
  8422. window.addEventListener("pagehide", this._boundEvents.pageHide);
  8423. }
  8424. _unbindEvents() {
  8425. if (!this._boundEvents) {
  8426. return;
  8427. }
  8428. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  8429. window.removeEventListener("popstate", this._boundEvents.popState);
  8430. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  8431. this._boundEvents = null;
  8432. }
  8433. }
  8434. exports.PDFHistory = PDFHistory;
  8435. function isDestHashesEqual(destHash, pushHash) {
  8436. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  8437. return false;
  8438. }
  8439. if (destHash === pushHash) {
  8440. return true;
  8441. }
  8442. const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  8443. if (nameddest === pushHash) {
  8444. return true;
  8445. }
  8446. return false;
  8447. }
  8448. function isDestArraysEqual(firstDest, secondDest) {
  8449. function isEntryEqual(first, second) {
  8450. if (typeof first !== typeof second) {
  8451. return false;
  8452. }
  8453. if (Array.isArray(first) || Array.isArray(second)) {
  8454. return false;
  8455. }
  8456. if (first !== null && typeof first === "object" && second !== null) {
  8457. if (Object.keys(first).length !== Object.keys(second).length) {
  8458. return false;
  8459. }
  8460. for (const key in first) {
  8461. if (!isEntryEqual(first[key], second[key])) {
  8462. return false;
  8463. }
  8464. }
  8465. return true;
  8466. }
  8467. return first === second || Number.isNaN(first) && Number.isNaN(second);
  8468. }
  8469. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  8470. return false;
  8471. }
  8472. if (firstDest.length !== secondDest.length) {
  8473. return false;
  8474. }
  8475. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  8476. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  8477. return false;
  8478. }
  8479. }
  8480. return true;
  8481. }
  8482. /***/ }),
  8483. /* 138 */
  8484. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8485. Object.defineProperty(exports, "__esModule", ({
  8486. value: true
  8487. }));
  8488. exports.PDFLayerViewer = void 0;
  8489. __webpack_require__(89);
  8490. var _base_tree_viewer = __webpack_require__(130);
  8491. class PDFLayerViewer extends _base_tree_viewer.BaseTreeViewer {
  8492. constructor(options) {
  8493. super(options);
  8494. this.l10n = options.l10n;
  8495. this.eventBus._on("optionalcontentconfigchanged", evt => {
  8496. this.#updateLayers(evt.promise);
  8497. });
  8498. this.eventBus._on("resetlayers", () => {
  8499. this.#updateLayers();
  8500. });
  8501. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  8502. }
  8503. reset() {
  8504. super.reset();
  8505. this._optionalContentConfig = null;
  8506. this._optionalContentHash = null;
  8507. }
  8508. _dispatchEvent(layersCount) {
  8509. this.eventBus.dispatch("layersloaded", {
  8510. source: this,
  8511. layersCount
  8512. });
  8513. }
  8514. _bindLink(element, _ref) {
  8515. let {
  8516. groupId,
  8517. input
  8518. } = _ref;
  8519. const setVisibility = () => {
  8520. this._optionalContentConfig.setVisibility(groupId, input.checked);
  8521. this._optionalContentHash = this._optionalContentConfig.getHash();
  8522. this.eventBus.dispatch("optionalcontentconfig", {
  8523. source: this,
  8524. promise: Promise.resolve(this._optionalContentConfig)
  8525. });
  8526. };
  8527. element.onclick = evt => {
  8528. if (evt.target === input) {
  8529. setVisibility();
  8530. return true;
  8531. } else if (evt.target !== element) {
  8532. return true;
  8533. }
  8534. input.checked = !input.checked;
  8535. setVisibility();
  8536. return false;
  8537. };
  8538. }
  8539. async _setNestedName(element, _ref2) {
  8540. let {
  8541. name = null
  8542. } = _ref2;
  8543. if (typeof name === "string") {
  8544. element.textContent = this._normalizeTextContent(name);
  8545. return;
  8546. }
  8547. element.textContent = await this.l10n.get("additional_layers");
  8548. element.style.fontStyle = "italic";
  8549. }
  8550. _addToggleButton(div, _ref3) {
  8551. let {
  8552. name = null
  8553. } = _ref3;
  8554. super._addToggleButton(div, name === null);
  8555. }
  8556. _toggleAllTreeItems() {
  8557. if (!this._optionalContentConfig) {
  8558. return;
  8559. }
  8560. super._toggleAllTreeItems();
  8561. }
  8562. render(_ref4) {
  8563. let {
  8564. optionalContentConfig,
  8565. pdfDocument
  8566. } = _ref4;
  8567. if (this._optionalContentConfig) {
  8568. this.reset();
  8569. }
  8570. this._optionalContentConfig = optionalContentConfig || null;
  8571. this._pdfDocument = pdfDocument || null;
  8572. const groups = optionalContentConfig?.getOrder();
  8573. if (!groups) {
  8574. this._dispatchEvent(0);
  8575. return;
  8576. }
  8577. this._optionalContentHash = optionalContentConfig.getHash();
  8578. const fragment = document.createDocumentFragment(),
  8579. queue = [{
  8580. parent: fragment,
  8581. groups
  8582. }];
  8583. let layersCount = 0,
  8584. hasAnyNesting = false;
  8585. while (queue.length > 0) {
  8586. const levelData = queue.shift();
  8587. for (const groupId of levelData.groups) {
  8588. const div = document.createElement("div");
  8589. div.className = "treeItem";
  8590. const element = document.createElement("a");
  8591. div.append(element);
  8592. if (typeof groupId === "object") {
  8593. hasAnyNesting = true;
  8594. this._addToggleButton(div, groupId);
  8595. this._setNestedName(element, groupId);
  8596. const itemsDiv = document.createElement("div");
  8597. itemsDiv.className = "treeItems";
  8598. div.append(itemsDiv);
  8599. queue.push({
  8600. parent: itemsDiv,
  8601. groups: groupId.order
  8602. });
  8603. } else {
  8604. const group = optionalContentConfig.getGroup(groupId);
  8605. const input = document.createElement("input");
  8606. this._bindLink(element, {
  8607. groupId,
  8608. input
  8609. });
  8610. input.type = "checkbox";
  8611. input.checked = group.visible;
  8612. const label = document.createElement("label");
  8613. label.textContent = this._normalizeTextContent(group.name);
  8614. label.append(input);
  8615. element.append(label);
  8616. layersCount++;
  8617. }
  8618. levelData.parent.append(div);
  8619. }
  8620. }
  8621. this._finishRendering(fragment, layersCount, hasAnyNesting);
  8622. }
  8623. async #updateLayers() {
  8624. let promise = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8625. if (!this._optionalContentConfig) {
  8626. return;
  8627. }
  8628. const pdfDocument = this._pdfDocument;
  8629. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig());
  8630. if (pdfDocument !== this._pdfDocument) {
  8631. return;
  8632. }
  8633. if (promise) {
  8634. if (optionalContentConfig.getHash() === this._optionalContentHash) {
  8635. return;
  8636. }
  8637. } else {
  8638. this.eventBus.dispatch("optionalcontentconfig", {
  8639. source: this,
  8640. promise: Promise.resolve(optionalContentConfig)
  8641. });
  8642. }
  8643. this.render({
  8644. optionalContentConfig,
  8645. pdfDocument: this._pdfDocument
  8646. });
  8647. }
  8648. }
  8649. exports.PDFLayerViewer = PDFLayerViewer;
  8650. /***/ }),
  8651. /* 139 */
  8652. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8653. Object.defineProperty(exports, "__esModule", ({
  8654. value: true
  8655. }));
  8656. exports.PDFOutlineViewer = void 0;
  8657. __webpack_require__(89);
  8658. __webpack_require__(76);
  8659. var _base_tree_viewer = __webpack_require__(130);
  8660. var _pdfjsLib = __webpack_require__(122);
  8661. var _ui_utils = __webpack_require__(97);
  8662. class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
  8663. constructor(options) {
  8664. super(options);
  8665. this.linkService = options.linkService;
  8666. this.downloadManager = options.downloadManager;
  8667. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  8668. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  8669. this.eventBus._on("pagechanging", evt => {
  8670. this._currentPageNumber = evt.pageNumber;
  8671. });
  8672. this.eventBus._on("pagesloaded", evt => {
  8673. this._isPagesLoaded = !!evt.pagesCount;
  8674. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8675. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8676. }
  8677. });
  8678. this.eventBus._on("sidebarviewchanged", evt => {
  8679. this._sidebarView = evt.view;
  8680. });
  8681. }
  8682. reset() {
  8683. super.reset();
  8684. this._outline = null;
  8685. this._pageNumberToDestHashCapability = null;
  8686. this._currentPageNumber = 1;
  8687. this._isPagesLoaded = null;
  8688. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8689. this._currentOutlineItemCapability.resolve(false);
  8690. }
  8691. this._currentOutlineItemCapability = null;
  8692. }
  8693. _dispatchEvent(outlineCount) {
  8694. this._currentOutlineItemCapability = new _pdfjsLib.PromiseCapability();
  8695. if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
  8696. this._currentOutlineItemCapability.resolve(false);
  8697. } else if (this._isPagesLoaded !== null) {
  8698. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8699. }
  8700. this.eventBus.dispatch("outlineloaded", {
  8701. source: this,
  8702. outlineCount,
  8703. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  8704. });
  8705. }
  8706. _bindLink(element, _ref) {
  8707. let {
  8708. url,
  8709. newWindow,
  8710. action,
  8711. attachment,
  8712. dest,
  8713. setOCGState
  8714. } = _ref;
  8715. const {
  8716. linkService
  8717. } = this;
  8718. if (url) {
  8719. linkService.addLinkAttributes(element, url, newWindow);
  8720. return;
  8721. }
  8722. if (action) {
  8723. element.href = linkService.getAnchorUrl("");
  8724. element.onclick = () => {
  8725. linkService.executeNamedAction(action);
  8726. return false;
  8727. };
  8728. return;
  8729. }
  8730. if (attachment) {
  8731. element.href = linkService.getAnchorUrl("");
  8732. element.onclick = () => {
  8733. this.downloadManager.openOrDownloadData(element, attachment.content, attachment.filename);
  8734. return false;
  8735. };
  8736. return;
  8737. }
  8738. if (setOCGState) {
  8739. element.href = linkService.getAnchorUrl("");
  8740. element.onclick = () => {
  8741. linkService.executeSetOCGState(setOCGState);
  8742. return false;
  8743. };
  8744. return;
  8745. }
  8746. element.href = linkService.getDestinationHash(dest);
  8747. element.onclick = evt => {
  8748. this._updateCurrentTreeItem(evt.target.parentNode);
  8749. if (dest) {
  8750. linkService.goToDestination(dest);
  8751. }
  8752. return false;
  8753. };
  8754. }
  8755. _setStyles(element, _ref2) {
  8756. let {
  8757. bold,
  8758. italic
  8759. } = _ref2;
  8760. if (bold) {
  8761. element.style.fontWeight = "bold";
  8762. }
  8763. if (italic) {
  8764. element.style.fontStyle = "italic";
  8765. }
  8766. }
  8767. _addToggleButton(div, _ref3) {
  8768. let {
  8769. count,
  8770. items
  8771. } = _ref3;
  8772. let hidden = false;
  8773. if (count < 0) {
  8774. let totalCount = items.length;
  8775. if (totalCount > 0) {
  8776. const queue = [...items];
  8777. while (queue.length > 0) {
  8778. const {
  8779. count: nestedCount,
  8780. items: nestedItems
  8781. } = queue.shift();
  8782. if (nestedCount > 0 && nestedItems.length > 0) {
  8783. totalCount += nestedItems.length;
  8784. queue.push(...nestedItems);
  8785. }
  8786. }
  8787. }
  8788. if (Math.abs(count) === totalCount) {
  8789. hidden = true;
  8790. }
  8791. }
  8792. super._addToggleButton(div, hidden);
  8793. }
  8794. _toggleAllTreeItems() {
  8795. if (!this._outline) {
  8796. return;
  8797. }
  8798. super._toggleAllTreeItems();
  8799. }
  8800. render(_ref4) {
  8801. let {
  8802. outline,
  8803. pdfDocument
  8804. } = _ref4;
  8805. if (this._outline) {
  8806. this.reset();
  8807. }
  8808. this._outline = outline || null;
  8809. this._pdfDocument = pdfDocument || null;
  8810. if (!outline) {
  8811. this._dispatchEvent(0);
  8812. return;
  8813. }
  8814. const fragment = document.createDocumentFragment();
  8815. const queue = [{
  8816. parent: fragment,
  8817. items: outline
  8818. }];
  8819. let outlineCount = 0,
  8820. hasAnyNesting = false;
  8821. while (queue.length > 0) {
  8822. const levelData = queue.shift();
  8823. for (const item of levelData.items) {
  8824. const div = document.createElement("div");
  8825. div.className = "treeItem";
  8826. const element = document.createElement("a");
  8827. this._bindLink(element, item);
  8828. this._setStyles(element, item);
  8829. element.textContent = this._normalizeTextContent(item.title);
  8830. div.append(element);
  8831. if (item.items.length > 0) {
  8832. hasAnyNesting = true;
  8833. this._addToggleButton(div, item);
  8834. const itemsDiv = document.createElement("div");
  8835. itemsDiv.className = "treeItems";
  8836. div.append(itemsDiv);
  8837. queue.push({
  8838. parent: itemsDiv,
  8839. items: item.items
  8840. });
  8841. }
  8842. levelData.parent.append(div);
  8843. outlineCount++;
  8844. }
  8845. }
  8846. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8847. }
  8848. async _currentOutlineItem() {
  8849. if (!this._isPagesLoaded) {
  8850. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8851. }
  8852. if (!this._outline || !this._pdfDocument) {
  8853. return;
  8854. }
  8855. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  8856. if (!pageNumberToDestHash) {
  8857. return;
  8858. }
  8859. this._updateCurrentTreeItem(null);
  8860. if (this._sidebarView !== _ui_utils.SidebarView.OUTLINE) {
  8861. return;
  8862. }
  8863. for (let i = this._currentPageNumber; i > 0; i--) {
  8864. const destHash = pageNumberToDestHash.get(i);
  8865. if (!destHash) {
  8866. continue;
  8867. }
  8868. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  8869. if (!linkElement) {
  8870. continue;
  8871. }
  8872. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8873. break;
  8874. }
  8875. }
  8876. async _getPageNumberToDestHash(pdfDocument) {
  8877. if (this._pageNumberToDestHashCapability) {
  8878. return this._pageNumberToDestHashCapability.promise;
  8879. }
  8880. this._pageNumberToDestHashCapability = new _pdfjsLib.PromiseCapability();
  8881. const pageNumberToDestHash = new Map(),
  8882. pageNumberNesting = new Map();
  8883. const queue = [{
  8884. nesting: 0,
  8885. items: this._outline
  8886. }];
  8887. while (queue.length > 0) {
  8888. const levelData = queue.shift(),
  8889. currentNesting = levelData.nesting;
  8890. for (const {
  8891. dest,
  8892. items
  8893. } of levelData.items) {
  8894. let explicitDest, pageNumber;
  8895. if (typeof dest === "string") {
  8896. explicitDest = await pdfDocument.getDestination(dest);
  8897. if (pdfDocument !== this._pdfDocument) {
  8898. return null;
  8899. }
  8900. } else {
  8901. explicitDest = dest;
  8902. }
  8903. if (Array.isArray(explicitDest)) {
  8904. const [destRef] = explicitDest;
  8905. if (typeof destRef === "object" && destRef !== null) {
  8906. pageNumber = this.linkService._cachedPageNumber(destRef);
  8907. if (!pageNumber) {
  8908. try {
  8909. pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
  8910. if (pdfDocument !== this._pdfDocument) {
  8911. return null;
  8912. }
  8913. this.linkService.cachePageRef(pageNumber, destRef);
  8914. } catch {}
  8915. }
  8916. } else if (Number.isInteger(destRef)) {
  8917. pageNumber = destRef + 1;
  8918. }
  8919. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8920. const destHash = this.linkService.getDestinationHash(dest);
  8921. pageNumberToDestHash.set(pageNumber, destHash);
  8922. pageNumberNesting.set(pageNumber, currentNesting);
  8923. }
  8924. }
  8925. if (items.length > 0) {
  8926. queue.push({
  8927. nesting: currentNesting + 1,
  8928. items
  8929. });
  8930. }
  8931. }
  8932. }
  8933. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8934. return this._pageNumberToDestHashCapability.promise;
  8935. }
  8936. }
  8937. exports.PDFOutlineViewer = PDFOutlineViewer;
  8938. /***/ }),
  8939. /* 140 */
  8940. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8941. Object.defineProperty(exports, "__esModule", ({
  8942. value: true
  8943. }));
  8944. exports.PDFPresentationMode = void 0;
  8945. var _ui_utils = __webpack_require__(97);
  8946. var _pdfjsLib = __webpack_require__(122);
  8947. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8948. const ACTIVE_SELECTOR = "pdfPresentationMode";
  8949. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8950. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8951. const PAGE_SWITCH_THRESHOLD = 0.1;
  8952. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8953. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8954. class PDFPresentationMode {
  8955. #state = _ui_utils.PresentationModeState.UNKNOWN;
  8956. #args = null;
  8957. constructor(_ref) {
  8958. let {
  8959. container,
  8960. pdfViewer,
  8961. eventBus
  8962. } = _ref;
  8963. this.container = container;
  8964. this.pdfViewer = pdfViewer;
  8965. this.eventBus = eventBus;
  8966. this.contextMenuOpen = false;
  8967. this.mouseScrollTimeStamp = 0;
  8968. this.mouseScrollDelta = 0;
  8969. this.touchSwipeState = null;
  8970. }
  8971. async request() {
  8972. const {
  8973. container,
  8974. pdfViewer
  8975. } = this;
  8976. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  8977. return false;
  8978. }
  8979. this.#addFullscreenChangeListeners();
  8980. this.#notifyStateChange(_ui_utils.PresentationModeState.CHANGING);
  8981. const promise = container.requestFullscreen();
  8982. this.#args = {
  8983. pageNumber: pdfViewer.currentPageNumber,
  8984. scaleValue: pdfViewer.currentScaleValue,
  8985. scrollMode: pdfViewer.scrollMode,
  8986. spreadMode: null,
  8987. annotationEditorMode: null
  8988. };
  8989. if (pdfViewer.spreadMode !== _ui_utils.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  8990. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  8991. this.#args.spreadMode = pdfViewer.spreadMode;
  8992. }
  8993. if (pdfViewer.annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  8994. this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
  8995. }
  8996. try {
  8997. await promise;
  8998. pdfViewer.focus();
  8999. return true;
  9000. } catch {
  9001. this.#removeFullscreenChangeListeners();
  9002. this.#notifyStateChange(_ui_utils.PresentationModeState.NORMAL);
  9003. }
  9004. return false;
  9005. }
  9006. get active() {
  9007. return this.#state === _ui_utils.PresentationModeState.CHANGING || this.#state === _ui_utils.PresentationModeState.FULLSCREEN;
  9008. }
  9009. #mouseWheel(evt) {
  9010. if (!this.active) {
  9011. return;
  9012. }
  9013. evt.preventDefault();
  9014. const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  9015. const currentTime = Date.now();
  9016. const storedTime = this.mouseScrollTimeStamp;
  9017. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9018. return;
  9019. }
  9020. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9021. this.#resetMouseScrollState();
  9022. }
  9023. this.mouseScrollDelta += delta;
  9024. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9025. const totalDelta = this.mouseScrollDelta;
  9026. this.#resetMouseScrollState();
  9027. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9028. if (success) {
  9029. this.mouseScrollTimeStamp = currentTime;
  9030. }
  9031. }
  9032. }
  9033. #notifyStateChange(state) {
  9034. this.#state = state;
  9035. this.eventBus.dispatch("presentationmodechanged", {
  9036. source: this,
  9037. state
  9038. });
  9039. }
  9040. #enter() {
  9041. this.#notifyStateChange(_ui_utils.PresentationModeState.FULLSCREEN);
  9042. this.container.classList.add(ACTIVE_SELECTOR);
  9043. setTimeout(() => {
  9044. this.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  9045. if (this.#args.spreadMode !== null) {
  9046. this.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  9047. }
  9048. this.pdfViewer.currentPageNumber = this.#args.pageNumber;
  9049. this.pdfViewer.currentScaleValue = "page-fit";
  9050. if (this.#args.annotationEditorMode !== null) {
  9051. this.pdfViewer.annotationEditorMode = {
  9052. mode: _pdfjsLib.AnnotationEditorType.NONE
  9053. };
  9054. }
  9055. }, 0);
  9056. this.#addWindowListeners();
  9057. this.#showControls();
  9058. this.contextMenuOpen = false;
  9059. window.getSelection().removeAllRanges();
  9060. }
  9061. #exit() {
  9062. const pageNumber = this.pdfViewer.currentPageNumber;
  9063. this.container.classList.remove(ACTIVE_SELECTOR);
  9064. setTimeout(() => {
  9065. this.#removeFullscreenChangeListeners();
  9066. this.#notifyStateChange(_ui_utils.PresentationModeState.NORMAL);
  9067. this.pdfViewer.scrollMode = this.#args.scrollMode;
  9068. if (this.#args.spreadMode !== null) {
  9069. this.pdfViewer.spreadMode = this.#args.spreadMode;
  9070. }
  9071. this.pdfViewer.currentScaleValue = this.#args.scaleValue;
  9072. this.pdfViewer.currentPageNumber = pageNumber;
  9073. if (this.#args.annotationEditorMode !== null) {
  9074. this.pdfViewer.annotationEditorMode = {
  9075. mode: this.#args.annotationEditorMode
  9076. };
  9077. }
  9078. this.#args = null;
  9079. }, 0);
  9080. this.#removeWindowListeners();
  9081. this.#hideControls();
  9082. this.#resetMouseScrollState();
  9083. this.contextMenuOpen = false;
  9084. }
  9085. #mouseDown(evt) {
  9086. if (this.contextMenuOpen) {
  9087. this.contextMenuOpen = false;
  9088. evt.preventDefault();
  9089. return;
  9090. }
  9091. if (evt.button !== 0) {
  9092. return;
  9093. }
  9094. if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
  9095. return;
  9096. }
  9097. evt.preventDefault();
  9098. if (evt.shiftKey) {
  9099. this.pdfViewer.previousPage();
  9100. } else {
  9101. this.pdfViewer.nextPage();
  9102. }
  9103. }
  9104. #contextMenu() {
  9105. this.contextMenuOpen = true;
  9106. }
  9107. #showControls() {
  9108. if (this.controlsTimeout) {
  9109. clearTimeout(this.controlsTimeout);
  9110. } else {
  9111. this.container.classList.add(CONTROLS_SELECTOR);
  9112. }
  9113. this.controlsTimeout = setTimeout(() => {
  9114. this.container.classList.remove(CONTROLS_SELECTOR);
  9115. delete this.controlsTimeout;
  9116. }, DELAY_BEFORE_HIDING_CONTROLS);
  9117. }
  9118. #hideControls() {
  9119. if (!this.controlsTimeout) {
  9120. return;
  9121. }
  9122. clearTimeout(this.controlsTimeout);
  9123. this.container.classList.remove(CONTROLS_SELECTOR);
  9124. delete this.controlsTimeout;
  9125. }
  9126. #resetMouseScrollState() {
  9127. this.mouseScrollTimeStamp = 0;
  9128. this.mouseScrollDelta = 0;
  9129. }
  9130. #touchSwipe(evt) {
  9131. if (!this.active) {
  9132. return;
  9133. }
  9134. if (evt.touches.length > 1) {
  9135. this.touchSwipeState = null;
  9136. return;
  9137. }
  9138. switch (evt.type) {
  9139. case "touchstart":
  9140. this.touchSwipeState = {
  9141. startX: evt.touches[0].pageX,
  9142. startY: evt.touches[0].pageY,
  9143. endX: evt.touches[0].pageX,
  9144. endY: evt.touches[0].pageY
  9145. };
  9146. break;
  9147. case "touchmove":
  9148. if (this.touchSwipeState === null) {
  9149. return;
  9150. }
  9151. this.touchSwipeState.endX = evt.touches[0].pageX;
  9152. this.touchSwipeState.endY = evt.touches[0].pageY;
  9153. evt.preventDefault();
  9154. break;
  9155. case "touchend":
  9156. if (this.touchSwipeState === null) {
  9157. return;
  9158. }
  9159. let delta = 0;
  9160. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9161. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9162. const absAngle = Math.abs(Math.atan2(dy, dx));
  9163. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9164. delta = dx;
  9165. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9166. delta = dy;
  9167. }
  9168. if (delta > 0) {
  9169. this.pdfViewer.previousPage();
  9170. } else if (delta < 0) {
  9171. this.pdfViewer.nextPage();
  9172. }
  9173. break;
  9174. }
  9175. }
  9176. #addWindowListeners() {
  9177. this.showControlsBind = this.#showControls.bind(this);
  9178. this.mouseDownBind = this.#mouseDown.bind(this);
  9179. this.mouseWheelBind = this.#mouseWheel.bind(this);
  9180. this.resetMouseScrollStateBind = this.#resetMouseScrollState.bind(this);
  9181. this.contextMenuBind = this.#contextMenu.bind(this);
  9182. this.touchSwipeBind = this.#touchSwipe.bind(this);
  9183. window.addEventListener("mousemove", this.showControlsBind);
  9184. window.addEventListener("mousedown", this.mouseDownBind);
  9185. window.addEventListener("wheel", this.mouseWheelBind, {
  9186. passive: false
  9187. });
  9188. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9189. window.addEventListener("contextmenu", this.contextMenuBind);
  9190. window.addEventListener("touchstart", this.touchSwipeBind);
  9191. window.addEventListener("touchmove", this.touchSwipeBind);
  9192. window.addEventListener("touchend", this.touchSwipeBind);
  9193. }
  9194. #removeWindowListeners() {
  9195. window.removeEventListener("mousemove", this.showControlsBind);
  9196. window.removeEventListener("mousedown", this.mouseDownBind);
  9197. window.removeEventListener("wheel", this.mouseWheelBind, {
  9198. passive: false
  9199. });
  9200. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9201. window.removeEventListener("contextmenu", this.contextMenuBind);
  9202. window.removeEventListener("touchstart", this.touchSwipeBind);
  9203. window.removeEventListener("touchmove", this.touchSwipeBind);
  9204. window.removeEventListener("touchend", this.touchSwipeBind);
  9205. delete this.showControlsBind;
  9206. delete this.mouseDownBind;
  9207. delete this.mouseWheelBind;
  9208. delete this.resetMouseScrollStateBind;
  9209. delete this.contextMenuBind;
  9210. delete this.touchSwipeBind;
  9211. }
  9212. #fullscreenChange() {
  9213. if (document.fullscreenElement) {
  9214. this.#enter();
  9215. } else {
  9216. this.#exit();
  9217. }
  9218. }
  9219. #addFullscreenChangeListeners() {
  9220. this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
  9221. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9222. }
  9223. #removeFullscreenChangeListeners() {
  9224. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9225. delete this.fullscreenChangeBind;
  9226. }
  9227. }
  9228. exports.PDFPresentationMode = PDFPresentationMode;
  9229. /***/ }),
  9230. /* 141 */
  9231. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9232. Object.defineProperty(exports, "__esModule", ({
  9233. value: true
  9234. }));
  9235. exports.PDFRenderingQueue = void 0;
  9236. var _pdfjsLib = __webpack_require__(122);
  9237. var _ui_utils = __webpack_require__(97);
  9238. const CLEANUP_TIMEOUT = 30000;
  9239. class PDFRenderingQueue {
  9240. constructor() {
  9241. this.pdfViewer = null;
  9242. this.pdfThumbnailViewer = null;
  9243. this.onIdle = null;
  9244. this.highestPriorityPage = null;
  9245. this.idleTimeout = null;
  9246. this.printing = false;
  9247. this.isThumbnailViewEnabled = false;
  9248. Object.defineProperty(this, "hasViewer", {
  9249. value: () => !!this.pdfViewer
  9250. });
  9251. }
  9252. setViewer(pdfViewer) {
  9253. this.pdfViewer = pdfViewer;
  9254. }
  9255. setThumbnailViewer(pdfThumbnailViewer) {
  9256. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9257. }
  9258. isHighestPriority(view) {
  9259. return this.highestPriorityPage === view.renderingId;
  9260. }
  9261. renderHighestPriority(currentlyVisiblePages) {
  9262. if (this.idleTimeout) {
  9263. clearTimeout(this.idleTimeout);
  9264. this.idleTimeout = null;
  9265. }
  9266. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  9267. return;
  9268. }
  9269. if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
  9270. return;
  9271. }
  9272. if (this.printing) {
  9273. return;
  9274. }
  9275. if (this.onIdle) {
  9276. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  9277. }
  9278. }
  9279. getHighestPriority(visible, views, scrolledDown) {
  9280. let preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9281. const visibleViews = visible.views,
  9282. numVisible = visibleViews.length;
  9283. if (numVisible === 0) {
  9284. return null;
  9285. }
  9286. for (let i = 0; i < numVisible; i++) {
  9287. const view = visibleViews[i].view;
  9288. if (!this.isViewFinished(view)) {
  9289. return view;
  9290. }
  9291. }
  9292. const firstId = visible.first.id,
  9293. lastId = visible.last.id;
  9294. if (lastId - firstId + 1 > numVisible) {
  9295. const visibleIds = visible.ids;
  9296. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  9297. const holeId = scrolledDown ? firstId + i : lastId - i;
  9298. if (visibleIds.has(holeId)) {
  9299. continue;
  9300. }
  9301. const holeView = views[holeId - 1];
  9302. if (!this.isViewFinished(holeView)) {
  9303. return holeView;
  9304. }
  9305. }
  9306. }
  9307. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  9308. let preRenderView = views[preRenderIndex];
  9309. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9310. return preRenderView;
  9311. }
  9312. if (preRenderExtra) {
  9313. preRenderIndex += scrolledDown ? 1 : -1;
  9314. preRenderView = views[preRenderIndex];
  9315. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9316. return preRenderView;
  9317. }
  9318. }
  9319. return null;
  9320. }
  9321. isViewFinished(view) {
  9322. return view.renderingState === _ui_utils.RenderingStates.FINISHED;
  9323. }
  9324. renderView(view) {
  9325. switch (view.renderingState) {
  9326. case _ui_utils.RenderingStates.FINISHED:
  9327. return false;
  9328. case _ui_utils.RenderingStates.PAUSED:
  9329. this.highestPriorityPage = view.renderingId;
  9330. view.resume();
  9331. break;
  9332. case _ui_utils.RenderingStates.RUNNING:
  9333. this.highestPriorityPage = view.renderingId;
  9334. break;
  9335. case _ui_utils.RenderingStates.INITIAL:
  9336. this.highestPriorityPage = view.renderingId;
  9337. view.draw().finally(() => {
  9338. this.renderHighestPriority();
  9339. }).catch(reason => {
  9340. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  9341. return;
  9342. }
  9343. console.error(`renderView: "${reason}"`);
  9344. });
  9345. break;
  9346. }
  9347. return true;
  9348. }
  9349. }
  9350. exports.PDFRenderingQueue = PDFRenderingQueue;
  9351. /***/ }),
  9352. /* 142 */
  9353. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9354. Object.defineProperty(exports, "__esModule", ({
  9355. value: true
  9356. }));
  9357. exports.PDFScriptingManager = void 0;
  9358. __webpack_require__(98);
  9359. __webpack_require__(109);
  9360. __webpack_require__(111);
  9361. __webpack_require__(114);
  9362. __webpack_require__(116);
  9363. __webpack_require__(118);
  9364. __webpack_require__(120);
  9365. __webpack_require__(76);
  9366. var _ui_utils = __webpack_require__(97);
  9367. var _pdfjsLib = __webpack_require__(122);
  9368. class PDFScriptingManager {
  9369. #closeCapability = null;
  9370. #destroyCapability = null;
  9371. #docProperties = null;
  9372. #eventBus = null;
  9373. #externalServices = null;
  9374. #pdfDocument = null;
  9375. #pdfViewer = null;
  9376. #ready = false;
  9377. #sandboxBundleSrc = null;
  9378. #scripting = null;
  9379. #willPrintCapability = null;
  9380. constructor(_ref) {
  9381. let {
  9382. eventBus,
  9383. sandboxBundleSrc = null,
  9384. externalServices = null,
  9385. docProperties = null
  9386. } = _ref;
  9387. this.#eventBus = eventBus;
  9388. this.#sandboxBundleSrc = sandboxBundleSrc;
  9389. this.#externalServices = externalServices;
  9390. this.#docProperties = docProperties;
  9391. }
  9392. setViewer(pdfViewer) {
  9393. this.#pdfViewer = pdfViewer;
  9394. }
  9395. async setDocument(pdfDocument) {
  9396. if (this.#pdfDocument) {
  9397. await this.#destroyScripting();
  9398. }
  9399. this.#pdfDocument = pdfDocument;
  9400. if (!pdfDocument) {
  9401. return;
  9402. }
  9403. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  9404. if (!objects && !docActions) {
  9405. await this.#destroyScripting();
  9406. return;
  9407. }
  9408. if (pdfDocument !== this.#pdfDocument) {
  9409. return;
  9410. }
  9411. try {
  9412. this.#scripting = this.#initScripting();
  9413. } catch (error) {
  9414. console.error(`setDocument: "${error.message}".`);
  9415. await this.#destroyScripting();
  9416. return;
  9417. }
  9418. this._internalEvents.set("updatefromsandbox", event => {
  9419. if (event?.source === window) {
  9420. this.#updateFromSandbox(event.detail);
  9421. }
  9422. });
  9423. this._internalEvents.set("dispatcheventinsandbox", event => {
  9424. this.#scripting?.dispatchEventInSandbox(event.detail);
  9425. });
  9426. this._internalEvents.set("pagechanging", _ref2 => {
  9427. let {
  9428. pageNumber,
  9429. previous
  9430. } = _ref2;
  9431. if (pageNumber === previous) {
  9432. return;
  9433. }
  9434. this.#dispatchPageClose(previous);
  9435. this.#dispatchPageOpen(pageNumber);
  9436. });
  9437. this._internalEvents.set("pagerendered", _ref3 => {
  9438. let {
  9439. pageNumber
  9440. } = _ref3;
  9441. if (!this._pageOpenPending.has(pageNumber)) {
  9442. return;
  9443. }
  9444. if (pageNumber !== this.#pdfViewer.currentPageNumber) {
  9445. return;
  9446. }
  9447. this.#dispatchPageOpen(pageNumber);
  9448. });
  9449. this._internalEvents.set("pagesdestroy", async () => {
  9450. await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
  9451. await this.#scripting?.dispatchEventInSandbox({
  9452. id: "doc",
  9453. name: "WillClose"
  9454. });
  9455. this.#closeCapability?.resolve();
  9456. });
  9457. for (const [name, listener] of this._internalEvents) {
  9458. this.#eventBus._on(name, listener);
  9459. }
  9460. try {
  9461. const docProperties = await this.#docProperties(pdfDocument);
  9462. if (pdfDocument !== this.#pdfDocument) {
  9463. return;
  9464. }
  9465. await this.#scripting.createSandbox({
  9466. objects,
  9467. calculationOrder,
  9468. appInfo: {
  9469. platform: navigator.platform,
  9470. language: navigator.language
  9471. },
  9472. docInfo: {
  9473. ...docProperties,
  9474. actions: docActions
  9475. }
  9476. });
  9477. this.#eventBus.dispatch("sandboxcreated", {
  9478. source: this
  9479. });
  9480. } catch (error) {
  9481. console.error(`setDocument: "${error.message}".`);
  9482. await this.#destroyScripting();
  9483. return;
  9484. }
  9485. await this.#scripting?.dispatchEventInSandbox({
  9486. id: "doc",
  9487. name: "Open"
  9488. });
  9489. await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
  9490. Promise.resolve().then(() => {
  9491. if (pdfDocument === this.#pdfDocument) {
  9492. this.#ready = true;
  9493. }
  9494. });
  9495. }
  9496. async dispatchWillSave() {
  9497. return this.#scripting?.dispatchEventInSandbox({
  9498. id: "doc",
  9499. name: "WillSave"
  9500. });
  9501. }
  9502. async dispatchDidSave() {
  9503. return this.#scripting?.dispatchEventInSandbox({
  9504. id: "doc",
  9505. name: "DidSave"
  9506. });
  9507. }
  9508. async dispatchWillPrint() {
  9509. if (!this.#scripting) {
  9510. return;
  9511. }
  9512. await this.#willPrintCapability?.promise;
  9513. this.#willPrintCapability = new _pdfjsLib.PromiseCapability();
  9514. try {
  9515. await this.#scripting.dispatchEventInSandbox({
  9516. id: "doc",
  9517. name: "WillPrint"
  9518. });
  9519. } catch (ex) {
  9520. this.#willPrintCapability.resolve();
  9521. this.#willPrintCapability = null;
  9522. throw ex;
  9523. }
  9524. await this.#willPrintCapability.promise;
  9525. }
  9526. async dispatchDidPrint() {
  9527. return this.#scripting?.dispatchEventInSandbox({
  9528. id: "doc",
  9529. name: "DidPrint"
  9530. });
  9531. }
  9532. get destroyPromise() {
  9533. return this.#destroyCapability?.promise || null;
  9534. }
  9535. get ready() {
  9536. return this.#ready;
  9537. }
  9538. get _internalEvents() {
  9539. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  9540. }
  9541. get _pageOpenPending() {
  9542. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  9543. }
  9544. get _visitedPages() {
  9545. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  9546. }
  9547. async #updateFromSandbox(detail) {
  9548. const pdfViewer = this.#pdfViewer;
  9549. const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
  9550. const {
  9551. id,
  9552. siblings,
  9553. command,
  9554. value
  9555. } = detail;
  9556. if (!id) {
  9557. switch (command) {
  9558. case "clear":
  9559. console.clear();
  9560. break;
  9561. case "error":
  9562. console.error(value);
  9563. break;
  9564. case "layout":
  9565. if (!isInPresentationMode) {
  9566. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
  9567. pdfViewer.spreadMode = modes.spreadMode;
  9568. }
  9569. break;
  9570. case "page-num":
  9571. pdfViewer.currentPageNumber = value + 1;
  9572. break;
  9573. case "print":
  9574. await pdfViewer.pagesPromise;
  9575. this.#eventBus.dispatch("print", {
  9576. source: this
  9577. });
  9578. break;
  9579. case "println":
  9580. console.log(value);
  9581. break;
  9582. case "zoom":
  9583. if (!isInPresentationMode) {
  9584. pdfViewer.currentScaleValue = value;
  9585. }
  9586. break;
  9587. case "SaveAs":
  9588. this.#eventBus.dispatch("download", {
  9589. source: this
  9590. });
  9591. break;
  9592. case "FirstPage":
  9593. pdfViewer.currentPageNumber = 1;
  9594. break;
  9595. case "LastPage":
  9596. pdfViewer.currentPageNumber = pdfViewer.pagesCount;
  9597. break;
  9598. case "NextPage":
  9599. pdfViewer.nextPage();
  9600. break;
  9601. case "PrevPage":
  9602. pdfViewer.previousPage();
  9603. break;
  9604. case "ZoomViewIn":
  9605. if (!isInPresentationMode) {
  9606. pdfViewer.increaseScale();
  9607. }
  9608. break;
  9609. case "ZoomViewOut":
  9610. if (!isInPresentationMode) {
  9611. pdfViewer.decreaseScale();
  9612. }
  9613. break;
  9614. case "WillPrintFinished":
  9615. this.#willPrintCapability?.resolve();
  9616. this.#willPrintCapability = null;
  9617. break;
  9618. }
  9619. return;
  9620. }
  9621. if (isInPresentationMode && detail.focus) {
  9622. return;
  9623. }
  9624. delete detail.id;
  9625. delete detail.siblings;
  9626. const ids = siblings ? [id, ...siblings] : [id];
  9627. for (const elementId of ids) {
  9628. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  9629. if (element) {
  9630. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  9631. detail
  9632. }));
  9633. } else {
  9634. this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
  9635. }
  9636. }
  9637. }
  9638. async #dispatchPageOpen(pageNumber) {
  9639. let initialize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9640. const pdfDocument = this.#pdfDocument,
  9641. visitedPages = this._visitedPages;
  9642. if (initialize) {
  9643. this.#closeCapability = new _pdfjsLib.PromiseCapability();
  9644. }
  9645. if (!this.#closeCapability) {
  9646. return;
  9647. }
  9648. const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
  9649. if (pageView?.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9650. this._pageOpenPending.add(pageNumber);
  9651. return;
  9652. }
  9653. this._pageOpenPending.delete(pageNumber);
  9654. const actionsPromise = (async () => {
  9655. const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
  9656. if (pdfDocument !== this.#pdfDocument) {
  9657. return;
  9658. }
  9659. await this.#scripting?.dispatchEventInSandbox({
  9660. id: "page",
  9661. name: "PageOpen",
  9662. pageNumber,
  9663. actions
  9664. });
  9665. })();
  9666. visitedPages.set(pageNumber, actionsPromise);
  9667. }
  9668. async #dispatchPageClose(pageNumber) {
  9669. const pdfDocument = this.#pdfDocument,
  9670. visitedPages = this._visitedPages;
  9671. if (!this.#closeCapability) {
  9672. return;
  9673. }
  9674. if (this._pageOpenPending.has(pageNumber)) {
  9675. return;
  9676. }
  9677. const actionsPromise = visitedPages.get(pageNumber);
  9678. if (!actionsPromise) {
  9679. return;
  9680. }
  9681. visitedPages.set(pageNumber, null);
  9682. await actionsPromise;
  9683. if (pdfDocument !== this.#pdfDocument) {
  9684. return;
  9685. }
  9686. await this.#scripting?.dispatchEventInSandbox({
  9687. id: "page",
  9688. name: "PageClose",
  9689. pageNumber
  9690. });
  9691. }
  9692. #initScripting() {
  9693. this.#destroyCapability = new _pdfjsLib.PromiseCapability();
  9694. if (this.#scripting) {
  9695. throw new Error("#initScripting: Scripting already exists.");
  9696. }
  9697. return this.#externalServices.createScripting({
  9698. sandboxBundleSrc: this.#sandboxBundleSrc
  9699. });
  9700. }
  9701. async #destroyScripting() {
  9702. if (!this.#scripting) {
  9703. this.#pdfDocument = null;
  9704. this.#destroyCapability?.resolve();
  9705. return;
  9706. }
  9707. if (this.#closeCapability) {
  9708. await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
  9709. setTimeout(resolve, 1000);
  9710. })]).catch(() => {});
  9711. this.#closeCapability = null;
  9712. }
  9713. this.#pdfDocument = null;
  9714. try {
  9715. await this.#scripting.destroySandbox();
  9716. } catch {}
  9717. this.#willPrintCapability?.reject(new Error("Scripting destroyed."));
  9718. this.#willPrintCapability = null;
  9719. for (const [name, listener] of this._internalEvents) {
  9720. this.#eventBus._off(name, listener);
  9721. }
  9722. this._internalEvents.clear();
  9723. this._pageOpenPending.clear();
  9724. this._visitedPages.clear();
  9725. this.#scripting = null;
  9726. this.#ready = false;
  9727. this.#destroyCapability?.resolve();
  9728. }
  9729. }
  9730. exports.PDFScriptingManager = PDFScriptingManager;
  9731. /***/ }),
  9732. /* 143 */
  9733. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9734. Object.defineProperty(exports, "__esModule", ({
  9735. value: true
  9736. }));
  9737. exports.PDFSidebar = void 0;
  9738. var _ui_utils = __webpack_require__(97);
  9739. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9740. const SIDEBAR_MIN_WIDTH = 200;
  9741. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9742. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9743. class PDFSidebar {
  9744. #isRTL = false;
  9745. #mouseMoveBound = this.#mouseMove.bind(this);
  9746. #mouseUpBound = this.#mouseUp.bind(this);
  9747. #outerContainerWidth = null;
  9748. #width = null;
  9749. constructor(_ref) {
  9750. let {
  9751. elements,
  9752. eventBus,
  9753. l10n
  9754. } = _ref;
  9755. this.isOpen = false;
  9756. this.active = _ui_utils.SidebarView.THUMBS;
  9757. this.isInitialViewSet = false;
  9758. this.isInitialEventDispatched = false;
  9759. this.onToggled = null;
  9760. this.onUpdateThumbnails = null;
  9761. this.outerContainer = elements.outerContainer;
  9762. this.sidebarContainer = elements.sidebarContainer;
  9763. this.toggleButton = elements.toggleButton;
  9764. this.resizer = elements.resizer;
  9765. this.thumbnailButton = elements.thumbnailButton;
  9766. this.outlineButton = elements.outlineButton;
  9767. this.attachmentsButton = elements.attachmentsButton;
  9768. this.layersButton = elements.layersButton;
  9769. this.thumbnailView = elements.thumbnailView;
  9770. this.outlineView = elements.outlineView;
  9771. this.attachmentsView = elements.attachmentsView;
  9772. this.layersView = elements.layersView;
  9773. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9774. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9775. this.eventBus = eventBus;
  9776. this.l10n = l10n;
  9777. l10n.getDirection().then(dir => {
  9778. this.#isRTL = dir === "rtl";
  9779. });
  9780. this.#addEventListeners();
  9781. }
  9782. reset() {
  9783. this.isInitialViewSet = false;
  9784. this.isInitialEventDispatched = false;
  9785. this.#hideUINotification(true);
  9786. this.switchView(_ui_utils.SidebarView.THUMBS);
  9787. this.outlineButton.disabled = false;
  9788. this.attachmentsButton.disabled = false;
  9789. this.layersButton.disabled = false;
  9790. this._currentOutlineItemButton.disabled = true;
  9791. }
  9792. get visibleView() {
  9793. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9794. }
  9795. setInitialView() {
  9796. let view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9797. if (this.isInitialViewSet) {
  9798. return;
  9799. }
  9800. this.isInitialViewSet = true;
  9801. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9802. this.#dispatchEvent();
  9803. return;
  9804. }
  9805. this.switchView(view, true);
  9806. if (!this.isInitialEventDispatched) {
  9807. this.#dispatchEvent();
  9808. }
  9809. }
  9810. switchView(view) {
  9811. let forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9812. const isViewChanged = view !== this.active;
  9813. let forceRendering = false;
  9814. switch (view) {
  9815. case _ui_utils.SidebarView.NONE:
  9816. if (this.isOpen) {
  9817. this.close();
  9818. }
  9819. return;
  9820. case _ui_utils.SidebarView.THUMBS:
  9821. if (this.isOpen && isViewChanged) {
  9822. forceRendering = true;
  9823. }
  9824. break;
  9825. case _ui_utils.SidebarView.OUTLINE:
  9826. if (this.outlineButton.disabled) {
  9827. return;
  9828. }
  9829. break;
  9830. case _ui_utils.SidebarView.ATTACHMENTS:
  9831. if (this.attachmentsButton.disabled) {
  9832. return;
  9833. }
  9834. break;
  9835. case _ui_utils.SidebarView.LAYERS:
  9836. if (this.layersButton.disabled) {
  9837. return;
  9838. }
  9839. break;
  9840. default:
  9841. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  9842. return;
  9843. }
  9844. this.active = view;
  9845. (0, _ui_utils.toggleCheckedBtn)(this.thumbnailButton, view === _ui_utils.SidebarView.THUMBS, this.thumbnailView);
  9846. (0, _ui_utils.toggleCheckedBtn)(this.outlineButton, view === _ui_utils.SidebarView.OUTLINE, this.outlineView);
  9847. (0, _ui_utils.toggleCheckedBtn)(this.attachmentsButton, view === _ui_utils.SidebarView.ATTACHMENTS, this.attachmentsView);
  9848. (0, _ui_utils.toggleCheckedBtn)(this.layersButton, view === _ui_utils.SidebarView.LAYERS, this.layersView);
  9849. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9850. if (forceOpen && !this.isOpen) {
  9851. this.open();
  9852. return;
  9853. }
  9854. if (forceRendering) {
  9855. this.onUpdateThumbnails();
  9856. this.onToggled();
  9857. }
  9858. if (isViewChanged) {
  9859. this.#dispatchEvent();
  9860. }
  9861. }
  9862. open() {
  9863. if (this.isOpen) {
  9864. return;
  9865. }
  9866. this.isOpen = true;
  9867. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true);
  9868. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9869. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9870. this.onUpdateThumbnails();
  9871. }
  9872. this.onToggled();
  9873. this.#dispatchEvent();
  9874. this.#hideUINotification();
  9875. }
  9876. close() {
  9877. if (!this.isOpen) {
  9878. return;
  9879. }
  9880. this.isOpen = false;
  9881. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false);
  9882. this.outerContainer.classList.add("sidebarMoving");
  9883. this.outerContainer.classList.remove("sidebarOpen");
  9884. this.onToggled();
  9885. this.#dispatchEvent();
  9886. }
  9887. toggle() {
  9888. if (this.isOpen) {
  9889. this.close();
  9890. } else {
  9891. this.open();
  9892. }
  9893. }
  9894. #dispatchEvent() {
  9895. if (this.isInitialViewSet) {
  9896. this.isInitialEventDispatched ||= true;
  9897. }
  9898. this.eventBus.dispatch("sidebarviewchanged", {
  9899. source: this,
  9900. view: this.visibleView
  9901. });
  9902. }
  9903. #showUINotification() {
  9904. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar_notification2");
  9905. this.l10n.translate(this.toggleButton);
  9906. if (!this.isOpen) {
  9907. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9908. }
  9909. }
  9910. #hideUINotification() {
  9911. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9912. if (this.isOpen || reset) {
  9913. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9914. }
  9915. if (reset) {
  9916. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar");
  9917. this.l10n.translate(this.toggleButton);
  9918. }
  9919. }
  9920. #addEventListeners() {
  9921. this.sidebarContainer.addEventListener("transitionend", evt => {
  9922. if (evt.target === this.sidebarContainer) {
  9923. this.outerContainer.classList.remove("sidebarMoving");
  9924. }
  9925. });
  9926. this.toggleButton.addEventListener("click", () => {
  9927. this.toggle();
  9928. });
  9929. this.thumbnailButton.addEventListener("click", () => {
  9930. this.switchView(_ui_utils.SidebarView.THUMBS);
  9931. });
  9932. this.outlineButton.addEventListener("click", () => {
  9933. this.switchView(_ui_utils.SidebarView.OUTLINE);
  9934. });
  9935. this.outlineButton.addEventListener("dblclick", () => {
  9936. this.eventBus.dispatch("toggleoutlinetree", {
  9937. source: this
  9938. });
  9939. });
  9940. this.attachmentsButton.addEventListener("click", () => {
  9941. this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9942. });
  9943. this.layersButton.addEventListener("click", () => {
  9944. this.switchView(_ui_utils.SidebarView.LAYERS);
  9945. });
  9946. this.layersButton.addEventListener("dblclick", () => {
  9947. this.eventBus.dispatch("resetlayers", {
  9948. source: this
  9949. });
  9950. });
  9951. this._currentOutlineItemButton.addEventListener("click", () => {
  9952. this.eventBus.dispatch("currentoutlineitem", {
  9953. source: this
  9954. });
  9955. });
  9956. const onTreeLoaded = (count, button, view) => {
  9957. button.disabled = !count;
  9958. if (count) {
  9959. this.#showUINotification();
  9960. } else if (this.active === view) {
  9961. this.switchView(_ui_utils.SidebarView.THUMBS);
  9962. }
  9963. };
  9964. this.eventBus._on("outlineloaded", evt => {
  9965. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9966. evt.currentOutlineItemPromise.then(enabled => {
  9967. if (!this.isInitialViewSet) {
  9968. return;
  9969. }
  9970. this._currentOutlineItemButton.disabled = !enabled;
  9971. });
  9972. });
  9973. this.eventBus._on("attachmentsloaded", evt => {
  9974. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9975. });
  9976. this.eventBus._on("layersloaded", evt => {
  9977. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView.LAYERS);
  9978. });
  9979. this.eventBus._on("presentationmodechanged", evt => {
  9980. if (evt.state === _ui_utils.PresentationModeState.NORMAL && this.visibleView === _ui_utils.SidebarView.THUMBS) {
  9981. this.onUpdateThumbnails();
  9982. }
  9983. });
  9984. this.resizer.addEventListener("mousedown", evt => {
  9985. if (evt.button !== 0) {
  9986. return;
  9987. }
  9988. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9989. window.addEventListener("mousemove", this.#mouseMoveBound);
  9990. window.addEventListener("mouseup", this.#mouseUpBound);
  9991. });
  9992. this.eventBus._on("resize", evt => {
  9993. if (evt.source !== window) {
  9994. return;
  9995. }
  9996. this.#outerContainerWidth = null;
  9997. if (!this.#width) {
  9998. return;
  9999. }
  10000. if (!this.isOpen) {
  10001. this.#updateWidth(this.#width);
  10002. return;
  10003. }
  10004. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10005. const updated = this.#updateWidth(this.#width);
  10006. Promise.resolve().then(() => {
  10007. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10008. if (updated) {
  10009. this.eventBus.dispatch("resize", {
  10010. source: this
  10011. });
  10012. }
  10013. });
  10014. });
  10015. }
  10016. get outerContainerWidth() {
  10017. return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
  10018. }
  10019. #updateWidth() {
  10020. let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10021. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  10022. if (width > maxWidth) {
  10023. width = maxWidth;
  10024. }
  10025. if (width < SIDEBAR_MIN_WIDTH) {
  10026. width = SIDEBAR_MIN_WIDTH;
  10027. }
  10028. if (width === this.#width) {
  10029. return false;
  10030. }
  10031. this.#width = width;
  10032. _ui_utils.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  10033. return true;
  10034. }
  10035. #mouseMove(evt) {
  10036. let width = evt.clientX;
  10037. if (this.#isRTL) {
  10038. width = this.outerContainerWidth - width;
  10039. }
  10040. this.#updateWidth(width);
  10041. }
  10042. #mouseUp(evt) {
  10043. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10044. this.eventBus.dispatch("resize", {
  10045. source: this
  10046. });
  10047. window.removeEventListener("mousemove", this.#mouseMoveBound);
  10048. window.removeEventListener("mouseup", this.#mouseUpBound);
  10049. }
  10050. }
  10051. exports.PDFSidebar = PDFSidebar;
  10052. /***/ }),
  10053. /* 144 */
  10054. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10055. Object.defineProperty(exports, "__esModule", ({
  10056. value: true
  10057. }));
  10058. exports.PDFThumbnailViewer = void 0;
  10059. __webpack_require__(76);
  10060. __webpack_require__(89);
  10061. var _ui_utils = __webpack_require__(97);
  10062. var _pdf_thumbnail_view = __webpack_require__(145);
  10063. const THUMBNAIL_SCROLL_MARGIN = -19;
  10064. const THUMBNAIL_SELECTED_CLASS = "selected";
  10065. class PDFThumbnailViewer {
  10066. constructor(_ref) {
  10067. let {
  10068. container,
  10069. eventBus,
  10070. linkService,
  10071. renderingQueue,
  10072. l10n,
  10073. pageColors
  10074. } = _ref;
  10075. this.container = container;
  10076. this.eventBus = eventBus;
  10077. this.linkService = linkService;
  10078. this.renderingQueue = renderingQueue;
  10079. this.l10n = l10n;
  10080. this.pageColors = pageColors || null;
  10081. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  10082. this._resetView();
  10083. }
  10084. _scrollUpdated() {
  10085. this.renderingQueue.renderHighestPriority();
  10086. }
  10087. getThumbnail(index) {
  10088. return this._thumbnails[index];
  10089. }
  10090. _getVisibleThumbs() {
  10091. return (0, _ui_utils.getVisibleElements)({
  10092. scrollEl: this.container,
  10093. views: this._thumbnails
  10094. });
  10095. }
  10096. scrollThumbnailIntoView(pageNumber) {
  10097. if (!this.pdfDocument) {
  10098. return;
  10099. }
  10100. const thumbnailView = this._thumbnails[pageNumber - 1];
  10101. if (!thumbnailView) {
  10102. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  10103. return;
  10104. }
  10105. if (pageNumber !== this._currentPageNumber) {
  10106. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10107. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  10108. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10109. }
  10110. const {
  10111. first,
  10112. last,
  10113. views
  10114. } = this._getVisibleThumbs();
  10115. if (views.length > 0) {
  10116. let shouldScroll = false;
  10117. if (pageNumber <= first.id || pageNumber >= last.id) {
  10118. shouldScroll = true;
  10119. } else {
  10120. for (const {
  10121. id,
  10122. percent
  10123. } of views) {
  10124. if (id !== pageNumber) {
  10125. continue;
  10126. }
  10127. shouldScroll = percent < 100;
  10128. break;
  10129. }
  10130. }
  10131. if (shouldScroll) {
  10132. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  10133. top: THUMBNAIL_SCROLL_MARGIN
  10134. });
  10135. }
  10136. }
  10137. this._currentPageNumber = pageNumber;
  10138. }
  10139. get pagesRotation() {
  10140. return this._pagesRotation;
  10141. }
  10142. set pagesRotation(rotation) {
  10143. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10144. throw new Error("Invalid thumbnails rotation angle.");
  10145. }
  10146. if (!this.pdfDocument) {
  10147. return;
  10148. }
  10149. if (this._pagesRotation === rotation) {
  10150. return;
  10151. }
  10152. this._pagesRotation = rotation;
  10153. const updateArgs = {
  10154. rotation
  10155. };
  10156. for (const thumbnail of this._thumbnails) {
  10157. thumbnail.update(updateArgs);
  10158. }
  10159. }
  10160. cleanup() {
  10161. for (const thumbnail of this._thumbnails) {
  10162. if (thumbnail.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10163. thumbnail.reset();
  10164. }
  10165. }
  10166. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  10167. }
  10168. _resetView() {
  10169. this._thumbnails = [];
  10170. this._currentPageNumber = 1;
  10171. this._pageLabels = null;
  10172. this._pagesRotation = 0;
  10173. this.container.textContent = "";
  10174. }
  10175. setDocument(pdfDocument) {
  10176. if (this.pdfDocument) {
  10177. this._cancelRendering();
  10178. this._resetView();
  10179. }
  10180. this.pdfDocument = pdfDocument;
  10181. if (!pdfDocument) {
  10182. return;
  10183. }
  10184. const firstPagePromise = pdfDocument.getPage(1);
  10185. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10186. firstPagePromise.then(firstPdfPage => {
  10187. const pagesCount = pdfDocument.numPages;
  10188. const viewport = firstPdfPage.getViewport({
  10189. scale: 1
  10190. });
  10191. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10192. const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  10193. container: this.container,
  10194. eventBus: this.eventBus,
  10195. id: pageNum,
  10196. defaultViewport: viewport.clone(),
  10197. optionalContentConfigPromise,
  10198. linkService: this.linkService,
  10199. renderingQueue: this.renderingQueue,
  10200. l10n: this.l10n,
  10201. pageColors: this.pageColors
  10202. });
  10203. this._thumbnails.push(thumbnail);
  10204. }
  10205. this._thumbnails[0]?.setPdfPage(firstPdfPage);
  10206. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10207. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10208. }).catch(reason => {
  10209. console.error("Unable to initialize thumbnail viewer", reason);
  10210. });
  10211. }
  10212. _cancelRendering() {
  10213. for (const thumbnail of this._thumbnails) {
  10214. thumbnail.cancelRendering();
  10215. }
  10216. }
  10217. setPageLabels(labels) {
  10218. if (!this.pdfDocument) {
  10219. return;
  10220. }
  10221. if (!labels) {
  10222. this._pageLabels = null;
  10223. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10224. this._pageLabels = null;
  10225. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  10226. } else {
  10227. this._pageLabels = labels;
  10228. }
  10229. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  10230. this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
  10231. }
  10232. }
  10233. async #ensurePdfPageLoaded(thumbView) {
  10234. if (thumbView.pdfPage) {
  10235. return thumbView.pdfPage;
  10236. }
  10237. try {
  10238. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  10239. if (!thumbView.pdfPage) {
  10240. thumbView.setPdfPage(pdfPage);
  10241. }
  10242. return pdfPage;
  10243. } catch (reason) {
  10244. console.error("Unable to get page for thumb view", reason);
  10245. return null;
  10246. }
  10247. }
  10248. #getScrollAhead(visible) {
  10249. if (visible.first?.id === 1) {
  10250. return true;
  10251. } else if (visible.last?.id === this._thumbnails.length) {
  10252. return false;
  10253. }
  10254. return this.scroll.down;
  10255. }
  10256. forceRendering() {
  10257. const visibleThumbs = this._getVisibleThumbs();
  10258. const scrollAhead = this.#getScrollAhead(visibleThumbs);
  10259. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  10260. if (thumbView) {
  10261. this.#ensurePdfPageLoaded(thumbView).then(() => {
  10262. this.renderingQueue.renderView(thumbView);
  10263. });
  10264. return true;
  10265. }
  10266. return false;
  10267. }
  10268. }
  10269. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  10270. /***/ }),
  10271. /* 145 */
  10272. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10273. Object.defineProperty(exports, "__esModule", ({
  10274. value: true
  10275. }));
  10276. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  10277. __webpack_require__(76);
  10278. var _ui_utils = __webpack_require__(97);
  10279. var _pdfjsLib = __webpack_require__(122);
  10280. const DRAW_UPSCALE_FACTOR = 2;
  10281. const MAX_NUM_SCALING_STEPS = 3;
  10282. const THUMBNAIL_WIDTH = 98;
  10283. class TempImageFactory {
  10284. static #tempCanvas = null;
  10285. static getCanvas(width, height) {
  10286. const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
  10287. tempCanvas.width = width;
  10288. tempCanvas.height = height;
  10289. const ctx = tempCanvas.getContext("2d", {
  10290. alpha: false
  10291. });
  10292. ctx.save();
  10293. ctx.fillStyle = "rgb(255, 255, 255)";
  10294. ctx.fillRect(0, 0, width, height);
  10295. ctx.restore();
  10296. return [tempCanvas, tempCanvas.getContext("2d")];
  10297. }
  10298. static destroyCanvas() {
  10299. const tempCanvas = this.#tempCanvas;
  10300. if (tempCanvas) {
  10301. tempCanvas.width = 0;
  10302. tempCanvas.height = 0;
  10303. }
  10304. this.#tempCanvas = null;
  10305. }
  10306. }
  10307. exports.TempImageFactory = TempImageFactory;
  10308. class PDFThumbnailView {
  10309. constructor(_ref) {
  10310. let {
  10311. container,
  10312. eventBus,
  10313. id,
  10314. defaultViewport,
  10315. optionalContentConfigPromise,
  10316. linkService,
  10317. renderingQueue,
  10318. l10n,
  10319. pageColors
  10320. } = _ref;
  10321. this.id = id;
  10322. this.renderingId = "thumbnail" + id;
  10323. this.pageLabel = null;
  10324. this.pdfPage = null;
  10325. this.rotation = 0;
  10326. this.viewport = defaultViewport;
  10327. this.pdfPageRotate = defaultViewport.rotation;
  10328. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  10329. this.pageColors = pageColors || null;
  10330. this.eventBus = eventBus;
  10331. this.linkService = linkService;
  10332. this.renderingQueue = renderingQueue;
  10333. this.renderTask = null;
  10334. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  10335. this.resume = null;
  10336. this.l10n = l10n;
  10337. const anchor = document.createElement("a");
  10338. anchor.href = linkService.getAnchorUrl("#page=" + id);
  10339. this._thumbPageTitle.then(msg => {
  10340. anchor.title = msg;
  10341. });
  10342. anchor.onclick = function () {
  10343. linkService.goToPage(id);
  10344. return false;
  10345. };
  10346. this.anchor = anchor;
  10347. const div = document.createElement("div");
  10348. div.className = "thumbnail";
  10349. div.setAttribute("data-page-number", this.id);
  10350. this.div = div;
  10351. this.#updateDims();
  10352. const img = document.createElement("div");
  10353. img.className = "thumbnailImage";
  10354. this._placeholderImg = img;
  10355. div.append(img);
  10356. anchor.append(div);
  10357. container.append(anchor);
  10358. }
  10359. #updateDims() {
  10360. const {
  10361. width,
  10362. height
  10363. } = this.viewport;
  10364. const ratio = width / height;
  10365. this.canvasWidth = THUMBNAIL_WIDTH;
  10366. this.canvasHeight = this.canvasWidth / ratio | 0;
  10367. this.scale = this.canvasWidth / width;
  10368. const {
  10369. style
  10370. } = this.div;
  10371. style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
  10372. style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
  10373. }
  10374. setPdfPage(pdfPage) {
  10375. this.pdfPage = pdfPage;
  10376. this.pdfPageRotate = pdfPage.rotate;
  10377. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10378. this.viewport = pdfPage.getViewport({
  10379. scale: 1,
  10380. rotation: totalRotation
  10381. });
  10382. this.reset();
  10383. }
  10384. reset() {
  10385. this.cancelRendering();
  10386. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  10387. this.div.removeAttribute("data-loaded");
  10388. this.image?.replaceWith(this._placeholderImg);
  10389. this.#updateDims();
  10390. if (this.image) {
  10391. this.image.removeAttribute("src");
  10392. delete this.image;
  10393. }
  10394. }
  10395. update(_ref2) {
  10396. let {
  10397. rotation = null
  10398. } = _ref2;
  10399. if (typeof rotation === "number") {
  10400. this.rotation = rotation;
  10401. }
  10402. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10403. this.viewport = this.viewport.clone({
  10404. scale: 1,
  10405. rotation: totalRotation
  10406. });
  10407. this.reset();
  10408. }
  10409. cancelRendering() {
  10410. if (this.renderTask) {
  10411. this.renderTask.cancel();
  10412. this.renderTask = null;
  10413. }
  10414. this.resume = null;
  10415. }
  10416. _getPageDrawContext() {
  10417. let upscaleFactor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  10418. const canvas = document.createElement("canvas");
  10419. const ctx = canvas.getContext("2d", {
  10420. alpha: false
  10421. });
  10422. const outputScale = new _ui_utils.OutputScale();
  10423. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  10424. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  10425. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10426. return {
  10427. ctx,
  10428. canvas,
  10429. transform
  10430. };
  10431. }
  10432. _convertCanvasToImage(canvas) {
  10433. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10434. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  10435. }
  10436. const reducedCanvas = this._reduceImage(canvas);
  10437. const image = document.createElement("img");
  10438. image.className = "thumbnailImage";
  10439. this._thumbPageCanvas.then(msg => {
  10440. image.setAttribute("aria-label", msg);
  10441. });
  10442. image.src = reducedCanvas.toDataURL();
  10443. this.image = image;
  10444. this.div.setAttribute("data-loaded", true);
  10445. this._placeholderImg.replaceWith(image);
  10446. reducedCanvas.width = 0;
  10447. reducedCanvas.height = 0;
  10448. }
  10449. async #finishRenderTask(renderTask, canvas) {
  10450. let error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10451. if (renderTask === this.renderTask) {
  10452. this.renderTask = null;
  10453. }
  10454. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  10455. return;
  10456. }
  10457. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10458. this._convertCanvasToImage(canvas);
  10459. if (error) {
  10460. throw error;
  10461. }
  10462. }
  10463. async draw() {
  10464. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  10465. console.error("Must be in new state before drawing");
  10466. return undefined;
  10467. }
  10468. const {
  10469. pdfPage
  10470. } = this;
  10471. if (!pdfPage) {
  10472. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10473. throw new Error("pdfPage is not loaded");
  10474. }
  10475. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  10476. const {
  10477. ctx,
  10478. canvas,
  10479. transform
  10480. } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
  10481. const drawViewport = this.viewport.clone({
  10482. scale: DRAW_UPSCALE_FACTOR * this.scale
  10483. });
  10484. const renderContinueCallback = cont => {
  10485. if (!this.renderingQueue.isHighestPriority(this)) {
  10486. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  10487. this.resume = () => {
  10488. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  10489. cont();
  10490. };
  10491. return;
  10492. }
  10493. cont();
  10494. };
  10495. const renderContext = {
  10496. canvasContext: ctx,
  10497. transform,
  10498. viewport: drawViewport,
  10499. optionalContentConfigPromise: this._optionalContentConfigPromise,
  10500. pageColors: this.pageColors
  10501. };
  10502. const renderTask = this.renderTask = pdfPage.render(renderContext);
  10503. renderTask.onContinue = renderContinueCallback;
  10504. const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
  10505. resultPromise.finally(() => {
  10506. canvas.width = 0;
  10507. canvas.height = 0;
  10508. this.eventBus.dispatch("thumbnailrendered", {
  10509. source: this,
  10510. pageNumber: this.id,
  10511. pdfPage: this.pdfPage
  10512. });
  10513. });
  10514. return resultPromise;
  10515. }
  10516. setImage(pageView) {
  10517. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  10518. return;
  10519. }
  10520. const {
  10521. thumbnailCanvas: canvas,
  10522. pdfPage,
  10523. scale
  10524. } = pageView;
  10525. if (!canvas) {
  10526. return;
  10527. }
  10528. if (!this.pdfPage) {
  10529. this.setPdfPage(pdfPage);
  10530. }
  10531. if (scale < this.scale) {
  10532. return;
  10533. }
  10534. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10535. this._convertCanvasToImage(canvas);
  10536. }
  10537. _reduceImage(img) {
  10538. const {
  10539. ctx,
  10540. canvas
  10541. } = this._getPageDrawContext();
  10542. if (img.width <= 2 * canvas.width) {
  10543. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10544. return canvas;
  10545. }
  10546. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10547. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10548. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10549. while (reducedWidth > img.width || reducedHeight > img.height) {
  10550. reducedWidth >>= 1;
  10551. reducedHeight >>= 1;
  10552. }
  10553. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10554. while (reducedWidth > 2 * canvas.width) {
  10555. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10556. reducedWidth >>= 1;
  10557. reducedHeight >>= 1;
  10558. }
  10559. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10560. return canvas;
  10561. }
  10562. get _thumbPageTitle() {
  10563. return this.l10n.get("thumb_page_title", {
  10564. page: this.pageLabel ?? this.id
  10565. });
  10566. }
  10567. get _thumbPageCanvas() {
  10568. return this.l10n.get("thumb_page_canvas", {
  10569. page: this.pageLabel ?? this.id
  10570. });
  10571. }
  10572. setPageLabel(label) {
  10573. this.pageLabel = typeof label === "string" ? label : null;
  10574. this._thumbPageTitle.then(msg => {
  10575. this.anchor.title = msg;
  10576. });
  10577. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10578. return;
  10579. }
  10580. this._thumbPageCanvas.then(msg => {
  10581. this.image?.setAttribute("aria-label", msg);
  10582. });
  10583. }
  10584. }
  10585. exports.PDFThumbnailView = PDFThumbnailView;
  10586. /***/ }),
  10587. /* 146 */
  10588. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10589. Object.defineProperty(exports, "__esModule", ({
  10590. value: true
  10591. }));
  10592. exports.PagesCountLimit = exports.PDFViewer = exports.PDFPageViewBuffer = void 0;
  10593. __webpack_require__(98);
  10594. __webpack_require__(109);
  10595. __webpack_require__(111);
  10596. __webpack_require__(114);
  10597. __webpack_require__(116);
  10598. __webpack_require__(118);
  10599. __webpack_require__(120);
  10600. __webpack_require__(76);
  10601. __webpack_require__(89);
  10602. var _pdfjsLib = __webpack_require__(122);
  10603. var _ui_utils = __webpack_require__(97);
  10604. var _l10n_utils = __webpack_require__(147);
  10605. var _pdf_page_view = __webpack_require__(148);
  10606. var _pdf_rendering_queue = __webpack_require__(141);
  10607. var _pdf_link_service = __webpack_require__(125);
  10608. const DEFAULT_CACHE_SIZE = 10;
  10609. const PagesCountLimit = {
  10610. FORCE_SCROLL_MODE_PAGE: 15000,
  10611. FORCE_LAZY_PAGE_INIT: 7500,
  10612. PAUSE_EAGER_PAGE_INIT: 250
  10613. };
  10614. exports.PagesCountLimit = PagesCountLimit;
  10615. function isValidAnnotationEditorMode(mode) {
  10616. return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !== _pdfjsLib.AnnotationEditorType.DISABLE;
  10617. }
  10618. class PDFPageViewBuffer {
  10619. #buf = new Set();
  10620. #size = 0;
  10621. constructor(size) {
  10622. this.#size = size;
  10623. }
  10624. push(view) {
  10625. const buf = this.#buf;
  10626. if (buf.has(view)) {
  10627. buf.delete(view);
  10628. }
  10629. buf.add(view);
  10630. if (buf.size > this.#size) {
  10631. this.#destroyFirstView();
  10632. }
  10633. }
  10634. resize(newSize) {
  10635. let idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10636. this.#size = newSize;
  10637. const buf = this.#buf;
  10638. if (idsToKeep) {
  10639. const ii = buf.size;
  10640. let i = 1;
  10641. for (const view of buf) {
  10642. if (idsToKeep.has(view.id)) {
  10643. buf.delete(view);
  10644. buf.add(view);
  10645. }
  10646. if (++i > ii) {
  10647. break;
  10648. }
  10649. }
  10650. }
  10651. while (buf.size > this.#size) {
  10652. this.#destroyFirstView();
  10653. }
  10654. }
  10655. has(view) {
  10656. return this.#buf.has(view);
  10657. }
  10658. [Symbol.iterator]() {
  10659. return this.#buf.keys();
  10660. }
  10661. #destroyFirstView() {
  10662. const firstView = this.#buf.keys().next().value;
  10663. firstView?.destroy();
  10664. this.#buf.delete(firstView);
  10665. }
  10666. }
  10667. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  10668. class PDFViewer {
  10669. #buffer = null;
  10670. #annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  10671. #annotationEditorUIManager = null;
  10672. #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10673. #containerTopLeft = null;
  10674. #copyCallbackBound = null;
  10675. #enablePermissions = false;
  10676. #getAllTextInProgress = false;
  10677. #hiddenCopyElement = null;
  10678. #interruptCopyCondition = false;
  10679. #previousContainerHeight = 0;
  10680. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  10681. #scrollModePageState = null;
  10682. #onVisibilityChange = null;
  10683. #scaleTimeoutId = null;
  10684. #textLayerMode = _ui_utils.TextLayerMode.ENABLE;
  10685. constructor(options) {
  10686. const viewerVersion = '3.10.111';
  10687. if (_pdfjsLib.version !== viewerVersion) {
  10688. throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
  10689. }
  10690. this.container = options.container;
  10691. this.viewer = options.viewer || options.container.firstElementChild;
  10692. if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
  10693. throw new Error("Invalid `container` and/or `viewer` option.");
  10694. }
  10695. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  10696. throw new Error("The `container` must be absolutely positioned.");
  10697. }
  10698. this.#resizeObserver.observe(this.container);
  10699. this.eventBus = options.eventBus;
  10700. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10701. this.downloadManager = options.downloadManager || null;
  10702. this.findController = options.findController || null;
  10703. if (this.findController) {
  10704. this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
  10705. }
  10706. this._scriptingManager = options.scriptingManager || null;
  10707. this.#textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  10708. this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10709. this.#annotationEditorMode = options.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.NONE;
  10710. this.imageResourcesPath = options.imageResourcesPath || "";
  10711. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10712. this.removePageBorders = options.removePageBorders || false;
  10713. if (options.useOnlyCssZoom) {
  10714. console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
  10715. options.maxCanvasPixels = 0;
  10716. }
  10717. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  10718. this.maxCanvasPixels = options.maxCanvasPixels;
  10719. this.l10n = options.l10n || _l10n_utils.NullL10n;
  10720. this.#enablePermissions = options.enablePermissions || false;
  10721. this.pageColors = options.pageColors || null;
  10722. this.defaultRenderingQueue = !options.renderingQueue;
  10723. if (this.defaultRenderingQueue) {
  10724. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10725. this.renderingQueue.setViewer(this);
  10726. } else {
  10727. this.renderingQueue = options.renderingQueue;
  10728. }
  10729. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10730. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10731. this._onBeforeDraw = this._onAfterDraw = null;
  10732. this._resetView();
  10733. if (this.removePageBorders) {
  10734. this.viewer.classList.add("removePageBorders");
  10735. }
  10736. this.#updateContainerHeightCss();
  10737. this.eventBus._on("thumbnailrendered", _ref => {
  10738. let {
  10739. pageNumber,
  10740. pdfPage
  10741. } = _ref;
  10742. const pageView = this._pages[pageNumber - 1];
  10743. if (!this.#buffer.has(pageView)) {
  10744. pdfPage?.cleanup();
  10745. }
  10746. });
  10747. }
  10748. get pagesCount() {
  10749. return this._pages.length;
  10750. }
  10751. getPageView(index) {
  10752. return this._pages[index];
  10753. }
  10754. getCachedPageViews() {
  10755. return new Set(this.#buffer);
  10756. }
  10757. get pageViewsReady() {
  10758. return this._pagesCapability.settled && this._pages.every(pageView => pageView?.pdfPage);
  10759. }
  10760. get renderForms() {
  10761. return this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10762. }
  10763. get enableScripting() {
  10764. return !!this._scriptingManager;
  10765. }
  10766. get currentPageNumber() {
  10767. return this._currentPageNumber;
  10768. }
  10769. set currentPageNumber(val) {
  10770. if (!Number.isInteger(val)) {
  10771. throw new Error("Invalid page number.");
  10772. }
  10773. if (!this.pdfDocument) {
  10774. return;
  10775. }
  10776. if (!this._setCurrentPageNumber(val, true)) {
  10777. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  10778. }
  10779. }
  10780. _setCurrentPageNumber(val) {
  10781. let resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10782. if (this._currentPageNumber === val) {
  10783. if (resetCurrentPageView) {
  10784. this.#resetCurrentPageView();
  10785. }
  10786. return true;
  10787. }
  10788. if (!(0 < val && val <= this.pagesCount)) {
  10789. return false;
  10790. }
  10791. const previous = this._currentPageNumber;
  10792. this._currentPageNumber = val;
  10793. this.eventBus.dispatch("pagechanging", {
  10794. source: this,
  10795. pageNumber: val,
  10796. pageLabel: this._pageLabels?.[val - 1] ?? null,
  10797. previous
  10798. });
  10799. if (resetCurrentPageView) {
  10800. this.#resetCurrentPageView();
  10801. }
  10802. return true;
  10803. }
  10804. get currentPageLabel() {
  10805. return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
  10806. }
  10807. set currentPageLabel(val) {
  10808. if (!this.pdfDocument) {
  10809. return;
  10810. }
  10811. let page = val | 0;
  10812. if (this._pageLabels) {
  10813. const i = this._pageLabels.indexOf(val);
  10814. if (i >= 0) {
  10815. page = i + 1;
  10816. }
  10817. }
  10818. if (!this._setCurrentPageNumber(page, true)) {
  10819. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  10820. }
  10821. }
  10822. get currentScale() {
  10823. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  10824. }
  10825. set currentScale(val) {
  10826. if (isNaN(val)) {
  10827. throw new Error("Invalid numeric scale.");
  10828. }
  10829. if (!this.pdfDocument) {
  10830. return;
  10831. }
  10832. this.#setScale(val, {
  10833. noScroll: false
  10834. });
  10835. }
  10836. get currentScaleValue() {
  10837. return this._currentScaleValue;
  10838. }
  10839. set currentScaleValue(val) {
  10840. if (!this.pdfDocument) {
  10841. return;
  10842. }
  10843. this.#setScale(val, {
  10844. noScroll: false
  10845. });
  10846. }
  10847. get pagesRotation() {
  10848. return this._pagesRotation;
  10849. }
  10850. set pagesRotation(rotation) {
  10851. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10852. throw new Error("Invalid pages rotation angle.");
  10853. }
  10854. if (!this.pdfDocument) {
  10855. return;
  10856. }
  10857. rotation %= 360;
  10858. if (rotation < 0) {
  10859. rotation += 360;
  10860. }
  10861. if (this._pagesRotation === rotation) {
  10862. return;
  10863. }
  10864. this._pagesRotation = rotation;
  10865. const pageNumber = this._currentPageNumber;
  10866. this.refresh(true, {
  10867. rotation
  10868. });
  10869. if (this._currentScaleValue) {
  10870. this.#setScale(this._currentScaleValue, {
  10871. noScroll: true
  10872. });
  10873. }
  10874. this.eventBus.dispatch("rotationchanging", {
  10875. source: this,
  10876. pagesRotation: rotation,
  10877. pageNumber
  10878. });
  10879. if (this.defaultRenderingQueue) {
  10880. this.update();
  10881. }
  10882. }
  10883. get firstPagePromise() {
  10884. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10885. }
  10886. get onePageRendered() {
  10887. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10888. }
  10889. get pagesPromise() {
  10890. return this.pdfDocument ? this._pagesCapability.promise : null;
  10891. }
  10892. #layerProperties() {
  10893. const self = this;
  10894. return {
  10895. get annotationEditorUIManager() {
  10896. return self.#annotationEditorUIManager;
  10897. },
  10898. get annotationStorage() {
  10899. return self.pdfDocument?.annotationStorage;
  10900. },
  10901. get downloadManager() {
  10902. return self.downloadManager;
  10903. },
  10904. get enableScripting() {
  10905. return !!self._scriptingManager;
  10906. },
  10907. get fieldObjectsPromise() {
  10908. return self.pdfDocument?.getFieldObjects();
  10909. },
  10910. get findController() {
  10911. return self.findController;
  10912. },
  10913. get hasJSActionsPromise() {
  10914. return self.pdfDocument?.hasJSActions();
  10915. },
  10916. get linkService() {
  10917. return self.linkService;
  10918. }
  10919. };
  10920. }
  10921. #initializePermissions(permissions) {
  10922. const params = {
  10923. annotationEditorMode: this.#annotationEditorMode,
  10924. annotationMode: this.#annotationMode,
  10925. textLayerMode: this.#textLayerMode
  10926. };
  10927. if (!permissions) {
  10928. return params;
  10929. }
  10930. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY) && this.#textLayerMode === _ui_utils.TextLayerMode.ENABLE) {
  10931. params.textLayerMode = _ui_utils.TextLayerMode.ENABLE_PERMISSIONS;
  10932. }
  10933. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) {
  10934. params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
  10935. }
  10936. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
  10937. params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE;
  10938. }
  10939. return params;
  10940. }
  10941. #onePageRenderedOrForceFetch() {
  10942. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10943. return Promise.resolve();
  10944. }
  10945. const visibilityChangePromise = new Promise(resolve => {
  10946. this.#onVisibilityChange = () => {
  10947. if (document.visibilityState !== "hidden") {
  10948. return;
  10949. }
  10950. resolve();
  10951. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  10952. this.#onVisibilityChange = null;
  10953. };
  10954. document.addEventListener("visibilitychange", this.#onVisibilityChange);
  10955. });
  10956. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  10957. }
  10958. async getAllText() {
  10959. const texts = [];
  10960. const buffer = [];
  10961. for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
  10962. if (this.#interruptCopyCondition) {
  10963. return null;
  10964. }
  10965. buffer.length = 0;
  10966. const page = await this.pdfDocument.getPage(pageNum);
  10967. const {
  10968. items
  10969. } = await page.getTextContent();
  10970. for (const item of items) {
  10971. if (item.str) {
  10972. buffer.push(item.str);
  10973. }
  10974. if (item.hasEOL) {
  10975. buffer.push("\n");
  10976. }
  10977. }
  10978. texts.push((0, _ui_utils.removeNullCharacters)(buffer.join("")));
  10979. }
  10980. return texts.join("\n");
  10981. }
  10982. #copyCallback(textLayerMode, event) {
  10983. const selection = document.getSelection();
  10984. const {
  10985. focusNode,
  10986. anchorNode
  10987. } = selection;
  10988. if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
  10989. if (this.#getAllTextInProgress || textLayerMode === _ui_utils.TextLayerMode.ENABLE_PERMISSIONS) {
  10990. event.preventDefault();
  10991. event.stopPropagation();
  10992. return;
  10993. }
  10994. this.#getAllTextInProgress = true;
  10995. const savedCursor = this.container.style.cursor;
  10996. this.container.style.cursor = "wait";
  10997. const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
  10998. window.addEventListener("keydown", interruptCopy);
  10999. this.getAllText().then(async text => {
  11000. if (text !== null) {
  11001. await navigator.clipboard.writeText(text);
  11002. }
  11003. }).catch(reason => {
  11004. console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
  11005. }).finally(() => {
  11006. this.#getAllTextInProgress = false;
  11007. this.#interruptCopyCondition = false;
  11008. window.removeEventListener("keydown", interruptCopy);
  11009. this.container.style.cursor = savedCursor;
  11010. });
  11011. event.preventDefault();
  11012. event.stopPropagation();
  11013. }
  11014. }
  11015. setDocument(pdfDocument) {
  11016. if (this.pdfDocument) {
  11017. this.eventBus.dispatch("pagesdestroy", {
  11018. source: this
  11019. });
  11020. this._cancelRendering();
  11021. this._resetView();
  11022. this.findController?.setDocument(null);
  11023. this._scriptingManager?.setDocument(null);
  11024. if (this.#annotationEditorUIManager) {
  11025. this.#annotationEditorUIManager.destroy();
  11026. this.#annotationEditorUIManager = null;
  11027. }
  11028. }
  11029. this.pdfDocument = pdfDocument;
  11030. if (!pdfDocument) {
  11031. return;
  11032. }
  11033. const pagesCount = pdfDocument.numPages;
  11034. const firstPagePromise = pdfDocument.getPage(1);
  11035. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  11036. const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
  11037. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11038. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  11039. const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  11040. this.eventBus.dispatch("scrollmodechanged", {
  11041. source: this,
  11042. mode
  11043. });
  11044. }
  11045. this._pagesCapability.promise.then(() => {
  11046. this.eventBus.dispatch("pagesloaded", {
  11047. source: this,
  11048. pagesCount
  11049. });
  11050. }, () => {});
  11051. this._onBeforeDraw = evt => {
  11052. const pageView = this._pages[evt.pageNumber - 1];
  11053. if (!pageView) {
  11054. return;
  11055. }
  11056. this.#buffer.push(pageView);
  11057. };
  11058. this.eventBus._on("pagerender", this._onBeforeDraw);
  11059. this._onAfterDraw = evt => {
  11060. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  11061. return;
  11062. }
  11063. this._onePageRenderedCapability.resolve({
  11064. timestamp: evt.timestamp
  11065. });
  11066. this.eventBus._off("pagerendered", this._onAfterDraw);
  11067. this._onAfterDraw = null;
  11068. if (this.#onVisibilityChange) {
  11069. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11070. this.#onVisibilityChange = null;
  11071. }
  11072. };
  11073. this.eventBus._on("pagerendered", this._onAfterDraw);
  11074. Promise.all([firstPagePromise, permissionsPromise]).then(_ref2 => {
  11075. let [firstPdfPage, permissions] = _ref2;
  11076. if (pdfDocument !== this.pdfDocument) {
  11077. return;
  11078. }
  11079. this._firstPageCapability.resolve(firstPdfPage);
  11080. this._optionalContentConfigPromise = optionalContentConfigPromise;
  11081. const {
  11082. annotationEditorMode,
  11083. annotationMode,
  11084. textLayerMode
  11085. } = this.#initializePermissions(permissions);
  11086. if (textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  11087. const element = this.#hiddenCopyElement = document.createElement("div");
  11088. element.id = "hiddenCopyElement";
  11089. this.viewer.before(element);
  11090. }
  11091. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  11092. const mode = annotationEditorMode;
  11093. if (pdfDocument.isPureXfa) {
  11094. console.warn("Warning: XFA-editing is not implemented.");
  11095. } else if (isValidAnnotationEditorMode(mode)) {
  11096. this.#annotationEditorUIManager = new _pdfjsLib.AnnotationEditorUIManager(this.container, this.viewer, this.eventBus, pdfDocument, this.pageColors);
  11097. if (mode !== _pdfjsLib.AnnotationEditorType.NONE) {
  11098. this.#annotationEditorUIManager.updateMode(mode);
  11099. }
  11100. } else {
  11101. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  11102. }
  11103. }
  11104. const layerProperties = this.#layerProperties.bind(this);
  11105. const viewerElement = this._scrollMode === _ui_utils.ScrollMode.PAGE ? null : this.viewer;
  11106. const scale = this.currentScale;
  11107. const viewport = firstPdfPage.getViewport({
  11108. scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  11109. });
  11110. this.viewer.style.setProperty("--scale-factor", viewport.scale);
  11111. if (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas") {
  11112. this.viewer.style.setProperty("--hcm-highligh-filter", pdfDocument.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  11113. }
  11114. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11115. const pageView = new _pdf_page_view.PDFPageView({
  11116. container: viewerElement,
  11117. eventBus: this.eventBus,
  11118. id: pageNum,
  11119. scale,
  11120. defaultViewport: viewport.clone(),
  11121. optionalContentConfigPromise,
  11122. renderingQueue: this.renderingQueue,
  11123. textLayerMode,
  11124. annotationMode,
  11125. imageResourcesPath: this.imageResourcesPath,
  11126. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  11127. maxCanvasPixels: this.maxCanvasPixels,
  11128. pageColors: this.pageColors,
  11129. l10n: this.l10n,
  11130. layerProperties
  11131. });
  11132. this._pages.push(pageView);
  11133. }
  11134. const firstPageView = this._pages[0];
  11135. if (firstPageView) {
  11136. firstPageView.setPdfPage(firstPdfPage);
  11137. this.linkService.cachePageRef(1, firstPdfPage.ref);
  11138. }
  11139. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11140. this.#ensurePageViewVisible();
  11141. } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  11142. this._updateSpreadMode();
  11143. }
  11144. this.#onePageRenderedOrForceFetch().then(async () => {
  11145. this.findController?.setDocument(pdfDocument);
  11146. this._scriptingManager?.setDocument(pdfDocument);
  11147. if (this.#hiddenCopyElement) {
  11148. this.#copyCallbackBound = this.#copyCallback.bind(this, textLayerMode);
  11149. document.addEventListener("copy", this.#copyCallbackBound);
  11150. }
  11151. if (this.#annotationEditorUIManager) {
  11152. this.eventBus.dispatch("annotationeditormodechanged", {
  11153. source: this,
  11154. mode: this.#annotationEditorMode
  11155. });
  11156. }
  11157. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  11158. this._pagesCapability.resolve();
  11159. return;
  11160. }
  11161. let getPagesLeft = pagesCount - 1;
  11162. if (getPagesLeft <= 0) {
  11163. this._pagesCapability.resolve();
  11164. return;
  11165. }
  11166. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  11167. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  11168. const pageView = this._pages[pageNum - 1];
  11169. if (!pageView.pdfPage) {
  11170. pageView.setPdfPage(pdfPage);
  11171. }
  11172. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  11173. if (--getPagesLeft === 0) {
  11174. this._pagesCapability.resolve();
  11175. }
  11176. }, reason => {
  11177. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  11178. if (--getPagesLeft === 0) {
  11179. this._pagesCapability.resolve();
  11180. }
  11181. });
  11182. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  11183. await promise;
  11184. }
  11185. }
  11186. });
  11187. this.eventBus.dispatch("pagesinit", {
  11188. source: this
  11189. });
  11190. pdfDocument.getMetadata().then(_ref3 => {
  11191. let {
  11192. info
  11193. } = _ref3;
  11194. if (pdfDocument !== this.pdfDocument) {
  11195. return;
  11196. }
  11197. if (info.Language) {
  11198. this.viewer.lang = info.Language;
  11199. }
  11200. });
  11201. if (this.defaultRenderingQueue) {
  11202. this.update();
  11203. }
  11204. }).catch(reason => {
  11205. console.error("Unable to initialize viewer", reason);
  11206. this._pagesCapability.reject(reason);
  11207. });
  11208. }
  11209. setPageLabels(labels) {
  11210. if (!this.pdfDocument) {
  11211. return;
  11212. }
  11213. if (!labels) {
  11214. this._pageLabels = null;
  11215. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11216. this._pageLabels = null;
  11217. console.error(`setPageLabels: Invalid page labels.`);
  11218. } else {
  11219. this._pageLabels = labels;
  11220. }
  11221. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  11222. this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11223. }
  11224. }
  11225. _resetView() {
  11226. this._pages = [];
  11227. this._currentPageNumber = 1;
  11228. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  11229. this._currentScaleValue = null;
  11230. this._pageLabels = null;
  11231. this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  11232. this._location = null;
  11233. this._pagesRotation = 0;
  11234. this._optionalContentConfigPromise = null;
  11235. this._firstPageCapability = new _pdfjsLib.PromiseCapability();
  11236. this._onePageRenderedCapability = new _pdfjsLib.PromiseCapability();
  11237. this._pagesCapability = new _pdfjsLib.PromiseCapability();
  11238. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  11239. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  11240. this._spreadMode = _ui_utils.SpreadMode.NONE;
  11241. this.#scrollModePageState = {
  11242. previousPageNumber: 1,
  11243. scrollDown: true,
  11244. pages: []
  11245. };
  11246. if (this._onBeforeDraw) {
  11247. this.eventBus._off("pagerender", this._onBeforeDraw);
  11248. this._onBeforeDraw = null;
  11249. }
  11250. if (this._onAfterDraw) {
  11251. this.eventBus._off("pagerendered", this._onAfterDraw);
  11252. this._onAfterDraw = null;
  11253. }
  11254. if (this.#onVisibilityChange) {
  11255. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11256. this.#onVisibilityChange = null;
  11257. }
  11258. this.viewer.textContent = "";
  11259. this._updateScrollMode();
  11260. this.viewer.removeAttribute("lang");
  11261. if (this.#hiddenCopyElement) {
  11262. document.removeEventListener("copy", this.#copyCallbackBound);
  11263. this.#copyCallbackBound = null;
  11264. this.#hiddenCopyElement.remove();
  11265. this.#hiddenCopyElement = null;
  11266. }
  11267. }
  11268. #ensurePageViewVisible() {
  11269. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  11270. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  11271. }
  11272. const pageNumber = this._currentPageNumber,
  11273. state = this.#scrollModePageState,
  11274. viewer = this.viewer;
  11275. viewer.textContent = "";
  11276. state.pages.length = 0;
  11277. if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
  11278. const pageView = this._pages[pageNumber - 1];
  11279. viewer.append(pageView.div);
  11280. state.pages.push(pageView);
  11281. } else {
  11282. const pageIndexSet = new Set(),
  11283. parity = this._spreadMode - 1;
  11284. if (parity === -1) {
  11285. pageIndexSet.add(pageNumber - 1);
  11286. } else if (pageNumber % 2 !== parity) {
  11287. pageIndexSet.add(pageNumber - 1);
  11288. pageIndexSet.add(pageNumber);
  11289. } else {
  11290. pageIndexSet.add(pageNumber - 2);
  11291. pageIndexSet.add(pageNumber - 1);
  11292. }
  11293. const spread = document.createElement("div");
  11294. spread.className = "spread";
  11295. if (this.isInPresentationMode) {
  11296. const dummyPage = document.createElement("div");
  11297. dummyPage.className = "dummyPage";
  11298. spread.append(dummyPage);
  11299. }
  11300. for (const i of pageIndexSet) {
  11301. const pageView = this._pages[i];
  11302. if (!pageView) {
  11303. continue;
  11304. }
  11305. spread.append(pageView.div);
  11306. state.pages.push(pageView);
  11307. }
  11308. viewer.append(spread);
  11309. }
  11310. state.scrollDown = pageNumber >= state.previousPageNumber;
  11311. state.previousPageNumber = pageNumber;
  11312. }
  11313. _scrollUpdate() {
  11314. if (this.pagesCount === 0) {
  11315. return;
  11316. }
  11317. this.update();
  11318. }
  11319. #scrollIntoView(pageView) {
  11320. let pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11321. const {
  11322. div,
  11323. id
  11324. } = pageView;
  11325. if (this._currentPageNumber !== id) {
  11326. this._setCurrentPageNumber(id);
  11327. }
  11328. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11329. this.#ensurePageViewVisible();
  11330. this.update();
  11331. }
  11332. if (!pageSpot && !this.isInPresentationMode) {
  11333. const left = div.offsetLeft + div.clientLeft,
  11334. right = left + div.clientWidth;
  11335. const {
  11336. scrollLeft,
  11337. clientWidth
  11338. } = this.container;
  11339. if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  11340. pageSpot = {
  11341. left: 0,
  11342. top: 0
  11343. };
  11344. }
  11345. }
  11346. (0, _ui_utils.scrollIntoView)(div, pageSpot);
  11347. if (!this._currentScaleValue && this._location) {
  11348. this._location = null;
  11349. }
  11350. }
  11351. #isSameScale(newScale) {
  11352. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  11353. }
  11354. #setScaleUpdatePages(newScale, newValue, _ref4) {
  11355. let {
  11356. noScroll = false,
  11357. preset = false,
  11358. drawingDelay = -1
  11359. } = _ref4;
  11360. this._currentScaleValue = newValue.toString();
  11361. if (this.#isSameScale(newScale)) {
  11362. if (preset) {
  11363. this.eventBus.dispatch("scalechanging", {
  11364. source: this,
  11365. scale: newScale,
  11366. presetValue: newValue
  11367. });
  11368. }
  11369. return;
  11370. }
  11371. this.viewer.style.setProperty("--scale-factor", newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  11372. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  11373. this.refresh(true, {
  11374. scale: newScale,
  11375. drawingDelay: postponeDrawing ? drawingDelay : -1
  11376. });
  11377. if (postponeDrawing) {
  11378. this.#scaleTimeoutId = setTimeout(() => {
  11379. this.#scaleTimeoutId = null;
  11380. this.refresh();
  11381. }, drawingDelay);
  11382. }
  11383. this._currentScale = newScale;
  11384. if (!noScroll) {
  11385. let page = this._currentPageNumber,
  11386. dest;
  11387. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  11388. page = this._location.pageNumber;
  11389. dest = [null, {
  11390. name: "XYZ"
  11391. }, this._location.left, this._location.top, null];
  11392. }
  11393. this.scrollPageIntoView({
  11394. pageNumber: page,
  11395. destArray: dest,
  11396. allowNegativeOffset: true
  11397. });
  11398. }
  11399. this.eventBus.dispatch("scalechanging", {
  11400. source: this,
  11401. scale: newScale,
  11402. presetValue: preset ? newValue : undefined
  11403. });
  11404. if (this.defaultRenderingQueue) {
  11405. this.update();
  11406. }
  11407. }
  11408. get #pageWidthScaleFactor() {
  11409. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
  11410. return 2;
  11411. }
  11412. return 1;
  11413. }
  11414. #setScale(value, options) {
  11415. let scale = parseFloat(value);
  11416. if (scale > 0) {
  11417. options.preset = false;
  11418. this.#setScaleUpdatePages(scale, value, options);
  11419. } else {
  11420. const currentPage = this._pages[this._currentPageNumber - 1];
  11421. if (!currentPage) {
  11422. return;
  11423. }
  11424. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  11425. vPadding = _ui_utils.VERTICAL_PADDING;
  11426. if (this.isInPresentationMode) {
  11427. hPadding = vPadding = 4;
  11428. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  11429. hPadding *= 2;
  11430. }
  11431. } else if (this.removePageBorders) {
  11432. hPadding = vPadding = 0;
  11433. } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
  11434. [hPadding, vPadding] = [vPadding, hPadding];
  11435. }
  11436. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
  11437. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  11438. switch (value) {
  11439. case "page-actual":
  11440. scale = 1;
  11441. break;
  11442. case "page-width":
  11443. scale = pageWidthScale;
  11444. break;
  11445. case "page-height":
  11446. scale = pageHeightScale;
  11447. break;
  11448. case "page-fit":
  11449. scale = Math.min(pageWidthScale, pageHeightScale);
  11450. break;
  11451. case "auto":
  11452. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  11453. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  11454. break;
  11455. default:
  11456. console.error(`#setScale: "${value}" is an unknown zoom value.`);
  11457. return;
  11458. }
  11459. options.preset = true;
  11460. this.#setScaleUpdatePages(scale, value, options);
  11461. }
  11462. }
  11463. #resetCurrentPageView() {
  11464. const pageView = this._pages[this._currentPageNumber - 1];
  11465. if (this.isInPresentationMode) {
  11466. this.#setScale(this._currentScaleValue, {
  11467. noScroll: true
  11468. });
  11469. }
  11470. this.#scrollIntoView(pageView);
  11471. }
  11472. pageLabelToPageNumber(label) {
  11473. if (!this._pageLabels) {
  11474. return null;
  11475. }
  11476. const i = this._pageLabels.indexOf(label);
  11477. if (i < 0) {
  11478. return null;
  11479. }
  11480. return i + 1;
  11481. }
  11482. scrollPageIntoView(_ref5) {
  11483. let {
  11484. pageNumber,
  11485. destArray = null,
  11486. allowNegativeOffset = false,
  11487. ignoreDestinationZoom = false
  11488. } = _ref5;
  11489. if (!this.pdfDocument) {
  11490. return;
  11491. }
  11492. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  11493. if (!pageView) {
  11494. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  11495. return;
  11496. }
  11497. if (this.isInPresentationMode || !destArray) {
  11498. this._setCurrentPageNumber(pageNumber, true);
  11499. return;
  11500. }
  11501. let x = 0,
  11502. y = 0;
  11503. let width = 0,
  11504. height = 0,
  11505. widthScale,
  11506. heightScale;
  11507. const changeOrientation = pageView.rotation % 180 !== 0;
  11508. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11509. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11510. let scale = 0;
  11511. switch (destArray[1].name) {
  11512. case "XYZ":
  11513. x = destArray[2];
  11514. y = destArray[3];
  11515. scale = destArray[4];
  11516. x = x !== null ? x : 0;
  11517. y = y !== null ? y : pageHeight;
  11518. break;
  11519. case "Fit":
  11520. case "FitB":
  11521. scale = "page-fit";
  11522. break;
  11523. case "FitH":
  11524. case "FitBH":
  11525. y = destArray[2];
  11526. scale = "page-width";
  11527. if (y === null && this._location) {
  11528. x = this._location.left;
  11529. y = this._location.top;
  11530. } else if (typeof y !== "number" || y < 0) {
  11531. y = pageHeight;
  11532. }
  11533. break;
  11534. case "FitV":
  11535. case "FitBV":
  11536. x = destArray[2];
  11537. width = pageWidth;
  11538. height = pageHeight;
  11539. scale = "page-height";
  11540. break;
  11541. case "FitR":
  11542. x = destArray[2];
  11543. y = destArray[3];
  11544. width = destArray[4] - x;
  11545. height = destArray[5] - y;
  11546. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  11547. vPadding = _ui_utils.VERTICAL_PADDING;
  11548. if (this.removePageBorders) {
  11549. hPadding = vPadding = 0;
  11550. }
  11551. widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11552. heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11553. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  11554. break;
  11555. default:
  11556. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  11557. return;
  11558. }
  11559. if (!ignoreDestinationZoom) {
  11560. if (scale && scale !== this._currentScale) {
  11561. this.currentScaleValue = scale;
  11562. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  11563. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11564. }
  11565. }
  11566. if (scale === "page-fit" && !destArray[4]) {
  11567. this.#scrollIntoView(pageView);
  11568. return;
  11569. }
  11570. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  11571. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  11572. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  11573. if (!allowNegativeOffset) {
  11574. left = Math.max(left, 0);
  11575. top = Math.max(top, 0);
  11576. }
  11577. this.#scrollIntoView(pageView, {
  11578. left,
  11579. top
  11580. });
  11581. }
  11582. _updateLocation(firstPage) {
  11583. const currentScale = this._currentScale;
  11584. const currentScaleValue = this._currentScaleValue;
  11585. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  11586. const pageNumber = firstPage.id;
  11587. const currentPageView = this._pages[pageNumber - 1];
  11588. const container = this.container;
  11589. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  11590. const intLeft = Math.round(topLeft[0]);
  11591. const intTop = Math.round(topLeft[1]);
  11592. let pdfOpenParams = `#page=${pageNumber}`;
  11593. if (!this.isInPresentationMode) {
  11594. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  11595. }
  11596. this._location = {
  11597. pageNumber,
  11598. scale: normalizedScaleValue,
  11599. top: intTop,
  11600. left: intLeft,
  11601. rotation: this._pagesRotation,
  11602. pdfOpenParams
  11603. };
  11604. }
  11605. update() {
  11606. const visible = this._getVisiblePages();
  11607. const visiblePages = visible.views,
  11608. numVisiblePages = visiblePages.length;
  11609. if (numVisiblePages === 0) {
  11610. return;
  11611. }
  11612. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11613. this.#buffer.resize(newCacheSize, visible.ids);
  11614. this.renderingQueue.renderHighestPriority(visible);
  11615. const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL);
  11616. const currentId = this._currentPageNumber;
  11617. let stillFullyVisible = false;
  11618. for (const page of visiblePages) {
  11619. if (page.percent < 100) {
  11620. break;
  11621. }
  11622. if (page.id === currentId && isSimpleLayout) {
  11623. stillFullyVisible = true;
  11624. break;
  11625. }
  11626. }
  11627. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  11628. this._updateLocation(visible.first);
  11629. this.eventBus.dispatch("updateviewarea", {
  11630. source: this,
  11631. location: this._location
  11632. });
  11633. }
  11634. containsElement(element) {
  11635. return this.container.contains(element);
  11636. }
  11637. focus() {
  11638. this.container.focus();
  11639. }
  11640. get _isContainerRtl() {
  11641. return getComputedStyle(this.container).direction === "rtl";
  11642. }
  11643. get isInPresentationMode() {
  11644. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11645. }
  11646. get isChangingPresentationMode() {
  11647. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11648. }
  11649. get isHorizontalScrollbarEnabled() {
  11650. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11651. }
  11652. get isVerticalScrollbarEnabled() {
  11653. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11654. }
  11655. _getVisiblePages() {
  11656. const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
  11657. horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
  11658. rtl = horizontal && this._isContainerRtl;
  11659. return (0, _ui_utils.getVisibleElements)({
  11660. scrollEl: this.container,
  11661. views,
  11662. sortByVisibility: true,
  11663. horizontal,
  11664. rtl
  11665. });
  11666. }
  11667. cleanup() {
  11668. for (const pageView of this._pages) {
  11669. if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11670. pageView.reset();
  11671. }
  11672. }
  11673. }
  11674. _cancelRendering() {
  11675. for (const pageView of this._pages) {
  11676. pageView.cancelRendering();
  11677. }
  11678. }
  11679. async #ensurePdfPageLoaded(pageView) {
  11680. if (pageView.pdfPage) {
  11681. return pageView.pdfPage;
  11682. }
  11683. try {
  11684. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  11685. if (!pageView.pdfPage) {
  11686. pageView.setPdfPage(pdfPage);
  11687. }
  11688. if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
  11689. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  11690. }
  11691. return pdfPage;
  11692. } catch (reason) {
  11693. console.error("Unable to get page for page view", reason);
  11694. return null;
  11695. }
  11696. }
  11697. #getScrollAhead(visible) {
  11698. if (visible.first?.id === 1) {
  11699. return true;
  11700. } else if (visible.last?.id === this.pagesCount) {
  11701. return false;
  11702. }
  11703. switch (this._scrollMode) {
  11704. case _ui_utils.ScrollMode.PAGE:
  11705. return this.#scrollModePageState.scrollDown;
  11706. case _ui_utils.ScrollMode.HORIZONTAL:
  11707. return this.scroll.right;
  11708. }
  11709. return this.scroll.down;
  11710. }
  11711. forceRendering(currentlyVisiblePages) {
  11712. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11713. const scrollAhead = this.#getScrollAhead(visiblePages);
  11714. const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
  11715. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  11716. if (pageView) {
  11717. this.#ensurePdfPageLoaded(pageView).then(() => {
  11718. this.renderingQueue.renderView(pageView);
  11719. });
  11720. return true;
  11721. }
  11722. return false;
  11723. }
  11724. get hasEqualPageSizes() {
  11725. const firstPageView = this._pages[0];
  11726. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  11727. const pageView = this._pages[i];
  11728. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11729. return false;
  11730. }
  11731. }
  11732. return true;
  11733. }
  11734. getPagesOverview() {
  11735. let initialOrientation;
  11736. return this._pages.map(pageView => {
  11737. const viewport = pageView.pdfPage.getViewport({
  11738. scale: 1
  11739. });
  11740. const orientation = (0, _ui_utils.isPortraitOrientation)(viewport);
  11741. if (initialOrientation === undefined) {
  11742. initialOrientation = orientation;
  11743. } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
  11744. return {
  11745. width: viewport.height,
  11746. height: viewport.width,
  11747. rotation: (viewport.rotation - 90) % 360
  11748. };
  11749. }
  11750. return {
  11751. width: viewport.width,
  11752. height: viewport.height,
  11753. rotation: viewport.rotation
  11754. };
  11755. });
  11756. }
  11757. get optionalContentConfigPromise() {
  11758. if (!this.pdfDocument) {
  11759. return Promise.resolve(null);
  11760. }
  11761. if (!this._optionalContentConfigPromise) {
  11762. console.error("optionalContentConfigPromise: Not initialized yet.");
  11763. return this.pdfDocument.getOptionalContentConfig();
  11764. }
  11765. return this._optionalContentConfigPromise;
  11766. }
  11767. set optionalContentConfigPromise(promise) {
  11768. if (!(promise instanceof Promise)) {
  11769. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  11770. }
  11771. if (!this.pdfDocument) {
  11772. return;
  11773. }
  11774. if (!this._optionalContentConfigPromise) {
  11775. return;
  11776. }
  11777. this._optionalContentConfigPromise = promise;
  11778. this.refresh(false, {
  11779. optionalContentConfigPromise: promise
  11780. });
  11781. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11782. source: this,
  11783. promise
  11784. });
  11785. }
  11786. get scrollMode() {
  11787. return this._scrollMode;
  11788. }
  11789. set scrollMode(mode) {
  11790. if (this._scrollMode === mode) {
  11791. return;
  11792. }
  11793. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11794. throw new Error(`Invalid scroll mode: ${mode}`);
  11795. }
  11796. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11797. return;
  11798. }
  11799. this._previousScrollMode = this._scrollMode;
  11800. this._scrollMode = mode;
  11801. this.eventBus.dispatch("scrollmodechanged", {
  11802. source: this,
  11803. mode
  11804. });
  11805. this._updateScrollMode(this._currentPageNumber);
  11806. }
  11807. _updateScrollMode() {
  11808. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11809. const scrollMode = this._scrollMode,
  11810. viewer = this.viewer;
  11811. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11812. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11813. if (!this.pdfDocument || !pageNumber) {
  11814. return;
  11815. }
  11816. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  11817. this.#ensurePageViewVisible();
  11818. } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
  11819. this._updateSpreadMode();
  11820. }
  11821. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11822. this.#setScale(this._currentScaleValue, {
  11823. noScroll: true
  11824. });
  11825. }
  11826. this._setCurrentPageNumber(pageNumber, true);
  11827. this.update();
  11828. }
  11829. get spreadMode() {
  11830. return this._spreadMode;
  11831. }
  11832. set spreadMode(mode) {
  11833. if (this._spreadMode === mode) {
  11834. return;
  11835. }
  11836. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11837. throw new Error(`Invalid spread mode: ${mode}`);
  11838. }
  11839. this._spreadMode = mode;
  11840. this.eventBus.dispatch("spreadmodechanged", {
  11841. source: this,
  11842. mode
  11843. });
  11844. this._updateSpreadMode(this._currentPageNumber);
  11845. }
  11846. _updateSpreadMode() {
  11847. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11848. if (!this.pdfDocument) {
  11849. return;
  11850. }
  11851. const viewer = this.viewer,
  11852. pages = this._pages;
  11853. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11854. this.#ensurePageViewVisible();
  11855. } else {
  11856. viewer.textContent = "";
  11857. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11858. for (const pageView of this._pages) {
  11859. viewer.append(pageView.div);
  11860. }
  11861. } else {
  11862. const parity = this._spreadMode - 1;
  11863. let spread = null;
  11864. for (let i = 0, ii = pages.length; i < ii; ++i) {
  11865. if (spread === null) {
  11866. spread = document.createElement("div");
  11867. spread.className = "spread";
  11868. viewer.append(spread);
  11869. } else if (i % 2 === parity) {
  11870. spread = spread.cloneNode(false);
  11871. viewer.append(spread);
  11872. }
  11873. spread.append(pages[i].div);
  11874. }
  11875. }
  11876. }
  11877. if (!pageNumber) {
  11878. return;
  11879. }
  11880. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11881. this.#setScale(this._currentScaleValue, {
  11882. noScroll: true
  11883. });
  11884. }
  11885. this._setCurrentPageNumber(pageNumber, true);
  11886. this.update();
  11887. }
  11888. _getPageAdvance(currentPageNumber) {
  11889. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11890. switch (this._scrollMode) {
  11891. case _ui_utils.ScrollMode.WRAPPED:
  11892. {
  11893. const {
  11894. views
  11895. } = this._getVisiblePages(),
  11896. pageLayout = new Map();
  11897. for (const {
  11898. id,
  11899. y,
  11900. percent,
  11901. widthPercent
  11902. } of views) {
  11903. if (percent === 0 || widthPercent < 100) {
  11904. continue;
  11905. }
  11906. let yArray = pageLayout.get(y);
  11907. if (!yArray) {
  11908. pageLayout.set(y, yArray ||= []);
  11909. }
  11910. yArray.push(id);
  11911. }
  11912. for (const yArray of pageLayout.values()) {
  11913. const currentIndex = yArray.indexOf(currentPageNumber);
  11914. if (currentIndex === -1) {
  11915. continue;
  11916. }
  11917. const numPages = yArray.length;
  11918. if (numPages === 1) {
  11919. break;
  11920. }
  11921. if (previous) {
  11922. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11923. const currentId = yArray[i],
  11924. expectedId = yArray[i + 1] - 1;
  11925. if (currentId < expectedId) {
  11926. return currentPageNumber - expectedId;
  11927. }
  11928. }
  11929. } else {
  11930. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  11931. const currentId = yArray[i],
  11932. expectedId = yArray[i - 1] + 1;
  11933. if (currentId > expectedId) {
  11934. return expectedId - currentPageNumber;
  11935. }
  11936. }
  11937. }
  11938. if (previous) {
  11939. const firstId = yArray[0];
  11940. if (firstId < currentPageNumber) {
  11941. return currentPageNumber - firstId + 1;
  11942. }
  11943. } else {
  11944. const lastId = yArray[numPages - 1];
  11945. if (lastId > currentPageNumber) {
  11946. return lastId - currentPageNumber + 1;
  11947. }
  11948. }
  11949. break;
  11950. }
  11951. break;
  11952. }
  11953. case _ui_utils.ScrollMode.HORIZONTAL:
  11954. {
  11955. break;
  11956. }
  11957. case _ui_utils.ScrollMode.PAGE:
  11958. case _ui_utils.ScrollMode.VERTICAL:
  11959. {
  11960. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11961. break;
  11962. }
  11963. const parity = this._spreadMode - 1;
  11964. if (previous && currentPageNumber % 2 !== parity) {
  11965. break;
  11966. } else if (!previous && currentPageNumber % 2 === parity) {
  11967. break;
  11968. }
  11969. const {
  11970. views
  11971. } = this._getVisiblePages(),
  11972. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11973. for (const {
  11974. id,
  11975. percent,
  11976. widthPercent
  11977. } of views) {
  11978. if (id !== expectedId) {
  11979. continue;
  11980. }
  11981. if (percent > 0 && widthPercent === 100) {
  11982. return 2;
  11983. }
  11984. break;
  11985. }
  11986. break;
  11987. }
  11988. }
  11989. return 1;
  11990. }
  11991. nextPage() {
  11992. const currentPageNumber = this._currentPageNumber,
  11993. pagesCount = this.pagesCount;
  11994. if (currentPageNumber >= pagesCount) {
  11995. return false;
  11996. }
  11997. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11998. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  11999. return true;
  12000. }
  12001. previousPage() {
  12002. const currentPageNumber = this._currentPageNumber;
  12003. if (currentPageNumber <= 1) {
  12004. return false;
  12005. }
  12006. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  12007. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  12008. return true;
  12009. }
  12010. increaseScale() {
  12011. let {
  12012. drawingDelay,
  12013. scaleFactor,
  12014. steps
  12015. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12016. if (!this.pdfDocument) {
  12017. return;
  12018. }
  12019. let newScale = this._currentScale;
  12020. if (scaleFactor > 1) {
  12021. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12022. } else {
  12023. steps ??= 1;
  12024. do {
  12025. newScale = Math.ceil((newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12026. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  12027. }
  12028. this.#setScale(Math.min(_ui_utils.MAX_SCALE, newScale), {
  12029. noScroll: false,
  12030. drawingDelay
  12031. });
  12032. }
  12033. decreaseScale() {
  12034. let {
  12035. drawingDelay,
  12036. scaleFactor,
  12037. steps
  12038. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12039. if (!this.pdfDocument) {
  12040. return;
  12041. }
  12042. let newScale = this._currentScale;
  12043. if (scaleFactor > 0 && scaleFactor < 1) {
  12044. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12045. } else {
  12046. steps ??= 1;
  12047. do {
  12048. newScale = Math.floor((newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12049. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  12050. }
  12051. this.#setScale(Math.max(_ui_utils.MIN_SCALE, newScale), {
  12052. noScroll: false,
  12053. drawingDelay
  12054. });
  12055. }
  12056. #updateContainerHeightCss() {
  12057. let height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.container.clientHeight;
  12058. if (height !== this.#previousContainerHeight) {
  12059. this.#previousContainerHeight = height;
  12060. _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`);
  12061. }
  12062. }
  12063. #resizeObserverCallback(entries) {
  12064. for (const entry of entries) {
  12065. if (entry.target === this.container) {
  12066. this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
  12067. this.#containerTopLeft = null;
  12068. break;
  12069. }
  12070. }
  12071. }
  12072. get containerTopLeft() {
  12073. return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
  12074. }
  12075. get annotationEditorMode() {
  12076. return this.#annotationEditorUIManager ? this.#annotationEditorMode : _pdfjsLib.AnnotationEditorType.DISABLE;
  12077. }
  12078. set annotationEditorMode(_ref6) {
  12079. let {
  12080. mode,
  12081. editId = null
  12082. } = _ref6;
  12083. if (!this.#annotationEditorUIManager) {
  12084. throw new Error(`The AnnotationEditor is not enabled.`);
  12085. }
  12086. if (this.#annotationEditorMode === mode) {
  12087. return;
  12088. }
  12089. if (!isValidAnnotationEditorMode(mode)) {
  12090. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  12091. }
  12092. if (!this.pdfDocument) {
  12093. return;
  12094. }
  12095. this.#annotationEditorMode = mode;
  12096. this.eventBus.dispatch("annotationeditormodechanged", {
  12097. source: this,
  12098. mode
  12099. });
  12100. this.#annotationEditorUIManager.updateMode(mode, editId);
  12101. }
  12102. set annotationEditorParams(_ref7) {
  12103. let {
  12104. type,
  12105. value
  12106. } = _ref7;
  12107. if (!this.#annotationEditorUIManager) {
  12108. throw new Error(`The AnnotationEditor is not enabled.`);
  12109. }
  12110. this.#annotationEditorUIManager.updateParams(type, value);
  12111. }
  12112. refresh() {
  12113. let noUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12114. let updateArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.create(null);
  12115. if (!this.pdfDocument) {
  12116. return;
  12117. }
  12118. for (const pageView of this._pages) {
  12119. pageView.update(updateArgs);
  12120. }
  12121. if (this.#scaleTimeoutId !== null) {
  12122. clearTimeout(this.#scaleTimeoutId);
  12123. this.#scaleTimeoutId = null;
  12124. }
  12125. if (!noUpdate) {
  12126. this.update();
  12127. }
  12128. }
  12129. }
  12130. exports.PDFViewer = PDFViewer;
  12131. /***/ }),
  12132. /* 147 */
  12133. /***/ ((__unused_webpack_module, exports) => {
  12134. Object.defineProperty(exports, "__esModule", ({
  12135. value: true
  12136. }));
  12137. exports.NullL10n = void 0;
  12138. exports.getL10nFallback = getL10nFallback;
  12139. const DEFAULT_L10N_STRINGS = {
  12140. of_pages: "of {{pagesCount}}",
  12141. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  12142. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  12143. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  12144. document_properties_date_string: "{{date}}, {{time}}",
  12145. document_properties_page_size_unit_inches: "in",
  12146. document_properties_page_size_unit_millimeters: "mm",
  12147. document_properties_page_size_orientation_portrait: "portrait",
  12148. document_properties_page_size_orientation_landscape: "landscape",
  12149. document_properties_page_size_name_a3: "A3",
  12150. document_properties_page_size_name_a4: "A4",
  12151. document_properties_page_size_name_letter: "Letter",
  12152. document_properties_page_size_name_legal: "Legal",
  12153. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  12154. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  12155. document_properties_linearized_yes: "Yes",
  12156. document_properties_linearized_no: "No",
  12157. additional_layers: "Additional Layers",
  12158. page_landmark: "Page {{page}}",
  12159. thumb_page_title: "Page {{page}}",
  12160. thumb_page_canvas: "Thumbnail of Page {{page}}",
  12161. find_reached_top: "Reached top of document, continued from bottom",
  12162. find_reached_bottom: "Reached end of document, continued from top",
  12163. "find_match_count[one]": "{{current}} of {{total}} match",
  12164. "find_match_count[other]": "{{current}} of {{total}} matches",
  12165. "find_match_count_limit[one]": "More than {{limit}} match",
  12166. "find_match_count_limit[other]": "More than {{limit}} matches",
  12167. find_not_found: "Phrase not found",
  12168. page_scale_width: "Page Width",
  12169. page_scale_fit: "Page Fit",
  12170. page_scale_auto: "Automatic Zoom",
  12171. page_scale_actual: "Actual Size",
  12172. page_scale_percent: "{{scale}}%",
  12173. loading_error: "An error occurred while loading the PDF.",
  12174. invalid_file_error: "Invalid or corrupted PDF file.",
  12175. missing_file_error: "Missing PDF file.",
  12176. unexpected_response_error: "Unexpected server response.",
  12177. rendering_error: "An error occurred while rendering the page.",
  12178. annotation_date_string: "{{date}}, {{time}}",
  12179. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  12180. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  12181. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
  12182. free_text2_default_content: "Start typing…",
  12183. editor_free_text2_aria_label: "Text Editor",
  12184. editor_ink2_aria_label: "Draw Editor",
  12185. editor_ink_canvas_aria_label: "User-created image"
  12186. };
  12187. {
  12188. DEFAULT_L10N_STRINGS.print_progress_percent = "{{progress}}%";
  12189. }
  12190. function getL10nFallback(key, args) {
  12191. switch (key) {
  12192. case "find_match_count":
  12193. key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
  12194. break;
  12195. case "find_match_count_limit":
  12196. key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
  12197. break;
  12198. }
  12199. return DEFAULT_L10N_STRINGS[key] || "";
  12200. }
  12201. function formatL10nValue(text, args) {
  12202. if (!args) {
  12203. return text;
  12204. }
  12205. return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  12206. return name in args ? args[name] : "{{" + name + "}}";
  12207. });
  12208. }
  12209. const NullL10n = {
  12210. async getLanguage() {
  12211. return "en-us";
  12212. },
  12213. async getDirection() {
  12214. return "ltr";
  12215. },
  12216. async get(key) {
  12217. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12218. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getL10nFallback(key, args);
  12219. return formatL10nValue(fallback, args);
  12220. },
  12221. async translate(element) {}
  12222. };
  12223. exports.NullL10n = NullL10n;
  12224. /***/ }),
  12225. /* 148 */
  12226. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12227. Object.defineProperty(exports, "__esModule", ({
  12228. value: true
  12229. }));
  12230. exports.PDFPageView = void 0;
  12231. __webpack_require__(89);
  12232. __webpack_require__(76);
  12233. var _pdfjsLib = __webpack_require__(122);
  12234. var _ui_utils = __webpack_require__(97);
  12235. var _annotation_editor_layer_builder = __webpack_require__(149);
  12236. var _annotation_layer_builder = __webpack_require__(150);
  12237. var _app_options = __webpack_require__(123);
  12238. var _l10n_utils = __webpack_require__(147);
  12239. var _pdf_link_service = __webpack_require__(125);
  12240. var _struct_tree_layer_builder = __webpack_require__(151);
  12241. var _text_accessibility = __webpack_require__(152);
  12242. var _text_highlighter = __webpack_require__(153);
  12243. var _text_layer_builder = __webpack_require__(154);
  12244. var _xfa_layer_builder = __webpack_require__(155);
  12245. const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  12246. const DEFAULT_LAYER_PROPERTIES = () => {
  12247. return null;
  12248. };
  12249. class PDFPageView {
  12250. #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  12251. #hasRestrictedScaling = false;
  12252. #layerProperties = null;
  12253. #loadingId = null;
  12254. #previousRotation = null;
  12255. #renderError = null;
  12256. #renderingState = _ui_utils.RenderingStates.INITIAL;
  12257. #textLayerMode = _ui_utils.TextLayerMode.ENABLE;
  12258. #useThumbnailCanvas = {
  12259. directDrawing: true,
  12260. initialOptionalContent: true,
  12261. regularAnnotations: true
  12262. };
  12263. #viewportMap = new WeakMap();
  12264. constructor(options) {
  12265. const container = options.container;
  12266. const defaultViewport = options.defaultViewport;
  12267. this.id = options.id;
  12268. this.renderingId = "page" + this.id;
  12269. this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
  12270. this.pdfPage = null;
  12271. this.pageLabel = null;
  12272. this.rotation = 0;
  12273. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  12274. this.viewport = defaultViewport;
  12275. this.pdfPageRotate = defaultViewport.rotation;
  12276. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  12277. this.#textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  12278. this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  12279. this.imageResourcesPath = options.imageResourcesPath || "";
  12280. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  12281. this.maxCanvasPixels = options.maxCanvasPixels ?? MAX_CANVAS_PIXELS;
  12282. this.pageColors = options.pageColors || null;
  12283. this.eventBus = options.eventBus;
  12284. this.renderingQueue = options.renderingQueue;
  12285. this.l10n = options.l10n || _l10n_utils.NullL10n;
  12286. this.renderTask = null;
  12287. this.resume = null;
  12288. this._isStandalone = !this.renderingQueue?.hasViewer();
  12289. this._container = container;
  12290. if (options.useOnlyCssZoom) {
  12291. console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
  12292. this.maxCanvasPixels = 0;
  12293. }
  12294. this._annotationCanvasMap = null;
  12295. this.annotationLayer = null;
  12296. this.annotationEditorLayer = null;
  12297. this.textLayer = null;
  12298. this.zoomLayer = null;
  12299. this.xfaLayer = null;
  12300. this.structTreeLayer = null;
  12301. const div = document.createElement("div");
  12302. div.className = "page";
  12303. div.setAttribute("data-page-number", this.id);
  12304. div.setAttribute("role", "region");
  12305. this.l10n.get("page_landmark", {
  12306. page: this.id
  12307. }).then(msg => {
  12308. div.setAttribute("aria-label", msg);
  12309. });
  12310. this.div = div;
  12311. this.#setDimensions();
  12312. container?.append(div);
  12313. if (this._isStandalone) {
  12314. container?.style.setProperty("--scale-factor", this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  12315. const {
  12316. optionalContentConfigPromise
  12317. } = options;
  12318. if (optionalContentConfigPromise) {
  12319. optionalContentConfigPromise.then(optionalContentConfig => {
  12320. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12321. return;
  12322. }
  12323. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12324. });
  12325. }
  12326. }
  12327. }
  12328. get renderingState() {
  12329. return this.#renderingState;
  12330. }
  12331. set renderingState(state) {
  12332. if (state === this.#renderingState) {
  12333. return;
  12334. }
  12335. this.#renderingState = state;
  12336. if (this.#loadingId) {
  12337. clearTimeout(this.#loadingId);
  12338. this.#loadingId = null;
  12339. }
  12340. switch (state) {
  12341. case _ui_utils.RenderingStates.PAUSED:
  12342. this.div.classList.remove("loading");
  12343. break;
  12344. case _ui_utils.RenderingStates.RUNNING:
  12345. this.div.classList.add("loadingIcon");
  12346. this.#loadingId = setTimeout(() => {
  12347. this.div.classList.add("loading");
  12348. this.#loadingId = null;
  12349. }, 0);
  12350. break;
  12351. case _ui_utils.RenderingStates.INITIAL:
  12352. case _ui_utils.RenderingStates.FINISHED:
  12353. this.div.classList.remove("loadingIcon", "loading");
  12354. break;
  12355. }
  12356. }
  12357. #setDimensions() {
  12358. const {
  12359. viewport
  12360. } = this;
  12361. if (this.pdfPage) {
  12362. if (this.#previousRotation === viewport.rotation) {
  12363. return;
  12364. }
  12365. this.#previousRotation = viewport.rotation;
  12366. }
  12367. (0, _pdfjsLib.setLayerDimensions)(this.div, viewport, true, false);
  12368. }
  12369. setPdfPage(pdfPage) {
  12370. if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
  12371. this._container?.style.setProperty("--hcm-highligh-filter", pdfPage.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  12372. }
  12373. this.pdfPage = pdfPage;
  12374. this.pdfPageRotate = pdfPage.rotate;
  12375. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12376. this.viewport = pdfPage.getViewport({
  12377. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12378. rotation: totalRotation
  12379. });
  12380. this.#setDimensions();
  12381. this.reset();
  12382. }
  12383. destroy() {
  12384. this.reset();
  12385. this.pdfPage?.cleanup();
  12386. }
  12387. get _textHighlighter() {
  12388. return (0, _pdfjsLib.shadow)(this, "_textHighlighter", new _text_highlighter.TextHighlighter({
  12389. pageIndex: this.id - 1,
  12390. eventBus: this.eventBus,
  12391. findController: this.#layerProperties().findController
  12392. }));
  12393. }
  12394. async #renderAnnotationLayer() {
  12395. let error = null;
  12396. try {
  12397. await this.annotationLayer.render(this.viewport, "display");
  12398. } catch (ex) {
  12399. console.error(`#renderAnnotationLayer: "${ex}".`);
  12400. error = ex;
  12401. } finally {
  12402. this.eventBus.dispatch("annotationlayerrendered", {
  12403. source: this,
  12404. pageNumber: this.id,
  12405. error
  12406. });
  12407. }
  12408. }
  12409. async #renderAnnotationEditorLayer() {
  12410. let error = null;
  12411. try {
  12412. await this.annotationEditorLayer.render(this.viewport, "display");
  12413. } catch (ex) {
  12414. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  12415. error = ex;
  12416. } finally {
  12417. this.eventBus.dispatch("annotationeditorlayerrendered", {
  12418. source: this,
  12419. pageNumber: this.id,
  12420. error
  12421. });
  12422. }
  12423. }
  12424. async #renderXfaLayer() {
  12425. let error = null;
  12426. try {
  12427. const result = await this.xfaLayer.render(this.viewport, "display");
  12428. if (result?.textDivs && this._textHighlighter) {
  12429. this.#buildXfaTextContentItems(result.textDivs);
  12430. }
  12431. } catch (ex) {
  12432. console.error(`#renderXfaLayer: "${ex}".`);
  12433. error = ex;
  12434. } finally {
  12435. this.eventBus.dispatch("xfalayerrendered", {
  12436. source: this,
  12437. pageNumber: this.id,
  12438. error
  12439. });
  12440. }
  12441. }
  12442. async #renderTextLayer() {
  12443. const {
  12444. pdfPage,
  12445. textLayer,
  12446. viewport
  12447. } = this;
  12448. if (!textLayer) {
  12449. return;
  12450. }
  12451. let error = null;
  12452. try {
  12453. if (!textLayer.renderingDone) {
  12454. const readableStream = pdfPage.streamTextContent({
  12455. includeMarkedContent: true,
  12456. disableNormalization: true
  12457. });
  12458. textLayer.setTextContentSource(readableStream);
  12459. }
  12460. await textLayer.render(viewport);
  12461. } catch (ex) {
  12462. if (ex instanceof _pdfjsLib.AbortException) {
  12463. return;
  12464. }
  12465. console.error(`#renderTextLayer: "${ex}".`);
  12466. error = ex;
  12467. }
  12468. this.eventBus.dispatch("textlayerrendered", {
  12469. source: this,
  12470. pageNumber: this.id,
  12471. numTextDivs: textLayer.numTextDivs,
  12472. error
  12473. });
  12474. this.#renderStructTreeLayer();
  12475. }
  12476. async #renderStructTreeLayer() {
  12477. if (!this.textLayer) {
  12478. return;
  12479. }
  12480. this.structTreeLayer ||= new _struct_tree_layer_builder.StructTreeLayerBuilder();
  12481. const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
  12482. const treeDom = this.structTreeLayer?.render(tree);
  12483. if (treeDom) {
  12484. this.canvas?.append(treeDom);
  12485. }
  12486. this.structTreeLayer?.show();
  12487. }
  12488. async #buildXfaTextContentItems(textDivs) {
  12489. const text = await this.pdfPage.getTextContent();
  12490. const items = [];
  12491. for (const item of text.items) {
  12492. items.push(item.str);
  12493. }
  12494. this._textHighlighter.setTextMapping(textDivs, items);
  12495. this._textHighlighter.enable();
  12496. }
  12497. _resetZoomLayer() {
  12498. let removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12499. if (!this.zoomLayer) {
  12500. return;
  12501. }
  12502. const zoomLayerCanvas = this.zoomLayer.firstChild;
  12503. this.#viewportMap.delete(zoomLayerCanvas);
  12504. zoomLayerCanvas.width = 0;
  12505. zoomLayerCanvas.height = 0;
  12506. if (removeFromDOM) {
  12507. this.zoomLayer.remove();
  12508. }
  12509. this.zoomLayer = null;
  12510. }
  12511. reset() {
  12512. let {
  12513. keepZoomLayer = false,
  12514. keepAnnotationLayer = false,
  12515. keepAnnotationEditorLayer = false,
  12516. keepXfaLayer = false,
  12517. keepTextLayer = false
  12518. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12519. this.cancelRendering({
  12520. keepAnnotationLayer,
  12521. keepAnnotationEditorLayer,
  12522. keepXfaLayer,
  12523. keepTextLayer
  12524. });
  12525. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  12526. const div = this.div;
  12527. const childNodes = div.childNodes,
  12528. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  12529. annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
  12530. annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
  12531. xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
  12532. textLayerNode = keepTextLayer && this.textLayer?.div || null;
  12533. for (let i = childNodes.length - 1; i >= 0; i--) {
  12534. const node = childNodes[i];
  12535. switch (node) {
  12536. case zoomLayerNode:
  12537. case annotationLayerNode:
  12538. case annotationEditorLayerNode:
  12539. case xfaLayerNode:
  12540. case textLayerNode:
  12541. continue;
  12542. }
  12543. node.remove();
  12544. }
  12545. div.removeAttribute("data-loaded");
  12546. if (annotationLayerNode) {
  12547. this.annotationLayer.hide();
  12548. }
  12549. if (annotationEditorLayerNode) {
  12550. this.annotationEditorLayer.hide();
  12551. }
  12552. if (xfaLayerNode) {
  12553. this.xfaLayer.hide();
  12554. }
  12555. if (textLayerNode) {
  12556. this.textLayer.hide();
  12557. }
  12558. this.structTreeLayer?.hide();
  12559. if (!zoomLayerNode) {
  12560. if (this.canvas) {
  12561. this.#viewportMap.delete(this.canvas);
  12562. this.canvas.width = 0;
  12563. this.canvas.height = 0;
  12564. delete this.canvas;
  12565. }
  12566. this._resetZoomLayer();
  12567. }
  12568. }
  12569. update(_ref) {
  12570. let {
  12571. scale = 0,
  12572. rotation = null,
  12573. optionalContentConfigPromise = null,
  12574. drawingDelay = -1
  12575. } = _ref;
  12576. this.scale = scale || this.scale;
  12577. if (typeof rotation === "number") {
  12578. this.rotation = rotation;
  12579. }
  12580. if (optionalContentConfigPromise instanceof Promise) {
  12581. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12582. optionalContentConfigPromise.then(optionalContentConfig => {
  12583. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12584. return;
  12585. }
  12586. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12587. });
  12588. }
  12589. this.#useThumbnailCanvas.directDrawing = true;
  12590. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12591. this.viewport = this.viewport.clone({
  12592. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12593. rotation: totalRotation
  12594. });
  12595. this.#setDimensions();
  12596. if (this._isStandalone) {
  12597. this._container?.style.setProperty("--scale-factor", this.viewport.scale);
  12598. }
  12599. if (this.canvas) {
  12600. let onlyCssZoom = false;
  12601. if (this.#hasRestrictedScaling) {
  12602. if (this.maxCanvasPixels === 0) {
  12603. onlyCssZoom = true;
  12604. } else if (this.maxCanvasPixels > 0) {
  12605. const {
  12606. width,
  12607. height
  12608. } = this.viewport;
  12609. const {
  12610. sx,
  12611. sy
  12612. } = this.outputScale;
  12613. onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
  12614. }
  12615. }
  12616. const postponeDrawing = !onlyCssZoom && drawingDelay >= 0 && drawingDelay < 1000;
  12617. if (postponeDrawing || onlyCssZoom) {
  12618. if (postponeDrawing && this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  12619. this.cancelRendering({
  12620. keepZoomLayer: true,
  12621. keepAnnotationLayer: true,
  12622. keepAnnotationEditorLayer: true,
  12623. keepXfaLayer: true,
  12624. keepTextLayer: true,
  12625. cancelExtraDelay: drawingDelay
  12626. });
  12627. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12628. this.#useThumbnailCanvas.directDrawing = false;
  12629. }
  12630. this.cssTransform({
  12631. target: this.canvas,
  12632. redrawAnnotationLayer: true,
  12633. redrawAnnotationEditorLayer: true,
  12634. redrawXfaLayer: true,
  12635. redrawTextLayer: !postponeDrawing,
  12636. hideTextLayer: postponeDrawing
  12637. });
  12638. if (postponeDrawing) {
  12639. return;
  12640. }
  12641. this.eventBus.dispatch("pagerendered", {
  12642. source: this,
  12643. pageNumber: this.id,
  12644. cssTransform: true,
  12645. timestamp: performance.now(),
  12646. error: this.#renderError
  12647. });
  12648. return;
  12649. }
  12650. if (!this.zoomLayer && !this.canvas.hidden) {
  12651. this.zoomLayer = this.canvas.parentNode;
  12652. this.zoomLayer.style.position = "absolute";
  12653. }
  12654. }
  12655. if (this.zoomLayer) {
  12656. this.cssTransform({
  12657. target: this.zoomLayer.firstChild
  12658. });
  12659. }
  12660. this.reset({
  12661. keepZoomLayer: true,
  12662. keepAnnotationLayer: true,
  12663. keepAnnotationEditorLayer: true,
  12664. keepXfaLayer: true,
  12665. keepTextLayer: true
  12666. });
  12667. }
  12668. cancelRendering() {
  12669. let {
  12670. keepAnnotationLayer = false,
  12671. keepAnnotationEditorLayer = false,
  12672. keepXfaLayer = false,
  12673. keepTextLayer = false,
  12674. cancelExtraDelay = 0
  12675. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12676. if (this.renderTask) {
  12677. this.renderTask.cancel(cancelExtraDelay);
  12678. this.renderTask = null;
  12679. }
  12680. this.resume = null;
  12681. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  12682. this.textLayer.cancel();
  12683. this.textLayer = null;
  12684. }
  12685. if (this.structTreeLayer && !this.textLayer) {
  12686. this.structTreeLayer = null;
  12687. }
  12688. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  12689. this.annotationLayer.cancel();
  12690. this.annotationLayer = null;
  12691. this._annotationCanvasMap = null;
  12692. }
  12693. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  12694. this.annotationEditorLayer.cancel();
  12695. this.annotationEditorLayer = null;
  12696. }
  12697. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  12698. this.xfaLayer.cancel();
  12699. this.xfaLayer = null;
  12700. this._textHighlighter?.disable();
  12701. }
  12702. }
  12703. cssTransform(_ref2) {
  12704. let {
  12705. target,
  12706. redrawAnnotationLayer = false,
  12707. redrawAnnotationEditorLayer = false,
  12708. redrawXfaLayer = false,
  12709. redrawTextLayer = false,
  12710. hideTextLayer = false
  12711. } = _ref2;
  12712. if (!target.hasAttribute("zooming")) {
  12713. target.setAttribute("zooming", true);
  12714. const {
  12715. style
  12716. } = target;
  12717. style.width = style.height = "";
  12718. }
  12719. const originalViewport = this.#viewportMap.get(target);
  12720. if (this.viewport !== originalViewport) {
  12721. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  12722. const absRotation = Math.abs(relativeRotation);
  12723. let scaleX = 1,
  12724. scaleY = 1;
  12725. if (absRotation === 90 || absRotation === 270) {
  12726. const {
  12727. width,
  12728. height
  12729. } = this.viewport;
  12730. scaleX = height / width;
  12731. scaleY = width / height;
  12732. }
  12733. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  12734. }
  12735. if (redrawAnnotationLayer && this.annotationLayer) {
  12736. this.#renderAnnotationLayer();
  12737. }
  12738. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  12739. this.#renderAnnotationEditorLayer();
  12740. }
  12741. if (redrawXfaLayer && this.xfaLayer) {
  12742. this.#renderXfaLayer();
  12743. }
  12744. if (this.textLayer) {
  12745. if (hideTextLayer) {
  12746. this.textLayer.hide();
  12747. this.structTreeLayer?.hide();
  12748. } else if (redrawTextLayer) {
  12749. this.#renderTextLayer();
  12750. }
  12751. }
  12752. }
  12753. get width() {
  12754. return this.viewport.width;
  12755. }
  12756. get height() {
  12757. return this.viewport.height;
  12758. }
  12759. getPagePoint(x, y) {
  12760. return this.viewport.convertToPdfPoint(x, y);
  12761. }
  12762. async #finishRenderTask(renderTask) {
  12763. let error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12764. if (renderTask === this.renderTask) {
  12765. this.renderTask = null;
  12766. }
  12767. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  12768. this.#renderError = null;
  12769. return;
  12770. }
  12771. this.#renderError = error;
  12772. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12773. this._resetZoomLayer(true);
  12774. this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
  12775. this.eventBus.dispatch("pagerendered", {
  12776. source: this,
  12777. pageNumber: this.id,
  12778. cssTransform: false,
  12779. timestamp: performance.now(),
  12780. error: this.#renderError
  12781. });
  12782. if (error) {
  12783. throw error;
  12784. }
  12785. }
  12786. async draw() {
  12787. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  12788. console.error("Must be in new state before drawing");
  12789. this.reset();
  12790. }
  12791. const {
  12792. div,
  12793. l10n,
  12794. pageColors,
  12795. pdfPage,
  12796. viewport
  12797. } = this;
  12798. if (!pdfPage) {
  12799. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12800. throw new Error("pdfPage is not loaded");
  12801. }
  12802. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12803. const canvasWrapper = document.createElement("div");
  12804. canvasWrapper.classList.add("canvasWrapper");
  12805. div.append(canvasWrapper);
  12806. if (!this.textLayer && this.#textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  12807. this._accessibilityManager ||= new _text_accessibility.TextAccessibilityManager();
  12808. this.textLayer = new _text_layer_builder.TextLayerBuilder({
  12809. highlighter: this._textHighlighter,
  12810. accessibilityManager: this._accessibilityManager,
  12811. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  12812. enablePermissions: this.#textLayerMode === _ui_utils.TextLayerMode.ENABLE_PERMISSIONS
  12813. });
  12814. div.append(this.textLayer.div);
  12815. }
  12816. if (!this.annotationLayer && this.#annotationMode !== _pdfjsLib.AnnotationMode.DISABLE) {
  12817. const {
  12818. annotationStorage,
  12819. downloadManager,
  12820. enableScripting,
  12821. fieldObjectsPromise,
  12822. hasJSActionsPromise,
  12823. linkService
  12824. } = this.#layerProperties();
  12825. this._annotationCanvasMap ||= new Map();
  12826. this.annotationLayer = new _annotation_layer_builder.AnnotationLayerBuilder({
  12827. pageDiv: div,
  12828. pdfPage,
  12829. annotationStorage,
  12830. imageResourcesPath: this.imageResourcesPath,
  12831. renderForms: this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS,
  12832. linkService,
  12833. downloadManager,
  12834. l10n,
  12835. enableScripting,
  12836. hasJSActionsPromise,
  12837. fieldObjectsPromise,
  12838. annotationCanvasMap: this._annotationCanvasMap,
  12839. accessibilityManager: this._accessibilityManager
  12840. });
  12841. }
  12842. const renderContinueCallback = cont => {
  12843. showCanvas?.(false);
  12844. if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
  12845. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  12846. this.resume = () => {
  12847. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12848. cont();
  12849. };
  12850. return;
  12851. }
  12852. cont();
  12853. };
  12854. const {
  12855. width,
  12856. height
  12857. } = viewport;
  12858. const canvas = document.createElement("canvas");
  12859. canvas.setAttribute("role", "presentation");
  12860. canvas.hidden = true;
  12861. const hasHCM = !!(pageColors?.background && pageColors?.foreground);
  12862. let showCanvas = isLastShow => {
  12863. if (!hasHCM || isLastShow) {
  12864. canvas.hidden = false;
  12865. showCanvas = null;
  12866. }
  12867. };
  12868. canvasWrapper.append(canvas);
  12869. this.canvas = canvas;
  12870. const ctx = canvas.getContext("2d", {
  12871. alpha: false
  12872. });
  12873. const outputScale = this.outputScale = new _ui_utils.OutputScale();
  12874. if (this.maxCanvasPixels === 0) {
  12875. const invScale = 1 / this.scale;
  12876. outputScale.sx *= invScale;
  12877. outputScale.sy *= invScale;
  12878. this.#hasRestrictedScaling = true;
  12879. } else if (this.maxCanvasPixels > 0) {
  12880. const pixelsInViewport = width * height;
  12881. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12882. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12883. outputScale.sx = maxScale;
  12884. outputScale.sy = maxScale;
  12885. this.#hasRestrictedScaling = true;
  12886. } else {
  12887. this.#hasRestrictedScaling = false;
  12888. }
  12889. }
  12890. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12891. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12892. canvas.width = (0, _ui_utils.roundToDivide)(width * outputScale.sx, sfx[0]);
  12893. canvas.height = (0, _ui_utils.roundToDivide)(height * outputScale.sy, sfy[0]);
  12894. const {
  12895. style
  12896. } = canvas;
  12897. style.width = (0, _ui_utils.roundToDivide)(width, sfx[1]) + "px";
  12898. style.height = (0, _ui_utils.roundToDivide)(height, sfy[1]) + "px";
  12899. this.#viewportMap.set(canvas, viewport);
  12900. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  12901. const renderContext = {
  12902. canvasContext: ctx,
  12903. transform,
  12904. viewport,
  12905. annotationMode: this.#annotationMode,
  12906. optionalContentConfigPromise: this._optionalContentConfigPromise,
  12907. annotationCanvasMap: this._annotationCanvasMap,
  12908. pageColors
  12909. };
  12910. const renderTask = this.renderTask = this.pdfPage.render(renderContext);
  12911. renderTask.onContinue = renderContinueCallback;
  12912. const resultPromise = renderTask.promise.then(async () => {
  12913. showCanvas?.(true);
  12914. await this.#finishRenderTask(renderTask);
  12915. this.#renderTextLayer();
  12916. if (this.annotationLayer) {
  12917. await this.#renderAnnotationLayer();
  12918. }
  12919. if (!this.annotationEditorLayer) {
  12920. const {
  12921. annotationEditorUIManager
  12922. } = this.#layerProperties();
  12923. if (!annotationEditorUIManager) {
  12924. return;
  12925. }
  12926. this.annotationEditorLayer = new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
  12927. uiManager: annotationEditorUIManager,
  12928. pageDiv: div,
  12929. pdfPage,
  12930. l10n,
  12931. accessibilityManager: this._accessibilityManager,
  12932. annotationLayer: this.annotationLayer?.annotationLayer
  12933. });
  12934. }
  12935. this.#renderAnnotationEditorLayer();
  12936. }, error => {
  12937. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12938. showCanvas?.(true);
  12939. }
  12940. return this.#finishRenderTask(renderTask, error);
  12941. });
  12942. if (pdfPage.isPureXfa) {
  12943. if (!this.xfaLayer) {
  12944. const {
  12945. annotationStorage,
  12946. linkService
  12947. } = this.#layerProperties();
  12948. this.xfaLayer = new _xfa_layer_builder.XfaLayerBuilder({
  12949. pageDiv: div,
  12950. pdfPage,
  12951. annotationStorage,
  12952. linkService
  12953. });
  12954. } else if (this.xfaLayer.div) {
  12955. div.append(this.xfaLayer.div);
  12956. }
  12957. this.#renderXfaLayer();
  12958. }
  12959. div.setAttribute("data-loaded", true);
  12960. this.eventBus.dispatch("pagerender", {
  12961. source: this,
  12962. pageNumber: this.id
  12963. });
  12964. return resultPromise;
  12965. }
  12966. setPageLabel(label) {
  12967. this.pageLabel = typeof label === "string" ? label : null;
  12968. if (this.pageLabel !== null) {
  12969. this.div.setAttribute("data-page-label", this.pageLabel);
  12970. } else {
  12971. this.div.removeAttribute("data-page-label");
  12972. }
  12973. }
  12974. get thumbnailCanvas() {
  12975. const {
  12976. directDrawing,
  12977. initialOptionalContent,
  12978. regularAnnotations
  12979. } = this.#useThumbnailCanvas;
  12980. return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
  12981. }
  12982. }
  12983. exports.PDFPageView = PDFPageView;
  12984. /***/ }),
  12985. /* 149 */
  12986. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12987. Object.defineProperty(exports, "__esModule", ({
  12988. value: true
  12989. }));
  12990. exports.AnnotationEditorLayerBuilder = void 0;
  12991. var _pdfjsLib = __webpack_require__(122);
  12992. var _l10n_utils = __webpack_require__(147);
  12993. class AnnotationEditorLayerBuilder {
  12994. #annotationLayer = null;
  12995. #uiManager;
  12996. constructor(options) {
  12997. this.pageDiv = options.pageDiv;
  12998. this.pdfPage = options.pdfPage;
  12999. this.accessibilityManager = options.accessibilityManager;
  13000. this.l10n = options.l10n || _l10n_utils.NullL10n;
  13001. this.annotationEditorLayer = null;
  13002. this.div = null;
  13003. this._cancelled = false;
  13004. this.#uiManager = options.uiManager;
  13005. this.#annotationLayer = options.annotationLayer || null;
  13006. }
  13007. async render(viewport) {
  13008. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13009. if (intent !== "display") {
  13010. return;
  13011. }
  13012. if (this._cancelled) {
  13013. return;
  13014. }
  13015. const clonedViewport = viewport.clone({
  13016. dontFlip: true
  13017. });
  13018. if (this.div) {
  13019. this.annotationEditorLayer.update({
  13020. viewport: clonedViewport
  13021. });
  13022. this.show();
  13023. return;
  13024. }
  13025. const div = this.div = document.createElement("div");
  13026. div.className = "annotationEditorLayer";
  13027. div.tabIndex = 0;
  13028. div.hidden = true;
  13029. this.pageDiv.append(div);
  13030. this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({
  13031. uiManager: this.#uiManager,
  13032. div,
  13033. accessibilityManager: this.accessibilityManager,
  13034. pageIndex: this.pdfPage.pageNumber - 1,
  13035. l10n: this.l10n,
  13036. viewport: clonedViewport,
  13037. annotationLayer: this.#annotationLayer
  13038. });
  13039. const parameters = {
  13040. viewport: clonedViewport,
  13041. div,
  13042. annotations: null,
  13043. intent
  13044. };
  13045. this.annotationEditorLayer.render(parameters);
  13046. this.show();
  13047. }
  13048. cancel() {
  13049. this._cancelled = true;
  13050. if (!this.div) {
  13051. return;
  13052. }
  13053. this.pageDiv = null;
  13054. this.annotationEditorLayer.destroy();
  13055. this.div.remove();
  13056. }
  13057. hide() {
  13058. if (!this.div) {
  13059. return;
  13060. }
  13061. this.div.hidden = true;
  13062. }
  13063. show() {
  13064. if (!this.div || this.annotationEditorLayer.isEmpty) {
  13065. return;
  13066. }
  13067. this.div.hidden = false;
  13068. }
  13069. }
  13070. exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
  13071. /***/ }),
  13072. /* 150 */
  13073. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13074. Object.defineProperty(exports, "__esModule", ({
  13075. value: true
  13076. }));
  13077. exports.AnnotationLayerBuilder = void 0;
  13078. var _pdfjsLib = __webpack_require__(122);
  13079. var _l10n_utils = __webpack_require__(147);
  13080. var _ui_utils = __webpack_require__(97);
  13081. class AnnotationLayerBuilder {
  13082. #onPresentationModeChanged = null;
  13083. constructor(_ref) {
  13084. let {
  13085. pageDiv,
  13086. pdfPage,
  13087. linkService,
  13088. downloadManager,
  13089. annotationStorage = null,
  13090. imageResourcesPath = "",
  13091. renderForms = true,
  13092. l10n = _l10n_utils.NullL10n,
  13093. enableScripting = false,
  13094. hasJSActionsPromise = null,
  13095. fieldObjectsPromise = null,
  13096. annotationCanvasMap = null,
  13097. accessibilityManager = null
  13098. } = _ref;
  13099. this.pageDiv = pageDiv;
  13100. this.pdfPage = pdfPage;
  13101. this.linkService = linkService;
  13102. this.downloadManager = downloadManager;
  13103. this.imageResourcesPath = imageResourcesPath;
  13104. this.renderForms = renderForms;
  13105. this.l10n = l10n;
  13106. this.annotationStorage = annotationStorage;
  13107. this.enableScripting = enableScripting;
  13108. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  13109. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  13110. this._annotationCanvasMap = annotationCanvasMap;
  13111. this._accessibilityManager = accessibilityManager;
  13112. this.annotationLayer = null;
  13113. this.div = null;
  13114. this._cancelled = false;
  13115. this._eventBus = linkService.eventBus;
  13116. }
  13117. async render(viewport) {
  13118. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13119. if (this.div) {
  13120. if (this._cancelled || !this.annotationLayer) {
  13121. return;
  13122. }
  13123. this.annotationLayer.update({
  13124. viewport: viewport.clone({
  13125. dontFlip: true
  13126. })
  13127. });
  13128. return;
  13129. }
  13130. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  13131. intent
  13132. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  13133. if (this._cancelled) {
  13134. return;
  13135. }
  13136. const div = this.div = document.createElement("div");
  13137. div.className = "annotationLayer";
  13138. this.pageDiv.append(div);
  13139. if (annotations.length === 0) {
  13140. this.hide();
  13141. return;
  13142. }
  13143. this.annotationLayer = new _pdfjsLib.AnnotationLayer({
  13144. div,
  13145. accessibilityManager: this._accessibilityManager,
  13146. annotationCanvasMap: this._annotationCanvasMap,
  13147. l10n: this.l10n,
  13148. page: this.pdfPage,
  13149. viewport: viewport.clone({
  13150. dontFlip: true
  13151. })
  13152. });
  13153. await this.annotationLayer.render({
  13154. annotations,
  13155. imageResourcesPath: this.imageResourcesPath,
  13156. renderForms: this.renderForms,
  13157. linkService: this.linkService,
  13158. downloadManager: this.downloadManager,
  13159. annotationStorage: this.annotationStorage,
  13160. enableScripting: this.enableScripting,
  13161. hasJSActions,
  13162. fieldObjects
  13163. });
  13164. if (this.linkService.isInPresentationMode) {
  13165. this.#updatePresentationModeState(_ui_utils.PresentationModeState.FULLSCREEN);
  13166. }
  13167. if (!this.#onPresentationModeChanged) {
  13168. this.#onPresentationModeChanged = evt => {
  13169. this.#updatePresentationModeState(evt.state);
  13170. };
  13171. this._eventBus?._on("presentationmodechanged", this.#onPresentationModeChanged);
  13172. }
  13173. }
  13174. cancel() {
  13175. this._cancelled = true;
  13176. if (this.#onPresentationModeChanged) {
  13177. this._eventBus?._off("presentationmodechanged", this.#onPresentationModeChanged);
  13178. this.#onPresentationModeChanged = null;
  13179. }
  13180. }
  13181. hide() {
  13182. if (!this.div) {
  13183. return;
  13184. }
  13185. this.div.hidden = true;
  13186. }
  13187. #updatePresentationModeState(state) {
  13188. if (!this.div) {
  13189. return;
  13190. }
  13191. let disableFormElements = false;
  13192. switch (state) {
  13193. case _ui_utils.PresentationModeState.FULLSCREEN:
  13194. disableFormElements = true;
  13195. break;
  13196. case _ui_utils.PresentationModeState.NORMAL:
  13197. break;
  13198. default:
  13199. return;
  13200. }
  13201. for (const section of this.div.childNodes) {
  13202. if (section.hasAttribute("data-internal-link")) {
  13203. continue;
  13204. }
  13205. section.inert = disableFormElements;
  13206. }
  13207. }
  13208. }
  13209. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  13210. /***/ }),
  13211. /* 151 */
  13212. /***/ ((__unused_webpack_module, exports) => {
  13213. Object.defineProperty(exports, "__esModule", ({
  13214. value: true
  13215. }));
  13216. exports.StructTreeLayerBuilder = void 0;
  13217. const PDF_ROLE_TO_HTML_ROLE = {
  13218. Document: null,
  13219. DocumentFragment: null,
  13220. Part: "group",
  13221. Sect: "group",
  13222. Div: "group",
  13223. Aside: "note",
  13224. NonStruct: "none",
  13225. P: null,
  13226. H: "heading",
  13227. Title: null,
  13228. FENote: "note",
  13229. Sub: "group",
  13230. Lbl: null,
  13231. Span: null,
  13232. Em: null,
  13233. Strong: null,
  13234. Link: "link",
  13235. Annot: "note",
  13236. Form: "form",
  13237. Ruby: null,
  13238. RB: null,
  13239. RT: null,
  13240. RP: null,
  13241. Warichu: null,
  13242. WT: null,
  13243. WP: null,
  13244. L: "list",
  13245. LI: "listitem",
  13246. LBody: null,
  13247. Table: "table",
  13248. TR: "row",
  13249. TH: "columnheader",
  13250. TD: "cell",
  13251. THead: "columnheader",
  13252. TBody: null,
  13253. TFoot: null,
  13254. Caption: null,
  13255. Figure: "figure",
  13256. Formula: null,
  13257. Artifact: null
  13258. };
  13259. const HEADING_PATTERN = /^H(\d+)$/;
  13260. class StructTreeLayerBuilder {
  13261. #treeDom = undefined;
  13262. get renderingDone() {
  13263. return this.#treeDom !== undefined;
  13264. }
  13265. render(structTree) {
  13266. if (this.#treeDom !== undefined) {
  13267. return this.#treeDom;
  13268. }
  13269. const treeDom = this.#walk(structTree);
  13270. treeDom?.classList.add("structTree");
  13271. return this.#treeDom = treeDom;
  13272. }
  13273. hide() {
  13274. if (this.#treeDom && !this.#treeDom.hidden) {
  13275. this.#treeDom.hidden = true;
  13276. }
  13277. }
  13278. show() {
  13279. if (this.#treeDom?.hidden) {
  13280. this.#treeDom.hidden = false;
  13281. }
  13282. }
  13283. #setAttributes(structElement, htmlElement) {
  13284. if (structElement.alt !== undefined) {
  13285. htmlElement.setAttribute("aria-label", structElement.alt);
  13286. }
  13287. if (structElement.id !== undefined) {
  13288. htmlElement.setAttribute("aria-owns", structElement.id);
  13289. }
  13290. if (structElement.lang !== undefined) {
  13291. htmlElement.setAttribute("lang", structElement.lang);
  13292. }
  13293. }
  13294. #walk(node) {
  13295. if (!node) {
  13296. return null;
  13297. }
  13298. const element = document.createElement("span");
  13299. if ("role" in node) {
  13300. const {
  13301. role
  13302. } = node;
  13303. const match = role.match(HEADING_PATTERN);
  13304. if (match) {
  13305. element.setAttribute("role", "heading");
  13306. element.setAttribute("aria-level", match[1]);
  13307. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  13308. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  13309. }
  13310. }
  13311. this.#setAttributes(node, element);
  13312. if (node.children) {
  13313. if (node.children.length === 1 && "id" in node.children[0]) {
  13314. this.#setAttributes(node.children[0], element);
  13315. } else {
  13316. for (const kid of node.children) {
  13317. element.append(this.#walk(kid));
  13318. }
  13319. }
  13320. }
  13321. return element;
  13322. }
  13323. }
  13324. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  13325. /***/ }),
  13326. /* 152 */
  13327. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13328. Object.defineProperty(exports, "__esModule", ({
  13329. value: true
  13330. }));
  13331. exports.TextAccessibilityManager = void 0;
  13332. __webpack_require__(76);
  13333. var _ui_utils = __webpack_require__(97);
  13334. class TextAccessibilityManager {
  13335. #enabled = false;
  13336. #textChildren = null;
  13337. #textNodes = new Map();
  13338. #waitingElements = new Map();
  13339. setTextMapping(textDivs) {
  13340. this.#textChildren = textDivs;
  13341. }
  13342. static #compareElementPositions(e1, e2) {
  13343. const rect1 = e1.getBoundingClientRect();
  13344. const rect2 = e2.getBoundingClientRect();
  13345. if (rect1.width === 0 && rect1.height === 0) {
  13346. return +1;
  13347. }
  13348. if (rect2.width === 0 && rect2.height === 0) {
  13349. return -1;
  13350. }
  13351. const top1 = rect1.y;
  13352. const bot1 = rect1.y + rect1.height;
  13353. const mid1 = rect1.y + rect1.height / 2;
  13354. const top2 = rect2.y;
  13355. const bot2 = rect2.y + rect2.height;
  13356. const mid2 = rect2.y + rect2.height / 2;
  13357. if (mid1 <= top2 && mid2 >= bot1) {
  13358. return -1;
  13359. }
  13360. if (mid2 <= top1 && mid1 >= bot2) {
  13361. return +1;
  13362. }
  13363. const centerX1 = rect1.x + rect1.width / 2;
  13364. const centerX2 = rect2.x + rect2.width / 2;
  13365. return centerX1 - centerX2;
  13366. }
  13367. enable() {
  13368. if (this.#enabled) {
  13369. throw new Error("TextAccessibilityManager is already enabled.");
  13370. }
  13371. if (!this.#textChildren) {
  13372. throw new Error("Text divs and strings have not been set.");
  13373. }
  13374. this.#enabled = true;
  13375. this.#textChildren = this.#textChildren.slice();
  13376. this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
  13377. if (this.#textNodes.size > 0) {
  13378. const textChildren = this.#textChildren;
  13379. for (const [id, nodeIndex] of this.#textNodes) {
  13380. const element = document.getElementById(id);
  13381. if (!element) {
  13382. this.#textNodes.delete(id);
  13383. continue;
  13384. }
  13385. this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
  13386. }
  13387. }
  13388. for (const [element, isRemovable] of this.#waitingElements) {
  13389. this.addPointerInTextLayer(element, isRemovable);
  13390. }
  13391. this.#waitingElements.clear();
  13392. }
  13393. disable() {
  13394. if (!this.#enabled) {
  13395. return;
  13396. }
  13397. this.#waitingElements.clear();
  13398. this.#textChildren = null;
  13399. this.#enabled = false;
  13400. }
  13401. removePointerInTextLayer(element) {
  13402. if (!this.#enabled) {
  13403. this.#waitingElements.delete(element);
  13404. return;
  13405. }
  13406. const children = this.#textChildren;
  13407. if (!children || children.length === 0) {
  13408. return;
  13409. }
  13410. const {
  13411. id
  13412. } = element;
  13413. const nodeIndex = this.#textNodes.get(id);
  13414. if (nodeIndex === undefined) {
  13415. return;
  13416. }
  13417. const node = children[nodeIndex];
  13418. this.#textNodes.delete(id);
  13419. let owns = node.getAttribute("aria-owns");
  13420. if (owns?.includes(id)) {
  13421. owns = owns.split(" ").filter(x => x !== id).join(" ");
  13422. if (owns) {
  13423. node.setAttribute("aria-owns", owns);
  13424. } else {
  13425. node.removeAttribute("aria-owns");
  13426. node.setAttribute("role", "presentation");
  13427. }
  13428. }
  13429. }
  13430. #addIdToAriaOwns(id, node) {
  13431. const owns = node.getAttribute("aria-owns");
  13432. if (!owns?.includes(id)) {
  13433. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  13434. }
  13435. node.removeAttribute("role");
  13436. }
  13437. addPointerInTextLayer(element, isRemovable) {
  13438. const {
  13439. id
  13440. } = element;
  13441. if (!id) {
  13442. return;
  13443. }
  13444. if (!this.#enabled) {
  13445. this.#waitingElements.set(element, isRemovable);
  13446. return;
  13447. }
  13448. if (isRemovable) {
  13449. this.removePointerInTextLayer(element);
  13450. }
  13451. const children = this.#textChildren;
  13452. if (!children || children.length === 0) {
  13453. return;
  13454. }
  13455. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
  13456. const nodeIndex = Math.max(0, index - 1);
  13457. this.#addIdToAriaOwns(id, children[nodeIndex]);
  13458. this.#textNodes.set(id, nodeIndex);
  13459. }
  13460. moveElementInDOM(container, element, contentElement, isRemovable) {
  13461. this.addPointerInTextLayer(contentElement, isRemovable);
  13462. if (!container.hasChildNodes()) {
  13463. container.append(element);
  13464. return;
  13465. }
  13466. const children = Array.from(container.childNodes).filter(node => node !== element);
  13467. if (children.length === 0) {
  13468. return;
  13469. }
  13470. const elementToCompare = contentElement || element;
  13471. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
  13472. if (index === 0) {
  13473. children[0].before(element);
  13474. } else {
  13475. children[index - 1].after(element);
  13476. }
  13477. }
  13478. }
  13479. exports.TextAccessibilityManager = TextAccessibilityManager;
  13480. /***/ }),
  13481. /* 153 */
  13482. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13483. Object.defineProperty(exports, "__esModule", ({
  13484. value: true
  13485. }));
  13486. exports.TextHighlighter = void 0;
  13487. __webpack_require__(76);
  13488. __webpack_require__(89);
  13489. class TextHighlighter {
  13490. constructor(_ref) {
  13491. let {
  13492. findController,
  13493. eventBus,
  13494. pageIndex
  13495. } = _ref;
  13496. this.findController = findController;
  13497. this.matches = [];
  13498. this.eventBus = eventBus;
  13499. this.pageIdx = pageIndex;
  13500. this._onUpdateTextLayerMatches = null;
  13501. this.textDivs = null;
  13502. this.textContentItemsStr = null;
  13503. this.enabled = false;
  13504. }
  13505. setTextMapping(divs, texts) {
  13506. this.textDivs = divs;
  13507. this.textContentItemsStr = texts;
  13508. }
  13509. enable() {
  13510. if (!this.textDivs || !this.textContentItemsStr) {
  13511. throw new Error("Text divs and strings have not been set.");
  13512. }
  13513. if (this.enabled) {
  13514. throw new Error("TextHighlighter is already enabled.");
  13515. }
  13516. this.enabled = true;
  13517. if (!this._onUpdateTextLayerMatches) {
  13518. this._onUpdateTextLayerMatches = evt => {
  13519. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  13520. this._updateMatches();
  13521. }
  13522. };
  13523. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13524. }
  13525. this._updateMatches();
  13526. }
  13527. disable() {
  13528. if (!this.enabled) {
  13529. return;
  13530. }
  13531. this.enabled = false;
  13532. if (this._onUpdateTextLayerMatches) {
  13533. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13534. this._onUpdateTextLayerMatches = null;
  13535. }
  13536. this._updateMatches(true);
  13537. }
  13538. _convertMatches(matches, matchesLength) {
  13539. if (!matches) {
  13540. return [];
  13541. }
  13542. const {
  13543. textContentItemsStr
  13544. } = this;
  13545. let i = 0,
  13546. iIndex = 0;
  13547. const end = textContentItemsStr.length - 1;
  13548. const result = [];
  13549. for (let m = 0, mm = matches.length; m < mm; m++) {
  13550. let matchIdx = matches[m];
  13551. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  13552. iIndex += textContentItemsStr[i].length;
  13553. i++;
  13554. }
  13555. if (i === textContentItemsStr.length) {
  13556. console.error("Could not find a matching mapping");
  13557. }
  13558. const match = {
  13559. begin: {
  13560. divIdx: i,
  13561. offset: matchIdx - iIndex
  13562. }
  13563. };
  13564. matchIdx += matchesLength[m];
  13565. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  13566. iIndex += textContentItemsStr[i].length;
  13567. i++;
  13568. }
  13569. match.end = {
  13570. divIdx: i,
  13571. offset: matchIdx - iIndex
  13572. };
  13573. result.push(match);
  13574. }
  13575. return result;
  13576. }
  13577. _renderMatches(matches) {
  13578. if (matches.length === 0) {
  13579. return;
  13580. }
  13581. const {
  13582. findController,
  13583. pageIdx
  13584. } = this;
  13585. const {
  13586. textContentItemsStr,
  13587. textDivs
  13588. } = this;
  13589. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  13590. const selectedMatchIdx = findController.selected.matchIdx;
  13591. const highlightAll = findController.state.highlightAll;
  13592. let prevEnd = null;
  13593. const infinity = {
  13594. divIdx: -1,
  13595. offset: undefined
  13596. };
  13597. function beginText(begin, className) {
  13598. const divIdx = begin.divIdx;
  13599. textDivs[divIdx].textContent = "";
  13600. return appendTextToDiv(divIdx, 0, begin.offset, className);
  13601. }
  13602. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  13603. let div = textDivs[divIdx];
  13604. if (div.nodeType === Node.TEXT_NODE) {
  13605. const span = document.createElement("span");
  13606. div.before(span);
  13607. span.append(div);
  13608. textDivs[divIdx] = span;
  13609. div = span;
  13610. }
  13611. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  13612. const node = document.createTextNode(content);
  13613. if (className) {
  13614. const span = document.createElement("span");
  13615. span.className = `${className} appended`;
  13616. span.append(node);
  13617. div.append(span);
  13618. return className.includes("selected") ? span.offsetLeft : 0;
  13619. }
  13620. div.append(node);
  13621. return 0;
  13622. }
  13623. let i0 = selectedMatchIdx,
  13624. i1 = i0 + 1;
  13625. if (highlightAll) {
  13626. i0 = 0;
  13627. i1 = matches.length;
  13628. } else if (!isSelectedPage) {
  13629. return;
  13630. }
  13631. let lastDivIdx = -1;
  13632. let lastOffset = -1;
  13633. for (let i = i0; i < i1; i++) {
  13634. const match = matches[i];
  13635. const begin = match.begin;
  13636. if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
  13637. continue;
  13638. }
  13639. lastDivIdx = begin.divIdx;
  13640. lastOffset = begin.offset;
  13641. const end = match.end;
  13642. const isSelected = isSelectedPage && i === selectedMatchIdx;
  13643. const highlightSuffix = isSelected ? " selected" : "";
  13644. let selectedLeft = 0;
  13645. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  13646. if (prevEnd !== null) {
  13647. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13648. }
  13649. beginText(begin);
  13650. } else {
  13651. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  13652. }
  13653. if (begin.divIdx === end.divIdx) {
  13654. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  13655. } else {
  13656. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  13657. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  13658. textDivs[n0].className = "highlight middle" + highlightSuffix;
  13659. }
  13660. beginText(end, "highlight end" + highlightSuffix);
  13661. }
  13662. prevEnd = end;
  13663. if (isSelected) {
  13664. findController.scrollMatchIntoView({
  13665. element: textDivs[begin.divIdx],
  13666. selectedLeft,
  13667. pageIndex: pageIdx,
  13668. matchIndex: selectedMatchIdx
  13669. });
  13670. }
  13671. }
  13672. if (prevEnd) {
  13673. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13674. }
  13675. }
  13676. _updateMatches() {
  13677. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13678. if (!this.enabled && !reset) {
  13679. return;
  13680. }
  13681. const {
  13682. findController,
  13683. matches,
  13684. pageIdx
  13685. } = this;
  13686. const {
  13687. textContentItemsStr,
  13688. textDivs
  13689. } = this;
  13690. let clearedUntilDivIdx = -1;
  13691. for (const match of matches) {
  13692. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13693. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  13694. const div = textDivs[n];
  13695. div.textContent = textContentItemsStr[n];
  13696. div.className = "";
  13697. }
  13698. clearedUntilDivIdx = match.end.divIdx + 1;
  13699. }
  13700. if (!findController?.highlightMatches || reset) {
  13701. return;
  13702. }
  13703. const pageMatches = findController.pageMatches[pageIdx] || null;
  13704. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13705. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13706. this._renderMatches(this.matches);
  13707. }
  13708. }
  13709. exports.TextHighlighter = TextHighlighter;
  13710. /***/ }),
  13711. /* 154 */
  13712. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13713. Object.defineProperty(exports, "__esModule", ({
  13714. value: true
  13715. }));
  13716. exports.TextLayerBuilder = void 0;
  13717. __webpack_require__(76);
  13718. var _pdfjsLib = __webpack_require__(122);
  13719. var _ui_utils = __webpack_require__(97);
  13720. class TextLayerBuilder {
  13721. #enablePermissions = false;
  13722. #rotation = 0;
  13723. #scale = 0;
  13724. #textContentSource = null;
  13725. constructor(_ref) {
  13726. let {
  13727. highlighter = null,
  13728. accessibilityManager = null,
  13729. isOffscreenCanvasSupported = true,
  13730. enablePermissions = false
  13731. } = _ref;
  13732. this.textContentItemsStr = [];
  13733. this.renderingDone = false;
  13734. this.textDivs = [];
  13735. this.textDivProperties = new WeakMap();
  13736. this.textLayerRenderTask = null;
  13737. this.highlighter = highlighter;
  13738. this.accessibilityManager = accessibilityManager;
  13739. this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  13740. this.#enablePermissions = enablePermissions === true;
  13741. this.div = document.createElement("div");
  13742. this.div.className = "textLayer";
  13743. this.hide();
  13744. }
  13745. #finishRendering() {
  13746. this.renderingDone = true;
  13747. const endOfContent = document.createElement("div");
  13748. endOfContent.className = "endOfContent";
  13749. this.div.append(endOfContent);
  13750. this.#bindMouse();
  13751. }
  13752. get numTextDivs() {
  13753. return this.textDivs.length;
  13754. }
  13755. async render(viewport) {
  13756. if (!this.#textContentSource) {
  13757. throw new Error('No "textContentSource" parameter specified.');
  13758. }
  13759. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  13760. const {
  13761. rotation
  13762. } = viewport;
  13763. if (this.renderingDone) {
  13764. const mustRotate = rotation !== this.#rotation;
  13765. const mustRescale = scale !== this.#scale;
  13766. if (mustRotate || mustRescale) {
  13767. this.hide();
  13768. (0, _pdfjsLib.updateTextLayer)({
  13769. container: this.div,
  13770. viewport,
  13771. textDivs: this.textDivs,
  13772. textDivProperties: this.textDivProperties,
  13773. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  13774. mustRescale,
  13775. mustRotate
  13776. });
  13777. this.#scale = scale;
  13778. this.#rotation = rotation;
  13779. }
  13780. this.show();
  13781. return;
  13782. }
  13783. this.cancel();
  13784. this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
  13785. this.accessibilityManager?.setTextMapping(this.textDivs);
  13786. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  13787. textContentSource: this.#textContentSource,
  13788. container: this.div,
  13789. viewport,
  13790. textDivs: this.textDivs,
  13791. textDivProperties: this.textDivProperties,
  13792. textContentItemsStr: this.textContentItemsStr,
  13793. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported
  13794. });
  13795. await this.textLayerRenderTask.promise;
  13796. this.#finishRendering();
  13797. this.#scale = scale;
  13798. this.#rotation = rotation;
  13799. this.show();
  13800. this.accessibilityManager?.enable();
  13801. }
  13802. hide() {
  13803. if (!this.div.hidden) {
  13804. this.highlighter?.disable();
  13805. this.div.hidden = true;
  13806. }
  13807. }
  13808. show() {
  13809. if (this.div.hidden && this.renderingDone) {
  13810. this.div.hidden = false;
  13811. this.highlighter?.enable();
  13812. }
  13813. }
  13814. cancel() {
  13815. if (this.textLayerRenderTask) {
  13816. this.textLayerRenderTask.cancel();
  13817. this.textLayerRenderTask = null;
  13818. }
  13819. this.highlighter?.disable();
  13820. this.accessibilityManager?.disable();
  13821. this.textContentItemsStr.length = 0;
  13822. this.textDivs.length = 0;
  13823. this.textDivProperties = new WeakMap();
  13824. }
  13825. setTextContentSource(source) {
  13826. this.cancel();
  13827. this.#textContentSource = source;
  13828. }
  13829. #bindMouse() {
  13830. const {
  13831. div
  13832. } = this;
  13833. div.addEventListener("mousedown", evt => {
  13834. const end = div.querySelector(".endOfContent");
  13835. if (!end) {
  13836. return;
  13837. }
  13838. let adjustTop = evt.target !== div;
  13839. adjustTop &&= getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  13840. if (adjustTop) {
  13841. const divBounds = div.getBoundingClientRect();
  13842. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  13843. end.style.top = (r * 100).toFixed(2) + "%";
  13844. }
  13845. end.classList.add("active");
  13846. });
  13847. div.addEventListener("mouseup", () => {
  13848. const end = div.querySelector(".endOfContent");
  13849. if (!end) {
  13850. return;
  13851. }
  13852. end.style.top = "";
  13853. end.classList.remove("active");
  13854. });
  13855. div.addEventListener("copy", event => {
  13856. if (!this.#enablePermissions) {
  13857. const selection = document.getSelection();
  13858. event.clipboardData.setData("text/plain", (0, _ui_utils.removeNullCharacters)((0, _pdfjsLib.normalizeUnicode)(selection.toString())));
  13859. }
  13860. event.preventDefault();
  13861. event.stopPropagation();
  13862. });
  13863. }
  13864. }
  13865. exports.TextLayerBuilder = TextLayerBuilder;
  13866. /***/ }),
  13867. /* 155 */
  13868. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13869. Object.defineProperty(exports, "__esModule", ({
  13870. value: true
  13871. }));
  13872. exports.XfaLayerBuilder = void 0;
  13873. var _pdfjsLib = __webpack_require__(122);
  13874. class XfaLayerBuilder {
  13875. constructor(_ref) {
  13876. let {
  13877. pageDiv,
  13878. pdfPage,
  13879. annotationStorage = null,
  13880. linkService,
  13881. xfaHtml = null
  13882. } = _ref;
  13883. this.pageDiv = pageDiv;
  13884. this.pdfPage = pdfPage;
  13885. this.annotationStorage = annotationStorage;
  13886. this.linkService = linkService;
  13887. this.xfaHtml = xfaHtml;
  13888. this.div = null;
  13889. this._cancelled = false;
  13890. }
  13891. async render(viewport) {
  13892. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13893. if (intent === "print") {
  13894. const parameters = {
  13895. viewport: viewport.clone({
  13896. dontFlip: true
  13897. }),
  13898. div: this.div,
  13899. xfaHtml: this.xfaHtml,
  13900. annotationStorage: this.annotationStorage,
  13901. linkService: this.linkService,
  13902. intent
  13903. };
  13904. const div = document.createElement("div");
  13905. this.pageDiv.append(div);
  13906. parameters.div = div;
  13907. return _pdfjsLib.XfaLayer.render(parameters);
  13908. }
  13909. const xfaHtml = await this.pdfPage.getXfa();
  13910. if (this._cancelled || !xfaHtml) {
  13911. return {
  13912. textDivs: []
  13913. };
  13914. }
  13915. const parameters = {
  13916. viewport: viewport.clone({
  13917. dontFlip: true
  13918. }),
  13919. div: this.div,
  13920. xfaHtml,
  13921. annotationStorage: this.annotationStorage,
  13922. linkService: this.linkService,
  13923. intent
  13924. };
  13925. if (this.div) {
  13926. return _pdfjsLib.XfaLayer.update(parameters);
  13927. }
  13928. this.div = document.createElement("div");
  13929. this.pageDiv.append(this.div);
  13930. parameters.div = this.div;
  13931. return _pdfjsLib.XfaLayer.render(parameters);
  13932. }
  13933. cancel() {
  13934. this._cancelled = true;
  13935. }
  13936. hide() {
  13937. if (!this.div) {
  13938. return;
  13939. }
  13940. this.div.hidden = true;
  13941. }
  13942. }
  13943. exports.XfaLayerBuilder = XfaLayerBuilder;
  13944. /***/ }),
  13945. /* 156 */
  13946. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13947. Object.defineProperty(exports, "__esModule", ({
  13948. value: true
  13949. }));
  13950. exports.SecondaryToolbar = void 0;
  13951. __webpack_require__(89);
  13952. var _ui_utils = __webpack_require__(97);
  13953. var _pdf_viewer = __webpack_require__(146);
  13954. class SecondaryToolbar {
  13955. constructor(options, eventBus, externalServices) {
  13956. this.toolbar = options.toolbar;
  13957. this.toggleButton = options.toggleButton;
  13958. this.buttons = [{
  13959. element: options.presentationModeButton,
  13960. eventName: "presentationmode",
  13961. close: true
  13962. }, {
  13963. element: options.printButton,
  13964. eventName: "print",
  13965. close: true
  13966. }, {
  13967. element: options.downloadButton,
  13968. eventName: "download",
  13969. close: true
  13970. }, {
  13971. element: options.viewBookmarkButton,
  13972. eventName: null,
  13973. close: true
  13974. }, {
  13975. element: options.firstPageButton,
  13976. eventName: "firstpage",
  13977. close: true
  13978. }, {
  13979. element: options.lastPageButton,
  13980. eventName: "lastpage",
  13981. close: true
  13982. }, {
  13983. element: options.pageRotateCwButton,
  13984. eventName: "rotatecw",
  13985. close: false
  13986. }, {
  13987. element: options.pageRotateCcwButton,
  13988. eventName: "rotateccw",
  13989. close: false
  13990. }, {
  13991. element: options.cursorSelectToolButton,
  13992. eventName: "switchcursortool",
  13993. eventDetails: {
  13994. tool: _ui_utils.CursorTool.SELECT
  13995. },
  13996. close: true
  13997. }, {
  13998. element: options.cursorHandToolButton,
  13999. eventName: "switchcursortool",
  14000. eventDetails: {
  14001. tool: _ui_utils.CursorTool.HAND
  14002. },
  14003. close: true
  14004. }, {
  14005. element: options.scrollPageButton,
  14006. eventName: "switchscrollmode",
  14007. eventDetails: {
  14008. mode: _ui_utils.ScrollMode.PAGE
  14009. },
  14010. close: true
  14011. }, {
  14012. element: options.scrollVerticalButton,
  14013. eventName: "switchscrollmode",
  14014. eventDetails: {
  14015. mode: _ui_utils.ScrollMode.VERTICAL
  14016. },
  14017. close: true
  14018. }, {
  14019. element: options.scrollHorizontalButton,
  14020. eventName: "switchscrollmode",
  14021. eventDetails: {
  14022. mode: _ui_utils.ScrollMode.HORIZONTAL
  14023. },
  14024. close: true
  14025. }, {
  14026. element: options.scrollWrappedButton,
  14027. eventName: "switchscrollmode",
  14028. eventDetails: {
  14029. mode: _ui_utils.ScrollMode.WRAPPED
  14030. },
  14031. close: true
  14032. }, {
  14033. element: options.spreadNoneButton,
  14034. eventName: "switchspreadmode",
  14035. eventDetails: {
  14036. mode: _ui_utils.SpreadMode.NONE
  14037. },
  14038. close: true
  14039. }, {
  14040. element: options.spreadOddButton,
  14041. eventName: "switchspreadmode",
  14042. eventDetails: {
  14043. mode: _ui_utils.SpreadMode.ODD
  14044. },
  14045. close: true
  14046. }, {
  14047. element: options.spreadEvenButton,
  14048. eventName: "switchspreadmode",
  14049. eventDetails: {
  14050. mode: _ui_utils.SpreadMode.EVEN
  14051. },
  14052. close: true
  14053. }, {
  14054. element: options.documentPropertiesButton,
  14055. eventName: "documentproperties",
  14056. close: true
  14057. }];
  14058. this.buttons.push({
  14059. element: options.openFileButton,
  14060. eventName: "openfile",
  14061. close: true
  14062. });
  14063. this.items = {
  14064. firstPage: options.firstPageButton,
  14065. lastPage: options.lastPageButton,
  14066. pageRotateCw: options.pageRotateCwButton,
  14067. pageRotateCcw: options.pageRotateCcwButton
  14068. };
  14069. this.eventBus = eventBus;
  14070. this.externalServices = externalServices;
  14071. this.opened = false;
  14072. this.#bindClickListeners();
  14073. this.#bindCursorToolsListener(options);
  14074. this.#bindScrollModeListener(options);
  14075. this.#bindSpreadModeListener(options);
  14076. this.reset();
  14077. }
  14078. get isOpen() {
  14079. return this.opened;
  14080. }
  14081. setPageNumber(pageNumber) {
  14082. this.pageNumber = pageNumber;
  14083. this.#updateUIState();
  14084. }
  14085. setPagesCount(pagesCount) {
  14086. this.pagesCount = pagesCount;
  14087. this.#updateUIState();
  14088. }
  14089. reset() {
  14090. this.pageNumber = 0;
  14091. this.pagesCount = 0;
  14092. this.#updateUIState();
  14093. this.eventBus.dispatch("secondarytoolbarreset", {
  14094. source: this
  14095. });
  14096. }
  14097. #updateUIState() {
  14098. this.items.firstPage.disabled = this.pageNumber <= 1;
  14099. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  14100. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  14101. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  14102. }
  14103. #bindClickListeners() {
  14104. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  14105. for (const {
  14106. element,
  14107. eventName,
  14108. close,
  14109. eventDetails
  14110. } of this.buttons) {
  14111. element.addEventListener("click", evt => {
  14112. if (eventName !== null) {
  14113. this.eventBus.dispatch(eventName, {
  14114. source: this,
  14115. ...eventDetails
  14116. });
  14117. }
  14118. if (close) {
  14119. this.close();
  14120. }
  14121. this.externalServices.reportTelemetry({
  14122. type: "buttons",
  14123. data: {
  14124. id: element.id
  14125. }
  14126. });
  14127. });
  14128. }
  14129. }
  14130. #bindCursorToolsListener(_ref) {
  14131. let {
  14132. cursorSelectToolButton,
  14133. cursorHandToolButton
  14134. } = _ref;
  14135. this.eventBus._on("cursortoolchanged", _ref2 => {
  14136. let {
  14137. tool
  14138. } = _ref2;
  14139. (0, _ui_utils.toggleCheckedBtn)(cursorSelectToolButton, tool === _ui_utils.CursorTool.SELECT);
  14140. (0, _ui_utils.toggleCheckedBtn)(cursorHandToolButton, tool === _ui_utils.CursorTool.HAND);
  14141. });
  14142. }
  14143. #bindScrollModeListener(_ref3) {
  14144. let {
  14145. scrollPageButton,
  14146. scrollVerticalButton,
  14147. scrollHorizontalButton,
  14148. scrollWrappedButton,
  14149. spreadNoneButton,
  14150. spreadOddButton,
  14151. spreadEvenButton
  14152. } = _ref3;
  14153. const scrollModeChanged = _ref4 => {
  14154. let {
  14155. mode
  14156. } = _ref4;
  14157. (0, _ui_utils.toggleCheckedBtn)(scrollPageButton, mode === _ui_utils.ScrollMode.PAGE);
  14158. (0, _ui_utils.toggleCheckedBtn)(scrollVerticalButton, mode === _ui_utils.ScrollMode.VERTICAL);
  14159. (0, _ui_utils.toggleCheckedBtn)(scrollHorizontalButton, mode === _ui_utils.ScrollMode.HORIZONTAL);
  14160. (0, _ui_utils.toggleCheckedBtn)(scrollWrappedButton, mode === _ui_utils.ScrollMode.WRAPPED);
  14161. const forceScrollModePage = this.pagesCount > _pdf_viewer.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  14162. scrollPageButton.disabled = forceScrollModePage;
  14163. scrollVerticalButton.disabled = forceScrollModePage;
  14164. scrollHorizontalButton.disabled = forceScrollModePage;
  14165. scrollWrappedButton.disabled = forceScrollModePage;
  14166. const isHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  14167. spreadNoneButton.disabled = isHorizontal;
  14168. spreadOddButton.disabled = isHorizontal;
  14169. spreadEvenButton.disabled = isHorizontal;
  14170. };
  14171. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  14172. this.eventBus._on("secondarytoolbarreset", evt => {
  14173. if (evt.source === this) {
  14174. scrollModeChanged({
  14175. mode: _ui_utils.ScrollMode.VERTICAL
  14176. });
  14177. }
  14178. });
  14179. }
  14180. #bindSpreadModeListener(_ref5) {
  14181. let {
  14182. spreadNoneButton,
  14183. spreadOddButton,
  14184. spreadEvenButton
  14185. } = _ref5;
  14186. const spreadModeChanged = _ref6 => {
  14187. let {
  14188. mode
  14189. } = _ref6;
  14190. (0, _ui_utils.toggleCheckedBtn)(spreadNoneButton, mode === _ui_utils.SpreadMode.NONE);
  14191. (0, _ui_utils.toggleCheckedBtn)(spreadOddButton, mode === _ui_utils.SpreadMode.ODD);
  14192. (0, _ui_utils.toggleCheckedBtn)(spreadEvenButton, mode === _ui_utils.SpreadMode.EVEN);
  14193. };
  14194. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  14195. this.eventBus._on("secondarytoolbarreset", evt => {
  14196. if (evt.source === this) {
  14197. spreadModeChanged({
  14198. mode: _ui_utils.SpreadMode.NONE
  14199. });
  14200. }
  14201. });
  14202. }
  14203. open() {
  14204. if (this.opened) {
  14205. return;
  14206. }
  14207. this.opened = true;
  14208. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true, this.toolbar);
  14209. }
  14210. close() {
  14211. if (!this.opened) {
  14212. return;
  14213. }
  14214. this.opened = false;
  14215. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false, this.toolbar);
  14216. }
  14217. toggle() {
  14218. if (this.opened) {
  14219. this.close();
  14220. } else {
  14221. this.open();
  14222. }
  14223. }
  14224. }
  14225. exports.SecondaryToolbar = SecondaryToolbar;
  14226. /***/ }),
  14227. /* 157 */
  14228. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14229. Object.defineProperty(exports, "__esModule", ({
  14230. value: true
  14231. }));
  14232. exports.Toolbar = void 0;
  14233. __webpack_require__(89);
  14234. var _ui_utils = __webpack_require__(97);
  14235. var _pdfjsLib = __webpack_require__(122);
  14236. const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  14237. class Toolbar {
  14238. #wasLocalized = false;
  14239. constructor(options, eventBus, l10n) {
  14240. this.toolbar = options.container;
  14241. this.eventBus = eventBus;
  14242. this.l10n = l10n;
  14243. this.buttons = [{
  14244. element: options.previous,
  14245. eventName: "previouspage"
  14246. }, {
  14247. element: options.next,
  14248. eventName: "nextpage"
  14249. }, {
  14250. element: options.zoomIn,
  14251. eventName: "zoomin"
  14252. }, {
  14253. element: options.zoomOut,
  14254. eventName: "zoomout"
  14255. }, {
  14256. element: options.print,
  14257. eventName: "print"
  14258. }, {
  14259. element: options.download,
  14260. eventName: "download"
  14261. }, {
  14262. element: options.editorFreeTextButton,
  14263. eventName: "switchannotationeditormode",
  14264. eventDetails: {
  14265. get mode() {
  14266. const {
  14267. classList
  14268. } = options.editorFreeTextButton;
  14269. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.FREETEXT;
  14270. }
  14271. }
  14272. }, {
  14273. element: options.editorInkButton,
  14274. eventName: "switchannotationeditormode",
  14275. eventDetails: {
  14276. get mode() {
  14277. const {
  14278. classList
  14279. } = options.editorInkButton;
  14280. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.INK;
  14281. }
  14282. }
  14283. }, {
  14284. element: options.editorStampButton,
  14285. eventName: "switchannotationeditormode",
  14286. eventDetails: {
  14287. get mode() {
  14288. const {
  14289. classList
  14290. } = options.editorStampButton;
  14291. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.STAMP;
  14292. }
  14293. }
  14294. }];
  14295. this.buttons.push({
  14296. element: options.openFile,
  14297. eventName: "openfile"
  14298. });
  14299. this.items = {
  14300. numPages: options.numPages,
  14301. pageNumber: options.pageNumber,
  14302. scaleSelect: options.scaleSelect,
  14303. customScaleOption: options.customScaleOption,
  14304. previous: options.previous,
  14305. next: options.next,
  14306. zoomIn: options.zoomIn,
  14307. zoomOut: options.zoomOut
  14308. };
  14309. this.#bindListeners(options);
  14310. this.reset();
  14311. }
  14312. setPageNumber(pageNumber, pageLabel) {
  14313. this.pageNumber = pageNumber;
  14314. this.pageLabel = pageLabel;
  14315. this.#updateUIState(false);
  14316. }
  14317. setPagesCount(pagesCount, hasPageLabels) {
  14318. this.pagesCount = pagesCount;
  14319. this.hasPageLabels = hasPageLabels;
  14320. this.#updateUIState(true);
  14321. }
  14322. setPageScale(pageScaleValue, pageScale) {
  14323. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  14324. this.pageScale = pageScale;
  14325. this.#updateUIState(false);
  14326. }
  14327. reset() {
  14328. this.pageNumber = 0;
  14329. this.pageLabel = null;
  14330. this.hasPageLabels = false;
  14331. this.pagesCount = 0;
  14332. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  14333. this.pageScale = _ui_utils.DEFAULT_SCALE;
  14334. this.#updateUIState(true);
  14335. this.updateLoadingIndicatorState();
  14336. this.eventBus.dispatch("toolbarreset", {
  14337. source: this
  14338. });
  14339. }
  14340. #bindListeners(options) {
  14341. const {
  14342. pageNumber,
  14343. scaleSelect
  14344. } = this.items;
  14345. const self = this;
  14346. for (const {
  14347. element,
  14348. eventName,
  14349. eventDetails
  14350. } of this.buttons) {
  14351. element.addEventListener("click", evt => {
  14352. if (eventName !== null) {
  14353. this.eventBus.dispatch(eventName, {
  14354. source: this,
  14355. ...eventDetails
  14356. });
  14357. }
  14358. });
  14359. }
  14360. pageNumber.addEventListener("click", function () {
  14361. this.select();
  14362. });
  14363. pageNumber.addEventListener("change", function () {
  14364. self.eventBus.dispatch("pagenumberchanged", {
  14365. source: self,
  14366. value: this.value
  14367. });
  14368. });
  14369. scaleSelect.addEventListener("change", function () {
  14370. if (this.value === "custom") {
  14371. return;
  14372. }
  14373. self.eventBus.dispatch("scalechanged", {
  14374. source: self,
  14375. value: this.value
  14376. });
  14377. });
  14378. scaleSelect.addEventListener("click", function (evt) {
  14379. const target = evt.target;
  14380. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  14381. this.blur();
  14382. }
  14383. });
  14384. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  14385. this.eventBus._on("localized", () => {
  14386. this.#wasLocalized = true;
  14387. this.#adjustScaleWidth();
  14388. this.#updateUIState(true);
  14389. });
  14390. this.#bindEditorToolsListener(options);
  14391. }
  14392. #bindEditorToolsListener(_ref) {
  14393. let {
  14394. editorFreeTextButton,
  14395. editorFreeTextParamsToolbar,
  14396. editorInkButton,
  14397. editorInkParamsToolbar,
  14398. editorStampButton,
  14399. editorStampParamsToolbar
  14400. } = _ref;
  14401. const editorModeChanged = _ref2 => {
  14402. let {
  14403. mode
  14404. } = _ref2;
  14405. (0, _ui_utils.toggleCheckedBtn)(editorFreeTextButton, mode === _pdfjsLib.AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
  14406. (0, _ui_utils.toggleCheckedBtn)(editorInkButton, mode === _pdfjsLib.AnnotationEditorType.INK, editorInkParamsToolbar);
  14407. (0, _ui_utils.toggleCheckedBtn)(editorStampButton, mode === _pdfjsLib.AnnotationEditorType.STAMP, editorStampParamsToolbar);
  14408. const isDisable = mode === _pdfjsLib.AnnotationEditorType.DISABLE;
  14409. editorFreeTextButton.disabled = isDisable;
  14410. editorInkButton.disabled = isDisable;
  14411. editorStampButton.disabled = isDisable;
  14412. };
  14413. this.eventBus._on("annotationeditormodechanged", editorModeChanged);
  14414. this.eventBus._on("toolbarreset", evt => {
  14415. if (evt.source === this) {
  14416. editorModeChanged({
  14417. mode: _pdfjsLib.AnnotationEditorType.DISABLE
  14418. });
  14419. }
  14420. });
  14421. }
  14422. #updateUIState() {
  14423. let resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14424. if (!this.#wasLocalized) {
  14425. return;
  14426. }
  14427. const {
  14428. pageNumber,
  14429. pagesCount,
  14430. pageScaleValue,
  14431. pageScale,
  14432. items
  14433. } = this;
  14434. if (resetNumPages) {
  14435. if (this.hasPageLabels) {
  14436. items.pageNumber.type = "text";
  14437. } else {
  14438. items.pageNumber.type = "number";
  14439. this.l10n.get("of_pages", {
  14440. pagesCount
  14441. }).then(msg => {
  14442. items.numPages.textContent = msg;
  14443. });
  14444. }
  14445. items.pageNumber.max = pagesCount;
  14446. }
  14447. if (this.hasPageLabels) {
  14448. items.pageNumber.value = this.pageLabel;
  14449. this.l10n.get("page_of_pages", {
  14450. pageNumber,
  14451. pagesCount
  14452. }).then(msg => {
  14453. items.numPages.textContent = msg;
  14454. });
  14455. } else {
  14456. items.pageNumber.value = pageNumber;
  14457. }
  14458. items.previous.disabled = pageNumber <= 1;
  14459. items.next.disabled = pageNumber >= pagesCount;
  14460. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  14461. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  14462. this.l10n.get("page_scale_percent", {
  14463. scale: Math.round(pageScale * 10000) / 100
  14464. }).then(msg => {
  14465. let predefinedValueFound = false;
  14466. for (const option of items.scaleSelect.options) {
  14467. if (option.value !== pageScaleValue) {
  14468. option.selected = false;
  14469. continue;
  14470. }
  14471. option.selected = true;
  14472. predefinedValueFound = true;
  14473. }
  14474. if (!predefinedValueFound) {
  14475. items.customScaleOption.textContent = msg;
  14476. items.customScaleOption.selected = true;
  14477. }
  14478. });
  14479. }
  14480. updateLoadingIndicatorState() {
  14481. let loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14482. const {
  14483. pageNumber
  14484. } = this.items;
  14485. pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  14486. }
  14487. async #adjustScaleWidth() {
  14488. const {
  14489. items,
  14490. l10n
  14491. } = this;
  14492. const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
  14493. await _ui_utils.animationStarted;
  14494. const style = getComputedStyle(items.scaleSelect);
  14495. const scaleSelectWidth = parseFloat(style.getPropertyValue("--scale-select-width"));
  14496. const canvas = document.createElement("canvas");
  14497. const ctx = canvas.getContext("2d", {
  14498. alpha: false
  14499. });
  14500. ctx.font = `${style.fontSize} ${style.fontFamily}`;
  14501. let maxWidth = 0;
  14502. for (const predefinedValue of await predefinedValuesPromise) {
  14503. const {
  14504. width
  14505. } = ctx.measureText(predefinedValue);
  14506. if (width > maxWidth) {
  14507. maxWidth = width;
  14508. }
  14509. }
  14510. maxWidth += 0.3 * scaleSelectWidth;
  14511. if (maxWidth > scaleSelectWidth) {
  14512. const container = items.scaleSelect.parentNode;
  14513. container.style.setProperty("--scale-select-width", `${maxWidth}px`);
  14514. }
  14515. canvas.width = 0;
  14516. canvas.height = 0;
  14517. }
  14518. }
  14519. exports.Toolbar = Toolbar;
  14520. /***/ }),
  14521. /* 158 */
  14522. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14523. Object.defineProperty(exports, "__esModule", ({
  14524. value: true
  14525. }));
  14526. exports.ViewHistory = void 0;
  14527. __webpack_require__(2);
  14528. __webpack_require__(89);
  14529. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  14530. class ViewHistory {
  14531. constructor(fingerprint) {
  14532. let cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  14533. this.fingerprint = fingerprint;
  14534. this.cacheSize = cacheSize;
  14535. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  14536. const database = JSON.parse(databaseStr || "{}");
  14537. let index = -1;
  14538. if (!Array.isArray(database.files)) {
  14539. database.files = [];
  14540. } else {
  14541. while (database.files.length >= this.cacheSize) {
  14542. database.files.shift();
  14543. }
  14544. for (let i = 0, ii = database.files.length; i < ii; i++) {
  14545. const branch = database.files[i];
  14546. if (branch.fingerprint === this.fingerprint) {
  14547. index = i;
  14548. break;
  14549. }
  14550. }
  14551. }
  14552. if (index === -1) {
  14553. index = database.files.push({
  14554. fingerprint: this.fingerprint
  14555. }) - 1;
  14556. }
  14557. this.file = database.files[index];
  14558. this.database = database;
  14559. });
  14560. }
  14561. async _writeToStorage() {
  14562. const databaseStr = JSON.stringify(this.database);
  14563. localStorage.setItem("pdfjs.history", databaseStr);
  14564. }
  14565. async _readFromStorage() {
  14566. return localStorage.getItem("pdfjs.history");
  14567. }
  14568. async set(name, val) {
  14569. await this._initializedPromise;
  14570. this.file[name] = val;
  14571. return this._writeToStorage();
  14572. }
  14573. async setMultiple(properties) {
  14574. await this._initializedPromise;
  14575. for (const name in properties) {
  14576. this.file[name] = properties[name];
  14577. }
  14578. return this._writeToStorage();
  14579. }
  14580. async get(name, defaultValue) {
  14581. await this._initializedPromise;
  14582. const val = this.file[name];
  14583. return val !== undefined ? val : defaultValue;
  14584. }
  14585. async getMultiple(properties) {
  14586. await this._initializedPromise;
  14587. const values = Object.create(null);
  14588. for (const name in properties) {
  14589. const val = this.file[name];
  14590. values[name] = val !== undefined ? val : properties[name];
  14591. }
  14592. return values;
  14593. }
  14594. }
  14595. exports.ViewHistory = ViewHistory;
  14596. /***/ }),
  14597. /* 159 */
  14598. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14599. Object.defineProperty(exports, "__esModule", ({
  14600. value: true
  14601. }));
  14602. exports.BasePreferences = void 0;
  14603. __webpack_require__(76);
  14604. var _app_options = __webpack_require__(123);
  14605. class BasePreferences {
  14606. #defaults = Object.freeze({
  14607. "annotationEditorMode": 0,
  14608. "annotationMode": 2,
  14609. "cursorToolOnLoad": 0,
  14610. "defaultZoomDelay": 400,
  14611. "defaultZoomValue": "",
  14612. "disablePageLabels": false,
  14613. "enablePermissions": false,
  14614. "enablePrintAutoRotate": true,
  14615. "enableScripting": true,
  14616. "enableStampEditor": true,
  14617. "externalLinkTarget": 0,
  14618. "historyUpdateUrl": false,
  14619. "ignoreDestinationZoom": false,
  14620. "forcePageColors": false,
  14621. "pageColorsBackground": "Canvas",
  14622. "pageColorsForeground": "CanvasText",
  14623. "pdfBugEnabled": false,
  14624. "sidebarViewOnLoad": -1,
  14625. "scrollModeOnLoad": -1,
  14626. "spreadModeOnLoad": -1,
  14627. "textLayerMode": 1,
  14628. "viewerCssTheme": 0,
  14629. "viewOnLoad": 0,
  14630. "disableAutoFetch": false,
  14631. "disableFontFace": false,
  14632. "disableRange": false,
  14633. "disableStream": false,
  14634. "enableXfa": true
  14635. });
  14636. #prefs = Object.create(null);
  14637. #initializedPromise = null;
  14638. constructor() {
  14639. if (this.constructor === BasePreferences) {
  14640. throw new Error("Cannot initialize BasePreferences.");
  14641. }
  14642. this.#initializedPromise = this._readFromStorage(this.#defaults).then(prefs => {
  14643. for (const name in this.#defaults) {
  14644. const prefValue = prefs?.[name];
  14645. if (typeof prefValue === typeof this.#defaults[name]) {
  14646. this.#prefs[name] = prefValue;
  14647. }
  14648. }
  14649. });
  14650. }
  14651. async _writeToStorage(prefObj) {
  14652. throw new Error("Not implemented: _writeToStorage");
  14653. }
  14654. async _readFromStorage(prefObj) {
  14655. throw new Error("Not implemented: _readFromStorage");
  14656. }
  14657. async reset() {
  14658. await this.#initializedPromise;
  14659. const prefs = this.#prefs;
  14660. this.#prefs = Object.create(null);
  14661. return this._writeToStorage(this.#defaults).catch(reason => {
  14662. this.#prefs = prefs;
  14663. throw reason;
  14664. });
  14665. }
  14666. async set(name, value) {
  14667. await this.#initializedPromise;
  14668. const defaultValue = this.#defaults[name],
  14669. prefs = this.#prefs;
  14670. if (defaultValue === undefined) {
  14671. throw new Error(`Set preference: "${name}" is undefined.`);
  14672. } else if (value === undefined) {
  14673. throw new Error("Set preference: no value is specified.");
  14674. }
  14675. const valueType = typeof value,
  14676. defaultType = typeof defaultValue;
  14677. if (valueType !== defaultType) {
  14678. if (valueType === "number" && defaultType === "string") {
  14679. value = value.toString();
  14680. } else {
  14681. throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
  14682. }
  14683. } else if (valueType === "number" && !Number.isInteger(value)) {
  14684. throw new Error(`Set preference: "${value}" must be an integer.`);
  14685. }
  14686. this.#prefs[name] = value;
  14687. return this._writeToStorage(this.#prefs).catch(reason => {
  14688. this.#prefs = prefs;
  14689. throw reason;
  14690. });
  14691. }
  14692. async get(name) {
  14693. await this.#initializedPromise;
  14694. const defaultValue = this.#defaults[name];
  14695. if (defaultValue === undefined) {
  14696. throw new Error(`Get preference: "${name}" is undefined.`);
  14697. }
  14698. return this.#prefs[name] ?? defaultValue;
  14699. }
  14700. async getAll() {
  14701. await this.#initializedPromise;
  14702. const obj = Object.create(null);
  14703. for (const name in this.#defaults) {
  14704. obj[name] = this.#prefs[name] ?? this.#defaults[name];
  14705. }
  14706. return obj;
  14707. }
  14708. }
  14709. exports.BasePreferences = BasePreferences;
  14710. /***/ }),
  14711. /* 160 */
  14712. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14713. Object.defineProperty(exports, "__esModule", ({
  14714. value: true
  14715. }));
  14716. exports.DownloadManager = void 0;
  14717. __webpack_require__(76);
  14718. __webpack_require__(92);
  14719. __webpack_require__(94);
  14720. __webpack_require__(95);
  14721. var _pdfjsLib = __webpack_require__(122);
  14722. ;
  14723. function download(blobUrl, filename) {
  14724. const a = document.createElement("a");
  14725. if (!a.click) {
  14726. throw new Error('DownloadManager: "a.click()" is not supported.');
  14727. }
  14728. a.href = blobUrl;
  14729. a.target = "_parent";
  14730. if ("download" in a) {
  14731. a.download = filename;
  14732. }
  14733. (document.body || document.documentElement).append(a);
  14734. a.click();
  14735. a.remove();
  14736. }
  14737. class DownloadManager {
  14738. #openBlobUrls = new WeakMap();
  14739. downloadUrl(url, filename, _options) {
  14740. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14741. console.error(`downloadUrl - not a valid URL: ${url}`);
  14742. return;
  14743. }
  14744. download(url + "#pdfjs.action=download", filename);
  14745. }
  14746. downloadData(data, filename, contentType) {
  14747. const blobUrl = URL.createObjectURL(new Blob([data], {
  14748. type: contentType
  14749. }));
  14750. download(blobUrl, filename);
  14751. }
  14752. openOrDownloadData(element, data, filename) {
  14753. const isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  14754. const contentType = isPdfData ? "application/pdf" : "";
  14755. if (isPdfData) {
  14756. let blobUrl = this.#openBlobUrls.get(element);
  14757. if (!blobUrl) {
  14758. blobUrl = URL.createObjectURL(new Blob([data], {
  14759. type: contentType
  14760. }));
  14761. this.#openBlobUrls.set(element, blobUrl);
  14762. }
  14763. let viewerUrl;
  14764. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  14765. try {
  14766. window.open(viewerUrl);
  14767. return true;
  14768. } catch (ex) {
  14769. console.error(`openOrDownloadData: ${ex}`);
  14770. URL.revokeObjectURL(blobUrl);
  14771. this.#openBlobUrls.delete(element);
  14772. }
  14773. }
  14774. this.downloadData(data, filename, contentType);
  14775. return false;
  14776. }
  14777. download(blob, url, filename, _options) {
  14778. const blobUrl = URL.createObjectURL(blob);
  14779. download(blobUrl, filename);
  14780. }
  14781. }
  14782. exports.DownloadManager = DownloadManager;
  14783. /***/ }),
  14784. /* 161 */
  14785. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14786. Object.defineProperty(exports, "__esModule", ({
  14787. value: true
  14788. }));
  14789. exports.GenericL10n = void 0;
  14790. __webpack_require__(162);
  14791. var _l10n_utils = __webpack_require__(147);
  14792. const PARTIAL_LANG_CODES = {
  14793. en: "en-US",
  14794. es: "es-ES",
  14795. fy: "fy-NL",
  14796. ga: "ga-IE",
  14797. gu: "gu-IN",
  14798. hi: "hi-IN",
  14799. hy: "hy-AM",
  14800. nb: "nb-NO",
  14801. ne: "ne-NP",
  14802. nn: "nn-NO",
  14803. pa: "pa-IN",
  14804. pt: "pt-PT",
  14805. sv: "sv-SE",
  14806. zh: "zh-CN"
  14807. };
  14808. function fixupLangCode(langCode) {
  14809. return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode;
  14810. }
  14811. class GenericL10n {
  14812. constructor(lang) {
  14813. const {
  14814. webL10n
  14815. } = document;
  14816. this._lang = lang;
  14817. this._ready = new Promise((resolve, reject) => {
  14818. webL10n.setLanguage(fixupLangCode(lang), () => {
  14819. resolve(webL10n);
  14820. });
  14821. });
  14822. }
  14823. async getLanguage() {
  14824. const l10n = await this._ready;
  14825. return l10n.getLanguage();
  14826. }
  14827. async getDirection() {
  14828. const l10n = await this._ready;
  14829. return l10n.getDirection();
  14830. }
  14831. async get(key) {
  14832. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  14833. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  14834. const l10n = await this._ready;
  14835. return l10n.get(key, args, fallback);
  14836. }
  14837. async translate(element) {
  14838. const l10n = await this._ready;
  14839. return l10n.translate(element);
  14840. }
  14841. }
  14842. exports.GenericL10n = GenericL10n;
  14843. /***/ }),
  14844. /* 162 */
  14845. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  14846. __webpack_require__(2);
  14847. document.webL10n = function (window, document) {
  14848. var gL10nData = {};
  14849. var gTextData = '';
  14850. var gTextProp = 'textContent';
  14851. var gLanguage = '';
  14852. var gMacros = {};
  14853. var gReadyState = 'loading';
  14854. var gAsyncResourceLoading = true;
  14855. function getL10nResourceLinks() {
  14856. return document.querySelectorAll('link[type="application/l10n"]');
  14857. }
  14858. function getL10nDictionary() {
  14859. var script = document.querySelector('script[type="application/l10n"]');
  14860. return script ? JSON.parse(script.innerHTML) : null;
  14861. }
  14862. function getTranslatableChildren(element) {
  14863. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14864. }
  14865. function getL10nAttributes(element) {
  14866. if (!element) return {};
  14867. var l10nId = element.getAttribute('data-l10n-id');
  14868. var l10nArgs = element.getAttribute('data-l10n-args');
  14869. var args = {};
  14870. if (l10nArgs) {
  14871. try {
  14872. args = JSON.parse(l10nArgs);
  14873. } catch (e) {
  14874. console.warn('could not parse arguments for #' + l10nId);
  14875. }
  14876. }
  14877. return {
  14878. id: l10nId,
  14879. args: args
  14880. };
  14881. }
  14882. function xhrLoadText(url, onSuccess, onFailure) {
  14883. onSuccess = onSuccess || function _onSuccess(data) {};
  14884. onFailure = onFailure || function _onFailure() {};
  14885. var xhr = new XMLHttpRequest();
  14886. xhr.open('GET', url, gAsyncResourceLoading);
  14887. if (xhr.overrideMimeType) {
  14888. xhr.overrideMimeType('text/plain; charset=utf-8');
  14889. }
  14890. xhr.onreadystatechange = function () {
  14891. if (xhr.readyState == 4) {
  14892. if (xhr.status == 200 || xhr.status === 0) {
  14893. onSuccess(xhr.responseText);
  14894. } else {
  14895. onFailure();
  14896. }
  14897. }
  14898. };
  14899. xhr.onerror = onFailure;
  14900. xhr.ontimeout = onFailure;
  14901. try {
  14902. xhr.send(null);
  14903. } catch (e) {
  14904. onFailure();
  14905. }
  14906. }
  14907. function parseResource(href, lang, successCallback, failureCallback) {
  14908. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14909. function evalString(text) {
  14910. if (text.lastIndexOf('\\') < 0) return text;
  14911. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  14912. }
  14913. function parseProperties(text, parsedPropertiesCallback) {
  14914. var dictionary = {};
  14915. var reBlank = /^\s*|\s*$/;
  14916. var reComment = /^\s*#|^\s*$/;
  14917. var reSection = /^\s*\[(.*)\]\s*$/;
  14918. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14919. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14920. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14921. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14922. var currentLang = '*';
  14923. var genericLang = lang.split('-', 1)[0];
  14924. var skipLang = false;
  14925. var match = '';
  14926. function nextEntry() {
  14927. while (true) {
  14928. if (!entries.length) {
  14929. parsedRawLinesCallback();
  14930. return;
  14931. }
  14932. var line = entries.shift();
  14933. if (reComment.test(line)) continue;
  14934. if (extendedSyntax) {
  14935. match = reSection.exec(line);
  14936. if (match) {
  14937. currentLang = match[1].toLowerCase();
  14938. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14939. continue;
  14940. } else if (skipLang) {
  14941. continue;
  14942. }
  14943. match = reImport.exec(line);
  14944. if (match) {
  14945. loadImport(baseURL + match[1], nextEntry);
  14946. return;
  14947. }
  14948. }
  14949. var tmp = line.match(reSplit);
  14950. if (tmp && tmp.length == 3) {
  14951. dictionary[tmp[1]] = evalString(tmp[2]);
  14952. }
  14953. }
  14954. }
  14955. nextEntry();
  14956. }
  14957. function loadImport(url, callback) {
  14958. xhrLoadText(url, function (content) {
  14959. parseRawLines(content, false, callback);
  14960. }, function () {
  14961. console.warn(url + ' not found.');
  14962. callback();
  14963. });
  14964. }
  14965. parseRawLines(text, true, function () {
  14966. parsedPropertiesCallback(dictionary);
  14967. });
  14968. }
  14969. xhrLoadText(href, function (response) {
  14970. gTextData += response;
  14971. parseProperties(response, function (data) {
  14972. for (var key in data) {
  14973. var id,
  14974. prop,
  14975. index = key.lastIndexOf('.');
  14976. if (index > 0) {
  14977. id = key.substring(0, index);
  14978. prop = key.substring(index + 1);
  14979. } else {
  14980. id = key;
  14981. prop = gTextProp;
  14982. }
  14983. if (!gL10nData[id]) {
  14984. gL10nData[id] = {};
  14985. }
  14986. gL10nData[id][prop] = data[key];
  14987. }
  14988. if (successCallback) {
  14989. successCallback();
  14990. }
  14991. });
  14992. }, failureCallback);
  14993. }
  14994. function loadLocale(lang, callback) {
  14995. if (lang) {
  14996. lang = lang.toLowerCase();
  14997. }
  14998. callback = callback || function _callback() {};
  14999. clear();
  15000. gLanguage = lang;
  15001. var langLinks = getL10nResourceLinks();
  15002. var langCount = langLinks.length;
  15003. if (langCount === 0) {
  15004. var dict = getL10nDictionary();
  15005. if (dict && dict.locales && dict.default_locale) {
  15006. console.log('using the embedded JSON directory, early way out');
  15007. gL10nData = dict.locales[lang];
  15008. if (!gL10nData) {
  15009. var defaultLocale = dict.default_locale.toLowerCase();
  15010. for (var anyCaseLang in dict.locales) {
  15011. anyCaseLang = anyCaseLang.toLowerCase();
  15012. if (anyCaseLang === lang) {
  15013. gL10nData = dict.locales[lang];
  15014. break;
  15015. } else if (anyCaseLang === defaultLocale) {
  15016. gL10nData = dict.locales[defaultLocale];
  15017. }
  15018. }
  15019. }
  15020. callback();
  15021. } else {
  15022. console.log('no resource to load, early way out');
  15023. }
  15024. gReadyState = 'complete';
  15025. return;
  15026. }
  15027. var onResourceLoaded = null;
  15028. var gResourceCount = 0;
  15029. onResourceLoaded = function () {
  15030. gResourceCount++;
  15031. if (gResourceCount >= langCount) {
  15032. callback();
  15033. gReadyState = 'complete';
  15034. }
  15035. };
  15036. function L10nResourceLink(link) {
  15037. var href = link.href;
  15038. this.load = function (lang, callback) {
  15039. parseResource(href, lang, callback, function () {
  15040. console.warn(href + ' not found.');
  15041. console.warn('"' + lang + '" resource not found');
  15042. gLanguage = '';
  15043. callback();
  15044. });
  15045. };
  15046. }
  15047. for (var i = 0; i < langCount; i++) {
  15048. var resource = new L10nResourceLink(langLinks[i]);
  15049. resource.load(lang, onResourceLoaded);
  15050. }
  15051. }
  15052. function clear() {
  15053. gL10nData = {};
  15054. gTextData = '';
  15055. gLanguage = '';
  15056. }
  15057. function getPluralRules(lang) {
  15058. var locales2rules = {
  15059. 'af': 3,
  15060. 'ak': 4,
  15061. 'am': 4,
  15062. 'ar': 1,
  15063. 'asa': 3,
  15064. 'az': 0,
  15065. 'be': 11,
  15066. 'bem': 3,
  15067. 'bez': 3,
  15068. 'bg': 3,
  15069. 'bh': 4,
  15070. 'bm': 0,
  15071. 'bn': 3,
  15072. 'bo': 0,
  15073. 'br': 20,
  15074. 'brx': 3,
  15075. 'bs': 11,
  15076. 'ca': 3,
  15077. 'cgg': 3,
  15078. 'chr': 3,
  15079. 'cs': 12,
  15080. 'cy': 17,
  15081. 'da': 3,
  15082. 'de': 3,
  15083. 'dv': 3,
  15084. 'dz': 0,
  15085. 'ee': 3,
  15086. 'el': 3,
  15087. 'en': 3,
  15088. 'eo': 3,
  15089. 'es': 3,
  15090. 'et': 3,
  15091. 'eu': 3,
  15092. 'fa': 0,
  15093. 'ff': 5,
  15094. 'fi': 3,
  15095. 'fil': 4,
  15096. 'fo': 3,
  15097. 'fr': 5,
  15098. 'fur': 3,
  15099. 'fy': 3,
  15100. 'ga': 8,
  15101. 'gd': 24,
  15102. 'gl': 3,
  15103. 'gsw': 3,
  15104. 'gu': 3,
  15105. 'guw': 4,
  15106. 'gv': 23,
  15107. 'ha': 3,
  15108. 'haw': 3,
  15109. 'he': 2,
  15110. 'hi': 4,
  15111. 'hr': 11,
  15112. 'hu': 0,
  15113. 'id': 0,
  15114. 'ig': 0,
  15115. 'ii': 0,
  15116. 'is': 3,
  15117. 'it': 3,
  15118. 'iu': 7,
  15119. 'ja': 0,
  15120. 'jmc': 3,
  15121. 'jv': 0,
  15122. 'ka': 0,
  15123. 'kab': 5,
  15124. 'kaj': 3,
  15125. 'kcg': 3,
  15126. 'kde': 0,
  15127. 'kea': 0,
  15128. 'kk': 3,
  15129. 'kl': 3,
  15130. 'km': 0,
  15131. 'kn': 0,
  15132. 'ko': 0,
  15133. 'ksb': 3,
  15134. 'ksh': 21,
  15135. 'ku': 3,
  15136. 'kw': 7,
  15137. 'lag': 18,
  15138. 'lb': 3,
  15139. 'lg': 3,
  15140. 'ln': 4,
  15141. 'lo': 0,
  15142. 'lt': 10,
  15143. 'lv': 6,
  15144. 'mas': 3,
  15145. 'mg': 4,
  15146. 'mk': 16,
  15147. 'ml': 3,
  15148. 'mn': 3,
  15149. 'mo': 9,
  15150. 'mr': 3,
  15151. 'ms': 0,
  15152. 'mt': 15,
  15153. 'my': 0,
  15154. 'nah': 3,
  15155. 'naq': 7,
  15156. 'nb': 3,
  15157. 'nd': 3,
  15158. 'ne': 3,
  15159. 'nl': 3,
  15160. 'nn': 3,
  15161. 'no': 3,
  15162. 'nr': 3,
  15163. 'nso': 4,
  15164. 'ny': 3,
  15165. 'nyn': 3,
  15166. 'om': 3,
  15167. 'or': 3,
  15168. 'pa': 3,
  15169. 'pap': 3,
  15170. 'pl': 13,
  15171. 'ps': 3,
  15172. 'pt': 3,
  15173. 'rm': 3,
  15174. 'ro': 9,
  15175. 'rof': 3,
  15176. 'ru': 11,
  15177. 'rwk': 3,
  15178. 'sah': 0,
  15179. 'saq': 3,
  15180. 'se': 7,
  15181. 'seh': 3,
  15182. 'ses': 0,
  15183. 'sg': 0,
  15184. 'sh': 11,
  15185. 'shi': 19,
  15186. 'sk': 12,
  15187. 'sl': 14,
  15188. 'sma': 7,
  15189. 'smi': 7,
  15190. 'smj': 7,
  15191. 'smn': 7,
  15192. 'sms': 7,
  15193. 'sn': 3,
  15194. 'so': 3,
  15195. 'sq': 3,
  15196. 'sr': 11,
  15197. 'ss': 3,
  15198. 'ssy': 3,
  15199. 'st': 3,
  15200. 'sv': 3,
  15201. 'sw': 3,
  15202. 'syr': 3,
  15203. 'ta': 3,
  15204. 'te': 3,
  15205. 'teo': 3,
  15206. 'th': 0,
  15207. 'ti': 4,
  15208. 'tig': 3,
  15209. 'tk': 3,
  15210. 'tl': 4,
  15211. 'tn': 3,
  15212. 'to': 0,
  15213. 'tr': 0,
  15214. 'ts': 3,
  15215. 'tzm': 22,
  15216. 'uk': 11,
  15217. 'ur': 3,
  15218. 've': 3,
  15219. 'vi': 0,
  15220. 'vun': 3,
  15221. 'wa': 4,
  15222. 'wae': 3,
  15223. 'wo': 0,
  15224. 'xh': 3,
  15225. 'xog': 3,
  15226. 'yo': 0,
  15227. 'zh': 0,
  15228. 'zu': 3
  15229. };
  15230. function isIn(n, list) {
  15231. return list.indexOf(n) !== -1;
  15232. }
  15233. function isBetween(n, start, end) {
  15234. return start <= n && n <= end;
  15235. }
  15236. var pluralRules = {
  15237. '0': function (n) {
  15238. return 'other';
  15239. },
  15240. '1': function (n) {
  15241. if (isBetween(n % 100, 3, 10)) return 'few';
  15242. if (n === 0) return 'zero';
  15243. if (isBetween(n % 100, 11, 99)) return 'many';
  15244. if (n == 2) return 'two';
  15245. if (n == 1) return 'one';
  15246. return 'other';
  15247. },
  15248. '2': function (n) {
  15249. if (n !== 0 && n % 10 === 0) return 'many';
  15250. if (n == 2) return 'two';
  15251. if (n == 1) return 'one';
  15252. return 'other';
  15253. },
  15254. '3': function (n) {
  15255. if (n == 1) return 'one';
  15256. return 'other';
  15257. },
  15258. '4': function (n) {
  15259. if (isBetween(n, 0, 1)) return 'one';
  15260. return 'other';
  15261. },
  15262. '5': function (n) {
  15263. if (isBetween(n, 0, 2) && n != 2) return 'one';
  15264. return 'other';
  15265. },
  15266. '6': function (n) {
  15267. if (n === 0) return 'zero';
  15268. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15269. return 'other';
  15270. },
  15271. '7': function (n) {
  15272. if (n == 2) return 'two';
  15273. if (n == 1) return 'one';
  15274. return 'other';
  15275. },
  15276. '8': function (n) {
  15277. if (isBetween(n, 3, 6)) return 'few';
  15278. if (isBetween(n, 7, 10)) return 'many';
  15279. if (n == 2) return 'two';
  15280. if (n == 1) return 'one';
  15281. return 'other';
  15282. },
  15283. '9': function (n) {
  15284. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  15285. if (n == 1) return 'one';
  15286. return 'other';
  15287. },
  15288. '10': function (n) {
  15289. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  15290. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  15291. return 'other';
  15292. },
  15293. '11': function (n) {
  15294. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15295. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  15296. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15297. return 'other';
  15298. },
  15299. '12': function (n) {
  15300. if (isBetween(n, 2, 4)) return 'few';
  15301. if (n == 1) return 'one';
  15302. return 'other';
  15303. },
  15304. '13': function (n) {
  15305. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15306. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  15307. if (n == 1) return 'one';
  15308. return 'other';
  15309. },
  15310. '14': function (n) {
  15311. if (isBetween(n % 100, 3, 4)) return 'few';
  15312. if (n % 100 == 2) return 'two';
  15313. if (n % 100 == 1) return 'one';
  15314. return 'other';
  15315. },
  15316. '15': function (n) {
  15317. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  15318. if (isBetween(n % 100, 11, 19)) return 'many';
  15319. if (n == 1) return 'one';
  15320. return 'other';
  15321. },
  15322. '16': function (n) {
  15323. if (n % 10 == 1 && n != 11) return 'one';
  15324. return 'other';
  15325. },
  15326. '17': function (n) {
  15327. if (n == 3) return 'few';
  15328. if (n === 0) return 'zero';
  15329. if (n == 6) return 'many';
  15330. if (n == 2) return 'two';
  15331. if (n == 1) return 'one';
  15332. return 'other';
  15333. },
  15334. '18': function (n) {
  15335. if (n === 0) return 'zero';
  15336. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  15337. return 'other';
  15338. },
  15339. '19': function (n) {
  15340. if (isBetween(n, 2, 10)) return 'few';
  15341. if (isBetween(n, 0, 1)) return 'one';
  15342. return 'other';
  15343. },
  15344. '20': function (n) {
  15345. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  15346. if (n % 1000000 === 0 && n !== 0) return 'many';
  15347. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  15348. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  15349. return 'other';
  15350. },
  15351. '21': function (n) {
  15352. if (n === 0) return 'zero';
  15353. if (n == 1) return 'one';
  15354. return 'other';
  15355. },
  15356. '22': function (n) {
  15357. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  15358. return 'other';
  15359. },
  15360. '23': function (n) {
  15361. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  15362. return 'other';
  15363. },
  15364. '24': function (n) {
  15365. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  15366. if (isIn(n, [2, 12])) return 'two';
  15367. if (isIn(n, [1, 11])) return 'one';
  15368. return 'other';
  15369. }
  15370. };
  15371. var index = locales2rules[lang.replace(/-.*$/, '')];
  15372. if (!(index in pluralRules)) {
  15373. console.warn('plural form unknown for [' + lang + ']');
  15374. return function () {
  15375. return 'other';
  15376. };
  15377. }
  15378. return pluralRules[index];
  15379. }
  15380. gMacros.plural = function (str, param, key, prop) {
  15381. var n = parseFloat(param);
  15382. if (isNaN(n)) return str;
  15383. if (prop != gTextProp) return str;
  15384. if (!gMacros._pluralRules) {
  15385. gMacros._pluralRules = getPluralRules(gLanguage);
  15386. }
  15387. var index = '[' + gMacros._pluralRules(n) + ']';
  15388. if (n === 0 && key + '[zero]' in gL10nData) {
  15389. str = gL10nData[key + '[zero]'][prop];
  15390. } else if (n == 1 && key + '[one]' in gL10nData) {
  15391. str = gL10nData[key + '[one]'][prop];
  15392. } else if (n == 2 && key + '[two]' in gL10nData) {
  15393. str = gL10nData[key + '[two]'][prop];
  15394. } else if (key + index in gL10nData) {
  15395. str = gL10nData[key + index][prop];
  15396. } else if (key + '[other]' in gL10nData) {
  15397. str = gL10nData[key + '[other]'][prop];
  15398. }
  15399. return str;
  15400. };
  15401. function getL10nData(key, args, fallback) {
  15402. var data = gL10nData[key];
  15403. if (!data) {
  15404. console.warn('#' + key + ' is undefined.');
  15405. if (!fallback) {
  15406. return null;
  15407. }
  15408. data = fallback;
  15409. }
  15410. var rv = {};
  15411. for (var prop in data) {
  15412. var str = data[prop];
  15413. str = substIndexes(str, args, key, prop);
  15414. str = substArguments(str, args, key);
  15415. rv[prop] = str;
  15416. }
  15417. return rv;
  15418. }
  15419. function substIndexes(str, args, key, prop) {
  15420. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15421. var reMatch = reIndex.exec(str);
  15422. if (!reMatch || !reMatch.length) return str;
  15423. var macroName = reMatch[1];
  15424. var paramName = reMatch[2];
  15425. var param;
  15426. if (args && paramName in args) {
  15427. param = args[paramName];
  15428. } else if (paramName in gL10nData) {
  15429. param = gL10nData[paramName];
  15430. }
  15431. if (macroName in gMacros) {
  15432. var macro = gMacros[macroName];
  15433. str = macro(str, param, key, prop);
  15434. }
  15435. return str;
  15436. }
  15437. function substArguments(str, args, key) {
  15438. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15439. return str.replace(reArgs, function (matched_text, arg) {
  15440. if (args && arg in args) {
  15441. return args[arg];
  15442. }
  15443. if (arg in gL10nData) {
  15444. return gL10nData[arg];
  15445. }
  15446. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15447. return matched_text;
  15448. });
  15449. }
  15450. function translateElement(element) {
  15451. var l10n = getL10nAttributes(element);
  15452. if (!l10n.id) return;
  15453. var data = getL10nData(l10n.id, l10n.args);
  15454. if (!data) {
  15455. console.warn('#' + l10n.id + ' is undefined.');
  15456. return;
  15457. }
  15458. if (data[gTextProp]) {
  15459. if (getChildElementCount(element) === 0) {
  15460. element[gTextProp] = data[gTextProp];
  15461. } else {
  15462. var children = element.childNodes;
  15463. var found = false;
  15464. for (var i = 0, l = children.length; i < l; i++) {
  15465. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15466. if (found) {
  15467. children[i].nodeValue = '';
  15468. } else {
  15469. children[i].nodeValue = data[gTextProp];
  15470. found = true;
  15471. }
  15472. }
  15473. }
  15474. if (!found) {
  15475. var textNode = document.createTextNode(data[gTextProp]);
  15476. element.prepend(textNode);
  15477. }
  15478. }
  15479. delete data[gTextProp];
  15480. }
  15481. for (var k in data) {
  15482. element[k] = data[k];
  15483. }
  15484. }
  15485. function getChildElementCount(element) {
  15486. if (element.children) {
  15487. return element.children.length;
  15488. }
  15489. if (typeof element.childElementCount !== 'undefined') {
  15490. return element.childElementCount;
  15491. }
  15492. var count = 0;
  15493. for (var i = 0; i < element.childNodes.length; i++) {
  15494. count += element.nodeType === 1 ? 1 : 0;
  15495. }
  15496. return count;
  15497. }
  15498. function translateFragment(element) {
  15499. element = element || document.documentElement;
  15500. var children = getTranslatableChildren(element);
  15501. var elementCount = children.length;
  15502. for (var i = 0; i < elementCount; i++) {
  15503. translateElement(children[i]);
  15504. }
  15505. translateElement(element);
  15506. }
  15507. return {
  15508. get: function (key, args, fallbackString) {
  15509. var index = key.lastIndexOf('.');
  15510. var prop = gTextProp;
  15511. if (index > 0) {
  15512. prop = key.substring(index + 1);
  15513. key = key.substring(0, index);
  15514. }
  15515. var fallback;
  15516. if (fallbackString) {
  15517. fallback = {};
  15518. fallback[prop] = fallbackString;
  15519. }
  15520. var data = getL10nData(key, args, fallback);
  15521. if (data && prop in data) {
  15522. return data[prop];
  15523. }
  15524. return '{{' + key + '}}';
  15525. },
  15526. getData: function () {
  15527. return gL10nData;
  15528. },
  15529. getText: function () {
  15530. return gTextData;
  15531. },
  15532. getLanguage: function () {
  15533. return gLanguage;
  15534. },
  15535. setLanguage: function (lang, callback) {
  15536. loadLocale(lang, function () {
  15537. if (callback) callback();
  15538. });
  15539. },
  15540. getDirection: function () {
  15541. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15542. var shortCode = gLanguage.split('-', 1)[0];
  15543. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15544. },
  15545. translate: translateFragment,
  15546. getReadyState: function () {
  15547. return gReadyState;
  15548. },
  15549. ready: function (callback) {
  15550. if (!callback) {
  15551. return;
  15552. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15553. window.setTimeout(function () {
  15554. callback();
  15555. });
  15556. } else if (document.addEventListener) {
  15557. document.addEventListener('localized', function once() {
  15558. document.removeEventListener('localized', once);
  15559. callback();
  15560. });
  15561. }
  15562. }
  15563. };
  15564. }(window, document);
  15565. /***/ }),
  15566. /* 163 */
  15567. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15568. Object.defineProperty(exports, "__esModule", ({
  15569. value: true
  15570. }));
  15571. exports.GenericScripting = void 0;
  15572. exports.docProperties = docProperties;
  15573. var _pdfjsLib = __webpack_require__(122);
  15574. async function docProperties(pdfDocument) {
  15575. const url = "",
  15576. baseUrl = url.split("#")[0];
  15577. let {
  15578. info,
  15579. metadata,
  15580. contentDispositionFilename,
  15581. contentLength
  15582. } = await pdfDocument.getMetadata();
  15583. if (!contentLength) {
  15584. const {
  15585. length
  15586. } = await pdfDocument.getDownloadInfo();
  15587. contentLength = length;
  15588. }
  15589. return {
  15590. ...info,
  15591. baseURL: baseUrl,
  15592. filesize: contentLength,
  15593. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  15594. metadata: metadata?.getRaw(),
  15595. authors: metadata?.get("dc:creator"),
  15596. numPages: pdfDocument.numPages,
  15597. URL: url
  15598. };
  15599. }
  15600. class GenericScripting {
  15601. constructor(sandboxBundleSrc) {
  15602. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
  15603. return window.pdfjsSandbox.QuickJSSandbox();
  15604. });
  15605. }
  15606. async createSandbox(data) {
  15607. const sandbox = await this._ready;
  15608. sandbox.create(data);
  15609. }
  15610. async dispatchEventInSandbox(event) {
  15611. const sandbox = await this._ready;
  15612. setTimeout(() => sandbox.dispatchEvent(event), 0);
  15613. }
  15614. async destroySandbox() {
  15615. const sandbox = await this._ready;
  15616. sandbox.nukeSandbox();
  15617. }
  15618. }
  15619. exports.GenericScripting = GenericScripting;
  15620. /***/ }),
  15621. /* 164 */
  15622. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15623. Object.defineProperty(exports, "__esModule", ({
  15624. value: true
  15625. }));
  15626. exports.PDFPrintService = void 0;
  15627. __webpack_require__(92);
  15628. __webpack_require__(94);
  15629. __webpack_require__(95);
  15630. __webpack_require__(76);
  15631. var _pdfjsLib = __webpack_require__(122);
  15632. var _app = __webpack_require__(75);
  15633. var _print_utils = __webpack_require__(165);
  15634. let activeService = null;
  15635. let dialog = null;
  15636. let overlayManager = null;
  15637. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  15638. const scratchCanvas = activeService.scratchCanvas;
  15639. const PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  15640. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15641. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15642. const ctx = scratchCanvas.getContext("2d");
  15643. ctx.save();
  15644. ctx.fillStyle = "rgb(255, 255, 255)";
  15645. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15646. ctx.restore();
  15647. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function (_ref) {
  15648. let [pdfPage, printAnnotationStorage] = _ref;
  15649. const renderContext = {
  15650. canvasContext: ctx,
  15651. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15652. viewport: pdfPage.getViewport({
  15653. scale: 1,
  15654. rotation: size.rotation
  15655. }),
  15656. intent: "print",
  15657. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  15658. optionalContentConfigPromise,
  15659. printAnnotationStorage
  15660. };
  15661. return pdfPage.render(renderContext).promise;
  15662. });
  15663. }
  15664. class PDFPrintService {
  15665. constructor(pdfDocument, pagesOverview, printContainer, printResolution) {
  15666. let optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15667. let printAnnotationStoragePromise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  15668. let l10n = arguments.length > 6 ? arguments[6] : undefined;
  15669. this.pdfDocument = pdfDocument;
  15670. this.pagesOverview = pagesOverview;
  15671. this.printContainer = printContainer;
  15672. this._printResolution = printResolution || 150;
  15673. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15674. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  15675. this.l10n = l10n;
  15676. this.currentPage = -1;
  15677. this.scratchCanvas = document.createElement("canvas");
  15678. }
  15679. layout() {
  15680. this.throwIfInactive();
  15681. const body = document.querySelector("body");
  15682. body.setAttribute("data-pdfjsprinting", true);
  15683. const {
  15684. width,
  15685. height
  15686. } = this.pagesOverview[0];
  15687. const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
  15688. if (!hasEqualPageSizes) {
  15689. console.warn("Not all pages have the same size. The printed result may be incorrect!");
  15690. }
  15691. this.pageStyleSheet = document.createElement("style");
  15692. this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
  15693. body.append(this.pageStyleSheet);
  15694. }
  15695. destroy() {
  15696. if (activeService !== this) {
  15697. return;
  15698. }
  15699. this.printContainer.textContent = "";
  15700. const body = document.querySelector("body");
  15701. body.removeAttribute("data-pdfjsprinting");
  15702. if (this.pageStyleSheet) {
  15703. this.pageStyleSheet.remove();
  15704. this.pageStyleSheet = null;
  15705. }
  15706. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15707. this.scratchCanvas = null;
  15708. activeService = null;
  15709. ensureOverlay().then(function () {
  15710. if (overlayManager.active === dialog) {
  15711. overlayManager.close(dialog);
  15712. }
  15713. });
  15714. }
  15715. renderPages() {
  15716. if (this.pdfDocument.isPureXfa) {
  15717. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  15718. return Promise.resolve();
  15719. }
  15720. const pageCount = this.pagesOverview.length;
  15721. const renderNextPage = (resolve, reject) => {
  15722. this.throwIfInactive();
  15723. if (++this.currentPage >= pageCount) {
  15724. renderProgress(pageCount, pageCount, this.l10n);
  15725. resolve();
  15726. return;
  15727. }
  15728. const index = this.currentPage;
  15729. renderProgress(index, pageCount, this.l10n);
  15730. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  15731. renderNextPage(resolve, reject);
  15732. }, reject);
  15733. };
  15734. return new Promise(renderNextPage);
  15735. }
  15736. useRenderedPage() {
  15737. this.throwIfInactive();
  15738. const img = document.createElement("img");
  15739. const scratchCanvas = this.scratchCanvas;
  15740. if ("toBlob" in scratchCanvas) {
  15741. scratchCanvas.toBlob(function (blob) {
  15742. img.src = URL.createObjectURL(blob);
  15743. });
  15744. } else {
  15745. img.src = scratchCanvas.toDataURL();
  15746. }
  15747. const wrapper = document.createElement("div");
  15748. wrapper.className = "printedPage";
  15749. wrapper.append(img);
  15750. this.printContainer.append(wrapper);
  15751. return new Promise(function (resolve, reject) {
  15752. img.onload = resolve;
  15753. img.onerror = reject;
  15754. });
  15755. }
  15756. performPrint() {
  15757. this.throwIfInactive();
  15758. return new Promise(resolve => {
  15759. setTimeout(() => {
  15760. if (!this.active) {
  15761. resolve();
  15762. return;
  15763. }
  15764. print.call(window);
  15765. setTimeout(resolve, 20);
  15766. }, 0);
  15767. });
  15768. }
  15769. get active() {
  15770. return this === activeService;
  15771. }
  15772. throwIfInactive() {
  15773. if (!this.active) {
  15774. throw new Error("This print request was cancelled or completed.");
  15775. }
  15776. }
  15777. }
  15778. exports.PDFPrintService = PDFPrintService;
  15779. const print = window.print;
  15780. window.print = function () {
  15781. if (activeService) {
  15782. console.warn("Ignored window.print() because of a pending print job.");
  15783. return;
  15784. }
  15785. ensureOverlay().then(function () {
  15786. if (activeService) {
  15787. overlayManager.open(dialog);
  15788. }
  15789. });
  15790. try {
  15791. dispatchEvent("beforeprint");
  15792. } finally {
  15793. if (!activeService) {
  15794. console.error("Expected print service to be initialized.");
  15795. ensureOverlay().then(function () {
  15796. if (overlayManager.active === dialog) {
  15797. overlayManager.close(dialog);
  15798. }
  15799. });
  15800. return;
  15801. }
  15802. const activeServiceOnEntry = activeService;
  15803. activeService.renderPages().then(function () {
  15804. return activeServiceOnEntry.performPrint();
  15805. }).catch(function () {}).then(function () {
  15806. if (activeServiceOnEntry.active) {
  15807. abort();
  15808. }
  15809. });
  15810. }
  15811. };
  15812. function dispatchEvent(eventType) {
  15813. const event = new CustomEvent(eventType, {
  15814. bubbles: false,
  15815. cancelable: false,
  15816. detail: "custom"
  15817. });
  15818. window.dispatchEvent(event);
  15819. }
  15820. function abort() {
  15821. if (activeService) {
  15822. activeService.destroy();
  15823. dispatchEvent("afterprint");
  15824. }
  15825. }
  15826. function renderProgress(index, total, l10n) {
  15827. dialog ||= document.getElementById("printServiceDialog");
  15828. const progress = Math.round(100 * index / total);
  15829. const progressBar = dialog.querySelector("progress");
  15830. const progressPerc = dialog.querySelector(".relative-progress");
  15831. progressBar.value = progress;
  15832. l10n.get("print_progress_percent", {
  15833. progress
  15834. }).then(msg => {
  15835. progressPerc.textContent = msg;
  15836. });
  15837. }
  15838. window.addEventListener("keydown", function (event) {
  15839. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15840. window.print();
  15841. event.preventDefault();
  15842. event.stopImmediatePropagation();
  15843. }
  15844. }, true);
  15845. if ("onbeforeprint" in window) {
  15846. const stopPropagationIfNeeded = function (event) {
  15847. if (event.detail !== "custom") {
  15848. event.stopImmediatePropagation();
  15849. }
  15850. };
  15851. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15852. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15853. }
  15854. let overlayPromise;
  15855. function ensureOverlay() {
  15856. if (!overlayPromise) {
  15857. overlayManager = _app.PDFViewerApplication.overlayManager;
  15858. if (!overlayManager) {
  15859. throw new Error("The overlay manager has not yet been initialized.");
  15860. }
  15861. dialog ||= document.getElementById("printServiceDialog");
  15862. overlayPromise = overlayManager.register(dialog, true);
  15863. document.getElementById("printCancel").onclick = abort;
  15864. dialog.addEventListener("close", abort);
  15865. }
  15866. return overlayPromise;
  15867. }
  15868. _app.PDFPrintServiceFactory.instance = {
  15869. supportsPrinting: true,
  15870. createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n) {
  15871. if (activeService) {
  15872. throw new Error("The print service is created and active.");
  15873. }
  15874. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n);
  15875. return activeService;
  15876. }
  15877. };
  15878. /***/ }),
  15879. /* 165 */
  15880. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15881. Object.defineProperty(exports, "__esModule", ({
  15882. value: true
  15883. }));
  15884. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  15885. var _pdfjsLib = __webpack_require__(122);
  15886. var _pdf_link_service = __webpack_require__(125);
  15887. var _xfa_layer_builder = __webpack_require__(155);
  15888. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  15889. const xfaHtml = pdfDocument.allXfaHtml;
  15890. const linkService = new _pdf_link_service.SimpleLinkService();
  15891. const scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  15892. for (const xfaPage of xfaHtml.children) {
  15893. const page = document.createElement("div");
  15894. page.className = "xfaPrintedPage";
  15895. printContainer.append(page);
  15896. const builder = new _xfa_layer_builder.XfaLayerBuilder({
  15897. pageDiv: page,
  15898. pdfPage: null,
  15899. annotationStorage: pdfDocument.annotationStorage,
  15900. linkService,
  15901. xfaHtml: xfaPage
  15902. });
  15903. const viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  15904. scale
  15905. });
  15906. builder.render(viewport, "print");
  15907. }
  15908. }
  15909. /***/ })
  15910. /******/ ]);
  15911. /************************************************************************/
  15912. /******/ // The module cache
  15913. /******/ var __webpack_module_cache__ = {};
  15914. /******/
  15915. /******/ // The require function
  15916. /******/ function __webpack_require__(moduleId) {
  15917. /******/ // Check if module is in cache
  15918. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  15919. /******/ if (cachedModule !== undefined) {
  15920. /******/ return cachedModule.exports;
  15921. /******/ }
  15922. /******/ // Create a new module (and put it into the cache)
  15923. /******/ var module = __webpack_module_cache__[moduleId] = {
  15924. /******/ // no module.id needed
  15925. /******/ // no module.loaded needed
  15926. /******/ exports: {}
  15927. /******/ };
  15928. /******/
  15929. /******/ // Execute the module function
  15930. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  15931. /******/
  15932. /******/ // Return the exports of the module
  15933. /******/ return module.exports;
  15934. /******/ }
  15935. /******/
  15936. /************************************************************************/
  15937. var __webpack_exports__ = {};
  15938. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  15939. (() => {
  15940. var exports = __webpack_exports__;
  15941. Object.defineProperty(exports, "__esModule", ({
  15942. value: true
  15943. }));
  15944. Object.defineProperty(exports, "PDFViewerApplication", ({
  15945. enumerable: true,
  15946. get: function () {
  15947. return _app.PDFViewerApplication;
  15948. }
  15949. }));
  15950. exports.PDFViewerApplicationConstants = void 0;
  15951. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  15952. enumerable: true,
  15953. get: function () {
  15954. return _app_options.AppOptions;
  15955. }
  15956. }));
  15957. __webpack_require__(1);
  15958. __webpack_require__(164);
  15959. var _ui_utils = __webpack_require__(97);
  15960. var _app_options = __webpack_require__(123);
  15961. var _pdf_link_service = __webpack_require__(125);
  15962. var _app = __webpack_require__(75);
  15963. const pdfjsVersion = '3.10.111';
  15964. const pdfjsBuild = 'e142baecb';
  15965. const AppConstants = {
  15966. LinkTarget: _pdf_link_service.LinkTarget,
  15967. RenderingStates: _ui_utils.RenderingStates,
  15968. ScrollMode: _ui_utils.ScrollMode,
  15969. SpreadMode: _ui_utils.SpreadMode
  15970. };
  15971. exports.PDFViewerApplicationConstants = AppConstants;
  15972. window.PDFViewerApplication = _app.PDFViewerApplication;
  15973. window.PDFViewerApplicationConstants = AppConstants;
  15974. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  15975. function getViewerConfiguration() {
  15976. return {
  15977. appContainer: document.body,
  15978. mainContainer: document.getElementById("viewerContainer"),
  15979. viewerContainer: document.getElementById("viewer"),
  15980. toolbar: {
  15981. container: document.getElementById("toolbarViewer"),
  15982. numPages: document.getElementById("numPages"),
  15983. pageNumber: document.getElementById("pageNumber"),
  15984. scaleSelect: document.getElementById("scaleSelect"),
  15985. customScaleOption: document.getElementById("customScaleOption"),
  15986. previous: document.getElementById("previous"),
  15987. next: document.getElementById("next"),
  15988. zoomIn: document.getElementById("zoomIn"),
  15989. zoomOut: document.getElementById("zoomOut"),
  15990. viewFind: document.getElementById("viewFind"),
  15991. openFile: document.getElementById("openFile"),
  15992. print: document.getElementById("print"),
  15993. editorFreeTextButton: document.getElementById("editorFreeText"),
  15994. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  15995. editorInkButton: document.getElementById("editorInk"),
  15996. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  15997. editorStampButton: document.getElementById("editorStamp"),
  15998. editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"),
  15999. download: document.getElementById("download")
  16000. },
  16001. secondaryToolbar: {
  16002. toolbar: document.getElementById("secondaryToolbar"),
  16003. toggleButton: document.getElementById("secondaryToolbarToggle"),
  16004. presentationModeButton: document.getElementById("presentationMode"),
  16005. openFileButton: document.getElementById("secondaryOpenFile"),
  16006. printButton: document.getElementById("secondaryPrint"),
  16007. downloadButton: document.getElementById("secondaryDownload"),
  16008. viewBookmarkButton: document.getElementById("viewBookmark"),
  16009. firstPageButton: document.getElementById("firstPage"),
  16010. lastPageButton: document.getElementById("lastPage"),
  16011. pageRotateCwButton: document.getElementById("pageRotateCw"),
  16012. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  16013. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  16014. cursorHandToolButton: document.getElementById("cursorHandTool"),
  16015. scrollPageButton: document.getElementById("scrollPage"),
  16016. scrollVerticalButton: document.getElementById("scrollVertical"),
  16017. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  16018. scrollWrappedButton: document.getElementById("scrollWrapped"),
  16019. spreadNoneButton: document.getElementById("spreadNone"),
  16020. spreadOddButton: document.getElementById("spreadOdd"),
  16021. spreadEvenButton: document.getElementById("spreadEven"),
  16022. documentPropertiesButton: document.getElementById("documentProperties")
  16023. },
  16024. sidebar: {
  16025. outerContainer: document.getElementById("outerContainer"),
  16026. sidebarContainer: document.getElementById("sidebarContainer"),
  16027. toggleButton: document.getElementById("sidebarToggle"),
  16028. resizer: document.getElementById("sidebarResizer"),
  16029. thumbnailButton: document.getElementById("viewThumbnail"),
  16030. outlineButton: document.getElementById("viewOutline"),
  16031. attachmentsButton: document.getElementById("viewAttachments"),
  16032. layersButton: document.getElementById("viewLayers"),
  16033. thumbnailView: document.getElementById("thumbnailView"),
  16034. outlineView: document.getElementById("outlineView"),
  16035. attachmentsView: document.getElementById("attachmentsView"),
  16036. layersView: document.getElementById("layersView"),
  16037. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  16038. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  16039. },
  16040. findBar: {
  16041. bar: document.getElementById("findbar"),
  16042. toggleButton: document.getElementById("viewFind"),
  16043. findField: document.getElementById("findInput"),
  16044. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  16045. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  16046. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  16047. entireWordCheckbox: document.getElementById("findEntireWord"),
  16048. findMsg: document.getElementById("findMsg"),
  16049. findResultsCount: document.getElementById("findResultsCount"),
  16050. findPreviousButton: document.getElementById("findPrevious"),
  16051. findNextButton: document.getElementById("findNext")
  16052. },
  16053. passwordOverlay: {
  16054. dialog: document.getElementById("passwordDialog"),
  16055. label: document.getElementById("passwordText"),
  16056. input: document.getElementById("password"),
  16057. submitButton: document.getElementById("passwordSubmit"),
  16058. cancelButton: document.getElementById("passwordCancel")
  16059. },
  16060. documentProperties: {
  16061. dialog: document.getElementById("documentPropertiesDialog"),
  16062. closeButton: document.getElementById("documentPropertiesClose"),
  16063. fields: {
  16064. fileName: document.getElementById("fileNameField"),
  16065. fileSize: document.getElementById("fileSizeField"),
  16066. title: document.getElementById("titleField"),
  16067. author: document.getElementById("authorField"),
  16068. subject: document.getElementById("subjectField"),
  16069. keywords: document.getElementById("keywordsField"),
  16070. creationDate: document.getElementById("creationDateField"),
  16071. modificationDate: document.getElementById("modificationDateField"),
  16072. creator: document.getElementById("creatorField"),
  16073. producer: document.getElementById("producerField"),
  16074. version: document.getElementById("versionField"),
  16075. pageCount: document.getElementById("pageCountField"),
  16076. pageSize: document.getElementById("pageSizeField"),
  16077. linearized: document.getElementById("linearizedField")
  16078. }
  16079. },
  16080. annotationEditorParams: {
  16081. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  16082. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  16083. editorInkColor: document.getElementById("editorInkColor"),
  16084. editorInkThickness: document.getElementById("editorInkThickness"),
  16085. editorInkOpacity: document.getElementById("editorInkOpacity"),
  16086. editorStampAddImage: document.getElementById("editorStampAddImage")
  16087. },
  16088. printContainer: document.getElementById("printContainer"),
  16089. openFileInput: document.getElementById("fileInput"),
  16090. debuggerScriptPath: "./debugger.js"
  16091. };
  16092. }
  16093. function webViewerLoad() {
  16094. const config = getViewerConfiguration();
  16095. const event = new CustomEvent("webviewerloaded", {
  16096. bubbles: true,
  16097. cancelable: true,
  16098. detail: {
  16099. source: window
  16100. }
  16101. });
  16102. try {
  16103. parent.document.dispatchEvent(event);
  16104. } catch (ex) {
  16105. console.error(`webviewerloaded: ${ex}`);
  16106. document.dispatchEvent(event);
  16107. }
  16108. _app.PDFViewerApplication.run(config);
  16109. }
  16110. document.blockUnblockOnload?.(true);
  16111. if (document.readyState === "interactive" || document.readyState === "complete") {
  16112. webViewerLoad();
  16113. } else {
  16114. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  16115. }
  16116. })();
  16117. /******/ })()
  16118. ;
  16119. //# sourceMappingURL=viewer.js.map