viewer.js 499 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612
  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. /******/ var __webpack_modules__ = ([
  24. /* 0 */,
  25. /* 1 */
  26. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27. "use strict";
  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__(158);
  35. var _download_manager = __webpack_require__(159);
  36. var _genericl10n = __webpack_require__(160);
  37. var _generic_scripting = __webpack_require__(162);
  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. "use strict";
  74. var $ = __webpack_require__(3);
  75. var DESCRIPTORS = __webpack_require__(6);
  76. var global = __webpack_require__(4);
  77. var getBuiltIn = __webpack_require__(24);
  78. var uncurryThis = __webpack_require__(14);
  79. var call = __webpack_require__(8);
  80. var isCallable = __webpack_require__(21);
  81. var isObject = __webpack_require__(20);
  82. var isArray = __webpack_require__(69);
  83. var hasOwn = __webpack_require__(39);
  84. var toString = __webpack_require__(70);
  85. var lengthOfArrayLike = __webpack_require__(64);
  86. var createProperty = __webpack_require__(73);
  87. var fails = __webpack_require__(7);
  88. var parseJSONString = __webpack_require__(74);
  89. var NATIVE_SYMBOL = __webpack_require__(27);
  90. var JSON = global.JSON;
  91. var Number = global.Number;
  92. var SyntaxError = global.SyntaxError;
  93. var nativeParse = JSON && JSON.parse;
  94. var enumerableOwnProperties = getBuiltIn('Object', 'keys');
  95. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  96. var at = uncurryThis(''.charAt);
  97. var slice = uncurryThis(''.slice);
  98. var exec = uncurryThis(/./.exec);
  99. var push = uncurryThis([].push);
  100. var IS_DIGIT = /^\d$/;
  101. var IS_NON_ZERO_DIGIT = /^[1-9]$/;
  102. var IS_NUMBER_START = /^(-|\d)$/;
  103. var IS_WHITESPACE = /^[\t\n\r ]$/;
  104. var PRIMITIVE = 0;
  105. var OBJECT = 1;
  106. var $parse = function (source, reviver) {
  107. source = toString(source);
  108. var context = new Context(source, 0, '');
  109. var root = context.parse();
  110. var value = root.value;
  111. var endIndex = context.skip(IS_WHITESPACE, root.end);
  112. if (endIndex < source.length) {
  113. throw SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
  114. }
  115. return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
  116. };
  117. var internalize = function (holder, name, reviver, node) {
  118. var val = holder[name];
  119. var unmodified = node && val === node.value;
  120. var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
  121. var elementRecordsLen, keys, len, i, P;
  122. if (isObject(val)) {
  123. var nodeIsArray = isArray(val);
  124. var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
  125. if (nodeIsArray) {
  126. elementRecordsLen = nodes.length;
  127. len = lengthOfArrayLike(val);
  128. for (i = 0; i < len; i++) {
  129. internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
  130. }
  131. } else {
  132. keys = enumerableOwnProperties(val);
  133. len = lengthOfArrayLike(keys);
  134. for (i = 0; i < len; i++) {
  135. P = keys[i];
  136. internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
  137. }
  138. }
  139. }
  140. return call(reviver, holder, name, val, context);
  141. };
  142. var internalizeProperty = function (object, key, value) {
  143. if (DESCRIPTORS) {
  144. var descriptor = getOwnPropertyDescriptor(object, key);
  145. if (descriptor && !descriptor.configurable)
  146. return;
  147. }
  148. if (value === undefined)
  149. delete object[key];
  150. else
  151. createProperty(object, key, value);
  152. };
  153. var Node = function (value, end, source, nodes) {
  154. this.value = value;
  155. this.end = end;
  156. this.source = source;
  157. this.nodes = nodes;
  158. };
  159. var Context = function (source, index) {
  160. this.source = source;
  161. this.index = index;
  162. };
  163. Context.prototype = {
  164. fork: function (nextIndex) {
  165. return new Context(this.source, nextIndex);
  166. },
  167. parse: function () {
  168. var source = this.source;
  169. var i = this.skip(IS_WHITESPACE, this.index);
  170. var fork = this.fork(i);
  171. var chr = at(source, i);
  172. if (exec(IS_NUMBER_START, chr))
  173. return fork.number();
  174. switch (chr) {
  175. case '{':
  176. return fork.object();
  177. case '[':
  178. return fork.array();
  179. case '"':
  180. return fork.string();
  181. case 't':
  182. return fork.keyword(true);
  183. case 'f':
  184. return fork.keyword(false);
  185. case 'n':
  186. return fork.keyword(null);
  187. }
  188. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  189. },
  190. node: function (type, value, start, end, nodes) {
  191. return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
  192. },
  193. object: function () {
  194. var source = this.source;
  195. var i = this.index + 1;
  196. var expectKeypair = false;
  197. var object = {};
  198. var nodes = {};
  199. while (i < source.length) {
  200. i = this.until([
  201. '"',
  202. '}'
  203. ], i);
  204. if (at(source, i) == '}' && !expectKeypair) {
  205. i++;
  206. break;
  207. }
  208. var result = this.fork(i).string();
  209. var key = result.value;
  210. i = result.end;
  211. i = this.until([':'], i) + 1;
  212. i = this.skip(IS_WHITESPACE, i);
  213. result = this.fork(i).parse();
  214. createProperty(nodes, key, result);
  215. createProperty(object, key, result.value);
  216. i = this.until([
  217. ',',
  218. '}'
  219. ], result.end);
  220. var chr = at(source, i);
  221. if (chr == ',') {
  222. expectKeypair = true;
  223. i++;
  224. } else if (chr == '}') {
  225. i++;
  226. break;
  227. }
  228. }
  229. return this.node(OBJECT, object, this.index, i, nodes);
  230. },
  231. array: function () {
  232. var source = this.source;
  233. var i = this.index + 1;
  234. var expectElement = false;
  235. var array = [];
  236. var nodes = [];
  237. while (i < source.length) {
  238. i = this.skip(IS_WHITESPACE, i);
  239. if (at(source, i) == ']' && !expectElement) {
  240. i++;
  241. break;
  242. }
  243. var result = this.fork(i).parse();
  244. push(nodes, result);
  245. push(array, result.value);
  246. i = this.until([
  247. ',',
  248. ']'
  249. ], result.end);
  250. if (at(source, i) == ',') {
  251. expectElement = true;
  252. i++;
  253. } else if (at(source, i) == ']') {
  254. i++;
  255. break;
  256. }
  257. }
  258. return this.node(OBJECT, array, this.index, i, nodes);
  259. },
  260. string: function () {
  261. var index = this.index;
  262. var parsed = parseJSONString(this.source, this.index + 1);
  263. return this.node(PRIMITIVE, parsed.value, index, parsed.end);
  264. },
  265. number: function () {
  266. var source = this.source;
  267. var startIndex = this.index;
  268. var i = startIndex;
  269. if (at(source, i) == '-')
  270. i++;
  271. if (at(source, i) == '0')
  272. i++;
  273. else if (exec(IS_NON_ZERO_DIGIT, at(source, i)))
  274. i = this.skip(IS_DIGIT, ++i);
  275. else
  276. throw SyntaxError('Failed to parse number at: ' + i);
  277. if (at(source, i) == '.')
  278. i = this.skip(IS_DIGIT, ++i);
  279. if (at(source, i) == 'e' || at(source, i) == 'E') {
  280. i++;
  281. if (at(source, i) == '+' || at(source, i) == '-')
  282. i++;
  283. var exponentStartIndex = i;
  284. i = this.skip(IS_DIGIT, i);
  285. if (exponentStartIndex == i)
  286. throw SyntaxError("Failed to parse number's exponent value at: " + i);
  287. }
  288. return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
  289. },
  290. keyword: function (value) {
  291. var keyword = '' + value;
  292. var index = this.index;
  293. var endIndex = index + keyword.length;
  294. if (slice(this.source, index, endIndex) != keyword)
  295. throw SyntaxError('Failed to parse value at: ' + index);
  296. return this.node(PRIMITIVE, value, index, endIndex);
  297. },
  298. skip: function (regex, i) {
  299. var source = this.source;
  300. for (; i < source.length; i++)
  301. if (!exec(regex, at(source, i)))
  302. break;
  303. return i;
  304. },
  305. until: function (array, i) {
  306. i = this.skip(IS_WHITESPACE, i);
  307. var chr = at(this.source, i);
  308. for (var j = 0; j < array.length; j++)
  309. if (array[j] == chr)
  310. return i;
  311. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  312. }
  313. };
  314. var NO_SOURCE_SUPPORT = fails(function () {
  315. var unsafeInt = '9007199254740993';
  316. var source;
  317. nativeParse(unsafeInt, function (key, value, context) {
  318. source = context.source;
  319. });
  320. return source !== unsafeInt;
  321. });
  322. var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
  323. return 1 / nativeParse('-0 \t') !== -Infinity;
  324. });
  325. $({
  326. target: 'JSON',
  327. stat: true,
  328. forced: NO_SOURCE_SUPPORT
  329. }, {
  330. parse: function parse(text, reviver) {
  331. return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
  332. }
  333. });
  334. /***/ }),
  335. /* 3 */
  336. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  337. var global = __webpack_require__(4);
  338. var getOwnPropertyDescriptor = (__webpack_require__(5).f);
  339. var createNonEnumerableProperty = __webpack_require__(44);
  340. var defineBuiltIn = __webpack_require__(48);
  341. var defineGlobalProperty = __webpack_require__(38);
  342. var copyConstructorProperties = __webpack_require__(56);
  343. var isForced = __webpack_require__(68);
  344. module.exports = function (options, source) {
  345. var TARGET = options.target;
  346. var GLOBAL = options.global;
  347. var STATIC = options.stat;
  348. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  349. if (GLOBAL) {
  350. target = global;
  351. } else if (STATIC) {
  352. target = global[TARGET] || defineGlobalProperty(TARGET, {});
  353. } else {
  354. target = (global[TARGET] || {}).prototype;
  355. }
  356. if (target)
  357. for (key in source) {
  358. sourceProperty = source[key];
  359. if (options.dontCallGetSet) {
  360. descriptor = getOwnPropertyDescriptor(target, key);
  361. targetProperty = descriptor && descriptor.value;
  362. } else
  363. targetProperty = target[key];
  364. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  365. if (!FORCED && targetProperty !== undefined) {
  366. if (typeof sourceProperty == typeof targetProperty)
  367. continue;
  368. copyConstructorProperties(sourceProperty, targetProperty);
  369. }
  370. if (options.sham || targetProperty && targetProperty.sham) {
  371. createNonEnumerableProperty(sourceProperty, 'sham', true);
  372. }
  373. defineBuiltIn(target, key, sourceProperty, options);
  374. }
  375. };
  376. /***/ }),
  377. /* 4 */
  378. /***/ (function(module) {
  379. var check = function (it) {
  380. return it && it.Math == Math && it;
  381. };
  382. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  383. return this;
  384. }()) || this || Function('return this')();
  385. /***/ }),
  386. /* 5 */
  387. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  388. var DESCRIPTORS = __webpack_require__(6);
  389. var call = __webpack_require__(8);
  390. var propertyIsEnumerableModule = __webpack_require__(10);
  391. var createPropertyDescriptor = __webpack_require__(11);
  392. var toIndexedObject = __webpack_require__(12);
  393. var toPropertyKey = __webpack_require__(18);
  394. var hasOwn = __webpack_require__(39);
  395. var IE8_DOM_DEFINE = __webpack_require__(42);
  396. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  397. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  398. O = toIndexedObject(O);
  399. P = toPropertyKey(P);
  400. if (IE8_DOM_DEFINE)
  401. try {
  402. return $getOwnPropertyDescriptor(O, P);
  403. } catch (error) {
  404. }
  405. if (hasOwn(O, P))
  406. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  407. };
  408. /***/ }),
  409. /* 6 */
  410. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  411. var fails = __webpack_require__(7);
  412. module.exports = !fails(function () {
  413. return Object.defineProperty({}, 1, {
  414. get: function () {
  415. return 7;
  416. }
  417. })[1] != 7;
  418. });
  419. /***/ }),
  420. /* 7 */
  421. /***/ ((module) => {
  422. module.exports = function (exec) {
  423. try {
  424. return !!exec();
  425. } catch (error) {
  426. return true;
  427. }
  428. };
  429. /***/ }),
  430. /* 8 */
  431. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  432. var NATIVE_BIND = __webpack_require__(9);
  433. var call = Function.prototype.call;
  434. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  435. return call.apply(call, arguments);
  436. };
  437. /***/ }),
  438. /* 9 */
  439. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  440. var fails = __webpack_require__(7);
  441. module.exports = !fails(function () {
  442. var test = function () {
  443. }.bind();
  444. return typeof test != 'function' || test.hasOwnProperty('prototype');
  445. });
  446. /***/ }),
  447. /* 10 */
  448. /***/ ((__unused_webpack_module, exports) => {
  449. "use strict";
  450. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  451. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  452. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  453. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  454. var descriptor = getOwnPropertyDescriptor(this, V);
  455. return !!descriptor && descriptor.enumerable;
  456. } : $propertyIsEnumerable;
  457. /***/ }),
  458. /* 11 */
  459. /***/ ((module) => {
  460. module.exports = function (bitmap, value) {
  461. return {
  462. enumerable: !(bitmap & 1),
  463. configurable: !(bitmap & 2),
  464. writable: !(bitmap & 4),
  465. value: value
  466. };
  467. };
  468. /***/ }),
  469. /* 12 */
  470. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  471. var IndexedObject = __webpack_require__(13);
  472. var requireObjectCoercible = __webpack_require__(16);
  473. module.exports = function (it) {
  474. return IndexedObject(requireObjectCoercible(it));
  475. };
  476. /***/ }),
  477. /* 13 */
  478. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  479. var uncurryThis = __webpack_require__(14);
  480. var fails = __webpack_require__(7);
  481. var classof = __webpack_require__(15);
  482. var $Object = Object;
  483. var split = uncurryThis(''.split);
  484. module.exports = fails(function () {
  485. return !$Object('z').propertyIsEnumerable(0);
  486. }) ? function (it) {
  487. return classof(it) == 'String' ? split(it, '') : $Object(it);
  488. } : $Object;
  489. /***/ }),
  490. /* 14 */
  491. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  492. var NATIVE_BIND = __webpack_require__(9);
  493. var FunctionPrototype = Function.prototype;
  494. var call = FunctionPrototype.call;
  495. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  496. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  497. return function () {
  498. return call.apply(fn, arguments);
  499. };
  500. };
  501. /***/ }),
  502. /* 15 */
  503. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  504. var uncurryThis = __webpack_require__(14);
  505. var toString = uncurryThis({}.toString);
  506. var stringSlice = uncurryThis(''.slice);
  507. module.exports = function (it) {
  508. return stringSlice(toString(it), 8, -1);
  509. };
  510. /***/ }),
  511. /* 16 */
  512. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  513. var isNullOrUndefined = __webpack_require__(17);
  514. var $TypeError = TypeError;
  515. module.exports = function (it) {
  516. if (isNullOrUndefined(it))
  517. throw $TypeError("Can't call method on " + it);
  518. return it;
  519. };
  520. /***/ }),
  521. /* 17 */
  522. /***/ ((module) => {
  523. module.exports = function (it) {
  524. return it === null || it === undefined;
  525. };
  526. /***/ }),
  527. /* 18 */
  528. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  529. var toPrimitive = __webpack_require__(19);
  530. var isSymbol = __webpack_require__(23);
  531. module.exports = function (argument) {
  532. var key = toPrimitive(argument, 'string');
  533. return isSymbol(key) ? key : key + '';
  534. };
  535. /***/ }),
  536. /* 19 */
  537. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  538. var call = __webpack_require__(8);
  539. var isObject = __webpack_require__(20);
  540. var isSymbol = __webpack_require__(23);
  541. var getMethod = __webpack_require__(30);
  542. var ordinaryToPrimitive = __webpack_require__(33);
  543. var wellKnownSymbol = __webpack_require__(34);
  544. var $TypeError = TypeError;
  545. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  546. module.exports = function (input, pref) {
  547. if (!isObject(input) || isSymbol(input))
  548. return input;
  549. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  550. var result;
  551. if (exoticToPrim) {
  552. if (pref === undefined)
  553. pref = 'default';
  554. result = call(exoticToPrim, input, pref);
  555. if (!isObject(result) || isSymbol(result))
  556. return result;
  557. throw $TypeError("Can't convert object to primitive value");
  558. }
  559. if (pref === undefined)
  560. pref = 'number';
  561. return ordinaryToPrimitive(input, pref);
  562. };
  563. /***/ }),
  564. /* 20 */
  565. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  566. var isCallable = __webpack_require__(21);
  567. var $documentAll = __webpack_require__(22);
  568. var documentAll = $documentAll.all;
  569. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  570. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  571. } : function (it) {
  572. return typeof it == 'object' ? it !== null : isCallable(it);
  573. };
  574. /***/ }),
  575. /* 21 */
  576. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  577. var $documentAll = __webpack_require__(22);
  578. var documentAll = $documentAll.all;
  579. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  580. return typeof argument == 'function' || argument === documentAll;
  581. } : function (argument) {
  582. return typeof argument == 'function';
  583. };
  584. /***/ }),
  585. /* 22 */
  586. /***/ ((module) => {
  587. var documentAll = typeof document == 'object' && document.all;
  588. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  589. module.exports = {
  590. all: documentAll,
  591. IS_HTMLDDA: IS_HTMLDDA
  592. };
  593. /***/ }),
  594. /* 23 */
  595. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  596. var getBuiltIn = __webpack_require__(24);
  597. var isCallable = __webpack_require__(21);
  598. var isPrototypeOf = __webpack_require__(25);
  599. var USE_SYMBOL_AS_UID = __webpack_require__(26);
  600. var $Object = Object;
  601. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  602. return typeof it == 'symbol';
  603. } : function (it) {
  604. var $Symbol = getBuiltIn('Symbol');
  605. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  606. };
  607. /***/ }),
  608. /* 24 */
  609. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  610. var global = __webpack_require__(4);
  611. var isCallable = __webpack_require__(21);
  612. var aFunction = function (argument) {
  613. return isCallable(argument) ? argument : undefined;
  614. };
  615. module.exports = function (namespace, method) {
  616. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  617. };
  618. /***/ }),
  619. /* 25 */
  620. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  621. var uncurryThis = __webpack_require__(14);
  622. module.exports = uncurryThis({}.isPrototypeOf);
  623. /***/ }),
  624. /* 26 */
  625. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  626. var NATIVE_SYMBOL = __webpack_require__(27);
  627. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  628. /***/ }),
  629. /* 27 */
  630. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  631. var V8_VERSION = __webpack_require__(28);
  632. var fails = __webpack_require__(7);
  633. var global = __webpack_require__(4);
  634. var $String = global.String;
  635. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  636. var symbol = Symbol();
  637. return !$String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  638. });
  639. /***/ }),
  640. /* 28 */
  641. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  642. var global = __webpack_require__(4);
  643. var userAgent = __webpack_require__(29);
  644. var process = global.process;
  645. var Deno = global.Deno;
  646. var versions = process && process.versions || Deno && Deno.version;
  647. var v8 = versions && versions.v8;
  648. var match, version;
  649. if (v8) {
  650. match = v8.split('.');
  651. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  652. }
  653. if (!version && userAgent) {
  654. match = userAgent.match(/Edge\/(\d+)/);
  655. if (!match || match[1] >= 74) {
  656. match = userAgent.match(/Chrome\/(\d+)/);
  657. if (match)
  658. version = +match[1];
  659. }
  660. }
  661. module.exports = version;
  662. /***/ }),
  663. /* 29 */
  664. /***/ ((module) => {
  665. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  666. /***/ }),
  667. /* 30 */
  668. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  669. var aCallable = __webpack_require__(31);
  670. var isNullOrUndefined = __webpack_require__(17);
  671. module.exports = function (V, P) {
  672. var func = V[P];
  673. return isNullOrUndefined(func) ? undefined : aCallable(func);
  674. };
  675. /***/ }),
  676. /* 31 */
  677. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  678. var isCallable = __webpack_require__(21);
  679. var tryToString = __webpack_require__(32);
  680. var $TypeError = TypeError;
  681. module.exports = function (argument) {
  682. if (isCallable(argument))
  683. return argument;
  684. throw $TypeError(tryToString(argument) + ' is not a function');
  685. };
  686. /***/ }),
  687. /* 32 */
  688. /***/ ((module) => {
  689. var $String = String;
  690. module.exports = function (argument) {
  691. try {
  692. return $String(argument);
  693. } catch (error) {
  694. return 'Object';
  695. }
  696. };
  697. /***/ }),
  698. /* 33 */
  699. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  700. var call = __webpack_require__(8);
  701. var isCallable = __webpack_require__(21);
  702. var isObject = __webpack_require__(20);
  703. var $TypeError = TypeError;
  704. module.exports = function (input, pref) {
  705. var fn, val;
  706. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  707. return val;
  708. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  709. return val;
  710. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  711. return val;
  712. throw $TypeError("Can't convert object to primitive value");
  713. };
  714. /***/ }),
  715. /* 34 */
  716. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  717. var global = __webpack_require__(4);
  718. var shared = __webpack_require__(35);
  719. var hasOwn = __webpack_require__(39);
  720. var uid = __webpack_require__(41);
  721. var NATIVE_SYMBOL = __webpack_require__(27);
  722. var USE_SYMBOL_AS_UID = __webpack_require__(26);
  723. var Symbol = global.Symbol;
  724. var WellKnownSymbolsStore = shared('wks');
  725. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  726. module.exports = function (name) {
  727. if (!hasOwn(WellKnownSymbolsStore, name)) {
  728. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) ? Symbol[name] : createWellKnownSymbol('Symbol.' + name);
  729. }
  730. return WellKnownSymbolsStore[name];
  731. };
  732. /***/ }),
  733. /* 35 */
  734. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  735. var IS_PURE = __webpack_require__(36);
  736. var store = __webpack_require__(37);
  737. (module.exports = function (key, value) {
  738. return store[key] || (store[key] = value !== undefined ? value : {});
  739. })('versions', []).push({
  740. version: '3.31.1',
  741. mode: IS_PURE ? 'pure' : 'global',
  742. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  743. license: 'https://github.com/zloirock/core-js/blob/v3.31.1/LICENSE',
  744. source: 'https://github.com/zloirock/core-js'
  745. });
  746. /***/ }),
  747. /* 36 */
  748. /***/ ((module) => {
  749. module.exports = false;
  750. /***/ }),
  751. /* 37 */
  752. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  753. var global = __webpack_require__(4);
  754. var defineGlobalProperty = __webpack_require__(38);
  755. var SHARED = '__core-js_shared__';
  756. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  757. module.exports = store;
  758. /***/ }),
  759. /* 38 */
  760. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  761. var global = __webpack_require__(4);
  762. var defineProperty = Object.defineProperty;
  763. module.exports = function (key, value) {
  764. try {
  765. defineProperty(global, key, {
  766. value: value,
  767. configurable: true,
  768. writable: true
  769. });
  770. } catch (error) {
  771. global[key] = value;
  772. }
  773. return value;
  774. };
  775. /***/ }),
  776. /* 39 */
  777. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  778. var uncurryThis = __webpack_require__(14);
  779. var toObject = __webpack_require__(40);
  780. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  781. module.exports = Object.hasOwn || function hasOwn(it, key) {
  782. return hasOwnProperty(toObject(it), key);
  783. };
  784. /***/ }),
  785. /* 40 */
  786. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  787. var requireObjectCoercible = __webpack_require__(16);
  788. var $Object = Object;
  789. module.exports = function (argument) {
  790. return $Object(requireObjectCoercible(argument));
  791. };
  792. /***/ }),
  793. /* 41 */
  794. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  795. var uncurryThis = __webpack_require__(14);
  796. var id = 0;
  797. var postfix = Math.random();
  798. var toString = uncurryThis(1.0.toString);
  799. module.exports = function (key) {
  800. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  801. };
  802. /***/ }),
  803. /* 42 */
  804. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  805. var DESCRIPTORS = __webpack_require__(6);
  806. var fails = __webpack_require__(7);
  807. var createElement = __webpack_require__(43);
  808. module.exports = !DESCRIPTORS && !fails(function () {
  809. return Object.defineProperty(createElement('div'), 'a', {
  810. get: function () {
  811. return 7;
  812. }
  813. }).a != 7;
  814. });
  815. /***/ }),
  816. /* 43 */
  817. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  818. var global = __webpack_require__(4);
  819. var isObject = __webpack_require__(20);
  820. var document = global.document;
  821. var EXISTS = isObject(document) && isObject(document.createElement);
  822. module.exports = function (it) {
  823. return EXISTS ? document.createElement(it) : {};
  824. };
  825. /***/ }),
  826. /* 44 */
  827. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  828. var DESCRIPTORS = __webpack_require__(6);
  829. var definePropertyModule = __webpack_require__(45);
  830. var createPropertyDescriptor = __webpack_require__(11);
  831. module.exports = DESCRIPTORS ? function (object, key, value) {
  832. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  833. } : function (object, key, value) {
  834. object[key] = value;
  835. return object;
  836. };
  837. /***/ }),
  838. /* 45 */
  839. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  840. var DESCRIPTORS = __webpack_require__(6);
  841. var IE8_DOM_DEFINE = __webpack_require__(42);
  842. var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(46);
  843. var anObject = __webpack_require__(47);
  844. var toPropertyKey = __webpack_require__(18);
  845. var $TypeError = TypeError;
  846. var $defineProperty = Object.defineProperty;
  847. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  848. var ENUMERABLE = 'enumerable';
  849. var CONFIGURABLE = 'configurable';
  850. var WRITABLE = 'writable';
  851. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  852. anObject(O);
  853. P = toPropertyKey(P);
  854. anObject(Attributes);
  855. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  856. var current = $getOwnPropertyDescriptor(O, P);
  857. if (current && current[WRITABLE]) {
  858. O[P] = Attributes.value;
  859. Attributes = {
  860. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  861. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  862. writable: false
  863. };
  864. }
  865. }
  866. return $defineProperty(O, P, Attributes);
  867. } : $defineProperty : function defineProperty(O, P, Attributes) {
  868. anObject(O);
  869. P = toPropertyKey(P);
  870. anObject(Attributes);
  871. if (IE8_DOM_DEFINE)
  872. try {
  873. return $defineProperty(O, P, Attributes);
  874. } catch (error) {
  875. }
  876. if ('get' in Attributes || 'set' in Attributes)
  877. throw $TypeError('Accessors not supported');
  878. if ('value' in Attributes)
  879. O[P] = Attributes.value;
  880. return O;
  881. };
  882. /***/ }),
  883. /* 46 */
  884. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  885. var DESCRIPTORS = __webpack_require__(6);
  886. var fails = __webpack_require__(7);
  887. module.exports = DESCRIPTORS && fails(function () {
  888. return Object.defineProperty(function () {
  889. }, 'prototype', {
  890. value: 42,
  891. writable: false
  892. }).prototype != 42;
  893. });
  894. /***/ }),
  895. /* 47 */
  896. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  897. var isObject = __webpack_require__(20);
  898. var $String = String;
  899. var $TypeError = TypeError;
  900. module.exports = function (argument) {
  901. if (isObject(argument))
  902. return argument;
  903. throw $TypeError($String(argument) + ' is not an object');
  904. };
  905. /***/ }),
  906. /* 48 */
  907. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  908. var isCallable = __webpack_require__(21);
  909. var definePropertyModule = __webpack_require__(45);
  910. var makeBuiltIn = __webpack_require__(49);
  911. var defineGlobalProperty = __webpack_require__(38);
  912. module.exports = function (O, key, value, options) {
  913. if (!options)
  914. options = {};
  915. var simple = options.enumerable;
  916. var name = options.name !== undefined ? options.name : key;
  917. if (isCallable(value))
  918. makeBuiltIn(value, name, options);
  919. if (options.global) {
  920. if (simple)
  921. O[key] = value;
  922. else
  923. defineGlobalProperty(key, value);
  924. } else {
  925. try {
  926. if (!options.unsafe)
  927. delete O[key];
  928. else if (O[key])
  929. simple = true;
  930. } catch (error) {
  931. }
  932. if (simple)
  933. O[key] = value;
  934. else
  935. definePropertyModule.f(O, key, {
  936. value: value,
  937. enumerable: false,
  938. configurable: !options.nonConfigurable,
  939. writable: !options.nonWritable
  940. });
  941. }
  942. return O;
  943. };
  944. /***/ }),
  945. /* 49 */
  946. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  947. var uncurryThis = __webpack_require__(14);
  948. var fails = __webpack_require__(7);
  949. var isCallable = __webpack_require__(21);
  950. var hasOwn = __webpack_require__(39);
  951. var DESCRIPTORS = __webpack_require__(6);
  952. var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(50).CONFIGURABLE);
  953. var inspectSource = __webpack_require__(51);
  954. var InternalStateModule = __webpack_require__(52);
  955. var enforceInternalState = InternalStateModule.enforce;
  956. var getInternalState = InternalStateModule.get;
  957. var $String = String;
  958. var defineProperty = Object.defineProperty;
  959. var stringSlice = uncurryThis(''.slice);
  960. var replace = uncurryThis(''.replace);
  961. var join = uncurryThis([].join);
  962. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  963. return defineProperty(function () {
  964. }, 'length', { value: 8 }).length !== 8;
  965. });
  966. var TEMPLATE = String(String).split('String');
  967. var makeBuiltIn = module.exports = function (value, name, options) {
  968. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  969. name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
  970. }
  971. if (options && options.getter)
  972. name = 'get ' + name;
  973. if (options && options.setter)
  974. name = 'set ' + name;
  975. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  976. if (DESCRIPTORS)
  977. defineProperty(value, 'name', {
  978. value: name,
  979. configurable: true
  980. });
  981. else
  982. value.name = name;
  983. }
  984. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  985. defineProperty(value, 'length', { value: options.arity });
  986. }
  987. try {
  988. if (options && hasOwn(options, 'constructor') && options.constructor) {
  989. if (DESCRIPTORS)
  990. defineProperty(value, 'prototype', { writable: false });
  991. } else if (value.prototype)
  992. value.prototype = undefined;
  993. } catch (error) {
  994. }
  995. var state = enforceInternalState(value);
  996. if (!hasOwn(state, 'source')) {
  997. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  998. }
  999. return value;
  1000. };
  1001. Function.prototype.toString = makeBuiltIn(function toString() {
  1002. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1003. }, 'toString');
  1004. /***/ }),
  1005. /* 50 */
  1006. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1007. var DESCRIPTORS = __webpack_require__(6);
  1008. var hasOwn = __webpack_require__(39);
  1009. var FunctionPrototype = Function.prototype;
  1010. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1011. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1012. var PROPER = EXISTS && function something() {
  1013. }.name === 'something';
  1014. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1015. module.exports = {
  1016. EXISTS: EXISTS,
  1017. PROPER: PROPER,
  1018. CONFIGURABLE: CONFIGURABLE
  1019. };
  1020. /***/ }),
  1021. /* 51 */
  1022. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1023. var uncurryThis = __webpack_require__(14);
  1024. var isCallable = __webpack_require__(21);
  1025. var store = __webpack_require__(37);
  1026. var functionToString = uncurryThis(Function.toString);
  1027. if (!isCallable(store.inspectSource)) {
  1028. store.inspectSource = function (it) {
  1029. return functionToString(it);
  1030. };
  1031. }
  1032. module.exports = store.inspectSource;
  1033. /***/ }),
  1034. /* 52 */
  1035. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1036. var NATIVE_WEAK_MAP = __webpack_require__(53);
  1037. var global = __webpack_require__(4);
  1038. var isObject = __webpack_require__(20);
  1039. var createNonEnumerableProperty = __webpack_require__(44);
  1040. var hasOwn = __webpack_require__(39);
  1041. var shared = __webpack_require__(37);
  1042. var sharedKey = __webpack_require__(54);
  1043. var hiddenKeys = __webpack_require__(55);
  1044. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1045. var TypeError = global.TypeError;
  1046. var WeakMap = global.WeakMap;
  1047. var set, get, has;
  1048. var enforce = function (it) {
  1049. return has(it) ? get(it) : set(it, {});
  1050. };
  1051. var getterFor = function (TYPE) {
  1052. return function (it) {
  1053. var state;
  1054. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1055. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1056. }
  1057. return state;
  1058. };
  1059. };
  1060. if (NATIVE_WEAK_MAP || shared.state) {
  1061. var store = shared.state || (shared.state = new WeakMap());
  1062. store.get = store.get;
  1063. store.has = store.has;
  1064. store.set = store.set;
  1065. set = function (it, metadata) {
  1066. if (store.has(it))
  1067. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1068. metadata.facade = it;
  1069. store.set(it, metadata);
  1070. return metadata;
  1071. };
  1072. get = function (it) {
  1073. return store.get(it) || {};
  1074. };
  1075. has = function (it) {
  1076. return store.has(it);
  1077. };
  1078. } else {
  1079. var STATE = sharedKey('state');
  1080. hiddenKeys[STATE] = true;
  1081. set = function (it, metadata) {
  1082. if (hasOwn(it, STATE))
  1083. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1084. metadata.facade = it;
  1085. createNonEnumerableProperty(it, STATE, metadata);
  1086. return metadata;
  1087. };
  1088. get = function (it) {
  1089. return hasOwn(it, STATE) ? it[STATE] : {};
  1090. };
  1091. has = function (it) {
  1092. return hasOwn(it, STATE);
  1093. };
  1094. }
  1095. module.exports = {
  1096. set: set,
  1097. get: get,
  1098. has: has,
  1099. enforce: enforce,
  1100. getterFor: getterFor
  1101. };
  1102. /***/ }),
  1103. /* 53 */
  1104. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1105. var global = __webpack_require__(4);
  1106. var isCallable = __webpack_require__(21);
  1107. var WeakMap = global.WeakMap;
  1108. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  1109. /***/ }),
  1110. /* 54 */
  1111. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1112. var shared = __webpack_require__(35);
  1113. var uid = __webpack_require__(41);
  1114. var keys = shared('keys');
  1115. module.exports = function (key) {
  1116. return keys[key] || (keys[key] = uid(key));
  1117. };
  1118. /***/ }),
  1119. /* 55 */
  1120. /***/ ((module) => {
  1121. module.exports = {};
  1122. /***/ }),
  1123. /* 56 */
  1124. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1125. var hasOwn = __webpack_require__(39);
  1126. var ownKeys = __webpack_require__(57);
  1127. var getOwnPropertyDescriptorModule = __webpack_require__(5);
  1128. var definePropertyModule = __webpack_require__(45);
  1129. module.exports = function (target, source, exceptions) {
  1130. var keys = ownKeys(source);
  1131. var defineProperty = definePropertyModule.f;
  1132. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1133. for (var i = 0; i < keys.length; i++) {
  1134. var key = keys[i];
  1135. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  1136. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1137. }
  1138. }
  1139. };
  1140. /***/ }),
  1141. /* 57 */
  1142. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1143. var getBuiltIn = __webpack_require__(24);
  1144. var uncurryThis = __webpack_require__(14);
  1145. var getOwnPropertyNamesModule = __webpack_require__(58);
  1146. var getOwnPropertySymbolsModule = __webpack_require__(67);
  1147. var anObject = __webpack_require__(47);
  1148. var concat = uncurryThis([].concat);
  1149. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1150. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1151. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1152. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1153. };
  1154. /***/ }),
  1155. /* 58 */
  1156. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1157. var internalObjectKeys = __webpack_require__(59);
  1158. var enumBugKeys = __webpack_require__(66);
  1159. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1160. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1161. return internalObjectKeys(O, hiddenKeys);
  1162. };
  1163. /***/ }),
  1164. /* 59 */
  1165. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1166. var uncurryThis = __webpack_require__(14);
  1167. var hasOwn = __webpack_require__(39);
  1168. var toIndexedObject = __webpack_require__(12);
  1169. var indexOf = (__webpack_require__(60).indexOf);
  1170. var hiddenKeys = __webpack_require__(55);
  1171. var push = uncurryThis([].push);
  1172. module.exports = function (object, names) {
  1173. var O = toIndexedObject(object);
  1174. var i = 0;
  1175. var result = [];
  1176. var key;
  1177. for (key in O)
  1178. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1179. while (names.length > i)
  1180. if (hasOwn(O, key = names[i++])) {
  1181. ~indexOf(result, key) || push(result, key);
  1182. }
  1183. return result;
  1184. };
  1185. /***/ }),
  1186. /* 60 */
  1187. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1188. var toIndexedObject = __webpack_require__(12);
  1189. var toAbsoluteIndex = __webpack_require__(61);
  1190. var lengthOfArrayLike = __webpack_require__(64);
  1191. var createMethod = function (IS_INCLUDES) {
  1192. return function ($this, el, fromIndex) {
  1193. var O = toIndexedObject($this);
  1194. var length = lengthOfArrayLike(O);
  1195. var index = toAbsoluteIndex(fromIndex, length);
  1196. var value;
  1197. if (IS_INCLUDES && el != el)
  1198. while (length > index) {
  1199. value = O[index++];
  1200. if (value != value)
  1201. return true;
  1202. }
  1203. else
  1204. for (; length > index; index++) {
  1205. if ((IS_INCLUDES || index in O) && O[index] === el)
  1206. return IS_INCLUDES || index || 0;
  1207. }
  1208. return !IS_INCLUDES && -1;
  1209. };
  1210. };
  1211. module.exports = {
  1212. includes: createMethod(true),
  1213. indexOf: createMethod(false)
  1214. };
  1215. /***/ }),
  1216. /* 61 */
  1217. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1218. var toIntegerOrInfinity = __webpack_require__(62);
  1219. var max = Math.max;
  1220. var min = Math.min;
  1221. module.exports = function (index, length) {
  1222. var integer = toIntegerOrInfinity(index);
  1223. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1224. };
  1225. /***/ }),
  1226. /* 62 */
  1227. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1228. var trunc = __webpack_require__(63);
  1229. module.exports = function (argument) {
  1230. var number = +argument;
  1231. return number !== number || number === 0 ? 0 : trunc(number);
  1232. };
  1233. /***/ }),
  1234. /* 63 */
  1235. /***/ ((module) => {
  1236. var ceil = Math.ceil;
  1237. var floor = Math.floor;
  1238. module.exports = Math.trunc || function trunc(x) {
  1239. var n = +x;
  1240. return (n > 0 ? floor : ceil)(n);
  1241. };
  1242. /***/ }),
  1243. /* 64 */
  1244. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1245. var toLength = __webpack_require__(65);
  1246. module.exports = function (obj) {
  1247. return toLength(obj.length);
  1248. };
  1249. /***/ }),
  1250. /* 65 */
  1251. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1252. var toIntegerOrInfinity = __webpack_require__(62);
  1253. var min = Math.min;
  1254. module.exports = function (argument) {
  1255. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1256. };
  1257. /***/ }),
  1258. /* 66 */
  1259. /***/ ((module) => {
  1260. module.exports = [
  1261. 'constructor',
  1262. 'hasOwnProperty',
  1263. 'isPrototypeOf',
  1264. 'propertyIsEnumerable',
  1265. 'toLocaleString',
  1266. 'toString',
  1267. 'valueOf'
  1268. ];
  1269. /***/ }),
  1270. /* 67 */
  1271. /***/ ((__unused_webpack_module, exports) => {
  1272. exports.f = Object.getOwnPropertySymbols;
  1273. /***/ }),
  1274. /* 68 */
  1275. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1276. var fails = __webpack_require__(7);
  1277. var isCallable = __webpack_require__(21);
  1278. var replacement = /#|\.prototype\./;
  1279. var isForced = function (feature, detection) {
  1280. var value = data[normalize(feature)];
  1281. return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1282. };
  1283. var normalize = isForced.normalize = function (string) {
  1284. return String(string).replace(replacement, '.').toLowerCase();
  1285. };
  1286. var data = isForced.data = {};
  1287. var NATIVE = isForced.NATIVE = 'N';
  1288. var POLYFILL = isForced.POLYFILL = 'P';
  1289. module.exports = isForced;
  1290. /***/ }),
  1291. /* 69 */
  1292. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1293. var classof = __webpack_require__(15);
  1294. module.exports = Array.isArray || function isArray(argument) {
  1295. return classof(argument) == 'Array';
  1296. };
  1297. /***/ }),
  1298. /* 70 */
  1299. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1300. var classof = __webpack_require__(71);
  1301. var $String = String;
  1302. module.exports = function (argument) {
  1303. if (classof(argument) === 'Symbol')
  1304. throw TypeError('Cannot convert a Symbol value to a string');
  1305. return $String(argument);
  1306. };
  1307. /***/ }),
  1308. /* 71 */
  1309. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1310. var TO_STRING_TAG_SUPPORT = __webpack_require__(72);
  1311. var isCallable = __webpack_require__(21);
  1312. var classofRaw = __webpack_require__(15);
  1313. var wellKnownSymbol = __webpack_require__(34);
  1314. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1315. var $Object = Object;
  1316. var CORRECT_ARGUMENTS = classofRaw((function () {
  1317. return arguments;
  1318. }())) == 'Arguments';
  1319. var tryGet = function (it, key) {
  1320. try {
  1321. return it[key];
  1322. } catch (error) {
  1323. }
  1324. };
  1325. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  1326. var O, tag, result;
  1327. 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;
  1328. };
  1329. /***/ }),
  1330. /* 72 */
  1331. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1332. var wellKnownSymbol = __webpack_require__(34);
  1333. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1334. var test = {};
  1335. test[TO_STRING_TAG] = 'z';
  1336. module.exports = String(test) === '[object z]';
  1337. /***/ }),
  1338. /* 73 */
  1339. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1340. "use strict";
  1341. var toPropertyKey = __webpack_require__(18);
  1342. var definePropertyModule = __webpack_require__(45);
  1343. var createPropertyDescriptor = __webpack_require__(11);
  1344. module.exports = function (object, key, value) {
  1345. var propertyKey = toPropertyKey(key);
  1346. if (propertyKey in object)
  1347. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  1348. else
  1349. object[propertyKey] = value;
  1350. };
  1351. /***/ }),
  1352. /* 74 */
  1353. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1354. var uncurryThis = __webpack_require__(14);
  1355. var hasOwn = __webpack_require__(39);
  1356. var $SyntaxError = SyntaxError;
  1357. var $parseInt = parseInt;
  1358. var fromCharCode = String.fromCharCode;
  1359. var at = uncurryThis(''.charAt);
  1360. var slice = uncurryThis(''.slice);
  1361. var exec = uncurryThis(/./.exec);
  1362. var codePoints = {
  1363. '\\"': '"',
  1364. '\\\\': '\\',
  1365. '\\/': '/',
  1366. '\\b': '\b',
  1367. '\\f': '\f',
  1368. '\\n': '\n',
  1369. '\\r': '\r',
  1370. '\\t': '\t'
  1371. };
  1372. var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i;
  1373. var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/;
  1374. module.exports = function (source, i) {
  1375. var unterminated = true;
  1376. var value = '';
  1377. while (i < source.length) {
  1378. var chr = at(source, i);
  1379. if (chr == '\\') {
  1380. var twoChars = slice(source, i, i + 2);
  1381. if (hasOwn(codePoints, twoChars)) {
  1382. value += codePoints[twoChars];
  1383. i += 2;
  1384. } else if (twoChars == '\\u') {
  1385. i += 2;
  1386. var fourHexDigits = slice(source, i, i + 4);
  1387. if (!exec(IS_4_HEX_DIGITS, fourHexDigits))
  1388. throw $SyntaxError('Bad Unicode escape at: ' + i);
  1389. value += fromCharCode($parseInt(fourHexDigits, 16));
  1390. i += 4;
  1391. } else
  1392. throw $SyntaxError('Unknown escape sequence: "' + twoChars + '"');
  1393. } else if (chr == '"') {
  1394. unterminated = false;
  1395. i++;
  1396. break;
  1397. } else {
  1398. if (exec(IS_C0_CONTROL_CODE, chr))
  1399. throw $SyntaxError('Bad control character in string literal at: ' + i);
  1400. value += chr;
  1401. i++;
  1402. }
  1403. }
  1404. if (unterminated)
  1405. throw $SyntaxError('Unterminated string at: ' + i);
  1406. return {
  1407. value: value,
  1408. end: i
  1409. };
  1410. };
  1411. /***/ }),
  1412. /* 75 */
  1413. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1414. "use strict";
  1415. Object.defineProperty(exports, "__esModule", ({
  1416. value: true
  1417. }));
  1418. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  1419. __webpack_require__(76);
  1420. __webpack_require__(89);
  1421. __webpack_require__(92);
  1422. __webpack_require__(94);
  1423. __webpack_require__(95);
  1424. var _ui_utils = __webpack_require__(97);
  1425. var _pdfjsLib = __webpack_require__(121);
  1426. var _app_options = __webpack_require__(122);
  1427. var _event_utils = __webpack_require__(123);
  1428. var _pdf_link_service = __webpack_require__(124);
  1429. var _webAnnotation_editor_params = __webpack_require__(125);
  1430. var _overlay_manager = __webpack_require__(126);
  1431. var _password_prompt = __webpack_require__(127);
  1432. var _webPdf_attachment_viewer = __webpack_require__(128);
  1433. var _webPdf_cursor_tools = __webpack_require__(130);
  1434. var _webPdf_document_properties = __webpack_require__(132);
  1435. var _webPdf_find_bar = __webpack_require__(133);
  1436. var _pdf_find_controller = __webpack_require__(134);
  1437. var _pdf_history = __webpack_require__(136);
  1438. var _webPdf_layer_viewer = __webpack_require__(137);
  1439. var _webPdf_outline_viewer = __webpack_require__(138);
  1440. var _webPdf_presentation_mode = __webpack_require__(139);
  1441. var _pdf_rendering_queue = __webpack_require__(140);
  1442. var _pdf_scripting_manager = __webpack_require__(141);
  1443. var _webPdf_sidebar = __webpack_require__(142);
  1444. var _webPdf_thumbnail_viewer = __webpack_require__(143);
  1445. var _pdf_viewer = __webpack_require__(145);
  1446. var _webSecondary_toolbar = __webpack_require__(155);
  1447. var _webToolbar = __webpack_require__(156);
  1448. var _view_history = __webpack_require__(157);
  1449. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  1450. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  1451. const ViewOnLoad = {
  1452. UNKNOWN: -1,
  1453. PREVIOUS: 0,
  1454. INITIAL: 1
  1455. };
  1456. const ViewerCssTheme = {
  1457. AUTOMATIC: 0,
  1458. LIGHT: 1,
  1459. DARK: 2
  1460. };
  1461. class DefaultExternalServices {
  1462. constructor() {
  1463. throw new Error("Cannot initialize DefaultExternalServices.");
  1464. }
  1465. static updateFindControlState(data) {}
  1466. static updateFindMatchesCount(data) {}
  1467. static initPassiveLoading(callbacks) {}
  1468. static reportTelemetry(data) {}
  1469. static createDownloadManager() {
  1470. throw new Error("Not implemented: createDownloadManager");
  1471. }
  1472. static createPreferences() {
  1473. throw new Error("Not implemented: createPreferences");
  1474. }
  1475. static createL10n(options) {
  1476. throw new Error("Not implemented: createL10n");
  1477. }
  1478. static createScripting(options) {
  1479. throw new Error("Not implemented: createScripting");
  1480. }
  1481. static get supportsPinchToZoom() {
  1482. return (0, _pdfjsLib.shadow)(this, "supportsPinchToZoom", true);
  1483. }
  1484. static get supportsIntegratedFind() {
  1485. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  1486. }
  1487. static get supportsDocumentFonts() {
  1488. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  1489. }
  1490. static get supportedMouseWheelZoomModifierKeys() {
  1491. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  1492. ctrlKey: true,
  1493. metaKey: true
  1494. });
  1495. }
  1496. static get isInAutomation() {
  1497. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  1498. }
  1499. static updateEditorStates(data) {
  1500. throw new Error("Not implemented: updateEditorStates");
  1501. }
  1502. static get canvasMaxAreaInBytes() {
  1503. return (0, _pdfjsLib.shadow)(this, "canvasMaxAreaInBytes", -1);
  1504. }
  1505. static getNimbusExperimentData() {
  1506. return (0, _pdfjsLib.shadow)(this, "getNimbusExperimentData", Promise.resolve(null));
  1507. }
  1508. }
  1509. exports.DefaultExternalServices = DefaultExternalServices;
  1510. const PDFViewerApplication = {
  1511. initialBookmark: document.location.hash.substring(1),
  1512. _initializedCapability: new _pdfjsLib.PromiseCapability(),
  1513. appConfig: null,
  1514. pdfDocument: null,
  1515. pdfLoadingTask: null,
  1516. printService: null,
  1517. pdfViewer: null,
  1518. pdfThumbnailViewer: null,
  1519. pdfRenderingQueue: null,
  1520. pdfPresentationMode: null,
  1521. pdfDocumentProperties: null,
  1522. pdfLinkService: null,
  1523. pdfHistory: null,
  1524. pdfSidebar: null,
  1525. pdfOutlineViewer: null,
  1526. pdfAttachmentViewer: null,
  1527. pdfLayerViewer: null,
  1528. pdfCursorTools: null,
  1529. pdfScriptingManager: null,
  1530. store: null,
  1531. downloadManager: null,
  1532. overlayManager: null,
  1533. preferences: null,
  1534. toolbar: null,
  1535. secondaryToolbar: null,
  1536. eventBus: null,
  1537. l10n: null,
  1538. annotationEditorParams: null,
  1539. isInitialViewSet: false,
  1540. downloadComplete: false,
  1541. isViewerEmbedded: window.parent !== window,
  1542. url: "",
  1543. baseUrl: "",
  1544. _downloadUrl: "",
  1545. externalServices: DefaultExternalServices,
  1546. _boundEvents: Object.create(null),
  1547. documentInfo: null,
  1548. metadata: null,
  1549. _contentDispositionFilename: null,
  1550. _contentLength: null,
  1551. _saveInProgress: false,
  1552. _wheelUnusedTicks: 0,
  1553. _wheelUnusedFactor: 1,
  1554. _touchUnusedTicks: 0,
  1555. _touchUnusedFactor: 1,
  1556. _PDFBug: null,
  1557. _hasAnnotationEditors: false,
  1558. _title: document.title,
  1559. _printAnnotationStoragePromise: null,
  1560. _touchInfo: null,
  1561. _isCtrlKeyDown: false,
  1562. _nimbusDataPromise: null,
  1563. async initialize(appConfig) {
  1564. this.preferences = this.externalServices.createPreferences();
  1565. this.appConfig = appConfig;
  1566. await this._initializeOptions();
  1567. this._forceCssTheme();
  1568. await this._initializeL10n();
  1569. if (this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf_link_service.LinkTarget.NONE) {
  1570. _app_options.AppOptions.set("externalLinkTarget", _pdf_link_service.LinkTarget.TOP);
  1571. }
  1572. await this._initializeViewerComponents();
  1573. this.bindEvents();
  1574. this.bindWindowEvents();
  1575. const appContainer = appConfig.appContainer || document.documentElement;
  1576. this.l10n.translate(appContainer).then(() => {
  1577. this.eventBus.dispatch("localized", {
  1578. source: this
  1579. });
  1580. });
  1581. this._initializedCapability.resolve();
  1582. },
  1583. async _initializeOptions() {
  1584. if (_app_options.AppOptions.get("disablePreferences")) {
  1585. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  1586. await this._parseHashParams();
  1587. }
  1588. return;
  1589. }
  1590. if (_app_options.AppOptions._hasUserOptions()) {
  1591. console.warn("_initializeOptions: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  1592. }
  1593. try {
  1594. _app_options.AppOptions.setAll(await this.preferences.getAll());
  1595. } catch (reason) {
  1596. console.error(`_initializeOptions: "${reason.message}".`);
  1597. }
  1598. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  1599. await this._parseHashParams();
  1600. }
  1601. },
  1602. async _parseHashParams() {
  1603. const hash = document.location.hash.substring(1);
  1604. if (!hash) {
  1605. return;
  1606. }
  1607. const {
  1608. mainContainer,
  1609. viewerContainer
  1610. } = this.appConfig,
  1611. params = (0, _ui_utils.parseQueryString)(hash);
  1612. if (params.get("disableworker") === "true") {
  1613. try {
  1614. await loadFakeWorker();
  1615. } catch (ex) {
  1616. console.error(`_parseHashParams: "${ex.message}".`);
  1617. }
  1618. }
  1619. if (params.has("disablerange")) {
  1620. _app_options.AppOptions.set("disableRange", params.get("disablerange") === "true");
  1621. }
  1622. if (params.has("disablestream")) {
  1623. _app_options.AppOptions.set("disableStream", params.get("disablestream") === "true");
  1624. }
  1625. if (params.has("disableautofetch")) {
  1626. _app_options.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  1627. }
  1628. if (params.has("disablefontface")) {
  1629. _app_options.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  1630. }
  1631. if (params.has("disablehistory")) {
  1632. _app_options.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  1633. }
  1634. if (params.has("verbosity")) {
  1635. _app_options.AppOptions.set("verbosity", params.get("verbosity") | 0);
  1636. }
  1637. if (params.has("textlayer")) {
  1638. switch (params.get("textlayer")) {
  1639. case "off":
  1640. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  1641. break;
  1642. case "visible":
  1643. case "shadow":
  1644. case "hover":
  1645. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  1646. try {
  1647. await loadPDFBug(this);
  1648. this._PDFBug.loadCSS();
  1649. } catch (ex) {
  1650. console.error(`_parseHashParams: "${ex.message}".`);
  1651. }
  1652. break;
  1653. }
  1654. }
  1655. if (params.has("pdfbug")) {
  1656. _app_options.AppOptions.set("pdfBug", true);
  1657. _app_options.AppOptions.set("fontExtraProperties", true);
  1658. const enabled = params.get("pdfbug").split(",");
  1659. try {
  1660. await loadPDFBug(this);
  1661. this._PDFBug.init(mainContainer, enabled);
  1662. } catch (ex) {
  1663. console.error(`_parseHashParams: "${ex.message}".`);
  1664. }
  1665. }
  1666. if (params.has("locale")) {
  1667. _app_options.AppOptions.set("locale", params.get("locale"));
  1668. }
  1669. },
  1670. async _initializeL10n() {
  1671. this.l10n = this.externalServices.createL10n({
  1672. locale: _app_options.AppOptions.get("locale")
  1673. });
  1674. const dir = await this.l10n.getDirection();
  1675. document.getElementsByTagName("html")[0].dir = dir;
  1676. },
  1677. _forceCssTheme() {
  1678. const cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  1679. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  1680. return;
  1681. }
  1682. try {
  1683. const styleSheet = document.styleSheets[0];
  1684. const cssRules = styleSheet?.cssRules || [];
  1685. for (let i = 0, ii = cssRules.length; i < ii; i++) {
  1686. const rule = cssRules[i];
  1687. if (rule instanceof CSSMediaRule && rule.media?.[0] === "(prefers-color-scheme: dark)") {
  1688. if (cssTheme === ViewerCssTheme.LIGHT) {
  1689. styleSheet.deleteRule(i);
  1690. return;
  1691. }
  1692. const darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  1693. if (darkRules?.[1]) {
  1694. styleSheet.deleteRule(i);
  1695. styleSheet.insertRule(darkRules[1], i);
  1696. }
  1697. return;
  1698. }
  1699. }
  1700. } catch (reason) {
  1701. console.error(`_forceCssTheme: "${reason?.message}".`);
  1702. }
  1703. },
  1704. async _initializeViewerComponents() {
  1705. const {
  1706. appConfig,
  1707. externalServices,
  1708. l10n
  1709. } = this;
  1710. const eventBus = externalServices.isInAutomation ? new _event_utils.AutomationEventBus() : new _event_utils.EventBus();
  1711. this.eventBus = eventBus;
  1712. this.overlayManager = new _overlay_manager.OverlayManager();
  1713. const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  1714. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  1715. this.pdfRenderingQueue = pdfRenderingQueue;
  1716. const pdfLinkService = new _pdf_link_service.PDFLinkService({
  1717. eventBus,
  1718. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  1719. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  1720. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  1721. });
  1722. this.pdfLinkService = pdfLinkService;
  1723. const downloadManager = externalServices.createDownloadManager();
  1724. this.downloadManager = downloadManager;
  1725. const findController = new _pdf_find_controller.PDFFindController({
  1726. linkService: pdfLinkService,
  1727. eventBus,
  1728. updateMatchesCountOnProgress: true
  1729. });
  1730. this.findController = findController;
  1731. const pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  1732. eventBus,
  1733. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc"),
  1734. externalServices,
  1735. docProperties: this._scriptingDocProperties.bind(this)
  1736. });
  1737. this.pdfScriptingManager = pdfScriptingManager;
  1738. const container = appConfig.mainContainer,
  1739. viewer = appConfig.viewerContainer;
  1740. const annotationEditorMode = _app_options.AppOptions.get("annotationEditorMode");
  1741. const isOffscreenCanvasSupported = _app_options.AppOptions.get("isOffscreenCanvasSupported") && _pdfjsLib.FeatureTest.isOffscreenCanvasSupported;
  1742. const pageColors = _app_options.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  1743. background: _app_options.AppOptions.get("pageColorsBackground"),
  1744. foreground: _app_options.AppOptions.get("pageColorsForeground")
  1745. } : null;
  1746. const pdfViewer = new _pdf_viewer.PDFViewer({
  1747. container,
  1748. viewer,
  1749. eventBus,
  1750. renderingQueue: pdfRenderingQueue,
  1751. linkService: pdfLinkService,
  1752. downloadManager,
  1753. findController,
  1754. scriptingManager: _app_options.AppOptions.get("enableScripting") && pdfScriptingManager,
  1755. l10n,
  1756. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  1757. annotationMode: _app_options.AppOptions.get("annotationMode"),
  1758. annotationEditorMode,
  1759. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  1760. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  1761. isOffscreenCanvasSupported,
  1762. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  1763. enablePermissions: _app_options.AppOptions.get("enablePermissions"),
  1764. pageColors
  1765. });
  1766. this.pdfViewer = pdfViewer;
  1767. pdfRenderingQueue.setViewer(pdfViewer);
  1768. pdfLinkService.setViewer(pdfViewer);
  1769. pdfScriptingManager.setViewer(pdfViewer);
  1770. if (appConfig.sidebar?.thumbnailView) {
  1771. this.pdfThumbnailViewer = new _webPdf_thumbnail_viewer.PDFThumbnailViewer({
  1772. container: appConfig.sidebar.thumbnailView,
  1773. eventBus,
  1774. renderingQueue: pdfRenderingQueue,
  1775. linkService: pdfLinkService,
  1776. l10n,
  1777. pageColors
  1778. });
  1779. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  1780. }
  1781. if (!this.isViewerEmbedded && !_app_options.AppOptions.get("disableHistory")) {
  1782. this.pdfHistory = new _pdf_history.PDFHistory({
  1783. linkService: pdfLinkService,
  1784. eventBus
  1785. });
  1786. pdfLinkService.setHistory(this.pdfHistory);
  1787. }
  1788. if (!this.supportsIntegratedFind && appConfig.findBar) {
  1789. this.findBar = new _webPdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, l10n);
  1790. }
  1791. if (appConfig.annotationEditorParams) {
  1792. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  1793. if (_app_options.AppOptions.get("enableStampEditor") && isOffscreenCanvasSupported) {
  1794. appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
  1795. }
  1796. this.annotationEditorParams = new _webAnnotation_editor_params.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  1797. } else {
  1798. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  1799. document.getElementById(id)?.classList.add("hidden");
  1800. }
  1801. }
  1802. }
  1803. if (appConfig.documentProperties) {
  1804. this.pdfDocumentProperties = new _webPdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
  1805. }
  1806. if (appConfig.secondaryToolbar?.cursorHandToolButton) {
  1807. this.pdfCursorTools = new _webPdf_cursor_tools.PDFCursorTools({
  1808. container,
  1809. eventBus,
  1810. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  1811. });
  1812. }
  1813. if (appConfig.toolbar) {
  1814. this.toolbar = new _webToolbar.Toolbar(appConfig.toolbar, eventBus, l10n);
  1815. }
  1816. if (appConfig.secondaryToolbar) {
  1817. this.secondaryToolbar = new _webSecondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, eventBus, externalServices);
  1818. }
  1819. if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
  1820. this.pdfPresentationMode = new _webPdf_presentation_mode.PDFPresentationMode({
  1821. container,
  1822. pdfViewer,
  1823. eventBus
  1824. });
  1825. }
  1826. if (appConfig.passwordOverlay) {
  1827. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, l10n, this.isViewerEmbedded);
  1828. }
  1829. if (appConfig.sidebar?.outlineView) {
  1830. this.pdfOutlineViewer = new _webPdf_outline_viewer.PDFOutlineViewer({
  1831. container: appConfig.sidebar.outlineView,
  1832. eventBus,
  1833. linkService: pdfLinkService,
  1834. downloadManager
  1835. });
  1836. }
  1837. if (appConfig.sidebar?.attachmentsView) {
  1838. this.pdfAttachmentViewer = new _webPdf_attachment_viewer.PDFAttachmentViewer({
  1839. container: appConfig.sidebar.attachmentsView,
  1840. eventBus,
  1841. downloadManager
  1842. });
  1843. }
  1844. if (appConfig.sidebar?.layersView) {
  1845. this.pdfLayerViewer = new _webPdf_layer_viewer.PDFLayerViewer({
  1846. container: appConfig.sidebar.layersView,
  1847. eventBus,
  1848. l10n
  1849. });
  1850. }
  1851. if (appConfig.sidebar) {
  1852. this.pdfSidebar = new _webPdf_sidebar.PDFSidebar({
  1853. elements: appConfig.sidebar,
  1854. eventBus,
  1855. l10n
  1856. });
  1857. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  1858. this.pdfSidebar.onUpdateThumbnails = () => {
  1859. for (const pageView of pdfViewer.getCachedPageViews()) {
  1860. if (pageView.renderingState === _ui_utils.RenderingStates.FINISHED) {
  1861. this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
  1862. }
  1863. }
  1864. this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  1865. };
  1866. }
  1867. },
  1868. async run(config) {
  1869. await this.initialize(config);
  1870. const {
  1871. appConfig,
  1872. eventBus
  1873. } = this;
  1874. let file;
  1875. let disablePresentationMode;
  1876. let disableOpenFile;
  1877. let disablePrint;
  1878. let disableDownload;
  1879. let disableBookmark;
  1880. let disableEditing;
  1881. const queryString = document.location.search.substring(1);
  1882. const params = (0, _ui_utils.parseQueryString)(queryString);
  1883. file = params.get("file") ?? _app_options.AppOptions.get("defaultUrl");
  1884. disablePresentationMode = params.get('disablepresentationmode') ?? 'false';
  1885. disableOpenFile = params.get("disableopenfile") ?? 'false';
  1886. disablePrint = params.get("disableprint") ?? 'false';
  1887. disableDownload = params.get("disabledownload") ?? 'false';
  1888. disableBookmark = params.get("disablebookmark") ?? 'false';
  1889. disableEditing = params.get("disableediting") ?? 'false';
  1890. validateFileURL(file);
  1891. const fileInput = appConfig.openFileInput;
  1892. fileInput.value = null;
  1893. fileInput.addEventListener("change", function (evt) {
  1894. const {
  1895. files
  1896. } = evt.target;
  1897. if (!files || files.length === 0) {
  1898. return;
  1899. }
  1900. eventBus.dispatch("fileinputchange", {
  1901. source: this,
  1902. fileInput: evt.target
  1903. });
  1904. });
  1905. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1906. evt.preventDefault();
  1907. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  1908. });
  1909. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1910. evt.preventDefault();
  1911. const {
  1912. files
  1913. } = evt.dataTransfer;
  1914. if (!files || files.length === 0) {
  1915. return;
  1916. }
  1917. eventBus.dispatch("fileinputchange", {
  1918. source: this,
  1919. fileInput: evt.dataTransfer
  1920. });
  1921. });
  1922. if (!this.supportsDocumentFonts) {
  1923. _app_options.AppOptions.set("disableFontFace", true);
  1924. this.l10n.get("web_fonts_disabled").then(msg => {
  1925. console.warn(msg);
  1926. });
  1927. }
  1928. if (!this.supportsPrinting) {
  1929. appConfig.toolbar?.print?.classList.add("hidden");
  1930. appConfig.secondaryToolbar?.printButton.classList.add("hidden");
  1931. }
  1932. if (!this.supportsFullscreen) {
  1933. appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
  1934. }
  1935. if (this.supportsIntegratedFind) {
  1936. appConfig.toolbar?.viewFind?.classList.add("hidden");
  1937. }
  1938. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1939. if (evt.target === this) {
  1940. eventBus.dispatch("resize", {
  1941. source: this
  1942. });
  1943. }
  1944. }, true);
  1945. if (file) {
  1946. this.open({
  1947. url: file
  1948. });
  1949. } else {
  1950. this._hideViewBookmark();
  1951. }
  1952. if ('true' === disablePresentationMode) {
  1953. document.getElementById("presentationMode").style.display='none';
  1954. }
  1955. if ('true' === disableOpenFile) {
  1956. document.getElementById("openFile").style.display='none';
  1957. }
  1958. if ('true' === disablePrint) {
  1959. document.getElementById("print").style.display='none';
  1960. }
  1961. if ('true' === disableDownload) {
  1962. document.getElementById("download").style.display='none';
  1963. }
  1964. if ('true' === disableBookmark) {
  1965. document.getElementById("viewBookmark").style.display='none';
  1966. }
  1967. if ('true' === disableEditing) {
  1968. document.getElementById("editorStamp").style.display='none';
  1969. document.getElementById("editorFreeText").style.display='none';
  1970. document.getElementById("editorInk").style.display='none';
  1971. document.getElementById("editorModeSeparator").style.display='none';
  1972. }
  1973. },
  1974. get initialized() {
  1975. return this._initializedCapability.settled;
  1976. },
  1977. get initializedPromise() {
  1978. return this._initializedCapability.promise;
  1979. },
  1980. zoomIn(steps, scaleFactor) {
  1981. if (this.pdfViewer.isInPresentationMode) {
  1982. return;
  1983. }
  1984. this.pdfViewer.increaseScale({
  1985. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  1986. steps,
  1987. scaleFactor
  1988. });
  1989. },
  1990. zoomOut(steps, scaleFactor) {
  1991. if (this.pdfViewer.isInPresentationMode) {
  1992. return;
  1993. }
  1994. this.pdfViewer.decreaseScale({
  1995. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  1996. steps,
  1997. scaleFactor
  1998. });
  1999. },
  2000. zoomReset() {
  2001. if (this.pdfViewer.isInPresentationMode) {
  2002. return;
  2003. }
  2004. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2005. },
  2006. get pagesCount() {
  2007. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  2008. },
  2009. get page() {
  2010. return this.pdfViewer.currentPageNumber;
  2011. },
  2012. set page(val) {
  2013. this.pdfViewer.currentPageNumber = val;
  2014. },
  2015. get supportsPrinting() {
  2016. return PDFPrintServiceFactory.instance.supportsPrinting;
  2017. },
  2018. get supportsFullscreen() {
  2019. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  2020. },
  2021. get supportsPinchToZoom() {
  2022. return this.externalServices.supportsPinchToZoom;
  2023. },
  2024. get supportsIntegratedFind() {
  2025. return this.externalServices.supportsIntegratedFind;
  2026. },
  2027. get supportsDocumentFonts() {
  2028. return this.externalServices.supportsDocumentFonts;
  2029. },
  2030. get loadingBar() {
  2031. const barElement = document.getElementById("loadingBar");
  2032. const bar = barElement ? new _ui_utils.ProgressBar(barElement) : null;
  2033. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  2034. },
  2035. get supportedMouseWheelZoomModifierKeys() {
  2036. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  2037. },
  2038. initPassiveLoading(file) {
  2039. throw new Error("Not implemented: initPassiveLoading");
  2040. },
  2041. setTitleUsingUrl() {
  2042. let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  2043. let downloadUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2044. this.url = url;
  2045. this.baseUrl = url.split("#")[0];
  2046. if (downloadUrl) {
  2047. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#")[0];
  2048. }
  2049. if ((0, _pdfjsLib.isDataScheme)(url)) {
  2050. this._hideViewBookmark();
  2051. }
  2052. let title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  2053. if (!title) {
  2054. try {
  2055. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  2056. } catch {
  2057. title = url;
  2058. }
  2059. }
  2060. this.setTitle(title);
  2061. },
  2062. setTitle() {
  2063. let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._title;
  2064. this._title = title;
  2065. if (this.isViewerEmbedded) {
  2066. return;
  2067. }
  2068. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  2069. document.title = `${editorIndicator ? "* " : ""}${title}`;
  2070. },
  2071. get _docFilename() {
  2072. return this._contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url);
  2073. },
  2074. _hideViewBookmark() {
  2075. const {
  2076. secondaryToolbar
  2077. } = this.appConfig;
  2078. secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
  2079. if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
  2080. document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
  2081. }
  2082. },
  2083. async close() {
  2084. this._unblockDocumentLoadEvent();
  2085. this._hideViewBookmark();
  2086. if (!this.pdfLoadingTask) {
  2087. return;
  2088. }
  2089. if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
  2090. try {
  2091. await this.save();
  2092. } catch {}
  2093. }
  2094. const promises = [];
  2095. promises.push(this.pdfLoadingTask.destroy());
  2096. this.pdfLoadingTask = null;
  2097. if (this.pdfDocument) {
  2098. this.pdfDocument = null;
  2099. this.pdfThumbnailViewer?.setDocument(null);
  2100. this.pdfViewer.setDocument(null);
  2101. this.pdfLinkService.setDocument(null);
  2102. this.pdfDocumentProperties?.setDocument(null);
  2103. }
  2104. this.pdfLinkService.externalLinkEnabled = true;
  2105. this.store = null;
  2106. this.isInitialViewSet = false;
  2107. this.downloadComplete = false;
  2108. this.url = "";
  2109. this.baseUrl = "";
  2110. this._downloadUrl = "";
  2111. this.documentInfo = null;
  2112. this.metadata = null;
  2113. this._contentDispositionFilename = null;
  2114. this._contentLength = null;
  2115. this._saveInProgress = false;
  2116. this._hasAnnotationEditors = false;
  2117. promises.push(this.pdfScriptingManager.destroyPromise);
  2118. this.setTitle();
  2119. this.pdfSidebar?.reset();
  2120. this.pdfOutlineViewer?.reset();
  2121. this.pdfAttachmentViewer?.reset();
  2122. this.pdfLayerViewer?.reset();
  2123. this.pdfHistory?.reset();
  2124. this.findBar?.reset();
  2125. this.toolbar?.reset();
  2126. this.secondaryToolbar?.reset();
  2127. this._PDFBug?.cleanup();
  2128. await Promise.all(promises);
  2129. },
  2130. async open(args) {
  2131. let deprecatedArgs = false;
  2132. if (typeof args === "string") {
  2133. args = {
  2134. url: args
  2135. };
  2136. deprecatedArgs = true;
  2137. } else if (args?.byteLength) {
  2138. args = {
  2139. data: args
  2140. };
  2141. deprecatedArgs = true;
  2142. }
  2143. if (deprecatedArgs) {
  2144. console.error("The `PDFViewerApplication.open` signature was updated, please use an object instead.");
  2145. }
  2146. if (this.pdfLoadingTask) {
  2147. await this.close();
  2148. }
  2149. const workerParams = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  2150. Object.assign(_pdfjsLib.GlobalWorkerOptions, workerParams);
  2151. if (args.url) {
  2152. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  2153. }
  2154. const apiParams = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  2155. const params = {
  2156. canvasMaxAreaInBytes: this.externalServices.canvasMaxAreaInBytes,
  2157. ...apiParams,
  2158. ...args
  2159. };
  2160. const loadingTask = (0, _pdfjsLib.getDocument)(params);
  2161. this.pdfLoadingTask = loadingTask;
  2162. loadingTask.onPassword = (updateCallback, reason) => {
  2163. if (this.isViewerEmbedded) {
  2164. this._unblockDocumentLoadEvent();
  2165. }
  2166. this.pdfLinkService.externalLinkEnabled = false;
  2167. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2168. this.passwordPrompt.open();
  2169. };
  2170. loadingTask.onProgress = _ref => {
  2171. let {
  2172. loaded,
  2173. total
  2174. } = _ref;
  2175. this.progress(loaded / total);
  2176. };
  2177. return loadingTask.promise.then(pdfDocument => {
  2178. this.load(pdfDocument);
  2179. }, reason => {
  2180. if (loadingTask !== this.pdfLoadingTask) {
  2181. return undefined;
  2182. }
  2183. let key = "loading_error";
  2184. if (reason instanceof _pdfjsLib.InvalidPDFException) {
  2185. key = "invalid_file_error";
  2186. } else if (reason instanceof _pdfjsLib.MissingPDFException) {
  2187. key = "missing_file_error";
  2188. } else if (reason instanceof _pdfjsLib.UnexpectedResponseException) {
  2189. key = "unexpected_response_error";
  2190. }
  2191. return this.l10n.get(key).then(msg => {
  2192. this._documentError(msg, {
  2193. message: reason?.message
  2194. });
  2195. throw reason;
  2196. });
  2197. });
  2198. },
  2199. _ensureDownloadComplete() {
  2200. if (this.pdfDocument && this.downloadComplete) {
  2201. return;
  2202. }
  2203. throw new Error("PDF document not downloaded.");
  2204. },
  2205. async download() {
  2206. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2207. const url = this._downloadUrl,
  2208. filename = this._docFilename;
  2209. try {
  2210. this._ensureDownloadComplete();
  2211. const data = await this.pdfDocument.getData();
  2212. const blob = new Blob([data], {
  2213. type: "application/pdf"
  2214. });
  2215. await this.downloadManager.download(blob, url, filename, options);
  2216. } catch {
  2217. await this.downloadManager.downloadUrl(url, filename, options);
  2218. }
  2219. },
  2220. async save() {
  2221. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2222. if (this._saveInProgress) {
  2223. return;
  2224. }
  2225. this._saveInProgress = true;
  2226. await this.pdfScriptingManager.dispatchWillSave();
  2227. const url = this._downloadUrl,
  2228. filename = this._docFilename;
  2229. try {
  2230. this._ensureDownloadComplete();
  2231. const data = await this.pdfDocument.saveDocument();
  2232. const blob = new Blob([data], {
  2233. type: "application/pdf"
  2234. });
  2235. await this.downloadManager.download(blob, url, filename, options);
  2236. } catch (reason) {
  2237. console.error(`Error when saving the document: ${reason.message}`);
  2238. await this.download(options);
  2239. } finally {
  2240. await this.pdfScriptingManager.dispatchDidSave();
  2241. this._saveInProgress = false;
  2242. }
  2243. if (this._hasAnnotationEditors) {
  2244. this.externalServices.reportTelemetry({
  2245. type: "editing",
  2246. data: {
  2247. type: "save"
  2248. }
  2249. });
  2250. }
  2251. },
  2252. downloadOrSave() {
  2253. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2254. if (this.pdfDocument?.annotationStorage.size > 0) {
  2255. this.save(options);
  2256. } else {
  2257. this.download(options);
  2258. }
  2259. },
  2260. openInExternalApp() {
  2261. this.downloadOrSave({
  2262. openInExternalApp: true
  2263. });
  2264. },
  2265. _documentError(message) {
  2266. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2267. this._unblockDocumentLoadEvent();
  2268. this._otherError(message, moreInfo);
  2269. this.eventBus.dispatch("documenterror", {
  2270. source: this,
  2271. message,
  2272. reason: moreInfo?.message ?? null
  2273. });
  2274. },
  2275. _otherError(message) {
  2276. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2277. const moreInfoText = [`PDF.js v${_pdfjsLib.version || "?"} (build: ${_pdfjsLib.build || "?"})`];
  2278. if (moreInfo) {
  2279. moreInfoText.push(`Message: ${moreInfo.message}`);
  2280. if (moreInfo.stack) {
  2281. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  2282. } else {
  2283. if (moreInfo.filename) {
  2284. moreInfoText.push(`File: ${moreInfo.filename}`);
  2285. }
  2286. if (moreInfo.lineNumber) {
  2287. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  2288. }
  2289. }
  2290. }
  2291. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  2292. },
  2293. progress(level) {
  2294. if (!this.loadingBar || this.downloadComplete) {
  2295. return;
  2296. }
  2297. const percent = Math.round(level * 100);
  2298. if (percent <= this.loadingBar.percent) {
  2299. return;
  2300. }
  2301. this.loadingBar.percent = percent;
  2302. if (this.pdfDocument?.loadingParams.disableAutoFetch ?? _app_options.AppOptions.get("disableAutoFetch")) {
  2303. this.loadingBar.setDisableAutoFetch();
  2304. }
  2305. },
  2306. load(pdfDocument) {
  2307. this.pdfDocument = pdfDocument;
  2308. pdfDocument.getDownloadInfo().then(_ref2 => {
  2309. let {
  2310. length
  2311. } = _ref2;
  2312. this._contentLength = length;
  2313. this.downloadComplete = true;
  2314. this.loadingBar?.hide();
  2315. firstPagePromise.then(() => {
  2316. this.eventBus.dispatch("documentloaded", {
  2317. source: this
  2318. });
  2319. });
  2320. });
  2321. const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
  2322. const pageModePromise = pdfDocument.getPageMode().catch(() => {});
  2323. const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
  2324. this.toolbar?.setPagesCount(pdfDocument.numPages, false);
  2325. this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
  2326. this.pdfLinkService.setDocument(pdfDocument);
  2327. this.pdfDocumentProperties?.setDocument(pdfDocument);
  2328. const pdfViewer = this.pdfViewer;
  2329. pdfViewer.setDocument(pdfDocument);
  2330. const {
  2331. firstPagePromise,
  2332. onePageRendered,
  2333. pagesPromise
  2334. } = pdfViewer;
  2335. this.pdfThumbnailViewer?.setDocument(pdfDocument);
  2336. const storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  2337. page: null,
  2338. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  2339. scrollLeft: "0",
  2340. scrollTop: "0",
  2341. rotation: null,
  2342. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  2343. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  2344. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  2345. }).catch(() => {});
  2346. firstPagePromise.then(pdfPage => {
  2347. this.loadingBar?.setWidth(this.appConfig.viewerContainer);
  2348. this._initializeAnnotationStorageCallbacks(pdfDocument);
  2349. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async _ref3 => {
  2350. let [timeStamp, stored, pageLayout, pageMode, openAction] = _ref3;
  2351. const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  2352. this._initializePdfHistory({
  2353. fingerprint: pdfDocument.fingerprints[0],
  2354. viewOnLoad,
  2355. initialDest: openAction?.dest
  2356. });
  2357. const initialBookmark = this.initialBookmark;
  2358. const zoom = _app_options.AppOptions.get("defaultZoomValue");
  2359. let hash = zoom ? `zoom=${zoom}` : null;
  2360. let rotation = null;
  2361. let sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  2362. let scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  2363. let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  2364. if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  2365. hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  2366. rotation = parseInt(stored.rotation, 10);
  2367. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  2368. sidebarView = stored.sidebarView | 0;
  2369. }
  2370. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  2371. scrollMode = stored.scrollMode | 0;
  2372. }
  2373. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  2374. spreadMode = stored.spreadMode | 0;
  2375. }
  2376. }
  2377. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  2378. sidebarView = (0, _ui_utils.apiPageModeToSidebarView)(pageMode);
  2379. }
  2380. if (pageLayout && scrollMode === _ui_utils.ScrollMode.UNKNOWN && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  2381. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(pageLayout);
  2382. spreadMode = modes.spreadMode;
  2383. }
  2384. this.setInitialView(hash, {
  2385. rotation,
  2386. sidebarView,
  2387. scrollMode,
  2388. spreadMode
  2389. });
  2390. this.eventBus.dispatch("documentinit", {
  2391. source: this
  2392. });
  2393. if (!this.isViewerEmbedded) {
  2394. pdfViewer.focus();
  2395. }
  2396. await Promise.race([pagesPromise, new Promise(resolve => {
  2397. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  2398. })]);
  2399. if (!initialBookmark && !hash) {
  2400. return;
  2401. }
  2402. if (pdfViewer.hasEqualPageSizes) {
  2403. return;
  2404. }
  2405. this.initialBookmark = initialBookmark;
  2406. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  2407. this.setInitialView(hash);
  2408. }).catch(() => {
  2409. this.setInitialView();
  2410. }).then(function () {
  2411. pdfViewer.update();
  2412. });
  2413. });
  2414. pagesPromise.then(() => {
  2415. this._unblockDocumentLoadEvent();
  2416. this._initializeAutoPrint(pdfDocument, openActionPromise);
  2417. }, reason => {
  2418. this.l10n.get("loading_error").then(msg => {
  2419. this._documentError(msg, {
  2420. message: reason?.message
  2421. });
  2422. });
  2423. });
  2424. onePageRendered.then(data => {
  2425. this.externalServices.reportTelemetry({
  2426. type: "pageInfo",
  2427. timestamp: data.timestamp
  2428. });
  2429. if (this.pdfOutlineViewer) {
  2430. pdfDocument.getOutline().then(outline => {
  2431. if (pdfDocument !== this.pdfDocument) {
  2432. return;
  2433. }
  2434. this.pdfOutlineViewer.render({
  2435. outline,
  2436. pdfDocument
  2437. });
  2438. });
  2439. }
  2440. if (this.pdfAttachmentViewer) {
  2441. pdfDocument.getAttachments().then(attachments => {
  2442. if (pdfDocument !== this.pdfDocument) {
  2443. return;
  2444. }
  2445. this.pdfAttachmentViewer.render({
  2446. attachments
  2447. });
  2448. });
  2449. }
  2450. if (this.pdfLayerViewer) {
  2451. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  2452. if (pdfDocument !== this.pdfDocument) {
  2453. return;
  2454. }
  2455. this.pdfLayerViewer.render({
  2456. optionalContentConfig,
  2457. pdfDocument
  2458. });
  2459. });
  2460. }
  2461. });
  2462. this._initializePageLabels(pdfDocument);
  2463. this._initializeMetadata(pdfDocument);
  2464. },
  2465. async _scriptingDocProperties(pdfDocument) {
  2466. if (!this.documentInfo) {
  2467. await new Promise(resolve => {
  2468. this.eventBus._on("metadataloaded", resolve, {
  2469. once: true
  2470. });
  2471. });
  2472. if (pdfDocument !== this.pdfDocument) {
  2473. return null;
  2474. }
  2475. }
  2476. if (!this._contentLength) {
  2477. await new Promise(resolve => {
  2478. this.eventBus._on("documentloaded", resolve, {
  2479. once: true
  2480. });
  2481. });
  2482. if (pdfDocument !== this.pdfDocument) {
  2483. return null;
  2484. }
  2485. }
  2486. return {
  2487. ...this.documentInfo,
  2488. baseURL: this.baseUrl,
  2489. filesize: this._contentLength,
  2490. filename: this._docFilename,
  2491. metadata: this.metadata?.getRaw(),
  2492. authors: this.metadata?.get("dc:creator"),
  2493. numPages: this.pagesCount,
  2494. URL: this.url
  2495. };
  2496. },
  2497. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  2498. const [openAction, javaScript] = await Promise.all([openActionPromise, !this.pdfViewer.enableScripting ? pdfDocument.getJavaScript() : null]);
  2499. if (pdfDocument !== this.pdfDocument) {
  2500. return;
  2501. }
  2502. let triggerAutoPrint = false;
  2503. if (openAction?.action === "Print") {
  2504. triggerAutoPrint = true;
  2505. }
  2506. if (javaScript) {
  2507. javaScript.some(js => {
  2508. if (!js) {
  2509. return false;
  2510. }
  2511. console.warn("Warning: JavaScript support is not enabled");
  2512. return true;
  2513. });
  2514. if (!triggerAutoPrint) {
  2515. for (const js of javaScript) {
  2516. if (js && _ui_utils.AutoPrintRegExp.test(js)) {
  2517. triggerAutoPrint = true;
  2518. break;
  2519. }
  2520. }
  2521. }
  2522. }
  2523. if (triggerAutoPrint) {
  2524. this.triggerPrinting();
  2525. }
  2526. },
  2527. async _initializeMetadata(pdfDocument) {
  2528. const {
  2529. info,
  2530. metadata,
  2531. contentDispositionFilename,
  2532. contentLength
  2533. } = await pdfDocument.getMetadata();
  2534. if (pdfDocument !== this.pdfDocument) {
  2535. return;
  2536. }
  2537. this.documentInfo = info;
  2538. this.metadata = metadata;
  2539. this._contentDispositionFilename ??= contentDispositionFilename;
  2540. this._contentLength ??= contentLength;
  2541. console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${_pdfjsLib.version || "?"} [${_pdfjsLib.build || "?"}])`);
  2542. let pdfTitle = info.Title;
  2543. const metadataTitle = metadata?.get("dc:title");
  2544. if (metadataTitle) {
  2545. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2546. pdfTitle = metadataTitle;
  2547. }
  2548. }
  2549. if (pdfTitle) {
  2550. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  2551. } else if (this._contentDispositionFilename) {
  2552. this.setTitle(this._contentDispositionFilename);
  2553. }
  2554. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  2555. if (pdfDocument.loadingParams.enableXfa) {
  2556. console.warn("Warning: XFA Foreground documents are not supported");
  2557. } else {
  2558. console.warn("Warning: XFA support is not enabled");
  2559. }
  2560. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  2561. console.warn("Warning: Interactive form support is not enabled");
  2562. }
  2563. if (info.IsSignaturesPresent) {
  2564. console.warn("Warning: Digital signatures validation is not supported");
  2565. }
  2566. this.eventBus.dispatch("metadataloaded", {
  2567. source: this
  2568. });
  2569. },
  2570. async _initializePageLabels(pdfDocument) {
  2571. const labels = await pdfDocument.getPageLabels();
  2572. if (pdfDocument !== this.pdfDocument) {
  2573. return;
  2574. }
  2575. if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
  2576. return;
  2577. }
  2578. const numLabels = labels.length;
  2579. let standardLabels = 0,
  2580. emptyLabels = 0;
  2581. for (let i = 0; i < numLabels; i++) {
  2582. const label = labels[i];
  2583. if (label === (i + 1).toString()) {
  2584. standardLabels++;
  2585. } else if (label === "") {
  2586. emptyLabels++;
  2587. } else {
  2588. break;
  2589. }
  2590. }
  2591. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  2592. return;
  2593. }
  2594. const {
  2595. pdfViewer,
  2596. pdfThumbnailViewer,
  2597. toolbar
  2598. } = this;
  2599. pdfViewer.setPageLabels(labels);
  2600. pdfThumbnailViewer?.setPageLabels(labels);
  2601. toolbar?.setPagesCount(numLabels, true);
  2602. toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2603. },
  2604. _initializePdfHistory(_ref4) {
  2605. let {
  2606. fingerprint,
  2607. viewOnLoad,
  2608. initialDest = null
  2609. } = _ref4;
  2610. if (!this.pdfHistory) {
  2611. return;
  2612. }
  2613. this.pdfHistory.initialize({
  2614. fingerprint,
  2615. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2616. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2617. });
  2618. if (this.pdfHistory.initialBookmark) {
  2619. this.initialBookmark = this.pdfHistory.initialBookmark;
  2620. this.initialRotation = this.pdfHistory.initialRotation;
  2621. }
  2622. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2623. this.initialBookmark = JSON.stringify(initialDest);
  2624. this.pdfHistory.push({
  2625. explicitDest: initialDest,
  2626. pageNumber: null
  2627. });
  2628. }
  2629. },
  2630. _initializeAnnotationStorageCallbacks(pdfDocument) {
  2631. if (pdfDocument !== this.pdfDocument) {
  2632. return;
  2633. }
  2634. const {
  2635. annotationStorage
  2636. } = pdfDocument;
  2637. annotationStorage.onSetModified = () => {
  2638. window.addEventListener("beforeunload", beforeUnload);
  2639. this._annotationStorageModified = true;
  2640. };
  2641. annotationStorage.onResetModified = () => {
  2642. window.removeEventListener("beforeunload", beforeUnload);
  2643. delete this._annotationStorageModified;
  2644. };
  2645. annotationStorage.onAnnotationEditor = typeStr => {
  2646. this._hasAnnotationEditors = !!typeStr;
  2647. this.setTitle();
  2648. if (typeStr) {
  2649. this.externalServices.reportTelemetry({
  2650. type: "editing",
  2651. data: {
  2652. type: typeStr
  2653. }
  2654. });
  2655. }
  2656. };
  2657. },
  2658. setInitialView(storedHash) {
  2659. let {
  2660. rotation,
  2661. sidebarView,
  2662. scrollMode,
  2663. spreadMode
  2664. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2665. const setRotation = angle => {
  2666. if ((0, _ui_utils.isValidRotation)(angle)) {
  2667. this.pdfViewer.pagesRotation = angle;
  2668. }
  2669. };
  2670. const setViewerModes = (scroll, spread) => {
  2671. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2672. this.pdfViewer.scrollMode = scroll;
  2673. }
  2674. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2675. this.pdfViewer.spreadMode = spread;
  2676. }
  2677. };
  2678. this.isInitialViewSet = true;
  2679. this.pdfSidebar?.setInitialView(sidebarView);
  2680. setViewerModes(scrollMode, spreadMode);
  2681. if (this.initialBookmark) {
  2682. setRotation(this.initialRotation);
  2683. delete this.initialRotation;
  2684. this.pdfLinkService.setHash(this.initialBookmark);
  2685. this.initialBookmark = null;
  2686. } else if (storedHash) {
  2687. setRotation(rotation);
  2688. this.pdfLinkService.setHash(storedHash);
  2689. }
  2690. this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2691. this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
  2692. if (!this.pdfViewer.currentScaleValue) {
  2693. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2694. }
  2695. },
  2696. _cleanup() {
  2697. if (!this.pdfDocument) {
  2698. return;
  2699. }
  2700. this.pdfViewer.cleanup();
  2701. this.pdfThumbnailViewer?.cleanup();
  2702. this.pdfDocument.cleanup();
  2703. },
  2704. forceRendering() {
  2705. this.pdfRenderingQueue.printing = !!this.printService;
  2706. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS;
  2707. this.pdfRenderingQueue.renderHighestPriority();
  2708. },
  2709. beforePrint() {
  2710. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => {
  2711. return this.pdfDocument?.annotationStorage.print;
  2712. });
  2713. if (this.printService) {
  2714. return;
  2715. }
  2716. if (!this.supportsPrinting) {
  2717. this.l10n.get("printing_not_supported").then(msg => {
  2718. this._otherError(msg);
  2719. });
  2720. return;
  2721. }
  2722. if (!this.pdfViewer.pageViewsReady) {
  2723. this.l10n.get("printing_not_ready").then(msg => {
  2724. window.alert(msg);
  2725. });
  2726. return;
  2727. }
  2728. const pagesOverview = this.pdfViewer.getPagesOverview();
  2729. const printContainer = this.appConfig.printContainer;
  2730. const printResolution = _app_options.AppOptions.get("printResolution");
  2731. const optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2732. const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this._printAnnotationStoragePromise, this.l10n);
  2733. this.printService = printService;
  2734. this.forceRendering();
  2735. this.setTitle();
  2736. printService.layout();
  2737. if (this._hasAnnotationEditors) {
  2738. this.externalServices.reportTelemetry({
  2739. type: "editing",
  2740. data: {
  2741. type: "print"
  2742. }
  2743. });
  2744. }
  2745. },
  2746. afterPrint() {
  2747. if (this._printAnnotationStoragePromise) {
  2748. this._printAnnotationStoragePromise.then(() => {
  2749. this.pdfScriptingManager.dispatchDidPrint();
  2750. });
  2751. this._printAnnotationStoragePromise = null;
  2752. }
  2753. if (this.printService) {
  2754. this.printService.destroy();
  2755. this.printService = null;
  2756. this.pdfDocument?.annotationStorage.resetModified();
  2757. }
  2758. this.forceRendering();
  2759. this.setTitle();
  2760. },
  2761. rotatePages(delta) {
  2762. this.pdfViewer.pagesRotation += delta;
  2763. },
  2764. requestPresentationMode() {
  2765. this.pdfPresentationMode?.request();
  2766. },
  2767. triggerPrinting() {
  2768. if (!this.supportsPrinting) {
  2769. return;
  2770. }
  2771. window.print();
  2772. },
  2773. bindEvents() {
  2774. const {
  2775. eventBus,
  2776. _boundEvents
  2777. } = this;
  2778. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2779. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2780. eventBus._on("resize", webViewerResize);
  2781. eventBus._on("hashchange", webViewerHashchange);
  2782. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2783. eventBus._on("afterprint", _boundEvents.afterPrint);
  2784. eventBus._on("pagerender", webViewerPageRender);
  2785. eventBus._on("pagerendered", webViewerPageRendered);
  2786. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2787. eventBus._on("pagechanging", webViewerPageChanging);
  2788. eventBus._on("scalechanging", webViewerScaleChanging);
  2789. eventBus._on("rotationchanging", webViewerRotationChanging);
  2790. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2791. eventBus._on("pagemode", webViewerPageMode);
  2792. eventBus._on("namedaction", webViewerNamedAction);
  2793. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2794. eventBus._on("presentationmode", webViewerPresentationMode);
  2795. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode);
  2796. eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams);
  2797. eventBus._on("print", webViewerPrint);
  2798. eventBus._on("download", webViewerDownload);
  2799. eventBus._on("openinexternalapp", webViewerOpenInExternalApp);
  2800. eventBus._on("firstpage", webViewerFirstPage);
  2801. eventBus._on("lastpage", webViewerLastPage);
  2802. eventBus._on("nextpage", webViewerNextPage);
  2803. eventBus._on("previouspage", webViewerPreviousPage);
  2804. eventBus._on("zoomin", webViewerZoomIn);
  2805. eventBus._on("zoomout", webViewerZoomOut);
  2806. eventBus._on("zoomreset", webViewerZoomReset);
  2807. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2808. eventBus._on("scalechanged", webViewerScaleChanged);
  2809. eventBus._on("rotatecw", webViewerRotateCw);
  2810. eventBus._on("rotateccw", webViewerRotateCcw);
  2811. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2812. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2813. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2814. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2815. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2816. eventBus._on("documentproperties", webViewerDocumentProperties);
  2817. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2818. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2819. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2820. if (_app_options.AppOptions.get("pdfBug")) {
  2821. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2822. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2823. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2824. }
  2825. eventBus._on("fileinputchange", webViewerFileInputChange);
  2826. eventBus._on("openfile", webViewerOpenFile);
  2827. },
  2828. bindWindowEvents() {
  2829. const {
  2830. eventBus,
  2831. _boundEvents
  2832. } = this;
  2833. function addWindowResolutionChange() {
  2834. let evt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  2835. if (evt) {
  2836. webViewerResolutionChange(evt);
  2837. }
  2838. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  2839. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  2840. once: true
  2841. });
  2842. _boundEvents.removeWindowResolutionChange ||= function () {
  2843. mediaQueryList.removeEventListener("change", addWindowResolutionChange);
  2844. _boundEvents.removeWindowResolutionChange = null;
  2845. };
  2846. }
  2847. addWindowResolutionChange();
  2848. _boundEvents.windowResize = () => {
  2849. eventBus.dispatch("resize", {
  2850. source: window
  2851. });
  2852. };
  2853. _boundEvents.windowHashChange = () => {
  2854. eventBus.dispatch("hashchange", {
  2855. source: window,
  2856. hash: document.location.hash.substring(1)
  2857. });
  2858. };
  2859. _boundEvents.windowBeforePrint = () => {
  2860. eventBus.dispatch("beforeprint", {
  2861. source: window
  2862. });
  2863. };
  2864. _boundEvents.windowAfterPrint = () => {
  2865. eventBus.dispatch("afterprint", {
  2866. source: window
  2867. });
  2868. };
  2869. _boundEvents.windowUpdateFromSandbox = event => {
  2870. eventBus.dispatch("updatefromsandbox", {
  2871. source: window,
  2872. detail: event.detail
  2873. });
  2874. };
  2875. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2876. window.addEventListener("wheel", webViewerWheel, {
  2877. passive: false
  2878. });
  2879. window.addEventListener("touchstart", webViewerTouchStart, {
  2880. passive: false
  2881. });
  2882. window.addEventListener("touchmove", webViewerTouchMove, {
  2883. passive: false
  2884. });
  2885. window.addEventListener("touchend", webViewerTouchEnd, {
  2886. passive: false
  2887. });
  2888. window.addEventListener("click", webViewerClick);
  2889. window.addEventListener("keydown", webViewerKeyDown);
  2890. window.addEventListener("keyup", webViewerKeyUp);
  2891. window.addEventListener("resize", _boundEvents.windowResize);
  2892. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2893. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2894. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2895. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2896. },
  2897. unbindEvents() {
  2898. const {
  2899. eventBus,
  2900. _boundEvents
  2901. } = this;
  2902. eventBus._off("resize", webViewerResize);
  2903. eventBus._off("hashchange", webViewerHashchange);
  2904. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2905. eventBus._off("afterprint", _boundEvents.afterPrint);
  2906. eventBus._off("pagerender", webViewerPageRender);
  2907. eventBus._off("pagerendered", webViewerPageRendered);
  2908. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2909. eventBus._off("pagechanging", webViewerPageChanging);
  2910. eventBus._off("scalechanging", webViewerScaleChanging);
  2911. eventBus._off("rotationchanging", webViewerRotationChanging);
  2912. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2913. eventBus._off("pagemode", webViewerPageMode);
  2914. eventBus._off("namedaction", webViewerNamedAction);
  2915. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2916. eventBus._off("presentationmode", webViewerPresentationMode);
  2917. eventBus._off("print", webViewerPrint);
  2918. eventBus._off("download", webViewerDownload);
  2919. eventBus._off("openinexternalapp", webViewerOpenInExternalApp);
  2920. eventBus._off("firstpage", webViewerFirstPage);
  2921. eventBus._off("lastpage", webViewerLastPage);
  2922. eventBus._off("nextpage", webViewerNextPage);
  2923. eventBus._off("previouspage", webViewerPreviousPage);
  2924. eventBus._off("zoomin", webViewerZoomIn);
  2925. eventBus._off("zoomout", webViewerZoomOut);
  2926. eventBus._off("zoomreset", webViewerZoomReset);
  2927. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2928. eventBus._off("scalechanged", webViewerScaleChanged);
  2929. eventBus._off("rotatecw", webViewerRotateCw);
  2930. eventBus._off("rotateccw", webViewerRotateCcw);
  2931. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2932. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2933. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2934. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2935. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2936. eventBus._off("documentproperties", webViewerDocumentProperties);
  2937. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2938. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2939. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2940. if (_boundEvents.reportPageStatsPDFBug) {
  2941. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2942. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2943. _boundEvents.reportPageStatsPDFBug = null;
  2944. }
  2945. eventBus._off("fileinputchange", webViewerFileInputChange);
  2946. eventBus._off("openfile", webViewerOpenFile);
  2947. _boundEvents.beforePrint = null;
  2948. _boundEvents.afterPrint = null;
  2949. },
  2950. unbindWindowEvents() {
  2951. const {
  2952. _boundEvents
  2953. } = this;
  2954. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2955. window.removeEventListener("wheel", webViewerWheel, {
  2956. passive: false
  2957. });
  2958. window.removeEventListener("touchstart", webViewerTouchStart, {
  2959. passive: false
  2960. });
  2961. window.removeEventListener("touchmove", webViewerTouchMove, {
  2962. passive: false
  2963. });
  2964. window.removeEventListener("touchend", webViewerTouchEnd, {
  2965. passive: false
  2966. });
  2967. window.removeEventListener("click", webViewerClick);
  2968. window.removeEventListener("keydown", webViewerKeyDown);
  2969. window.removeEventListener("keyup", webViewerKeyUp);
  2970. window.removeEventListener("resize", _boundEvents.windowResize);
  2971. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2972. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2973. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2974. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2975. _boundEvents.removeWindowResolutionChange?.();
  2976. _boundEvents.windowResize = null;
  2977. _boundEvents.windowHashChange = null;
  2978. _boundEvents.windowBeforePrint = null;
  2979. _boundEvents.windowAfterPrint = null;
  2980. _boundEvents.windowUpdateFromSandbox = null;
  2981. },
  2982. _accumulateTicks(ticks, prop) {
  2983. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  2984. this[prop] = 0;
  2985. }
  2986. this[prop] += ticks;
  2987. const wholeTicks = Math.trunc(this[prop]);
  2988. this[prop] -= wholeTicks;
  2989. return wholeTicks;
  2990. },
  2991. _accumulateFactor(previousScale, factor, prop) {
  2992. if (factor === 1) {
  2993. return 1;
  2994. }
  2995. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  2996. this[prop] = 1;
  2997. }
  2998. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  2999. this[prop] = factor / newFactor;
  3000. return newFactor;
  3001. },
  3002. _centerAtPos(previousScale, x, y) {
  3003. const {
  3004. pdfViewer
  3005. } = this;
  3006. const scaleDiff = pdfViewer.currentScale / previousScale - 1;
  3007. if (scaleDiff !== 0) {
  3008. const [top, left] = pdfViewer.containerTopLeft;
  3009. pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
  3010. pdfViewer.container.scrollTop += (y - top) * scaleDiff;
  3011. }
  3012. },
  3013. _unblockDocumentLoadEvent() {
  3014. document.blockUnblockOnload?.(false);
  3015. this._unblockDocumentLoadEvent = () => {};
  3016. },
  3017. get scriptingReady() {
  3018. return this.pdfScriptingManager.ready;
  3019. }
  3020. };
  3021. exports.PDFViewerApplication = PDFViewerApplication;
  3022. {
  3023. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  3024. var validateFileURL = function (file) {
  3025. if (!file) {
  3026. return;
  3027. }
  3028. try {
  3029. const viewerOrigin = new URL(window.location.href).origin || "null";
  3030. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  3031. return;
  3032. }
  3033. const fileOrigin = new URL(file, window.location.href).origin;
  3034. if (fileOrigin !== viewerOrigin) {
  3035. throw new Error("file origin does not match viewer's");
  3036. }
  3037. } catch (ex) {
  3038. PDFViewerApplication.l10n.get("loading_error").then(msg => {
  3039. PDFViewerApplication._documentError(msg, {
  3040. message: ex?.message
  3041. });
  3042. });
  3043. throw ex;
  3044. }
  3045. };
  3046. }
  3047. async function loadFakeWorker() {
  3048. _pdfjsLib.GlobalWorkerOptions.workerSrc ||= _app_options.AppOptions.get("workerSrc");
  3049. await (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.workerSrc);
  3050. }
  3051. async function loadPDFBug(self) {
  3052. const {
  3053. debuggerScriptPath
  3054. } = self.appConfig;
  3055. const {
  3056. PDFBug
  3057. } = await import(debuggerScriptPath);
  3058. self._PDFBug = PDFBug;
  3059. }
  3060. function reportPageStatsPDFBug(_ref5) {
  3061. let {
  3062. pageNumber
  3063. } = _ref5;
  3064. if (!globalThis.Stats?.enabled) {
  3065. return;
  3066. }
  3067. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3068. globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
  3069. }
  3070. function webViewerPageRender(_ref6) {
  3071. let {
  3072. pageNumber
  3073. } = _ref6;
  3074. if (pageNumber === PDFViewerApplication.page) {
  3075. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true);
  3076. }
  3077. }
  3078. function webViewerPageRendered(_ref7) {
  3079. let {
  3080. pageNumber,
  3081. error
  3082. } = _ref7;
  3083. if (pageNumber === PDFViewerApplication.page) {
  3084. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false);
  3085. }
  3086. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS) {
  3087. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3088. const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
  3089. if (pageView) {
  3090. thumbnailView?.setImage(pageView);
  3091. }
  3092. }
  3093. if (error) {
  3094. PDFViewerApplication.l10n.get("rendering_error").then(msg => {
  3095. PDFViewerApplication._otherError(msg, error);
  3096. });
  3097. }
  3098. }
  3099. function webViewerPageMode(_ref8) {
  3100. let {
  3101. mode
  3102. } = _ref8;
  3103. let view;
  3104. switch (mode) {
  3105. case "thumbs":
  3106. view = _ui_utils.SidebarView.THUMBS;
  3107. break;
  3108. case "bookmarks":
  3109. case "outline":
  3110. view = _ui_utils.SidebarView.OUTLINE;
  3111. break;
  3112. case "attachments":
  3113. view = _ui_utils.SidebarView.ATTACHMENTS;
  3114. break;
  3115. case "layers":
  3116. view = _ui_utils.SidebarView.LAYERS;
  3117. break;
  3118. case "none":
  3119. view = _ui_utils.SidebarView.NONE;
  3120. break;
  3121. default:
  3122. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3123. return;
  3124. }
  3125. PDFViewerApplication.pdfSidebar?.switchView(view, true);
  3126. }
  3127. function webViewerNamedAction(evt) {
  3128. switch (evt.action) {
  3129. case "GoToPage":
  3130. PDFViewerApplication.appConfig.toolbar?.pageNumber.select();
  3131. break;
  3132. case "Find":
  3133. if (!PDFViewerApplication.supportsIntegratedFind) {
  3134. PDFViewerApplication?.findBar.toggle();
  3135. }
  3136. break;
  3137. case "Print":
  3138. PDFViewerApplication.triggerPrinting();
  3139. break;
  3140. case "SaveAs":
  3141. PDFViewerApplication.downloadOrSave();
  3142. break;
  3143. }
  3144. }
  3145. function webViewerPresentationModeChanged(evt) {
  3146. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3147. }
  3148. function webViewerSidebarViewChanged(_ref9) {
  3149. let {
  3150. view
  3151. } = _ref9;
  3152. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils.SidebarView.THUMBS;
  3153. if (PDFViewerApplication.isInitialViewSet) {
  3154. PDFViewerApplication.store?.set("sidebarView", view).catch(() => {});
  3155. }
  3156. }
  3157. function webViewerUpdateViewarea(_ref10) {
  3158. let {
  3159. location
  3160. } = _ref10;
  3161. if (PDFViewerApplication.isInitialViewSet) {
  3162. PDFViewerApplication.store?.setMultiple({
  3163. page: location.pageNumber,
  3164. zoom: location.scale,
  3165. scrollLeft: location.left,
  3166. scrollTop: location.top,
  3167. rotation: location.rotation
  3168. }).catch(() => {});
  3169. }
  3170. if (PDFViewerApplication.appConfig.secondaryToolbar) {
  3171. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3172. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3173. }
  3174. }
  3175. function webViewerScrollModeChanged(evt) {
  3176. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3177. PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {});
  3178. }
  3179. }
  3180. function webViewerSpreadModeChanged(evt) {
  3181. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3182. PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
  3183. }
  3184. }
  3185. function webViewerResize() {
  3186. const {
  3187. pdfDocument,
  3188. pdfViewer,
  3189. pdfRenderingQueue
  3190. } = PDFViewerApplication;
  3191. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  3192. return;
  3193. }
  3194. if (!pdfDocument) {
  3195. return;
  3196. }
  3197. const currentScaleValue = pdfViewer.currentScaleValue;
  3198. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  3199. pdfViewer.currentScaleValue = currentScaleValue;
  3200. }
  3201. pdfViewer.update();
  3202. }
  3203. function webViewerHashchange(evt) {
  3204. const hash = evt.hash;
  3205. if (!hash) {
  3206. return;
  3207. }
  3208. if (!PDFViewerApplication.isInitialViewSet) {
  3209. PDFViewerApplication.initialBookmark = hash;
  3210. } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
  3211. PDFViewerApplication.pdfLinkService.setHash(hash);
  3212. }
  3213. }
  3214. {
  3215. var webViewerFileInputChange = function (evt) {
  3216. if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
  3217. return;
  3218. }
  3219. const file = evt.fileInput.files[0];
  3220. PDFViewerApplication.open({
  3221. url: URL.createObjectURL(file),
  3222. originalUrl: file.name
  3223. });
  3224. };
  3225. var webViewerOpenFile = function (evt) {
  3226. const fileInput = PDFViewerApplication.appConfig.openFileInput;
  3227. fileInput.click();
  3228. };
  3229. }
  3230. function webViewerPresentationMode() {
  3231. PDFViewerApplication.requestPresentationMode();
  3232. }
  3233. function webViewerSwitchAnnotationEditorMode(evt) {
  3234. PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
  3235. }
  3236. function webViewerSwitchAnnotationEditorParams(evt) {
  3237. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  3238. }
  3239. function webViewerPrint() {
  3240. PDFViewerApplication.triggerPrinting();
  3241. }
  3242. function webViewerDownload() {
  3243. PDFViewerApplication.downloadOrSave();
  3244. }
  3245. function webViewerOpenInExternalApp() {
  3246. PDFViewerApplication.openInExternalApp();
  3247. }
  3248. function webViewerFirstPage() {
  3249. PDFViewerApplication.page = 1;
  3250. }
  3251. function webViewerLastPage() {
  3252. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3253. }
  3254. function webViewerNextPage() {
  3255. PDFViewerApplication.pdfViewer.nextPage();
  3256. }
  3257. function webViewerPreviousPage() {
  3258. PDFViewerApplication.pdfViewer.previousPage();
  3259. }
  3260. function webViewerZoomIn() {
  3261. PDFViewerApplication.zoomIn();
  3262. }
  3263. function webViewerZoomOut() {
  3264. PDFViewerApplication.zoomOut();
  3265. }
  3266. function webViewerZoomReset() {
  3267. PDFViewerApplication.zoomReset();
  3268. }
  3269. function webViewerPageNumberChanged(evt) {
  3270. const pdfViewer = PDFViewerApplication.pdfViewer;
  3271. if (evt.value !== "") {
  3272. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3273. }
  3274. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3275. PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3276. }
  3277. }
  3278. function webViewerScaleChanged(evt) {
  3279. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3280. }
  3281. function webViewerRotateCw() {
  3282. PDFViewerApplication.rotatePages(90);
  3283. }
  3284. function webViewerRotateCcw() {
  3285. PDFViewerApplication.rotatePages(-90);
  3286. }
  3287. function webViewerOptionalContentConfig(evt) {
  3288. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3289. }
  3290. function webViewerSwitchScrollMode(evt) {
  3291. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3292. }
  3293. function webViewerSwitchSpreadMode(evt) {
  3294. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3295. }
  3296. function webViewerDocumentProperties() {
  3297. PDFViewerApplication.pdfDocumentProperties?.open();
  3298. }
  3299. function webViewerFindFromUrlHash(evt) {
  3300. PDFViewerApplication.eventBus.dispatch("find", {
  3301. source: evt.source,
  3302. type: "",
  3303. query: evt.query,
  3304. caseSensitive: false,
  3305. entireWord: false,
  3306. highlightAll: true,
  3307. findPrevious: false,
  3308. matchDiacritics: true
  3309. });
  3310. }
  3311. function webViewerUpdateFindMatchesCount(_ref11) {
  3312. let {
  3313. matchesCount
  3314. } = _ref11;
  3315. if (PDFViewerApplication.supportsIntegratedFind) {
  3316. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3317. } else {
  3318. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3319. }
  3320. }
  3321. function webViewerUpdateFindControlState(_ref12) {
  3322. let {
  3323. state,
  3324. previous,
  3325. matchesCount,
  3326. rawQuery
  3327. } = _ref12;
  3328. if (PDFViewerApplication.supportsIntegratedFind) {
  3329. PDFViewerApplication.externalServices.updateFindControlState({
  3330. result: state,
  3331. findPrevious: previous,
  3332. matchesCount,
  3333. rawQuery
  3334. });
  3335. } else {
  3336. PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount);
  3337. }
  3338. }
  3339. function webViewerScaleChanging(evt) {
  3340. PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale);
  3341. PDFViewerApplication.pdfViewer.update();
  3342. }
  3343. function webViewerRotationChanging(evt) {
  3344. if (PDFViewerApplication.pdfThumbnailViewer) {
  3345. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3346. }
  3347. PDFViewerApplication.forceRendering();
  3348. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3349. }
  3350. function webViewerPageChanging(_ref13) {
  3351. let {
  3352. pageNumber,
  3353. pageLabel
  3354. } = _ref13;
  3355. PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel);
  3356. PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber);
  3357. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS) {
  3358. PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
  3359. }
  3360. const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3361. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === _ui_utils.RenderingStates.RUNNING);
  3362. }
  3363. function webViewerResolutionChange(evt) {
  3364. PDFViewerApplication.pdfViewer.refresh();
  3365. }
  3366. function webViewerVisibilityChange(evt) {
  3367. if (document.visibilityState === "visible") {
  3368. setZoomDisabledTimeout();
  3369. }
  3370. }
  3371. let zoomDisabledTimeout = null;
  3372. function setZoomDisabledTimeout() {
  3373. if (zoomDisabledTimeout) {
  3374. clearTimeout(zoomDisabledTimeout);
  3375. }
  3376. zoomDisabledTimeout = setTimeout(function () {
  3377. zoomDisabledTimeout = null;
  3378. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3379. }
  3380. function webViewerWheel(evt) {
  3381. const {
  3382. pdfViewer,
  3383. supportedMouseWheelZoomModifierKeys,
  3384. supportsPinchToZoom
  3385. } = PDFViewerApplication;
  3386. if (pdfViewer.isInPresentationMode) {
  3387. return;
  3388. }
  3389. const deltaMode = evt.deltaMode;
  3390. let scaleFactor = Math.exp(-evt.deltaY / 100);
  3391. const isBuiltInMac = false;
  3392. const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  3393. if (isPinchToZoom || evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  3394. evt.preventDefault();
  3395. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3396. return;
  3397. }
  3398. const previousScale = pdfViewer.currentScale;
  3399. if (isPinchToZoom && supportsPinchToZoom) {
  3400. scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
  3401. if (scaleFactor < 1) {
  3402. PDFViewerApplication.zoomOut(null, scaleFactor);
  3403. } else if (scaleFactor > 1) {
  3404. PDFViewerApplication.zoomIn(null, scaleFactor);
  3405. } else {
  3406. return;
  3407. }
  3408. } else {
  3409. const delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3410. let ticks = 0;
  3411. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3412. if (Math.abs(delta) >= 1) {
  3413. ticks = Math.sign(delta);
  3414. } else {
  3415. ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
  3416. }
  3417. } else {
  3418. const PIXELS_PER_LINE_SCALE = 30;
  3419. ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  3420. }
  3421. if (ticks < 0) {
  3422. PDFViewerApplication.zoomOut(-ticks);
  3423. } else if (ticks > 0) {
  3424. PDFViewerApplication.zoomIn(ticks);
  3425. } else {
  3426. return;
  3427. }
  3428. }
  3429. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
  3430. } else {
  3431. setZoomDisabledTimeout();
  3432. }
  3433. }
  3434. function webViewerTouchStart(evt) {
  3435. if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  3436. return;
  3437. }
  3438. evt.preventDefault();
  3439. if (evt.touches.length !== 2) {
  3440. PDFViewerApplication._touchInfo = null;
  3441. return;
  3442. }
  3443. let [touch0, touch1] = evt.touches;
  3444. if (touch0.identifier > touch1.identifier) {
  3445. [touch0, touch1] = [touch1, touch0];
  3446. }
  3447. PDFViewerApplication._touchInfo = {
  3448. touch0X: touch0.pageX,
  3449. touch0Y: touch0.pageY,
  3450. touch1X: touch1.pageX,
  3451. touch1Y: touch1.pageY
  3452. };
  3453. }
  3454. function webViewerTouchMove(evt) {
  3455. if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
  3456. return;
  3457. }
  3458. const {
  3459. pdfViewer,
  3460. _touchInfo,
  3461. supportsPinchToZoom
  3462. } = PDFViewerApplication;
  3463. let [touch0, touch1] = evt.touches;
  3464. if (touch0.identifier > touch1.identifier) {
  3465. [touch0, touch1] = [touch1, touch0];
  3466. }
  3467. const {
  3468. pageX: page0X,
  3469. pageY: page0Y
  3470. } = touch0;
  3471. const {
  3472. pageX: page1X,
  3473. pageY: page1Y
  3474. } = touch1;
  3475. const {
  3476. touch0X: pTouch0X,
  3477. touch0Y: pTouch0Y,
  3478. touch1X: pTouch1X,
  3479. touch1Y: pTouch1Y
  3480. } = _touchInfo;
  3481. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  3482. return;
  3483. }
  3484. _touchInfo.touch0X = page0X;
  3485. _touchInfo.touch0Y = page0Y;
  3486. _touchInfo.touch1X = page1X;
  3487. _touchInfo.touch1Y = page1Y;
  3488. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  3489. const v1X = pTouch1X - page0X;
  3490. const v1Y = pTouch1Y - page0Y;
  3491. const v2X = page1X - page0X;
  3492. const v2Y = page1Y - page0Y;
  3493. const det = v1X * v2Y - v1Y * v2X;
  3494. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3495. return;
  3496. }
  3497. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  3498. const v1X = pTouch0X - page1X;
  3499. const v1Y = pTouch0Y - page1Y;
  3500. const v2X = page0X - page1X;
  3501. const v2Y = page0Y - page1Y;
  3502. const det = v1X * v2Y - v1Y * v2X;
  3503. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3504. return;
  3505. }
  3506. } else {
  3507. const diff0X = page0X - pTouch0X;
  3508. const diff1X = page1X - pTouch1X;
  3509. const diff0Y = page0Y - pTouch0Y;
  3510. const diff1Y = page1Y - pTouch1Y;
  3511. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  3512. if (dotProduct >= 0) {
  3513. return;
  3514. }
  3515. }
  3516. evt.preventDefault();
  3517. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  3518. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  3519. const previousScale = pdfViewer.currentScale;
  3520. if (supportsPinchToZoom) {
  3521. const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
  3522. if (newScaleFactor < 1) {
  3523. PDFViewerApplication.zoomOut(null, newScaleFactor);
  3524. } else if (newScaleFactor > 1) {
  3525. PDFViewerApplication.zoomIn(null, newScaleFactor);
  3526. } else {
  3527. return;
  3528. }
  3529. } else {
  3530. const PIXELS_PER_LINE_SCALE = 30;
  3531. const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  3532. if (ticks < 0) {
  3533. PDFViewerApplication.zoomOut(-ticks);
  3534. } else if (ticks > 0) {
  3535. PDFViewerApplication.zoomIn(ticks);
  3536. } else {
  3537. return;
  3538. }
  3539. }
  3540. PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
  3541. }
  3542. function webViewerTouchEnd(evt) {
  3543. if (!PDFViewerApplication._touchInfo) {
  3544. return;
  3545. }
  3546. evt.preventDefault();
  3547. PDFViewerApplication._touchInfo = null;
  3548. PDFViewerApplication._touchUnusedTicks = 0;
  3549. PDFViewerApplication._touchUnusedFactor = 1;
  3550. }
  3551. function webViewerClick(evt) {
  3552. if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
  3553. return;
  3554. }
  3555. const appConfig = PDFViewerApplication.appConfig;
  3556. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
  3557. PDFViewerApplication.secondaryToolbar.close();
  3558. }
  3559. }
  3560. function webViewerKeyUp(evt) {
  3561. if (evt.key === "Control") {
  3562. PDFViewerApplication._isCtrlKeyDown = false;
  3563. }
  3564. }
  3565. function webViewerKeyDown(evt) {
  3566. PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
  3567. if (PDFViewerApplication.overlayManager.active) {
  3568. return;
  3569. }
  3570. const {
  3571. eventBus,
  3572. pdfViewer
  3573. } = PDFViewerApplication;
  3574. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  3575. let handled = false,
  3576. ensureViewerFocused = false;
  3577. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3578. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3579. switch (evt.keyCode) {
  3580. case 70:
  3581. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3582. PDFViewerApplication.findBar?.open();
  3583. handled = true;
  3584. }
  3585. break;
  3586. case 71:
  3587. if (!PDFViewerApplication.supportsIntegratedFind) {
  3588. const {
  3589. state
  3590. } = PDFViewerApplication.findController;
  3591. if (state) {
  3592. const newState = {
  3593. source: window,
  3594. type: "again",
  3595. findPrevious: cmd === 5 || cmd === 12
  3596. };
  3597. eventBus.dispatch("find", {
  3598. ...state,
  3599. ...newState
  3600. });
  3601. }
  3602. handled = true;
  3603. }
  3604. break;
  3605. case 61:
  3606. case 107:
  3607. case 187:
  3608. case 171:
  3609. PDFViewerApplication.zoomIn();
  3610. handled = true;
  3611. break;
  3612. case 173:
  3613. case 109:
  3614. case 189:
  3615. PDFViewerApplication.zoomOut();
  3616. handled = true;
  3617. break;
  3618. case 48:
  3619. case 96:
  3620. if (!isViewerInPresentationMode) {
  3621. setTimeout(function () {
  3622. PDFViewerApplication.zoomReset();
  3623. });
  3624. handled = false;
  3625. }
  3626. break;
  3627. case 38:
  3628. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3629. PDFViewerApplication.page = 1;
  3630. handled = true;
  3631. ensureViewerFocused = true;
  3632. }
  3633. break;
  3634. case 40:
  3635. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3636. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3637. handled = true;
  3638. ensureViewerFocused = true;
  3639. }
  3640. break;
  3641. }
  3642. }
  3643. if (cmd === 1 || cmd === 8) {
  3644. switch (evt.keyCode) {
  3645. case 83:
  3646. eventBus.dispatch("download", {
  3647. source: window
  3648. });
  3649. handled = true;
  3650. break;
  3651. case 79:
  3652. {
  3653. eventBus.dispatch("openfile", {
  3654. source: window
  3655. });
  3656. handled = true;
  3657. }
  3658. break;
  3659. }
  3660. }
  3661. if (cmd === 3 || cmd === 10) {
  3662. switch (evt.keyCode) {
  3663. case 80:
  3664. PDFViewerApplication.requestPresentationMode();
  3665. handled = true;
  3666. PDFViewerApplication.externalServices.reportTelemetry({
  3667. type: "buttons",
  3668. data: {
  3669. id: "presentationModeKeyboard"
  3670. }
  3671. });
  3672. break;
  3673. case 71:
  3674. if (PDFViewerApplication.appConfig.toolbar) {
  3675. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3676. handled = true;
  3677. }
  3678. break;
  3679. }
  3680. }
  3681. if (handled) {
  3682. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3683. pdfViewer.focus();
  3684. }
  3685. evt.preventDefault();
  3686. return;
  3687. }
  3688. const curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3689. const curElementTagName = curElement?.tagName.toUpperCase();
  3690. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement?.isContentEditable) {
  3691. if (evt.keyCode !== 27) {
  3692. return;
  3693. }
  3694. }
  3695. if (cmd === 0) {
  3696. let turnPage = 0,
  3697. turnOnlyIfPageFit = false;
  3698. switch (evt.keyCode) {
  3699. case 38:
  3700. case 33:
  3701. if (pdfViewer.isVerticalScrollbarEnabled) {
  3702. turnOnlyIfPageFit = true;
  3703. }
  3704. turnPage = -1;
  3705. break;
  3706. case 8:
  3707. if (!isViewerInPresentationMode) {
  3708. turnOnlyIfPageFit = true;
  3709. }
  3710. turnPage = -1;
  3711. break;
  3712. case 37:
  3713. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3714. turnOnlyIfPageFit = true;
  3715. }
  3716. case 75:
  3717. case 80:
  3718. turnPage = -1;
  3719. break;
  3720. case 27:
  3721. if (PDFViewerApplication.secondaryToolbar?.isOpen) {
  3722. PDFViewerApplication.secondaryToolbar.close();
  3723. handled = true;
  3724. }
  3725. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) {
  3726. PDFViewerApplication.findBar.close();
  3727. handled = true;
  3728. }
  3729. break;
  3730. case 40:
  3731. case 34:
  3732. if (pdfViewer.isVerticalScrollbarEnabled) {
  3733. turnOnlyIfPageFit = true;
  3734. }
  3735. turnPage = 1;
  3736. break;
  3737. case 13:
  3738. case 32:
  3739. if (!isViewerInPresentationMode) {
  3740. turnOnlyIfPageFit = true;
  3741. }
  3742. turnPage = 1;
  3743. break;
  3744. case 39:
  3745. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3746. turnOnlyIfPageFit = true;
  3747. }
  3748. case 74:
  3749. case 78:
  3750. turnPage = 1;
  3751. break;
  3752. case 36:
  3753. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3754. PDFViewerApplication.page = 1;
  3755. handled = true;
  3756. ensureViewerFocused = true;
  3757. }
  3758. break;
  3759. case 35:
  3760. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3761. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3762. handled = true;
  3763. ensureViewerFocused = true;
  3764. }
  3765. break;
  3766. case 83:
  3767. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils.CursorTool.SELECT);
  3768. break;
  3769. case 72:
  3770. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils.CursorTool.HAND);
  3771. break;
  3772. case 82:
  3773. PDFViewerApplication.rotatePages(90);
  3774. break;
  3775. case 115:
  3776. PDFViewerApplication.pdfSidebar?.toggle();
  3777. break;
  3778. }
  3779. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  3780. if (turnPage > 0) {
  3781. pdfViewer.nextPage();
  3782. } else {
  3783. pdfViewer.previousPage();
  3784. }
  3785. handled = true;
  3786. }
  3787. }
  3788. if (cmd === 4) {
  3789. switch (evt.keyCode) {
  3790. case 13:
  3791. case 32:
  3792. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  3793. break;
  3794. }
  3795. pdfViewer.previousPage();
  3796. handled = true;
  3797. break;
  3798. case 82:
  3799. PDFViewerApplication.rotatePages(-90);
  3800. break;
  3801. }
  3802. }
  3803. if (!handled && !isViewerInPresentationMode) {
  3804. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3805. ensureViewerFocused = true;
  3806. }
  3807. }
  3808. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3809. pdfViewer.focus();
  3810. }
  3811. if (handled) {
  3812. evt.preventDefault();
  3813. }
  3814. }
  3815. function beforeUnload(evt) {
  3816. evt.preventDefault();
  3817. evt.returnValue = "";
  3818. return false;
  3819. }
  3820. function webViewerAnnotationEditorStatesChanged(data) {
  3821. PDFViewerApplication.externalServices.updateEditorStates(data);
  3822. }
  3823. const PDFPrintServiceFactory = {
  3824. instance: {
  3825. supportsPrinting: false,
  3826. createPrintService() {
  3827. throw new Error("Not implemented: createPrintService");
  3828. }
  3829. }
  3830. };
  3831. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3832. /***/ }),
  3833. /* 76 */
  3834. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  3835. var $ = __webpack_require__(3);
  3836. var global = __webpack_require__(4);
  3837. var apply = __webpack_require__(77);
  3838. var wrapErrorConstructorWithCause = __webpack_require__(78);
  3839. var WEB_ASSEMBLY = 'WebAssembly';
  3840. var WebAssembly = global[WEB_ASSEMBLY];
  3841. var FORCED = Error('e', { cause: 7 }).cause !== 7;
  3842. var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  3843. var O = {};
  3844. O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);
  3845. $({
  3846. global: true,
  3847. constructor: true,
  3848. arity: 1,
  3849. forced: FORCED
  3850. }, O);
  3851. };
  3852. var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  3853. if (WebAssembly && WebAssembly[ERROR_NAME]) {
  3854. var O = {};
  3855. O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);
  3856. $({
  3857. target: WEB_ASSEMBLY,
  3858. stat: true,
  3859. constructor: true,
  3860. arity: 1,
  3861. forced: FORCED
  3862. }, O);
  3863. }
  3864. };
  3865. exportGlobalErrorCauseWrapper('Error', function (init) {
  3866. return function Error(message) {
  3867. return apply(init, this, arguments);
  3868. };
  3869. });
  3870. exportGlobalErrorCauseWrapper('EvalError', function (init) {
  3871. return function EvalError(message) {
  3872. return apply(init, this, arguments);
  3873. };
  3874. });
  3875. exportGlobalErrorCauseWrapper('RangeError', function (init) {
  3876. return function RangeError(message) {
  3877. return apply(init, this, arguments);
  3878. };
  3879. });
  3880. exportGlobalErrorCauseWrapper('ReferenceError', function (init) {
  3881. return function ReferenceError(message) {
  3882. return apply(init, this, arguments);
  3883. };
  3884. });
  3885. exportGlobalErrorCauseWrapper('SyntaxError', function (init) {
  3886. return function SyntaxError(message) {
  3887. return apply(init, this, arguments);
  3888. };
  3889. });
  3890. exportGlobalErrorCauseWrapper('TypeError', function (init) {
  3891. return function TypeError(message) {
  3892. return apply(init, this, arguments);
  3893. };
  3894. });
  3895. exportGlobalErrorCauseWrapper('URIError', function (init) {
  3896. return function URIError(message) {
  3897. return apply(init, this, arguments);
  3898. };
  3899. });
  3900. exportWebAssemblyErrorCauseWrapper('CompileError', function (init) {
  3901. return function CompileError(message) {
  3902. return apply(init, this, arguments);
  3903. };
  3904. });
  3905. exportWebAssemblyErrorCauseWrapper('LinkError', function (init) {
  3906. return function LinkError(message) {
  3907. return apply(init, this, arguments);
  3908. };
  3909. });
  3910. exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
  3911. return function RuntimeError(message) {
  3912. return apply(init, this, arguments);
  3913. };
  3914. });
  3915. /***/ }),
  3916. /* 77 */
  3917. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3918. var NATIVE_BIND = __webpack_require__(9);
  3919. var FunctionPrototype = Function.prototype;
  3920. var apply = FunctionPrototype.apply;
  3921. var call = FunctionPrototype.call;
  3922. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  3923. return call.apply(apply, arguments);
  3924. });
  3925. /***/ }),
  3926. /* 78 */
  3927. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3928. "use strict";
  3929. var getBuiltIn = __webpack_require__(24);
  3930. var hasOwn = __webpack_require__(39);
  3931. var createNonEnumerableProperty = __webpack_require__(44);
  3932. var isPrototypeOf = __webpack_require__(25);
  3933. var setPrototypeOf = __webpack_require__(79);
  3934. var copyConstructorProperties = __webpack_require__(56);
  3935. var proxyAccessor = __webpack_require__(82);
  3936. var inheritIfRequired = __webpack_require__(83);
  3937. var normalizeStringArgument = __webpack_require__(84);
  3938. var installErrorCause = __webpack_require__(85);
  3939. var installErrorStack = __webpack_require__(86);
  3940. var DESCRIPTORS = __webpack_require__(6);
  3941. var IS_PURE = __webpack_require__(36);
  3942. module.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) {
  3943. var STACK_TRACE_LIMIT = 'stackTraceLimit';
  3944. var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1;
  3945. var path = FULL_NAME.split('.');
  3946. var ERROR_NAME = path[path.length - 1];
  3947. var OriginalError = getBuiltIn.apply(null, path);
  3948. if (!OriginalError)
  3949. return;
  3950. var OriginalErrorPrototype = OriginalError.prototype;
  3951. if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause'))
  3952. delete OriginalErrorPrototype.cause;
  3953. if (!FORCED)
  3954. return OriginalError;
  3955. var BaseError = getBuiltIn('Error');
  3956. var WrappedError = wrapper(function (a, b) {
  3957. var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined);
  3958. var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError();
  3959. if (message !== undefined)
  3960. createNonEnumerableProperty(result, 'message', message);
  3961. installErrorStack(result, WrappedError, result.stack, 2);
  3962. if (this && isPrototypeOf(OriginalErrorPrototype, this))
  3963. inheritIfRequired(result, this, WrappedError);
  3964. if (arguments.length > OPTIONS_POSITION)
  3965. installErrorCause(result, arguments[OPTIONS_POSITION]);
  3966. return result;
  3967. });
  3968. WrappedError.prototype = OriginalErrorPrototype;
  3969. if (ERROR_NAME !== 'Error') {
  3970. if (setPrototypeOf)
  3971. setPrototypeOf(WrappedError, BaseError);
  3972. else
  3973. copyConstructorProperties(WrappedError, BaseError, { name: true });
  3974. } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) {
  3975. proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT);
  3976. proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace');
  3977. }
  3978. copyConstructorProperties(WrappedError, OriginalError);
  3979. if (!IS_PURE)
  3980. try {
  3981. if (OriginalErrorPrototype.name !== ERROR_NAME) {
  3982. createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME);
  3983. }
  3984. OriginalErrorPrototype.constructor = WrappedError;
  3985. } catch (error) {
  3986. }
  3987. return WrappedError;
  3988. };
  3989. /***/ }),
  3990. /* 79 */
  3991. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3992. var uncurryThisAccessor = __webpack_require__(80);
  3993. var anObject = __webpack_require__(47);
  3994. var aPossiblePrototype = __webpack_require__(81);
  3995. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  3996. var CORRECT_SETTER = false;
  3997. var test = {};
  3998. var setter;
  3999. try {
  4000. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  4001. setter(test, []);
  4002. CORRECT_SETTER = test instanceof Array;
  4003. } catch (error) {
  4004. }
  4005. return function setPrototypeOf(O, proto) {
  4006. anObject(O);
  4007. aPossiblePrototype(proto);
  4008. if (CORRECT_SETTER)
  4009. setter(O, proto);
  4010. else
  4011. O.__proto__ = proto;
  4012. return O;
  4013. };
  4014. }()) : undefined);
  4015. /***/ }),
  4016. /* 80 */
  4017. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4018. var uncurryThis = __webpack_require__(14);
  4019. var aCallable = __webpack_require__(31);
  4020. module.exports = function (object, key, method) {
  4021. try {
  4022. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  4023. } catch (error) {
  4024. }
  4025. };
  4026. /***/ }),
  4027. /* 81 */
  4028. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4029. var isCallable = __webpack_require__(21);
  4030. var $String = String;
  4031. var $TypeError = TypeError;
  4032. module.exports = function (argument) {
  4033. if (typeof argument == 'object' || isCallable(argument))
  4034. return argument;
  4035. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  4036. };
  4037. /***/ }),
  4038. /* 82 */
  4039. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4040. var defineProperty = (__webpack_require__(45).f);
  4041. module.exports = function (Target, Source, key) {
  4042. key in Target || defineProperty(Target, key, {
  4043. configurable: true,
  4044. get: function () {
  4045. return Source[key];
  4046. },
  4047. set: function (it) {
  4048. Source[key] = it;
  4049. }
  4050. });
  4051. };
  4052. /***/ }),
  4053. /* 83 */
  4054. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4055. var isCallable = __webpack_require__(21);
  4056. var isObject = __webpack_require__(20);
  4057. var setPrototypeOf = __webpack_require__(79);
  4058. module.exports = function ($this, dummy, Wrapper) {
  4059. var NewTarget, NewTargetPrototype;
  4060. if (setPrototypeOf && isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  4061. setPrototypeOf($this, NewTargetPrototype);
  4062. return $this;
  4063. };
  4064. /***/ }),
  4065. /* 84 */
  4066. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4067. var toString = __webpack_require__(70);
  4068. module.exports = function (argument, $default) {
  4069. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  4070. };
  4071. /***/ }),
  4072. /* 85 */
  4073. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4074. var isObject = __webpack_require__(20);
  4075. var createNonEnumerableProperty = __webpack_require__(44);
  4076. module.exports = function (O, options) {
  4077. if (isObject(options) && 'cause' in options) {
  4078. createNonEnumerableProperty(O, 'cause', options.cause);
  4079. }
  4080. };
  4081. /***/ }),
  4082. /* 86 */
  4083. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4084. var createNonEnumerableProperty = __webpack_require__(44);
  4085. var clearErrorStack = __webpack_require__(87);
  4086. var ERROR_STACK_INSTALLABLE = __webpack_require__(88);
  4087. var captureStackTrace = Error.captureStackTrace;
  4088. module.exports = function (error, C, stack, dropEntries) {
  4089. if (ERROR_STACK_INSTALLABLE) {
  4090. if (captureStackTrace)
  4091. captureStackTrace(error, C);
  4092. else
  4093. createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  4094. }
  4095. };
  4096. /***/ }),
  4097. /* 87 */
  4098. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4099. var uncurryThis = __webpack_require__(14);
  4100. var $Error = Error;
  4101. var replace = uncurryThis(''.replace);
  4102. var TEST = function (arg) {
  4103. return String($Error(arg).stack);
  4104. }('zxcasd');
  4105. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  4106. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  4107. module.exports = function (stack, dropEntries) {
  4108. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  4109. while (dropEntries--)
  4110. stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  4111. }
  4112. return stack;
  4113. };
  4114. /***/ }),
  4115. /* 88 */
  4116. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4117. var fails = __webpack_require__(7);
  4118. var createPropertyDescriptor = __webpack_require__(11);
  4119. module.exports = !fails(function () {
  4120. var error = Error('a');
  4121. if (!('stack' in error))
  4122. return true;
  4123. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  4124. return error.stack !== 7;
  4125. });
  4126. /***/ }),
  4127. /* 89 */
  4128. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4129. "use strict";
  4130. var $ = __webpack_require__(3);
  4131. var toObject = __webpack_require__(40);
  4132. var lengthOfArrayLike = __webpack_require__(64);
  4133. var setArrayLength = __webpack_require__(90);
  4134. var doesNotExceedSafeInteger = __webpack_require__(91);
  4135. var fails = __webpack_require__(7);
  4136. var INCORRECT_TO_LENGTH = fails(function () {
  4137. return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
  4138. });
  4139. var properErrorOnNonWritableLength = function () {
  4140. try {
  4141. Object.defineProperty([], 'length', { writable: false }).push();
  4142. } catch (error) {
  4143. return error instanceof TypeError;
  4144. }
  4145. };
  4146. var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
  4147. $({
  4148. target: 'Array',
  4149. proto: true,
  4150. arity: 1,
  4151. forced: FORCED
  4152. }, {
  4153. push: function push(item) {
  4154. var O = toObject(this);
  4155. var len = lengthOfArrayLike(O);
  4156. var argCount = arguments.length;
  4157. doesNotExceedSafeInteger(len + argCount);
  4158. for (var i = 0; i < argCount; i++) {
  4159. O[len] = arguments[i];
  4160. len++;
  4161. }
  4162. setArrayLength(O, len);
  4163. return len;
  4164. }
  4165. });
  4166. /***/ }),
  4167. /* 90 */
  4168. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4169. "use strict";
  4170. var DESCRIPTORS = __webpack_require__(6);
  4171. var isArray = __webpack_require__(69);
  4172. var $TypeError = TypeError;
  4173. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  4174. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !(function () {
  4175. if (this !== undefined)
  4176. return true;
  4177. try {
  4178. Object.defineProperty([], 'length', { writable: false }).length = 1;
  4179. } catch (error) {
  4180. return error instanceof TypeError;
  4181. }
  4182. }());
  4183. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  4184. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  4185. throw $TypeError('Cannot set read only .length');
  4186. }
  4187. return O.length = length;
  4188. } : function (O, length) {
  4189. return O.length = length;
  4190. };
  4191. /***/ }),
  4192. /* 91 */
  4193. /***/ ((module) => {
  4194. var $TypeError = TypeError;
  4195. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  4196. module.exports = function (it) {
  4197. if (it > MAX_SAFE_INTEGER)
  4198. throw $TypeError('Maximum allowed index exceeded');
  4199. return it;
  4200. };
  4201. /***/ }),
  4202. /* 92 */
  4203. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4204. "use strict";
  4205. var defineBuiltIn = __webpack_require__(48);
  4206. var uncurryThis = __webpack_require__(14);
  4207. var toString = __webpack_require__(70);
  4208. var validateArgumentsLength = __webpack_require__(93);
  4209. var $URLSearchParams = URLSearchParams;
  4210. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4211. var append = uncurryThis(URLSearchParamsPrototype.append);
  4212. var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
  4213. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4214. var push = uncurryThis([].push);
  4215. var params = new $URLSearchParams('a=1&a=2');
  4216. params['delete']('a', 1);
  4217. if (params + '' !== 'a=2') {
  4218. defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name) {
  4219. var length = arguments.length;
  4220. var $value = length < 2 ? undefined : arguments[1];
  4221. if (length && $value === undefined)
  4222. return $delete(this, name);
  4223. var entries = [];
  4224. forEach(this, function (v, k) {
  4225. push(entries, {
  4226. key: k,
  4227. value: v
  4228. });
  4229. });
  4230. validateArgumentsLength(length, 1);
  4231. var key = toString(name);
  4232. var value = toString($value);
  4233. var index = 0;
  4234. var dindex = 0;
  4235. var found = false;
  4236. var entriesLength = entries.length;
  4237. var entry;
  4238. while (index < entriesLength) {
  4239. entry = entries[index++];
  4240. if (found || entry.key === key) {
  4241. found = true;
  4242. $delete(this, entry.key);
  4243. } else
  4244. dindex++;
  4245. }
  4246. while (dindex < entriesLength) {
  4247. entry = entries[dindex++];
  4248. if (!(entry.key === key && entry.value === value))
  4249. append(this, entry.key, entry.value);
  4250. }
  4251. }, {
  4252. enumerable: true,
  4253. unsafe: true
  4254. });
  4255. }
  4256. /***/ }),
  4257. /* 93 */
  4258. /***/ ((module) => {
  4259. var $TypeError = TypeError;
  4260. module.exports = function (passed, required) {
  4261. if (passed < required)
  4262. throw $TypeError('Not enough arguments');
  4263. return passed;
  4264. };
  4265. /***/ }),
  4266. /* 94 */
  4267. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4268. "use strict";
  4269. var defineBuiltIn = __webpack_require__(48);
  4270. var uncurryThis = __webpack_require__(14);
  4271. var toString = __webpack_require__(70);
  4272. var validateArgumentsLength = __webpack_require__(93);
  4273. var $URLSearchParams = URLSearchParams;
  4274. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4275. var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
  4276. var $has = uncurryThis(URLSearchParamsPrototype.has);
  4277. var params = new $URLSearchParams('a=1');
  4278. if (params.has('a', 2)) {
  4279. defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name) {
  4280. var length = arguments.length;
  4281. var $value = length < 2 ? undefined : arguments[1];
  4282. if (length && $value === undefined)
  4283. return $has(this, name);
  4284. var values = getAll(this, name);
  4285. validateArgumentsLength(length, 1);
  4286. var value = toString($value);
  4287. var index = 0;
  4288. while (index < values.length) {
  4289. if (values[index++] === value)
  4290. return true;
  4291. }
  4292. return false;
  4293. }, {
  4294. enumerable: true,
  4295. unsafe: true
  4296. });
  4297. }
  4298. /***/ }),
  4299. /* 95 */
  4300. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4301. "use strict";
  4302. var DESCRIPTORS = __webpack_require__(6);
  4303. var uncurryThis = __webpack_require__(14);
  4304. var defineBuiltInAccessor = __webpack_require__(96);
  4305. var URLSearchParamsPrototype = URLSearchParams.prototype;
  4306. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4307. if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
  4308. defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
  4309. get: function size() {
  4310. var count = 0;
  4311. forEach(this, function () {
  4312. count++;
  4313. });
  4314. return count;
  4315. },
  4316. configurable: true,
  4317. enumerable: true
  4318. });
  4319. }
  4320. /***/ }),
  4321. /* 96 */
  4322. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4323. var makeBuiltIn = __webpack_require__(49);
  4324. var defineProperty = __webpack_require__(45);
  4325. module.exports = function (target, name, descriptor) {
  4326. if (descriptor.get)
  4327. makeBuiltIn(descriptor.get, name, { getter: true });
  4328. if (descriptor.set)
  4329. makeBuiltIn(descriptor.set, name, { setter: true });
  4330. return defineProperty.f(target, name, descriptor);
  4331. };
  4332. /***/ }),
  4333. /* 97 */
  4334. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4335. "use strict";
  4336. Object.defineProperty(exports, "__esModule", ({
  4337. value: true
  4338. }));
  4339. 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;
  4340. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  4341. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  4342. exports.approximateFraction = approximateFraction;
  4343. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4344. exports.binarySearchFirstItem = binarySearchFirstItem;
  4345. exports.docStyle = void 0;
  4346. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4347. exports.getPageSizeInches = getPageSizeInches;
  4348. exports.getVisibleElements = getVisibleElements;
  4349. exports.isPortraitOrientation = isPortraitOrientation;
  4350. exports.isValidRotation = isValidRotation;
  4351. exports.isValidScrollMode = isValidScrollMode;
  4352. exports.isValidSpreadMode = isValidSpreadMode;
  4353. exports.noContextMenuHandler = noContextMenuHandler;
  4354. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4355. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4356. exports.parseQueryString = parseQueryString;
  4357. exports.removeNullCharacters = removeNullCharacters;
  4358. exports.roundToDivide = roundToDivide;
  4359. exports.scrollIntoView = scrollIntoView;
  4360. exports.toggleCheckedBtn = toggleCheckedBtn;
  4361. exports.toggleExpandedBtn = toggleExpandedBtn;
  4362. exports.watchScroll = watchScroll;
  4363. __webpack_require__(92);
  4364. __webpack_require__(94);
  4365. __webpack_require__(95);
  4366. __webpack_require__(98);
  4367. __webpack_require__(108);
  4368. __webpack_require__(110);
  4369. __webpack_require__(113);
  4370. __webpack_require__(115);
  4371. __webpack_require__(117);
  4372. __webpack_require__(119);
  4373. __webpack_require__(89);
  4374. const DEFAULT_SCALE_VALUE = "auto";
  4375. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4376. const DEFAULT_SCALE = 1.0;
  4377. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4378. const DEFAULT_SCALE_DELTA = 1.1;
  4379. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  4380. const MIN_SCALE = 0.1;
  4381. exports.MIN_SCALE = MIN_SCALE;
  4382. const MAX_SCALE = 10.0;
  4383. exports.MAX_SCALE = MAX_SCALE;
  4384. const UNKNOWN_SCALE = 0;
  4385. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4386. const MAX_AUTO_SCALE = 1.25;
  4387. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4388. const SCROLLBAR_PADDING = 40;
  4389. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4390. const VERTICAL_PADDING = 5;
  4391. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4392. const RenderingStates = {
  4393. INITIAL: 0,
  4394. RUNNING: 1,
  4395. PAUSED: 2,
  4396. FINISHED: 3
  4397. };
  4398. exports.RenderingStates = RenderingStates;
  4399. const PresentationModeState = {
  4400. UNKNOWN: 0,
  4401. NORMAL: 1,
  4402. CHANGING: 2,
  4403. FULLSCREEN: 3
  4404. };
  4405. exports.PresentationModeState = PresentationModeState;
  4406. const SidebarView = {
  4407. UNKNOWN: -1,
  4408. NONE: 0,
  4409. THUMBS: 1,
  4410. OUTLINE: 2,
  4411. ATTACHMENTS: 3,
  4412. LAYERS: 4
  4413. };
  4414. exports.SidebarView = SidebarView;
  4415. const TextLayerMode = {
  4416. DISABLE: 0,
  4417. ENABLE: 1,
  4418. ENABLE_PERMISSIONS: 2
  4419. };
  4420. exports.TextLayerMode = TextLayerMode;
  4421. const ScrollMode = {
  4422. UNKNOWN: -1,
  4423. VERTICAL: 0,
  4424. HORIZONTAL: 1,
  4425. WRAPPED: 2,
  4426. PAGE: 3
  4427. };
  4428. exports.ScrollMode = ScrollMode;
  4429. const SpreadMode = {
  4430. UNKNOWN: -1,
  4431. NONE: 0,
  4432. ODD: 1,
  4433. EVEN: 2
  4434. };
  4435. exports.SpreadMode = SpreadMode;
  4436. const CursorTool = {
  4437. SELECT: 0,
  4438. HAND: 1,
  4439. ZOOM: 2
  4440. };
  4441. exports.CursorTool = CursorTool;
  4442. const AutoPrintRegExp = /\bprint\s*\(/;
  4443. exports.AutoPrintRegExp = AutoPrintRegExp;
  4444. class OutputScale {
  4445. constructor() {
  4446. const pixelRatio = window.devicePixelRatio || 1;
  4447. this.sx = pixelRatio;
  4448. this.sy = pixelRatio;
  4449. }
  4450. get scaled() {
  4451. return this.sx !== 1 || this.sy !== 1;
  4452. }
  4453. }
  4454. exports.OutputScale = OutputScale;
  4455. function scrollIntoView(element, spot) {
  4456. let scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4457. let parent = element.offsetParent;
  4458. if (!parent) {
  4459. console.error("offsetParent is not set -- cannot scroll");
  4460. return;
  4461. }
  4462. let offsetY = element.offsetTop + element.clientTop;
  4463. let offsetX = element.offsetLeft + element.clientLeft;
  4464. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  4465. offsetY += parent.offsetTop;
  4466. offsetX += parent.offsetLeft;
  4467. parent = parent.offsetParent;
  4468. if (!parent) {
  4469. return;
  4470. }
  4471. }
  4472. if (spot) {
  4473. if (spot.top !== undefined) {
  4474. offsetY += spot.top;
  4475. }
  4476. if (spot.left !== undefined) {
  4477. offsetX += spot.left;
  4478. parent.scrollLeft = offsetX;
  4479. }
  4480. }
  4481. parent.scrollTop = offsetY;
  4482. }
  4483. function watchScroll(viewAreaElement, callback) {
  4484. const debounceScroll = function (evt) {
  4485. if (rAF) {
  4486. return;
  4487. }
  4488. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4489. rAF = null;
  4490. const currentX = viewAreaElement.scrollLeft;
  4491. const lastX = state.lastX;
  4492. if (currentX !== lastX) {
  4493. state.right = currentX > lastX;
  4494. }
  4495. state.lastX = currentX;
  4496. const currentY = viewAreaElement.scrollTop;
  4497. const lastY = state.lastY;
  4498. if (currentY !== lastY) {
  4499. state.down = currentY > lastY;
  4500. }
  4501. state.lastY = currentY;
  4502. callback(state);
  4503. });
  4504. };
  4505. const state = {
  4506. right: true,
  4507. down: true,
  4508. lastX: viewAreaElement.scrollLeft,
  4509. lastY: viewAreaElement.scrollTop,
  4510. _eventHandler: debounceScroll
  4511. };
  4512. let rAF = null;
  4513. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4514. return state;
  4515. }
  4516. function parseQueryString(query) {
  4517. const params = new Map();
  4518. for (const [key, value] of new URLSearchParams(query)) {
  4519. params.set(key.toLowerCase(), value);
  4520. }
  4521. return params;
  4522. }
  4523. const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  4524. function removeNullCharacters(str) {
  4525. let replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4526. if (typeof str !== "string") {
  4527. console.error(`The argument must be a string.`);
  4528. return str;
  4529. }
  4530. if (replaceInvisible) {
  4531. str = str.replaceAll(InvisibleCharactersRegExp, " ");
  4532. }
  4533. return str.replaceAll("\x00", "");
  4534. }
  4535. function binarySearchFirstItem(items, condition) {
  4536. let start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  4537. let minIndex = start;
  4538. let maxIndex = items.length - 1;
  4539. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4540. return items.length;
  4541. }
  4542. if (condition(items[minIndex])) {
  4543. return minIndex;
  4544. }
  4545. while (minIndex < maxIndex) {
  4546. const currentIndex = minIndex + maxIndex >> 1;
  4547. const currentItem = items[currentIndex];
  4548. if (condition(currentItem)) {
  4549. maxIndex = currentIndex;
  4550. } else {
  4551. minIndex = currentIndex + 1;
  4552. }
  4553. }
  4554. return minIndex;
  4555. }
  4556. function approximateFraction(x) {
  4557. if (Math.floor(x) === x) {
  4558. return [x, 1];
  4559. }
  4560. const xinv = 1 / x;
  4561. const limit = 8;
  4562. if (xinv > limit) {
  4563. return [1, limit];
  4564. } else if (Math.floor(xinv) === xinv) {
  4565. return [1, xinv];
  4566. }
  4567. const x_ = x > 1 ? xinv : x;
  4568. let a = 0,
  4569. b = 1,
  4570. c = 1,
  4571. d = 1;
  4572. while (true) {
  4573. const p = a + c,
  4574. q = b + d;
  4575. if (q > limit) {
  4576. break;
  4577. }
  4578. if (x_ <= p / q) {
  4579. c = p;
  4580. d = q;
  4581. } else {
  4582. a = p;
  4583. b = q;
  4584. }
  4585. }
  4586. let result;
  4587. if (x_ - a / b < c / d - x_) {
  4588. result = x_ === x ? [a, b] : [b, a];
  4589. } else {
  4590. result = x_ === x ? [c, d] : [d, c];
  4591. }
  4592. return result;
  4593. }
  4594. function roundToDivide(x, div) {
  4595. const r = x % div;
  4596. return r === 0 ? x : Math.round(x - r + div);
  4597. }
  4598. function getPageSizeInches(_ref) {
  4599. let {
  4600. view,
  4601. userUnit,
  4602. rotate
  4603. } = _ref;
  4604. const [x1, y1, x2, y2] = view;
  4605. const changeOrientation = rotate % 180 !== 0;
  4606. const width = (x2 - x1) / 72 * userUnit;
  4607. const height = (y2 - y1) / 72 * userUnit;
  4608. return {
  4609. width: changeOrientation ? height : width,
  4610. height: changeOrientation ? width : height
  4611. };
  4612. }
  4613. function backtrackBeforeAllVisibleElements(index, views, top) {
  4614. if (index < 2) {
  4615. return index;
  4616. }
  4617. let elt = views[index].div;
  4618. let pageTop = elt.offsetTop + elt.clientTop;
  4619. if (pageTop >= top) {
  4620. elt = views[index - 1].div;
  4621. pageTop = elt.offsetTop + elt.clientTop;
  4622. }
  4623. for (let i = index - 2; i >= 0; --i) {
  4624. elt = views[i].div;
  4625. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  4626. break;
  4627. }
  4628. index = i;
  4629. }
  4630. return index;
  4631. }
  4632. function getVisibleElements(_ref2) {
  4633. let {
  4634. scrollEl,
  4635. views,
  4636. sortByVisibility = false,
  4637. horizontal = false,
  4638. rtl = false
  4639. } = _ref2;
  4640. const top = scrollEl.scrollTop,
  4641. bottom = top + scrollEl.clientHeight;
  4642. const left = scrollEl.scrollLeft,
  4643. right = left + scrollEl.clientWidth;
  4644. function isElementBottomAfterViewTop(view) {
  4645. const element = view.div;
  4646. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  4647. return elementBottom > top;
  4648. }
  4649. function isElementNextAfterViewHorizontally(view) {
  4650. const element = view.div;
  4651. const elementLeft = element.offsetLeft + element.clientLeft;
  4652. const elementRight = elementLeft + element.clientWidth;
  4653. return rtl ? elementLeft < right : elementRight > left;
  4654. }
  4655. const visible = [],
  4656. ids = new Set(),
  4657. numViews = views.length;
  4658. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  4659. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  4660. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  4661. }
  4662. let lastEdge = horizontal ? right : -1;
  4663. for (let i = firstVisibleElementInd; i < numViews; i++) {
  4664. const view = views[i],
  4665. element = view.div;
  4666. const currentWidth = element.offsetLeft + element.clientLeft;
  4667. const currentHeight = element.offsetTop + element.clientTop;
  4668. const viewWidth = element.clientWidth,
  4669. viewHeight = element.clientHeight;
  4670. const viewRight = currentWidth + viewWidth;
  4671. const viewBottom = currentHeight + viewHeight;
  4672. if (lastEdge === -1) {
  4673. if (viewBottom >= bottom) {
  4674. lastEdge = viewBottom;
  4675. }
  4676. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  4677. break;
  4678. }
  4679. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  4680. continue;
  4681. }
  4682. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  4683. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  4684. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  4685. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  4686. const percent = fractionHeight * fractionWidth * 100 | 0;
  4687. visible.push({
  4688. id: view.id,
  4689. x: currentWidth,
  4690. y: currentHeight,
  4691. view,
  4692. percent,
  4693. widthPercent: fractionWidth * 100 | 0
  4694. });
  4695. ids.add(view.id);
  4696. }
  4697. const first = visible[0],
  4698. last = visible.at(-1);
  4699. if (sortByVisibility) {
  4700. visible.sort(function (a, b) {
  4701. const pc = a.percent - b.percent;
  4702. if (Math.abs(pc) > 0.001) {
  4703. return -pc;
  4704. }
  4705. return a.id - b.id;
  4706. });
  4707. }
  4708. return {
  4709. first,
  4710. last,
  4711. views: visible,
  4712. ids
  4713. };
  4714. }
  4715. function noContextMenuHandler(evt) {
  4716. evt.preventDefault();
  4717. }
  4718. function normalizeWheelEventDirection(evt) {
  4719. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  4720. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  4721. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  4722. delta = -delta;
  4723. }
  4724. return delta;
  4725. }
  4726. function normalizeWheelEventDelta(evt) {
  4727. const deltaMode = evt.deltaMode;
  4728. let delta = normalizeWheelEventDirection(evt);
  4729. const MOUSE_PIXELS_PER_LINE = 30;
  4730. const MOUSE_LINES_PER_PAGE = 30;
  4731. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  4732. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  4733. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  4734. delta /= MOUSE_LINES_PER_PAGE;
  4735. }
  4736. return delta;
  4737. }
  4738. function isValidRotation(angle) {
  4739. return Number.isInteger(angle) && angle % 90 === 0;
  4740. }
  4741. function isValidScrollMode(mode) {
  4742. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  4743. }
  4744. function isValidSpreadMode(mode) {
  4745. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  4746. }
  4747. function isPortraitOrientation(size) {
  4748. return size.width <= size.height;
  4749. }
  4750. const animationStarted = new Promise(function (resolve) {
  4751. window.requestAnimationFrame(resolve);
  4752. });
  4753. exports.animationStarted = animationStarted;
  4754. const docStyle = document.documentElement.style;
  4755. exports.docStyle = docStyle;
  4756. function clamp(v, min, max) {
  4757. return Math.min(Math.max(v, min), max);
  4758. }
  4759. class ProgressBar {
  4760. #classList = null;
  4761. #disableAutoFetchTimeout = null;
  4762. #percent = 0;
  4763. #style = null;
  4764. #visible = true;
  4765. constructor(bar) {
  4766. this.#classList = bar.classList;
  4767. this.#style = bar.style;
  4768. }
  4769. get percent() {
  4770. return this.#percent;
  4771. }
  4772. set percent(val) {
  4773. this.#percent = clamp(val, 0, 100);
  4774. if (isNaN(val)) {
  4775. this.#classList.add("indeterminate");
  4776. return;
  4777. }
  4778. this.#classList.remove("indeterminate");
  4779. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  4780. }
  4781. setWidth(viewer) {
  4782. if (!viewer) {
  4783. return;
  4784. }
  4785. const container = viewer.parentNode;
  4786. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4787. if (scrollbarWidth > 0) {
  4788. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  4789. }
  4790. }
  4791. setDisableAutoFetch() {
  4792. let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 5000;
  4793. if (isNaN(this.#percent)) {
  4794. return;
  4795. }
  4796. if (this.#disableAutoFetchTimeout) {
  4797. clearTimeout(this.#disableAutoFetchTimeout);
  4798. }
  4799. this.show();
  4800. this.#disableAutoFetchTimeout = setTimeout(() => {
  4801. this.#disableAutoFetchTimeout = null;
  4802. this.hide();
  4803. }, delay);
  4804. }
  4805. hide() {
  4806. if (!this.#visible) {
  4807. return;
  4808. }
  4809. this.#visible = false;
  4810. this.#classList.add("hidden");
  4811. }
  4812. show() {
  4813. if (this.#visible) {
  4814. return;
  4815. }
  4816. this.#visible = true;
  4817. this.#classList.remove("hidden");
  4818. }
  4819. }
  4820. exports.ProgressBar = ProgressBar;
  4821. function getActiveOrFocusedElement() {
  4822. let curRoot = document;
  4823. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4824. while (curActiveOrFocused?.shadowRoot) {
  4825. curRoot = curActiveOrFocused.shadowRoot;
  4826. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4827. }
  4828. return curActiveOrFocused;
  4829. }
  4830. function apiPageLayoutToViewerModes(layout) {
  4831. let scrollMode = ScrollMode.VERTICAL,
  4832. spreadMode = SpreadMode.NONE;
  4833. switch (layout) {
  4834. case "SinglePage":
  4835. scrollMode = ScrollMode.PAGE;
  4836. break;
  4837. case "OneColumn":
  4838. break;
  4839. case "TwoPageLeft":
  4840. scrollMode = ScrollMode.PAGE;
  4841. case "TwoColumnLeft":
  4842. spreadMode = SpreadMode.ODD;
  4843. break;
  4844. case "TwoPageRight":
  4845. scrollMode = ScrollMode.PAGE;
  4846. case "TwoColumnRight":
  4847. spreadMode = SpreadMode.EVEN;
  4848. break;
  4849. }
  4850. return {
  4851. scrollMode,
  4852. spreadMode
  4853. };
  4854. }
  4855. function apiPageModeToSidebarView(mode) {
  4856. switch (mode) {
  4857. case "UseNone":
  4858. return SidebarView.NONE;
  4859. case "UseThumbs":
  4860. return SidebarView.THUMBS;
  4861. case "UseOutlines":
  4862. return SidebarView.OUTLINE;
  4863. case "UseAttachments":
  4864. return SidebarView.ATTACHMENTS;
  4865. case "UseOC":
  4866. return SidebarView.LAYERS;
  4867. }
  4868. return SidebarView.NONE;
  4869. }
  4870. function toggleCheckedBtn(button, toggle) {
  4871. let view = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4872. button.classList.toggle("toggled", toggle);
  4873. button.setAttribute("aria-checked", toggle);
  4874. view?.classList.toggle("hidden", !toggle);
  4875. }
  4876. function toggleExpandedBtn(button, toggle) {
  4877. let view = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4878. button.classList.toggle("toggled", toggle);
  4879. button.setAttribute("aria-expanded", toggle);
  4880. view?.classList.toggle("hidden", !toggle);
  4881. }
  4882. /***/ }),
  4883. /* 98 */
  4884. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4885. var $ = __webpack_require__(3);
  4886. var difference = __webpack_require__(99);
  4887. var setMethodAcceptSetLike = __webpack_require__(107);
  4888. $({
  4889. target: 'Set',
  4890. proto: true,
  4891. real: true,
  4892. forced: !setMethodAcceptSetLike('difference')
  4893. }, { difference: difference });
  4894. /***/ }),
  4895. /* 99 */
  4896. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4897. "use strict";
  4898. var aSet = __webpack_require__(100);
  4899. var SetHelpers = __webpack_require__(101);
  4900. var clone = __webpack_require__(102);
  4901. var size = __webpack_require__(105);
  4902. var getSetRecord = __webpack_require__(106);
  4903. var iterateSet = __webpack_require__(103);
  4904. var iterateSimple = __webpack_require__(104);
  4905. var has = SetHelpers.has;
  4906. var remove = SetHelpers.remove;
  4907. module.exports = function difference(other) {
  4908. var O = aSet(this);
  4909. var otherRec = getSetRecord(other);
  4910. var result = clone(O);
  4911. if (size(O) <= otherRec.size)
  4912. iterateSet(O, function (e) {
  4913. if (otherRec.includes(e))
  4914. remove(result, e);
  4915. });
  4916. else
  4917. iterateSimple(otherRec.getIterator(), function (e) {
  4918. if (has(O, e))
  4919. remove(result, e);
  4920. });
  4921. return result;
  4922. };
  4923. /***/ }),
  4924. /* 100 */
  4925. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4926. var has = (__webpack_require__(101).has);
  4927. module.exports = function (it) {
  4928. has(it);
  4929. return it;
  4930. };
  4931. /***/ }),
  4932. /* 101 */
  4933. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4934. var uncurryThis = __webpack_require__(14);
  4935. var SetPrototype = Set.prototype;
  4936. module.exports = {
  4937. Set: Set,
  4938. add: uncurryThis(SetPrototype.add),
  4939. has: uncurryThis(SetPrototype.has),
  4940. remove: uncurryThis(SetPrototype['delete']),
  4941. proto: SetPrototype
  4942. };
  4943. /***/ }),
  4944. /* 102 */
  4945. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4946. var SetHelpers = __webpack_require__(101);
  4947. var iterate = __webpack_require__(103);
  4948. var Set = SetHelpers.Set;
  4949. var add = SetHelpers.add;
  4950. module.exports = function (set) {
  4951. var result = new Set();
  4952. iterate(set, function (it) {
  4953. add(result, it);
  4954. });
  4955. return result;
  4956. };
  4957. /***/ }),
  4958. /* 103 */
  4959. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4960. var uncurryThis = __webpack_require__(14);
  4961. var iterateSimple = __webpack_require__(104);
  4962. var SetHelpers = __webpack_require__(101);
  4963. var Set = SetHelpers.Set;
  4964. var SetPrototype = SetHelpers.proto;
  4965. var forEach = uncurryThis(SetPrototype.forEach);
  4966. var keys = uncurryThis(SetPrototype.keys);
  4967. var next = keys(new Set()).next;
  4968. module.exports = function (set, fn, interruptible) {
  4969. return interruptible ? iterateSimple(keys(set), fn, next) : forEach(set, fn);
  4970. };
  4971. /***/ }),
  4972. /* 104 */
  4973. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4974. var call = __webpack_require__(8);
  4975. module.exports = function (iterator, fn, $next) {
  4976. var next = $next || iterator.next;
  4977. var step, result;
  4978. while (!(step = call(next, iterator)).done) {
  4979. result = fn(step.value);
  4980. if (result !== undefined)
  4981. return result;
  4982. }
  4983. };
  4984. /***/ }),
  4985. /* 105 */
  4986. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4987. var uncurryThisAccessor = __webpack_require__(80);
  4988. var SetHelpers = __webpack_require__(101);
  4989. module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
  4990. return set.size;
  4991. };
  4992. /***/ }),
  4993. /* 106 */
  4994. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4995. var aCallable = __webpack_require__(31);
  4996. var anObject = __webpack_require__(47);
  4997. var call = __webpack_require__(8);
  4998. var toIntegerOrInfinity = __webpack_require__(62);
  4999. var $TypeError = TypeError;
  5000. var max = Math.max;
  5001. var SetRecord = function (set, size, has, keys) {
  5002. this.set = set;
  5003. this.size = size;
  5004. this.has = has;
  5005. this.keys = keys;
  5006. };
  5007. SetRecord.prototype = {
  5008. getIterator: function () {
  5009. return anObject(call(this.keys, this.set));
  5010. },
  5011. includes: function (it) {
  5012. return call(this.has, this.set, it);
  5013. }
  5014. };
  5015. module.exports = function (obj) {
  5016. anObject(obj);
  5017. var numSize = +obj.size;
  5018. if (numSize != numSize)
  5019. throw $TypeError('Invalid size');
  5020. return new SetRecord(obj, max(toIntegerOrInfinity(numSize), 0), aCallable(obj.has), aCallable(obj.keys));
  5021. };
  5022. /***/ }),
  5023. /* 107 */
  5024. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5025. var getBuiltIn = __webpack_require__(24);
  5026. var createEmptySetLike = function () {
  5027. return {
  5028. size: 0,
  5029. has: function () {
  5030. return false;
  5031. },
  5032. keys: function () {
  5033. return {
  5034. next: function () {
  5035. return { done: true };
  5036. }
  5037. };
  5038. }
  5039. };
  5040. };
  5041. module.exports = function (name) {
  5042. try {
  5043. var Set = getBuiltIn('Set');
  5044. new Set()[name](createEmptySetLike());
  5045. return true;
  5046. } catch (error) {
  5047. return false;
  5048. }
  5049. };
  5050. /***/ }),
  5051. /* 108 */
  5052. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5053. var $ = __webpack_require__(3);
  5054. var fails = __webpack_require__(7);
  5055. var intersection = __webpack_require__(109);
  5056. var setMethodAcceptSetLike = __webpack_require__(107);
  5057. var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
  5058. return Array.from(new Set([
  5059. 1,
  5060. 2,
  5061. 3
  5062. ]).intersection(new Set([
  5063. 3,
  5064. 2
  5065. ]))) != '3,2';
  5066. });
  5067. $({
  5068. target: 'Set',
  5069. proto: true,
  5070. real: true,
  5071. forced: INCORRECT
  5072. }, { intersection: intersection });
  5073. /***/ }),
  5074. /* 109 */
  5075. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5076. "use strict";
  5077. var aSet = __webpack_require__(100);
  5078. var SetHelpers = __webpack_require__(101);
  5079. var size = __webpack_require__(105);
  5080. var getSetRecord = __webpack_require__(106);
  5081. var iterateSet = __webpack_require__(103);
  5082. var iterateSimple = __webpack_require__(104);
  5083. var Set = SetHelpers.Set;
  5084. var add = SetHelpers.add;
  5085. var has = SetHelpers.has;
  5086. module.exports = function intersection(other) {
  5087. var O = aSet(this);
  5088. var otherRec = getSetRecord(other);
  5089. var result = new Set();
  5090. if (size(O) > otherRec.size) {
  5091. iterateSimple(otherRec.getIterator(), function (e) {
  5092. if (has(O, e))
  5093. add(result, e);
  5094. });
  5095. } else {
  5096. iterateSet(O, function (e) {
  5097. if (otherRec.includes(e))
  5098. add(result, e);
  5099. });
  5100. }
  5101. return result;
  5102. };
  5103. /***/ }),
  5104. /* 110 */
  5105. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5106. var $ = __webpack_require__(3);
  5107. var isDisjointFrom = __webpack_require__(111);
  5108. var setMethodAcceptSetLike = __webpack_require__(107);
  5109. $({
  5110. target: 'Set',
  5111. proto: true,
  5112. real: true,
  5113. forced: !setMethodAcceptSetLike('isDisjointFrom')
  5114. }, { isDisjointFrom: isDisjointFrom });
  5115. /***/ }),
  5116. /* 111 */
  5117. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5118. "use strict";
  5119. var aSet = __webpack_require__(100);
  5120. var has = (__webpack_require__(101).has);
  5121. var size = __webpack_require__(105);
  5122. var getSetRecord = __webpack_require__(106);
  5123. var iterateSet = __webpack_require__(103);
  5124. var iterateSimple = __webpack_require__(104);
  5125. var iteratorClose = __webpack_require__(112);
  5126. module.exports = function isDisjointFrom(other) {
  5127. var O = aSet(this);
  5128. var otherRec = getSetRecord(other);
  5129. if (size(O) <= otherRec.size)
  5130. return iterateSet(O, function (e) {
  5131. if (otherRec.includes(e))
  5132. return false;
  5133. }, true) !== false;
  5134. var iterator = otherRec.getIterator();
  5135. return iterateSimple(iterator, function (e) {
  5136. if (has(O, e))
  5137. return iteratorClose(iterator, 'normal', false);
  5138. }) !== false;
  5139. };
  5140. /***/ }),
  5141. /* 112 */
  5142. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5143. var call = __webpack_require__(8);
  5144. var anObject = __webpack_require__(47);
  5145. var getMethod = __webpack_require__(30);
  5146. module.exports = function (iterator, kind, value) {
  5147. var innerResult, innerError;
  5148. anObject(iterator);
  5149. try {
  5150. innerResult = getMethod(iterator, 'return');
  5151. if (!innerResult) {
  5152. if (kind === 'throw')
  5153. throw value;
  5154. return value;
  5155. }
  5156. innerResult = call(innerResult, iterator);
  5157. } catch (error) {
  5158. innerError = true;
  5159. innerResult = error;
  5160. }
  5161. if (kind === 'throw')
  5162. throw value;
  5163. if (innerError)
  5164. throw innerResult;
  5165. anObject(innerResult);
  5166. return value;
  5167. };
  5168. /***/ }),
  5169. /* 113 */
  5170. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5171. var $ = __webpack_require__(3);
  5172. var isSubsetOf = __webpack_require__(114);
  5173. var setMethodAcceptSetLike = __webpack_require__(107);
  5174. $({
  5175. target: 'Set',
  5176. proto: true,
  5177. real: true,
  5178. forced: !setMethodAcceptSetLike('isSubsetOf')
  5179. }, { isSubsetOf: isSubsetOf });
  5180. /***/ }),
  5181. /* 114 */
  5182. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5183. "use strict";
  5184. var aSet = __webpack_require__(100);
  5185. var size = __webpack_require__(105);
  5186. var iterate = __webpack_require__(103);
  5187. var getSetRecord = __webpack_require__(106);
  5188. module.exports = function isSubsetOf(other) {
  5189. var O = aSet(this);
  5190. var otherRec = getSetRecord(other);
  5191. if (size(O) > otherRec.size)
  5192. return false;
  5193. return iterate(O, function (e) {
  5194. if (!otherRec.includes(e))
  5195. return false;
  5196. }, true) !== false;
  5197. };
  5198. /***/ }),
  5199. /* 115 */
  5200. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5201. var $ = __webpack_require__(3);
  5202. var isSupersetOf = __webpack_require__(116);
  5203. var setMethodAcceptSetLike = __webpack_require__(107);
  5204. $({
  5205. target: 'Set',
  5206. proto: true,
  5207. real: true,
  5208. forced: !setMethodAcceptSetLike('isSupersetOf')
  5209. }, { isSupersetOf: isSupersetOf });
  5210. /***/ }),
  5211. /* 116 */
  5212. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5213. "use strict";
  5214. var aSet = __webpack_require__(100);
  5215. var has = (__webpack_require__(101).has);
  5216. var size = __webpack_require__(105);
  5217. var getSetRecord = __webpack_require__(106);
  5218. var iterateSimple = __webpack_require__(104);
  5219. var iteratorClose = __webpack_require__(112);
  5220. module.exports = function isSupersetOf(other) {
  5221. var O = aSet(this);
  5222. var otherRec = getSetRecord(other);
  5223. if (size(O) < otherRec.size)
  5224. return false;
  5225. var iterator = otherRec.getIterator();
  5226. return iterateSimple(iterator, function (e) {
  5227. if (!has(O, e))
  5228. return iteratorClose(iterator, 'normal', false);
  5229. }) !== false;
  5230. };
  5231. /***/ }),
  5232. /* 117 */
  5233. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5234. var $ = __webpack_require__(3);
  5235. var symmetricDifference = __webpack_require__(118);
  5236. var setMethodAcceptSetLike = __webpack_require__(107);
  5237. $({
  5238. target: 'Set',
  5239. proto: true,
  5240. real: true,
  5241. forced: !setMethodAcceptSetLike('symmetricDifference')
  5242. }, { symmetricDifference: symmetricDifference });
  5243. /***/ }),
  5244. /* 118 */
  5245. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5246. "use strict";
  5247. var aSet = __webpack_require__(100);
  5248. var SetHelpers = __webpack_require__(101);
  5249. var clone = __webpack_require__(102);
  5250. var getSetRecord = __webpack_require__(106);
  5251. var iterateSimple = __webpack_require__(104);
  5252. var add = SetHelpers.add;
  5253. var has = SetHelpers.has;
  5254. var remove = SetHelpers.remove;
  5255. module.exports = function symmetricDifference(other) {
  5256. var O = aSet(this);
  5257. var keysIter = getSetRecord(other).getIterator();
  5258. var result = clone(O);
  5259. iterateSimple(keysIter, function (e) {
  5260. if (has(O, e))
  5261. remove(result, e);
  5262. else
  5263. add(result, e);
  5264. });
  5265. return result;
  5266. };
  5267. /***/ }),
  5268. /* 119 */
  5269. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5270. var $ = __webpack_require__(3);
  5271. var union = __webpack_require__(120);
  5272. var setMethodAcceptSetLike = __webpack_require__(107);
  5273. $({
  5274. target: 'Set',
  5275. proto: true,
  5276. real: true,
  5277. forced: !setMethodAcceptSetLike('union')
  5278. }, { union: union });
  5279. /***/ }),
  5280. /* 120 */
  5281. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5282. "use strict";
  5283. var aSet = __webpack_require__(100);
  5284. var add = (__webpack_require__(101).add);
  5285. var clone = __webpack_require__(102);
  5286. var getSetRecord = __webpack_require__(106);
  5287. var iterateSimple = __webpack_require__(104);
  5288. module.exports = function union(other) {
  5289. var O = aSet(this);
  5290. var keysIter = getSetRecord(other).getIterator();
  5291. var result = clone(O);
  5292. iterateSimple(keysIter, function (it) {
  5293. add(result, it);
  5294. });
  5295. return result;
  5296. };
  5297. /***/ }),
  5298. /* 121 */
  5299. /***/ ((module) => {
  5300. "use strict";
  5301. module.exports = globalThis.pdfjsLib;
  5302. /***/ }),
  5303. /* 122 */
  5304. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5305. "use strict";
  5306. Object.defineProperty(exports, "__esModule", ({
  5307. value: true
  5308. }));
  5309. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  5310. __webpack_require__(76);
  5311. const compatibilityParams = Object.create(null);
  5312. exports.compatibilityParams = compatibilityParams;
  5313. {
  5314. const userAgent = navigator.userAgent || "";
  5315. const platform = navigator.platform || "";
  5316. const maxTouchPoints = navigator.maxTouchPoints || 1;
  5317. const isAndroid = /Android/.test(userAgent);
  5318. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  5319. (function checkCanvasSizeLimitation() {
  5320. if (isIOS || isAndroid) {
  5321. compatibilityParams.maxCanvasPixels = 5242880;
  5322. }
  5323. })();
  5324. }
  5325. const OptionKind = {
  5326. VIEWER: 0x02,
  5327. API: 0x04,
  5328. WORKER: 0x08,
  5329. PREFERENCE: 0x80
  5330. };
  5331. exports.OptionKind = OptionKind;
  5332. const defaultOptions = {
  5333. annotationEditorMode: {
  5334. value: 0,
  5335. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5336. },
  5337. annotationMode: {
  5338. value: 2,
  5339. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5340. },
  5341. cursorToolOnLoad: {
  5342. value: 0,
  5343. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5344. },
  5345. defaultZoomDelay: {
  5346. value: 400,
  5347. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5348. },
  5349. defaultZoomValue: {
  5350. value: "",
  5351. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5352. },
  5353. disableHistory: {
  5354. value: false,
  5355. kind: OptionKind.VIEWER
  5356. },
  5357. disablePageLabels: {
  5358. value: false,
  5359. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5360. },
  5361. enablePermissions: {
  5362. value: false,
  5363. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5364. },
  5365. enablePrintAutoRotate: {
  5366. value: true,
  5367. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5368. },
  5369. enableScripting: {
  5370. value: true,
  5371. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5372. },
  5373. enableStampEditor: {
  5374. value: true,
  5375. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5376. },
  5377. externalLinkRel: {
  5378. value: "noopener noreferrer nofollow",
  5379. kind: OptionKind.VIEWER
  5380. },
  5381. externalLinkTarget: {
  5382. value: 0,
  5383. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5384. },
  5385. historyUpdateUrl: {
  5386. value: false,
  5387. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5388. },
  5389. ignoreDestinationZoom: {
  5390. value: false,
  5391. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5392. },
  5393. imageResourcesPath: {
  5394. value: "./images/",
  5395. kind: OptionKind.VIEWER
  5396. },
  5397. maxCanvasPixels: {
  5398. value: 16777216,
  5399. kind: OptionKind.VIEWER
  5400. },
  5401. forcePageColors: {
  5402. value: false,
  5403. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5404. },
  5405. pageColorsBackground: {
  5406. value: "Canvas",
  5407. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5408. },
  5409. pageColorsForeground: {
  5410. value: "CanvasText",
  5411. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5412. },
  5413. pdfBugEnabled: {
  5414. value: false,
  5415. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5416. },
  5417. printResolution: {
  5418. value: 150,
  5419. kind: OptionKind.VIEWER
  5420. },
  5421. sidebarViewOnLoad: {
  5422. value: -1,
  5423. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5424. },
  5425. scrollModeOnLoad: {
  5426. value: -1,
  5427. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5428. },
  5429. spreadModeOnLoad: {
  5430. value: -1,
  5431. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5432. },
  5433. textLayerMode: {
  5434. value: 1,
  5435. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5436. },
  5437. viewerCssTheme: {
  5438. value: 0,
  5439. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5440. },
  5441. viewOnLoad: {
  5442. value: 0,
  5443. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5444. },
  5445. cMapPacked: {
  5446. value: true,
  5447. kind: OptionKind.API
  5448. },
  5449. cMapUrl: {
  5450. value: "../web/cmaps/",
  5451. kind: OptionKind.API
  5452. },
  5453. disableAutoFetch: {
  5454. value: false,
  5455. kind: OptionKind.API + OptionKind.PREFERENCE
  5456. },
  5457. disableFontFace: {
  5458. value: false,
  5459. kind: OptionKind.API + OptionKind.PREFERENCE
  5460. },
  5461. disableRange: {
  5462. value: false,
  5463. kind: OptionKind.API + OptionKind.PREFERENCE
  5464. },
  5465. disableStream: {
  5466. value: false,
  5467. kind: OptionKind.API + OptionKind.PREFERENCE
  5468. },
  5469. docBaseUrl: {
  5470. value: "",
  5471. kind: OptionKind.API
  5472. },
  5473. enableXfa: {
  5474. value: true,
  5475. kind: OptionKind.API + OptionKind.PREFERENCE
  5476. },
  5477. fontExtraProperties: {
  5478. value: false,
  5479. kind: OptionKind.API
  5480. },
  5481. isEvalSupported: {
  5482. value: true,
  5483. kind: OptionKind.API
  5484. },
  5485. isOffscreenCanvasSupported: {
  5486. value: true,
  5487. kind: OptionKind.API
  5488. },
  5489. maxImageSize: {
  5490. value: -1,
  5491. kind: OptionKind.API
  5492. },
  5493. pdfBug: {
  5494. value: false,
  5495. kind: OptionKind.API
  5496. },
  5497. standardFontDataUrl: {
  5498. value: "../web/standard_fonts/",
  5499. kind: OptionKind.API
  5500. },
  5501. verbosity: {
  5502. value: 1,
  5503. kind: OptionKind.API
  5504. },
  5505. workerPort: {
  5506. value: null,
  5507. kind: OptionKind.WORKER
  5508. },
  5509. workerSrc: {
  5510. value: "../build/pdf.worker.js",
  5511. kind: OptionKind.WORKER
  5512. }
  5513. };
  5514. {
  5515. defaultOptions.defaultUrl = {
  5516. value: "",
  5517. kind: OptionKind.VIEWER
  5518. };
  5519. defaultOptions.disablePreferences = {
  5520. value: false,
  5521. kind: OptionKind.VIEWER
  5522. };
  5523. defaultOptions.locale = {
  5524. value: navigator.language || "en-US",
  5525. kind: OptionKind.VIEWER
  5526. };
  5527. defaultOptions.sandboxBundleSrc = {
  5528. value: "../build/pdf.sandbox.js",
  5529. kind: OptionKind.VIEWER
  5530. };
  5531. }
  5532. const userOptions = Object.create(null);
  5533. class AppOptions {
  5534. constructor() {
  5535. throw new Error("Cannot initialize AppOptions.");
  5536. }
  5537. static get(name) {
  5538. const userOption = userOptions[name];
  5539. if (userOption !== undefined) {
  5540. return userOption;
  5541. }
  5542. const defaultOption = defaultOptions[name];
  5543. if (defaultOption !== undefined) {
  5544. return compatibilityParams[name] ?? defaultOption.value;
  5545. }
  5546. return undefined;
  5547. }
  5548. static getAll() {
  5549. let kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5550. const options = Object.create(null);
  5551. for (const name in defaultOptions) {
  5552. const defaultOption = defaultOptions[name];
  5553. if (kind) {
  5554. if ((kind & defaultOption.kind) === 0) {
  5555. continue;
  5556. }
  5557. if (kind === OptionKind.PREFERENCE) {
  5558. const value = defaultOption.value,
  5559. valueType = typeof value;
  5560. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  5561. options[name] = value;
  5562. continue;
  5563. }
  5564. throw new Error(`Invalid type for preference: ${name}`);
  5565. }
  5566. }
  5567. const userOption = userOptions[name];
  5568. options[name] = userOption !== undefined ? userOption : compatibilityParams[name] ?? defaultOption.value;
  5569. }
  5570. return options;
  5571. }
  5572. static set(name, value) {
  5573. userOptions[name] = value;
  5574. }
  5575. static setAll(options) {
  5576. for (const name in options) {
  5577. userOptions[name] = options[name];
  5578. }
  5579. }
  5580. static remove(name) {
  5581. delete userOptions[name];
  5582. }
  5583. }
  5584. exports.AppOptions = AppOptions;
  5585. {
  5586. AppOptions._hasUserOptions = function () {
  5587. return Object.keys(userOptions).length > 0;
  5588. };
  5589. }
  5590. /***/ }),
  5591. /* 123 */
  5592. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5593. "use strict";
  5594. Object.defineProperty(exports, "__esModule", ({
  5595. value: true
  5596. }));
  5597. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  5598. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  5599. __webpack_require__(76);
  5600. __webpack_require__(89);
  5601. const WaitOnType = {
  5602. EVENT: "event",
  5603. TIMEOUT: "timeout"
  5604. };
  5605. exports.WaitOnType = WaitOnType;
  5606. function waitOnEventOrTimeout(_ref) {
  5607. let {
  5608. target,
  5609. name,
  5610. delay = 0
  5611. } = _ref;
  5612. return new Promise(function (resolve, reject) {
  5613. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  5614. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  5615. }
  5616. function handler(type) {
  5617. if (target instanceof EventBus) {
  5618. target._off(name, eventHandler);
  5619. } else {
  5620. target.removeEventListener(name, eventHandler);
  5621. }
  5622. if (timeout) {
  5623. clearTimeout(timeout);
  5624. }
  5625. resolve(type);
  5626. }
  5627. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  5628. if (target instanceof EventBus) {
  5629. target._on(name, eventHandler);
  5630. } else {
  5631. target.addEventListener(name, eventHandler);
  5632. }
  5633. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  5634. const timeout = setTimeout(timeoutHandler, delay);
  5635. });
  5636. }
  5637. class EventBus {
  5638. #listeners = Object.create(null);
  5639. on(eventName, listener) {
  5640. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5641. this._on(eventName, listener, {
  5642. external: true,
  5643. once: options?.once
  5644. });
  5645. }
  5646. off(eventName, listener) {
  5647. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5648. this._off(eventName, listener, {
  5649. external: true,
  5650. once: options?.once
  5651. });
  5652. }
  5653. dispatch(eventName, data) {
  5654. const eventListeners = this.#listeners[eventName];
  5655. if (!eventListeners || eventListeners.length === 0) {
  5656. return;
  5657. }
  5658. let externalListeners;
  5659. for (const {
  5660. listener,
  5661. external,
  5662. once
  5663. } of eventListeners.slice(0)) {
  5664. if (once) {
  5665. this._off(eventName, listener);
  5666. }
  5667. if (external) {
  5668. (externalListeners ||= []).push(listener);
  5669. continue;
  5670. }
  5671. listener(data);
  5672. }
  5673. if (externalListeners) {
  5674. for (const listener of externalListeners) {
  5675. listener(data);
  5676. }
  5677. externalListeners = null;
  5678. }
  5679. }
  5680. _on(eventName, listener) {
  5681. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5682. const eventListeners = this.#listeners[eventName] ||= [];
  5683. eventListeners.push({
  5684. listener,
  5685. external: options?.external === true,
  5686. once: options?.once === true
  5687. });
  5688. }
  5689. _off(eventName, listener) {
  5690. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5691. const eventListeners = this.#listeners[eventName];
  5692. if (!eventListeners) {
  5693. return;
  5694. }
  5695. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  5696. if (eventListeners[i].listener === listener) {
  5697. eventListeners.splice(i, 1);
  5698. return;
  5699. }
  5700. }
  5701. }
  5702. }
  5703. exports.EventBus = EventBus;
  5704. class AutomationEventBus extends EventBus {
  5705. dispatch(eventName, data) {
  5706. throw new Error("Not implemented: AutomationEventBus.dispatch");
  5707. }
  5708. }
  5709. exports.AutomationEventBus = AutomationEventBus;
  5710. /***/ }),
  5711. /* 124 */
  5712. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5713. "use strict";
  5714. Object.defineProperty(exports, "__esModule", ({
  5715. value: true
  5716. }));
  5717. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  5718. __webpack_require__(76);
  5719. __webpack_require__(89);
  5720. __webpack_require__(2);
  5721. var _ui_utils = __webpack_require__(97);
  5722. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  5723. const LinkTarget = {
  5724. NONE: 0,
  5725. SELF: 1,
  5726. BLANK: 2,
  5727. PARENT: 3,
  5728. TOP: 4
  5729. };
  5730. exports.LinkTarget = LinkTarget;
  5731. function addLinkAttributes(link) {
  5732. let {
  5733. url,
  5734. target,
  5735. rel,
  5736. enabled = true
  5737. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5738. if (!url || typeof url !== "string") {
  5739. throw new Error('A valid "url" parameter must provided.');
  5740. }
  5741. const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  5742. if (enabled) {
  5743. link.href = link.title = urlNullRemoved;
  5744. } else {
  5745. link.href = "";
  5746. link.title = `Disabled: ${urlNullRemoved}`;
  5747. link.onclick = () => {
  5748. return false;
  5749. };
  5750. }
  5751. let targetStr = "";
  5752. switch (target) {
  5753. case LinkTarget.NONE:
  5754. break;
  5755. case LinkTarget.SELF:
  5756. targetStr = "_self";
  5757. break;
  5758. case LinkTarget.BLANK:
  5759. targetStr = "_blank";
  5760. break;
  5761. case LinkTarget.PARENT:
  5762. targetStr = "_parent";
  5763. break;
  5764. case LinkTarget.TOP:
  5765. targetStr = "_top";
  5766. break;
  5767. }
  5768. link.target = targetStr;
  5769. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  5770. }
  5771. class PDFLinkService {
  5772. #pagesRefCache = new Map();
  5773. constructor() {
  5774. let {
  5775. eventBus,
  5776. externalLinkTarget = null,
  5777. externalLinkRel = null,
  5778. ignoreDestinationZoom = false
  5779. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5780. this.eventBus = eventBus;
  5781. this.externalLinkTarget = externalLinkTarget;
  5782. this.externalLinkRel = externalLinkRel;
  5783. this.externalLinkEnabled = true;
  5784. this._ignoreDestinationZoom = ignoreDestinationZoom;
  5785. this.baseUrl = null;
  5786. this.pdfDocument = null;
  5787. this.pdfViewer = null;
  5788. this.pdfHistory = null;
  5789. }
  5790. setDocument(pdfDocument) {
  5791. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5792. this.baseUrl = baseUrl;
  5793. this.pdfDocument = pdfDocument;
  5794. this.#pagesRefCache.clear();
  5795. }
  5796. setViewer(pdfViewer) {
  5797. this.pdfViewer = pdfViewer;
  5798. }
  5799. setHistory(pdfHistory) {
  5800. this.pdfHistory = pdfHistory;
  5801. }
  5802. get pagesCount() {
  5803. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  5804. }
  5805. get page() {
  5806. return this.pdfViewer.currentPageNumber;
  5807. }
  5808. set page(value) {
  5809. this.pdfViewer.currentPageNumber = value;
  5810. }
  5811. get rotation() {
  5812. return this.pdfViewer.pagesRotation;
  5813. }
  5814. set rotation(value) {
  5815. this.pdfViewer.pagesRotation = value;
  5816. }
  5817. get isInPresentationMode() {
  5818. return this.pdfViewer.isInPresentationMode;
  5819. }
  5820. #goToDestinationHelper(rawDest) {
  5821. let namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5822. let explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  5823. const destRef = explicitDest[0];
  5824. let pageNumber;
  5825. if (typeof destRef === "object" && destRef !== null) {
  5826. pageNumber = this._cachedPageNumber(destRef);
  5827. if (!pageNumber) {
  5828. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  5829. this.cachePageRef(pageIndex + 1, destRef);
  5830. this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
  5831. }).catch(() => {
  5832. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
  5833. });
  5834. return;
  5835. }
  5836. } else if (Number.isInteger(destRef)) {
  5837. pageNumber = destRef + 1;
  5838. } else {
  5839. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
  5840. return;
  5841. }
  5842. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  5843. console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
  5844. return;
  5845. }
  5846. if (this.pdfHistory) {
  5847. this.pdfHistory.pushCurrentPosition();
  5848. this.pdfHistory.push({
  5849. namedDest,
  5850. explicitDest,
  5851. pageNumber
  5852. });
  5853. }
  5854. this.pdfViewer.scrollPageIntoView({
  5855. pageNumber,
  5856. destArray: explicitDest,
  5857. ignoreDestinationZoom: this._ignoreDestinationZoom
  5858. });
  5859. }
  5860. async goToDestination(dest) {
  5861. if (!this.pdfDocument) {
  5862. return;
  5863. }
  5864. let namedDest, explicitDest;
  5865. if (typeof dest === "string") {
  5866. namedDest = dest;
  5867. explicitDest = await this.pdfDocument.getDestination(dest);
  5868. } else {
  5869. namedDest = null;
  5870. explicitDest = await dest;
  5871. }
  5872. if (!Array.isArray(explicitDest)) {
  5873. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
  5874. return;
  5875. }
  5876. this.#goToDestinationHelper(dest, namedDest, explicitDest);
  5877. }
  5878. goToPage(val) {
  5879. if (!this.pdfDocument) {
  5880. return;
  5881. }
  5882. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  5883. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  5884. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  5885. return;
  5886. }
  5887. if (this.pdfHistory) {
  5888. this.pdfHistory.pushCurrentPosition();
  5889. this.pdfHistory.pushPage(pageNumber);
  5890. }
  5891. this.pdfViewer.scrollPageIntoView({
  5892. pageNumber
  5893. });
  5894. }
  5895. addLinkAttributes(link, url) {
  5896. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5897. addLinkAttributes(link, {
  5898. url,
  5899. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  5900. rel: this.externalLinkRel,
  5901. enabled: this.externalLinkEnabled
  5902. });
  5903. }
  5904. getDestinationHash(dest) {
  5905. if (typeof dest === "string") {
  5906. if (dest.length > 0) {
  5907. return this.getAnchorUrl("#" + escape(dest));
  5908. }
  5909. } else if (Array.isArray(dest)) {
  5910. const str = JSON.stringify(dest);
  5911. if (str.length > 0) {
  5912. return this.getAnchorUrl("#" + escape(str));
  5913. }
  5914. }
  5915. return this.getAnchorUrl("");
  5916. }
  5917. getAnchorUrl(anchor) {
  5918. return this.baseUrl ? this.baseUrl + anchor : anchor;
  5919. }
  5920. setHash(hash) {
  5921. if (!this.pdfDocument) {
  5922. return;
  5923. }
  5924. let pageNumber, dest;
  5925. if (hash.includes("=")) {
  5926. const params = (0, _ui_utils.parseQueryString)(hash);
  5927. if (params.has("search")) {
  5928. const query = params.get("search").replaceAll('"', ""),
  5929. phrase = params.get("phrase") === "true";
  5930. this.eventBus.dispatch("findfromurlhash", {
  5931. source: this,
  5932. query: phrase ? query : query.match(/\S+/g)
  5933. });
  5934. }
  5935. if (params.has("page")) {
  5936. pageNumber = params.get("page") | 0 || 1;
  5937. }
  5938. if (params.has("zoom")) {
  5939. const zoomArgs = params.get("zoom").split(",");
  5940. const zoomArg = zoomArgs[0];
  5941. const zoomArgNumber = parseFloat(zoomArg);
  5942. if (!zoomArg.includes("Fit")) {
  5943. dest = [null, {
  5944. name: "XYZ"
  5945. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  5946. } else if (zoomArg === "Fit" || zoomArg === "FitB") {
  5947. dest = [null, {
  5948. name: zoomArg
  5949. }];
  5950. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  5951. dest = [null, {
  5952. name: zoomArg
  5953. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  5954. } else if (zoomArg === "FitR") {
  5955. if (zoomArgs.length !== 5) {
  5956. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  5957. } else {
  5958. dest = [null, {
  5959. name: zoomArg
  5960. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  5961. }
  5962. } else {
  5963. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  5964. }
  5965. }
  5966. if (dest) {
  5967. this.pdfViewer.scrollPageIntoView({
  5968. pageNumber: pageNumber || this.page,
  5969. destArray: dest,
  5970. allowNegativeOffset: true
  5971. });
  5972. } else if (pageNumber) {
  5973. this.page = pageNumber;
  5974. }
  5975. if (params.has("pagemode")) {
  5976. this.eventBus.dispatch("pagemode", {
  5977. source: this,
  5978. mode: params.get("pagemode")
  5979. });
  5980. }
  5981. if (params.has("nameddest")) {
  5982. this.goToDestination(params.get("nameddest"));
  5983. }
  5984. } else {
  5985. dest = unescape(hash);
  5986. try {
  5987. dest = JSON.parse(dest);
  5988. if (!Array.isArray(dest)) {
  5989. dest = dest.toString();
  5990. }
  5991. } catch {}
  5992. if (typeof dest === "string" || PDFLinkService.#isValidExplicitDestination(dest)) {
  5993. this.goToDestination(dest);
  5994. return;
  5995. }
  5996. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  5997. }
  5998. }
  5999. executeNamedAction(action) {
  6000. switch (action) {
  6001. case "GoBack":
  6002. this.pdfHistory?.back();
  6003. break;
  6004. case "GoForward":
  6005. this.pdfHistory?.forward();
  6006. break;
  6007. case "NextPage":
  6008. this.pdfViewer.nextPage();
  6009. break;
  6010. case "PrevPage":
  6011. this.pdfViewer.previousPage();
  6012. break;
  6013. case "LastPage":
  6014. this.page = this.pagesCount;
  6015. break;
  6016. case "FirstPage":
  6017. this.page = 1;
  6018. break;
  6019. default:
  6020. break;
  6021. }
  6022. this.eventBus.dispatch("namedaction", {
  6023. source: this,
  6024. action
  6025. });
  6026. }
  6027. async executeSetOCGState(action) {
  6028. const pdfDocument = this.pdfDocument;
  6029. const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  6030. if (pdfDocument !== this.pdfDocument) {
  6031. return;
  6032. }
  6033. let operator;
  6034. for (const elem of action.state) {
  6035. switch (elem) {
  6036. case "ON":
  6037. case "OFF":
  6038. case "Toggle":
  6039. operator = elem;
  6040. continue;
  6041. }
  6042. switch (operator) {
  6043. case "ON":
  6044. optionalContentConfig.setVisibility(elem, true);
  6045. break;
  6046. case "OFF":
  6047. optionalContentConfig.setVisibility(elem, false);
  6048. break;
  6049. case "Toggle":
  6050. const group = optionalContentConfig.getGroup(elem);
  6051. if (group) {
  6052. optionalContentConfig.setVisibility(elem, !group.visible);
  6053. }
  6054. break;
  6055. }
  6056. }
  6057. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  6058. }
  6059. cachePageRef(pageNum, pageRef) {
  6060. if (!pageRef) {
  6061. return;
  6062. }
  6063. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  6064. this.#pagesRefCache.set(refStr, pageNum);
  6065. }
  6066. _cachedPageNumber(pageRef) {
  6067. if (!pageRef) {
  6068. return null;
  6069. }
  6070. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  6071. return this.#pagesRefCache.get(refStr) || null;
  6072. }
  6073. static #isValidExplicitDestination(dest) {
  6074. if (!Array.isArray(dest)) {
  6075. return false;
  6076. }
  6077. const destLength = dest.length;
  6078. if (destLength < 2) {
  6079. return false;
  6080. }
  6081. const page = dest[0];
  6082. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6083. return false;
  6084. }
  6085. const zoom = dest[1];
  6086. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  6087. return false;
  6088. }
  6089. let allowNull = true;
  6090. switch (zoom.name) {
  6091. case "XYZ":
  6092. if (destLength !== 5) {
  6093. return false;
  6094. }
  6095. break;
  6096. case "Fit":
  6097. case "FitB":
  6098. return destLength === 2;
  6099. case "FitH":
  6100. case "FitBH":
  6101. case "FitV":
  6102. case "FitBV":
  6103. if (destLength !== 3) {
  6104. return false;
  6105. }
  6106. break;
  6107. case "FitR":
  6108. if (destLength !== 6) {
  6109. return false;
  6110. }
  6111. allowNull = false;
  6112. break;
  6113. default:
  6114. return false;
  6115. }
  6116. for (let i = 2; i < destLength; i++) {
  6117. const param = dest[i];
  6118. if (!(typeof param === "number" || allowNull && param === null)) {
  6119. return false;
  6120. }
  6121. }
  6122. return true;
  6123. }
  6124. }
  6125. exports.PDFLinkService = PDFLinkService;
  6126. class SimpleLinkService {
  6127. constructor() {
  6128. this.externalLinkEnabled = true;
  6129. }
  6130. get pagesCount() {
  6131. return 0;
  6132. }
  6133. get page() {
  6134. return 0;
  6135. }
  6136. set page(value) {}
  6137. get rotation() {
  6138. return 0;
  6139. }
  6140. set rotation(value) {}
  6141. get isInPresentationMode() {
  6142. return false;
  6143. }
  6144. async goToDestination(dest) {}
  6145. goToPage(val) {}
  6146. addLinkAttributes(link, url) {
  6147. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6148. addLinkAttributes(link, {
  6149. url,
  6150. enabled: this.externalLinkEnabled
  6151. });
  6152. }
  6153. getDestinationHash(dest) {
  6154. return "#";
  6155. }
  6156. getAnchorUrl(hash) {
  6157. return "#";
  6158. }
  6159. setHash(hash) {}
  6160. executeNamedAction(action) {}
  6161. executeSetOCGState(action) {}
  6162. cachePageRef(pageNum, pageRef) {}
  6163. }
  6164. exports.SimpleLinkService = SimpleLinkService;
  6165. /***/ }),
  6166. /* 125 */
  6167. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6168. "use strict";
  6169. Object.defineProperty(exports, "__esModule", ({
  6170. value: true
  6171. }));
  6172. exports.AnnotationEditorParams = void 0;
  6173. var _pdfjsLib = __webpack_require__(121);
  6174. class AnnotationEditorParams {
  6175. constructor(options, eventBus) {
  6176. this.eventBus = eventBus;
  6177. this.#bindListeners(options);
  6178. }
  6179. #bindListeners(_ref) {
  6180. let {
  6181. editorFreeTextFontSize,
  6182. editorFreeTextColor,
  6183. editorInkColor,
  6184. editorInkThickness,
  6185. editorInkOpacity
  6186. } = _ref;
  6187. const dispatchEvent = (typeStr, value) => {
  6188. this.eventBus.dispatch("switchannotationeditorparams", {
  6189. source: this,
  6190. type: _pdfjsLib.AnnotationEditorParamsType[typeStr],
  6191. value
  6192. });
  6193. };
  6194. editorFreeTextFontSize.addEventListener("input", function () {
  6195. dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
  6196. });
  6197. editorFreeTextColor.addEventListener("input", function () {
  6198. dispatchEvent("FREETEXT_COLOR", this.value);
  6199. });
  6200. editorInkColor.addEventListener("input", function () {
  6201. dispatchEvent("INK_COLOR", this.value);
  6202. });
  6203. editorInkThickness.addEventListener("input", function () {
  6204. dispatchEvent("INK_THICKNESS", this.valueAsNumber);
  6205. });
  6206. editorInkOpacity.addEventListener("input", function () {
  6207. dispatchEvent("INK_OPACITY", this.valueAsNumber);
  6208. });
  6209. this.eventBus._on("annotationeditorparamschanged", evt => {
  6210. for (const [type, value] of evt.details) {
  6211. switch (type) {
  6212. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE:
  6213. editorFreeTextFontSize.value = value;
  6214. break;
  6215. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR:
  6216. editorFreeTextColor.value = value;
  6217. break;
  6218. case _pdfjsLib.AnnotationEditorParamsType.INK_COLOR:
  6219. editorInkColor.value = value;
  6220. break;
  6221. case _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS:
  6222. editorInkThickness.value = value;
  6223. break;
  6224. case _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY:
  6225. editorInkOpacity.value = value;
  6226. break;
  6227. }
  6228. }
  6229. });
  6230. }
  6231. }
  6232. exports.AnnotationEditorParams = AnnotationEditorParams;
  6233. /***/ }),
  6234. /* 126 */
  6235. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6236. "use strict";
  6237. Object.defineProperty(exports, "__esModule", ({
  6238. value: true
  6239. }));
  6240. exports.OverlayManager = void 0;
  6241. __webpack_require__(76);
  6242. class OverlayManager {
  6243. #overlays = new WeakMap();
  6244. #active = null;
  6245. get active() {
  6246. return this.#active;
  6247. }
  6248. async register(dialog) {
  6249. let canForceClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6250. if (typeof dialog !== "object") {
  6251. throw new Error("Not enough parameters.");
  6252. } else if (this.#overlays.has(dialog)) {
  6253. throw new Error("The overlay is already registered.");
  6254. }
  6255. this.#overlays.set(dialog, {
  6256. canForceClose
  6257. });
  6258. dialog.addEventListener("cancel", evt => {
  6259. this.#active = null;
  6260. });
  6261. }
  6262. async open(dialog) {
  6263. if (!this.#overlays.has(dialog)) {
  6264. throw new Error("The overlay does not exist.");
  6265. } else if (this.#active) {
  6266. if (this.#active === dialog) {
  6267. throw new Error("The overlay is already active.");
  6268. } else if (this.#overlays.get(dialog).canForceClose) {
  6269. await this.close();
  6270. } else {
  6271. throw new Error("Another overlay is currently active.");
  6272. }
  6273. }
  6274. this.#active = dialog;
  6275. dialog.showModal();
  6276. }
  6277. async close() {
  6278. let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.#active;
  6279. if (!this.#overlays.has(dialog)) {
  6280. throw new Error("The overlay does not exist.");
  6281. } else if (!this.#active) {
  6282. throw new Error("The overlay is currently not active.");
  6283. } else if (this.#active !== dialog) {
  6284. throw new Error("Another overlay is currently active.");
  6285. }
  6286. dialog.close();
  6287. this.#active = null;
  6288. }
  6289. }
  6290. exports.OverlayManager = OverlayManager;
  6291. /***/ }),
  6292. /* 127 */
  6293. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6294. "use strict";
  6295. Object.defineProperty(exports, "__esModule", ({
  6296. value: true
  6297. }));
  6298. exports.PasswordPrompt = void 0;
  6299. __webpack_require__(76);
  6300. var _pdfjsLib = __webpack_require__(121);
  6301. class PasswordPrompt {
  6302. #activeCapability = null;
  6303. #updateCallback = null;
  6304. #reason = null;
  6305. constructor(options, overlayManager, l10n) {
  6306. let isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6307. this.dialog = options.dialog;
  6308. this.label = options.label;
  6309. this.input = options.input;
  6310. this.submitButton = options.submitButton;
  6311. this.cancelButton = options.cancelButton;
  6312. this.overlayManager = overlayManager;
  6313. this.l10n = l10n;
  6314. this._isViewerEmbedded = isViewerEmbedded;
  6315. this.submitButton.addEventListener("click", this.#verify.bind(this));
  6316. this.cancelButton.addEventListener("click", this.close.bind(this));
  6317. this.input.addEventListener("keydown", e => {
  6318. if (e.keyCode === 13) {
  6319. this.#verify();
  6320. }
  6321. });
  6322. this.overlayManager.register(this.dialog, true);
  6323. this.dialog.addEventListener("close", this.#cancel.bind(this));
  6324. }
  6325. async open() {
  6326. if (this.#activeCapability) {
  6327. await this.#activeCapability.promise;
  6328. }
  6329. this.#activeCapability = new _pdfjsLib.PromiseCapability();
  6330. try {
  6331. await this.overlayManager.open(this.dialog);
  6332. } catch (ex) {
  6333. this.#activeCapability.resolve();
  6334. throw ex;
  6335. }
  6336. const passwordIncorrect = this.#reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
  6337. if (!this._isViewerEmbedded || passwordIncorrect) {
  6338. this.input.focus();
  6339. }
  6340. this.label.textContent = await this.l10n.get(`password_${passwordIncorrect ? "invalid" : "label"}`);
  6341. }
  6342. async close() {
  6343. if (this.overlayManager.active === this.dialog) {
  6344. this.overlayManager.close(this.dialog);
  6345. }
  6346. }
  6347. #verify() {
  6348. const password = this.input.value;
  6349. if (password?.length > 0) {
  6350. this.#invokeCallback(password);
  6351. }
  6352. }
  6353. #cancel() {
  6354. this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  6355. this.#activeCapability.resolve();
  6356. }
  6357. #invokeCallback(password) {
  6358. if (!this.#updateCallback) {
  6359. return;
  6360. }
  6361. this.close();
  6362. this.input.value = "";
  6363. this.#updateCallback(password);
  6364. this.#updateCallback = null;
  6365. }
  6366. async setUpdateCallback(updateCallback, reason) {
  6367. if (this.#activeCapability) {
  6368. await this.#activeCapability.promise;
  6369. }
  6370. this.#updateCallback = updateCallback;
  6371. this.#reason = reason;
  6372. }
  6373. }
  6374. exports.PasswordPrompt = PasswordPrompt;
  6375. /***/ }),
  6376. /* 128 */
  6377. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6378. "use strict";
  6379. Object.defineProperty(exports, "__esModule", ({
  6380. value: true
  6381. }));
  6382. exports.PDFAttachmentViewer = void 0;
  6383. var _pdfjsLib = __webpack_require__(121);
  6384. var _base_tree_viewer = __webpack_require__(129);
  6385. var _event_utils = __webpack_require__(123);
  6386. class PDFAttachmentViewer extends _base_tree_viewer.BaseTreeViewer {
  6387. constructor(options) {
  6388. super(options);
  6389. this.downloadManager = options.downloadManager;
  6390. this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
  6391. }
  6392. reset() {
  6393. let keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6394. super.reset();
  6395. this._attachments = null;
  6396. if (!keepRenderedCapability) {
  6397. this._renderedCapability = new _pdfjsLib.PromiseCapability();
  6398. }
  6399. this._pendingDispatchEvent = false;
  6400. }
  6401. async _dispatchEvent(attachmentsCount) {
  6402. this._renderedCapability.resolve();
  6403. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  6404. this._pendingDispatchEvent = true;
  6405. await (0, _event_utils.waitOnEventOrTimeout)({
  6406. target: this.eventBus,
  6407. name: "annotationlayerrendered",
  6408. delay: 1000
  6409. });
  6410. if (!this._pendingDispatchEvent) {
  6411. return;
  6412. }
  6413. }
  6414. this._pendingDispatchEvent = false;
  6415. this.eventBus.dispatch("attachmentsloaded", {
  6416. source: this,
  6417. attachmentsCount
  6418. });
  6419. }
  6420. _bindLink(element, _ref) {
  6421. let {
  6422. content,
  6423. filename
  6424. } = _ref;
  6425. element.onclick = () => {
  6426. this.downloadManager.openOrDownloadData(element, content, filename);
  6427. return false;
  6428. };
  6429. }
  6430. render(_ref2) {
  6431. let {
  6432. attachments,
  6433. keepRenderedCapability = false
  6434. } = _ref2;
  6435. if (this._attachments) {
  6436. this.reset(keepRenderedCapability);
  6437. }
  6438. this._attachments = attachments || null;
  6439. if (!attachments) {
  6440. this._dispatchEvent(0);
  6441. return;
  6442. }
  6443. const fragment = document.createDocumentFragment();
  6444. let attachmentsCount = 0;
  6445. for (const name in attachments) {
  6446. const item = attachments[name];
  6447. const content = item.content,
  6448. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename, true);
  6449. const div = document.createElement("div");
  6450. div.className = "treeItem";
  6451. const element = document.createElement("a");
  6452. this._bindLink(element, {
  6453. content,
  6454. filename
  6455. });
  6456. element.textContent = this._normalizeTextContent(filename);
  6457. div.append(element);
  6458. fragment.append(div);
  6459. attachmentsCount++;
  6460. }
  6461. this._finishRendering(fragment, attachmentsCount);
  6462. }
  6463. #appendAttachment(_ref3) {
  6464. let {
  6465. filename,
  6466. content
  6467. } = _ref3;
  6468. const renderedPromise = this._renderedCapability.promise;
  6469. renderedPromise.then(() => {
  6470. if (renderedPromise !== this._renderedCapability.promise) {
  6471. return;
  6472. }
  6473. const attachments = this._attachments || Object.create(null);
  6474. for (const name in attachments) {
  6475. if (filename === name) {
  6476. return;
  6477. }
  6478. }
  6479. attachments[filename] = {
  6480. filename,
  6481. content
  6482. };
  6483. this.render({
  6484. attachments,
  6485. keepRenderedCapability: true
  6486. });
  6487. });
  6488. }
  6489. }
  6490. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  6491. /***/ }),
  6492. /* 129 */
  6493. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6494. "use strict";
  6495. Object.defineProperty(exports, "__esModule", ({
  6496. value: true
  6497. }));
  6498. exports.BaseTreeViewer = void 0;
  6499. __webpack_require__(76);
  6500. var _ui_utils = __webpack_require__(97);
  6501. const TREEITEM_OFFSET_TOP = -100;
  6502. const TREEITEM_SELECTED_CLASS = "selected";
  6503. class BaseTreeViewer {
  6504. constructor(options) {
  6505. if (this.constructor === BaseTreeViewer) {
  6506. throw new Error("Cannot initialize BaseTreeViewer.");
  6507. }
  6508. this.container = options.container;
  6509. this.eventBus = options.eventBus;
  6510. this.reset();
  6511. }
  6512. reset() {
  6513. this._pdfDocument = null;
  6514. this._lastToggleIsShow = true;
  6515. this._currentTreeItem = null;
  6516. this.container.textContent = "";
  6517. this.container.classList.remove("treeWithDeepNesting");
  6518. }
  6519. _dispatchEvent(count) {
  6520. throw new Error("Not implemented: _dispatchEvent");
  6521. }
  6522. _bindLink(element, params) {
  6523. throw new Error("Not implemented: _bindLink");
  6524. }
  6525. _normalizeTextContent(str) {
  6526. return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013";
  6527. }
  6528. _addToggleButton(div) {
  6529. let hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6530. const toggler = document.createElement("div");
  6531. toggler.className = "treeItemToggler";
  6532. if (hidden) {
  6533. toggler.classList.add("treeItemsHidden");
  6534. }
  6535. toggler.onclick = evt => {
  6536. evt.stopPropagation();
  6537. toggler.classList.toggle("treeItemsHidden");
  6538. if (evt.shiftKey) {
  6539. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  6540. this._toggleTreeItem(div, shouldShowAll);
  6541. }
  6542. };
  6543. div.prepend(toggler);
  6544. }
  6545. _toggleTreeItem(root) {
  6546. let show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6547. this._lastToggleIsShow = show;
  6548. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  6549. toggler.classList.toggle("treeItemsHidden", !show);
  6550. }
  6551. }
  6552. _toggleAllTreeItems() {
  6553. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  6554. }
  6555. _finishRendering(fragment, count) {
  6556. let hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6557. if (hasAnyNesting) {
  6558. this.container.classList.add("treeWithDeepNesting");
  6559. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  6560. }
  6561. this.container.append(fragment);
  6562. this._dispatchEvent(count);
  6563. }
  6564. render(params) {
  6565. throw new Error("Not implemented: render");
  6566. }
  6567. _updateCurrentTreeItem() {
  6568. let treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6569. if (this._currentTreeItem) {
  6570. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  6571. this._currentTreeItem = null;
  6572. }
  6573. if (treeItem) {
  6574. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  6575. this._currentTreeItem = treeItem;
  6576. }
  6577. }
  6578. _scrollToCurrentTreeItem(treeItem) {
  6579. if (!treeItem) {
  6580. return;
  6581. }
  6582. let currentNode = treeItem.parentNode;
  6583. while (currentNode && currentNode !== this.container) {
  6584. if (currentNode.classList.contains("treeItem")) {
  6585. const toggler = currentNode.firstElementChild;
  6586. toggler?.classList.remove("treeItemsHidden");
  6587. }
  6588. currentNode = currentNode.parentNode;
  6589. }
  6590. this._updateCurrentTreeItem(treeItem);
  6591. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  6592. }
  6593. }
  6594. exports.BaseTreeViewer = BaseTreeViewer;
  6595. /***/ }),
  6596. /* 130 */
  6597. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6598. "use strict";
  6599. Object.defineProperty(exports, "__esModule", ({
  6600. value: true
  6601. }));
  6602. exports.PDFCursorTools = void 0;
  6603. var _pdfjsLib = __webpack_require__(121);
  6604. var _ui_utils = __webpack_require__(97);
  6605. var _grab_to_pan = __webpack_require__(131);
  6606. class PDFCursorTools {
  6607. #active = _ui_utils.CursorTool.SELECT;
  6608. #prevActive = null;
  6609. constructor(_ref) {
  6610. let {
  6611. container,
  6612. eventBus,
  6613. cursorToolOnLoad = _ui_utils.CursorTool.SELECT
  6614. } = _ref;
  6615. this.container = container;
  6616. this.eventBus = eventBus;
  6617. this.#addEventListeners();
  6618. Promise.resolve().then(() => {
  6619. this.switchTool(cursorToolOnLoad);
  6620. });
  6621. }
  6622. get activeTool() {
  6623. return this.#active;
  6624. }
  6625. switchTool(tool) {
  6626. if (this.#prevActive !== null) {
  6627. return;
  6628. }
  6629. if (tool === this.#active) {
  6630. return;
  6631. }
  6632. const disableActiveTool = () => {
  6633. switch (this.#active) {
  6634. case _ui_utils.CursorTool.SELECT:
  6635. break;
  6636. case _ui_utils.CursorTool.HAND:
  6637. this._handTool.deactivate();
  6638. break;
  6639. case _ui_utils.CursorTool.ZOOM:
  6640. }
  6641. };
  6642. switch (tool) {
  6643. case _ui_utils.CursorTool.SELECT:
  6644. disableActiveTool();
  6645. break;
  6646. case _ui_utils.CursorTool.HAND:
  6647. disableActiveTool();
  6648. this._handTool.activate();
  6649. break;
  6650. case _ui_utils.CursorTool.ZOOM:
  6651. default:
  6652. console.error(`switchTool: "${tool}" is an unsupported value.`);
  6653. return;
  6654. }
  6655. this.#active = tool;
  6656. this.eventBus.dispatch("cursortoolchanged", {
  6657. source: this,
  6658. tool
  6659. });
  6660. }
  6661. #addEventListeners() {
  6662. this.eventBus._on("switchcursortool", evt => {
  6663. this.switchTool(evt.tool);
  6664. });
  6665. let annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE,
  6666. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  6667. const disableActive = () => {
  6668. const prevActive = this.#active;
  6669. this.switchTool(_ui_utils.CursorTool.SELECT);
  6670. this.#prevActive ??= prevActive;
  6671. };
  6672. const enableActive = () => {
  6673. const prevActive = this.#prevActive;
  6674. if (prevActive !== null && annotationEditorMode === _pdfjsLib.AnnotationEditorType.NONE && presentationModeState === _ui_utils.PresentationModeState.NORMAL) {
  6675. this.#prevActive = null;
  6676. this.switchTool(prevActive);
  6677. }
  6678. };
  6679. this.eventBus._on("secondarytoolbarreset", evt => {
  6680. if (this.#prevActive !== null) {
  6681. annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  6682. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  6683. enableActive();
  6684. }
  6685. });
  6686. this.eventBus._on("annotationeditormodechanged", _ref2 => {
  6687. let {
  6688. mode
  6689. } = _ref2;
  6690. annotationEditorMode = mode;
  6691. if (mode === _pdfjsLib.AnnotationEditorType.NONE) {
  6692. enableActive();
  6693. } else {
  6694. disableActive();
  6695. }
  6696. });
  6697. this.eventBus._on("presentationmodechanged", _ref3 => {
  6698. let {
  6699. state
  6700. } = _ref3;
  6701. presentationModeState = state;
  6702. if (state === _ui_utils.PresentationModeState.NORMAL) {
  6703. enableActive();
  6704. } else if (state === _ui_utils.PresentationModeState.FULLSCREEN) {
  6705. disableActive();
  6706. }
  6707. });
  6708. }
  6709. get _handTool() {
  6710. return (0, _pdfjsLib.shadow)(this, "_handTool", new _grab_to_pan.GrabToPan({
  6711. element: this.container
  6712. }));
  6713. }
  6714. }
  6715. exports.PDFCursorTools = PDFCursorTools;
  6716. /***/ }),
  6717. /* 131 */
  6718. /***/ ((__unused_webpack_module, exports) => {
  6719. "use strict";
  6720. Object.defineProperty(exports, "__esModule", ({
  6721. value: true
  6722. }));
  6723. exports.GrabToPan = void 0;
  6724. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  6725. class GrabToPan {
  6726. constructor(_ref) {
  6727. let {
  6728. element
  6729. } = _ref;
  6730. this.element = element;
  6731. this.document = element.ownerDocument;
  6732. this.activate = this.activate.bind(this);
  6733. this.deactivate = this.deactivate.bind(this);
  6734. this.toggle = this.toggle.bind(this);
  6735. this._onMouseDown = this.#onMouseDown.bind(this);
  6736. this._onMouseMove = this.#onMouseMove.bind(this);
  6737. this._endPan = this.#endPan.bind(this);
  6738. const overlay = this.overlay = document.createElement("div");
  6739. overlay.className = "grab-to-pan-grabbing";
  6740. }
  6741. activate() {
  6742. if (!this.active) {
  6743. this.active = true;
  6744. this.element.addEventListener("mousedown", this._onMouseDown, true);
  6745. this.element.classList.add(CSS_CLASS_GRAB);
  6746. }
  6747. }
  6748. deactivate() {
  6749. if (this.active) {
  6750. this.active = false;
  6751. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  6752. this._endPan();
  6753. this.element.classList.remove(CSS_CLASS_GRAB);
  6754. }
  6755. }
  6756. toggle() {
  6757. if (this.active) {
  6758. this.deactivate();
  6759. } else {
  6760. this.activate();
  6761. }
  6762. }
  6763. ignoreTarget(node) {
  6764. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  6765. }
  6766. #onMouseDown(event) {
  6767. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  6768. return;
  6769. }
  6770. if (event.originalTarget) {
  6771. try {
  6772. event.originalTarget.tagName;
  6773. } catch {
  6774. return;
  6775. }
  6776. }
  6777. this.scrollLeftStart = this.element.scrollLeft;
  6778. this.scrollTopStart = this.element.scrollTop;
  6779. this.clientXStart = event.clientX;
  6780. this.clientYStart = event.clientY;
  6781. this.document.addEventListener("mousemove", this._onMouseMove, true);
  6782. this.document.addEventListener("mouseup", this._endPan, true);
  6783. this.element.addEventListener("scroll", this._endPan, true);
  6784. event.preventDefault();
  6785. event.stopPropagation();
  6786. const focusedElement = document.activeElement;
  6787. if (focusedElement && !focusedElement.contains(event.target)) {
  6788. focusedElement.blur();
  6789. }
  6790. }
  6791. #onMouseMove(event) {
  6792. this.element.removeEventListener("scroll", this._endPan, true);
  6793. if (!(event.buttons & 1)) {
  6794. this._endPan();
  6795. return;
  6796. }
  6797. const xDiff = event.clientX - this.clientXStart;
  6798. const yDiff = event.clientY - this.clientYStart;
  6799. this.element.scrollTo({
  6800. top: this.scrollTopStart - yDiff,
  6801. left: this.scrollLeftStart - xDiff,
  6802. behavior: "instant"
  6803. });
  6804. if (!this.overlay.parentNode) {
  6805. document.body.append(this.overlay);
  6806. }
  6807. }
  6808. #endPan() {
  6809. this.element.removeEventListener("scroll", this._endPan, true);
  6810. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  6811. this.document.removeEventListener("mouseup", this._endPan, true);
  6812. this.overlay.remove();
  6813. }
  6814. }
  6815. exports.GrabToPan = GrabToPan;
  6816. /***/ }),
  6817. /* 132 */
  6818. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6819. "use strict";
  6820. Object.defineProperty(exports, "__esModule", ({
  6821. value: true
  6822. }));
  6823. exports.PDFDocumentProperties = void 0;
  6824. var _ui_utils = __webpack_require__(97);
  6825. var _pdfjsLib = __webpack_require__(121);
  6826. const DEFAULT_FIELD_CONTENT = "-";
  6827. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  6828. const US_PAGE_NAMES = {
  6829. "8.5x11": "Letter",
  6830. "8.5x14": "Legal"
  6831. };
  6832. const METRIC_PAGE_NAMES = {
  6833. "297x420": "A3",
  6834. "210x297": "A4"
  6835. };
  6836. function getPageName(size, isPortrait, pageNames) {
  6837. const width = isPortrait ? size.width : size.height;
  6838. const height = isPortrait ? size.height : size.width;
  6839. return pageNames[`${width}x${height}`];
  6840. }
  6841. class PDFDocumentProperties {
  6842. #fieldData = null;
  6843. constructor(_ref, overlayManager, eventBus, l10n, fileNameLookup) {
  6844. let {
  6845. dialog,
  6846. fields,
  6847. closeButton
  6848. } = _ref;
  6849. this.dialog = dialog;
  6850. this.fields = fields;
  6851. this.overlayManager = overlayManager;
  6852. this.l10n = l10n;
  6853. this._fileNameLookup = fileNameLookup;
  6854. this.#reset();
  6855. closeButton.addEventListener("click", this.close.bind(this));
  6856. this.overlayManager.register(this.dialog);
  6857. eventBus._on("pagechanging", evt => {
  6858. this._currentPageNumber = evt.pageNumber;
  6859. });
  6860. eventBus._on("rotationchanging", evt => {
  6861. this._pagesRotation = evt.pagesRotation;
  6862. });
  6863. this._isNonMetricLocale = true;
  6864. l10n.getLanguage().then(locale => {
  6865. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  6866. });
  6867. }
  6868. async open() {
  6869. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  6870. const currentPageNumber = this._currentPageNumber;
  6871. const pagesRotation = this._pagesRotation;
  6872. if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
  6873. this.#updateUI();
  6874. return;
  6875. }
  6876. const {
  6877. info,
  6878. contentLength
  6879. } = await this.pdfDocument.getMetadata();
  6880. 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 => {
  6881. return this.#parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  6882. }), this.#parseLinearization(info.IsLinearized)]);
  6883. this.#fieldData = Object.freeze({
  6884. fileName,
  6885. fileSize,
  6886. title: info.Title,
  6887. author: info.Author,
  6888. subject: info.Subject,
  6889. keywords: info.Keywords,
  6890. creationDate,
  6891. modificationDate,
  6892. creator: info.Creator,
  6893. producer: info.Producer,
  6894. version: info.PDFFormatVersion,
  6895. pageCount: this.pdfDocument.numPages,
  6896. pageSize,
  6897. linearized: isLinearized,
  6898. _currentPageNumber: currentPageNumber,
  6899. _pagesRotation: pagesRotation
  6900. });
  6901. this.#updateUI();
  6902. const {
  6903. length
  6904. } = await this.pdfDocument.getDownloadInfo();
  6905. if (contentLength === length) {
  6906. return;
  6907. }
  6908. const data = Object.assign(Object.create(null), this.#fieldData);
  6909. data.fileSize = await this.#parseFileSize(length);
  6910. this.#fieldData = Object.freeze(data);
  6911. this.#updateUI();
  6912. }
  6913. async close() {
  6914. this.overlayManager.close(this.dialog);
  6915. }
  6916. setDocument(pdfDocument) {
  6917. if (this.pdfDocument) {
  6918. this.#reset();
  6919. this.#updateUI(true);
  6920. }
  6921. if (!pdfDocument) {
  6922. return;
  6923. }
  6924. this.pdfDocument = pdfDocument;
  6925. this._dataAvailableCapability.resolve();
  6926. }
  6927. #reset() {
  6928. this.pdfDocument = null;
  6929. this.#fieldData = null;
  6930. this._dataAvailableCapability = new _pdfjsLib.PromiseCapability();
  6931. this._currentPageNumber = 1;
  6932. this._pagesRotation = 0;
  6933. }
  6934. #updateUI() {
  6935. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6936. if (reset || !this.#fieldData) {
  6937. for (const id in this.fields) {
  6938. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6939. }
  6940. return;
  6941. }
  6942. if (this.overlayManager.active !== this.dialog) {
  6943. return;
  6944. }
  6945. for (const id in this.fields) {
  6946. const content = this.#fieldData[id];
  6947. this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6948. }
  6949. }
  6950. async #parseFileSize() {
  6951. let fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  6952. const kb = fileSize / 1024,
  6953. mb = kb / 1024;
  6954. if (!kb) {
  6955. return undefined;
  6956. }
  6957. return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
  6958. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  6959. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  6960. size_b: fileSize.toLocaleString()
  6961. });
  6962. }
  6963. async #parsePageSize(pageSizeInches, pagesRotation) {
  6964. if (!pageSizeInches) {
  6965. return undefined;
  6966. }
  6967. if (pagesRotation % 180 !== 0) {
  6968. pageSizeInches = {
  6969. width: pageSizeInches.height,
  6970. height: pageSizeInches.width
  6971. };
  6972. }
  6973. const isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6974. let sizeInches = {
  6975. width: Math.round(pageSizeInches.width * 100) / 100,
  6976. height: Math.round(pageSizeInches.height * 100) / 100
  6977. };
  6978. let sizeMillimeters = {
  6979. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6980. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6981. };
  6982. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6983. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6984. const exactMillimeters = {
  6985. width: pageSizeInches.width * 25.4,
  6986. height: pageSizeInches.height * 25.4
  6987. };
  6988. const intMillimeters = {
  6989. width: Math.round(sizeMillimeters.width),
  6990. height: Math.round(sizeMillimeters.height)
  6991. };
  6992. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6993. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6994. if (rawName) {
  6995. sizeInches = {
  6996. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6997. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6998. };
  6999. sizeMillimeters = intMillimeters;
  7000. }
  7001. }
  7002. }
  7003. const [{
  7004. width,
  7005. height
  7006. }, 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"}`)]);
  7007. return this.l10n.get(`document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
  7008. width: width.toLocaleString(),
  7009. height: height.toLocaleString(),
  7010. unit,
  7011. name,
  7012. orientation
  7013. });
  7014. }
  7015. async #parseDate(inputDate) {
  7016. const dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  7017. if (!dateObject) {
  7018. return undefined;
  7019. }
  7020. return this.l10n.get("document_properties_date_string", {
  7021. date: dateObject.toLocaleDateString(),
  7022. time: dateObject.toLocaleTimeString()
  7023. });
  7024. }
  7025. #parseLinearization(isLinearized) {
  7026. return this.l10n.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
  7027. }
  7028. }
  7029. exports.PDFDocumentProperties = PDFDocumentProperties;
  7030. /***/ }),
  7031. /* 133 */
  7032. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7033. "use strict";
  7034. Object.defineProperty(exports, "__esModule", ({
  7035. value: true
  7036. }));
  7037. exports.PDFFindBar = void 0;
  7038. var _pdf_find_controller = __webpack_require__(134);
  7039. var _ui_utils = __webpack_require__(97);
  7040. const MATCHES_COUNT_LIMIT = 1000;
  7041. class PDFFindBar {
  7042. constructor(options, eventBus, l10n) {
  7043. this.opened = false;
  7044. this.bar = options.bar;
  7045. this.toggleButton = options.toggleButton;
  7046. this.findField = options.findField;
  7047. this.highlightAll = options.highlightAllCheckbox;
  7048. this.caseSensitive = options.caseSensitiveCheckbox;
  7049. this.matchDiacritics = options.matchDiacriticsCheckbox;
  7050. this.entireWord = options.entireWordCheckbox;
  7051. this.findMsg = options.findMsg;
  7052. this.findResultsCount = options.findResultsCount;
  7053. this.findPreviousButton = options.findPreviousButton;
  7054. this.findNextButton = options.findNextButton;
  7055. this.eventBus = eventBus;
  7056. this.l10n = l10n;
  7057. this.toggleButton.addEventListener("click", () => {
  7058. this.toggle();
  7059. });
  7060. this.findField.addEventListener("input", () => {
  7061. this.dispatchEvent("");
  7062. });
  7063. this.bar.addEventListener("keydown", e => {
  7064. switch (e.keyCode) {
  7065. case 13:
  7066. if (e.target === this.findField) {
  7067. this.dispatchEvent("again", e.shiftKey);
  7068. }
  7069. break;
  7070. case 27:
  7071. this.close();
  7072. break;
  7073. }
  7074. });
  7075. this.findPreviousButton.addEventListener("click", () => {
  7076. this.dispatchEvent("again", true);
  7077. });
  7078. this.findNextButton.addEventListener("click", () => {
  7079. this.dispatchEvent("again", false);
  7080. });
  7081. this.highlightAll.addEventListener("click", () => {
  7082. this.dispatchEvent("highlightallchange");
  7083. });
  7084. this.caseSensitive.addEventListener("click", () => {
  7085. this.dispatchEvent("casesensitivitychange");
  7086. });
  7087. this.entireWord.addEventListener("click", () => {
  7088. this.dispatchEvent("entirewordchange");
  7089. });
  7090. this.matchDiacritics.addEventListener("click", () => {
  7091. this.dispatchEvent("diacriticmatchingchange");
  7092. });
  7093. this.eventBus._on("resize", this.#adjustWidth.bind(this));
  7094. }
  7095. reset() {
  7096. this.updateUIState();
  7097. }
  7098. dispatchEvent(type) {
  7099. let findPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7100. this.eventBus.dispatch("find", {
  7101. source: this,
  7102. type,
  7103. query: this.findField.value,
  7104. caseSensitive: this.caseSensitive.checked,
  7105. entireWord: this.entireWord.checked,
  7106. highlightAll: this.highlightAll.checked,
  7107. findPrevious: findPrev,
  7108. matchDiacritics: this.matchDiacritics.checked
  7109. });
  7110. }
  7111. updateUIState(state, previous, matchesCount) {
  7112. let findMsg = Promise.resolve("");
  7113. let status = "";
  7114. switch (state) {
  7115. case _pdf_find_controller.FindState.FOUND:
  7116. break;
  7117. case _pdf_find_controller.FindState.PENDING:
  7118. status = "pending";
  7119. break;
  7120. case _pdf_find_controller.FindState.NOT_FOUND:
  7121. findMsg = this.l10n.get("find_not_found");
  7122. status = "notFound";
  7123. break;
  7124. case _pdf_find_controller.FindState.WRAPPED:
  7125. findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
  7126. break;
  7127. }
  7128. this.findField.setAttribute("data-status", status);
  7129. this.findField.setAttribute("aria-invalid", state === _pdf_find_controller.FindState.NOT_FOUND);
  7130. findMsg.then(msg => {
  7131. this.findMsg.setAttribute("data-status", status);
  7132. this.findMsg.textContent = msg;
  7133. this.#adjustWidth();
  7134. });
  7135. this.updateResultsCount(matchesCount);
  7136. }
  7137. updateResultsCount() {
  7138. let {
  7139. current = 0,
  7140. total = 0
  7141. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7142. const limit = MATCHES_COUNT_LIMIT;
  7143. let matchCountMsg = Promise.resolve("");
  7144. if (total > 0) {
  7145. if (total > limit) {
  7146. let key = "find_match_count_limit";
  7147. matchCountMsg = this.l10n.get(key, {
  7148. limit
  7149. });
  7150. } else {
  7151. let key = "find_match_count";
  7152. matchCountMsg = this.l10n.get(key, {
  7153. current,
  7154. total
  7155. });
  7156. }
  7157. }
  7158. matchCountMsg.then(msg => {
  7159. this.findResultsCount.textContent = msg;
  7160. this.#adjustWidth();
  7161. });
  7162. }
  7163. open() {
  7164. if (!this.opened) {
  7165. this.opened = true;
  7166. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true, this.bar);
  7167. }
  7168. this.findField.select();
  7169. this.findField.focus();
  7170. this.#adjustWidth();
  7171. }
  7172. close() {
  7173. if (!this.opened) {
  7174. return;
  7175. }
  7176. this.opened = false;
  7177. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false, this.bar);
  7178. this.eventBus.dispatch("findbarclose", {
  7179. source: this
  7180. });
  7181. }
  7182. toggle() {
  7183. if (this.opened) {
  7184. this.close();
  7185. } else {
  7186. this.open();
  7187. }
  7188. }
  7189. #adjustWidth() {
  7190. if (!this.opened) {
  7191. return;
  7192. }
  7193. this.bar.classList.remove("wrapContainers");
  7194. const findbarHeight = this.bar.clientHeight;
  7195. const inputContainerHeight = this.bar.firstElementChild.clientHeight;
  7196. if (findbarHeight > inputContainerHeight) {
  7197. this.bar.classList.add("wrapContainers");
  7198. }
  7199. }
  7200. }
  7201. exports.PDFFindBar = PDFFindBar;
  7202. /***/ }),
  7203. /* 134 */
  7204. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7205. "use strict";
  7206. Object.defineProperty(exports, "__esModule", ({
  7207. value: true
  7208. }));
  7209. exports.PDFFindController = exports.FindState = void 0;
  7210. __webpack_require__(98);
  7211. __webpack_require__(108);
  7212. __webpack_require__(110);
  7213. __webpack_require__(113);
  7214. __webpack_require__(115);
  7215. __webpack_require__(117);
  7216. __webpack_require__(119);
  7217. __webpack_require__(89);
  7218. var _ui_utils = __webpack_require__(97);
  7219. var _pdf_find_utils = __webpack_require__(135);
  7220. var _pdfjsLib = __webpack_require__(121);
  7221. const FindState = {
  7222. FOUND: 0,
  7223. NOT_FOUND: 1,
  7224. WRAPPED: 2,
  7225. PENDING: 3
  7226. };
  7227. exports.FindState = FindState;
  7228. const FIND_TIMEOUT = 250;
  7229. const MATCH_SCROLL_OFFSET_TOP = -50;
  7230. const MATCH_SCROLL_OFFSET_LEFT = -400;
  7231. const CHARACTERS_TO_NORMALIZE = {
  7232. "\u2010": "-",
  7233. "\u2018": "'",
  7234. "\u2019": "'",
  7235. "\u201A": "'",
  7236. "\u201B": "'",
  7237. "\u201C": '"',
  7238. "\u201D": '"',
  7239. "\u201E": '"',
  7240. "\u201F": '"',
  7241. "\u00BC": "1/4",
  7242. "\u00BD": "1/2",
  7243. "\u00BE": "3/4"
  7244. };
  7245. 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]);
  7246. let DIACRITICS_EXCEPTION_STR;
  7247. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  7248. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  7249. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  7250. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  7251. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  7252. const SYLLABLES_LENGTHS = new Map();
  7253. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  7254. const NFKC_CHARS_TO_NORMALIZE = new Map();
  7255. let noSyllablesRegExp = null;
  7256. let withSyllablesRegExp = null;
  7257. function normalize(text) {
  7258. const syllablePositions = [];
  7259. let m;
  7260. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  7261. let {
  7262. index
  7263. } = m;
  7264. for (const char of m[0]) {
  7265. let len = SYLLABLES_LENGTHS.get(char);
  7266. if (!len) {
  7267. len = char.normalize("NFD").length;
  7268. SYLLABLES_LENGTHS.set(char, len);
  7269. }
  7270. syllablePositions.push([len, index++]);
  7271. }
  7272. }
  7273. let normalizationRegex;
  7274. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  7275. normalizationRegex = noSyllablesRegExp;
  7276. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  7277. normalizationRegex = withSyllablesRegExp;
  7278. } else {
  7279. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  7280. const toNormalizeWithNFKC = (0, _pdf_find_utils.getNormalizeWithNFKC)();
  7281. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  7282. const HKDiacritics = "(?:\u3099|\u309A)";
  7283. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  7284. if (syllablePositions.length === 0) {
  7285. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  7286. } else {
  7287. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  7288. }
  7289. }
  7290. const rawDiacriticsPositions = [];
  7291. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  7292. rawDiacriticsPositions.push([m[0].length, m.index]);
  7293. }
  7294. let normalized = text.normalize("NFD");
  7295. const positions = [[0, 0]];
  7296. let rawDiacriticsIndex = 0;
  7297. let syllableIndex = 0;
  7298. let shift = 0;
  7299. let shiftOrigin = 0;
  7300. let eol = 0;
  7301. let hasDiacritics = false;
  7302. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
  7303. i -= shiftOrigin;
  7304. if (p1) {
  7305. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  7306. const jj = replacement.length;
  7307. for (let j = 1; j < jj; j++) {
  7308. positions.push([i - shift + j, shift - j]);
  7309. }
  7310. shift -= jj - 1;
  7311. return replacement;
  7312. }
  7313. if (p2) {
  7314. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  7315. if (!replacement) {
  7316. replacement = p2.normalize("NFKC");
  7317. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  7318. }
  7319. const jj = replacement.length;
  7320. for (let j = 1; j < jj; j++) {
  7321. positions.push([i - shift + j, shift - j]);
  7322. }
  7323. shift -= jj - 1;
  7324. return replacement;
  7325. }
  7326. if (p3) {
  7327. hasDiacritics = true;
  7328. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7329. ++rawDiacriticsIndex;
  7330. } else {
  7331. positions.push([i - 1 - shift + 1, shift - 1]);
  7332. shift -= 1;
  7333. shiftOrigin += 1;
  7334. }
  7335. positions.push([i - shift + 1, shift]);
  7336. shiftOrigin += 1;
  7337. eol += 1;
  7338. return p3.charAt(0);
  7339. }
  7340. if (p4) {
  7341. const hasTrailingDashEOL = p4.endsWith("\n");
  7342. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  7343. hasDiacritics = true;
  7344. let jj = len;
  7345. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7346. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  7347. ++rawDiacriticsIndex;
  7348. }
  7349. for (let j = 1; j <= jj; j++) {
  7350. positions.push([i - 1 - shift + j, shift - j]);
  7351. }
  7352. shift -= jj;
  7353. shiftOrigin += jj;
  7354. if (hasTrailingDashEOL) {
  7355. i += len - 1;
  7356. positions.push([i - shift + 1, 1 + shift]);
  7357. shift += 1;
  7358. shiftOrigin += 1;
  7359. eol += 1;
  7360. return p4.slice(0, len);
  7361. }
  7362. return p4;
  7363. }
  7364. if (p5) {
  7365. const len = p5.length - 2;
  7366. positions.push([i - shift + len, 1 + shift]);
  7367. shift += 1;
  7368. shiftOrigin += 1;
  7369. eol += 1;
  7370. return p5.slice(0, -2);
  7371. }
  7372. if (p6) {
  7373. const len = p6.length - 1;
  7374. positions.push([i - shift + len, shift]);
  7375. shiftOrigin += 1;
  7376. eol += 1;
  7377. return p6.slice(0, -1);
  7378. }
  7379. if (p7) {
  7380. positions.push([i - shift + 1, shift - 1]);
  7381. shift -= 1;
  7382. shiftOrigin += 1;
  7383. eol += 1;
  7384. return " ";
  7385. }
  7386. if (i + eol === syllablePositions[syllableIndex]?.[1]) {
  7387. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  7388. ++syllableIndex;
  7389. for (let j = 1; j <= newCharLen; j++) {
  7390. positions.push([i - (shift - j), shift - j]);
  7391. }
  7392. shift -= newCharLen;
  7393. shiftOrigin += newCharLen;
  7394. }
  7395. return p8;
  7396. });
  7397. positions.push([normalized.length, shift]);
  7398. return [normalized, positions, hasDiacritics];
  7399. }
  7400. function getOriginalIndex(diffs, pos, len) {
  7401. if (!diffs) {
  7402. return [pos, len];
  7403. }
  7404. const start = pos;
  7405. const end = pos + len - 1;
  7406. let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
  7407. if (diffs[i][0] > start) {
  7408. --i;
  7409. }
  7410. let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  7411. if (diffs[j][0] > end) {
  7412. --j;
  7413. }
  7414. const oldStart = start + diffs[i][1];
  7415. const oldEnd = end + diffs[j][1];
  7416. const oldLen = oldEnd + 1 - oldStart;
  7417. return [oldStart, oldLen];
  7418. }
  7419. class PDFFindController {
  7420. #state = null;
  7421. #updateMatchesCountOnProgress = true;
  7422. #visitedPagesCount = 0;
  7423. constructor(_ref) {
  7424. let {
  7425. linkService,
  7426. eventBus,
  7427. updateMatchesCountOnProgress = true
  7428. } = _ref;
  7429. this._linkService = linkService;
  7430. this._eventBus = eventBus;
  7431. this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
  7432. this.onIsPageVisible = null;
  7433. this.#reset();
  7434. eventBus._on("find", this.#onFind.bind(this));
  7435. eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
  7436. }
  7437. get highlightMatches() {
  7438. return this._highlightMatches;
  7439. }
  7440. get pageMatches() {
  7441. return this._pageMatches;
  7442. }
  7443. get pageMatchesLength() {
  7444. return this._pageMatchesLength;
  7445. }
  7446. get selected() {
  7447. return this._selected;
  7448. }
  7449. get state() {
  7450. return this.#state;
  7451. }
  7452. setDocument(pdfDocument) {
  7453. if (this._pdfDocument) {
  7454. this.#reset();
  7455. }
  7456. if (!pdfDocument) {
  7457. return;
  7458. }
  7459. this._pdfDocument = pdfDocument;
  7460. this._firstPageCapability.resolve();
  7461. }
  7462. #onFind(state) {
  7463. if (!state) {
  7464. return;
  7465. }
  7466. if (state.phraseSearch === false) {
  7467. console.error("The `phraseSearch`-parameter was removed, please provide " + "an Array of strings in the `query`-parameter instead.");
  7468. if (typeof state.query === "string") {
  7469. state.query = state.query.match(/\S+/g);
  7470. }
  7471. }
  7472. const pdfDocument = this._pdfDocument;
  7473. const {
  7474. type
  7475. } = state;
  7476. if (this.#state === null || this.#shouldDirtyMatch(state)) {
  7477. this._dirtyMatch = true;
  7478. }
  7479. this.#state = state;
  7480. if (type !== "highlightallchange") {
  7481. this.#updateUIState(FindState.PENDING);
  7482. }
  7483. this._firstPageCapability.promise.then(() => {
  7484. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7485. return;
  7486. }
  7487. this.#extractText();
  7488. const findbarClosed = !this._highlightMatches;
  7489. const pendingTimeout = !!this._findTimeout;
  7490. if (this._findTimeout) {
  7491. clearTimeout(this._findTimeout);
  7492. this._findTimeout = null;
  7493. }
  7494. if (!type) {
  7495. this._findTimeout = setTimeout(() => {
  7496. this.#nextMatch();
  7497. this._findTimeout = null;
  7498. }, FIND_TIMEOUT);
  7499. } else if (this._dirtyMatch) {
  7500. this.#nextMatch();
  7501. } else if (type === "again") {
  7502. this.#nextMatch();
  7503. if (findbarClosed && this.#state.highlightAll) {
  7504. this.#updateAllPages();
  7505. }
  7506. } else if (type === "highlightallchange") {
  7507. if (pendingTimeout) {
  7508. this.#nextMatch();
  7509. } else {
  7510. this._highlightMatches = true;
  7511. }
  7512. this.#updateAllPages();
  7513. } else {
  7514. this.#nextMatch();
  7515. }
  7516. });
  7517. }
  7518. scrollMatchIntoView(_ref2) {
  7519. let {
  7520. element = null,
  7521. selectedLeft = 0,
  7522. pageIndex = -1,
  7523. matchIndex = -1
  7524. } = _ref2;
  7525. if (!this._scrollMatches || !element) {
  7526. return;
  7527. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  7528. return;
  7529. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  7530. return;
  7531. }
  7532. this._scrollMatches = false;
  7533. const spot = {
  7534. top: MATCH_SCROLL_OFFSET_TOP,
  7535. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  7536. };
  7537. (0, _ui_utils.scrollIntoView)(element, spot, true);
  7538. }
  7539. #reset() {
  7540. this._highlightMatches = false;
  7541. this._scrollMatches = false;
  7542. this._pdfDocument = null;
  7543. this._pageMatches = [];
  7544. this._pageMatchesLength = [];
  7545. this.#visitedPagesCount = 0;
  7546. this.#state = null;
  7547. this._selected = {
  7548. pageIdx: -1,
  7549. matchIdx: -1
  7550. };
  7551. this._offset = {
  7552. pageIdx: null,
  7553. matchIdx: null,
  7554. wrapped: false
  7555. };
  7556. this._extractTextPromises = [];
  7557. this._pageContents = [];
  7558. this._pageDiffs = [];
  7559. this._hasDiacritics = [];
  7560. this._matchesCountTotal = 0;
  7561. this._pagesToSearch = null;
  7562. this._pendingFindMatches = new Set();
  7563. this._resumePageIdx = null;
  7564. this._dirtyMatch = false;
  7565. clearTimeout(this._findTimeout);
  7566. this._findTimeout = null;
  7567. this._firstPageCapability = new _pdfjsLib.PromiseCapability();
  7568. }
  7569. get #query() {
  7570. const {
  7571. query
  7572. } = this.#state;
  7573. if (typeof query === "string") {
  7574. if (query !== this._rawQuery) {
  7575. this._rawQuery = query;
  7576. [this._normalizedQuery] = normalize(query);
  7577. }
  7578. return this._normalizedQuery;
  7579. }
  7580. return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
  7581. }
  7582. #shouldDirtyMatch(state) {
  7583. const newQuery = state.query,
  7584. prevQuery = this.#state.query;
  7585. const newType = typeof newQuery,
  7586. prevType = typeof prevQuery;
  7587. if (newType !== prevType) {
  7588. return true;
  7589. }
  7590. if (newType === "string") {
  7591. if (newQuery !== prevQuery) {
  7592. return true;
  7593. }
  7594. } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
  7595. return true;
  7596. }
  7597. switch (state.type) {
  7598. case "again":
  7599. const pageNumber = this._selected.pageIdx + 1;
  7600. const linkService = this._linkService;
  7601. return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
  7602. case "highlightallchange":
  7603. return false;
  7604. }
  7605. return true;
  7606. }
  7607. #isEntireWord(content, startIdx, length) {
  7608. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  7609. if (match) {
  7610. const first = content.charCodeAt(startIdx);
  7611. const limit = match[1].charCodeAt(0);
  7612. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7613. return false;
  7614. }
  7615. }
  7616. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  7617. if (match) {
  7618. const last = content.charCodeAt(startIdx + length - 1);
  7619. const limit = match[1].charCodeAt(0);
  7620. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7621. return false;
  7622. }
  7623. }
  7624. return true;
  7625. }
  7626. #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
  7627. const matches = this._pageMatches[pageIndex] = [];
  7628. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  7629. if (!query) {
  7630. return;
  7631. }
  7632. const diffs = this._pageDiffs[pageIndex];
  7633. let match;
  7634. while ((match = query.exec(pageContent)) !== null) {
  7635. if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
  7636. continue;
  7637. }
  7638. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  7639. if (matchLen) {
  7640. matches.push(matchPos);
  7641. matchesLength.push(matchLen);
  7642. }
  7643. }
  7644. }
  7645. #convertToRegExpString(query, hasDiacritics) {
  7646. const {
  7647. matchDiacritics
  7648. } = this.#state;
  7649. let isUnicode = false;
  7650. query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  7651. if (p1) {
  7652. return `[ ]*\\${p1}[ ]*`;
  7653. }
  7654. if (p2) {
  7655. return `[ ]*${p2}[ ]*`;
  7656. }
  7657. if (p3) {
  7658. return "[ ]+";
  7659. }
  7660. if (matchDiacritics) {
  7661. return p4 || p5;
  7662. }
  7663. if (p4) {
  7664. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  7665. }
  7666. if (hasDiacritics) {
  7667. isUnicode = true;
  7668. return `${p5}\\p{M}*`;
  7669. }
  7670. return p5;
  7671. });
  7672. const trailingSpaces = "[ ]*";
  7673. if (query.endsWith(trailingSpaces)) {
  7674. query = query.slice(0, query.length - trailingSpaces.length);
  7675. }
  7676. if (matchDiacritics) {
  7677. if (hasDiacritics) {
  7678. DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
  7679. isUnicode = true;
  7680. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  7681. }
  7682. }
  7683. return [isUnicode, query];
  7684. }
  7685. #calculateMatch(pageIndex) {
  7686. let query = this.#query;
  7687. if (query.length === 0) {
  7688. return;
  7689. }
  7690. const {
  7691. caseSensitive,
  7692. entireWord
  7693. } = this.#state;
  7694. const pageContent = this._pageContents[pageIndex];
  7695. const hasDiacritics = this._hasDiacritics[pageIndex];
  7696. let isUnicode = false;
  7697. if (typeof query === "string") {
  7698. [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
  7699. } else {
  7700. query = query.sort().reverse().map(q => {
  7701. const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
  7702. isUnicode ||= isUnicodePart;
  7703. return `(${queryPart})`;
  7704. }).join("|");
  7705. }
  7706. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  7707. query = query ? new RegExp(query, flags) : null;
  7708. this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
  7709. if (this.#state.highlightAll) {
  7710. this.#updatePage(pageIndex);
  7711. }
  7712. if (this._resumePageIdx === pageIndex) {
  7713. this._resumePageIdx = null;
  7714. this.#nextPageMatch();
  7715. }
  7716. const pageMatchesCount = this._pageMatches[pageIndex].length;
  7717. this._matchesCountTotal += pageMatchesCount;
  7718. if (this.#updateMatchesCountOnProgress) {
  7719. if (pageMatchesCount > 0) {
  7720. this.#updateUIResultsCount();
  7721. }
  7722. } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
  7723. this.#updateUIResultsCount();
  7724. }
  7725. }
  7726. #extractText() {
  7727. if (this._extractTextPromises.length > 0) {
  7728. return;
  7729. }
  7730. let promise = Promise.resolve();
  7731. const textOptions = {
  7732. disableNormalization: true
  7733. };
  7734. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  7735. const extractTextCapability = new _pdfjsLib.PromiseCapability();
  7736. this._extractTextPromises[i] = extractTextCapability.promise;
  7737. promise = promise.then(() => {
  7738. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  7739. return pdfPage.getTextContent(textOptions);
  7740. }).then(textContent => {
  7741. const strBuf = [];
  7742. for (const textItem of textContent.items) {
  7743. strBuf.push(textItem.str);
  7744. if (textItem.hasEOL) {
  7745. strBuf.push("\n");
  7746. }
  7747. }
  7748. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  7749. extractTextCapability.resolve();
  7750. }, reason => {
  7751. console.error(`Unable to get text content for page ${i + 1}`, reason);
  7752. this._pageContents[i] = "";
  7753. this._pageDiffs[i] = null;
  7754. this._hasDiacritics[i] = false;
  7755. extractTextCapability.resolve();
  7756. });
  7757. });
  7758. }
  7759. }
  7760. #updatePage(index) {
  7761. if (this._scrollMatches && this._selected.pageIdx === index) {
  7762. this._linkService.page = index + 1;
  7763. }
  7764. this._eventBus.dispatch("updatetextlayermatches", {
  7765. source: this,
  7766. pageIndex: index
  7767. });
  7768. }
  7769. #updateAllPages() {
  7770. this._eventBus.dispatch("updatetextlayermatches", {
  7771. source: this,
  7772. pageIndex: -1
  7773. });
  7774. }
  7775. #nextMatch() {
  7776. const previous = this.#state.findPrevious;
  7777. const currentPageIndex = this._linkService.page - 1;
  7778. const numPages = this._linkService.pagesCount;
  7779. this._highlightMatches = true;
  7780. if (this._dirtyMatch) {
  7781. this._dirtyMatch = false;
  7782. this._selected.pageIdx = this._selected.matchIdx = -1;
  7783. this._offset.pageIdx = currentPageIndex;
  7784. this._offset.matchIdx = null;
  7785. this._offset.wrapped = false;
  7786. this._resumePageIdx = null;
  7787. this._pageMatches.length = 0;
  7788. this._pageMatchesLength.length = 0;
  7789. this.#visitedPagesCount = 0;
  7790. this._matchesCountTotal = 0;
  7791. this.#updateAllPages();
  7792. for (let i = 0; i < numPages; i++) {
  7793. if (this._pendingFindMatches.has(i)) {
  7794. continue;
  7795. }
  7796. this._pendingFindMatches.add(i);
  7797. this._extractTextPromises[i].then(() => {
  7798. this._pendingFindMatches.delete(i);
  7799. this.#calculateMatch(i);
  7800. });
  7801. }
  7802. }
  7803. const query = this.#query;
  7804. if (query.length === 0) {
  7805. this.#updateUIState(FindState.FOUND);
  7806. return;
  7807. }
  7808. if (this._resumePageIdx) {
  7809. return;
  7810. }
  7811. const offset = this._offset;
  7812. this._pagesToSearch = numPages;
  7813. if (offset.matchIdx !== null) {
  7814. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  7815. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  7816. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  7817. this.#updateMatch(true);
  7818. return;
  7819. }
  7820. this.#advanceOffsetPage(previous);
  7821. }
  7822. this.#nextPageMatch();
  7823. }
  7824. #matchesReady(matches) {
  7825. const offset = this._offset;
  7826. const numMatches = matches.length;
  7827. const previous = this.#state.findPrevious;
  7828. if (numMatches) {
  7829. offset.matchIdx = previous ? numMatches - 1 : 0;
  7830. this.#updateMatch(true);
  7831. return true;
  7832. }
  7833. this.#advanceOffsetPage(previous);
  7834. if (offset.wrapped) {
  7835. offset.matchIdx = null;
  7836. if (this._pagesToSearch < 0) {
  7837. this.#updateMatch(false);
  7838. return true;
  7839. }
  7840. }
  7841. return false;
  7842. }
  7843. #nextPageMatch() {
  7844. if (this._resumePageIdx !== null) {
  7845. console.error("There can only be one pending page.");
  7846. }
  7847. let matches = null;
  7848. do {
  7849. const pageIdx = this._offset.pageIdx;
  7850. matches = this._pageMatches[pageIdx];
  7851. if (!matches) {
  7852. this._resumePageIdx = pageIdx;
  7853. break;
  7854. }
  7855. } while (!this.#matchesReady(matches));
  7856. }
  7857. #advanceOffsetPage(previous) {
  7858. const offset = this._offset;
  7859. const numPages = this._linkService.pagesCount;
  7860. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7861. offset.matchIdx = null;
  7862. this._pagesToSearch--;
  7863. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7864. offset.pageIdx = previous ? numPages - 1 : 0;
  7865. offset.wrapped = true;
  7866. }
  7867. }
  7868. #updateMatch() {
  7869. let found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7870. let state = FindState.NOT_FOUND;
  7871. const wrapped = this._offset.wrapped;
  7872. this._offset.wrapped = false;
  7873. if (found) {
  7874. const previousPage = this._selected.pageIdx;
  7875. this._selected.pageIdx = this._offset.pageIdx;
  7876. this._selected.matchIdx = this._offset.matchIdx;
  7877. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7878. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  7879. this.#updatePage(previousPage);
  7880. }
  7881. }
  7882. this.#updateUIState(state, this.#state.findPrevious);
  7883. if (this._selected.pageIdx !== -1) {
  7884. this._scrollMatches = true;
  7885. this.#updatePage(this._selected.pageIdx);
  7886. }
  7887. }
  7888. #onFindBarClose(evt) {
  7889. const pdfDocument = this._pdfDocument;
  7890. this._firstPageCapability.promise.then(() => {
  7891. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7892. return;
  7893. }
  7894. if (this._findTimeout) {
  7895. clearTimeout(this._findTimeout);
  7896. this._findTimeout = null;
  7897. }
  7898. if (this._resumePageIdx) {
  7899. this._resumePageIdx = null;
  7900. this._dirtyMatch = true;
  7901. }
  7902. this.#updateUIState(FindState.FOUND);
  7903. this._highlightMatches = false;
  7904. this.#updateAllPages();
  7905. });
  7906. }
  7907. #requestMatchesCount() {
  7908. const {
  7909. pageIdx,
  7910. matchIdx
  7911. } = this._selected;
  7912. let current = 0,
  7913. total = this._matchesCountTotal;
  7914. if (matchIdx !== -1) {
  7915. for (let i = 0; i < pageIdx; i++) {
  7916. current += this._pageMatches[i]?.length || 0;
  7917. }
  7918. current += matchIdx + 1;
  7919. }
  7920. if (current < 1 || current > total) {
  7921. current = total = 0;
  7922. }
  7923. return {
  7924. current,
  7925. total
  7926. };
  7927. }
  7928. #updateUIResultsCount() {
  7929. this._eventBus.dispatch("updatefindmatchescount", {
  7930. source: this,
  7931. matchesCount: this.#requestMatchesCount()
  7932. });
  7933. }
  7934. #updateUIState(state) {
  7935. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7936. if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
  7937. return;
  7938. }
  7939. this._eventBus.dispatch("updatefindcontrolstate", {
  7940. source: this,
  7941. state,
  7942. previous,
  7943. matchesCount: this.#requestMatchesCount(),
  7944. rawQuery: this.#state?.query ?? null
  7945. });
  7946. }
  7947. }
  7948. exports.PDFFindController = PDFFindController;
  7949. /***/ }),
  7950. /* 135 */
  7951. /***/ ((__unused_webpack_module, exports) => {
  7952. "use strict";
  7953. Object.defineProperty(exports, "__esModule", ({
  7954. value: true
  7955. }));
  7956. exports.CharacterType = void 0;
  7957. exports.getCharacterType = getCharacterType;
  7958. exports.getNormalizeWithNFKC = getNormalizeWithNFKC;
  7959. const CharacterType = {
  7960. SPACE: 0,
  7961. ALPHA_LETTER: 1,
  7962. PUNCT: 2,
  7963. HAN_LETTER: 3,
  7964. KATAKANA_LETTER: 4,
  7965. HIRAGANA_LETTER: 5,
  7966. HALFWIDTH_KATAKANA_LETTER: 6,
  7967. THAI_LETTER: 7
  7968. };
  7969. exports.CharacterType = CharacterType;
  7970. function isAlphabeticalScript(charCode) {
  7971. return charCode < 0x2e80;
  7972. }
  7973. function isAscii(charCode) {
  7974. return (charCode & 0xff80) === 0;
  7975. }
  7976. function isAsciiAlpha(charCode) {
  7977. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7978. }
  7979. function isAsciiDigit(charCode) {
  7980. return charCode >= 0x30 && charCode <= 0x39;
  7981. }
  7982. function isAsciiSpace(charCode) {
  7983. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7984. }
  7985. function isHan(charCode) {
  7986. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7987. }
  7988. function isKatakana(charCode) {
  7989. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7990. }
  7991. function isHiragana(charCode) {
  7992. return charCode >= 0x3040 && charCode <= 0x309f;
  7993. }
  7994. function isHalfwidthKatakana(charCode) {
  7995. return charCode >= 0xff60 && charCode <= 0xff9f;
  7996. }
  7997. function isThai(charCode) {
  7998. return (charCode & 0xff80) === 0x0e00;
  7999. }
  8000. function getCharacterType(charCode) {
  8001. if (isAlphabeticalScript(charCode)) {
  8002. if (isAscii(charCode)) {
  8003. if (isAsciiSpace(charCode)) {
  8004. return CharacterType.SPACE;
  8005. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  8006. return CharacterType.ALPHA_LETTER;
  8007. }
  8008. return CharacterType.PUNCT;
  8009. } else if (isThai(charCode)) {
  8010. return CharacterType.THAI_LETTER;
  8011. } else if (charCode === 0xa0) {
  8012. return CharacterType.SPACE;
  8013. }
  8014. return CharacterType.ALPHA_LETTER;
  8015. }
  8016. if (isHan(charCode)) {
  8017. return CharacterType.HAN_LETTER;
  8018. } else if (isKatakana(charCode)) {
  8019. return CharacterType.KATAKANA_LETTER;
  8020. } else if (isHiragana(charCode)) {
  8021. return CharacterType.HIRAGANA_LETTER;
  8022. } else if (isHalfwidthKatakana(charCode)) {
  8023. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  8024. }
  8025. return CharacterType.ALPHA_LETTER;
  8026. }
  8027. let NormalizeWithNFKC;
  8028. function getNormalizeWithNFKC() {
  8029. NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`;
  8030. return NormalizeWithNFKC;
  8031. }
  8032. /***/ }),
  8033. /* 136 */
  8034. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8035. "use strict";
  8036. Object.defineProperty(exports, "__esModule", ({
  8037. value: true
  8038. }));
  8039. exports.PDFHistory = void 0;
  8040. exports.isDestArraysEqual = isDestArraysEqual;
  8041. exports.isDestHashesEqual = isDestHashesEqual;
  8042. var _ui_utils = __webpack_require__(97);
  8043. var _event_utils = __webpack_require__(123);
  8044. const HASH_CHANGE_TIMEOUT = 1000;
  8045. const POSITION_UPDATED_THRESHOLD = 50;
  8046. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  8047. function getCurrentHash() {
  8048. return document.location.hash;
  8049. }
  8050. class PDFHistory {
  8051. constructor(_ref) {
  8052. let {
  8053. linkService,
  8054. eventBus
  8055. } = _ref;
  8056. this.linkService = linkService;
  8057. this.eventBus = eventBus;
  8058. this._initialized = false;
  8059. this._fingerprint = "";
  8060. this.reset();
  8061. this._boundEvents = null;
  8062. this.eventBus._on("pagesinit", () => {
  8063. this._isPagesLoaded = false;
  8064. this.eventBus._on("pagesloaded", evt => {
  8065. this._isPagesLoaded = !!evt.pagesCount;
  8066. }, {
  8067. once: true
  8068. });
  8069. });
  8070. }
  8071. initialize(_ref2) {
  8072. let {
  8073. fingerprint,
  8074. resetHistory = false,
  8075. updateUrl = false
  8076. } = _ref2;
  8077. if (!fingerprint || typeof fingerprint !== "string") {
  8078. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  8079. return;
  8080. }
  8081. if (this._initialized) {
  8082. this.reset();
  8083. }
  8084. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  8085. this._fingerprint = fingerprint;
  8086. this._updateUrl = updateUrl === true;
  8087. this._initialized = true;
  8088. this._bindEvents();
  8089. const state = window.history.state;
  8090. this._popStateInProgress = false;
  8091. this._blockHashChange = 0;
  8092. this._currentHash = getCurrentHash();
  8093. this._numPositionUpdates = 0;
  8094. this._uid = this._maxUid = 0;
  8095. this._destination = null;
  8096. this._position = null;
  8097. if (!this._isValidState(state, true) || resetHistory) {
  8098. const {
  8099. hash,
  8100. page,
  8101. rotation
  8102. } = this._parseCurrentHash(true);
  8103. if (!hash || reInitialized || resetHistory) {
  8104. this._pushOrReplaceState(null, true);
  8105. return;
  8106. }
  8107. this._pushOrReplaceState({
  8108. hash,
  8109. page,
  8110. rotation
  8111. }, true);
  8112. return;
  8113. }
  8114. const destination = state.destination;
  8115. this._updateInternalState(destination, state.uid, true);
  8116. if (destination.rotation !== undefined) {
  8117. this._initialRotation = destination.rotation;
  8118. }
  8119. if (destination.dest) {
  8120. this._initialBookmark = JSON.stringify(destination.dest);
  8121. this._destination.page = null;
  8122. } else if (destination.hash) {
  8123. this._initialBookmark = destination.hash;
  8124. } else if (destination.page) {
  8125. this._initialBookmark = `page=${destination.page}`;
  8126. }
  8127. }
  8128. reset() {
  8129. if (this._initialized) {
  8130. this._pageHide();
  8131. this._initialized = false;
  8132. this._unbindEvents();
  8133. }
  8134. if (this._updateViewareaTimeout) {
  8135. clearTimeout(this._updateViewareaTimeout);
  8136. this._updateViewareaTimeout = null;
  8137. }
  8138. this._initialBookmark = null;
  8139. this._initialRotation = null;
  8140. }
  8141. push(_ref3) {
  8142. let {
  8143. namedDest = null,
  8144. explicitDest,
  8145. pageNumber
  8146. } = _ref3;
  8147. if (!this._initialized) {
  8148. return;
  8149. }
  8150. if (namedDest && typeof namedDest !== "string") {
  8151. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  8152. return;
  8153. } else if (!Array.isArray(explicitDest)) {
  8154. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  8155. return;
  8156. } else if (!this._isValidPage(pageNumber)) {
  8157. if (pageNumber !== null || this._destination) {
  8158. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  8159. return;
  8160. }
  8161. }
  8162. const hash = namedDest || JSON.stringify(explicitDest);
  8163. if (!hash) {
  8164. return;
  8165. }
  8166. let forceReplace = false;
  8167. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  8168. if (this._destination.page) {
  8169. return;
  8170. }
  8171. forceReplace = true;
  8172. }
  8173. if (this._popStateInProgress && !forceReplace) {
  8174. return;
  8175. }
  8176. this._pushOrReplaceState({
  8177. dest: explicitDest,
  8178. hash,
  8179. page: pageNumber,
  8180. rotation: this.linkService.rotation
  8181. }, forceReplace);
  8182. if (!this._popStateInProgress) {
  8183. this._popStateInProgress = true;
  8184. Promise.resolve().then(() => {
  8185. this._popStateInProgress = false;
  8186. });
  8187. }
  8188. }
  8189. pushPage(pageNumber) {
  8190. if (!this._initialized) {
  8191. return;
  8192. }
  8193. if (!this._isValidPage(pageNumber)) {
  8194. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  8195. return;
  8196. }
  8197. if (this._destination?.page === pageNumber) {
  8198. return;
  8199. }
  8200. if (this._popStateInProgress) {
  8201. return;
  8202. }
  8203. this._pushOrReplaceState({
  8204. dest: null,
  8205. hash: `page=${pageNumber}`,
  8206. page: pageNumber,
  8207. rotation: this.linkService.rotation
  8208. });
  8209. if (!this._popStateInProgress) {
  8210. this._popStateInProgress = true;
  8211. Promise.resolve().then(() => {
  8212. this._popStateInProgress = false;
  8213. });
  8214. }
  8215. }
  8216. pushCurrentPosition() {
  8217. if (!this._initialized || this._popStateInProgress) {
  8218. return;
  8219. }
  8220. this._tryPushCurrentPosition();
  8221. }
  8222. back() {
  8223. if (!this._initialized || this._popStateInProgress) {
  8224. return;
  8225. }
  8226. const state = window.history.state;
  8227. if (this._isValidState(state) && state.uid > 0) {
  8228. window.history.back();
  8229. }
  8230. }
  8231. forward() {
  8232. if (!this._initialized || this._popStateInProgress) {
  8233. return;
  8234. }
  8235. const state = window.history.state;
  8236. if (this._isValidState(state) && state.uid < this._maxUid) {
  8237. window.history.forward();
  8238. }
  8239. }
  8240. get popStateInProgress() {
  8241. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  8242. }
  8243. get initialBookmark() {
  8244. return this._initialized ? this._initialBookmark : null;
  8245. }
  8246. get initialRotation() {
  8247. return this._initialized ? this._initialRotation : null;
  8248. }
  8249. _pushOrReplaceState(destination) {
  8250. let forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8251. const shouldReplace = forceReplace || !this._destination;
  8252. const newState = {
  8253. fingerprint: this._fingerprint,
  8254. uid: shouldReplace ? this._uid : this._uid + 1,
  8255. destination
  8256. };
  8257. this._updateInternalState(destination, newState.uid);
  8258. let newUrl;
  8259. if (this._updateUrl && destination?.hash) {
  8260. const baseUrl = document.location.href.split("#")[0];
  8261. if (!baseUrl.startsWith("file://")) {
  8262. newUrl = `${baseUrl}#${destination.hash}`;
  8263. }
  8264. }
  8265. if (shouldReplace) {
  8266. window.history.replaceState(newState, "", newUrl);
  8267. } else {
  8268. window.history.pushState(newState, "", newUrl);
  8269. }
  8270. }
  8271. _tryPushCurrentPosition() {
  8272. let temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8273. if (!this._position) {
  8274. return;
  8275. }
  8276. let position = this._position;
  8277. if (temporary) {
  8278. position = Object.assign(Object.create(null), this._position);
  8279. position.temporary = true;
  8280. }
  8281. if (!this._destination) {
  8282. this._pushOrReplaceState(position);
  8283. return;
  8284. }
  8285. if (this._destination.temporary) {
  8286. this._pushOrReplaceState(position, true);
  8287. return;
  8288. }
  8289. if (this._destination.hash === position.hash) {
  8290. return;
  8291. }
  8292. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  8293. return;
  8294. }
  8295. let forceReplace = false;
  8296. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  8297. if (this._destination.dest !== undefined || !this._destination.first) {
  8298. return;
  8299. }
  8300. forceReplace = true;
  8301. }
  8302. this._pushOrReplaceState(position, forceReplace);
  8303. }
  8304. _isValidPage(val) {
  8305. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  8306. }
  8307. _isValidState(state) {
  8308. let checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8309. if (!state) {
  8310. return false;
  8311. }
  8312. if (state.fingerprint !== this._fingerprint) {
  8313. if (checkReload) {
  8314. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  8315. return false;
  8316. }
  8317. const [perfEntry] = performance.getEntriesByType("navigation");
  8318. if (perfEntry?.type !== "reload") {
  8319. return false;
  8320. }
  8321. } else {
  8322. return false;
  8323. }
  8324. }
  8325. if (!Number.isInteger(state.uid) || state.uid < 0) {
  8326. return false;
  8327. }
  8328. if (state.destination === null || typeof state.destination !== "object") {
  8329. return false;
  8330. }
  8331. return true;
  8332. }
  8333. _updateInternalState(destination, uid) {
  8334. let removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8335. if (this._updateViewareaTimeout) {
  8336. clearTimeout(this._updateViewareaTimeout);
  8337. this._updateViewareaTimeout = null;
  8338. }
  8339. if (removeTemporary && destination?.temporary) {
  8340. delete destination.temporary;
  8341. }
  8342. this._destination = destination;
  8343. this._uid = uid;
  8344. this._maxUid = Math.max(this._maxUid, uid);
  8345. this._numPositionUpdates = 0;
  8346. }
  8347. _parseCurrentHash() {
  8348. let checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8349. const hash = unescape(getCurrentHash()).substring(1);
  8350. const params = (0, _ui_utils.parseQueryString)(hash);
  8351. const nameddest = params.get("nameddest") || "";
  8352. let page = params.get("page") | 0;
  8353. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  8354. page = null;
  8355. }
  8356. return {
  8357. hash,
  8358. page,
  8359. rotation: this.linkService.rotation
  8360. };
  8361. }
  8362. _updateViewarea(_ref4) {
  8363. let {
  8364. location
  8365. } = _ref4;
  8366. if (this._updateViewareaTimeout) {
  8367. clearTimeout(this._updateViewareaTimeout);
  8368. this._updateViewareaTimeout = null;
  8369. }
  8370. this._position = {
  8371. hash: location.pdfOpenParams.substring(1),
  8372. page: this.linkService.page,
  8373. first: location.pageNumber,
  8374. rotation: location.rotation
  8375. };
  8376. if (this._popStateInProgress) {
  8377. return;
  8378. }
  8379. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  8380. this._numPositionUpdates++;
  8381. }
  8382. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  8383. this._updateViewareaTimeout = setTimeout(() => {
  8384. if (!this._popStateInProgress) {
  8385. this._tryPushCurrentPosition(true);
  8386. }
  8387. this._updateViewareaTimeout = null;
  8388. }, UPDATE_VIEWAREA_TIMEOUT);
  8389. }
  8390. }
  8391. _popState(_ref5) {
  8392. let {
  8393. state
  8394. } = _ref5;
  8395. const newHash = getCurrentHash(),
  8396. hashChanged = this._currentHash !== newHash;
  8397. this._currentHash = newHash;
  8398. if (!state) {
  8399. this._uid++;
  8400. const {
  8401. hash,
  8402. page,
  8403. rotation
  8404. } = this._parseCurrentHash();
  8405. this._pushOrReplaceState({
  8406. hash,
  8407. page,
  8408. rotation
  8409. }, true);
  8410. return;
  8411. }
  8412. if (!this._isValidState(state)) {
  8413. return;
  8414. }
  8415. this._popStateInProgress = true;
  8416. if (hashChanged) {
  8417. this._blockHashChange++;
  8418. (0, _event_utils.waitOnEventOrTimeout)({
  8419. target: window,
  8420. name: "hashchange",
  8421. delay: HASH_CHANGE_TIMEOUT
  8422. }).then(() => {
  8423. this._blockHashChange--;
  8424. });
  8425. }
  8426. const destination = state.destination;
  8427. this._updateInternalState(destination, state.uid, true);
  8428. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  8429. this.linkService.rotation = destination.rotation;
  8430. }
  8431. if (destination.dest) {
  8432. this.linkService.goToDestination(destination.dest);
  8433. } else if (destination.hash) {
  8434. this.linkService.setHash(destination.hash);
  8435. } else if (destination.page) {
  8436. this.linkService.page = destination.page;
  8437. }
  8438. Promise.resolve().then(() => {
  8439. this._popStateInProgress = false;
  8440. });
  8441. }
  8442. _pageHide() {
  8443. if (!this._destination || this._destination.temporary) {
  8444. this._tryPushCurrentPosition();
  8445. }
  8446. }
  8447. _bindEvents() {
  8448. if (this._boundEvents) {
  8449. return;
  8450. }
  8451. this._boundEvents = {
  8452. updateViewarea: this._updateViewarea.bind(this),
  8453. popState: this._popState.bind(this),
  8454. pageHide: this._pageHide.bind(this)
  8455. };
  8456. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  8457. window.addEventListener("popstate", this._boundEvents.popState);
  8458. window.addEventListener("pagehide", this._boundEvents.pageHide);
  8459. }
  8460. _unbindEvents() {
  8461. if (!this._boundEvents) {
  8462. return;
  8463. }
  8464. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  8465. window.removeEventListener("popstate", this._boundEvents.popState);
  8466. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  8467. this._boundEvents = null;
  8468. }
  8469. }
  8470. exports.PDFHistory = PDFHistory;
  8471. function isDestHashesEqual(destHash, pushHash) {
  8472. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  8473. return false;
  8474. }
  8475. if (destHash === pushHash) {
  8476. return true;
  8477. }
  8478. const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  8479. if (nameddest === pushHash) {
  8480. return true;
  8481. }
  8482. return false;
  8483. }
  8484. function isDestArraysEqual(firstDest, secondDest) {
  8485. function isEntryEqual(first, second) {
  8486. if (typeof first !== typeof second) {
  8487. return false;
  8488. }
  8489. if (Array.isArray(first) || Array.isArray(second)) {
  8490. return false;
  8491. }
  8492. if (first !== null && typeof first === "object" && second !== null) {
  8493. if (Object.keys(first).length !== Object.keys(second).length) {
  8494. return false;
  8495. }
  8496. for (const key in first) {
  8497. if (!isEntryEqual(first[key], second[key])) {
  8498. return false;
  8499. }
  8500. }
  8501. return true;
  8502. }
  8503. return first === second || Number.isNaN(first) && Number.isNaN(second);
  8504. }
  8505. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  8506. return false;
  8507. }
  8508. if (firstDest.length !== secondDest.length) {
  8509. return false;
  8510. }
  8511. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  8512. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  8513. return false;
  8514. }
  8515. }
  8516. return true;
  8517. }
  8518. /***/ }),
  8519. /* 137 */
  8520. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8521. "use strict";
  8522. Object.defineProperty(exports, "__esModule", ({
  8523. value: true
  8524. }));
  8525. exports.PDFLayerViewer = void 0;
  8526. __webpack_require__(89);
  8527. var _base_tree_viewer = __webpack_require__(129);
  8528. class PDFLayerViewer extends _base_tree_viewer.BaseTreeViewer {
  8529. constructor(options) {
  8530. super(options);
  8531. this.l10n = options.l10n;
  8532. this.eventBus._on("optionalcontentconfigchanged", evt => {
  8533. this.#updateLayers(evt.promise);
  8534. });
  8535. this.eventBus._on("resetlayers", () => {
  8536. this.#updateLayers();
  8537. });
  8538. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  8539. }
  8540. reset() {
  8541. super.reset();
  8542. this._optionalContentConfig = null;
  8543. this._optionalContentHash = null;
  8544. }
  8545. _dispatchEvent(layersCount) {
  8546. this.eventBus.dispatch("layersloaded", {
  8547. source: this,
  8548. layersCount
  8549. });
  8550. }
  8551. _bindLink(element, _ref) {
  8552. let {
  8553. groupId,
  8554. input
  8555. } = _ref;
  8556. const setVisibility = () => {
  8557. this._optionalContentConfig.setVisibility(groupId, input.checked);
  8558. this._optionalContentHash = this._optionalContentConfig.getHash();
  8559. this.eventBus.dispatch("optionalcontentconfig", {
  8560. source: this,
  8561. promise: Promise.resolve(this._optionalContentConfig)
  8562. });
  8563. };
  8564. element.onclick = evt => {
  8565. if (evt.target === input) {
  8566. setVisibility();
  8567. return true;
  8568. } else if (evt.target !== element) {
  8569. return true;
  8570. }
  8571. input.checked = !input.checked;
  8572. setVisibility();
  8573. return false;
  8574. };
  8575. }
  8576. async _setNestedName(element, _ref2) {
  8577. let {
  8578. name = null
  8579. } = _ref2;
  8580. if (typeof name === "string") {
  8581. element.textContent = this._normalizeTextContent(name);
  8582. return;
  8583. }
  8584. element.textContent = await this.l10n.get("additional_layers");
  8585. element.style.fontStyle = "italic";
  8586. }
  8587. _addToggleButton(div, _ref3) {
  8588. let {
  8589. name = null
  8590. } = _ref3;
  8591. super._addToggleButton(div, name === null);
  8592. }
  8593. _toggleAllTreeItems() {
  8594. if (!this._optionalContentConfig) {
  8595. return;
  8596. }
  8597. super._toggleAllTreeItems();
  8598. }
  8599. render(_ref4) {
  8600. let {
  8601. optionalContentConfig,
  8602. pdfDocument
  8603. } = _ref4;
  8604. if (this._optionalContentConfig) {
  8605. this.reset();
  8606. }
  8607. this._optionalContentConfig = optionalContentConfig || null;
  8608. this._pdfDocument = pdfDocument || null;
  8609. const groups = optionalContentConfig?.getOrder();
  8610. if (!groups) {
  8611. this._dispatchEvent(0);
  8612. return;
  8613. }
  8614. this._optionalContentHash = optionalContentConfig.getHash();
  8615. const fragment = document.createDocumentFragment(),
  8616. queue = [{
  8617. parent: fragment,
  8618. groups
  8619. }];
  8620. let layersCount = 0,
  8621. hasAnyNesting = false;
  8622. while (queue.length > 0) {
  8623. const levelData = queue.shift();
  8624. for (const groupId of levelData.groups) {
  8625. const div = document.createElement("div");
  8626. div.className = "treeItem";
  8627. const element = document.createElement("a");
  8628. div.append(element);
  8629. if (typeof groupId === "object") {
  8630. hasAnyNesting = true;
  8631. this._addToggleButton(div, groupId);
  8632. this._setNestedName(element, groupId);
  8633. const itemsDiv = document.createElement("div");
  8634. itemsDiv.className = "treeItems";
  8635. div.append(itemsDiv);
  8636. queue.push({
  8637. parent: itemsDiv,
  8638. groups: groupId.order
  8639. });
  8640. } else {
  8641. const group = optionalContentConfig.getGroup(groupId);
  8642. const input = document.createElement("input");
  8643. this._bindLink(element, {
  8644. groupId,
  8645. input
  8646. });
  8647. input.type = "checkbox";
  8648. input.checked = group.visible;
  8649. const label = document.createElement("label");
  8650. label.textContent = this._normalizeTextContent(group.name);
  8651. label.append(input);
  8652. element.append(label);
  8653. layersCount++;
  8654. }
  8655. levelData.parent.append(div);
  8656. }
  8657. }
  8658. this._finishRendering(fragment, layersCount, hasAnyNesting);
  8659. }
  8660. async #updateLayers() {
  8661. let promise = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8662. if (!this._optionalContentConfig) {
  8663. return;
  8664. }
  8665. const pdfDocument = this._pdfDocument;
  8666. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig());
  8667. if (pdfDocument !== this._pdfDocument) {
  8668. return;
  8669. }
  8670. if (promise) {
  8671. if (optionalContentConfig.getHash() === this._optionalContentHash) {
  8672. return;
  8673. }
  8674. } else {
  8675. this.eventBus.dispatch("optionalcontentconfig", {
  8676. source: this,
  8677. promise: Promise.resolve(optionalContentConfig)
  8678. });
  8679. }
  8680. this.render({
  8681. optionalContentConfig,
  8682. pdfDocument: this._pdfDocument
  8683. });
  8684. }
  8685. }
  8686. exports.PDFLayerViewer = PDFLayerViewer;
  8687. /***/ }),
  8688. /* 138 */
  8689. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8690. "use strict";
  8691. Object.defineProperty(exports, "__esModule", ({
  8692. value: true
  8693. }));
  8694. exports.PDFOutlineViewer = void 0;
  8695. __webpack_require__(89);
  8696. __webpack_require__(76);
  8697. var _base_tree_viewer = __webpack_require__(129);
  8698. var _pdfjsLib = __webpack_require__(121);
  8699. var _ui_utils = __webpack_require__(97);
  8700. class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
  8701. constructor(options) {
  8702. super(options);
  8703. this.linkService = options.linkService;
  8704. this.downloadManager = options.downloadManager;
  8705. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  8706. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  8707. this.eventBus._on("pagechanging", evt => {
  8708. this._currentPageNumber = evt.pageNumber;
  8709. });
  8710. this.eventBus._on("pagesloaded", evt => {
  8711. this._isPagesLoaded = !!evt.pagesCount;
  8712. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8713. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8714. }
  8715. });
  8716. this.eventBus._on("sidebarviewchanged", evt => {
  8717. this._sidebarView = evt.view;
  8718. });
  8719. }
  8720. reset() {
  8721. super.reset();
  8722. this._outline = null;
  8723. this._pageNumberToDestHashCapability = null;
  8724. this._currentPageNumber = 1;
  8725. this._isPagesLoaded = null;
  8726. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8727. this._currentOutlineItemCapability.resolve(false);
  8728. }
  8729. this._currentOutlineItemCapability = null;
  8730. }
  8731. _dispatchEvent(outlineCount) {
  8732. this._currentOutlineItemCapability = new _pdfjsLib.PromiseCapability();
  8733. if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
  8734. this._currentOutlineItemCapability.resolve(false);
  8735. } else if (this._isPagesLoaded !== null) {
  8736. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8737. }
  8738. this.eventBus.dispatch("outlineloaded", {
  8739. source: this,
  8740. outlineCount,
  8741. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  8742. });
  8743. }
  8744. _bindLink(element, _ref) {
  8745. let {
  8746. url,
  8747. newWindow,
  8748. action,
  8749. attachment,
  8750. dest,
  8751. setOCGState
  8752. } = _ref;
  8753. const {
  8754. linkService
  8755. } = this;
  8756. if (url) {
  8757. linkService.addLinkAttributes(element, url, newWindow);
  8758. return;
  8759. }
  8760. if (action) {
  8761. element.href = linkService.getAnchorUrl("");
  8762. element.onclick = () => {
  8763. linkService.executeNamedAction(action);
  8764. return false;
  8765. };
  8766. return;
  8767. }
  8768. if (attachment) {
  8769. element.href = linkService.getAnchorUrl("");
  8770. element.onclick = () => {
  8771. this.downloadManager.openOrDownloadData(element, attachment.content, attachment.filename);
  8772. return false;
  8773. };
  8774. return;
  8775. }
  8776. if (setOCGState) {
  8777. element.href = linkService.getAnchorUrl("");
  8778. element.onclick = () => {
  8779. linkService.executeSetOCGState(setOCGState);
  8780. return false;
  8781. };
  8782. return;
  8783. }
  8784. element.href = linkService.getDestinationHash(dest);
  8785. element.onclick = evt => {
  8786. this._updateCurrentTreeItem(evt.target.parentNode);
  8787. if (dest) {
  8788. linkService.goToDestination(dest);
  8789. }
  8790. return false;
  8791. };
  8792. }
  8793. _setStyles(element, _ref2) {
  8794. let {
  8795. bold,
  8796. italic
  8797. } = _ref2;
  8798. if (bold) {
  8799. element.style.fontWeight = "bold";
  8800. }
  8801. if (italic) {
  8802. element.style.fontStyle = "italic";
  8803. }
  8804. }
  8805. _addToggleButton(div, _ref3) {
  8806. let {
  8807. count,
  8808. items
  8809. } = _ref3;
  8810. let hidden = false;
  8811. if (count < 0) {
  8812. let totalCount = items.length;
  8813. if (totalCount > 0) {
  8814. const queue = [...items];
  8815. while (queue.length > 0) {
  8816. const {
  8817. count: nestedCount,
  8818. items: nestedItems
  8819. } = queue.shift();
  8820. if (nestedCount > 0 && nestedItems.length > 0) {
  8821. totalCount += nestedItems.length;
  8822. queue.push(...nestedItems);
  8823. }
  8824. }
  8825. }
  8826. if (Math.abs(count) === totalCount) {
  8827. hidden = true;
  8828. }
  8829. }
  8830. super._addToggleButton(div, hidden);
  8831. }
  8832. _toggleAllTreeItems() {
  8833. if (!this._outline) {
  8834. return;
  8835. }
  8836. super._toggleAllTreeItems();
  8837. }
  8838. render(_ref4) {
  8839. let {
  8840. outline,
  8841. pdfDocument
  8842. } = _ref4;
  8843. if (this._outline) {
  8844. this.reset();
  8845. }
  8846. this._outline = outline || null;
  8847. this._pdfDocument = pdfDocument || null;
  8848. if (!outline) {
  8849. this._dispatchEvent(0);
  8850. return;
  8851. }
  8852. const fragment = document.createDocumentFragment();
  8853. const queue = [{
  8854. parent: fragment,
  8855. items: outline
  8856. }];
  8857. let outlineCount = 0,
  8858. hasAnyNesting = false;
  8859. while (queue.length > 0) {
  8860. const levelData = queue.shift();
  8861. for (const item of levelData.items) {
  8862. const div = document.createElement("div");
  8863. div.className = "treeItem";
  8864. const element = document.createElement("a");
  8865. this._bindLink(element, item);
  8866. this._setStyles(element, item);
  8867. element.textContent = this._normalizeTextContent(item.title);
  8868. div.append(element);
  8869. if (item.items.length > 0) {
  8870. hasAnyNesting = true;
  8871. this._addToggleButton(div, item);
  8872. const itemsDiv = document.createElement("div");
  8873. itemsDiv.className = "treeItems";
  8874. div.append(itemsDiv);
  8875. queue.push({
  8876. parent: itemsDiv,
  8877. items: item.items
  8878. });
  8879. }
  8880. levelData.parent.append(div);
  8881. outlineCount++;
  8882. }
  8883. }
  8884. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8885. }
  8886. async _currentOutlineItem() {
  8887. if (!this._isPagesLoaded) {
  8888. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8889. }
  8890. if (!this._outline || !this._pdfDocument) {
  8891. return;
  8892. }
  8893. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  8894. if (!pageNumberToDestHash) {
  8895. return;
  8896. }
  8897. this._updateCurrentTreeItem(null);
  8898. if (this._sidebarView !== _ui_utils.SidebarView.OUTLINE) {
  8899. return;
  8900. }
  8901. for (let i = this._currentPageNumber; i > 0; i--) {
  8902. const destHash = pageNumberToDestHash.get(i);
  8903. if (!destHash) {
  8904. continue;
  8905. }
  8906. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  8907. if (!linkElement) {
  8908. continue;
  8909. }
  8910. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8911. break;
  8912. }
  8913. }
  8914. async _getPageNumberToDestHash(pdfDocument) {
  8915. if (this._pageNumberToDestHashCapability) {
  8916. return this._pageNumberToDestHashCapability.promise;
  8917. }
  8918. this._pageNumberToDestHashCapability = new _pdfjsLib.PromiseCapability();
  8919. const pageNumberToDestHash = new Map(),
  8920. pageNumberNesting = new Map();
  8921. const queue = [{
  8922. nesting: 0,
  8923. items: this._outline
  8924. }];
  8925. while (queue.length > 0) {
  8926. const levelData = queue.shift(),
  8927. currentNesting = levelData.nesting;
  8928. for (const {
  8929. dest,
  8930. items
  8931. } of levelData.items) {
  8932. let explicitDest, pageNumber;
  8933. if (typeof dest === "string") {
  8934. explicitDest = await pdfDocument.getDestination(dest);
  8935. if (pdfDocument !== this._pdfDocument) {
  8936. return null;
  8937. }
  8938. } else {
  8939. explicitDest = dest;
  8940. }
  8941. if (Array.isArray(explicitDest)) {
  8942. const [destRef] = explicitDest;
  8943. if (typeof destRef === "object" && destRef !== null) {
  8944. pageNumber = this.linkService._cachedPageNumber(destRef);
  8945. if (!pageNumber) {
  8946. try {
  8947. pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
  8948. if (pdfDocument !== this._pdfDocument) {
  8949. return null;
  8950. }
  8951. this.linkService.cachePageRef(pageNumber, destRef);
  8952. } catch {}
  8953. }
  8954. } else if (Number.isInteger(destRef)) {
  8955. pageNumber = destRef + 1;
  8956. }
  8957. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8958. const destHash = this.linkService.getDestinationHash(dest);
  8959. pageNumberToDestHash.set(pageNumber, destHash);
  8960. pageNumberNesting.set(pageNumber, currentNesting);
  8961. }
  8962. }
  8963. if (items.length > 0) {
  8964. queue.push({
  8965. nesting: currentNesting + 1,
  8966. items
  8967. });
  8968. }
  8969. }
  8970. }
  8971. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8972. return this._pageNumberToDestHashCapability.promise;
  8973. }
  8974. }
  8975. exports.PDFOutlineViewer = PDFOutlineViewer;
  8976. /***/ }),
  8977. /* 139 */
  8978. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8979. "use strict";
  8980. Object.defineProperty(exports, "__esModule", ({
  8981. value: true
  8982. }));
  8983. exports.PDFPresentationMode = void 0;
  8984. var _ui_utils = __webpack_require__(97);
  8985. var _pdfjsLib = __webpack_require__(121);
  8986. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8987. const ACTIVE_SELECTOR = "pdfPresentationMode";
  8988. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8989. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8990. const PAGE_SWITCH_THRESHOLD = 0.1;
  8991. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8992. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8993. class PDFPresentationMode {
  8994. #state = _ui_utils.PresentationModeState.UNKNOWN;
  8995. #args = null;
  8996. constructor(_ref) {
  8997. let {
  8998. container,
  8999. pdfViewer,
  9000. eventBus
  9001. } = _ref;
  9002. this.container = container;
  9003. this.pdfViewer = pdfViewer;
  9004. this.eventBus = eventBus;
  9005. this.contextMenuOpen = false;
  9006. this.mouseScrollTimeStamp = 0;
  9007. this.mouseScrollDelta = 0;
  9008. this.touchSwipeState = null;
  9009. }
  9010. async request() {
  9011. const {
  9012. container,
  9013. pdfViewer
  9014. } = this;
  9015. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  9016. return false;
  9017. }
  9018. this.#addFullscreenChangeListeners();
  9019. this.#notifyStateChange(_ui_utils.PresentationModeState.CHANGING);
  9020. const promise = container.requestFullscreen();
  9021. this.#args = {
  9022. pageNumber: pdfViewer.currentPageNumber,
  9023. scaleValue: pdfViewer.currentScaleValue,
  9024. scrollMode: pdfViewer.scrollMode,
  9025. spreadMode: null,
  9026. annotationEditorMode: null
  9027. };
  9028. if (pdfViewer.spreadMode !== _ui_utils.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  9029. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  9030. this.#args.spreadMode = pdfViewer.spreadMode;
  9031. }
  9032. if (pdfViewer.annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  9033. this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
  9034. }
  9035. try {
  9036. await promise;
  9037. pdfViewer.focus();
  9038. return true;
  9039. } catch {
  9040. this.#removeFullscreenChangeListeners();
  9041. this.#notifyStateChange(_ui_utils.PresentationModeState.NORMAL);
  9042. }
  9043. return false;
  9044. }
  9045. get active() {
  9046. return this.#state === _ui_utils.PresentationModeState.CHANGING || this.#state === _ui_utils.PresentationModeState.FULLSCREEN;
  9047. }
  9048. #mouseWheel(evt) {
  9049. if (!this.active) {
  9050. return;
  9051. }
  9052. evt.preventDefault();
  9053. const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  9054. const currentTime = Date.now();
  9055. const storedTime = this.mouseScrollTimeStamp;
  9056. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9057. return;
  9058. }
  9059. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9060. this.#resetMouseScrollState();
  9061. }
  9062. this.mouseScrollDelta += delta;
  9063. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9064. const totalDelta = this.mouseScrollDelta;
  9065. this.#resetMouseScrollState();
  9066. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9067. if (success) {
  9068. this.mouseScrollTimeStamp = currentTime;
  9069. }
  9070. }
  9071. }
  9072. #notifyStateChange(state) {
  9073. this.#state = state;
  9074. this.eventBus.dispatch("presentationmodechanged", {
  9075. source: this,
  9076. state
  9077. });
  9078. }
  9079. #enter() {
  9080. this.#notifyStateChange(_ui_utils.PresentationModeState.FULLSCREEN);
  9081. this.container.classList.add(ACTIVE_SELECTOR);
  9082. setTimeout(() => {
  9083. this.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  9084. if (this.#args.spreadMode !== null) {
  9085. this.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  9086. }
  9087. this.pdfViewer.currentPageNumber = this.#args.pageNumber;
  9088. this.pdfViewer.currentScaleValue = "page-fit";
  9089. if (this.#args.annotationEditorMode !== null) {
  9090. this.pdfViewer.annotationEditorMode = {
  9091. mode: _pdfjsLib.AnnotationEditorType.NONE
  9092. };
  9093. }
  9094. }, 0);
  9095. this.#addWindowListeners();
  9096. this.#showControls();
  9097. this.contextMenuOpen = false;
  9098. window.getSelection().removeAllRanges();
  9099. }
  9100. #exit() {
  9101. const pageNumber = this.pdfViewer.currentPageNumber;
  9102. this.container.classList.remove(ACTIVE_SELECTOR);
  9103. setTimeout(() => {
  9104. this.#removeFullscreenChangeListeners();
  9105. this.#notifyStateChange(_ui_utils.PresentationModeState.NORMAL);
  9106. this.pdfViewer.scrollMode = this.#args.scrollMode;
  9107. if (this.#args.spreadMode !== null) {
  9108. this.pdfViewer.spreadMode = this.#args.spreadMode;
  9109. }
  9110. this.pdfViewer.currentScaleValue = this.#args.scaleValue;
  9111. this.pdfViewer.currentPageNumber = pageNumber;
  9112. if (this.#args.annotationEditorMode !== null) {
  9113. this.pdfViewer.annotationEditorMode = {
  9114. mode: this.#args.annotationEditorMode
  9115. };
  9116. }
  9117. this.#args = null;
  9118. }, 0);
  9119. this.#removeWindowListeners();
  9120. this.#hideControls();
  9121. this.#resetMouseScrollState();
  9122. this.contextMenuOpen = false;
  9123. }
  9124. #mouseDown(evt) {
  9125. if (this.contextMenuOpen) {
  9126. this.contextMenuOpen = false;
  9127. evt.preventDefault();
  9128. return;
  9129. }
  9130. if (evt.button !== 0) {
  9131. return;
  9132. }
  9133. if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
  9134. return;
  9135. }
  9136. evt.preventDefault();
  9137. if (evt.shiftKey) {
  9138. this.pdfViewer.previousPage();
  9139. } else {
  9140. this.pdfViewer.nextPage();
  9141. }
  9142. }
  9143. #contextMenu() {
  9144. this.contextMenuOpen = true;
  9145. }
  9146. #showControls() {
  9147. if (this.controlsTimeout) {
  9148. clearTimeout(this.controlsTimeout);
  9149. } else {
  9150. this.container.classList.add(CONTROLS_SELECTOR);
  9151. }
  9152. this.controlsTimeout = setTimeout(() => {
  9153. this.container.classList.remove(CONTROLS_SELECTOR);
  9154. delete this.controlsTimeout;
  9155. }, DELAY_BEFORE_HIDING_CONTROLS);
  9156. }
  9157. #hideControls() {
  9158. if (!this.controlsTimeout) {
  9159. return;
  9160. }
  9161. clearTimeout(this.controlsTimeout);
  9162. this.container.classList.remove(CONTROLS_SELECTOR);
  9163. delete this.controlsTimeout;
  9164. }
  9165. #resetMouseScrollState() {
  9166. this.mouseScrollTimeStamp = 0;
  9167. this.mouseScrollDelta = 0;
  9168. }
  9169. #touchSwipe(evt) {
  9170. if (!this.active) {
  9171. return;
  9172. }
  9173. if (evt.touches.length > 1) {
  9174. this.touchSwipeState = null;
  9175. return;
  9176. }
  9177. switch (evt.type) {
  9178. case "touchstart":
  9179. this.touchSwipeState = {
  9180. startX: evt.touches[0].pageX,
  9181. startY: evt.touches[0].pageY,
  9182. endX: evt.touches[0].pageX,
  9183. endY: evt.touches[0].pageY
  9184. };
  9185. break;
  9186. case "touchmove":
  9187. if (this.touchSwipeState === null) {
  9188. return;
  9189. }
  9190. this.touchSwipeState.endX = evt.touches[0].pageX;
  9191. this.touchSwipeState.endY = evt.touches[0].pageY;
  9192. evt.preventDefault();
  9193. break;
  9194. case "touchend":
  9195. if (this.touchSwipeState === null) {
  9196. return;
  9197. }
  9198. let delta = 0;
  9199. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9200. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9201. const absAngle = Math.abs(Math.atan2(dy, dx));
  9202. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9203. delta = dx;
  9204. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9205. delta = dy;
  9206. }
  9207. if (delta > 0) {
  9208. this.pdfViewer.previousPage();
  9209. } else if (delta < 0) {
  9210. this.pdfViewer.nextPage();
  9211. }
  9212. break;
  9213. }
  9214. }
  9215. #addWindowListeners() {
  9216. this.showControlsBind = this.#showControls.bind(this);
  9217. this.mouseDownBind = this.#mouseDown.bind(this);
  9218. this.mouseWheelBind = this.#mouseWheel.bind(this);
  9219. this.resetMouseScrollStateBind = this.#resetMouseScrollState.bind(this);
  9220. this.contextMenuBind = this.#contextMenu.bind(this);
  9221. this.touchSwipeBind = this.#touchSwipe.bind(this);
  9222. window.addEventListener("mousemove", this.showControlsBind);
  9223. window.addEventListener("mousedown", this.mouseDownBind);
  9224. window.addEventListener("wheel", this.mouseWheelBind, {
  9225. passive: false
  9226. });
  9227. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9228. window.addEventListener("contextmenu", this.contextMenuBind);
  9229. window.addEventListener("touchstart", this.touchSwipeBind);
  9230. window.addEventListener("touchmove", this.touchSwipeBind);
  9231. window.addEventListener("touchend", this.touchSwipeBind);
  9232. }
  9233. #removeWindowListeners() {
  9234. window.removeEventListener("mousemove", this.showControlsBind);
  9235. window.removeEventListener("mousedown", this.mouseDownBind);
  9236. window.removeEventListener("wheel", this.mouseWheelBind, {
  9237. passive: false
  9238. });
  9239. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9240. window.removeEventListener("contextmenu", this.contextMenuBind);
  9241. window.removeEventListener("touchstart", this.touchSwipeBind);
  9242. window.removeEventListener("touchmove", this.touchSwipeBind);
  9243. window.removeEventListener("touchend", this.touchSwipeBind);
  9244. delete this.showControlsBind;
  9245. delete this.mouseDownBind;
  9246. delete this.mouseWheelBind;
  9247. delete this.resetMouseScrollStateBind;
  9248. delete this.contextMenuBind;
  9249. delete this.touchSwipeBind;
  9250. }
  9251. #fullscreenChange() {
  9252. if (document.fullscreenElement) {
  9253. this.#enter();
  9254. } else {
  9255. this.#exit();
  9256. }
  9257. }
  9258. #addFullscreenChangeListeners() {
  9259. this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
  9260. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9261. }
  9262. #removeFullscreenChangeListeners() {
  9263. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9264. delete this.fullscreenChangeBind;
  9265. }
  9266. }
  9267. exports.PDFPresentationMode = PDFPresentationMode;
  9268. /***/ }),
  9269. /* 140 */
  9270. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9271. "use strict";
  9272. Object.defineProperty(exports, "__esModule", ({
  9273. value: true
  9274. }));
  9275. exports.PDFRenderingQueue = void 0;
  9276. var _pdfjsLib = __webpack_require__(121);
  9277. var _ui_utils = __webpack_require__(97);
  9278. const CLEANUP_TIMEOUT = 30000;
  9279. class PDFRenderingQueue {
  9280. constructor() {
  9281. this.pdfViewer = null;
  9282. this.pdfThumbnailViewer = null;
  9283. this.onIdle = null;
  9284. this.highestPriorityPage = null;
  9285. this.idleTimeout = null;
  9286. this.printing = false;
  9287. this.isThumbnailViewEnabled = false;
  9288. Object.defineProperty(this, "hasViewer", {
  9289. value: () => !!this.pdfViewer
  9290. });
  9291. }
  9292. setViewer(pdfViewer) {
  9293. this.pdfViewer = pdfViewer;
  9294. }
  9295. setThumbnailViewer(pdfThumbnailViewer) {
  9296. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9297. }
  9298. isHighestPriority(view) {
  9299. return this.highestPriorityPage === view.renderingId;
  9300. }
  9301. renderHighestPriority(currentlyVisiblePages) {
  9302. if (this.idleTimeout) {
  9303. clearTimeout(this.idleTimeout);
  9304. this.idleTimeout = null;
  9305. }
  9306. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  9307. return;
  9308. }
  9309. if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
  9310. return;
  9311. }
  9312. if (this.printing) {
  9313. return;
  9314. }
  9315. if (this.onIdle) {
  9316. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  9317. }
  9318. }
  9319. getHighestPriority(visible, views, scrolledDown) {
  9320. let preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9321. const visibleViews = visible.views,
  9322. numVisible = visibleViews.length;
  9323. if (numVisible === 0) {
  9324. return null;
  9325. }
  9326. for (let i = 0; i < numVisible; i++) {
  9327. const view = visibleViews[i].view;
  9328. if (!this.isViewFinished(view)) {
  9329. return view;
  9330. }
  9331. }
  9332. const firstId = visible.first.id,
  9333. lastId = visible.last.id;
  9334. if (lastId - firstId + 1 > numVisible) {
  9335. const visibleIds = visible.ids;
  9336. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  9337. const holeId = scrolledDown ? firstId + i : lastId - i;
  9338. if (visibleIds.has(holeId)) {
  9339. continue;
  9340. }
  9341. const holeView = views[holeId - 1];
  9342. if (!this.isViewFinished(holeView)) {
  9343. return holeView;
  9344. }
  9345. }
  9346. }
  9347. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  9348. let preRenderView = views[preRenderIndex];
  9349. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9350. return preRenderView;
  9351. }
  9352. if (preRenderExtra) {
  9353. preRenderIndex += scrolledDown ? 1 : -1;
  9354. preRenderView = views[preRenderIndex];
  9355. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9356. return preRenderView;
  9357. }
  9358. }
  9359. return null;
  9360. }
  9361. isViewFinished(view) {
  9362. return view.renderingState === _ui_utils.RenderingStates.FINISHED;
  9363. }
  9364. renderView(view) {
  9365. switch (view.renderingState) {
  9366. case _ui_utils.RenderingStates.FINISHED:
  9367. return false;
  9368. case _ui_utils.RenderingStates.PAUSED:
  9369. this.highestPriorityPage = view.renderingId;
  9370. view.resume();
  9371. break;
  9372. case _ui_utils.RenderingStates.RUNNING:
  9373. this.highestPriorityPage = view.renderingId;
  9374. break;
  9375. case _ui_utils.RenderingStates.INITIAL:
  9376. this.highestPriorityPage = view.renderingId;
  9377. view.draw().finally(() => {
  9378. this.renderHighestPriority();
  9379. }).catch(reason => {
  9380. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  9381. return;
  9382. }
  9383. console.error(`renderView: "${reason}"`);
  9384. });
  9385. break;
  9386. }
  9387. return true;
  9388. }
  9389. }
  9390. exports.PDFRenderingQueue = PDFRenderingQueue;
  9391. /***/ }),
  9392. /* 141 */
  9393. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9394. "use strict";
  9395. Object.defineProperty(exports, "__esModule", ({
  9396. value: true
  9397. }));
  9398. exports.PDFScriptingManager = void 0;
  9399. __webpack_require__(98);
  9400. __webpack_require__(108);
  9401. __webpack_require__(110);
  9402. __webpack_require__(113);
  9403. __webpack_require__(115);
  9404. __webpack_require__(117);
  9405. __webpack_require__(119);
  9406. __webpack_require__(76);
  9407. var _ui_utils = __webpack_require__(97);
  9408. var _pdfjsLib = __webpack_require__(121);
  9409. class PDFScriptingManager {
  9410. #closeCapability = null;
  9411. #destroyCapability = null;
  9412. #docProperties = null;
  9413. #eventBus = null;
  9414. #externalServices = null;
  9415. #pdfDocument = null;
  9416. #pdfViewer = null;
  9417. #ready = false;
  9418. #sandboxBundleSrc = null;
  9419. #scripting = null;
  9420. constructor(_ref) {
  9421. let {
  9422. eventBus,
  9423. sandboxBundleSrc = null,
  9424. externalServices = null,
  9425. docProperties = null
  9426. } = _ref;
  9427. this.#eventBus = eventBus;
  9428. this.#sandboxBundleSrc = sandboxBundleSrc;
  9429. this.#externalServices = externalServices;
  9430. this.#docProperties = docProperties;
  9431. }
  9432. setViewer(pdfViewer) {
  9433. this.#pdfViewer = pdfViewer;
  9434. }
  9435. async setDocument(pdfDocument) {
  9436. if (this.#pdfDocument) {
  9437. await this.#destroyScripting();
  9438. }
  9439. this.#pdfDocument = pdfDocument;
  9440. if (!pdfDocument) {
  9441. return;
  9442. }
  9443. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  9444. if (!objects && !docActions) {
  9445. await this.#destroyScripting();
  9446. return;
  9447. }
  9448. if (pdfDocument !== this.#pdfDocument) {
  9449. return;
  9450. }
  9451. try {
  9452. this.#scripting = this.#initScripting();
  9453. } catch (error) {
  9454. console.error(`setDocument: "${error.message}".`);
  9455. await this.#destroyScripting();
  9456. return;
  9457. }
  9458. this._internalEvents.set("updatefromsandbox", event => {
  9459. if (event?.source === window) {
  9460. this.#updateFromSandbox(event.detail);
  9461. }
  9462. });
  9463. this._internalEvents.set("dispatcheventinsandbox", event => {
  9464. this.#scripting?.dispatchEventInSandbox(event.detail);
  9465. });
  9466. this._internalEvents.set("pagechanging", _ref2 => {
  9467. let {
  9468. pageNumber,
  9469. previous
  9470. } = _ref2;
  9471. if (pageNumber === previous) {
  9472. return;
  9473. }
  9474. this.#dispatchPageClose(previous);
  9475. this.#dispatchPageOpen(pageNumber);
  9476. });
  9477. this._internalEvents.set("pagerendered", _ref3 => {
  9478. let {
  9479. pageNumber
  9480. } = _ref3;
  9481. if (!this._pageOpenPending.has(pageNumber)) {
  9482. return;
  9483. }
  9484. if (pageNumber !== this.#pdfViewer.currentPageNumber) {
  9485. return;
  9486. }
  9487. this.#dispatchPageOpen(pageNumber);
  9488. });
  9489. this._internalEvents.set("pagesdestroy", async () => {
  9490. await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
  9491. await this.#scripting?.dispatchEventInSandbox({
  9492. id: "doc",
  9493. name: "WillClose"
  9494. });
  9495. this.#closeCapability?.resolve();
  9496. });
  9497. for (const [name, listener] of this._internalEvents) {
  9498. this.#eventBus._on(name, listener);
  9499. }
  9500. try {
  9501. const docProperties = await this.#docProperties(pdfDocument);
  9502. if (pdfDocument !== this.#pdfDocument) {
  9503. return;
  9504. }
  9505. await this.#scripting.createSandbox({
  9506. objects,
  9507. calculationOrder,
  9508. appInfo: {
  9509. platform: navigator.platform,
  9510. language: navigator.language
  9511. },
  9512. docInfo: {
  9513. ...docProperties,
  9514. actions: docActions
  9515. }
  9516. });
  9517. this.#eventBus.dispatch("sandboxcreated", {
  9518. source: this
  9519. });
  9520. } catch (error) {
  9521. console.error(`setDocument: "${error.message}".`);
  9522. await this.#destroyScripting();
  9523. return;
  9524. }
  9525. await this.#scripting?.dispatchEventInSandbox({
  9526. id: "doc",
  9527. name: "Open"
  9528. });
  9529. await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
  9530. Promise.resolve().then(() => {
  9531. if (pdfDocument === this.#pdfDocument) {
  9532. this.#ready = true;
  9533. }
  9534. });
  9535. }
  9536. async dispatchWillSave() {
  9537. return this.#scripting?.dispatchEventInSandbox({
  9538. id: "doc",
  9539. name: "WillSave"
  9540. });
  9541. }
  9542. async dispatchDidSave() {
  9543. return this.#scripting?.dispatchEventInSandbox({
  9544. id: "doc",
  9545. name: "DidSave"
  9546. });
  9547. }
  9548. async dispatchWillPrint() {
  9549. return this.#scripting?.dispatchEventInSandbox({
  9550. id: "doc",
  9551. name: "WillPrint"
  9552. });
  9553. }
  9554. async dispatchDidPrint() {
  9555. return this.#scripting?.dispatchEventInSandbox({
  9556. id: "doc",
  9557. name: "DidPrint"
  9558. });
  9559. }
  9560. get destroyPromise() {
  9561. return this.#destroyCapability?.promise || null;
  9562. }
  9563. get ready() {
  9564. return this.#ready;
  9565. }
  9566. get _internalEvents() {
  9567. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  9568. }
  9569. get _pageOpenPending() {
  9570. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  9571. }
  9572. get _visitedPages() {
  9573. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  9574. }
  9575. async #updateFromSandbox(detail) {
  9576. const pdfViewer = this.#pdfViewer;
  9577. const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
  9578. const {
  9579. id,
  9580. siblings,
  9581. command,
  9582. value
  9583. } = detail;
  9584. if (!id) {
  9585. switch (command) {
  9586. case "clear":
  9587. console.clear();
  9588. break;
  9589. case "error":
  9590. console.error(value);
  9591. break;
  9592. case "layout":
  9593. if (!isInPresentationMode) {
  9594. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
  9595. pdfViewer.spreadMode = modes.spreadMode;
  9596. }
  9597. break;
  9598. case "page-num":
  9599. pdfViewer.currentPageNumber = value + 1;
  9600. break;
  9601. case "print":
  9602. await pdfViewer.pagesPromise;
  9603. this.#eventBus.dispatch("print", {
  9604. source: this
  9605. });
  9606. break;
  9607. case "println":
  9608. console.log(value);
  9609. break;
  9610. case "zoom":
  9611. if (!isInPresentationMode) {
  9612. pdfViewer.currentScaleValue = value;
  9613. }
  9614. break;
  9615. case "SaveAs":
  9616. this.#eventBus.dispatch("download", {
  9617. source: this
  9618. });
  9619. break;
  9620. case "FirstPage":
  9621. pdfViewer.currentPageNumber = 1;
  9622. break;
  9623. case "LastPage":
  9624. pdfViewer.currentPageNumber = pdfViewer.pagesCount;
  9625. break;
  9626. case "NextPage":
  9627. pdfViewer.nextPage();
  9628. break;
  9629. case "PrevPage":
  9630. pdfViewer.previousPage();
  9631. break;
  9632. case "ZoomViewIn":
  9633. if (!isInPresentationMode) {
  9634. pdfViewer.increaseScale();
  9635. }
  9636. break;
  9637. case "ZoomViewOut":
  9638. if (!isInPresentationMode) {
  9639. pdfViewer.decreaseScale();
  9640. }
  9641. break;
  9642. }
  9643. return;
  9644. }
  9645. if (isInPresentationMode && detail.focus) {
  9646. return;
  9647. }
  9648. delete detail.id;
  9649. delete detail.siblings;
  9650. const ids = siblings ? [id, ...siblings] : [id];
  9651. for (const elementId of ids) {
  9652. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  9653. if (element) {
  9654. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  9655. detail
  9656. }));
  9657. } else {
  9658. this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
  9659. }
  9660. }
  9661. }
  9662. async #dispatchPageOpen(pageNumber) {
  9663. let initialize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9664. const pdfDocument = this.#pdfDocument,
  9665. visitedPages = this._visitedPages;
  9666. if (initialize) {
  9667. this.#closeCapability = new _pdfjsLib.PromiseCapability();
  9668. }
  9669. if (!this.#closeCapability) {
  9670. return;
  9671. }
  9672. const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
  9673. if (pageView?.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9674. this._pageOpenPending.add(pageNumber);
  9675. return;
  9676. }
  9677. this._pageOpenPending.delete(pageNumber);
  9678. const actionsPromise = (async () => {
  9679. const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
  9680. if (pdfDocument !== this.#pdfDocument) {
  9681. return;
  9682. }
  9683. await this.#scripting?.dispatchEventInSandbox({
  9684. id: "page",
  9685. name: "PageOpen",
  9686. pageNumber,
  9687. actions
  9688. });
  9689. })();
  9690. visitedPages.set(pageNumber, actionsPromise);
  9691. }
  9692. async #dispatchPageClose(pageNumber) {
  9693. const pdfDocument = this.#pdfDocument,
  9694. visitedPages = this._visitedPages;
  9695. if (!this.#closeCapability) {
  9696. return;
  9697. }
  9698. if (this._pageOpenPending.has(pageNumber)) {
  9699. return;
  9700. }
  9701. const actionsPromise = visitedPages.get(pageNumber);
  9702. if (!actionsPromise) {
  9703. return;
  9704. }
  9705. visitedPages.set(pageNumber, null);
  9706. await actionsPromise;
  9707. if (pdfDocument !== this.#pdfDocument) {
  9708. return;
  9709. }
  9710. await this.#scripting?.dispatchEventInSandbox({
  9711. id: "page",
  9712. name: "PageClose",
  9713. pageNumber
  9714. });
  9715. }
  9716. #initScripting() {
  9717. this.#destroyCapability = new _pdfjsLib.PromiseCapability();
  9718. if (this.#scripting) {
  9719. throw new Error("#initScripting: Scripting already exists.");
  9720. }
  9721. return this.#externalServices.createScripting({
  9722. sandboxBundleSrc: this.#sandboxBundleSrc
  9723. });
  9724. }
  9725. async #destroyScripting() {
  9726. if (!this.#scripting) {
  9727. this.#pdfDocument = null;
  9728. this.#destroyCapability?.resolve();
  9729. return;
  9730. }
  9731. if (this.#closeCapability) {
  9732. await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
  9733. setTimeout(resolve, 1000);
  9734. })]).catch(() => {});
  9735. this.#closeCapability = null;
  9736. }
  9737. this.#pdfDocument = null;
  9738. try {
  9739. await this.#scripting.destroySandbox();
  9740. } catch {}
  9741. for (const [name, listener] of this._internalEvents) {
  9742. this.#eventBus._off(name, listener);
  9743. }
  9744. this._internalEvents.clear();
  9745. this._pageOpenPending.clear();
  9746. this._visitedPages.clear();
  9747. this.#scripting = null;
  9748. this.#ready = false;
  9749. this.#destroyCapability?.resolve();
  9750. }
  9751. }
  9752. exports.PDFScriptingManager = PDFScriptingManager;
  9753. /***/ }),
  9754. /* 142 */
  9755. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9756. "use strict";
  9757. Object.defineProperty(exports, "__esModule", ({
  9758. value: true
  9759. }));
  9760. exports.PDFSidebar = void 0;
  9761. var _ui_utils = __webpack_require__(97);
  9762. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9763. const SIDEBAR_MIN_WIDTH = 200;
  9764. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9765. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9766. class PDFSidebar {
  9767. #isRTL = false;
  9768. #mouseMoveBound = this.#mouseMove.bind(this);
  9769. #mouseUpBound = this.#mouseUp.bind(this);
  9770. #outerContainerWidth = null;
  9771. #width = null;
  9772. constructor(_ref) {
  9773. let {
  9774. elements,
  9775. eventBus,
  9776. l10n
  9777. } = _ref;
  9778. this.isOpen = false;
  9779. this.active = _ui_utils.SidebarView.THUMBS;
  9780. this.isInitialViewSet = false;
  9781. this.isInitialEventDispatched = false;
  9782. this.onToggled = null;
  9783. this.onUpdateThumbnails = null;
  9784. this.outerContainer = elements.outerContainer;
  9785. this.sidebarContainer = elements.sidebarContainer;
  9786. this.toggleButton = elements.toggleButton;
  9787. this.resizer = elements.resizer;
  9788. this.thumbnailButton = elements.thumbnailButton;
  9789. this.outlineButton = elements.outlineButton;
  9790. this.attachmentsButton = elements.attachmentsButton;
  9791. this.layersButton = elements.layersButton;
  9792. this.thumbnailView = elements.thumbnailView;
  9793. this.outlineView = elements.outlineView;
  9794. this.attachmentsView = elements.attachmentsView;
  9795. this.layersView = elements.layersView;
  9796. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9797. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9798. this.eventBus = eventBus;
  9799. this.l10n = l10n;
  9800. l10n.getDirection().then(dir => {
  9801. this.#isRTL = dir === "rtl";
  9802. });
  9803. this.#addEventListeners();
  9804. }
  9805. reset() {
  9806. this.isInitialViewSet = false;
  9807. this.isInitialEventDispatched = false;
  9808. this.#hideUINotification(true);
  9809. this.switchView(_ui_utils.SidebarView.THUMBS);
  9810. this.outlineButton.disabled = false;
  9811. this.attachmentsButton.disabled = false;
  9812. this.layersButton.disabled = false;
  9813. this._currentOutlineItemButton.disabled = true;
  9814. }
  9815. get visibleView() {
  9816. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9817. }
  9818. setInitialView() {
  9819. let view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9820. if (this.isInitialViewSet) {
  9821. return;
  9822. }
  9823. this.isInitialViewSet = true;
  9824. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9825. this.#dispatchEvent();
  9826. return;
  9827. }
  9828. this.switchView(view, true);
  9829. if (!this.isInitialEventDispatched) {
  9830. this.#dispatchEvent();
  9831. }
  9832. }
  9833. switchView(view) {
  9834. let forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9835. const isViewChanged = view !== this.active;
  9836. let forceRendering = false;
  9837. switch (view) {
  9838. case _ui_utils.SidebarView.NONE:
  9839. if (this.isOpen) {
  9840. this.close();
  9841. }
  9842. return;
  9843. case _ui_utils.SidebarView.THUMBS:
  9844. if (this.isOpen && isViewChanged) {
  9845. forceRendering = true;
  9846. }
  9847. break;
  9848. case _ui_utils.SidebarView.OUTLINE:
  9849. if (this.outlineButton.disabled) {
  9850. return;
  9851. }
  9852. break;
  9853. case _ui_utils.SidebarView.ATTACHMENTS:
  9854. if (this.attachmentsButton.disabled) {
  9855. return;
  9856. }
  9857. break;
  9858. case _ui_utils.SidebarView.LAYERS:
  9859. if (this.layersButton.disabled) {
  9860. return;
  9861. }
  9862. break;
  9863. default:
  9864. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  9865. return;
  9866. }
  9867. this.active = view;
  9868. (0, _ui_utils.toggleCheckedBtn)(this.thumbnailButton, view === _ui_utils.SidebarView.THUMBS, this.thumbnailView);
  9869. (0, _ui_utils.toggleCheckedBtn)(this.outlineButton, view === _ui_utils.SidebarView.OUTLINE, this.outlineView);
  9870. (0, _ui_utils.toggleCheckedBtn)(this.attachmentsButton, view === _ui_utils.SidebarView.ATTACHMENTS, this.attachmentsView);
  9871. (0, _ui_utils.toggleCheckedBtn)(this.layersButton, view === _ui_utils.SidebarView.LAYERS, this.layersView);
  9872. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9873. if (forceOpen && !this.isOpen) {
  9874. this.open();
  9875. return;
  9876. }
  9877. if (forceRendering) {
  9878. this.onUpdateThumbnails();
  9879. this.onToggled();
  9880. }
  9881. if (isViewChanged) {
  9882. this.#dispatchEvent();
  9883. }
  9884. }
  9885. open() {
  9886. if (this.isOpen) {
  9887. return;
  9888. }
  9889. this.isOpen = true;
  9890. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true);
  9891. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9892. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9893. this.onUpdateThumbnails();
  9894. }
  9895. this.onToggled();
  9896. this.#dispatchEvent();
  9897. this.#hideUINotification();
  9898. }
  9899. close() {
  9900. if (!this.isOpen) {
  9901. return;
  9902. }
  9903. this.isOpen = false;
  9904. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false);
  9905. this.outerContainer.classList.add("sidebarMoving");
  9906. this.outerContainer.classList.remove("sidebarOpen");
  9907. this.onToggled();
  9908. this.#dispatchEvent();
  9909. }
  9910. toggle() {
  9911. if (this.isOpen) {
  9912. this.close();
  9913. } else {
  9914. this.open();
  9915. }
  9916. }
  9917. #dispatchEvent() {
  9918. if (this.isInitialViewSet) {
  9919. this.isInitialEventDispatched ||= true;
  9920. }
  9921. this.eventBus.dispatch("sidebarviewchanged", {
  9922. source: this,
  9923. view: this.visibleView
  9924. });
  9925. }
  9926. #showUINotification() {
  9927. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar_notification2");
  9928. this.l10n.translate(this.toggleButton);
  9929. if (!this.isOpen) {
  9930. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9931. }
  9932. }
  9933. #hideUINotification() {
  9934. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9935. if (this.isOpen || reset) {
  9936. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9937. }
  9938. if (reset) {
  9939. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar");
  9940. this.l10n.translate(this.toggleButton);
  9941. }
  9942. }
  9943. #addEventListeners() {
  9944. this.sidebarContainer.addEventListener("transitionend", evt => {
  9945. if (evt.target === this.sidebarContainer) {
  9946. this.outerContainer.classList.remove("sidebarMoving");
  9947. }
  9948. });
  9949. this.toggleButton.addEventListener("click", () => {
  9950. this.toggle();
  9951. });
  9952. this.thumbnailButton.addEventListener("click", () => {
  9953. this.switchView(_ui_utils.SidebarView.THUMBS);
  9954. });
  9955. this.outlineButton.addEventListener("click", () => {
  9956. this.switchView(_ui_utils.SidebarView.OUTLINE);
  9957. });
  9958. this.outlineButton.addEventListener("dblclick", () => {
  9959. this.eventBus.dispatch("toggleoutlinetree", {
  9960. source: this
  9961. });
  9962. });
  9963. this.attachmentsButton.addEventListener("click", () => {
  9964. this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9965. });
  9966. this.layersButton.addEventListener("click", () => {
  9967. this.switchView(_ui_utils.SidebarView.LAYERS);
  9968. });
  9969. this.layersButton.addEventListener("dblclick", () => {
  9970. this.eventBus.dispatch("resetlayers", {
  9971. source: this
  9972. });
  9973. });
  9974. this._currentOutlineItemButton.addEventListener("click", () => {
  9975. this.eventBus.dispatch("currentoutlineitem", {
  9976. source: this
  9977. });
  9978. });
  9979. const onTreeLoaded = (count, button, view) => {
  9980. button.disabled = !count;
  9981. if (count) {
  9982. this.#showUINotification();
  9983. } else if (this.active === view) {
  9984. this.switchView(_ui_utils.SidebarView.THUMBS);
  9985. }
  9986. };
  9987. this.eventBus._on("outlineloaded", evt => {
  9988. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9989. evt.currentOutlineItemPromise.then(enabled => {
  9990. if (!this.isInitialViewSet) {
  9991. return;
  9992. }
  9993. this._currentOutlineItemButton.disabled = !enabled;
  9994. });
  9995. });
  9996. this.eventBus._on("attachmentsloaded", evt => {
  9997. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9998. });
  9999. this.eventBus._on("layersloaded", evt => {
  10000. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView.LAYERS);
  10001. });
  10002. this.eventBus._on("presentationmodechanged", evt => {
  10003. if (evt.state === _ui_utils.PresentationModeState.NORMAL && this.visibleView === _ui_utils.SidebarView.THUMBS) {
  10004. this.onUpdateThumbnails();
  10005. }
  10006. });
  10007. this.resizer.addEventListener("mousedown", evt => {
  10008. if (evt.button !== 0) {
  10009. return;
  10010. }
  10011. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10012. window.addEventListener("mousemove", this.#mouseMoveBound);
  10013. window.addEventListener("mouseup", this.#mouseUpBound);
  10014. });
  10015. this.eventBus._on("resize", evt => {
  10016. if (evt.source !== window) {
  10017. return;
  10018. }
  10019. this.#outerContainerWidth = null;
  10020. if (!this.#width) {
  10021. return;
  10022. }
  10023. if (!this.isOpen) {
  10024. this.#updateWidth(this.#width);
  10025. return;
  10026. }
  10027. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10028. const updated = this.#updateWidth(this.#width);
  10029. Promise.resolve().then(() => {
  10030. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10031. if (updated) {
  10032. this.eventBus.dispatch("resize", {
  10033. source: this
  10034. });
  10035. }
  10036. });
  10037. });
  10038. }
  10039. get outerContainerWidth() {
  10040. return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
  10041. }
  10042. #updateWidth() {
  10043. let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10044. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  10045. if (width > maxWidth) {
  10046. width = maxWidth;
  10047. }
  10048. if (width < SIDEBAR_MIN_WIDTH) {
  10049. width = SIDEBAR_MIN_WIDTH;
  10050. }
  10051. if (width === this.#width) {
  10052. return false;
  10053. }
  10054. this.#width = width;
  10055. _ui_utils.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  10056. return true;
  10057. }
  10058. #mouseMove(evt) {
  10059. let width = evt.clientX;
  10060. if (this.#isRTL) {
  10061. width = this.outerContainerWidth - width;
  10062. }
  10063. this.#updateWidth(width);
  10064. }
  10065. #mouseUp(evt) {
  10066. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10067. this.eventBus.dispatch("resize", {
  10068. source: this
  10069. });
  10070. window.removeEventListener("mousemove", this.#mouseMoveBound);
  10071. window.removeEventListener("mouseup", this.#mouseUpBound);
  10072. }
  10073. }
  10074. exports.PDFSidebar = PDFSidebar;
  10075. /***/ }),
  10076. /* 143 */
  10077. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10078. "use strict";
  10079. Object.defineProperty(exports, "__esModule", ({
  10080. value: true
  10081. }));
  10082. exports.PDFThumbnailViewer = void 0;
  10083. __webpack_require__(76);
  10084. __webpack_require__(89);
  10085. var _ui_utils = __webpack_require__(97);
  10086. var _pdf_thumbnail_view = __webpack_require__(144);
  10087. const THUMBNAIL_SCROLL_MARGIN = -19;
  10088. const THUMBNAIL_SELECTED_CLASS = "selected";
  10089. class PDFThumbnailViewer {
  10090. constructor(_ref) {
  10091. let {
  10092. container,
  10093. eventBus,
  10094. linkService,
  10095. renderingQueue,
  10096. l10n,
  10097. pageColors
  10098. } = _ref;
  10099. this.container = container;
  10100. this.eventBus = eventBus;
  10101. this.linkService = linkService;
  10102. this.renderingQueue = renderingQueue;
  10103. this.l10n = l10n;
  10104. this.pageColors = pageColors || null;
  10105. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  10106. this._resetView();
  10107. }
  10108. _scrollUpdated() {
  10109. this.renderingQueue.renderHighestPriority();
  10110. }
  10111. getThumbnail(index) {
  10112. return this._thumbnails[index];
  10113. }
  10114. _getVisibleThumbs() {
  10115. return (0, _ui_utils.getVisibleElements)({
  10116. scrollEl: this.container,
  10117. views: this._thumbnails
  10118. });
  10119. }
  10120. scrollThumbnailIntoView(pageNumber) {
  10121. if (!this.pdfDocument) {
  10122. return;
  10123. }
  10124. const thumbnailView = this._thumbnails[pageNumber - 1];
  10125. if (!thumbnailView) {
  10126. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  10127. return;
  10128. }
  10129. if (pageNumber !== this._currentPageNumber) {
  10130. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10131. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  10132. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10133. }
  10134. const {
  10135. first,
  10136. last,
  10137. views
  10138. } = this._getVisibleThumbs();
  10139. if (views.length > 0) {
  10140. let shouldScroll = false;
  10141. if (pageNumber <= first.id || pageNumber >= last.id) {
  10142. shouldScroll = true;
  10143. } else {
  10144. for (const {
  10145. id,
  10146. percent
  10147. } of views) {
  10148. if (id !== pageNumber) {
  10149. continue;
  10150. }
  10151. shouldScroll = percent < 100;
  10152. break;
  10153. }
  10154. }
  10155. if (shouldScroll) {
  10156. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  10157. top: THUMBNAIL_SCROLL_MARGIN
  10158. });
  10159. }
  10160. }
  10161. this._currentPageNumber = pageNumber;
  10162. }
  10163. get pagesRotation() {
  10164. return this._pagesRotation;
  10165. }
  10166. set pagesRotation(rotation) {
  10167. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10168. throw new Error("Invalid thumbnails rotation angle.");
  10169. }
  10170. if (!this.pdfDocument) {
  10171. return;
  10172. }
  10173. if (this._pagesRotation === rotation) {
  10174. return;
  10175. }
  10176. this._pagesRotation = rotation;
  10177. const updateArgs = {
  10178. rotation
  10179. };
  10180. for (const thumbnail of this._thumbnails) {
  10181. thumbnail.update(updateArgs);
  10182. }
  10183. }
  10184. cleanup() {
  10185. for (const thumbnail of this._thumbnails) {
  10186. if (thumbnail.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10187. thumbnail.reset();
  10188. }
  10189. }
  10190. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  10191. }
  10192. _resetView() {
  10193. this._thumbnails = [];
  10194. this._currentPageNumber = 1;
  10195. this._pageLabels = null;
  10196. this._pagesRotation = 0;
  10197. this.container.textContent = "";
  10198. }
  10199. setDocument(pdfDocument) {
  10200. if (this.pdfDocument) {
  10201. this._cancelRendering();
  10202. this._resetView();
  10203. }
  10204. this.pdfDocument = pdfDocument;
  10205. if (!pdfDocument) {
  10206. return;
  10207. }
  10208. const firstPagePromise = pdfDocument.getPage(1);
  10209. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10210. firstPagePromise.then(firstPdfPage => {
  10211. const pagesCount = pdfDocument.numPages;
  10212. const viewport = firstPdfPage.getViewport({
  10213. scale: 1
  10214. });
  10215. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10216. const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  10217. container: this.container,
  10218. eventBus: this.eventBus,
  10219. id: pageNum,
  10220. defaultViewport: viewport.clone(),
  10221. optionalContentConfigPromise,
  10222. linkService: this.linkService,
  10223. renderingQueue: this.renderingQueue,
  10224. l10n: this.l10n,
  10225. pageColors: this.pageColors
  10226. });
  10227. this._thumbnails.push(thumbnail);
  10228. }
  10229. this._thumbnails[0]?.setPdfPage(firstPdfPage);
  10230. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10231. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10232. }).catch(reason => {
  10233. console.error("Unable to initialize thumbnail viewer", reason);
  10234. });
  10235. }
  10236. _cancelRendering() {
  10237. for (const thumbnail of this._thumbnails) {
  10238. thumbnail.cancelRendering();
  10239. }
  10240. }
  10241. setPageLabels(labels) {
  10242. if (!this.pdfDocument) {
  10243. return;
  10244. }
  10245. if (!labels) {
  10246. this._pageLabels = null;
  10247. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10248. this._pageLabels = null;
  10249. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  10250. } else {
  10251. this._pageLabels = labels;
  10252. }
  10253. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  10254. this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
  10255. }
  10256. }
  10257. async #ensurePdfPageLoaded(thumbView) {
  10258. if (thumbView.pdfPage) {
  10259. return thumbView.pdfPage;
  10260. }
  10261. try {
  10262. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  10263. if (!thumbView.pdfPage) {
  10264. thumbView.setPdfPage(pdfPage);
  10265. }
  10266. return pdfPage;
  10267. } catch (reason) {
  10268. console.error("Unable to get page for thumb view", reason);
  10269. return null;
  10270. }
  10271. }
  10272. #getScrollAhead(visible) {
  10273. if (visible.first?.id === 1) {
  10274. return true;
  10275. } else if (visible.last?.id === this._thumbnails.length) {
  10276. return false;
  10277. }
  10278. return this.scroll.down;
  10279. }
  10280. forceRendering() {
  10281. const visibleThumbs = this._getVisibleThumbs();
  10282. const scrollAhead = this.#getScrollAhead(visibleThumbs);
  10283. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  10284. if (thumbView) {
  10285. this.#ensurePdfPageLoaded(thumbView).then(() => {
  10286. this.renderingQueue.renderView(thumbView);
  10287. });
  10288. return true;
  10289. }
  10290. return false;
  10291. }
  10292. }
  10293. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  10294. /***/ }),
  10295. /* 144 */
  10296. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10297. "use strict";
  10298. Object.defineProperty(exports, "__esModule", ({
  10299. value: true
  10300. }));
  10301. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  10302. __webpack_require__(76);
  10303. var _ui_utils = __webpack_require__(97);
  10304. var _pdfjsLib = __webpack_require__(121);
  10305. const DRAW_UPSCALE_FACTOR = 2;
  10306. const MAX_NUM_SCALING_STEPS = 3;
  10307. const THUMBNAIL_WIDTH = 98;
  10308. class TempImageFactory {
  10309. static #tempCanvas = null;
  10310. static getCanvas(width, height) {
  10311. const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
  10312. tempCanvas.width = width;
  10313. tempCanvas.height = height;
  10314. const ctx = tempCanvas.getContext("2d", {
  10315. alpha: false
  10316. });
  10317. ctx.save();
  10318. ctx.fillStyle = "rgb(255, 255, 255)";
  10319. ctx.fillRect(0, 0, width, height);
  10320. ctx.restore();
  10321. return [tempCanvas, tempCanvas.getContext("2d")];
  10322. }
  10323. static destroyCanvas() {
  10324. const tempCanvas = this.#tempCanvas;
  10325. if (tempCanvas) {
  10326. tempCanvas.width = 0;
  10327. tempCanvas.height = 0;
  10328. }
  10329. this.#tempCanvas = null;
  10330. }
  10331. }
  10332. exports.TempImageFactory = TempImageFactory;
  10333. class PDFThumbnailView {
  10334. constructor(_ref) {
  10335. let {
  10336. container,
  10337. eventBus,
  10338. id,
  10339. defaultViewport,
  10340. optionalContentConfigPromise,
  10341. linkService,
  10342. renderingQueue,
  10343. l10n,
  10344. pageColors
  10345. } = _ref;
  10346. this.id = id;
  10347. this.renderingId = "thumbnail" + id;
  10348. this.pageLabel = null;
  10349. this.pdfPage = null;
  10350. this.rotation = 0;
  10351. this.viewport = defaultViewport;
  10352. this.pdfPageRotate = defaultViewport.rotation;
  10353. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  10354. this.pageColors = pageColors || null;
  10355. this.eventBus = eventBus;
  10356. this.linkService = linkService;
  10357. this.renderingQueue = renderingQueue;
  10358. this.renderTask = null;
  10359. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  10360. this.resume = null;
  10361. this.l10n = l10n;
  10362. const anchor = document.createElement("a");
  10363. anchor.href = linkService.getAnchorUrl("#page=" + id);
  10364. this._thumbPageTitle.then(msg => {
  10365. anchor.title = msg;
  10366. });
  10367. anchor.onclick = function () {
  10368. linkService.goToPage(id);
  10369. return false;
  10370. };
  10371. this.anchor = anchor;
  10372. const div = document.createElement("div");
  10373. div.className = "thumbnail";
  10374. div.setAttribute("data-page-number", this.id);
  10375. this.div = div;
  10376. this.#updateDims();
  10377. const img = document.createElement("div");
  10378. img.className = "thumbnailImage";
  10379. this._placeholderImg = img;
  10380. div.append(img);
  10381. anchor.append(div);
  10382. container.append(anchor);
  10383. }
  10384. #updateDims() {
  10385. const {
  10386. width,
  10387. height
  10388. } = this.viewport;
  10389. const ratio = width / height;
  10390. this.canvasWidth = THUMBNAIL_WIDTH;
  10391. this.canvasHeight = this.canvasWidth / ratio | 0;
  10392. this.scale = this.canvasWidth / width;
  10393. const {
  10394. style
  10395. } = this.div;
  10396. style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
  10397. style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
  10398. }
  10399. setPdfPage(pdfPage) {
  10400. this.pdfPage = pdfPage;
  10401. this.pdfPageRotate = pdfPage.rotate;
  10402. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10403. this.viewport = pdfPage.getViewport({
  10404. scale: 1,
  10405. rotation: totalRotation
  10406. });
  10407. this.reset();
  10408. }
  10409. reset() {
  10410. this.cancelRendering();
  10411. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  10412. this.div.removeAttribute("data-loaded");
  10413. this.image?.replaceWith(this._placeholderImg);
  10414. this.#updateDims();
  10415. if (this.image) {
  10416. this.image.removeAttribute("src");
  10417. delete this.image;
  10418. }
  10419. }
  10420. update(_ref2) {
  10421. let {
  10422. rotation = null
  10423. } = _ref2;
  10424. if (typeof rotation === "number") {
  10425. this.rotation = rotation;
  10426. }
  10427. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10428. this.viewport = this.viewport.clone({
  10429. scale: 1,
  10430. rotation: totalRotation
  10431. });
  10432. this.reset();
  10433. }
  10434. cancelRendering() {
  10435. if (this.renderTask) {
  10436. this.renderTask.cancel();
  10437. this.renderTask = null;
  10438. }
  10439. this.resume = null;
  10440. }
  10441. _getPageDrawContext() {
  10442. let upscaleFactor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  10443. const canvas = document.createElement("canvas");
  10444. const ctx = canvas.getContext("2d", {
  10445. alpha: false
  10446. });
  10447. const outputScale = new _ui_utils.OutputScale();
  10448. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  10449. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  10450. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10451. return {
  10452. ctx,
  10453. canvas,
  10454. transform
  10455. };
  10456. }
  10457. _convertCanvasToImage(canvas) {
  10458. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10459. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  10460. }
  10461. const reducedCanvas = this._reduceImage(canvas);
  10462. const image = document.createElement("img");
  10463. image.className = "thumbnailImage";
  10464. this._thumbPageCanvas.then(msg => {
  10465. image.setAttribute("aria-label", msg);
  10466. });
  10467. image.src = reducedCanvas.toDataURL();
  10468. this.image = image;
  10469. this.div.setAttribute("data-loaded", true);
  10470. this._placeholderImg.replaceWith(image);
  10471. reducedCanvas.width = 0;
  10472. reducedCanvas.height = 0;
  10473. }
  10474. async #finishRenderTask(renderTask, canvas) {
  10475. let error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10476. if (renderTask === this.renderTask) {
  10477. this.renderTask = null;
  10478. }
  10479. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  10480. return;
  10481. }
  10482. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10483. this._convertCanvasToImage(canvas);
  10484. if (error) {
  10485. throw error;
  10486. }
  10487. }
  10488. async draw() {
  10489. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  10490. console.error("Must be in new state before drawing");
  10491. return undefined;
  10492. }
  10493. const {
  10494. pdfPage
  10495. } = this;
  10496. if (!pdfPage) {
  10497. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10498. throw new Error("pdfPage is not loaded");
  10499. }
  10500. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  10501. const {
  10502. ctx,
  10503. canvas,
  10504. transform
  10505. } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
  10506. const drawViewport = this.viewport.clone({
  10507. scale: DRAW_UPSCALE_FACTOR * this.scale
  10508. });
  10509. const renderContinueCallback = cont => {
  10510. if (!this.renderingQueue.isHighestPriority(this)) {
  10511. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  10512. this.resume = () => {
  10513. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  10514. cont();
  10515. };
  10516. return;
  10517. }
  10518. cont();
  10519. };
  10520. const renderContext = {
  10521. canvasContext: ctx,
  10522. transform,
  10523. viewport: drawViewport,
  10524. optionalContentConfigPromise: this._optionalContentConfigPromise,
  10525. pageColors: this.pageColors
  10526. };
  10527. const renderTask = this.renderTask = pdfPage.render(renderContext);
  10528. renderTask.onContinue = renderContinueCallback;
  10529. const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
  10530. resultPromise.finally(() => {
  10531. canvas.width = 0;
  10532. canvas.height = 0;
  10533. this.eventBus.dispatch("thumbnailrendered", {
  10534. source: this,
  10535. pageNumber: this.id,
  10536. pdfPage: this.pdfPage
  10537. });
  10538. });
  10539. return resultPromise;
  10540. }
  10541. setImage(pageView) {
  10542. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  10543. return;
  10544. }
  10545. const {
  10546. thumbnailCanvas: canvas,
  10547. pdfPage,
  10548. scale
  10549. } = pageView;
  10550. if (!canvas) {
  10551. return;
  10552. }
  10553. if (!this.pdfPage) {
  10554. this.setPdfPage(pdfPage);
  10555. }
  10556. if (scale < this.scale) {
  10557. return;
  10558. }
  10559. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10560. this._convertCanvasToImage(canvas);
  10561. }
  10562. _reduceImage(img) {
  10563. const {
  10564. ctx,
  10565. canvas
  10566. } = this._getPageDrawContext();
  10567. if (img.width <= 2 * canvas.width) {
  10568. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10569. return canvas;
  10570. }
  10571. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10572. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10573. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10574. while (reducedWidth > img.width || reducedHeight > img.height) {
  10575. reducedWidth >>= 1;
  10576. reducedHeight >>= 1;
  10577. }
  10578. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10579. while (reducedWidth > 2 * canvas.width) {
  10580. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10581. reducedWidth >>= 1;
  10582. reducedHeight >>= 1;
  10583. }
  10584. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10585. return canvas;
  10586. }
  10587. get _thumbPageTitle() {
  10588. return this.l10n.get("thumb_page_title", {
  10589. page: this.pageLabel ?? this.id
  10590. });
  10591. }
  10592. get _thumbPageCanvas() {
  10593. return this.l10n.get("thumb_page_canvas", {
  10594. page: this.pageLabel ?? this.id
  10595. });
  10596. }
  10597. setPageLabel(label) {
  10598. this.pageLabel = typeof label === "string" ? label : null;
  10599. this._thumbPageTitle.then(msg => {
  10600. this.anchor.title = msg;
  10601. });
  10602. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10603. return;
  10604. }
  10605. this._thumbPageCanvas.then(msg => {
  10606. this.image?.setAttribute("aria-label", msg);
  10607. });
  10608. }
  10609. }
  10610. exports.PDFThumbnailView = PDFThumbnailView;
  10611. /***/ }),
  10612. /* 145 */
  10613. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10614. "use strict";
  10615. Object.defineProperty(exports, "__esModule", ({
  10616. value: true
  10617. }));
  10618. exports.PagesCountLimit = exports.PDFViewer = exports.PDFPageViewBuffer = void 0;
  10619. __webpack_require__(98);
  10620. __webpack_require__(108);
  10621. __webpack_require__(110);
  10622. __webpack_require__(113);
  10623. __webpack_require__(115);
  10624. __webpack_require__(117);
  10625. __webpack_require__(119);
  10626. __webpack_require__(76);
  10627. __webpack_require__(89);
  10628. var _pdfjsLib = __webpack_require__(121);
  10629. var _ui_utils = __webpack_require__(97);
  10630. var _l10n_utils = __webpack_require__(146);
  10631. var _pdf_page_view = __webpack_require__(147);
  10632. var _pdf_rendering_queue = __webpack_require__(140);
  10633. var _pdf_link_service = __webpack_require__(124);
  10634. const DEFAULT_CACHE_SIZE = 10;
  10635. const PagesCountLimit = {
  10636. FORCE_SCROLL_MODE_PAGE: 15000,
  10637. FORCE_LAZY_PAGE_INIT: 7500,
  10638. PAUSE_EAGER_PAGE_INIT: 250
  10639. };
  10640. exports.PagesCountLimit = PagesCountLimit;
  10641. function isValidAnnotationEditorMode(mode) {
  10642. return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !== _pdfjsLib.AnnotationEditorType.DISABLE;
  10643. }
  10644. class PDFPageViewBuffer {
  10645. #buf = new Set();
  10646. #size = 0;
  10647. constructor(size) {
  10648. this.#size = size;
  10649. }
  10650. push(view) {
  10651. const buf = this.#buf;
  10652. if (buf.has(view)) {
  10653. buf.delete(view);
  10654. }
  10655. buf.add(view);
  10656. if (buf.size > this.#size) {
  10657. this.#destroyFirstView();
  10658. }
  10659. }
  10660. resize(newSize) {
  10661. let idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10662. this.#size = newSize;
  10663. const buf = this.#buf;
  10664. if (idsToKeep) {
  10665. const ii = buf.size;
  10666. let i = 1;
  10667. for (const view of buf) {
  10668. if (idsToKeep.has(view.id)) {
  10669. buf.delete(view);
  10670. buf.add(view);
  10671. }
  10672. if (++i > ii) {
  10673. break;
  10674. }
  10675. }
  10676. }
  10677. while (buf.size > this.#size) {
  10678. this.#destroyFirstView();
  10679. }
  10680. }
  10681. has(view) {
  10682. return this.#buf.has(view);
  10683. }
  10684. [Symbol.iterator]() {
  10685. return this.#buf.keys();
  10686. }
  10687. #destroyFirstView() {
  10688. const firstView = this.#buf.keys().next().value;
  10689. firstView?.destroy();
  10690. this.#buf.delete(firstView);
  10691. }
  10692. }
  10693. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  10694. class PDFViewer {
  10695. #buffer = null;
  10696. #annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  10697. #annotationEditorUIManager = null;
  10698. #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10699. #containerTopLeft = null;
  10700. #copyCallbackBound = null;
  10701. #enablePermissions = false;
  10702. #getAllTextInProgress = false;
  10703. #hiddenCopyElement = null;
  10704. #interruptCopyCondition = false;
  10705. #previousContainerHeight = 0;
  10706. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  10707. #scrollModePageState = null;
  10708. #onVisibilityChange = null;
  10709. #scaleTimeoutId = null;
  10710. #textLayerMode = _ui_utils.TextLayerMode.ENABLE;
  10711. constructor(options) {
  10712. const viewerVersion = '3.9.179';
  10713. if (_pdfjsLib.version !== viewerVersion) {
  10714. throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
  10715. }
  10716. this.container = options.container;
  10717. this.viewer = options.viewer || options.container.firstElementChild;
  10718. if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
  10719. throw new Error("Invalid `container` and/or `viewer` option.");
  10720. }
  10721. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  10722. throw new Error("The `container` must be absolutely positioned.");
  10723. }
  10724. this.#resizeObserver.observe(this.container);
  10725. this.eventBus = options.eventBus;
  10726. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10727. this.downloadManager = options.downloadManager || null;
  10728. this.findController = options.findController || null;
  10729. if (this.findController) {
  10730. this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
  10731. }
  10732. this._scriptingManager = options.scriptingManager || null;
  10733. this.#textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  10734. this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10735. this.#annotationEditorMode = options.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.NONE;
  10736. this.imageResourcesPath = options.imageResourcesPath || "";
  10737. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10738. this.removePageBorders = options.removePageBorders || false;
  10739. if (options.useOnlyCssZoom) {
  10740. console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
  10741. options.maxCanvasPixels = 0;
  10742. }
  10743. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  10744. this.maxCanvasPixels = options.maxCanvasPixels;
  10745. this.l10n = options.l10n || _l10n_utils.NullL10n;
  10746. this.#enablePermissions = options.enablePermissions || false;
  10747. this.pageColors = options.pageColors || null;
  10748. this.defaultRenderingQueue = !options.renderingQueue;
  10749. if (this.defaultRenderingQueue) {
  10750. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10751. this.renderingQueue.setViewer(this);
  10752. } else {
  10753. this.renderingQueue = options.renderingQueue;
  10754. }
  10755. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10756. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10757. this._onBeforeDraw = this._onAfterDraw = null;
  10758. this._resetView();
  10759. if (this.removePageBorders) {
  10760. this.viewer.classList.add("removePageBorders");
  10761. }
  10762. this.#updateContainerHeightCss();
  10763. this.eventBus._on("thumbnailrendered", _ref => {
  10764. let {
  10765. pageNumber,
  10766. pdfPage
  10767. } = _ref;
  10768. const pageView = this._pages[pageNumber - 1];
  10769. if (!this.#buffer.has(pageView)) {
  10770. pdfPage?.cleanup();
  10771. }
  10772. });
  10773. }
  10774. get pagesCount() {
  10775. return this._pages.length;
  10776. }
  10777. getPageView(index) {
  10778. return this._pages[index];
  10779. }
  10780. getCachedPageViews() {
  10781. return new Set(this.#buffer);
  10782. }
  10783. get pageViewsReady() {
  10784. return this._pagesCapability.settled && this._pages.every(pageView => pageView?.pdfPage);
  10785. }
  10786. get renderForms() {
  10787. return this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10788. }
  10789. get enableScripting() {
  10790. return !!this._scriptingManager;
  10791. }
  10792. get currentPageNumber() {
  10793. return this._currentPageNumber;
  10794. }
  10795. set currentPageNumber(val) {
  10796. if (!Number.isInteger(val)) {
  10797. throw new Error("Invalid page number.");
  10798. }
  10799. if (!this.pdfDocument) {
  10800. return;
  10801. }
  10802. if (!this._setCurrentPageNumber(val, true)) {
  10803. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  10804. }
  10805. }
  10806. _setCurrentPageNumber(val) {
  10807. let resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10808. if (this._currentPageNumber === val) {
  10809. if (resetCurrentPageView) {
  10810. this.#resetCurrentPageView();
  10811. }
  10812. return true;
  10813. }
  10814. if (!(0 < val && val <= this.pagesCount)) {
  10815. return false;
  10816. }
  10817. const previous = this._currentPageNumber;
  10818. this._currentPageNumber = val;
  10819. this.eventBus.dispatch("pagechanging", {
  10820. source: this,
  10821. pageNumber: val,
  10822. pageLabel: this._pageLabels?.[val - 1] ?? null,
  10823. previous
  10824. });
  10825. if (resetCurrentPageView) {
  10826. this.#resetCurrentPageView();
  10827. }
  10828. return true;
  10829. }
  10830. get currentPageLabel() {
  10831. return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
  10832. }
  10833. set currentPageLabel(val) {
  10834. if (!this.pdfDocument) {
  10835. return;
  10836. }
  10837. let page = val | 0;
  10838. if (this._pageLabels) {
  10839. const i = this._pageLabels.indexOf(val);
  10840. if (i >= 0) {
  10841. page = i + 1;
  10842. }
  10843. }
  10844. if (!this._setCurrentPageNumber(page, true)) {
  10845. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  10846. }
  10847. }
  10848. get currentScale() {
  10849. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  10850. }
  10851. set currentScale(val) {
  10852. if (isNaN(val)) {
  10853. throw new Error("Invalid numeric scale.");
  10854. }
  10855. if (!this.pdfDocument) {
  10856. return;
  10857. }
  10858. this.#setScale(val, {
  10859. noScroll: false
  10860. });
  10861. }
  10862. get currentScaleValue() {
  10863. return this._currentScaleValue;
  10864. }
  10865. set currentScaleValue(val) {
  10866. if (!this.pdfDocument) {
  10867. return;
  10868. }
  10869. this.#setScale(val, {
  10870. noScroll: false
  10871. });
  10872. }
  10873. get pagesRotation() {
  10874. return this._pagesRotation;
  10875. }
  10876. set pagesRotation(rotation) {
  10877. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10878. throw new Error("Invalid pages rotation angle.");
  10879. }
  10880. if (!this.pdfDocument) {
  10881. return;
  10882. }
  10883. rotation %= 360;
  10884. if (rotation < 0) {
  10885. rotation += 360;
  10886. }
  10887. if (this._pagesRotation === rotation) {
  10888. return;
  10889. }
  10890. this._pagesRotation = rotation;
  10891. const pageNumber = this._currentPageNumber;
  10892. this.refresh(true, {
  10893. rotation
  10894. });
  10895. if (this._currentScaleValue) {
  10896. this.#setScale(this._currentScaleValue, {
  10897. noScroll: true
  10898. });
  10899. }
  10900. this.eventBus.dispatch("rotationchanging", {
  10901. source: this,
  10902. pagesRotation: rotation,
  10903. pageNumber
  10904. });
  10905. if (this.defaultRenderingQueue) {
  10906. this.update();
  10907. }
  10908. }
  10909. get firstPagePromise() {
  10910. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10911. }
  10912. get onePageRendered() {
  10913. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10914. }
  10915. get pagesPromise() {
  10916. return this.pdfDocument ? this._pagesCapability.promise : null;
  10917. }
  10918. #layerProperties() {
  10919. const self = this;
  10920. return {
  10921. get annotationEditorUIManager() {
  10922. return self.#annotationEditorUIManager;
  10923. },
  10924. get annotationStorage() {
  10925. return self.pdfDocument?.annotationStorage;
  10926. },
  10927. get downloadManager() {
  10928. return self.downloadManager;
  10929. },
  10930. get enableScripting() {
  10931. return !!self._scriptingManager;
  10932. },
  10933. get fieldObjectsPromise() {
  10934. return self.pdfDocument?.getFieldObjects();
  10935. },
  10936. get findController() {
  10937. return self.findController;
  10938. },
  10939. get hasJSActionsPromise() {
  10940. return self.pdfDocument?.hasJSActions();
  10941. },
  10942. get linkService() {
  10943. return self.linkService;
  10944. }
  10945. };
  10946. }
  10947. #initializePermissions(permissions) {
  10948. const params = {
  10949. annotationEditorMode: this.#annotationEditorMode,
  10950. annotationMode: this.#annotationMode,
  10951. textLayerMode: this.#textLayerMode
  10952. };
  10953. if (!permissions) {
  10954. return params;
  10955. }
  10956. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY) && this.#textLayerMode === _ui_utils.TextLayerMode.ENABLE) {
  10957. params.textLayerMode = _ui_utils.TextLayerMode.ENABLE_PERMISSIONS;
  10958. }
  10959. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) {
  10960. params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
  10961. }
  10962. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
  10963. params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE;
  10964. }
  10965. return params;
  10966. }
  10967. #onePageRenderedOrForceFetch() {
  10968. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10969. return Promise.resolve();
  10970. }
  10971. const visibilityChangePromise = new Promise(resolve => {
  10972. this.#onVisibilityChange = () => {
  10973. if (document.visibilityState !== "hidden") {
  10974. return;
  10975. }
  10976. resolve();
  10977. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  10978. this.#onVisibilityChange = null;
  10979. };
  10980. document.addEventListener("visibilitychange", this.#onVisibilityChange);
  10981. });
  10982. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  10983. }
  10984. async getAllText() {
  10985. const texts = [];
  10986. const buffer = [];
  10987. for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
  10988. if (this.#interruptCopyCondition) {
  10989. return null;
  10990. }
  10991. buffer.length = 0;
  10992. const page = await this.pdfDocument.getPage(pageNum);
  10993. const {
  10994. items
  10995. } = await page.getTextContent();
  10996. for (const item of items) {
  10997. if (item.str) {
  10998. buffer.push(item.str);
  10999. }
  11000. if (item.hasEOL) {
  11001. buffer.push("\n");
  11002. }
  11003. }
  11004. texts.push((0, _ui_utils.removeNullCharacters)(buffer.join("")));
  11005. }
  11006. return texts.join("\n");
  11007. }
  11008. #copyCallback(textLayerMode, event) {
  11009. const selection = document.getSelection();
  11010. const {
  11011. focusNode,
  11012. anchorNode
  11013. } = selection;
  11014. if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
  11015. if (this.#getAllTextInProgress || textLayerMode === _ui_utils.TextLayerMode.ENABLE_PERMISSIONS) {
  11016. event.preventDefault();
  11017. event.stopPropagation();
  11018. return;
  11019. }
  11020. this.#getAllTextInProgress = true;
  11021. const savedCursor = this.container.style.cursor;
  11022. this.container.style.cursor = "wait";
  11023. const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
  11024. window.addEventListener("keydown", interruptCopy);
  11025. this.getAllText().then(async text => {
  11026. if (text !== null) {
  11027. await navigator.clipboard.writeText(text);
  11028. }
  11029. }).catch(reason => {
  11030. console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
  11031. }).finally(() => {
  11032. this.#getAllTextInProgress = false;
  11033. this.#interruptCopyCondition = false;
  11034. window.removeEventListener("keydown", interruptCopy);
  11035. this.container.style.cursor = savedCursor;
  11036. });
  11037. event.preventDefault();
  11038. event.stopPropagation();
  11039. }
  11040. }
  11041. setDocument(pdfDocument) {
  11042. if (this.pdfDocument) {
  11043. this.eventBus.dispatch("pagesdestroy", {
  11044. source: this
  11045. });
  11046. this._cancelRendering();
  11047. this._resetView();
  11048. this.findController?.setDocument(null);
  11049. this._scriptingManager?.setDocument(null);
  11050. if (this.#annotationEditorUIManager) {
  11051. this.#annotationEditorUIManager.destroy();
  11052. this.#annotationEditorUIManager = null;
  11053. }
  11054. }
  11055. this.pdfDocument = pdfDocument;
  11056. if (!pdfDocument) {
  11057. return;
  11058. }
  11059. const pagesCount = pdfDocument.numPages;
  11060. const firstPagePromise = pdfDocument.getPage(1);
  11061. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  11062. const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
  11063. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11064. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  11065. const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  11066. this.eventBus.dispatch("scrollmodechanged", {
  11067. source: this,
  11068. mode
  11069. });
  11070. }
  11071. this._pagesCapability.promise.then(() => {
  11072. this.eventBus.dispatch("pagesloaded", {
  11073. source: this,
  11074. pagesCount
  11075. });
  11076. }, () => {});
  11077. this._onBeforeDraw = evt => {
  11078. const pageView = this._pages[evt.pageNumber - 1];
  11079. if (!pageView) {
  11080. return;
  11081. }
  11082. this.#buffer.push(pageView);
  11083. };
  11084. this.eventBus._on("pagerender", this._onBeforeDraw);
  11085. this._onAfterDraw = evt => {
  11086. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  11087. return;
  11088. }
  11089. this._onePageRenderedCapability.resolve({
  11090. timestamp: evt.timestamp
  11091. });
  11092. this.eventBus._off("pagerendered", this._onAfterDraw);
  11093. this._onAfterDraw = null;
  11094. if (this.#onVisibilityChange) {
  11095. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11096. this.#onVisibilityChange = null;
  11097. }
  11098. };
  11099. this.eventBus._on("pagerendered", this._onAfterDraw);
  11100. Promise.all([firstPagePromise, permissionsPromise]).then(_ref2 => {
  11101. let [firstPdfPage, permissions] = _ref2;
  11102. if (pdfDocument !== this.pdfDocument) {
  11103. return;
  11104. }
  11105. this._firstPageCapability.resolve(firstPdfPage);
  11106. this._optionalContentConfigPromise = optionalContentConfigPromise;
  11107. const {
  11108. annotationEditorMode,
  11109. annotationMode,
  11110. textLayerMode
  11111. } = this.#initializePermissions(permissions);
  11112. if (textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  11113. const element = this.#hiddenCopyElement = document.createElement("div");
  11114. element.id = "hiddenCopyElement";
  11115. this.viewer.before(element);
  11116. }
  11117. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  11118. const mode = annotationEditorMode;
  11119. if (pdfDocument.isPureXfa) {
  11120. console.warn("Warning: XFA-editing is not implemented.");
  11121. } else if (isValidAnnotationEditorMode(mode)) {
  11122. this.#annotationEditorUIManager = new _pdfjsLib.AnnotationEditorUIManager(this.container, this.eventBus, pdfDocument, this.pageColors);
  11123. if (mode !== _pdfjsLib.AnnotationEditorType.NONE) {
  11124. this.#annotationEditorUIManager.updateMode(mode);
  11125. }
  11126. } else {
  11127. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  11128. }
  11129. }
  11130. const layerProperties = this.#layerProperties.bind(this);
  11131. const viewerElement = this._scrollMode === _ui_utils.ScrollMode.PAGE ? null : this.viewer;
  11132. const scale = this.currentScale;
  11133. const viewport = firstPdfPage.getViewport({
  11134. scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  11135. });
  11136. this.viewer.style.setProperty("--scale-factor", viewport.scale);
  11137. if (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas") {
  11138. this.viewer.style.setProperty("--hcm-highligh-filter", pdfDocument.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  11139. }
  11140. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11141. const pageView = new _pdf_page_view.PDFPageView({
  11142. container: viewerElement,
  11143. eventBus: this.eventBus,
  11144. id: pageNum,
  11145. scale,
  11146. defaultViewport: viewport.clone(),
  11147. optionalContentConfigPromise,
  11148. renderingQueue: this.renderingQueue,
  11149. textLayerMode,
  11150. annotationMode,
  11151. imageResourcesPath: this.imageResourcesPath,
  11152. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  11153. maxCanvasPixels: this.maxCanvasPixels,
  11154. pageColors: this.pageColors,
  11155. l10n: this.l10n,
  11156. layerProperties
  11157. });
  11158. this._pages.push(pageView);
  11159. }
  11160. const firstPageView = this._pages[0];
  11161. if (firstPageView) {
  11162. firstPageView.setPdfPage(firstPdfPage);
  11163. this.linkService.cachePageRef(1, firstPdfPage.ref);
  11164. }
  11165. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11166. this.#ensurePageViewVisible();
  11167. } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  11168. this._updateSpreadMode();
  11169. }
  11170. this.#onePageRenderedOrForceFetch().then(async () => {
  11171. this.findController?.setDocument(pdfDocument);
  11172. this._scriptingManager?.setDocument(pdfDocument);
  11173. if (this.#hiddenCopyElement) {
  11174. this.#copyCallbackBound = this.#copyCallback.bind(this, textLayerMode);
  11175. document.addEventListener("copy", this.#copyCallbackBound);
  11176. }
  11177. if (this.#annotationEditorUIManager) {
  11178. this.eventBus.dispatch("annotationeditormodechanged", {
  11179. source: this,
  11180. mode: this.#annotationEditorMode
  11181. });
  11182. }
  11183. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  11184. this._pagesCapability.resolve();
  11185. return;
  11186. }
  11187. let getPagesLeft = pagesCount - 1;
  11188. if (getPagesLeft <= 0) {
  11189. this._pagesCapability.resolve();
  11190. return;
  11191. }
  11192. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  11193. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  11194. const pageView = this._pages[pageNum - 1];
  11195. if (!pageView.pdfPage) {
  11196. pageView.setPdfPage(pdfPage);
  11197. }
  11198. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  11199. if (--getPagesLeft === 0) {
  11200. this._pagesCapability.resolve();
  11201. }
  11202. }, reason => {
  11203. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  11204. if (--getPagesLeft === 0) {
  11205. this._pagesCapability.resolve();
  11206. }
  11207. });
  11208. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  11209. await promise;
  11210. }
  11211. }
  11212. });
  11213. this.eventBus.dispatch("pagesinit", {
  11214. source: this
  11215. });
  11216. pdfDocument.getMetadata().then(_ref3 => {
  11217. let {
  11218. info
  11219. } = _ref3;
  11220. if (pdfDocument !== this.pdfDocument) {
  11221. return;
  11222. }
  11223. if (info.Language) {
  11224. this.viewer.lang = info.Language;
  11225. }
  11226. });
  11227. if (this.defaultRenderingQueue) {
  11228. this.update();
  11229. }
  11230. }).catch(reason => {
  11231. console.error("Unable to initialize viewer", reason);
  11232. this._pagesCapability.reject(reason);
  11233. });
  11234. }
  11235. setPageLabels(labels) {
  11236. if (!this.pdfDocument) {
  11237. return;
  11238. }
  11239. if (!labels) {
  11240. this._pageLabels = null;
  11241. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11242. this._pageLabels = null;
  11243. console.error(`setPageLabels: Invalid page labels.`);
  11244. } else {
  11245. this._pageLabels = labels;
  11246. }
  11247. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  11248. this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11249. }
  11250. }
  11251. _resetView() {
  11252. this._pages = [];
  11253. this._currentPageNumber = 1;
  11254. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  11255. this._currentScaleValue = null;
  11256. this._pageLabels = null;
  11257. this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  11258. this._location = null;
  11259. this._pagesRotation = 0;
  11260. this._optionalContentConfigPromise = null;
  11261. this._firstPageCapability = new _pdfjsLib.PromiseCapability();
  11262. this._onePageRenderedCapability = new _pdfjsLib.PromiseCapability();
  11263. this._pagesCapability = new _pdfjsLib.PromiseCapability();
  11264. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  11265. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  11266. this._spreadMode = _ui_utils.SpreadMode.NONE;
  11267. this.#scrollModePageState = {
  11268. previousPageNumber: 1,
  11269. scrollDown: true,
  11270. pages: []
  11271. };
  11272. if (this._onBeforeDraw) {
  11273. this.eventBus._off("pagerender", this._onBeforeDraw);
  11274. this._onBeforeDraw = null;
  11275. }
  11276. if (this._onAfterDraw) {
  11277. this.eventBus._off("pagerendered", this._onAfterDraw);
  11278. this._onAfterDraw = null;
  11279. }
  11280. if (this.#onVisibilityChange) {
  11281. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11282. this.#onVisibilityChange = null;
  11283. }
  11284. this.viewer.textContent = "";
  11285. this._updateScrollMode();
  11286. this.viewer.removeAttribute("lang");
  11287. if (this.#hiddenCopyElement) {
  11288. document.removeEventListener("copy", this.#copyCallbackBound);
  11289. this.#copyCallbackBound = null;
  11290. this.#hiddenCopyElement.remove();
  11291. this.#hiddenCopyElement = null;
  11292. }
  11293. }
  11294. #ensurePageViewVisible() {
  11295. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  11296. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  11297. }
  11298. const pageNumber = this._currentPageNumber,
  11299. state = this.#scrollModePageState,
  11300. viewer = this.viewer;
  11301. viewer.textContent = "";
  11302. state.pages.length = 0;
  11303. if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
  11304. const pageView = this._pages[pageNumber - 1];
  11305. viewer.append(pageView.div);
  11306. state.pages.push(pageView);
  11307. } else {
  11308. const pageIndexSet = new Set(),
  11309. parity = this._spreadMode - 1;
  11310. if (parity === -1) {
  11311. pageIndexSet.add(pageNumber - 1);
  11312. } else if (pageNumber % 2 !== parity) {
  11313. pageIndexSet.add(pageNumber - 1);
  11314. pageIndexSet.add(pageNumber);
  11315. } else {
  11316. pageIndexSet.add(pageNumber - 2);
  11317. pageIndexSet.add(pageNumber - 1);
  11318. }
  11319. const spread = document.createElement("div");
  11320. spread.className = "spread";
  11321. if (this.isInPresentationMode) {
  11322. const dummyPage = document.createElement("div");
  11323. dummyPage.className = "dummyPage";
  11324. spread.append(dummyPage);
  11325. }
  11326. for (const i of pageIndexSet) {
  11327. const pageView = this._pages[i];
  11328. if (!pageView) {
  11329. continue;
  11330. }
  11331. spread.append(pageView.div);
  11332. state.pages.push(pageView);
  11333. }
  11334. viewer.append(spread);
  11335. }
  11336. state.scrollDown = pageNumber >= state.previousPageNumber;
  11337. state.previousPageNumber = pageNumber;
  11338. }
  11339. _scrollUpdate() {
  11340. if (this.pagesCount === 0) {
  11341. return;
  11342. }
  11343. this.update();
  11344. }
  11345. #scrollIntoView(pageView) {
  11346. let pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11347. const {
  11348. div,
  11349. id
  11350. } = pageView;
  11351. if (this._currentPageNumber !== id) {
  11352. this._setCurrentPageNumber(id);
  11353. }
  11354. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11355. this.#ensurePageViewVisible();
  11356. this.update();
  11357. }
  11358. if (!pageSpot && !this.isInPresentationMode) {
  11359. const left = div.offsetLeft + div.clientLeft,
  11360. right = left + div.clientWidth;
  11361. const {
  11362. scrollLeft,
  11363. clientWidth
  11364. } = this.container;
  11365. if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  11366. pageSpot = {
  11367. left: 0,
  11368. top: 0
  11369. };
  11370. }
  11371. }
  11372. (0, _ui_utils.scrollIntoView)(div, pageSpot);
  11373. if (!this._currentScaleValue && this._location) {
  11374. this._location = null;
  11375. }
  11376. }
  11377. #isSameScale(newScale) {
  11378. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  11379. }
  11380. #setScaleUpdatePages(newScale, newValue, _ref4) {
  11381. let {
  11382. noScroll = false,
  11383. preset = false,
  11384. drawingDelay = -1
  11385. } = _ref4;
  11386. this._currentScaleValue = newValue.toString();
  11387. if (this.#isSameScale(newScale)) {
  11388. if (preset) {
  11389. this.eventBus.dispatch("scalechanging", {
  11390. source: this,
  11391. scale: newScale,
  11392. presetValue: newValue
  11393. });
  11394. }
  11395. return;
  11396. }
  11397. this.viewer.style.setProperty("--scale-factor", newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  11398. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  11399. this.refresh(true, {
  11400. scale: newScale,
  11401. drawingDelay: postponeDrawing ? drawingDelay : -1
  11402. });
  11403. if (postponeDrawing) {
  11404. this.#scaleTimeoutId = setTimeout(() => {
  11405. this.#scaleTimeoutId = null;
  11406. this.refresh();
  11407. }, drawingDelay);
  11408. }
  11409. this._currentScale = newScale;
  11410. if (!noScroll) {
  11411. let page = this._currentPageNumber,
  11412. dest;
  11413. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  11414. page = this._location.pageNumber;
  11415. dest = [null, {
  11416. name: "XYZ"
  11417. }, this._location.left, this._location.top, null];
  11418. }
  11419. this.scrollPageIntoView({
  11420. pageNumber: page,
  11421. destArray: dest,
  11422. allowNegativeOffset: true
  11423. });
  11424. }
  11425. this.eventBus.dispatch("scalechanging", {
  11426. source: this,
  11427. scale: newScale,
  11428. presetValue: preset ? newValue : undefined
  11429. });
  11430. if (this.defaultRenderingQueue) {
  11431. this.update();
  11432. }
  11433. }
  11434. get #pageWidthScaleFactor() {
  11435. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
  11436. return 2;
  11437. }
  11438. return 1;
  11439. }
  11440. #setScale(value, options) {
  11441. let scale = parseFloat(value);
  11442. if (scale > 0) {
  11443. options.preset = false;
  11444. this.#setScaleUpdatePages(scale, value, options);
  11445. } else {
  11446. const currentPage = this._pages[this._currentPageNumber - 1];
  11447. if (!currentPage) {
  11448. return;
  11449. }
  11450. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  11451. vPadding = _ui_utils.VERTICAL_PADDING;
  11452. if (this.isInPresentationMode) {
  11453. hPadding = vPadding = 4;
  11454. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  11455. hPadding *= 2;
  11456. }
  11457. } else if (this.removePageBorders) {
  11458. hPadding = vPadding = 0;
  11459. } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
  11460. [hPadding, vPadding] = [vPadding, hPadding];
  11461. }
  11462. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
  11463. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  11464. switch (value) {
  11465. case "page-actual":
  11466. scale = 1;
  11467. break;
  11468. case "page-width":
  11469. scale = pageWidthScale;
  11470. break;
  11471. case "page-height":
  11472. scale = pageHeightScale;
  11473. break;
  11474. case "page-fit":
  11475. scale = Math.min(pageWidthScale, pageHeightScale);
  11476. break;
  11477. case "auto":
  11478. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  11479. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  11480. break;
  11481. default:
  11482. console.error(`#setScale: "${value}" is an unknown zoom value.`);
  11483. return;
  11484. }
  11485. options.preset = true;
  11486. this.#setScaleUpdatePages(scale, value, options);
  11487. }
  11488. }
  11489. #resetCurrentPageView() {
  11490. const pageView = this._pages[this._currentPageNumber - 1];
  11491. if (this.isInPresentationMode) {
  11492. this.#setScale(this._currentScaleValue, {
  11493. noScroll: true
  11494. });
  11495. }
  11496. this.#scrollIntoView(pageView);
  11497. }
  11498. pageLabelToPageNumber(label) {
  11499. if (!this._pageLabels) {
  11500. return null;
  11501. }
  11502. const i = this._pageLabels.indexOf(label);
  11503. if (i < 0) {
  11504. return null;
  11505. }
  11506. return i + 1;
  11507. }
  11508. scrollPageIntoView(_ref5) {
  11509. let {
  11510. pageNumber,
  11511. destArray = null,
  11512. allowNegativeOffset = false,
  11513. ignoreDestinationZoom = false
  11514. } = _ref5;
  11515. if (!this.pdfDocument) {
  11516. return;
  11517. }
  11518. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  11519. if (!pageView) {
  11520. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  11521. return;
  11522. }
  11523. if (this.isInPresentationMode || !destArray) {
  11524. this._setCurrentPageNumber(pageNumber, true);
  11525. return;
  11526. }
  11527. let x = 0,
  11528. y = 0;
  11529. let width = 0,
  11530. height = 0,
  11531. widthScale,
  11532. heightScale;
  11533. const changeOrientation = pageView.rotation % 180 !== 0;
  11534. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11535. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11536. let scale = 0;
  11537. switch (destArray[1].name) {
  11538. case "XYZ":
  11539. x = destArray[2];
  11540. y = destArray[3];
  11541. scale = destArray[4];
  11542. x = x !== null ? x : 0;
  11543. y = y !== null ? y : pageHeight;
  11544. break;
  11545. case "Fit":
  11546. case "FitB":
  11547. scale = "page-fit";
  11548. break;
  11549. case "FitH":
  11550. case "FitBH":
  11551. y = destArray[2];
  11552. scale = "page-width";
  11553. if (y === null && this._location) {
  11554. x = this._location.left;
  11555. y = this._location.top;
  11556. } else if (typeof y !== "number" || y < 0) {
  11557. y = pageHeight;
  11558. }
  11559. break;
  11560. case "FitV":
  11561. case "FitBV":
  11562. x = destArray[2];
  11563. width = pageWidth;
  11564. height = pageHeight;
  11565. scale = "page-height";
  11566. break;
  11567. case "FitR":
  11568. x = destArray[2];
  11569. y = destArray[3];
  11570. width = destArray[4] - x;
  11571. height = destArray[5] - y;
  11572. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  11573. vPadding = _ui_utils.VERTICAL_PADDING;
  11574. if (this.removePageBorders) {
  11575. hPadding = vPadding = 0;
  11576. }
  11577. widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11578. heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11579. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  11580. break;
  11581. default:
  11582. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  11583. return;
  11584. }
  11585. if (!ignoreDestinationZoom) {
  11586. if (scale && scale !== this._currentScale) {
  11587. this.currentScaleValue = scale;
  11588. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  11589. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11590. }
  11591. }
  11592. if (scale === "page-fit" && !destArray[4]) {
  11593. this.#scrollIntoView(pageView);
  11594. return;
  11595. }
  11596. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  11597. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  11598. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  11599. if (!allowNegativeOffset) {
  11600. left = Math.max(left, 0);
  11601. top = Math.max(top, 0);
  11602. }
  11603. this.#scrollIntoView(pageView, {
  11604. left,
  11605. top
  11606. });
  11607. }
  11608. _updateLocation(firstPage) {
  11609. const currentScale = this._currentScale;
  11610. const currentScaleValue = this._currentScaleValue;
  11611. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  11612. const pageNumber = firstPage.id;
  11613. const currentPageView = this._pages[pageNumber - 1];
  11614. const container = this.container;
  11615. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  11616. const intLeft = Math.round(topLeft[0]);
  11617. const intTop = Math.round(topLeft[1]);
  11618. let pdfOpenParams = `#page=${pageNumber}`;
  11619. if (!this.isInPresentationMode) {
  11620. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  11621. }
  11622. this._location = {
  11623. pageNumber,
  11624. scale: normalizedScaleValue,
  11625. top: intTop,
  11626. left: intLeft,
  11627. rotation: this._pagesRotation,
  11628. pdfOpenParams
  11629. };
  11630. }
  11631. update() {
  11632. const visible = this._getVisiblePages();
  11633. const visiblePages = visible.views,
  11634. numVisiblePages = visiblePages.length;
  11635. if (numVisiblePages === 0) {
  11636. return;
  11637. }
  11638. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11639. this.#buffer.resize(newCacheSize, visible.ids);
  11640. this.renderingQueue.renderHighestPriority(visible);
  11641. const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL);
  11642. const currentId = this._currentPageNumber;
  11643. let stillFullyVisible = false;
  11644. for (const page of visiblePages) {
  11645. if (page.percent < 100) {
  11646. break;
  11647. }
  11648. if (page.id === currentId && isSimpleLayout) {
  11649. stillFullyVisible = true;
  11650. break;
  11651. }
  11652. }
  11653. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  11654. this._updateLocation(visible.first);
  11655. this.eventBus.dispatch("updateviewarea", {
  11656. source: this,
  11657. location: this._location
  11658. });
  11659. }
  11660. containsElement(element) {
  11661. return this.container.contains(element);
  11662. }
  11663. focus() {
  11664. this.container.focus();
  11665. }
  11666. get _isContainerRtl() {
  11667. return getComputedStyle(this.container).direction === "rtl";
  11668. }
  11669. get isInPresentationMode() {
  11670. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11671. }
  11672. get isChangingPresentationMode() {
  11673. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11674. }
  11675. get isHorizontalScrollbarEnabled() {
  11676. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11677. }
  11678. get isVerticalScrollbarEnabled() {
  11679. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11680. }
  11681. _getVisiblePages() {
  11682. const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
  11683. horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
  11684. rtl = horizontal && this._isContainerRtl;
  11685. return (0, _ui_utils.getVisibleElements)({
  11686. scrollEl: this.container,
  11687. views,
  11688. sortByVisibility: true,
  11689. horizontal,
  11690. rtl
  11691. });
  11692. }
  11693. cleanup() {
  11694. for (const pageView of this._pages) {
  11695. if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11696. pageView.reset();
  11697. }
  11698. }
  11699. }
  11700. _cancelRendering() {
  11701. for (const pageView of this._pages) {
  11702. pageView.cancelRendering();
  11703. }
  11704. }
  11705. async #ensurePdfPageLoaded(pageView) {
  11706. if (pageView.pdfPage) {
  11707. return pageView.pdfPage;
  11708. }
  11709. try {
  11710. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  11711. if (!pageView.pdfPage) {
  11712. pageView.setPdfPage(pdfPage);
  11713. }
  11714. if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
  11715. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  11716. }
  11717. return pdfPage;
  11718. } catch (reason) {
  11719. console.error("Unable to get page for page view", reason);
  11720. return null;
  11721. }
  11722. }
  11723. #getScrollAhead(visible) {
  11724. if (visible.first?.id === 1) {
  11725. return true;
  11726. } else if (visible.last?.id === this.pagesCount) {
  11727. return false;
  11728. }
  11729. switch (this._scrollMode) {
  11730. case _ui_utils.ScrollMode.PAGE:
  11731. return this.#scrollModePageState.scrollDown;
  11732. case _ui_utils.ScrollMode.HORIZONTAL:
  11733. return this.scroll.right;
  11734. }
  11735. return this.scroll.down;
  11736. }
  11737. forceRendering(currentlyVisiblePages) {
  11738. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11739. const scrollAhead = this.#getScrollAhead(visiblePages);
  11740. const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
  11741. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  11742. if (pageView) {
  11743. this.#ensurePdfPageLoaded(pageView).then(() => {
  11744. this.renderingQueue.renderView(pageView);
  11745. });
  11746. return true;
  11747. }
  11748. return false;
  11749. }
  11750. get hasEqualPageSizes() {
  11751. const firstPageView = this._pages[0];
  11752. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  11753. const pageView = this._pages[i];
  11754. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11755. return false;
  11756. }
  11757. }
  11758. return true;
  11759. }
  11760. getPagesOverview() {
  11761. let initialOrientation;
  11762. return this._pages.map(pageView => {
  11763. const viewport = pageView.pdfPage.getViewport({
  11764. scale: 1
  11765. });
  11766. const orientation = (0, _ui_utils.isPortraitOrientation)(viewport);
  11767. if (initialOrientation === undefined) {
  11768. initialOrientation = orientation;
  11769. } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
  11770. return {
  11771. width: viewport.height,
  11772. height: viewport.width,
  11773. rotation: (viewport.rotation - 90) % 360
  11774. };
  11775. }
  11776. return {
  11777. width: viewport.width,
  11778. height: viewport.height,
  11779. rotation: viewport.rotation
  11780. };
  11781. });
  11782. }
  11783. get optionalContentConfigPromise() {
  11784. if (!this.pdfDocument) {
  11785. return Promise.resolve(null);
  11786. }
  11787. if (!this._optionalContentConfigPromise) {
  11788. console.error("optionalContentConfigPromise: Not initialized yet.");
  11789. return this.pdfDocument.getOptionalContentConfig();
  11790. }
  11791. return this._optionalContentConfigPromise;
  11792. }
  11793. set optionalContentConfigPromise(promise) {
  11794. if (!(promise instanceof Promise)) {
  11795. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  11796. }
  11797. if (!this.pdfDocument) {
  11798. return;
  11799. }
  11800. if (!this._optionalContentConfigPromise) {
  11801. return;
  11802. }
  11803. this._optionalContentConfigPromise = promise;
  11804. this.refresh(false, {
  11805. optionalContentConfigPromise: promise
  11806. });
  11807. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11808. source: this,
  11809. promise
  11810. });
  11811. }
  11812. get scrollMode() {
  11813. return this._scrollMode;
  11814. }
  11815. set scrollMode(mode) {
  11816. if (this._scrollMode === mode) {
  11817. return;
  11818. }
  11819. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11820. throw new Error(`Invalid scroll mode: ${mode}`);
  11821. }
  11822. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11823. return;
  11824. }
  11825. this._previousScrollMode = this._scrollMode;
  11826. this._scrollMode = mode;
  11827. this.eventBus.dispatch("scrollmodechanged", {
  11828. source: this,
  11829. mode
  11830. });
  11831. this._updateScrollMode(this._currentPageNumber);
  11832. }
  11833. _updateScrollMode() {
  11834. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11835. const scrollMode = this._scrollMode,
  11836. viewer = this.viewer;
  11837. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11838. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11839. if (!this.pdfDocument || !pageNumber) {
  11840. return;
  11841. }
  11842. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  11843. this.#ensurePageViewVisible();
  11844. } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
  11845. this._updateSpreadMode();
  11846. }
  11847. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11848. this.#setScale(this._currentScaleValue, {
  11849. noScroll: true
  11850. });
  11851. }
  11852. this._setCurrentPageNumber(pageNumber, true);
  11853. this.update();
  11854. }
  11855. get spreadMode() {
  11856. return this._spreadMode;
  11857. }
  11858. set spreadMode(mode) {
  11859. if (this._spreadMode === mode) {
  11860. return;
  11861. }
  11862. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11863. throw new Error(`Invalid spread mode: ${mode}`);
  11864. }
  11865. this._spreadMode = mode;
  11866. this.eventBus.dispatch("spreadmodechanged", {
  11867. source: this,
  11868. mode
  11869. });
  11870. this._updateSpreadMode(this._currentPageNumber);
  11871. }
  11872. _updateSpreadMode() {
  11873. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11874. if (!this.pdfDocument) {
  11875. return;
  11876. }
  11877. const viewer = this.viewer,
  11878. pages = this._pages;
  11879. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11880. this.#ensurePageViewVisible();
  11881. } else {
  11882. viewer.textContent = "";
  11883. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11884. for (const pageView of this._pages) {
  11885. viewer.append(pageView.div);
  11886. }
  11887. } else {
  11888. const parity = this._spreadMode - 1;
  11889. let spread = null;
  11890. for (let i = 0, ii = pages.length; i < ii; ++i) {
  11891. if (spread === null) {
  11892. spread = document.createElement("div");
  11893. spread.className = "spread";
  11894. viewer.append(spread);
  11895. } else if (i % 2 === parity) {
  11896. spread = spread.cloneNode(false);
  11897. viewer.append(spread);
  11898. }
  11899. spread.append(pages[i].div);
  11900. }
  11901. }
  11902. }
  11903. if (!pageNumber) {
  11904. return;
  11905. }
  11906. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11907. this.#setScale(this._currentScaleValue, {
  11908. noScroll: true
  11909. });
  11910. }
  11911. this._setCurrentPageNumber(pageNumber, true);
  11912. this.update();
  11913. }
  11914. _getPageAdvance(currentPageNumber) {
  11915. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11916. switch (this._scrollMode) {
  11917. case _ui_utils.ScrollMode.WRAPPED:
  11918. {
  11919. const {
  11920. views
  11921. } = this._getVisiblePages(),
  11922. pageLayout = new Map();
  11923. for (const {
  11924. id,
  11925. y,
  11926. percent,
  11927. widthPercent
  11928. } of views) {
  11929. if (percent === 0 || widthPercent < 100) {
  11930. continue;
  11931. }
  11932. let yArray = pageLayout.get(y);
  11933. if (!yArray) {
  11934. pageLayout.set(y, yArray ||= []);
  11935. }
  11936. yArray.push(id);
  11937. }
  11938. for (const yArray of pageLayout.values()) {
  11939. const currentIndex = yArray.indexOf(currentPageNumber);
  11940. if (currentIndex === -1) {
  11941. continue;
  11942. }
  11943. const numPages = yArray.length;
  11944. if (numPages === 1) {
  11945. break;
  11946. }
  11947. if (previous) {
  11948. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11949. const currentId = yArray[i],
  11950. expectedId = yArray[i + 1] - 1;
  11951. if (currentId < expectedId) {
  11952. return currentPageNumber - expectedId;
  11953. }
  11954. }
  11955. } else {
  11956. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  11957. const currentId = yArray[i],
  11958. expectedId = yArray[i - 1] + 1;
  11959. if (currentId > expectedId) {
  11960. return expectedId - currentPageNumber;
  11961. }
  11962. }
  11963. }
  11964. if (previous) {
  11965. const firstId = yArray[0];
  11966. if (firstId < currentPageNumber) {
  11967. return currentPageNumber - firstId + 1;
  11968. }
  11969. } else {
  11970. const lastId = yArray[numPages - 1];
  11971. if (lastId > currentPageNumber) {
  11972. return lastId - currentPageNumber + 1;
  11973. }
  11974. }
  11975. break;
  11976. }
  11977. break;
  11978. }
  11979. case _ui_utils.ScrollMode.HORIZONTAL:
  11980. {
  11981. break;
  11982. }
  11983. case _ui_utils.ScrollMode.PAGE:
  11984. case _ui_utils.ScrollMode.VERTICAL:
  11985. {
  11986. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11987. break;
  11988. }
  11989. const parity = this._spreadMode - 1;
  11990. if (previous && currentPageNumber % 2 !== parity) {
  11991. break;
  11992. } else if (!previous && currentPageNumber % 2 === parity) {
  11993. break;
  11994. }
  11995. const {
  11996. views
  11997. } = this._getVisiblePages(),
  11998. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11999. for (const {
  12000. id,
  12001. percent,
  12002. widthPercent
  12003. } of views) {
  12004. if (id !== expectedId) {
  12005. continue;
  12006. }
  12007. if (percent > 0 && widthPercent === 100) {
  12008. return 2;
  12009. }
  12010. break;
  12011. }
  12012. break;
  12013. }
  12014. }
  12015. return 1;
  12016. }
  12017. nextPage() {
  12018. const currentPageNumber = this._currentPageNumber,
  12019. pagesCount = this.pagesCount;
  12020. if (currentPageNumber >= pagesCount) {
  12021. return false;
  12022. }
  12023. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  12024. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  12025. return true;
  12026. }
  12027. previousPage() {
  12028. const currentPageNumber = this._currentPageNumber;
  12029. if (currentPageNumber <= 1) {
  12030. return false;
  12031. }
  12032. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  12033. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  12034. return true;
  12035. }
  12036. increaseScale() {
  12037. let {
  12038. drawingDelay,
  12039. scaleFactor,
  12040. steps
  12041. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12042. if (!this.pdfDocument) {
  12043. return;
  12044. }
  12045. let newScale = this._currentScale;
  12046. if (scaleFactor > 1) {
  12047. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12048. } else {
  12049. steps ??= 1;
  12050. do {
  12051. newScale = Math.ceil((newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12052. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  12053. }
  12054. this.#setScale(Math.min(_ui_utils.MAX_SCALE, newScale), {
  12055. noScroll: false,
  12056. drawingDelay
  12057. });
  12058. }
  12059. decreaseScale() {
  12060. let {
  12061. drawingDelay,
  12062. scaleFactor,
  12063. steps
  12064. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12065. if (!this.pdfDocument) {
  12066. return;
  12067. }
  12068. let newScale = this._currentScale;
  12069. if (scaleFactor > 0 && scaleFactor < 1) {
  12070. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12071. } else {
  12072. steps ??= 1;
  12073. do {
  12074. newScale = Math.floor((newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12075. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  12076. }
  12077. this.#setScale(Math.max(_ui_utils.MIN_SCALE, newScale), {
  12078. noScroll: false,
  12079. drawingDelay
  12080. });
  12081. }
  12082. #updateContainerHeightCss() {
  12083. let height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.container.clientHeight;
  12084. if (height !== this.#previousContainerHeight) {
  12085. this.#previousContainerHeight = height;
  12086. _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`);
  12087. }
  12088. }
  12089. #resizeObserverCallback(entries) {
  12090. for (const entry of entries) {
  12091. if (entry.target === this.container) {
  12092. this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
  12093. this.#containerTopLeft = null;
  12094. break;
  12095. }
  12096. }
  12097. }
  12098. get containerTopLeft() {
  12099. return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
  12100. }
  12101. get annotationEditorMode() {
  12102. return this.#annotationEditorUIManager ? this.#annotationEditorMode : _pdfjsLib.AnnotationEditorType.DISABLE;
  12103. }
  12104. set annotationEditorMode(_ref6) {
  12105. let {
  12106. mode,
  12107. editId = null
  12108. } = _ref6;
  12109. if (!this.#annotationEditorUIManager) {
  12110. throw new Error(`The AnnotationEditor is not enabled.`);
  12111. }
  12112. if (this.#annotationEditorMode === mode) {
  12113. return;
  12114. }
  12115. if (!isValidAnnotationEditorMode(mode)) {
  12116. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  12117. }
  12118. if (!this.pdfDocument) {
  12119. return;
  12120. }
  12121. this.#annotationEditorMode = mode;
  12122. this.eventBus.dispatch("annotationeditormodechanged", {
  12123. source: this,
  12124. mode
  12125. });
  12126. this.#annotationEditorUIManager.updateMode(mode, editId);
  12127. }
  12128. set annotationEditorParams(_ref7) {
  12129. let {
  12130. type,
  12131. value
  12132. } = _ref7;
  12133. if (!this.#annotationEditorUIManager) {
  12134. throw new Error(`The AnnotationEditor is not enabled.`);
  12135. }
  12136. this.#annotationEditorUIManager.updateParams(type, value);
  12137. }
  12138. refresh() {
  12139. let noUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12140. let updateArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.create(null);
  12141. if (!this.pdfDocument) {
  12142. return;
  12143. }
  12144. for (const pageView of this._pages) {
  12145. pageView.update(updateArgs);
  12146. }
  12147. if (this.#scaleTimeoutId !== null) {
  12148. clearTimeout(this.#scaleTimeoutId);
  12149. this.#scaleTimeoutId = null;
  12150. }
  12151. if (!noUpdate) {
  12152. this.update();
  12153. }
  12154. }
  12155. }
  12156. exports.PDFViewer = PDFViewer;
  12157. /***/ }),
  12158. /* 146 */
  12159. /***/ ((__unused_webpack_module, exports) => {
  12160. "use strict";
  12161. Object.defineProperty(exports, "__esModule", ({
  12162. value: true
  12163. }));
  12164. exports.NullL10n = void 0;
  12165. exports.getL10nFallback = getL10nFallback;
  12166. const DEFAULT_L10N_STRINGS = {
  12167. of_pages: "of {{pagesCount}}",
  12168. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  12169. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  12170. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  12171. document_properties_date_string: "{{date}}, {{time}}",
  12172. document_properties_page_size_unit_inches: "in",
  12173. document_properties_page_size_unit_millimeters: "mm",
  12174. document_properties_page_size_orientation_portrait: "portrait",
  12175. document_properties_page_size_orientation_landscape: "landscape",
  12176. document_properties_page_size_name_a3: "A3",
  12177. document_properties_page_size_name_a4: "A4",
  12178. document_properties_page_size_name_letter: "Letter",
  12179. document_properties_page_size_name_legal: "Legal",
  12180. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  12181. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  12182. document_properties_linearized_yes: "Yes",
  12183. document_properties_linearized_no: "No",
  12184. additional_layers: "Additional Layers",
  12185. page_landmark: "Page {{page}}",
  12186. thumb_page_title: "Page {{page}}",
  12187. thumb_page_canvas: "Thumbnail of Page {{page}}",
  12188. find_reached_top: "Reached top of document, continued from bottom",
  12189. find_reached_bottom: "Reached end of document, continued from top",
  12190. "find_match_count[one]": "{{current}} of {{total}} match",
  12191. "find_match_count[other]": "{{current}} of {{total}} matches",
  12192. "find_match_count_limit[one]": "More than {{limit}} match",
  12193. "find_match_count_limit[other]": "More than {{limit}} matches",
  12194. find_not_found: "Phrase not found",
  12195. page_scale_width: "Page Width",
  12196. page_scale_fit: "Page Fit",
  12197. page_scale_auto: "Automatic Zoom",
  12198. page_scale_actual: "Actual Size",
  12199. page_scale_percent: "{{scale}}%",
  12200. loading_error: "An error occurred while loading the PDF.",
  12201. invalid_file_error: "Invalid or corrupted PDF file.",
  12202. missing_file_error: "Missing PDF file.",
  12203. unexpected_response_error: "Unexpected server response.",
  12204. rendering_error: "An error occurred while rendering the page.",
  12205. annotation_date_string: "{{date}}, {{time}}",
  12206. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  12207. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  12208. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
  12209. free_text2_default_content: "Start typing…",
  12210. editor_free_text2_aria_label: "Text Editor",
  12211. editor_ink2_aria_label: "Draw Editor",
  12212. editor_ink_canvas_aria_label: "User-created image"
  12213. };
  12214. {
  12215. DEFAULT_L10N_STRINGS.print_progress_percent = "{{progress}}%";
  12216. }
  12217. function getL10nFallback(key, args) {
  12218. switch (key) {
  12219. case "find_match_count":
  12220. key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
  12221. break;
  12222. case "find_match_count_limit":
  12223. key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
  12224. break;
  12225. }
  12226. return DEFAULT_L10N_STRINGS[key] || "";
  12227. }
  12228. function formatL10nValue(text, args) {
  12229. if (!args) {
  12230. return text;
  12231. }
  12232. return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  12233. return name in args ? args[name] : "{{" + name + "}}";
  12234. });
  12235. }
  12236. const NullL10n = {
  12237. async getLanguage() {
  12238. return "en-us";
  12239. },
  12240. async getDirection() {
  12241. return "ltr";
  12242. },
  12243. async get(key) {
  12244. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12245. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getL10nFallback(key, args);
  12246. return formatL10nValue(fallback, args);
  12247. },
  12248. async translate(element) {}
  12249. };
  12250. exports.NullL10n = NullL10n;
  12251. /***/ }),
  12252. /* 147 */
  12253. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12254. "use strict";
  12255. Object.defineProperty(exports, "__esModule", ({
  12256. value: true
  12257. }));
  12258. exports.PDFPageView = void 0;
  12259. __webpack_require__(89);
  12260. __webpack_require__(76);
  12261. var _pdfjsLib = __webpack_require__(121);
  12262. var _ui_utils = __webpack_require__(97);
  12263. var _annotation_editor_layer_builder = __webpack_require__(148);
  12264. var _annotation_layer_builder = __webpack_require__(149);
  12265. var _app_options = __webpack_require__(122);
  12266. var _l10n_utils = __webpack_require__(146);
  12267. var _pdf_link_service = __webpack_require__(124);
  12268. var _struct_tree_layer_builder = __webpack_require__(150);
  12269. var _text_accessibility = __webpack_require__(151);
  12270. var _text_highlighter = __webpack_require__(152);
  12271. var _text_layer_builder = __webpack_require__(153);
  12272. var _xfa_layer_builder = __webpack_require__(154);
  12273. const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  12274. const DEFAULT_LAYER_PROPERTIES = () => {
  12275. return null;
  12276. };
  12277. class PDFPageView {
  12278. #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  12279. #hasRestrictedScaling = false;
  12280. #layerProperties = null;
  12281. #loadingId = null;
  12282. #previousRotation = null;
  12283. #renderError = null;
  12284. #renderingState = _ui_utils.RenderingStates.INITIAL;
  12285. #textLayerMode = _ui_utils.TextLayerMode.ENABLE;
  12286. #useThumbnailCanvas = {
  12287. directDrawing: true,
  12288. initialOptionalContent: true,
  12289. regularAnnotations: true
  12290. };
  12291. #viewportMap = new WeakMap();
  12292. constructor(options) {
  12293. const container = options.container;
  12294. const defaultViewport = options.defaultViewport;
  12295. this.id = options.id;
  12296. this.renderingId = "page" + this.id;
  12297. this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
  12298. this.pdfPage = null;
  12299. this.pageLabel = null;
  12300. this.rotation = 0;
  12301. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  12302. this.viewport = defaultViewport;
  12303. this.pdfPageRotate = defaultViewport.rotation;
  12304. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  12305. this.#textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  12306. this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  12307. this.imageResourcesPath = options.imageResourcesPath || "";
  12308. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  12309. this.maxCanvasPixels = options.maxCanvasPixels ?? MAX_CANVAS_PIXELS;
  12310. this.pageColors = options.pageColors || null;
  12311. this.eventBus = options.eventBus;
  12312. this.renderingQueue = options.renderingQueue;
  12313. this.l10n = options.l10n || _l10n_utils.NullL10n;
  12314. this.renderTask = null;
  12315. this.resume = null;
  12316. this._isStandalone = !this.renderingQueue?.hasViewer();
  12317. this._container = container;
  12318. if (options.useOnlyCssZoom) {
  12319. console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
  12320. this.maxCanvasPixels = 0;
  12321. }
  12322. this._annotationCanvasMap = null;
  12323. this.annotationLayer = null;
  12324. this.annotationEditorLayer = null;
  12325. this.textLayer = null;
  12326. this.zoomLayer = null;
  12327. this.xfaLayer = null;
  12328. this.structTreeLayer = null;
  12329. const div = document.createElement("div");
  12330. div.className = "page";
  12331. div.setAttribute("data-page-number", this.id);
  12332. div.setAttribute("role", "region");
  12333. this.l10n.get("page_landmark", {
  12334. page: this.id
  12335. }).then(msg => {
  12336. div.setAttribute("aria-label", msg);
  12337. });
  12338. this.div = div;
  12339. this.#setDimensions();
  12340. container?.append(div);
  12341. if (this._isStandalone) {
  12342. container?.style.setProperty("--scale-factor", this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  12343. const {
  12344. optionalContentConfigPromise
  12345. } = options;
  12346. if (optionalContentConfigPromise) {
  12347. optionalContentConfigPromise.then(optionalContentConfig => {
  12348. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12349. return;
  12350. }
  12351. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12352. });
  12353. }
  12354. }
  12355. }
  12356. get renderingState() {
  12357. return this.#renderingState;
  12358. }
  12359. set renderingState(state) {
  12360. if (state === this.#renderingState) {
  12361. return;
  12362. }
  12363. this.#renderingState = state;
  12364. if (this.#loadingId) {
  12365. clearTimeout(this.#loadingId);
  12366. this.#loadingId = null;
  12367. }
  12368. switch (state) {
  12369. case _ui_utils.RenderingStates.PAUSED:
  12370. this.div.classList.remove("loading");
  12371. break;
  12372. case _ui_utils.RenderingStates.RUNNING:
  12373. this.div.classList.add("loadingIcon");
  12374. this.#loadingId = setTimeout(() => {
  12375. this.div.classList.add("loading");
  12376. this.#loadingId = null;
  12377. }, 0);
  12378. break;
  12379. case _ui_utils.RenderingStates.INITIAL:
  12380. case _ui_utils.RenderingStates.FINISHED:
  12381. this.div.classList.remove("loadingIcon", "loading");
  12382. break;
  12383. }
  12384. }
  12385. #setDimensions() {
  12386. const {
  12387. viewport
  12388. } = this;
  12389. if (this.pdfPage) {
  12390. if (this.#previousRotation === viewport.rotation) {
  12391. return;
  12392. }
  12393. this.#previousRotation = viewport.rotation;
  12394. }
  12395. (0, _pdfjsLib.setLayerDimensions)(this.div, viewport, true, false);
  12396. }
  12397. setPdfPage(pdfPage) {
  12398. if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
  12399. this._container?.style.setProperty("--hcm-highligh-filter", pdfPage.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  12400. }
  12401. this.pdfPage = pdfPage;
  12402. this.pdfPageRotate = pdfPage.rotate;
  12403. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12404. this.viewport = pdfPage.getViewport({
  12405. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12406. rotation: totalRotation
  12407. });
  12408. this.#setDimensions();
  12409. this.reset();
  12410. }
  12411. destroy() {
  12412. this.reset();
  12413. this.pdfPage?.cleanup();
  12414. }
  12415. get _textHighlighter() {
  12416. return (0, _pdfjsLib.shadow)(this, "_textHighlighter", new _text_highlighter.TextHighlighter({
  12417. pageIndex: this.id - 1,
  12418. eventBus: this.eventBus,
  12419. findController: this.#layerProperties().findController
  12420. }));
  12421. }
  12422. async #renderAnnotationLayer() {
  12423. let error = null;
  12424. try {
  12425. await this.annotationLayer.render(this.viewport, "display");
  12426. } catch (ex) {
  12427. console.error(`#renderAnnotationLayer: "${ex}".`);
  12428. error = ex;
  12429. } finally {
  12430. this.eventBus.dispatch("annotationlayerrendered", {
  12431. source: this,
  12432. pageNumber: this.id,
  12433. error
  12434. });
  12435. }
  12436. }
  12437. async #renderAnnotationEditorLayer() {
  12438. let error = null;
  12439. try {
  12440. await this.annotationEditorLayer.render(this.viewport, "display");
  12441. } catch (ex) {
  12442. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  12443. error = ex;
  12444. } finally {
  12445. this.eventBus.dispatch("annotationeditorlayerrendered", {
  12446. source: this,
  12447. pageNumber: this.id,
  12448. error
  12449. });
  12450. }
  12451. }
  12452. async #renderXfaLayer() {
  12453. let error = null;
  12454. try {
  12455. const result = await this.xfaLayer.render(this.viewport, "display");
  12456. if (result?.textDivs && this._textHighlighter) {
  12457. this.#buildXfaTextContentItems(result.textDivs);
  12458. }
  12459. } catch (ex) {
  12460. console.error(`#renderXfaLayer: "${ex}".`);
  12461. error = ex;
  12462. } finally {
  12463. this.eventBus.dispatch("xfalayerrendered", {
  12464. source: this,
  12465. pageNumber: this.id,
  12466. error
  12467. });
  12468. }
  12469. }
  12470. async #renderTextLayer() {
  12471. const {
  12472. pdfPage,
  12473. textLayer,
  12474. viewport
  12475. } = this;
  12476. if (!textLayer) {
  12477. return;
  12478. }
  12479. let error = null;
  12480. try {
  12481. if (!textLayer.renderingDone) {
  12482. const readableStream = pdfPage.streamTextContent({
  12483. includeMarkedContent: true,
  12484. disableNormalization: true
  12485. });
  12486. textLayer.setTextContentSource(readableStream);
  12487. }
  12488. await textLayer.render(viewport);
  12489. } catch (ex) {
  12490. if (ex instanceof _pdfjsLib.AbortException) {
  12491. return;
  12492. }
  12493. console.error(`#renderTextLayer: "${ex}".`);
  12494. error = ex;
  12495. }
  12496. this.eventBus.dispatch("textlayerrendered", {
  12497. source: this,
  12498. pageNumber: this.id,
  12499. numTextDivs: textLayer.numTextDivs,
  12500. error
  12501. });
  12502. this.#renderStructTreeLayer();
  12503. }
  12504. async #renderStructTreeLayer() {
  12505. if (!this.textLayer) {
  12506. return;
  12507. }
  12508. this.structTreeLayer ||= new _struct_tree_layer_builder.StructTreeLayerBuilder();
  12509. const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
  12510. const treeDom = this.structTreeLayer?.render(tree);
  12511. if (treeDom) {
  12512. this.canvas?.append(treeDom);
  12513. }
  12514. this.structTreeLayer?.show();
  12515. }
  12516. async #buildXfaTextContentItems(textDivs) {
  12517. const text = await this.pdfPage.getTextContent();
  12518. const items = [];
  12519. for (const item of text.items) {
  12520. items.push(item.str);
  12521. }
  12522. this._textHighlighter.setTextMapping(textDivs, items);
  12523. this._textHighlighter.enable();
  12524. }
  12525. _resetZoomLayer() {
  12526. let removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12527. if (!this.zoomLayer) {
  12528. return;
  12529. }
  12530. const zoomLayerCanvas = this.zoomLayer.firstChild;
  12531. this.#viewportMap.delete(zoomLayerCanvas);
  12532. zoomLayerCanvas.width = 0;
  12533. zoomLayerCanvas.height = 0;
  12534. if (removeFromDOM) {
  12535. this.zoomLayer.remove();
  12536. }
  12537. this.zoomLayer = null;
  12538. }
  12539. reset() {
  12540. let {
  12541. keepZoomLayer = false,
  12542. keepAnnotationLayer = false,
  12543. keepAnnotationEditorLayer = false,
  12544. keepXfaLayer = false,
  12545. keepTextLayer = false
  12546. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12547. this.cancelRendering({
  12548. keepAnnotationLayer,
  12549. keepAnnotationEditorLayer,
  12550. keepXfaLayer,
  12551. keepTextLayer
  12552. });
  12553. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  12554. const div = this.div;
  12555. const childNodes = div.childNodes,
  12556. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  12557. annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
  12558. annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
  12559. xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
  12560. textLayerNode = keepTextLayer && this.textLayer?.div || null;
  12561. for (let i = childNodes.length - 1; i >= 0; i--) {
  12562. const node = childNodes[i];
  12563. switch (node) {
  12564. case zoomLayerNode:
  12565. case annotationLayerNode:
  12566. case annotationEditorLayerNode:
  12567. case xfaLayerNode:
  12568. case textLayerNode:
  12569. continue;
  12570. }
  12571. node.remove();
  12572. }
  12573. div.removeAttribute("data-loaded");
  12574. if (annotationLayerNode) {
  12575. this.annotationLayer.hide();
  12576. }
  12577. if (annotationEditorLayerNode) {
  12578. this.annotationEditorLayer.hide();
  12579. }
  12580. if (xfaLayerNode) {
  12581. this.xfaLayer.hide();
  12582. }
  12583. if (textLayerNode) {
  12584. this.textLayer.hide();
  12585. }
  12586. this.structTreeLayer?.hide();
  12587. if (!zoomLayerNode) {
  12588. if (this.canvas) {
  12589. this.#viewportMap.delete(this.canvas);
  12590. this.canvas.width = 0;
  12591. this.canvas.height = 0;
  12592. delete this.canvas;
  12593. }
  12594. this._resetZoomLayer();
  12595. }
  12596. }
  12597. update(_ref) {
  12598. let {
  12599. scale = 0,
  12600. rotation = null,
  12601. optionalContentConfigPromise = null,
  12602. drawingDelay = -1
  12603. } = _ref;
  12604. this.scale = scale || this.scale;
  12605. if (typeof rotation === "number") {
  12606. this.rotation = rotation;
  12607. }
  12608. if (optionalContentConfigPromise instanceof Promise) {
  12609. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12610. optionalContentConfigPromise.then(optionalContentConfig => {
  12611. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12612. return;
  12613. }
  12614. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12615. });
  12616. }
  12617. this.#useThumbnailCanvas.directDrawing = true;
  12618. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12619. this.viewport = this.viewport.clone({
  12620. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12621. rotation: totalRotation
  12622. });
  12623. this.#setDimensions();
  12624. if (this._isStandalone) {
  12625. this._container?.style.setProperty("--scale-factor", this.viewport.scale);
  12626. }
  12627. if (this.canvas) {
  12628. let onlyCssZoom = false;
  12629. if (this.#hasRestrictedScaling) {
  12630. if (this.maxCanvasPixels === 0) {
  12631. onlyCssZoom = true;
  12632. } else if (this.maxCanvasPixels > 0) {
  12633. const {
  12634. width,
  12635. height
  12636. } = this.viewport;
  12637. const {
  12638. sx,
  12639. sy
  12640. } = this.outputScale;
  12641. onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
  12642. }
  12643. }
  12644. const postponeDrawing = !onlyCssZoom && drawingDelay >= 0 && drawingDelay < 1000;
  12645. if (postponeDrawing || onlyCssZoom) {
  12646. if (postponeDrawing && this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  12647. this.cancelRendering({
  12648. keepZoomLayer: true,
  12649. keepAnnotationLayer: true,
  12650. keepAnnotationEditorLayer: true,
  12651. keepXfaLayer: true,
  12652. keepTextLayer: true,
  12653. cancelExtraDelay: drawingDelay
  12654. });
  12655. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12656. this.#useThumbnailCanvas.directDrawing = false;
  12657. }
  12658. this.cssTransform({
  12659. target: this.canvas,
  12660. redrawAnnotationLayer: true,
  12661. redrawAnnotationEditorLayer: true,
  12662. redrawXfaLayer: true,
  12663. redrawTextLayer: !postponeDrawing,
  12664. hideTextLayer: postponeDrawing
  12665. });
  12666. if (postponeDrawing) {
  12667. return;
  12668. }
  12669. this.eventBus.dispatch("pagerendered", {
  12670. source: this,
  12671. pageNumber: this.id,
  12672. cssTransform: true,
  12673. timestamp: performance.now(),
  12674. error: this.#renderError
  12675. });
  12676. return;
  12677. }
  12678. if (!this.zoomLayer && !this.canvas.hidden) {
  12679. this.zoomLayer = this.canvas.parentNode;
  12680. this.zoomLayer.style.position = "absolute";
  12681. }
  12682. }
  12683. if (this.zoomLayer) {
  12684. this.cssTransform({
  12685. target: this.zoomLayer.firstChild
  12686. });
  12687. }
  12688. this.reset({
  12689. keepZoomLayer: true,
  12690. keepAnnotationLayer: true,
  12691. keepAnnotationEditorLayer: true,
  12692. keepXfaLayer: true,
  12693. keepTextLayer: true
  12694. });
  12695. }
  12696. cancelRendering() {
  12697. let {
  12698. keepAnnotationLayer = false,
  12699. keepAnnotationEditorLayer = false,
  12700. keepXfaLayer = false,
  12701. keepTextLayer = false,
  12702. cancelExtraDelay = 0
  12703. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12704. if (this.renderTask) {
  12705. this.renderTask.cancel(cancelExtraDelay);
  12706. this.renderTask = null;
  12707. }
  12708. this.resume = null;
  12709. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  12710. this.textLayer.cancel();
  12711. this.textLayer = null;
  12712. }
  12713. if (this.structTreeLayer && !this.textLayer) {
  12714. this.structTreeLayer = null;
  12715. }
  12716. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  12717. this.annotationLayer.cancel();
  12718. this.annotationLayer = null;
  12719. this._annotationCanvasMap = null;
  12720. }
  12721. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  12722. this.annotationEditorLayer.cancel();
  12723. this.annotationEditorLayer = null;
  12724. }
  12725. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  12726. this.xfaLayer.cancel();
  12727. this.xfaLayer = null;
  12728. this._textHighlighter?.disable();
  12729. }
  12730. }
  12731. cssTransform(_ref2) {
  12732. let {
  12733. target,
  12734. redrawAnnotationLayer = false,
  12735. redrawAnnotationEditorLayer = false,
  12736. redrawXfaLayer = false,
  12737. redrawTextLayer = false,
  12738. hideTextLayer = false
  12739. } = _ref2;
  12740. if (!target.hasAttribute("zooming")) {
  12741. target.setAttribute("zooming", true);
  12742. const {
  12743. style
  12744. } = target;
  12745. style.width = style.height = "";
  12746. }
  12747. const originalViewport = this.#viewportMap.get(target);
  12748. if (this.viewport !== originalViewport) {
  12749. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  12750. const absRotation = Math.abs(relativeRotation);
  12751. let scaleX = 1,
  12752. scaleY = 1;
  12753. if (absRotation === 90 || absRotation === 270) {
  12754. const {
  12755. width,
  12756. height
  12757. } = this.viewport;
  12758. scaleX = height / width;
  12759. scaleY = width / height;
  12760. }
  12761. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  12762. }
  12763. if (redrawAnnotationLayer && this.annotationLayer) {
  12764. this.#renderAnnotationLayer();
  12765. }
  12766. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  12767. this.#renderAnnotationEditorLayer();
  12768. }
  12769. if (redrawXfaLayer && this.xfaLayer) {
  12770. this.#renderXfaLayer();
  12771. }
  12772. if (this.textLayer) {
  12773. if (hideTextLayer) {
  12774. this.textLayer.hide();
  12775. this.structTreeLayer?.hide();
  12776. } else if (redrawTextLayer) {
  12777. this.#renderTextLayer();
  12778. }
  12779. }
  12780. }
  12781. get width() {
  12782. return this.viewport.width;
  12783. }
  12784. get height() {
  12785. return this.viewport.height;
  12786. }
  12787. getPagePoint(x, y) {
  12788. return this.viewport.convertToPdfPoint(x, y);
  12789. }
  12790. async #finishRenderTask(renderTask) {
  12791. let error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12792. if (renderTask === this.renderTask) {
  12793. this.renderTask = null;
  12794. }
  12795. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  12796. this.#renderError = null;
  12797. return;
  12798. }
  12799. this.#renderError = error;
  12800. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12801. this._resetZoomLayer(true);
  12802. this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
  12803. this.eventBus.dispatch("pagerendered", {
  12804. source: this,
  12805. pageNumber: this.id,
  12806. cssTransform: false,
  12807. timestamp: performance.now(),
  12808. error: this.#renderError
  12809. });
  12810. if (error) {
  12811. throw error;
  12812. }
  12813. }
  12814. async draw() {
  12815. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  12816. console.error("Must be in new state before drawing");
  12817. this.reset();
  12818. }
  12819. const {
  12820. div,
  12821. l10n,
  12822. pageColors,
  12823. pdfPage,
  12824. viewport
  12825. } = this;
  12826. if (!pdfPage) {
  12827. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12828. throw new Error("pdfPage is not loaded");
  12829. }
  12830. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12831. const canvasWrapper = document.createElement("div");
  12832. canvasWrapper.classList.add("canvasWrapper");
  12833. div.append(canvasWrapper);
  12834. if (!this.textLayer && this.#textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  12835. this._accessibilityManager ||= new _text_accessibility.TextAccessibilityManager();
  12836. this.textLayer = new _text_layer_builder.TextLayerBuilder({
  12837. highlighter: this._textHighlighter,
  12838. accessibilityManager: this._accessibilityManager,
  12839. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  12840. enablePermissions: this.#textLayerMode === _ui_utils.TextLayerMode.ENABLE_PERMISSIONS
  12841. });
  12842. div.append(this.textLayer.div);
  12843. }
  12844. if (!this.annotationLayer && this.#annotationMode !== _pdfjsLib.AnnotationMode.DISABLE) {
  12845. const {
  12846. annotationStorage,
  12847. downloadManager,
  12848. enableScripting,
  12849. fieldObjectsPromise,
  12850. hasJSActionsPromise,
  12851. linkService
  12852. } = this.#layerProperties();
  12853. this._annotationCanvasMap ||= new Map();
  12854. this.annotationLayer = new _annotation_layer_builder.AnnotationLayerBuilder({
  12855. pageDiv: div,
  12856. pdfPage,
  12857. annotationStorage,
  12858. imageResourcesPath: this.imageResourcesPath,
  12859. renderForms: this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS,
  12860. linkService,
  12861. downloadManager,
  12862. l10n,
  12863. enableScripting,
  12864. hasJSActionsPromise,
  12865. fieldObjectsPromise,
  12866. annotationCanvasMap: this._annotationCanvasMap,
  12867. accessibilityManager: this._accessibilityManager
  12868. });
  12869. }
  12870. const renderContinueCallback = cont => {
  12871. showCanvas?.(false);
  12872. if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
  12873. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  12874. this.resume = () => {
  12875. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12876. cont();
  12877. };
  12878. return;
  12879. }
  12880. cont();
  12881. };
  12882. const {
  12883. width,
  12884. height
  12885. } = viewport;
  12886. const canvas = document.createElement("canvas");
  12887. canvas.setAttribute("role", "presentation");
  12888. canvas.hidden = true;
  12889. const hasHCM = !!(pageColors?.background && pageColors?.foreground);
  12890. let showCanvas = isLastShow => {
  12891. if (!hasHCM || isLastShow) {
  12892. canvas.hidden = false;
  12893. showCanvas = null;
  12894. }
  12895. };
  12896. canvasWrapper.append(canvas);
  12897. this.canvas = canvas;
  12898. const ctx = canvas.getContext("2d", {
  12899. alpha: false
  12900. });
  12901. const outputScale = this.outputScale = new _ui_utils.OutputScale();
  12902. if (this.maxCanvasPixels === 0) {
  12903. const invScale = 1 / this.scale;
  12904. outputScale.sx *= invScale;
  12905. outputScale.sy *= invScale;
  12906. this.#hasRestrictedScaling = true;
  12907. } else if (this.maxCanvasPixels > 0) {
  12908. const pixelsInViewport = width * height;
  12909. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12910. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12911. outputScale.sx = maxScale;
  12912. outputScale.sy = maxScale;
  12913. this.#hasRestrictedScaling = true;
  12914. } else {
  12915. this.#hasRestrictedScaling = false;
  12916. }
  12917. }
  12918. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12919. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12920. canvas.width = (0, _ui_utils.roundToDivide)(width * outputScale.sx, sfx[0]);
  12921. canvas.height = (0, _ui_utils.roundToDivide)(height * outputScale.sy, sfy[0]);
  12922. const {
  12923. style
  12924. } = canvas;
  12925. style.width = (0, _ui_utils.roundToDivide)(width, sfx[1]) + "px";
  12926. style.height = (0, _ui_utils.roundToDivide)(height, sfy[1]) + "px";
  12927. this.#viewportMap.set(canvas, viewport);
  12928. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  12929. const renderContext = {
  12930. canvasContext: ctx,
  12931. transform,
  12932. viewport,
  12933. annotationMode: this.#annotationMode,
  12934. optionalContentConfigPromise: this._optionalContentConfigPromise,
  12935. annotationCanvasMap: this._annotationCanvasMap,
  12936. pageColors
  12937. };
  12938. const renderTask = this.renderTask = this.pdfPage.render(renderContext);
  12939. renderTask.onContinue = renderContinueCallback;
  12940. const resultPromise = renderTask.promise.then(async () => {
  12941. showCanvas?.(true);
  12942. await this.#finishRenderTask(renderTask);
  12943. this.#renderTextLayer();
  12944. if (this.annotationLayer) {
  12945. await this.#renderAnnotationLayer();
  12946. }
  12947. if (!this.annotationEditorLayer) {
  12948. const {
  12949. annotationEditorUIManager
  12950. } = this.#layerProperties();
  12951. if (!annotationEditorUIManager) {
  12952. return;
  12953. }
  12954. this.annotationEditorLayer = new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
  12955. uiManager: annotationEditorUIManager,
  12956. pageDiv: div,
  12957. pdfPage,
  12958. l10n,
  12959. accessibilityManager: this._accessibilityManager,
  12960. annotationLayer: this.annotationLayer?.annotationLayer
  12961. });
  12962. }
  12963. this.#renderAnnotationEditorLayer();
  12964. }, error => {
  12965. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12966. showCanvas?.(true);
  12967. }
  12968. return this.#finishRenderTask(renderTask, error);
  12969. });
  12970. if (pdfPage.isPureXfa) {
  12971. if (!this.xfaLayer) {
  12972. const {
  12973. annotationStorage,
  12974. linkService
  12975. } = this.#layerProperties();
  12976. this.xfaLayer = new _xfa_layer_builder.XfaLayerBuilder({
  12977. pageDiv: div,
  12978. pdfPage,
  12979. annotationStorage,
  12980. linkService
  12981. });
  12982. } else if (this.xfaLayer.div) {
  12983. div.append(this.xfaLayer.div);
  12984. }
  12985. this.#renderXfaLayer();
  12986. }
  12987. div.setAttribute("data-loaded", true);
  12988. this.eventBus.dispatch("pagerender", {
  12989. source: this,
  12990. pageNumber: this.id
  12991. });
  12992. return resultPromise;
  12993. }
  12994. setPageLabel(label) {
  12995. this.pageLabel = typeof label === "string" ? label : null;
  12996. if (this.pageLabel !== null) {
  12997. this.div.setAttribute("data-page-label", this.pageLabel);
  12998. } else {
  12999. this.div.removeAttribute("data-page-label");
  13000. }
  13001. }
  13002. get thumbnailCanvas() {
  13003. const {
  13004. directDrawing,
  13005. initialOptionalContent,
  13006. regularAnnotations
  13007. } = this.#useThumbnailCanvas;
  13008. return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
  13009. }
  13010. }
  13011. exports.PDFPageView = PDFPageView;
  13012. /***/ }),
  13013. /* 148 */
  13014. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13015. "use strict";
  13016. Object.defineProperty(exports, "__esModule", ({
  13017. value: true
  13018. }));
  13019. exports.AnnotationEditorLayerBuilder = void 0;
  13020. var _pdfjsLib = __webpack_require__(121);
  13021. var _l10n_utils = __webpack_require__(146);
  13022. class AnnotationEditorLayerBuilder {
  13023. #annotationLayer = null;
  13024. #uiManager;
  13025. constructor(options) {
  13026. this.pageDiv = options.pageDiv;
  13027. this.pdfPage = options.pdfPage;
  13028. this.accessibilityManager = options.accessibilityManager;
  13029. this.l10n = options.l10n || _l10n_utils.NullL10n;
  13030. this.annotationEditorLayer = null;
  13031. this.div = null;
  13032. this._cancelled = false;
  13033. this.#uiManager = options.uiManager;
  13034. this.#annotationLayer = options.annotationLayer || null;
  13035. }
  13036. async render(viewport) {
  13037. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13038. if (intent !== "display") {
  13039. return;
  13040. }
  13041. if (this._cancelled) {
  13042. return;
  13043. }
  13044. const clonedViewport = viewport.clone({
  13045. dontFlip: true
  13046. });
  13047. if (this.div) {
  13048. this.annotationEditorLayer.update({
  13049. viewport: clonedViewport
  13050. });
  13051. this.show();
  13052. return;
  13053. }
  13054. const div = this.div = document.createElement("div");
  13055. div.className = "annotationEditorLayer";
  13056. div.tabIndex = 0;
  13057. div.hidden = true;
  13058. this.pageDiv.append(div);
  13059. this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({
  13060. uiManager: this.#uiManager,
  13061. div,
  13062. accessibilityManager: this.accessibilityManager,
  13063. pageIndex: this.pdfPage.pageNumber - 1,
  13064. l10n: this.l10n,
  13065. viewport: clonedViewport,
  13066. annotationLayer: this.#annotationLayer
  13067. });
  13068. const parameters = {
  13069. viewport: clonedViewport,
  13070. div,
  13071. annotations: null,
  13072. intent
  13073. };
  13074. this.annotationEditorLayer.render(parameters);
  13075. this.show();
  13076. }
  13077. cancel() {
  13078. this._cancelled = true;
  13079. if (!this.div) {
  13080. return;
  13081. }
  13082. this.pageDiv = null;
  13083. this.annotationEditorLayer.destroy();
  13084. this.div.remove();
  13085. }
  13086. hide() {
  13087. if (!this.div) {
  13088. return;
  13089. }
  13090. this.div.hidden = true;
  13091. }
  13092. show() {
  13093. if (!this.div || this.annotationEditorLayer.isEmpty) {
  13094. return;
  13095. }
  13096. this.div.hidden = false;
  13097. }
  13098. }
  13099. exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
  13100. /***/ }),
  13101. /* 149 */
  13102. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13103. "use strict";
  13104. Object.defineProperty(exports, "__esModule", ({
  13105. value: true
  13106. }));
  13107. exports.AnnotationLayerBuilder = void 0;
  13108. var _pdfjsLib = __webpack_require__(121);
  13109. var _l10n_utils = __webpack_require__(146);
  13110. var _ui_utils = __webpack_require__(97);
  13111. class AnnotationLayerBuilder {
  13112. #onPresentationModeChanged = null;
  13113. constructor(_ref) {
  13114. let {
  13115. pageDiv,
  13116. pdfPage,
  13117. linkService,
  13118. downloadManager,
  13119. annotationStorage = null,
  13120. imageResourcesPath = "",
  13121. renderForms = true,
  13122. l10n = _l10n_utils.NullL10n,
  13123. enableScripting = false,
  13124. hasJSActionsPromise = null,
  13125. fieldObjectsPromise = null,
  13126. annotationCanvasMap = null,
  13127. accessibilityManager = null
  13128. } = _ref;
  13129. this.pageDiv = pageDiv;
  13130. this.pdfPage = pdfPage;
  13131. this.linkService = linkService;
  13132. this.downloadManager = downloadManager;
  13133. this.imageResourcesPath = imageResourcesPath;
  13134. this.renderForms = renderForms;
  13135. this.l10n = l10n;
  13136. this.annotationStorage = annotationStorage;
  13137. this.enableScripting = enableScripting;
  13138. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  13139. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  13140. this._annotationCanvasMap = annotationCanvasMap;
  13141. this._accessibilityManager = accessibilityManager;
  13142. this.annotationLayer = null;
  13143. this.div = null;
  13144. this._cancelled = false;
  13145. this._eventBus = linkService.eventBus;
  13146. }
  13147. async render(viewport) {
  13148. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13149. if (this.div) {
  13150. if (this._cancelled || !this.annotationLayer) {
  13151. return;
  13152. }
  13153. this.annotationLayer.update({
  13154. viewport: viewport.clone({
  13155. dontFlip: true
  13156. })
  13157. });
  13158. return;
  13159. }
  13160. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  13161. intent
  13162. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  13163. if (this._cancelled) {
  13164. return;
  13165. }
  13166. const div = this.div = document.createElement("div");
  13167. div.className = "annotationLayer";
  13168. this.pageDiv.append(div);
  13169. if (annotations.length === 0) {
  13170. this.hide();
  13171. return;
  13172. }
  13173. this.annotationLayer = new _pdfjsLib.AnnotationLayer({
  13174. div,
  13175. accessibilityManager: this._accessibilityManager,
  13176. annotationCanvasMap: this._annotationCanvasMap,
  13177. l10n: this.l10n,
  13178. page: this.pdfPage,
  13179. viewport: viewport.clone({
  13180. dontFlip: true
  13181. })
  13182. });
  13183. await this.annotationLayer.render({
  13184. annotations,
  13185. imageResourcesPath: this.imageResourcesPath,
  13186. renderForms: this.renderForms,
  13187. linkService: this.linkService,
  13188. downloadManager: this.downloadManager,
  13189. annotationStorage: this.annotationStorage,
  13190. enableScripting: this.enableScripting,
  13191. hasJSActions,
  13192. fieldObjects
  13193. });
  13194. if (this.linkService.isInPresentationMode) {
  13195. this.#updatePresentationModeState(_ui_utils.PresentationModeState.FULLSCREEN);
  13196. }
  13197. if (!this.#onPresentationModeChanged) {
  13198. this.#onPresentationModeChanged = evt => {
  13199. this.#updatePresentationModeState(evt.state);
  13200. };
  13201. this._eventBus?._on("presentationmodechanged", this.#onPresentationModeChanged);
  13202. }
  13203. }
  13204. cancel() {
  13205. this._cancelled = true;
  13206. if (this.#onPresentationModeChanged) {
  13207. this._eventBus?._off("presentationmodechanged", this.#onPresentationModeChanged);
  13208. this.#onPresentationModeChanged = null;
  13209. }
  13210. }
  13211. hide() {
  13212. if (!this.div) {
  13213. return;
  13214. }
  13215. this.div.hidden = true;
  13216. }
  13217. #updatePresentationModeState(state) {
  13218. if (!this.div) {
  13219. return;
  13220. }
  13221. let disableFormElements = false;
  13222. switch (state) {
  13223. case _ui_utils.PresentationModeState.FULLSCREEN:
  13224. disableFormElements = true;
  13225. break;
  13226. case _ui_utils.PresentationModeState.NORMAL:
  13227. break;
  13228. default:
  13229. return;
  13230. }
  13231. for (const section of this.div.childNodes) {
  13232. if (section.hasAttribute("data-internal-link")) {
  13233. continue;
  13234. }
  13235. section.inert = disableFormElements;
  13236. }
  13237. }
  13238. }
  13239. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  13240. /***/ }),
  13241. /* 150 */
  13242. /***/ ((__unused_webpack_module, exports) => {
  13243. "use strict";
  13244. Object.defineProperty(exports, "__esModule", ({
  13245. value: true
  13246. }));
  13247. exports.StructTreeLayerBuilder = void 0;
  13248. const PDF_ROLE_TO_HTML_ROLE = {
  13249. Document: null,
  13250. DocumentFragment: null,
  13251. Part: "group",
  13252. Sect: "group",
  13253. Div: "group",
  13254. Aside: "note",
  13255. NonStruct: "none",
  13256. P: null,
  13257. H: "heading",
  13258. Title: null,
  13259. FENote: "note",
  13260. Sub: "group",
  13261. Lbl: null,
  13262. Span: null,
  13263. Em: null,
  13264. Strong: null,
  13265. Link: "link",
  13266. Annot: "note",
  13267. Form: "form",
  13268. Ruby: null,
  13269. RB: null,
  13270. RT: null,
  13271. RP: null,
  13272. Warichu: null,
  13273. WT: null,
  13274. WP: null,
  13275. L: "list",
  13276. LI: "listitem",
  13277. LBody: null,
  13278. Table: "table",
  13279. TR: "row",
  13280. TH: "columnheader",
  13281. TD: "cell",
  13282. THead: "columnheader",
  13283. TBody: null,
  13284. TFoot: null,
  13285. Caption: null,
  13286. Figure: "figure",
  13287. Formula: null,
  13288. Artifact: null
  13289. };
  13290. const HEADING_PATTERN = /^H(\d+)$/;
  13291. class StructTreeLayerBuilder {
  13292. #treeDom = undefined;
  13293. get renderingDone() {
  13294. return this.#treeDom !== undefined;
  13295. }
  13296. render(structTree) {
  13297. if (this.#treeDom !== undefined) {
  13298. return this.#treeDom;
  13299. }
  13300. const treeDom = this.#walk(structTree);
  13301. treeDom?.classList.add("structTree");
  13302. return this.#treeDom = treeDom;
  13303. }
  13304. hide() {
  13305. if (this.#treeDom && !this.#treeDom.hidden) {
  13306. this.#treeDom.hidden = true;
  13307. }
  13308. }
  13309. show() {
  13310. if (this.#treeDom?.hidden) {
  13311. this.#treeDom.hidden = false;
  13312. }
  13313. }
  13314. #setAttributes(structElement, htmlElement) {
  13315. if (structElement.alt !== undefined) {
  13316. htmlElement.setAttribute("aria-label", structElement.alt);
  13317. }
  13318. if (structElement.id !== undefined) {
  13319. htmlElement.setAttribute("aria-owns", structElement.id);
  13320. }
  13321. if (structElement.lang !== undefined) {
  13322. htmlElement.setAttribute("lang", structElement.lang);
  13323. }
  13324. }
  13325. #walk(node) {
  13326. if (!node) {
  13327. return null;
  13328. }
  13329. const element = document.createElement("span");
  13330. if ("role" in node) {
  13331. const {
  13332. role
  13333. } = node;
  13334. const match = role.match(HEADING_PATTERN);
  13335. if (match) {
  13336. element.setAttribute("role", "heading");
  13337. element.setAttribute("aria-level", match[1]);
  13338. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  13339. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  13340. }
  13341. }
  13342. this.#setAttributes(node, element);
  13343. if (node.children) {
  13344. if (node.children.length === 1 && "id" in node.children[0]) {
  13345. this.#setAttributes(node.children[0], element);
  13346. } else {
  13347. for (const kid of node.children) {
  13348. element.append(this.#walk(kid));
  13349. }
  13350. }
  13351. }
  13352. return element;
  13353. }
  13354. }
  13355. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  13356. /***/ }),
  13357. /* 151 */
  13358. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13359. "use strict";
  13360. Object.defineProperty(exports, "__esModule", ({
  13361. value: true
  13362. }));
  13363. exports.TextAccessibilityManager = void 0;
  13364. __webpack_require__(76);
  13365. var _ui_utils = __webpack_require__(97);
  13366. class TextAccessibilityManager {
  13367. #enabled = false;
  13368. #textChildren = null;
  13369. #textNodes = new Map();
  13370. #waitingElements = new Map();
  13371. setTextMapping(textDivs) {
  13372. this.#textChildren = textDivs;
  13373. }
  13374. static #compareElementPositions(e1, e2) {
  13375. const rect1 = e1.getBoundingClientRect();
  13376. const rect2 = e2.getBoundingClientRect();
  13377. if (rect1.width === 0 && rect1.height === 0) {
  13378. return +1;
  13379. }
  13380. if (rect2.width === 0 && rect2.height === 0) {
  13381. return -1;
  13382. }
  13383. const top1 = rect1.y;
  13384. const bot1 = rect1.y + rect1.height;
  13385. const mid1 = rect1.y + rect1.height / 2;
  13386. const top2 = rect2.y;
  13387. const bot2 = rect2.y + rect2.height;
  13388. const mid2 = rect2.y + rect2.height / 2;
  13389. if (mid1 <= top2 && mid2 >= bot1) {
  13390. return -1;
  13391. }
  13392. if (mid2 <= top1 && mid1 >= bot2) {
  13393. return +1;
  13394. }
  13395. const centerX1 = rect1.x + rect1.width / 2;
  13396. const centerX2 = rect2.x + rect2.width / 2;
  13397. return centerX1 - centerX2;
  13398. }
  13399. enable() {
  13400. if (this.#enabled) {
  13401. throw new Error("TextAccessibilityManager is already enabled.");
  13402. }
  13403. if (!this.#textChildren) {
  13404. throw new Error("Text divs and strings have not been set.");
  13405. }
  13406. this.#enabled = true;
  13407. this.#textChildren = this.#textChildren.slice();
  13408. this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
  13409. if (this.#textNodes.size > 0) {
  13410. const textChildren = this.#textChildren;
  13411. for (const [id, nodeIndex] of this.#textNodes) {
  13412. const element = document.getElementById(id);
  13413. if (!element) {
  13414. this.#textNodes.delete(id);
  13415. continue;
  13416. }
  13417. this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
  13418. }
  13419. }
  13420. for (const [element, isRemovable] of this.#waitingElements) {
  13421. this.addPointerInTextLayer(element, isRemovable);
  13422. }
  13423. this.#waitingElements.clear();
  13424. }
  13425. disable() {
  13426. if (!this.#enabled) {
  13427. return;
  13428. }
  13429. this.#waitingElements.clear();
  13430. this.#textChildren = null;
  13431. this.#enabled = false;
  13432. }
  13433. removePointerInTextLayer(element) {
  13434. if (!this.#enabled) {
  13435. this.#waitingElements.delete(element);
  13436. return;
  13437. }
  13438. const children = this.#textChildren;
  13439. if (!children || children.length === 0) {
  13440. return;
  13441. }
  13442. const {
  13443. id
  13444. } = element;
  13445. const nodeIndex = this.#textNodes.get(id);
  13446. if (nodeIndex === undefined) {
  13447. return;
  13448. }
  13449. const node = children[nodeIndex];
  13450. this.#textNodes.delete(id);
  13451. let owns = node.getAttribute("aria-owns");
  13452. if (owns?.includes(id)) {
  13453. owns = owns.split(" ").filter(x => x !== id).join(" ");
  13454. if (owns) {
  13455. node.setAttribute("aria-owns", owns);
  13456. } else {
  13457. node.removeAttribute("aria-owns");
  13458. node.setAttribute("role", "presentation");
  13459. }
  13460. }
  13461. }
  13462. #addIdToAriaOwns(id, node) {
  13463. const owns = node.getAttribute("aria-owns");
  13464. if (!owns?.includes(id)) {
  13465. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  13466. }
  13467. node.removeAttribute("role");
  13468. }
  13469. addPointerInTextLayer(element, isRemovable) {
  13470. const {
  13471. id
  13472. } = element;
  13473. if (!id) {
  13474. return;
  13475. }
  13476. if (!this.#enabled) {
  13477. this.#waitingElements.set(element, isRemovable);
  13478. return;
  13479. }
  13480. if (isRemovable) {
  13481. this.removePointerInTextLayer(element);
  13482. }
  13483. const children = this.#textChildren;
  13484. if (!children || children.length === 0) {
  13485. return;
  13486. }
  13487. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
  13488. const nodeIndex = Math.max(0, index - 1);
  13489. this.#addIdToAriaOwns(id, children[nodeIndex]);
  13490. this.#textNodes.set(id, nodeIndex);
  13491. }
  13492. moveElementInDOM(container, element, contentElement, isRemovable) {
  13493. this.addPointerInTextLayer(contentElement, isRemovable);
  13494. if (!container.hasChildNodes()) {
  13495. container.append(element);
  13496. return;
  13497. }
  13498. const children = Array.from(container.childNodes).filter(node => node !== element);
  13499. if (children.length === 0) {
  13500. return;
  13501. }
  13502. const elementToCompare = contentElement || element;
  13503. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
  13504. if (index === 0) {
  13505. children[0].before(element);
  13506. } else {
  13507. children[index - 1].after(element);
  13508. }
  13509. }
  13510. }
  13511. exports.TextAccessibilityManager = TextAccessibilityManager;
  13512. /***/ }),
  13513. /* 152 */
  13514. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13515. "use strict";
  13516. Object.defineProperty(exports, "__esModule", ({
  13517. value: true
  13518. }));
  13519. exports.TextHighlighter = void 0;
  13520. __webpack_require__(76);
  13521. __webpack_require__(89);
  13522. class TextHighlighter {
  13523. constructor(_ref) {
  13524. let {
  13525. findController,
  13526. eventBus,
  13527. pageIndex
  13528. } = _ref;
  13529. this.findController = findController;
  13530. this.matches = [];
  13531. this.eventBus = eventBus;
  13532. this.pageIdx = pageIndex;
  13533. this._onUpdateTextLayerMatches = null;
  13534. this.textDivs = null;
  13535. this.textContentItemsStr = null;
  13536. this.enabled = false;
  13537. }
  13538. setTextMapping(divs, texts) {
  13539. this.textDivs = divs;
  13540. this.textContentItemsStr = texts;
  13541. }
  13542. enable() {
  13543. if (!this.textDivs || !this.textContentItemsStr) {
  13544. throw new Error("Text divs and strings have not been set.");
  13545. }
  13546. if (this.enabled) {
  13547. throw new Error("TextHighlighter is already enabled.");
  13548. }
  13549. this.enabled = true;
  13550. if (!this._onUpdateTextLayerMatches) {
  13551. this._onUpdateTextLayerMatches = evt => {
  13552. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  13553. this._updateMatches();
  13554. }
  13555. };
  13556. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13557. }
  13558. this._updateMatches();
  13559. }
  13560. disable() {
  13561. if (!this.enabled) {
  13562. return;
  13563. }
  13564. this.enabled = false;
  13565. if (this._onUpdateTextLayerMatches) {
  13566. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13567. this._onUpdateTextLayerMatches = null;
  13568. }
  13569. this._updateMatches(true);
  13570. }
  13571. _convertMatches(matches, matchesLength) {
  13572. if (!matches) {
  13573. return [];
  13574. }
  13575. const {
  13576. textContentItemsStr
  13577. } = this;
  13578. let i = 0,
  13579. iIndex = 0;
  13580. const end = textContentItemsStr.length - 1;
  13581. const result = [];
  13582. for (let m = 0, mm = matches.length; m < mm; m++) {
  13583. let matchIdx = matches[m];
  13584. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  13585. iIndex += textContentItemsStr[i].length;
  13586. i++;
  13587. }
  13588. if (i === textContentItemsStr.length) {
  13589. console.error("Could not find a matching mapping");
  13590. }
  13591. const match = {
  13592. begin: {
  13593. divIdx: i,
  13594. offset: matchIdx - iIndex
  13595. }
  13596. };
  13597. matchIdx += matchesLength[m];
  13598. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  13599. iIndex += textContentItemsStr[i].length;
  13600. i++;
  13601. }
  13602. match.end = {
  13603. divIdx: i,
  13604. offset: matchIdx - iIndex
  13605. };
  13606. result.push(match);
  13607. }
  13608. return result;
  13609. }
  13610. _renderMatches(matches) {
  13611. if (matches.length === 0) {
  13612. return;
  13613. }
  13614. const {
  13615. findController,
  13616. pageIdx
  13617. } = this;
  13618. const {
  13619. textContentItemsStr,
  13620. textDivs
  13621. } = this;
  13622. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  13623. const selectedMatchIdx = findController.selected.matchIdx;
  13624. const highlightAll = findController.state.highlightAll;
  13625. let prevEnd = null;
  13626. const infinity = {
  13627. divIdx: -1,
  13628. offset: undefined
  13629. };
  13630. function beginText(begin, className) {
  13631. const divIdx = begin.divIdx;
  13632. textDivs[divIdx].textContent = "";
  13633. return appendTextToDiv(divIdx, 0, begin.offset, className);
  13634. }
  13635. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  13636. let div = textDivs[divIdx];
  13637. if (div.nodeType === Node.TEXT_NODE) {
  13638. const span = document.createElement("span");
  13639. div.before(span);
  13640. span.append(div);
  13641. textDivs[divIdx] = span;
  13642. div = span;
  13643. }
  13644. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  13645. const node = document.createTextNode(content);
  13646. if (className) {
  13647. const span = document.createElement("span");
  13648. span.className = `${className} appended`;
  13649. span.append(node);
  13650. div.append(span);
  13651. return className.includes("selected") ? span.offsetLeft : 0;
  13652. }
  13653. div.append(node);
  13654. return 0;
  13655. }
  13656. let i0 = selectedMatchIdx,
  13657. i1 = i0 + 1;
  13658. if (highlightAll) {
  13659. i0 = 0;
  13660. i1 = matches.length;
  13661. } else if (!isSelectedPage) {
  13662. return;
  13663. }
  13664. let lastDivIdx = -1;
  13665. let lastOffset = -1;
  13666. for (let i = i0; i < i1; i++) {
  13667. const match = matches[i];
  13668. const begin = match.begin;
  13669. if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
  13670. continue;
  13671. }
  13672. lastDivIdx = begin.divIdx;
  13673. lastOffset = begin.offset;
  13674. const end = match.end;
  13675. const isSelected = isSelectedPage && i === selectedMatchIdx;
  13676. const highlightSuffix = isSelected ? " selected" : "";
  13677. let selectedLeft = 0;
  13678. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  13679. if (prevEnd !== null) {
  13680. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13681. }
  13682. beginText(begin);
  13683. } else {
  13684. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  13685. }
  13686. if (begin.divIdx === end.divIdx) {
  13687. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  13688. } else {
  13689. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  13690. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  13691. textDivs[n0].className = "highlight middle" + highlightSuffix;
  13692. }
  13693. beginText(end, "highlight end" + highlightSuffix);
  13694. }
  13695. prevEnd = end;
  13696. if (isSelected) {
  13697. findController.scrollMatchIntoView({
  13698. element: textDivs[begin.divIdx],
  13699. selectedLeft,
  13700. pageIndex: pageIdx,
  13701. matchIndex: selectedMatchIdx
  13702. });
  13703. }
  13704. }
  13705. if (prevEnd) {
  13706. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13707. }
  13708. }
  13709. _updateMatches() {
  13710. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13711. if (!this.enabled && !reset) {
  13712. return;
  13713. }
  13714. const {
  13715. findController,
  13716. matches,
  13717. pageIdx
  13718. } = this;
  13719. const {
  13720. textContentItemsStr,
  13721. textDivs
  13722. } = this;
  13723. let clearedUntilDivIdx = -1;
  13724. for (const match of matches) {
  13725. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13726. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  13727. const div = textDivs[n];
  13728. div.textContent = textContentItemsStr[n];
  13729. div.className = "";
  13730. }
  13731. clearedUntilDivIdx = match.end.divIdx + 1;
  13732. }
  13733. if (!findController?.highlightMatches || reset) {
  13734. return;
  13735. }
  13736. const pageMatches = findController.pageMatches[pageIdx] || null;
  13737. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13738. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13739. this._renderMatches(this.matches);
  13740. }
  13741. }
  13742. exports.TextHighlighter = TextHighlighter;
  13743. /***/ }),
  13744. /* 153 */
  13745. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13746. "use strict";
  13747. Object.defineProperty(exports, "__esModule", ({
  13748. value: true
  13749. }));
  13750. exports.TextLayerBuilder = void 0;
  13751. __webpack_require__(76);
  13752. var _pdfjsLib = __webpack_require__(121);
  13753. var _ui_utils = __webpack_require__(97);
  13754. class TextLayerBuilder {
  13755. #enablePermissions = false;
  13756. #rotation = 0;
  13757. #scale = 0;
  13758. #textContentSource = null;
  13759. constructor(_ref) {
  13760. let {
  13761. highlighter = null,
  13762. accessibilityManager = null,
  13763. isOffscreenCanvasSupported = true,
  13764. enablePermissions = false
  13765. } = _ref;
  13766. this.textContentItemsStr = [];
  13767. this.renderingDone = false;
  13768. this.textDivs = [];
  13769. this.textDivProperties = new WeakMap();
  13770. this.textLayerRenderTask = null;
  13771. this.highlighter = highlighter;
  13772. this.accessibilityManager = accessibilityManager;
  13773. this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  13774. this.#enablePermissions = enablePermissions === true;
  13775. this.div = document.createElement("div");
  13776. this.div.className = "textLayer";
  13777. this.hide();
  13778. }
  13779. #finishRendering() {
  13780. this.renderingDone = true;
  13781. const endOfContent = document.createElement("div");
  13782. endOfContent.className = "endOfContent";
  13783. this.div.append(endOfContent);
  13784. this.#bindMouse();
  13785. }
  13786. get numTextDivs() {
  13787. return this.textDivs.length;
  13788. }
  13789. async render(viewport) {
  13790. if (!this.#textContentSource) {
  13791. throw new Error('No "textContentSource" parameter specified.');
  13792. }
  13793. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  13794. const {
  13795. rotation
  13796. } = viewport;
  13797. if (this.renderingDone) {
  13798. const mustRotate = rotation !== this.#rotation;
  13799. const mustRescale = scale !== this.#scale;
  13800. if (mustRotate || mustRescale) {
  13801. this.hide();
  13802. (0, _pdfjsLib.updateTextLayer)({
  13803. container: this.div,
  13804. viewport,
  13805. textDivs: this.textDivs,
  13806. textDivProperties: this.textDivProperties,
  13807. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  13808. mustRescale,
  13809. mustRotate
  13810. });
  13811. this.#scale = scale;
  13812. this.#rotation = rotation;
  13813. }
  13814. this.show();
  13815. return;
  13816. }
  13817. this.cancel();
  13818. this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
  13819. this.accessibilityManager?.setTextMapping(this.textDivs);
  13820. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  13821. textContentSource: this.#textContentSource,
  13822. container: this.div,
  13823. viewport,
  13824. textDivs: this.textDivs,
  13825. textDivProperties: this.textDivProperties,
  13826. textContentItemsStr: this.textContentItemsStr,
  13827. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported
  13828. });
  13829. await this.textLayerRenderTask.promise;
  13830. this.#finishRendering();
  13831. this.#scale = scale;
  13832. this.#rotation = rotation;
  13833. this.show();
  13834. this.accessibilityManager?.enable();
  13835. }
  13836. hide() {
  13837. if (!this.div.hidden) {
  13838. this.highlighter?.disable();
  13839. this.div.hidden = true;
  13840. }
  13841. }
  13842. show() {
  13843. if (this.div.hidden && this.renderingDone) {
  13844. this.div.hidden = false;
  13845. this.highlighter?.enable();
  13846. }
  13847. }
  13848. cancel() {
  13849. if (this.textLayerRenderTask) {
  13850. this.textLayerRenderTask.cancel();
  13851. this.textLayerRenderTask = null;
  13852. }
  13853. this.highlighter?.disable();
  13854. this.accessibilityManager?.disable();
  13855. this.textContentItemsStr.length = 0;
  13856. this.textDivs.length = 0;
  13857. this.textDivProperties = new WeakMap();
  13858. }
  13859. setTextContentSource(source) {
  13860. this.cancel();
  13861. this.#textContentSource = source;
  13862. }
  13863. #bindMouse() {
  13864. const {
  13865. div
  13866. } = this;
  13867. div.addEventListener("mousedown", evt => {
  13868. const end = div.querySelector(".endOfContent");
  13869. if (!end) {
  13870. return;
  13871. }
  13872. let adjustTop = evt.target !== div;
  13873. adjustTop &&= getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  13874. if (adjustTop) {
  13875. const divBounds = div.getBoundingClientRect();
  13876. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  13877. end.style.top = (r * 100).toFixed(2) + "%";
  13878. }
  13879. end.classList.add("active");
  13880. });
  13881. div.addEventListener("mouseup", () => {
  13882. const end = div.querySelector(".endOfContent");
  13883. if (!end) {
  13884. return;
  13885. }
  13886. end.style.top = "";
  13887. end.classList.remove("active");
  13888. });
  13889. div.addEventListener("copy", event => {
  13890. if (!this.#enablePermissions) {
  13891. const selection = document.getSelection();
  13892. event.clipboardData.setData("text/plain", (0, _ui_utils.removeNullCharacters)((0, _pdfjsLib.normalizeUnicode)(selection.toString())));
  13893. }
  13894. event.preventDefault();
  13895. event.stopPropagation();
  13896. });
  13897. }
  13898. }
  13899. exports.TextLayerBuilder = TextLayerBuilder;
  13900. /***/ }),
  13901. /* 154 */
  13902. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13903. "use strict";
  13904. Object.defineProperty(exports, "__esModule", ({
  13905. value: true
  13906. }));
  13907. exports.XfaLayerBuilder = void 0;
  13908. var _pdfjsLib = __webpack_require__(121);
  13909. class XfaLayerBuilder {
  13910. constructor(_ref) {
  13911. let {
  13912. pageDiv,
  13913. pdfPage,
  13914. annotationStorage = null,
  13915. linkService,
  13916. xfaHtml = null
  13917. } = _ref;
  13918. this.pageDiv = pageDiv;
  13919. this.pdfPage = pdfPage;
  13920. this.annotationStorage = annotationStorage;
  13921. this.linkService = linkService;
  13922. this.xfaHtml = xfaHtml;
  13923. this.div = null;
  13924. this._cancelled = false;
  13925. }
  13926. async render(viewport) {
  13927. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13928. if (intent === "print") {
  13929. const parameters = {
  13930. viewport: viewport.clone({
  13931. dontFlip: true
  13932. }),
  13933. div: this.div,
  13934. xfaHtml: this.xfaHtml,
  13935. annotationStorage: this.annotationStorage,
  13936. linkService: this.linkService,
  13937. intent
  13938. };
  13939. const div = document.createElement("div");
  13940. this.pageDiv.append(div);
  13941. parameters.div = div;
  13942. return _pdfjsLib.XfaLayer.render(parameters);
  13943. }
  13944. const xfaHtml = await this.pdfPage.getXfa();
  13945. if (this._cancelled || !xfaHtml) {
  13946. return {
  13947. textDivs: []
  13948. };
  13949. }
  13950. const parameters = {
  13951. viewport: viewport.clone({
  13952. dontFlip: true
  13953. }),
  13954. div: this.div,
  13955. xfaHtml,
  13956. annotationStorage: this.annotationStorage,
  13957. linkService: this.linkService,
  13958. intent
  13959. };
  13960. if (this.div) {
  13961. return _pdfjsLib.XfaLayer.update(parameters);
  13962. }
  13963. this.div = document.createElement("div");
  13964. this.pageDiv.append(this.div);
  13965. parameters.div = this.div;
  13966. return _pdfjsLib.XfaLayer.render(parameters);
  13967. }
  13968. cancel() {
  13969. this._cancelled = true;
  13970. }
  13971. hide() {
  13972. if (!this.div) {
  13973. return;
  13974. }
  13975. this.div.hidden = true;
  13976. }
  13977. }
  13978. exports.XfaLayerBuilder = XfaLayerBuilder;
  13979. /***/ }),
  13980. /* 155 */
  13981. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13982. "use strict";
  13983. Object.defineProperty(exports, "__esModule", ({
  13984. value: true
  13985. }));
  13986. exports.SecondaryToolbar = void 0;
  13987. __webpack_require__(89);
  13988. var _ui_utils = __webpack_require__(97);
  13989. var _pdf_viewer = __webpack_require__(145);
  13990. class SecondaryToolbar {
  13991. constructor(options, eventBus, externalServices) {
  13992. this.toolbar = options.toolbar;
  13993. this.toggleButton = options.toggleButton;
  13994. this.buttons = [{
  13995. element: options.presentationModeButton,
  13996. eventName: "presentationmode",
  13997. close: true
  13998. }, {
  13999. element: options.printButton,
  14000. eventName: "print",
  14001. close: true
  14002. }, {
  14003. element: options.downloadButton,
  14004. eventName: "download",
  14005. close: true
  14006. }, {
  14007. element: options.viewBookmarkButton,
  14008. eventName: null,
  14009. close: true
  14010. }, {
  14011. element: options.firstPageButton,
  14012. eventName: "firstpage",
  14013. close: true
  14014. }, {
  14015. element: options.lastPageButton,
  14016. eventName: "lastpage",
  14017. close: true
  14018. }, {
  14019. element: options.pageRotateCwButton,
  14020. eventName: "rotatecw",
  14021. close: false
  14022. }, {
  14023. element: options.pageRotateCcwButton,
  14024. eventName: "rotateccw",
  14025. close: false
  14026. }, {
  14027. element: options.cursorSelectToolButton,
  14028. eventName: "switchcursortool",
  14029. eventDetails: {
  14030. tool: _ui_utils.CursorTool.SELECT
  14031. },
  14032. close: true
  14033. }, {
  14034. element: options.cursorHandToolButton,
  14035. eventName: "switchcursortool",
  14036. eventDetails: {
  14037. tool: _ui_utils.CursorTool.HAND
  14038. },
  14039. close: true
  14040. }, {
  14041. element: options.scrollPageButton,
  14042. eventName: "switchscrollmode",
  14043. eventDetails: {
  14044. mode: _ui_utils.ScrollMode.PAGE
  14045. },
  14046. close: true
  14047. }, {
  14048. element: options.scrollVerticalButton,
  14049. eventName: "switchscrollmode",
  14050. eventDetails: {
  14051. mode: _ui_utils.ScrollMode.VERTICAL
  14052. },
  14053. close: true
  14054. }, {
  14055. element: options.scrollHorizontalButton,
  14056. eventName: "switchscrollmode",
  14057. eventDetails: {
  14058. mode: _ui_utils.ScrollMode.HORIZONTAL
  14059. },
  14060. close: true
  14061. }, {
  14062. element: options.scrollWrappedButton,
  14063. eventName: "switchscrollmode",
  14064. eventDetails: {
  14065. mode: _ui_utils.ScrollMode.WRAPPED
  14066. },
  14067. close: true
  14068. }, {
  14069. element: options.spreadNoneButton,
  14070. eventName: "switchspreadmode",
  14071. eventDetails: {
  14072. mode: _ui_utils.SpreadMode.NONE
  14073. },
  14074. close: true
  14075. }, {
  14076. element: options.spreadOddButton,
  14077. eventName: "switchspreadmode",
  14078. eventDetails: {
  14079. mode: _ui_utils.SpreadMode.ODD
  14080. },
  14081. close: true
  14082. }, {
  14083. element: options.spreadEvenButton,
  14084. eventName: "switchspreadmode",
  14085. eventDetails: {
  14086. mode: _ui_utils.SpreadMode.EVEN
  14087. },
  14088. close: true
  14089. }, {
  14090. element: options.documentPropertiesButton,
  14091. eventName: "documentproperties",
  14092. close: true
  14093. }];
  14094. this.buttons.push({
  14095. element: options.openFileButton,
  14096. eventName: "openfile",
  14097. close: true
  14098. });
  14099. this.items = {
  14100. firstPage: options.firstPageButton,
  14101. lastPage: options.lastPageButton,
  14102. pageRotateCw: options.pageRotateCwButton,
  14103. pageRotateCcw: options.pageRotateCcwButton
  14104. };
  14105. this.eventBus = eventBus;
  14106. this.externalServices = externalServices;
  14107. this.opened = false;
  14108. this.#bindClickListeners();
  14109. this.#bindCursorToolsListener(options);
  14110. this.#bindScrollModeListener(options);
  14111. this.#bindSpreadModeListener(options);
  14112. this.reset();
  14113. }
  14114. get isOpen() {
  14115. return this.opened;
  14116. }
  14117. setPageNumber(pageNumber) {
  14118. this.pageNumber = pageNumber;
  14119. this.#updateUIState();
  14120. }
  14121. setPagesCount(pagesCount) {
  14122. this.pagesCount = pagesCount;
  14123. this.#updateUIState();
  14124. }
  14125. reset() {
  14126. this.pageNumber = 0;
  14127. this.pagesCount = 0;
  14128. this.#updateUIState();
  14129. this.eventBus.dispatch("secondarytoolbarreset", {
  14130. source: this
  14131. });
  14132. }
  14133. #updateUIState() {
  14134. this.items.firstPage.disabled = this.pageNumber <= 1;
  14135. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  14136. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  14137. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  14138. }
  14139. #bindClickListeners() {
  14140. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  14141. for (const {
  14142. element,
  14143. eventName,
  14144. close,
  14145. eventDetails
  14146. } of this.buttons) {
  14147. element.addEventListener("click", evt => {
  14148. if (eventName !== null) {
  14149. this.eventBus.dispatch(eventName, {
  14150. source: this,
  14151. ...eventDetails
  14152. });
  14153. }
  14154. if (close) {
  14155. this.close();
  14156. }
  14157. this.externalServices.reportTelemetry({
  14158. type: "buttons",
  14159. data: {
  14160. id: element.id
  14161. }
  14162. });
  14163. });
  14164. }
  14165. }
  14166. #bindCursorToolsListener(_ref) {
  14167. let {
  14168. cursorSelectToolButton,
  14169. cursorHandToolButton
  14170. } = _ref;
  14171. this.eventBus._on("cursortoolchanged", _ref2 => {
  14172. let {
  14173. tool
  14174. } = _ref2;
  14175. (0, _ui_utils.toggleCheckedBtn)(cursorSelectToolButton, tool === _ui_utils.CursorTool.SELECT);
  14176. (0, _ui_utils.toggleCheckedBtn)(cursorHandToolButton, tool === _ui_utils.CursorTool.HAND);
  14177. });
  14178. }
  14179. #bindScrollModeListener(_ref3) {
  14180. let {
  14181. scrollPageButton,
  14182. scrollVerticalButton,
  14183. scrollHorizontalButton,
  14184. scrollWrappedButton,
  14185. spreadNoneButton,
  14186. spreadOddButton,
  14187. spreadEvenButton
  14188. } = _ref3;
  14189. const scrollModeChanged = _ref4 => {
  14190. let {
  14191. mode
  14192. } = _ref4;
  14193. (0, _ui_utils.toggleCheckedBtn)(scrollPageButton, mode === _ui_utils.ScrollMode.PAGE);
  14194. (0, _ui_utils.toggleCheckedBtn)(scrollVerticalButton, mode === _ui_utils.ScrollMode.VERTICAL);
  14195. (0, _ui_utils.toggleCheckedBtn)(scrollHorizontalButton, mode === _ui_utils.ScrollMode.HORIZONTAL);
  14196. (0, _ui_utils.toggleCheckedBtn)(scrollWrappedButton, mode === _ui_utils.ScrollMode.WRAPPED);
  14197. const forceScrollModePage = this.pagesCount > _pdf_viewer.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  14198. scrollPageButton.disabled = forceScrollModePage;
  14199. scrollVerticalButton.disabled = forceScrollModePage;
  14200. scrollHorizontalButton.disabled = forceScrollModePage;
  14201. scrollWrappedButton.disabled = forceScrollModePage;
  14202. const isHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  14203. spreadNoneButton.disabled = isHorizontal;
  14204. spreadOddButton.disabled = isHorizontal;
  14205. spreadEvenButton.disabled = isHorizontal;
  14206. };
  14207. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  14208. this.eventBus._on("secondarytoolbarreset", evt => {
  14209. if (evt.source === this) {
  14210. scrollModeChanged({
  14211. mode: _ui_utils.ScrollMode.VERTICAL
  14212. });
  14213. }
  14214. });
  14215. }
  14216. #bindSpreadModeListener(_ref5) {
  14217. let {
  14218. spreadNoneButton,
  14219. spreadOddButton,
  14220. spreadEvenButton
  14221. } = _ref5;
  14222. const spreadModeChanged = _ref6 => {
  14223. let {
  14224. mode
  14225. } = _ref6;
  14226. (0, _ui_utils.toggleCheckedBtn)(spreadNoneButton, mode === _ui_utils.SpreadMode.NONE);
  14227. (0, _ui_utils.toggleCheckedBtn)(spreadOddButton, mode === _ui_utils.SpreadMode.ODD);
  14228. (0, _ui_utils.toggleCheckedBtn)(spreadEvenButton, mode === _ui_utils.SpreadMode.EVEN);
  14229. };
  14230. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  14231. this.eventBus._on("secondarytoolbarreset", evt => {
  14232. if (evt.source === this) {
  14233. spreadModeChanged({
  14234. mode: _ui_utils.SpreadMode.NONE
  14235. });
  14236. }
  14237. });
  14238. }
  14239. open() {
  14240. if (this.opened) {
  14241. return;
  14242. }
  14243. this.opened = true;
  14244. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true, this.toolbar);
  14245. }
  14246. close() {
  14247. if (!this.opened) {
  14248. return;
  14249. }
  14250. this.opened = false;
  14251. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false, this.toolbar);
  14252. }
  14253. toggle() {
  14254. if (this.opened) {
  14255. this.close();
  14256. } else {
  14257. this.open();
  14258. }
  14259. }
  14260. }
  14261. exports.SecondaryToolbar = SecondaryToolbar;
  14262. /***/ }),
  14263. /* 156 */
  14264. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14265. "use strict";
  14266. Object.defineProperty(exports, "__esModule", ({
  14267. value: true
  14268. }));
  14269. exports.Toolbar = void 0;
  14270. __webpack_require__(89);
  14271. var _ui_utils = __webpack_require__(97);
  14272. var _pdfjsLib = __webpack_require__(121);
  14273. const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  14274. class Toolbar {
  14275. #wasLocalized = false;
  14276. constructor(options, eventBus, l10n) {
  14277. this.toolbar = options.container;
  14278. this.eventBus = eventBus;
  14279. this.l10n = l10n;
  14280. this.buttons = [{
  14281. element: options.previous,
  14282. eventName: "previouspage"
  14283. }, {
  14284. element: options.next,
  14285. eventName: "nextpage"
  14286. }, {
  14287. element: options.zoomIn,
  14288. eventName: "zoomin"
  14289. }, {
  14290. element: options.zoomOut,
  14291. eventName: "zoomout"
  14292. }, {
  14293. element: options.print,
  14294. eventName: "print"
  14295. }, {
  14296. element: options.download,
  14297. eventName: "download"
  14298. }, {
  14299. element: options.editorFreeTextButton,
  14300. eventName: "switchannotationeditormode",
  14301. eventDetails: {
  14302. get mode() {
  14303. const {
  14304. classList
  14305. } = options.editorFreeTextButton;
  14306. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.FREETEXT;
  14307. }
  14308. }
  14309. }, {
  14310. element: options.editorInkButton,
  14311. eventName: "switchannotationeditormode",
  14312. eventDetails: {
  14313. get mode() {
  14314. const {
  14315. classList
  14316. } = options.editorInkButton;
  14317. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.INK;
  14318. }
  14319. }
  14320. }, {
  14321. element: options.editorStampButton,
  14322. eventName: "switchannotationeditormode",
  14323. eventDetails: {
  14324. get mode() {
  14325. const {
  14326. classList
  14327. } = options.editorStampButton;
  14328. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.STAMP;
  14329. }
  14330. }
  14331. }];
  14332. this.buttons.push({
  14333. element: options.openFile,
  14334. eventName: "openfile"
  14335. });
  14336. this.items = {
  14337. numPages: options.numPages,
  14338. pageNumber: options.pageNumber,
  14339. scaleSelect: options.scaleSelect,
  14340. customScaleOption: options.customScaleOption,
  14341. previous: options.previous,
  14342. next: options.next,
  14343. zoomIn: options.zoomIn,
  14344. zoomOut: options.zoomOut
  14345. };
  14346. this.#bindListeners(options);
  14347. this.reset();
  14348. }
  14349. setPageNumber(pageNumber, pageLabel) {
  14350. this.pageNumber = pageNumber;
  14351. this.pageLabel = pageLabel;
  14352. this.#updateUIState(false);
  14353. }
  14354. setPagesCount(pagesCount, hasPageLabels) {
  14355. this.pagesCount = pagesCount;
  14356. this.hasPageLabels = hasPageLabels;
  14357. this.#updateUIState(true);
  14358. }
  14359. setPageScale(pageScaleValue, pageScale) {
  14360. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  14361. this.pageScale = pageScale;
  14362. this.#updateUIState(false);
  14363. }
  14364. reset() {
  14365. this.pageNumber = 0;
  14366. this.pageLabel = null;
  14367. this.hasPageLabels = false;
  14368. this.pagesCount = 0;
  14369. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  14370. this.pageScale = _ui_utils.DEFAULT_SCALE;
  14371. this.#updateUIState(true);
  14372. this.updateLoadingIndicatorState();
  14373. this.eventBus.dispatch("toolbarreset", {
  14374. source: this
  14375. });
  14376. }
  14377. #bindListeners(options) {
  14378. const {
  14379. pageNumber,
  14380. scaleSelect
  14381. } = this.items;
  14382. const self = this;
  14383. for (const {
  14384. element,
  14385. eventName,
  14386. eventDetails
  14387. } of this.buttons) {
  14388. element.addEventListener("click", evt => {
  14389. if (eventName !== null) {
  14390. this.eventBus.dispatch(eventName, {
  14391. source: this,
  14392. ...eventDetails
  14393. });
  14394. }
  14395. });
  14396. }
  14397. pageNumber.addEventListener("click", function () {
  14398. this.select();
  14399. });
  14400. pageNumber.addEventListener("change", function () {
  14401. self.eventBus.dispatch("pagenumberchanged", {
  14402. source: self,
  14403. value: this.value
  14404. });
  14405. });
  14406. scaleSelect.addEventListener("change", function () {
  14407. if (this.value === "custom") {
  14408. return;
  14409. }
  14410. self.eventBus.dispatch("scalechanged", {
  14411. source: self,
  14412. value: this.value
  14413. });
  14414. });
  14415. scaleSelect.addEventListener("click", function (evt) {
  14416. const target = evt.target;
  14417. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  14418. this.blur();
  14419. }
  14420. });
  14421. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  14422. this.eventBus._on("localized", () => {
  14423. this.#wasLocalized = true;
  14424. this.#adjustScaleWidth();
  14425. this.#updateUIState(true);
  14426. });
  14427. this.#bindEditorToolsListener(options);
  14428. }
  14429. #bindEditorToolsListener(_ref) {
  14430. let {
  14431. editorFreeTextButton,
  14432. editorFreeTextParamsToolbar,
  14433. editorInkButton,
  14434. editorInkParamsToolbar,
  14435. editorStampButton
  14436. } = _ref;
  14437. const editorModeChanged = _ref2 => {
  14438. let {
  14439. mode
  14440. } = _ref2;
  14441. (0, _ui_utils.toggleCheckedBtn)(editorFreeTextButton, mode === _pdfjsLib.AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
  14442. (0, _ui_utils.toggleCheckedBtn)(editorInkButton, mode === _pdfjsLib.AnnotationEditorType.INK, editorInkParamsToolbar);
  14443. (0, _ui_utils.toggleCheckedBtn)(editorStampButton, mode === _pdfjsLib.AnnotationEditorType.STAMP);
  14444. const isDisable = mode === _pdfjsLib.AnnotationEditorType.DISABLE;
  14445. editorFreeTextButton.disabled = isDisable;
  14446. editorInkButton.disabled = isDisable;
  14447. editorStampButton.disabled = isDisable;
  14448. };
  14449. this.eventBus._on("annotationeditormodechanged", editorModeChanged);
  14450. this.eventBus._on("toolbarreset", evt => {
  14451. if (evt.source === this) {
  14452. editorModeChanged({
  14453. mode: _pdfjsLib.AnnotationEditorType.DISABLE
  14454. });
  14455. }
  14456. });
  14457. }
  14458. #updateUIState() {
  14459. let resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14460. if (!this.#wasLocalized) {
  14461. return;
  14462. }
  14463. const {
  14464. pageNumber,
  14465. pagesCount,
  14466. pageScaleValue,
  14467. pageScale,
  14468. items
  14469. } = this;
  14470. if (resetNumPages) {
  14471. if (this.hasPageLabels) {
  14472. items.pageNumber.type = "text";
  14473. } else {
  14474. items.pageNumber.type = "number";
  14475. this.l10n.get("of_pages", {
  14476. pagesCount
  14477. }).then(msg => {
  14478. items.numPages.textContent = msg;
  14479. });
  14480. }
  14481. items.pageNumber.max = pagesCount;
  14482. }
  14483. if (this.hasPageLabels) {
  14484. items.pageNumber.value = this.pageLabel;
  14485. this.l10n.get("page_of_pages", {
  14486. pageNumber,
  14487. pagesCount
  14488. }).then(msg => {
  14489. items.numPages.textContent = msg;
  14490. });
  14491. } else {
  14492. items.pageNumber.value = pageNumber;
  14493. }
  14494. items.previous.disabled = pageNumber <= 1;
  14495. items.next.disabled = pageNumber >= pagesCount;
  14496. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  14497. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  14498. this.l10n.get("page_scale_percent", {
  14499. scale: Math.round(pageScale * 10000) / 100
  14500. }).then(msg => {
  14501. let predefinedValueFound = false;
  14502. for (const option of items.scaleSelect.options) {
  14503. if (option.value !== pageScaleValue) {
  14504. option.selected = false;
  14505. continue;
  14506. }
  14507. option.selected = true;
  14508. predefinedValueFound = true;
  14509. }
  14510. if (!predefinedValueFound) {
  14511. items.customScaleOption.textContent = msg;
  14512. items.customScaleOption.selected = true;
  14513. }
  14514. });
  14515. }
  14516. updateLoadingIndicatorState() {
  14517. let loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14518. const {
  14519. pageNumber
  14520. } = this.items;
  14521. pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  14522. }
  14523. async #adjustScaleWidth() {
  14524. const {
  14525. items,
  14526. l10n
  14527. } = this;
  14528. const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
  14529. await _ui_utils.animationStarted;
  14530. const style = getComputedStyle(items.scaleSelect);
  14531. const scaleSelectWidth = parseFloat(style.getPropertyValue("--scale-select-width"));
  14532. const canvas = document.createElement("canvas");
  14533. const ctx = canvas.getContext("2d", {
  14534. alpha: false
  14535. });
  14536. ctx.font = `${style.fontSize} ${style.fontFamily}`;
  14537. let maxWidth = 0;
  14538. for (const predefinedValue of await predefinedValuesPromise) {
  14539. const {
  14540. width
  14541. } = ctx.measureText(predefinedValue);
  14542. if (width > maxWidth) {
  14543. maxWidth = width;
  14544. }
  14545. }
  14546. maxWidth += 0.3 * scaleSelectWidth;
  14547. if (maxWidth > scaleSelectWidth) {
  14548. const container = items.scaleSelect.parentNode;
  14549. container.style.setProperty("--scale-select-width", `${maxWidth}px`);
  14550. }
  14551. canvas.width = 0;
  14552. canvas.height = 0;
  14553. }
  14554. }
  14555. exports.Toolbar = Toolbar;
  14556. /***/ }),
  14557. /* 157 */
  14558. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14559. "use strict";
  14560. Object.defineProperty(exports, "__esModule", ({
  14561. value: true
  14562. }));
  14563. exports.ViewHistory = void 0;
  14564. __webpack_require__(2);
  14565. __webpack_require__(89);
  14566. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  14567. class ViewHistory {
  14568. constructor(fingerprint) {
  14569. let cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  14570. this.fingerprint = fingerprint;
  14571. this.cacheSize = cacheSize;
  14572. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  14573. const database = JSON.parse(databaseStr || "{}");
  14574. let index = -1;
  14575. if (!Array.isArray(database.files)) {
  14576. database.files = [];
  14577. } else {
  14578. while (database.files.length >= this.cacheSize) {
  14579. database.files.shift();
  14580. }
  14581. for (let i = 0, ii = database.files.length; i < ii; i++) {
  14582. const branch = database.files[i];
  14583. if (branch.fingerprint === this.fingerprint) {
  14584. index = i;
  14585. break;
  14586. }
  14587. }
  14588. }
  14589. if (index === -1) {
  14590. index = database.files.push({
  14591. fingerprint: this.fingerprint
  14592. }) - 1;
  14593. }
  14594. this.file = database.files[index];
  14595. this.database = database;
  14596. });
  14597. }
  14598. async _writeToStorage() {
  14599. const databaseStr = JSON.stringify(this.database);
  14600. localStorage.setItem("pdfjs.history", databaseStr);
  14601. }
  14602. async _readFromStorage() {
  14603. return localStorage.getItem("pdfjs.history");
  14604. }
  14605. async set(name, val) {
  14606. await this._initializedPromise;
  14607. this.file[name] = val;
  14608. return this._writeToStorage();
  14609. }
  14610. async setMultiple(properties) {
  14611. await this._initializedPromise;
  14612. for (const name in properties) {
  14613. this.file[name] = properties[name];
  14614. }
  14615. return this._writeToStorage();
  14616. }
  14617. async get(name, defaultValue) {
  14618. await this._initializedPromise;
  14619. const val = this.file[name];
  14620. return val !== undefined ? val : defaultValue;
  14621. }
  14622. async getMultiple(properties) {
  14623. await this._initializedPromise;
  14624. const values = Object.create(null);
  14625. for (const name in properties) {
  14626. const val = this.file[name];
  14627. values[name] = val !== undefined ? val : properties[name];
  14628. }
  14629. return values;
  14630. }
  14631. }
  14632. exports.ViewHistory = ViewHistory;
  14633. /***/ }),
  14634. /* 158 */
  14635. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14636. "use strict";
  14637. Object.defineProperty(exports, "__esModule", ({
  14638. value: true
  14639. }));
  14640. exports.BasePreferences = void 0;
  14641. __webpack_require__(76);
  14642. var _app_options = __webpack_require__(122);
  14643. class BasePreferences {
  14644. #defaults = Object.freeze({
  14645. "annotationEditorMode": 0,
  14646. "annotationMode": 2,
  14647. "cursorToolOnLoad": 0,
  14648. "defaultZoomDelay": 400,
  14649. "defaultZoomValue": "",
  14650. "disablePageLabels": false,
  14651. "enablePermissions": false,
  14652. "enablePrintAutoRotate": true,
  14653. "enableScripting": true,
  14654. "enableStampEditor": true,
  14655. "externalLinkTarget": 0,
  14656. "historyUpdateUrl": false,
  14657. "ignoreDestinationZoom": false,
  14658. "forcePageColors": false,
  14659. "pageColorsBackground": "Canvas",
  14660. "pageColorsForeground": "CanvasText",
  14661. "pdfBugEnabled": false,
  14662. "sidebarViewOnLoad": -1,
  14663. "scrollModeOnLoad": -1,
  14664. "spreadModeOnLoad": -1,
  14665. "textLayerMode": 1,
  14666. "viewerCssTheme": 0,
  14667. "viewOnLoad": 0,
  14668. "disableAutoFetch": false,
  14669. "disableFontFace": false,
  14670. "disableRange": false,
  14671. "disableStream": false,
  14672. "enableXfa": true
  14673. });
  14674. #prefs = Object.create(null);
  14675. #initializedPromise = null;
  14676. constructor() {
  14677. if (this.constructor === BasePreferences) {
  14678. throw new Error("Cannot initialize BasePreferences.");
  14679. }
  14680. this.#initializedPromise = this._readFromStorage(this.#defaults).then(prefs => {
  14681. for (const name in this.#defaults) {
  14682. const prefValue = prefs?.[name];
  14683. if (typeof prefValue === typeof this.#defaults[name]) {
  14684. this.#prefs[name] = prefValue;
  14685. }
  14686. }
  14687. });
  14688. }
  14689. async _writeToStorage(prefObj) {
  14690. throw new Error("Not implemented: _writeToStorage");
  14691. }
  14692. async _readFromStorage(prefObj) {
  14693. throw new Error("Not implemented: _readFromStorage");
  14694. }
  14695. async reset() {
  14696. await this.#initializedPromise;
  14697. const prefs = this.#prefs;
  14698. this.#prefs = Object.create(null);
  14699. return this._writeToStorage(this.#defaults).catch(reason => {
  14700. this.#prefs = prefs;
  14701. throw reason;
  14702. });
  14703. }
  14704. async set(name, value) {
  14705. await this.#initializedPromise;
  14706. const defaultValue = this.#defaults[name],
  14707. prefs = this.#prefs;
  14708. if (defaultValue === undefined) {
  14709. throw new Error(`Set preference: "${name}" is undefined.`);
  14710. } else if (value === undefined) {
  14711. throw new Error("Set preference: no value is specified.");
  14712. }
  14713. const valueType = typeof value,
  14714. defaultType = typeof defaultValue;
  14715. if (valueType !== defaultType) {
  14716. if (valueType === "number" && defaultType === "string") {
  14717. value = value.toString();
  14718. } else {
  14719. throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
  14720. }
  14721. } else if (valueType === "number" && !Number.isInteger(value)) {
  14722. throw new Error(`Set preference: "${value}" must be an integer.`);
  14723. }
  14724. this.#prefs[name] = value;
  14725. return this._writeToStorage(this.#prefs).catch(reason => {
  14726. this.#prefs = prefs;
  14727. throw reason;
  14728. });
  14729. }
  14730. async get(name) {
  14731. await this.#initializedPromise;
  14732. const defaultValue = this.#defaults[name];
  14733. if (defaultValue === undefined) {
  14734. throw new Error(`Get preference: "${name}" is undefined.`);
  14735. }
  14736. return this.#prefs[name] ?? defaultValue;
  14737. }
  14738. async getAll() {
  14739. await this.#initializedPromise;
  14740. const obj = Object.create(null);
  14741. for (const name in this.#defaults) {
  14742. obj[name] = this.#prefs[name] ?? this.#defaults[name];
  14743. }
  14744. return obj;
  14745. }
  14746. }
  14747. exports.BasePreferences = BasePreferences;
  14748. /***/ }),
  14749. /* 159 */
  14750. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14751. "use strict";
  14752. Object.defineProperty(exports, "__esModule", ({
  14753. value: true
  14754. }));
  14755. exports.DownloadManager = void 0;
  14756. __webpack_require__(76);
  14757. __webpack_require__(92);
  14758. __webpack_require__(94);
  14759. __webpack_require__(95);
  14760. var _pdfjsLib = __webpack_require__(121);
  14761. ;
  14762. function download(blobUrl, filename) {
  14763. const a = document.createElement("a");
  14764. if (!a.click) {
  14765. throw new Error('DownloadManager: "a.click()" is not supported.');
  14766. }
  14767. a.href = blobUrl;
  14768. a.target = "_parent";
  14769. if ("download" in a) {
  14770. a.download = filename;
  14771. }
  14772. (document.body || document.documentElement).append(a);
  14773. a.click();
  14774. a.remove();
  14775. }
  14776. class DownloadManager {
  14777. #openBlobUrls = new WeakMap();
  14778. downloadUrl(url, filename, _options) {
  14779. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14780. console.error(`downloadUrl - not a valid URL: ${url}`);
  14781. return;
  14782. }
  14783. download(url + "#pdfjs.action=download", filename);
  14784. }
  14785. downloadData(data, filename, contentType) {
  14786. const blobUrl = URL.createObjectURL(new Blob([data], {
  14787. type: contentType
  14788. }));
  14789. download(blobUrl, filename);
  14790. }
  14791. openOrDownloadData(element, data, filename) {
  14792. const isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  14793. const contentType = isPdfData ? "application/pdf" : "";
  14794. if (isPdfData) {
  14795. let blobUrl = this.#openBlobUrls.get(element);
  14796. if (!blobUrl) {
  14797. blobUrl = URL.createObjectURL(new Blob([data], {
  14798. type: contentType
  14799. }));
  14800. this.#openBlobUrls.set(element, blobUrl);
  14801. }
  14802. let viewerUrl;
  14803. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  14804. try {
  14805. window.open(viewerUrl);
  14806. return true;
  14807. } catch (ex) {
  14808. console.error(`openOrDownloadData: ${ex}`);
  14809. URL.revokeObjectURL(blobUrl);
  14810. this.#openBlobUrls.delete(element);
  14811. }
  14812. }
  14813. this.downloadData(data, filename, contentType);
  14814. return false;
  14815. }
  14816. download(blob, url, filename, _options) {
  14817. const blobUrl = URL.createObjectURL(blob);
  14818. download(blobUrl, filename);
  14819. }
  14820. }
  14821. exports.DownloadManager = DownloadManager;
  14822. /***/ }),
  14823. /* 160 */
  14824. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14825. "use strict";
  14826. Object.defineProperty(exports, "__esModule", ({
  14827. value: true
  14828. }));
  14829. exports.GenericL10n = void 0;
  14830. __webpack_require__(161);
  14831. var _l10n_utils = __webpack_require__(146);
  14832. const PARTIAL_LANG_CODES = {
  14833. en: "en-US",
  14834. es: "es-ES",
  14835. fy: "fy-NL",
  14836. ga: "ga-IE",
  14837. gu: "gu-IN",
  14838. hi: "hi-IN",
  14839. hy: "hy-AM",
  14840. nb: "nb-NO",
  14841. ne: "ne-NP",
  14842. nn: "nn-NO",
  14843. pa: "pa-IN",
  14844. pt: "pt-PT",
  14845. sv: "sv-SE",
  14846. zh: "zh-CN"
  14847. };
  14848. function fixupLangCode(langCode) {
  14849. return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode;
  14850. }
  14851. class GenericL10n {
  14852. constructor(lang) {
  14853. const {
  14854. webL10n
  14855. } = document;
  14856. this._lang = lang;
  14857. this._ready = new Promise((resolve, reject) => {
  14858. webL10n.setLanguage(fixupLangCode(lang), () => {
  14859. resolve(webL10n);
  14860. });
  14861. });
  14862. }
  14863. async getLanguage() {
  14864. const l10n = await this._ready;
  14865. return l10n.getLanguage();
  14866. }
  14867. async getDirection() {
  14868. const l10n = await this._ready;
  14869. return l10n.getDirection();
  14870. }
  14871. async get(key) {
  14872. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  14873. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  14874. const l10n = await this._ready;
  14875. return l10n.get(key, args, fallback);
  14876. }
  14877. async translate(element) {
  14878. const l10n = await this._ready;
  14879. return l10n.translate(element);
  14880. }
  14881. }
  14882. exports.GenericL10n = GenericL10n;
  14883. /***/ }),
  14884. /* 161 */
  14885. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  14886. "use strict";
  14887. __webpack_require__(2);
  14888. document.webL10n = function (window, document) {
  14889. var gL10nData = {};
  14890. var gTextData = '';
  14891. var gTextProp = 'textContent';
  14892. var gLanguage = '';
  14893. var gMacros = {};
  14894. var gReadyState = 'loading';
  14895. var gAsyncResourceLoading = true;
  14896. function getL10nResourceLinks() {
  14897. return document.querySelectorAll('link[type="application/l10n"]');
  14898. }
  14899. function getL10nDictionary() {
  14900. var script = document.querySelector('script[type="application/l10n"]');
  14901. return script ? JSON.parse(script.innerHTML) : null;
  14902. }
  14903. function getTranslatableChildren(element) {
  14904. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14905. }
  14906. function getL10nAttributes(element) {
  14907. if (!element) return {};
  14908. var l10nId = element.getAttribute('data-l10n-id');
  14909. var l10nArgs = element.getAttribute('data-l10n-args');
  14910. var args = {};
  14911. if (l10nArgs) {
  14912. try {
  14913. args = JSON.parse(l10nArgs);
  14914. } catch (e) {
  14915. console.warn('could not parse arguments for #' + l10nId);
  14916. }
  14917. }
  14918. return {
  14919. id: l10nId,
  14920. args: args
  14921. };
  14922. }
  14923. function xhrLoadText(url, onSuccess, onFailure) {
  14924. onSuccess = onSuccess || function _onSuccess(data) {};
  14925. onFailure = onFailure || function _onFailure() {};
  14926. var xhr = new XMLHttpRequest();
  14927. xhr.open('GET', url, gAsyncResourceLoading);
  14928. if (xhr.overrideMimeType) {
  14929. xhr.overrideMimeType('text/plain; charset=utf-8');
  14930. }
  14931. xhr.onreadystatechange = function () {
  14932. if (xhr.readyState == 4) {
  14933. if (xhr.status == 200 || xhr.status === 0) {
  14934. onSuccess(xhr.responseText);
  14935. } else {
  14936. onFailure();
  14937. }
  14938. }
  14939. };
  14940. xhr.onerror = onFailure;
  14941. xhr.ontimeout = onFailure;
  14942. try {
  14943. xhr.send(null);
  14944. } catch (e) {
  14945. onFailure();
  14946. }
  14947. }
  14948. function parseResource(href, lang, successCallback, failureCallback) {
  14949. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14950. function evalString(text) {
  14951. if (text.lastIndexOf('\\') < 0) return text;
  14952. 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, "'");
  14953. }
  14954. function parseProperties(text, parsedPropertiesCallback) {
  14955. var dictionary = {};
  14956. var reBlank = /^\s*|\s*$/;
  14957. var reComment = /^\s*#|^\s*$/;
  14958. var reSection = /^\s*\[(.*)\]\s*$/;
  14959. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14960. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14961. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14962. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14963. var currentLang = '*';
  14964. var genericLang = lang.split('-', 1)[0];
  14965. var skipLang = false;
  14966. var match = '';
  14967. function nextEntry() {
  14968. while (true) {
  14969. if (!entries.length) {
  14970. parsedRawLinesCallback();
  14971. return;
  14972. }
  14973. var line = entries.shift();
  14974. if (reComment.test(line)) continue;
  14975. if (extendedSyntax) {
  14976. match = reSection.exec(line);
  14977. if (match) {
  14978. currentLang = match[1].toLowerCase();
  14979. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14980. continue;
  14981. } else if (skipLang) {
  14982. continue;
  14983. }
  14984. match = reImport.exec(line);
  14985. if (match) {
  14986. loadImport(baseURL + match[1], nextEntry);
  14987. return;
  14988. }
  14989. }
  14990. var tmp = line.match(reSplit);
  14991. if (tmp && tmp.length == 3) {
  14992. dictionary[tmp[1]] = evalString(tmp[2]);
  14993. }
  14994. }
  14995. }
  14996. nextEntry();
  14997. }
  14998. function loadImport(url, callback) {
  14999. xhrLoadText(url, function (content) {
  15000. parseRawLines(content, false, callback);
  15001. }, function () {
  15002. console.warn(url + ' not found.');
  15003. callback();
  15004. });
  15005. }
  15006. parseRawLines(text, true, function () {
  15007. parsedPropertiesCallback(dictionary);
  15008. });
  15009. }
  15010. xhrLoadText(href, function (response) {
  15011. gTextData += response;
  15012. parseProperties(response, function (data) {
  15013. for (var key in data) {
  15014. var id,
  15015. prop,
  15016. index = key.lastIndexOf('.');
  15017. if (index > 0) {
  15018. id = key.substring(0, index);
  15019. prop = key.substring(index + 1);
  15020. } else {
  15021. id = key;
  15022. prop = gTextProp;
  15023. }
  15024. if (!gL10nData[id]) {
  15025. gL10nData[id] = {};
  15026. }
  15027. gL10nData[id][prop] = data[key];
  15028. }
  15029. if (successCallback) {
  15030. successCallback();
  15031. }
  15032. });
  15033. }, failureCallback);
  15034. }
  15035. function loadLocale(lang, callback) {
  15036. if (lang) {
  15037. lang = lang.toLowerCase();
  15038. }
  15039. callback = callback || function _callback() {};
  15040. clear();
  15041. gLanguage = lang;
  15042. var langLinks = getL10nResourceLinks();
  15043. var langCount = langLinks.length;
  15044. if (langCount === 0) {
  15045. var dict = getL10nDictionary();
  15046. if (dict && dict.locales && dict.default_locale) {
  15047. console.log('using the embedded JSON directory, early way out');
  15048. gL10nData = dict.locales[lang];
  15049. if (!gL10nData) {
  15050. var defaultLocale = dict.default_locale.toLowerCase();
  15051. for (var anyCaseLang in dict.locales) {
  15052. anyCaseLang = anyCaseLang.toLowerCase();
  15053. if (anyCaseLang === lang) {
  15054. gL10nData = dict.locales[lang];
  15055. break;
  15056. } else if (anyCaseLang === defaultLocale) {
  15057. gL10nData = dict.locales[defaultLocale];
  15058. }
  15059. }
  15060. }
  15061. callback();
  15062. } else {
  15063. console.log('no resource to load, early way out');
  15064. }
  15065. gReadyState = 'complete';
  15066. return;
  15067. }
  15068. var onResourceLoaded = null;
  15069. var gResourceCount = 0;
  15070. onResourceLoaded = function () {
  15071. gResourceCount++;
  15072. if (gResourceCount >= langCount) {
  15073. callback();
  15074. gReadyState = 'complete';
  15075. }
  15076. };
  15077. function L10nResourceLink(link) {
  15078. var href = link.href;
  15079. this.load = function (lang, callback) {
  15080. parseResource(href, lang, callback, function () {
  15081. console.warn(href + ' not found.');
  15082. console.warn('"' + lang + '" resource not found');
  15083. gLanguage = '';
  15084. callback();
  15085. });
  15086. };
  15087. }
  15088. for (var i = 0; i < langCount; i++) {
  15089. var resource = new L10nResourceLink(langLinks[i]);
  15090. resource.load(lang, onResourceLoaded);
  15091. }
  15092. }
  15093. function clear() {
  15094. gL10nData = {};
  15095. gTextData = '';
  15096. gLanguage = '';
  15097. }
  15098. function getPluralRules(lang) {
  15099. var locales2rules = {
  15100. 'af': 3,
  15101. 'ak': 4,
  15102. 'am': 4,
  15103. 'ar': 1,
  15104. 'asa': 3,
  15105. 'az': 0,
  15106. 'be': 11,
  15107. 'bem': 3,
  15108. 'bez': 3,
  15109. 'bg': 3,
  15110. 'bh': 4,
  15111. 'bm': 0,
  15112. 'bn': 3,
  15113. 'bo': 0,
  15114. 'br': 20,
  15115. 'brx': 3,
  15116. 'bs': 11,
  15117. 'ca': 3,
  15118. 'cgg': 3,
  15119. 'chr': 3,
  15120. 'cs': 12,
  15121. 'cy': 17,
  15122. 'da': 3,
  15123. 'de': 3,
  15124. 'dv': 3,
  15125. 'dz': 0,
  15126. 'ee': 3,
  15127. 'el': 3,
  15128. 'en': 3,
  15129. 'eo': 3,
  15130. 'es': 3,
  15131. 'et': 3,
  15132. 'eu': 3,
  15133. 'fa': 0,
  15134. 'ff': 5,
  15135. 'fi': 3,
  15136. 'fil': 4,
  15137. 'fo': 3,
  15138. 'fr': 5,
  15139. 'fur': 3,
  15140. 'fy': 3,
  15141. 'ga': 8,
  15142. 'gd': 24,
  15143. 'gl': 3,
  15144. 'gsw': 3,
  15145. 'gu': 3,
  15146. 'guw': 4,
  15147. 'gv': 23,
  15148. 'ha': 3,
  15149. 'haw': 3,
  15150. 'he': 2,
  15151. 'hi': 4,
  15152. 'hr': 11,
  15153. 'hu': 0,
  15154. 'id': 0,
  15155. 'ig': 0,
  15156. 'ii': 0,
  15157. 'is': 3,
  15158. 'it': 3,
  15159. 'iu': 7,
  15160. 'ja': 0,
  15161. 'jmc': 3,
  15162. 'jv': 0,
  15163. 'ka': 0,
  15164. 'kab': 5,
  15165. 'kaj': 3,
  15166. 'kcg': 3,
  15167. 'kde': 0,
  15168. 'kea': 0,
  15169. 'kk': 3,
  15170. 'kl': 3,
  15171. 'km': 0,
  15172. 'kn': 0,
  15173. 'ko': 0,
  15174. 'ksb': 3,
  15175. 'ksh': 21,
  15176. 'ku': 3,
  15177. 'kw': 7,
  15178. 'lag': 18,
  15179. 'lb': 3,
  15180. 'lg': 3,
  15181. 'ln': 4,
  15182. 'lo': 0,
  15183. 'lt': 10,
  15184. 'lv': 6,
  15185. 'mas': 3,
  15186. 'mg': 4,
  15187. 'mk': 16,
  15188. 'ml': 3,
  15189. 'mn': 3,
  15190. 'mo': 9,
  15191. 'mr': 3,
  15192. 'ms': 0,
  15193. 'mt': 15,
  15194. 'my': 0,
  15195. 'nah': 3,
  15196. 'naq': 7,
  15197. 'nb': 3,
  15198. 'nd': 3,
  15199. 'ne': 3,
  15200. 'nl': 3,
  15201. 'nn': 3,
  15202. 'no': 3,
  15203. 'nr': 3,
  15204. 'nso': 4,
  15205. 'ny': 3,
  15206. 'nyn': 3,
  15207. 'om': 3,
  15208. 'or': 3,
  15209. 'pa': 3,
  15210. 'pap': 3,
  15211. 'pl': 13,
  15212. 'ps': 3,
  15213. 'pt': 3,
  15214. 'rm': 3,
  15215. 'ro': 9,
  15216. 'rof': 3,
  15217. 'ru': 11,
  15218. 'rwk': 3,
  15219. 'sah': 0,
  15220. 'saq': 3,
  15221. 'se': 7,
  15222. 'seh': 3,
  15223. 'ses': 0,
  15224. 'sg': 0,
  15225. 'sh': 11,
  15226. 'shi': 19,
  15227. 'sk': 12,
  15228. 'sl': 14,
  15229. 'sma': 7,
  15230. 'smi': 7,
  15231. 'smj': 7,
  15232. 'smn': 7,
  15233. 'sms': 7,
  15234. 'sn': 3,
  15235. 'so': 3,
  15236. 'sq': 3,
  15237. 'sr': 11,
  15238. 'ss': 3,
  15239. 'ssy': 3,
  15240. 'st': 3,
  15241. 'sv': 3,
  15242. 'sw': 3,
  15243. 'syr': 3,
  15244. 'ta': 3,
  15245. 'te': 3,
  15246. 'teo': 3,
  15247. 'th': 0,
  15248. 'ti': 4,
  15249. 'tig': 3,
  15250. 'tk': 3,
  15251. 'tl': 4,
  15252. 'tn': 3,
  15253. 'to': 0,
  15254. 'tr': 0,
  15255. 'ts': 3,
  15256. 'tzm': 22,
  15257. 'uk': 11,
  15258. 'ur': 3,
  15259. 've': 3,
  15260. 'vi': 0,
  15261. 'vun': 3,
  15262. 'wa': 4,
  15263. 'wae': 3,
  15264. 'wo': 0,
  15265. 'xh': 3,
  15266. 'xog': 3,
  15267. 'yo': 0,
  15268. 'zh': 0,
  15269. 'zu': 3
  15270. };
  15271. function isIn(n, list) {
  15272. return list.indexOf(n) !== -1;
  15273. }
  15274. function isBetween(n, start, end) {
  15275. return start <= n && n <= end;
  15276. }
  15277. var pluralRules = {
  15278. '0': function (n) {
  15279. return 'other';
  15280. },
  15281. '1': function (n) {
  15282. if (isBetween(n % 100, 3, 10)) return 'few';
  15283. if (n === 0) return 'zero';
  15284. if (isBetween(n % 100, 11, 99)) return 'many';
  15285. if (n == 2) return 'two';
  15286. if (n == 1) return 'one';
  15287. return 'other';
  15288. },
  15289. '2': function (n) {
  15290. if (n !== 0 && n % 10 === 0) return 'many';
  15291. if (n == 2) return 'two';
  15292. if (n == 1) return 'one';
  15293. return 'other';
  15294. },
  15295. '3': function (n) {
  15296. if (n == 1) return 'one';
  15297. return 'other';
  15298. },
  15299. '4': function (n) {
  15300. if (isBetween(n, 0, 1)) return 'one';
  15301. return 'other';
  15302. },
  15303. '5': function (n) {
  15304. if (isBetween(n, 0, 2) && n != 2) return 'one';
  15305. return 'other';
  15306. },
  15307. '6': function (n) {
  15308. if (n === 0) return 'zero';
  15309. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15310. return 'other';
  15311. },
  15312. '7': function (n) {
  15313. if (n == 2) return 'two';
  15314. if (n == 1) return 'one';
  15315. return 'other';
  15316. },
  15317. '8': function (n) {
  15318. if (isBetween(n, 3, 6)) return 'few';
  15319. if (isBetween(n, 7, 10)) return 'many';
  15320. if (n == 2) return 'two';
  15321. if (n == 1) return 'one';
  15322. return 'other';
  15323. },
  15324. '9': function (n) {
  15325. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  15326. if (n == 1) return 'one';
  15327. return 'other';
  15328. },
  15329. '10': function (n) {
  15330. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  15331. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  15332. return 'other';
  15333. },
  15334. '11': function (n) {
  15335. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15336. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  15337. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15338. return 'other';
  15339. },
  15340. '12': function (n) {
  15341. if (isBetween(n, 2, 4)) return 'few';
  15342. if (n == 1) return 'one';
  15343. return 'other';
  15344. },
  15345. '13': function (n) {
  15346. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15347. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  15348. if (n == 1) return 'one';
  15349. return 'other';
  15350. },
  15351. '14': function (n) {
  15352. if (isBetween(n % 100, 3, 4)) return 'few';
  15353. if (n % 100 == 2) return 'two';
  15354. if (n % 100 == 1) return 'one';
  15355. return 'other';
  15356. },
  15357. '15': function (n) {
  15358. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  15359. if (isBetween(n % 100, 11, 19)) return 'many';
  15360. if (n == 1) return 'one';
  15361. return 'other';
  15362. },
  15363. '16': function (n) {
  15364. if (n % 10 == 1 && n != 11) return 'one';
  15365. return 'other';
  15366. },
  15367. '17': function (n) {
  15368. if (n == 3) return 'few';
  15369. if (n === 0) return 'zero';
  15370. if (n == 6) return 'many';
  15371. if (n == 2) return 'two';
  15372. if (n == 1) return 'one';
  15373. return 'other';
  15374. },
  15375. '18': function (n) {
  15376. if (n === 0) return 'zero';
  15377. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  15378. return 'other';
  15379. },
  15380. '19': function (n) {
  15381. if (isBetween(n, 2, 10)) return 'few';
  15382. if (isBetween(n, 0, 1)) return 'one';
  15383. return 'other';
  15384. },
  15385. '20': function (n) {
  15386. 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';
  15387. if (n % 1000000 === 0 && n !== 0) return 'many';
  15388. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  15389. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  15390. return 'other';
  15391. },
  15392. '21': function (n) {
  15393. if (n === 0) return 'zero';
  15394. if (n == 1) return 'one';
  15395. return 'other';
  15396. },
  15397. '22': function (n) {
  15398. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  15399. return 'other';
  15400. },
  15401. '23': function (n) {
  15402. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  15403. return 'other';
  15404. },
  15405. '24': function (n) {
  15406. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  15407. if (isIn(n, [2, 12])) return 'two';
  15408. if (isIn(n, [1, 11])) return 'one';
  15409. return 'other';
  15410. }
  15411. };
  15412. var index = locales2rules[lang.replace(/-.*$/, '')];
  15413. if (!(index in pluralRules)) {
  15414. console.warn('plural form unknown for [' + lang + ']');
  15415. return function () {
  15416. return 'other';
  15417. };
  15418. }
  15419. return pluralRules[index];
  15420. }
  15421. gMacros.plural = function (str, param, key, prop) {
  15422. var n = parseFloat(param);
  15423. if (isNaN(n)) return str;
  15424. if (prop != gTextProp) return str;
  15425. if (!gMacros._pluralRules) {
  15426. gMacros._pluralRules = getPluralRules(gLanguage);
  15427. }
  15428. var index = '[' + gMacros._pluralRules(n) + ']';
  15429. if (n === 0 && key + '[zero]' in gL10nData) {
  15430. str = gL10nData[key + '[zero]'][prop];
  15431. } else if (n == 1 && key + '[one]' in gL10nData) {
  15432. str = gL10nData[key + '[one]'][prop];
  15433. } else if (n == 2 && key + '[two]' in gL10nData) {
  15434. str = gL10nData[key + '[two]'][prop];
  15435. } else if (key + index in gL10nData) {
  15436. str = gL10nData[key + index][prop];
  15437. } else if (key + '[other]' in gL10nData) {
  15438. str = gL10nData[key + '[other]'][prop];
  15439. }
  15440. return str;
  15441. };
  15442. function getL10nData(key, args, fallback) {
  15443. var data = gL10nData[key];
  15444. if (!data) {
  15445. console.warn('#' + key + ' is undefined.');
  15446. if (!fallback) {
  15447. return null;
  15448. }
  15449. data = fallback;
  15450. }
  15451. var rv = {};
  15452. for (var prop in data) {
  15453. var str = data[prop];
  15454. str = substIndexes(str, args, key, prop);
  15455. str = substArguments(str, args, key);
  15456. rv[prop] = str;
  15457. }
  15458. return rv;
  15459. }
  15460. function substIndexes(str, args, key, prop) {
  15461. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15462. var reMatch = reIndex.exec(str);
  15463. if (!reMatch || !reMatch.length) return str;
  15464. var macroName = reMatch[1];
  15465. var paramName = reMatch[2];
  15466. var param;
  15467. if (args && paramName in args) {
  15468. param = args[paramName];
  15469. } else if (paramName in gL10nData) {
  15470. param = gL10nData[paramName];
  15471. }
  15472. if (macroName in gMacros) {
  15473. var macro = gMacros[macroName];
  15474. str = macro(str, param, key, prop);
  15475. }
  15476. return str;
  15477. }
  15478. function substArguments(str, args, key) {
  15479. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15480. return str.replace(reArgs, function (matched_text, arg) {
  15481. if (args && arg in args) {
  15482. return args[arg];
  15483. }
  15484. if (arg in gL10nData) {
  15485. return gL10nData[arg];
  15486. }
  15487. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15488. return matched_text;
  15489. });
  15490. }
  15491. function translateElement(element) {
  15492. var l10n = getL10nAttributes(element);
  15493. if (!l10n.id) return;
  15494. var data = getL10nData(l10n.id, l10n.args);
  15495. if (!data) {
  15496. console.warn('#' + l10n.id + ' is undefined.');
  15497. return;
  15498. }
  15499. if (data[gTextProp]) {
  15500. if (getChildElementCount(element) === 0) {
  15501. element[gTextProp] = data[gTextProp];
  15502. } else {
  15503. var children = element.childNodes;
  15504. var found = false;
  15505. for (var i = 0, l = children.length; i < l; i++) {
  15506. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15507. if (found) {
  15508. children[i].nodeValue = '';
  15509. } else {
  15510. children[i].nodeValue = data[gTextProp];
  15511. found = true;
  15512. }
  15513. }
  15514. }
  15515. if (!found) {
  15516. var textNode = document.createTextNode(data[gTextProp]);
  15517. element.prepend(textNode);
  15518. }
  15519. }
  15520. delete data[gTextProp];
  15521. }
  15522. for (var k in data) {
  15523. element[k] = data[k];
  15524. }
  15525. }
  15526. function getChildElementCount(element) {
  15527. if (element.children) {
  15528. return element.children.length;
  15529. }
  15530. if (typeof element.childElementCount !== 'undefined') {
  15531. return element.childElementCount;
  15532. }
  15533. var count = 0;
  15534. for (var i = 0; i < element.childNodes.length; i++) {
  15535. count += element.nodeType === 1 ? 1 : 0;
  15536. }
  15537. return count;
  15538. }
  15539. function translateFragment(element) {
  15540. element = element || document.documentElement;
  15541. var children = getTranslatableChildren(element);
  15542. var elementCount = children.length;
  15543. for (var i = 0; i < elementCount; i++) {
  15544. translateElement(children[i]);
  15545. }
  15546. translateElement(element);
  15547. }
  15548. return {
  15549. get: function (key, args, fallbackString) {
  15550. var index = key.lastIndexOf('.');
  15551. var prop = gTextProp;
  15552. if (index > 0) {
  15553. prop = key.substring(index + 1);
  15554. key = key.substring(0, index);
  15555. }
  15556. var fallback;
  15557. if (fallbackString) {
  15558. fallback = {};
  15559. fallback[prop] = fallbackString;
  15560. }
  15561. var data = getL10nData(key, args, fallback);
  15562. if (data && prop in data) {
  15563. return data[prop];
  15564. }
  15565. return '{{' + key + '}}';
  15566. },
  15567. getData: function () {
  15568. return gL10nData;
  15569. },
  15570. getText: function () {
  15571. return gTextData;
  15572. },
  15573. getLanguage: function () {
  15574. return gLanguage;
  15575. },
  15576. setLanguage: function (lang, callback) {
  15577. loadLocale(lang, function () {
  15578. if (callback) callback();
  15579. });
  15580. },
  15581. getDirection: function () {
  15582. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15583. var shortCode = gLanguage.split('-', 1)[0];
  15584. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15585. },
  15586. translate: translateFragment,
  15587. getReadyState: function () {
  15588. return gReadyState;
  15589. },
  15590. ready: function (callback) {
  15591. if (!callback) {
  15592. return;
  15593. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15594. window.setTimeout(function () {
  15595. callback();
  15596. });
  15597. } else if (document.addEventListener) {
  15598. document.addEventListener('localized', function once() {
  15599. document.removeEventListener('localized', once);
  15600. callback();
  15601. });
  15602. }
  15603. }
  15604. };
  15605. }(window, document);
  15606. /***/ }),
  15607. /* 162 */
  15608. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15609. "use strict";
  15610. Object.defineProperty(exports, "__esModule", ({
  15611. value: true
  15612. }));
  15613. exports.GenericScripting = void 0;
  15614. exports.docProperties = docProperties;
  15615. var _pdfjsLib = __webpack_require__(121);
  15616. async function docProperties(pdfDocument) {
  15617. const url = "",
  15618. baseUrl = url.split("#")[0];
  15619. let {
  15620. info,
  15621. metadata,
  15622. contentDispositionFilename,
  15623. contentLength
  15624. } = await pdfDocument.getMetadata();
  15625. if (!contentLength) {
  15626. const {
  15627. length
  15628. } = await pdfDocument.getDownloadInfo();
  15629. contentLength = length;
  15630. }
  15631. return {
  15632. ...info,
  15633. baseURL: baseUrl,
  15634. filesize: contentLength,
  15635. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  15636. metadata: metadata?.getRaw(),
  15637. authors: metadata?.get("dc:creator"),
  15638. numPages: pdfDocument.numPages,
  15639. URL: url
  15640. };
  15641. }
  15642. class GenericScripting {
  15643. constructor(sandboxBundleSrc) {
  15644. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
  15645. return window.pdfjsSandbox.QuickJSSandbox();
  15646. });
  15647. }
  15648. async createSandbox(data) {
  15649. const sandbox = await this._ready;
  15650. sandbox.create(data);
  15651. }
  15652. async dispatchEventInSandbox(event) {
  15653. const sandbox = await this._ready;
  15654. setTimeout(() => sandbox.dispatchEvent(event), 0);
  15655. }
  15656. async destroySandbox() {
  15657. const sandbox = await this._ready;
  15658. sandbox.nukeSandbox();
  15659. }
  15660. }
  15661. exports.GenericScripting = GenericScripting;
  15662. /***/ }),
  15663. /* 163 */
  15664. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15665. "use strict";
  15666. Object.defineProperty(exports, "__esModule", ({
  15667. value: true
  15668. }));
  15669. exports.PDFPrintService = void 0;
  15670. __webpack_require__(92);
  15671. __webpack_require__(94);
  15672. __webpack_require__(95);
  15673. __webpack_require__(76);
  15674. var _pdfjsLib = __webpack_require__(121);
  15675. var _app = __webpack_require__(75);
  15676. var _print_utils = __webpack_require__(164);
  15677. let activeService = null;
  15678. let dialog = null;
  15679. let overlayManager = null;
  15680. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  15681. const scratchCanvas = activeService.scratchCanvas;
  15682. const PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  15683. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15684. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15685. const ctx = scratchCanvas.getContext("2d");
  15686. ctx.save();
  15687. ctx.fillStyle = "rgb(255, 255, 255)";
  15688. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15689. ctx.restore();
  15690. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function (_ref) {
  15691. let [pdfPage, printAnnotationStorage] = _ref;
  15692. const renderContext = {
  15693. canvasContext: ctx,
  15694. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15695. viewport: pdfPage.getViewport({
  15696. scale: 1,
  15697. rotation: size.rotation
  15698. }),
  15699. intent: "print",
  15700. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  15701. optionalContentConfigPromise,
  15702. printAnnotationStorage
  15703. };
  15704. return pdfPage.render(renderContext).promise;
  15705. });
  15706. }
  15707. class PDFPrintService {
  15708. constructor(pdfDocument, pagesOverview, printContainer, printResolution) {
  15709. let optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15710. let printAnnotationStoragePromise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  15711. let l10n = arguments.length > 6 ? arguments[6] : undefined;
  15712. this.pdfDocument = pdfDocument;
  15713. this.pagesOverview = pagesOverview;
  15714. this.printContainer = printContainer;
  15715. this._printResolution = printResolution || 150;
  15716. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15717. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  15718. this.l10n = l10n;
  15719. this.currentPage = -1;
  15720. this.scratchCanvas = document.createElement("canvas");
  15721. }
  15722. layout() {
  15723. this.throwIfInactive();
  15724. const body = document.querySelector("body");
  15725. body.setAttribute("data-pdfjsprinting", true);
  15726. const {
  15727. width,
  15728. height
  15729. } = this.pagesOverview[0];
  15730. const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
  15731. if (!hasEqualPageSizes) {
  15732. console.warn("Not all pages have the same size. The printed result may be incorrect!");
  15733. }
  15734. this.pageStyleSheet = document.createElement("style");
  15735. this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
  15736. body.append(this.pageStyleSheet);
  15737. }
  15738. destroy() {
  15739. if (activeService !== this) {
  15740. return;
  15741. }
  15742. this.printContainer.textContent = "";
  15743. const body = document.querySelector("body");
  15744. body.removeAttribute("data-pdfjsprinting");
  15745. if (this.pageStyleSheet) {
  15746. this.pageStyleSheet.remove();
  15747. this.pageStyleSheet = null;
  15748. }
  15749. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15750. this.scratchCanvas = null;
  15751. activeService = null;
  15752. ensureOverlay().then(function () {
  15753. if (overlayManager.active === dialog) {
  15754. overlayManager.close(dialog);
  15755. }
  15756. });
  15757. }
  15758. renderPages() {
  15759. if (this.pdfDocument.isPureXfa) {
  15760. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  15761. return Promise.resolve();
  15762. }
  15763. const pageCount = this.pagesOverview.length;
  15764. const renderNextPage = (resolve, reject) => {
  15765. this.throwIfInactive();
  15766. if (++this.currentPage >= pageCount) {
  15767. renderProgress(pageCount, pageCount, this.l10n);
  15768. resolve();
  15769. return;
  15770. }
  15771. const index = this.currentPage;
  15772. renderProgress(index, pageCount, this.l10n);
  15773. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  15774. renderNextPage(resolve, reject);
  15775. }, reject);
  15776. };
  15777. return new Promise(renderNextPage);
  15778. }
  15779. useRenderedPage() {
  15780. this.throwIfInactive();
  15781. const img = document.createElement("img");
  15782. const scratchCanvas = this.scratchCanvas;
  15783. if ("toBlob" in scratchCanvas) {
  15784. scratchCanvas.toBlob(function (blob) {
  15785. img.src = URL.createObjectURL(blob);
  15786. });
  15787. } else {
  15788. img.src = scratchCanvas.toDataURL();
  15789. }
  15790. const wrapper = document.createElement("div");
  15791. wrapper.className = "printedPage";
  15792. wrapper.append(img);
  15793. this.printContainer.append(wrapper);
  15794. return new Promise(function (resolve, reject) {
  15795. img.onload = resolve;
  15796. img.onerror = reject;
  15797. });
  15798. }
  15799. performPrint() {
  15800. this.throwIfInactive();
  15801. return new Promise(resolve => {
  15802. setTimeout(() => {
  15803. if (!this.active) {
  15804. resolve();
  15805. return;
  15806. }
  15807. print.call(window);
  15808. setTimeout(resolve, 20);
  15809. }, 0);
  15810. });
  15811. }
  15812. get active() {
  15813. return this === activeService;
  15814. }
  15815. throwIfInactive() {
  15816. if (!this.active) {
  15817. throw new Error("This print request was cancelled or completed.");
  15818. }
  15819. }
  15820. }
  15821. exports.PDFPrintService = PDFPrintService;
  15822. const print = window.print;
  15823. window.print = function () {
  15824. if (activeService) {
  15825. console.warn("Ignored window.print() because of a pending print job.");
  15826. return;
  15827. }
  15828. ensureOverlay().then(function () {
  15829. if (activeService) {
  15830. overlayManager.open(dialog);
  15831. }
  15832. });
  15833. try {
  15834. dispatchEvent("beforeprint");
  15835. } finally {
  15836. if (!activeService) {
  15837. console.error("Expected print service to be initialized.");
  15838. ensureOverlay().then(function () {
  15839. if (overlayManager.active === dialog) {
  15840. overlayManager.close(dialog);
  15841. }
  15842. });
  15843. return;
  15844. }
  15845. const activeServiceOnEntry = activeService;
  15846. activeService.renderPages().then(function () {
  15847. return activeServiceOnEntry.performPrint();
  15848. }).catch(function () {}).then(function () {
  15849. if (activeServiceOnEntry.active) {
  15850. abort();
  15851. }
  15852. });
  15853. }
  15854. };
  15855. function dispatchEvent(eventType) {
  15856. const event = new CustomEvent(eventType, {
  15857. bubbles: false,
  15858. cancelable: false,
  15859. detail: "custom"
  15860. });
  15861. window.dispatchEvent(event);
  15862. }
  15863. function abort() {
  15864. if (activeService) {
  15865. activeService.destroy();
  15866. dispatchEvent("afterprint");
  15867. }
  15868. }
  15869. function renderProgress(index, total, l10n) {
  15870. dialog ||= document.getElementById("printServiceDialog");
  15871. const progress = Math.round(100 * index / total);
  15872. const progressBar = dialog.querySelector("progress");
  15873. const progressPerc = dialog.querySelector(".relative-progress");
  15874. progressBar.value = progress;
  15875. l10n.get("print_progress_percent", {
  15876. progress
  15877. }).then(msg => {
  15878. progressPerc.textContent = msg;
  15879. });
  15880. }
  15881. window.addEventListener("keydown", function (event) {
  15882. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15883. window.print();
  15884. event.preventDefault();
  15885. event.stopImmediatePropagation();
  15886. }
  15887. }, true);
  15888. if ("onbeforeprint" in window) {
  15889. const stopPropagationIfNeeded = function (event) {
  15890. if (event.detail !== "custom") {
  15891. event.stopImmediatePropagation();
  15892. }
  15893. };
  15894. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15895. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15896. }
  15897. let overlayPromise;
  15898. function ensureOverlay() {
  15899. if (!overlayPromise) {
  15900. overlayManager = _app.PDFViewerApplication.overlayManager;
  15901. if (!overlayManager) {
  15902. throw new Error("The overlay manager has not yet been initialized.");
  15903. }
  15904. dialog ||= document.getElementById("printServiceDialog");
  15905. overlayPromise = overlayManager.register(dialog, true);
  15906. document.getElementById("printCancel").onclick = abort;
  15907. dialog.addEventListener("close", abort);
  15908. }
  15909. return overlayPromise;
  15910. }
  15911. _app.PDFPrintServiceFactory.instance = {
  15912. supportsPrinting: true,
  15913. createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n) {
  15914. if (activeService) {
  15915. throw new Error("The print service is created and active.");
  15916. }
  15917. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n);
  15918. return activeService;
  15919. }
  15920. };
  15921. /***/ }),
  15922. /* 164 */
  15923. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15924. "use strict";
  15925. Object.defineProperty(exports, "__esModule", ({
  15926. value: true
  15927. }));
  15928. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  15929. var _pdfjsLib = __webpack_require__(121);
  15930. var _pdf_link_service = __webpack_require__(124);
  15931. var _xfa_layer_builder = __webpack_require__(154);
  15932. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  15933. const xfaHtml = pdfDocument.allXfaHtml;
  15934. const linkService = new _pdf_link_service.SimpleLinkService();
  15935. const scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  15936. for (const xfaPage of xfaHtml.children) {
  15937. const page = document.createElement("div");
  15938. page.className = "xfaPrintedPage";
  15939. printContainer.append(page);
  15940. const builder = new _xfa_layer_builder.XfaLayerBuilder({
  15941. pageDiv: page,
  15942. pdfPage: null,
  15943. annotationStorage: pdfDocument.annotationStorage,
  15944. linkService,
  15945. xfaHtml: xfaPage
  15946. });
  15947. const viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  15948. scale
  15949. });
  15950. builder.render(viewport, "print");
  15951. }
  15952. }
  15953. /***/ })
  15954. /******/ ]);
  15955. /************************************************************************/
  15956. /******/ // The module cache
  15957. /******/ var __webpack_module_cache__ = {};
  15958. /******/
  15959. /******/ // The require function
  15960. /******/ function __webpack_require__(moduleId) {
  15961. /******/ // Check if module is in cache
  15962. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  15963. /******/ if (cachedModule !== undefined) {
  15964. /******/ return cachedModule.exports;
  15965. /******/ }
  15966. /******/ // Create a new module (and put it into the cache)
  15967. /******/ var module = __webpack_module_cache__[moduleId] = {
  15968. /******/ // no module.id needed
  15969. /******/ // no module.loaded needed
  15970. /******/ exports: {}
  15971. /******/ };
  15972. /******/
  15973. /******/ // Execute the module function
  15974. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  15975. /******/
  15976. /******/ // Return the exports of the module
  15977. /******/ return module.exports;
  15978. /******/ }
  15979. /******/
  15980. /************************************************************************/
  15981. var __webpack_exports__ = {};
  15982. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  15983. (() => {
  15984. "use strict";
  15985. var exports = __webpack_exports__;
  15986. Object.defineProperty(exports, "__esModule", ({
  15987. value: true
  15988. }));
  15989. Object.defineProperty(exports, "PDFViewerApplication", ({
  15990. enumerable: true,
  15991. get: function () {
  15992. return _app.PDFViewerApplication;
  15993. }
  15994. }));
  15995. exports.PDFViewerApplicationConstants = void 0;
  15996. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  15997. enumerable: true,
  15998. get: function () {
  15999. return _app_options.AppOptions;
  16000. }
  16001. }));
  16002. __webpack_require__(1);
  16003. __webpack_require__(163);
  16004. var _ui_utils = __webpack_require__(97);
  16005. var _app_options = __webpack_require__(122);
  16006. var _pdf_link_service = __webpack_require__(124);
  16007. var _app = __webpack_require__(75);
  16008. const pdfjsVersion = '3.9.179';
  16009. const pdfjsBuild = '1ef6fbc52';
  16010. const AppConstants = {
  16011. LinkTarget: _pdf_link_service.LinkTarget,
  16012. RenderingStates: _ui_utils.RenderingStates,
  16013. ScrollMode: _ui_utils.ScrollMode,
  16014. SpreadMode: _ui_utils.SpreadMode
  16015. };
  16016. exports.PDFViewerApplicationConstants = AppConstants;
  16017. window.PDFViewerApplication = _app.PDFViewerApplication;
  16018. window.PDFViewerApplicationConstants = AppConstants;
  16019. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  16020. function getViewerConfiguration() {
  16021. return {
  16022. appContainer: document.body,
  16023. mainContainer: document.getElementById("viewerContainer"),
  16024. viewerContainer: document.getElementById("viewer"),
  16025. toolbar: {
  16026. container: document.getElementById("toolbarViewer"),
  16027. numPages: document.getElementById("numPages"),
  16028. pageNumber: document.getElementById("pageNumber"),
  16029. scaleSelect: document.getElementById("scaleSelect"),
  16030. customScaleOption: document.getElementById("customScaleOption"),
  16031. previous: document.getElementById("previous"),
  16032. next: document.getElementById("next"),
  16033. zoomIn: document.getElementById("zoomIn"),
  16034. zoomOut: document.getElementById("zoomOut"),
  16035. viewFind: document.getElementById("viewFind"),
  16036. openFile: document.getElementById("openFile"),
  16037. print: document.getElementById("print"),
  16038. editorFreeTextButton: document.getElementById("editorFreeText"),
  16039. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  16040. editorInkButton: document.getElementById("editorInk"),
  16041. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  16042. editorStampButton: document.getElementById("editorStamp"),
  16043. download: document.getElementById("download")
  16044. },
  16045. secondaryToolbar: {
  16046. toolbar: document.getElementById("secondaryToolbar"),
  16047. toggleButton: document.getElementById("secondaryToolbarToggle"),
  16048. presentationModeButton: document.getElementById("presentationMode"),
  16049. openFileButton: document.getElementById("secondaryOpenFile"),
  16050. printButton: document.getElementById("secondaryPrint"),
  16051. downloadButton: document.getElementById("secondaryDownload"),
  16052. viewBookmarkButton: document.getElementById("viewBookmark"),
  16053. firstPageButton: document.getElementById("firstPage"),
  16054. lastPageButton: document.getElementById("lastPage"),
  16055. pageRotateCwButton: document.getElementById("pageRotateCw"),
  16056. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  16057. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  16058. cursorHandToolButton: document.getElementById("cursorHandTool"),
  16059. scrollPageButton: document.getElementById("scrollPage"),
  16060. scrollVerticalButton: document.getElementById("scrollVertical"),
  16061. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  16062. scrollWrappedButton: document.getElementById("scrollWrapped"),
  16063. spreadNoneButton: document.getElementById("spreadNone"),
  16064. spreadOddButton: document.getElementById("spreadOdd"),
  16065. spreadEvenButton: document.getElementById("spreadEven"),
  16066. documentPropertiesButton: document.getElementById("documentProperties")
  16067. },
  16068. sidebar: {
  16069. outerContainer: document.getElementById("outerContainer"),
  16070. sidebarContainer: document.getElementById("sidebarContainer"),
  16071. toggleButton: document.getElementById("sidebarToggle"),
  16072. resizer: document.getElementById("sidebarResizer"),
  16073. thumbnailButton: document.getElementById("viewThumbnail"),
  16074. outlineButton: document.getElementById("viewOutline"),
  16075. attachmentsButton: document.getElementById("viewAttachments"),
  16076. layersButton: document.getElementById("viewLayers"),
  16077. thumbnailView: document.getElementById("thumbnailView"),
  16078. outlineView: document.getElementById("outlineView"),
  16079. attachmentsView: document.getElementById("attachmentsView"),
  16080. layersView: document.getElementById("layersView"),
  16081. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  16082. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  16083. },
  16084. findBar: {
  16085. bar: document.getElementById("findbar"),
  16086. toggleButton: document.getElementById("viewFind"),
  16087. findField: document.getElementById("findInput"),
  16088. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  16089. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  16090. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  16091. entireWordCheckbox: document.getElementById("findEntireWord"),
  16092. findMsg: document.getElementById("findMsg"),
  16093. findResultsCount: document.getElementById("findResultsCount"),
  16094. findPreviousButton: document.getElementById("findPrevious"),
  16095. findNextButton: document.getElementById("findNext")
  16096. },
  16097. passwordOverlay: {
  16098. dialog: document.getElementById("passwordDialog"),
  16099. label: document.getElementById("passwordText"),
  16100. input: document.getElementById("password"),
  16101. submitButton: document.getElementById("passwordSubmit"),
  16102. cancelButton: document.getElementById("passwordCancel")
  16103. },
  16104. documentProperties: {
  16105. dialog: document.getElementById("documentPropertiesDialog"),
  16106. closeButton: document.getElementById("documentPropertiesClose"),
  16107. fields: {
  16108. fileName: document.getElementById("fileNameField"),
  16109. fileSize: document.getElementById("fileSizeField"),
  16110. title: document.getElementById("titleField"),
  16111. author: document.getElementById("authorField"),
  16112. subject: document.getElementById("subjectField"),
  16113. keywords: document.getElementById("keywordsField"),
  16114. creationDate: document.getElementById("creationDateField"),
  16115. modificationDate: document.getElementById("modificationDateField"),
  16116. creator: document.getElementById("creatorField"),
  16117. producer: document.getElementById("producerField"),
  16118. version: document.getElementById("versionField"),
  16119. pageCount: document.getElementById("pageCountField"),
  16120. pageSize: document.getElementById("pageSizeField"),
  16121. linearized: document.getElementById("linearizedField")
  16122. }
  16123. },
  16124. annotationEditorParams: {
  16125. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  16126. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  16127. editorInkColor: document.getElementById("editorInkColor"),
  16128. editorInkThickness: document.getElementById("editorInkThickness"),
  16129. editorInkOpacity: document.getElementById("editorInkOpacity")
  16130. },
  16131. printContainer: document.getElementById("printContainer"),
  16132. openFileInput: document.getElementById("fileInput"),
  16133. debuggerScriptPath: "./debugger.js"
  16134. };
  16135. }
  16136. function webViewerLoad() {
  16137. const config = getViewerConfiguration();
  16138. const event = new CustomEvent("webviewerloaded", {
  16139. bubbles: true,
  16140. cancelable: true,
  16141. detail: {
  16142. source: window
  16143. }
  16144. });
  16145. try {
  16146. parent.document.dispatchEvent(event);
  16147. } catch (ex) {
  16148. console.error(`webviewerloaded: ${ex}`);
  16149. document.dispatchEvent(event);
  16150. }
  16151. _app.PDFViewerApplication.run(config);
  16152. }
  16153. document.blockUnblockOnload?.(true);
  16154. if (document.readyState === "interactive" || document.readyState === "complete") {
  16155. webViewerLoad();
  16156. } else {
  16157. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  16158. }
  16159. })();
  16160. /******/ })()
  16161. ;
  16162. //# sourceMappingURL=viewer.js.map