viewer.js 499 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. /******/ (() => { // webpackBootstrap
  23. /******/ "use strict";
  24. /******/ var __webpack_modules__ = ([
  25. /* 0 */,
  26. /* 1 */
  27. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28. Object.defineProperty(exports, "__esModule", ({
  29. value: true
  30. }));
  31. exports.GenericCom = void 0;
  32. __webpack_require__(2);
  33. var _app = __webpack_require__(75);
  34. var _preferences = __webpack_require__(159);
  35. var _download_manager = __webpack_require__(160);
  36. var _genericl10n = __webpack_require__(161);
  37. var _generic_scripting = __webpack_require__(163);
  38. ;
  39. const GenericCom = {};
  40. exports.GenericCom = GenericCom;
  41. class GenericPreferences extends _preferences.BasePreferences {
  42. async _writeToStorage(prefObj) {
  43. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  44. }
  45. async _readFromStorage(prefObj) {
  46. return JSON.parse(localStorage.getItem("pdfjs.preferences"));
  47. }
  48. }
  49. class GenericExternalServices extends _app.DefaultExternalServices {
  50. static createDownloadManager() {
  51. return new _download_manager.DownloadManager();
  52. }
  53. static createPreferences() {
  54. return new GenericPreferences();
  55. }
  56. static createL10n(_ref) {
  57. let {
  58. locale = "en-US"
  59. } = _ref;
  60. return new _genericl10n.GenericL10n(locale);
  61. }
  62. static createScripting(_ref2) {
  63. let {
  64. sandboxBundleSrc
  65. } = _ref2;
  66. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  67. }
  68. }
  69. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  70. /***/ }),
  71. /* 2 */
  72. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  73. var $ = __webpack_require__(3);
  74. var DESCRIPTORS = __webpack_require__(6);
  75. var global = __webpack_require__(4);
  76. var getBuiltIn = __webpack_require__(24);
  77. var uncurryThis = __webpack_require__(14);
  78. var call = __webpack_require__(8);
  79. var isCallable = __webpack_require__(21);
  80. var isObject = __webpack_require__(20);
  81. var isArray = __webpack_require__(69);
  82. var hasOwn = __webpack_require__(39);
  83. var toString = __webpack_require__(70);
  84. var lengthOfArrayLike = __webpack_require__(64);
  85. var createProperty = __webpack_require__(73);
  86. var fails = __webpack_require__(7);
  87. var parseJSONString = __webpack_require__(74);
  88. var NATIVE_SYMBOL = __webpack_require__(27);
  89. var JSON = global.JSON;
  90. var Number = global.Number;
  91. var SyntaxError = global.SyntaxError;
  92. var nativeParse = JSON && JSON.parse;
  93. var enumerableOwnProperties = getBuiltIn('Object', 'keys');
  94. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  95. var at = uncurryThis(''.charAt);
  96. var slice = uncurryThis(''.slice);
  97. var exec = uncurryThis(/./.exec);
  98. var push = uncurryThis([].push);
  99. var IS_DIGIT = /^\d$/;
  100. var IS_NON_ZERO_DIGIT = /^[1-9]$/;
  101. var IS_NUMBER_START = /^(-|\d)$/;
  102. var IS_WHITESPACE = /^[\t\n\r ]$/;
  103. var PRIMITIVE = 0;
  104. var OBJECT = 1;
  105. var $parse = function (source, reviver) {
  106. source = toString(source);
  107. var context = new Context(source, 0, '');
  108. var root = context.parse();
  109. var value = root.value;
  110. var endIndex = context.skip(IS_WHITESPACE, root.end);
  111. if (endIndex < source.length) {
  112. throw SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
  113. }
  114. return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
  115. };
  116. var internalize = function (holder, name, reviver, node) {
  117. var val = holder[name];
  118. var unmodified = node && val === node.value;
  119. var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
  120. var elementRecordsLen, keys, len, i, P;
  121. if (isObject(val)) {
  122. var nodeIsArray = isArray(val);
  123. var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
  124. if (nodeIsArray) {
  125. elementRecordsLen = nodes.length;
  126. len = lengthOfArrayLike(val);
  127. for (i = 0; i < len; i++) {
  128. internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
  129. }
  130. } else {
  131. keys = enumerableOwnProperties(val);
  132. len = lengthOfArrayLike(keys);
  133. for (i = 0; i < len; i++) {
  134. P = keys[i];
  135. internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
  136. }
  137. }
  138. }
  139. return call(reviver, holder, name, val, context);
  140. };
  141. var internalizeProperty = function (object, key, value) {
  142. if (DESCRIPTORS) {
  143. var descriptor = getOwnPropertyDescriptor(object, key);
  144. if (descriptor && !descriptor.configurable)
  145. return;
  146. }
  147. if (value === undefined)
  148. delete object[key];
  149. else
  150. createProperty(object, key, value);
  151. };
  152. var Node = function (value, end, source, nodes) {
  153. this.value = value;
  154. this.end = end;
  155. this.source = source;
  156. this.nodes = nodes;
  157. };
  158. var Context = function (source, index) {
  159. this.source = source;
  160. this.index = index;
  161. };
  162. Context.prototype = {
  163. fork: function (nextIndex) {
  164. return new Context(this.source, nextIndex);
  165. },
  166. parse: function () {
  167. var source = this.source;
  168. var i = this.skip(IS_WHITESPACE, this.index);
  169. var fork = this.fork(i);
  170. var chr = at(source, i);
  171. if (exec(IS_NUMBER_START, chr))
  172. return fork.number();
  173. switch (chr) {
  174. case '{':
  175. return fork.object();
  176. case '[':
  177. return fork.array();
  178. case '"':
  179. return fork.string();
  180. case 't':
  181. return fork.keyword(true);
  182. case 'f':
  183. return fork.keyword(false);
  184. case 'n':
  185. return fork.keyword(null);
  186. }
  187. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  188. },
  189. node: function (type, value, start, end, nodes) {
  190. return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
  191. },
  192. object: function () {
  193. var source = this.source;
  194. var i = this.index + 1;
  195. var expectKeypair = false;
  196. var object = {};
  197. var nodes = {};
  198. while (i < source.length) {
  199. i = this.until([
  200. '"',
  201. '}'
  202. ], i);
  203. if (at(source, i) === '}' && !expectKeypair) {
  204. i++;
  205. break;
  206. }
  207. var result = this.fork(i).string();
  208. var key = result.value;
  209. i = result.end;
  210. i = this.until([':'], i) + 1;
  211. i = this.skip(IS_WHITESPACE, i);
  212. result = this.fork(i).parse();
  213. createProperty(nodes, key, result);
  214. createProperty(object, key, result.value);
  215. i = this.until([
  216. ',',
  217. '}'
  218. ], result.end);
  219. var chr = at(source, i);
  220. if (chr === ',') {
  221. expectKeypair = true;
  222. i++;
  223. } else if (chr === '}') {
  224. i++;
  225. break;
  226. }
  227. }
  228. return this.node(OBJECT, object, this.index, i, nodes);
  229. },
  230. array: function () {
  231. var source = this.source;
  232. var i = this.index + 1;
  233. var expectElement = false;
  234. var array = [];
  235. var nodes = [];
  236. while (i < source.length) {
  237. i = this.skip(IS_WHITESPACE, i);
  238. if (at(source, i) === ']' && !expectElement) {
  239. i++;
  240. break;
  241. }
  242. var result = this.fork(i).parse();
  243. push(nodes, result);
  244. push(array, result.value);
  245. i = this.until([
  246. ',',
  247. ']'
  248. ], result.end);
  249. if (at(source, i) === ',') {
  250. expectElement = true;
  251. i++;
  252. } else if (at(source, i) === ']') {
  253. i++;
  254. break;
  255. }
  256. }
  257. return this.node(OBJECT, array, this.index, i, nodes);
  258. },
  259. string: function () {
  260. var index = this.index;
  261. var parsed = parseJSONString(this.source, this.index + 1);
  262. return this.node(PRIMITIVE, parsed.value, index, parsed.end);
  263. },
  264. number: function () {
  265. var source = this.source;
  266. var startIndex = this.index;
  267. var i = startIndex;
  268. if (at(source, i) === '-')
  269. i++;
  270. if (at(source, i) === '0')
  271. i++;
  272. else if (exec(IS_NON_ZERO_DIGIT, at(source, i)))
  273. i = this.skip(IS_DIGIT, ++i);
  274. else
  275. throw SyntaxError('Failed to parse number at: ' + i);
  276. if (at(source, i) === '.')
  277. i = this.skip(IS_DIGIT, ++i);
  278. if (at(source, i) === 'e' || at(source, i) === 'E') {
  279. i++;
  280. if (at(source, i) === '+' || at(source, i) === '-')
  281. i++;
  282. var exponentStartIndex = i;
  283. i = this.skip(IS_DIGIT, i);
  284. if (exponentStartIndex === i)
  285. throw SyntaxError("Failed to parse number's exponent value at: " + i);
  286. }
  287. return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
  288. },
  289. keyword: function (value) {
  290. var keyword = '' + value;
  291. var index = this.index;
  292. var endIndex = index + keyword.length;
  293. if (slice(this.source, index, endIndex) !== keyword)
  294. throw SyntaxError('Failed to parse value at: ' + index);
  295. return this.node(PRIMITIVE, value, index, endIndex);
  296. },
  297. skip: function (regex, i) {
  298. var source = this.source;
  299. for (; i < source.length; i++)
  300. if (!exec(regex, at(source, i)))
  301. break;
  302. return i;
  303. },
  304. until: function (array, i) {
  305. i = this.skip(IS_WHITESPACE, i);
  306. var chr = at(this.source, i);
  307. for (var j = 0; j < array.length; j++)
  308. if (array[j] === chr)
  309. return i;
  310. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  311. }
  312. };
  313. var NO_SOURCE_SUPPORT = fails(function () {
  314. var unsafeInt = '9007199254740993';
  315. var source;
  316. nativeParse(unsafeInt, function (key, value, context) {
  317. source = context.source;
  318. });
  319. return source !== unsafeInt;
  320. });
  321. var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
  322. return 1 / nativeParse('-0 \t') !== -Infinity;
  323. });
  324. $({
  325. target: 'JSON',
  326. stat: true,
  327. forced: NO_SOURCE_SUPPORT
  328. }, {
  329. parse: function parse(text, reviver) {
  330. return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
  331. }
  332. });
  333. /***/ }),
  334. /* 3 */
  335. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  336. var global = __webpack_require__(4);
  337. var getOwnPropertyDescriptor = (__webpack_require__(5).f);
  338. var createNonEnumerableProperty = __webpack_require__(44);
  339. var defineBuiltIn = __webpack_require__(48);
  340. var defineGlobalProperty = __webpack_require__(38);
  341. var copyConstructorProperties = __webpack_require__(56);
  342. var isForced = __webpack_require__(68);
  343. module.exports = function (options, source) {
  344. var TARGET = options.target;
  345. var GLOBAL = options.global;
  346. var STATIC = options.stat;
  347. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  348. if (GLOBAL) {
  349. target = global;
  350. } else if (STATIC) {
  351. target = global[TARGET] || defineGlobalProperty(TARGET, {});
  352. } else {
  353. target = (global[TARGET] || {}).prototype;
  354. }
  355. if (target)
  356. for (key in source) {
  357. sourceProperty = source[key];
  358. if (options.dontCallGetSet) {
  359. descriptor = getOwnPropertyDescriptor(target, key);
  360. targetProperty = descriptor && descriptor.value;
  361. } else
  362. targetProperty = target[key];
  363. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  364. if (!FORCED && targetProperty !== undefined) {
  365. if (typeof sourceProperty == typeof targetProperty)
  366. continue;
  367. copyConstructorProperties(sourceProperty, targetProperty);
  368. }
  369. if (options.sham || targetProperty && targetProperty.sham) {
  370. createNonEnumerableProperty(sourceProperty, 'sham', true);
  371. }
  372. defineBuiltIn(target, key, sourceProperty, options);
  373. }
  374. };
  375. /***/ }),
  376. /* 4 */
  377. /***/ (function(module) {
  378. var check = function (it) {
  379. return it && it.Math === Math && it;
  380. };
  381. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  382. return this;
  383. }()) || this || Function('return this')();
  384. /***/ }),
  385. /* 5 */
  386. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  387. var DESCRIPTORS = __webpack_require__(6);
  388. var call = __webpack_require__(8);
  389. var propertyIsEnumerableModule = __webpack_require__(10);
  390. var createPropertyDescriptor = __webpack_require__(11);
  391. var toIndexedObject = __webpack_require__(12);
  392. var toPropertyKey = __webpack_require__(18);
  393. var hasOwn = __webpack_require__(39);
  394. var IE8_DOM_DEFINE = __webpack_require__(42);
  395. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  396. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  397. O = toIndexedObject(O);
  398. P = toPropertyKey(P);
  399. if (IE8_DOM_DEFINE)
  400. try {
  401. return $getOwnPropertyDescriptor(O, P);
  402. } catch (error) {
  403. }
  404. if (hasOwn(O, P))
  405. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  406. };
  407. /***/ }),
  408. /* 6 */
  409. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  410. var fails = __webpack_require__(7);
  411. module.exports = !fails(function () {
  412. return Object.defineProperty({}, 1, {
  413. get: function () {
  414. return 7;
  415. }
  416. })[1] !== 7;
  417. });
  418. /***/ }),
  419. /* 7 */
  420. /***/ ((module) => {
  421. module.exports = function (exec) {
  422. try {
  423. return !!exec();
  424. } catch (error) {
  425. return true;
  426. }
  427. };
  428. /***/ }),
  429. /* 8 */
  430. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  431. var NATIVE_BIND = __webpack_require__(9);
  432. var call = Function.prototype.call;
  433. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  434. return call.apply(call, arguments);
  435. };
  436. /***/ }),
  437. /* 9 */
  438. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  439. var fails = __webpack_require__(7);
  440. module.exports = !fails(function () {
  441. var test = function () {
  442. }.bind();
  443. return typeof test != 'function' || test.hasOwnProperty('prototype');
  444. });
  445. /***/ }),
  446. /* 10 */
  447. /***/ ((__unused_webpack_module, exports) => {
  448. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  449. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  450. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  451. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  452. var descriptor = getOwnPropertyDescriptor(this, V);
  453. return !!descriptor && descriptor.enumerable;
  454. } : $propertyIsEnumerable;
  455. /***/ }),
  456. /* 11 */
  457. /***/ ((module) => {
  458. module.exports = function (bitmap, value) {
  459. return {
  460. enumerable: !(bitmap & 1),
  461. configurable: !(bitmap & 2),
  462. writable: !(bitmap & 4),
  463. value: value
  464. };
  465. };
  466. /***/ }),
  467. /* 12 */
  468. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  469. var IndexedObject = __webpack_require__(13);
  470. var requireObjectCoercible = __webpack_require__(16);
  471. module.exports = function (it) {
  472. return IndexedObject(requireObjectCoercible(it));
  473. };
  474. /***/ }),
  475. /* 13 */
  476. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  477. var uncurryThis = __webpack_require__(14);
  478. var fails = __webpack_require__(7);
  479. var classof = __webpack_require__(15);
  480. var $Object = Object;
  481. var split = uncurryThis(''.split);
  482. module.exports = fails(function () {
  483. return !$Object('z').propertyIsEnumerable(0);
  484. }) ? function (it) {
  485. return classof(it) === 'String' ? split(it, '') : $Object(it);
  486. } : $Object;
  487. /***/ }),
  488. /* 14 */
  489. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  490. var NATIVE_BIND = __webpack_require__(9);
  491. var FunctionPrototype = Function.prototype;
  492. var call = FunctionPrototype.call;
  493. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  494. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  495. return function () {
  496. return call.apply(fn, arguments);
  497. };
  498. };
  499. /***/ }),
  500. /* 15 */
  501. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  502. var uncurryThis = __webpack_require__(14);
  503. var toString = uncurryThis({}.toString);
  504. var stringSlice = uncurryThis(''.slice);
  505. module.exports = function (it) {
  506. return stringSlice(toString(it), 8, -1);
  507. };
  508. /***/ }),
  509. /* 16 */
  510. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  511. var isNullOrUndefined = __webpack_require__(17);
  512. var $TypeError = TypeError;
  513. module.exports = function (it) {
  514. if (isNullOrUndefined(it))
  515. throw $TypeError("Can't call method on " + it);
  516. return it;
  517. };
  518. /***/ }),
  519. /* 17 */
  520. /***/ ((module) => {
  521. module.exports = function (it) {
  522. return it === null || it === undefined;
  523. };
  524. /***/ }),
  525. /* 18 */
  526. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  527. var toPrimitive = __webpack_require__(19);
  528. var isSymbol = __webpack_require__(23);
  529. module.exports = function (argument) {
  530. var key = toPrimitive(argument, 'string');
  531. return isSymbol(key) ? key : key + '';
  532. };
  533. /***/ }),
  534. /* 19 */
  535. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  536. var call = __webpack_require__(8);
  537. var isObject = __webpack_require__(20);
  538. var isSymbol = __webpack_require__(23);
  539. var getMethod = __webpack_require__(30);
  540. var ordinaryToPrimitive = __webpack_require__(33);
  541. var wellKnownSymbol = __webpack_require__(34);
  542. var $TypeError = TypeError;
  543. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  544. module.exports = function (input, pref) {
  545. if (!isObject(input) || isSymbol(input))
  546. return input;
  547. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  548. var result;
  549. if (exoticToPrim) {
  550. if (pref === undefined)
  551. pref = 'default';
  552. result = call(exoticToPrim, input, pref);
  553. if (!isObject(result) || isSymbol(result))
  554. return result;
  555. throw $TypeError("Can't convert object to primitive value");
  556. }
  557. if (pref === undefined)
  558. pref = 'number';
  559. return ordinaryToPrimitive(input, pref);
  560. };
  561. /***/ }),
  562. /* 20 */
  563. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  564. var isCallable = __webpack_require__(21);
  565. var $documentAll = __webpack_require__(22);
  566. var documentAll = $documentAll.all;
  567. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  568. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  569. } : function (it) {
  570. return typeof it == 'object' ? it !== null : isCallable(it);
  571. };
  572. /***/ }),
  573. /* 21 */
  574. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  575. var $documentAll = __webpack_require__(22);
  576. var documentAll = $documentAll.all;
  577. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  578. return typeof argument == 'function' || argument === documentAll;
  579. } : function (argument) {
  580. return typeof argument == 'function';
  581. };
  582. /***/ }),
  583. /* 22 */
  584. /***/ ((module) => {
  585. var documentAll = typeof document == 'object' && document.all;
  586. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  587. module.exports = {
  588. all: documentAll,
  589. IS_HTMLDDA: IS_HTMLDDA
  590. };
  591. /***/ }),
  592. /* 23 */
  593. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  594. var getBuiltIn = __webpack_require__(24);
  595. var isCallable = __webpack_require__(21);
  596. var isPrototypeOf = __webpack_require__(25);
  597. var USE_SYMBOL_AS_UID = __webpack_require__(26);
  598. var $Object = Object;
  599. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  600. return typeof it == 'symbol';
  601. } : function (it) {
  602. var $Symbol = getBuiltIn('Symbol');
  603. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  604. };
  605. /***/ }),
  606. /* 24 */
  607. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  608. var global = __webpack_require__(4);
  609. var isCallable = __webpack_require__(21);
  610. var aFunction = function (argument) {
  611. return isCallable(argument) ? argument : undefined;
  612. };
  613. module.exports = function (namespace, method) {
  614. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  615. };
  616. /***/ }),
  617. /* 25 */
  618. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  619. var uncurryThis = __webpack_require__(14);
  620. module.exports = uncurryThis({}.isPrototypeOf);
  621. /***/ }),
  622. /* 26 */
  623. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  624. var NATIVE_SYMBOL = __webpack_require__(27);
  625. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  626. /***/ }),
  627. /* 27 */
  628. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  629. var V8_VERSION = __webpack_require__(28);
  630. var fails = __webpack_require__(7);
  631. var global = __webpack_require__(4);
  632. var $String = global.String;
  633. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  634. var symbol = Symbol('symbol detection');
  635. return !$String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  636. });
  637. /***/ }),
  638. /* 28 */
  639. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  640. var global = __webpack_require__(4);
  641. var userAgent = __webpack_require__(29);
  642. var process = global.process;
  643. var Deno = global.Deno;
  644. var versions = process && process.versions || Deno && Deno.version;
  645. var v8 = versions && versions.v8;
  646. var match, version;
  647. if (v8) {
  648. match = v8.split('.');
  649. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  650. }
  651. if (!version && userAgent) {
  652. match = userAgent.match(/Edge\/(\d+)/);
  653. if (!match || match[1] >= 74) {
  654. match = userAgent.match(/Chrome\/(\d+)/);
  655. if (match)
  656. version = +match[1];
  657. }
  658. }
  659. module.exports = version;
  660. /***/ }),
  661. /* 29 */
  662. /***/ ((module) => {
  663. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  664. /***/ }),
  665. /* 30 */
  666. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  667. var aCallable = __webpack_require__(31);
  668. var isNullOrUndefined = __webpack_require__(17);
  669. module.exports = function (V, P) {
  670. var func = V[P];
  671. return isNullOrUndefined(func) ? undefined : aCallable(func);
  672. };
  673. /***/ }),
  674. /* 31 */
  675. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  676. var isCallable = __webpack_require__(21);
  677. var tryToString = __webpack_require__(32);
  678. var $TypeError = TypeError;
  679. module.exports = function (argument) {
  680. if (isCallable(argument))
  681. return argument;
  682. throw $TypeError(tryToString(argument) + ' is not a function');
  683. };
  684. /***/ }),
  685. /* 32 */
  686. /***/ ((module) => {
  687. var $String = String;
  688. module.exports = function (argument) {
  689. try {
  690. return $String(argument);
  691. } catch (error) {
  692. return 'Object';
  693. }
  694. };
  695. /***/ }),
  696. /* 33 */
  697. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  698. var call = __webpack_require__(8);
  699. var isCallable = __webpack_require__(21);
  700. var isObject = __webpack_require__(20);
  701. var $TypeError = TypeError;
  702. module.exports = function (input, pref) {
  703. var fn, val;
  704. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  705. return val;
  706. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  707. return val;
  708. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  709. return val;
  710. throw $TypeError("Can't convert object to primitive value");
  711. };
  712. /***/ }),
  713. /* 34 */
  714. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  715. var global = __webpack_require__(4);
  716. var shared = __webpack_require__(35);
  717. var hasOwn = __webpack_require__(39);
  718. var uid = __webpack_require__(41);
  719. var NATIVE_SYMBOL = __webpack_require__(27);
  720. var USE_SYMBOL_AS_UID = __webpack_require__(26);
  721. var Symbol = global.Symbol;
  722. var WellKnownSymbolsStore = shared('wks');
  723. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  724. module.exports = function (name) {
  725. if (!hasOwn(WellKnownSymbolsStore, name)) {
  726. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) ? Symbol[name] : createWellKnownSymbol('Symbol.' + name);
  727. }
  728. return WellKnownSymbolsStore[name];
  729. };
  730. /***/ }),
  731. /* 35 */
  732. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  733. var IS_PURE = __webpack_require__(36);
  734. var store = __webpack_require__(37);
  735. (module.exports = function (key, value) {
  736. return store[key] || (store[key] = value !== undefined ? value : {});
  737. })('versions', []).push({
  738. version: '3.32.1',
  739. mode: IS_PURE ? 'pure' : 'global',
  740. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  741. license: 'https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE',
  742. source: 'https://github.com/zloirock/core-js'
  743. });
  744. /***/ }),
  745. /* 36 */
  746. /***/ ((module) => {
  747. module.exports = false;
  748. /***/ }),
  749. /* 37 */
  750. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  751. var global = __webpack_require__(4);
  752. var defineGlobalProperty = __webpack_require__(38);
  753. var SHARED = '__core-js_shared__';
  754. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  755. module.exports = store;
  756. /***/ }),
  757. /* 38 */
  758. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  759. var global = __webpack_require__(4);
  760. var defineProperty = Object.defineProperty;
  761. module.exports = function (key, value) {
  762. try {
  763. defineProperty(global, key, {
  764. value: value,
  765. configurable: true,
  766. writable: true
  767. });
  768. } catch (error) {
  769. global[key] = value;
  770. }
  771. return value;
  772. };
  773. /***/ }),
  774. /* 39 */
  775. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  776. var uncurryThis = __webpack_require__(14);
  777. var toObject = __webpack_require__(40);
  778. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  779. module.exports = Object.hasOwn || function hasOwn(it, key) {
  780. return hasOwnProperty(toObject(it), key);
  781. };
  782. /***/ }),
  783. /* 40 */
  784. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  785. var requireObjectCoercible = __webpack_require__(16);
  786. var $Object = Object;
  787. module.exports = function (argument) {
  788. return $Object(requireObjectCoercible(argument));
  789. };
  790. /***/ }),
  791. /* 41 */
  792. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  793. var uncurryThis = __webpack_require__(14);
  794. var id = 0;
  795. var postfix = Math.random();
  796. var toString = uncurryThis(1.0.toString);
  797. module.exports = function (key) {
  798. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  799. };
  800. /***/ }),
  801. /* 42 */
  802. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  803. var DESCRIPTORS = __webpack_require__(6);
  804. var fails = __webpack_require__(7);
  805. var createElement = __webpack_require__(43);
  806. module.exports = !DESCRIPTORS && !fails(function () {
  807. return Object.defineProperty(createElement('div'), 'a', {
  808. get: function () {
  809. return 7;
  810. }
  811. }).a !== 7;
  812. });
  813. /***/ }),
  814. /* 43 */
  815. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  816. var global = __webpack_require__(4);
  817. var isObject = __webpack_require__(20);
  818. var document = global.document;
  819. var EXISTS = isObject(document) && isObject(document.createElement);
  820. module.exports = function (it) {
  821. return EXISTS ? document.createElement(it) : {};
  822. };
  823. /***/ }),
  824. /* 44 */
  825. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  826. var DESCRIPTORS = __webpack_require__(6);
  827. var definePropertyModule = __webpack_require__(45);
  828. var createPropertyDescriptor = __webpack_require__(11);
  829. module.exports = DESCRIPTORS ? function (object, key, value) {
  830. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  831. } : function (object, key, value) {
  832. object[key] = value;
  833. return object;
  834. };
  835. /***/ }),
  836. /* 45 */
  837. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  838. var DESCRIPTORS = __webpack_require__(6);
  839. var IE8_DOM_DEFINE = __webpack_require__(42);
  840. var V8_PROTOTYPE_DEFINE_BUG = __webpack_require__(46);
  841. var anObject = __webpack_require__(47);
  842. var toPropertyKey = __webpack_require__(18);
  843. var $TypeError = TypeError;
  844. var $defineProperty = Object.defineProperty;
  845. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  846. var ENUMERABLE = 'enumerable';
  847. var CONFIGURABLE = 'configurable';
  848. var WRITABLE = 'writable';
  849. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  850. anObject(O);
  851. P = toPropertyKey(P);
  852. anObject(Attributes);
  853. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  854. var current = $getOwnPropertyDescriptor(O, P);
  855. if (current && current[WRITABLE]) {
  856. O[P] = Attributes.value;
  857. Attributes = {
  858. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  859. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  860. writable: false
  861. };
  862. }
  863. }
  864. return $defineProperty(O, P, Attributes);
  865. } : $defineProperty : function defineProperty(O, P, Attributes) {
  866. anObject(O);
  867. P = toPropertyKey(P);
  868. anObject(Attributes);
  869. if (IE8_DOM_DEFINE)
  870. try {
  871. return $defineProperty(O, P, Attributes);
  872. } catch (error) {
  873. }
  874. if ('get' in Attributes || 'set' in Attributes)
  875. throw $TypeError('Accessors not supported');
  876. if ('value' in Attributes)
  877. O[P] = Attributes.value;
  878. return O;
  879. };
  880. /***/ }),
  881. /* 46 */
  882. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  883. var DESCRIPTORS = __webpack_require__(6);
  884. var fails = __webpack_require__(7);
  885. module.exports = DESCRIPTORS && fails(function () {
  886. return Object.defineProperty(function () {
  887. }, 'prototype', {
  888. value: 42,
  889. writable: false
  890. }).prototype !== 42;
  891. });
  892. /***/ }),
  893. /* 47 */
  894. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  895. var isObject = __webpack_require__(20);
  896. var $String = String;
  897. var $TypeError = TypeError;
  898. module.exports = function (argument) {
  899. if (isObject(argument))
  900. return argument;
  901. throw $TypeError($String(argument) + ' is not an object');
  902. };
  903. /***/ }),
  904. /* 48 */
  905. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  906. var isCallable = __webpack_require__(21);
  907. var definePropertyModule = __webpack_require__(45);
  908. var makeBuiltIn = __webpack_require__(49);
  909. var defineGlobalProperty = __webpack_require__(38);
  910. module.exports = function (O, key, value, options) {
  911. if (!options)
  912. options = {};
  913. var simple = options.enumerable;
  914. var name = options.name !== undefined ? options.name : key;
  915. if (isCallable(value))
  916. makeBuiltIn(value, name, options);
  917. if (options.global) {
  918. if (simple)
  919. O[key] = value;
  920. else
  921. defineGlobalProperty(key, value);
  922. } else {
  923. try {
  924. if (!options.unsafe)
  925. delete O[key];
  926. else if (O[key])
  927. simple = true;
  928. } catch (error) {
  929. }
  930. if (simple)
  931. O[key] = value;
  932. else
  933. definePropertyModule.f(O, key, {
  934. value: value,
  935. enumerable: false,
  936. configurable: !options.nonConfigurable,
  937. writable: !options.nonWritable
  938. });
  939. }
  940. return O;
  941. };
  942. /***/ }),
  943. /* 49 */
  944. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  945. var uncurryThis = __webpack_require__(14);
  946. var fails = __webpack_require__(7);
  947. var isCallable = __webpack_require__(21);
  948. var hasOwn = __webpack_require__(39);
  949. var DESCRIPTORS = __webpack_require__(6);
  950. var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(50).CONFIGURABLE);
  951. var inspectSource = __webpack_require__(51);
  952. var InternalStateModule = __webpack_require__(52);
  953. var enforceInternalState = InternalStateModule.enforce;
  954. var getInternalState = InternalStateModule.get;
  955. var $String = String;
  956. var defineProperty = Object.defineProperty;
  957. var stringSlice = uncurryThis(''.slice);
  958. var replace = uncurryThis(''.replace);
  959. var join = uncurryThis([].join);
  960. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  961. return defineProperty(function () {
  962. }, 'length', { value: 8 }).length !== 8;
  963. });
  964. var TEMPLATE = String(String).split('String');
  965. var makeBuiltIn = module.exports = function (value, name, options) {
  966. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  967. name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
  968. }
  969. if (options && options.getter)
  970. name = 'get ' + name;
  971. if (options && options.setter)
  972. name = 'set ' + name;
  973. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  974. if (DESCRIPTORS)
  975. defineProperty(value, 'name', {
  976. value: name,
  977. configurable: true
  978. });
  979. else
  980. value.name = name;
  981. }
  982. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  983. defineProperty(value, 'length', { value: options.arity });
  984. }
  985. try {
  986. if (options && hasOwn(options, 'constructor') && options.constructor) {
  987. if (DESCRIPTORS)
  988. defineProperty(value, 'prototype', { writable: false });
  989. } else if (value.prototype)
  990. value.prototype = undefined;
  991. } catch (error) {
  992. }
  993. var state = enforceInternalState(value);
  994. if (!hasOwn(state, 'source')) {
  995. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  996. }
  997. return value;
  998. };
  999. Function.prototype.toString = makeBuiltIn(function toString() {
  1000. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1001. }, 'toString');
  1002. /***/ }),
  1003. /* 50 */
  1004. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1005. var DESCRIPTORS = __webpack_require__(6);
  1006. var hasOwn = __webpack_require__(39);
  1007. var FunctionPrototype = Function.prototype;
  1008. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1009. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1010. var PROPER = EXISTS && function something() {
  1011. }.name === 'something';
  1012. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1013. module.exports = {
  1014. EXISTS: EXISTS,
  1015. PROPER: PROPER,
  1016. CONFIGURABLE: CONFIGURABLE
  1017. };
  1018. /***/ }),
  1019. /* 51 */
  1020. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1021. var uncurryThis = __webpack_require__(14);
  1022. var isCallable = __webpack_require__(21);
  1023. var store = __webpack_require__(37);
  1024. var functionToString = uncurryThis(Function.toString);
  1025. if (!isCallable(store.inspectSource)) {
  1026. store.inspectSource = function (it) {
  1027. return functionToString(it);
  1028. };
  1029. }
  1030. module.exports = store.inspectSource;
  1031. /***/ }),
  1032. /* 52 */
  1033. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1034. var NATIVE_WEAK_MAP = __webpack_require__(53);
  1035. var global = __webpack_require__(4);
  1036. var isObject = __webpack_require__(20);
  1037. var createNonEnumerableProperty = __webpack_require__(44);
  1038. var hasOwn = __webpack_require__(39);
  1039. var shared = __webpack_require__(37);
  1040. var sharedKey = __webpack_require__(54);
  1041. var hiddenKeys = __webpack_require__(55);
  1042. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1043. var TypeError = global.TypeError;
  1044. var WeakMap = global.WeakMap;
  1045. var set, get, has;
  1046. var enforce = function (it) {
  1047. return has(it) ? get(it) : set(it, {});
  1048. };
  1049. var getterFor = function (TYPE) {
  1050. return function (it) {
  1051. var state;
  1052. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1053. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1054. }
  1055. return state;
  1056. };
  1057. };
  1058. if (NATIVE_WEAK_MAP || shared.state) {
  1059. var store = shared.state || (shared.state = new WeakMap());
  1060. store.get = store.get;
  1061. store.has = store.has;
  1062. store.set = store.set;
  1063. set = function (it, metadata) {
  1064. if (store.has(it))
  1065. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1066. metadata.facade = it;
  1067. store.set(it, metadata);
  1068. return metadata;
  1069. };
  1070. get = function (it) {
  1071. return store.get(it) || {};
  1072. };
  1073. has = function (it) {
  1074. return store.has(it);
  1075. };
  1076. } else {
  1077. var STATE = sharedKey('state');
  1078. hiddenKeys[STATE] = true;
  1079. set = function (it, metadata) {
  1080. if (hasOwn(it, STATE))
  1081. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1082. metadata.facade = it;
  1083. createNonEnumerableProperty(it, STATE, metadata);
  1084. return metadata;
  1085. };
  1086. get = function (it) {
  1087. return hasOwn(it, STATE) ? it[STATE] : {};
  1088. };
  1089. has = function (it) {
  1090. return hasOwn(it, STATE);
  1091. };
  1092. }
  1093. module.exports = {
  1094. set: set,
  1095. get: get,
  1096. has: has,
  1097. enforce: enforce,
  1098. getterFor: getterFor
  1099. };
  1100. /***/ }),
  1101. /* 53 */
  1102. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1103. var global = __webpack_require__(4);
  1104. var isCallable = __webpack_require__(21);
  1105. var WeakMap = global.WeakMap;
  1106. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  1107. /***/ }),
  1108. /* 54 */
  1109. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1110. var shared = __webpack_require__(35);
  1111. var uid = __webpack_require__(41);
  1112. var keys = shared('keys');
  1113. module.exports = function (key) {
  1114. return keys[key] || (keys[key] = uid(key));
  1115. };
  1116. /***/ }),
  1117. /* 55 */
  1118. /***/ ((module) => {
  1119. module.exports = {};
  1120. /***/ }),
  1121. /* 56 */
  1122. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1123. var hasOwn = __webpack_require__(39);
  1124. var ownKeys = __webpack_require__(57);
  1125. var getOwnPropertyDescriptorModule = __webpack_require__(5);
  1126. var definePropertyModule = __webpack_require__(45);
  1127. module.exports = function (target, source, exceptions) {
  1128. var keys = ownKeys(source);
  1129. var defineProperty = definePropertyModule.f;
  1130. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1131. for (var i = 0; i < keys.length; i++) {
  1132. var key = keys[i];
  1133. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  1134. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1135. }
  1136. }
  1137. };
  1138. /***/ }),
  1139. /* 57 */
  1140. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1141. var getBuiltIn = __webpack_require__(24);
  1142. var uncurryThis = __webpack_require__(14);
  1143. var getOwnPropertyNamesModule = __webpack_require__(58);
  1144. var getOwnPropertySymbolsModule = __webpack_require__(67);
  1145. var anObject = __webpack_require__(47);
  1146. var concat = uncurryThis([].concat);
  1147. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1148. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1149. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1150. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1151. };
  1152. /***/ }),
  1153. /* 58 */
  1154. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1155. var internalObjectKeys = __webpack_require__(59);
  1156. var enumBugKeys = __webpack_require__(66);
  1157. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1158. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1159. return internalObjectKeys(O, hiddenKeys);
  1160. };
  1161. /***/ }),
  1162. /* 59 */
  1163. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1164. var uncurryThis = __webpack_require__(14);
  1165. var hasOwn = __webpack_require__(39);
  1166. var toIndexedObject = __webpack_require__(12);
  1167. var indexOf = (__webpack_require__(60).indexOf);
  1168. var hiddenKeys = __webpack_require__(55);
  1169. var push = uncurryThis([].push);
  1170. module.exports = function (object, names) {
  1171. var O = toIndexedObject(object);
  1172. var i = 0;
  1173. var result = [];
  1174. var key;
  1175. for (key in O)
  1176. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1177. while (names.length > i)
  1178. if (hasOwn(O, key = names[i++])) {
  1179. ~indexOf(result, key) || push(result, key);
  1180. }
  1181. return result;
  1182. };
  1183. /***/ }),
  1184. /* 60 */
  1185. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1186. var toIndexedObject = __webpack_require__(12);
  1187. var toAbsoluteIndex = __webpack_require__(61);
  1188. var lengthOfArrayLike = __webpack_require__(64);
  1189. var createMethod = function (IS_INCLUDES) {
  1190. return function ($this, el, fromIndex) {
  1191. var O = toIndexedObject($this);
  1192. var length = lengthOfArrayLike(O);
  1193. var index = toAbsoluteIndex(fromIndex, length);
  1194. var value;
  1195. if (IS_INCLUDES && el !== el)
  1196. while (length > index) {
  1197. value = O[index++];
  1198. if (value !== value)
  1199. return true;
  1200. }
  1201. else
  1202. for (; length > index; index++) {
  1203. if ((IS_INCLUDES || index in O) && O[index] === el)
  1204. return IS_INCLUDES || index || 0;
  1205. }
  1206. return !IS_INCLUDES && -1;
  1207. };
  1208. };
  1209. module.exports = {
  1210. includes: createMethod(true),
  1211. indexOf: createMethod(false)
  1212. };
  1213. /***/ }),
  1214. /* 61 */
  1215. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1216. var toIntegerOrInfinity = __webpack_require__(62);
  1217. var max = Math.max;
  1218. var min = Math.min;
  1219. module.exports = function (index, length) {
  1220. var integer = toIntegerOrInfinity(index);
  1221. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1222. };
  1223. /***/ }),
  1224. /* 62 */
  1225. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1226. var trunc = __webpack_require__(63);
  1227. module.exports = function (argument) {
  1228. var number = +argument;
  1229. return number !== number || number === 0 ? 0 : trunc(number);
  1230. };
  1231. /***/ }),
  1232. /* 63 */
  1233. /***/ ((module) => {
  1234. var ceil = Math.ceil;
  1235. var floor = Math.floor;
  1236. module.exports = Math.trunc || function trunc(x) {
  1237. var n = +x;
  1238. return (n > 0 ? floor : ceil)(n);
  1239. };
  1240. /***/ }),
  1241. /* 64 */
  1242. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1243. var toLength = __webpack_require__(65);
  1244. module.exports = function (obj) {
  1245. return toLength(obj.length);
  1246. };
  1247. /***/ }),
  1248. /* 65 */
  1249. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1250. var toIntegerOrInfinity = __webpack_require__(62);
  1251. var min = Math.min;
  1252. module.exports = function (argument) {
  1253. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1254. };
  1255. /***/ }),
  1256. /* 66 */
  1257. /***/ ((module) => {
  1258. module.exports = [
  1259. 'constructor',
  1260. 'hasOwnProperty',
  1261. 'isPrototypeOf',
  1262. 'propertyIsEnumerable',
  1263. 'toLocaleString',
  1264. 'toString',
  1265. 'valueOf'
  1266. ];
  1267. /***/ }),
  1268. /* 67 */
  1269. /***/ ((__unused_webpack_module, exports) => {
  1270. exports.f = Object.getOwnPropertySymbols;
  1271. /***/ }),
  1272. /* 68 */
  1273. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1274. var fails = __webpack_require__(7);
  1275. var isCallable = __webpack_require__(21);
  1276. var replacement = /#|\.prototype\./;
  1277. var isForced = function (feature, detection) {
  1278. var value = data[normalize(feature)];
  1279. return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1280. };
  1281. var normalize = isForced.normalize = function (string) {
  1282. return String(string).replace(replacement, '.').toLowerCase();
  1283. };
  1284. var data = isForced.data = {};
  1285. var NATIVE = isForced.NATIVE = 'N';
  1286. var POLYFILL = isForced.POLYFILL = 'P';
  1287. module.exports = isForced;
  1288. /***/ }),
  1289. /* 69 */
  1290. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1291. var classof = __webpack_require__(15);
  1292. module.exports = Array.isArray || function isArray(argument) {
  1293. return classof(argument) === 'Array';
  1294. };
  1295. /***/ }),
  1296. /* 70 */
  1297. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1298. var classof = __webpack_require__(71);
  1299. var $String = String;
  1300. module.exports = function (argument) {
  1301. if (classof(argument) === 'Symbol')
  1302. throw TypeError('Cannot convert a Symbol value to a string');
  1303. return $String(argument);
  1304. };
  1305. /***/ }),
  1306. /* 71 */
  1307. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1308. var TO_STRING_TAG_SUPPORT = __webpack_require__(72);
  1309. var isCallable = __webpack_require__(21);
  1310. var classofRaw = __webpack_require__(15);
  1311. var wellKnownSymbol = __webpack_require__(34);
  1312. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1313. var $Object = Object;
  1314. var CORRECT_ARGUMENTS = classofRaw((function () {
  1315. return arguments;
  1316. }())) === 'Arguments';
  1317. var tryGet = function (it, key) {
  1318. try {
  1319. return it[key];
  1320. } catch (error) {
  1321. }
  1322. };
  1323. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  1324. var O, tag, result;
  1325. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  1326. };
  1327. /***/ }),
  1328. /* 72 */
  1329. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1330. var wellKnownSymbol = __webpack_require__(34);
  1331. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1332. var test = {};
  1333. test[TO_STRING_TAG] = 'z';
  1334. module.exports = String(test) === '[object z]';
  1335. /***/ }),
  1336. /* 73 */
  1337. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1338. var toPropertyKey = __webpack_require__(18);
  1339. var definePropertyModule = __webpack_require__(45);
  1340. var createPropertyDescriptor = __webpack_require__(11);
  1341. module.exports = function (object, key, value) {
  1342. var propertyKey = toPropertyKey(key);
  1343. if (propertyKey in object)
  1344. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  1345. else
  1346. object[propertyKey] = value;
  1347. };
  1348. /***/ }),
  1349. /* 74 */
  1350. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1351. var uncurryThis = __webpack_require__(14);
  1352. var hasOwn = __webpack_require__(39);
  1353. var $SyntaxError = SyntaxError;
  1354. var $parseInt = parseInt;
  1355. var fromCharCode = String.fromCharCode;
  1356. var at = uncurryThis(''.charAt);
  1357. var slice = uncurryThis(''.slice);
  1358. var exec = uncurryThis(/./.exec);
  1359. var codePoints = {
  1360. '\\"': '"',
  1361. '\\\\': '\\',
  1362. '\\/': '/',
  1363. '\\b': '\b',
  1364. '\\f': '\f',
  1365. '\\n': '\n',
  1366. '\\r': '\r',
  1367. '\\t': '\t'
  1368. };
  1369. var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i;
  1370. var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/;
  1371. module.exports = function (source, i) {
  1372. var unterminated = true;
  1373. var value = '';
  1374. while (i < source.length) {
  1375. var chr = at(source, i);
  1376. if (chr === '\\') {
  1377. var twoChars = slice(source, i, i + 2);
  1378. if (hasOwn(codePoints, twoChars)) {
  1379. value += codePoints[twoChars];
  1380. i += 2;
  1381. } else if (twoChars === '\\u') {
  1382. i += 2;
  1383. var fourHexDigits = slice(source, i, i + 4);
  1384. if (!exec(IS_4_HEX_DIGITS, fourHexDigits))
  1385. throw $SyntaxError('Bad Unicode escape at: ' + i);
  1386. value += fromCharCode($parseInt(fourHexDigits, 16));
  1387. i += 4;
  1388. } else
  1389. throw $SyntaxError('Unknown escape sequence: "' + twoChars + '"');
  1390. } else if (chr === '"') {
  1391. unterminated = false;
  1392. i++;
  1393. break;
  1394. } else {
  1395. if (exec(IS_C0_CONTROL_CODE, chr))
  1396. throw $SyntaxError('Bad control character in string literal at: ' + i);
  1397. value += chr;
  1398. i++;
  1399. }
  1400. }
  1401. if (unterminated)
  1402. throw $SyntaxError('Unterminated string at: ' + i);
  1403. return {
  1404. value: value,
  1405. end: i
  1406. };
  1407. };
  1408. /***/ }),
  1409. /* 75 */
  1410. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1411. Object.defineProperty(exports, "__esModule", ({
  1412. value: true
  1413. }));
  1414. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  1415. __webpack_require__(76);
  1416. __webpack_require__(89);
  1417. __webpack_require__(92);
  1418. __webpack_require__(94);
  1419. __webpack_require__(95);
  1420. var _ui_utils = __webpack_require__(97);
  1421. var _pdfjsLib = __webpack_require__(122);
  1422. var _app_options = __webpack_require__(123);
  1423. var _event_utils = __webpack_require__(124);
  1424. var _pdf_link_service = __webpack_require__(125);
  1425. var _webAnnotation_editor_params = __webpack_require__(126);
  1426. var _overlay_manager = __webpack_require__(127);
  1427. var _password_prompt = __webpack_require__(128);
  1428. var _webPdf_attachment_viewer = __webpack_require__(129);
  1429. var _webPdf_cursor_tools = __webpack_require__(131);
  1430. var _webPdf_document_properties = __webpack_require__(133);
  1431. var _webPdf_find_bar = __webpack_require__(134);
  1432. var _pdf_find_controller = __webpack_require__(135);
  1433. var _pdf_history = __webpack_require__(137);
  1434. var _webPdf_layer_viewer = __webpack_require__(138);
  1435. var _webPdf_outline_viewer = __webpack_require__(139);
  1436. var _webPdf_presentation_mode = __webpack_require__(140);
  1437. var _pdf_rendering_queue = __webpack_require__(141);
  1438. var _pdf_scripting_manager = __webpack_require__(142);
  1439. var _webPdf_sidebar = __webpack_require__(143);
  1440. var _webPdf_thumbnail_viewer = __webpack_require__(144);
  1441. var _pdf_viewer = __webpack_require__(146);
  1442. var _webSecondary_toolbar = __webpack_require__(156);
  1443. var _webToolbar = __webpack_require__(157);
  1444. var _view_history = __webpack_require__(158);
  1445. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  1446. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  1447. const ViewOnLoad = {
  1448. UNKNOWN: -1,
  1449. PREVIOUS: 0,
  1450. INITIAL: 1
  1451. };
  1452. const ViewerCssTheme = {
  1453. AUTOMATIC: 0,
  1454. LIGHT: 1,
  1455. DARK: 2
  1456. };
  1457. class DefaultExternalServices {
  1458. constructor() {
  1459. throw new Error("Cannot initialize DefaultExternalServices.");
  1460. }
  1461. static updateFindControlState(data) {}
  1462. static updateFindMatchesCount(data) {}
  1463. static initPassiveLoading(callbacks) {}
  1464. static reportTelemetry(data) {}
  1465. static createDownloadManager() {
  1466. throw new Error("Not implemented: createDownloadManager");
  1467. }
  1468. static createPreferences() {
  1469. throw new Error("Not implemented: createPreferences");
  1470. }
  1471. static createL10n(options) {
  1472. throw new Error("Not implemented: createL10n");
  1473. }
  1474. static createScripting(options) {
  1475. throw new Error("Not implemented: createScripting");
  1476. }
  1477. static get supportsPinchToZoom() {
  1478. return (0, _pdfjsLib.shadow)(this, "supportsPinchToZoom", true);
  1479. }
  1480. static get supportsIntegratedFind() {
  1481. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  1482. }
  1483. static get supportsDocumentFonts() {
  1484. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  1485. }
  1486. static get supportedMouseWheelZoomModifierKeys() {
  1487. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  1488. ctrlKey: true,
  1489. metaKey: true
  1490. });
  1491. }
  1492. static get isInAutomation() {
  1493. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  1494. }
  1495. static updateEditorStates(data) {
  1496. throw new Error("Not implemented: updateEditorStates");
  1497. }
  1498. static get canvasMaxAreaInBytes() {
  1499. return (0, _pdfjsLib.shadow)(this, "canvasMaxAreaInBytes", -1);
  1500. }
  1501. static getNimbusExperimentData() {
  1502. return (0, _pdfjsLib.shadow)(this, "getNimbusExperimentData", Promise.resolve(null));
  1503. }
  1504. }
  1505. exports.DefaultExternalServices = DefaultExternalServices;
  1506. const PDFViewerApplication = {
  1507. initialBookmark: document.location.hash.substring(1),
  1508. _initializedCapability: new _pdfjsLib.PromiseCapability(),
  1509. appConfig: null,
  1510. pdfDocument: null,
  1511. pdfLoadingTask: null,
  1512. printService: null,
  1513. pdfViewer: null,
  1514. pdfThumbnailViewer: null,
  1515. pdfRenderingQueue: null,
  1516. pdfPresentationMode: null,
  1517. pdfDocumentProperties: null,
  1518. pdfLinkService: null,
  1519. pdfHistory: null,
  1520. pdfSidebar: null,
  1521. pdfOutlineViewer: null,
  1522. pdfAttachmentViewer: null,
  1523. pdfLayerViewer: null,
  1524. pdfCursorTools: null,
  1525. pdfScriptingManager: null,
  1526. store: null,
  1527. downloadManager: null,
  1528. overlayManager: null,
  1529. preferences: null,
  1530. toolbar: null,
  1531. secondaryToolbar: null,
  1532. eventBus: null,
  1533. l10n: null,
  1534. annotationEditorParams: null,
  1535. isInitialViewSet: false,
  1536. downloadComplete: false,
  1537. isViewerEmbedded: window.parent !== window,
  1538. url: "",
  1539. baseUrl: "",
  1540. _downloadUrl: "",
  1541. externalServices: DefaultExternalServices,
  1542. _boundEvents: Object.create(null),
  1543. documentInfo: null,
  1544. metadata: null,
  1545. _contentDispositionFilename: null,
  1546. _contentLength: null,
  1547. _saveInProgress: false,
  1548. _wheelUnusedTicks: 0,
  1549. _wheelUnusedFactor: 1,
  1550. _touchUnusedTicks: 0,
  1551. _touchUnusedFactor: 1,
  1552. _PDFBug: null,
  1553. _hasAnnotationEditors: false,
  1554. _title: document.title,
  1555. _printAnnotationStoragePromise: null,
  1556. _touchInfo: null,
  1557. _isCtrlKeyDown: false,
  1558. _nimbusDataPromise: null,
  1559. async initialize(appConfig) {
  1560. this.preferences = this.externalServices.createPreferences();
  1561. this.appConfig = appConfig;
  1562. await this._initializeOptions();
  1563. this._forceCssTheme();
  1564. await this._initializeL10n();
  1565. if (this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf_link_service.LinkTarget.NONE) {
  1566. _app_options.AppOptions.set("externalLinkTarget", _pdf_link_service.LinkTarget.TOP);
  1567. }
  1568. await this._initializeViewerComponents();
  1569. this.bindEvents();
  1570. this.bindWindowEvents();
  1571. const appContainer = appConfig.appContainer || document.documentElement;
  1572. this.l10n.translate(appContainer).then(() => {
  1573. this.eventBus.dispatch("localized", {
  1574. source: this
  1575. });
  1576. });
  1577. this._initializedCapability.resolve();
  1578. },
  1579. async _initializeOptions() {
  1580. if (_app_options.AppOptions.get("disablePreferences")) {
  1581. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  1582. await this._parseHashParams();
  1583. }
  1584. return;
  1585. }
  1586. if (_app_options.AppOptions._hasUserOptions()) {
  1587. console.warn("_initializeOptions: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  1588. }
  1589. try {
  1590. _app_options.AppOptions.setAll(await this.preferences.getAll());
  1591. } catch (reason) {
  1592. console.error(`_initializeOptions: "${reason.message}".`);
  1593. }
  1594. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  1595. await this._parseHashParams();
  1596. }
  1597. },
  1598. async _parseHashParams() {
  1599. const hash = document.location.hash.substring(1);
  1600. if (!hash) {
  1601. return;
  1602. }
  1603. const {
  1604. mainContainer,
  1605. viewerContainer
  1606. } = this.appConfig,
  1607. params = (0, _ui_utils.parseQueryString)(hash);
  1608. if (params.get("disableworker") === "true") {
  1609. try {
  1610. await loadFakeWorker();
  1611. } catch (ex) {
  1612. console.error(`_parseHashParams: "${ex.message}".`);
  1613. }
  1614. }
  1615. if (params.has("disablerange")) {
  1616. _app_options.AppOptions.set("disableRange", params.get("disablerange") === "true");
  1617. }
  1618. if (params.has("disablestream")) {
  1619. _app_options.AppOptions.set("disableStream", params.get("disablestream") === "true");
  1620. }
  1621. if (params.has("disableautofetch")) {
  1622. _app_options.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  1623. }
  1624. if (params.has("disablefontface")) {
  1625. _app_options.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  1626. }
  1627. if (params.has("disablehistory")) {
  1628. _app_options.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  1629. }
  1630. if (params.has("verbosity")) {
  1631. _app_options.AppOptions.set("verbosity", params.get("verbosity") | 0);
  1632. }
  1633. if (params.has("textlayer")) {
  1634. switch (params.get("textlayer")) {
  1635. case "off":
  1636. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  1637. break;
  1638. case "visible":
  1639. case "shadow":
  1640. case "hover":
  1641. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  1642. try {
  1643. await loadPDFBug(this);
  1644. this._PDFBug.loadCSS();
  1645. } catch (ex) {
  1646. console.error(`_parseHashParams: "${ex.message}".`);
  1647. }
  1648. break;
  1649. }
  1650. }
  1651. if (params.has("pdfbug")) {
  1652. _app_options.AppOptions.set("pdfBug", true);
  1653. _app_options.AppOptions.set("fontExtraProperties", true);
  1654. const enabled = params.get("pdfbug").split(",");
  1655. try {
  1656. await loadPDFBug(this);
  1657. this._PDFBug.init(mainContainer, enabled);
  1658. } catch (ex) {
  1659. console.error(`_parseHashParams: "${ex.message}".`);
  1660. }
  1661. }
  1662. if (params.has("locale")) {
  1663. _app_options.AppOptions.set("locale", params.get("locale"));
  1664. }
  1665. },
  1666. async _initializeL10n() {
  1667. this.l10n = this.externalServices.createL10n({
  1668. locale: _app_options.AppOptions.get("locale")
  1669. });
  1670. const dir = await this.l10n.getDirection();
  1671. document.getElementsByTagName("html")[0].dir = dir;
  1672. },
  1673. _forceCssTheme() {
  1674. const cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  1675. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  1676. return;
  1677. }
  1678. try {
  1679. const styleSheet = document.styleSheets[0];
  1680. const cssRules = styleSheet?.cssRules || [];
  1681. for (let i = 0, ii = cssRules.length; i < ii; i++) {
  1682. const rule = cssRules[i];
  1683. if (rule instanceof CSSMediaRule && rule.media?.[0] === "(prefers-color-scheme: dark)") {
  1684. if (cssTheme === ViewerCssTheme.LIGHT) {
  1685. styleSheet.deleteRule(i);
  1686. return;
  1687. }
  1688. const darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  1689. if (darkRules?.[1]) {
  1690. styleSheet.deleteRule(i);
  1691. styleSheet.insertRule(darkRules[1], i);
  1692. }
  1693. return;
  1694. }
  1695. }
  1696. } catch (reason) {
  1697. console.error(`_forceCssTheme: "${reason?.message}".`);
  1698. }
  1699. },
  1700. async _initializeViewerComponents() {
  1701. const {
  1702. appConfig,
  1703. externalServices,
  1704. l10n
  1705. } = this;
  1706. const eventBus = externalServices.isInAutomation ? new _event_utils.AutomationEventBus() : new _event_utils.EventBus();
  1707. this.eventBus = eventBus;
  1708. this.overlayManager = new _overlay_manager.OverlayManager();
  1709. const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  1710. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  1711. this.pdfRenderingQueue = pdfRenderingQueue;
  1712. const pdfLinkService = new _pdf_link_service.PDFLinkService({
  1713. eventBus,
  1714. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  1715. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  1716. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  1717. });
  1718. this.pdfLinkService = pdfLinkService;
  1719. const downloadManager = externalServices.createDownloadManager();
  1720. this.downloadManager = downloadManager;
  1721. const findController = new _pdf_find_controller.PDFFindController({
  1722. linkService: pdfLinkService,
  1723. eventBus,
  1724. updateMatchesCountOnProgress: true
  1725. });
  1726. this.findController = findController;
  1727. const pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  1728. eventBus,
  1729. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc"),
  1730. externalServices,
  1731. docProperties: this._scriptingDocProperties.bind(this)
  1732. });
  1733. this.pdfScriptingManager = pdfScriptingManager;
  1734. const container = appConfig.mainContainer,
  1735. viewer = appConfig.viewerContainer;
  1736. const annotationEditorMode = _app_options.AppOptions.get("annotationEditorMode");
  1737. const isOffscreenCanvasSupported = _app_options.AppOptions.get("isOffscreenCanvasSupported") && _pdfjsLib.FeatureTest.isOffscreenCanvasSupported;
  1738. const pageColors = _app_options.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  1739. background: _app_options.AppOptions.get("pageColorsBackground"),
  1740. foreground: _app_options.AppOptions.get("pageColorsForeground")
  1741. } : null;
  1742. const pdfViewer = new _pdf_viewer.PDFViewer({
  1743. container,
  1744. viewer,
  1745. eventBus,
  1746. renderingQueue: pdfRenderingQueue,
  1747. linkService: pdfLinkService,
  1748. downloadManager,
  1749. findController,
  1750. scriptingManager: _app_options.AppOptions.get("enableScripting") && pdfScriptingManager,
  1751. l10n,
  1752. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  1753. annotationMode: _app_options.AppOptions.get("annotationMode"),
  1754. annotationEditorMode,
  1755. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  1756. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  1757. isOffscreenCanvasSupported,
  1758. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  1759. enablePermissions: _app_options.AppOptions.get("enablePermissions"),
  1760. pageColors
  1761. });
  1762. this.pdfViewer = pdfViewer;
  1763. pdfRenderingQueue.setViewer(pdfViewer);
  1764. pdfLinkService.setViewer(pdfViewer);
  1765. pdfScriptingManager.setViewer(pdfViewer);
  1766. if (appConfig.sidebar?.thumbnailView) {
  1767. this.pdfThumbnailViewer = new _webPdf_thumbnail_viewer.PDFThumbnailViewer({
  1768. container: appConfig.sidebar.thumbnailView,
  1769. eventBus,
  1770. renderingQueue: pdfRenderingQueue,
  1771. linkService: pdfLinkService,
  1772. l10n,
  1773. pageColors
  1774. });
  1775. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  1776. }
  1777. if (!this.isViewerEmbedded && !_app_options.AppOptions.get("disableHistory")) {
  1778. this.pdfHistory = new _pdf_history.PDFHistory({
  1779. linkService: pdfLinkService,
  1780. eventBus
  1781. });
  1782. pdfLinkService.setHistory(this.pdfHistory);
  1783. }
  1784. if (!this.supportsIntegratedFind && appConfig.findBar) {
  1785. this.findBar = new _webPdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, l10n);
  1786. }
  1787. if (appConfig.annotationEditorParams) {
  1788. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  1789. if (_app_options.AppOptions.get("enableStampEditor") && isOffscreenCanvasSupported) {
  1790. appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
  1791. }
  1792. this.annotationEditorParams = new _webAnnotation_editor_params.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  1793. } else {
  1794. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  1795. document.getElementById(id)?.classList.add("hidden");
  1796. }
  1797. }
  1798. }
  1799. if (appConfig.documentProperties) {
  1800. this.pdfDocumentProperties = new _webPdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
  1801. }
  1802. if (appConfig.secondaryToolbar?.cursorHandToolButton) {
  1803. this.pdfCursorTools = new _webPdf_cursor_tools.PDFCursorTools({
  1804. container,
  1805. eventBus,
  1806. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  1807. });
  1808. }
  1809. if (appConfig.toolbar) {
  1810. this.toolbar = new _webToolbar.Toolbar(appConfig.toolbar, eventBus, l10n);
  1811. }
  1812. if (appConfig.secondaryToolbar) {
  1813. this.secondaryToolbar = new _webSecondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, eventBus, externalServices);
  1814. }
  1815. if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
  1816. this.pdfPresentationMode = new _webPdf_presentation_mode.PDFPresentationMode({
  1817. container,
  1818. pdfViewer,
  1819. eventBus
  1820. });
  1821. }
  1822. if (appConfig.passwordOverlay) {
  1823. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, l10n, this.isViewerEmbedded);
  1824. }
  1825. if (appConfig.sidebar?.outlineView) {
  1826. this.pdfOutlineViewer = new _webPdf_outline_viewer.PDFOutlineViewer({
  1827. container: appConfig.sidebar.outlineView,
  1828. eventBus,
  1829. linkService: pdfLinkService,
  1830. downloadManager
  1831. });
  1832. }
  1833. if (appConfig.sidebar?.attachmentsView) {
  1834. this.pdfAttachmentViewer = new _webPdf_attachment_viewer.PDFAttachmentViewer({
  1835. container: appConfig.sidebar.attachmentsView,
  1836. eventBus,
  1837. downloadManager
  1838. });
  1839. }
  1840. if (appConfig.sidebar?.layersView) {
  1841. this.pdfLayerViewer = new _webPdf_layer_viewer.PDFLayerViewer({
  1842. container: appConfig.sidebar.layersView,
  1843. eventBus,
  1844. l10n
  1845. });
  1846. }
  1847. if (appConfig.sidebar) {
  1848. this.pdfSidebar = new _webPdf_sidebar.PDFSidebar({
  1849. elements: appConfig.sidebar,
  1850. eventBus,
  1851. l10n
  1852. });
  1853. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  1854. this.pdfSidebar.onUpdateThumbnails = () => {
  1855. for (const pageView of pdfViewer.getCachedPageViews()) {
  1856. if (pageView.renderingState === _ui_utils.RenderingStates.FINISHED) {
  1857. this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
  1858. }
  1859. }
  1860. this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  1861. };
  1862. }
  1863. },
  1864. async run(config) {
  1865. await this.initialize(config);
  1866. const {
  1867. appConfig,
  1868. eventBus
  1869. } = this;
  1870. let file;
  1871. const queryString = document.location.search.substring(1);
  1872. const params = (0, _ui_utils.parseQueryString)(queryString);
  1873. file = params.get("file") ?? _app_options.AppOptions.get("defaultUrl");
  1874. file = file.replace("+", "%2B").replace("#", "%23")
  1875. validateFileURL(file);
  1876. const fileInput = appConfig.openFileInput;
  1877. fileInput.value = null;
  1878. fileInput.addEventListener("change", function (evt) {
  1879. const {
  1880. files
  1881. } = evt.target;
  1882. if (!files || files.length === 0) {
  1883. return;
  1884. }
  1885. eventBus.dispatch("fileinputchange", {
  1886. source: this,
  1887. fileInput: evt.target
  1888. });
  1889. });
  1890. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1891. evt.preventDefault();
  1892. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  1893. });
  1894. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1895. evt.preventDefault();
  1896. const {
  1897. files
  1898. } = evt.dataTransfer;
  1899. if (!files || files.length === 0) {
  1900. return;
  1901. }
  1902. eventBus.dispatch("fileinputchange", {
  1903. source: this,
  1904. fileInput: evt.dataTransfer
  1905. });
  1906. });
  1907. if (!this.supportsDocumentFonts) {
  1908. _app_options.AppOptions.set("disableFontFace", true);
  1909. this.l10n.get("web_fonts_disabled").then(msg => {
  1910. console.warn(msg);
  1911. });
  1912. }
  1913. if (!this.supportsPrinting) {
  1914. appConfig.toolbar?.print?.classList.add("hidden");
  1915. appConfig.secondaryToolbar?.printButton.classList.add("hidden");
  1916. }
  1917. if (!this.supportsFullscreen) {
  1918. appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
  1919. }
  1920. if (this.supportsIntegratedFind) {
  1921. appConfig.toolbar?.viewFind?.classList.add("hidden");
  1922. }
  1923. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1924. if (evt.target === this) {
  1925. eventBus.dispatch("resize", {
  1926. source: this
  1927. });
  1928. }
  1929. }, true);
  1930. if (file) {
  1931. this.open({
  1932. url: file
  1933. });
  1934. } else {
  1935. this._hideViewBookmark();
  1936. }
  1937. },
  1938. get initialized() {
  1939. return this._initializedCapability.settled;
  1940. },
  1941. get initializedPromise() {
  1942. return this._initializedCapability.promise;
  1943. },
  1944. zoomIn(steps, scaleFactor) {
  1945. if (this.pdfViewer.isInPresentationMode) {
  1946. return;
  1947. }
  1948. this.pdfViewer.increaseScale({
  1949. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  1950. steps,
  1951. scaleFactor
  1952. });
  1953. },
  1954. zoomOut(steps, scaleFactor) {
  1955. if (this.pdfViewer.isInPresentationMode) {
  1956. return;
  1957. }
  1958. this.pdfViewer.decreaseScale({
  1959. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  1960. steps,
  1961. scaleFactor
  1962. });
  1963. },
  1964. zoomReset() {
  1965. if (this.pdfViewer.isInPresentationMode) {
  1966. return;
  1967. }
  1968. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1969. },
  1970. get pagesCount() {
  1971. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1972. },
  1973. get page() {
  1974. return this.pdfViewer.currentPageNumber;
  1975. },
  1976. set page(val) {
  1977. this.pdfViewer.currentPageNumber = val;
  1978. },
  1979. get supportsPrinting() {
  1980. return PDFPrintServiceFactory.instance.supportsPrinting;
  1981. },
  1982. get supportsFullscreen() {
  1983. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  1984. },
  1985. get supportsPinchToZoom() {
  1986. return this.externalServices.supportsPinchToZoom;
  1987. },
  1988. get supportsIntegratedFind() {
  1989. return this.externalServices.supportsIntegratedFind;
  1990. },
  1991. get supportsDocumentFonts() {
  1992. return this.externalServices.supportsDocumentFonts;
  1993. },
  1994. get loadingBar() {
  1995. const barElement = document.getElementById("loadingBar");
  1996. const bar = barElement ? new _ui_utils.ProgressBar(barElement) : null;
  1997. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1998. },
  1999. get supportedMouseWheelZoomModifierKeys() {
  2000. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  2001. },
  2002. initPassiveLoading(file) {
  2003. throw new Error("Not implemented: initPassiveLoading");
  2004. },
  2005. setTitleUsingUrl() {
  2006. let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  2007. let downloadUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2008. this.url = url;
  2009. this.baseUrl = url.split("#")[0];
  2010. if (downloadUrl) {
  2011. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#")[0];
  2012. }
  2013. if ((0, _pdfjsLib.isDataScheme)(url)) {
  2014. this._hideViewBookmark();
  2015. }
  2016. let title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  2017. if (!title) {
  2018. try {
  2019. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  2020. } catch {
  2021. title = url;
  2022. }
  2023. }
  2024. this.setTitle(title);
  2025. },
  2026. setTitle() {
  2027. let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._title;
  2028. this._title = title;
  2029. if (this.isViewerEmbedded) {
  2030. return;
  2031. }
  2032. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  2033. document.title = `${editorIndicator ? "* " : ""}${title}`;
  2034. },
  2035. get _docFilename() {
  2036. return this._contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url);
  2037. },
  2038. _hideViewBookmark() {
  2039. const {
  2040. secondaryToolbar
  2041. } = this.appConfig;
  2042. secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
  2043. if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
  2044. document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
  2045. }
  2046. },
  2047. async close() {
  2048. this._unblockDocumentLoadEvent();
  2049. this._hideViewBookmark();
  2050. if (!this.pdfLoadingTask) {
  2051. return;
  2052. }
  2053. if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
  2054. try {
  2055. await this.save();
  2056. } catch {}
  2057. }
  2058. const promises = [];
  2059. promises.push(this.pdfLoadingTask.destroy());
  2060. this.pdfLoadingTask = null;
  2061. if (this.pdfDocument) {
  2062. this.pdfDocument = null;
  2063. this.pdfThumbnailViewer?.setDocument(null);
  2064. this.pdfViewer.setDocument(null);
  2065. this.pdfLinkService.setDocument(null);
  2066. this.pdfDocumentProperties?.setDocument(null);
  2067. }
  2068. this.pdfLinkService.externalLinkEnabled = true;
  2069. this.store = null;
  2070. this.isInitialViewSet = false;
  2071. this.downloadComplete = false;
  2072. this.url = "";
  2073. this.baseUrl = "";
  2074. this._downloadUrl = "";
  2075. this.documentInfo = null;
  2076. this.metadata = null;
  2077. this._contentDispositionFilename = null;
  2078. this._contentLength = null;
  2079. this._saveInProgress = false;
  2080. this._hasAnnotationEditors = false;
  2081. promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
  2082. this.setTitle();
  2083. this.pdfSidebar?.reset();
  2084. this.pdfOutlineViewer?.reset();
  2085. this.pdfAttachmentViewer?.reset();
  2086. this.pdfLayerViewer?.reset();
  2087. this.pdfHistory?.reset();
  2088. this.findBar?.reset();
  2089. this.toolbar?.reset();
  2090. this.secondaryToolbar?.reset();
  2091. this._PDFBug?.cleanup();
  2092. await Promise.all(promises);
  2093. },
  2094. async open(args) {
  2095. let deprecatedArgs = false;
  2096. if (typeof args === "string") {
  2097. args = {
  2098. url: args
  2099. };
  2100. deprecatedArgs = true;
  2101. } else if (args?.byteLength) {
  2102. args = {
  2103. data: args
  2104. };
  2105. deprecatedArgs = true;
  2106. }
  2107. if (deprecatedArgs) {
  2108. console.error("The `PDFViewerApplication.open` signature was updated, please use an object instead.");
  2109. }
  2110. if (this.pdfLoadingTask) {
  2111. await this.close();
  2112. }
  2113. const workerParams = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  2114. Object.assign(_pdfjsLib.GlobalWorkerOptions, workerParams);
  2115. if (args.url) {
  2116. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  2117. }
  2118. const apiParams = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  2119. const params = {
  2120. canvasMaxAreaInBytes: this.externalServices.canvasMaxAreaInBytes,
  2121. ...apiParams,
  2122. ...args
  2123. };
  2124. const loadingTask = (0, _pdfjsLib.getDocument)(params);
  2125. this.pdfLoadingTask = loadingTask;
  2126. loadingTask.onPassword = (updateCallback, reason) => {
  2127. if (this.isViewerEmbedded) {
  2128. this._unblockDocumentLoadEvent();
  2129. }
  2130. this.pdfLinkService.externalLinkEnabled = false;
  2131. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2132. this.passwordPrompt.open();
  2133. };
  2134. loadingTask.onProgress = _ref => {
  2135. let {
  2136. loaded,
  2137. total
  2138. } = _ref;
  2139. this.progress(loaded / total);
  2140. };
  2141. return loadingTask.promise.then(pdfDocument => {
  2142. this.load(pdfDocument);
  2143. }, reason => {
  2144. if (loadingTask !== this.pdfLoadingTask) {
  2145. return undefined;
  2146. }
  2147. let key = "loading_error";
  2148. if (reason instanceof _pdfjsLib.InvalidPDFException) {
  2149. key = "invalid_file_error";
  2150. } else if (reason instanceof _pdfjsLib.MissingPDFException) {
  2151. key = "missing_file_error";
  2152. } else if (reason instanceof _pdfjsLib.UnexpectedResponseException) {
  2153. key = "unexpected_response_error";
  2154. }
  2155. return this.l10n.get(key).then(msg => {
  2156. this._documentError(msg, {
  2157. message: reason?.message
  2158. });
  2159. throw reason;
  2160. });
  2161. });
  2162. },
  2163. _ensureDownloadComplete() {
  2164. if (this.pdfDocument && this.downloadComplete) {
  2165. return;
  2166. }
  2167. throw new Error("PDF document not downloaded.");
  2168. },
  2169. async download() {
  2170. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2171. const url = this._downloadUrl,
  2172. filename = this._docFilename;
  2173. try {
  2174. this._ensureDownloadComplete();
  2175. const data = await this.pdfDocument.getData();
  2176. const blob = new Blob([data], {
  2177. type: "application/pdf"
  2178. });
  2179. await this.downloadManager.download(blob, url, filename, options);
  2180. } catch {
  2181. await this.downloadManager.downloadUrl(url, filename, options);
  2182. }
  2183. },
  2184. async save() {
  2185. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2186. if (this._saveInProgress) {
  2187. return;
  2188. }
  2189. this._saveInProgress = true;
  2190. await this.pdfScriptingManager.dispatchWillSave();
  2191. const url = this._downloadUrl,
  2192. filename = this._docFilename;
  2193. try {
  2194. this._ensureDownloadComplete();
  2195. const data = await this.pdfDocument.saveDocument();
  2196. const blob = new Blob([data], {
  2197. type: "application/pdf"
  2198. });
  2199. await this.downloadManager.download(blob, url, filename, options);
  2200. } catch (reason) {
  2201. console.error(`Error when saving the document: ${reason.message}`);
  2202. await this.download(options);
  2203. } finally {
  2204. await this.pdfScriptingManager.dispatchDidSave();
  2205. this._saveInProgress = false;
  2206. }
  2207. if (this._hasAnnotationEditors) {
  2208. this.externalServices.reportTelemetry({
  2209. type: "editing",
  2210. data: {
  2211. type: "save"
  2212. }
  2213. });
  2214. }
  2215. },
  2216. downloadOrSave() {
  2217. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2218. if (this.pdfDocument?.annotationStorage.size > 0) {
  2219. this.save(options);
  2220. } else {
  2221. this.download(options);
  2222. }
  2223. },
  2224. openInExternalApp() {
  2225. this.downloadOrSave({
  2226. openInExternalApp: true
  2227. });
  2228. },
  2229. _documentError(message) {
  2230. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2231. this._unblockDocumentLoadEvent();
  2232. this._otherError(message, moreInfo);
  2233. this.eventBus.dispatch("documenterror", {
  2234. source: this,
  2235. message,
  2236. reason: moreInfo?.message ?? null
  2237. });
  2238. },
  2239. _otherError(message) {
  2240. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2241. const moreInfoText = [`PDF.js v${_pdfjsLib.version || "?"} (build: ${_pdfjsLib.build || "?"})`];
  2242. if (moreInfo) {
  2243. moreInfoText.push(`Message: ${moreInfo.message}`);
  2244. if (moreInfo.stack) {
  2245. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  2246. } else {
  2247. if (moreInfo.filename) {
  2248. moreInfoText.push(`File: ${moreInfo.filename}`);
  2249. }
  2250. if (moreInfo.lineNumber) {
  2251. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  2252. }
  2253. }
  2254. }
  2255. window.parent.postMessage({
  2256. type: "error",
  2257. msg: `${message}`
  2258. })
  2259. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  2260. },
  2261. progress(level) {
  2262. if (!this.loadingBar || this.downloadComplete) {
  2263. return;
  2264. }
  2265. const percent = Math.round(level * 100);
  2266. if (percent <= this.loadingBar.percent) {
  2267. return;
  2268. }
  2269. this.loadingBar.percent = percent;
  2270. if (this.pdfDocument?.loadingParams.disableAutoFetch ?? _app_options.AppOptions.get("disableAutoFetch")) {
  2271. this.loadingBar.setDisableAutoFetch();
  2272. }
  2273. },
  2274. load(pdfDocument) {
  2275. this.pdfDocument = pdfDocument;
  2276. pdfDocument.getDownloadInfo().then(_ref2 => {
  2277. let {
  2278. length
  2279. } = _ref2;
  2280. this._contentLength = length;
  2281. this.downloadComplete = true;
  2282. this.loadingBar?.hide();
  2283. firstPagePromise.then(() => {
  2284. this.eventBus.dispatch("documentloaded", {
  2285. source: this
  2286. });
  2287. });
  2288. });
  2289. const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
  2290. const pageModePromise = pdfDocument.getPageMode().catch(() => {});
  2291. const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
  2292. this.toolbar?.setPagesCount(pdfDocument.numPages, false);
  2293. this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
  2294. this.pdfLinkService.setDocument(pdfDocument);
  2295. this.pdfDocumentProperties?.setDocument(pdfDocument);
  2296. const pdfViewer = this.pdfViewer;
  2297. pdfViewer.setDocument(pdfDocument);
  2298. const {
  2299. firstPagePromise,
  2300. onePageRendered,
  2301. pagesPromise
  2302. } = pdfViewer;
  2303. this.pdfThumbnailViewer?.setDocument(pdfDocument);
  2304. const storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  2305. page: null,
  2306. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  2307. scrollLeft: "0",
  2308. scrollTop: "0",
  2309. rotation: null,
  2310. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  2311. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  2312. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  2313. }).catch(() => {});
  2314. firstPagePromise.then(pdfPage => {
  2315. this.loadingBar?.setWidth(this.appConfig.viewerContainer);
  2316. this._initializeAnnotationStorageCallbacks(pdfDocument);
  2317. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async _ref3 => {
  2318. let [timeStamp, stored, pageLayout, pageMode, openAction] = _ref3;
  2319. const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  2320. this._initializePdfHistory({
  2321. fingerprint: pdfDocument.fingerprints[0],
  2322. viewOnLoad,
  2323. initialDest: openAction?.dest
  2324. });
  2325. const initialBookmark = this.initialBookmark;
  2326. const zoom = _app_options.AppOptions.get("defaultZoomValue");
  2327. let hash = zoom ? `zoom=${zoom}` : null;
  2328. let rotation = null;
  2329. let sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  2330. let scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  2331. let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  2332. if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  2333. hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  2334. rotation = parseInt(stored.rotation, 10);
  2335. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  2336. sidebarView = stored.sidebarView | 0;
  2337. }
  2338. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  2339. scrollMode = stored.scrollMode | 0;
  2340. }
  2341. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  2342. spreadMode = stored.spreadMode | 0;
  2343. }
  2344. }
  2345. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  2346. sidebarView = (0, _ui_utils.apiPageModeToSidebarView)(pageMode);
  2347. }
  2348. if (pageLayout && scrollMode === _ui_utils.ScrollMode.UNKNOWN && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  2349. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(pageLayout);
  2350. spreadMode = modes.spreadMode;
  2351. }
  2352. this.setInitialView(hash, {
  2353. rotation,
  2354. sidebarView,
  2355. scrollMode,
  2356. spreadMode
  2357. });
  2358. this.eventBus.dispatch("documentinit", {
  2359. source: this
  2360. });
  2361. if (!this.isViewerEmbedded) {
  2362. pdfViewer.focus();
  2363. }
  2364. await Promise.race([pagesPromise, new Promise(resolve => {
  2365. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  2366. })]);
  2367. if (!initialBookmark && !hash) {
  2368. return;
  2369. }
  2370. if (pdfViewer.hasEqualPageSizes) {
  2371. return;
  2372. }
  2373. this.initialBookmark = initialBookmark;
  2374. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  2375. this.setInitialView(hash);
  2376. }).catch(() => {
  2377. this.setInitialView();
  2378. }).then(function () {
  2379. pdfViewer.update();
  2380. });
  2381. });
  2382. pagesPromise.then(() => {
  2383. this._unblockDocumentLoadEvent();
  2384. this._initializeAutoPrint(pdfDocument, openActionPromise);
  2385. }, reason => {
  2386. this.l10n.get("loading_error").then(msg => {
  2387. this._documentError(msg, {
  2388. message: reason?.message
  2389. });
  2390. });
  2391. });
  2392. onePageRendered.then(data => {
  2393. this.externalServices.reportTelemetry({
  2394. type: "pageInfo",
  2395. timestamp: data.timestamp
  2396. });
  2397. if (this.pdfOutlineViewer) {
  2398. pdfDocument.getOutline().then(outline => {
  2399. if (pdfDocument !== this.pdfDocument) {
  2400. return;
  2401. }
  2402. this.pdfOutlineViewer.render({
  2403. outline,
  2404. pdfDocument
  2405. });
  2406. });
  2407. }
  2408. if (this.pdfAttachmentViewer) {
  2409. pdfDocument.getAttachments().then(attachments => {
  2410. if (pdfDocument !== this.pdfDocument) {
  2411. return;
  2412. }
  2413. this.pdfAttachmentViewer.render({
  2414. attachments
  2415. });
  2416. });
  2417. }
  2418. if (this.pdfLayerViewer) {
  2419. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  2420. if (pdfDocument !== this.pdfDocument) {
  2421. return;
  2422. }
  2423. this.pdfLayerViewer.render({
  2424. optionalContentConfig,
  2425. pdfDocument
  2426. });
  2427. });
  2428. }
  2429. });
  2430. this._initializePageLabels(pdfDocument);
  2431. this._initializeMetadata(pdfDocument);
  2432. },
  2433. async _scriptingDocProperties(pdfDocument) {
  2434. if (!this.documentInfo) {
  2435. await new Promise(resolve => {
  2436. this.eventBus._on("metadataloaded", resolve, {
  2437. once: true
  2438. });
  2439. });
  2440. if (pdfDocument !== this.pdfDocument) {
  2441. return null;
  2442. }
  2443. }
  2444. if (!this._contentLength) {
  2445. await new Promise(resolve => {
  2446. this.eventBus._on("documentloaded", resolve, {
  2447. once: true
  2448. });
  2449. });
  2450. if (pdfDocument !== this.pdfDocument) {
  2451. return null;
  2452. }
  2453. }
  2454. return {
  2455. ...this.documentInfo,
  2456. baseURL: this.baseUrl,
  2457. filesize: this._contentLength,
  2458. filename: this._docFilename,
  2459. metadata: this.metadata?.getRaw(),
  2460. authors: this.metadata?.get("dc:creator"),
  2461. numPages: this.pagesCount,
  2462. URL: this.url
  2463. };
  2464. },
  2465. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  2466. const [openAction, jsActions] = await Promise.all([openActionPromise, this.pdfViewer.enableScripting ? null : pdfDocument.getJSActions()]);
  2467. if (pdfDocument !== this.pdfDocument) {
  2468. return;
  2469. }
  2470. let triggerAutoPrint = openAction?.action === "Print";
  2471. if (jsActions) {
  2472. console.warn("Warning: JavaScript support is not enabled");
  2473. for (const name in jsActions) {
  2474. if (triggerAutoPrint) {
  2475. break;
  2476. }
  2477. switch (name) {
  2478. case "WillClose":
  2479. case "WillSave":
  2480. case "DidSave":
  2481. case "WillPrint":
  2482. case "DidPrint":
  2483. continue;
  2484. }
  2485. triggerAutoPrint = jsActions[name].some(js => _ui_utils.AutoPrintRegExp.test(js));
  2486. }
  2487. }
  2488. if (triggerAutoPrint) {
  2489. this.triggerPrinting();
  2490. }
  2491. },
  2492. async _initializeMetadata(pdfDocument) {
  2493. const {
  2494. info,
  2495. metadata,
  2496. contentDispositionFilename,
  2497. contentLength
  2498. } = await pdfDocument.getMetadata();
  2499. if (pdfDocument !== this.pdfDocument) {
  2500. return;
  2501. }
  2502. this.documentInfo = info;
  2503. this.metadata = metadata;
  2504. this._contentDispositionFilename ??= contentDispositionFilename;
  2505. this._contentLength ??= contentLength;
  2506. console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${_pdfjsLib.version || "?"} [${_pdfjsLib.build || "?"}])`);
  2507. let pdfTitle = info.Title;
  2508. const metadataTitle = metadata?.get("dc:title");
  2509. if (metadataTitle) {
  2510. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2511. pdfTitle = metadataTitle;
  2512. }
  2513. }
  2514. if (pdfTitle) {
  2515. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  2516. } else if (this._contentDispositionFilename) {
  2517. this.setTitle(this._contentDispositionFilename);
  2518. }
  2519. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  2520. if (pdfDocument.loadingParams.enableXfa) {
  2521. console.warn("Warning: XFA Foreground documents are not supported");
  2522. } else {
  2523. console.warn("Warning: XFA support is not enabled");
  2524. }
  2525. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  2526. console.warn("Warning: Interactive form support is not enabled");
  2527. }
  2528. if (info.IsSignaturesPresent) {
  2529. console.warn("Warning: Digital signatures validation is not supported");
  2530. }
  2531. this.eventBus.dispatch("metadataloaded", {
  2532. source: this
  2533. });
  2534. },
  2535. async _initializePageLabels(pdfDocument) {
  2536. const labels = await pdfDocument.getPageLabels();
  2537. if (pdfDocument !== this.pdfDocument) {
  2538. return;
  2539. }
  2540. if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
  2541. return;
  2542. }
  2543. const numLabels = labels.length;
  2544. let standardLabels = 0,
  2545. emptyLabels = 0;
  2546. for (let i = 0; i < numLabels; i++) {
  2547. const label = labels[i];
  2548. if (label === (i + 1).toString()) {
  2549. standardLabels++;
  2550. } else if (label === "") {
  2551. emptyLabels++;
  2552. } else {
  2553. break;
  2554. }
  2555. }
  2556. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  2557. return;
  2558. }
  2559. const {
  2560. pdfViewer,
  2561. pdfThumbnailViewer,
  2562. toolbar
  2563. } = this;
  2564. pdfViewer.setPageLabels(labels);
  2565. pdfThumbnailViewer?.setPageLabels(labels);
  2566. toolbar?.setPagesCount(numLabels, true);
  2567. toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2568. },
  2569. _initializePdfHistory(_ref4) {
  2570. let {
  2571. fingerprint,
  2572. viewOnLoad,
  2573. initialDest = null
  2574. } = _ref4;
  2575. if (!this.pdfHistory) {
  2576. return;
  2577. }
  2578. this.pdfHistory.initialize({
  2579. fingerprint,
  2580. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2581. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2582. });
  2583. if (this.pdfHistory.initialBookmark) {
  2584. this.initialBookmark = this.pdfHistory.initialBookmark;
  2585. this.initialRotation = this.pdfHistory.initialRotation;
  2586. }
  2587. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2588. this.initialBookmark = JSON.stringify(initialDest);
  2589. this.pdfHistory.push({
  2590. explicitDest: initialDest,
  2591. pageNumber: null
  2592. });
  2593. }
  2594. },
  2595. _initializeAnnotationStorageCallbacks(pdfDocument) {
  2596. if (pdfDocument !== this.pdfDocument) {
  2597. return;
  2598. }
  2599. const {
  2600. annotationStorage
  2601. } = pdfDocument;
  2602. annotationStorage.onSetModified = () => {
  2603. window.addEventListener("beforeunload", beforeUnload);
  2604. this._annotationStorageModified = true;
  2605. };
  2606. annotationStorage.onResetModified = () => {
  2607. window.removeEventListener("beforeunload", beforeUnload);
  2608. delete this._annotationStorageModified;
  2609. };
  2610. annotationStorage.onAnnotationEditor = typeStr => {
  2611. this._hasAnnotationEditors = !!typeStr;
  2612. this.setTitle();
  2613. if (typeStr) {
  2614. this.externalServices.reportTelemetry({
  2615. type: "editing",
  2616. data: {
  2617. type: typeStr
  2618. }
  2619. });
  2620. }
  2621. };
  2622. },
  2623. setInitialView(storedHash) {
  2624. let {
  2625. rotation,
  2626. sidebarView,
  2627. scrollMode,
  2628. spreadMode
  2629. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2630. const setRotation = angle => {
  2631. if ((0, _ui_utils.isValidRotation)(angle)) {
  2632. this.pdfViewer.pagesRotation = angle;
  2633. }
  2634. };
  2635. const setViewerModes = (scroll, spread) => {
  2636. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2637. this.pdfViewer.scrollMode = scroll;
  2638. }
  2639. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2640. this.pdfViewer.spreadMode = spread;
  2641. }
  2642. };
  2643. this.isInitialViewSet = true;
  2644. this.pdfSidebar?.setInitialView(sidebarView);
  2645. setViewerModes(scrollMode, spreadMode);
  2646. if (this.initialBookmark) {
  2647. setRotation(this.initialRotation);
  2648. delete this.initialRotation;
  2649. this.pdfLinkService.setHash(this.initialBookmark);
  2650. this.initialBookmark = null;
  2651. } else if (storedHash) {
  2652. setRotation(rotation);
  2653. this.pdfLinkService.setHash(storedHash);
  2654. }
  2655. this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2656. this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);
  2657. if (!this.pdfViewer.currentScaleValue) {
  2658. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2659. }
  2660. },
  2661. _cleanup() {
  2662. if (!this.pdfDocument) {
  2663. return;
  2664. }
  2665. this.pdfViewer.cleanup();
  2666. this.pdfThumbnailViewer?.cleanup();
  2667. this.pdfDocument.cleanup();
  2668. },
  2669. forceRendering() {
  2670. this.pdfRenderingQueue.printing = !!this.printService;
  2671. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS;
  2672. this.pdfRenderingQueue.renderHighestPriority();
  2673. },
  2674. beforePrint() {
  2675. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => {}).then(() => {
  2676. return this.pdfDocument?.annotationStorage.print;
  2677. });
  2678. if (this.printService) {
  2679. return;
  2680. }
  2681. if (!this.supportsPrinting) {
  2682. this.l10n.get("printing_not_supported").then(msg => {
  2683. this._otherError(msg);
  2684. });
  2685. return;
  2686. }
  2687. if (!this.pdfViewer.pageViewsReady) {
  2688. this.l10n.get("printing_not_ready").then(msg => {
  2689. window.alert(msg);
  2690. });
  2691. return;
  2692. }
  2693. const pagesOverview = this.pdfViewer.getPagesOverview();
  2694. const printContainer = this.appConfig.printContainer;
  2695. const printResolution = _app_options.AppOptions.get("printResolution");
  2696. const optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2697. const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this._printAnnotationStoragePromise, this.l10n);
  2698. this.printService = printService;
  2699. this.forceRendering();
  2700. this.setTitle();
  2701. printService.layout();
  2702. if (this._hasAnnotationEditors) {
  2703. this.externalServices.reportTelemetry({
  2704. type: "editing",
  2705. data: {
  2706. type: "print"
  2707. }
  2708. });
  2709. }
  2710. },
  2711. afterPrint() {
  2712. if (this._printAnnotationStoragePromise) {
  2713. this._printAnnotationStoragePromise.then(() => {
  2714. this.pdfScriptingManager.dispatchDidPrint();
  2715. });
  2716. this._printAnnotationStoragePromise = null;
  2717. }
  2718. if (this.printService) {
  2719. this.printService.destroy();
  2720. this.printService = null;
  2721. this.pdfDocument?.annotationStorage.resetModified();
  2722. }
  2723. this.forceRendering();
  2724. this.setTitle();
  2725. },
  2726. rotatePages(delta) {
  2727. this.pdfViewer.pagesRotation += delta;
  2728. },
  2729. requestPresentationMode() {
  2730. this.pdfPresentationMode?.request();
  2731. },
  2732. triggerPrinting() {
  2733. if (!this.supportsPrinting) {
  2734. return;
  2735. }
  2736. window.print();
  2737. },
  2738. bindEvents() {
  2739. const {
  2740. eventBus,
  2741. _boundEvents
  2742. } = this;
  2743. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2744. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2745. eventBus._on("resize", webViewerResize);
  2746. eventBus._on("hashchange", webViewerHashchange);
  2747. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2748. eventBus._on("afterprint", _boundEvents.afterPrint);
  2749. eventBus._on("pagerender", webViewerPageRender);
  2750. eventBus._on("pagerendered", webViewerPageRendered);
  2751. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2752. eventBus._on("pagechanging", webViewerPageChanging);
  2753. eventBus._on("scalechanging", webViewerScaleChanging);
  2754. eventBus._on("rotationchanging", webViewerRotationChanging);
  2755. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2756. eventBus._on("pagemode", webViewerPageMode);
  2757. eventBus._on("namedaction", webViewerNamedAction);
  2758. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2759. eventBus._on("presentationmode", webViewerPresentationMode);
  2760. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode);
  2761. eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams);
  2762. eventBus._on("print", webViewerPrint);
  2763. eventBus._on("download", webViewerDownload);
  2764. eventBus._on("openinexternalapp", webViewerOpenInExternalApp);
  2765. eventBus._on("firstpage", webViewerFirstPage);
  2766. eventBus._on("lastpage", webViewerLastPage);
  2767. eventBus._on("nextpage", webViewerNextPage);
  2768. eventBus._on("previouspage", webViewerPreviousPage);
  2769. eventBus._on("zoomin", webViewerZoomIn);
  2770. eventBus._on("zoomout", webViewerZoomOut);
  2771. eventBus._on("zoomreset", webViewerZoomReset);
  2772. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2773. eventBus._on("scalechanged", webViewerScaleChanged);
  2774. eventBus._on("rotatecw", webViewerRotateCw);
  2775. eventBus._on("rotateccw", webViewerRotateCcw);
  2776. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2777. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2778. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2779. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2780. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2781. eventBus._on("documentproperties", webViewerDocumentProperties);
  2782. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2783. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2784. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2785. if (_app_options.AppOptions.get("pdfBug")) {
  2786. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2787. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2788. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2789. }
  2790. eventBus._on("fileinputchange", webViewerFileInputChange);
  2791. eventBus._on("openfile", webViewerOpenFile);
  2792. },
  2793. bindWindowEvents() {
  2794. const {
  2795. eventBus,
  2796. _boundEvents
  2797. } = this;
  2798. function addWindowResolutionChange() {
  2799. let evt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  2800. if (evt) {
  2801. webViewerResolutionChange(evt);
  2802. }
  2803. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  2804. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  2805. once: true
  2806. });
  2807. _boundEvents.removeWindowResolutionChange ||= function () {
  2808. mediaQueryList.removeEventListener("change", addWindowResolutionChange);
  2809. _boundEvents.removeWindowResolutionChange = null;
  2810. };
  2811. }
  2812. addWindowResolutionChange();
  2813. _boundEvents.windowResize = () => {
  2814. eventBus.dispatch("resize", {
  2815. source: window
  2816. });
  2817. };
  2818. _boundEvents.windowHashChange = () => {
  2819. eventBus.dispatch("hashchange", {
  2820. source: window,
  2821. hash: document.location.hash.substring(1)
  2822. });
  2823. };
  2824. _boundEvents.windowBeforePrint = () => {
  2825. eventBus.dispatch("beforeprint", {
  2826. source: window
  2827. });
  2828. };
  2829. _boundEvents.windowAfterPrint = () => {
  2830. eventBus.dispatch("afterprint", {
  2831. source: window
  2832. });
  2833. };
  2834. _boundEvents.windowUpdateFromSandbox = event => {
  2835. eventBus.dispatch("updatefromsandbox", {
  2836. source: window,
  2837. detail: event.detail
  2838. });
  2839. };
  2840. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2841. window.addEventListener("wheel", webViewerWheel, {
  2842. passive: false
  2843. });
  2844. window.addEventListener("touchstart", webViewerTouchStart, {
  2845. passive: false
  2846. });
  2847. window.addEventListener("touchmove", webViewerTouchMove, {
  2848. passive: false
  2849. });
  2850. window.addEventListener("touchend", webViewerTouchEnd, {
  2851. passive: false
  2852. });
  2853. window.addEventListener("click", webViewerClick);
  2854. window.addEventListener("keydown", webViewerKeyDown);
  2855. window.addEventListener("keyup", webViewerKeyUp);
  2856. window.addEventListener("resize", _boundEvents.windowResize);
  2857. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2858. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2859. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2860. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2861. },
  2862. unbindEvents() {
  2863. const {
  2864. eventBus,
  2865. _boundEvents
  2866. } = this;
  2867. eventBus._off("resize", webViewerResize);
  2868. eventBus._off("hashchange", webViewerHashchange);
  2869. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2870. eventBus._off("afterprint", _boundEvents.afterPrint);
  2871. eventBus._off("pagerender", webViewerPageRender);
  2872. eventBus._off("pagerendered", webViewerPageRendered);
  2873. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2874. eventBus._off("pagechanging", webViewerPageChanging);
  2875. eventBus._off("scalechanging", webViewerScaleChanging);
  2876. eventBus._off("rotationchanging", webViewerRotationChanging);
  2877. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2878. eventBus._off("pagemode", webViewerPageMode);
  2879. eventBus._off("namedaction", webViewerNamedAction);
  2880. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2881. eventBus._off("presentationmode", webViewerPresentationMode);
  2882. eventBus._off("print", webViewerPrint);
  2883. eventBus._off("download", webViewerDownload);
  2884. eventBus._off("openinexternalapp", webViewerOpenInExternalApp);
  2885. eventBus._off("firstpage", webViewerFirstPage);
  2886. eventBus._off("lastpage", webViewerLastPage);
  2887. eventBus._off("nextpage", webViewerNextPage);
  2888. eventBus._off("previouspage", webViewerPreviousPage);
  2889. eventBus._off("zoomin", webViewerZoomIn);
  2890. eventBus._off("zoomout", webViewerZoomOut);
  2891. eventBus._off("zoomreset", webViewerZoomReset);
  2892. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2893. eventBus._off("scalechanged", webViewerScaleChanged);
  2894. eventBus._off("rotatecw", webViewerRotateCw);
  2895. eventBus._off("rotateccw", webViewerRotateCcw);
  2896. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2897. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2898. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2899. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2900. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2901. eventBus._off("documentproperties", webViewerDocumentProperties);
  2902. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2903. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2904. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2905. if (_boundEvents.reportPageStatsPDFBug) {
  2906. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2907. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2908. _boundEvents.reportPageStatsPDFBug = null;
  2909. }
  2910. eventBus._off("fileinputchange", webViewerFileInputChange);
  2911. eventBus._off("openfile", webViewerOpenFile);
  2912. _boundEvents.beforePrint = null;
  2913. _boundEvents.afterPrint = null;
  2914. },
  2915. unbindWindowEvents() {
  2916. const {
  2917. _boundEvents
  2918. } = this;
  2919. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2920. window.removeEventListener("wheel", webViewerWheel, {
  2921. passive: false
  2922. });
  2923. window.removeEventListener("touchstart", webViewerTouchStart, {
  2924. passive: false
  2925. });
  2926. window.removeEventListener("touchmove", webViewerTouchMove, {
  2927. passive: false
  2928. });
  2929. window.removeEventListener("touchend", webViewerTouchEnd, {
  2930. passive: false
  2931. });
  2932. window.removeEventListener("click", webViewerClick);
  2933. window.removeEventListener("keydown", webViewerKeyDown);
  2934. window.removeEventListener("keyup", webViewerKeyUp);
  2935. window.removeEventListener("resize", _boundEvents.windowResize);
  2936. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2937. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2938. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2939. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2940. _boundEvents.removeWindowResolutionChange?.();
  2941. _boundEvents.windowResize = null;
  2942. _boundEvents.windowHashChange = null;
  2943. _boundEvents.windowBeforePrint = null;
  2944. _boundEvents.windowAfterPrint = null;
  2945. _boundEvents.windowUpdateFromSandbox = null;
  2946. },
  2947. _accumulateTicks(ticks, prop) {
  2948. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  2949. this[prop] = 0;
  2950. }
  2951. this[prop] += ticks;
  2952. const wholeTicks = Math.trunc(this[prop]);
  2953. this[prop] -= wholeTicks;
  2954. return wholeTicks;
  2955. },
  2956. _accumulateFactor(previousScale, factor, prop) {
  2957. if (factor === 1) {
  2958. return 1;
  2959. }
  2960. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  2961. this[prop] = 1;
  2962. }
  2963. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  2964. this[prop] = factor / newFactor;
  2965. return newFactor;
  2966. },
  2967. _centerAtPos(previousScale, x, y) {
  2968. const {
  2969. pdfViewer
  2970. } = this;
  2971. const scaleDiff = pdfViewer.currentScale / previousScale - 1;
  2972. if (scaleDiff !== 0) {
  2973. const [top, left] = pdfViewer.containerTopLeft;
  2974. pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
  2975. pdfViewer.container.scrollTop += (y - top) * scaleDiff;
  2976. }
  2977. },
  2978. _unblockDocumentLoadEvent() {
  2979. document.blockUnblockOnload?.(false);
  2980. this._unblockDocumentLoadEvent = () => {};
  2981. },
  2982. get scriptingReady() {
  2983. return this.pdfScriptingManager.ready;
  2984. }
  2985. };
  2986. exports.PDFViewerApplication = PDFViewerApplication;
  2987. {
  2988. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2989. var validateFileURL = function (file) {
  2990. if (!file) {
  2991. return;
  2992. }
  2993. try {
  2994. const viewerOrigin = new URL(window.location.href).origin || "null";
  2995. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2996. return;
  2997. }
  2998. const fileOrigin = new URL(file, window.location.href).origin;
  2999. /*if (fileOrigin !== viewerOrigin) {
  3000. throw new Error("file origin does not match viewer's");
  3001. }*/
  3002. } catch (ex) {
  3003. PDFViewerApplication.l10n.get("loading_error").then(msg => {
  3004. PDFViewerApplication._documentError(msg, {
  3005. message: ex?.message
  3006. });
  3007. });
  3008. throw ex;
  3009. }
  3010. };
  3011. }
  3012. async function loadFakeWorker() {
  3013. _pdfjsLib.GlobalWorkerOptions.workerSrc ||= _app_options.AppOptions.get("workerSrc");
  3014. await (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.workerSrc);
  3015. }
  3016. async function loadPDFBug(self) {
  3017. const {
  3018. debuggerScriptPath
  3019. } = self.appConfig;
  3020. const {
  3021. PDFBug
  3022. } = await import(debuggerScriptPath);
  3023. self._PDFBug = PDFBug;
  3024. }
  3025. function reportPageStatsPDFBug(_ref5) {
  3026. let {
  3027. pageNumber
  3028. } = _ref5;
  3029. if (!globalThis.Stats?.enabled) {
  3030. return;
  3031. }
  3032. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3033. globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
  3034. }
  3035. function webViewerPageRender(_ref6) {
  3036. let {
  3037. pageNumber
  3038. } = _ref6;
  3039. if (pageNumber === PDFViewerApplication.page) {
  3040. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(true);
  3041. }
  3042. }
  3043. function webViewerPageRendered(_ref7) {
  3044. let {
  3045. pageNumber,
  3046. error
  3047. } = _ref7;
  3048. if (pageNumber === PDFViewerApplication.page) {
  3049. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(false);
  3050. }
  3051. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS) {
  3052. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3053. const thumbnailView = PDFViewerApplication.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
  3054. if (pageView) {
  3055. thumbnailView?.setImage(pageView);
  3056. }
  3057. }
  3058. if (error) {
  3059. PDFViewerApplication.l10n.get("rendering_error").then(msg => {
  3060. PDFViewerApplication._otherError(msg, error);
  3061. });
  3062. }
  3063. }
  3064. function webViewerPageMode(_ref8) {
  3065. let {
  3066. mode
  3067. } = _ref8;
  3068. let view;
  3069. switch (mode) {
  3070. case "thumbs":
  3071. view = _ui_utils.SidebarView.THUMBS;
  3072. break;
  3073. case "bookmarks":
  3074. case "outline":
  3075. view = _ui_utils.SidebarView.OUTLINE;
  3076. break;
  3077. case "attachments":
  3078. view = _ui_utils.SidebarView.ATTACHMENTS;
  3079. break;
  3080. case "layers":
  3081. view = _ui_utils.SidebarView.LAYERS;
  3082. break;
  3083. case "none":
  3084. view = _ui_utils.SidebarView.NONE;
  3085. break;
  3086. default:
  3087. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3088. return;
  3089. }
  3090. PDFViewerApplication.pdfSidebar?.switchView(view, true);
  3091. }
  3092. function webViewerNamedAction(evt) {
  3093. switch (evt.action) {
  3094. case "GoToPage":
  3095. PDFViewerApplication.appConfig.toolbar?.pageNumber.select();
  3096. break;
  3097. case "Find":
  3098. if (!PDFViewerApplication.supportsIntegratedFind) {
  3099. PDFViewerApplication?.findBar.toggle();
  3100. }
  3101. break;
  3102. case "Print":
  3103. PDFViewerApplication.triggerPrinting();
  3104. break;
  3105. case "SaveAs":
  3106. PDFViewerApplication.downloadOrSave();
  3107. break;
  3108. }
  3109. }
  3110. function webViewerPresentationModeChanged(evt) {
  3111. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3112. }
  3113. function webViewerSidebarViewChanged(_ref9) {
  3114. let {
  3115. view
  3116. } = _ref9;
  3117. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils.SidebarView.THUMBS;
  3118. if (PDFViewerApplication.isInitialViewSet) {
  3119. PDFViewerApplication.store?.set("sidebarView", view).catch(() => {});
  3120. }
  3121. }
  3122. function webViewerUpdateViewarea(_ref10) {
  3123. let {
  3124. location
  3125. } = _ref10;
  3126. if (PDFViewerApplication.isInitialViewSet) {
  3127. PDFViewerApplication.store?.setMultiple({
  3128. page: location.pageNumber,
  3129. zoom: location.scale,
  3130. scrollLeft: location.left,
  3131. scrollTop: location.top,
  3132. rotation: location.rotation
  3133. }).catch(() => {});
  3134. }
  3135. if (PDFViewerApplication.appConfig.secondaryToolbar) {
  3136. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3137. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3138. }
  3139. }
  3140. function webViewerScrollModeChanged(evt) {
  3141. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3142. PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {});
  3143. }
  3144. }
  3145. function webViewerSpreadModeChanged(evt) {
  3146. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  3147. PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
  3148. }
  3149. }
  3150. function webViewerResize() {
  3151. const {
  3152. pdfDocument,
  3153. pdfViewer,
  3154. pdfRenderingQueue
  3155. } = PDFViewerApplication;
  3156. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  3157. return;
  3158. }
  3159. if (!pdfDocument) {
  3160. return;
  3161. }
  3162. const currentScaleValue = pdfViewer.currentScaleValue;
  3163. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  3164. pdfViewer.currentScaleValue = currentScaleValue;
  3165. }
  3166. pdfViewer.update();
  3167. }
  3168. function webViewerHashchange(evt) {
  3169. const hash = evt.hash;
  3170. if (!hash) {
  3171. return;
  3172. }
  3173. if (!PDFViewerApplication.isInitialViewSet) {
  3174. PDFViewerApplication.initialBookmark = hash;
  3175. } else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
  3176. PDFViewerApplication.pdfLinkService.setHash(hash);
  3177. }
  3178. }
  3179. {
  3180. var webViewerFileInputChange = function (evt) {
  3181. if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
  3182. return;
  3183. }
  3184. const file = evt.fileInput.files[0];
  3185. PDFViewerApplication.open({
  3186. url: URL.createObjectURL(file),
  3187. originalUrl: file.name
  3188. });
  3189. };
  3190. var webViewerOpenFile = function (evt) {
  3191. const fileInput = PDFViewerApplication.appConfig.openFileInput;
  3192. fileInput.click();
  3193. };
  3194. }
  3195. function webViewerPresentationMode() {
  3196. PDFViewerApplication.requestPresentationMode();
  3197. }
  3198. function webViewerSwitchAnnotationEditorMode(evt) {
  3199. PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
  3200. }
  3201. function webViewerSwitchAnnotationEditorParams(evt) {
  3202. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  3203. }
  3204. function webViewerPrint() {
  3205. PDFViewerApplication.triggerPrinting();
  3206. }
  3207. function webViewerDownload() {
  3208. PDFViewerApplication.downloadOrSave();
  3209. }
  3210. function webViewerOpenInExternalApp() {
  3211. PDFViewerApplication.openInExternalApp();
  3212. }
  3213. function webViewerFirstPage() {
  3214. PDFViewerApplication.page = 1;
  3215. }
  3216. function webViewerLastPage() {
  3217. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3218. }
  3219. function webViewerNextPage() {
  3220. PDFViewerApplication.pdfViewer.nextPage();
  3221. }
  3222. function webViewerPreviousPage() {
  3223. PDFViewerApplication.pdfViewer.previousPage();
  3224. }
  3225. function webViewerZoomIn() {
  3226. PDFViewerApplication.zoomIn();
  3227. }
  3228. function webViewerZoomOut() {
  3229. PDFViewerApplication.zoomOut();
  3230. }
  3231. function webViewerZoomReset() {
  3232. PDFViewerApplication.zoomReset();
  3233. }
  3234. function webViewerPageNumberChanged(evt) {
  3235. const pdfViewer = PDFViewerApplication.pdfViewer;
  3236. if (evt.value !== "") {
  3237. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3238. }
  3239. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3240. PDFViewerApplication.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3241. }
  3242. }
  3243. function webViewerScaleChanged(evt) {
  3244. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3245. }
  3246. function webViewerRotateCw() {
  3247. PDFViewerApplication.rotatePages(90);
  3248. }
  3249. function webViewerRotateCcw() {
  3250. PDFViewerApplication.rotatePages(-90);
  3251. }
  3252. function webViewerOptionalContentConfig(evt) {
  3253. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3254. }
  3255. function webViewerSwitchScrollMode(evt) {
  3256. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3257. }
  3258. function webViewerSwitchSpreadMode(evt) {
  3259. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3260. }
  3261. function webViewerDocumentProperties() {
  3262. PDFViewerApplication.pdfDocumentProperties?.open();
  3263. }
  3264. function webViewerFindFromUrlHash(evt) {
  3265. PDFViewerApplication.eventBus.dispatch("find", {
  3266. source: evt.source,
  3267. type: "",
  3268. query: evt.query,
  3269. caseSensitive: false,
  3270. entireWord: false,
  3271. highlightAll: true,
  3272. findPrevious: false,
  3273. matchDiacritics: true
  3274. });
  3275. }
  3276. function webViewerUpdateFindMatchesCount(_ref11) {
  3277. let {
  3278. matchesCount
  3279. } = _ref11;
  3280. if (PDFViewerApplication.supportsIntegratedFind) {
  3281. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3282. } else {
  3283. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3284. }
  3285. }
  3286. function webViewerUpdateFindControlState(_ref12) {
  3287. let {
  3288. state,
  3289. previous,
  3290. matchesCount,
  3291. rawQuery
  3292. } = _ref12;
  3293. if (PDFViewerApplication.supportsIntegratedFind) {
  3294. PDFViewerApplication.externalServices.updateFindControlState({
  3295. result: state,
  3296. findPrevious: previous,
  3297. matchesCount,
  3298. rawQuery
  3299. });
  3300. } else {
  3301. PDFViewerApplication.findBar?.updateUIState(state, previous, matchesCount);
  3302. }
  3303. }
  3304. function webViewerScaleChanging(evt) {
  3305. PDFViewerApplication.toolbar?.setPageScale(evt.presetValue, evt.scale);
  3306. PDFViewerApplication.pdfViewer.update();
  3307. }
  3308. function webViewerRotationChanging(evt) {
  3309. if (PDFViewerApplication.pdfThumbnailViewer) {
  3310. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3311. }
  3312. PDFViewerApplication.forceRendering();
  3313. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3314. }
  3315. function webViewerPageChanging(_ref13) {
  3316. let {
  3317. pageNumber,
  3318. pageLabel
  3319. } = _ref13;
  3320. PDFViewerApplication.toolbar?.setPageNumber(pageNumber, pageLabel);
  3321. PDFViewerApplication.secondaryToolbar?.setPageNumber(pageNumber);
  3322. if (PDFViewerApplication.pdfSidebar?.visibleView === _ui_utils.SidebarView.THUMBS) {
  3323. PDFViewerApplication.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
  3324. }
  3325. const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3326. PDFViewerApplication.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === _ui_utils.RenderingStates.RUNNING);
  3327. }
  3328. function webViewerResolutionChange(evt) {
  3329. PDFViewerApplication.pdfViewer.refresh();
  3330. }
  3331. function webViewerVisibilityChange(evt) {
  3332. if (document.visibilityState === "visible") {
  3333. setZoomDisabledTimeout();
  3334. }
  3335. }
  3336. let zoomDisabledTimeout = null;
  3337. function setZoomDisabledTimeout() {
  3338. if (zoomDisabledTimeout) {
  3339. clearTimeout(zoomDisabledTimeout);
  3340. }
  3341. zoomDisabledTimeout = setTimeout(function () {
  3342. zoomDisabledTimeout = null;
  3343. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3344. }
  3345. function webViewerWheel(evt) {
  3346. const {
  3347. pdfViewer,
  3348. supportedMouseWheelZoomModifierKeys,
  3349. supportsPinchToZoom
  3350. } = PDFViewerApplication;
  3351. if (pdfViewer.isInPresentationMode) {
  3352. return;
  3353. }
  3354. const deltaMode = evt.deltaMode;
  3355. let scaleFactor = Math.exp(-evt.deltaY / 100);
  3356. const isBuiltInMac = false;
  3357. const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  3358. if (isPinchToZoom || evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  3359. evt.preventDefault();
  3360. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3361. return;
  3362. }
  3363. const previousScale = pdfViewer.currentScale;
  3364. if (isPinchToZoom && supportsPinchToZoom) {
  3365. scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
  3366. if (scaleFactor < 1) {
  3367. PDFViewerApplication.zoomOut(null, scaleFactor);
  3368. } else if (scaleFactor > 1) {
  3369. PDFViewerApplication.zoomIn(null, scaleFactor);
  3370. } else {
  3371. return;
  3372. }
  3373. } else {
  3374. const delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3375. let ticks = 0;
  3376. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3377. if (Math.abs(delta) >= 1) {
  3378. ticks = Math.sign(delta);
  3379. } else {
  3380. ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
  3381. }
  3382. } else {
  3383. const PIXELS_PER_LINE_SCALE = 30;
  3384. ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  3385. }
  3386. if (ticks < 0) {
  3387. PDFViewerApplication.zoomOut(-ticks);
  3388. } else if (ticks > 0) {
  3389. PDFViewerApplication.zoomIn(ticks);
  3390. } else {
  3391. return;
  3392. }
  3393. }
  3394. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
  3395. } else {
  3396. setZoomDisabledTimeout();
  3397. }
  3398. }
  3399. function webViewerTouchStart(evt) {
  3400. if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  3401. return;
  3402. }
  3403. evt.preventDefault();
  3404. if (evt.touches.length !== 2) {
  3405. PDFViewerApplication._touchInfo = null;
  3406. return;
  3407. }
  3408. let [touch0, touch1] = evt.touches;
  3409. if (touch0.identifier > touch1.identifier) {
  3410. [touch0, touch1] = [touch1, touch0];
  3411. }
  3412. PDFViewerApplication._touchInfo = {
  3413. touch0X: touch0.pageX,
  3414. touch0Y: touch0.pageY,
  3415. touch1X: touch1.pageX,
  3416. touch1Y: touch1.pageY
  3417. };
  3418. }
  3419. function webViewerTouchMove(evt) {
  3420. if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
  3421. return;
  3422. }
  3423. const {
  3424. pdfViewer,
  3425. _touchInfo,
  3426. supportsPinchToZoom
  3427. } = PDFViewerApplication;
  3428. let [touch0, touch1] = evt.touches;
  3429. if (touch0.identifier > touch1.identifier) {
  3430. [touch0, touch1] = [touch1, touch0];
  3431. }
  3432. const {
  3433. pageX: page0X,
  3434. pageY: page0Y
  3435. } = touch0;
  3436. const {
  3437. pageX: page1X,
  3438. pageY: page1Y
  3439. } = touch1;
  3440. const {
  3441. touch0X: pTouch0X,
  3442. touch0Y: pTouch0Y,
  3443. touch1X: pTouch1X,
  3444. touch1Y: pTouch1Y
  3445. } = _touchInfo;
  3446. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  3447. return;
  3448. }
  3449. _touchInfo.touch0X = page0X;
  3450. _touchInfo.touch0Y = page0Y;
  3451. _touchInfo.touch1X = page1X;
  3452. _touchInfo.touch1Y = page1Y;
  3453. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  3454. const v1X = pTouch1X - page0X;
  3455. const v1Y = pTouch1Y - page0Y;
  3456. const v2X = page1X - page0X;
  3457. const v2Y = page1Y - page0Y;
  3458. const det = v1X * v2Y - v1Y * v2X;
  3459. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3460. return;
  3461. }
  3462. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  3463. const v1X = pTouch0X - page1X;
  3464. const v1Y = pTouch0Y - page1Y;
  3465. const v2X = page0X - page1X;
  3466. const v2Y = page0Y - page1Y;
  3467. const det = v1X * v2Y - v1Y * v2X;
  3468. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  3469. return;
  3470. }
  3471. } else {
  3472. const diff0X = page0X - pTouch0X;
  3473. const diff1X = page1X - pTouch1X;
  3474. const diff0Y = page0Y - pTouch0Y;
  3475. const diff1Y = page1Y - pTouch1Y;
  3476. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  3477. if (dotProduct >= 0) {
  3478. return;
  3479. }
  3480. }
  3481. evt.preventDefault();
  3482. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  3483. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  3484. const previousScale = pdfViewer.currentScale;
  3485. if (supportsPinchToZoom) {
  3486. const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
  3487. if (newScaleFactor < 1) {
  3488. PDFViewerApplication.zoomOut(null, newScaleFactor);
  3489. } else if (newScaleFactor > 1) {
  3490. PDFViewerApplication.zoomIn(null, newScaleFactor);
  3491. } else {
  3492. return;
  3493. }
  3494. } else {
  3495. const PIXELS_PER_LINE_SCALE = 30;
  3496. const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  3497. if (ticks < 0) {
  3498. PDFViewerApplication.zoomOut(-ticks);
  3499. } else if (ticks > 0) {
  3500. PDFViewerApplication.zoomIn(ticks);
  3501. } else {
  3502. return;
  3503. }
  3504. }
  3505. PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
  3506. }
  3507. function webViewerTouchEnd(evt) {
  3508. if (!PDFViewerApplication._touchInfo) {
  3509. return;
  3510. }
  3511. evt.preventDefault();
  3512. PDFViewerApplication._touchInfo = null;
  3513. PDFViewerApplication._touchUnusedTicks = 0;
  3514. PDFViewerApplication._touchUnusedFactor = 1;
  3515. }
  3516. function webViewerClick(evt) {
  3517. if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
  3518. return;
  3519. }
  3520. const appConfig = PDFViewerApplication.appConfig;
  3521. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
  3522. PDFViewerApplication.secondaryToolbar.close();
  3523. }
  3524. }
  3525. function webViewerKeyUp(evt) {
  3526. if (evt.key === "Control") {
  3527. PDFViewerApplication._isCtrlKeyDown = false;
  3528. }
  3529. }
  3530. function webViewerKeyDown(evt) {
  3531. PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
  3532. if (PDFViewerApplication.overlayManager.active) {
  3533. return;
  3534. }
  3535. const {
  3536. eventBus,
  3537. pdfViewer
  3538. } = PDFViewerApplication;
  3539. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  3540. let handled = false,
  3541. ensureViewerFocused = false;
  3542. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3543. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3544. switch (evt.keyCode) {
  3545. case 70:
  3546. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3547. PDFViewerApplication.findBar?.open();
  3548. handled = true;
  3549. }
  3550. break;
  3551. case 71:
  3552. if (!PDFViewerApplication.supportsIntegratedFind) {
  3553. const {
  3554. state
  3555. } = PDFViewerApplication.findController;
  3556. if (state) {
  3557. const newState = {
  3558. source: window,
  3559. type: "again",
  3560. findPrevious: cmd === 5 || cmd === 12
  3561. };
  3562. eventBus.dispatch("find", {
  3563. ...state,
  3564. ...newState
  3565. });
  3566. }
  3567. handled = true;
  3568. }
  3569. break;
  3570. case 61:
  3571. case 107:
  3572. case 187:
  3573. case 171:
  3574. PDFViewerApplication.zoomIn();
  3575. handled = true;
  3576. break;
  3577. case 173:
  3578. case 109:
  3579. case 189:
  3580. PDFViewerApplication.zoomOut();
  3581. handled = true;
  3582. break;
  3583. case 48:
  3584. case 96:
  3585. if (!isViewerInPresentationMode) {
  3586. setTimeout(function () {
  3587. PDFViewerApplication.zoomReset();
  3588. });
  3589. handled = false;
  3590. }
  3591. break;
  3592. case 38:
  3593. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3594. PDFViewerApplication.page = 1;
  3595. handled = true;
  3596. ensureViewerFocused = true;
  3597. }
  3598. break;
  3599. case 40:
  3600. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3601. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3602. handled = true;
  3603. ensureViewerFocused = true;
  3604. }
  3605. break;
  3606. }
  3607. }
  3608. if (cmd === 1 || cmd === 8) {
  3609. switch (evt.keyCode) {
  3610. case 83:
  3611. eventBus.dispatch("download", {
  3612. source: window
  3613. });
  3614. handled = true;
  3615. break;
  3616. case 79:
  3617. {
  3618. eventBus.dispatch("openfile", {
  3619. source: window
  3620. });
  3621. handled = true;
  3622. }
  3623. break;
  3624. }
  3625. }
  3626. if (cmd === 3 || cmd === 10) {
  3627. switch (evt.keyCode) {
  3628. case 80:
  3629. PDFViewerApplication.requestPresentationMode();
  3630. handled = true;
  3631. PDFViewerApplication.externalServices.reportTelemetry({
  3632. type: "buttons",
  3633. data: {
  3634. id: "presentationModeKeyboard"
  3635. }
  3636. });
  3637. break;
  3638. case 71:
  3639. if (PDFViewerApplication.appConfig.toolbar) {
  3640. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3641. handled = true;
  3642. }
  3643. break;
  3644. }
  3645. }
  3646. if (handled) {
  3647. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3648. pdfViewer.focus();
  3649. }
  3650. evt.preventDefault();
  3651. return;
  3652. }
  3653. const curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3654. const curElementTagName = curElement?.tagName.toUpperCase();
  3655. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement?.isContentEditable) {
  3656. if (evt.keyCode !== 27) {
  3657. return;
  3658. }
  3659. }
  3660. if (cmd === 0) {
  3661. let turnPage = 0,
  3662. turnOnlyIfPageFit = false;
  3663. switch (evt.keyCode) {
  3664. case 38:
  3665. case 33:
  3666. if (pdfViewer.isVerticalScrollbarEnabled) {
  3667. turnOnlyIfPageFit = true;
  3668. }
  3669. turnPage = -1;
  3670. break;
  3671. case 8:
  3672. if (!isViewerInPresentationMode) {
  3673. turnOnlyIfPageFit = true;
  3674. }
  3675. turnPage = -1;
  3676. break;
  3677. case 37:
  3678. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3679. turnOnlyIfPageFit = true;
  3680. }
  3681. case 75:
  3682. case 80:
  3683. turnPage = -1;
  3684. break;
  3685. case 27:
  3686. if (PDFViewerApplication.secondaryToolbar?.isOpen) {
  3687. PDFViewerApplication.secondaryToolbar.close();
  3688. handled = true;
  3689. }
  3690. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar?.opened) {
  3691. PDFViewerApplication.findBar.close();
  3692. handled = true;
  3693. }
  3694. break;
  3695. case 40:
  3696. case 34:
  3697. if (pdfViewer.isVerticalScrollbarEnabled) {
  3698. turnOnlyIfPageFit = true;
  3699. }
  3700. turnPage = 1;
  3701. break;
  3702. case 13:
  3703. case 32:
  3704. if (!isViewerInPresentationMode) {
  3705. turnOnlyIfPageFit = true;
  3706. }
  3707. turnPage = 1;
  3708. break;
  3709. case 39:
  3710. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3711. turnOnlyIfPageFit = true;
  3712. }
  3713. case 74:
  3714. case 78:
  3715. turnPage = 1;
  3716. break;
  3717. case 36:
  3718. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3719. PDFViewerApplication.page = 1;
  3720. handled = true;
  3721. ensureViewerFocused = true;
  3722. }
  3723. break;
  3724. case 35:
  3725. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3726. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3727. handled = true;
  3728. ensureViewerFocused = true;
  3729. }
  3730. break;
  3731. case 83:
  3732. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils.CursorTool.SELECT);
  3733. break;
  3734. case 72:
  3735. PDFViewerApplication.pdfCursorTools?.switchTool(_ui_utils.CursorTool.HAND);
  3736. break;
  3737. case 82:
  3738. PDFViewerApplication.rotatePages(90);
  3739. break;
  3740. case 115:
  3741. PDFViewerApplication.pdfSidebar?.toggle();
  3742. break;
  3743. }
  3744. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  3745. if (turnPage > 0) {
  3746. pdfViewer.nextPage();
  3747. } else {
  3748. pdfViewer.previousPage();
  3749. }
  3750. handled = true;
  3751. }
  3752. }
  3753. if (cmd === 4) {
  3754. switch (evt.keyCode) {
  3755. case 13:
  3756. case 32:
  3757. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  3758. break;
  3759. }
  3760. pdfViewer.previousPage();
  3761. handled = true;
  3762. break;
  3763. case 82:
  3764. PDFViewerApplication.rotatePages(-90);
  3765. break;
  3766. }
  3767. }
  3768. if (!handled && !isViewerInPresentationMode) {
  3769. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3770. ensureViewerFocused = true;
  3771. }
  3772. }
  3773. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3774. pdfViewer.focus();
  3775. }
  3776. if (handled) {
  3777. evt.preventDefault();
  3778. }
  3779. }
  3780. function beforeUnload(evt) {
  3781. evt.preventDefault();
  3782. evt.returnValue = "";
  3783. return false;
  3784. }
  3785. function webViewerAnnotationEditorStatesChanged(data) {
  3786. PDFViewerApplication.externalServices.updateEditorStates(data);
  3787. }
  3788. const PDFPrintServiceFactory = {
  3789. instance: {
  3790. supportsPrinting: false,
  3791. createPrintService() {
  3792. throw new Error("Not implemented: createPrintService");
  3793. }
  3794. }
  3795. };
  3796. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3797. /***/ }),
  3798. /* 76 */
  3799. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  3800. var $ = __webpack_require__(3);
  3801. var global = __webpack_require__(4);
  3802. var apply = __webpack_require__(77);
  3803. var wrapErrorConstructorWithCause = __webpack_require__(78);
  3804. var WEB_ASSEMBLY = 'WebAssembly';
  3805. var WebAssembly = global[WEB_ASSEMBLY];
  3806. var FORCED = Error('e', { cause: 7 }).cause !== 7;
  3807. var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  3808. var O = {};
  3809. O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);
  3810. $({
  3811. global: true,
  3812. constructor: true,
  3813. arity: 1,
  3814. forced: FORCED
  3815. }, O);
  3816. };
  3817. var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  3818. if (WebAssembly && WebAssembly[ERROR_NAME]) {
  3819. var O = {};
  3820. O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);
  3821. $({
  3822. target: WEB_ASSEMBLY,
  3823. stat: true,
  3824. constructor: true,
  3825. arity: 1,
  3826. forced: FORCED
  3827. }, O);
  3828. }
  3829. };
  3830. exportGlobalErrorCauseWrapper('Error', function (init) {
  3831. return function Error(message) {
  3832. return apply(init, this, arguments);
  3833. };
  3834. });
  3835. exportGlobalErrorCauseWrapper('EvalError', function (init) {
  3836. return function EvalError(message) {
  3837. return apply(init, this, arguments);
  3838. };
  3839. });
  3840. exportGlobalErrorCauseWrapper('RangeError', function (init) {
  3841. return function RangeError(message) {
  3842. return apply(init, this, arguments);
  3843. };
  3844. });
  3845. exportGlobalErrorCauseWrapper('ReferenceError', function (init) {
  3846. return function ReferenceError(message) {
  3847. return apply(init, this, arguments);
  3848. };
  3849. });
  3850. exportGlobalErrorCauseWrapper('SyntaxError', function (init) {
  3851. return function SyntaxError(message) {
  3852. return apply(init, this, arguments);
  3853. };
  3854. });
  3855. exportGlobalErrorCauseWrapper('TypeError', function (init) {
  3856. return function TypeError(message) {
  3857. return apply(init, this, arguments);
  3858. };
  3859. });
  3860. exportGlobalErrorCauseWrapper('URIError', function (init) {
  3861. return function URIError(message) {
  3862. return apply(init, this, arguments);
  3863. };
  3864. });
  3865. exportWebAssemblyErrorCauseWrapper('CompileError', function (init) {
  3866. return function CompileError(message) {
  3867. return apply(init, this, arguments);
  3868. };
  3869. });
  3870. exportWebAssemblyErrorCauseWrapper('LinkError', function (init) {
  3871. return function LinkError(message) {
  3872. return apply(init, this, arguments);
  3873. };
  3874. });
  3875. exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
  3876. return function RuntimeError(message) {
  3877. return apply(init, this, arguments);
  3878. };
  3879. });
  3880. /***/ }),
  3881. /* 77 */
  3882. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3883. var NATIVE_BIND = __webpack_require__(9);
  3884. var FunctionPrototype = Function.prototype;
  3885. var apply = FunctionPrototype.apply;
  3886. var call = FunctionPrototype.call;
  3887. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  3888. return call.apply(apply, arguments);
  3889. });
  3890. /***/ }),
  3891. /* 78 */
  3892. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3893. var getBuiltIn = __webpack_require__(24);
  3894. var hasOwn = __webpack_require__(39);
  3895. var createNonEnumerableProperty = __webpack_require__(44);
  3896. var isPrototypeOf = __webpack_require__(25);
  3897. var setPrototypeOf = __webpack_require__(79);
  3898. var copyConstructorProperties = __webpack_require__(56);
  3899. var proxyAccessor = __webpack_require__(82);
  3900. var inheritIfRequired = __webpack_require__(83);
  3901. var normalizeStringArgument = __webpack_require__(84);
  3902. var installErrorCause = __webpack_require__(85);
  3903. var installErrorStack = __webpack_require__(86);
  3904. var DESCRIPTORS = __webpack_require__(6);
  3905. var IS_PURE = __webpack_require__(36);
  3906. module.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) {
  3907. var STACK_TRACE_LIMIT = 'stackTraceLimit';
  3908. var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1;
  3909. var path = FULL_NAME.split('.');
  3910. var ERROR_NAME = path[path.length - 1];
  3911. var OriginalError = getBuiltIn.apply(null, path);
  3912. if (!OriginalError)
  3913. return;
  3914. var OriginalErrorPrototype = OriginalError.prototype;
  3915. if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause'))
  3916. delete OriginalErrorPrototype.cause;
  3917. if (!FORCED)
  3918. return OriginalError;
  3919. var BaseError = getBuiltIn('Error');
  3920. var WrappedError = wrapper(function (a, b) {
  3921. var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined);
  3922. var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError();
  3923. if (message !== undefined)
  3924. createNonEnumerableProperty(result, 'message', message);
  3925. installErrorStack(result, WrappedError, result.stack, 2);
  3926. if (this && isPrototypeOf(OriginalErrorPrototype, this))
  3927. inheritIfRequired(result, this, WrappedError);
  3928. if (arguments.length > OPTIONS_POSITION)
  3929. installErrorCause(result, arguments[OPTIONS_POSITION]);
  3930. return result;
  3931. });
  3932. WrappedError.prototype = OriginalErrorPrototype;
  3933. if (ERROR_NAME !== 'Error') {
  3934. if (setPrototypeOf)
  3935. setPrototypeOf(WrappedError, BaseError);
  3936. else
  3937. copyConstructorProperties(WrappedError, BaseError, { name: true });
  3938. } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) {
  3939. proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT);
  3940. proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace');
  3941. }
  3942. copyConstructorProperties(WrappedError, OriginalError);
  3943. if (!IS_PURE)
  3944. try {
  3945. if (OriginalErrorPrototype.name !== ERROR_NAME) {
  3946. createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME);
  3947. }
  3948. OriginalErrorPrototype.constructor = WrappedError;
  3949. } catch (error) {
  3950. }
  3951. return WrappedError;
  3952. };
  3953. /***/ }),
  3954. /* 79 */
  3955. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3956. var uncurryThisAccessor = __webpack_require__(80);
  3957. var anObject = __webpack_require__(47);
  3958. var aPossiblePrototype = __webpack_require__(81);
  3959. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  3960. var CORRECT_SETTER = false;
  3961. var test = {};
  3962. var setter;
  3963. try {
  3964. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  3965. setter(test, []);
  3966. CORRECT_SETTER = test instanceof Array;
  3967. } catch (error) {
  3968. }
  3969. return function setPrototypeOf(O, proto) {
  3970. anObject(O);
  3971. aPossiblePrototype(proto);
  3972. if (CORRECT_SETTER)
  3973. setter(O, proto);
  3974. else
  3975. O.__proto__ = proto;
  3976. return O;
  3977. };
  3978. }()) : undefined);
  3979. /***/ }),
  3980. /* 80 */
  3981. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3982. var uncurryThis = __webpack_require__(14);
  3983. var aCallable = __webpack_require__(31);
  3984. module.exports = function (object, key, method) {
  3985. try {
  3986. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  3987. } catch (error) {
  3988. }
  3989. };
  3990. /***/ }),
  3991. /* 81 */
  3992. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3993. var isCallable = __webpack_require__(21);
  3994. var $String = String;
  3995. var $TypeError = TypeError;
  3996. module.exports = function (argument) {
  3997. if (typeof argument == 'object' || isCallable(argument))
  3998. return argument;
  3999. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  4000. };
  4001. /***/ }),
  4002. /* 82 */
  4003. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4004. var defineProperty = (__webpack_require__(45).f);
  4005. module.exports = function (Target, Source, key) {
  4006. key in Target || defineProperty(Target, key, {
  4007. configurable: true,
  4008. get: function () {
  4009. return Source[key];
  4010. },
  4011. set: function (it) {
  4012. Source[key] = it;
  4013. }
  4014. });
  4015. };
  4016. /***/ }),
  4017. /* 83 */
  4018. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4019. var isCallable = __webpack_require__(21);
  4020. var isObject = __webpack_require__(20);
  4021. var setPrototypeOf = __webpack_require__(79);
  4022. module.exports = function ($this, dummy, Wrapper) {
  4023. var NewTarget, NewTargetPrototype;
  4024. if (setPrototypeOf && isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  4025. setPrototypeOf($this, NewTargetPrototype);
  4026. return $this;
  4027. };
  4028. /***/ }),
  4029. /* 84 */
  4030. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4031. var toString = __webpack_require__(70);
  4032. module.exports = function (argument, $default) {
  4033. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  4034. };
  4035. /***/ }),
  4036. /* 85 */
  4037. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4038. var isObject = __webpack_require__(20);
  4039. var createNonEnumerableProperty = __webpack_require__(44);
  4040. module.exports = function (O, options) {
  4041. if (isObject(options) && 'cause' in options) {
  4042. createNonEnumerableProperty(O, 'cause', options.cause);
  4043. }
  4044. };
  4045. /***/ }),
  4046. /* 86 */
  4047. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4048. var createNonEnumerableProperty = __webpack_require__(44);
  4049. var clearErrorStack = __webpack_require__(87);
  4050. var ERROR_STACK_INSTALLABLE = __webpack_require__(88);
  4051. var captureStackTrace = Error.captureStackTrace;
  4052. module.exports = function (error, C, stack, dropEntries) {
  4053. if (ERROR_STACK_INSTALLABLE) {
  4054. if (captureStackTrace)
  4055. captureStackTrace(error, C);
  4056. else
  4057. createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  4058. }
  4059. };
  4060. /***/ }),
  4061. /* 87 */
  4062. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4063. var uncurryThis = __webpack_require__(14);
  4064. var $Error = Error;
  4065. var replace = uncurryThis(''.replace);
  4066. var TEST = function (arg) {
  4067. return String($Error(arg).stack);
  4068. }('zxcasd');
  4069. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  4070. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  4071. module.exports = function (stack, dropEntries) {
  4072. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  4073. while (dropEntries--)
  4074. stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  4075. }
  4076. return stack;
  4077. };
  4078. /***/ }),
  4079. /* 88 */
  4080. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4081. var fails = __webpack_require__(7);
  4082. var createPropertyDescriptor = __webpack_require__(11);
  4083. module.exports = !fails(function () {
  4084. var error = Error('a');
  4085. if (!('stack' in error))
  4086. return true;
  4087. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  4088. return error.stack !== 7;
  4089. });
  4090. /***/ }),
  4091. /* 89 */
  4092. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4093. var $ = __webpack_require__(3);
  4094. var toObject = __webpack_require__(40);
  4095. var lengthOfArrayLike = __webpack_require__(64);
  4096. var setArrayLength = __webpack_require__(90);
  4097. var doesNotExceedSafeInteger = __webpack_require__(91);
  4098. var fails = __webpack_require__(7);
  4099. var INCORRECT_TO_LENGTH = fails(function () {
  4100. return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
  4101. });
  4102. var properErrorOnNonWritableLength = function () {
  4103. try {
  4104. Object.defineProperty([], 'length', { writable: false }).push();
  4105. } catch (error) {
  4106. return error instanceof TypeError;
  4107. }
  4108. };
  4109. var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
  4110. $({
  4111. target: 'Array',
  4112. proto: true,
  4113. arity: 1,
  4114. forced: FORCED
  4115. }, {
  4116. push: function push(item) {
  4117. var O = toObject(this);
  4118. var len = lengthOfArrayLike(O);
  4119. var argCount = arguments.length;
  4120. doesNotExceedSafeInteger(len + argCount);
  4121. for (var i = 0; i < argCount; i++) {
  4122. O[len] = arguments[i];
  4123. len++;
  4124. }
  4125. setArrayLength(O, len);
  4126. return len;
  4127. }
  4128. });
  4129. /***/ }),
  4130. /* 90 */
  4131. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4132. var DESCRIPTORS = __webpack_require__(6);
  4133. var isArray = __webpack_require__(69);
  4134. var $TypeError = TypeError;
  4135. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  4136. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !(function () {
  4137. if (this !== undefined)
  4138. return true;
  4139. try {
  4140. Object.defineProperty([], 'length', { writable: false }).length = 1;
  4141. } catch (error) {
  4142. return error instanceof TypeError;
  4143. }
  4144. }());
  4145. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  4146. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  4147. throw $TypeError('Cannot set read only .length');
  4148. }
  4149. return O.length = length;
  4150. } : function (O, length) {
  4151. return O.length = length;
  4152. };
  4153. /***/ }),
  4154. /* 91 */
  4155. /***/ ((module) => {
  4156. var $TypeError = TypeError;
  4157. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  4158. module.exports = function (it) {
  4159. if (it > MAX_SAFE_INTEGER)
  4160. throw $TypeError('Maximum allowed index exceeded');
  4161. return it;
  4162. };
  4163. /***/ }),
  4164. /* 92 */
  4165. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4166. var defineBuiltIn = __webpack_require__(48);
  4167. var uncurryThis = __webpack_require__(14);
  4168. var toString = __webpack_require__(70);
  4169. var validateArgumentsLength = __webpack_require__(93);
  4170. var $URLSearchParams = URLSearchParams;
  4171. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4172. var append = uncurryThis(URLSearchParamsPrototype.append);
  4173. var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
  4174. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4175. var push = uncurryThis([].push);
  4176. var params = new $URLSearchParams('a=1&a=2&b=3');
  4177. params['delete']('a', 1);
  4178. params['delete']('b', undefined);
  4179. if (params + '' !== 'a=2') {
  4180. defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name) {
  4181. var length = arguments.length;
  4182. var $value = length < 2 ? undefined : arguments[1];
  4183. if (length && $value === undefined)
  4184. return $delete(this, name);
  4185. var entries = [];
  4186. forEach(this, function (v, k) {
  4187. push(entries, {
  4188. key: k,
  4189. value: v
  4190. });
  4191. });
  4192. validateArgumentsLength(length, 1);
  4193. var key = toString(name);
  4194. var value = toString($value);
  4195. var index = 0;
  4196. var dindex = 0;
  4197. var found = false;
  4198. var entriesLength = entries.length;
  4199. var entry;
  4200. while (index < entriesLength) {
  4201. entry = entries[index++];
  4202. if (found || entry.key === key) {
  4203. found = true;
  4204. $delete(this, entry.key);
  4205. } else
  4206. dindex++;
  4207. }
  4208. while (dindex < entriesLength) {
  4209. entry = entries[dindex++];
  4210. if (!(entry.key === key && entry.value === value))
  4211. append(this, entry.key, entry.value);
  4212. }
  4213. }, {
  4214. enumerable: true,
  4215. unsafe: true
  4216. });
  4217. }
  4218. /***/ }),
  4219. /* 93 */
  4220. /***/ ((module) => {
  4221. var $TypeError = TypeError;
  4222. module.exports = function (passed, required) {
  4223. if (passed < required)
  4224. throw $TypeError('Not enough arguments');
  4225. return passed;
  4226. };
  4227. /***/ }),
  4228. /* 94 */
  4229. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4230. var defineBuiltIn = __webpack_require__(48);
  4231. var uncurryThis = __webpack_require__(14);
  4232. var toString = __webpack_require__(70);
  4233. var validateArgumentsLength = __webpack_require__(93);
  4234. var $URLSearchParams = URLSearchParams;
  4235. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4236. var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
  4237. var $has = uncurryThis(URLSearchParamsPrototype.has);
  4238. var params = new $URLSearchParams('a=1');
  4239. if (params.has('a', 2) || !params.has('a', undefined)) {
  4240. defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name) {
  4241. var length = arguments.length;
  4242. var $value = length < 2 ? undefined : arguments[1];
  4243. if (length && $value === undefined)
  4244. return $has(this, name);
  4245. var values = getAll(this, name);
  4246. validateArgumentsLength(length, 1);
  4247. var value = toString($value);
  4248. var index = 0;
  4249. while (index < values.length) {
  4250. if (values[index++] === value)
  4251. return true;
  4252. }
  4253. return false;
  4254. }, {
  4255. enumerable: true,
  4256. unsafe: true
  4257. });
  4258. }
  4259. /***/ }),
  4260. /* 95 */
  4261. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4262. var DESCRIPTORS = __webpack_require__(6);
  4263. var uncurryThis = __webpack_require__(14);
  4264. var defineBuiltInAccessor = __webpack_require__(96);
  4265. var URLSearchParamsPrototype = URLSearchParams.prototype;
  4266. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4267. if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
  4268. defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
  4269. get: function size() {
  4270. var count = 0;
  4271. forEach(this, function () {
  4272. count++;
  4273. });
  4274. return count;
  4275. },
  4276. configurable: true,
  4277. enumerable: true
  4278. });
  4279. }
  4280. /***/ }),
  4281. /* 96 */
  4282. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4283. var makeBuiltIn = __webpack_require__(49);
  4284. var defineProperty = __webpack_require__(45);
  4285. module.exports = function (target, name, descriptor) {
  4286. if (descriptor.get)
  4287. makeBuiltIn(descriptor.get, name, { getter: true });
  4288. if (descriptor.set)
  4289. makeBuiltIn(descriptor.set, name, { setter: true });
  4290. return defineProperty.f(target, name, descriptor);
  4291. };
  4292. /***/ }),
  4293. /* 97 */
  4294. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4295. Object.defineProperty(exports, "__esModule", ({
  4296. value: true
  4297. }));
  4298. 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;
  4299. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  4300. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  4301. exports.approximateFraction = approximateFraction;
  4302. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4303. exports.binarySearchFirstItem = binarySearchFirstItem;
  4304. exports.docStyle = void 0;
  4305. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4306. exports.getPageSizeInches = getPageSizeInches;
  4307. exports.getVisibleElements = getVisibleElements;
  4308. exports.isPortraitOrientation = isPortraitOrientation;
  4309. exports.isValidRotation = isValidRotation;
  4310. exports.isValidScrollMode = isValidScrollMode;
  4311. exports.isValidSpreadMode = isValidSpreadMode;
  4312. exports.noContextMenuHandler = noContextMenuHandler;
  4313. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4314. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4315. exports.parseQueryString = parseQueryString;
  4316. exports.removeNullCharacters = removeNullCharacters;
  4317. exports.roundToDivide = roundToDivide;
  4318. exports.scrollIntoView = scrollIntoView;
  4319. exports.toggleCheckedBtn = toggleCheckedBtn;
  4320. exports.toggleExpandedBtn = toggleExpandedBtn;
  4321. exports.watchScroll = watchScroll;
  4322. __webpack_require__(92);
  4323. __webpack_require__(94);
  4324. __webpack_require__(95);
  4325. __webpack_require__(98);
  4326. __webpack_require__(109);
  4327. __webpack_require__(111);
  4328. __webpack_require__(114);
  4329. __webpack_require__(116);
  4330. __webpack_require__(118);
  4331. __webpack_require__(120);
  4332. __webpack_require__(89);
  4333. const DEFAULT_SCALE_VALUE = "auto";
  4334. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4335. const DEFAULT_SCALE = 1.0;
  4336. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4337. const DEFAULT_SCALE_DELTA = 1.1;
  4338. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  4339. const MIN_SCALE = 0.1;
  4340. exports.MIN_SCALE = MIN_SCALE;
  4341. const MAX_SCALE = 10.0;
  4342. exports.MAX_SCALE = MAX_SCALE;
  4343. const UNKNOWN_SCALE = 0;
  4344. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4345. const MAX_AUTO_SCALE = 1.25;
  4346. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4347. const SCROLLBAR_PADDING = 40;
  4348. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4349. const VERTICAL_PADDING = 5;
  4350. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4351. const RenderingStates = {
  4352. INITIAL: 0,
  4353. RUNNING: 1,
  4354. PAUSED: 2,
  4355. FINISHED: 3
  4356. };
  4357. exports.RenderingStates = RenderingStates;
  4358. const PresentationModeState = {
  4359. UNKNOWN: 0,
  4360. NORMAL: 1,
  4361. CHANGING: 2,
  4362. FULLSCREEN: 3
  4363. };
  4364. exports.PresentationModeState = PresentationModeState;
  4365. const SidebarView = {
  4366. UNKNOWN: -1,
  4367. NONE: 0,
  4368. THUMBS: 1,
  4369. OUTLINE: 2,
  4370. ATTACHMENTS: 3,
  4371. LAYERS: 4
  4372. };
  4373. exports.SidebarView = SidebarView;
  4374. const TextLayerMode = {
  4375. DISABLE: 0,
  4376. ENABLE: 1,
  4377. ENABLE_PERMISSIONS: 2
  4378. };
  4379. exports.TextLayerMode = TextLayerMode;
  4380. const ScrollMode = {
  4381. UNKNOWN: -1,
  4382. VERTICAL: 0,
  4383. HORIZONTAL: 1,
  4384. WRAPPED: 2,
  4385. PAGE: 3
  4386. };
  4387. exports.ScrollMode = ScrollMode;
  4388. const SpreadMode = {
  4389. UNKNOWN: -1,
  4390. NONE: 0,
  4391. ODD: 1,
  4392. EVEN: 2
  4393. };
  4394. exports.SpreadMode = SpreadMode;
  4395. const CursorTool = {
  4396. SELECT: 0,
  4397. HAND: 1,
  4398. ZOOM: 2
  4399. };
  4400. exports.CursorTool = CursorTool;
  4401. const AutoPrintRegExp = /\bprint\s*\(/;
  4402. exports.AutoPrintRegExp = AutoPrintRegExp;
  4403. class OutputScale {
  4404. constructor() {
  4405. const pixelRatio = window.devicePixelRatio || 1;
  4406. this.sx = pixelRatio;
  4407. this.sy = pixelRatio;
  4408. }
  4409. get scaled() {
  4410. return this.sx !== 1 || this.sy !== 1;
  4411. }
  4412. }
  4413. exports.OutputScale = OutputScale;
  4414. function scrollIntoView(element, spot) {
  4415. let scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4416. let parent = element.offsetParent;
  4417. if (!parent) {
  4418. console.error("offsetParent is not set -- cannot scroll");
  4419. return;
  4420. }
  4421. let offsetY = element.offsetTop + element.clientTop;
  4422. let offsetX = element.offsetLeft + element.clientLeft;
  4423. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  4424. offsetY += parent.offsetTop;
  4425. offsetX += parent.offsetLeft;
  4426. parent = parent.offsetParent;
  4427. if (!parent) {
  4428. return;
  4429. }
  4430. }
  4431. if (spot) {
  4432. if (spot.top !== undefined) {
  4433. offsetY += spot.top;
  4434. }
  4435. if (spot.left !== undefined) {
  4436. offsetX += spot.left;
  4437. parent.scrollLeft = offsetX;
  4438. }
  4439. }
  4440. parent.scrollTop = offsetY;
  4441. }
  4442. function watchScroll(viewAreaElement, callback) {
  4443. const debounceScroll = function (evt) {
  4444. if (rAF) {
  4445. return;
  4446. }
  4447. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4448. rAF = null;
  4449. const currentX = viewAreaElement.scrollLeft;
  4450. const lastX = state.lastX;
  4451. if (currentX !== lastX) {
  4452. state.right = currentX > lastX;
  4453. }
  4454. state.lastX = currentX;
  4455. const currentY = viewAreaElement.scrollTop;
  4456. const lastY = state.lastY;
  4457. if (currentY !== lastY) {
  4458. state.down = currentY > lastY;
  4459. }
  4460. state.lastY = currentY;
  4461. callback(state);
  4462. });
  4463. };
  4464. const state = {
  4465. right: true,
  4466. down: true,
  4467. lastX: viewAreaElement.scrollLeft,
  4468. lastY: viewAreaElement.scrollTop,
  4469. _eventHandler: debounceScroll
  4470. };
  4471. let rAF = null;
  4472. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4473. return state;
  4474. }
  4475. function parseQueryString(query) {
  4476. const params = new Map();
  4477. for (const [key, value] of new URLSearchParams(query)) {
  4478. params.set(key.toLowerCase(), value);
  4479. }
  4480. return params;
  4481. }
  4482. const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  4483. function removeNullCharacters(str) {
  4484. let replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4485. if (typeof str !== "string") {
  4486. console.error(`The argument must be a string.`);
  4487. return str;
  4488. }
  4489. if (replaceInvisible) {
  4490. str = str.replaceAll(InvisibleCharactersRegExp, " ");
  4491. }
  4492. return str.replaceAll("\x00", "");
  4493. }
  4494. function binarySearchFirstItem(items, condition) {
  4495. let start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  4496. let minIndex = start;
  4497. let maxIndex = items.length - 1;
  4498. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4499. return items.length;
  4500. }
  4501. if (condition(items[minIndex])) {
  4502. return minIndex;
  4503. }
  4504. while (minIndex < maxIndex) {
  4505. const currentIndex = minIndex + maxIndex >> 1;
  4506. const currentItem = items[currentIndex];
  4507. if (condition(currentItem)) {
  4508. maxIndex = currentIndex;
  4509. } else {
  4510. minIndex = currentIndex + 1;
  4511. }
  4512. }
  4513. return minIndex;
  4514. }
  4515. function approximateFraction(x) {
  4516. if (Math.floor(x) === x) {
  4517. return [x, 1];
  4518. }
  4519. const xinv = 1 / x;
  4520. const limit = 8;
  4521. if (xinv > limit) {
  4522. return [1, limit];
  4523. } else if (Math.floor(xinv) === xinv) {
  4524. return [1, xinv];
  4525. }
  4526. const x_ = x > 1 ? xinv : x;
  4527. let a = 0,
  4528. b = 1,
  4529. c = 1,
  4530. d = 1;
  4531. while (true) {
  4532. const p = a + c,
  4533. q = b + d;
  4534. if (q > limit) {
  4535. break;
  4536. }
  4537. if (x_ <= p / q) {
  4538. c = p;
  4539. d = q;
  4540. } else {
  4541. a = p;
  4542. b = q;
  4543. }
  4544. }
  4545. let result;
  4546. if (x_ - a / b < c / d - x_) {
  4547. result = x_ === x ? [a, b] : [b, a];
  4548. } else {
  4549. result = x_ === x ? [c, d] : [d, c];
  4550. }
  4551. return result;
  4552. }
  4553. function roundToDivide(x, div) {
  4554. const r = x % div;
  4555. return r === 0 ? x : Math.round(x - r + div);
  4556. }
  4557. function getPageSizeInches(_ref) {
  4558. let {
  4559. view,
  4560. userUnit,
  4561. rotate
  4562. } = _ref;
  4563. const [x1, y1, x2, y2] = view;
  4564. const changeOrientation = rotate % 180 !== 0;
  4565. const width = (x2 - x1) / 72 * userUnit;
  4566. const height = (y2 - y1) / 72 * userUnit;
  4567. return {
  4568. width: changeOrientation ? height : width,
  4569. height: changeOrientation ? width : height
  4570. };
  4571. }
  4572. function backtrackBeforeAllVisibleElements(index, views, top) {
  4573. if (index < 2) {
  4574. return index;
  4575. }
  4576. let elt = views[index].div;
  4577. let pageTop = elt.offsetTop + elt.clientTop;
  4578. if (pageTop >= top) {
  4579. elt = views[index - 1].div;
  4580. pageTop = elt.offsetTop + elt.clientTop;
  4581. }
  4582. for (let i = index - 2; i >= 0; --i) {
  4583. elt = views[i].div;
  4584. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  4585. break;
  4586. }
  4587. index = i;
  4588. }
  4589. return index;
  4590. }
  4591. function getVisibleElements(_ref2) {
  4592. let {
  4593. scrollEl,
  4594. views,
  4595. sortByVisibility = false,
  4596. horizontal = false,
  4597. rtl = false
  4598. } = _ref2;
  4599. const top = scrollEl.scrollTop,
  4600. bottom = top + scrollEl.clientHeight;
  4601. const left = scrollEl.scrollLeft,
  4602. right = left + scrollEl.clientWidth;
  4603. function isElementBottomAfterViewTop(view) {
  4604. const element = view.div;
  4605. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  4606. return elementBottom > top;
  4607. }
  4608. function isElementNextAfterViewHorizontally(view) {
  4609. const element = view.div;
  4610. const elementLeft = element.offsetLeft + element.clientLeft;
  4611. const elementRight = elementLeft + element.clientWidth;
  4612. return rtl ? elementLeft < right : elementRight > left;
  4613. }
  4614. const visible = [],
  4615. ids = new Set(),
  4616. numViews = views.length;
  4617. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  4618. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  4619. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  4620. }
  4621. let lastEdge = horizontal ? right : -1;
  4622. for (let i = firstVisibleElementInd; i < numViews; i++) {
  4623. const view = views[i],
  4624. element = view.div;
  4625. const currentWidth = element.offsetLeft + element.clientLeft;
  4626. const currentHeight = element.offsetTop + element.clientTop;
  4627. const viewWidth = element.clientWidth,
  4628. viewHeight = element.clientHeight;
  4629. const viewRight = currentWidth + viewWidth;
  4630. const viewBottom = currentHeight + viewHeight;
  4631. if (lastEdge === -1) {
  4632. if (viewBottom >= bottom) {
  4633. lastEdge = viewBottom;
  4634. }
  4635. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  4636. break;
  4637. }
  4638. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  4639. continue;
  4640. }
  4641. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  4642. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  4643. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  4644. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  4645. const percent = fractionHeight * fractionWidth * 100 | 0;
  4646. visible.push({
  4647. id: view.id,
  4648. x: currentWidth,
  4649. y: currentHeight,
  4650. view,
  4651. percent,
  4652. widthPercent: fractionWidth * 100 | 0
  4653. });
  4654. ids.add(view.id);
  4655. }
  4656. const first = visible[0],
  4657. last = visible.at(-1);
  4658. if (sortByVisibility) {
  4659. visible.sort(function (a, b) {
  4660. const pc = a.percent - b.percent;
  4661. if (Math.abs(pc) > 0.001) {
  4662. return -pc;
  4663. }
  4664. return a.id - b.id;
  4665. });
  4666. }
  4667. return {
  4668. first,
  4669. last,
  4670. views: visible,
  4671. ids
  4672. };
  4673. }
  4674. function noContextMenuHandler(evt) {
  4675. evt.preventDefault();
  4676. }
  4677. function normalizeWheelEventDirection(evt) {
  4678. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  4679. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  4680. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  4681. delta = -delta;
  4682. }
  4683. return delta;
  4684. }
  4685. function normalizeWheelEventDelta(evt) {
  4686. const deltaMode = evt.deltaMode;
  4687. let delta = normalizeWheelEventDirection(evt);
  4688. const MOUSE_PIXELS_PER_LINE = 30;
  4689. const MOUSE_LINES_PER_PAGE = 30;
  4690. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  4691. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  4692. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  4693. delta /= MOUSE_LINES_PER_PAGE;
  4694. }
  4695. return delta;
  4696. }
  4697. function isValidRotation(angle) {
  4698. return Number.isInteger(angle) && angle % 90 === 0;
  4699. }
  4700. function isValidScrollMode(mode) {
  4701. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  4702. }
  4703. function isValidSpreadMode(mode) {
  4704. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  4705. }
  4706. function isPortraitOrientation(size) {
  4707. return size.width <= size.height;
  4708. }
  4709. const animationStarted = new Promise(function (resolve) {
  4710. window.requestAnimationFrame(resolve);
  4711. });
  4712. exports.animationStarted = animationStarted;
  4713. const docStyle = document.documentElement.style;
  4714. exports.docStyle = docStyle;
  4715. function clamp(v, min, max) {
  4716. return Math.min(Math.max(v, min), max);
  4717. }
  4718. class ProgressBar {
  4719. #classList = null;
  4720. #disableAutoFetchTimeout = null;
  4721. #percent = 0;
  4722. #style = null;
  4723. #visible = true;
  4724. constructor(bar) {
  4725. this.#classList = bar.classList;
  4726. this.#style = bar.style;
  4727. }
  4728. get percent() {
  4729. return this.#percent;
  4730. }
  4731. set percent(val) {
  4732. this.#percent = clamp(val, 0, 100);
  4733. if (isNaN(val)) {
  4734. this.#classList.add("indeterminate");
  4735. return;
  4736. }
  4737. this.#classList.remove("indeterminate");
  4738. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  4739. }
  4740. setWidth(viewer) {
  4741. if (!viewer) {
  4742. return;
  4743. }
  4744. const container = viewer.parentNode;
  4745. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4746. if (scrollbarWidth > 0) {
  4747. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  4748. }
  4749. }
  4750. setDisableAutoFetch() {
  4751. let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 5000;
  4752. if (isNaN(this.#percent)) {
  4753. return;
  4754. }
  4755. if (this.#disableAutoFetchTimeout) {
  4756. clearTimeout(this.#disableAutoFetchTimeout);
  4757. }
  4758. this.show();
  4759. this.#disableAutoFetchTimeout = setTimeout(() => {
  4760. this.#disableAutoFetchTimeout = null;
  4761. this.hide();
  4762. }, delay);
  4763. }
  4764. hide() {
  4765. if (!this.#visible) {
  4766. return;
  4767. }
  4768. this.#visible = false;
  4769. this.#classList.add("hidden");
  4770. }
  4771. show() {
  4772. if (this.#visible) {
  4773. return;
  4774. }
  4775. this.#visible = true;
  4776. this.#classList.remove("hidden");
  4777. }
  4778. }
  4779. exports.ProgressBar = ProgressBar;
  4780. function getActiveOrFocusedElement() {
  4781. let curRoot = document;
  4782. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4783. while (curActiveOrFocused?.shadowRoot) {
  4784. curRoot = curActiveOrFocused.shadowRoot;
  4785. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4786. }
  4787. return curActiveOrFocused;
  4788. }
  4789. function apiPageLayoutToViewerModes(layout) {
  4790. let scrollMode = ScrollMode.VERTICAL,
  4791. spreadMode = SpreadMode.NONE;
  4792. switch (layout) {
  4793. case "SinglePage":
  4794. scrollMode = ScrollMode.PAGE;
  4795. break;
  4796. case "OneColumn":
  4797. break;
  4798. case "TwoPageLeft":
  4799. scrollMode = ScrollMode.PAGE;
  4800. case "TwoColumnLeft":
  4801. spreadMode = SpreadMode.ODD;
  4802. break;
  4803. case "TwoPageRight":
  4804. scrollMode = ScrollMode.PAGE;
  4805. case "TwoColumnRight":
  4806. spreadMode = SpreadMode.EVEN;
  4807. break;
  4808. }
  4809. return {
  4810. scrollMode,
  4811. spreadMode
  4812. };
  4813. }
  4814. function apiPageModeToSidebarView(mode) {
  4815. switch (mode) {
  4816. case "UseNone":
  4817. return SidebarView.NONE;
  4818. case "UseThumbs":
  4819. return SidebarView.THUMBS;
  4820. case "UseOutlines":
  4821. return SidebarView.OUTLINE;
  4822. case "UseAttachments":
  4823. return SidebarView.ATTACHMENTS;
  4824. case "UseOC":
  4825. return SidebarView.LAYERS;
  4826. }
  4827. return SidebarView.NONE;
  4828. }
  4829. function toggleCheckedBtn(button, toggle) {
  4830. let view = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4831. button.classList.toggle("toggled", toggle);
  4832. button.setAttribute("aria-checked", toggle);
  4833. view?.classList.toggle("hidden", !toggle);
  4834. }
  4835. function toggleExpandedBtn(button, toggle) {
  4836. let view = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4837. button.classList.toggle("toggled", toggle);
  4838. button.setAttribute("aria-expanded", toggle);
  4839. view?.classList.toggle("hidden", !toggle);
  4840. }
  4841. /***/ }),
  4842. /* 98 */
  4843. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4844. var $ = __webpack_require__(3);
  4845. var difference = __webpack_require__(99);
  4846. var setMethodAcceptSetLike = __webpack_require__(108);
  4847. $({
  4848. target: 'Set',
  4849. proto: true,
  4850. real: true,
  4851. forced: !setMethodAcceptSetLike('difference')
  4852. }, { difference: difference });
  4853. /***/ }),
  4854. /* 99 */
  4855. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4856. var aSet = __webpack_require__(100);
  4857. var SetHelpers = __webpack_require__(101);
  4858. var clone = __webpack_require__(102);
  4859. var size = __webpack_require__(105);
  4860. var getSetRecord = __webpack_require__(106);
  4861. var iterateSet = __webpack_require__(103);
  4862. var iterateSimple = __webpack_require__(104);
  4863. var has = SetHelpers.has;
  4864. var remove = SetHelpers.remove;
  4865. module.exports = function difference(other) {
  4866. var O = aSet(this);
  4867. var otherRec = getSetRecord(other);
  4868. var result = clone(O);
  4869. if (size(O) <= otherRec.size)
  4870. iterateSet(O, function (e) {
  4871. if (otherRec.includes(e))
  4872. remove(result, e);
  4873. });
  4874. else
  4875. iterateSimple(otherRec.getIterator(), function (e) {
  4876. if (has(O, e))
  4877. remove(result, e);
  4878. });
  4879. return result;
  4880. };
  4881. /***/ }),
  4882. /* 100 */
  4883. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4884. var has = (__webpack_require__(101).has);
  4885. module.exports = function (it) {
  4886. has(it);
  4887. return it;
  4888. };
  4889. /***/ }),
  4890. /* 101 */
  4891. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4892. var uncurryThis = __webpack_require__(14);
  4893. var SetPrototype = Set.prototype;
  4894. module.exports = {
  4895. Set: Set,
  4896. add: uncurryThis(SetPrototype.add),
  4897. has: uncurryThis(SetPrototype.has),
  4898. remove: uncurryThis(SetPrototype['delete']),
  4899. proto: SetPrototype
  4900. };
  4901. /***/ }),
  4902. /* 102 */
  4903. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4904. var SetHelpers = __webpack_require__(101);
  4905. var iterate = __webpack_require__(103);
  4906. var Set = SetHelpers.Set;
  4907. var add = SetHelpers.add;
  4908. module.exports = function (set) {
  4909. var result = new Set();
  4910. iterate(set, function (it) {
  4911. add(result, it);
  4912. });
  4913. return result;
  4914. };
  4915. /***/ }),
  4916. /* 103 */
  4917. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4918. var uncurryThis = __webpack_require__(14);
  4919. var iterateSimple = __webpack_require__(104);
  4920. var SetHelpers = __webpack_require__(101);
  4921. var Set = SetHelpers.Set;
  4922. var SetPrototype = SetHelpers.proto;
  4923. var forEach = uncurryThis(SetPrototype.forEach);
  4924. var keys = uncurryThis(SetPrototype.keys);
  4925. var next = keys(new Set()).next;
  4926. module.exports = function (set, fn, interruptible) {
  4927. return interruptible ? iterateSimple({
  4928. iterator: keys(set),
  4929. next: next
  4930. }, fn) : forEach(set, fn);
  4931. };
  4932. /***/ }),
  4933. /* 104 */
  4934. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4935. var call = __webpack_require__(8);
  4936. module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {
  4937. var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;
  4938. var next = record.next;
  4939. var step, result;
  4940. while (!(step = call(next, iterator)).done) {
  4941. result = fn(step.value);
  4942. if (result !== undefined)
  4943. return result;
  4944. }
  4945. };
  4946. /***/ }),
  4947. /* 105 */
  4948. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4949. var uncurryThisAccessor = __webpack_require__(80);
  4950. var SetHelpers = __webpack_require__(101);
  4951. module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
  4952. return set.size;
  4953. };
  4954. /***/ }),
  4955. /* 106 */
  4956. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4957. var aCallable = __webpack_require__(31);
  4958. var anObject = __webpack_require__(47);
  4959. var call = __webpack_require__(8);
  4960. var toIntegerOrInfinity = __webpack_require__(62);
  4961. var getIteratorDirect = __webpack_require__(107);
  4962. var INVALID_SIZE = 'Invalid size';
  4963. var $RangeError = RangeError;
  4964. var $TypeError = TypeError;
  4965. var max = Math.max;
  4966. var SetRecord = function (set, size, has, keys) {
  4967. this.set = set;
  4968. this.size = size;
  4969. this.has = has;
  4970. this.keys = keys;
  4971. };
  4972. SetRecord.prototype = {
  4973. getIterator: function () {
  4974. return getIteratorDirect(anObject(call(this.keys, this.set)));
  4975. },
  4976. includes: function (it) {
  4977. return call(this.has, this.set, it);
  4978. }
  4979. };
  4980. module.exports = function (obj) {
  4981. anObject(obj);
  4982. var numSize = +obj.size;
  4983. if (numSize !== numSize)
  4984. throw $TypeError(INVALID_SIZE);
  4985. var intSize = toIntegerOrInfinity(numSize);
  4986. if (intSize < 0)
  4987. throw $RangeError(INVALID_SIZE);
  4988. return new SetRecord(obj, max(intSize, 0), aCallable(obj.has), aCallable(obj.keys));
  4989. };
  4990. /***/ }),
  4991. /* 107 */
  4992. /***/ ((module) => {
  4993. module.exports = function (obj) {
  4994. return {
  4995. iterator: obj,
  4996. next: obj.next,
  4997. done: false
  4998. };
  4999. };
  5000. /***/ }),
  5001. /* 108 */
  5002. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5003. var getBuiltIn = __webpack_require__(24);
  5004. var createSetLike = function (size) {
  5005. return {
  5006. size: size,
  5007. has: function () {
  5008. return false;
  5009. },
  5010. keys: function () {
  5011. return {
  5012. next: function () {
  5013. return { done: true };
  5014. }
  5015. };
  5016. }
  5017. };
  5018. };
  5019. module.exports = function (name) {
  5020. var Set = getBuiltIn('Set');
  5021. try {
  5022. new Set()[name](createSetLike(0));
  5023. try {
  5024. new Set()[name](createSetLike(-1));
  5025. return false;
  5026. } catch (error2) {
  5027. return true;
  5028. }
  5029. } catch (error) {
  5030. return false;
  5031. }
  5032. };
  5033. /***/ }),
  5034. /* 109 */
  5035. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5036. var $ = __webpack_require__(3);
  5037. var fails = __webpack_require__(7);
  5038. var intersection = __webpack_require__(110);
  5039. var setMethodAcceptSetLike = __webpack_require__(108);
  5040. var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
  5041. return Array.from(new Set([
  5042. 1,
  5043. 2,
  5044. 3
  5045. ]).intersection(new Set([
  5046. 3,
  5047. 2
  5048. ]))) !== '3,2';
  5049. });
  5050. $({
  5051. target: 'Set',
  5052. proto: true,
  5053. real: true,
  5054. forced: INCORRECT
  5055. }, { intersection: intersection });
  5056. /***/ }),
  5057. /* 110 */
  5058. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5059. var aSet = __webpack_require__(100);
  5060. var SetHelpers = __webpack_require__(101);
  5061. var size = __webpack_require__(105);
  5062. var getSetRecord = __webpack_require__(106);
  5063. var iterateSet = __webpack_require__(103);
  5064. var iterateSimple = __webpack_require__(104);
  5065. var Set = SetHelpers.Set;
  5066. var add = SetHelpers.add;
  5067. var has = SetHelpers.has;
  5068. module.exports = function intersection(other) {
  5069. var O = aSet(this);
  5070. var otherRec = getSetRecord(other);
  5071. var result = new Set();
  5072. if (size(O) > otherRec.size) {
  5073. iterateSimple(otherRec.getIterator(), function (e) {
  5074. if (has(O, e))
  5075. add(result, e);
  5076. });
  5077. } else {
  5078. iterateSet(O, function (e) {
  5079. if (otherRec.includes(e))
  5080. add(result, e);
  5081. });
  5082. }
  5083. return result;
  5084. };
  5085. /***/ }),
  5086. /* 111 */
  5087. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5088. var $ = __webpack_require__(3);
  5089. var isDisjointFrom = __webpack_require__(112);
  5090. var setMethodAcceptSetLike = __webpack_require__(108);
  5091. $({
  5092. target: 'Set',
  5093. proto: true,
  5094. real: true,
  5095. forced: !setMethodAcceptSetLike('isDisjointFrom')
  5096. }, { isDisjointFrom: isDisjointFrom });
  5097. /***/ }),
  5098. /* 112 */
  5099. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5100. var aSet = __webpack_require__(100);
  5101. var has = (__webpack_require__(101).has);
  5102. var size = __webpack_require__(105);
  5103. var getSetRecord = __webpack_require__(106);
  5104. var iterateSet = __webpack_require__(103);
  5105. var iterateSimple = __webpack_require__(104);
  5106. var iteratorClose = __webpack_require__(113);
  5107. module.exports = function isDisjointFrom(other) {
  5108. var O = aSet(this);
  5109. var otherRec = getSetRecord(other);
  5110. if (size(O) <= otherRec.size)
  5111. return iterateSet(O, function (e) {
  5112. if (otherRec.includes(e))
  5113. return false;
  5114. }, true) !== false;
  5115. var iterator = otherRec.getIterator();
  5116. return iterateSimple(iterator, function (e) {
  5117. if (has(O, e))
  5118. return iteratorClose(iterator, 'normal', false);
  5119. }) !== false;
  5120. };
  5121. /***/ }),
  5122. /* 113 */
  5123. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5124. var call = __webpack_require__(8);
  5125. var anObject = __webpack_require__(47);
  5126. var getMethod = __webpack_require__(30);
  5127. module.exports = function (iterator, kind, value) {
  5128. var innerResult, innerError;
  5129. anObject(iterator);
  5130. try {
  5131. innerResult = getMethod(iterator, 'return');
  5132. if (!innerResult) {
  5133. if (kind === 'throw')
  5134. throw value;
  5135. return value;
  5136. }
  5137. innerResult = call(innerResult, iterator);
  5138. } catch (error) {
  5139. innerError = true;
  5140. innerResult = error;
  5141. }
  5142. if (kind === 'throw')
  5143. throw value;
  5144. if (innerError)
  5145. throw innerResult;
  5146. anObject(innerResult);
  5147. return value;
  5148. };
  5149. /***/ }),
  5150. /* 114 */
  5151. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5152. var $ = __webpack_require__(3);
  5153. var isSubsetOf = __webpack_require__(115);
  5154. var setMethodAcceptSetLike = __webpack_require__(108);
  5155. $({
  5156. target: 'Set',
  5157. proto: true,
  5158. real: true,
  5159. forced: !setMethodAcceptSetLike('isSubsetOf')
  5160. }, { isSubsetOf: isSubsetOf });
  5161. /***/ }),
  5162. /* 115 */
  5163. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5164. var aSet = __webpack_require__(100);
  5165. var size = __webpack_require__(105);
  5166. var iterate = __webpack_require__(103);
  5167. var getSetRecord = __webpack_require__(106);
  5168. module.exports = function isSubsetOf(other) {
  5169. var O = aSet(this);
  5170. var otherRec = getSetRecord(other);
  5171. if (size(O) > otherRec.size)
  5172. return false;
  5173. return iterate(O, function (e) {
  5174. if (!otherRec.includes(e))
  5175. return false;
  5176. }, true) !== false;
  5177. };
  5178. /***/ }),
  5179. /* 116 */
  5180. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5181. var $ = __webpack_require__(3);
  5182. var isSupersetOf = __webpack_require__(117);
  5183. var setMethodAcceptSetLike = __webpack_require__(108);
  5184. $({
  5185. target: 'Set',
  5186. proto: true,
  5187. real: true,
  5188. forced: !setMethodAcceptSetLike('isSupersetOf')
  5189. }, { isSupersetOf: isSupersetOf });
  5190. /***/ }),
  5191. /* 117 */
  5192. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5193. var aSet = __webpack_require__(100);
  5194. var has = (__webpack_require__(101).has);
  5195. var size = __webpack_require__(105);
  5196. var getSetRecord = __webpack_require__(106);
  5197. var iterateSimple = __webpack_require__(104);
  5198. var iteratorClose = __webpack_require__(113);
  5199. module.exports = function isSupersetOf(other) {
  5200. var O = aSet(this);
  5201. var otherRec = getSetRecord(other);
  5202. if (size(O) < otherRec.size)
  5203. return false;
  5204. var iterator = otherRec.getIterator();
  5205. return iterateSimple(iterator, function (e) {
  5206. if (!has(O, e))
  5207. return iteratorClose(iterator, 'normal', false);
  5208. }) !== false;
  5209. };
  5210. /***/ }),
  5211. /* 118 */
  5212. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5213. var $ = __webpack_require__(3);
  5214. var symmetricDifference = __webpack_require__(119);
  5215. var setMethodAcceptSetLike = __webpack_require__(108);
  5216. $({
  5217. target: 'Set',
  5218. proto: true,
  5219. real: true,
  5220. forced: !setMethodAcceptSetLike('symmetricDifference')
  5221. }, { symmetricDifference: symmetricDifference });
  5222. /***/ }),
  5223. /* 119 */
  5224. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5225. var aSet = __webpack_require__(100);
  5226. var SetHelpers = __webpack_require__(101);
  5227. var clone = __webpack_require__(102);
  5228. var getSetRecord = __webpack_require__(106);
  5229. var iterateSimple = __webpack_require__(104);
  5230. var add = SetHelpers.add;
  5231. var has = SetHelpers.has;
  5232. var remove = SetHelpers.remove;
  5233. module.exports = function symmetricDifference(other) {
  5234. var O = aSet(this);
  5235. var keysIter = getSetRecord(other).getIterator();
  5236. var result = clone(O);
  5237. iterateSimple(keysIter, function (e) {
  5238. if (has(O, e))
  5239. remove(result, e);
  5240. else
  5241. add(result, e);
  5242. });
  5243. return result;
  5244. };
  5245. /***/ }),
  5246. /* 120 */
  5247. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  5248. var $ = __webpack_require__(3);
  5249. var union = __webpack_require__(121);
  5250. var setMethodAcceptSetLike = __webpack_require__(108);
  5251. $({
  5252. target: 'Set',
  5253. proto: true,
  5254. real: true,
  5255. forced: !setMethodAcceptSetLike('union')
  5256. }, { union: union });
  5257. /***/ }),
  5258. /* 121 */
  5259. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  5260. var aSet = __webpack_require__(100);
  5261. var add = (__webpack_require__(101).add);
  5262. var clone = __webpack_require__(102);
  5263. var getSetRecord = __webpack_require__(106);
  5264. var iterateSimple = __webpack_require__(104);
  5265. module.exports = function union(other) {
  5266. var O = aSet(this);
  5267. var keysIter = getSetRecord(other).getIterator();
  5268. var result = clone(O);
  5269. iterateSimple(keysIter, function (it) {
  5270. add(result, it);
  5271. });
  5272. return result;
  5273. };
  5274. /***/ }),
  5275. /* 122 */
  5276. /***/ ((module) => {
  5277. module.exports = globalThis.pdfjsLib;
  5278. /***/ }),
  5279. /* 123 */
  5280. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5281. Object.defineProperty(exports, "__esModule", ({
  5282. value: true
  5283. }));
  5284. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  5285. __webpack_require__(76);
  5286. const compatibilityParams = Object.create(null);
  5287. exports.compatibilityParams = compatibilityParams;
  5288. {
  5289. const userAgent = navigator.userAgent || "";
  5290. const platform = navigator.platform || "";
  5291. const maxTouchPoints = navigator.maxTouchPoints || 1;
  5292. const isAndroid = /Android/.test(userAgent);
  5293. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  5294. (function checkCanvasSizeLimitation() {
  5295. if (isIOS || isAndroid) {
  5296. compatibilityParams.maxCanvasPixels = 5242880;
  5297. }
  5298. })();
  5299. }
  5300. const OptionKind = {
  5301. VIEWER: 0x02,
  5302. API: 0x04,
  5303. WORKER: 0x08,
  5304. PREFERENCE: 0x80
  5305. };
  5306. exports.OptionKind = OptionKind;
  5307. const defaultOptions = {
  5308. annotationEditorMode: {
  5309. value: 0,
  5310. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5311. },
  5312. annotationMode: {
  5313. value: 2,
  5314. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5315. },
  5316. cursorToolOnLoad: {
  5317. value: 0,
  5318. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5319. },
  5320. defaultZoomDelay: {
  5321. value: 400,
  5322. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5323. },
  5324. defaultZoomValue: {
  5325. value: "",
  5326. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5327. },
  5328. disableHistory: {
  5329. value: false,
  5330. kind: OptionKind.VIEWER
  5331. },
  5332. disablePageLabels: {
  5333. value: false,
  5334. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5335. },
  5336. enablePermissions: {
  5337. value: false,
  5338. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5339. },
  5340. enablePrintAutoRotate: {
  5341. value: true,
  5342. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5343. },
  5344. enableScripting: {
  5345. value: true,
  5346. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5347. },
  5348. enableStampEditor: {
  5349. value: true,
  5350. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5351. },
  5352. externalLinkRel: {
  5353. value: "noopener noreferrer nofollow",
  5354. kind: OptionKind.VIEWER
  5355. },
  5356. externalLinkTarget: {
  5357. value: 0,
  5358. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5359. },
  5360. historyUpdateUrl: {
  5361. value: false,
  5362. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5363. },
  5364. ignoreDestinationZoom: {
  5365. value: false,
  5366. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5367. },
  5368. imageResourcesPath: {
  5369. value: "./images/",
  5370. kind: OptionKind.VIEWER
  5371. },
  5372. maxCanvasPixels: {
  5373. value: 16777216,
  5374. kind: OptionKind.VIEWER
  5375. },
  5376. forcePageColors: {
  5377. value: false,
  5378. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5379. },
  5380. pageColorsBackground: {
  5381. value: "Canvas",
  5382. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5383. },
  5384. pageColorsForeground: {
  5385. value: "CanvasText",
  5386. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5387. },
  5388. pdfBugEnabled: {
  5389. value: false,
  5390. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5391. },
  5392. printResolution: {
  5393. value: 150,
  5394. kind: OptionKind.VIEWER
  5395. },
  5396. sidebarViewOnLoad: {
  5397. value: -1,
  5398. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5399. },
  5400. scrollModeOnLoad: {
  5401. value: -1,
  5402. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5403. },
  5404. spreadModeOnLoad: {
  5405. value: -1,
  5406. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5407. },
  5408. textLayerMode: {
  5409. value: 1,
  5410. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5411. },
  5412. viewerCssTheme: {
  5413. value: 0,
  5414. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5415. },
  5416. viewOnLoad: {
  5417. value: 0,
  5418. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  5419. },
  5420. cMapPacked: {
  5421. value: true,
  5422. kind: OptionKind.API
  5423. },
  5424. cMapUrl: {
  5425. value: "../web/cmaps/",
  5426. kind: OptionKind.API
  5427. },
  5428. disableAutoFetch: {
  5429. value: false,
  5430. kind: OptionKind.API + OptionKind.PREFERENCE
  5431. },
  5432. disableFontFace: {
  5433. value: false,
  5434. kind: OptionKind.API + OptionKind.PREFERENCE
  5435. },
  5436. disableRange: {
  5437. value: false,
  5438. kind: OptionKind.API + OptionKind.PREFERENCE
  5439. },
  5440. disableStream: {
  5441. value: false,
  5442. kind: OptionKind.API + OptionKind.PREFERENCE
  5443. },
  5444. docBaseUrl: {
  5445. value: "",
  5446. kind: OptionKind.API
  5447. },
  5448. enableXfa: {
  5449. value: true,
  5450. kind: OptionKind.API + OptionKind.PREFERENCE
  5451. },
  5452. fontExtraProperties: {
  5453. value: false,
  5454. kind: OptionKind.API
  5455. },
  5456. isEvalSupported: {
  5457. value: true,
  5458. kind: OptionKind.API
  5459. },
  5460. isOffscreenCanvasSupported: {
  5461. value: true,
  5462. kind: OptionKind.API
  5463. },
  5464. maxImageSize: {
  5465. value: -1,
  5466. kind: OptionKind.API
  5467. },
  5468. pdfBug: {
  5469. value: false,
  5470. kind: OptionKind.API
  5471. },
  5472. standardFontDataUrl: {
  5473. value: "../web/standard_fonts/",
  5474. kind: OptionKind.API
  5475. },
  5476. verbosity: {
  5477. value: 1,
  5478. kind: OptionKind.API
  5479. },
  5480. workerPort: {
  5481. value: null,
  5482. kind: OptionKind.WORKER
  5483. },
  5484. workerSrc: {
  5485. value: "../build/pdf.worker.js",
  5486. kind: OptionKind.WORKER
  5487. }
  5488. };
  5489. {
  5490. defaultOptions.defaultUrl = {
  5491. value: "compressed.tracemonkey-pldi-09.pdf",
  5492. kind: OptionKind.VIEWER
  5493. };
  5494. defaultOptions.disablePreferences = {
  5495. value: false,
  5496. kind: OptionKind.VIEWER
  5497. };
  5498. defaultOptions.locale = {
  5499. value: navigator.language || "en-US",
  5500. kind: OptionKind.VIEWER
  5501. };
  5502. defaultOptions.sandboxBundleSrc = {
  5503. value: "../build/pdf.sandbox.js",
  5504. kind: OptionKind.VIEWER
  5505. };
  5506. }
  5507. const userOptions = Object.create(null);
  5508. class AppOptions {
  5509. constructor() {
  5510. throw new Error("Cannot initialize AppOptions.");
  5511. }
  5512. static get(name) {
  5513. const userOption = userOptions[name];
  5514. if (userOption !== undefined) {
  5515. return userOption;
  5516. }
  5517. const defaultOption = defaultOptions[name];
  5518. if (defaultOption !== undefined) {
  5519. return compatibilityParams[name] ?? defaultOption.value;
  5520. }
  5521. return undefined;
  5522. }
  5523. static getAll() {
  5524. let kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5525. const options = Object.create(null);
  5526. for (const name in defaultOptions) {
  5527. const defaultOption = defaultOptions[name];
  5528. if (kind) {
  5529. if ((kind & defaultOption.kind) === 0) {
  5530. continue;
  5531. }
  5532. if (kind === OptionKind.PREFERENCE) {
  5533. const value = defaultOption.value,
  5534. valueType = typeof value;
  5535. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  5536. options[name] = value;
  5537. continue;
  5538. }
  5539. throw new Error(`Invalid type for preference: ${name}`);
  5540. }
  5541. }
  5542. const userOption = userOptions[name];
  5543. options[name] = userOption !== undefined ? userOption : compatibilityParams[name] ?? defaultOption.value;
  5544. }
  5545. return options;
  5546. }
  5547. static set(name, value) {
  5548. userOptions[name] = value;
  5549. }
  5550. static setAll(options) {
  5551. for (const name in options) {
  5552. userOptions[name] = options[name];
  5553. }
  5554. }
  5555. static remove(name) {
  5556. delete userOptions[name];
  5557. }
  5558. }
  5559. exports.AppOptions = AppOptions;
  5560. {
  5561. AppOptions._hasUserOptions = function () {
  5562. return Object.keys(userOptions).length > 0;
  5563. };
  5564. }
  5565. /***/ }),
  5566. /* 124 */
  5567. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5568. Object.defineProperty(exports, "__esModule", ({
  5569. value: true
  5570. }));
  5571. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  5572. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  5573. __webpack_require__(76);
  5574. __webpack_require__(89);
  5575. const WaitOnType = {
  5576. EVENT: "event",
  5577. TIMEOUT: "timeout"
  5578. };
  5579. exports.WaitOnType = WaitOnType;
  5580. function waitOnEventOrTimeout(_ref) {
  5581. let {
  5582. target,
  5583. name,
  5584. delay = 0
  5585. } = _ref;
  5586. return new Promise(function (resolve, reject) {
  5587. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  5588. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  5589. }
  5590. function handler(type) {
  5591. if (target instanceof EventBus) {
  5592. target._off(name, eventHandler);
  5593. } else {
  5594. target.removeEventListener(name, eventHandler);
  5595. }
  5596. if (timeout) {
  5597. clearTimeout(timeout);
  5598. }
  5599. resolve(type);
  5600. }
  5601. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  5602. if (target instanceof EventBus) {
  5603. target._on(name, eventHandler);
  5604. } else {
  5605. target.addEventListener(name, eventHandler);
  5606. }
  5607. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  5608. const timeout = setTimeout(timeoutHandler, delay);
  5609. });
  5610. }
  5611. class EventBus {
  5612. #listeners = Object.create(null);
  5613. on(eventName, listener) {
  5614. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5615. this._on(eventName, listener, {
  5616. external: true,
  5617. once: options?.once
  5618. });
  5619. }
  5620. off(eventName, listener) {
  5621. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5622. this._off(eventName, listener, {
  5623. external: true,
  5624. once: options?.once
  5625. });
  5626. }
  5627. dispatch(eventName, data) {
  5628. const eventListeners = this.#listeners[eventName];
  5629. if (!eventListeners || eventListeners.length === 0) {
  5630. return;
  5631. }
  5632. let externalListeners;
  5633. for (const {
  5634. listener,
  5635. external,
  5636. once
  5637. } of eventListeners.slice(0)) {
  5638. if (once) {
  5639. this._off(eventName, listener);
  5640. }
  5641. if (external) {
  5642. (externalListeners ||= []).push(listener);
  5643. continue;
  5644. }
  5645. listener(data);
  5646. }
  5647. if (externalListeners) {
  5648. for (const listener of externalListeners) {
  5649. listener(data);
  5650. }
  5651. externalListeners = null;
  5652. }
  5653. }
  5654. _on(eventName, listener) {
  5655. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5656. const eventListeners = this.#listeners[eventName] ||= [];
  5657. eventListeners.push({
  5658. listener,
  5659. external: options?.external === true,
  5660. once: options?.once === true
  5661. });
  5662. }
  5663. _off(eventName, listener) {
  5664. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5665. const eventListeners = this.#listeners[eventName];
  5666. if (!eventListeners) {
  5667. return;
  5668. }
  5669. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  5670. if (eventListeners[i].listener === listener) {
  5671. eventListeners.splice(i, 1);
  5672. return;
  5673. }
  5674. }
  5675. }
  5676. }
  5677. exports.EventBus = EventBus;
  5678. class AutomationEventBus extends EventBus {
  5679. dispatch(eventName, data) {
  5680. throw new Error("Not implemented: AutomationEventBus.dispatch");
  5681. }
  5682. }
  5683. exports.AutomationEventBus = AutomationEventBus;
  5684. /***/ }),
  5685. /* 125 */
  5686. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5687. Object.defineProperty(exports, "__esModule", ({
  5688. value: true
  5689. }));
  5690. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  5691. __webpack_require__(76);
  5692. __webpack_require__(89);
  5693. __webpack_require__(2);
  5694. var _ui_utils = __webpack_require__(97);
  5695. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  5696. const LinkTarget = {
  5697. NONE: 0,
  5698. SELF: 1,
  5699. BLANK: 2,
  5700. PARENT: 3,
  5701. TOP: 4
  5702. };
  5703. exports.LinkTarget = LinkTarget;
  5704. function addLinkAttributes(link) {
  5705. let {
  5706. url,
  5707. target,
  5708. rel,
  5709. enabled = true
  5710. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5711. if (!url || typeof url !== "string") {
  5712. throw new Error('A valid "url" parameter must provided.');
  5713. }
  5714. const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  5715. if (enabled) {
  5716. link.href = link.title = urlNullRemoved;
  5717. } else {
  5718. link.href = "";
  5719. link.title = `Disabled: ${urlNullRemoved}`;
  5720. link.onclick = () => {
  5721. return false;
  5722. };
  5723. }
  5724. let targetStr = "";
  5725. switch (target) {
  5726. case LinkTarget.NONE:
  5727. break;
  5728. case LinkTarget.SELF:
  5729. targetStr = "_self";
  5730. break;
  5731. case LinkTarget.BLANK:
  5732. targetStr = "_blank";
  5733. break;
  5734. case LinkTarget.PARENT:
  5735. targetStr = "_parent";
  5736. break;
  5737. case LinkTarget.TOP:
  5738. targetStr = "_top";
  5739. break;
  5740. }
  5741. link.target = targetStr;
  5742. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  5743. }
  5744. class PDFLinkService {
  5745. #pagesRefCache = new Map();
  5746. constructor() {
  5747. let {
  5748. eventBus,
  5749. externalLinkTarget = null,
  5750. externalLinkRel = null,
  5751. ignoreDestinationZoom = false
  5752. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5753. this.eventBus = eventBus;
  5754. this.externalLinkTarget = externalLinkTarget;
  5755. this.externalLinkRel = externalLinkRel;
  5756. this.externalLinkEnabled = true;
  5757. this._ignoreDestinationZoom = ignoreDestinationZoom;
  5758. this.baseUrl = null;
  5759. this.pdfDocument = null;
  5760. this.pdfViewer = null;
  5761. this.pdfHistory = null;
  5762. }
  5763. setDocument(pdfDocument) {
  5764. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5765. this.baseUrl = baseUrl;
  5766. this.pdfDocument = pdfDocument;
  5767. this.#pagesRefCache.clear();
  5768. }
  5769. setViewer(pdfViewer) {
  5770. this.pdfViewer = pdfViewer;
  5771. }
  5772. setHistory(pdfHistory) {
  5773. this.pdfHistory = pdfHistory;
  5774. }
  5775. get pagesCount() {
  5776. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  5777. }
  5778. get page() {
  5779. return this.pdfViewer.currentPageNumber;
  5780. }
  5781. set page(value) {
  5782. this.pdfViewer.currentPageNumber = value;
  5783. }
  5784. get rotation() {
  5785. return this.pdfViewer.pagesRotation;
  5786. }
  5787. set rotation(value) {
  5788. this.pdfViewer.pagesRotation = value;
  5789. }
  5790. get isInPresentationMode() {
  5791. return this.pdfViewer.isInPresentationMode;
  5792. }
  5793. #goToDestinationHelper(rawDest) {
  5794. let namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5795. let explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  5796. const destRef = explicitDest[0];
  5797. let pageNumber;
  5798. if (typeof destRef === "object" && destRef !== null) {
  5799. pageNumber = this._cachedPageNumber(destRef);
  5800. if (!pageNumber) {
  5801. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  5802. this.cachePageRef(pageIndex + 1, destRef);
  5803. this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
  5804. }).catch(() => {
  5805. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
  5806. });
  5807. return;
  5808. }
  5809. } else if (Number.isInteger(destRef)) {
  5810. pageNumber = destRef + 1;
  5811. } else {
  5812. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
  5813. return;
  5814. }
  5815. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  5816. console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
  5817. return;
  5818. }
  5819. if (this.pdfHistory) {
  5820. this.pdfHistory.pushCurrentPosition();
  5821. this.pdfHistory.push({
  5822. namedDest,
  5823. explicitDest,
  5824. pageNumber
  5825. });
  5826. }
  5827. this.pdfViewer.scrollPageIntoView({
  5828. pageNumber,
  5829. destArray: explicitDest,
  5830. ignoreDestinationZoom: this._ignoreDestinationZoom
  5831. });
  5832. }
  5833. async goToDestination(dest) {
  5834. if (!this.pdfDocument) {
  5835. return;
  5836. }
  5837. let namedDest, explicitDest;
  5838. if (typeof dest === "string") {
  5839. namedDest = dest;
  5840. explicitDest = await this.pdfDocument.getDestination(dest);
  5841. } else {
  5842. namedDest = null;
  5843. explicitDest = await dest;
  5844. }
  5845. if (!Array.isArray(explicitDest)) {
  5846. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
  5847. return;
  5848. }
  5849. this.#goToDestinationHelper(dest, namedDest, explicitDest);
  5850. }
  5851. goToPage(val) {
  5852. if (!this.pdfDocument) {
  5853. return;
  5854. }
  5855. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  5856. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  5857. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  5858. return;
  5859. }
  5860. if (this.pdfHistory) {
  5861. this.pdfHistory.pushCurrentPosition();
  5862. this.pdfHistory.pushPage(pageNumber);
  5863. }
  5864. this.pdfViewer.scrollPageIntoView({
  5865. pageNumber
  5866. });
  5867. }
  5868. addLinkAttributes(link, url) {
  5869. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5870. addLinkAttributes(link, {
  5871. url,
  5872. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  5873. rel: this.externalLinkRel,
  5874. enabled: this.externalLinkEnabled
  5875. });
  5876. }
  5877. getDestinationHash(dest) {
  5878. if (typeof dest === "string") {
  5879. if (dest.length > 0) {
  5880. return this.getAnchorUrl("#" + escape(dest));
  5881. }
  5882. } else if (Array.isArray(dest)) {
  5883. const str = JSON.stringify(dest);
  5884. if (str.length > 0) {
  5885. return this.getAnchorUrl("#" + escape(str));
  5886. }
  5887. }
  5888. return this.getAnchorUrl("");
  5889. }
  5890. getAnchorUrl(anchor) {
  5891. return this.baseUrl ? this.baseUrl + anchor : anchor;
  5892. }
  5893. setHash(hash) {
  5894. if (!this.pdfDocument) {
  5895. return;
  5896. }
  5897. let pageNumber, dest;
  5898. if (hash.includes("=")) {
  5899. const params = (0, _ui_utils.parseQueryString)(hash);
  5900. if (params.has("search")) {
  5901. const query = params.get("search").replaceAll('"', ""),
  5902. phrase = params.get("phrase") === "true";
  5903. this.eventBus.dispatch("findfromurlhash", {
  5904. source: this,
  5905. query: phrase ? query : query.match(/\S+/g)
  5906. });
  5907. }
  5908. if (params.has("page")) {
  5909. pageNumber = params.get("page") | 0 || 1;
  5910. }
  5911. if (params.has("zoom")) {
  5912. const zoomArgs = params.get("zoom").split(",");
  5913. const zoomArg = zoomArgs[0];
  5914. const zoomArgNumber = parseFloat(zoomArg);
  5915. if (!zoomArg.includes("Fit")) {
  5916. dest = [null, {
  5917. name: "XYZ"
  5918. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  5919. } else if (zoomArg === "Fit" || zoomArg === "FitB") {
  5920. dest = [null, {
  5921. name: zoomArg
  5922. }];
  5923. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  5924. dest = [null, {
  5925. name: zoomArg
  5926. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  5927. } else if (zoomArg === "FitR") {
  5928. if (zoomArgs.length !== 5) {
  5929. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  5930. } else {
  5931. dest = [null, {
  5932. name: zoomArg
  5933. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  5934. }
  5935. } else {
  5936. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  5937. }
  5938. }
  5939. if (dest) {
  5940. this.pdfViewer.scrollPageIntoView({
  5941. pageNumber: pageNumber || this.page,
  5942. destArray: dest,
  5943. allowNegativeOffset: true
  5944. });
  5945. } else if (pageNumber) {
  5946. this.page = pageNumber;
  5947. }
  5948. if (params.has("pagemode")) {
  5949. this.eventBus.dispatch("pagemode", {
  5950. source: this,
  5951. mode: params.get("pagemode")
  5952. });
  5953. }
  5954. if (params.has("nameddest")) {
  5955. this.goToDestination(params.get("nameddest"));
  5956. }
  5957. } else {
  5958. dest = unescape(hash);
  5959. try {
  5960. dest = JSON.parse(dest);
  5961. if (!Array.isArray(dest)) {
  5962. dest = dest.toString();
  5963. }
  5964. } catch {}
  5965. if (typeof dest === "string" || PDFLinkService.#isValidExplicitDestination(dest)) {
  5966. this.goToDestination(dest);
  5967. return;
  5968. }
  5969. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  5970. }
  5971. }
  5972. executeNamedAction(action) {
  5973. switch (action) {
  5974. case "GoBack":
  5975. this.pdfHistory?.back();
  5976. break;
  5977. case "GoForward":
  5978. this.pdfHistory?.forward();
  5979. break;
  5980. case "NextPage":
  5981. this.pdfViewer.nextPage();
  5982. break;
  5983. case "PrevPage":
  5984. this.pdfViewer.previousPage();
  5985. break;
  5986. case "LastPage":
  5987. this.page = this.pagesCount;
  5988. break;
  5989. case "FirstPage":
  5990. this.page = 1;
  5991. break;
  5992. default:
  5993. break;
  5994. }
  5995. this.eventBus.dispatch("namedaction", {
  5996. source: this,
  5997. action
  5998. });
  5999. }
  6000. async executeSetOCGState(action) {
  6001. const pdfDocument = this.pdfDocument;
  6002. const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  6003. if (pdfDocument !== this.pdfDocument) {
  6004. return;
  6005. }
  6006. let operator;
  6007. for (const elem of action.state) {
  6008. switch (elem) {
  6009. case "ON":
  6010. case "OFF":
  6011. case "Toggle":
  6012. operator = elem;
  6013. continue;
  6014. }
  6015. switch (operator) {
  6016. case "ON":
  6017. optionalContentConfig.setVisibility(elem, true);
  6018. break;
  6019. case "OFF":
  6020. optionalContentConfig.setVisibility(elem, false);
  6021. break;
  6022. case "Toggle":
  6023. const group = optionalContentConfig.getGroup(elem);
  6024. if (group) {
  6025. optionalContentConfig.setVisibility(elem, !group.visible);
  6026. }
  6027. break;
  6028. }
  6029. }
  6030. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  6031. }
  6032. cachePageRef(pageNum, pageRef) {
  6033. if (!pageRef) {
  6034. return;
  6035. }
  6036. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  6037. this.#pagesRefCache.set(refStr, pageNum);
  6038. }
  6039. _cachedPageNumber(pageRef) {
  6040. if (!pageRef) {
  6041. return null;
  6042. }
  6043. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  6044. return this.#pagesRefCache.get(refStr) || null;
  6045. }
  6046. static #isValidExplicitDestination(dest) {
  6047. if (!Array.isArray(dest)) {
  6048. return false;
  6049. }
  6050. const destLength = dest.length;
  6051. if (destLength < 2) {
  6052. return false;
  6053. }
  6054. const page = dest[0];
  6055. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6056. return false;
  6057. }
  6058. const zoom = dest[1];
  6059. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  6060. return false;
  6061. }
  6062. let allowNull = true;
  6063. switch (zoom.name) {
  6064. case "XYZ":
  6065. if (destLength !== 5) {
  6066. return false;
  6067. }
  6068. break;
  6069. case "Fit":
  6070. case "FitB":
  6071. return destLength === 2;
  6072. case "FitH":
  6073. case "FitBH":
  6074. case "FitV":
  6075. case "FitBV":
  6076. if (destLength !== 3) {
  6077. return false;
  6078. }
  6079. break;
  6080. case "FitR":
  6081. if (destLength !== 6) {
  6082. return false;
  6083. }
  6084. allowNull = false;
  6085. break;
  6086. default:
  6087. return false;
  6088. }
  6089. for (let i = 2; i < destLength; i++) {
  6090. const param = dest[i];
  6091. if (!(typeof param === "number" || allowNull && param === null)) {
  6092. return false;
  6093. }
  6094. }
  6095. return true;
  6096. }
  6097. }
  6098. exports.PDFLinkService = PDFLinkService;
  6099. class SimpleLinkService {
  6100. constructor() {
  6101. this.externalLinkEnabled = true;
  6102. }
  6103. get pagesCount() {
  6104. return 0;
  6105. }
  6106. get page() {
  6107. return 0;
  6108. }
  6109. set page(value) {}
  6110. get rotation() {
  6111. return 0;
  6112. }
  6113. set rotation(value) {}
  6114. get isInPresentationMode() {
  6115. return false;
  6116. }
  6117. async goToDestination(dest) {}
  6118. goToPage(val) {}
  6119. addLinkAttributes(link, url) {
  6120. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6121. addLinkAttributes(link, {
  6122. url,
  6123. enabled: this.externalLinkEnabled
  6124. });
  6125. }
  6126. getDestinationHash(dest) {
  6127. return "#";
  6128. }
  6129. getAnchorUrl(hash) {
  6130. return "#";
  6131. }
  6132. setHash(hash) {}
  6133. executeNamedAction(action) {}
  6134. executeSetOCGState(action) {}
  6135. cachePageRef(pageNum, pageRef) {}
  6136. }
  6137. exports.SimpleLinkService = SimpleLinkService;
  6138. /***/ }),
  6139. /* 126 */
  6140. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6141. Object.defineProperty(exports, "__esModule", ({
  6142. value: true
  6143. }));
  6144. exports.AnnotationEditorParams = void 0;
  6145. var _pdfjsLib = __webpack_require__(122);
  6146. class AnnotationEditorParams {
  6147. constructor(options, eventBus) {
  6148. this.eventBus = eventBus;
  6149. this.#bindListeners(options);
  6150. }
  6151. #bindListeners(_ref) {
  6152. let {
  6153. editorFreeTextFontSize,
  6154. editorFreeTextColor,
  6155. editorInkColor,
  6156. editorInkThickness,
  6157. editorInkOpacity,
  6158. editorStampAddImage
  6159. } = _ref;
  6160. const dispatchEvent = (typeStr, value) => {
  6161. this.eventBus.dispatch("switchannotationeditorparams", {
  6162. source: this,
  6163. type: _pdfjsLib.AnnotationEditorParamsType[typeStr],
  6164. value
  6165. });
  6166. };
  6167. editorFreeTextFontSize.addEventListener("input", function () {
  6168. dispatchEvent("FREETEXT_SIZE", this.valueAsNumber);
  6169. });
  6170. editorFreeTextColor.addEventListener("input", function () {
  6171. dispatchEvent("FREETEXT_COLOR", this.value);
  6172. });
  6173. editorInkColor.addEventListener("input", function () {
  6174. dispatchEvent("INK_COLOR", this.value);
  6175. });
  6176. editorInkThickness.addEventListener("input", function () {
  6177. dispatchEvent("INK_THICKNESS", this.valueAsNumber);
  6178. });
  6179. editorInkOpacity.addEventListener("input", function () {
  6180. dispatchEvent("INK_OPACITY", this.valueAsNumber);
  6181. });
  6182. editorStampAddImage.addEventListener("click", () => {
  6183. dispatchEvent("CREATE");
  6184. });
  6185. this.eventBus._on("annotationeditorparamschanged", evt => {
  6186. for (const [type, value] of evt.details) {
  6187. switch (type) {
  6188. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE:
  6189. editorFreeTextFontSize.value = value;
  6190. break;
  6191. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR:
  6192. editorFreeTextColor.value = value;
  6193. break;
  6194. case _pdfjsLib.AnnotationEditorParamsType.INK_COLOR:
  6195. editorInkColor.value = value;
  6196. break;
  6197. case _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS:
  6198. editorInkThickness.value = value;
  6199. break;
  6200. case _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY:
  6201. editorInkOpacity.value = value;
  6202. break;
  6203. }
  6204. }
  6205. });
  6206. }
  6207. }
  6208. exports.AnnotationEditorParams = AnnotationEditorParams;
  6209. /***/ }),
  6210. /* 127 */
  6211. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6212. Object.defineProperty(exports, "__esModule", ({
  6213. value: true
  6214. }));
  6215. exports.OverlayManager = void 0;
  6216. __webpack_require__(76);
  6217. class OverlayManager {
  6218. #overlays = new WeakMap();
  6219. #active = null;
  6220. get active() {
  6221. return this.#active;
  6222. }
  6223. async register(dialog) {
  6224. let canForceClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6225. if (typeof dialog !== "object") {
  6226. throw new Error("Not enough parameters.");
  6227. } else if (this.#overlays.has(dialog)) {
  6228. throw new Error("The overlay is already registered.");
  6229. }
  6230. this.#overlays.set(dialog, {
  6231. canForceClose
  6232. });
  6233. dialog.addEventListener("cancel", evt => {
  6234. this.#active = null;
  6235. });
  6236. }
  6237. async open(dialog) {
  6238. if (!this.#overlays.has(dialog)) {
  6239. throw new Error("The overlay does not exist.");
  6240. } else if (this.#active) {
  6241. if (this.#active === dialog) {
  6242. throw new Error("The overlay is already active.");
  6243. } else if (this.#overlays.get(dialog).canForceClose) {
  6244. await this.close();
  6245. } else {
  6246. throw new Error("Another overlay is currently active.");
  6247. }
  6248. }
  6249. this.#active = dialog;
  6250. dialog.showModal();
  6251. }
  6252. async close() {
  6253. let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.#active;
  6254. if (!this.#overlays.has(dialog)) {
  6255. throw new Error("The overlay does not exist.");
  6256. } else if (!this.#active) {
  6257. throw new Error("The overlay is currently not active.");
  6258. } else if (this.#active !== dialog) {
  6259. throw new Error("Another overlay is currently active.");
  6260. }
  6261. dialog.close();
  6262. this.#active = null;
  6263. }
  6264. }
  6265. exports.OverlayManager = OverlayManager;
  6266. /***/ }),
  6267. /* 128 */
  6268. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6269. Object.defineProperty(exports, "__esModule", ({
  6270. value: true
  6271. }));
  6272. exports.PasswordPrompt = void 0;
  6273. __webpack_require__(76);
  6274. var _pdfjsLib = __webpack_require__(122);
  6275. class PasswordPrompt {
  6276. #activeCapability = null;
  6277. #updateCallback = null;
  6278. #reason = null;
  6279. constructor(options, overlayManager, l10n) {
  6280. let isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6281. this.dialog = options.dialog;
  6282. this.label = options.label;
  6283. this.input = options.input;
  6284. this.submitButton = options.submitButton;
  6285. this.cancelButton = options.cancelButton;
  6286. this.overlayManager = overlayManager;
  6287. this.l10n = l10n;
  6288. this._isViewerEmbedded = isViewerEmbedded;
  6289. this.submitButton.addEventListener("click", this.#verify.bind(this));
  6290. this.cancelButton.addEventListener("click", this.close.bind(this));
  6291. this.input.addEventListener("keydown", e => {
  6292. if (e.keyCode === 13) {
  6293. this.#verify();
  6294. }
  6295. });
  6296. this.overlayManager.register(this.dialog, true);
  6297. this.dialog.addEventListener("close", this.#cancel.bind(this));
  6298. }
  6299. async open() {
  6300. if (this.#activeCapability) {
  6301. await this.#activeCapability.promise;
  6302. }
  6303. this.#activeCapability = new _pdfjsLib.PromiseCapability();
  6304. try {
  6305. await this.overlayManager.open(this.dialog);
  6306. } catch (ex) {
  6307. this.#activeCapability.resolve();
  6308. throw ex;
  6309. }
  6310. const passwordIncorrect = this.#reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
  6311. if (!this._isViewerEmbedded || passwordIncorrect) {
  6312. this.input.focus();
  6313. }
  6314. this.label.textContent = await this.l10n.get(`password_${passwordIncorrect ? "invalid" : "label"}`);
  6315. }
  6316. async close() {
  6317. if (this.overlayManager.active === this.dialog) {
  6318. this.overlayManager.close(this.dialog);
  6319. }
  6320. }
  6321. #verify() {
  6322. const password = this.input.value;
  6323. if (password?.length > 0) {
  6324. this.#invokeCallback(password);
  6325. }
  6326. }
  6327. #cancel() {
  6328. this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  6329. this.#activeCapability.resolve();
  6330. }
  6331. #invokeCallback(password) {
  6332. if (!this.#updateCallback) {
  6333. return;
  6334. }
  6335. this.close();
  6336. this.input.value = "";
  6337. this.#updateCallback(password);
  6338. this.#updateCallback = null;
  6339. }
  6340. async setUpdateCallback(updateCallback, reason) {
  6341. if (this.#activeCapability) {
  6342. await this.#activeCapability.promise;
  6343. }
  6344. this.#updateCallback = updateCallback;
  6345. this.#reason = reason;
  6346. }
  6347. }
  6348. exports.PasswordPrompt = PasswordPrompt;
  6349. /***/ }),
  6350. /* 129 */
  6351. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6352. Object.defineProperty(exports, "__esModule", ({
  6353. value: true
  6354. }));
  6355. exports.PDFAttachmentViewer = void 0;
  6356. var _pdfjsLib = __webpack_require__(122);
  6357. var _base_tree_viewer = __webpack_require__(130);
  6358. var _event_utils = __webpack_require__(124);
  6359. class PDFAttachmentViewer extends _base_tree_viewer.BaseTreeViewer {
  6360. constructor(options) {
  6361. super(options);
  6362. this.downloadManager = options.downloadManager;
  6363. this.eventBus._on("fileattachmentannotation", this.#appendAttachment.bind(this));
  6364. }
  6365. reset() {
  6366. let keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6367. super.reset();
  6368. this._attachments = null;
  6369. if (!keepRenderedCapability) {
  6370. this._renderedCapability = new _pdfjsLib.PromiseCapability();
  6371. }
  6372. this._pendingDispatchEvent = false;
  6373. }
  6374. async _dispatchEvent(attachmentsCount) {
  6375. this._renderedCapability.resolve();
  6376. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  6377. this._pendingDispatchEvent = true;
  6378. await (0, _event_utils.waitOnEventOrTimeout)({
  6379. target: this.eventBus,
  6380. name: "annotationlayerrendered",
  6381. delay: 1000
  6382. });
  6383. if (!this._pendingDispatchEvent) {
  6384. return;
  6385. }
  6386. }
  6387. this._pendingDispatchEvent = false;
  6388. this.eventBus.dispatch("attachmentsloaded", {
  6389. source: this,
  6390. attachmentsCount
  6391. });
  6392. }
  6393. _bindLink(element, _ref) {
  6394. let {
  6395. content,
  6396. filename
  6397. } = _ref;
  6398. element.onclick = () => {
  6399. this.downloadManager.openOrDownloadData(element, content, filename);
  6400. return false;
  6401. };
  6402. }
  6403. render(_ref2) {
  6404. let {
  6405. attachments,
  6406. keepRenderedCapability = false
  6407. } = _ref2;
  6408. if (this._attachments) {
  6409. this.reset(keepRenderedCapability);
  6410. }
  6411. this._attachments = attachments || null;
  6412. if (!attachments) {
  6413. this._dispatchEvent(0);
  6414. return;
  6415. }
  6416. const fragment = document.createDocumentFragment();
  6417. let attachmentsCount = 0;
  6418. for (const name in attachments) {
  6419. const item = attachments[name];
  6420. const content = item.content,
  6421. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename, true);
  6422. const div = document.createElement("div");
  6423. div.className = "treeItem";
  6424. const element = document.createElement("a");
  6425. this._bindLink(element, {
  6426. content,
  6427. filename
  6428. });
  6429. element.textContent = this._normalizeTextContent(filename);
  6430. div.append(element);
  6431. fragment.append(div);
  6432. attachmentsCount++;
  6433. }
  6434. this._finishRendering(fragment, attachmentsCount);
  6435. }
  6436. #appendAttachment(_ref3) {
  6437. let {
  6438. filename,
  6439. content
  6440. } = _ref3;
  6441. const renderedPromise = this._renderedCapability.promise;
  6442. renderedPromise.then(() => {
  6443. if (renderedPromise !== this._renderedCapability.promise) {
  6444. return;
  6445. }
  6446. const attachments = this._attachments || Object.create(null);
  6447. for (const name in attachments) {
  6448. if (filename === name) {
  6449. return;
  6450. }
  6451. }
  6452. attachments[filename] = {
  6453. filename,
  6454. content
  6455. };
  6456. this.render({
  6457. attachments,
  6458. keepRenderedCapability: true
  6459. });
  6460. });
  6461. }
  6462. }
  6463. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  6464. /***/ }),
  6465. /* 130 */
  6466. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6467. Object.defineProperty(exports, "__esModule", ({
  6468. value: true
  6469. }));
  6470. exports.BaseTreeViewer = void 0;
  6471. __webpack_require__(76);
  6472. var _ui_utils = __webpack_require__(97);
  6473. const TREEITEM_OFFSET_TOP = -100;
  6474. const TREEITEM_SELECTED_CLASS = "selected";
  6475. class BaseTreeViewer {
  6476. constructor(options) {
  6477. if (this.constructor === BaseTreeViewer) {
  6478. throw new Error("Cannot initialize BaseTreeViewer.");
  6479. }
  6480. this.container = options.container;
  6481. this.eventBus = options.eventBus;
  6482. this.reset();
  6483. }
  6484. reset() {
  6485. this._pdfDocument = null;
  6486. this._lastToggleIsShow = true;
  6487. this._currentTreeItem = null;
  6488. this.container.textContent = "";
  6489. this.container.classList.remove("treeWithDeepNesting");
  6490. }
  6491. _dispatchEvent(count) {
  6492. throw new Error("Not implemented: _dispatchEvent");
  6493. }
  6494. _bindLink(element, params) {
  6495. throw new Error("Not implemented: _bindLink");
  6496. }
  6497. _normalizeTextContent(str) {
  6498. return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013";
  6499. }
  6500. _addToggleButton(div) {
  6501. let hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6502. const toggler = document.createElement("div");
  6503. toggler.className = "treeItemToggler";
  6504. if (hidden) {
  6505. toggler.classList.add("treeItemsHidden");
  6506. }
  6507. toggler.onclick = evt => {
  6508. evt.stopPropagation();
  6509. toggler.classList.toggle("treeItemsHidden");
  6510. if (evt.shiftKey) {
  6511. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  6512. this._toggleTreeItem(div, shouldShowAll);
  6513. }
  6514. };
  6515. div.prepend(toggler);
  6516. }
  6517. _toggleTreeItem(root) {
  6518. let show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6519. this._lastToggleIsShow = show;
  6520. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  6521. toggler.classList.toggle("treeItemsHidden", !show);
  6522. }
  6523. }
  6524. _toggleAllTreeItems() {
  6525. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  6526. }
  6527. _finishRendering(fragment, count) {
  6528. let hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6529. if (hasAnyNesting) {
  6530. this.container.classList.add("treeWithDeepNesting");
  6531. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  6532. }
  6533. this.container.append(fragment);
  6534. this._dispatchEvent(count);
  6535. }
  6536. render(params) {
  6537. throw new Error("Not implemented: render");
  6538. }
  6539. _updateCurrentTreeItem() {
  6540. let treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6541. if (this._currentTreeItem) {
  6542. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  6543. this._currentTreeItem = null;
  6544. }
  6545. if (treeItem) {
  6546. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  6547. this._currentTreeItem = treeItem;
  6548. }
  6549. }
  6550. _scrollToCurrentTreeItem(treeItem) {
  6551. if (!treeItem) {
  6552. return;
  6553. }
  6554. let currentNode = treeItem.parentNode;
  6555. while (currentNode && currentNode !== this.container) {
  6556. if (currentNode.classList.contains("treeItem")) {
  6557. const toggler = currentNode.firstElementChild;
  6558. toggler?.classList.remove("treeItemsHidden");
  6559. }
  6560. currentNode = currentNode.parentNode;
  6561. }
  6562. this._updateCurrentTreeItem(treeItem);
  6563. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  6564. }
  6565. }
  6566. exports.BaseTreeViewer = BaseTreeViewer;
  6567. /***/ }),
  6568. /* 131 */
  6569. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6570. Object.defineProperty(exports, "__esModule", ({
  6571. value: true
  6572. }));
  6573. exports.PDFCursorTools = void 0;
  6574. var _pdfjsLib = __webpack_require__(122);
  6575. var _ui_utils = __webpack_require__(97);
  6576. var _grab_to_pan = __webpack_require__(132);
  6577. class PDFCursorTools {
  6578. #active = _ui_utils.CursorTool.SELECT;
  6579. #prevActive = null;
  6580. constructor(_ref) {
  6581. let {
  6582. container,
  6583. eventBus,
  6584. cursorToolOnLoad = _ui_utils.CursorTool.SELECT
  6585. } = _ref;
  6586. this.container = container;
  6587. this.eventBus = eventBus;
  6588. this.#addEventListeners();
  6589. Promise.resolve().then(() => {
  6590. this.switchTool(cursorToolOnLoad);
  6591. });
  6592. }
  6593. get activeTool() {
  6594. return this.#active;
  6595. }
  6596. switchTool(tool) {
  6597. if (this.#prevActive !== null) {
  6598. return;
  6599. }
  6600. if (tool === this.#active) {
  6601. return;
  6602. }
  6603. const disableActiveTool = () => {
  6604. switch (this.#active) {
  6605. case _ui_utils.CursorTool.SELECT:
  6606. break;
  6607. case _ui_utils.CursorTool.HAND:
  6608. this._handTool.deactivate();
  6609. break;
  6610. case _ui_utils.CursorTool.ZOOM:
  6611. }
  6612. };
  6613. switch (tool) {
  6614. case _ui_utils.CursorTool.SELECT:
  6615. disableActiveTool();
  6616. break;
  6617. case _ui_utils.CursorTool.HAND:
  6618. disableActiveTool();
  6619. this._handTool.activate();
  6620. break;
  6621. case _ui_utils.CursorTool.ZOOM:
  6622. default:
  6623. console.error(`switchTool: "${tool}" is an unsupported value.`);
  6624. return;
  6625. }
  6626. this.#active = tool;
  6627. this.eventBus.dispatch("cursortoolchanged", {
  6628. source: this,
  6629. tool
  6630. });
  6631. }
  6632. #addEventListeners() {
  6633. this.eventBus._on("switchcursortool", evt => {
  6634. this.switchTool(evt.tool);
  6635. });
  6636. let annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE,
  6637. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  6638. const disableActive = () => {
  6639. const prevActive = this.#active;
  6640. this.switchTool(_ui_utils.CursorTool.SELECT);
  6641. this.#prevActive ??= prevActive;
  6642. };
  6643. const enableActive = () => {
  6644. const prevActive = this.#prevActive;
  6645. if (prevActive !== null && annotationEditorMode === _pdfjsLib.AnnotationEditorType.NONE && presentationModeState === _ui_utils.PresentationModeState.NORMAL) {
  6646. this.#prevActive = null;
  6647. this.switchTool(prevActive);
  6648. }
  6649. };
  6650. this.eventBus._on("secondarytoolbarreset", evt => {
  6651. if (this.#prevActive !== null) {
  6652. annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  6653. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  6654. enableActive();
  6655. }
  6656. });
  6657. this.eventBus._on("annotationeditormodechanged", _ref2 => {
  6658. let {
  6659. mode
  6660. } = _ref2;
  6661. annotationEditorMode = mode;
  6662. if (mode === _pdfjsLib.AnnotationEditorType.NONE) {
  6663. enableActive();
  6664. } else {
  6665. disableActive();
  6666. }
  6667. });
  6668. this.eventBus._on("presentationmodechanged", _ref3 => {
  6669. let {
  6670. state
  6671. } = _ref3;
  6672. presentationModeState = state;
  6673. if (state === _ui_utils.PresentationModeState.NORMAL) {
  6674. enableActive();
  6675. } else if (state === _ui_utils.PresentationModeState.FULLSCREEN) {
  6676. disableActive();
  6677. }
  6678. });
  6679. }
  6680. get _handTool() {
  6681. return (0, _pdfjsLib.shadow)(this, "_handTool", new _grab_to_pan.GrabToPan({
  6682. element: this.container
  6683. }));
  6684. }
  6685. }
  6686. exports.PDFCursorTools = PDFCursorTools;
  6687. /***/ }),
  6688. /* 132 */
  6689. /***/ ((__unused_webpack_module, exports) => {
  6690. Object.defineProperty(exports, "__esModule", ({
  6691. value: true
  6692. }));
  6693. exports.GrabToPan = void 0;
  6694. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  6695. class GrabToPan {
  6696. constructor(_ref) {
  6697. let {
  6698. element
  6699. } = _ref;
  6700. this.element = element;
  6701. this.document = element.ownerDocument;
  6702. this.activate = this.activate.bind(this);
  6703. this.deactivate = this.deactivate.bind(this);
  6704. this.toggle = this.toggle.bind(this);
  6705. this._onMouseDown = this.#onMouseDown.bind(this);
  6706. this._onMouseMove = this.#onMouseMove.bind(this);
  6707. this._endPan = this.#endPan.bind(this);
  6708. const overlay = this.overlay = document.createElement("div");
  6709. overlay.className = "grab-to-pan-grabbing";
  6710. }
  6711. activate() {
  6712. if (!this.active) {
  6713. this.active = true;
  6714. this.element.addEventListener("mousedown", this._onMouseDown, true);
  6715. this.element.classList.add(CSS_CLASS_GRAB);
  6716. }
  6717. }
  6718. deactivate() {
  6719. if (this.active) {
  6720. this.active = false;
  6721. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  6722. this._endPan();
  6723. this.element.classList.remove(CSS_CLASS_GRAB);
  6724. }
  6725. }
  6726. toggle() {
  6727. if (this.active) {
  6728. this.deactivate();
  6729. } else {
  6730. this.activate();
  6731. }
  6732. }
  6733. ignoreTarget(node) {
  6734. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  6735. }
  6736. #onMouseDown(event) {
  6737. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  6738. return;
  6739. }
  6740. if (event.originalTarget) {
  6741. try {
  6742. event.originalTarget.tagName;
  6743. } catch {
  6744. return;
  6745. }
  6746. }
  6747. this.scrollLeftStart = this.element.scrollLeft;
  6748. this.scrollTopStart = this.element.scrollTop;
  6749. this.clientXStart = event.clientX;
  6750. this.clientYStart = event.clientY;
  6751. this.document.addEventListener("mousemove", this._onMouseMove, true);
  6752. this.document.addEventListener("mouseup", this._endPan, true);
  6753. this.element.addEventListener("scroll", this._endPan, true);
  6754. event.preventDefault();
  6755. event.stopPropagation();
  6756. const focusedElement = document.activeElement;
  6757. if (focusedElement && !focusedElement.contains(event.target)) {
  6758. focusedElement.blur();
  6759. }
  6760. }
  6761. #onMouseMove(event) {
  6762. this.element.removeEventListener("scroll", this._endPan, true);
  6763. if (!(event.buttons & 1)) {
  6764. this._endPan();
  6765. return;
  6766. }
  6767. const xDiff = event.clientX - this.clientXStart;
  6768. const yDiff = event.clientY - this.clientYStart;
  6769. this.element.scrollTo({
  6770. top: this.scrollTopStart - yDiff,
  6771. left: this.scrollLeftStart - xDiff,
  6772. behavior: "instant"
  6773. });
  6774. if (!this.overlay.parentNode) {
  6775. document.body.append(this.overlay);
  6776. }
  6777. }
  6778. #endPan() {
  6779. this.element.removeEventListener("scroll", this._endPan, true);
  6780. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  6781. this.document.removeEventListener("mouseup", this._endPan, true);
  6782. this.overlay.remove();
  6783. }
  6784. }
  6785. exports.GrabToPan = GrabToPan;
  6786. /***/ }),
  6787. /* 133 */
  6788. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6789. Object.defineProperty(exports, "__esModule", ({
  6790. value: true
  6791. }));
  6792. exports.PDFDocumentProperties = void 0;
  6793. var _ui_utils = __webpack_require__(97);
  6794. var _pdfjsLib = __webpack_require__(122);
  6795. const DEFAULT_FIELD_CONTENT = "-";
  6796. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  6797. const US_PAGE_NAMES = {
  6798. "8.5x11": "Letter",
  6799. "8.5x14": "Legal"
  6800. };
  6801. const METRIC_PAGE_NAMES = {
  6802. "297x420": "A3",
  6803. "210x297": "A4"
  6804. };
  6805. function getPageName(size, isPortrait, pageNames) {
  6806. const width = isPortrait ? size.width : size.height;
  6807. const height = isPortrait ? size.height : size.width;
  6808. return pageNames[`${width}x${height}`];
  6809. }
  6810. class PDFDocumentProperties {
  6811. #fieldData = null;
  6812. constructor(_ref, overlayManager, eventBus, l10n, fileNameLookup) {
  6813. let {
  6814. dialog,
  6815. fields,
  6816. closeButton
  6817. } = _ref;
  6818. this.dialog = dialog;
  6819. this.fields = fields;
  6820. this.overlayManager = overlayManager;
  6821. this.l10n = l10n;
  6822. this._fileNameLookup = fileNameLookup;
  6823. this.#reset();
  6824. closeButton.addEventListener("click", this.close.bind(this));
  6825. this.overlayManager.register(this.dialog);
  6826. eventBus._on("pagechanging", evt => {
  6827. this._currentPageNumber = evt.pageNumber;
  6828. });
  6829. eventBus._on("rotationchanging", evt => {
  6830. this._pagesRotation = evt.pagesRotation;
  6831. });
  6832. this._isNonMetricLocale = true;
  6833. l10n.getLanguage().then(locale => {
  6834. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  6835. });
  6836. }
  6837. async open() {
  6838. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  6839. const currentPageNumber = this._currentPageNumber;
  6840. const pagesRotation = this._pagesRotation;
  6841. if (this.#fieldData && currentPageNumber === this.#fieldData._currentPageNumber && pagesRotation === this.#fieldData._pagesRotation) {
  6842. this.#updateUI();
  6843. return;
  6844. }
  6845. const {
  6846. info,
  6847. contentLength
  6848. } = await this.pdfDocument.getMetadata();
  6849. 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 => {
  6850. return this.#parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  6851. }), this.#parseLinearization(info.IsLinearized)]);
  6852. this.#fieldData = Object.freeze({
  6853. fileName,
  6854. fileSize,
  6855. title: info.Title,
  6856. author: info.Author,
  6857. subject: info.Subject,
  6858. keywords: info.Keywords,
  6859. creationDate,
  6860. modificationDate,
  6861. creator: info.Creator,
  6862. producer: info.Producer,
  6863. version: info.PDFFormatVersion,
  6864. pageCount: this.pdfDocument.numPages,
  6865. pageSize,
  6866. linearized: isLinearized,
  6867. _currentPageNumber: currentPageNumber,
  6868. _pagesRotation: pagesRotation
  6869. });
  6870. this.#updateUI();
  6871. const {
  6872. length
  6873. } = await this.pdfDocument.getDownloadInfo();
  6874. if (contentLength === length) {
  6875. return;
  6876. }
  6877. const data = Object.assign(Object.create(null), this.#fieldData);
  6878. data.fileSize = await this.#parseFileSize(length);
  6879. this.#fieldData = Object.freeze(data);
  6880. this.#updateUI();
  6881. }
  6882. async close() {
  6883. this.overlayManager.close(this.dialog);
  6884. }
  6885. setDocument(pdfDocument) {
  6886. if (this.pdfDocument) {
  6887. this.#reset();
  6888. this.#updateUI(true);
  6889. }
  6890. if (!pdfDocument) {
  6891. return;
  6892. }
  6893. this.pdfDocument = pdfDocument;
  6894. this._dataAvailableCapability.resolve();
  6895. }
  6896. #reset() {
  6897. this.pdfDocument = null;
  6898. this.#fieldData = null;
  6899. this._dataAvailableCapability = new _pdfjsLib.PromiseCapability();
  6900. this._currentPageNumber = 1;
  6901. this._pagesRotation = 0;
  6902. }
  6903. #updateUI() {
  6904. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6905. if (reset || !this.#fieldData) {
  6906. for (const id in this.fields) {
  6907. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6908. }
  6909. return;
  6910. }
  6911. if (this.overlayManager.active !== this.dialog) {
  6912. return;
  6913. }
  6914. for (const id in this.fields) {
  6915. const content = this.#fieldData[id];
  6916. this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6917. }
  6918. }
  6919. async #parseFileSize() {
  6920. let fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  6921. const kb = fileSize / 1024,
  6922. mb = kb / 1024;
  6923. if (!kb) {
  6924. return undefined;
  6925. }
  6926. return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
  6927. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  6928. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  6929. size_b: fileSize.toLocaleString()
  6930. });
  6931. }
  6932. async #parsePageSize(pageSizeInches, pagesRotation) {
  6933. if (!pageSizeInches) {
  6934. return undefined;
  6935. }
  6936. if (pagesRotation % 180 !== 0) {
  6937. pageSizeInches = {
  6938. width: pageSizeInches.height,
  6939. height: pageSizeInches.width
  6940. };
  6941. }
  6942. const isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6943. let sizeInches = {
  6944. width: Math.round(pageSizeInches.width * 100) / 100,
  6945. height: Math.round(pageSizeInches.height * 100) / 100
  6946. };
  6947. let sizeMillimeters = {
  6948. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6949. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6950. };
  6951. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6952. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6953. const exactMillimeters = {
  6954. width: pageSizeInches.width * 25.4,
  6955. height: pageSizeInches.height * 25.4
  6956. };
  6957. const intMillimeters = {
  6958. width: Math.round(sizeMillimeters.width),
  6959. height: Math.round(sizeMillimeters.height)
  6960. };
  6961. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6962. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6963. if (rawName) {
  6964. sizeInches = {
  6965. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6966. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6967. };
  6968. sizeMillimeters = intMillimeters;
  6969. }
  6970. }
  6971. }
  6972. const [{
  6973. width,
  6974. height
  6975. }, 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"}`)]);
  6976. return this.l10n.get(`document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
  6977. width: width.toLocaleString(),
  6978. height: height.toLocaleString(),
  6979. unit,
  6980. name,
  6981. orientation
  6982. });
  6983. }
  6984. async #parseDate(inputDate) {
  6985. const dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  6986. if (!dateObject) {
  6987. return undefined;
  6988. }
  6989. return this.l10n.get("document_properties_date_string", {
  6990. date: dateObject.toLocaleDateString(),
  6991. time: dateObject.toLocaleTimeString()
  6992. });
  6993. }
  6994. #parseLinearization(isLinearized) {
  6995. return this.l10n.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
  6996. }
  6997. }
  6998. exports.PDFDocumentProperties = PDFDocumentProperties;
  6999. /***/ }),
  7000. /* 134 */
  7001. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7002. Object.defineProperty(exports, "__esModule", ({
  7003. value: true
  7004. }));
  7005. exports.PDFFindBar = void 0;
  7006. var _pdf_find_controller = __webpack_require__(135);
  7007. var _ui_utils = __webpack_require__(97);
  7008. const MATCHES_COUNT_LIMIT = 1000;
  7009. class PDFFindBar {
  7010. constructor(options, eventBus, l10n) {
  7011. this.opened = false;
  7012. this.bar = options.bar;
  7013. this.toggleButton = options.toggleButton;
  7014. this.findField = options.findField;
  7015. this.highlightAll = options.highlightAllCheckbox;
  7016. this.caseSensitive = options.caseSensitiveCheckbox;
  7017. this.matchDiacritics = options.matchDiacriticsCheckbox;
  7018. this.entireWord = options.entireWordCheckbox;
  7019. this.findMsg = options.findMsg;
  7020. this.findResultsCount = options.findResultsCount;
  7021. this.findPreviousButton = options.findPreviousButton;
  7022. this.findNextButton = options.findNextButton;
  7023. this.eventBus = eventBus;
  7024. this.l10n = l10n;
  7025. this.toggleButton.addEventListener("click", () => {
  7026. this.toggle();
  7027. });
  7028. this.findField.addEventListener("input", () => {
  7029. this.dispatchEvent("");
  7030. });
  7031. this.bar.addEventListener("keydown", e => {
  7032. switch (e.keyCode) {
  7033. case 13:
  7034. if (e.target === this.findField) {
  7035. this.dispatchEvent("again", e.shiftKey);
  7036. }
  7037. break;
  7038. case 27:
  7039. this.close();
  7040. break;
  7041. }
  7042. });
  7043. this.findPreviousButton.addEventListener("click", () => {
  7044. this.dispatchEvent("again", true);
  7045. });
  7046. this.findNextButton.addEventListener("click", () => {
  7047. this.dispatchEvent("again", false);
  7048. });
  7049. this.highlightAll.addEventListener("click", () => {
  7050. this.dispatchEvent("highlightallchange");
  7051. });
  7052. this.caseSensitive.addEventListener("click", () => {
  7053. this.dispatchEvent("casesensitivitychange");
  7054. });
  7055. this.entireWord.addEventListener("click", () => {
  7056. this.dispatchEvent("entirewordchange");
  7057. });
  7058. this.matchDiacritics.addEventListener("click", () => {
  7059. this.dispatchEvent("diacriticmatchingchange");
  7060. });
  7061. this.eventBus._on("resize", this.#adjustWidth.bind(this));
  7062. }
  7063. reset() {
  7064. this.updateUIState();
  7065. }
  7066. dispatchEvent(type) {
  7067. let findPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7068. this.eventBus.dispatch("find", {
  7069. source: this,
  7070. type,
  7071. query: this.findField.value,
  7072. caseSensitive: this.caseSensitive.checked,
  7073. entireWord: this.entireWord.checked,
  7074. highlightAll: this.highlightAll.checked,
  7075. findPrevious: findPrev,
  7076. matchDiacritics: this.matchDiacritics.checked
  7077. });
  7078. }
  7079. updateUIState(state, previous, matchesCount) {
  7080. let findMsg = Promise.resolve("");
  7081. let status = "";
  7082. switch (state) {
  7083. case _pdf_find_controller.FindState.FOUND:
  7084. break;
  7085. case _pdf_find_controller.FindState.PENDING:
  7086. status = "pending";
  7087. break;
  7088. case _pdf_find_controller.FindState.NOT_FOUND:
  7089. findMsg = this.l10n.get("find_not_found");
  7090. status = "notFound";
  7091. break;
  7092. case _pdf_find_controller.FindState.WRAPPED:
  7093. findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
  7094. break;
  7095. }
  7096. this.findField.setAttribute("data-status", status);
  7097. this.findField.setAttribute("aria-invalid", state === _pdf_find_controller.FindState.NOT_FOUND);
  7098. findMsg.then(msg => {
  7099. this.findMsg.setAttribute("data-status", status);
  7100. this.findMsg.textContent = msg;
  7101. this.#adjustWidth();
  7102. });
  7103. this.updateResultsCount(matchesCount);
  7104. }
  7105. updateResultsCount() {
  7106. let {
  7107. current = 0,
  7108. total = 0
  7109. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7110. const limit = MATCHES_COUNT_LIMIT;
  7111. let matchCountMsg = Promise.resolve("");
  7112. if (total > 0) {
  7113. if (total > limit) {
  7114. let key = "find_match_count_limit";
  7115. matchCountMsg = this.l10n.get(key, {
  7116. limit
  7117. });
  7118. } else {
  7119. let key = "find_match_count";
  7120. matchCountMsg = this.l10n.get(key, {
  7121. current,
  7122. total
  7123. });
  7124. }
  7125. }
  7126. matchCountMsg.then(msg => {
  7127. this.findResultsCount.textContent = msg;
  7128. this.#adjustWidth();
  7129. });
  7130. }
  7131. open() {
  7132. if (!this.opened) {
  7133. this.opened = true;
  7134. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true, this.bar);
  7135. }
  7136. this.findField.select();
  7137. this.findField.focus();
  7138. this.#adjustWidth();
  7139. }
  7140. close() {
  7141. if (!this.opened) {
  7142. return;
  7143. }
  7144. this.opened = false;
  7145. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false, this.bar);
  7146. this.eventBus.dispatch("findbarclose", {
  7147. source: this
  7148. });
  7149. }
  7150. toggle() {
  7151. if (this.opened) {
  7152. this.close();
  7153. } else {
  7154. this.open();
  7155. }
  7156. }
  7157. #adjustWidth() {
  7158. if (!this.opened) {
  7159. return;
  7160. }
  7161. this.bar.classList.remove("wrapContainers");
  7162. const findbarHeight = this.bar.clientHeight;
  7163. const inputContainerHeight = this.bar.firstElementChild.clientHeight;
  7164. if (findbarHeight > inputContainerHeight) {
  7165. this.bar.classList.add("wrapContainers");
  7166. }
  7167. }
  7168. }
  7169. exports.PDFFindBar = PDFFindBar;
  7170. /***/ }),
  7171. /* 135 */
  7172. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7173. Object.defineProperty(exports, "__esModule", ({
  7174. value: true
  7175. }));
  7176. exports.PDFFindController = exports.FindState = void 0;
  7177. __webpack_require__(98);
  7178. __webpack_require__(109);
  7179. __webpack_require__(111);
  7180. __webpack_require__(114);
  7181. __webpack_require__(116);
  7182. __webpack_require__(118);
  7183. __webpack_require__(120);
  7184. __webpack_require__(89);
  7185. var _ui_utils = __webpack_require__(97);
  7186. var _pdf_find_utils = __webpack_require__(136);
  7187. var _pdfjsLib = __webpack_require__(122);
  7188. const FindState = {
  7189. FOUND: 0,
  7190. NOT_FOUND: 1,
  7191. WRAPPED: 2,
  7192. PENDING: 3
  7193. };
  7194. exports.FindState = FindState;
  7195. const FIND_TIMEOUT = 250;
  7196. const MATCH_SCROLL_OFFSET_TOP = -50;
  7197. const MATCH_SCROLL_OFFSET_LEFT = -400;
  7198. const CHARACTERS_TO_NORMALIZE = {
  7199. "\u2010": "-",
  7200. "\u2018": "'",
  7201. "\u2019": "'",
  7202. "\u201A": "'",
  7203. "\u201B": "'",
  7204. "\u201C": '"',
  7205. "\u201D": '"',
  7206. "\u201E": '"',
  7207. "\u201F": '"',
  7208. "\u00BC": "1/4",
  7209. "\u00BD": "1/2",
  7210. "\u00BE": "3/4"
  7211. };
  7212. 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]);
  7213. let DIACRITICS_EXCEPTION_STR;
  7214. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  7215. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  7216. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  7217. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  7218. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  7219. const SYLLABLES_LENGTHS = new Map();
  7220. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  7221. const NFKC_CHARS_TO_NORMALIZE = new Map();
  7222. let noSyllablesRegExp = null;
  7223. let withSyllablesRegExp = null;
  7224. function normalize(text) {
  7225. const syllablePositions = [];
  7226. let m;
  7227. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  7228. let {
  7229. index
  7230. } = m;
  7231. for (const char of m[0]) {
  7232. let len = SYLLABLES_LENGTHS.get(char);
  7233. if (!len) {
  7234. len = char.normalize("NFD").length;
  7235. SYLLABLES_LENGTHS.set(char, len);
  7236. }
  7237. syllablePositions.push([len, index++]);
  7238. }
  7239. }
  7240. let normalizationRegex;
  7241. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  7242. normalizationRegex = noSyllablesRegExp;
  7243. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  7244. normalizationRegex = withSyllablesRegExp;
  7245. } else {
  7246. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  7247. const toNormalizeWithNFKC = (0, _pdf_find_utils.getNormalizeWithNFKC)();
  7248. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  7249. const HKDiacritics = "(?:\u3099|\u309A)";
  7250. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  7251. if (syllablePositions.length === 0) {
  7252. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  7253. } else {
  7254. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  7255. }
  7256. }
  7257. const rawDiacriticsPositions = [];
  7258. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  7259. rawDiacriticsPositions.push([m[0].length, m.index]);
  7260. }
  7261. let normalized = text.normalize("NFD");
  7262. const positions = [[0, 0]];
  7263. let rawDiacriticsIndex = 0;
  7264. let syllableIndex = 0;
  7265. let shift = 0;
  7266. let shiftOrigin = 0;
  7267. let eol = 0;
  7268. let hasDiacritics = false;
  7269. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
  7270. i -= shiftOrigin;
  7271. if (p1) {
  7272. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  7273. const jj = replacement.length;
  7274. for (let j = 1; j < jj; j++) {
  7275. positions.push([i - shift + j, shift - j]);
  7276. }
  7277. shift -= jj - 1;
  7278. return replacement;
  7279. }
  7280. if (p2) {
  7281. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  7282. if (!replacement) {
  7283. replacement = p2.normalize("NFKC");
  7284. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  7285. }
  7286. const jj = replacement.length;
  7287. for (let j = 1; j < jj; j++) {
  7288. positions.push([i - shift + j, shift - j]);
  7289. }
  7290. shift -= jj - 1;
  7291. return replacement;
  7292. }
  7293. if (p3) {
  7294. hasDiacritics = true;
  7295. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7296. ++rawDiacriticsIndex;
  7297. } else {
  7298. positions.push([i - 1 - shift + 1, shift - 1]);
  7299. shift -= 1;
  7300. shiftOrigin += 1;
  7301. }
  7302. positions.push([i - shift + 1, shift]);
  7303. shiftOrigin += 1;
  7304. eol += 1;
  7305. return p3.charAt(0);
  7306. }
  7307. if (p4) {
  7308. const hasTrailingDashEOL = p4.endsWith("\n");
  7309. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  7310. hasDiacritics = true;
  7311. let jj = len;
  7312. if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
  7313. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  7314. ++rawDiacriticsIndex;
  7315. }
  7316. for (let j = 1; j <= jj; j++) {
  7317. positions.push([i - 1 - shift + j, shift - j]);
  7318. }
  7319. shift -= jj;
  7320. shiftOrigin += jj;
  7321. if (hasTrailingDashEOL) {
  7322. i += len - 1;
  7323. positions.push([i - shift + 1, 1 + shift]);
  7324. shift += 1;
  7325. shiftOrigin += 1;
  7326. eol += 1;
  7327. return p4.slice(0, len);
  7328. }
  7329. return p4;
  7330. }
  7331. if (p5) {
  7332. const len = p5.length - 2;
  7333. positions.push([i - shift + len, 1 + shift]);
  7334. shift += 1;
  7335. shiftOrigin += 1;
  7336. eol += 1;
  7337. return p5.slice(0, -2);
  7338. }
  7339. if (p6) {
  7340. const len = p6.length - 1;
  7341. positions.push([i - shift + len, shift]);
  7342. shiftOrigin += 1;
  7343. eol += 1;
  7344. return p6.slice(0, -1);
  7345. }
  7346. if (p7) {
  7347. positions.push([i - shift + 1, shift - 1]);
  7348. shift -= 1;
  7349. shiftOrigin += 1;
  7350. eol += 1;
  7351. return " ";
  7352. }
  7353. if (i + eol === syllablePositions[syllableIndex]?.[1]) {
  7354. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  7355. ++syllableIndex;
  7356. for (let j = 1; j <= newCharLen; j++) {
  7357. positions.push([i - (shift - j), shift - j]);
  7358. }
  7359. shift -= newCharLen;
  7360. shiftOrigin += newCharLen;
  7361. }
  7362. return p8;
  7363. });
  7364. positions.push([normalized.length, shift]);
  7365. return [normalized, positions, hasDiacritics];
  7366. }
  7367. function getOriginalIndex(diffs, pos, len) {
  7368. if (!diffs) {
  7369. return [pos, len];
  7370. }
  7371. const start = pos;
  7372. const end = pos + len - 1;
  7373. let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
  7374. if (diffs[i][0] > start) {
  7375. --i;
  7376. }
  7377. let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  7378. if (diffs[j][0] > end) {
  7379. --j;
  7380. }
  7381. const oldStart = start + diffs[i][1];
  7382. const oldEnd = end + diffs[j][1];
  7383. const oldLen = oldEnd + 1 - oldStart;
  7384. return [oldStart, oldLen];
  7385. }
  7386. class PDFFindController {
  7387. #state = null;
  7388. #updateMatchesCountOnProgress = true;
  7389. #visitedPagesCount = 0;
  7390. constructor(_ref) {
  7391. let {
  7392. linkService,
  7393. eventBus,
  7394. updateMatchesCountOnProgress = true
  7395. } = _ref;
  7396. this._linkService = linkService;
  7397. this._eventBus = eventBus;
  7398. this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
  7399. this.onIsPageVisible = null;
  7400. this.#reset();
  7401. eventBus._on("find", this.#onFind.bind(this));
  7402. eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
  7403. }
  7404. get highlightMatches() {
  7405. return this._highlightMatches;
  7406. }
  7407. get pageMatches() {
  7408. return this._pageMatches;
  7409. }
  7410. get pageMatchesLength() {
  7411. return this._pageMatchesLength;
  7412. }
  7413. get selected() {
  7414. return this._selected;
  7415. }
  7416. get state() {
  7417. return this.#state;
  7418. }
  7419. setDocument(pdfDocument) {
  7420. if (this._pdfDocument) {
  7421. this.#reset();
  7422. }
  7423. if (!pdfDocument) {
  7424. return;
  7425. }
  7426. this._pdfDocument = pdfDocument;
  7427. this._firstPageCapability.resolve();
  7428. }
  7429. #onFind(state) {
  7430. if (!state) {
  7431. return;
  7432. }
  7433. if (state.phraseSearch === false) {
  7434. console.error("The `phraseSearch`-parameter was removed, please provide " + "an Array of strings in the `query`-parameter instead.");
  7435. if (typeof state.query === "string") {
  7436. state.query = state.query.match(/\S+/g);
  7437. }
  7438. }
  7439. const pdfDocument = this._pdfDocument;
  7440. const {
  7441. type
  7442. } = state;
  7443. if (this.#state === null || this.#shouldDirtyMatch(state)) {
  7444. this._dirtyMatch = true;
  7445. }
  7446. this.#state = state;
  7447. if (type !== "highlightallchange") {
  7448. this.#updateUIState(FindState.PENDING);
  7449. }
  7450. this._firstPageCapability.promise.then(() => {
  7451. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7452. return;
  7453. }
  7454. this.#extractText();
  7455. const findbarClosed = !this._highlightMatches;
  7456. const pendingTimeout = !!this._findTimeout;
  7457. if (this._findTimeout) {
  7458. clearTimeout(this._findTimeout);
  7459. this._findTimeout = null;
  7460. }
  7461. if (!type) {
  7462. this._findTimeout = setTimeout(() => {
  7463. this.#nextMatch();
  7464. this._findTimeout = null;
  7465. }, FIND_TIMEOUT);
  7466. } else if (this._dirtyMatch) {
  7467. this.#nextMatch();
  7468. } else if (type === "again") {
  7469. this.#nextMatch();
  7470. if (findbarClosed && this.#state.highlightAll) {
  7471. this.#updateAllPages();
  7472. }
  7473. } else if (type === "highlightallchange") {
  7474. if (pendingTimeout) {
  7475. this.#nextMatch();
  7476. } else {
  7477. this._highlightMatches = true;
  7478. }
  7479. this.#updateAllPages();
  7480. } else {
  7481. this.#nextMatch();
  7482. }
  7483. });
  7484. }
  7485. scrollMatchIntoView(_ref2) {
  7486. let {
  7487. element = null,
  7488. selectedLeft = 0,
  7489. pageIndex = -1,
  7490. matchIndex = -1
  7491. } = _ref2;
  7492. if (!this._scrollMatches || !element) {
  7493. return;
  7494. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  7495. return;
  7496. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  7497. return;
  7498. }
  7499. this._scrollMatches = false;
  7500. const spot = {
  7501. top: MATCH_SCROLL_OFFSET_TOP,
  7502. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  7503. };
  7504. (0, _ui_utils.scrollIntoView)(element, spot, true);
  7505. }
  7506. #reset() {
  7507. this._highlightMatches = false;
  7508. this._scrollMatches = false;
  7509. this._pdfDocument = null;
  7510. this._pageMatches = [];
  7511. this._pageMatchesLength = [];
  7512. this.#visitedPagesCount = 0;
  7513. this.#state = null;
  7514. this._selected = {
  7515. pageIdx: -1,
  7516. matchIdx: -1
  7517. };
  7518. this._offset = {
  7519. pageIdx: null,
  7520. matchIdx: null,
  7521. wrapped: false
  7522. };
  7523. this._extractTextPromises = [];
  7524. this._pageContents = [];
  7525. this._pageDiffs = [];
  7526. this._hasDiacritics = [];
  7527. this._matchesCountTotal = 0;
  7528. this._pagesToSearch = null;
  7529. this._pendingFindMatches = new Set();
  7530. this._resumePageIdx = null;
  7531. this._dirtyMatch = false;
  7532. clearTimeout(this._findTimeout);
  7533. this._findTimeout = null;
  7534. this._firstPageCapability = new _pdfjsLib.PromiseCapability();
  7535. }
  7536. get #query() {
  7537. const {
  7538. query
  7539. } = this.#state;
  7540. if (typeof query === "string") {
  7541. if (query !== this._rawQuery) {
  7542. this._rawQuery = query;
  7543. [this._normalizedQuery] = normalize(query);
  7544. }
  7545. return this._normalizedQuery;
  7546. }
  7547. return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
  7548. }
  7549. #shouldDirtyMatch(state) {
  7550. const newQuery = state.query,
  7551. prevQuery = this.#state.query;
  7552. const newType = typeof newQuery,
  7553. prevType = typeof prevQuery;
  7554. if (newType !== prevType) {
  7555. return true;
  7556. }
  7557. if (newType === "string") {
  7558. if (newQuery !== prevQuery) {
  7559. return true;
  7560. }
  7561. } else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
  7562. return true;
  7563. }
  7564. switch (state.type) {
  7565. case "again":
  7566. const pageNumber = this._selected.pageIdx + 1;
  7567. const linkService = this._linkService;
  7568. return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
  7569. case "highlightallchange":
  7570. return false;
  7571. }
  7572. return true;
  7573. }
  7574. #isEntireWord(content, startIdx, length) {
  7575. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  7576. if (match) {
  7577. const first = content.charCodeAt(startIdx);
  7578. const limit = match[1].charCodeAt(0);
  7579. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7580. return false;
  7581. }
  7582. }
  7583. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  7584. if (match) {
  7585. const last = content.charCodeAt(startIdx + length - 1);
  7586. const limit = match[1].charCodeAt(0);
  7587. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  7588. return false;
  7589. }
  7590. }
  7591. return true;
  7592. }
  7593. #calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
  7594. const matches = this._pageMatches[pageIndex] = [];
  7595. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  7596. if (!query) {
  7597. return;
  7598. }
  7599. const diffs = this._pageDiffs[pageIndex];
  7600. let match;
  7601. while ((match = query.exec(pageContent)) !== null) {
  7602. if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
  7603. continue;
  7604. }
  7605. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  7606. if (matchLen) {
  7607. matches.push(matchPos);
  7608. matchesLength.push(matchLen);
  7609. }
  7610. }
  7611. }
  7612. #convertToRegExpString(query, hasDiacritics) {
  7613. const {
  7614. matchDiacritics
  7615. } = this.#state;
  7616. let isUnicode = false;
  7617. query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  7618. if (p1) {
  7619. return `[ ]*\\${p1}[ ]*`;
  7620. }
  7621. if (p2) {
  7622. return `[ ]*${p2}[ ]*`;
  7623. }
  7624. if (p3) {
  7625. return "[ ]+";
  7626. }
  7627. if (matchDiacritics) {
  7628. return p4 || p5;
  7629. }
  7630. if (p4) {
  7631. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  7632. }
  7633. if (hasDiacritics) {
  7634. isUnicode = true;
  7635. return `${p5}\\p{M}*`;
  7636. }
  7637. return p5;
  7638. });
  7639. const trailingSpaces = "[ ]*";
  7640. if (query.endsWith(trailingSpaces)) {
  7641. query = query.slice(0, query.length - trailingSpaces.length);
  7642. }
  7643. if (matchDiacritics) {
  7644. if (hasDiacritics) {
  7645. DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
  7646. isUnicode = true;
  7647. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  7648. }
  7649. }
  7650. return [isUnicode, query];
  7651. }
  7652. #calculateMatch(pageIndex) {
  7653. let query = this.#query;
  7654. if (query.length === 0) {
  7655. return;
  7656. }
  7657. const {
  7658. caseSensitive,
  7659. entireWord
  7660. } = this.#state;
  7661. const pageContent = this._pageContents[pageIndex];
  7662. const hasDiacritics = this._hasDiacritics[pageIndex];
  7663. let isUnicode = false;
  7664. if (typeof query === "string") {
  7665. [isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
  7666. } else {
  7667. query = query.sort().reverse().map(q => {
  7668. const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
  7669. isUnicode ||= isUnicodePart;
  7670. return `(${queryPart})`;
  7671. }).join("|");
  7672. }
  7673. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  7674. query = query ? new RegExp(query, flags) : null;
  7675. this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
  7676. if (this.#state.highlightAll) {
  7677. this.#updatePage(pageIndex);
  7678. }
  7679. if (this._resumePageIdx === pageIndex) {
  7680. this._resumePageIdx = null;
  7681. this.#nextPageMatch();
  7682. }
  7683. const pageMatchesCount = this._pageMatches[pageIndex].length;
  7684. this._matchesCountTotal += pageMatchesCount;
  7685. if (this.#updateMatchesCountOnProgress) {
  7686. if (pageMatchesCount > 0) {
  7687. this.#updateUIResultsCount();
  7688. }
  7689. } else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
  7690. this.#updateUIResultsCount();
  7691. }
  7692. }
  7693. #extractText() {
  7694. if (this._extractTextPromises.length > 0) {
  7695. return;
  7696. }
  7697. let promise = Promise.resolve();
  7698. const textOptions = {
  7699. disableNormalization: true
  7700. };
  7701. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  7702. const extractTextCapability = new _pdfjsLib.PromiseCapability();
  7703. this._extractTextPromises[i] = extractTextCapability.promise;
  7704. promise = promise.then(() => {
  7705. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  7706. return pdfPage.getTextContent(textOptions);
  7707. }).then(textContent => {
  7708. const strBuf = [];
  7709. for (const textItem of textContent.items) {
  7710. strBuf.push(textItem.str);
  7711. if (textItem.hasEOL) {
  7712. strBuf.push("\n");
  7713. }
  7714. }
  7715. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  7716. extractTextCapability.resolve();
  7717. }, reason => {
  7718. console.error(`Unable to get text content for page ${i + 1}`, reason);
  7719. this._pageContents[i] = "";
  7720. this._pageDiffs[i] = null;
  7721. this._hasDiacritics[i] = false;
  7722. extractTextCapability.resolve();
  7723. });
  7724. });
  7725. }
  7726. }
  7727. #updatePage(index) {
  7728. if (this._scrollMatches && this._selected.pageIdx === index) {
  7729. this._linkService.page = index + 1;
  7730. }
  7731. this._eventBus.dispatch("updatetextlayermatches", {
  7732. source: this,
  7733. pageIndex: index
  7734. });
  7735. }
  7736. #updateAllPages() {
  7737. this._eventBus.dispatch("updatetextlayermatches", {
  7738. source: this,
  7739. pageIndex: -1
  7740. });
  7741. }
  7742. #nextMatch() {
  7743. const previous = this.#state.findPrevious;
  7744. const currentPageIndex = this._linkService.page - 1;
  7745. const numPages = this._linkService.pagesCount;
  7746. this._highlightMatches = true;
  7747. if (this._dirtyMatch) {
  7748. this._dirtyMatch = false;
  7749. this._selected.pageIdx = this._selected.matchIdx = -1;
  7750. this._offset.pageIdx = currentPageIndex;
  7751. this._offset.matchIdx = null;
  7752. this._offset.wrapped = false;
  7753. this._resumePageIdx = null;
  7754. this._pageMatches.length = 0;
  7755. this._pageMatchesLength.length = 0;
  7756. this.#visitedPagesCount = 0;
  7757. this._matchesCountTotal = 0;
  7758. this.#updateAllPages();
  7759. for (let i = 0; i < numPages; i++) {
  7760. if (this._pendingFindMatches.has(i)) {
  7761. continue;
  7762. }
  7763. this._pendingFindMatches.add(i);
  7764. this._extractTextPromises[i].then(() => {
  7765. this._pendingFindMatches.delete(i);
  7766. this.#calculateMatch(i);
  7767. });
  7768. }
  7769. }
  7770. const query = this.#query;
  7771. if (query.length === 0) {
  7772. this.#updateUIState(FindState.FOUND);
  7773. return;
  7774. }
  7775. if (this._resumePageIdx) {
  7776. return;
  7777. }
  7778. const offset = this._offset;
  7779. this._pagesToSearch = numPages;
  7780. if (offset.matchIdx !== null) {
  7781. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  7782. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  7783. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  7784. this.#updateMatch(true);
  7785. return;
  7786. }
  7787. this.#advanceOffsetPage(previous);
  7788. }
  7789. this.#nextPageMatch();
  7790. }
  7791. #matchesReady(matches) {
  7792. const offset = this._offset;
  7793. const numMatches = matches.length;
  7794. const previous = this.#state.findPrevious;
  7795. if (numMatches) {
  7796. offset.matchIdx = previous ? numMatches - 1 : 0;
  7797. this.#updateMatch(true);
  7798. return true;
  7799. }
  7800. this.#advanceOffsetPage(previous);
  7801. if (offset.wrapped) {
  7802. offset.matchIdx = null;
  7803. if (this._pagesToSearch < 0) {
  7804. this.#updateMatch(false);
  7805. return true;
  7806. }
  7807. }
  7808. return false;
  7809. }
  7810. #nextPageMatch() {
  7811. if (this._resumePageIdx !== null) {
  7812. console.error("There can only be one pending page.");
  7813. }
  7814. let matches = null;
  7815. do {
  7816. const pageIdx = this._offset.pageIdx;
  7817. matches = this._pageMatches[pageIdx];
  7818. if (!matches) {
  7819. this._resumePageIdx = pageIdx;
  7820. break;
  7821. }
  7822. } while (!this.#matchesReady(matches));
  7823. }
  7824. #advanceOffsetPage(previous) {
  7825. const offset = this._offset;
  7826. const numPages = this._linkService.pagesCount;
  7827. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7828. offset.matchIdx = null;
  7829. this._pagesToSearch--;
  7830. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7831. offset.pageIdx = previous ? numPages - 1 : 0;
  7832. offset.wrapped = true;
  7833. }
  7834. }
  7835. #updateMatch() {
  7836. let found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7837. let state = FindState.NOT_FOUND;
  7838. const wrapped = this._offset.wrapped;
  7839. this._offset.wrapped = false;
  7840. if (found) {
  7841. const previousPage = this._selected.pageIdx;
  7842. this._selected.pageIdx = this._offset.pageIdx;
  7843. this._selected.matchIdx = this._offset.matchIdx;
  7844. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7845. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  7846. this.#updatePage(previousPage);
  7847. }
  7848. }
  7849. this.#updateUIState(state, this.#state.findPrevious);
  7850. if (this._selected.pageIdx !== -1) {
  7851. this._scrollMatches = true;
  7852. this.#updatePage(this._selected.pageIdx);
  7853. }
  7854. }
  7855. #onFindBarClose(evt) {
  7856. const pdfDocument = this._pdfDocument;
  7857. this._firstPageCapability.promise.then(() => {
  7858. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  7859. return;
  7860. }
  7861. if (this._findTimeout) {
  7862. clearTimeout(this._findTimeout);
  7863. this._findTimeout = null;
  7864. }
  7865. if (this._resumePageIdx) {
  7866. this._resumePageIdx = null;
  7867. this._dirtyMatch = true;
  7868. }
  7869. this.#updateUIState(FindState.FOUND);
  7870. this._highlightMatches = false;
  7871. this.#updateAllPages();
  7872. });
  7873. }
  7874. #requestMatchesCount() {
  7875. const {
  7876. pageIdx,
  7877. matchIdx
  7878. } = this._selected;
  7879. let current = 0,
  7880. total = this._matchesCountTotal;
  7881. if (matchIdx !== -1) {
  7882. for (let i = 0; i < pageIdx; i++) {
  7883. current += this._pageMatches[i]?.length || 0;
  7884. }
  7885. current += matchIdx + 1;
  7886. }
  7887. if (current < 1 || current > total) {
  7888. current = total = 0;
  7889. }
  7890. return {
  7891. current,
  7892. total
  7893. };
  7894. }
  7895. #updateUIResultsCount() {
  7896. this._eventBus.dispatch("updatefindmatchescount", {
  7897. source: this,
  7898. matchesCount: this.#requestMatchesCount()
  7899. });
  7900. }
  7901. #updateUIState(state) {
  7902. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7903. if (!this.#updateMatchesCountOnProgress && (this.#visitedPagesCount !== this._linkService.pagesCount || state === FindState.PENDING)) {
  7904. return;
  7905. }
  7906. this._eventBus.dispatch("updatefindcontrolstate", {
  7907. source: this,
  7908. state,
  7909. previous,
  7910. matchesCount: this.#requestMatchesCount(),
  7911. rawQuery: this.#state?.query ?? null
  7912. });
  7913. }
  7914. }
  7915. exports.PDFFindController = PDFFindController;
  7916. /***/ }),
  7917. /* 136 */
  7918. /***/ ((__unused_webpack_module, exports) => {
  7919. Object.defineProperty(exports, "__esModule", ({
  7920. value: true
  7921. }));
  7922. exports.CharacterType = void 0;
  7923. exports.getCharacterType = getCharacterType;
  7924. exports.getNormalizeWithNFKC = getNormalizeWithNFKC;
  7925. const CharacterType = {
  7926. SPACE: 0,
  7927. ALPHA_LETTER: 1,
  7928. PUNCT: 2,
  7929. HAN_LETTER: 3,
  7930. KATAKANA_LETTER: 4,
  7931. HIRAGANA_LETTER: 5,
  7932. HALFWIDTH_KATAKANA_LETTER: 6,
  7933. THAI_LETTER: 7
  7934. };
  7935. exports.CharacterType = CharacterType;
  7936. function isAlphabeticalScript(charCode) {
  7937. return charCode < 0x2e80;
  7938. }
  7939. function isAscii(charCode) {
  7940. return (charCode & 0xff80) === 0;
  7941. }
  7942. function isAsciiAlpha(charCode) {
  7943. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7944. }
  7945. function isAsciiDigit(charCode) {
  7946. return charCode >= 0x30 && charCode <= 0x39;
  7947. }
  7948. function isAsciiSpace(charCode) {
  7949. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7950. }
  7951. function isHan(charCode) {
  7952. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7953. }
  7954. function isKatakana(charCode) {
  7955. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7956. }
  7957. function isHiragana(charCode) {
  7958. return charCode >= 0x3040 && charCode <= 0x309f;
  7959. }
  7960. function isHalfwidthKatakana(charCode) {
  7961. return charCode >= 0xff60 && charCode <= 0xff9f;
  7962. }
  7963. function isThai(charCode) {
  7964. return (charCode & 0xff80) === 0x0e00;
  7965. }
  7966. function getCharacterType(charCode) {
  7967. if (isAlphabeticalScript(charCode)) {
  7968. if (isAscii(charCode)) {
  7969. if (isAsciiSpace(charCode)) {
  7970. return CharacterType.SPACE;
  7971. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7972. return CharacterType.ALPHA_LETTER;
  7973. }
  7974. return CharacterType.PUNCT;
  7975. } else if (isThai(charCode)) {
  7976. return CharacterType.THAI_LETTER;
  7977. } else if (charCode === 0xa0) {
  7978. return CharacterType.SPACE;
  7979. }
  7980. return CharacterType.ALPHA_LETTER;
  7981. }
  7982. if (isHan(charCode)) {
  7983. return CharacterType.HAN_LETTER;
  7984. } else if (isKatakana(charCode)) {
  7985. return CharacterType.KATAKANA_LETTER;
  7986. } else if (isHiragana(charCode)) {
  7987. return CharacterType.HIRAGANA_LETTER;
  7988. } else if (isHalfwidthKatakana(charCode)) {
  7989. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7990. }
  7991. return CharacterType.ALPHA_LETTER;
  7992. }
  7993. let NormalizeWithNFKC;
  7994. function getNormalizeWithNFKC() {
  7995. NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`;
  7996. return NormalizeWithNFKC;
  7997. }
  7998. /***/ }),
  7999. /* 137 */
  8000. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8001. Object.defineProperty(exports, "__esModule", ({
  8002. value: true
  8003. }));
  8004. exports.PDFHistory = void 0;
  8005. exports.isDestArraysEqual = isDestArraysEqual;
  8006. exports.isDestHashesEqual = isDestHashesEqual;
  8007. var _ui_utils = __webpack_require__(97);
  8008. var _event_utils = __webpack_require__(124);
  8009. const HASH_CHANGE_TIMEOUT = 1000;
  8010. const POSITION_UPDATED_THRESHOLD = 50;
  8011. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  8012. function getCurrentHash() {
  8013. return document.location.hash;
  8014. }
  8015. class PDFHistory {
  8016. constructor(_ref) {
  8017. let {
  8018. linkService,
  8019. eventBus
  8020. } = _ref;
  8021. this.linkService = linkService;
  8022. this.eventBus = eventBus;
  8023. this._initialized = false;
  8024. this._fingerprint = "";
  8025. this.reset();
  8026. this._boundEvents = null;
  8027. this.eventBus._on("pagesinit", () => {
  8028. this._isPagesLoaded = false;
  8029. this.eventBus._on("pagesloaded", evt => {
  8030. this._isPagesLoaded = !!evt.pagesCount;
  8031. }, {
  8032. once: true
  8033. });
  8034. });
  8035. }
  8036. initialize(_ref2) {
  8037. let {
  8038. fingerprint,
  8039. resetHistory = false,
  8040. updateUrl = false
  8041. } = _ref2;
  8042. if (!fingerprint || typeof fingerprint !== "string") {
  8043. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  8044. return;
  8045. }
  8046. if (this._initialized) {
  8047. this.reset();
  8048. }
  8049. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  8050. this._fingerprint = fingerprint;
  8051. this._updateUrl = updateUrl === true;
  8052. this._initialized = true;
  8053. this._bindEvents();
  8054. const state = window.history.state;
  8055. this._popStateInProgress = false;
  8056. this._blockHashChange = 0;
  8057. this._currentHash = getCurrentHash();
  8058. this._numPositionUpdates = 0;
  8059. this._uid = this._maxUid = 0;
  8060. this._destination = null;
  8061. this._position = null;
  8062. if (!this._isValidState(state, true) || resetHistory) {
  8063. const {
  8064. hash,
  8065. page,
  8066. rotation
  8067. } = this._parseCurrentHash(true);
  8068. if (!hash || reInitialized || resetHistory) {
  8069. this._pushOrReplaceState(null, true);
  8070. return;
  8071. }
  8072. this._pushOrReplaceState({
  8073. hash,
  8074. page,
  8075. rotation
  8076. }, true);
  8077. return;
  8078. }
  8079. const destination = state.destination;
  8080. this._updateInternalState(destination, state.uid, true);
  8081. if (destination.rotation !== undefined) {
  8082. this._initialRotation = destination.rotation;
  8083. }
  8084. if (destination.dest) {
  8085. this._initialBookmark = JSON.stringify(destination.dest);
  8086. this._destination.page = null;
  8087. } else if (destination.hash) {
  8088. this._initialBookmark = destination.hash;
  8089. } else if (destination.page) {
  8090. this._initialBookmark = `page=${destination.page}`;
  8091. }
  8092. }
  8093. reset() {
  8094. if (this._initialized) {
  8095. this._pageHide();
  8096. this._initialized = false;
  8097. this._unbindEvents();
  8098. }
  8099. if (this._updateViewareaTimeout) {
  8100. clearTimeout(this._updateViewareaTimeout);
  8101. this._updateViewareaTimeout = null;
  8102. }
  8103. this._initialBookmark = null;
  8104. this._initialRotation = null;
  8105. }
  8106. push(_ref3) {
  8107. let {
  8108. namedDest = null,
  8109. explicitDest,
  8110. pageNumber
  8111. } = _ref3;
  8112. if (!this._initialized) {
  8113. return;
  8114. }
  8115. if (namedDest && typeof namedDest !== "string") {
  8116. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  8117. return;
  8118. } else if (!Array.isArray(explicitDest)) {
  8119. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  8120. return;
  8121. } else if (!this._isValidPage(pageNumber)) {
  8122. if (pageNumber !== null || this._destination) {
  8123. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  8124. return;
  8125. }
  8126. }
  8127. const hash = namedDest || JSON.stringify(explicitDest);
  8128. if (!hash) {
  8129. return;
  8130. }
  8131. let forceReplace = false;
  8132. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  8133. if (this._destination.page) {
  8134. return;
  8135. }
  8136. forceReplace = true;
  8137. }
  8138. if (this._popStateInProgress && !forceReplace) {
  8139. return;
  8140. }
  8141. this._pushOrReplaceState({
  8142. dest: explicitDest,
  8143. hash,
  8144. page: pageNumber,
  8145. rotation: this.linkService.rotation
  8146. }, forceReplace);
  8147. if (!this._popStateInProgress) {
  8148. this._popStateInProgress = true;
  8149. Promise.resolve().then(() => {
  8150. this._popStateInProgress = false;
  8151. });
  8152. }
  8153. }
  8154. pushPage(pageNumber) {
  8155. if (!this._initialized) {
  8156. return;
  8157. }
  8158. if (!this._isValidPage(pageNumber)) {
  8159. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  8160. return;
  8161. }
  8162. if (this._destination?.page === pageNumber) {
  8163. return;
  8164. }
  8165. if (this._popStateInProgress) {
  8166. return;
  8167. }
  8168. this._pushOrReplaceState({
  8169. dest: null,
  8170. hash: `page=${pageNumber}`,
  8171. page: pageNumber,
  8172. rotation: this.linkService.rotation
  8173. });
  8174. if (!this._popStateInProgress) {
  8175. this._popStateInProgress = true;
  8176. Promise.resolve().then(() => {
  8177. this._popStateInProgress = false;
  8178. });
  8179. }
  8180. }
  8181. pushCurrentPosition() {
  8182. if (!this._initialized || this._popStateInProgress) {
  8183. return;
  8184. }
  8185. this._tryPushCurrentPosition();
  8186. }
  8187. back() {
  8188. if (!this._initialized || this._popStateInProgress) {
  8189. return;
  8190. }
  8191. const state = window.history.state;
  8192. if (this._isValidState(state) && state.uid > 0) {
  8193. window.history.back();
  8194. }
  8195. }
  8196. forward() {
  8197. if (!this._initialized || this._popStateInProgress) {
  8198. return;
  8199. }
  8200. const state = window.history.state;
  8201. if (this._isValidState(state) && state.uid < this._maxUid) {
  8202. window.history.forward();
  8203. }
  8204. }
  8205. get popStateInProgress() {
  8206. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  8207. }
  8208. get initialBookmark() {
  8209. return this._initialized ? this._initialBookmark : null;
  8210. }
  8211. get initialRotation() {
  8212. return this._initialized ? this._initialRotation : null;
  8213. }
  8214. _pushOrReplaceState(destination) {
  8215. let forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8216. const shouldReplace = forceReplace || !this._destination;
  8217. const newState = {
  8218. fingerprint: this._fingerprint,
  8219. uid: shouldReplace ? this._uid : this._uid + 1,
  8220. destination
  8221. };
  8222. this._updateInternalState(destination, newState.uid);
  8223. let newUrl;
  8224. if (this._updateUrl && destination?.hash) {
  8225. const baseUrl = document.location.href.split("#")[0];
  8226. if (!baseUrl.startsWith("file://")) {
  8227. newUrl = `${baseUrl}#${destination.hash}`;
  8228. }
  8229. }
  8230. if (shouldReplace) {
  8231. window.history.replaceState(newState, "", newUrl);
  8232. } else {
  8233. window.history.pushState(newState, "", newUrl);
  8234. }
  8235. }
  8236. _tryPushCurrentPosition() {
  8237. let temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8238. if (!this._position) {
  8239. return;
  8240. }
  8241. let position = this._position;
  8242. if (temporary) {
  8243. position = Object.assign(Object.create(null), this._position);
  8244. position.temporary = true;
  8245. }
  8246. if (!this._destination) {
  8247. this._pushOrReplaceState(position);
  8248. return;
  8249. }
  8250. if (this._destination.temporary) {
  8251. this._pushOrReplaceState(position, true);
  8252. return;
  8253. }
  8254. if (this._destination.hash === position.hash) {
  8255. return;
  8256. }
  8257. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  8258. return;
  8259. }
  8260. let forceReplace = false;
  8261. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  8262. if (this._destination.dest !== undefined || !this._destination.first) {
  8263. return;
  8264. }
  8265. forceReplace = true;
  8266. }
  8267. this._pushOrReplaceState(position, forceReplace);
  8268. }
  8269. _isValidPage(val) {
  8270. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  8271. }
  8272. _isValidState(state) {
  8273. let checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8274. if (!state) {
  8275. return false;
  8276. }
  8277. if (state.fingerprint !== this._fingerprint) {
  8278. if (checkReload) {
  8279. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  8280. return false;
  8281. }
  8282. const [perfEntry] = performance.getEntriesByType("navigation");
  8283. if (perfEntry?.type !== "reload") {
  8284. return false;
  8285. }
  8286. } else {
  8287. return false;
  8288. }
  8289. }
  8290. if (!Number.isInteger(state.uid) || state.uid < 0) {
  8291. return false;
  8292. }
  8293. if (state.destination === null || typeof state.destination !== "object") {
  8294. return false;
  8295. }
  8296. return true;
  8297. }
  8298. _updateInternalState(destination, uid) {
  8299. let removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8300. if (this._updateViewareaTimeout) {
  8301. clearTimeout(this._updateViewareaTimeout);
  8302. this._updateViewareaTimeout = null;
  8303. }
  8304. if (removeTemporary && destination?.temporary) {
  8305. delete destination.temporary;
  8306. }
  8307. this._destination = destination;
  8308. this._uid = uid;
  8309. this._maxUid = Math.max(this._maxUid, uid);
  8310. this._numPositionUpdates = 0;
  8311. }
  8312. _parseCurrentHash() {
  8313. let checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8314. const hash = unescape(getCurrentHash()).substring(1);
  8315. const params = (0, _ui_utils.parseQueryString)(hash);
  8316. const nameddest = params.get("nameddest") || "";
  8317. let page = params.get("page") | 0;
  8318. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  8319. page = null;
  8320. }
  8321. return {
  8322. hash,
  8323. page,
  8324. rotation: this.linkService.rotation
  8325. };
  8326. }
  8327. _updateViewarea(_ref4) {
  8328. let {
  8329. location
  8330. } = _ref4;
  8331. if (this._updateViewareaTimeout) {
  8332. clearTimeout(this._updateViewareaTimeout);
  8333. this._updateViewareaTimeout = null;
  8334. }
  8335. this._position = {
  8336. hash: location.pdfOpenParams.substring(1),
  8337. page: this.linkService.page,
  8338. first: location.pageNumber,
  8339. rotation: location.rotation
  8340. };
  8341. if (this._popStateInProgress) {
  8342. return;
  8343. }
  8344. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  8345. this._numPositionUpdates++;
  8346. }
  8347. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  8348. this._updateViewareaTimeout = setTimeout(() => {
  8349. if (!this._popStateInProgress) {
  8350. this._tryPushCurrentPosition(true);
  8351. }
  8352. this._updateViewareaTimeout = null;
  8353. }, UPDATE_VIEWAREA_TIMEOUT);
  8354. }
  8355. }
  8356. _popState(_ref5) {
  8357. let {
  8358. state
  8359. } = _ref5;
  8360. const newHash = getCurrentHash(),
  8361. hashChanged = this._currentHash !== newHash;
  8362. this._currentHash = newHash;
  8363. if (!state) {
  8364. this._uid++;
  8365. const {
  8366. hash,
  8367. page,
  8368. rotation
  8369. } = this._parseCurrentHash();
  8370. this._pushOrReplaceState({
  8371. hash,
  8372. page,
  8373. rotation
  8374. }, true);
  8375. return;
  8376. }
  8377. if (!this._isValidState(state)) {
  8378. return;
  8379. }
  8380. this._popStateInProgress = true;
  8381. if (hashChanged) {
  8382. this._blockHashChange++;
  8383. (0, _event_utils.waitOnEventOrTimeout)({
  8384. target: window,
  8385. name: "hashchange",
  8386. delay: HASH_CHANGE_TIMEOUT
  8387. }).then(() => {
  8388. this._blockHashChange--;
  8389. });
  8390. }
  8391. const destination = state.destination;
  8392. this._updateInternalState(destination, state.uid, true);
  8393. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  8394. this.linkService.rotation = destination.rotation;
  8395. }
  8396. if (destination.dest) {
  8397. this.linkService.goToDestination(destination.dest);
  8398. } else if (destination.hash) {
  8399. this.linkService.setHash(destination.hash);
  8400. } else if (destination.page) {
  8401. this.linkService.page = destination.page;
  8402. }
  8403. Promise.resolve().then(() => {
  8404. this._popStateInProgress = false;
  8405. });
  8406. }
  8407. _pageHide() {
  8408. if (!this._destination || this._destination.temporary) {
  8409. this._tryPushCurrentPosition();
  8410. }
  8411. }
  8412. _bindEvents() {
  8413. if (this._boundEvents) {
  8414. return;
  8415. }
  8416. this._boundEvents = {
  8417. updateViewarea: this._updateViewarea.bind(this),
  8418. popState: this._popState.bind(this),
  8419. pageHide: this._pageHide.bind(this)
  8420. };
  8421. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  8422. window.addEventListener("popstate", this._boundEvents.popState);
  8423. window.addEventListener("pagehide", this._boundEvents.pageHide);
  8424. }
  8425. _unbindEvents() {
  8426. if (!this._boundEvents) {
  8427. return;
  8428. }
  8429. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  8430. window.removeEventListener("popstate", this._boundEvents.popState);
  8431. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  8432. this._boundEvents = null;
  8433. }
  8434. }
  8435. exports.PDFHistory = PDFHistory;
  8436. function isDestHashesEqual(destHash, pushHash) {
  8437. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  8438. return false;
  8439. }
  8440. if (destHash === pushHash) {
  8441. return true;
  8442. }
  8443. const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  8444. if (nameddest === pushHash) {
  8445. return true;
  8446. }
  8447. return false;
  8448. }
  8449. function isDestArraysEqual(firstDest, secondDest) {
  8450. function isEntryEqual(first, second) {
  8451. if (typeof first !== typeof second) {
  8452. return false;
  8453. }
  8454. if (Array.isArray(first) || Array.isArray(second)) {
  8455. return false;
  8456. }
  8457. if (first !== null && typeof first === "object" && second !== null) {
  8458. if (Object.keys(first).length !== Object.keys(second).length) {
  8459. return false;
  8460. }
  8461. for (const key in first) {
  8462. if (!isEntryEqual(first[key], second[key])) {
  8463. return false;
  8464. }
  8465. }
  8466. return true;
  8467. }
  8468. return first === second || Number.isNaN(first) && Number.isNaN(second);
  8469. }
  8470. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  8471. return false;
  8472. }
  8473. if (firstDest.length !== secondDest.length) {
  8474. return false;
  8475. }
  8476. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  8477. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  8478. return false;
  8479. }
  8480. }
  8481. return true;
  8482. }
  8483. /***/ }),
  8484. /* 138 */
  8485. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8486. Object.defineProperty(exports, "__esModule", ({
  8487. value: true
  8488. }));
  8489. exports.PDFLayerViewer = void 0;
  8490. __webpack_require__(89);
  8491. var _base_tree_viewer = __webpack_require__(130);
  8492. class PDFLayerViewer extends _base_tree_viewer.BaseTreeViewer {
  8493. constructor(options) {
  8494. super(options);
  8495. this.l10n = options.l10n;
  8496. this.eventBus._on("optionalcontentconfigchanged", evt => {
  8497. this.#updateLayers(evt.promise);
  8498. });
  8499. this.eventBus._on("resetlayers", () => {
  8500. this.#updateLayers();
  8501. });
  8502. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  8503. }
  8504. reset() {
  8505. super.reset();
  8506. this._optionalContentConfig = null;
  8507. this._optionalContentHash = null;
  8508. }
  8509. _dispatchEvent(layersCount) {
  8510. this.eventBus.dispatch("layersloaded", {
  8511. source: this,
  8512. layersCount
  8513. });
  8514. }
  8515. _bindLink(element, _ref) {
  8516. let {
  8517. groupId,
  8518. input
  8519. } = _ref;
  8520. const setVisibility = () => {
  8521. this._optionalContentConfig.setVisibility(groupId, input.checked);
  8522. this._optionalContentHash = this._optionalContentConfig.getHash();
  8523. this.eventBus.dispatch("optionalcontentconfig", {
  8524. source: this,
  8525. promise: Promise.resolve(this._optionalContentConfig)
  8526. });
  8527. };
  8528. element.onclick = evt => {
  8529. if (evt.target === input) {
  8530. setVisibility();
  8531. return true;
  8532. } else if (evt.target !== element) {
  8533. return true;
  8534. }
  8535. input.checked = !input.checked;
  8536. setVisibility();
  8537. return false;
  8538. };
  8539. }
  8540. async _setNestedName(element, _ref2) {
  8541. let {
  8542. name = null
  8543. } = _ref2;
  8544. if (typeof name === "string") {
  8545. element.textContent = this._normalizeTextContent(name);
  8546. return;
  8547. }
  8548. element.textContent = await this.l10n.get("additional_layers");
  8549. element.style.fontStyle = "italic";
  8550. }
  8551. _addToggleButton(div, _ref3) {
  8552. let {
  8553. name = null
  8554. } = _ref3;
  8555. super._addToggleButton(div, name === null);
  8556. }
  8557. _toggleAllTreeItems() {
  8558. if (!this._optionalContentConfig) {
  8559. return;
  8560. }
  8561. super._toggleAllTreeItems();
  8562. }
  8563. render(_ref4) {
  8564. let {
  8565. optionalContentConfig,
  8566. pdfDocument
  8567. } = _ref4;
  8568. if (this._optionalContentConfig) {
  8569. this.reset();
  8570. }
  8571. this._optionalContentConfig = optionalContentConfig || null;
  8572. this._pdfDocument = pdfDocument || null;
  8573. const groups = optionalContentConfig?.getOrder();
  8574. if (!groups) {
  8575. this._dispatchEvent(0);
  8576. return;
  8577. }
  8578. this._optionalContentHash = optionalContentConfig.getHash();
  8579. const fragment = document.createDocumentFragment(),
  8580. queue = [{
  8581. parent: fragment,
  8582. groups
  8583. }];
  8584. let layersCount = 0,
  8585. hasAnyNesting = false;
  8586. while (queue.length > 0) {
  8587. const levelData = queue.shift();
  8588. for (const groupId of levelData.groups) {
  8589. const div = document.createElement("div");
  8590. div.className = "treeItem";
  8591. const element = document.createElement("a");
  8592. div.append(element);
  8593. if (typeof groupId === "object") {
  8594. hasAnyNesting = true;
  8595. this._addToggleButton(div, groupId);
  8596. this._setNestedName(element, groupId);
  8597. const itemsDiv = document.createElement("div");
  8598. itemsDiv.className = "treeItems";
  8599. div.append(itemsDiv);
  8600. queue.push({
  8601. parent: itemsDiv,
  8602. groups: groupId.order
  8603. });
  8604. } else {
  8605. const group = optionalContentConfig.getGroup(groupId);
  8606. const input = document.createElement("input");
  8607. this._bindLink(element, {
  8608. groupId,
  8609. input
  8610. });
  8611. input.type = "checkbox";
  8612. input.checked = group.visible;
  8613. const label = document.createElement("label");
  8614. label.textContent = this._normalizeTextContent(group.name);
  8615. label.append(input);
  8616. element.append(label);
  8617. layersCount++;
  8618. }
  8619. levelData.parent.append(div);
  8620. }
  8621. }
  8622. this._finishRendering(fragment, layersCount, hasAnyNesting);
  8623. }
  8624. async #updateLayers() {
  8625. let promise = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8626. if (!this._optionalContentConfig) {
  8627. return;
  8628. }
  8629. const pdfDocument = this._pdfDocument;
  8630. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig());
  8631. if (pdfDocument !== this._pdfDocument) {
  8632. return;
  8633. }
  8634. if (promise) {
  8635. if (optionalContentConfig.getHash() === this._optionalContentHash) {
  8636. return;
  8637. }
  8638. } else {
  8639. this.eventBus.dispatch("optionalcontentconfig", {
  8640. source: this,
  8641. promise: Promise.resolve(optionalContentConfig)
  8642. });
  8643. }
  8644. this.render({
  8645. optionalContentConfig,
  8646. pdfDocument: this._pdfDocument
  8647. });
  8648. }
  8649. }
  8650. exports.PDFLayerViewer = PDFLayerViewer;
  8651. /***/ }),
  8652. /* 139 */
  8653. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8654. Object.defineProperty(exports, "__esModule", ({
  8655. value: true
  8656. }));
  8657. exports.PDFOutlineViewer = void 0;
  8658. __webpack_require__(89);
  8659. __webpack_require__(76);
  8660. var _base_tree_viewer = __webpack_require__(130);
  8661. var _pdfjsLib = __webpack_require__(122);
  8662. var _ui_utils = __webpack_require__(97);
  8663. class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
  8664. constructor(options) {
  8665. super(options);
  8666. this.linkService = options.linkService;
  8667. this.downloadManager = options.downloadManager;
  8668. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  8669. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  8670. this.eventBus._on("pagechanging", evt => {
  8671. this._currentPageNumber = evt.pageNumber;
  8672. });
  8673. this.eventBus._on("pagesloaded", evt => {
  8674. this._isPagesLoaded = !!evt.pagesCount;
  8675. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8676. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8677. }
  8678. });
  8679. this.eventBus._on("sidebarviewchanged", evt => {
  8680. this._sidebarView = evt.view;
  8681. });
  8682. }
  8683. reset() {
  8684. super.reset();
  8685. this._outline = null;
  8686. this._pageNumberToDestHashCapability = null;
  8687. this._currentPageNumber = 1;
  8688. this._isPagesLoaded = null;
  8689. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  8690. this._currentOutlineItemCapability.resolve(false);
  8691. }
  8692. this._currentOutlineItemCapability = null;
  8693. }
  8694. _dispatchEvent(outlineCount) {
  8695. this._currentOutlineItemCapability = new _pdfjsLib.PromiseCapability();
  8696. if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
  8697. this._currentOutlineItemCapability.resolve(false);
  8698. } else if (this._isPagesLoaded !== null) {
  8699. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  8700. }
  8701. this.eventBus.dispatch("outlineloaded", {
  8702. source: this,
  8703. outlineCount,
  8704. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  8705. });
  8706. }
  8707. _bindLink(element, _ref) {
  8708. let {
  8709. url,
  8710. newWindow,
  8711. action,
  8712. attachment,
  8713. dest,
  8714. setOCGState
  8715. } = _ref;
  8716. const {
  8717. linkService
  8718. } = this;
  8719. if (url) {
  8720. linkService.addLinkAttributes(element, url, newWindow);
  8721. return;
  8722. }
  8723. if (action) {
  8724. element.href = linkService.getAnchorUrl("");
  8725. element.onclick = () => {
  8726. linkService.executeNamedAction(action);
  8727. return false;
  8728. };
  8729. return;
  8730. }
  8731. if (attachment) {
  8732. element.href = linkService.getAnchorUrl("");
  8733. element.onclick = () => {
  8734. this.downloadManager.openOrDownloadData(element, attachment.content, attachment.filename);
  8735. return false;
  8736. };
  8737. return;
  8738. }
  8739. if (setOCGState) {
  8740. element.href = linkService.getAnchorUrl("");
  8741. element.onclick = () => {
  8742. linkService.executeSetOCGState(setOCGState);
  8743. return false;
  8744. };
  8745. return;
  8746. }
  8747. element.href = linkService.getDestinationHash(dest);
  8748. element.onclick = evt => {
  8749. this._updateCurrentTreeItem(evt.target.parentNode);
  8750. if (dest) {
  8751. linkService.goToDestination(dest);
  8752. }
  8753. return false;
  8754. };
  8755. }
  8756. _setStyles(element, _ref2) {
  8757. let {
  8758. bold,
  8759. italic
  8760. } = _ref2;
  8761. if (bold) {
  8762. element.style.fontWeight = "bold";
  8763. }
  8764. if (italic) {
  8765. element.style.fontStyle = "italic";
  8766. }
  8767. }
  8768. _addToggleButton(div, _ref3) {
  8769. let {
  8770. count,
  8771. items
  8772. } = _ref3;
  8773. let hidden = false;
  8774. if (count < 0) {
  8775. let totalCount = items.length;
  8776. if (totalCount > 0) {
  8777. const queue = [...items];
  8778. while (queue.length > 0) {
  8779. const {
  8780. count: nestedCount,
  8781. items: nestedItems
  8782. } = queue.shift();
  8783. if (nestedCount > 0 && nestedItems.length > 0) {
  8784. totalCount += nestedItems.length;
  8785. queue.push(...nestedItems);
  8786. }
  8787. }
  8788. }
  8789. if (Math.abs(count) === totalCount) {
  8790. hidden = true;
  8791. }
  8792. }
  8793. super._addToggleButton(div, hidden);
  8794. }
  8795. _toggleAllTreeItems() {
  8796. if (!this._outline) {
  8797. return;
  8798. }
  8799. super._toggleAllTreeItems();
  8800. }
  8801. render(_ref4) {
  8802. let {
  8803. outline,
  8804. pdfDocument
  8805. } = _ref4;
  8806. if (this._outline) {
  8807. this.reset();
  8808. }
  8809. this._outline = outline || null;
  8810. this._pdfDocument = pdfDocument || null;
  8811. if (!outline) {
  8812. this._dispatchEvent(0);
  8813. return;
  8814. }
  8815. const fragment = document.createDocumentFragment();
  8816. const queue = [{
  8817. parent: fragment,
  8818. items: outline
  8819. }];
  8820. let outlineCount = 0,
  8821. hasAnyNesting = false;
  8822. while (queue.length > 0) {
  8823. const levelData = queue.shift();
  8824. for (const item of levelData.items) {
  8825. const div = document.createElement("div");
  8826. div.className = "treeItem";
  8827. const element = document.createElement("a");
  8828. this._bindLink(element, item);
  8829. this._setStyles(element, item);
  8830. element.textContent = this._normalizeTextContent(item.title);
  8831. div.append(element);
  8832. if (item.items.length > 0) {
  8833. hasAnyNesting = true;
  8834. this._addToggleButton(div, item);
  8835. const itemsDiv = document.createElement("div");
  8836. itemsDiv.className = "treeItems";
  8837. div.append(itemsDiv);
  8838. queue.push({
  8839. parent: itemsDiv,
  8840. items: item.items
  8841. });
  8842. }
  8843. levelData.parent.append(div);
  8844. outlineCount++;
  8845. }
  8846. }
  8847. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8848. }
  8849. async _currentOutlineItem() {
  8850. if (!this._isPagesLoaded) {
  8851. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8852. }
  8853. if (!this._outline || !this._pdfDocument) {
  8854. return;
  8855. }
  8856. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  8857. if (!pageNumberToDestHash) {
  8858. return;
  8859. }
  8860. this._updateCurrentTreeItem(null);
  8861. if (this._sidebarView !== _ui_utils.SidebarView.OUTLINE) {
  8862. return;
  8863. }
  8864. for (let i = this._currentPageNumber; i > 0; i--) {
  8865. const destHash = pageNumberToDestHash.get(i);
  8866. if (!destHash) {
  8867. continue;
  8868. }
  8869. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  8870. if (!linkElement) {
  8871. continue;
  8872. }
  8873. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8874. break;
  8875. }
  8876. }
  8877. async _getPageNumberToDestHash(pdfDocument) {
  8878. if (this._pageNumberToDestHashCapability) {
  8879. return this._pageNumberToDestHashCapability.promise;
  8880. }
  8881. this._pageNumberToDestHashCapability = new _pdfjsLib.PromiseCapability();
  8882. const pageNumberToDestHash = new Map(),
  8883. pageNumberNesting = new Map();
  8884. const queue = [{
  8885. nesting: 0,
  8886. items: this._outline
  8887. }];
  8888. while (queue.length > 0) {
  8889. const levelData = queue.shift(),
  8890. currentNesting = levelData.nesting;
  8891. for (const {
  8892. dest,
  8893. items
  8894. } of levelData.items) {
  8895. let explicitDest, pageNumber;
  8896. if (typeof dest === "string") {
  8897. explicitDest = await pdfDocument.getDestination(dest);
  8898. if (pdfDocument !== this._pdfDocument) {
  8899. return null;
  8900. }
  8901. } else {
  8902. explicitDest = dest;
  8903. }
  8904. if (Array.isArray(explicitDest)) {
  8905. const [destRef] = explicitDest;
  8906. if (typeof destRef === "object" && destRef !== null) {
  8907. pageNumber = this.linkService._cachedPageNumber(destRef);
  8908. if (!pageNumber) {
  8909. try {
  8910. pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
  8911. if (pdfDocument !== this._pdfDocument) {
  8912. return null;
  8913. }
  8914. this.linkService.cachePageRef(pageNumber, destRef);
  8915. } catch {}
  8916. }
  8917. } else if (Number.isInteger(destRef)) {
  8918. pageNumber = destRef + 1;
  8919. }
  8920. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8921. const destHash = this.linkService.getDestinationHash(dest);
  8922. pageNumberToDestHash.set(pageNumber, destHash);
  8923. pageNumberNesting.set(pageNumber, currentNesting);
  8924. }
  8925. }
  8926. if (items.length > 0) {
  8927. queue.push({
  8928. nesting: currentNesting + 1,
  8929. items
  8930. });
  8931. }
  8932. }
  8933. }
  8934. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8935. return this._pageNumberToDestHashCapability.promise;
  8936. }
  8937. }
  8938. exports.PDFOutlineViewer = PDFOutlineViewer;
  8939. /***/ }),
  8940. /* 140 */
  8941. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8942. Object.defineProperty(exports, "__esModule", ({
  8943. value: true
  8944. }));
  8945. exports.PDFPresentationMode = void 0;
  8946. var _ui_utils = __webpack_require__(97);
  8947. var _pdfjsLib = __webpack_require__(122);
  8948. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8949. const ACTIVE_SELECTOR = "pdfPresentationMode";
  8950. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8951. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8952. const PAGE_SWITCH_THRESHOLD = 0.1;
  8953. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8954. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8955. class PDFPresentationMode {
  8956. #state = _ui_utils.PresentationModeState.UNKNOWN;
  8957. #args = null;
  8958. constructor(_ref) {
  8959. let {
  8960. container,
  8961. pdfViewer,
  8962. eventBus
  8963. } = _ref;
  8964. this.container = container;
  8965. this.pdfViewer = pdfViewer;
  8966. this.eventBus = eventBus;
  8967. this.contextMenuOpen = false;
  8968. this.mouseScrollTimeStamp = 0;
  8969. this.mouseScrollDelta = 0;
  8970. this.touchSwipeState = null;
  8971. }
  8972. async request() {
  8973. const {
  8974. container,
  8975. pdfViewer
  8976. } = this;
  8977. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  8978. return false;
  8979. }
  8980. this.#addFullscreenChangeListeners();
  8981. this.#notifyStateChange(_ui_utils.PresentationModeState.CHANGING);
  8982. const promise = container.requestFullscreen();
  8983. this.#args = {
  8984. pageNumber: pdfViewer.currentPageNumber,
  8985. scaleValue: pdfViewer.currentScaleValue,
  8986. scrollMode: pdfViewer.scrollMode,
  8987. spreadMode: null,
  8988. annotationEditorMode: null
  8989. };
  8990. if (pdfViewer.spreadMode !== _ui_utils.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  8991. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  8992. this.#args.spreadMode = pdfViewer.spreadMode;
  8993. }
  8994. if (pdfViewer.annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  8995. this.#args.annotationEditorMode = pdfViewer.annotationEditorMode;
  8996. }
  8997. try {
  8998. await promise;
  8999. pdfViewer.focus();
  9000. return true;
  9001. } catch {
  9002. this.#removeFullscreenChangeListeners();
  9003. this.#notifyStateChange(_ui_utils.PresentationModeState.NORMAL);
  9004. }
  9005. return false;
  9006. }
  9007. get active() {
  9008. return this.#state === _ui_utils.PresentationModeState.CHANGING || this.#state === _ui_utils.PresentationModeState.FULLSCREEN;
  9009. }
  9010. #mouseWheel(evt) {
  9011. if (!this.active) {
  9012. return;
  9013. }
  9014. evt.preventDefault();
  9015. const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  9016. const currentTime = Date.now();
  9017. const storedTime = this.mouseScrollTimeStamp;
  9018. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  9019. return;
  9020. }
  9021. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  9022. this.#resetMouseScrollState();
  9023. }
  9024. this.mouseScrollDelta += delta;
  9025. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  9026. const totalDelta = this.mouseScrollDelta;
  9027. this.#resetMouseScrollState();
  9028. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  9029. if (success) {
  9030. this.mouseScrollTimeStamp = currentTime;
  9031. }
  9032. }
  9033. }
  9034. #notifyStateChange(state) {
  9035. this.#state = state;
  9036. this.eventBus.dispatch("presentationmodechanged", {
  9037. source: this,
  9038. state
  9039. });
  9040. }
  9041. #enter() {
  9042. this.#notifyStateChange(_ui_utils.PresentationModeState.FULLSCREEN);
  9043. this.container.classList.add(ACTIVE_SELECTOR);
  9044. setTimeout(() => {
  9045. this.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  9046. if (this.#args.spreadMode !== null) {
  9047. this.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  9048. }
  9049. this.pdfViewer.currentPageNumber = this.#args.pageNumber;
  9050. this.pdfViewer.currentScaleValue = "page-fit";
  9051. if (this.#args.annotationEditorMode !== null) {
  9052. this.pdfViewer.annotationEditorMode = {
  9053. mode: _pdfjsLib.AnnotationEditorType.NONE
  9054. };
  9055. }
  9056. }, 0);
  9057. this.#addWindowListeners();
  9058. this.#showControls();
  9059. this.contextMenuOpen = false;
  9060. window.getSelection().removeAllRanges();
  9061. }
  9062. #exit() {
  9063. const pageNumber = this.pdfViewer.currentPageNumber;
  9064. this.container.classList.remove(ACTIVE_SELECTOR);
  9065. setTimeout(() => {
  9066. this.#removeFullscreenChangeListeners();
  9067. this.#notifyStateChange(_ui_utils.PresentationModeState.NORMAL);
  9068. this.pdfViewer.scrollMode = this.#args.scrollMode;
  9069. if (this.#args.spreadMode !== null) {
  9070. this.pdfViewer.spreadMode = this.#args.spreadMode;
  9071. }
  9072. this.pdfViewer.currentScaleValue = this.#args.scaleValue;
  9073. this.pdfViewer.currentPageNumber = pageNumber;
  9074. if (this.#args.annotationEditorMode !== null) {
  9075. this.pdfViewer.annotationEditorMode = {
  9076. mode: this.#args.annotationEditorMode
  9077. };
  9078. }
  9079. this.#args = null;
  9080. }, 0);
  9081. this.#removeWindowListeners();
  9082. this.#hideControls();
  9083. this.#resetMouseScrollState();
  9084. this.contextMenuOpen = false;
  9085. }
  9086. #mouseDown(evt) {
  9087. if (this.contextMenuOpen) {
  9088. this.contextMenuOpen = false;
  9089. evt.preventDefault();
  9090. return;
  9091. }
  9092. if (evt.button !== 0) {
  9093. return;
  9094. }
  9095. if (evt.target.href && evt.target.parentNode?.hasAttribute("data-internal-link")) {
  9096. return;
  9097. }
  9098. evt.preventDefault();
  9099. if (evt.shiftKey) {
  9100. this.pdfViewer.previousPage();
  9101. } else {
  9102. this.pdfViewer.nextPage();
  9103. }
  9104. }
  9105. #contextMenu() {
  9106. this.contextMenuOpen = true;
  9107. }
  9108. #showControls() {
  9109. if (this.controlsTimeout) {
  9110. clearTimeout(this.controlsTimeout);
  9111. } else {
  9112. this.container.classList.add(CONTROLS_SELECTOR);
  9113. }
  9114. this.controlsTimeout = setTimeout(() => {
  9115. this.container.classList.remove(CONTROLS_SELECTOR);
  9116. delete this.controlsTimeout;
  9117. }, DELAY_BEFORE_HIDING_CONTROLS);
  9118. }
  9119. #hideControls() {
  9120. if (!this.controlsTimeout) {
  9121. return;
  9122. }
  9123. clearTimeout(this.controlsTimeout);
  9124. this.container.classList.remove(CONTROLS_SELECTOR);
  9125. delete this.controlsTimeout;
  9126. }
  9127. #resetMouseScrollState() {
  9128. this.mouseScrollTimeStamp = 0;
  9129. this.mouseScrollDelta = 0;
  9130. }
  9131. #touchSwipe(evt) {
  9132. if (!this.active) {
  9133. return;
  9134. }
  9135. if (evt.touches.length > 1) {
  9136. this.touchSwipeState = null;
  9137. return;
  9138. }
  9139. switch (evt.type) {
  9140. case "touchstart":
  9141. this.touchSwipeState = {
  9142. startX: evt.touches[0].pageX,
  9143. startY: evt.touches[0].pageY,
  9144. endX: evt.touches[0].pageX,
  9145. endY: evt.touches[0].pageY
  9146. };
  9147. break;
  9148. case "touchmove":
  9149. if (this.touchSwipeState === null) {
  9150. return;
  9151. }
  9152. this.touchSwipeState.endX = evt.touches[0].pageX;
  9153. this.touchSwipeState.endY = evt.touches[0].pageY;
  9154. evt.preventDefault();
  9155. break;
  9156. case "touchend":
  9157. if (this.touchSwipeState === null) {
  9158. return;
  9159. }
  9160. let delta = 0;
  9161. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9162. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9163. const absAngle = Math.abs(Math.atan2(dy, dx));
  9164. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9165. delta = dx;
  9166. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9167. delta = dy;
  9168. }
  9169. if (delta > 0) {
  9170. this.pdfViewer.previousPage();
  9171. } else if (delta < 0) {
  9172. this.pdfViewer.nextPage();
  9173. }
  9174. break;
  9175. }
  9176. }
  9177. #addWindowListeners() {
  9178. this.showControlsBind = this.#showControls.bind(this);
  9179. this.mouseDownBind = this.#mouseDown.bind(this);
  9180. this.mouseWheelBind = this.#mouseWheel.bind(this);
  9181. this.resetMouseScrollStateBind = this.#resetMouseScrollState.bind(this);
  9182. this.contextMenuBind = this.#contextMenu.bind(this);
  9183. this.touchSwipeBind = this.#touchSwipe.bind(this);
  9184. window.addEventListener("mousemove", this.showControlsBind);
  9185. window.addEventListener("mousedown", this.mouseDownBind);
  9186. window.addEventListener("wheel", this.mouseWheelBind, {
  9187. passive: false
  9188. });
  9189. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9190. window.addEventListener("contextmenu", this.contextMenuBind);
  9191. window.addEventListener("touchstart", this.touchSwipeBind);
  9192. window.addEventListener("touchmove", this.touchSwipeBind);
  9193. window.addEventListener("touchend", this.touchSwipeBind);
  9194. }
  9195. #removeWindowListeners() {
  9196. window.removeEventListener("mousemove", this.showControlsBind);
  9197. window.removeEventListener("mousedown", this.mouseDownBind);
  9198. window.removeEventListener("wheel", this.mouseWheelBind, {
  9199. passive: false
  9200. });
  9201. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9202. window.removeEventListener("contextmenu", this.contextMenuBind);
  9203. window.removeEventListener("touchstart", this.touchSwipeBind);
  9204. window.removeEventListener("touchmove", this.touchSwipeBind);
  9205. window.removeEventListener("touchend", this.touchSwipeBind);
  9206. delete this.showControlsBind;
  9207. delete this.mouseDownBind;
  9208. delete this.mouseWheelBind;
  9209. delete this.resetMouseScrollStateBind;
  9210. delete this.contextMenuBind;
  9211. delete this.touchSwipeBind;
  9212. }
  9213. #fullscreenChange() {
  9214. if (document.fullscreenElement) {
  9215. this.#enter();
  9216. } else {
  9217. this.#exit();
  9218. }
  9219. }
  9220. #addFullscreenChangeListeners() {
  9221. this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
  9222. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9223. }
  9224. #removeFullscreenChangeListeners() {
  9225. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9226. delete this.fullscreenChangeBind;
  9227. }
  9228. }
  9229. exports.PDFPresentationMode = PDFPresentationMode;
  9230. /***/ }),
  9231. /* 141 */
  9232. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9233. Object.defineProperty(exports, "__esModule", ({
  9234. value: true
  9235. }));
  9236. exports.PDFRenderingQueue = void 0;
  9237. var _pdfjsLib = __webpack_require__(122);
  9238. var _ui_utils = __webpack_require__(97);
  9239. const CLEANUP_TIMEOUT = 30000;
  9240. class PDFRenderingQueue {
  9241. constructor() {
  9242. this.pdfViewer = null;
  9243. this.pdfThumbnailViewer = null;
  9244. this.onIdle = null;
  9245. this.highestPriorityPage = null;
  9246. this.idleTimeout = null;
  9247. this.printing = false;
  9248. this.isThumbnailViewEnabled = false;
  9249. Object.defineProperty(this, "hasViewer", {
  9250. value: () => !!this.pdfViewer
  9251. });
  9252. }
  9253. setViewer(pdfViewer) {
  9254. this.pdfViewer = pdfViewer;
  9255. }
  9256. setThumbnailViewer(pdfThumbnailViewer) {
  9257. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9258. }
  9259. isHighestPriority(view) {
  9260. return this.highestPriorityPage === view.renderingId;
  9261. }
  9262. renderHighestPriority(currentlyVisiblePages) {
  9263. if (this.idleTimeout) {
  9264. clearTimeout(this.idleTimeout);
  9265. this.idleTimeout = null;
  9266. }
  9267. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  9268. return;
  9269. }
  9270. if (this.isThumbnailViewEnabled && this.pdfThumbnailViewer?.forceRendering()) {
  9271. return;
  9272. }
  9273. if (this.printing) {
  9274. return;
  9275. }
  9276. if (this.onIdle) {
  9277. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  9278. }
  9279. }
  9280. getHighestPriority(visible, views, scrolledDown) {
  9281. let preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9282. const visibleViews = visible.views,
  9283. numVisible = visibleViews.length;
  9284. if (numVisible === 0) {
  9285. return null;
  9286. }
  9287. for (let i = 0; i < numVisible; i++) {
  9288. const view = visibleViews[i].view;
  9289. if (!this.isViewFinished(view)) {
  9290. return view;
  9291. }
  9292. }
  9293. const firstId = visible.first.id,
  9294. lastId = visible.last.id;
  9295. if (lastId - firstId + 1 > numVisible) {
  9296. const visibleIds = visible.ids;
  9297. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  9298. const holeId = scrolledDown ? firstId + i : lastId - i;
  9299. if (visibleIds.has(holeId)) {
  9300. continue;
  9301. }
  9302. const holeView = views[holeId - 1];
  9303. if (!this.isViewFinished(holeView)) {
  9304. return holeView;
  9305. }
  9306. }
  9307. }
  9308. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  9309. let preRenderView = views[preRenderIndex];
  9310. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9311. return preRenderView;
  9312. }
  9313. if (preRenderExtra) {
  9314. preRenderIndex += scrolledDown ? 1 : -1;
  9315. preRenderView = views[preRenderIndex];
  9316. if (preRenderView && !this.isViewFinished(preRenderView)) {
  9317. return preRenderView;
  9318. }
  9319. }
  9320. return null;
  9321. }
  9322. isViewFinished(view) {
  9323. return view.renderingState === _ui_utils.RenderingStates.FINISHED;
  9324. }
  9325. renderView(view) {
  9326. switch (view.renderingState) {
  9327. case _ui_utils.RenderingStates.FINISHED:
  9328. return false;
  9329. case _ui_utils.RenderingStates.PAUSED:
  9330. this.highestPriorityPage = view.renderingId;
  9331. view.resume();
  9332. break;
  9333. case _ui_utils.RenderingStates.RUNNING:
  9334. this.highestPriorityPage = view.renderingId;
  9335. break;
  9336. case _ui_utils.RenderingStates.INITIAL:
  9337. this.highestPriorityPage = view.renderingId;
  9338. view.draw().finally(() => {
  9339. this.renderHighestPriority();
  9340. }).catch(reason => {
  9341. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  9342. return;
  9343. }
  9344. console.error(`renderView: "${reason}"`);
  9345. });
  9346. break;
  9347. }
  9348. return true;
  9349. }
  9350. }
  9351. exports.PDFRenderingQueue = PDFRenderingQueue;
  9352. /***/ }),
  9353. /* 142 */
  9354. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9355. Object.defineProperty(exports, "__esModule", ({
  9356. value: true
  9357. }));
  9358. exports.PDFScriptingManager = void 0;
  9359. __webpack_require__(98);
  9360. __webpack_require__(109);
  9361. __webpack_require__(111);
  9362. __webpack_require__(114);
  9363. __webpack_require__(116);
  9364. __webpack_require__(118);
  9365. __webpack_require__(120);
  9366. __webpack_require__(76);
  9367. var _ui_utils = __webpack_require__(97);
  9368. var _pdfjsLib = __webpack_require__(122);
  9369. class PDFScriptingManager {
  9370. #closeCapability = null;
  9371. #destroyCapability = null;
  9372. #docProperties = null;
  9373. #eventBus = null;
  9374. #externalServices = null;
  9375. #pdfDocument = null;
  9376. #pdfViewer = null;
  9377. #ready = false;
  9378. #sandboxBundleSrc = null;
  9379. #scripting = null;
  9380. #willPrintCapability = null;
  9381. constructor(_ref) {
  9382. let {
  9383. eventBus,
  9384. sandboxBundleSrc = null,
  9385. externalServices = null,
  9386. docProperties = null
  9387. } = _ref;
  9388. this.#eventBus = eventBus;
  9389. this.#sandboxBundleSrc = sandboxBundleSrc;
  9390. this.#externalServices = externalServices;
  9391. this.#docProperties = docProperties;
  9392. }
  9393. setViewer(pdfViewer) {
  9394. this.#pdfViewer = pdfViewer;
  9395. }
  9396. async setDocument(pdfDocument) {
  9397. if (this.#pdfDocument) {
  9398. await this.#destroyScripting();
  9399. }
  9400. this.#pdfDocument = pdfDocument;
  9401. if (!pdfDocument) {
  9402. return;
  9403. }
  9404. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  9405. if (!objects && !docActions) {
  9406. await this.#destroyScripting();
  9407. return;
  9408. }
  9409. if (pdfDocument !== this.#pdfDocument) {
  9410. return;
  9411. }
  9412. try {
  9413. this.#scripting = this.#initScripting();
  9414. } catch (error) {
  9415. console.error(`setDocument: "${error.message}".`);
  9416. await this.#destroyScripting();
  9417. return;
  9418. }
  9419. this._internalEvents.set("updatefromsandbox", event => {
  9420. if (event?.source === window) {
  9421. this.#updateFromSandbox(event.detail);
  9422. }
  9423. });
  9424. this._internalEvents.set("dispatcheventinsandbox", event => {
  9425. this.#scripting?.dispatchEventInSandbox(event.detail);
  9426. });
  9427. this._internalEvents.set("pagechanging", _ref2 => {
  9428. let {
  9429. pageNumber,
  9430. previous
  9431. } = _ref2;
  9432. if (pageNumber === previous) {
  9433. return;
  9434. }
  9435. this.#dispatchPageClose(previous);
  9436. this.#dispatchPageOpen(pageNumber);
  9437. });
  9438. this._internalEvents.set("pagerendered", _ref3 => {
  9439. let {
  9440. pageNumber
  9441. } = _ref3;
  9442. if (!this._pageOpenPending.has(pageNumber)) {
  9443. return;
  9444. }
  9445. if (pageNumber !== this.#pdfViewer.currentPageNumber) {
  9446. return;
  9447. }
  9448. this.#dispatchPageOpen(pageNumber);
  9449. });
  9450. this._internalEvents.set("pagesdestroy", async () => {
  9451. await this.#dispatchPageClose(this.#pdfViewer.currentPageNumber);
  9452. await this.#scripting?.dispatchEventInSandbox({
  9453. id: "doc",
  9454. name: "WillClose"
  9455. });
  9456. this.#closeCapability?.resolve();
  9457. });
  9458. for (const [name, listener] of this._internalEvents) {
  9459. this.#eventBus._on(name, listener);
  9460. }
  9461. try {
  9462. const docProperties = await this.#docProperties(pdfDocument);
  9463. if (pdfDocument !== this.#pdfDocument) {
  9464. return;
  9465. }
  9466. await this.#scripting.createSandbox({
  9467. objects,
  9468. calculationOrder,
  9469. appInfo: {
  9470. platform: navigator.platform,
  9471. language: navigator.language
  9472. },
  9473. docInfo: {
  9474. ...docProperties,
  9475. actions: docActions
  9476. }
  9477. });
  9478. this.#eventBus.dispatch("sandboxcreated", {
  9479. source: this
  9480. });
  9481. } catch (error) {
  9482. console.error(`setDocument: "${error.message}".`);
  9483. await this.#destroyScripting();
  9484. return;
  9485. }
  9486. await this.#scripting?.dispatchEventInSandbox({
  9487. id: "doc",
  9488. name: "Open"
  9489. });
  9490. await this.#dispatchPageOpen(this.#pdfViewer.currentPageNumber, true);
  9491. Promise.resolve().then(() => {
  9492. if (pdfDocument === this.#pdfDocument) {
  9493. this.#ready = true;
  9494. }
  9495. });
  9496. }
  9497. async dispatchWillSave() {
  9498. return this.#scripting?.dispatchEventInSandbox({
  9499. id: "doc",
  9500. name: "WillSave"
  9501. });
  9502. }
  9503. async dispatchDidSave() {
  9504. return this.#scripting?.dispatchEventInSandbox({
  9505. id: "doc",
  9506. name: "DidSave"
  9507. });
  9508. }
  9509. async dispatchWillPrint() {
  9510. if (!this.#scripting) {
  9511. return;
  9512. }
  9513. await this.#willPrintCapability?.promise;
  9514. this.#willPrintCapability = new _pdfjsLib.PromiseCapability();
  9515. try {
  9516. await this.#scripting.dispatchEventInSandbox({
  9517. id: "doc",
  9518. name: "WillPrint"
  9519. });
  9520. } catch (ex) {
  9521. this.#willPrintCapability.resolve();
  9522. this.#willPrintCapability = null;
  9523. throw ex;
  9524. }
  9525. await this.#willPrintCapability.promise;
  9526. }
  9527. async dispatchDidPrint() {
  9528. return this.#scripting?.dispatchEventInSandbox({
  9529. id: "doc",
  9530. name: "DidPrint"
  9531. });
  9532. }
  9533. get destroyPromise() {
  9534. return this.#destroyCapability?.promise || null;
  9535. }
  9536. get ready() {
  9537. return this.#ready;
  9538. }
  9539. get _internalEvents() {
  9540. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  9541. }
  9542. get _pageOpenPending() {
  9543. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  9544. }
  9545. get _visitedPages() {
  9546. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  9547. }
  9548. async #updateFromSandbox(detail) {
  9549. const pdfViewer = this.#pdfViewer;
  9550. const isInPresentationMode = pdfViewer.isInPresentationMode || pdfViewer.isChangingPresentationMode;
  9551. const {
  9552. id,
  9553. siblings,
  9554. command,
  9555. value
  9556. } = detail;
  9557. if (!id) {
  9558. switch (command) {
  9559. case "clear":
  9560. console.clear();
  9561. break;
  9562. case "error":
  9563. console.error(value);
  9564. break;
  9565. case "layout":
  9566. if (!isInPresentationMode) {
  9567. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
  9568. pdfViewer.spreadMode = modes.spreadMode;
  9569. }
  9570. break;
  9571. case "page-num":
  9572. pdfViewer.currentPageNumber = value + 1;
  9573. break;
  9574. case "print":
  9575. await pdfViewer.pagesPromise;
  9576. this.#eventBus.dispatch("print", {
  9577. source: this
  9578. });
  9579. break;
  9580. case "println":
  9581. console.log(value);
  9582. break;
  9583. case "zoom":
  9584. if (!isInPresentationMode) {
  9585. pdfViewer.currentScaleValue = value;
  9586. }
  9587. break;
  9588. case "SaveAs":
  9589. this.#eventBus.dispatch("download", {
  9590. source: this
  9591. });
  9592. break;
  9593. case "FirstPage":
  9594. pdfViewer.currentPageNumber = 1;
  9595. break;
  9596. case "LastPage":
  9597. pdfViewer.currentPageNumber = pdfViewer.pagesCount;
  9598. break;
  9599. case "NextPage":
  9600. pdfViewer.nextPage();
  9601. break;
  9602. case "PrevPage":
  9603. pdfViewer.previousPage();
  9604. break;
  9605. case "ZoomViewIn":
  9606. if (!isInPresentationMode) {
  9607. pdfViewer.increaseScale();
  9608. }
  9609. break;
  9610. case "ZoomViewOut":
  9611. if (!isInPresentationMode) {
  9612. pdfViewer.decreaseScale();
  9613. }
  9614. break;
  9615. case "WillPrintFinished":
  9616. this.#willPrintCapability?.resolve();
  9617. this.#willPrintCapability = null;
  9618. break;
  9619. }
  9620. return;
  9621. }
  9622. if (isInPresentationMode && detail.focus) {
  9623. return;
  9624. }
  9625. delete detail.id;
  9626. delete detail.siblings;
  9627. const ids = siblings ? [id, ...siblings] : [id];
  9628. for (const elementId of ids) {
  9629. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  9630. if (element) {
  9631. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  9632. detail
  9633. }));
  9634. } else {
  9635. this.#pdfDocument?.annotationStorage.setValue(elementId, detail);
  9636. }
  9637. }
  9638. }
  9639. async #dispatchPageOpen(pageNumber) {
  9640. let initialize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9641. const pdfDocument = this.#pdfDocument,
  9642. visitedPages = this._visitedPages;
  9643. if (initialize) {
  9644. this.#closeCapability = new _pdfjsLib.PromiseCapability();
  9645. }
  9646. if (!this.#closeCapability) {
  9647. return;
  9648. }
  9649. const pageView = this.#pdfViewer.getPageView(pageNumber - 1);
  9650. if (pageView?.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9651. this._pageOpenPending.add(pageNumber);
  9652. return;
  9653. }
  9654. this._pageOpenPending.delete(pageNumber);
  9655. const actionsPromise = (async () => {
  9656. const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
  9657. if (pdfDocument !== this.#pdfDocument) {
  9658. return;
  9659. }
  9660. await this.#scripting?.dispatchEventInSandbox({
  9661. id: "page",
  9662. name: "PageOpen",
  9663. pageNumber,
  9664. actions
  9665. });
  9666. })();
  9667. visitedPages.set(pageNumber, actionsPromise);
  9668. }
  9669. async #dispatchPageClose(pageNumber) {
  9670. const pdfDocument = this.#pdfDocument,
  9671. visitedPages = this._visitedPages;
  9672. if (!this.#closeCapability) {
  9673. return;
  9674. }
  9675. if (this._pageOpenPending.has(pageNumber)) {
  9676. return;
  9677. }
  9678. const actionsPromise = visitedPages.get(pageNumber);
  9679. if (!actionsPromise) {
  9680. return;
  9681. }
  9682. visitedPages.set(pageNumber, null);
  9683. await actionsPromise;
  9684. if (pdfDocument !== this.#pdfDocument) {
  9685. return;
  9686. }
  9687. await this.#scripting?.dispatchEventInSandbox({
  9688. id: "page",
  9689. name: "PageClose",
  9690. pageNumber
  9691. });
  9692. }
  9693. #initScripting() {
  9694. this.#destroyCapability = new _pdfjsLib.PromiseCapability();
  9695. if (this.#scripting) {
  9696. throw new Error("#initScripting: Scripting already exists.");
  9697. }
  9698. return this.#externalServices.createScripting({
  9699. sandboxBundleSrc: this.#sandboxBundleSrc
  9700. });
  9701. }
  9702. async #destroyScripting() {
  9703. if (!this.#scripting) {
  9704. this.#pdfDocument = null;
  9705. this.#destroyCapability?.resolve();
  9706. return;
  9707. }
  9708. if (this.#closeCapability) {
  9709. await Promise.race([this.#closeCapability.promise, new Promise(resolve => {
  9710. setTimeout(resolve, 1000);
  9711. })]).catch(() => {});
  9712. this.#closeCapability = null;
  9713. }
  9714. this.#pdfDocument = null;
  9715. try {
  9716. await this.#scripting.destroySandbox();
  9717. } catch {}
  9718. this.#willPrintCapability?.reject(new Error("Scripting destroyed."));
  9719. this.#willPrintCapability = null;
  9720. for (const [name, listener] of this._internalEvents) {
  9721. this.#eventBus._off(name, listener);
  9722. }
  9723. this._internalEvents.clear();
  9724. this._pageOpenPending.clear();
  9725. this._visitedPages.clear();
  9726. this.#scripting = null;
  9727. this.#ready = false;
  9728. this.#destroyCapability?.resolve();
  9729. }
  9730. }
  9731. exports.PDFScriptingManager = PDFScriptingManager;
  9732. /***/ }),
  9733. /* 143 */
  9734. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9735. Object.defineProperty(exports, "__esModule", ({
  9736. value: true
  9737. }));
  9738. exports.PDFSidebar = void 0;
  9739. var _ui_utils = __webpack_require__(97);
  9740. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9741. const SIDEBAR_MIN_WIDTH = 200;
  9742. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9743. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9744. class PDFSidebar {
  9745. #isRTL = false;
  9746. #mouseMoveBound = this.#mouseMove.bind(this);
  9747. #mouseUpBound = this.#mouseUp.bind(this);
  9748. #outerContainerWidth = null;
  9749. #width = null;
  9750. constructor(_ref) {
  9751. let {
  9752. elements,
  9753. eventBus,
  9754. l10n
  9755. } = _ref;
  9756. this.isOpen = false;
  9757. this.active = _ui_utils.SidebarView.THUMBS;
  9758. this.isInitialViewSet = false;
  9759. this.isInitialEventDispatched = false;
  9760. this.onToggled = null;
  9761. this.onUpdateThumbnails = null;
  9762. this.outerContainer = elements.outerContainer;
  9763. this.sidebarContainer = elements.sidebarContainer;
  9764. this.toggleButton = elements.toggleButton;
  9765. this.resizer = elements.resizer;
  9766. this.thumbnailButton = elements.thumbnailButton;
  9767. this.outlineButton = elements.outlineButton;
  9768. this.attachmentsButton = elements.attachmentsButton;
  9769. this.layersButton = elements.layersButton;
  9770. this.thumbnailView = elements.thumbnailView;
  9771. this.outlineView = elements.outlineView;
  9772. this.attachmentsView = elements.attachmentsView;
  9773. this.layersView = elements.layersView;
  9774. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9775. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9776. this.eventBus = eventBus;
  9777. this.l10n = l10n;
  9778. l10n.getDirection().then(dir => {
  9779. this.#isRTL = dir === "rtl";
  9780. });
  9781. this.#addEventListeners();
  9782. }
  9783. reset() {
  9784. this.isInitialViewSet = false;
  9785. this.isInitialEventDispatched = false;
  9786. this.#hideUINotification(true);
  9787. this.switchView(_ui_utils.SidebarView.THUMBS);
  9788. this.outlineButton.disabled = false;
  9789. this.attachmentsButton.disabled = false;
  9790. this.layersButton.disabled = false;
  9791. this._currentOutlineItemButton.disabled = true;
  9792. }
  9793. get visibleView() {
  9794. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9795. }
  9796. setInitialView() {
  9797. let view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9798. if (this.isInitialViewSet) {
  9799. return;
  9800. }
  9801. this.isInitialViewSet = true;
  9802. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9803. this.#dispatchEvent();
  9804. return;
  9805. }
  9806. this.switchView(view, true);
  9807. if (!this.isInitialEventDispatched) {
  9808. this.#dispatchEvent();
  9809. }
  9810. }
  9811. switchView(view) {
  9812. let forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9813. const isViewChanged = view !== this.active;
  9814. let forceRendering = false;
  9815. switch (view) {
  9816. case _ui_utils.SidebarView.NONE:
  9817. if (this.isOpen) {
  9818. this.close();
  9819. }
  9820. return;
  9821. case _ui_utils.SidebarView.THUMBS:
  9822. if (this.isOpen && isViewChanged) {
  9823. forceRendering = true;
  9824. }
  9825. break;
  9826. case _ui_utils.SidebarView.OUTLINE:
  9827. if (this.outlineButton.disabled) {
  9828. return;
  9829. }
  9830. break;
  9831. case _ui_utils.SidebarView.ATTACHMENTS:
  9832. if (this.attachmentsButton.disabled) {
  9833. return;
  9834. }
  9835. break;
  9836. case _ui_utils.SidebarView.LAYERS:
  9837. if (this.layersButton.disabled) {
  9838. return;
  9839. }
  9840. break;
  9841. default:
  9842. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  9843. return;
  9844. }
  9845. this.active = view;
  9846. (0, _ui_utils.toggleCheckedBtn)(this.thumbnailButton, view === _ui_utils.SidebarView.THUMBS, this.thumbnailView);
  9847. (0, _ui_utils.toggleCheckedBtn)(this.outlineButton, view === _ui_utils.SidebarView.OUTLINE, this.outlineView);
  9848. (0, _ui_utils.toggleCheckedBtn)(this.attachmentsButton, view === _ui_utils.SidebarView.ATTACHMENTS, this.attachmentsView);
  9849. (0, _ui_utils.toggleCheckedBtn)(this.layersButton, view === _ui_utils.SidebarView.LAYERS, this.layersView);
  9850. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9851. if (forceOpen && !this.isOpen) {
  9852. this.open();
  9853. return;
  9854. }
  9855. if (forceRendering) {
  9856. this.onUpdateThumbnails();
  9857. this.onToggled();
  9858. }
  9859. if (isViewChanged) {
  9860. this.#dispatchEvent();
  9861. }
  9862. }
  9863. open() {
  9864. if (this.isOpen) {
  9865. return;
  9866. }
  9867. this.isOpen = true;
  9868. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true);
  9869. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9870. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9871. this.onUpdateThumbnails();
  9872. }
  9873. this.onToggled();
  9874. this.#dispatchEvent();
  9875. this.#hideUINotification();
  9876. }
  9877. close() {
  9878. if (!this.isOpen) {
  9879. return;
  9880. }
  9881. this.isOpen = false;
  9882. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false);
  9883. this.outerContainer.classList.add("sidebarMoving");
  9884. this.outerContainer.classList.remove("sidebarOpen");
  9885. this.onToggled();
  9886. this.#dispatchEvent();
  9887. }
  9888. toggle() {
  9889. if (this.isOpen) {
  9890. this.close();
  9891. } else {
  9892. this.open();
  9893. }
  9894. }
  9895. #dispatchEvent() {
  9896. if (this.isInitialViewSet) {
  9897. this.isInitialEventDispatched ||= true;
  9898. }
  9899. this.eventBus.dispatch("sidebarviewchanged", {
  9900. source: this,
  9901. view: this.visibleView
  9902. });
  9903. }
  9904. #showUINotification() {
  9905. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar_notification2");
  9906. this.l10n.translate(this.toggleButton);
  9907. if (!this.isOpen) {
  9908. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9909. }
  9910. }
  9911. #hideUINotification() {
  9912. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9913. if (this.isOpen || reset) {
  9914. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9915. }
  9916. if (reset) {
  9917. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar");
  9918. this.l10n.translate(this.toggleButton);
  9919. }
  9920. }
  9921. #addEventListeners() {
  9922. this.sidebarContainer.addEventListener("transitionend", evt => {
  9923. if (evt.target === this.sidebarContainer) {
  9924. this.outerContainer.classList.remove("sidebarMoving");
  9925. }
  9926. });
  9927. this.toggleButton.addEventListener("click", () => {
  9928. this.toggle();
  9929. });
  9930. this.thumbnailButton.addEventListener("click", () => {
  9931. this.switchView(_ui_utils.SidebarView.THUMBS);
  9932. });
  9933. this.outlineButton.addEventListener("click", () => {
  9934. this.switchView(_ui_utils.SidebarView.OUTLINE);
  9935. });
  9936. this.outlineButton.addEventListener("dblclick", () => {
  9937. this.eventBus.dispatch("toggleoutlinetree", {
  9938. source: this
  9939. });
  9940. });
  9941. this.attachmentsButton.addEventListener("click", () => {
  9942. this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9943. });
  9944. this.layersButton.addEventListener("click", () => {
  9945. this.switchView(_ui_utils.SidebarView.LAYERS);
  9946. });
  9947. this.layersButton.addEventListener("dblclick", () => {
  9948. this.eventBus.dispatch("resetlayers", {
  9949. source: this
  9950. });
  9951. });
  9952. this._currentOutlineItemButton.addEventListener("click", () => {
  9953. this.eventBus.dispatch("currentoutlineitem", {
  9954. source: this
  9955. });
  9956. });
  9957. const onTreeLoaded = (count, button, view) => {
  9958. button.disabled = !count;
  9959. if (count) {
  9960. this.#showUINotification();
  9961. } else if (this.active === view) {
  9962. this.switchView(_ui_utils.SidebarView.THUMBS);
  9963. }
  9964. };
  9965. this.eventBus._on("outlineloaded", evt => {
  9966. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9967. evt.currentOutlineItemPromise.then(enabled => {
  9968. if (!this.isInitialViewSet) {
  9969. return;
  9970. }
  9971. this._currentOutlineItemButton.disabled = !enabled;
  9972. });
  9973. });
  9974. this.eventBus._on("attachmentsloaded", evt => {
  9975. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9976. });
  9977. this.eventBus._on("layersloaded", evt => {
  9978. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView.LAYERS);
  9979. });
  9980. this.eventBus._on("presentationmodechanged", evt => {
  9981. if (evt.state === _ui_utils.PresentationModeState.NORMAL && this.visibleView === _ui_utils.SidebarView.THUMBS) {
  9982. this.onUpdateThumbnails();
  9983. }
  9984. });
  9985. this.resizer.addEventListener("mousedown", evt => {
  9986. if (evt.button !== 0) {
  9987. return;
  9988. }
  9989. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9990. window.addEventListener("mousemove", this.#mouseMoveBound);
  9991. window.addEventListener("mouseup", this.#mouseUpBound);
  9992. });
  9993. this.eventBus._on("resize", evt => {
  9994. if (evt.source !== window) {
  9995. return;
  9996. }
  9997. this.#outerContainerWidth = null;
  9998. if (!this.#width) {
  9999. return;
  10000. }
  10001. if (!this.isOpen) {
  10002. this.#updateWidth(this.#width);
  10003. return;
  10004. }
  10005. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  10006. const updated = this.#updateWidth(this.#width);
  10007. Promise.resolve().then(() => {
  10008. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10009. if (updated) {
  10010. this.eventBus.dispatch("resize", {
  10011. source: this
  10012. });
  10013. }
  10014. });
  10015. });
  10016. }
  10017. get outerContainerWidth() {
  10018. return this.#outerContainerWidth ||= this.outerContainer.clientWidth;
  10019. }
  10020. #updateWidth() {
  10021. let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10022. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  10023. if (width > maxWidth) {
  10024. width = maxWidth;
  10025. }
  10026. if (width < SIDEBAR_MIN_WIDTH) {
  10027. width = SIDEBAR_MIN_WIDTH;
  10028. }
  10029. if (width === this.#width) {
  10030. return false;
  10031. }
  10032. this.#width = width;
  10033. _ui_utils.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  10034. return true;
  10035. }
  10036. #mouseMove(evt) {
  10037. let width = evt.clientX;
  10038. if (this.#isRTL) {
  10039. width = this.outerContainerWidth - width;
  10040. }
  10041. this.#updateWidth(width);
  10042. }
  10043. #mouseUp(evt) {
  10044. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  10045. this.eventBus.dispatch("resize", {
  10046. source: this
  10047. });
  10048. window.removeEventListener("mousemove", this.#mouseMoveBound);
  10049. window.removeEventListener("mouseup", this.#mouseUpBound);
  10050. }
  10051. }
  10052. exports.PDFSidebar = PDFSidebar;
  10053. /***/ }),
  10054. /* 144 */
  10055. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10056. Object.defineProperty(exports, "__esModule", ({
  10057. value: true
  10058. }));
  10059. exports.PDFThumbnailViewer = void 0;
  10060. __webpack_require__(76);
  10061. __webpack_require__(89);
  10062. var _ui_utils = __webpack_require__(97);
  10063. var _pdf_thumbnail_view = __webpack_require__(145);
  10064. const THUMBNAIL_SCROLL_MARGIN = -19;
  10065. const THUMBNAIL_SELECTED_CLASS = "selected";
  10066. class PDFThumbnailViewer {
  10067. constructor(_ref) {
  10068. let {
  10069. container,
  10070. eventBus,
  10071. linkService,
  10072. renderingQueue,
  10073. l10n,
  10074. pageColors
  10075. } = _ref;
  10076. this.container = container;
  10077. this.eventBus = eventBus;
  10078. this.linkService = linkService;
  10079. this.renderingQueue = renderingQueue;
  10080. this.l10n = l10n;
  10081. this.pageColors = pageColors || null;
  10082. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  10083. this._resetView();
  10084. }
  10085. _scrollUpdated() {
  10086. this.renderingQueue.renderHighestPriority();
  10087. }
  10088. getThumbnail(index) {
  10089. return this._thumbnails[index];
  10090. }
  10091. _getVisibleThumbs() {
  10092. return (0, _ui_utils.getVisibleElements)({
  10093. scrollEl: this.container,
  10094. views: this._thumbnails
  10095. });
  10096. }
  10097. scrollThumbnailIntoView(pageNumber) {
  10098. if (!this.pdfDocument) {
  10099. return;
  10100. }
  10101. const thumbnailView = this._thumbnails[pageNumber - 1];
  10102. if (!thumbnailView) {
  10103. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  10104. return;
  10105. }
  10106. if (pageNumber !== this._currentPageNumber) {
  10107. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10108. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  10109. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10110. }
  10111. const {
  10112. first,
  10113. last,
  10114. views
  10115. } = this._getVisibleThumbs();
  10116. if (views.length > 0) {
  10117. let shouldScroll = false;
  10118. if (pageNumber <= first.id || pageNumber >= last.id) {
  10119. shouldScroll = true;
  10120. } else {
  10121. for (const {
  10122. id,
  10123. percent
  10124. } of views) {
  10125. if (id !== pageNumber) {
  10126. continue;
  10127. }
  10128. shouldScroll = percent < 100;
  10129. break;
  10130. }
  10131. }
  10132. if (shouldScroll) {
  10133. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  10134. top: THUMBNAIL_SCROLL_MARGIN
  10135. });
  10136. }
  10137. }
  10138. this._currentPageNumber = pageNumber;
  10139. }
  10140. get pagesRotation() {
  10141. return this._pagesRotation;
  10142. }
  10143. set pagesRotation(rotation) {
  10144. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10145. throw new Error("Invalid thumbnails rotation angle.");
  10146. }
  10147. if (!this.pdfDocument) {
  10148. return;
  10149. }
  10150. if (this._pagesRotation === rotation) {
  10151. return;
  10152. }
  10153. this._pagesRotation = rotation;
  10154. const updateArgs = {
  10155. rotation
  10156. };
  10157. for (const thumbnail of this._thumbnails) {
  10158. thumbnail.update(updateArgs);
  10159. }
  10160. }
  10161. cleanup() {
  10162. for (const thumbnail of this._thumbnails) {
  10163. if (thumbnail.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10164. thumbnail.reset();
  10165. }
  10166. }
  10167. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  10168. }
  10169. _resetView() {
  10170. this._thumbnails = [];
  10171. this._currentPageNumber = 1;
  10172. this._pageLabels = null;
  10173. this._pagesRotation = 0;
  10174. this.container.textContent = "";
  10175. }
  10176. setDocument(pdfDocument) {
  10177. if (this.pdfDocument) {
  10178. this._cancelRendering();
  10179. this._resetView();
  10180. }
  10181. this.pdfDocument = pdfDocument;
  10182. if (!pdfDocument) {
  10183. return;
  10184. }
  10185. const firstPagePromise = pdfDocument.getPage(1);
  10186. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10187. firstPagePromise.then(firstPdfPage => {
  10188. const pagesCount = pdfDocument.numPages;
  10189. const viewport = firstPdfPage.getViewport({
  10190. scale: 1
  10191. });
  10192. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10193. const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  10194. container: this.container,
  10195. eventBus: this.eventBus,
  10196. id: pageNum,
  10197. defaultViewport: viewport.clone(),
  10198. optionalContentConfigPromise,
  10199. linkService: this.linkService,
  10200. renderingQueue: this.renderingQueue,
  10201. l10n: this.l10n,
  10202. pageColors: this.pageColors
  10203. });
  10204. this._thumbnails.push(thumbnail);
  10205. }
  10206. this._thumbnails[0]?.setPdfPage(firstPdfPage);
  10207. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  10208. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  10209. }).catch(reason => {
  10210. console.error("Unable to initialize thumbnail viewer", reason);
  10211. });
  10212. }
  10213. _cancelRendering() {
  10214. for (const thumbnail of this._thumbnails) {
  10215. thumbnail.cancelRendering();
  10216. }
  10217. }
  10218. setPageLabels(labels) {
  10219. if (!this.pdfDocument) {
  10220. return;
  10221. }
  10222. if (!labels) {
  10223. this._pageLabels = null;
  10224. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10225. this._pageLabels = null;
  10226. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  10227. } else {
  10228. this._pageLabels = labels;
  10229. }
  10230. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  10231. this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
  10232. }
  10233. }
  10234. async #ensurePdfPageLoaded(thumbView) {
  10235. if (thumbView.pdfPage) {
  10236. return thumbView.pdfPage;
  10237. }
  10238. try {
  10239. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  10240. if (!thumbView.pdfPage) {
  10241. thumbView.setPdfPage(pdfPage);
  10242. }
  10243. return pdfPage;
  10244. } catch (reason) {
  10245. console.error("Unable to get page for thumb view", reason);
  10246. return null;
  10247. }
  10248. }
  10249. #getScrollAhead(visible) {
  10250. if (visible.first?.id === 1) {
  10251. return true;
  10252. } else if (visible.last?.id === this._thumbnails.length) {
  10253. return false;
  10254. }
  10255. return this.scroll.down;
  10256. }
  10257. forceRendering() {
  10258. const visibleThumbs = this._getVisibleThumbs();
  10259. const scrollAhead = this.#getScrollAhead(visibleThumbs);
  10260. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  10261. if (thumbView) {
  10262. this.#ensurePdfPageLoaded(thumbView).then(() => {
  10263. this.renderingQueue.renderView(thumbView);
  10264. });
  10265. return true;
  10266. }
  10267. return false;
  10268. }
  10269. }
  10270. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  10271. /***/ }),
  10272. /* 145 */
  10273. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10274. Object.defineProperty(exports, "__esModule", ({
  10275. value: true
  10276. }));
  10277. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  10278. __webpack_require__(76);
  10279. var _ui_utils = __webpack_require__(97);
  10280. var _pdfjsLib = __webpack_require__(122);
  10281. const DRAW_UPSCALE_FACTOR = 2;
  10282. const MAX_NUM_SCALING_STEPS = 3;
  10283. const THUMBNAIL_WIDTH = 98;
  10284. class TempImageFactory {
  10285. static #tempCanvas = null;
  10286. static getCanvas(width, height) {
  10287. const tempCanvas = this.#tempCanvas ||= document.createElement("canvas");
  10288. tempCanvas.width = width;
  10289. tempCanvas.height = height;
  10290. const ctx = tempCanvas.getContext("2d", {
  10291. alpha: false
  10292. });
  10293. ctx.save();
  10294. ctx.fillStyle = "rgb(255, 255, 255)";
  10295. ctx.fillRect(0, 0, width, height);
  10296. ctx.restore();
  10297. return [tempCanvas, tempCanvas.getContext("2d")];
  10298. }
  10299. static destroyCanvas() {
  10300. const tempCanvas = this.#tempCanvas;
  10301. if (tempCanvas) {
  10302. tempCanvas.width = 0;
  10303. tempCanvas.height = 0;
  10304. }
  10305. this.#tempCanvas = null;
  10306. }
  10307. }
  10308. exports.TempImageFactory = TempImageFactory;
  10309. class PDFThumbnailView {
  10310. constructor(_ref) {
  10311. let {
  10312. container,
  10313. eventBus,
  10314. id,
  10315. defaultViewport,
  10316. optionalContentConfigPromise,
  10317. linkService,
  10318. renderingQueue,
  10319. l10n,
  10320. pageColors
  10321. } = _ref;
  10322. this.id = id;
  10323. this.renderingId = "thumbnail" + id;
  10324. this.pageLabel = null;
  10325. this.pdfPage = null;
  10326. this.rotation = 0;
  10327. this.viewport = defaultViewport;
  10328. this.pdfPageRotate = defaultViewport.rotation;
  10329. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  10330. this.pageColors = pageColors || null;
  10331. this.eventBus = eventBus;
  10332. this.linkService = linkService;
  10333. this.renderingQueue = renderingQueue;
  10334. this.renderTask = null;
  10335. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  10336. this.resume = null;
  10337. this.l10n = l10n;
  10338. const anchor = document.createElement("a");
  10339. anchor.href = linkService.getAnchorUrl("#page=" + id);
  10340. this._thumbPageTitle.then(msg => {
  10341. anchor.title = msg;
  10342. });
  10343. anchor.onclick = function () {
  10344. linkService.goToPage(id);
  10345. return false;
  10346. };
  10347. this.anchor = anchor;
  10348. const div = document.createElement("div");
  10349. div.className = "thumbnail";
  10350. div.setAttribute("data-page-number", this.id);
  10351. this.div = div;
  10352. this.#updateDims();
  10353. const img = document.createElement("div");
  10354. img.className = "thumbnailImage";
  10355. this._placeholderImg = img;
  10356. div.append(img);
  10357. anchor.append(div);
  10358. container.append(anchor);
  10359. }
  10360. #updateDims() {
  10361. const {
  10362. width,
  10363. height
  10364. } = this.viewport;
  10365. const ratio = width / height;
  10366. this.canvasWidth = THUMBNAIL_WIDTH;
  10367. this.canvasHeight = this.canvasWidth / ratio | 0;
  10368. this.scale = this.canvasWidth / width;
  10369. const {
  10370. style
  10371. } = this.div;
  10372. style.setProperty("--thumbnail-width", `${this.canvasWidth}px`);
  10373. style.setProperty("--thumbnail-height", `${this.canvasHeight}px`);
  10374. }
  10375. setPdfPage(pdfPage) {
  10376. this.pdfPage = pdfPage;
  10377. this.pdfPageRotate = pdfPage.rotate;
  10378. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10379. this.viewport = pdfPage.getViewport({
  10380. scale: 1,
  10381. rotation: totalRotation
  10382. });
  10383. this.reset();
  10384. }
  10385. reset() {
  10386. this.cancelRendering();
  10387. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  10388. this.div.removeAttribute("data-loaded");
  10389. this.image?.replaceWith(this._placeholderImg);
  10390. this.#updateDims();
  10391. if (this.image) {
  10392. this.image.removeAttribute("src");
  10393. delete this.image;
  10394. }
  10395. }
  10396. update(_ref2) {
  10397. let {
  10398. rotation = null
  10399. } = _ref2;
  10400. if (typeof rotation === "number") {
  10401. this.rotation = rotation;
  10402. }
  10403. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10404. this.viewport = this.viewport.clone({
  10405. scale: 1,
  10406. rotation: totalRotation
  10407. });
  10408. this.reset();
  10409. }
  10410. cancelRendering() {
  10411. if (this.renderTask) {
  10412. this.renderTask.cancel();
  10413. this.renderTask = null;
  10414. }
  10415. this.resume = null;
  10416. }
  10417. _getPageDrawContext() {
  10418. let upscaleFactor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  10419. const canvas = document.createElement("canvas");
  10420. const ctx = canvas.getContext("2d", {
  10421. alpha: false
  10422. });
  10423. const outputScale = new _ui_utils.OutputScale();
  10424. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  10425. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  10426. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10427. return {
  10428. ctx,
  10429. canvas,
  10430. transform
  10431. };
  10432. }
  10433. _convertCanvasToImage(canvas) {
  10434. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10435. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  10436. }
  10437. const reducedCanvas = this._reduceImage(canvas);
  10438. const image = document.createElement("img");
  10439. image.className = "thumbnailImage";
  10440. this._thumbPageCanvas.then(msg => {
  10441. image.setAttribute("aria-label", msg);
  10442. });
  10443. image.src = reducedCanvas.toDataURL();
  10444. this.image = image;
  10445. this.div.setAttribute("data-loaded", true);
  10446. this._placeholderImg.replaceWith(image);
  10447. reducedCanvas.width = 0;
  10448. reducedCanvas.height = 0;
  10449. }
  10450. async #finishRenderTask(renderTask, canvas) {
  10451. let error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10452. if (renderTask === this.renderTask) {
  10453. this.renderTask = null;
  10454. }
  10455. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  10456. return;
  10457. }
  10458. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10459. this._convertCanvasToImage(canvas);
  10460. if (error) {
  10461. throw error;
  10462. }
  10463. }
  10464. async draw() {
  10465. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  10466. console.error("Must be in new state before drawing");
  10467. return undefined;
  10468. }
  10469. const {
  10470. pdfPage
  10471. } = this;
  10472. if (!pdfPage) {
  10473. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10474. throw new Error("pdfPage is not loaded");
  10475. }
  10476. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  10477. const {
  10478. ctx,
  10479. canvas,
  10480. transform
  10481. } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
  10482. const drawViewport = this.viewport.clone({
  10483. scale: DRAW_UPSCALE_FACTOR * this.scale
  10484. });
  10485. const renderContinueCallback = cont => {
  10486. if (!this.renderingQueue.isHighestPriority(this)) {
  10487. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  10488. this.resume = () => {
  10489. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  10490. cont();
  10491. };
  10492. return;
  10493. }
  10494. cont();
  10495. };
  10496. const renderContext = {
  10497. canvasContext: ctx,
  10498. transform,
  10499. viewport: drawViewport,
  10500. optionalContentConfigPromise: this._optionalContentConfigPromise,
  10501. pageColors: this.pageColors
  10502. };
  10503. const renderTask = this.renderTask = pdfPage.render(renderContext);
  10504. renderTask.onContinue = renderContinueCallback;
  10505. const resultPromise = renderTask.promise.then(() => this.#finishRenderTask(renderTask, canvas), error => this.#finishRenderTask(renderTask, canvas, error));
  10506. resultPromise.finally(() => {
  10507. canvas.width = 0;
  10508. canvas.height = 0;
  10509. this.eventBus.dispatch("thumbnailrendered", {
  10510. source: this,
  10511. pageNumber: this.id,
  10512. pdfPage: this.pdfPage
  10513. });
  10514. });
  10515. return resultPromise;
  10516. }
  10517. setImage(pageView) {
  10518. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  10519. return;
  10520. }
  10521. const {
  10522. thumbnailCanvas: canvas,
  10523. pdfPage,
  10524. scale
  10525. } = pageView;
  10526. if (!canvas) {
  10527. return;
  10528. }
  10529. if (!this.pdfPage) {
  10530. this.setPdfPage(pdfPage);
  10531. }
  10532. if (scale < this.scale) {
  10533. return;
  10534. }
  10535. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  10536. this._convertCanvasToImage(canvas);
  10537. }
  10538. _reduceImage(img) {
  10539. const {
  10540. ctx,
  10541. canvas
  10542. } = this._getPageDrawContext();
  10543. if (img.width <= 2 * canvas.width) {
  10544. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10545. return canvas;
  10546. }
  10547. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10548. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10549. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10550. while (reducedWidth > img.width || reducedHeight > img.height) {
  10551. reducedWidth >>= 1;
  10552. reducedHeight >>= 1;
  10553. }
  10554. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10555. while (reducedWidth > 2 * canvas.width) {
  10556. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10557. reducedWidth >>= 1;
  10558. reducedHeight >>= 1;
  10559. }
  10560. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10561. return canvas;
  10562. }
  10563. get _thumbPageTitle() {
  10564. return this.l10n.get("thumb_page_title", {
  10565. page: this.pageLabel ?? this.id
  10566. });
  10567. }
  10568. get _thumbPageCanvas() {
  10569. return this.l10n.get("thumb_page_canvas", {
  10570. page: this.pageLabel ?? this.id
  10571. });
  10572. }
  10573. setPageLabel(label) {
  10574. this.pageLabel = typeof label === "string" ? label : null;
  10575. this._thumbPageTitle.then(msg => {
  10576. this.anchor.title = msg;
  10577. });
  10578. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10579. return;
  10580. }
  10581. this._thumbPageCanvas.then(msg => {
  10582. this.image?.setAttribute("aria-label", msg);
  10583. });
  10584. }
  10585. }
  10586. exports.PDFThumbnailView = PDFThumbnailView;
  10587. /***/ }),
  10588. /* 146 */
  10589. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10590. Object.defineProperty(exports, "__esModule", ({
  10591. value: true
  10592. }));
  10593. exports.PagesCountLimit = exports.PDFViewer = exports.PDFPageViewBuffer = void 0;
  10594. __webpack_require__(98);
  10595. __webpack_require__(109);
  10596. __webpack_require__(111);
  10597. __webpack_require__(114);
  10598. __webpack_require__(116);
  10599. __webpack_require__(118);
  10600. __webpack_require__(120);
  10601. __webpack_require__(76);
  10602. __webpack_require__(89);
  10603. var _pdfjsLib = __webpack_require__(122);
  10604. var _ui_utils = __webpack_require__(97);
  10605. var _l10n_utils = __webpack_require__(147);
  10606. var _pdf_page_view = __webpack_require__(148);
  10607. var _pdf_rendering_queue = __webpack_require__(141);
  10608. var _pdf_link_service = __webpack_require__(125);
  10609. const DEFAULT_CACHE_SIZE = 10;
  10610. const PagesCountLimit = {
  10611. FORCE_SCROLL_MODE_PAGE: 15000,
  10612. FORCE_LAZY_PAGE_INIT: 7500,
  10613. PAUSE_EAGER_PAGE_INIT: 250
  10614. };
  10615. exports.PagesCountLimit = PagesCountLimit;
  10616. function isValidAnnotationEditorMode(mode) {
  10617. return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !== _pdfjsLib.AnnotationEditorType.DISABLE;
  10618. }
  10619. class PDFPageViewBuffer {
  10620. #buf = new Set();
  10621. #size = 0;
  10622. constructor(size) {
  10623. this.#size = size;
  10624. }
  10625. push(view) {
  10626. const buf = this.#buf;
  10627. if (buf.has(view)) {
  10628. buf.delete(view);
  10629. }
  10630. buf.add(view);
  10631. if (buf.size > this.#size) {
  10632. this.#destroyFirstView();
  10633. }
  10634. }
  10635. resize(newSize) {
  10636. let idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10637. this.#size = newSize;
  10638. const buf = this.#buf;
  10639. if (idsToKeep) {
  10640. const ii = buf.size;
  10641. let i = 1;
  10642. for (const view of buf) {
  10643. if (idsToKeep.has(view.id)) {
  10644. buf.delete(view);
  10645. buf.add(view);
  10646. }
  10647. if (++i > ii) {
  10648. break;
  10649. }
  10650. }
  10651. }
  10652. while (buf.size > this.#size) {
  10653. this.#destroyFirstView();
  10654. }
  10655. }
  10656. has(view) {
  10657. return this.#buf.has(view);
  10658. }
  10659. [Symbol.iterator]() {
  10660. return this.#buf.keys();
  10661. }
  10662. #destroyFirstView() {
  10663. const firstView = this.#buf.keys().next().value;
  10664. firstView?.destroy();
  10665. this.#buf.delete(firstView);
  10666. }
  10667. }
  10668. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  10669. class PDFViewer {
  10670. #buffer = null;
  10671. #annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  10672. #annotationEditorUIManager = null;
  10673. #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10674. #containerTopLeft = null;
  10675. #copyCallbackBound = null;
  10676. #enablePermissions = false;
  10677. #getAllTextInProgress = false;
  10678. #hiddenCopyElement = null;
  10679. #interruptCopyCondition = false;
  10680. #previousContainerHeight = 0;
  10681. #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
  10682. #scrollModePageState = null;
  10683. #onVisibilityChange = null;
  10684. #scaleTimeoutId = null;
  10685. #textLayerMode = _ui_utils.TextLayerMode.ENABLE;
  10686. constructor(options) {
  10687. const viewerVersion = '3.10.111';
  10688. if (_pdfjsLib.version !== viewerVersion) {
  10689. throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
  10690. }
  10691. this.container = options.container;
  10692. this.viewer = options.viewer || options.container.firstElementChild;
  10693. if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
  10694. throw new Error("Invalid `container` and/or `viewer` option.");
  10695. }
  10696. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  10697. throw new Error("The `container` must be absolutely positioned.");
  10698. }
  10699. this.#resizeObserver.observe(this.container);
  10700. this.eventBus = options.eventBus;
  10701. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10702. this.downloadManager = options.downloadManager || null;
  10703. this.findController = options.findController || null;
  10704. if (this.findController) {
  10705. this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
  10706. }
  10707. this._scriptingManager = options.scriptingManager || null;
  10708. this.#textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  10709. this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10710. this.#annotationEditorMode = options.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.NONE;
  10711. this.imageResourcesPath = options.imageResourcesPath || "";
  10712. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10713. this.removePageBorders = options.removePageBorders || false;
  10714. if (options.useOnlyCssZoom) {
  10715. console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
  10716. options.maxCanvasPixels = 0;
  10717. }
  10718. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  10719. this.maxCanvasPixels = options.maxCanvasPixels;
  10720. this.l10n = options.l10n || _l10n_utils.NullL10n;
  10721. this.#enablePermissions = options.enablePermissions || false;
  10722. this.pageColors = options.pageColors || null;
  10723. this.defaultRenderingQueue = !options.renderingQueue;
  10724. if (this.defaultRenderingQueue) {
  10725. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10726. this.renderingQueue.setViewer(this);
  10727. } else {
  10728. this.renderingQueue = options.renderingQueue;
  10729. }
  10730. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10731. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10732. this._onBeforeDraw = this._onAfterDraw = null;
  10733. this._resetView();
  10734. if (this.removePageBorders) {
  10735. this.viewer.classList.add("removePageBorders");
  10736. }
  10737. this.#updateContainerHeightCss();
  10738. this.eventBus._on("thumbnailrendered", _ref => {
  10739. let {
  10740. pageNumber,
  10741. pdfPage
  10742. } = _ref;
  10743. const pageView = this._pages[pageNumber - 1];
  10744. if (!this.#buffer.has(pageView)) {
  10745. pdfPage?.cleanup();
  10746. }
  10747. });
  10748. }
  10749. get pagesCount() {
  10750. return this._pages.length;
  10751. }
  10752. getPageView(index) {
  10753. return this._pages[index];
  10754. }
  10755. getCachedPageViews() {
  10756. return new Set(this.#buffer);
  10757. }
  10758. get pageViewsReady() {
  10759. return this._pagesCapability.settled && this._pages.every(pageView => pageView?.pdfPage);
  10760. }
  10761. get renderForms() {
  10762. return this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  10763. }
  10764. get enableScripting() {
  10765. return !!this._scriptingManager;
  10766. }
  10767. get currentPageNumber() {
  10768. return this._currentPageNumber;
  10769. }
  10770. set currentPageNumber(val) {
  10771. if (!Number.isInteger(val)) {
  10772. throw new Error("Invalid page number.");
  10773. }
  10774. if (!this.pdfDocument) {
  10775. return;
  10776. }
  10777. if (!this._setCurrentPageNumber(val, true)) {
  10778. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  10779. }
  10780. }
  10781. _setCurrentPageNumber(val) {
  10782. let resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10783. if (this._currentPageNumber === val) {
  10784. if (resetCurrentPageView) {
  10785. this.#resetCurrentPageView();
  10786. }
  10787. return true;
  10788. }
  10789. if (!(0 < val && val <= this.pagesCount)) {
  10790. return false;
  10791. }
  10792. const previous = this._currentPageNumber;
  10793. this._currentPageNumber = val;
  10794. this.eventBus.dispatch("pagechanging", {
  10795. source: this,
  10796. pageNumber: val,
  10797. pageLabel: this._pageLabels?.[val - 1] ?? null,
  10798. previous
  10799. });
  10800. if (resetCurrentPageView) {
  10801. this.#resetCurrentPageView();
  10802. }
  10803. return true;
  10804. }
  10805. get currentPageLabel() {
  10806. return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
  10807. }
  10808. set currentPageLabel(val) {
  10809. if (!this.pdfDocument) {
  10810. return;
  10811. }
  10812. let page = val | 0;
  10813. if (this._pageLabels) {
  10814. const i = this._pageLabels.indexOf(val);
  10815. if (i >= 0) {
  10816. page = i + 1;
  10817. }
  10818. }
  10819. if (!this._setCurrentPageNumber(page, true)) {
  10820. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  10821. }
  10822. }
  10823. get currentScale() {
  10824. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  10825. }
  10826. set currentScale(val) {
  10827. if (isNaN(val)) {
  10828. throw new Error("Invalid numeric scale.");
  10829. }
  10830. if (!this.pdfDocument) {
  10831. return;
  10832. }
  10833. this.#setScale(val, {
  10834. noScroll: false
  10835. });
  10836. }
  10837. get currentScaleValue() {
  10838. return this._currentScaleValue;
  10839. }
  10840. set currentScaleValue(val) {
  10841. if (!this.pdfDocument) {
  10842. return;
  10843. }
  10844. this.#setScale(val, {
  10845. noScroll: false
  10846. });
  10847. }
  10848. get pagesRotation() {
  10849. return this._pagesRotation;
  10850. }
  10851. set pagesRotation(rotation) {
  10852. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10853. throw new Error("Invalid pages rotation angle.");
  10854. }
  10855. if (!this.pdfDocument) {
  10856. return;
  10857. }
  10858. rotation %= 360;
  10859. if (rotation < 0) {
  10860. rotation += 360;
  10861. }
  10862. if (this._pagesRotation === rotation) {
  10863. return;
  10864. }
  10865. this._pagesRotation = rotation;
  10866. const pageNumber = this._currentPageNumber;
  10867. this.refresh(true, {
  10868. rotation
  10869. });
  10870. if (this._currentScaleValue) {
  10871. this.#setScale(this._currentScaleValue, {
  10872. noScroll: true
  10873. });
  10874. }
  10875. this.eventBus.dispatch("rotationchanging", {
  10876. source: this,
  10877. pagesRotation: rotation,
  10878. pageNumber
  10879. });
  10880. if (this.defaultRenderingQueue) {
  10881. this.update();
  10882. }
  10883. }
  10884. get firstPagePromise() {
  10885. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10886. }
  10887. get onePageRendered() {
  10888. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10889. }
  10890. get pagesPromise() {
  10891. return this.pdfDocument ? this._pagesCapability.promise : null;
  10892. }
  10893. #layerProperties() {
  10894. const self = this;
  10895. return {
  10896. get annotationEditorUIManager() {
  10897. return self.#annotationEditorUIManager;
  10898. },
  10899. get annotationStorage() {
  10900. return self.pdfDocument?.annotationStorage;
  10901. },
  10902. get downloadManager() {
  10903. return self.downloadManager;
  10904. },
  10905. get enableScripting() {
  10906. return !!self._scriptingManager;
  10907. },
  10908. get fieldObjectsPromise() {
  10909. return self.pdfDocument?.getFieldObjects();
  10910. },
  10911. get findController() {
  10912. return self.findController;
  10913. },
  10914. get hasJSActionsPromise() {
  10915. return self.pdfDocument?.hasJSActions();
  10916. },
  10917. get linkService() {
  10918. return self.linkService;
  10919. }
  10920. };
  10921. }
  10922. #initializePermissions(permissions) {
  10923. const params = {
  10924. annotationEditorMode: this.#annotationEditorMode,
  10925. annotationMode: this.#annotationMode,
  10926. textLayerMode: this.#textLayerMode
  10927. };
  10928. if (!permissions) {
  10929. return params;
  10930. }
  10931. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY) && this.#textLayerMode === _ui_utils.TextLayerMode.ENABLE) {
  10932. params.textLayerMode = _ui_utils.TextLayerMode.ENABLE_PERMISSIONS;
  10933. }
  10934. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) {
  10935. params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
  10936. }
  10937. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
  10938. params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE;
  10939. }
  10940. return params;
  10941. }
  10942. #onePageRenderedOrForceFetch() {
  10943. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10944. return Promise.resolve();
  10945. }
  10946. const visibilityChangePromise = new Promise(resolve => {
  10947. this.#onVisibilityChange = () => {
  10948. if (document.visibilityState !== "hidden") {
  10949. return;
  10950. }
  10951. resolve();
  10952. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  10953. this.#onVisibilityChange = null;
  10954. };
  10955. document.addEventListener("visibilitychange", this.#onVisibilityChange);
  10956. });
  10957. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  10958. }
  10959. async getAllText() {
  10960. const texts = [];
  10961. const buffer = [];
  10962. for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
  10963. if (this.#interruptCopyCondition) {
  10964. return null;
  10965. }
  10966. buffer.length = 0;
  10967. const page = await this.pdfDocument.getPage(pageNum);
  10968. const {
  10969. items
  10970. } = await page.getTextContent();
  10971. for (const item of items) {
  10972. if (item.str) {
  10973. buffer.push(item.str);
  10974. }
  10975. if (item.hasEOL) {
  10976. buffer.push("\n");
  10977. }
  10978. }
  10979. texts.push((0, _ui_utils.removeNullCharacters)(buffer.join("")));
  10980. }
  10981. return texts.join("\n");
  10982. }
  10983. #copyCallback(textLayerMode, event) {
  10984. const selection = document.getSelection();
  10985. const {
  10986. focusNode,
  10987. anchorNode
  10988. } = selection;
  10989. if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
  10990. if (this.#getAllTextInProgress || textLayerMode === _ui_utils.TextLayerMode.ENABLE_PERMISSIONS) {
  10991. event.preventDefault();
  10992. event.stopPropagation();
  10993. return;
  10994. }
  10995. this.#getAllTextInProgress = true;
  10996. const savedCursor = this.container.style.cursor;
  10997. this.container.style.cursor = "wait";
  10998. const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
  10999. window.addEventListener("keydown", interruptCopy);
  11000. this.getAllText().then(async text => {
  11001. if (text !== null) {
  11002. await navigator.clipboard.writeText(text);
  11003. }
  11004. }).catch(reason => {
  11005. console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
  11006. }).finally(() => {
  11007. this.#getAllTextInProgress = false;
  11008. this.#interruptCopyCondition = false;
  11009. window.removeEventListener("keydown", interruptCopy);
  11010. this.container.style.cursor = savedCursor;
  11011. });
  11012. event.preventDefault();
  11013. event.stopPropagation();
  11014. }
  11015. }
  11016. setDocument(pdfDocument) {
  11017. if (this.pdfDocument) {
  11018. this.eventBus.dispatch("pagesdestroy", {
  11019. source: this
  11020. });
  11021. this._cancelRendering();
  11022. this._resetView();
  11023. this.findController?.setDocument(null);
  11024. this._scriptingManager?.setDocument(null);
  11025. if (this.#annotationEditorUIManager) {
  11026. this.#annotationEditorUIManager.destroy();
  11027. this.#annotationEditorUIManager = null;
  11028. }
  11029. }
  11030. this.pdfDocument = pdfDocument;
  11031. if (!pdfDocument) {
  11032. return;
  11033. }
  11034. const pagesCount = pdfDocument.numPages;
  11035. const firstPagePromise = pdfDocument.getPage(1);
  11036. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  11037. const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
  11038. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11039. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  11040. const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  11041. this.eventBus.dispatch("scrollmodechanged", {
  11042. source: this,
  11043. mode
  11044. });
  11045. }
  11046. this._pagesCapability.promise.then(() => {
  11047. this.eventBus.dispatch("pagesloaded", {
  11048. source: this,
  11049. pagesCount
  11050. });
  11051. }, () => {});
  11052. this._onBeforeDraw = evt => {
  11053. const pageView = this._pages[evt.pageNumber - 1];
  11054. if (!pageView) {
  11055. return;
  11056. }
  11057. this.#buffer.push(pageView);
  11058. };
  11059. this.eventBus._on("pagerender", this._onBeforeDraw);
  11060. this._onAfterDraw = evt => {
  11061. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  11062. return;
  11063. }
  11064. this._onePageRenderedCapability.resolve({
  11065. timestamp: evt.timestamp
  11066. });
  11067. this.eventBus._off("pagerendered", this._onAfterDraw);
  11068. this._onAfterDraw = null;
  11069. if (this.#onVisibilityChange) {
  11070. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11071. this.#onVisibilityChange = null;
  11072. }
  11073. };
  11074. this.eventBus._on("pagerendered", this._onAfterDraw);
  11075. Promise.all([firstPagePromise, permissionsPromise]).then(_ref2 => {
  11076. let [firstPdfPage, permissions] = _ref2;
  11077. if (pdfDocument !== this.pdfDocument) {
  11078. return;
  11079. }
  11080. this._firstPageCapability.resolve(firstPdfPage);
  11081. this._optionalContentConfigPromise = optionalContentConfigPromise;
  11082. const {
  11083. annotationEditorMode,
  11084. annotationMode,
  11085. textLayerMode
  11086. } = this.#initializePermissions(permissions);
  11087. if (textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  11088. const element = this.#hiddenCopyElement = document.createElement("div");
  11089. element.id = "hiddenCopyElement";
  11090. this.viewer.before(element);
  11091. }
  11092. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  11093. const mode = annotationEditorMode;
  11094. if (pdfDocument.isPureXfa) {
  11095. console.warn("Warning: XFA-editing is not implemented.");
  11096. } else if (isValidAnnotationEditorMode(mode)) {
  11097. this.#annotationEditorUIManager = new _pdfjsLib.AnnotationEditorUIManager(this.container, this.viewer, this.eventBus, pdfDocument, this.pageColors);
  11098. if (mode !== _pdfjsLib.AnnotationEditorType.NONE) {
  11099. this.#annotationEditorUIManager.updateMode(mode);
  11100. }
  11101. } else {
  11102. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  11103. }
  11104. }
  11105. const layerProperties = this.#layerProperties.bind(this);
  11106. const viewerElement = this._scrollMode === _ui_utils.ScrollMode.PAGE ? null : this.viewer;
  11107. const scale = this.currentScale;
  11108. const viewport = firstPdfPage.getViewport({
  11109. scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  11110. });
  11111. this.viewer.style.setProperty("--scale-factor", viewport.scale);
  11112. if (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas") {
  11113. this.viewer.style.setProperty("--hcm-highligh-filter", pdfDocument.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  11114. }
  11115. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  11116. const pageView = new _pdf_page_view.PDFPageView({
  11117. container: viewerElement,
  11118. eventBus: this.eventBus,
  11119. id: pageNum,
  11120. scale,
  11121. defaultViewport: viewport.clone(),
  11122. optionalContentConfigPromise,
  11123. renderingQueue: this.renderingQueue,
  11124. textLayerMode,
  11125. annotationMode,
  11126. imageResourcesPath: this.imageResourcesPath,
  11127. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  11128. maxCanvasPixels: this.maxCanvasPixels,
  11129. pageColors: this.pageColors,
  11130. l10n: this.l10n,
  11131. layerProperties
  11132. });
  11133. this._pages.push(pageView);
  11134. }
  11135. const firstPageView = this._pages[0];
  11136. if (firstPageView) {
  11137. firstPageView.setPdfPage(firstPdfPage);
  11138. this.linkService.cachePageRef(1, firstPdfPage.ref);
  11139. }
  11140. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11141. this.#ensurePageViewVisible();
  11142. } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  11143. this._updateSpreadMode();
  11144. }
  11145. this.#onePageRenderedOrForceFetch().then(async () => {
  11146. this.findController?.setDocument(pdfDocument);
  11147. this._scriptingManager?.setDocument(pdfDocument);
  11148. if (this.#hiddenCopyElement) {
  11149. this.#copyCallbackBound = this.#copyCallback.bind(this, textLayerMode);
  11150. document.addEventListener("copy", this.#copyCallbackBound);
  11151. }
  11152. if (this.#annotationEditorUIManager) {
  11153. this.eventBus.dispatch("annotationeditormodechanged", {
  11154. source: this,
  11155. mode: this.#annotationEditorMode
  11156. });
  11157. }
  11158. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  11159. this._pagesCapability.resolve();
  11160. return;
  11161. }
  11162. let getPagesLeft = pagesCount - 1;
  11163. if (getPagesLeft <= 0) {
  11164. this._pagesCapability.resolve();
  11165. return;
  11166. }
  11167. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  11168. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  11169. const pageView = this._pages[pageNum - 1];
  11170. if (!pageView.pdfPage) {
  11171. pageView.setPdfPage(pdfPage);
  11172. }
  11173. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  11174. if (--getPagesLeft === 0) {
  11175. this._pagesCapability.resolve();
  11176. }
  11177. }, reason => {
  11178. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  11179. if (--getPagesLeft === 0) {
  11180. this._pagesCapability.resolve();
  11181. }
  11182. });
  11183. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  11184. await promise;
  11185. }
  11186. }
  11187. });
  11188. this.eventBus.dispatch("pagesinit", {
  11189. source: this
  11190. });
  11191. pdfDocument.getMetadata().then(_ref3 => {
  11192. let {
  11193. info
  11194. } = _ref3;
  11195. if (pdfDocument !== this.pdfDocument) {
  11196. return;
  11197. }
  11198. if (info.Language) {
  11199. this.viewer.lang = info.Language;
  11200. }
  11201. });
  11202. if (this.defaultRenderingQueue) {
  11203. this.update();
  11204. }
  11205. }).catch(reason => {
  11206. console.error("Unable to initialize viewer", reason);
  11207. this._pagesCapability.reject(reason);
  11208. });
  11209. }
  11210. setPageLabels(labels) {
  11211. if (!this.pdfDocument) {
  11212. return;
  11213. }
  11214. if (!labels) {
  11215. this._pageLabels = null;
  11216. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  11217. this._pageLabels = null;
  11218. console.error(`setPageLabels: Invalid page labels.`);
  11219. } else {
  11220. this._pageLabels = labels;
  11221. }
  11222. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  11223. this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
  11224. }
  11225. }
  11226. _resetView() {
  11227. this._pages = [];
  11228. this._currentPageNumber = 1;
  11229. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  11230. this._currentScaleValue = null;
  11231. this._pageLabels = null;
  11232. this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  11233. this._location = null;
  11234. this._pagesRotation = 0;
  11235. this._optionalContentConfigPromise = null;
  11236. this._firstPageCapability = new _pdfjsLib.PromiseCapability();
  11237. this._onePageRenderedCapability = new _pdfjsLib.PromiseCapability();
  11238. this._pagesCapability = new _pdfjsLib.PromiseCapability();
  11239. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  11240. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  11241. this._spreadMode = _ui_utils.SpreadMode.NONE;
  11242. this.#scrollModePageState = {
  11243. previousPageNumber: 1,
  11244. scrollDown: true,
  11245. pages: []
  11246. };
  11247. if (this._onBeforeDraw) {
  11248. this.eventBus._off("pagerender", this._onBeforeDraw);
  11249. this._onBeforeDraw = null;
  11250. }
  11251. if (this._onAfterDraw) {
  11252. this.eventBus._off("pagerendered", this._onAfterDraw);
  11253. this._onAfterDraw = null;
  11254. }
  11255. if (this.#onVisibilityChange) {
  11256. document.removeEventListener("visibilitychange", this.#onVisibilityChange);
  11257. this.#onVisibilityChange = null;
  11258. }
  11259. this.viewer.textContent = "";
  11260. this._updateScrollMode();
  11261. this.viewer.removeAttribute("lang");
  11262. if (this.#hiddenCopyElement) {
  11263. document.removeEventListener("copy", this.#copyCallbackBound);
  11264. this.#copyCallbackBound = null;
  11265. this.#hiddenCopyElement.remove();
  11266. this.#hiddenCopyElement = null;
  11267. }
  11268. }
  11269. #ensurePageViewVisible() {
  11270. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  11271. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  11272. }
  11273. const pageNumber = this._currentPageNumber,
  11274. state = this.#scrollModePageState,
  11275. viewer = this.viewer;
  11276. viewer.textContent = "";
  11277. state.pages.length = 0;
  11278. if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
  11279. const pageView = this._pages[pageNumber - 1];
  11280. viewer.append(pageView.div);
  11281. state.pages.push(pageView);
  11282. } else {
  11283. const pageIndexSet = new Set(),
  11284. parity = this._spreadMode - 1;
  11285. if (parity === -1) {
  11286. pageIndexSet.add(pageNumber - 1);
  11287. } else if (pageNumber % 2 !== parity) {
  11288. pageIndexSet.add(pageNumber - 1);
  11289. pageIndexSet.add(pageNumber);
  11290. } else {
  11291. pageIndexSet.add(pageNumber - 2);
  11292. pageIndexSet.add(pageNumber - 1);
  11293. }
  11294. const spread = document.createElement("div");
  11295. spread.className = "spread";
  11296. if (this.isInPresentationMode) {
  11297. const dummyPage = document.createElement("div");
  11298. dummyPage.className = "dummyPage";
  11299. spread.append(dummyPage);
  11300. }
  11301. for (const i of pageIndexSet) {
  11302. const pageView = this._pages[i];
  11303. if (!pageView) {
  11304. continue;
  11305. }
  11306. spread.append(pageView.div);
  11307. state.pages.push(pageView);
  11308. }
  11309. viewer.append(spread);
  11310. }
  11311. state.scrollDown = pageNumber >= state.previousPageNumber;
  11312. state.previousPageNumber = pageNumber;
  11313. }
  11314. _scrollUpdate() {
  11315. if (this.pagesCount === 0) {
  11316. return;
  11317. }
  11318. this.update();
  11319. }
  11320. #scrollIntoView(pageView) {
  11321. let pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11322. const {
  11323. div,
  11324. id
  11325. } = pageView;
  11326. if (this._currentPageNumber !== id) {
  11327. this._setCurrentPageNumber(id);
  11328. }
  11329. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11330. this.#ensurePageViewVisible();
  11331. this.update();
  11332. }
  11333. if (!pageSpot && !this.isInPresentationMode) {
  11334. const left = div.offsetLeft + div.clientLeft,
  11335. right = left + div.clientWidth;
  11336. const {
  11337. scrollLeft,
  11338. clientWidth
  11339. } = this.container;
  11340. if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  11341. pageSpot = {
  11342. left: 0,
  11343. top: 0
  11344. };
  11345. }
  11346. }
  11347. (0, _ui_utils.scrollIntoView)(div, pageSpot);
  11348. if (!this._currentScaleValue && this._location) {
  11349. this._location = null;
  11350. }
  11351. }
  11352. #isSameScale(newScale) {
  11353. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  11354. }
  11355. #setScaleUpdatePages(newScale, newValue, _ref4) {
  11356. let {
  11357. noScroll = false,
  11358. preset = false,
  11359. drawingDelay = -1
  11360. } = _ref4;
  11361. this._currentScaleValue = newValue.toString();
  11362. if (this.#isSameScale(newScale)) {
  11363. if (preset) {
  11364. this.eventBus.dispatch("scalechanging", {
  11365. source: this,
  11366. scale: newScale,
  11367. presetValue: newValue
  11368. });
  11369. }
  11370. return;
  11371. }
  11372. this.viewer.style.setProperty("--scale-factor", newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  11373. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  11374. this.refresh(true, {
  11375. scale: newScale,
  11376. drawingDelay: postponeDrawing ? drawingDelay : -1
  11377. });
  11378. if (postponeDrawing) {
  11379. this.#scaleTimeoutId = setTimeout(() => {
  11380. this.#scaleTimeoutId = null;
  11381. this.refresh();
  11382. }, drawingDelay);
  11383. }
  11384. this._currentScale = newScale;
  11385. if (!noScroll) {
  11386. let page = this._currentPageNumber,
  11387. dest;
  11388. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  11389. page = this._location.pageNumber;
  11390. dest = [null, {
  11391. name: "XYZ"
  11392. }, this._location.left, this._location.top, null];
  11393. }
  11394. this.scrollPageIntoView({
  11395. pageNumber: page,
  11396. destArray: dest,
  11397. allowNegativeOffset: true
  11398. });
  11399. }
  11400. this.eventBus.dispatch("scalechanging", {
  11401. source: this,
  11402. scale: newScale,
  11403. presetValue: preset ? newValue : undefined
  11404. });
  11405. if (this.defaultRenderingQueue) {
  11406. this.update();
  11407. }
  11408. }
  11409. get #pageWidthScaleFactor() {
  11410. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
  11411. return 2;
  11412. }
  11413. return 1;
  11414. }
  11415. #setScale(value, options) {
  11416. let scale = parseFloat(value);
  11417. if (scale > 0) {
  11418. options.preset = false;
  11419. this.#setScaleUpdatePages(scale, value, options);
  11420. } else {
  11421. const currentPage = this._pages[this._currentPageNumber - 1];
  11422. if (!currentPage) {
  11423. return;
  11424. }
  11425. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  11426. vPadding = _ui_utils.VERTICAL_PADDING;
  11427. if (this.isInPresentationMode) {
  11428. hPadding = vPadding = 4;
  11429. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  11430. hPadding *= 2;
  11431. }
  11432. } else if (this.removePageBorders) {
  11433. hPadding = vPadding = 0;
  11434. } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
  11435. [hPadding, vPadding] = [vPadding, hPadding];
  11436. }
  11437. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this.#pageWidthScaleFactor;
  11438. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  11439. switch (value) {
  11440. case "page-actual":
  11441. scale = 1;
  11442. break;
  11443. case "page-width":
  11444. scale = pageWidthScale;
  11445. break;
  11446. case "page-height":
  11447. scale = pageHeightScale;
  11448. break;
  11449. case "page-fit":
  11450. scale = Math.min(pageWidthScale, pageHeightScale);
  11451. break;
  11452. case "auto":
  11453. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  11454. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  11455. break;
  11456. default:
  11457. console.error(`#setScale: "${value}" is an unknown zoom value.`);
  11458. return;
  11459. }
  11460. options.preset = true;
  11461. this.#setScaleUpdatePages(scale, value, options);
  11462. }
  11463. }
  11464. #resetCurrentPageView() {
  11465. const pageView = this._pages[this._currentPageNumber - 1];
  11466. if (this.isInPresentationMode) {
  11467. this.#setScale(this._currentScaleValue, {
  11468. noScroll: true
  11469. });
  11470. }
  11471. this.#scrollIntoView(pageView);
  11472. }
  11473. pageLabelToPageNumber(label) {
  11474. if (!this._pageLabels) {
  11475. return null;
  11476. }
  11477. const i = this._pageLabels.indexOf(label);
  11478. if (i < 0) {
  11479. return null;
  11480. }
  11481. return i + 1;
  11482. }
  11483. scrollPageIntoView(_ref5) {
  11484. let {
  11485. pageNumber,
  11486. destArray = null,
  11487. allowNegativeOffset = false,
  11488. ignoreDestinationZoom = false
  11489. } = _ref5;
  11490. if (!this.pdfDocument) {
  11491. return;
  11492. }
  11493. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  11494. if (!pageView) {
  11495. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  11496. return;
  11497. }
  11498. if (this.isInPresentationMode || !destArray) {
  11499. this._setCurrentPageNumber(pageNumber, true);
  11500. return;
  11501. }
  11502. let x = 0,
  11503. y = 0;
  11504. let width = 0,
  11505. height = 0,
  11506. widthScale,
  11507. heightScale;
  11508. const changeOrientation = pageView.rotation % 180 !== 0;
  11509. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11510. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11511. let scale = 0;
  11512. switch (destArray[1].name) {
  11513. case "XYZ":
  11514. x = destArray[2];
  11515. y = destArray[3];
  11516. scale = destArray[4];
  11517. x = x !== null ? x : 0;
  11518. y = y !== null ? y : pageHeight;
  11519. break;
  11520. case "Fit":
  11521. case "FitB":
  11522. scale = "page-fit";
  11523. break;
  11524. case "FitH":
  11525. case "FitBH":
  11526. y = destArray[2];
  11527. scale = "page-width";
  11528. if (y === null && this._location) {
  11529. x = this._location.left;
  11530. y = this._location.top;
  11531. } else if (typeof y !== "number" || y < 0) {
  11532. y = pageHeight;
  11533. }
  11534. break;
  11535. case "FitV":
  11536. case "FitBV":
  11537. x = destArray[2];
  11538. width = pageWidth;
  11539. height = pageHeight;
  11540. scale = "page-height";
  11541. break;
  11542. case "FitR":
  11543. x = destArray[2];
  11544. y = destArray[3];
  11545. width = destArray[4] - x;
  11546. height = destArray[5] - y;
  11547. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  11548. vPadding = _ui_utils.VERTICAL_PADDING;
  11549. if (this.removePageBorders) {
  11550. hPadding = vPadding = 0;
  11551. }
  11552. widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11553. heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  11554. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  11555. break;
  11556. default:
  11557. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  11558. return;
  11559. }
  11560. if (!ignoreDestinationZoom) {
  11561. if (scale && scale !== this._currentScale) {
  11562. this.currentScaleValue = scale;
  11563. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  11564. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11565. }
  11566. }
  11567. if (scale === "page-fit" && !destArray[4]) {
  11568. this.#scrollIntoView(pageView);
  11569. return;
  11570. }
  11571. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  11572. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  11573. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  11574. if (!allowNegativeOffset) {
  11575. left = Math.max(left, 0);
  11576. top = Math.max(top, 0);
  11577. }
  11578. this.#scrollIntoView(pageView, {
  11579. left,
  11580. top
  11581. });
  11582. }
  11583. _updateLocation(firstPage) {
  11584. const currentScale = this._currentScale;
  11585. const currentScaleValue = this._currentScaleValue;
  11586. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  11587. const pageNumber = firstPage.id;
  11588. const currentPageView = this._pages[pageNumber - 1];
  11589. const container = this.container;
  11590. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  11591. const intLeft = Math.round(topLeft[0]);
  11592. const intTop = Math.round(topLeft[1]);
  11593. let pdfOpenParams = `#page=${pageNumber}`;
  11594. if (!this.isInPresentationMode) {
  11595. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  11596. }
  11597. this._location = {
  11598. pageNumber,
  11599. scale: normalizedScaleValue,
  11600. top: intTop,
  11601. left: intLeft,
  11602. rotation: this._pagesRotation,
  11603. pdfOpenParams
  11604. };
  11605. }
  11606. update() {
  11607. const visible = this._getVisiblePages();
  11608. const visiblePages = visible.views,
  11609. numVisiblePages = visiblePages.length;
  11610. if (numVisiblePages === 0) {
  11611. return;
  11612. }
  11613. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11614. this.#buffer.resize(newCacheSize, visible.ids);
  11615. this.renderingQueue.renderHighestPriority(visible);
  11616. const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL);
  11617. const currentId = this._currentPageNumber;
  11618. let stillFullyVisible = false;
  11619. for (const page of visiblePages) {
  11620. if (page.percent < 100) {
  11621. break;
  11622. }
  11623. if (page.id === currentId && isSimpleLayout) {
  11624. stillFullyVisible = true;
  11625. break;
  11626. }
  11627. }
  11628. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  11629. this._updateLocation(visible.first);
  11630. this.eventBus.dispatch("updateviewarea", {
  11631. source: this,
  11632. location: this._location
  11633. });
  11634. }
  11635. containsElement(element) {
  11636. return this.container.contains(element);
  11637. }
  11638. focus() {
  11639. this.container.focus();
  11640. }
  11641. get _isContainerRtl() {
  11642. return getComputedStyle(this.container).direction === "rtl";
  11643. }
  11644. get isInPresentationMode() {
  11645. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11646. }
  11647. get isChangingPresentationMode() {
  11648. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11649. }
  11650. get isHorizontalScrollbarEnabled() {
  11651. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11652. }
  11653. get isVerticalScrollbarEnabled() {
  11654. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11655. }
  11656. _getVisiblePages() {
  11657. const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? this.#scrollModePageState.pages : this._pages,
  11658. horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
  11659. rtl = horizontal && this._isContainerRtl;
  11660. return (0, _ui_utils.getVisibleElements)({
  11661. scrollEl: this.container,
  11662. views,
  11663. sortByVisibility: true,
  11664. horizontal,
  11665. rtl
  11666. });
  11667. }
  11668. cleanup() {
  11669. for (const pageView of this._pages) {
  11670. if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11671. pageView.reset();
  11672. }
  11673. }
  11674. }
  11675. _cancelRendering() {
  11676. for (const pageView of this._pages) {
  11677. pageView.cancelRendering();
  11678. }
  11679. }
  11680. async #ensurePdfPageLoaded(pageView) {
  11681. if (pageView.pdfPage) {
  11682. return pageView.pdfPage;
  11683. }
  11684. try {
  11685. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  11686. if (!pageView.pdfPage) {
  11687. pageView.setPdfPage(pdfPage);
  11688. }
  11689. if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
  11690. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  11691. }
  11692. return pdfPage;
  11693. } catch (reason) {
  11694. console.error("Unable to get page for page view", reason);
  11695. return null;
  11696. }
  11697. }
  11698. #getScrollAhead(visible) {
  11699. if (visible.first?.id === 1) {
  11700. return true;
  11701. } else if (visible.last?.id === this.pagesCount) {
  11702. return false;
  11703. }
  11704. switch (this._scrollMode) {
  11705. case _ui_utils.ScrollMode.PAGE:
  11706. return this.#scrollModePageState.scrollDown;
  11707. case _ui_utils.ScrollMode.HORIZONTAL:
  11708. return this.scroll.right;
  11709. }
  11710. return this.scroll.down;
  11711. }
  11712. forceRendering(currentlyVisiblePages) {
  11713. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11714. const scrollAhead = this.#getScrollAhead(visiblePages);
  11715. const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
  11716. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  11717. if (pageView) {
  11718. this.#ensurePdfPageLoaded(pageView).then(() => {
  11719. this.renderingQueue.renderView(pageView);
  11720. });
  11721. return true;
  11722. }
  11723. return false;
  11724. }
  11725. get hasEqualPageSizes() {
  11726. const firstPageView = this._pages[0];
  11727. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  11728. const pageView = this._pages[i];
  11729. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11730. return false;
  11731. }
  11732. }
  11733. return true;
  11734. }
  11735. getPagesOverview() {
  11736. let initialOrientation;
  11737. return this._pages.map(pageView => {
  11738. const viewport = pageView.pdfPage.getViewport({
  11739. scale: 1
  11740. });
  11741. const orientation = (0, _ui_utils.isPortraitOrientation)(viewport);
  11742. if (initialOrientation === undefined) {
  11743. initialOrientation = orientation;
  11744. } else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
  11745. return {
  11746. width: viewport.height,
  11747. height: viewport.width,
  11748. rotation: (viewport.rotation - 90) % 360
  11749. };
  11750. }
  11751. return {
  11752. width: viewport.width,
  11753. height: viewport.height,
  11754. rotation: viewport.rotation
  11755. };
  11756. });
  11757. }
  11758. get optionalContentConfigPromise() {
  11759. if (!this.pdfDocument) {
  11760. return Promise.resolve(null);
  11761. }
  11762. if (!this._optionalContentConfigPromise) {
  11763. console.error("optionalContentConfigPromise: Not initialized yet.");
  11764. return this.pdfDocument.getOptionalContentConfig();
  11765. }
  11766. return this._optionalContentConfigPromise;
  11767. }
  11768. set optionalContentConfigPromise(promise) {
  11769. if (!(promise instanceof Promise)) {
  11770. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  11771. }
  11772. if (!this.pdfDocument) {
  11773. return;
  11774. }
  11775. if (!this._optionalContentConfigPromise) {
  11776. return;
  11777. }
  11778. this._optionalContentConfigPromise = promise;
  11779. this.refresh(false, {
  11780. optionalContentConfigPromise: promise
  11781. });
  11782. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11783. source: this,
  11784. promise
  11785. });
  11786. }
  11787. get scrollMode() {
  11788. return this._scrollMode;
  11789. }
  11790. set scrollMode(mode) {
  11791. if (this._scrollMode === mode) {
  11792. return;
  11793. }
  11794. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11795. throw new Error(`Invalid scroll mode: ${mode}`);
  11796. }
  11797. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11798. return;
  11799. }
  11800. this._previousScrollMode = this._scrollMode;
  11801. this._scrollMode = mode;
  11802. this.eventBus.dispatch("scrollmodechanged", {
  11803. source: this,
  11804. mode
  11805. });
  11806. this._updateScrollMode(this._currentPageNumber);
  11807. }
  11808. _updateScrollMode() {
  11809. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11810. const scrollMode = this._scrollMode,
  11811. viewer = this.viewer;
  11812. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11813. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11814. if (!this.pdfDocument || !pageNumber) {
  11815. return;
  11816. }
  11817. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  11818. this.#ensurePageViewVisible();
  11819. } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
  11820. this._updateSpreadMode();
  11821. }
  11822. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11823. this.#setScale(this._currentScaleValue, {
  11824. noScroll: true
  11825. });
  11826. }
  11827. this._setCurrentPageNumber(pageNumber, true);
  11828. this.update();
  11829. }
  11830. get spreadMode() {
  11831. return this._spreadMode;
  11832. }
  11833. set spreadMode(mode) {
  11834. if (this._spreadMode === mode) {
  11835. return;
  11836. }
  11837. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11838. throw new Error(`Invalid spread mode: ${mode}`);
  11839. }
  11840. this._spreadMode = mode;
  11841. this.eventBus.dispatch("spreadmodechanged", {
  11842. source: this,
  11843. mode
  11844. });
  11845. this._updateSpreadMode(this._currentPageNumber);
  11846. }
  11847. _updateSpreadMode() {
  11848. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11849. if (!this.pdfDocument) {
  11850. return;
  11851. }
  11852. const viewer = this.viewer,
  11853. pages = this._pages;
  11854. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11855. this.#ensurePageViewVisible();
  11856. } else {
  11857. viewer.textContent = "";
  11858. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11859. for (const pageView of this._pages) {
  11860. viewer.append(pageView.div);
  11861. }
  11862. } else {
  11863. const parity = this._spreadMode - 1;
  11864. let spread = null;
  11865. for (let i = 0, ii = pages.length; i < ii; ++i) {
  11866. if (spread === null) {
  11867. spread = document.createElement("div");
  11868. spread.className = "spread";
  11869. viewer.append(spread);
  11870. } else if (i % 2 === parity) {
  11871. spread = spread.cloneNode(false);
  11872. viewer.append(spread);
  11873. }
  11874. spread.append(pages[i].div);
  11875. }
  11876. }
  11877. }
  11878. if (!pageNumber) {
  11879. return;
  11880. }
  11881. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11882. this.#setScale(this._currentScaleValue, {
  11883. noScroll: true
  11884. });
  11885. }
  11886. this._setCurrentPageNumber(pageNumber, true);
  11887. this.update();
  11888. }
  11889. _getPageAdvance(currentPageNumber) {
  11890. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11891. switch (this._scrollMode) {
  11892. case _ui_utils.ScrollMode.WRAPPED:
  11893. {
  11894. const {
  11895. views
  11896. } = this._getVisiblePages(),
  11897. pageLayout = new Map();
  11898. for (const {
  11899. id,
  11900. y,
  11901. percent,
  11902. widthPercent
  11903. } of views) {
  11904. if (percent === 0 || widthPercent < 100) {
  11905. continue;
  11906. }
  11907. let yArray = pageLayout.get(y);
  11908. if (!yArray) {
  11909. pageLayout.set(y, yArray ||= []);
  11910. }
  11911. yArray.push(id);
  11912. }
  11913. for (const yArray of pageLayout.values()) {
  11914. const currentIndex = yArray.indexOf(currentPageNumber);
  11915. if (currentIndex === -1) {
  11916. continue;
  11917. }
  11918. const numPages = yArray.length;
  11919. if (numPages === 1) {
  11920. break;
  11921. }
  11922. if (previous) {
  11923. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11924. const currentId = yArray[i],
  11925. expectedId = yArray[i + 1] - 1;
  11926. if (currentId < expectedId) {
  11927. return currentPageNumber - expectedId;
  11928. }
  11929. }
  11930. } else {
  11931. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  11932. const currentId = yArray[i],
  11933. expectedId = yArray[i - 1] + 1;
  11934. if (currentId > expectedId) {
  11935. return expectedId - currentPageNumber;
  11936. }
  11937. }
  11938. }
  11939. if (previous) {
  11940. const firstId = yArray[0];
  11941. if (firstId < currentPageNumber) {
  11942. return currentPageNumber - firstId + 1;
  11943. }
  11944. } else {
  11945. const lastId = yArray[numPages - 1];
  11946. if (lastId > currentPageNumber) {
  11947. return lastId - currentPageNumber + 1;
  11948. }
  11949. }
  11950. break;
  11951. }
  11952. break;
  11953. }
  11954. case _ui_utils.ScrollMode.HORIZONTAL:
  11955. {
  11956. break;
  11957. }
  11958. case _ui_utils.ScrollMode.PAGE:
  11959. case _ui_utils.ScrollMode.VERTICAL:
  11960. {
  11961. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11962. break;
  11963. }
  11964. const parity = this._spreadMode - 1;
  11965. if (previous && currentPageNumber % 2 !== parity) {
  11966. break;
  11967. } else if (!previous && currentPageNumber % 2 === parity) {
  11968. break;
  11969. }
  11970. const {
  11971. views
  11972. } = this._getVisiblePages(),
  11973. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11974. for (const {
  11975. id,
  11976. percent,
  11977. widthPercent
  11978. } of views) {
  11979. if (id !== expectedId) {
  11980. continue;
  11981. }
  11982. if (percent > 0 && widthPercent === 100) {
  11983. return 2;
  11984. }
  11985. break;
  11986. }
  11987. break;
  11988. }
  11989. }
  11990. return 1;
  11991. }
  11992. nextPage() {
  11993. const currentPageNumber = this._currentPageNumber,
  11994. pagesCount = this.pagesCount;
  11995. if (currentPageNumber >= pagesCount) {
  11996. return false;
  11997. }
  11998. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11999. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  12000. return true;
  12001. }
  12002. previousPage() {
  12003. const currentPageNumber = this._currentPageNumber;
  12004. if (currentPageNumber <= 1) {
  12005. return false;
  12006. }
  12007. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  12008. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  12009. return true;
  12010. }
  12011. increaseScale() {
  12012. let {
  12013. drawingDelay,
  12014. scaleFactor,
  12015. steps
  12016. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12017. if (!this.pdfDocument) {
  12018. return;
  12019. }
  12020. let newScale = this._currentScale;
  12021. if (scaleFactor > 1) {
  12022. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12023. } else {
  12024. steps ??= 1;
  12025. do {
  12026. newScale = Math.ceil((newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12027. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  12028. }
  12029. this.#setScale(Math.min(_ui_utils.MAX_SCALE, newScale), {
  12030. noScroll: false,
  12031. drawingDelay
  12032. });
  12033. }
  12034. decreaseScale() {
  12035. let {
  12036. drawingDelay,
  12037. scaleFactor,
  12038. steps
  12039. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12040. if (!this.pdfDocument) {
  12041. return;
  12042. }
  12043. let newScale = this._currentScale;
  12044. if (scaleFactor > 0 && scaleFactor < 1) {
  12045. newScale = Math.round(newScale * scaleFactor * 100) / 100;
  12046. } else {
  12047. steps ??= 1;
  12048. do {
  12049. newScale = Math.floor((newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2) * 10) / 10;
  12050. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  12051. }
  12052. this.#setScale(Math.max(_ui_utils.MIN_SCALE, newScale), {
  12053. noScroll: false,
  12054. drawingDelay
  12055. });
  12056. }
  12057. #updateContainerHeightCss() {
  12058. let height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.container.clientHeight;
  12059. if (height !== this.#previousContainerHeight) {
  12060. this.#previousContainerHeight = height;
  12061. _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`);
  12062. }
  12063. }
  12064. #resizeObserverCallback(entries) {
  12065. for (const entry of entries) {
  12066. if (entry.target === this.container) {
  12067. this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
  12068. this.#containerTopLeft = null;
  12069. break;
  12070. }
  12071. }
  12072. }
  12073. get containerTopLeft() {
  12074. return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
  12075. }
  12076. get annotationEditorMode() {
  12077. return this.#annotationEditorUIManager ? this.#annotationEditorMode : _pdfjsLib.AnnotationEditorType.DISABLE;
  12078. }
  12079. set annotationEditorMode(_ref6) {
  12080. let {
  12081. mode,
  12082. editId = null
  12083. } = _ref6;
  12084. if (!this.#annotationEditorUIManager) {
  12085. throw new Error(`The AnnotationEditor is not enabled.`);
  12086. }
  12087. if (this.#annotationEditorMode === mode) {
  12088. return;
  12089. }
  12090. if (!isValidAnnotationEditorMode(mode)) {
  12091. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  12092. }
  12093. if (!this.pdfDocument) {
  12094. return;
  12095. }
  12096. this.#annotationEditorMode = mode;
  12097. this.eventBus.dispatch("annotationeditormodechanged", {
  12098. source: this,
  12099. mode
  12100. });
  12101. this.#annotationEditorUIManager.updateMode(mode, editId);
  12102. }
  12103. set annotationEditorParams(_ref7) {
  12104. let {
  12105. type,
  12106. value
  12107. } = _ref7;
  12108. if (!this.#annotationEditorUIManager) {
  12109. throw new Error(`The AnnotationEditor is not enabled.`);
  12110. }
  12111. this.#annotationEditorUIManager.updateParams(type, value);
  12112. }
  12113. refresh() {
  12114. let noUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12115. let updateArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.create(null);
  12116. if (!this.pdfDocument) {
  12117. return;
  12118. }
  12119. for (const pageView of this._pages) {
  12120. pageView.update(updateArgs);
  12121. }
  12122. if (this.#scaleTimeoutId !== null) {
  12123. clearTimeout(this.#scaleTimeoutId);
  12124. this.#scaleTimeoutId = null;
  12125. }
  12126. if (!noUpdate) {
  12127. this.update();
  12128. }
  12129. }
  12130. }
  12131. exports.PDFViewer = PDFViewer;
  12132. /***/ }),
  12133. /* 147 */
  12134. /***/ ((__unused_webpack_module, exports) => {
  12135. Object.defineProperty(exports, "__esModule", ({
  12136. value: true
  12137. }));
  12138. exports.NullL10n = void 0;
  12139. exports.getL10nFallback = getL10nFallback;
  12140. const DEFAULT_L10N_STRINGS = {
  12141. of_pages: "of {{pagesCount}}",
  12142. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  12143. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  12144. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  12145. document_properties_date_string: "{{date}}, {{time}}",
  12146. document_properties_page_size_unit_inches: "in",
  12147. document_properties_page_size_unit_millimeters: "mm",
  12148. document_properties_page_size_orientation_portrait: "portrait",
  12149. document_properties_page_size_orientation_landscape: "landscape",
  12150. document_properties_page_size_name_a3: "A3",
  12151. document_properties_page_size_name_a4: "A4",
  12152. document_properties_page_size_name_letter: "Letter",
  12153. document_properties_page_size_name_legal: "Legal",
  12154. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  12155. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  12156. document_properties_linearized_yes: "Yes",
  12157. document_properties_linearized_no: "No",
  12158. additional_layers: "Additional Layers",
  12159. page_landmark: "Page {{page}}",
  12160. thumb_page_title: "Page {{page}}",
  12161. thumb_page_canvas: "Thumbnail of Page {{page}}",
  12162. find_reached_top: "Reached top of document, continued from bottom",
  12163. find_reached_bottom: "Reached end of document, continued from top",
  12164. "find_match_count[one]": "{{current}} of {{total}} match",
  12165. "find_match_count[other]": "{{current}} of {{total}} matches",
  12166. "find_match_count_limit[one]": "More than {{limit}} match",
  12167. "find_match_count_limit[other]": "More than {{limit}} matches",
  12168. find_not_found: "Phrase not found",
  12169. page_scale_width: "Page Width",
  12170. page_scale_fit: "Page Fit",
  12171. page_scale_auto: "Automatic Zoom",
  12172. page_scale_actual: "Actual Size",
  12173. page_scale_percent: "{{scale}}%",
  12174. loading_error: "An error occurred while loading the PDF.",
  12175. invalid_file_error: "Invalid or corrupted PDF file.",
  12176. missing_file_error: "Missing PDF file.",
  12177. unexpected_response_error: "Unexpected server response.",
  12178. rendering_error: "An error occurred while rendering the page.",
  12179. annotation_date_string: "{{date}}, {{time}}",
  12180. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  12181. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  12182. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
  12183. free_text2_default_content: "Start typing…",
  12184. editor_free_text2_aria_label: "Text Editor",
  12185. editor_ink2_aria_label: "Draw Editor",
  12186. editor_ink_canvas_aria_label: "User-created image"
  12187. };
  12188. {
  12189. DEFAULT_L10N_STRINGS.print_progress_percent = "{{progress}}%";
  12190. }
  12191. function getL10nFallback(key, args) {
  12192. switch (key) {
  12193. case "find_match_count":
  12194. key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
  12195. break;
  12196. case "find_match_count_limit":
  12197. key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
  12198. break;
  12199. }
  12200. return DEFAULT_L10N_STRINGS[key] || "";
  12201. }
  12202. function formatL10nValue(text, args) {
  12203. if (!args) {
  12204. return text;
  12205. }
  12206. return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  12207. return name in args ? args[name] : "{{" + name + "}}";
  12208. });
  12209. }
  12210. const NullL10n = {
  12211. async getLanguage() {
  12212. return "en-us";
  12213. },
  12214. async getDirection() {
  12215. return "ltr";
  12216. },
  12217. async get(key) {
  12218. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12219. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getL10nFallback(key, args);
  12220. return formatL10nValue(fallback, args);
  12221. },
  12222. async translate(element) {}
  12223. };
  12224. exports.NullL10n = NullL10n;
  12225. /***/ }),
  12226. /* 148 */
  12227. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12228. Object.defineProperty(exports, "__esModule", ({
  12229. value: true
  12230. }));
  12231. exports.PDFPageView = void 0;
  12232. __webpack_require__(89);
  12233. __webpack_require__(76);
  12234. var _pdfjsLib = __webpack_require__(122);
  12235. var _ui_utils = __webpack_require__(97);
  12236. var _annotation_editor_layer_builder = __webpack_require__(149);
  12237. var _annotation_layer_builder = __webpack_require__(150);
  12238. var _app_options = __webpack_require__(123);
  12239. var _l10n_utils = __webpack_require__(147);
  12240. var _pdf_link_service = __webpack_require__(125);
  12241. var _struct_tree_layer_builder = __webpack_require__(151);
  12242. var _text_accessibility = __webpack_require__(152);
  12243. var _text_highlighter = __webpack_require__(153);
  12244. var _text_layer_builder = __webpack_require__(154);
  12245. var _xfa_layer_builder = __webpack_require__(155);
  12246. const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  12247. const DEFAULT_LAYER_PROPERTIES = () => {
  12248. return null;
  12249. };
  12250. class PDFPageView {
  12251. #annotationMode = _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  12252. #hasRestrictedScaling = false;
  12253. #layerProperties = null;
  12254. #loadingId = null;
  12255. #previousRotation = null;
  12256. #renderError = null;
  12257. #renderingState = _ui_utils.RenderingStates.INITIAL;
  12258. #textLayerMode = _ui_utils.TextLayerMode.ENABLE;
  12259. #useThumbnailCanvas = {
  12260. directDrawing: true,
  12261. initialOptionalContent: true,
  12262. regularAnnotations: true
  12263. };
  12264. #viewportMap = new WeakMap();
  12265. constructor(options) {
  12266. const container = options.container;
  12267. const defaultViewport = options.defaultViewport;
  12268. this.id = options.id;
  12269. this.renderingId = "page" + this.id;
  12270. this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
  12271. this.pdfPage = null;
  12272. this.pageLabel = null;
  12273. this.rotation = 0;
  12274. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  12275. this.viewport = defaultViewport;
  12276. this.pdfPageRotate = defaultViewport.rotation;
  12277. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  12278. this.#textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  12279. this.#annotationMode = options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  12280. this.imageResourcesPath = options.imageResourcesPath || "";
  12281. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  12282. this.maxCanvasPixels = options.maxCanvasPixels ?? MAX_CANVAS_PIXELS;
  12283. this.pageColors = options.pageColors || null;
  12284. this.eventBus = options.eventBus;
  12285. this.renderingQueue = options.renderingQueue;
  12286. this.l10n = options.l10n || _l10n_utils.NullL10n;
  12287. this.renderTask = null;
  12288. this.resume = null;
  12289. this._isStandalone = !this.renderingQueue?.hasViewer();
  12290. this._container = container;
  12291. if (options.useOnlyCssZoom) {
  12292. console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
  12293. this.maxCanvasPixels = 0;
  12294. }
  12295. this._annotationCanvasMap = null;
  12296. this.annotationLayer = null;
  12297. this.annotationEditorLayer = null;
  12298. this.textLayer = null;
  12299. this.zoomLayer = null;
  12300. this.xfaLayer = null;
  12301. this.structTreeLayer = null;
  12302. const div = document.createElement("div");
  12303. div.className = "page";
  12304. div.setAttribute("data-page-number", this.id);
  12305. div.setAttribute("role", "region");
  12306. this.l10n.get("page_landmark", {
  12307. page: this.id
  12308. }).then(msg => {
  12309. div.setAttribute("aria-label", msg);
  12310. });
  12311. this.div = div;
  12312. this.#setDimensions();
  12313. container?.append(div);
  12314. if (this._isStandalone) {
  12315. container?.style.setProperty("--scale-factor", this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  12316. const {
  12317. optionalContentConfigPromise
  12318. } = options;
  12319. if (optionalContentConfigPromise) {
  12320. optionalContentConfigPromise.then(optionalContentConfig => {
  12321. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12322. return;
  12323. }
  12324. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12325. });
  12326. }
  12327. }
  12328. }
  12329. get renderingState() {
  12330. return this.#renderingState;
  12331. }
  12332. set renderingState(state) {
  12333. if (state === this.#renderingState) {
  12334. return;
  12335. }
  12336. this.#renderingState = state;
  12337. if (this.#loadingId) {
  12338. clearTimeout(this.#loadingId);
  12339. this.#loadingId = null;
  12340. }
  12341. switch (state) {
  12342. case _ui_utils.RenderingStates.PAUSED:
  12343. this.div.classList.remove("loading");
  12344. break;
  12345. case _ui_utils.RenderingStates.RUNNING:
  12346. this.div.classList.add("loadingIcon");
  12347. this.#loadingId = setTimeout(() => {
  12348. this.div.classList.add("loading");
  12349. this.#loadingId = null;
  12350. }, 0);
  12351. break;
  12352. case _ui_utils.RenderingStates.INITIAL:
  12353. case _ui_utils.RenderingStates.FINISHED:
  12354. this.div.classList.remove("loadingIcon", "loading");
  12355. break;
  12356. }
  12357. }
  12358. #setDimensions() {
  12359. const {
  12360. viewport
  12361. } = this;
  12362. if (this.pdfPage) {
  12363. if (this.#previousRotation === viewport.rotation) {
  12364. return;
  12365. }
  12366. this.#previousRotation = viewport.rotation;
  12367. }
  12368. (0, _pdfjsLib.setLayerDimensions)(this.div, viewport, true, false);
  12369. }
  12370. setPdfPage(pdfPage) {
  12371. if (this._isStandalone && (this.pageColors?.foreground === "CanvasText" || this.pageColors?.background === "Canvas")) {
  12372. this._container?.style.setProperty("--hcm-highligh-filter", pdfPage.filterFactory.addHighlightHCMFilter("CanvasText", "Canvas", "HighlightText", "Highlight"));
  12373. }
  12374. this.pdfPage = pdfPage;
  12375. this.pdfPageRotate = pdfPage.rotate;
  12376. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12377. this.viewport = pdfPage.getViewport({
  12378. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12379. rotation: totalRotation
  12380. });
  12381. this.#setDimensions();
  12382. this.reset();
  12383. }
  12384. destroy() {
  12385. this.reset();
  12386. this.pdfPage?.cleanup();
  12387. }
  12388. get _textHighlighter() {
  12389. return (0, _pdfjsLib.shadow)(this, "_textHighlighter", new _text_highlighter.TextHighlighter({
  12390. pageIndex: this.id - 1,
  12391. eventBus: this.eventBus,
  12392. findController: this.#layerProperties().findController
  12393. }));
  12394. }
  12395. async #renderAnnotationLayer() {
  12396. let error = null;
  12397. try {
  12398. await this.annotationLayer.render(this.viewport, "display");
  12399. } catch (ex) {
  12400. console.error(`#renderAnnotationLayer: "${ex}".`);
  12401. error = ex;
  12402. } finally {
  12403. this.eventBus.dispatch("annotationlayerrendered", {
  12404. source: this,
  12405. pageNumber: this.id,
  12406. error
  12407. });
  12408. }
  12409. }
  12410. async #renderAnnotationEditorLayer() {
  12411. let error = null;
  12412. try {
  12413. await this.annotationEditorLayer.render(this.viewport, "display");
  12414. } catch (ex) {
  12415. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  12416. error = ex;
  12417. } finally {
  12418. this.eventBus.dispatch("annotationeditorlayerrendered", {
  12419. source: this,
  12420. pageNumber: this.id,
  12421. error
  12422. });
  12423. }
  12424. }
  12425. async #renderXfaLayer() {
  12426. let error = null;
  12427. try {
  12428. const result = await this.xfaLayer.render(this.viewport, "display");
  12429. if (result?.textDivs && this._textHighlighter) {
  12430. this.#buildXfaTextContentItems(result.textDivs);
  12431. }
  12432. } catch (ex) {
  12433. console.error(`#renderXfaLayer: "${ex}".`);
  12434. error = ex;
  12435. } finally {
  12436. this.eventBus.dispatch("xfalayerrendered", {
  12437. source: this,
  12438. pageNumber: this.id,
  12439. error
  12440. });
  12441. }
  12442. }
  12443. async #renderTextLayer() {
  12444. const {
  12445. pdfPage,
  12446. textLayer,
  12447. viewport
  12448. } = this;
  12449. if (!textLayer) {
  12450. return;
  12451. }
  12452. let error = null;
  12453. try {
  12454. if (!textLayer.renderingDone) {
  12455. const readableStream = pdfPage.streamTextContent({
  12456. includeMarkedContent: true,
  12457. disableNormalization: true
  12458. });
  12459. textLayer.setTextContentSource(readableStream);
  12460. }
  12461. await textLayer.render(viewport);
  12462. } catch (ex) {
  12463. if (ex instanceof _pdfjsLib.AbortException) {
  12464. return;
  12465. }
  12466. console.error(`#renderTextLayer: "${ex}".`);
  12467. error = ex;
  12468. }
  12469. this.eventBus.dispatch("textlayerrendered", {
  12470. source: this,
  12471. pageNumber: this.id,
  12472. numTextDivs: textLayer.numTextDivs,
  12473. error
  12474. });
  12475. this.#renderStructTreeLayer();
  12476. }
  12477. async #renderStructTreeLayer() {
  12478. if (!this.textLayer) {
  12479. return;
  12480. }
  12481. this.structTreeLayer ||= new _struct_tree_layer_builder.StructTreeLayerBuilder();
  12482. const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
  12483. const treeDom = this.structTreeLayer?.render(tree);
  12484. if (treeDom) {
  12485. this.canvas?.append(treeDom);
  12486. }
  12487. this.structTreeLayer?.show();
  12488. }
  12489. async #buildXfaTextContentItems(textDivs) {
  12490. const text = await this.pdfPage.getTextContent();
  12491. const items = [];
  12492. for (const item of text.items) {
  12493. items.push(item.str);
  12494. }
  12495. this._textHighlighter.setTextMapping(textDivs, items);
  12496. this._textHighlighter.enable();
  12497. }
  12498. _resetZoomLayer() {
  12499. let removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12500. if (!this.zoomLayer) {
  12501. return;
  12502. }
  12503. const zoomLayerCanvas = this.zoomLayer.firstChild;
  12504. this.#viewportMap.delete(zoomLayerCanvas);
  12505. zoomLayerCanvas.width = 0;
  12506. zoomLayerCanvas.height = 0;
  12507. if (removeFromDOM) {
  12508. this.zoomLayer.remove();
  12509. }
  12510. this.zoomLayer = null;
  12511. }
  12512. reset() {
  12513. let {
  12514. keepZoomLayer = false,
  12515. keepAnnotationLayer = false,
  12516. keepAnnotationEditorLayer = false,
  12517. keepXfaLayer = false,
  12518. keepTextLayer = false
  12519. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12520. this.cancelRendering({
  12521. keepAnnotationLayer,
  12522. keepAnnotationEditorLayer,
  12523. keepXfaLayer,
  12524. keepTextLayer
  12525. });
  12526. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  12527. const div = this.div;
  12528. const childNodes = div.childNodes,
  12529. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  12530. annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
  12531. annotationEditorLayerNode = keepAnnotationEditorLayer && this.annotationEditorLayer?.div || null,
  12532. xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null,
  12533. textLayerNode = keepTextLayer && this.textLayer?.div || null;
  12534. for (let i = childNodes.length - 1; i >= 0; i--) {
  12535. const node = childNodes[i];
  12536. switch (node) {
  12537. case zoomLayerNode:
  12538. case annotationLayerNode:
  12539. case annotationEditorLayerNode:
  12540. case xfaLayerNode:
  12541. case textLayerNode:
  12542. continue;
  12543. }
  12544. node.remove();
  12545. }
  12546. div.removeAttribute("data-loaded");
  12547. if (annotationLayerNode) {
  12548. this.annotationLayer.hide();
  12549. }
  12550. if (annotationEditorLayerNode) {
  12551. this.annotationEditorLayer.hide();
  12552. }
  12553. if (xfaLayerNode) {
  12554. this.xfaLayer.hide();
  12555. }
  12556. if (textLayerNode) {
  12557. this.textLayer.hide();
  12558. }
  12559. this.structTreeLayer?.hide();
  12560. if (!zoomLayerNode) {
  12561. if (this.canvas) {
  12562. this.#viewportMap.delete(this.canvas);
  12563. this.canvas.width = 0;
  12564. this.canvas.height = 0;
  12565. delete this.canvas;
  12566. }
  12567. this._resetZoomLayer();
  12568. }
  12569. }
  12570. update(_ref) {
  12571. let {
  12572. scale = 0,
  12573. rotation = null,
  12574. optionalContentConfigPromise = null,
  12575. drawingDelay = -1
  12576. } = _ref;
  12577. this.scale = scale || this.scale;
  12578. if (typeof rotation === "number") {
  12579. this.rotation = rotation;
  12580. }
  12581. if (optionalContentConfigPromise instanceof Promise) {
  12582. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12583. optionalContentConfigPromise.then(optionalContentConfig => {
  12584. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  12585. return;
  12586. }
  12587. this.#useThumbnailCanvas.initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  12588. });
  12589. }
  12590. this.#useThumbnailCanvas.directDrawing = true;
  12591. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12592. this.viewport = this.viewport.clone({
  12593. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12594. rotation: totalRotation
  12595. });
  12596. this.#setDimensions();
  12597. if (this._isStandalone) {
  12598. this._container?.style.setProperty("--scale-factor", this.viewport.scale);
  12599. }
  12600. if (this.canvas) {
  12601. let onlyCssZoom = false;
  12602. if (this.#hasRestrictedScaling) {
  12603. if (this.maxCanvasPixels === 0) {
  12604. onlyCssZoom = true;
  12605. } else if (this.maxCanvasPixels > 0) {
  12606. const {
  12607. width,
  12608. height
  12609. } = this.viewport;
  12610. const {
  12611. sx,
  12612. sy
  12613. } = this.outputScale;
  12614. onlyCssZoom = (Math.floor(width) * sx | 0) * (Math.floor(height) * sy | 0) > this.maxCanvasPixels;
  12615. }
  12616. }
  12617. const postponeDrawing = !onlyCssZoom && drawingDelay >= 0 && drawingDelay < 1000;
  12618. if (postponeDrawing || onlyCssZoom) {
  12619. if (postponeDrawing && this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  12620. this.cancelRendering({
  12621. keepZoomLayer: true,
  12622. keepAnnotationLayer: true,
  12623. keepAnnotationEditorLayer: true,
  12624. keepXfaLayer: true,
  12625. keepTextLayer: true,
  12626. cancelExtraDelay: drawingDelay
  12627. });
  12628. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12629. this.#useThumbnailCanvas.directDrawing = false;
  12630. }
  12631. this.cssTransform({
  12632. target: this.canvas,
  12633. redrawAnnotationLayer: true,
  12634. redrawAnnotationEditorLayer: true,
  12635. redrawXfaLayer: true,
  12636. redrawTextLayer: !postponeDrawing,
  12637. hideTextLayer: postponeDrawing
  12638. });
  12639. if (postponeDrawing) {
  12640. return;
  12641. }
  12642. this.eventBus.dispatch("pagerendered", {
  12643. source: this,
  12644. pageNumber: this.id,
  12645. cssTransform: true,
  12646. timestamp: performance.now(),
  12647. error: this.#renderError
  12648. });
  12649. return;
  12650. }
  12651. if (!this.zoomLayer && !this.canvas.hidden) {
  12652. this.zoomLayer = this.canvas.parentNode;
  12653. this.zoomLayer.style.position = "absolute";
  12654. }
  12655. }
  12656. if (this.zoomLayer) {
  12657. this.cssTransform({
  12658. target: this.zoomLayer.firstChild
  12659. });
  12660. }
  12661. this.reset({
  12662. keepZoomLayer: true,
  12663. keepAnnotationLayer: true,
  12664. keepAnnotationEditorLayer: true,
  12665. keepXfaLayer: true,
  12666. keepTextLayer: true
  12667. });
  12668. }
  12669. cancelRendering() {
  12670. let {
  12671. keepAnnotationLayer = false,
  12672. keepAnnotationEditorLayer = false,
  12673. keepXfaLayer = false,
  12674. keepTextLayer = false,
  12675. cancelExtraDelay = 0
  12676. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12677. if (this.renderTask) {
  12678. this.renderTask.cancel(cancelExtraDelay);
  12679. this.renderTask = null;
  12680. }
  12681. this.resume = null;
  12682. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  12683. this.textLayer.cancel();
  12684. this.textLayer = null;
  12685. }
  12686. if (this.structTreeLayer && !this.textLayer) {
  12687. this.structTreeLayer = null;
  12688. }
  12689. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  12690. this.annotationLayer.cancel();
  12691. this.annotationLayer = null;
  12692. this._annotationCanvasMap = null;
  12693. }
  12694. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  12695. this.annotationEditorLayer.cancel();
  12696. this.annotationEditorLayer = null;
  12697. }
  12698. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  12699. this.xfaLayer.cancel();
  12700. this.xfaLayer = null;
  12701. this._textHighlighter?.disable();
  12702. }
  12703. }
  12704. cssTransform(_ref2) {
  12705. let {
  12706. target,
  12707. redrawAnnotationLayer = false,
  12708. redrawAnnotationEditorLayer = false,
  12709. redrawXfaLayer = false,
  12710. redrawTextLayer = false,
  12711. hideTextLayer = false
  12712. } = _ref2;
  12713. if (!target.hasAttribute("zooming")) {
  12714. target.setAttribute("zooming", true);
  12715. const {
  12716. style
  12717. } = target;
  12718. style.width = style.height = "";
  12719. }
  12720. const originalViewport = this.#viewportMap.get(target);
  12721. if (this.viewport !== originalViewport) {
  12722. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  12723. const absRotation = Math.abs(relativeRotation);
  12724. let scaleX = 1,
  12725. scaleY = 1;
  12726. if (absRotation === 90 || absRotation === 270) {
  12727. const {
  12728. width,
  12729. height
  12730. } = this.viewport;
  12731. scaleX = height / width;
  12732. scaleY = width / height;
  12733. }
  12734. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  12735. }
  12736. if (redrawAnnotationLayer && this.annotationLayer) {
  12737. this.#renderAnnotationLayer();
  12738. }
  12739. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  12740. this.#renderAnnotationEditorLayer();
  12741. }
  12742. if (redrawXfaLayer && this.xfaLayer) {
  12743. this.#renderXfaLayer();
  12744. }
  12745. if (this.textLayer) {
  12746. if (hideTextLayer) {
  12747. this.textLayer.hide();
  12748. this.structTreeLayer?.hide();
  12749. } else if (redrawTextLayer) {
  12750. this.#renderTextLayer();
  12751. }
  12752. }
  12753. }
  12754. get width() {
  12755. return this.viewport.width;
  12756. }
  12757. get height() {
  12758. return this.viewport.height;
  12759. }
  12760. getPagePoint(x, y) {
  12761. return this.viewport.convertToPdfPoint(x, y);
  12762. }
  12763. async #finishRenderTask(renderTask) {
  12764. let error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12765. if (renderTask === this.renderTask) {
  12766. this.renderTask = null;
  12767. }
  12768. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  12769. this.#renderError = null;
  12770. return;
  12771. }
  12772. this.#renderError = error;
  12773. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12774. this._resetZoomLayer(true);
  12775. this.#useThumbnailCanvas.regularAnnotations = !renderTask.separateAnnots;
  12776. this.eventBus.dispatch("pagerendered", {
  12777. source: this,
  12778. pageNumber: this.id,
  12779. cssTransform: false,
  12780. timestamp: performance.now(),
  12781. error: this.#renderError
  12782. });
  12783. if (error) {
  12784. throw error;
  12785. }
  12786. }
  12787. async draw() {
  12788. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  12789. console.error("Must be in new state before drawing");
  12790. this.reset();
  12791. }
  12792. const {
  12793. div,
  12794. l10n,
  12795. pageColors,
  12796. pdfPage,
  12797. viewport
  12798. } = this;
  12799. if (!pdfPage) {
  12800. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12801. throw new Error("pdfPage is not loaded");
  12802. }
  12803. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12804. const canvasWrapper = document.createElement("div");
  12805. canvasWrapper.classList.add("canvasWrapper");
  12806. div.append(canvasWrapper);
  12807. if (!this.textLayer && this.#textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  12808. this._accessibilityManager ||= new _text_accessibility.TextAccessibilityManager();
  12809. this.textLayer = new _text_layer_builder.TextLayerBuilder({
  12810. highlighter: this._textHighlighter,
  12811. accessibilityManager: this._accessibilityManager,
  12812. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  12813. enablePermissions: this.#textLayerMode === _ui_utils.TextLayerMode.ENABLE_PERMISSIONS
  12814. });
  12815. div.append(this.textLayer.div);
  12816. }
  12817. if (!this.annotationLayer && this.#annotationMode !== _pdfjsLib.AnnotationMode.DISABLE) {
  12818. const {
  12819. annotationStorage,
  12820. downloadManager,
  12821. enableScripting,
  12822. fieldObjectsPromise,
  12823. hasJSActionsPromise,
  12824. linkService
  12825. } = this.#layerProperties();
  12826. this._annotationCanvasMap ||= new Map();
  12827. this.annotationLayer = new _annotation_layer_builder.AnnotationLayerBuilder({
  12828. pageDiv: div,
  12829. pdfPage,
  12830. annotationStorage,
  12831. imageResourcesPath: this.imageResourcesPath,
  12832. renderForms: this.#annotationMode === _pdfjsLib.AnnotationMode.ENABLE_FORMS,
  12833. linkService,
  12834. downloadManager,
  12835. l10n,
  12836. enableScripting,
  12837. hasJSActionsPromise,
  12838. fieldObjectsPromise,
  12839. annotationCanvasMap: this._annotationCanvasMap,
  12840. accessibilityManager: this._accessibilityManager
  12841. });
  12842. }
  12843. const renderContinueCallback = cont => {
  12844. showCanvas?.(false);
  12845. if (this.renderingQueue && !this.renderingQueue.isHighestPriority(this)) {
  12846. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  12847. this.resume = () => {
  12848. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12849. cont();
  12850. };
  12851. return;
  12852. }
  12853. cont();
  12854. };
  12855. const {
  12856. width,
  12857. height
  12858. } = viewport;
  12859. const canvas = document.createElement("canvas");
  12860. canvas.setAttribute("role", "presentation");
  12861. canvas.hidden = true;
  12862. const hasHCM = !!(pageColors?.background && pageColors?.foreground);
  12863. let showCanvas = isLastShow => {
  12864. if (!hasHCM || isLastShow) {
  12865. canvas.hidden = false;
  12866. showCanvas = null;
  12867. }
  12868. };
  12869. canvasWrapper.append(canvas);
  12870. this.canvas = canvas;
  12871. const ctx = canvas.getContext("2d", {
  12872. alpha: false
  12873. });
  12874. const outputScale = this.outputScale = new _ui_utils.OutputScale();
  12875. if (this.maxCanvasPixels === 0) {
  12876. const invScale = 1 / this.scale;
  12877. outputScale.sx *= invScale;
  12878. outputScale.sy *= invScale;
  12879. this.#hasRestrictedScaling = true;
  12880. } else if (this.maxCanvasPixels > 0) {
  12881. const pixelsInViewport = width * height;
  12882. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12883. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12884. outputScale.sx = maxScale;
  12885. outputScale.sy = maxScale;
  12886. this.#hasRestrictedScaling = true;
  12887. } else {
  12888. this.#hasRestrictedScaling = false;
  12889. }
  12890. }
  12891. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12892. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12893. canvas.width = (0, _ui_utils.roundToDivide)(width * outputScale.sx, sfx[0]);
  12894. canvas.height = (0, _ui_utils.roundToDivide)(height * outputScale.sy, sfy[0]);
  12895. const {
  12896. style
  12897. } = canvas;
  12898. style.width = (0, _ui_utils.roundToDivide)(width, sfx[1]) + "px";
  12899. style.height = (0, _ui_utils.roundToDivide)(height, sfy[1]) + "px";
  12900. this.#viewportMap.set(canvas, viewport);
  12901. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  12902. const renderContext = {
  12903. canvasContext: ctx,
  12904. transform,
  12905. viewport,
  12906. annotationMode: this.#annotationMode,
  12907. optionalContentConfigPromise: this._optionalContentConfigPromise,
  12908. annotationCanvasMap: this._annotationCanvasMap,
  12909. pageColors
  12910. };
  12911. const renderTask = this.renderTask = this.pdfPage.render(renderContext);
  12912. renderTask.onContinue = renderContinueCallback;
  12913. const resultPromise = renderTask.promise.then(async () => {
  12914. showCanvas?.(true);
  12915. await this.#finishRenderTask(renderTask);
  12916. this.#renderTextLayer();
  12917. if (this.annotationLayer) {
  12918. await this.#renderAnnotationLayer();
  12919. }
  12920. if (!this.annotationEditorLayer) {
  12921. const {
  12922. annotationEditorUIManager
  12923. } = this.#layerProperties();
  12924. if (!annotationEditorUIManager) {
  12925. return;
  12926. }
  12927. this.annotationEditorLayer = new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
  12928. uiManager: annotationEditorUIManager,
  12929. pageDiv: div,
  12930. pdfPage,
  12931. l10n,
  12932. accessibilityManager: this._accessibilityManager,
  12933. annotationLayer: this.annotationLayer?.annotationLayer
  12934. });
  12935. }
  12936. this.#renderAnnotationEditorLayer();
  12937. }, error => {
  12938. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12939. showCanvas?.(true);
  12940. }
  12941. return this.#finishRenderTask(renderTask, error);
  12942. });
  12943. if (pdfPage.isPureXfa) {
  12944. if (!this.xfaLayer) {
  12945. const {
  12946. annotationStorage,
  12947. linkService
  12948. } = this.#layerProperties();
  12949. this.xfaLayer = new _xfa_layer_builder.XfaLayerBuilder({
  12950. pageDiv: div,
  12951. pdfPage,
  12952. annotationStorage,
  12953. linkService
  12954. });
  12955. } else if (this.xfaLayer.div) {
  12956. div.append(this.xfaLayer.div);
  12957. }
  12958. this.#renderXfaLayer();
  12959. }
  12960. div.setAttribute("data-loaded", true);
  12961. this.eventBus.dispatch("pagerender", {
  12962. source: this,
  12963. pageNumber: this.id
  12964. });
  12965. return resultPromise;
  12966. }
  12967. setPageLabel(label) {
  12968. this.pageLabel = typeof label === "string" ? label : null;
  12969. if (this.pageLabel !== null) {
  12970. this.div.setAttribute("data-page-label", this.pageLabel);
  12971. } else {
  12972. this.div.removeAttribute("data-page-label");
  12973. }
  12974. }
  12975. get thumbnailCanvas() {
  12976. const {
  12977. directDrawing,
  12978. initialOptionalContent,
  12979. regularAnnotations
  12980. } = this.#useThumbnailCanvas;
  12981. return directDrawing && initialOptionalContent && regularAnnotations ? this.canvas : null;
  12982. }
  12983. }
  12984. exports.PDFPageView = PDFPageView;
  12985. /***/ }),
  12986. /* 149 */
  12987. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12988. Object.defineProperty(exports, "__esModule", ({
  12989. value: true
  12990. }));
  12991. exports.AnnotationEditorLayerBuilder = void 0;
  12992. var _pdfjsLib = __webpack_require__(122);
  12993. var _l10n_utils = __webpack_require__(147);
  12994. class AnnotationEditorLayerBuilder {
  12995. #annotationLayer = null;
  12996. #uiManager;
  12997. constructor(options) {
  12998. this.pageDiv = options.pageDiv;
  12999. this.pdfPage = options.pdfPage;
  13000. this.accessibilityManager = options.accessibilityManager;
  13001. this.l10n = options.l10n || _l10n_utils.NullL10n;
  13002. this.annotationEditorLayer = null;
  13003. this.div = null;
  13004. this._cancelled = false;
  13005. this.#uiManager = options.uiManager;
  13006. this.#annotationLayer = options.annotationLayer || null;
  13007. }
  13008. async render(viewport) {
  13009. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13010. if (intent !== "display") {
  13011. return;
  13012. }
  13013. if (this._cancelled) {
  13014. return;
  13015. }
  13016. const clonedViewport = viewport.clone({
  13017. dontFlip: true
  13018. });
  13019. if (this.div) {
  13020. this.annotationEditorLayer.update({
  13021. viewport: clonedViewport
  13022. });
  13023. this.show();
  13024. return;
  13025. }
  13026. const div = this.div = document.createElement("div");
  13027. div.className = "annotationEditorLayer";
  13028. div.tabIndex = 0;
  13029. div.hidden = true;
  13030. this.pageDiv.append(div);
  13031. this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({
  13032. uiManager: this.#uiManager,
  13033. div,
  13034. accessibilityManager: this.accessibilityManager,
  13035. pageIndex: this.pdfPage.pageNumber - 1,
  13036. l10n: this.l10n,
  13037. viewport: clonedViewport,
  13038. annotationLayer: this.#annotationLayer
  13039. });
  13040. const parameters = {
  13041. viewport: clonedViewport,
  13042. div,
  13043. annotations: null,
  13044. intent
  13045. };
  13046. this.annotationEditorLayer.render(parameters);
  13047. this.show();
  13048. }
  13049. cancel() {
  13050. this._cancelled = true;
  13051. if (!this.div) {
  13052. return;
  13053. }
  13054. this.pageDiv = null;
  13055. this.annotationEditorLayer.destroy();
  13056. this.div.remove();
  13057. }
  13058. hide() {
  13059. if (!this.div) {
  13060. return;
  13061. }
  13062. this.div.hidden = true;
  13063. }
  13064. show() {
  13065. if (!this.div || this.annotationEditorLayer.isEmpty) {
  13066. return;
  13067. }
  13068. this.div.hidden = false;
  13069. }
  13070. }
  13071. exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
  13072. /***/ }),
  13073. /* 150 */
  13074. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13075. Object.defineProperty(exports, "__esModule", ({
  13076. value: true
  13077. }));
  13078. exports.AnnotationLayerBuilder = void 0;
  13079. var _pdfjsLib = __webpack_require__(122);
  13080. var _l10n_utils = __webpack_require__(147);
  13081. var _ui_utils = __webpack_require__(97);
  13082. class AnnotationLayerBuilder {
  13083. #onPresentationModeChanged = null;
  13084. constructor(_ref) {
  13085. let {
  13086. pageDiv,
  13087. pdfPage,
  13088. linkService,
  13089. downloadManager,
  13090. annotationStorage = null,
  13091. imageResourcesPath = "",
  13092. renderForms = true,
  13093. l10n = _l10n_utils.NullL10n,
  13094. enableScripting = false,
  13095. hasJSActionsPromise = null,
  13096. fieldObjectsPromise = null,
  13097. annotationCanvasMap = null,
  13098. accessibilityManager = null
  13099. } = _ref;
  13100. this.pageDiv = pageDiv;
  13101. this.pdfPage = pdfPage;
  13102. this.linkService = linkService;
  13103. this.downloadManager = downloadManager;
  13104. this.imageResourcesPath = imageResourcesPath;
  13105. this.renderForms = renderForms;
  13106. this.l10n = l10n;
  13107. this.annotationStorage = annotationStorage;
  13108. this.enableScripting = enableScripting;
  13109. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  13110. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  13111. this._annotationCanvasMap = annotationCanvasMap;
  13112. this._accessibilityManager = accessibilityManager;
  13113. this.annotationLayer = null;
  13114. this.div = null;
  13115. this._cancelled = false;
  13116. this._eventBus = linkService.eventBus;
  13117. }
  13118. async render(viewport) {
  13119. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13120. if (this.div) {
  13121. if (this._cancelled || !this.annotationLayer) {
  13122. return;
  13123. }
  13124. this.annotationLayer.update({
  13125. viewport: viewport.clone({
  13126. dontFlip: true
  13127. })
  13128. });
  13129. return;
  13130. }
  13131. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  13132. intent
  13133. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  13134. if (this._cancelled) {
  13135. return;
  13136. }
  13137. const div = this.div = document.createElement("div");
  13138. div.className = "annotationLayer";
  13139. this.pageDiv.append(div);
  13140. if (annotations.length === 0) {
  13141. this.hide();
  13142. return;
  13143. }
  13144. this.annotationLayer = new _pdfjsLib.AnnotationLayer({
  13145. div,
  13146. accessibilityManager: this._accessibilityManager,
  13147. annotationCanvasMap: this._annotationCanvasMap,
  13148. l10n: this.l10n,
  13149. page: this.pdfPage,
  13150. viewport: viewport.clone({
  13151. dontFlip: true
  13152. })
  13153. });
  13154. await this.annotationLayer.render({
  13155. annotations,
  13156. imageResourcesPath: this.imageResourcesPath,
  13157. renderForms: this.renderForms,
  13158. linkService: this.linkService,
  13159. downloadManager: this.downloadManager,
  13160. annotationStorage: this.annotationStorage,
  13161. enableScripting: this.enableScripting,
  13162. hasJSActions,
  13163. fieldObjects
  13164. });
  13165. if (this.linkService.isInPresentationMode) {
  13166. this.#updatePresentationModeState(_ui_utils.PresentationModeState.FULLSCREEN);
  13167. }
  13168. if (!this.#onPresentationModeChanged) {
  13169. this.#onPresentationModeChanged = evt => {
  13170. this.#updatePresentationModeState(evt.state);
  13171. };
  13172. this._eventBus?._on("presentationmodechanged", this.#onPresentationModeChanged);
  13173. }
  13174. }
  13175. cancel() {
  13176. this._cancelled = true;
  13177. if (this.#onPresentationModeChanged) {
  13178. this._eventBus?._off("presentationmodechanged", this.#onPresentationModeChanged);
  13179. this.#onPresentationModeChanged = null;
  13180. }
  13181. }
  13182. hide() {
  13183. if (!this.div) {
  13184. return;
  13185. }
  13186. this.div.hidden = true;
  13187. }
  13188. #updatePresentationModeState(state) {
  13189. if (!this.div) {
  13190. return;
  13191. }
  13192. let disableFormElements = false;
  13193. switch (state) {
  13194. case _ui_utils.PresentationModeState.FULLSCREEN:
  13195. disableFormElements = true;
  13196. break;
  13197. case _ui_utils.PresentationModeState.NORMAL:
  13198. break;
  13199. default:
  13200. return;
  13201. }
  13202. for (const section of this.div.childNodes) {
  13203. if (section.hasAttribute("data-internal-link")) {
  13204. continue;
  13205. }
  13206. section.inert = disableFormElements;
  13207. }
  13208. }
  13209. }
  13210. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  13211. /***/ }),
  13212. /* 151 */
  13213. /***/ ((__unused_webpack_module, exports) => {
  13214. Object.defineProperty(exports, "__esModule", ({
  13215. value: true
  13216. }));
  13217. exports.StructTreeLayerBuilder = void 0;
  13218. const PDF_ROLE_TO_HTML_ROLE = {
  13219. Document: null,
  13220. DocumentFragment: null,
  13221. Part: "group",
  13222. Sect: "group",
  13223. Div: "group",
  13224. Aside: "note",
  13225. NonStruct: "none",
  13226. P: null,
  13227. H: "heading",
  13228. Title: null,
  13229. FENote: "note",
  13230. Sub: "group",
  13231. Lbl: null,
  13232. Span: null,
  13233. Em: null,
  13234. Strong: null,
  13235. Link: "link",
  13236. Annot: "note",
  13237. Form: "form",
  13238. Ruby: null,
  13239. RB: null,
  13240. RT: null,
  13241. RP: null,
  13242. Warichu: null,
  13243. WT: null,
  13244. WP: null,
  13245. L: "list",
  13246. LI: "listitem",
  13247. LBody: null,
  13248. Table: "table",
  13249. TR: "row",
  13250. TH: "columnheader",
  13251. TD: "cell",
  13252. THead: "columnheader",
  13253. TBody: null,
  13254. TFoot: null,
  13255. Caption: null,
  13256. Figure: "figure",
  13257. Formula: null,
  13258. Artifact: null
  13259. };
  13260. const HEADING_PATTERN = /^H(\d+)$/;
  13261. class StructTreeLayerBuilder {
  13262. #treeDom = undefined;
  13263. get renderingDone() {
  13264. return this.#treeDom !== undefined;
  13265. }
  13266. render(structTree) {
  13267. if (this.#treeDom !== undefined) {
  13268. return this.#treeDom;
  13269. }
  13270. const treeDom = this.#walk(structTree);
  13271. treeDom?.classList.add("structTree");
  13272. return this.#treeDom = treeDom;
  13273. }
  13274. hide() {
  13275. if (this.#treeDom && !this.#treeDom.hidden) {
  13276. this.#treeDom.hidden = true;
  13277. }
  13278. }
  13279. show() {
  13280. if (this.#treeDom?.hidden) {
  13281. this.#treeDom.hidden = false;
  13282. }
  13283. }
  13284. #setAttributes(structElement, htmlElement) {
  13285. if (structElement.alt !== undefined) {
  13286. htmlElement.setAttribute("aria-label", structElement.alt);
  13287. }
  13288. if (structElement.id !== undefined) {
  13289. htmlElement.setAttribute("aria-owns", structElement.id);
  13290. }
  13291. if (structElement.lang !== undefined) {
  13292. htmlElement.setAttribute("lang", structElement.lang);
  13293. }
  13294. }
  13295. #walk(node) {
  13296. if (!node) {
  13297. return null;
  13298. }
  13299. const element = document.createElement("span");
  13300. if ("role" in node) {
  13301. const {
  13302. role
  13303. } = node;
  13304. const match = role.match(HEADING_PATTERN);
  13305. if (match) {
  13306. element.setAttribute("role", "heading");
  13307. element.setAttribute("aria-level", match[1]);
  13308. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  13309. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  13310. }
  13311. }
  13312. this.#setAttributes(node, element);
  13313. if (node.children) {
  13314. if (node.children.length === 1 && "id" in node.children[0]) {
  13315. this.#setAttributes(node.children[0], element);
  13316. } else {
  13317. for (const kid of node.children) {
  13318. element.append(this.#walk(kid));
  13319. }
  13320. }
  13321. }
  13322. return element;
  13323. }
  13324. }
  13325. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  13326. /***/ }),
  13327. /* 152 */
  13328. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13329. Object.defineProperty(exports, "__esModule", ({
  13330. value: true
  13331. }));
  13332. exports.TextAccessibilityManager = void 0;
  13333. __webpack_require__(76);
  13334. var _ui_utils = __webpack_require__(97);
  13335. class TextAccessibilityManager {
  13336. #enabled = false;
  13337. #textChildren = null;
  13338. #textNodes = new Map();
  13339. #waitingElements = new Map();
  13340. setTextMapping(textDivs) {
  13341. this.#textChildren = textDivs;
  13342. }
  13343. static #compareElementPositions(e1, e2) {
  13344. const rect1 = e1.getBoundingClientRect();
  13345. const rect2 = e2.getBoundingClientRect();
  13346. if (rect1.width === 0 && rect1.height === 0) {
  13347. return +1;
  13348. }
  13349. if (rect2.width === 0 && rect2.height === 0) {
  13350. return -1;
  13351. }
  13352. const top1 = rect1.y;
  13353. const bot1 = rect1.y + rect1.height;
  13354. const mid1 = rect1.y + rect1.height / 2;
  13355. const top2 = rect2.y;
  13356. const bot2 = rect2.y + rect2.height;
  13357. const mid2 = rect2.y + rect2.height / 2;
  13358. if (mid1 <= top2 && mid2 >= bot1) {
  13359. return -1;
  13360. }
  13361. if (mid2 <= top1 && mid1 >= bot2) {
  13362. return +1;
  13363. }
  13364. const centerX1 = rect1.x + rect1.width / 2;
  13365. const centerX2 = rect2.x + rect2.width / 2;
  13366. return centerX1 - centerX2;
  13367. }
  13368. enable() {
  13369. if (this.#enabled) {
  13370. throw new Error("TextAccessibilityManager is already enabled.");
  13371. }
  13372. if (!this.#textChildren) {
  13373. throw new Error("Text divs and strings have not been set.");
  13374. }
  13375. this.#enabled = true;
  13376. this.#textChildren = this.#textChildren.slice();
  13377. this.#textChildren.sort(TextAccessibilityManager.#compareElementPositions);
  13378. if (this.#textNodes.size > 0) {
  13379. const textChildren = this.#textChildren;
  13380. for (const [id, nodeIndex] of this.#textNodes) {
  13381. const element = document.getElementById(id);
  13382. if (!element) {
  13383. this.#textNodes.delete(id);
  13384. continue;
  13385. }
  13386. this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
  13387. }
  13388. }
  13389. for (const [element, isRemovable] of this.#waitingElements) {
  13390. this.addPointerInTextLayer(element, isRemovable);
  13391. }
  13392. this.#waitingElements.clear();
  13393. }
  13394. disable() {
  13395. if (!this.#enabled) {
  13396. return;
  13397. }
  13398. this.#waitingElements.clear();
  13399. this.#textChildren = null;
  13400. this.#enabled = false;
  13401. }
  13402. removePointerInTextLayer(element) {
  13403. if (!this.#enabled) {
  13404. this.#waitingElements.delete(element);
  13405. return;
  13406. }
  13407. const children = this.#textChildren;
  13408. if (!children || children.length === 0) {
  13409. return;
  13410. }
  13411. const {
  13412. id
  13413. } = element;
  13414. const nodeIndex = this.#textNodes.get(id);
  13415. if (nodeIndex === undefined) {
  13416. return;
  13417. }
  13418. const node = children[nodeIndex];
  13419. this.#textNodes.delete(id);
  13420. let owns = node.getAttribute("aria-owns");
  13421. if (owns?.includes(id)) {
  13422. owns = owns.split(" ").filter(x => x !== id).join(" ");
  13423. if (owns) {
  13424. node.setAttribute("aria-owns", owns);
  13425. } else {
  13426. node.removeAttribute("aria-owns");
  13427. node.setAttribute("role", "presentation");
  13428. }
  13429. }
  13430. }
  13431. #addIdToAriaOwns(id, node) {
  13432. const owns = node.getAttribute("aria-owns");
  13433. if (!owns?.includes(id)) {
  13434. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  13435. }
  13436. node.removeAttribute("role");
  13437. }
  13438. addPointerInTextLayer(element, isRemovable) {
  13439. const {
  13440. id
  13441. } = element;
  13442. if (!id) {
  13443. return;
  13444. }
  13445. if (!this.#enabled) {
  13446. this.#waitingElements.set(element, isRemovable);
  13447. return;
  13448. }
  13449. if (isRemovable) {
  13450. this.removePointerInTextLayer(element);
  13451. }
  13452. const children = this.#textChildren;
  13453. if (!children || children.length === 0) {
  13454. return;
  13455. }
  13456. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
  13457. const nodeIndex = Math.max(0, index - 1);
  13458. this.#addIdToAriaOwns(id, children[nodeIndex]);
  13459. this.#textNodes.set(id, nodeIndex);
  13460. }
  13461. moveElementInDOM(container, element, contentElement, isRemovable) {
  13462. this.addPointerInTextLayer(contentElement, isRemovable);
  13463. if (!container.hasChildNodes()) {
  13464. container.append(element);
  13465. return;
  13466. }
  13467. const children = Array.from(container.childNodes).filter(node => node !== element);
  13468. if (children.length === 0) {
  13469. return;
  13470. }
  13471. const elementToCompare = contentElement || element;
  13472. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
  13473. if (index === 0) {
  13474. children[0].before(element);
  13475. } else {
  13476. children[index - 1].after(element);
  13477. }
  13478. }
  13479. }
  13480. exports.TextAccessibilityManager = TextAccessibilityManager;
  13481. /***/ }),
  13482. /* 153 */
  13483. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13484. Object.defineProperty(exports, "__esModule", ({
  13485. value: true
  13486. }));
  13487. exports.TextHighlighter = void 0;
  13488. __webpack_require__(76);
  13489. __webpack_require__(89);
  13490. class TextHighlighter {
  13491. constructor(_ref) {
  13492. let {
  13493. findController,
  13494. eventBus,
  13495. pageIndex
  13496. } = _ref;
  13497. this.findController = findController;
  13498. this.matches = [];
  13499. this.eventBus = eventBus;
  13500. this.pageIdx = pageIndex;
  13501. this._onUpdateTextLayerMatches = null;
  13502. this.textDivs = null;
  13503. this.textContentItemsStr = null;
  13504. this.enabled = false;
  13505. }
  13506. setTextMapping(divs, texts) {
  13507. this.textDivs = divs;
  13508. this.textContentItemsStr = texts;
  13509. }
  13510. enable() {
  13511. if (!this.textDivs || !this.textContentItemsStr) {
  13512. throw new Error("Text divs and strings have not been set.");
  13513. }
  13514. if (this.enabled) {
  13515. throw new Error("TextHighlighter is already enabled.");
  13516. }
  13517. this.enabled = true;
  13518. if (!this._onUpdateTextLayerMatches) {
  13519. this._onUpdateTextLayerMatches = evt => {
  13520. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  13521. this._updateMatches();
  13522. }
  13523. };
  13524. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13525. }
  13526. this._updateMatches();
  13527. }
  13528. disable() {
  13529. if (!this.enabled) {
  13530. return;
  13531. }
  13532. this.enabled = false;
  13533. if (this._onUpdateTextLayerMatches) {
  13534. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13535. this._onUpdateTextLayerMatches = null;
  13536. }
  13537. this._updateMatches(true);
  13538. }
  13539. _convertMatches(matches, matchesLength) {
  13540. if (!matches) {
  13541. return [];
  13542. }
  13543. const {
  13544. textContentItemsStr
  13545. } = this;
  13546. let i = 0,
  13547. iIndex = 0;
  13548. const end = textContentItemsStr.length - 1;
  13549. const result = [];
  13550. for (let m = 0, mm = matches.length; m < mm; m++) {
  13551. let matchIdx = matches[m];
  13552. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  13553. iIndex += textContentItemsStr[i].length;
  13554. i++;
  13555. }
  13556. if (i === textContentItemsStr.length) {
  13557. console.error("Could not find a matching mapping");
  13558. }
  13559. const match = {
  13560. begin: {
  13561. divIdx: i,
  13562. offset: matchIdx - iIndex
  13563. }
  13564. };
  13565. matchIdx += matchesLength[m];
  13566. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  13567. iIndex += textContentItemsStr[i].length;
  13568. i++;
  13569. }
  13570. match.end = {
  13571. divIdx: i,
  13572. offset: matchIdx - iIndex
  13573. };
  13574. result.push(match);
  13575. }
  13576. return result;
  13577. }
  13578. _renderMatches(matches) {
  13579. if (matches.length === 0) {
  13580. return;
  13581. }
  13582. const {
  13583. findController,
  13584. pageIdx
  13585. } = this;
  13586. const {
  13587. textContentItemsStr,
  13588. textDivs
  13589. } = this;
  13590. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  13591. const selectedMatchIdx = findController.selected.matchIdx;
  13592. const highlightAll = findController.state.highlightAll;
  13593. let prevEnd = null;
  13594. const infinity = {
  13595. divIdx: -1,
  13596. offset: undefined
  13597. };
  13598. function beginText(begin, className) {
  13599. const divIdx = begin.divIdx;
  13600. textDivs[divIdx].textContent = "";
  13601. return appendTextToDiv(divIdx, 0, begin.offset, className);
  13602. }
  13603. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  13604. let div = textDivs[divIdx];
  13605. if (div.nodeType === Node.TEXT_NODE) {
  13606. const span = document.createElement("span");
  13607. div.before(span);
  13608. span.append(div);
  13609. textDivs[divIdx] = span;
  13610. div = span;
  13611. }
  13612. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  13613. const node = document.createTextNode(content);
  13614. if (className) {
  13615. const span = document.createElement("span");
  13616. span.className = `${className} appended`;
  13617. span.append(node);
  13618. div.append(span);
  13619. return className.includes("selected") ? span.offsetLeft : 0;
  13620. }
  13621. div.append(node);
  13622. return 0;
  13623. }
  13624. let i0 = selectedMatchIdx,
  13625. i1 = i0 + 1;
  13626. if (highlightAll) {
  13627. i0 = 0;
  13628. i1 = matches.length;
  13629. } else if (!isSelectedPage) {
  13630. return;
  13631. }
  13632. let lastDivIdx = -1;
  13633. let lastOffset = -1;
  13634. for (let i = i0; i < i1; i++) {
  13635. const match = matches[i];
  13636. const begin = match.begin;
  13637. if (begin.divIdx === lastDivIdx && begin.offset === lastOffset) {
  13638. continue;
  13639. }
  13640. lastDivIdx = begin.divIdx;
  13641. lastOffset = begin.offset;
  13642. const end = match.end;
  13643. const isSelected = isSelectedPage && i === selectedMatchIdx;
  13644. const highlightSuffix = isSelected ? " selected" : "";
  13645. let selectedLeft = 0;
  13646. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  13647. if (prevEnd !== null) {
  13648. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13649. }
  13650. beginText(begin);
  13651. } else {
  13652. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  13653. }
  13654. if (begin.divIdx === end.divIdx) {
  13655. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  13656. } else {
  13657. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  13658. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  13659. textDivs[n0].className = "highlight middle" + highlightSuffix;
  13660. }
  13661. beginText(end, "highlight end" + highlightSuffix);
  13662. }
  13663. prevEnd = end;
  13664. if (isSelected) {
  13665. findController.scrollMatchIntoView({
  13666. element: textDivs[begin.divIdx],
  13667. selectedLeft,
  13668. pageIndex: pageIdx,
  13669. matchIndex: selectedMatchIdx
  13670. });
  13671. }
  13672. }
  13673. if (prevEnd) {
  13674. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13675. }
  13676. }
  13677. _updateMatches() {
  13678. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13679. if (!this.enabled && !reset) {
  13680. return;
  13681. }
  13682. const {
  13683. findController,
  13684. matches,
  13685. pageIdx
  13686. } = this;
  13687. const {
  13688. textContentItemsStr,
  13689. textDivs
  13690. } = this;
  13691. let clearedUntilDivIdx = -1;
  13692. for (const match of matches) {
  13693. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13694. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  13695. const div = textDivs[n];
  13696. div.textContent = textContentItemsStr[n];
  13697. div.className = "";
  13698. }
  13699. clearedUntilDivIdx = match.end.divIdx + 1;
  13700. }
  13701. if (!findController?.highlightMatches || reset) {
  13702. return;
  13703. }
  13704. const pageMatches = findController.pageMatches[pageIdx] || null;
  13705. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13706. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13707. this._renderMatches(this.matches);
  13708. }
  13709. }
  13710. exports.TextHighlighter = TextHighlighter;
  13711. /***/ }),
  13712. /* 154 */
  13713. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13714. Object.defineProperty(exports, "__esModule", ({
  13715. value: true
  13716. }));
  13717. exports.TextLayerBuilder = void 0;
  13718. __webpack_require__(76);
  13719. var _pdfjsLib = __webpack_require__(122);
  13720. var _ui_utils = __webpack_require__(97);
  13721. class TextLayerBuilder {
  13722. #enablePermissions = false;
  13723. #rotation = 0;
  13724. #scale = 0;
  13725. #textContentSource = null;
  13726. constructor(_ref) {
  13727. let {
  13728. highlighter = null,
  13729. accessibilityManager = null,
  13730. isOffscreenCanvasSupported = true,
  13731. enablePermissions = false
  13732. } = _ref;
  13733. this.textContentItemsStr = [];
  13734. this.renderingDone = false;
  13735. this.textDivs = [];
  13736. this.textDivProperties = new WeakMap();
  13737. this.textLayerRenderTask = null;
  13738. this.highlighter = highlighter;
  13739. this.accessibilityManager = accessibilityManager;
  13740. this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  13741. this.#enablePermissions = enablePermissions === true;
  13742. this.div = document.createElement("div");
  13743. this.div.className = "textLayer";
  13744. this.hide();
  13745. }
  13746. #finishRendering() {
  13747. this.renderingDone = true;
  13748. const endOfContent = document.createElement("div");
  13749. endOfContent.className = "endOfContent";
  13750. this.div.append(endOfContent);
  13751. this.#bindMouse();
  13752. }
  13753. get numTextDivs() {
  13754. return this.textDivs.length;
  13755. }
  13756. async render(viewport) {
  13757. if (!this.#textContentSource) {
  13758. throw new Error('No "textContentSource" parameter specified.');
  13759. }
  13760. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  13761. const {
  13762. rotation
  13763. } = viewport;
  13764. if (this.renderingDone) {
  13765. const mustRotate = rotation !== this.#rotation;
  13766. const mustRescale = scale !== this.#scale;
  13767. if (mustRotate || mustRescale) {
  13768. this.hide();
  13769. (0, _pdfjsLib.updateTextLayer)({
  13770. container: this.div,
  13771. viewport,
  13772. textDivs: this.textDivs,
  13773. textDivProperties: this.textDivProperties,
  13774. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  13775. mustRescale,
  13776. mustRotate
  13777. });
  13778. this.#scale = scale;
  13779. this.#rotation = rotation;
  13780. }
  13781. this.show();
  13782. return;
  13783. }
  13784. this.cancel();
  13785. this.highlighter?.setTextMapping(this.textDivs, this.textContentItemsStr);
  13786. this.accessibilityManager?.setTextMapping(this.textDivs);
  13787. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  13788. textContentSource: this.#textContentSource,
  13789. container: this.div,
  13790. viewport,
  13791. textDivs: this.textDivs,
  13792. textDivProperties: this.textDivProperties,
  13793. textContentItemsStr: this.textContentItemsStr,
  13794. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported
  13795. });
  13796. await this.textLayerRenderTask.promise;
  13797. this.#finishRendering();
  13798. this.#scale = scale;
  13799. this.#rotation = rotation;
  13800. this.show();
  13801. this.accessibilityManager?.enable();
  13802. }
  13803. hide() {
  13804. if (!this.div.hidden) {
  13805. this.highlighter?.disable();
  13806. this.div.hidden = true;
  13807. }
  13808. }
  13809. show() {
  13810. if (this.div.hidden && this.renderingDone) {
  13811. this.div.hidden = false;
  13812. this.highlighter?.enable();
  13813. }
  13814. }
  13815. cancel() {
  13816. if (this.textLayerRenderTask) {
  13817. this.textLayerRenderTask.cancel();
  13818. this.textLayerRenderTask = null;
  13819. }
  13820. this.highlighter?.disable();
  13821. this.accessibilityManager?.disable();
  13822. this.textContentItemsStr.length = 0;
  13823. this.textDivs.length = 0;
  13824. this.textDivProperties = new WeakMap();
  13825. }
  13826. setTextContentSource(source) {
  13827. this.cancel();
  13828. this.#textContentSource = source;
  13829. }
  13830. #bindMouse() {
  13831. const {
  13832. div
  13833. } = this;
  13834. div.addEventListener("mousedown", evt => {
  13835. const end = div.querySelector(".endOfContent");
  13836. if (!end) {
  13837. return;
  13838. }
  13839. let adjustTop = evt.target !== div;
  13840. adjustTop &&= getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  13841. if (adjustTop) {
  13842. const divBounds = div.getBoundingClientRect();
  13843. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  13844. end.style.top = (r * 100).toFixed(2) + "%";
  13845. }
  13846. end.classList.add("active");
  13847. });
  13848. div.addEventListener("mouseup", () => {
  13849. const end = div.querySelector(".endOfContent");
  13850. if (!end) {
  13851. return;
  13852. }
  13853. end.style.top = "";
  13854. end.classList.remove("active");
  13855. });
  13856. div.addEventListener("copy", event => {
  13857. if (!this.#enablePermissions) {
  13858. const selection = document.getSelection();
  13859. event.clipboardData.setData("text/plain", (0, _ui_utils.removeNullCharacters)((0, _pdfjsLib.normalizeUnicode)(selection.toString())));
  13860. }
  13861. event.preventDefault();
  13862. event.stopPropagation();
  13863. });
  13864. }
  13865. }
  13866. exports.TextLayerBuilder = TextLayerBuilder;
  13867. /***/ }),
  13868. /* 155 */
  13869. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13870. Object.defineProperty(exports, "__esModule", ({
  13871. value: true
  13872. }));
  13873. exports.XfaLayerBuilder = void 0;
  13874. var _pdfjsLib = __webpack_require__(122);
  13875. class XfaLayerBuilder {
  13876. constructor(_ref) {
  13877. let {
  13878. pageDiv,
  13879. pdfPage,
  13880. annotationStorage = null,
  13881. linkService,
  13882. xfaHtml = null
  13883. } = _ref;
  13884. this.pageDiv = pageDiv;
  13885. this.pdfPage = pdfPage;
  13886. this.annotationStorage = annotationStorage;
  13887. this.linkService = linkService;
  13888. this.xfaHtml = xfaHtml;
  13889. this.div = null;
  13890. this._cancelled = false;
  13891. }
  13892. async render(viewport) {
  13893. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  13894. if (intent === "print") {
  13895. const parameters = {
  13896. viewport: viewport.clone({
  13897. dontFlip: true
  13898. }),
  13899. div: this.div,
  13900. xfaHtml: this.xfaHtml,
  13901. annotationStorage: this.annotationStorage,
  13902. linkService: this.linkService,
  13903. intent
  13904. };
  13905. const div = document.createElement("div");
  13906. this.pageDiv.append(div);
  13907. parameters.div = div;
  13908. return _pdfjsLib.XfaLayer.render(parameters);
  13909. }
  13910. const xfaHtml = await this.pdfPage.getXfa();
  13911. if (this._cancelled || !xfaHtml) {
  13912. return {
  13913. textDivs: []
  13914. };
  13915. }
  13916. const parameters = {
  13917. viewport: viewport.clone({
  13918. dontFlip: true
  13919. }),
  13920. div: this.div,
  13921. xfaHtml,
  13922. annotationStorage: this.annotationStorage,
  13923. linkService: this.linkService,
  13924. intent
  13925. };
  13926. if (this.div) {
  13927. return _pdfjsLib.XfaLayer.update(parameters);
  13928. }
  13929. this.div = document.createElement("div");
  13930. this.pageDiv.append(this.div);
  13931. parameters.div = this.div;
  13932. return _pdfjsLib.XfaLayer.render(parameters);
  13933. }
  13934. cancel() {
  13935. this._cancelled = true;
  13936. }
  13937. hide() {
  13938. if (!this.div) {
  13939. return;
  13940. }
  13941. this.div.hidden = true;
  13942. }
  13943. }
  13944. exports.XfaLayerBuilder = XfaLayerBuilder;
  13945. /***/ }),
  13946. /* 156 */
  13947. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13948. Object.defineProperty(exports, "__esModule", ({
  13949. value: true
  13950. }));
  13951. exports.SecondaryToolbar = void 0;
  13952. __webpack_require__(89);
  13953. var _ui_utils = __webpack_require__(97);
  13954. var _pdf_viewer = __webpack_require__(146);
  13955. class SecondaryToolbar {
  13956. constructor(options, eventBus, externalServices) {
  13957. this.toolbar = options.toolbar;
  13958. this.toggleButton = options.toggleButton;
  13959. this.buttons = [{
  13960. element: options.presentationModeButton,
  13961. eventName: "presentationmode",
  13962. close: true
  13963. }, {
  13964. element: options.printButton,
  13965. eventName: "print",
  13966. close: true
  13967. }, {
  13968. element: options.downloadButton,
  13969. eventName: "download",
  13970. close: true
  13971. }, {
  13972. element: options.viewBookmarkButton,
  13973. eventName: null,
  13974. close: true
  13975. }, {
  13976. element: options.firstPageButton,
  13977. eventName: "firstpage",
  13978. close: true
  13979. }, {
  13980. element: options.lastPageButton,
  13981. eventName: "lastpage",
  13982. close: true
  13983. }, {
  13984. element: options.pageRotateCwButton,
  13985. eventName: "rotatecw",
  13986. close: false
  13987. }, {
  13988. element: options.pageRotateCcwButton,
  13989. eventName: "rotateccw",
  13990. close: false
  13991. }, {
  13992. element: options.cursorSelectToolButton,
  13993. eventName: "switchcursortool",
  13994. eventDetails: {
  13995. tool: _ui_utils.CursorTool.SELECT
  13996. },
  13997. close: true
  13998. }, {
  13999. element: options.cursorHandToolButton,
  14000. eventName: "switchcursortool",
  14001. eventDetails: {
  14002. tool: _ui_utils.CursorTool.HAND
  14003. },
  14004. close: true
  14005. }, {
  14006. element: options.scrollPageButton,
  14007. eventName: "switchscrollmode",
  14008. eventDetails: {
  14009. mode: _ui_utils.ScrollMode.PAGE
  14010. },
  14011. close: true
  14012. }, {
  14013. element: options.scrollVerticalButton,
  14014. eventName: "switchscrollmode",
  14015. eventDetails: {
  14016. mode: _ui_utils.ScrollMode.VERTICAL
  14017. },
  14018. close: true
  14019. }, {
  14020. element: options.scrollHorizontalButton,
  14021. eventName: "switchscrollmode",
  14022. eventDetails: {
  14023. mode: _ui_utils.ScrollMode.HORIZONTAL
  14024. },
  14025. close: true
  14026. }, {
  14027. element: options.scrollWrappedButton,
  14028. eventName: "switchscrollmode",
  14029. eventDetails: {
  14030. mode: _ui_utils.ScrollMode.WRAPPED
  14031. },
  14032. close: true
  14033. }, {
  14034. element: options.spreadNoneButton,
  14035. eventName: "switchspreadmode",
  14036. eventDetails: {
  14037. mode: _ui_utils.SpreadMode.NONE
  14038. },
  14039. close: true
  14040. }, {
  14041. element: options.spreadOddButton,
  14042. eventName: "switchspreadmode",
  14043. eventDetails: {
  14044. mode: _ui_utils.SpreadMode.ODD
  14045. },
  14046. close: true
  14047. }, {
  14048. element: options.spreadEvenButton,
  14049. eventName: "switchspreadmode",
  14050. eventDetails: {
  14051. mode: _ui_utils.SpreadMode.EVEN
  14052. },
  14053. close: true
  14054. }, {
  14055. element: options.documentPropertiesButton,
  14056. eventName: "documentproperties",
  14057. close: true
  14058. }];
  14059. this.buttons.push({
  14060. element: options.openFileButton,
  14061. eventName: "openfile",
  14062. close: true
  14063. });
  14064. this.items = {
  14065. firstPage: options.firstPageButton,
  14066. lastPage: options.lastPageButton,
  14067. pageRotateCw: options.pageRotateCwButton,
  14068. pageRotateCcw: options.pageRotateCcwButton
  14069. };
  14070. this.eventBus = eventBus;
  14071. this.externalServices = externalServices;
  14072. this.opened = false;
  14073. this.#bindClickListeners();
  14074. this.#bindCursorToolsListener(options);
  14075. this.#bindScrollModeListener(options);
  14076. this.#bindSpreadModeListener(options);
  14077. this.reset();
  14078. }
  14079. get isOpen() {
  14080. return this.opened;
  14081. }
  14082. setPageNumber(pageNumber) {
  14083. this.pageNumber = pageNumber;
  14084. this.#updateUIState();
  14085. }
  14086. setPagesCount(pagesCount) {
  14087. this.pagesCount = pagesCount;
  14088. this.#updateUIState();
  14089. }
  14090. reset() {
  14091. this.pageNumber = 0;
  14092. this.pagesCount = 0;
  14093. this.#updateUIState();
  14094. this.eventBus.dispatch("secondarytoolbarreset", {
  14095. source: this
  14096. });
  14097. }
  14098. #updateUIState() {
  14099. this.items.firstPage.disabled = this.pageNumber <= 1;
  14100. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  14101. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  14102. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  14103. }
  14104. #bindClickListeners() {
  14105. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  14106. for (const {
  14107. element,
  14108. eventName,
  14109. close,
  14110. eventDetails
  14111. } of this.buttons) {
  14112. element.addEventListener("click", evt => {
  14113. if (eventName !== null) {
  14114. this.eventBus.dispatch(eventName, {
  14115. source: this,
  14116. ...eventDetails
  14117. });
  14118. }
  14119. if (close) {
  14120. this.close();
  14121. }
  14122. this.externalServices.reportTelemetry({
  14123. type: "buttons",
  14124. data: {
  14125. id: element.id
  14126. }
  14127. });
  14128. });
  14129. }
  14130. }
  14131. #bindCursorToolsListener(_ref) {
  14132. let {
  14133. cursorSelectToolButton,
  14134. cursorHandToolButton
  14135. } = _ref;
  14136. this.eventBus._on("cursortoolchanged", _ref2 => {
  14137. let {
  14138. tool
  14139. } = _ref2;
  14140. (0, _ui_utils.toggleCheckedBtn)(cursorSelectToolButton, tool === _ui_utils.CursorTool.SELECT);
  14141. (0, _ui_utils.toggleCheckedBtn)(cursorHandToolButton, tool === _ui_utils.CursorTool.HAND);
  14142. });
  14143. }
  14144. #bindScrollModeListener(_ref3) {
  14145. let {
  14146. scrollPageButton,
  14147. scrollVerticalButton,
  14148. scrollHorizontalButton,
  14149. scrollWrappedButton,
  14150. spreadNoneButton,
  14151. spreadOddButton,
  14152. spreadEvenButton
  14153. } = _ref3;
  14154. const scrollModeChanged = _ref4 => {
  14155. let {
  14156. mode
  14157. } = _ref4;
  14158. (0, _ui_utils.toggleCheckedBtn)(scrollPageButton, mode === _ui_utils.ScrollMode.PAGE);
  14159. (0, _ui_utils.toggleCheckedBtn)(scrollVerticalButton, mode === _ui_utils.ScrollMode.VERTICAL);
  14160. (0, _ui_utils.toggleCheckedBtn)(scrollHorizontalButton, mode === _ui_utils.ScrollMode.HORIZONTAL);
  14161. (0, _ui_utils.toggleCheckedBtn)(scrollWrappedButton, mode === _ui_utils.ScrollMode.WRAPPED);
  14162. const forceScrollModePage = this.pagesCount > _pdf_viewer.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  14163. scrollPageButton.disabled = forceScrollModePage;
  14164. scrollVerticalButton.disabled = forceScrollModePage;
  14165. scrollHorizontalButton.disabled = forceScrollModePage;
  14166. scrollWrappedButton.disabled = forceScrollModePage;
  14167. const isHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  14168. spreadNoneButton.disabled = isHorizontal;
  14169. spreadOddButton.disabled = isHorizontal;
  14170. spreadEvenButton.disabled = isHorizontal;
  14171. };
  14172. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  14173. this.eventBus._on("secondarytoolbarreset", evt => {
  14174. if (evt.source === this) {
  14175. scrollModeChanged({
  14176. mode: _ui_utils.ScrollMode.VERTICAL
  14177. });
  14178. }
  14179. });
  14180. }
  14181. #bindSpreadModeListener(_ref5) {
  14182. let {
  14183. spreadNoneButton,
  14184. spreadOddButton,
  14185. spreadEvenButton
  14186. } = _ref5;
  14187. const spreadModeChanged = _ref6 => {
  14188. let {
  14189. mode
  14190. } = _ref6;
  14191. (0, _ui_utils.toggleCheckedBtn)(spreadNoneButton, mode === _ui_utils.SpreadMode.NONE);
  14192. (0, _ui_utils.toggleCheckedBtn)(spreadOddButton, mode === _ui_utils.SpreadMode.ODD);
  14193. (0, _ui_utils.toggleCheckedBtn)(spreadEvenButton, mode === _ui_utils.SpreadMode.EVEN);
  14194. };
  14195. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  14196. this.eventBus._on("secondarytoolbarreset", evt => {
  14197. if (evt.source === this) {
  14198. spreadModeChanged({
  14199. mode: _ui_utils.SpreadMode.NONE
  14200. });
  14201. }
  14202. });
  14203. }
  14204. open() {
  14205. if (this.opened) {
  14206. return;
  14207. }
  14208. this.opened = true;
  14209. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, true, this.toolbar);
  14210. }
  14211. close() {
  14212. if (!this.opened) {
  14213. return;
  14214. }
  14215. this.opened = false;
  14216. (0, _ui_utils.toggleExpandedBtn)(this.toggleButton, false, this.toolbar);
  14217. }
  14218. toggle() {
  14219. if (this.opened) {
  14220. this.close();
  14221. } else {
  14222. this.open();
  14223. }
  14224. }
  14225. }
  14226. exports.SecondaryToolbar = SecondaryToolbar;
  14227. /***/ }),
  14228. /* 157 */
  14229. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14230. Object.defineProperty(exports, "__esModule", ({
  14231. value: true
  14232. }));
  14233. exports.Toolbar = void 0;
  14234. __webpack_require__(89);
  14235. var _ui_utils = __webpack_require__(97);
  14236. var _pdfjsLib = __webpack_require__(122);
  14237. const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  14238. class Toolbar {
  14239. #wasLocalized = false;
  14240. constructor(options, eventBus, l10n) {
  14241. this.toolbar = options.container;
  14242. this.eventBus = eventBus;
  14243. this.l10n = l10n;
  14244. this.buttons = [{
  14245. element: options.previous,
  14246. eventName: "previouspage"
  14247. }, {
  14248. element: options.next,
  14249. eventName: "nextpage"
  14250. }, {
  14251. element: options.zoomIn,
  14252. eventName: "zoomin"
  14253. }, {
  14254. element: options.zoomOut,
  14255. eventName: "zoomout"
  14256. }, {
  14257. element: options.print,
  14258. eventName: "print"
  14259. }, {
  14260. element: options.download,
  14261. eventName: "download"
  14262. }, {
  14263. element: options.editorFreeTextButton,
  14264. eventName: "switchannotationeditormode",
  14265. eventDetails: {
  14266. get mode() {
  14267. const {
  14268. classList
  14269. } = options.editorFreeTextButton;
  14270. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.FREETEXT;
  14271. }
  14272. }
  14273. }, {
  14274. element: options.editorInkButton,
  14275. eventName: "switchannotationeditormode",
  14276. eventDetails: {
  14277. get mode() {
  14278. const {
  14279. classList
  14280. } = options.editorInkButton;
  14281. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.INK;
  14282. }
  14283. }
  14284. }, {
  14285. element: options.editorStampButton,
  14286. eventName: "switchannotationeditormode",
  14287. eventDetails: {
  14288. get mode() {
  14289. const {
  14290. classList
  14291. } = options.editorStampButton;
  14292. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.STAMP;
  14293. }
  14294. }
  14295. }];
  14296. this.buttons.push({
  14297. element: options.openFile,
  14298. eventName: "openfile"
  14299. });
  14300. this.items = {
  14301. numPages: options.numPages,
  14302. pageNumber: options.pageNumber,
  14303. scaleSelect: options.scaleSelect,
  14304. customScaleOption: options.customScaleOption,
  14305. previous: options.previous,
  14306. next: options.next,
  14307. zoomIn: options.zoomIn,
  14308. zoomOut: options.zoomOut
  14309. };
  14310. this.#bindListeners(options);
  14311. this.reset();
  14312. }
  14313. setPageNumber(pageNumber, pageLabel) {
  14314. this.pageNumber = pageNumber;
  14315. this.pageLabel = pageLabel;
  14316. this.#updateUIState(false);
  14317. }
  14318. setPagesCount(pagesCount, hasPageLabels) {
  14319. this.pagesCount = pagesCount;
  14320. this.hasPageLabels = hasPageLabels;
  14321. this.#updateUIState(true);
  14322. }
  14323. setPageScale(pageScaleValue, pageScale) {
  14324. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  14325. this.pageScale = pageScale;
  14326. this.#updateUIState(false);
  14327. }
  14328. reset() {
  14329. this.pageNumber = 0;
  14330. this.pageLabel = null;
  14331. this.hasPageLabels = false;
  14332. this.pagesCount = 0;
  14333. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  14334. this.pageScale = _ui_utils.DEFAULT_SCALE;
  14335. this.#updateUIState(true);
  14336. this.updateLoadingIndicatorState();
  14337. this.eventBus.dispatch("toolbarreset", {
  14338. source: this
  14339. });
  14340. }
  14341. #bindListeners(options) {
  14342. const {
  14343. pageNumber,
  14344. scaleSelect
  14345. } = this.items;
  14346. const self = this;
  14347. for (const {
  14348. element,
  14349. eventName,
  14350. eventDetails
  14351. } of this.buttons) {
  14352. element.addEventListener("click", evt => {
  14353. if (eventName !== null) {
  14354. this.eventBus.dispatch(eventName, {
  14355. source: this,
  14356. ...eventDetails
  14357. });
  14358. }
  14359. });
  14360. }
  14361. pageNumber.addEventListener("click", function () {
  14362. this.select();
  14363. });
  14364. pageNumber.addEventListener("change", function () {
  14365. self.eventBus.dispatch("pagenumberchanged", {
  14366. source: self,
  14367. value: this.value
  14368. });
  14369. });
  14370. scaleSelect.addEventListener("change", function () {
  14371. if (this.value === "custom") {
  14372. return;
  14373. }
  14374. self.eventBus.dispatch("scalechanged", {
  14375. source: self,
  14376. value: this.value
  14377. });
  14378. });
  14379. scaleSelect.addEventListener("click", function (evt) {
  14380. const target = evt.target;
  14381. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  14382. this.blur();
  14383. }
  14384. });
  14385. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  14386. this.eventBus._on("localized", () => {
  14387. this.#wasLocalized = true;
  14388. this.#adjustScaleWidth();
  14389. this.#updateUIState(true);
  14390. });
  14391. this.#bindEditorToolsListener(options);
  14392. }
  14393. #bindEditorToolsListener(_ref) {
  14394. let {
  14395. editorFreeTextButton,
  14396. editorFreeTextParamsToolbar,
  14397. editorInkButton,
  14398. editorInkParamsToolbar,
  14399. editorStampButton,
  14400. editorStampParamsToolbar
  14401. } = _ref;
  14402. const editorModeChanged = _ref2 => {
  14403. let {
  14404. mode
  14405. } = _ref2;
  14406. (0, _ui_utils.toggleCheckedBtn)(editorFreeTextButton, mode === _pdfjsLib.AnnotationEditorType.FREETEXT, editorFreeTextParamsToolbar);
  14407. (0, _ui_utils.toggleCheckedBtn)(editorInkButton, mode === _pdfjsLib.AnnotationEditorType.INK, editorInkParamsToolbar);
  14408. (0, _ui_utils.toggleCheckedBtn)(editorStampButton, mode === _pdfjsLib.AnnotationEditorType.STAMP, editorStampParamsToolbar);
  14409. const isDisable = mode === _pdfjsLib.AnnotationEditorType.DISABLE;
  14410. editorFreeTextButton.disabled = isDisable;
  14411. editorInkButton.disabled = isDisable;
  14412. editorStampButton.disabled = isDisable;
  14413. };
  14414. this.eventBus._on("annotationeditormodechanged", editorModeChanged);
  14415. this.eventBus._on("toolbarreset", evt => {
  14416. if (evt.source === this) {
  14417. editorModeChanged({
  14418. mode: _pdfjsLib.AnnotationEditorType.DISABLE
  14419. });
  14420. }
  14421. });
  14422. }
  14423. #updateUIState() {
  14424. let resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14425. if (!this.#wasLocalized) {
  14426. return;
  14427. }
  14428. const {
  14429. pageNumber,
  14430. pagesCount,
  14431. pageScaleValue,
  14432. pageScale,
  14433. items
  14434. } = this;
  14435. if (resetNumPages) {
  14436. if (this.hasPageLabels) {
  14437. items.pageNumber.type = "text";
  14438. } else {
  14439. items.pageNumber.type = "number";
  14440. this.l10n.get("of_pages", {
  14441. pagesCount
  14442. }).then(msg => {
  14443. items.numPages.textContent = msg;
  14444. });
  14445. }
  14446. items.pageNumber.max = pagesCount;
  14447. }
  14448. if (this.hasPageLabels) {
  14449. items.pageNumber.value = this.pageLabel;
  14450. this.l10n.get("page_of_pages", {
  14451. pageNumber,
  14452. pagesCount
  14453. }).then(msg => {
  14454. items.numPages.textContent = msg;
  14455. });
  14456. } else {
  14457. items.pageNumber.value = pageNumber;
  14458. }
  14459. items.previous.disabled = pageNumber <= 1;
  14460. items.next.disabled = pageNumber >= pagesCount;
  14461. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  14462. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  14463. this.l10n.get("page_scale_percent", {
  14464. scale: Math.round(pageScale * 10000) / 100
  14465. }).then(msg => {
  14466. let predefinedValueFound = false;
  14467. for (const option of items.scaleSelect.options) {
  14468. if (option.value !== pageScaleValue) {
  14469. option.selected = false;
  14470. continue;
  14471. }
  14472. option.selected = true;
  14473. predefinedValueFound = true;
  14474. }
  14475. if (!predefinedValueFound) {
  14476. items.customScaleOption.textContent = msg;
  14477. items.customScaleOption.selected = true;
  14478. }
  14479. });
  14480. }
  14481. updateLoadingIndicatorState() {
  14482. let loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14483. const {
  14484. pageNumber
  14485. } = this.items;
  14486. pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  14487. }
  14488. async #adjustScaleWidth() {
  14489. const {
  14490. items,
  14491. l10n
  14492. } = this;
  14493. const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
  14494. await _ui_utils.animationStarted;
  14495. const style = getComputedStyle(items.scaleSelect);
  14496. const scaleSelectWidth = parseFloat(style.getPropertyValue("--scale-select-width"));
  14497. const canvas = document.createElement("canvas");
  14498. const ctx = canvas.getContext("2d", {
  14499. alpha: false
  14500. });
  14501. ctx.font = `${style.fontSize} ${style.fontFamily}`;
  14502. let maxWidth = 0;
  14503. for (const predefinedValue of await predefinedValuesPromise) {
  14504. const {
  14505. width
  14506. } = ctx.measureText(predefinedValue);
  14507. if (width > maxWidth) {
  14508. maxWidth = width;
  14509. }
  14510. }
  14511. maxWidth += 0.3 * scaleSelectWidth;
  14512. if (maxWidth > scaleSelectWidth) {
  14513. const container = items.scaleSelect.parentNode;
  14514. container.style.setProperty("--scale-select-width", `${maxWidth}px`);
  14515. }
  14516. canvas.width = 0;
  14517. canvas.height = 0;
  14518. }
  14519. }
  14520. exports.Toolbar = Toolbar;
  14521. /***/ }),
  14522. /* 158 */
  14523. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14524. Object.defineProperty(exports, "__esModule", ({
  14525. value: true
  14526. }));
  14527. exports.ViewHistory = void 0;
  14528. __webpack_require__(2);
  14529. __webpack_require__(89);
  14530. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  14531. class ViewHistory {
  14532. constructor(fingerprint) {
  14533. let cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  14534. this.fingerprint = fingerprint;
  14535. this.cacheSize = cacheSize;
  14536. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  14537. const database = JSON.parse(databaseStr || "{}");
  14538. let index = -1;
  14539. if (!Array.isArray(database.files)) {
  14540. database.files = [];
  14541. } else {
  14542. while (database.files.length >= this.cacheSize) {
  14543. database.files.shift();
  14544. }
  14545. for (let i = 0, ii = database.files.length; i < ii; i++) {
  14546. const branch = database.files[i];
  14547. if (branch.fingerprint === this.fingerprint) {
  14548. index = i;
  14549. break;
  14550. }
  14551. }
  14552. }
  14553. if (index === -1) {
  14554. index = database.files.push({
  14555. fingerprint: this.fingerprint
  14556. }) - 1;
  14557. }
  14558. this.file = database.files[index];
  14559. this.database = database;
  14560. });
  14561. }
  14562. async _writeToStorage() {
  14563. const databaseStr = JSON.stringify(this.database);
  14564. localStorage.setItem("pdfjs.history", databaseStr);
  14565. }
  14566. async _readFromStorage() {
  14567. return localStorage.getItem("pdfjs.history");
  14568. }
  14569. async set(name, val) {
  14570. await this._initializedPromise;
  14571. this.file[name] = val;
  14572. return this._writeToStorage();
  14573. }
  14574. async setMultiple(properties) {
  14575. await this._initializedPromise;
  14576. for (const name in properties) {
  14577. this.file[name] = properties[name];
  14578. }
  14579. return this._writeToStorage();
  14580. }
  14581. async get(name, defaultValue) {
  14582. await this._initializedPromise;
  14583. const val = this.file[name];
  14584. return val !== undefined ? val : defaultValue;
  14585. }
  14586. async getMultiple(properties) {
  14587. await this._initializedPromise;
  14588. const values = Object.create(null);
  14589. for (const name in properties) {
  14590. const val = this.file[name];
  14591. values[name] = val !== undefined ? val : properties[name];
  14592. }
  14593. return values;
  14594. }
  14595. }
  14596. exports.ViewHistory = ViewHistory;
  14597. /***/ }),
  14598. /* 159 */
  14599. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14600. Object.defineProperty(exports, "__esModule", ({
  14601. value: true
  14602. }));
  14603. exports.BasePreferences = void 0;
  14604. __webpack_require__(76);
  14605. var _app_options = __webpack_require__(123);
  14606. class BasePreferences {
  14607. #defaults = Object.freeze({
  14608. "annotationEditorMode": 0,
  14609. "annotationMode": 2,
  14610. "cursorToolOnLoad": 0,
  14611. "defaultZoomDelay": 400,
  14612. "defaultZoomValue": "",
  14613. "disablePageLabels": false,
  14614. "enablePermissions": false,
  14615. "enablePrintAutoRotate": true,
  14616. "enableScripting": true,
  14617. "enableStampEditor": true,
  14618. "externalLinkTarget": 0,
  14619. "historyUpdateUrl": false,
  14620. "ignoreDestinationZoom": false,
  14621. "forcePageColors": false,
  14622. "pageColorsBackground": "Canvas",
  14623. "pageColorsForeground": "CanvasText",
  14624. "pdfBugEnabled": false,
  14625. "sidebarViewOnLoad": -1,
  14626. "scrollModeOnLoad": -1,
  14627. "spreadModeOnLoad": -1,
  14628. "textLayerMode": 1,
  14629. "viewerCssTheme": 0,
  14630. "viewOnLoad": 0,
  14631. "disableAutoFetch": false,
  14632. "disableFontFace": false,
  14633. "disableRange": false,
  14634. "disableStream": false,
  14635. "enableXfa": true
  14636. });
  14637. #prefs = Object.create(null);
  14638. #initializedPromise = null;
  14639. constructor() {
  14640. if (this.constructor === BasePreferences) {
  14641. throw new Error("Cannot initialize BasePreferences.");
  14642. }
  14643. this.#initializedPromise = this._readFromStorage(this.#defaults).then(prefs => {
  14644. for (const name in this.#defaults) {
  14645. const prefValue = prefs?.[name];
  14646. if (typeof prefValue === typeof this.#defaults[name]) {
  14647. this.#prefs[name] = prefValue;
  14648. }
  14649. }
  14650. });
  14651. }
  14652. async _writeToStorage(prefObj) {
  14653. throw new Error("Not implemented: _writeToStorage");
  14654. }
  14655. async _readFromStorage(prefObj) {
  14656. throw new Error("Not implemented: _readFromStorage");
  14657. }
  14658. async reset() {
  14659. await this.#initializedPromise;
  14660. const prefs = this.#prefs;
  14661. this.#prefs = Object.create(null);
  14662. return this._writeToStorage(this.#defaults).catch(reason => {
  14663. this.#prefs = prefs;
  14664. throw reason;
  14665. });
  14666. }
  14667. async set(name, value) {
  14668. await this.#initializedPromise;
  14669. const defaultValue = this.#defaults[name],
  14670. prefs = this.#prefs;
  14671. if (defaultValue === undefined) {
  14672. throw new Error(`Set preference: "${name}" is undefined.`);
  14673. } else if (value === undefined) {
  14674. throw new Error("Set preference: no value is specified.");
  14675. }
  14676. const valueType = typeof value,
  14677. defaultType = typeof defaultValue;
  14678. if (valueType !== defaultType) {
  14679. if (valueType === "number" && defaultType === "string") {
  14680. value = value.toString();
  14681. } else {
  14682. throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
  14683. }
  14684. } else if (valueType === "number" && !Number.isInteger(value)) {
  14685. throw new Error(`Set preference: "${value}" must be an integer.`);
  14686. }
  14687. this.#prefs[name] = value;
  14688. return this._writeToStorage(this.#prefs).catch(reason => {
  14689. this.#prefs = prefs;
  14690. throw reason;
  14691. });
  14692. }
  14693. async get(name) {
  14694. await this.#initializedPromise;
  14695. const defaultValue = this.#defaults[name];
  14696. if (defaultValue === undefined) {
  14697. throw new Error(`Get preference: "${name}" is undefined.`);
  14698. }
  14699. return this.#prefs[name] ?? defaultValue;
  14700. }
  14701. async getAll() {
  14702. await this.#initializedPromise;
  14703. const obj = Object.create(null);
  14704. for (const name in this.#defaults) {
  14705. obj[name] = this.#prefs[name] ?? this.#defaults[name];
  14706. }
  14707. return obj;
  14708. }
  14709. }
  14710. exports.BasePreferences = BasePreferences;
  14711. /***/ }),
  14712. /* 160 */
  14713. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14714. Object.defineProperty(exports, "__esModule", ({
  14715. value: true
  14716. }));
  14717. exports.DownloadManager = void 0;
  14718. __webpack_require__(76);
  14719. __webpack_require__(92);
  14720. __webpack_require__(94);
  14721. __webpack_require__(95);
  14722. var _pdfjsLib = __webpack_require__(122);
  14723. ;
  14724. function download(blobUrl, filename) {
  14725. const a = document.createElement("a");
  14726. if (!a.click) {
  14727. throw new Error('DownloadManager: "a.click()" is not supported.');
  14728. }
  14729. a.href = blobUrl;
  14730. a.target = "_parent";
  14731. if ("download" in a) {
  14732. a.download = filename;
  14733. }
  14734. (document.body || document.documentElement).append(a);
  14735. a.click();
  14736. a.remove();
  14737. }
  14738. class DownloadManager {
  14739. #openBlobUrls = new WeakMap();
  14740. downloadUrl(url, filename, _options) {
  14741. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14742. console.error(`downloadUrl - not a valid URL: ${url}`);
  14743. return;
  14744. }
  14745. download(url + "#pdfjs.action=download", filename);
  14746. }
  14747. downloadData(data, filename, contentType) {
  14748. const blobUrl = URL.createObjectURL(new Blob([data], {
  14749. type: contentType
  14750. }));
  14751. download(blobUrl, filename);
  14752. }
  14753. openOrDownloadData(element, data, filename) {
  14754. const isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  14755. const contentType = isPdfData ? "application/pdf" : "";
  14756. if (isPdfData) {
  14757. let blobUrl = this.#openBlobUrls.get(element);
  14758. if (!blobUrl) {
  14759. blobUrl = URL.createObjectURL(new Blob([data], {
  14760. type: contentType
  14761. }));
  14762. this.#openBlobUrls.set(element, blobUrl);
  14763. }
  14764. let viewerUrl;
  14765. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  14766. try {
  14767. window.open(viewerUrl);
  14768. return true;
  14769. } catch (ex) {
  14770. console.error(`openOrDownloadData: ${ex}`);
  14771. URL.revokeObjectURL(blobUrl);
  14772. this.#openBlobUrls.delete(element);
  14773. }
  14774. }
  14775. this.downloadData(data, filename, contentType);
  14776. return false;
  14777. }
  14778. download(blob, url, filename, _options) {
  14779. const blobUrl = URL.createObjectURL(blob);
  14780. download(blobUrl, filename);
  14781. }
  14782. }
  14783. exports.DownloadManager = DownloadManager;
  14784. /***/ }),
  14785. /* 161 */
  14786. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14787. Object.defineProperty(exports, "__esModule", ({
  14788. value: true
  14789. }));
  14790. exports.GenericL10n = void 0;
  14791. __webpack_require__(162);
  14792. var _l10n_utils = __webpack_require__(147);
  14793. const PARTIAL_LANG_CODES = {
  14794. en: "en-US",
  14795. es: "es-ES",
  14796. fy: "fy-NL",
  14797. ga: "ga-IE",
  14798. gu: "gu-IN",
  14799. hi: "hi-IN",
  14800. hy: "hy-AM",
  14801. nb: "nb-NO",
  14802. ne: "ne-NP",
  14803. nn: "nn-NO",
  14804. pa: "pa-IN",
  14805. pt: "pt-PT",
  14806. sv: "sv-SE",
  14807. zh: "zh-CN"
  14808. };
  14809. function fixupLangCode(langCode) {
  14810. return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode;
  14811. }
  14812. class GenericL10n {
  14813. constructor(lang) {
  14814. const {
  14815. webL10n
  14816. } = document;
  14817. this._lang = lang;
  14818. this._ready = new Promise((resolve, reject) => {
  14819. webL10n.setLanguage(fixupLangCode(lang), () => {
  14820. resolve(webL10n);
  14821. });
  14822. });
  14823. }
  14824. async getLanguage() {
  14825. const l10n = await this._ready;
  14826. return l10n.getLanguage();
  14827. }
  14828. async getDirection() {
  14829. const l10n = await this._ready;
  14830. return l10n.getDirection();
  14831. }
  14832. async get(key) {
  14833. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  14834. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  14835. const l10n = await this._ready;
  14836. return l10n.get(key, args, fallback);
  14837. }
  14838. async translate(element) {
  14839. const l10n = await this._ready;
  14840. return l10n.translate(element);
  14841. }
  14842. }
  14843. exports.GenericL10n = GenericL10n;
  14844. /***/ }),
  14845. /* 162 */
  14846. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  14847. __webpack_require__(2);
  14848. document.webL10n = function (window, document) {
  14849. var gL10nData = {};
  14850. var gTextData = '';
  14851. var gTextProp = 'textContent';
  14852. var gLanguage = '';
  14853. var gMacros = {};
  14854. var gReadyState = 'loading';
  14855. var gAsyncResourceLoading = true;
  14856. function getL10nResourceLinks() {
  14857. return document.querySelectorAll('link[type="application/l10n"]');
  14858. }
  14859. function getL10nDictionary() {
  14860. var script = document.querySelector('script[type="application/l10n"]');
  14861. return script ? JSON.parse(script.innerHTML) : null;
  14862. }
  14863. function getTranslatableChildren(element) {
  14864. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14865. }
  14866. function getL10nAttributes(element) {
  14867. if (!element) return {};
  14868. var l10nId = element.getAttribute('data-l10n-id');
  14869. var l10nArgs = element.getAttribute('data-l10n-args');
  14870. var args = {};
  14871. if (l10nArgs) {
  14872. try {
  14873. args = JSON.parse(l10nArgs);
  14874. } catch (e) {
  14875. console.warn('could not parse arguments for #' + l10nId);
  14876. }
  14877. }
  14878. return {
  14879. id: l10nId,
  14880. args: args
  14881. };
  14882. }
  14883. function xhrLoadText(url, onSuccess, onFailure) {
  14884. onSuccess = onSuccess || function _onSuccess(data) {};
  14885. onFailure = onFailure || function _onFailure() {};
  14886. var xhr = new XMLHttpRequest();
  14887. xhr.open('GET', url, gAsyncResourceLoading);
  14888. if (xhr.overrideMimeType) {
  14889. xhr.overrideMimeType('text/plain; charset=utf-8');
  14890. }
  14891. xhr.onreadystatechange = function () {
  14892. if (xhr.readyState == 4) {
  14893. if (xhr.status == 200 || xhr.status === 0) {
  14894. onSuccess(xhr.responseText);
  14895. } else {
  14896. onFailure();
  14897. }
  14898. }
  14899. };
  14900. xhr.onerror = onFailure;
  14901. xhr.ontimeout = onFailure;
  14902. try {
  14903. xhr.send(null);
  14904. } catch (e) {
  14905. onFailure();
  14906. }
  14907. }
  14908. function parseResource(href, lang, successCallback, failureCallback) {
  14909. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14910. function evalString(text) {
  14911. if (text.lastIndexOf('\\') < 0) return text;
  14912. 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, "'");
  14913. }
  14914. function parseProperties(text, parsedPropertiesCallback) {
  14915. var dictionary = {};
  14916. var reBlank = /^\s*|\s*$/;
  14917. var reComment = /^\s*#|^\s*$/;
  14918. var reSection = /^\s*\[(.*)\]\s*$/;
  14919. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14920. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14921. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14922. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14923. var currentLang = '*';
  14924. var genericLang = lang.split('-', 1)[0];
  14925. var skipLang = false;
  14926. var match = '';
  14927. function nextEntry() {
  14928. while (true) {
  14929. if (!entries.length) {
  14930. parsedRawLinesCallback();
  14931. return;
  14932. }
  14933. var line = entries.shift();
  14934. if (reComment.test(line)) continue;
  14935. if (extendedSyntax) {
  14936. match = reSection.exec(line);
  14937. if (match) {
  14938. currentLang = match[1].toLowerCase();
  14939. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14940. continue;
  14941. } else if (skipLang) {
  14942. continue;
  14943. }
  14944. match = reImport.exec(line);
  14945. if (match) {
  14946. loadImport(baseURL + match[1], nextEntry);
  14947. return;
  14948. }
  14949. }
  14950. var tmp = line.match(reSplit);
  14951. if (tmp && tmp.length == 3) {
  14952. dictionary[tmp[1]] = evalString(tmp[2]);
  14953. }
  14954. }
  14955. }
  14956. nextEntry();
  14957. }
  14958. function loadImport(url, callback) {
  14959. xhrLoadText(url, function (content) {
  14960. parseRawLines(content, false, callback);
  14961. }, function () {
  14962. console.warn(url + ' not found.');
  14963. callback();
  14964. });
  14965. }
  14966. parseRawLines(text, true, function () {
  14967. parsedPropertiesCallback(dictionary);
  14968. });
  14969. }
  14970. xhrLoadText(href, function (response) {
  14971. gTextData += response;
  14972. parseProperties(response, function (data) {
  14973. for (var key in data) {
  14974. var id,
  14975. prop,
  14976. index = key.lastIndexOf('.');
  14977. if (index > 0) {
  14978. id = key.substring(0, index);
  14979. prop = key.substring(index + 1);
  14980. } else {
  14981. id = key;
  14982. prop = gTextProp;
  14983. }
  14984. if (!gL10nData[id]) {
  14985. gL10nData[id] = {};
  14986. }
  14987. gL10nData[id][prop] = data[key];
  14988. }
  14989. if (successCallback) {
  14990. successCallback();
  14991. }
  14992. });
  14993. }, failureCallback);
  14994. }
  14995. function loadLocale(lang, callback) {
  14996. if (lang) {
  14997. lang = lang.toLowerCase();
  14998. }
  14999. callback = callback || function _callback() {};
  15000. clear();
  15001. gLanguage = lang;
  15002. var langLinks = getL10nResourceLinks();
  15003. var langCount = langLinks.length;
  15004. if (langCount === 0) {
  15005. var dict = getL10nDictionary();
  15006. if (dict && dict.locales && dict.default_locale) {
  15007. console.log('using the embedded JSON directory, early way out');
  15008. gL10nData = dict.locales[lang];
  15009. if (!gL10nData) {
  15010. var defaultLocale = dict.default_locale.toLowerCase();
  15011. for (var anyCaseLang in dict.locales) {
  15012. anyCaseLang = anyCaseLang.toLowerCase();
  15013. if (anyCaseLang === lang) {
  15014. gL10nData = dict.locales[lang];
  15015. break;
  15016. } else if (anyCaseLang === defaultLocale) {
  15017. gL10nData = dict.locales[defaultLocale];
  15018. }
  15019. }
  15020. }
  15021. callback();
  15022. } else {
  15023. console.log('no resource to load, early way out');
  15024. }
  15025. gReadyState = 'complete';
  15026. return;
  15027. }
  15028. var onResourceLoaded = null;
  15029. var gResourceCount = 0;
  15030. onResourceLoaded = function () {
  15031. gResourceCount++;
  15032. if (gResourceCount >= langCount) {
  15033. callback();
  15034. gReadyState = 'complete';
  15035. }
  15036. };
  15037. function L10nResourceLink(link) {
  15038. var href = link.href;
  15039. this.load = function (lang, callback) {
  15040. parseResource(href, lang, callback, function () {
  15041. console.warn(href + ' not found.');
  15042. console.warn('"' + lang + '" resource not found');
  15043. gLanguage = '';
  15044. callback();
  15045. });
  15046. };
  15047. }
  15048. for (var i = 0; i < langCount; i++) {
  15049. var resource = new L10nResourceLink(langLinks[i]);
  15050. resource.load(lang, onResourceLoaded);
  15051. }
  15052. }
  15053. function clear() {
  15054. gL10nData = {};
  15055. gTextData = '';
  15056. gLanguage = '';
  15057. }
  15058. function getPluralRules(lang) {
  15059. var locales2rules = {
  15060. 'af': 3,
  15061. 'ak': 4,
  15062. 'am': 4,
  15063. 'ar': 1,
  15064. 'asa': 3,
  15065. 'az': 0,
  15066. 'be': 11,
  15067. 'bem': 3,
  15068. 'bez': 3,
  15069. 'bg': 3,
  15070. 'bh': 4,
  15071. 'bm': 0,
  15072. 'bn': 3,
  15073. 'bo': 0,
  15074. 'br': 20,
  15075. 'brx': 3,
  15076. 'bs': 11,
  15077. 'ca': 3,
  15078. 'cgg': 3,
  15079. 'chr': 3,
  15080. 'cs': 12,
  15081. 'cy': 17,
  15082. 'da': 3,
  15083. 'de': 3,
  15084. 'dv': 3,
  15085. 'dz': 0,
  15086. 'ee': 3,
  15087. 'el': 3,
  15088. 'en': 3,
  15089. 'eo': 3,
  15090. 'es': 3,
  15091. 'et': 3,
  15092. 'eu': 3,
  15093. 'fa': 0,
  15094. 'ff': 5,
  15095. 'fi': 3,
  15096. 'fil': 4,
  15097. 'fo': 3,
  15098. 'fr': 5,
  15099. 'fur': 3,
  15100. 'fy': 3,
  15101. 'ga': 8,
  15102. 'gd': 24,
  15103. 'gl': 3,
  15104. 'gsw': 3,
  15105. 'gu': 3,
  15106. 'guw': 4,
  15107. 'gv': 23,
  15108. 'ha': 3,
  15109. 'haw': 3,
  15110. 'he': 2,
  15111. 'hi': 4,
  15112. 'hr': 11,
  15113. 'hu': 0,
  15114. 'id': 0,
  15115. 'ig': 0,
  15116. 'ii': 0,
  15117. 'is': 3,
  15118. 'it': 3,
  15119. 'iu': 7,
  15120. 'ja': 0,
  15121. 'jmc': 3,
  15122. 'jv': 0,
  15123. 'ka': 0,
  15124. 'kab': 5,
  15125. 'kaj': 3,
  15126. 'kcg': 3,
  15127. 'kde': 0,
  15128. 'kea': 0,
  15129. 'kk': 3,
  15130. 'kl': 3,
  15131. 'km': 0,
  15132. 'kn': 0,
  15133. 'ko': 0,
  15134. 'ksb': 3,
  15135. 'ksh': 21,
  15136. 'ku': 3,
  15137. 'kw': 7,
  15138. 'lag': 18,
  15139. 'lb': 3,
  15140. 'lg': 3,
  15141. 'ln': 4,
  15142. 'lo': 0,
  15143. 'lt': 10,
  15144. 'lv': 6,
  15145. 'mas': 3,
  15146. 'mg': 4,
  15147. 'mk': 16,
  15148. 'ml': 3,
  15149. 'mn': 3,
  15150. 'mo': 9,
  15151. 'mr': 3,
  15152. 'ms': 0,
  15153. 'mt': 15,
  15154. 'my': 0,
  15155. 'nah': 3,
  15156. 'naq': 7,
  15157. 'nb': 3,
  15158. 'nd': 3,
  15159. 'ne': 3,
  15160. 'nl': 3,
  15161. 'nn': 3,
  15162. 'no': 3,
  15163. 'nr': 3,
  15164. 'nso': 4,
  15165. 'ny': 3,
  15166. 'nyn': 3,
  15167. 'om': 3,
  15168. 'or': 3,
  15169. 'pa': 3,
  15170. 'pap': 3,
  15171. 'pl': 13,
  15172. 'ps': 3,
  15173. 'pt': 3,
  15174. 'rm': 3,
  15175. 'ro': 9,
  15176. 'rof': 3,
  15177. 'ru': 11,
  15178. 'rwk': 3,
  15179. 'sah': 0,
  15180. 'saq': 3,
  15181. 'se': 7,
  15182. 'seh': 3,
  15183. 'ses': 0,
  15184. 'sg': 0,
  15185. 'sh': 11,
  15186. 'shi': 19,
  15187. 'sk': 12,
  15188. 'sl': 14,
  15189. 'sma': 7,
  15190. 'smi': 7,
  15191. 'smj': 7,
  15192. 'smn': 7,
  15193. 'sms': 7,
  15194. 'sn': 3,
  15195. 'so': 3,
  15196. 'sq': 3,
  15197. 'sr': 11,
  15198. 'ss': 3,
  15199. 'ssy': 3,
  15200. 'st': 3,
  15201. 'sv': 3,
  15202. 'sw': 3,
  15203. 'syr': 3,
  15204. 'ta': 3,
  15205. 'te': 3,
  15206. 'teo': 3,
  15207. 'th': 0,
  15208. 'ti': 4,
  15209. 'tig': 3,
  15210. 'tk': 3,
  15211. 'tl': 4,
  15212. 'tn': 3,
  15213. 'to': 0,
  15214. 'tr': 0,
  15215. 'ts': 3,
  15216. 'tzm': 22,
  15217. 'uk': 11,
  15218. 'ur': 3,
  15219. 've': 3,
  15220. 'vi': 0,
  15221. 'vun': 3,
  15222. 'wa': 4,
  15223. 'wae': 3,
  15224. 'wo': 0,
  15225. 'xh': 3,
  15226. 'xog': 3,
  15227. 'yo': 0,
  15228. 'zh': 0,
  15229. 'zu': 3
  15230. };
  15231. function isIn(n, list) {
  15232. return list.indexOf(n) !== -1;
  15233. }
  15234. function isBetween(n, start, end) {
  15235. return start <= n && n <= end;
  15236. }
  15237. var pluralRules = {
  15238. '0': function (n) {
  15239. return 'other';
  15240. },
  15241. '1': function (n) {
  15242. if (isBetween(n % 100, 3, 10)) return 'few';
  15243. if (n === 0) return 'zero';
  15244. if (isBetween(n % 100, 11, 99)) return 'many';
  15245. if (n == 2) return 'two';
  15246. if (n == 1) return 'one';
  15247. return 'other';
  15248. },
  15249. '2': function (n) {
  15250. if (n !== 0 && n % 10 === 0) return 'many';
  15251. if (n == 2) return 'two';
  15252. if (n == 1) return 'one';
  15253. return 'other';
  15254. },
  15255. '3': function (n) {
  15256. if (n == 1) return 'one';
  15257. return 'other';
  15258. },
  15259. '4': function (n) {
  15260. if (isBetween(n, 0, 1)) return 'one';
  15261. return 'other';
  15262. },
  15263. '5': function (n) {
  15264. if (isBetween(n, 0, 2) && n != 2) return 'one';
  15265. return 'other';
  15266. },
  15267. '6': function (n) {
  15268. if (n === 0) return 'zero';
  15269. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15270. return 'other';
  15271. },
  15272. '7': function (n) {
  15273. if (n == 2) return 'two';
  15274. if (n == 1) return 'one';
  15275. return 'other';
  15276. },
  15277. '8': function (n) {
  15278. if (isBetween(n, 3, 6)) return 'few';
  15279. if (isBetween(n, 7, 10)) return 'many';
  15280. if (n == 2) return 'two';
  15281. if (n == 1) return 'one';
  15282. return 'other';
  15283. },
  15284. '9': function (n) {
  15285. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  15286. if (n == 1) return 'one';
  15287. return 'other';
  15288. },
  15289. '10': function (n) {
  15290. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  15291. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  15292. return 'other';
  15293. },
  15294. '11': function (n) {
  15295. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15296. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  15297. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15298. return 'other';
  15299. },
  15300. '12': function (n) {
  15301. if (isBetween(n, 2, 4)) return 'few';
  15302. if (n == 1) return 'one';
  15303. return 'other';
  15304. },
  15305. '13': function (n) {
  15306. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15307. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  15308. if (n == 1) return 'one';
  15309. return 'other';
  15310. },
  15311. '14': function (n) {
  15312. if (isBetween(n % 100, 3, 4)) return 'few';
  15313. if (n % 100 == 2) return 'two';
  15314. if (n % 100 == 1) return 'one';
  15315. return 'other';
  15316. },
  15317. '15': function (n) {
  15318. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  15319. if (isBetween(n % 100, 11, 19)) return 'many';
  15320. if (n == 1) return 'one';
  15321. return 'other';
  15322. },
  15323. '16': function (n) {
  15324. if (n % 10 == 1 && n != 11) return 'one';
  15325. return 'other';
  15326. },
  15327. '17': function (n) {
  15328. if (n == 3) return 'few';
  15329. if (n === 0) return 'zero';
  15330. if (n == 6) return 'many';
  15331. if (n == 2) return 'two';
  15332. if (n == 1) return 'one';
  15333. return 'other';
  15334. },
  15335. '18': function (n) {
  15336. if (n === 0) return 'zero';
  15337. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  15338. return 'other';
  15339. },
  15340. '19': function (n) {
  15341. if (isBetween(n, 2, 10)) return 'few';
  15342. if (isBetween(n, 0, 1)) return 'one';
  15343. return 'other';
  15344. },
  15345. '20': function (n) {
  15346. 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';
  15347. if (n % 1000000 === 0 && n !== 0) return 'many';
  15348. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  15349. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  15350. return 'other';
  15351. },
  15352. '21': function (n) {
  15353. if (n === 0) return 'zero';
  15354. if (n == 1) return 'one';
  15355. return 'other';
  15356. },
  15357. '22': function (n) {
  15358. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  15359. return 'other';
  15360. },
  15361. '23': function (n) {
  15362. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  15363. return 'other';
  15364. },
  15365. '24': function (n) {
  15366. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  15367. if (isIn(n, [2, 12])) return 'two';
  15368. if (isIn(n, [1, 11])) return 'one';
  15369. return 'other';
  15370. }
  15371. };
  15372. var index = locales2rules[lang.replace(/-.*$/, '')];
  15373. if (!(index in pluralRules)) {
  15374. console.warn('plural form unknown for [' + lang + ']');
  15375. return function () {
  15376. return 'other';
  15377. };
  15378. }
  15379. return pluralRules[index];
  15380. }
  15381. gMacros.plural = function (str, param, key, prop) {
  15382. var n = parseFloat(param);
  15383. if (isNaN(n)) return str;
  15384. if (prop != gTextProp) return str;
  15385. if (!gMacros._pluralRules) {
  15386. gMacros._pluralRules = getPluralRules(gLanguage);
  15387. }
  15388. var index = '[' + gMacros._pluralRules(n) + ']';
  15389. if (n === 0 && key + '[zero]' in gL10nData) {
  15390. str = gL10nData[key + '[zero]'][prop];
  15391. } else if (n == 1 && key + '[one]' in gL10nData) {
  15392. str = gL10nData[key + '[one]'][prop];
  15393. } else if (n == 2 && key + '[two]' in gL10nData) {
  15394. str = gL10nData[key + '[two]'][prop];
  15395. } else if (key + index in gL10nData) {
  15396. str = gL10nData[key + index][prop];
  15397. } else if (key + '[other]' in gL10nData) {
  15398. str = gL10nData[key + '[other]'][prop];
  15399. }
  15400. return str;
  15401. };
  15402. function getL10nData(key, args, fallback) {
  15403. var data = gL10nData[key];
  15404. if (!data) {
  15405. console.warn('#' + key + ' is undefined.');
  15406. if (!fallback) {
  15407. return null;
  15408. }
  15409. data = fallback;
  15410. }
  15411. var rv = {};
  15412. for (var prop in data) {
  15413. var str = data[prop];
  15414. str = substIndexes(str, args, key, prop);
  15415. str = substArguments(str, args, key);
  15416. rv[prop] = str;
  15417. }
  15418. return rv;
  15419. }
  15420. function substIndexes(str, args, key, prop) {
  15421. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15422. var reMatch = reIndex.exec(str);
  15423. if (!reMatch || !reMatch.length) return str;
  15424. var macroName = reMatch[1];
  15425. var paramName = reMatch[2];
  15426. var param;
  15427. if (args && paramName in args) {
  15428. param = args[paramName];
  15429. } else if (paramName in gL10nData) {
  15430. param = gL10nData[paramName];
  15431. }
  15432. if (macroName in gMacros) {
  15433. var macro = gMacros[macroName];
  15434. str = macro(str, param, key, prop);
  15435. }
  15436. return str;
  15437. }
  15438. function substArguments(str, args, key) {
  15439. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15440. return str.replace(reArgs, function (matched_text, arg) {
  15441. if (args && arg in args) {
  15442. return args[arg];
  15443. }
  15444. if (arg in gL10nData) {
  15445. return gL10nData[arg];
  15446. }
  15447. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15448. return matched_text;
  15449. });
  15450. }
  15451. function translateElement(element) {
  15452. var l10n = getL10nAttributes(element);
  15453. if (!l10n.id) return;
  15454. var data = getL10nData(l10n.id, l10n.args);
  15455. if (!data) {
  15456. console.warn('#' + l10n.id + ' is undefined.');
  15457. return;
  15458. }
  15459. if (data[gTextProp]) {
  15460. if (getChildElementCount(element) === 0) {
  15461. element[gTextProp] = data[gTextProp];
  15462. } else {
  15463. var children = element.childNodes;
  15464. var found = false;
  15465. for (var i = 0, l = children.length; i < l; i++) {
  15466. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15467. if (found) {
  15468. children[i].nodeValue = '';
  15469. } else {
  15470. children[i].nodeValue = data[gTextProp];
  15471. found = true;
  15472. }
  15473. }
  15474. }
  15475. if (!found) {
  15476. var textNode = document.createTextNode(data[gTextProp]);
  15477. element.prepend(textNode);
  15478. }
  15479. }
  15480. delete data[gTextProp];
  15481. }
  15482. for (var k in data) {
  15483. element[k] = data[k];
  15484. }
  15485. }
  15486. function getChildElementCount(element) {
  15487. if (element.children) {
  15488. return element.children.length;
  15489. }
  15490. if (typeof element.childElementCount !== 'undefined') {
  15491. return element.childElementCount;
  15492. }
  15493. var count = 0;
  15494. for (var i = 0; i < element.childNodes.length; i++) {
  15495. count += element.nodeType === 1 ? 1 : 0;
  15496. }
  15497. return count;
  15498. }
  15499. function translateFragment(element) {
  15500. element = element || document.documentElement;
  15501. var children = getTranslatableChildren(element);
  15502. var elementCount = children.length;
  15503. for (var i = 0; i < elementCount; i++) {
  15504. translateElement(children[i]);
  15505. }
  15506. translateElement(element);
  15507. }
  15508. return {
  15509. get: function (key, args, fallbackString) {
  15510. var index = key.lastIndexOf('.');
  15511. var prop = gTextProp;
  15512. if (index > 0) {
  15513. prop = key.substring(index + 1);
  15514. key = key.substring(0, index);
  15515. }
  15516. var fallback;
  15517. if (fallbackString) {
  15518. fallback = {};
  15519. fallback[prop] = fallbackString;
  15520. }
  15521. var data = getL10nData(key, args, fallback);
  15522. if (data && prop in data) {
  15523. return data[prop];
  15524. }
  15525. return '{{' + key + '}}';
  15526. },
  15527. getData: function () {
  15528. return gL10nData;
  15529. },
  15530. getText: function () {
  15531. return gTextData;
  15532. },
  15533. getLanguage: function () {
  15534. return gLanguage;
  15535. },
  15536. setLanguage: function (lang, callback) {
  15537. loadLocale(lang, function () {
  15538. if (callback) callback();
  15539. });
  15540. },
  15541. getDirection: function () {
  15542. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15543. var shortCode = gLanguage.split('-', 1)[0];
  15544. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15545. },
  15546. translate: translateFragment,
  15547. getReadyState: function () {
  15548. return gReadyState;
  15549. },
  15550. ready: function (callback) {
  15551. if (!callback) {
  15552. return;
  15553. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15554. window.setTimeout(function () {
  15555. callback();
  15556. });
  15557. } else if (document.addEventListener) {
  15558. document.addEventListener('localized', function once() {
  15559. document.removeEventListener('localized', once);
  15560. callback();
  15561. });
  15562. }
  15563. }
  15564. };
  15565. }(window, document);
  15566. /***/ }),
  15567. /* 163 */
  15568. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15569. Object.defineProperty(exports, "__esModule", ({
  15570. value: true
  15571. }));
  15572. exports.GenericScripting = void 0;
  15573. exports.docProperties = docProperties;
  15574. var _pdfjsLib = __webpack_require__(122);
  15575. async function docProperties(pdfDocument) {
  15576. const url = "",
  15577. baseUrl = url.split("#")[0];
  15578. let {
  15579. info,
  15580. metadata,
  15581. contentDispositionFilename,
  15582. contentLength
  15583. } = await pdfDocument.getMetadata();
  15584. if (!contentLength) {
  15585. const {
  15586. length
  15587. } = await pdfDocument.getDownloadInfo();
  15588. contentLength = length;
  15589. }
  15590. return {
  15591. ...info,
  15592. baseURL: baseUrl,
  15593. filesize: contentLength,
  15594. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  15595. metadata: metadata?.getRaw(),
  15596. authors: metadata?.get("dc:creator"),
  15597. numPages: pdfDocument.numPages,
  15598. URL: url
  15599. };
  15600. }
  15601. class GenericScripting {
  15602. constructor(sandboxBundleSrc) {
  15603. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
  15604. return window.pdfjsSandbox.QuickJSSandbox();
  15605. });
  15606. }
  15607. async createSandbox(data) {
  15608. const sandbox = await this._ready;
  15609. sandbox.create(data);
  15610. }
  15611. async dispatchEventInSandbox(event) {
  15612. const sandbox = await this._ready;
  15613. setTimeout(() => sandbox.dispatchEvent(event), 0);
  15614. }
  15615. async destroySandbox() {
  15616. const sandbox = await this._ready;
  15617. sandbox.nukeSandbox();
  15618. }
  15619. }
  15620. exports.GenericScripting = GenericScripting;
  15621. /***/ }),
  15622. /* 164 */
  15623. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15624. Object.defineProperty(exports, "__esModule", ({
  15625. value: true
  15626. }));
  15627. exports.PDFPrintService = void 0;
  15628. __webpack_require__(92);
  15629. __webpack_require__(94);
  15630. __webpack_require__(95);
  15631. __webpack_require__(76);
  15632. var _pdfjsLib = __webpack_require__(122);
  15633. var _app = __webpack_require__(75);
  15634. var _print_utils = __webpack_require__(165);
  15635. let activeService = null;
  15636. let dialog = null;
  15637. let overlayManager = null;
  15638. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  15639. const scratchCanvas = activeService.scratchCanvas;
  15640. const PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  15641. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15642. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15643. const ctx = scratchCanvas.getContext("2d");
  15644. ctx.save();
  15645. ctx.fillStyle = "rgb(255, 255, 255)";
  15646. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15647. ctx.restore();
  15648. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function (_ref) {
  15649. let [pdfPage, printAnnotationStorage] = _ref;
  15650. const renderContext = {
  15651. canvasContext: ctx,
  15652. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15653. viewport: pdfPage.getViewport({
  15654. scale: 1,
  15655. rotation: size.rotation
  15656. }),
  15657. intent: "print",
  15658. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  15659. optionalContentConfigPromise,
  15660. printAnnotationStorage
  15661. };
  15662. return pdfPage.render(renderContext).promise;
  15663. });
  15664. }
  15665. class PDFPrintService {
  15666. constructor(pdfDocument, pagesOverview, printContainer, printResolution) {
  15667. let optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15668. let printAnnotationStoragePromise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  15669. let l10n = arguments.length > 6 ? arguments[6] : undefined;
  15670. this.pdfDocument = pdfDocument;
  15671. this.pagesOverview = pagesOverview;
  15672. this.printContainer = printContainer;
  15673. this._printResolution = printResolution || 150;
  15674. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15675. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  15676. this.l10n = l10n;
  15677. this.currentPage = -1;
  15678. this.scratchCanvas = document.createElement("canvas");
  15679. }
  15680. layout() {
  15681. this.throwIfInactive();
  15682. const body = document.querySelector("body");
  15683. body.setAttribute("data-pdfjsprinting", true);
  15684. const {
  15685. width,
  15686. height
  15687. } = this.pagesOverview[0];
  15688. const hasEqualPageSizes = this.pagesOverview.every(size => size.width === width && size.height === height);
  15689. if (!hasEqualPageSizes) {
  15690. console.warn("Not all pages have the same size. The printed result may be incorrect!");
  15691. }
  15692. this.pageStyleSheet = document.createElement("style");
  15693. this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
  15694. body.append(this.pageStyleSheet);
  15695. }
  15696. destroy() {
  15697. if (activeService !== this) {
  15698. return;
  15699. }
  15700. this.printContainer.textContent = "";
  15701. const body = document.querySelector("body");
  15702. body.removeAttribute("data-pdfjsprinting");
  15703. if (this.pageStyleSheet) {
  15704. this.pageStyleSheet.remove();
  15705. this.pageStyleSheet = null;
  15706. }
  15707. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15708. this.scratchCanvas = null;
  15709. activeService = null;
  15710. ensureOverlay().then(function () {
  15711. if (overlayManager.active === dialog) {
  15712. overlayManager.close(dialog);
  15713. }
  15714. });
  15715. }
  15716. renderPages() {
  15717. if (this.pdfDocument.isPureXfa) {
  15718. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  15719. return Promise.resolve();
  15720. }
  15721. const pageCount = this.pagesOverview.length;
  15722. const renderNextPage = (resolve, reject) => {
  15723. this.throwIfInactive();
  15724. if (++this.currentPage >= pageCount) {
  15725. renderProgress(pageCount, pageCount, this.l10n);
  15726. resolve();
  15727. return;
  15728. }
  15729. const index = this.currentPage;
  15730. renderProgress(index, pageCount, this.l10n);
  15731. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  15732. renderNextPage(resolve, reject);
  15733. }, reject);
  15734. };
  15735. return new Promise(renderNextPage);
  15736. }
  15737. useRenderedPage() {
  15738. this.throwIfInactive();
  15739. const img = document.createElement("img");
  15740. const scratchCanvas = this.scratchCanvas;
  15741. if ("toBlob" in scratchCanvas) {
  15742. scratchCanvas.toBlob(function (blob) {
  15743. img.src = URL.createObjectURL(blob);
  15744. });
  15745. } else {
  15746. img.src = scratchCanvas.toDataURL();
  15747. }
  15748. const wrapper = document.createElement("div");
  15749. wrapper.className = "printedPage";
  15750. wrapper.append(img);
  15751. this.printContainer.append(wrapper);
  15752. return new Promise(function (resolve, reject) {
  15753. img.onload = resolve;
  15754. img.onerror = reject;
  15755. });
  15756. }
  15757. performPrint() {
  15758. this.throwIfInactive();
  15759. return new Promise(resolve => {
  15760. setTimeout(() => {
  15761. if (!this.active) {
  15762. resolve();
  15763. return;
  15764. }
  15765. print.call(window);
  15766. setTimeout(resolve, 20);
  15767. }, 0);
  15768. });
  15769. }
  15770. get active() {
  15771. return this === activeService;
  15772. }
  15773. throwIfInactive() {
  15774. if (!this.active) {
  15775. throw new Error("This print request was cancelled or completed.");
  15776. }
  15777. }
  15778. }
  15779. exports.PDFPrintService = PDFPrintService;
  15780. const print = window.print;
  15781. window.print = function () {
  15782. if (activeService) {
  15783. console.warn("Ignored window.print() because of a pending print job.");
  15784. return;
  15785. }
  15786. ensureOverlay().then(function () {
  15787. if (activeService) {
  15788. overlayManager.open(dialog);
  15789. }
  15790. });
  15791. try {
  15792. dispatchEvent("beforeprint");
  15793. } finally {
  15794. if (!activeService) {
  15795. console.error("Expected print service to be initialized.");
  15796. ensureOverlay().then(function () {
  15797. if (overlayManager.active === dialog) {
  15798. overlayManager.close(dialog);
  15799. }
  15800. });
  15801. return;
  15802. }
  15803. const activeServiceOnEntry = activeService;
  15804. activeService.renderPages().then(function () {
  15805. return activeServiceOnEntry.performPrint();
  15806. }).catch(function () {}).then(function () {
  15807. if (activeServiceOnEntry.active) {
  15808. abort();
  15809. }
  15810. });
  15811. }
  15812. };
  15813. function dispatchEvent(eventType) {
  15814. const event = new CustomEvent(eventType, {
  15815. bubbles: false,
  15816. cancelable: false,
  15817. detail: "custom"
  15818. });
  15819. window.dispatchEvent(event);
  15820. }
  15821. function abort() {
  15822. if (activeService) {
  15823. activeService.destroy();
  15824. dispatchEvent("afterprint");
  15825. }
  15826. }
  15827. function renderProgress(index, total, l10n) {
  15828. dialog ||= document.getElementById("printServiceDialog");
  15829. const progress = Math.round(100 * index / total);
  15830. const progressBar = dialog.querySelector("progress");
  15831. const progressPerc = dialog.querySelector(".relative-progress");
  15832. progressBar.value = progress;
  15833. l10n.get("print_progress_percent", {
  15834. progress
  15835. }).then(msg => {
  15836. progressPerc.textContent = msg;
  15837. });
  15838. }
  15839. window.addEventListener("keydown", function (event) {
  15840. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15841. window.print();
  15842. event.preventDefault();
  15843. event.stopImmediatePropagation();
  15844. }
  15845. }, true);
  15846. if ("onbeforeprint" in window) {
  15847. const stopPropagationIfNeeded = function (event) {
  15848. if (event.detail !== "custom") {
  15849. event.stopImmediatePropagation();
  15850. }
  15851. };
  15852. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15853. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15854. }
  15855. let overlayPromise;
  15856. function ensureOverlay() {
  15857. if (!overlayPromise) {
  15858. overlayManager = _app.PDFViewerApplication.overlayManager;
  15859. if (!overlayManager) {
  15860. throw new Error("The overlay manager has not yet been initialized.");
  15861. }
  15862. dialog ||= document.getElementById("printServiceDialog");
  15863. overlayPromise = overlayManager.register(dialog, true);
  15864. document.getElementById("printCancel").onclick = abort;
  15865. dialog.addEventListener("close", abort);
  15866. }
  15867. return overlayPromise;
  15868. }
  15869. _app.PDFPrintServiceFactory.instance = {
  15870. supportsPrinting: true,
  15871. createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n) {
  15872. if (activeService) {
  15873. throw new Error("The print service is created and active.");
  15874. }
  15875. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n);
  15876. return activeService;
  15877. }
  15878. };
  15879. /***/ }),
  15880. /* 165 */
  15881. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15882. Object.defineProperty(exports, "__esModule", ({
  15883. value: true
  15884. }));
  15885. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  15886. var _pdfjsLib = __webpack_require__(122);
  15887. var _pdf_link_service = __webpack_require__(125);
  15888. var _xfa_layer_builder = __webpack_require__(155);
  15889. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  15890. const xfaHtml = pdfDocument.allXfaHtml;
  15891. const linkService = new _pdf_link_service.SimpleLinkService();
  15892. const scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  15893. for (const xfaPage of xfaHtml.children) {
  15894. const page = document.createElement("div");
  15895. page.className = "xfaPrintedPage";
  15896. printContainer.append(page);
  15897. const builder = new _xfa_layer_builder.XfaLayerBuilder({
  15898. pageDiv: page,
  15899. pdfPage: null,
  15900. annotationStorage: pdfDocument.annotationStorage,
  15901. linkService,
  15902. xfaHtml: xfaPage
  15903. });
  15904. const viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  15905. scale
  15906. });
  15907. builder.render(viewport, "print");
  15908. }
  15909. }
  15910. /***/ })
  15911. /******/ ]);
  15912. /************************************************************************/
  15913. /******/ // The module cache
  15914. /******/ var __webpack_module_cache__ = {};
  15915. /******/
  15916. /******/ // The require function
  15917. /******/ function __webpack_require__(moduleId) {
  15918. /******/ // Check if module is in cache
  15919. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  15920. /******/ if (cachedModule !== undefined) {
  15921. /******/ return cachedModule.exports;
  15922. /******/ }
  15923. /******/ // Create a new module (and put it into the cache)
  15924. /******/ var module = __webpack_module_cache__[moduleId] = {
  15925. /******/ // no module.id needed
  15926. /******/ // no module.loaded needed
  15927. /******/ exports: {}
  15928. /******/ };
  15929. /******/
  15930. /******/ // Execute the module function
  15931. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  15932. /******/
  15933. /******/ // Return the exports of the module
  15934. /******/ return module.exports;
  15935. /******/ }
  15936. /******/
  15937. /************************************************************************/
  15938. var __webpack_exports__ = {};
  15939. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  15940. (() => {
  15941. var exports = __webpack_exports__;
  15942. Object.defineProperty(exports, "__esModule", ({
  15943. value: true
  15944. }));
  15945. Object.defineProperty(exports, "PDFViewerApplication", ({
  15946. enumerable: true,
  15947. get: function () {
  15948. return _app.PDFViewerApplication;
  15949. }
  15950. }));
  15951. exports.PDFViewerApplicationConstants = void 0;
  15952. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  15953. enumerable: true,
  15954. get: function () {
  15955. return _app_options.AppOptions;
  15956. }
  15957. }));
  15958. __webpack_require__(1);
  15959. __webpack_require__(164);
  15960. var _ui_utils = __webpack_require__(97);
  15961. var _app_options = __webpack_require__(123);
  15962. var _pdf_link_service = __webpack_require__(125);
  15963. var _app = __webpack_require__(75);
  15964. const pdfjsVersion = '3.10.111';
  15965. const pdfjsBuild = 'e142baecb';
  15966. const AppConstants = {
  15967. LinkTarget: _pdf_link_service.LinkTarget,
  15968. RenderingStates: _ui_utils.RenderingStates,
  15969. ScrollMode: _ui_utils.ScrollMode,
  15970. SpreadMode: _ui_utils.SpreadMode
  15971. };
  15972. exports.PDFViewerApplicationConstants = AppConstants;
  15973. window.PDFViewerApplication = _app.PDFViewerApplication;
  15974. window.PDFViewerApplicationConstants = AppConstants;
  15975. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  15976. function getViewerConfiguration() {
  15977. return {
  15978. appContainer: document.body,
  15979. mainContainer: document.getElementById("viewerContainer"),
  15980. viewerContainer: document.getElementById("viewer"),
  15981. toolbar: {
  15982. container: document.getElementById("toolbarViewer"),
  15983. numPages: document.getElementById("numPages"),
  15984. pageNumber: document.getElementById("pageNumber"),
  15985. scaleSelect: document.getElementById("scaleSelect"),
  15986. customScaleOption: document.getElementById("customScaleOption"),
  15987. previous: document.getElementById("previous"),
  15988. next: document.getElementById("next"),
  15989. zoomIn: document.getElementById("zoomIn"),
  15990. zoomOut: document.getElementById("zoomOut"),
  15991. viewFind: document.getElementById("viewFind"),
  15992. openFile: document.getElementById("openFile"),
  15993. print: document.getElementById("print"),
  15994. editorFreeTextButton: document.getElementById("editorFreeText"),
  15995. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  15996. editorInkButton: document.getElementById("editorInk"),
  15997. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  15998. editorStampButton: document.getElementById("editorStamp"),
  15999. editorStampParamsToolbar: document.getElementById("editorStampParamsToolbar"),
  16000. download: document.getElementById("download")
  16001. },
  16002. secondaryToolbar: {
  16003. toolbar: document.getElementById("secondaryToolbar"),
  16004. toggleButton: document.getElementById("secondaryToolbarToggle"),
  16005. presentationModeButton: document.getElementById("presentationMode"),
  16006. openFileButton: document.getElementById("secondaryOpenFile"),
  16007. printButton: document.getElementById("secondaryPrint"),
  16008. downloadButton: document.getElementById("secondaryDownload"),
  16009. viewBookmarkButton: document.getElementById("viewBookmark"),
  16010. firstPageButton: document.getElementById("firstPage"),
  16011. lastPageButton: document.getElementById("lastPage"),
  16012. pageRotateCwButton: document.getElementById("pageRotateCw"),
  16013. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  16014. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  16015. cursorHandToolButton: document.getElementById("cursorHandTool"),
  16016. scrollPageButton: document.getElementById("scrollPage"),
  16017. scrollVerticalButton: document.getElementById("scrollVertical"),
  16018. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  16019. scrollWrappedButton: document.getElementById("scrollWrapped"),
  16020. spreadNoneButton: document.getElementById("spreadNone"),
  16021. spreadOddButton: document.getElementById("spreadOdd"),
  16022. spreadEvenButton: document.getElementById("spreadEven"),
  16023. documentPropertiesButton: document.getElementById("documentProperties")
  16024. },
  16025. sidebar: {
  16026. outerContainer: document.getElementById("outerContainer"),
  16027. sidebarContainer: document.getElementById("sidebarContainer"),
  16028. toggleButton: document.getElementById("sidebarToggle"),
  16029. resizer: document.getElementById("sidebarResizer"),
  16030. thumbnailButton: document.getElementById("viewThumbnail"),
  16031. outlineButton: document.getElementById("viewOutline"),
  16032. attachmentsButton: document.getElementById("viewAttachments"),
  16033. layersButton: document.getElementById("viewLayers"),
  16034. thumbnailView: document.getElementById("thumbnailView"),
  16035. outlineView: document.getElementById("outlineView"),
  16036. attachmentsView: document.getElementById("attachmentsView"),
  16037. layersView: document.getElementById("layersView"),
  16038. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  16039. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  16040. },
  16041. findBar: {
  16042. bar: document.getElementById("findbar"),
  16043. toggleButton: document.getElementById("viewFind"),
  16044. findField: document.getElementById("findInput"),
  16045. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  16046. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  16047. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  16048. entireWordCheckbox: document.getElementById("findEntireWord"),
  16049. findMsg: document.getElementById("findMsg"),
  16050. findResultsCount: document.getElementById("findResultsCount"),
  16051. findPreviousButton: document.getElementById("findPrevious"),
  16052. findNextButton: document.getElementById("findNext")
  16053. },
  16054. passwordOverlay: {
  16055. dialog: document.getElementById("passwordDialog"),
  16056. label: document.getElementById("passwordText"),
  16057. input: document.getElementById("password"),
  16058. submitButton: document.getElementById("passwordSubmit"),
  16059. cancelButton: document.getElementById("passwordCancel")
  16060. },
  16061. documentProperties: {
  16062. dialog: document.getElementById("documentPropertiesDialog"),
  16063. closeButton: document.getElementById("documentPropertiesClose"),
  16064. fields: {
  16065. fileName: document.getElementById("fileNameField"),
  16066. fileSize: document.getElementById("fileSizeField"),
  16067. title: document.getElementById("titleField"),
  16068. author: document.getElementById("authorField"),
  16069. subject: document.getElementById("subjectField"),
  16070. keywords: document.getElementById("keywordsField"),
  16071. creationDate: document.getElementById("creationDateField"),
  16072. modificationDate: document.getElementById("modificationDateField"),
  16073. creator: document.getElementById("creatorField"),
  16074. producer: document.getElementById("producerField"),
  16075. version: document.getElementById("versionField"),
  16076. pageCount: document.getElementById("pageCountField"),
  16077. pageSize: document.getElementById("pageSizeField"),
  16078. linearized: document.getElementById("linearizedField")
  16079. }
  16080. },
  16081. annotationEditorParams: {
  16082. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  16083. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  16084. editorInkColor: document.getElementById("editorInkColor"),
  16085. editorInkThickness: document.getElementById("editorInkThickness"),
  16086. editorInkOpacity: document.getElementById("editorInkOpacity"),
  16087. editorStampAddImage: document.getElementById("editorStampAddImage")
  16088. },
  16089. printContainer: document.getElementById("printContainer"),
  16090. openFileInput: document.getElementById("fileInput"),
  16091. debuggerScriptPath: "./debugger.js"
  16092. };
  16093. }
  16094. function webViewerLoad() {
  16095. const config = getViewerConfiguration();
  16096. const event = new CustomEvent("webviewerloaded", {
  16097. bubbles: true,
  16098. cancelable: true,
  16099. detail: {
  16100. source: window
  16101. }
  16102. });
  16103. try {
  16104. parent.document.dispatchEvent(event);
  16105. } catch (ex) {
  16106. console.error(`webviewerloaded: ${ex}`);
  16107. document.dispatchEvent(event);
  16108. }
  16109. _app.PDFViewerApplication.run(config);
  16110. }
  16111. document.blockUnblockOnload?.(true);
  16112. if (document.readyState === "interactive" || document.readyState === "complete") {
  16113. webViewerLoad();
  16114. } else {
  16115. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  16116. }
  16117. })();
  16118. /******/ })()
  16119. ;
  16120. //# sourceMappingURL=viewer.js.map