2
0

pdf_viewer.js 167 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 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. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
  31. })(this, function() {
  32. return /******/ (() => { // webpackBootstrap
  33. /******/ "use strict";
  34. /******/ var __webpack_modules__ = ([
  35. /* 0 */
  36. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  37. Object.defineProperty(exports, "__esModule", ({
  38. value: true
  39. }));
  40. Object.defineProperty(exports, "AnnotationLayerBuilder", ({
  41. enumerable: true,
  42. get: function () {
  43. return _annotation_layer_builder.AnnotationLayerBuilder;
  44. }
  45. }));
  46. Object.defineProperty(exports, "DefaultAnnotationLayerFactory", ({
  47. enumerable: true,
  48. get: function () {
  49. return _annotation_layer_builder.DefaultAnnotationLayerFactory;
  50. }
  51. }));
  52. Object.defineProperty(exports, "DefaultTextLayerFactory", ({
  53. enumerable: true,
  54. get: function () {
  55. return _text_layer_builder.DefaultTextLayerFactory;
  56. }
  57. }));
  58. Object.defineProperty(exports, "TextLayerBuilder", ({
  59. enumerable: true,
  60. get: function () {
  61. return _text_layer_builder.TextLayerBuilder;
  62. }
  63. }));
  64. Object.defineProperty(exports, "EventBus", ({
  65. enumerable: true,
  66. get: function () {
  67. return _ui_utils.EventBus;
  68. }
  69. }));
  70. Object.defineProperty(exports, "NullL10n", ({
  71. enumerable: true,
  72. get: function () {
  73. return _ui_utils.NullL10n;
  74. }
  75. }));
  76. Object.defineProperty(exports, "ProgressBar", ({
  77. enumerable: true,
  78. get: function () {
  79. return _ui_utils.ProgressBar;
  80. }
  81. }));
  82. Object.defineProperty(exports, "PDFLinkService", ({
  83. enumerable: true,
  84. get: function () {
  85. return _pdf_link_service.PDFLinkService;
  86. }
  87. }));
  88. Object.defineProperty(exports, "SimpleLinkService", ({
  89. enumerable: true,
  90. get: function () {
  91. return _pdf_link_service.SimpleLinkService;
  92. }
  93. }));
  94. Object.defineProperty(exports, "DownloadManager", ({
  95. enumerable: true,
  96. get: function () {
  97. return _download_manager.DownloadManager;
  98. }
  99. }));
  100. Object.defineProperty(exports, "GenericL10n", ({
  101. enumerable: true,
  102. get: function () {
  103. return _genericl10n.GenericL10n;
  104. }
  105. }));
  106. Object.defineProperty(exports, "PDFFindController", ({
  107. enumerable: true,
  108. get: function () {
  109. return _pdf_find_controller.PDFFindController;
  110. }
  111. }));
  112. Object.defineProperty(exports, "PDFHistory", ({
  113. enumerable: true,
  114. get: function () {
  115. return _pdf_history.PDFHistory;
  116. }
  117. }));
  118. Object.defineProperty(exports, "PDFPageView", ({
  119. enumerable: true,
  120. get: function () {
  121. return _pdf_page_view.PDFPageView;
  122. }
  123. }));
  124. Object.defineProperty(exports, "PDFSinglePageViewer", ({
  125. enumerable: true,
  126. get: function () {
  127. return _pdf_single_page_viewer.PDFSinglePageViewer;
  128. }
  129. }));
  130. Object.defineProperty(exports, "PDFViewer", ({
  131. enumerable: true,
  132. get: function () {
  133. return _pdf_viewer.PDFViewer;
  134. }
  135. }));
  136. var _annotation_layer_builder = __w_pdfjs_require__(1);
  137. var _text_layer_builder = __w_pdfjs_require__(5);
  138. var _ui_utils = __w_pdfjs_require__(3);
  139. var _pdf_link_service = __w_pdfjs_require__(4);
  140. var _download_manager = __w_pdfjs_require__(6);
  141. var _genericl10n = __w_pdfjs_require__(8);
  142. var _pdf_find_controller = __w_pdfjs_require__(10);
  143. var _pdf_history = __w_pdfjs_require__(12);
  144. var _pdf_page_view = __w_pdfjs_require__(13);
  145. var _pdf_single_page_viewer = __w_pdfjs_require__(15);
  146. var _pdf_viewer = __w_pdfjs_require__(17);
  147. const pdfjsVersion = '2.7.570';
  148. const pdfjsBuild = 'f2c7338b0';
  149. /***/ }),
  150. /* 1 */
  151. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  152. Object.defineProperty(exports, "__esModule", ({
  153. value: true
  154. }));
  155. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  156. var _pdfjsLib = __w_pdfjs_require__(2);
  157. var _ui_utils = __w_pdfjs_require__(3);
  158. var _pdf_link_service = __w_pdfjs_require__(4);
  159. class AnnotationLayerBuilder {
  160. constructor({
  161. pageDiv,
  162. pdfPage,
  163. linkService,
  164. downloadManager,
  165. annotationStorage = null,
  166. imageResourcesPath = "",
  167. renderInteractiveForms = true,
  168. l10n = _ui_utils.NullL10n,
  169. enableScripting = false,
  170. hasJSActionsPromise = null,
  171. mouseState = null
  172. }) {
  173. this.pageDiv = pageDiv;
  174. this.pdfPage = pdfPage;
  175. this.linkService = linkService;
  176. this.downloadManager = downloadManager;
  177. this.imageResourcesPath = imageResourcesPath;
  178. this.renderInteractiveForms = renderInteractiveForms;
  179. this.l10n = l10n;
  180. this.annotationStorage = annotationStorage;
  181. this.enableScripting = enableScripting;
  182. this._hasJSActionsPromise = hasJSActionsPromise;
  183. this._mouseState = mouseState;
  184. this.div = null;
  185. this._cancelled = false;
  186. }
  187. render(viewport, intent = "display") {
  188. return Promise.all([this.pdfPage.getAnnotations({
  189. intent
  190. }), this._hasJSActionsPromise]).then(([annotations, hasJSActions = false]) => {
  191. if (this._cancelled) {
  192. return;
  193. }
  194. if (annotations.length === 0) {
  195. return;
  196. }
  197. const parameters = {
  198. viewport: viewport.clone({
  199. dontFlip: true
  200. }),
  201. div: this.div,
  202. annotations,
  203. page: this.pdfPage,
  204. imageResourcesPath: this.imageResourcesPath,
  205. renderInteractiveForms: this.renderInteractiveForms,
  206. linkService: this.linkService,
  207. downloadManager: this.downloadManager,
  208. annotationStorage: this.annotationStorage,
  209. enableScripting: this.enableScripting,
  210. hasJSActions,
  211. mouseState: this._mouseState
  212. };
  213. if (this.div) {
  214. _pdfjsLib.AnnotationLayer.update(parameters);
  215. } else {
  216. this.div = document.createElement("div");
  217. this.div.className = "annotationLayer";
  218. this.pageDiv.appendChild(this.div);
  219. parameters.div = this.div;
  220. _pdfjsLib.AnnotationLayer.render(parameters);
  221. this.l10n.translate(this.div);
  222. }
  223. });
  224. }
  225. cancel() {
  226. this._cancelled = true;
  227. }
  228. hide() {
  229. if (!this.div) {
  230. return;
  231. }
  232. this.div.setAttribute("hidden", "true");
  233. }
  234. }
  235. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  236. class DefaultAnnotationLayerFactory {
  237. createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = true, l10n = _ui_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
  238. return new AnnotationLayerBuilder({
  239. pageDiv,
  240. pdfPage,
  241. imageResourcesPath,
  242. renderInteractiveForms,
  243. linkService: new _pdf_link_service.SimpleLinkService(),
  244. l10n,
  245. annotationStorage,
  246. enableScripting,
  247. hasJSActionsPromise,
  248. mouseState
  249. });
  250. }
  251. }
  252. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  253. /***/ }),
  254. /* 2 */
  255. /***/ ((module) => {
  256. let pdfjsLib;
  257. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  258. pdfjsLib = window["pdfjs-dist/build/pdf"];
  259. } else {
  260. pdfjsLib = require("../build/pdf.js");
  261. }
  262. module.exports = pdfjsLib;
  263. /***/ }),
  264. /* 3 */
  265. /***/ ((__unused_webpack_module, exports) => {
  266. Object.defineProperty(exports, "__esModule", ({
  267. value: true
  268. }));
  269. exports.approximateFraction = approximateFraction;
  270. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  271. exports.binarySearchFirstItem = binarySearchFirstItem;
  272. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  273. exports.getOutputScale = getOutputScale;
  274. exports.getPageSizeInches = getPageSizeInches;
  275. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  276. exports.getVisibleElements = getVisibleElements;
  277. exports.isPortraitOrientation = isPortraitOrientation;
  278. exports.isValidRotation = isValidRotation;
  279. exports.isValidScrollMode = isValidScrollMode;
  280. exports.isValidSpreadMode = isValidSpreadMode;
  281. exports.moveToEndOfArray = moveToEndOfArray;
  282. exports.noContextMenuHandler = noContextMenuHandler;
  283. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  284. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  285. exports.parseQueryString = parseQueryString;
  286. exports.roundToDivide = roundToDivide;
  287. exports.scrollIntoView = scrollIntoView;
  288. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  289. exports.watchScroll = watchScroll;
  290. exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
  291. const CSS_UNITS = 96.0 / 72.0;
  292. exports.CSS_UNITS = CSS_UNITS;
  293. const DEFAULT_SCALE_VALUE = "auto";
  294. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  295. const DEFAULT_SCALE = 1.0;
  296. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  297. const MIN_SCALE = 0.1;
  298. exports.MIN_SCALE = MIN_SCALE;
  299. const MAX_SCALE = 10.0;
  300. exports.MAX_SCALE = MAX_SCALE;
  301. const UNKNOWN_SCALE = 0;
  302. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  303. const MAX_AUTO_SCALE = 1.25;
  304. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  305. const SCROLLBAR_PADDING = 40;
  306. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  307. const VERTICAL_PADDING = 5;
  308. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  309. const LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  310. const PresentationModeState = {
  311. UNKNOWN: 0,
  312. NORMAL: 1,
  313. CHANGING: 2,
  314. FULLSCREEN: 3
  315. };
  316. exports.PresentationModeState = PresentationModeState;
  317. const SidebarView = {
  318. UNKNOWN: -1,
  319. NONE: 0,
  320. THUMBS: 1,
  321. OUTLINE: 2,
  322. ATTACHMENTS: 3,
  323. LAYERS: 4
  324. };
  325. exports.SidebarView = SidebarView;
  326. const RendererType = {
  327. CANVAS: "canvas",
  328. SVG: "svg"
  329. };
  330. exports.RendererType = RendererType;
  331. const TextLayerMode = {
  332. DISABLE: 0,
  333. ENABLE: 1,
  334. ENABLE_ENHANCE: 2
  335. };
  336. exports.TextLayerMode = TextLayerMode;
  337. const ScrollMode = {
  338. UNKNOWN: -1,
  339. VERTICAL: 0,
  340. HORIZONTAL: 1,
  341. WRAPPED: 2
  342. };
  343. exports.ScrollMode = ScrollMode;
  344. const SpreadMode = {
  345. UNKNOWN: -1,
  346. NONE: 0,
  347. ODD: 1,
  348. EVEN: 2
  349. };
  350. exports.SpreadMode = SpreadMode;
  351. const AutoPrintRegExp = /\bprint\s*\(/;
  352. exports.AutoPrintRegExp = AutoPrintRegExp;
  353. function formatL10nValue(text, args) {
  354. if (!args) {
  355. return text;
  356. }
  357. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  358. return name in args ? args[name] : "{{" + name + "}}";
  359. });
  360. }
  361. const NullL10n = {
  362. async getLanguage() {
  363. return "en-us";
  364. },
  365. async getDirection() {
  366. return "ltr";
  367. },
  368. async get(property, args, fallback) {
  369. return formatL10nValue(fallback, args);
  370. },
  371. async translate(element) {}
  372. };
  373. exports.NullL10n = NullL10n;
  374. function getOutputScale(ctx) {
  375. const devicePixelRatio = window.devicePixelRatio || 1;
  376. const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  377. const pixelRatio = devicePixelRatio / backingStoreRatio;
  378. return {
  379. sx: pixelRatio,
  380. sy: pixelRatio,
  381. scaled: pixelRatio !== 1
  382. };
  383. }
  384. function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
  385. let parent = element.offsetParent;
  386. if (!parent) {
  387. console.error("offsetParent is not set -- cannot scroll");
  388. return;
  389. }
  390. let offsetY = element.offsetTop + element.clientTop;
  391. let offsetX = element.offsetLeft + element.clientLeft;
  392. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  393. if (parent.dataset._scaleY) {
  394. offsetY /= parent.dataset._scaleY;
  395. offsetX /= parent.dataset._scaleX;
  396. }
  397. offsetY += parent.offsetTop;
  398. offsetX += parent.offsetLeft;
  399. parent = parent.offsetParent;
  400. if (!parent) {
  401. return;
  402. }
  403. }
  404. if (spot) {
  405. if (spot.top !== undefined) {
  406. offsetY += spot.top;
  407. }
  408. if (spot.left !== undefined) {
  409. offsetX += spot.left;
  410. parent.scrollLeft = offsetX;
  411. }
  412. }
  413. parent.scrollTop = offsetY;
  414. }
  415. function watchScroll(viewAreaElement, callback) {
  416. const debounceScroll = function (evt) {
  417. if (rAF) {
  418. return;
  419. }
  420. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  421. rAF = null;
  422. const currentX = viewAreaElement.scrollLeft;
  423. const lastX = state.lastX;
  424. if (currentX !== lastX) {
  425. state.right = currentX > lastX;
  426. }
  427. state.lastX = currentX;
  428. const currentY = viewAreaElement.scrollTop;
  429. const lastY = state.lastY;
  430. if (currentY !== lastY) {
  431. state.down = currentY > lastY;
  432. }
  433. state.lastY = currentY;
  434. callback(state);
  435. });
  436. };
  437. const state = {
  438. right: true,
  439. down: true,
  440. lastX: viewAreaElement.scrollLeft,
  441. lastY: viewAreaElement.scrollTop,
  442. _eventHandler: debounceScroll
  443. };
  444. let rAF = null;
  445. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  446. return state;
  447. }
  448. function parseQueryString(query) {
  449. const parts = query.split("&");
  450. const params = Object.create(null);
  451. for (let i = 0, ii = parts.length; i < ii; ++i) {
  452. const param = parts[i].split("=");
  453. const key = param[0].toLowerCase();
  454. const value = param.length > 1 ? param[1] : null;
  455. params[decodeURIComponent(key)] = decodeURIComponent(value);
  456. }
  457. return params;
  458. }
  459. function binarySearchFirstItem(items, condition) {
  460. let minIndex = 0;
  461. let maxIndex = items.length - 1;
  462. if (maxIndex < 0 || !condition(items[maxIndex])) {
  463. return items.length;
  464. }
  465. if (condition(items[minIndex])) {
  466. return minIndex;
  467. }
  468. while (minIndex < maxIndex) {
  469. const currentIndex = minIndex + maxIndex >> 1;
  470. const currentItem = items[currentIndex];
  471. if (condition(currentItem)) {
  472. maxIndex = currentIndex;
  473. } else {
  474. minIndex = currentIndex + 1;
  475. }
  476. }
  477. return minIndex;
  478. }
  479. function approximateFraction(x) {
  480. if (Math.floor(x) === x) {
  481. return [x, 1];
  482. }
  483. const xinv = 1 / x;
  484. const limit = 8;
  485. if (xinv > limit) {
  486. return [1, limit];
  487. } else if (Math.floor(xinv) === xinv) {
  488. return [1, xinv];
  489. }
  490. const x_ = x > 1 ? xinv : x;
  491. let a = 0,
  492. b = 1,
  493. c = 1,
  494. d = 1;
  495. while (true) {
  496. const p = a + c,
  497. q = b + d;
  498. if (q > limit) {
  499. break;
  500. }
  501. if (x_ <= p / q) {
  502. c = p;
  503. d = q;
  504. } else {
  505. a = p;
  506. b = q;
  507. }
  508. }
  509. let result;
  510. if (x_ - a / b < c / d - x_) {
  511. result = x_ === x ? [a, b] : [b, a];
  512. } else {
  513. result = x_ === x ? [c, d] : [d, c];
  514. }
  515. return result;
  516. }
  517. function roundToDivide(x, div) {
  518. const r = x % div;
  519. return r === 0 ? x : Math.round(x - r + div);
  520. }
  521. function getPageSizeInches({
  522. view,
  523. userUnit,
  524. rotate
  525. }) {
  526. const [x1, y1, x2, y2] = view;
  527. const changeOrientation = rotate % 180 !== 0;
  528. const width = (x2 - x1) / 72 * userUnit;
  529. const height = (y2 - y1) / 72 * userUnit;
  530. return {
  531. width: changeOrientation ? height : width,
  532. height: changeOrientation ? width : height
  533. };
  534. }
  535. function backtrackBeforeAllVisibleElements(index, views, top) {
  536. if (index < 2) {
  537. return index;
  538. }
  539. let elt = views[index].div;
  540. let pageTop = elt.offsetTop + elt.clientTop;
  541. if (pageTop >= top) {
  542. elt = views[index - 1].div;
  543. pageTop = elt.offsetTop + elt.clientTop;
  544. }
  545. for (let i = index - 2; i >= 0; --i) {
  546. elt = views[i].div;
  547. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  548. break;
  549. }
  550. index = i;
  551. }
  552. return index;
  553. }
  554. function getVisibleElements({
  555. scrollEl,
  556. views,
  557. sortByVisibility = false,
  558. horizontal = false,
  559. rtl = false
  560. }) {
  561. const top = scrollEl.scrollTop,
  562. bottom = top + scrollEl.clientHeight;
  563. const left = scrollEl.scrollLeft,
  564. right = left + scrollEl.clientWidth;
  565. function isElementBottomAfterViewTop(view) {
  566. const element = view.div;
  567. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  568. return elementBottom > top;
  569. }
  570. function isElementNextAfterViewHorizontally(view) {
  571. const element = view.div;
  572. const elementLeft = element.offsetLeft + element.clientLeft;
  573. const elementRight = elementLeft + element.clientWidth;
  574. return rtl ? elementLeft < right : elementRight > left;
  575. }
  576. const visible = [],
  577. numViews = views.length;
  578. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  579. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  580. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  581. }
  582. let lastEdge = horizontal ? right : -1;
  583. for (let i = firstVisibleElementInd; i < numViews; i++) {
  584. const view = views[i],
  585. element = view.div;
  586. const currentWidth = element.offsetLeft + element.clientLeft;
  587. const currentHeight = element.offsetTop + element.clientTop;
  588. const viewWidth = element.clientWidth,
  589. viewHeight = element.clientHeight;
  590. const viewRight = currentWidth + viewWidth;
  591. const viewBottom = currentHeight + viewHeight;
  592. if (lastEdge === -1) {
  593. if (viewBottom >= bottom) {
  594. lastEdge = viewBottom;
  595. }
  596. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  597. break;
  598. }
  599. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  600. continue;
  601. }
  602. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  603. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  604. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  605. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  606. const percent = fractionHeight * fractionWidth * 100 | 0;
  607. visible.push({
  608. id: view.id,
  609. x: currentWidth,
  610. y: currentHeight,
  611. view,
  612. percent,
  613. widthPercent: fractionWidth * 100 | 0
  614. });
  615. }
  616. const first = visible[0],
  617. last = visible[visible.length - 1];
  618. if (sortByVisibility) {
  619. visible.sort(function (a, b) {
  620. const pc = a.percent - b.percent;
  621. if (Math.abs(pc) > 0.001) {
  622. return -pc;
  623. }
  624. return a.id - b.id;
  625. });
  626. }
  627. return {
  628. first,
  629. last,
  630. views: visible
  631. };
  632. }
  633. function noContextMenuHandler(evt) {
  634. evt.preventDefault();
  635. }
  636. function isDataSchema(url) {
  637. let i = 0;
  638. const ii = url.length;
  639. while (i < ii && url[i].trim() === "") {
  640. i++;
  641. }
  642. return url.substring(i, i + 5).toLowerCase() === "data:";
  643. }
  644. function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
  645. if (typeof url !== "string") {
  646. return defaultFilename;
  647. }
  648. if (isDataSchema(url)) {
  649. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  650. return defaultFilename;
  651. }
  652. const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  653. const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  654. const splitURI = reURI.exec(url);
  655. let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  656. if (suggestedFilename) {
  657. suggestedFilename = suggestedFilename[0];
  658. if (suggestedFilename.includes("%")) {
  659. try {
  660. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  661. } catch (ex) {}
  662. }
  663. }
  664. return suggestedFilename || defaultFilename;
  665. }
  666. function normalizeWheelEventDirection(evt) {
  667. let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  668. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  669. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  670. delta = -delta;
  671. }
  672. return delta;
  673. }
  674. function normalizeWheelEventDelta(evt) {
  675. let delta = normalizeWheelEventDirection(evt);
  676. const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  677. const MOUSE_DOM_DELTA_LINE_MODE = 1;
  678. const MOUSE_PIXELS_PER_LINE = 30;
  679. const MOUSE_LINES_PER_PAGE = 30;
  680. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  681. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  682. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  683. delta /= MOUSE_LINES_PER_PAGE;
  684. }
  685. return delta;
  686. }
  687. function isValidRotation(angle) {
  688. return Number.isInteger(angle) && angle % 90 === 0;
  689. }
  690. function isValidScrollMode(mode) {
  691. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  692. }
  693. function isValidSpreadMode(mode) {
  694. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  695. }
  696. function isPortraitOrientation(size) {
  697. return size.width <= size.height;
  698. }
  699. const WaitOnType = {
  700. EVENT: "event",
  701. TIMEOUT: "timeout"
  702. };
  703. exports.WaitOnType = WaitOnType;
  704. function waitOnEventOrTimeout({
  705. target,
  706. name,
  707. delay = 0
  708. }) {
  709. return new Promise(function (resolve, reject) {
  710. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  711. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  712. }
  713. function handler(type) {
  714. if (target instanceof EventBus) {
  715. target._off(name, eventHandler);
  716. } else {
  717. target.removeEventListener(name, eventHandler);
  718. }
  719. if (timeout) {
  720. clearTimeout(timeout);
  721. }
  722. resolve(type);
  723. }
  724. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  725. if (target instanceof EventBus) {
  726. target._on(name, eventHandler);
  727. } else {
  728. target.addEventListener(name, eventHandler);
  729. }
  730. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  731. const timeout = setTimeout(timeoutHandler, delay);
  732. });
  733. }
  734. const animationStarted = new Promise(function (resolve) {
  735. window.requestAnimationFrame(resolve);
  736. });
  737. exports.animationStarted = animationStarted;
  738. function dispatchDOMEvent(eventName, args = null) {
  739. throw new Error("Not implemented: dispatchDOMEvent");
  740. }
  741. class EventBus {
  742. constructor(options) {
  743. this._listeners = Object.create(null);
  744. }
  745. on(eventName, listener, options = null) {
  746. this._on(eventName, listener, {
  747. external: true,
  748. once: options?.once
  749. });
  750. }
  751. off(eventName, listener, options = null) {
  752. this._off(eventName, listener, {
  753. external: true,
  754. once: options?.once
  755. });
  756. }
  757. dispatch(eventName) {
  758. const eventListeners = this._listeners[eventName];
  759. if (!eventListeners || eventListeners.length === 0) {
  760. return;
  761. }
  762. const args = Array.prototype.slice.call(arguments, 1);
  763. let externalListeners;
  764. eventListeners.slice(0).forEach(({
  765. listener,
  766. external,
  767. once
  768. }) => {
  769. if (once) {
  770. this._off(eventName, listener);
  771. }
  772. if (external) {
  773. (externalListeners || (externalListeners = [])).push(listener);
  774. return;
  775. }
  776. listener.apply(null, args);
  777. });
  778. if (externalListeners) {
  779. externalListeners.forEach(listener => {
  780. listener.apply(null, args);
  781. });
  782. externalListeners = null;
  783. }
  784. }
  785. _on(eventName, listener, options = null) {
  786. var _this$_listeners;
  787. const eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  788. eventListeners.push({
  789. listener,
  790. external: options?.external === true,
  791. once: options?.once === true
  792. });
  793. }
  794. _off(eventName, listener, options = null) {
  795. const eventListeners = this._listeners[eventName];
  796. if (!eventListeners) {
  797. return;
  798. }
  799. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  800. if (eventListeners[i].listener === listener) {
  801. eventListeners.splice(i, 1);
  802. return;
  803. }
  804. }
  805. }
  806. }
  807. exports.EventBus = EventBus;
  808. function clamp(v, min, max) {
  809. return Math.min(Math.max(v, min), max);
  810. }
  811. class ProgressBar {
  812. constructor(id, {
  813. height,
  814. width,
  815. units
  816. } = {}) {
  817. this.visible = true;
  818. this.div = document.querySelector(id + " .progress");
  819. this.bar = this.div.parentNode;
  820. this.height = height || 100;
  821. this.width = width || 100;
  822. this.units = units || "%";
  823. this.div.style.height = this.height + this.units;
  824. this.percent = 0;
  825. }
  826. _updateBar() {
  827. if (this._indeterminate) {
  828. this.div.classList.add("indeterminate");
  829. this.div.style.width = this.width + this.units;
  830. return;
  831. }
  832. this.div.classList.remove("indeterminate");
  833. const progressSize = this.width * this._percent / 100;
  834. this.div.style.width = progressSize + this.units;
  835. }
  836. get percent() {
  837. return this._percent;
  838. }
  839. set percent(val) {
  840. this._indeterminate = isNaN(val);
  841. this._percent = clamp(val, 0, 100);
  842. this._updateBar();
  843. }
  844. setWidth(viewer) {
  845. if (!viewer) {
  846. return;
  847. }
  848. const container = viewer.parentNode;
  849. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  850. if (scrollbarWidth > 0) {
  851. const doc = document.documentElement;
  852. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, `${scrollbarWidth}px`);
  853. }
  854. }
  855. hide() {
  856. if (!this.visible) {
  857. return;
  858. }
  859. this.visible = false;
  860. this.bar.classList.add("hidden");
  861. }
  862. show() {
  863. if (this.visible) {
  864. return;
  865. }
  866. this.visible = true;
  867. this.bar.classList.remove("hidden");
  868. }
  869. }
  870. exports.ProgressBar = ProgressBar;
  871. function moveToEndOfArray(arr, condition) {
  872. const moved = [],
  873. len = arr.length;
  874. let write = 0;
  875. for (let read = 0; read < len; ++read) {
  876. if (condition(arr[read])) {
  877. moved.push(arr[read]);
  878. } else {
  879. arr[write] = arr[read];
  880. ++write;
  881. }
  882. }
  883. for (let read = 0; write < len; ++read, ++write) {
  884. arr[write] = moved[read];
  885. }
  886. }
  887. function getActiveOrFocusedElement() {
  888. let curRoot = document;
  889. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  890. while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
  891. curRoot = curActiveOrFocused.shadowRoot;
  892. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  893. }
  894. return curActiveOrFocused;
  895. }
  896. /***/ }),
  897. /* 4 */
  898. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  899. Object.defineProperty(exports, "__esModule", ({
  900. value: true
  901. }));
  902. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  903. var _ui_utils = __w_pdfjs_require__(3);
  904. class PDFLinkService {
  905. constructor({
  906. eventBus,
  907. externalLinkTarget = null,
  908. externalLinkRel = null,
  909. externalLinkEnabled = true,
  910. ignoreDestinationZoom = false
  911. } = {}) {
  912. this.eventBus = eventBus;
  913. this.externalLinkTarget = externalLinkTarget;
  914. this.externalLinkRel = externalLinkRel;
  915. this.externalLinkEnabled = externalLinkEnabled;
  916. this._ignoreDestinationZoom = ignoreDestinationZoom;
  917. this.baseUrl = null;
  918. this.pdfDocument = null;
  919. this.pdfViewer = null;
  920. this.pdfHistory = null;
  921. this._pagesRefCache = null;
  922. }
  923. setDocument(pdfDocument, baseUrl = null) {
  924. this.baseUrl = baseUrl;
  925. this.pdfDocument = pdfDocument;
  926. this._pagesRefCache = Object.create(null);
  927. }
  928. setViewer(pdfViewer) {
  929. this.pdfViewer = pdfViewer;
  930. }
  931. setHistory(pdfHistory) {
  932. this.pdfHistory = pdfHistory;
  933. }
  934. get pagesCount() {
  935. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  936. }
  937. get page() {
  938. return this.pdfViewer.currentPageNumber;
  939. }
  940. set page(value) {
  941. this.pdfViewer.currentPageNumber = value;
  942. }
  943. get rotation() {
  944. return this.pdfViewer.pagesRotation;
  945. }
  946. set rotation(value) {
  947. this.pdfViewer.pagesRotation = value;
  948. }
  949. navigateTo(dest) {
  950. console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
  951. this.goToDestination(dest);
  952. }
  953. _goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
  954. const destRef = explicitDest[0];
  955. let pageNumber;
  956. if (destRef instanceof Object) {
  957. pageNumber = this._cachedPageNumber(destRef);
  958. if (pageNumber === null) {
  959. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  960. this.cachePageRef(pageIndex + 1, destRef);
  961. this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  962. }).catch(() => {
  963. console.error(`PDFLinkService._goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
  964. });
  965. return;
  966. }
  967. } else if (Number.isInteger(destRef)) {
  968. pageNumber = destRef + 1;
  969. } else {
  970. console.error(`PDFLinkService._goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
  971. return;
  972. }
  973. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  974. console.error(`PDFLinkService._goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
  975. return;
  976. }
  977. if (this.pdfHistory) {
  978. this.pdfHistory.pushCurrentPosition();
  979. this.pdfHistory.push({
  980. namedDest,
  981. explicitDest,
  982. pageNumber
  983. });
  984. }
  985. this.pdfViewer.scrollPageIntoView({
  986. pageNumber,
  987. destArray: explicitDest,
  988. ignoreDestinationZoom: this._ignoreDestinationZoom
  989. });
  990. }
  991. async goToDestination(dest) {
  992. if (!this.pdfDocument) {
  993. return;
  994. }
  995. let namedDest, explicitDest;
  996. if (typeof dest === "string") {
  997. namedDest = dest;
  998. explicitDest = await this.pdfDocument.getDestination(dest);
  999. } else {
  1000. namedDest = null;
  1001. explicitDest = await dest;
  1002. }
  1003. if (!Array.isArray(explicitDest)) {
  1004. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
  1005. return;
  1006. }
  1007. this._goToDestinationHelper(dest, namedDest, explicitDest);
  1008. }
  1009. goToPage(val) {
  1010. if (!this.pdfDocument) {
  1011. return;
  1012. }
  1013. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  1014. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  1015. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  1016. return;
  1017. }
  1018. if (this.pdfHistory) {
  1019. this.pdfHistory.pushCurrentPosition();
  1020. this.pdfHistory.pushPage(pageNumber);
  1021. }
  1022. this.pdfViewer.scrollPageIntoView({
  1023. pageNumber
  1024. });
  1025. }
  1026. getDestinationHash(dest) {
  1027. if (typeof dest === "string") {
  1028. if (dest.length > 0) {
  1029. return this.getAnchorUrl("#" + escape(dest));
  1030. }
  1031. } else if (Array.isArray(dest)) {
  1032. const str = JSON.stringify(dest);
  1033. if (str.length > 0) {
  1034. return this.getAnchorUrl("#" + escape(str));
  1035. }
  1036. }
  1037. return this.getAnchorUrl("");
  1038. }
  1039. getAnchorUrl(anchor) {
  1040. return (this.baseUrl || "") + anchor;
  1041. }
  1042. setHash(hash) {
  1043. if (!this.pdfDocument) {
  1044. return;
  1045. }
  1046. let pageNumber, dest;
  1047. if (hash.includes("=")) {
  1048. const params = (0, _ui_utils.parseQueryString)(hash);
  1049. if ("search" in params) {
  1050. this.eventBus.dispatch("findfromurlhash", {
  1051. source: this,
  1052. query: params.search.replace(/"/g, ""),
  1053. phraseSearch: params.phrase === "true"
  1054. });
  1055. }
  1056. if ("page" in params) {
  1057. pageNumber = params.page | 0 || 1;
  1058. }
  1059. if ("zoom" in params) {
  1060. const zoomArgs = params.zoom.split(",");
  1061. const zoomArg = zoomArgs[0];
  1062. const zoomArgNumber = parseFloat(zoomArg);
  1063. if (!zoomArg.includes("Fit")) {
  1064. dest = [null, {
  1065. name: "XYZ"
  1066. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1067. } else {
  1068. if (zoomArg === "Fit" || zoomArg === "FitB") {
  1069. dest = [null, {
  1070. name: zoomArg
  1071. }];
  1072. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  1073. dest = [null, {
  1074. name: zoomArg
  1075. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1076. } else if (zoomArg === "FitR") {
  1077. if (zoomArgs.length !== 5) {
  1078. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1079. } else {
  1080. dest = [null, {
  1081. name: zoomArg
  1082. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1083. }
  1084. } else {
  1085. console.error(`PDFLinkService.setHash: "${zoomArg}" is not ` + "a valid zoom value.");
  1086. }
  1087. }
  1088. }
  1089. if (dest) {
  1090. this.pdfViewer.scrollPageIntoView({
  1091. pageNumber: pageNumber || this.page,
  1092. destArray: dest,
  1093. allowNegativeOffset: true
  1094. });
  1095. } else if (pageNumber) {
  1096. this.page = pageNumber;
  1097. }
  1098. if ("pagemode" in params) {
  1099. this.eventBus.dispatch("pagemode", {
  1100. source: this,
  1101. mode: params.pagemode
  1102. });
  1103. }
  1104. if ("nameddest" in params) {
  1105. this.goToDestination(params.nameddest);
  1106. }
  1107. } else {
  1108. dest = unescape(hash);
  1109. try {
  1110. dest = JSON.parse(dest);
  1111. if (!Array.isArray(dest)) {
  1112. dest = dest.toString();
  1113. }
  1114. } catch (ex) {}
  1115. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  1116. this.goToDestination(dest);
  1117. return;
  1118. }
  1119. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not ` + "a valid destination.");
  1120. }
  1121. }
  1122. executeNamedAction(action) {
  1123. switch (action) {
  1124. case "GoBack":
  1125. if (this.pdfHistory) {
  1126. this.pdfHistory.back();
  1127. }
  1128. break;
  1129. case "GoForward":
  1130. if (this.pdfHistory) {
  1131. this.pdfHistory.forward();
  1132. }
  1133. break;
  1134. case "NextPage":
  1135. this.pdfViewer.nextPage();
  1136. break;
  1137. case "PrevPage":
  1138. this.pdfViewer.previousPage();
  1139. break;
  1140. case "LastPage":
  1141. this.page = this.pagesCount;
  1142. break;
  1143. case "FirstPage":
  1144. this.page = 1;
  1145. break;
  1146. default:
  1147. break;
  1148. }
  1149. this.eventBus.dispatch("namedaction", {
  1150. source: this,
  1151. action
  1152. });
  1153. }
  1154. cachePageRef(pageNum, pageRef) {
  1155. if (!pageRef) {
  1156. return;
  1157. }
  1158. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  1159. this._pagesRefCache[refStr] = pageNum;
  1160. }
  1161. _cachedPageNumber(pageRef) {
  1162. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  1163. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1164. }
  1165. isPageVisible(pageNumber) {
  1166. return this.pdfViewer.isPageVisible(pageNumber);
  1167. }
  1168. isPageCached(pageNumber) {
  1169. return this.pdfViewer.isPageCached(pageNumber);
  1170. }
  1171. }
  1172. exports.PDFLinkService = PDFLinkService;
  1173. function isValidExplicitDestination(dest) {
  1174. if (!Array.isArray(dest)) {
  1175. return false;
  1176. }
  1177. const destLength = dest.length;
  1178. if (destLength < 2) {
  1179. return false;
  1180. }
  1181. const page = dest[0];
  1182. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1183. return false;
  1184. }
  1185. const zoom = dest[1];
  1186. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  1187. return false;
  1188. }
  1189. let allowNull = true;
  1190. switch (zoom.name) {
  1191. case "XYZ":
  1192. if (destLength !== 5) {
  1193. return false;
  1194. }
  1195. break;
  1196. case "Fit":
  1197. case "FitB":
  1198. return destLength === 2;
  1199. case "FitH":
  1200. case "FitBH":
  1201. case "FitV":
  1202. case "FitBV":
  1203. if (destLength !== 3) {
  1204. return false;
  1205. }
  1206. break;
  1207. case "FitR":
  1208. if (destLength !== 6) {
  1209. return false;
  1210. }
  1211. allowNull = false;
  1212. break;
  1213. default:
  1214. return false;
  1215. }
  1216. for (let i = 2; i < destLength; i++) {
  1217. const param = dest[i];
  1218. if (!(typeof param === "number" || allowNull && param === null)) {
  1219. return false;
  1220. }
  1221. }
  1222. return true;
  1223. }
  1224. class SimpleLinkService {
  1225. constructor() {
  1226. this.externalLinkTarget = null;
  1227. this.externalLinkRel = null;
  1228. this.externalLinkEnabled = true;
  1229. this._ignoreDestinationZoom = false;
  1230. }
  1231. get pagesCount() {
  1232. return 0;
  1233. }
  1234. get page() {
  1235. return 0;
  1236. }
  1237. set page(value) {}
  1238. get rotation() {
  1239. return 0;
  1240. }
  1241. set rotation(value) {}
  1242. async goToDestination(dest) {}
  1243. goToPage(val) {}
  1244. getDestinationHash(dest) {
  1245. return "#";
  1246. }
  1247. getAnchorUrl(hash) {
  1248. return "#";
  1249. }
  1250. setHash(hash) {}
  1251. executeNamedAction(action) {}
  1252. cachePageRef(pageNum, pageRef) {}
  1253. isPageVisible(pageNumber) {
  1254. return true;
  1255. }
  1256. isPageCached(pageNumber) {
  1257. return true;
  1258. }
  1259. }
  1260. exports.SimpleLinkService = SimpleLinkService;
  1261. /***/ }),
  1262. /* 5 */
  1263. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1264. Object.defineProperty(exports, "__esModule", ({
  1265. value: true
  1266. }));
  1267. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  1268. var _pdfjsLib = __w_pdfjs_require__(2);
  1269. const EXPAND_DIVS_TIMEOUT = 300;
  1270. class TextLayerBuilder {
  1271. constructor({
  1272. textLayerDiv,
  1273. eventBus,
  1274. pageIndex,
  1275. viewport,
  1276. findController = null,
  1277. enhanceTextSelection = false
  1278. }) {
  1279. this.textLayerDiv = textLayerDiv;
  1280. this.eventBus = eventBus;
  1281. this.textContent = null;
  1282. this.textContentItemsStr = [];
  1283. this.textContentStream = null;
  1284. this.renderingDone = false;
  1285. this.pageIdx = pageIndex;
  1286. this.pageNumber = this.pageIdx + 1;
  1287. this.matches = [];
  1288. this.viewport = viewport;
  1289. this.textDivs = [];
  1290. this.findController = findController;
  1291. this.textLayerRenderTask = null;
  1292. this.enhanceTextSelection = enhanceTextSelection;
  1293. this._onUpdateTextLayerMatches = null;
  1294. this._bindMouse();
  1295. }
  1296. _finishRendering() {
  1297. this.renderingDone = true;
  1298. if (!this.enhanceTextSelection) {
  1299. const endOfContent = document.createElement("div");
  1300. endOfContent.className = "endOfContent";
  1301. this.textLayerDiv.appendChild(endOfContent);
  1302. }
  1303. this.eventBus.dispatch("textlayerrendered", {
  1304. source: this,
  1305. pageNumber: this.pageNumber,
  1306. numTextDivs: this.textDivs.length
  1307. });
  1308. }
  1309. render(timeout = 0) {
  1310. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  1311. return;
  1312. }
  1313. this.cancel();
  1314. this.textDivs = [];
  1315. const textLayerFrag = document.createDocumentFragment();
  1316. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  1317. textContent: this.textContent,
  1318. textContentStream: this.textContentStream,
  1319. container: textLayerFrag,
  1320. viewport: this.viewport,
  1321. textDivs: this.textDivs,
  1322. textContentItemsStr: this.textContentItemsStr,
  1323. timeout,
  1324. enhanceTextSelection: this.enhanceTextSelection
  1325. });
  1326. this.textLayerRenderTask.promise.then(() => {
  1327. this.textLayerDiv.appendChild(textLayerFrag);
  1328. this._finishRendering();
  1329. this._updateMatches();
  1330. }, function (reason) {});
  1331. if (!this._onUpdateTextLayerMatches) {
  1332. this._onUpdateTextLayerMatches = evt => {
  1333. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  1334. this._updateMatches();
  1335. }
  1336. };
  1337. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  1338. }
  1339. }
  1340. cancel() {
  1341. if (this.textLayerRenderTask) {
  1342. this.textLayerRenderTask.cancel();
  1343. this.textLayerRenderTask = null;
  1344. }
  1345. if (this._onUpdateTextLayerMatches) {
  1346. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  1347. this._onUpdateTextLayerMatches = null;
  1348. }
  1349. }
  1350. setTextContentStream(readableStream) {
  1351. this.cancel();
  1352. this.textContentStream = readableStream;
  1353. }
  1354. setTextContent(textContent) {
  1355. this.cancel();
  1356. this.textContent = textContent;
  1357. }
  1358. _convertMatches(matches, matchesLength) {
  1359. if (!matches) {
  1360. return [];
  1361. }
  1362. const {
  1363. textContentItemsStr
  1364. } = this;
  1365. let i = 0,
  1366. iIndex = 0;
  1367. const end = textContentItemsStr.length - 1;
  1368. const result = [];
  1369. for (let m = 0, mm = matches.length; m < mm; m++) {
  1370. let matchIdx = matches[m];
  1371. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  1372. iIndex += textContentItemsStr[i].length;
  1373. i++;
  1374. }
  1375. if (i === textContentItemsStr.length) {
  1376. console.error("Could not find a matching mapping");
  1377. }
  1378. const match = {
  1379. begin: {
  1380. divIdx: i,
  1381. offset: matchIdx - iIndex
  1382. }
  1383. };
  1384. matchIdx += matchesLength[m];
  1385. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  1386. iIndex += textContentItemsStr[i].length;
  1387. i++;
  1388. }
  1389. match.end = {
  1390. divIdx: i,
  1391. offset: matchIdx - iIndex
  1392. };
  1393. result.push(match);
  1394. }
  1395. return result;
  1396. }
  1397. _renderMatches(matches) {
  1398. if (matches.length === 0) {
  1399. return;
  1400. }
  1401. const {
  1402. findController,
  1403. pageIdx,
  1404. textContentItemsStr,
  1405. textDivs
  1406. } = this;
  1407. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  1408. const selectedMatchIdx = findController.selected.matchIdx;
  1409. const highlightAll = findController.state.highlightAll;
  1410. let prevEnd = null;
  1411. const infinity = {
  1412. divIdx: -1,
  1413. offset: undefined
  1414. };
  1415. function beginText(begin, className) {
  1416. const divIdx = begin.divIdx;
  1417. textDivs[divIdx].textContent = "";
  1418. appendTextToDiv(divIdx, 0, begin.offset, className);
  1419. }
  1420. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  1421. const div = textDivs[divIdx];
  1422. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  1423. const node = document.createTextNode(content);
  1424. if (className) {
  1425. const span = document.createElement("span");
  1426. span.className = className;
  1427. span.appendChild(node);
  1428. div.appendChild(span);
  1429. return;
  1430. }
  1431. div.appendChild(node);
  1432. }
  1433. let i0 = selectedMatchIdx,
  1434. i1 = i0 + 1;
  1435. if (highlightAll) {
  1436. i0 = 0;
  1437. i1 = matches.length;
  1438. } else if (!isSelectedPage) {
  1439. return;
  1440. }
  1441. for (let i = i0; i < i1; i++) {
  1442. const match = matches[i];
  1443. const begin = match.begin;
  1444. const end = match.end;
  1445. const isSelected = isSelectedPage && i === selectedMatchIdx;
  1446. const highlightSuffix = isSelected ? " selected" : "";
  1447. if (isSelected) {
  1448. findController.scrollMatchIntoView({
  1449. element: textDivs[begin.divIdx],
  1450. pageIndex: pageIdx,
  1451. matchIndex: selectedMatchIdx
  1452. });
  1453. }
  1454. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  1455. if (prevEnd !== null) {
  1456. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1457. }
  1458. beginText(begin);
  1459. } else {
  1460. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  1461. }
  1462. if (begin.divIdx === end.divIdx) {
  1463. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  1464. } else {
  1465. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  1466. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  1467. textDivs[n0].className = "highlight middle" + highlightSuffix;
  1468. }
  1469. beginText(end, "highlight end" + highlightSuffix);
  1470. }
  1471. prevEnd = end;
  1472. }
  1473. if (prevEnd) {
  1474. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1475. }
  1476. }
  1477. _updateMatches() {
  1478. if (!this.renderingDone) {
  1479. return;
  1480. }
  1481. const {
  1482. findController,
  1483. matches,
  1484. pageIdx,
  1485. textContentItemsStr,
  1486. textDivs
  1487. } = this;
  1488. let clearedUntilDivIdx = -1;
  1489. for (let i = 0, ii = matches.length; i < ii; i++) {
  1490. const match = matches[i];
  1491. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  1492. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  1493. const div = textDivs[n];
  1494. div.textContent = textContentItemsStr[n];
  1495. div.className = "";
  1496. }
  1497. clearedUntilDivIdx = match.end.divIdx + 1;
  1498. }
  1499. if (!findController || !findController.highlightMatches) {
  1500. return;
  1501. }
  1502. const pageMatches = findController.pageMatches[pageIdx] || null;
  1503. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  1504. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  1505. this._renderMatches(this.matches);
  1506. }
  1507. _bindMouse() {
  1508. const div = this.textLayerDiv;
  1509. let expandDivsTimer = null;
  1510. div.addEventListener("mousedown", evt => {
  1511. if (this.enhanceTextSelection && this.textLayerRenderTask) {
  1512. this.textLayerRenderTask.expandTextDivs(true);
  1513. if (expandDivsTimer) {
  1514. clearTimeout(expandDivsTimer);
  1515. expandDivsTimer = null;
  1516. }
  1517. return;
  1518. }
  1519. const end = div.querySelector(".endOfContent");
  1520. if (!end) {
  1521. return;
  1522. }
  1523. let adjustTop = evt.target !== div;
  1524. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  1525. if (adjustTop) {
  1526. const divBounds = div.getBoundingClientRect();
  1527. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  1528. end.style.top = (r * 100).toFixed(2) + "%";
  1529. }
  1530. end.classList.add("active");
  1531. });
  1532. div.addEventListener("mouseup", () => {
  1533. if (this.enhanceTextSelection && this.textLayerRenderTask) {
  1534. expandDivsTimer = setTimeout(() => {
  1535. if (this.textLayerRenderTask) {
  1536. this.textLayerRenderTask.expandTextDivs(false);
  1537. }
  1538. expandDivsTimer = null;
  1539. }, EXPAND_DIVS_TIMEOUT);
  1540. return;
  1541. }
  1542. const end = div.querySelector(".endOfContent");
  1543. if (!end) {
  1544. return;
  1545. }
  1546. end.style.top = "";
  1547. end.classList.remove("active");
  1548. });
  1549. }
  1550. }
  1551. exports.TextLayerBuilder = TextLayerBuilder;
  1552. class DefaultTextLayerFactory {
  1553. createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
  1554. return new TextLayerBuilder({
  1555. textLayerDiv,
  1556. pageIndex,
  1557. viewport,
  1558. enhanceTextSelection,
  1559. eventBus
  1560. });
  1561. }
  1562. }
  1563. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  1564. /***/ }),
  1565. /* 6 */
  1566. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1567. Object.defineProperty(exports, "__esModule", ({
  1568. value: true
  1569. }));
  1570. exports.DownloadManager = void 0;
  1571. var _pdfjsLib = __w_pdfjs_require__(2);
  1572. var _viewer_compatibility = __w_pdfjs_require__(7);
  1573. ;
  1574. function download(blobUrl, filename) {
  1575. const a = document.createElement("a");
  1576. if (!a.click) {
  1577. throw new Error('DownloadManager: "a.click()" is not supported.');
  1578. }
  1579. a.href = blobUrl;
  1580. a.target = "_parent";
  1581. if ("download" in a) {
  1582. a.download = filename;
  1583. }
  1584. (document.body || document.documentElement).appendChild(a);
  1585. a.click();
  1586. a.remove();
  1587. }
  1588. class DownloadManager {
  1589. downloadUrl(url, filename) {
  1590. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  1591. return;
  1592. }
  1593. download(url + "#pdfjs.action=download", filename);
  1594. }
  1595. downloadData(data, filename, contentType) {
  1596. const blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  1597. download(blobUrl, filename);
  1598. }
  1599. download(blob, url, filename, sourceEventType = "download") {
  1600. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  1601. this.downloadUrl(url, filename);
  1602. return;
  1603. }
  1604. const blobUrl = URL.createObjectURL(blob);
  1605. download(blobUrl, filename);
  1606. }
  1607. }
  1608. exports.DownloadManager = DownloadManager;
  1609. /***/ }),
  1610. /* 7 */
  1611. /***/ ((__unused_webpack_module, exports) => {
  1612. Object.defineProperty(exports, "__esModule", ({
  1613. value: true
  1614. }));
  1615. exports.viewerCompatibilityParams = void 0;
  1616. const compatibilityParams = Object.create(null);
  1617. {
  1618. const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  1619. const platform = typeof navigator !== "undefined" && navigator.platform || "";
  1620. const maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  1621. const isAndroid = /Android/.test(userAgent);
  1622. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  1623. const isIOSChrome = /CriOS/.test(userAgent);
  1624. (function checkOnBlobSupport() {
  1625. if (isIOSChrome) {
  1626. compatibilityParams.disableCreateObjectURL = true;
  1627. }
  1628. })();
  1629. (function checkCanvasSizeLimitation() {
  1630. if (isIOS || isAndroid) {
  1631. compatibilityParams.maxCanvasPixels = 5242880;
  1632. }
  1633. })();
  1634. }
  1635. const viewerCompatibilityParams = Object.freeze(compatibilityParams);
  1636. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  1637. /***/ }),
  1638. /* 8 */
  1639. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1640. Object.defineProperty(exports, "__esModule", ({
  1641. value: true
  1642. }));
  1643. exports.GenericL10n = void 0;
  1644. __w_pdfjs_require__(9);
  1645. const webL10n = document.webL10n;
  1646. class GenericL10n {
  1647. constructor(lang) {
  1648. this._lang = lang;
  1649. this._ready = new Promise((resolve, reject) => {
  1650. webL10n.setLanguage(lang, () => {
  1651. resolve(webL10n);
  1652. });
  1653. });
  1654. }
  1655. async getLanguage() {
  1656. const l10n = await this._ready;
  1657. return l10n.getLanguage();
  1658. }
  1659. async getDirection() {
  1660. const l10n = await this._ready;
  1661. return l10n.getDirection();
  1662. }
  1663. async get(property, args, fallback) {
  1664. const l10n = await this._ready;
  1665. return l10n.get(property, args, fallback);
  1666. }
  1667. async translate(element) {
  1668. const l10n = await this._ready;
  1669. return l10n.translate(element);
  1670. }
  1671. }
  1672. exports.GenericL10n = GenericL10n;
  1673. /***/ }),
  1674. /* 9 */
  1675. /***/ (() => {
  1676. document.webL10n = function (window, document, undefined) {
  1677. var gL10nData = {};
  1678. var gTextData = '';
  1679. var gTextProp = 'textContent';
  1680. var gLanguage = '';
  1681. var gMacros = {};
  1682. var gReadyState = 'loading';
  1683. var gAsyncResourceLoading = true;
  1684. function getL10nResourceLinks() {
  1685. return document.querySelectorAll('link[type="application/l10n"]');
  1686. }
  1687. function getL10nDictionary() {
  1688. var script = document.querySelector('script[type="application/l10n"]');
  1689. return script ? JSON.parse(script.innerHTML) : null;
  1690. }
  1691. function getTranslatableChildren(element) {
  1692. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  1693. }
  1694. function getL10nAttributes(element) {
  1695. if (!element) return {};
  1696. var l10nId = element.getAttribute('data-l10n-id');
  1697. var l10nArgs = element.getAttribute('data-l10n-args');
  1698. var args = {};
  1699. if (l10nArgs) {
  1700. try {
  1701. args = JSON.parse(l10nArgs);
  1702. } catch (e) {
  1703. console.warn('could not parse arguments for #' + l10nId);
  1704. }
  1705. }
  1706. return {
  1707. id: l10nId,
  1708. args: args
  1709. };
  1710. }
  1711. function xhrLoadText(url, onSuccess, onFailure) {
  1712. onSuccess = onSuccess || function _onSuccess(data) {};
  1713. onFailure = onFailure || function _onFailure() {};
  1714. var xhr = new XMLHttpRequest();
  1715. xhr.open('GET', url, gAsyncResourceLoading);
  1716. if (xhr.overrideMimeType) {
  1717. xhr.overrideMimeType('text/plain; charset=utf-8');
  1718. }
  1719. xhr.onreadystatechange = function () {
  1720. if (xhr.readyState == 4) {
  1721. if (xhr.status == 200 || xhr.status === 0) {
  1722. onSuccess(xhr.responseText);
  1723. } else {
  1724. onFailure();
  1725. }
  1726. }
  1727. };
  1728. xhr.onerror = onFailure;
  1729. xhr.ontimeout = onFailure;
  1730. try {
  1731. xhr.send(null);
  1732. } catch (e) {
  1733. onFailure();
  1734. }
  1735. }
  1736. function parseResource(href, lang, successCallback, failureCallback) {
  1737. var baseURL = href.replace(/[^\/]*$/, '') || './';
  1738. function evalString(text) {
  1739. if (text.lastIndexOf('\\') < 0) return text;
  1740. 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, "'");
  1741. }
  1742. function parseProperties(text, parsedPropertiesCallback) {
  1743. var dictionary = {};
  1744. var reBlank = /^\s*|\s*$/;
  1745. var reComment = /^\s*#|^\s*$/;
  1746. var reSection = /^\s*\[(.*)\]\s*$/;
  1747. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  1748. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  1749. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  1750. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  1751. var currentLang = '*';
  1752. var genericLang = lang.split('-', 1)[0];
  1753. var skipLang = false;
  1754. var match = '';
  1755. function nextEntry() {
  1756. while (true) {
  1757. if (!entries.length) {
  1758. parsedRawLinesCallback();
  1759. return;
  1760. }
  1761. var line = entries.shift();
  1762. if (reComment.test(line)) continue;
  1763. if (extendedSyntax) {
  1764. match = reSection.exec(line);
  1765. if (match) {
  1766. currentLang = match[1].toLowerCase();
  1767. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  1768. continue;
  1769. } else if (skipLang) {
  1770. continue;
  1771. }
  1772. match = reImport.exec(line);
  1773. if (match) {
  1774. loadImport(baseURL + match[1], nextEntry);
  1775. return;
  1776. }
  1777. }
  1778. var tmp = line.match(reSplit);
  1779. if (tmp && tmp.length == 3) {
  1780. dictionary[tmp[1]] = evalString(tmp[2]);
  1781. }
  1782. }
  1783. }
  1784. nextEntry();
  1785. }
  1786. function loadImport(url, callback) {
  1787. xhrLoadText(url, function (content) {
  1788. parseRawLines(content, false, callback);
  1789. }, function () {
  1790. console.warn(url + ' not found.');
  1791. callback();
  1792. });
  1793. }
  1794. parseRawLines(text, true, function () {
  1795. parsedPropertiesCallback(dictionary);
  1796. });
  1797. }
  1798. xhrLoadText(href, function (response) {
  1799. gTextData += response;
  1800. parseProperties(response, function (data) {
  1801. for (var key in data) {
  1802. var id,
  1803. prop,
  1804. index = key.lastIndexOf('.');
  1805. if (index > 0) {
  1806. id = key.substring(0, index);
  1807. prop = key.substring(index + 1);
  1808. } else {
  1809. id = key;
  1810. prop = gTextProp;
  1811. }
  1812. if (!gL10nData[id]) {
  1813. gL10nData[id] = {};
  1814. }
  1815. gL10nData[id][prop] = data[key];
  1816. }
  1817. if (successCallback) {
  1818. successCallback();
  1819. }
  1820. });
  1821. }, failureCallback);
  1822. }
  1823. function loadLocale(lang, callback) {
  1824. if (lang) {
  1825. lang = lang.toLowerCase();
  1826. }
  1827. callback = callback || function _callback() {};
  1828. clear();
  1829. gLanguage = lang;
  1830. var langLinks = getL10nResourceLinks();
  1831. var langCount = langLinks.length;
  1832. if (langCount === 0) {
  1833. var dict = getL10nDictionary();
  1834. if (dict && dict.locales && dict.default_locale) {
  1835. console.log('using the embedded JSON directory, early way out');
  1836. gL10nData = dict.locales[lang];
  1837. if (!gL10nData) {
  1838. var defaultLocale = dict.default_locale.toLowerCase();
  1839. for (var anyCaseLang in dict.locales) {
  1840. anyCaseLang = anyCaseLang.toLowerCase();
  1841. if (anyCaseLang === lang) {
  1842. gL10nData = dict.locales[lang];
  1843. break;
  1844. } else if (anyCaseLang === defaultLocale) {
  1845. gL10nData = dict.locales[defaultLocale];
  1846. }
  1847. }
  1848. }
  1849. callback();
  1850. } else {
  1851. console.log('no resource to load, early way out');
  1852. }
  1853. gReadyState = 'complete';
  1854. return;
  1855. }
  1856. var onResourceLoaded = null;
  1857. var gResourceCount = 0;
  1858. onResourceLoaded = function () {
  1859. gResourceCount++;
  1860. if (gResourceCount >= langCount) {
  1861. callback();
  1862. gReadyState = 'complete';
  1863. }
  1864. };
  1865. function L10nResourceLink(link) {
  1866. var href = link.href;
  1867. this.load = function (lang, callback) {
  1868. parseResource(href, lang, callback, function () {
  1869. console.warn(href + ' not found.');
  1870. console.warn('"' + lang + '" resource not found');
  1871. gLanguage = '';
  1872. callback();
  1873. });
  1874. };
  1875. }
  1876. for (var i = 0; i < langCount; i++) {
  1877. var resource = new L10nResourceLink(langLinks[i]);
  1878. resource.load(lang, onResourceLoaded);
  1879. }
  1880. }
  1881. function clear() {
  1882. gL10nData = {};
  1883. gTextData = '';
  1884. gLanguage = '';
  1885. }
  1886. function getPluralRules(lang) {
  1887. var locales2rules = {
  1888. 'af': 3,
  1889. 'ak': 4,
  1890. 'am': 4,
  1891. 'ar': 1,
  1892. 'asa': 3,
  1893. 'az': 0,
  1894. 'be': 11,
  1895. 'bem': 3,
  1896. 'bez': 3,
  1897. 'bg': 3,
  1898. 'bh': 4,
  1899. 'bm': 0,
  1900. 'bn': 3,
  1901. 'bo': 0,
  1902. 'br': 20,
  1903. 'brx': 3,
  1904. 'bs': 11,
  1905. 'ca': 3,
  1906. 'cgg': 3,
  1907. 'chr': 3,
  1908. 'cs': 12,
  1909. 'cy': 17,
  1910. 'da': 3,
  1911. 'de': 3,
  1912. 'dv': 3,
  1913. 'dz': 0,
  1914. 'ee': 3,
  1915. 'el': 3,
  1916. 'en': 3,
  1917. 'eo': 3,
  1918. 'es': 3,
  1919. 'et': 3,
  1920. 'eu': 3,
  1921. 'fa': 0,
  1922. 'ff': 5,
  1923. 'fi': 3,
  1924. 'fil': 4,
  1925. 'fo': 3,
  1926. 'fr': 5,
  1927. 'fur': 3,
  1928. 'fy': 3,
  1929. 'ga': 8,
  1930. 'gd': 24,
  1931. 'gl': 3,
  1932. 'gsw': 3,
  1933. 'gu': 3,
  1934. 'guw': 4,
  1935. 'gv': 23,
  1936. 'ha': 3,
  1937. 'haw': 3,
  1938. 'he': 2,
  1939. 'hi': 4,
  1940. 'hr': 11,
  1941. 'hu': 0,
  1942. 'id': 0,
  1943. 'ig': 0,
  1944. 'ii': 0,
  1945. 'is': 3,
  1946. 'it': 3,
  1947. 'iu': 7,
  1948. 'ja': 0,
  1949. 'jmc': 3,
  1950. 'jv': 0,
  1951. 'ka': 0,
  1952. 'kab': 5,
  1953. 'kaj': 3,
  1954. 'kcg': 3,
  1955. 'kde': 0,
  1956. 'kea': 0,
  1957. 'kk': 3,
  1958. 'kl': 3,
  1959. 'km': 0,
  1960. 'kn': 0,
  1961. 'ko': 0,
  1962. 'ksb': 3,
  1963. 'ksh': 21,
  1964. 'ku': 3,
  1965. 'kw': 7,
  1966. 'lag': 18,
  1967. 'lb': 3,
  1968. 'lg': 3,
  1969. 'ln': 4,
  1970. 'lo': 0,
  1971. 'lt': 10,
  1972. 'lv': 6,
  1973. 'mas': 3,
  1974. 'mg': 4,
  1975. 'mk': 16,
  1976. 'ml': 3,
  1977. 'mn': 3,
  1978. 'mo': 9,
  1979. 'mr': 3,
  1980. 'ms': 0,
  1981. 'mt': 15,
  1982. 'my': 0,
  1983. 'nah': 3,
  1984. 'naq': 7,
  1985. 'nb': 3,
  1986. 'nd': 3,
  1987. 'ne': 3,
  1988. 'nl': 3,
  1989. 'nn': 3,
  1990. 'no': 3,
  1991. 'nr': 3,
  1992. 'nso': 4,
  1993. 'ny': 3,
  1994. 'nyn': 3,
  1995. 'om': 3,
  1996. 'or': 3,
  1997. 'pa': 3,
  1998. 'pap': 3,
  1999. 'pl': 13,
  2000. 'ps': 3,
  2001. 'pt': 3,
  2002. 'rm': 3,
  2003. 'ro': 9,
  2004. 'rof': 3,
  2005. 'ru': 11,
  2006. 'rwk': 3,
  2007. 'sah': 0,
  2008. 'saq': 3,
  2009. 'se': 7,
  2010. 'seh': 3,
  2011. 'ses': 0,
  2012. 'sg': 0,
  2013. 'sh': 11,
  2014. 'shi': 19,
  2015. 'sk': 12,
  2016. 'sl': 14,
  2017. 'sma': 7,
  2018. 'smi': 7,
  2019. 'smj': 7,
  2020. 'smn': 7,
  2021. 'sms': 7,
  2022. 'sn': 3,
  2023. 'so': 3,
  2024. 'sq': 3,
  2025. 'sr': 11,
  2026. 'ss': 3,
  2027. 'ssy': 3,
  2028. 'st': 3,
  2029. 'sv': 3,
  2030. 'sw': 3,
  2031. 'syr': 3,
  2032. 'ta': 3,
  2033. 'te': 3,
  2034. 'teo': 3,
  2035. 'th': 0,
  2036. 'ti': 4,
  2037. 'tig': 3,
  2038. 'tk': 3,
  2039. 'tl': 4,
  2040. 'tn': 3,
  2041. 'to': 0,
  2042. 'tr': 0,
  2043. 'ts': 3,
  2044. 'tzm': 22,
  2045. 'uk': 11,
  2046. 'ur': 3,
  2047. 've': 3,
  2048. 'vi': 0,
  2049. 'vun': 3,
  2050. 'wa': 4,
  2051. 'wae': 3,
  2052. 'wo': 0,
  2053. 'xh': 3,
  2054. 'xog': 3,
  2055. 'yo': 0,
  2056. 'zh': 0,
  2057. 'zu': 3
  2058. };
  2059. function isIn(n, list) {
  2060. return list.indexOf(n) !== -1;
  2061. }
  2062. function isBetween(n, start, end) {
  2063. return start <= n && n <= end;
  2064. }
  2065. var pluralRules = {
  2066. '0': function (n) {
  2067. return 'other';
  2068. },
  2069. '1': function (n) {
  2070. if (isBetween(n % 100, 3, 10)) return 'few';
  2071. if (n === 0) return 'zero';
  2072. if (isBetween(n % 100, 11, 99)) return 'many';
  2073. if (n == 2) return 'two';
  2074. if (n == 1) return 'one';
  2075. return 'other';
  2076. },
  2077. '2': function (n) {
  2078. if (n !== 0 && n % 10 === 0) return 'many';
  2079. if (n == 2) return 'two';
  2080. if (n == 1) return 'one';
  2081. return 'other';
  2082. },
  2083. '3': function (n) {
  2084. if (n == 1) return 'one';
  2085. return 'other';
  2086. },
  2087. '4': function (n) {
  2088. if (isBetween(n, 0, 1)) return 'one';
  2089. return 'other';
  2090. },
  2091. '5': function (n) {
  2092. if (isBetween(n, 0, 2) && n != 2) return 'one';
  2093. return 'other';
  2094. },
  2095. '6': function (n) {
  2096. if (n === 0) return 'zero';
  2097. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2098. return 'other';
  2099. },
  2100. '7': function (n) {
  2101. if (n == 2) return 'two';
  2102. if (n == 1) return 'one';
  2103. return 'other';
  2104. },
  2105. '8': function (n) {
  2106. if (isBetween(n, 3, 6)) return 'few';
  2107. if (isBetween(n, 7, 10)) return 'many';
  2108. if (n == 2) return 'two';
  2109. if (n == 1) return 'one';
  2110. return 'other';
  2111. },
  2112. '9': function (n) {
  2113. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  2114. if (n == 1) return 'one';
  2115. return 'other';
  2116. },
  2117. '10': function (n) {
  2118. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  2119. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  2120. return 'other';
  2121. },
  2122. '11': function (n) {
  2123. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  2124. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  2125. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2126. return 'other';
  2127. },
  2128. '12': function (n) {
  2129. if (isBetween(n, 2, 4)) return 'few';
  2130. if (n == 1) return 'one';
  2131. return 'other';
  2132. },
  2133. '13': function (n) {
  2134. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  2135. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  2136. if (n == 1) return 'one';
  2137. return 'other';
  2138. },
  2139. '14': function (n) {
  2140. if (isBetween(n % 100, 3, 4)) return 'few';
  2141. if (n % 100 == 2) return 'two';
  2142. if (n % 100 == 1) return 'one';
  2143. return 'other';
  2144. },
  2145. '15': function (n) {
  2146. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  2147. if (isBetween(n % 100, 11, 19)) return 'many';
  2148. if (n == 1) return 'one';
  2149. return 'other';
  2150. },
  2151. '16': function (n) {
  2152. if (n % 10 == 1 && n != 11) return 'one';
  2153. return 'other';
  2154. },
  2155. '17': function (n) {
  2156. if (n == 3) return 'few';
  2157. if (n === 0) return 'zero';
  2158. if (n == 6) return 'many';
  2159. if (n == 2) return 'two';
  2160. if (n == 1) return 'one';
  2161. return 'other';
  2162. },
  2163. '18': function (n) {
  2164. if (n === 0) return 'zero';
  2165. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  2166. return 'other';
  2167. },
  2168. '19': function (n) {
  2169. if (isBetween(n, 2, 10)) return 'few';
  2170. if (isBetween(n, 0, 1)) return 'one';
  2171. return 'other';
  2172. },
  2173. '20': function (n) {
  2174. 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';
  2175. if (n % 1000000 === 0 && n !== 0) return 'many';
  2176. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  2177. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  2178. return 'other';
  2179. },
  2180. '21': function (n) {
  2181. if (n === 0) return 'zero';
  2182. if (n == 1) return 'one';
  2183. return 'other';
  2184. },
  2185. '22': function (n) {
  2186. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  2187. return 'other';
  2188. },
  2189. '23': function (n) {
  2190. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  2191. return 'other';
  2192. },
  2193. '24': function (n) {
  2194. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  2195. if (isIn(n, [2, 12])) return 'two';
  2196. if (isIn(n, [1, 11])) return 'one';
  2197. return 'other';
  2198. }
  2199. };
  2200. var index = locales2rules[lang.replace(/-.*$/, '')];
  2201. if (!(index in pluralRules)) {
  2202. console.warn('plural form unknown for [' + lang + ']');
  2203. return function () {
  2204. return 'other';
  2205. };
  2206. }
  2207. return pluralRules[index];
  2208. }
  2209. gMacros.plural = function (str, param, key, prop) {
  2210. var n = parseFloat(param);
  2211. if (isNaN(n)) return str;
  2212. if (prop != gTextProp) return str;
  2213. if (!gMacros._pluralRules) {
  2214. gMacros._pluralRules = getPluralRules(gLanguage);
  2215. }
  2216. var index = '[' + gMacros._pluralRules(n) + ']';
  2217. if (n === 0 && key + '[zero]' in gL10nData) {
  2218. str = gL10nData[key + '[zero]'][prop];
  2219. } else if (n == 1 && key + '[one]' in gL10nData) {
  2220. str = gL10nData[key + '[one]'][prop];
  2221. } else if (n == 2 && key + '[two]' in gL10nData) {
  2222. str = gL10nData[key + '[two]'][prop];
  2223. } else if (key + index in gL10nData) {
  2224. str = gL10nData[key + index][prop];
  2225. } else if (key + '[other]' in gL10nData) {
  2226. str = gL10nData[key + '[other]'][prop];
  2227. }
  2228. return str;
  2229. };
  2230. function getL10nData(key, args, fallback) {
  2231. var data = gL10nData[key];
  2232. if (!data) {
  2233. console.warn('#' + key + ' is undefined.');
  2234. if (!fallback) {
  2235. return null;
  2236. }
  2237. data = fallback;
  2238. }
  2239. var rv = {};
  2240. for (var prop in data) {
  2241. var str = data[prop];
  2242. str = substIndexes(str, args, key, prop);
  2243. str = substArguments(str, args, key);
  2244. rv[prop] = str;
  2245. }
  2246. return rv;
  2247. }
  2248. function substIndexes(str, args, key, prop) {
  2249. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  2250. var reMatch = reIndex.exec(str);
  2251. if (!reMatch || !reMatch.length) return str;
  2252. var macroName = reMatch[1];
  2253. var paramName = reMatch[2];
  2254. var param;
  2255. if (args && paramName in args) {
  2256. param = args[paramName];
  2257. } else if (paramName in gL10nData) {
  2258. param = gL10nData[paramName];
  2259. }
  2260. if (macroName in gMacros) {
  2261. var macro = gMacros[macroName];
  2262. str = macro(str, param, key, prop);
  2263. }
  2264. return str;
  2265. }
  2266. function substArguments(str, args, key) {
  2267. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  2268. return str.replace(reArgs, function (matched_text, arg) {
  2269. if (args && arg in args) {
  2270. return args[arg];
  2271. }
  2272. if (arg in gL10nData) {
  2273. return gL10nData[arg];
  2274. }
  2275. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  2276. return matched_text;
  2277. });
  2278. }
  2279. function translateElement(element) {
  2280. var l10n = getL10nAttributes(element);
  2281. if (!l10n.id) return;
  2282. var data = getL10nData(l10n.id, l10n.args);
  2283. if (!data) {
  2284. console.warn('#' + l10n.id + ' is undefined.');
  2285. return;
  2286. }
  2287. if (data[gTextProp]) {
  2288. if (getChildElementCount(element) === 0) {
  2289. element[gTextProp] = data[gTextProp];
  2290. } else {
  2291. var children = element.childNodes;
  2292. var found = false;
  2293. for (var i = 0, l = children.length; i < l; i++) {
  2294. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  2295. if (found) {
  2296. children[i].nodeValue = '';
  2297. } else {
  2298. children[i].nodeValue = data[gTextProp];
  2299. found = true;
  2300. }
  2301. }
  2302. }
  2303. if (!found) {
  2304. var textNode = document.createTextNode(data[gTextProp]);
  2305. element.insertBefore(textNode, element.firstChild);
  2306. }
  2307. }
  2308. delete data[gTextProp];
  2309. }
  2310. for (var k in data) {
  2311. element[k] = data[k];
  2312. }
  2313. }
  2314. function getChildElementCount(element) {
  2315. if (element.children) {
  2316. return element.children.length;
  2317. }
  2318. if (typeof element.childElementCount !== 'undefined') {
  2319. return element.childElementCount;
  2320. }
  2321. var count = 0;
  2322. for (var i = 0; i < element.childNodes.length; i++) {
  2323. count += element.nodeType === 1 ? 1 : 0;
  2324. }
  2325. return count;
  2326. }
  2327. function translateFragment(element) {
  2328. element = element || document.documentElement;
  2329. var children = getTranslatableChildren(element);
  2330. var elementCount = children.length;
  2331. for (var i = 0; i < elementCount; i++) {
  2332. translateElement(children[i]);
  2333. }
  2334. translateElement(element);
  2335. }
  2336. return {
  2337. get: function (key, args, fallbackString) {
  2338. var index = key.lastIndexOf('.');
  2339. var prop = gTextProp;
  2340. if (index > 0) {
  2341. prop = key.substring(index + 1);
  2342. key = key.substring(0, index);
  2343. }
  2344. var fallback;
  2345. if (fallbackString) {
  2346. fallback = {};
  2347. fallback[prop] = fallbackString;
  2348. }
  2349. var data = getL10nData(key, args, fallback);
  2350. if (data && prop in data) {
  2351. return data[prop];
  2352. }
  2353. return '{{' + key + '}}';
  2354. },
  2355. getData: function () {
  2356. return gL10nData;
  2357. },
  2358. getText: function () {
  2359. return gTextData;
  2360. },
  2361. getLanguage: function () {
  2362. return gLanguage;
  2363. },
  2364. setLanguage: function (lang, callback) {
  2365. loadLocale(lang, function () {
  2366. if (callback) callback();
  2367. });
  2368. },
  2369. getDirection: function () {
  2370. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  2371. var shortCode = gLanguage.split('-', 1)[0];
  2372. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  2373. },
  2374. translate: translateFragment,
  2375. getReadyState: function () {
  2376. return gReadyState;
  2377. },
  2378. ready: function (callback) {
  2379. if (!callback) {
  2380. return;
  2381. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  2382. window.setTimeout(function () {
  2383. callback();
  2384. });
  2385. } else if (document.addEventListener) {
  2386. document.addEventListener('localized', function once() {
  2387. document.removeEventListener('localized', once);
  2388. callback();
  2389. });
  2390. }
  2391. }
  2392. };
  2393. }(window, document);
  2394. /***/ }),
  2395. /* 10 */
  2396. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2397. Object.defineProperty(exports, "__esModule", ({
  2398. value: true
  2399. }));
  2400. exports.PDFFindController = exports.FindState = void 0;
  2401. var _pdfjsLib = __w_pdfjs_require__(2);
  2402. var _pdf_find_utils = __w_pdfjs_require__(11);
  2403. var _ui_utils = __w_pdfjs_require__(3);
  2404. const FindState = {
  2405. FOUND: 0,
  2406. NOT_FOUND: 1,
  2407. WRAPPED: 2,
  2408. PENDING: 3
  2409. };
  2410. exports.FindState = FindState;
  2411. const FIND_TIMEOUT = 250;
  2412. const MATCH_SCROLL_OFFSET_TOP = -50;
  2413. const MATCH_SCROLL_OFFSET_LEFT = -400;
  2414. const CHARACTERS_TO_NORMALIZE = {
  2415. "\u2018": "'",
  2416. "\u2019": "'",
  2417. "\u201A": "'",
  2418. "\u201B": "'",
  2419. "\u201C": '"',
  2420. "\u201D": '"',
  2421. "\u201E": '"',
  2422. "\u201F": '"',
  2423. "\u00BC": "1/4",
  2424. "\u00BD": "1/2",
  2425. "\u00BE": "3/4"
  2426. };
  2427. let normalizationRegex = null;
  2428. function normalize(text) {
  2429. if (!normalizationRegex) {
  2430. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  2431. normalizationRegex = new RegExp(`[${replace}]`, "g");
  2432. }
  2433. let diffs = null;
  2434. const normalizedText = text.replace(normalizationRegex, function (ch, index) {
  2435. const normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  2436. diff = normalizedCh.length - ch.length;
  2437. if (diff !== 0) {
  2438. (diffs || (diffs = [])).push([index, diff]);
  2439. }
  2440. return normalizedCh;
  2441. });
  2442. return [normalizedText, diffs];
  2443. }
  2444. function getOriginalIndex(matchIndex, diffs = null) {
  2445. if (!diffs) {
  2446. return matchIndex;
  2447. }
  2448. let totalDiff = 0;
  2449. for (const [index, diff] of diffs) {
  2450. const currentIndex = index + totalDiff;
  2451. if (currentIndex >= matchIndex) {
  2452. break;
  2453. }
  2454. if (currentIndex + diff > matchIndex) {
  2455. totalDiff += matchIndex - currentIndex;
  2456. break;
  2457. }
  2458. totalDiff += diff;
  2459. }
  2460. return matchIndex - totalDiff;
  2461. }
  2462. class PDFFindController {
  2463. constructor({
  2464. linkService,
  2465. eventBus
  2466. }) {
  2467. this._linkService = linkService;
  2468. this._eventBus = eventBus;
  2469. this._reset();
  2470. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  2471. }
  2472. get highlightMatches() {
  2473. return this._highlightMatches;
  2474. }
  2475. get pageMatches() {
  2476. return this._pageMatches;
  2477. }
  2478. get pageMatchesLength() {
  2479. return this._pageMatchesLength;
  2480. }
  2481. get selected() {
  2482. return this._selected;
  2483. }
  2484. get state() {
  2485. return this._state;
  2486. }
  2487. setDocument(pdfDocument) {
  2488. if (this._pdfDocument) {
  2489. this._reset();
  2490. }
  2491. if (!pdfDocument) {
  2492. return;
  2493. }
  2494. this._pdfDocument = pdfDocument;
  2495. this._firstPageCapability.resolve();
  2496. }
  2497. executeCommand(cmd, state) {
  2498. if (!state) {
  2499. return;
  2500. }
  2501. const pdfDocument = this._pdfDocument;
  2502. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  2503. this._dirtyMatch = true;
  2504. }
  2505. this._state = state;
  2506. if (cmd !== "findhighlightallchange") {
  2507. this._updateUIState(FindState.PENDING);
  2508. }
  2509. this._firstPageCapability.promise.then(() => {
  2510. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  2511. return;
  2512. }
  2513. this._extractText();
  2514. const findbarClosed = !this._highlightMatches;
  2515. const pendingTimeout = !!this._findTimeout;
  2516. if (this._findTimeout) {
  2517. clearTimeout(this._findTimeout);
  2518. this._findTimeout = null;
  2519. }
  2520. if (cmd === "find") {
  2521. this._findTimeout = setTimeout(() => {
  2522. this._nextMatch();
  2523. this._findTimeout = null;
  2524. }, FIND_TIMEOUT);
  2525. } else if (this._dirtyMatch) {
  2526. this._nextMatch();
  2527. } else if (cmd === "findagain") {
  2528. this._nextMatch();
  2529. if (findbarClosed && this._state.highlightAll) {
  2530. this._updateAllPages();
  2531. }
  2532. } else if (cmd === "findhighlightallchange") {
  2533. if (pendingTimeout) {
  2534. this._nextMatch();
  2535. } else {
  2536. this._highlightMatches = true;
  2537. }
  2538. this._updateAllPages();
  2539. } else {
  2540. this._nextMatch();
  2541. }
  2542. });
  2543. }
  2544. scrollMatchIntoView({
  2545. element = null,
  2546. pageIndex = -1,
  2547. matchIndex = -1
  2548. }) {
  2549. if (!this._scrollMatches || !element) {
  2550. return;
  2551. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  2552. return;
  2553. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  2554. return;
  2555. }
  2556. this._scrollMatches = false;
  2557. const spot = {
  2558. top: MATCH_SCROLL_OFFSET_TOP,
  2559. left: MATCH_SCROLL_OFFSET_LEFT
  2560. };
  2561. (0, _ui_utils.scrollIntoView)(element, spot, true);
  2562. }
  2563. _reset() {
  2564. this._highlightMatches = false;
  2565. this._scrollMatches = false;
  2566. this._pdfDocument = null;
  2567. this._pageMatches = [];
  2568. this._pageMatchesLength = [];
  2569. this._state = null;
  2570. this._selected = {
  2571. pageIdx: -1,
  2572. matchIdx: -1
  2573. };
  2574. this._offset = {
  2575. pageIdx: null,
  2576. matchIdx: null,
  2577. wrapped: false
  2578. };
  2579. this._extractTextPromises = [];
  2580. this._pageContents = [];
  2581. this._pageDiffs = [];
  2582. this._matchesCountTotal = 0;
  2583. this._pagesToSearch = null;
  2584. this._pendingFindMatches = Object.create(null);
  2585. this._resumePageIdx = null;
  2586. this._dirtyMatch = false;
  2587. clearTimeout(this._findTimeout);
  2588. this._findTimeout = null;
  2589. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  2590. }
  2591. get _query() {
  2592. if (this._state.query !== this._rawQuery) {
  2593. this._rawQuery = this._state.query;
  2594. [this._normalizedQuery] = normalize(this._state.query);
  2595. }
  2596. return this._normalizedQuery;
  2597. }
  2598. _shouldDirtyMatch(cmd, state) {
  2599. if (state.query !== this._state.query) {
  2600. return true;
  2601. }
  2602. switch (cmd) {
  2603. case "findagain":
  2604. const pageNumber = this._selected.pageIdx + 1;
  2605. const linkService = this._linkService;
  2606. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  2607. return true;
  2608. }
  2609. return false;
  2610. case "findhighlightallchange":
  2611. return false;
  2612. }
  2613. return true;
  2614. }
  2615. _prepareMatches(matchesWithLength, matches, matchesLength) {
  2616. function isSubTerm(currentIndex) {
  2617. const currentElem = matchesWithLength[currentIndex];
  2618. const nextElem = matchesWithLength[currentIndex + 1];
  2619. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  2620. currentElem.skipped = true;
  2621. return true;
  2622. }
  2623. for (let i = currentIndex - 1; i >= 0; i--) {
  2624. const prevElem = matchesWithLength[i];
  2625. if (prevElem.skipped) {
  2626. continue;
  2627. }
  2628. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  2629. break;
  2630. }
  2631. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  2632. currentElem.skipped = true;
  2633. return true;
  2634. }
  2635. }
  2636. return false;
  2637. }
  2638. matchesWithLength.sort(function (a, b) {
  2639. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  2640. });
  2641. for (let i = 0, len = matchesWithLength.length; i < len; i++) {
  2642. if (isSubTerm(i)) {
  2643. continue;
  2644. }
  2645. matches.push(matchesWithLength[i].match);
  2646. matchesLength.push(matchesWithLength[i].matchLength);
  2647. }
  2648. }
  2649. _isEntireWord(content, startIdx, length) {
  2650. if (startIdx > 0) {
  2651. const first = content.charCodeAt(startIdx);
  2652. const limit = content.charCodeAt(startIdx - 1);
  2653. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  2654. return false;
  2655. }
  2656. }
  2657. const endIdx = startIdx + length - 1;
  2658. if (endIdx < content.length - 1) {
  2659. const last = content.charCodeAt(endIdx);
  2660. const limit = content.charCodeAt(endIdx + 1);
  2661. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  2662. return false;
  2663. }
  2664. }
  2665. return true;
  2666. }
  2667. _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  2668. const matches = [],
  2669. matchesLength = [];
  2670. const queryLen = query.length;
  2671. let matchIdx = -queryLen;
  2672. while (true) {
  2673. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  2674. if (matchIdx === -1) {
  2675. break;
  2676. }
  2677. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  2678. continue;
  2679. }
  2680. const originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  2681. matchEnd = matchIdx + queryLen - 1,
  2682. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  2683. matches.push(originalMatchIdx);
  2684. matchesLength.push(originalQueryLen);
  2685. }
  2686. this._pageMatches[pageIndex] = matches;
  2687. this._pageMatchesLength[pageIndex] = matchesLength;
  2688. }
  2689. _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  2690. const matchesWithLength = [];
  2691. const queryArray = query.match(/\S+/g);
  2692. for (let i = 0, len = queryArray.length; i < len; i++) {
  2693. const subquery = queryArray[i];
  2694. const subqueryLen = subquery.length;
  2695. let matchIdx = -subqueryLen;
  2696. while (true) {
  2697. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  2698. if (matchIdx === -1) {
  2699. break;
  2700. }
  2701. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  2702. continue;
  2703. }
  2704. const originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  2705. matchEnd = matchIdx + subqueryLen - 1,
  2706. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  2707. matchesWithLength.push({
  2708. match: originalMatchIdx,
  2709. matchLength: originalQueryLen,
  2710. skipped: false
  2711. });
  2712. }
  2713. }
  2714. this._pageMatchesLength[pageIndex] = [];
  2715. this._pageMatches[pageIndex] = [];
  2716. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  2717. }
  2718. _calculateMatch(pageIndex) {
  2719. let pageContent = this._pageContents[pageIndex];
  2720. const pageDiffs = this._pageDiffs[pageIndex];
  2721. let query = this._query;
  2722. const {
  2723. caseSensitive,
  2724. entireWord,
  2725. phraseSearch
  2726. } = this._state;
  2727. if (query.length === 0) {
  2728. return;
  2729. }
  2730. if (!caseSensitive) {
  2731. pageContent = pageContent.toLowerCase();
  2732. query = query.toLowerCase();
  2733. }
  2734. if (phraseSearch) {
  2735. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  2736. } else {
  2737. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  2738. }
  2739. if (this._state.highlightAll) {
  2740. this._updatePage(pageIndex);
  2741. }
  2742. if (this._resumePageIdx === pageIndex) {
  2743. this._resumePageIdx = null;
  2744. this._nextPageMatch();
  2745. }
  2746. const pageMatchesCount = this._pageMatches[pageIndex].length;
  2747. if (pageMatchesCount > 0) {
  2748. this._matchesCountTotal += pageMatchesCount;
  2749. this._updateUIResultsCount();
  2750. }
  2751. }
  2752. _extractText() {
  2753. if (this._extractTextPromises.length > 0) {
  2754. return;
  2755. }
  2756. let promise = Promise.resolve();
  2757. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  2758. const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  2759. this._extractTextPromises[i] = extractTextCapability.promise;
  2760. promise = promise.then(() => {
  2761. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  2762. return pdfPage.getTextContent({
  2763. normalizeWhitespace: true
  2764. });
  2765. }).then(textContent => {
  2766. const textItems = textContent.items;
  2767. const strBuf = [];
  2768. for (let j = 0, jj = textItems.length; j < jj; j++) {
  2769. strBuf.push(textItems[j].str);
  2770. }
  2771. [this._pageContents[i], this._pageDiffs[i]] = normalize(strBuf.join(""));
  2772. extractTextCapability.resolve(i);
  2773. }, reason => {
  2774. console.error(`Unable to get text content for page ${i + 1}`, reason);
  2775. this._pageContents[i] = "";
  2776. this._pageDiffs[i] = null;
  2777. extractTextCapability.resolve(i);
  2778. });
  2779. });
  2780. }
  2781. }
  2782. _updatePage(index) {
  2783. if (this._scrollMatches && this._selected.pageIdx === index) {
  2784. this._linkService.page = index + 1;
  2785. }
  2786. this._eventBus.dispatch("updatetextlayermatches", {
  2787. source: this,
  2788. pageIndex: index
  2789. });
  2790. }
  2791. _updateAllPages() {
  2792. this._eventBus.dispatch("updatetextlayermatches", {
  2793. source: this,
  2794. pageIndex: -1
  2795. });
  2796. }
  2797. _nextMatch() {
  2798. const previous = this._state.findPrevious;
  2799. const currentPageIndex = this._linkService.page - 1;
  2800. const numPages = this._linkService.pagesCount;
  2801. this._highlightMatches = true;
  2802. if (this._dirtyMatch) {
  2803. this._dirtyMatch = false;
  2804. this._selected.pageIdx = this._selected.matchIdx = -1;
  2805. this._offset.pageIdx = currentPageIndex;
  2806. this._offset.matchIdx = null;
  2807. this._offset.wrapped = false;
  2808. this._resumePageIdx = null;
  2809. this._pageMatches.length = 0;
  2810. this._pageMatchesLength.length = 0;
  2811. this._matchesCountTotal = 0;
  2812. this._updateAllPages();
  2813. for (let i = 0; i < numPages; i++) {
  2814. if (this._pendingFindMatches[i] === true) {
  2815. continue;
  2816. }
  2817. this._pendingFindMatches[i] = true;
  2818. this._extractTextPromises[i].then(pageIdx => {
  2819. delete this._pendingFindMatches[pageIdx];
  2820. this._calculateMatch(pageIdx);
  2821. });
  2822. }
  2823. }
  2824. if (this._query === "") {
  2825. this._updateUIState(FindState.FOUND);
  2826. return;
  2827. }
  2828. if (this._resumePageIdx) {
  2829. return;
  2830. }
  2831. const offset = this._offset;
  2832. this._pagesToSearch = numPages;
  2833. if (offset.matchIdx !== null) {
  2834. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  2835. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  2836. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  2837. this._updateMatch(true);
  2838. return;
  2839. }
  2840. this._advanceOffsetPage(previous);
  2841. }
  2842. this._nextPageMatch();
  2843. }
  2844. _matchesReady(matches) {
  2845. const offset = this._offset;
  2846. const numMatches = matches.length;
  2847. const previous = this._state.findPrevious;
  2848. if (numMatches) {
  2849. offset.matchIdx = previous ? numMatches - 1 : 0;
  2850. this._updateMatch(true);
  2851. return true;
  2852. }
  2853. this._advanceOffsetPage(previous);
  2854. if (offset.wrapped) {
  2855. offset.matchIdx = null;
  2856. if (this._pagesToSearch < 0) {
  2857. this._updateMatch(false);
  2858. return true;
  2859. }
  2860. }
  2861. return false;
  2862. }
  2863. _nextPageMatch() {
  2864. if (this._resumePageIdx !== null) {
  2865. console.error("There can only be one pending page.");
  2866. }
  2867. let matches = null;
  2868. do {
  2869. const pageIdx = this._offset.pageIdx;
  2870. matches = this._pageMatches[pageIdx];
  2871. if (!matches) {
  2872. this._resumePageIdx = pageIdx;
  2873. break;
  2874. }
  2875. } while (!this._matchesReady(matches));
  2876. }
  2877. _advanceOffsetPage(previous) {
  2878. const offset = this._offset;
  2879. const numPages = this._linkService.pagesCount;
  2880. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  2881. offset.matchIdx = null;
  2882. this._pagesToSearch--;
  2883. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  2884. offset.pageIdx = previous ? numPages - 1 : 0;
  2885. offset.wrapped = true;
  2886. }
  2887. }
  2888. _updateMatch(found = false) {
  2889. let state = FindState.NOT_FOUND;
  2890. const wrapped = this._offset.wrapped;
  2891. this._offset.wrapped = false;
  2892. if (found) {
  2893. const previousPage = this._selected.pageIdx;
  2894. this._selected.pageIdx = this._offset.pageIdx;
  2895. this._selected.matchIdx = this._offset.matchIdx;
  2896. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  2897. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  2898. this._updatePage(previousPage);
  2899. }
  2900. }
  2901. this._updateUIState(state, this._state.findPrevious);
  2902. if (this._selected.pageIdx !== -1) {
  2903. this._scrollMatches = true;
  2904. this._updatePage(this._selected.pageIdx);
  2905. }
  2906. }
  2907. _onFindBarClose(evt) {
  2908. const pdfDocument = this._pdfDocument;
  2909. this._firstPageCapability.promise.then(() => {
  2910. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  2911. return;
  2912. }
  2913. if (this._findTimeout) {
  2914. clearTimeout(this._findTimeout);
  2915. this._findTimeout = null;
  2916. }
  2917. if (this._resumePageIdx) {
  2918. this._resumePageIdx = null;
  2919. this._dirtyMatch = true;
  2920. }
  2921. this._updateUIState(FindState.FOUND);
  2922. this._highlightMatches = false;
  2923. this._updateAllPages();
  2924. });
  2925. }
  2926. _requestMatchesCount() {
  2927. const {
  2928. pageIdx,
  2929. matchIdx
  2930. } = this._selected;
  2931. let current = 0,
  2932. total = this._matchesCountTotal;
  2933. if (matchIdx !== -1) {
  2934. for (let i = 0; i < pageIdx; i++) {
  2935. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  2936. }
  2937. current += matchIdx + 1;
  2938. }
  2939. if (current < 1 || current > total) {
  2940. current = total = 0;
  2941. }
  2942. return {
  2943. current,
  2944. total
  2945. };
  2946. }
  2947. _updateUIResultsCount() {
  2948. this._eventBus.dispatch("updatefindmatchescount", {
  2949. source: this,
  2950. matchesCount: this._requestMatchesCount()
  2951. });
  2952. }
  2953. _updateUIState(state, previous) {
  2954. this._eventBus.dispatch("updatefindcontrolstate", {
  2955. source: this,
  2956. state,
  2957. previous,
  2958. matchesCount: this._requestMatchesCount(),
  2959. rawQuery: this._state ? this._state.query : null
  2960. });
  2961. }
  2962. }
  2963. exports.PDFFindController = PDFFindController;
  2964. /***/ }),
  2965. /* 11 */
  2966. /***/ ((__unused_webpack_module, exports) => {
  2967. Object.defineProperty(exports, "__esModule", ({
  2968. value: true
  2969. }));
  2970. exports.getCharacterType = getCharacterType;
  2971. exports.CharacterType = void 0;
  2972. const CharacterType = {
  2973. SPACE: 0,
  2974. ALPHA_LETTER: 1,
  2975. PUNCT: 2,
  2976. HAN_LETTER: 3,
  2977. KATAKANA_LETTER: 4,
  2978. HIRAGANA_LETTER: 5,
  2979. HALFWIDTH_KATAKANA_LETTER: 6,
  2980. THAI_LETTER: 7
  2981. };
  2982. exports.CharacterType = CharacterType;
  2983. function isAlphabeticalScript(charCode) {
  2984. return charCode < 0x2e80;
  2985. }
  2986. function isAscii(charCode) {
  2987. return (charCode & 0xff80) === 0;
  2988. }
  2989. function isAsciiAlpha(charCode) {
  2990. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  2991. }
  2992. function isAsciiDigit(charCode) {
  2993. return charCode >= 0x30 && charCode <= 0x39;
  2994. }
  2995. function isAsciiSpace(charCode) {
  2996. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  2997. }
  2998. function isHan(charCode) {
  2999. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  3000. }
  3001. function isKatakana(charCode) {
  3002. return charCode >= 0x30a0 && charCode <= 0x30ff;
  3003. }
  3004. function isHiragana(charCode) {
  3005. return charCode >= 0x3040 && charCode <= 0x309f;
  3006. }
  3007. function isHalfwidthKatakana(charCode) {
  3008. return charCode >= 0xff60 && charCode <= 0xff9f;
  3009. }
  3010. function isThai(charCode) {
  3011. return (charCode & 0xff80) === 0x0e00;
  3012. }
  3013. function getCharacterType(charCode) {
  3014. if (isAlphabeticalScript(charCode)) {
  3015. if (isAscii(charCode)) {
  3016. if (isAsciiSpace(charCode)) {
  3017. return CharacterType.SPACE;
  3018. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  3019. return CharacterType.ALPHA_LETTER;
  3020. }
  3021. return CharacterType.PUNCT;
  3022. } else if (isThai(charCode)) {
  3023. return CharacterType.THAI_LETTER;
  3024. } else if (charCode === 0xa0) {
  3025. return CharacterType.SPACE;
  3026. }
  3027. return CharacterType.ALPHA_LETTER;
  3028. }
  3029. if (isHan(charCode)) {
  3030. return CharacterType.HAN_LETTER;
  3031. } else if (isKatakana(charCode)) {
  3032. return CharacterType.KATAKANA_LETTER;
  3033. } else if (isHiragana(charCode)) {
  3034. return CharacterType.HIRAGANA_LETTER;
  3035. } else if (isHalfwidthKatakana(charCode)) {
  3036. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  3037. }
  3038. return CharacterType.ALPHA_LETTER;
  3039. }
  3040. /***/ }),
  3041. /* 12 */
  3042. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3043. Object.defineProperty(exports, "__esModule", ({
  3044. value: true
  3045. }));
  3046. exports.isDestArraysEqual = isDestArraysEqual;
  3047. exports.isDestHashesEqual = isDestHashesEqual;
  3048. exports.PDFHistory = void 0;
  3049. var _ui_utils = __w_pdfjs_require__(3);
  3050. const HASH_CHANGE_TIMEOUT = 1000;
  3051. const POSITION_UPDATED_THRESHOLD = 50;
  3052. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  3053. function getCurrentHash() {
  3054. return document.location.hash;
  3055. }
  3056. class PDFHistory {
  3057. constructor({
  3058. linkService,
  3059. eventBus
  3060. }) {
  3061. this.linkService = linkService;
  3062. this.eventBus = eventBus;
  3063. this._initialized = false;
  3064. this._fingerprint = "";
  3065. this.reset();
  3066. this._boundEvents = null;
  3067. this._isViewerInPresentationMode = false;
  3068. this.eventBus._on("presentationmodechanged", evt => {
  3069. this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  3070. });
  3071. this.eventBus._on("pagesinit", () => {
  3072. this._isPagesLoaded = false;
  3073. this.eventBus._on("pagesloaded", evt => {
  3074. this._isPagesLoaded = !!evt.pagesCount;
  3075. }, {
  3076. once: true
  3077. });
  3078. });
  3079. }
  3080. initialize({
  3081. fingerprint,
  3082. resetHistory = false,
  3083. updateUrl = false
  3084. }) {
  3085. if (!fingerprint || typeof fingerprint !== "string") {
  3086. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  3087. return;
  3088. }
  3089. if (this._initialized) {
  3090. this.reset();
  3091. }
  3092. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  3093. this._fingerprint = fingerprint;
  3094. this._updateUrl = updateUrl === true;
  3095. this._initialized = true;
  3096. this._bindEvents();
  3097. const state = window.history.state;
  3098. this._popStateInProgress = false;
  3099. this._blockHashChange = 0;
  3100. this._currentHash = getCurrentHash();
  3101. this._numPositionUpdates = 0;
  3102. this._uid = this._maxUid = 0;
  3103. this._destination = null;
  3104. this._position = null;
  3105. if (!this._isValidState(state, true) || resetHistory) {
  3106. const {
  3107. hash,
  3108. page,
  3109. rotation
  3110. } = this._parseCurrentHash(true);
  3111. if (!hash || reInitialized || resetHistory) {
  3112. this._pushOrReplaceState(null, true);
  3113. return;
  3114. }
  3115. this._pushOrReplaceState({
  3116. hash,
  3117. page,
  3118. rotation
  3119. }, true);
  3120. return;
  3121. }
  3122. const destination = state.destination;
  3123. this._updateInternalState(destination, state.uid, true);
  3124. if (destination.rotation !== undefined) {
  3125. this._initialRotation = destination.rotation;
  3126. }
  3127. if (destination.dest) {
  3128. this._initialBookmark = JSON.stringify(destination.dest);
  3129. this._destination.page = null;
  3130. } else if (destination.hash) {
  3131. this._initialBookmark = destination.hash;
  3132. } else if (destination.page) {
  3133. this._initialBookmark = `page=${destination.page}`;
  3134. }
  3135. }
  3136. reset() {
  3137. if (this._initialized) {
  3138. this._pageHide();
  3139. this._initialized = false;
  3140. this._unbindEvents();
  3141. }
  3142. if (this._updateViewareaTimeout) {
  3143. clearTimeout(this._updateViewareaTimeout);
  3144. this._updateViewareaTimeout = null;
  3145. }
  3146. this._initialBookmark = null;
  3147. this._initialRotation = null;
  3148. }
  3149. push({
  3150. namedDest = null,
  3151. explicitDest,
  3152. pageNumber
  3153. }) {
  3154. if (!this._initialized) {
  3155. return;
  3156. }
  3157. if (namedDest && typeof namedDest !== "string") {
  3158. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  3159. return;
  3160. } else if (!Array.isArray(explicitDest)) {
  3161. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  3162. return;
  3163. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  3164. if (pageNumber !== null || this._destination) {
  3165. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  3166. return;
  3167. }
  3168. }
  3169. const hash = namedDest || JSON.stringify(explicitDest);
  3170. if (!hash) {
  3171. return;
  3172. }
  3173. let forceReplace = false;
  3174. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  3175. if (this._destination.page) {
  3176. return;
  3177. }
  3178. forceReplace = true;
  3179. }
  3180. if (this._popStateInProgress && !forceReplace) {
  3181. return;
  3182. }
  3183. this._pushOrReplaceState({
  3184. dest: explicitDest,
  3185. hash,
  3186. page: pageNumber,
  3187. rotation: this.linkService.rotation
  3188. }, forceReplace);
  3189. if (!this._popStateInProgress) {
  3190. this._popStateInProgress = true;
  3191. Promise.resolve().then(() => {
  3192. this._popStateInProgress = false;
  3193. });
  3194. }
  3195. }
  3196. pushPage(pageNumber) {
  3197. if (!this._initialized) {
  3198. return;
  3199. }
  3200. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  3201. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  3202. return;
  3203. }
  3204. if (this._destination?.page === pageNumber) {
  3205. return;
  3206. }
  3207. if (this._popStateInProgress) {
  3208. return;
  3209. }
  3210. this._pushOrReplaceState({
  3211. hash: `page=${pageNumber}`,
  3212. page: pageNumber,
  3213. rotation: this.linkService.rotation
  3214. });
  3215. if (!this._popStateInProgress) {
  3216. this._popStateInProgress = true;
  3217. Promise.resolve().then(() => {
  3218. this._popStateInProgress = false;
  3219. });
  3220. }
  3221. }
  3222. pushCurrentPosition() {
  3223. if (!this._initialized || this._popStateInProgress) {
  3224. return;
  3225. }
  3226. this._tryPushCurrentPosition();
  3227. }
  3228. back() {
  3229. if (!this._initialized || this._popStateInProgress) {
  3230. return;
  3231. }
  3232. const state = window.history.state;
  3233. if (this._isValidState(state) && state.uid > 0) {
  3234. window.history.back();
  3235. }
  3236. }
  3237. forward() {
  3238. if (!this._initialized || this._popStateInProgress) {
  3239. return;
  3240. }
  3241. const state = window.history.state;
  3242. if (this._isValidState(state) && state.uid < this._maxUid) {
  3243. window.history.forward();
  3244. }
  3245. }
  3246. get popStateInProgress() {
  3247. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  3248. }
  3249. get initialBookmark() {
  3250. return this._initialized ? this._initialBookmark : null;
  3251. }
  3252. get initialRotation() {
  3253. return this._initialized ? this._initialRotation : null;
  3254. }
  3255. _pushOrReplaceState(destination, forceReplace = false) {
  3256. const shouldReplace = forceReplace || !this._destination;
  3257. const newState = {
  3258. fingerprint: this._fingerprint,
  3259. uid: shouldReplace ? this._uid : this._uid + 1,
  3260. destination
  3261. };
  3262. this._updateInternalState(destination, newState.uid);
  3263. let newUrl;
  3264. if (this._updateUrl && destination?.hash) {
  3265. const baseUrl = document.location.href.split("#")[0];
  3266. if (!baseUrl.startsWith("file://")) {
  3267. newUrl = `${baseUrl}#${destination.hash}`;
  3268. }
  3269. }
  3270. if (shouldReplace) {
  3271. window.history.replaceState(newState, "", newUrl);
  3272. } else {
  3273. window.history.pushState(newState, "", newUrl);
  3274. }
  3275. }
  3276. _tryPushCurrentPosition(temporary = false) {
  3277. if (!this._position) {
  3278. return;
  3279. }
  3280. let position = this._position;
  3281. if (temporary) {
  3282. position = Object.assign(Object.create(null), this._position);
  3283. position.temporary = true;
  3284. }
  3285. if (!this._destination) {
  3286. this._pushOrReplaceState(position);
  3287. return;
  3288. }
  3289. if (this._destination.temporary) {
  3290. this._pushOrReplaceState(position, true);
  3291. return;
  3292. }
  3293. if (this._destination.hash === position.hash) {
  3294. return;
  3295. }
  3296. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  3297. return;
  3298. }
  3299. let forceReplace = false;
  3300. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  3301. if (this._destination.dest || !this._destination.first) {
  3302. return;
  3303. }
  3304. forceReplace = true;
  3305. }
  3306. this._pushOrReplaceState(position, forceReplace);
  3307. }
  3308. _isValidState(state, checkReload = false) {
  3309. if (!state) {
  3310. return false;
  3311. }
  3312. if (state.fingerprint !== this._fingerprint) {
  3313. if (checkReload) {
  3314. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  3315. return false;
  3316. }
  3317. const [perfEntry] = performance.getEntriesByType("navigation");
  3318. if (perfEntry?.type !== "reload") {
  3319. return false;
  3320. }
  3321. } else {
  3322. return false;
  3323. }
  3324. }
  3325. if (!Number.isInteger(state.uid) || state.uid < 0) {
  3326. return false;
  3327. }
  3328. if (state.destination === null || typeof state.destination !== "object") {
  3329. return false;
  3330. }
  3331. return true;
  3332. }
  3333. _updateInternalState(destination, uid, removeTemporary = false) {
  3334. if (this._updateViewareaTimeout) {
  3335. clearTimeout(this._updateViewareaTimeout);
  3336. this._updateViewareaTimeout = null;
  3337. }
  3338. if (removeTemporary && destination?.temporary) {
  3339. delete destination.temporary;
  3340. }
  3341. this._destination = destination;
  3342. this._uid = uid;
  3343. this._maxUid = Math.max(this._maxUid, uid);
  3344. this._numPositionUpdates = 0;
  3345. }
  3346. _parseCurrentHash(checkNameddest = false) {
  3347. const hash = unescape(getCurrentHash()).substring(1);
  3348. const params = (0, _ui_utils.parseQueryString)(hash);
  3349. const nameddest = params.nameddest || "";
  3350. let page = params.page | 0;
  3351. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  3352. page = null;
  3353. }
  3354. return {
  3355. hash,
  3356. page,
  3357. rotation: this.linkService.rotation
  3358. };
  3359. }
  3360. _updateViewarea({
  3361. location
  3362. }) {
  3363. if (this._updateViewareaTimeout) {
  3364. clearTimeout(this._updateViewareaTimeout);
  3365. this._updateViewareaTimeout = null;
  3366. }
  3367. this._position = {
  3368. hash: this._isViewerInPresentationMode ? `page=${location.pageNumber}` : location.pdfOpenParams.substring(1),
  3369. page: this.linkService.page,
  3370. first: location.pageNumber,
  3371. rotation: location.rotation
  3372. };
  3373. if (this._popStateInProgress) {
  3374. return;
  3375. }
  3376. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  3377. this._numPositionUpdates++;
  3378. }
  3379. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  3380. this._updateViewareaTimeout = setTimeout(() => {
  3381. if (!this._popStateInProgress) {
  3382. this._tryPushCurrentPosition(true);
  3383. }
  3384. this._updateViewareaTimeout = null;
  3385. }, UPDATE_VIEWAREA_TIMEOUT);
  3386. }
  3387. }
  3388. _popState({
  3389. state
  3390. }) {
  3391. const newHash = getCurrentHash(),
  3392. hashChanged = this._currentHash !== newHash;
  3393. this._currentHash = newHash;
  3394. if (!state) {
  3395. this._uid++;
  3396. const {
  3397. hash,
  3398. page,
  3399. rotation
  3400. } = this._parseCurrentHash();
  3401. this._pushOrReplaceState({
  3402. hash,
  3403. page,
  3404. rotation
  3405. }, true);
  3406. return;
  3407. }
  3408. if (!this._isValidState(state)) {
  3409. return;
  3410. }
  3411. this._popStateInProgress = true;
  3412. if (hashChanged) {
  3413. this._blockHashChange++;
  3414. (0, _ui_utils.waitOnEventOrTimeout)({
  3415. target: window,
  3416. name: "hashchange",
  3417. delay: HASH_CHANGE_TIMEOUT
  3418. }).then(() => {
  3419. this._blockHashChange--;
  3420. });
  3421. }
  3422. const destination = state.destination;
  3423. this._updateInternalState(destination, state.uid, true);
  3424. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  3425. this.linkService.rotation = destination.rotation;
  3426. }
  3427. if (destination.dest) {
  3428. this.linkService.goToDestination(destination.dest);
  3429. } else if (destination.hash) {
  3430. this.linkService.setHash(destination.hash);
  3431. } else if (destination.page) {
  3432. this.linkService.page = destination.page;
  3433. }
  3434. Promise.resolve().then(() => {
  3435. this._popStateInProgress = false;
  3436. });
  3437. }
  3438. _pageHide() {
  3439. if (!this._destination || this._destination.temporary) {
  3440. this._tryPushCurrentPosition();
  3441. }
  3442. }
  3443. _bindEvents() {
  3444. if (this._boundEvents) {
  3445. return;
  3446. }
  3447. this._boundEvents = {
  3448. updateViewarea: this._updateViewarea.bind(this),
  3449. popState: this._popState.bind(this),
  3450. pageHide: this._pageHide.bind(this)
  3451. };
  3452. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  3453. window.addEventListener("popstate", this._boundEvents.popState);
  3454. window.addEventListener("pagehide", this._boundEvents.pageHide);
  3455. }
  3456. _unbindEvents() {
  3457. if (!this._boundEvents) {
  3458. return;
  3459. }
  3460. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  3461. window.removeEventListener("popstate", this._boundEvents.popState);
  3462. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  3463. this._boundEvents = null;
  3464. }
  3465. }
  3466. exports.PDFHistory = PDFHistory;
  3467. function isDestHashesEqual(destHash, pushHash) {
  3468. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  3469. return false;
  3470. }
  3471. if (destHash === pushHash) {
  3472. return true;
  3473. }
  3474. const {
  3475. nameddest
  3476. } = (0, _ui_utils.parseQueryString)(destHash);
  3477. if (nameddest === pushHash) {
  3478. return true;
  3479. }
  3480. return false;
  3481. }
  3482. function isDestArraysEqual(firstDest, secondDest) {
  3483. function isEntryEqual(first, second) {
  3484. if (typeof first !== typeof second) {
  3485. return false;
  3486. }
  3487. if (Array.isArray(first) || Array.isArray(second)) {
  3488. return false;
  3489. }
  3490. if (first !== null && typeof first === "object" && second !== null) {
  3491. if (Object.keys(first).length !== Object.keys(second).length) {
  3492. return false;
  3493. }
  3494. for (const key in first) {
  3495. if (!isEntryEqual(first[key], second[key])) {
  3496. return false;
  3497. }
  3498. }
  3499. return true;
  3500. }
  3501. return first === second || Number.isNaN(first) && Number.isNaN(second);
  3502. }
  3503. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  3504. return false;
  3505. }
  3506. if (firstDest.length !== secondDest.length) {
  3507. return false;
  3508. }
  3509. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  3510. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  3511. return false;
  3512. }
  3513. }
  3514. return true;
  3515. }
  3516. /***/ }),
  3517. /* 13 */
  3518. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3519. Object.defineProperty(exports, "__esModule", ({
  3520. value: true
  3521. }));
  3522. exports.PDFPageView = void 0;
  3523. var _ui_utils = __w_pdfjs_require__(3);
  3524. var _pdfjsLib = __w_pdfjs_require__(2);
  3525. var _pdf_rendering_queue = __w_pdfjs_require__(14);
  3526. var _viewer_compatibility = __w_pdfjs_require__(7);
  3527. const MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  3528. class PDFPageView {
  3529. constructor(options) {
  3530. const container = options.container;
  3531. const defaultViewport = options.defaultViewport;
  3532. this.id = options.id;
  3533. this.renderingId = "page" + this.id;
  3534. this.pdfPage = null;
  3535. this.pageLabel = null;
  3536. this.rotation = 0;
  3537. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  3538. this.viewport = defaultViewport;
  3539. this.pdfPageRotate = defaultViewport.rotation;
  3540. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  3541. this.hasRestrictedScaling = false;
  3542. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  3543. this.imageResourcesPath = options.imageResourcesPath || "";
  3544. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  3545. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  3546. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  3547. this.eventBus = options.eventBus;
  3548. this.renderingQueue = options.renderingQueue;
  3549. this.textLayerFactory = options.textLayerFactory;
  3550. this.annotationLayerFactory = options.annotationLayerFactory;
  3551. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  3552. this.enableWebGL = options.enableWebGL || false;
  3553. this.l10n = options.l10n || _ui_utils.NullL10n;
  3554. this.enableScripting = options.enableScripting || false;
  3555. this.paintTask = null;
  3556. this.paintedViewportMap = new WeakMap();
  3557. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  3558. this.resume = null;
  3559. this._renderError = null;
  3560. this.annotationLayer = null;
  3561. this.textLayer = null;
  3562. this.zoomLayer = null;
  3563. const div = document.createElement("div");
  3564. div.className = "page";
  3565. div.style.width = Math.floor(this.viewport.width) + "px";
  3566. div.style.height = Math.floor(this.viewport.height) + "px";
  3567. div.setAttribute("data-page-number", this.id);
  3568. this.div = div;
  3569. container.appendChild(div);
  3570. }
  3571. setPdfPage(pdfPage) {
  3572. this.pdfPage = pdfPage;
  3573. this.pdfPageRotate = pdfPage.rotate;
  3574. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  3575. this.viewport = pdfPage.getViewport({
  3576. scale: this.scale * _ui_utils.CSS_UNITS,
  3577. rotation: totalRotation
  3578. });
  3579. this.reset();
  3580. }
  3581. destroy() {
  3582. this.reset();
  3583. if (this.pdfPage) {
  3584. this.pdfPage.cleanup();
  3585. }
  3586. }
  3587. async _renderAnnotationLayer() {
  3588. let error = null;
  3589. try {
  3590. await this.annotationLayer.render(this.viewport, "display");
  3591. } catch (ex) {
  3592. error = ex;
  3593. } finally {
  3594. this.eventBus.dispatch("annotationlayerrendered", {
  3595. source: this,
  3596. pageNumber: this.id,
  3597. error
  3598. });
  3599. }
  3600. }
  3601. _resetZoomLayer(removeFromDOM = false) {
  3602. if (!this.zoomLayer) {
  3603. return;
  3604. }
  3605. const zoomLayerCanvas = this.zoomLayer.firstChild;
  3606. this.paintedViewportMap.delete(zoomLayerCanvas);
  3607. zoomLayerCanvas.width = 0;
  3608. zoomLayerCanvas.height = 0;
  3609. if (removeFromDOM) {
  3610. this.zoomLayer.remove();
  3611. }
  3612. this.zoomLayer = null;
  3613. }
  3614. reset(keepZoomLayer = false, keepAnnotations = false) {
  3615. this.cancelRendering(keepAnnotations);
  3616. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  3617. const div = this.div;
  3618. div.style.width = Math.floor(this.viewport.width) + "px";
  3619. div.style.height = Math.floor(this.viewport.height) + "px";
  3620. const childNodes = div.childNodes;
  3621. const currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  3622. const currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  3623. for (let i = childNodes.length - 1; i >= 0; i--) {
  3624. const node = childNodes[i];
  3625. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  3626. continue;
  3627. }
  3628. div.removeChild(node);
  3629. }
  3630. div.removeAttribute("data-loaded");
  3631. if (currentAnnotationNode) {
  3632. this.annotationLayer.hide();
  3633. } else if (this.annotationLayer) {
  3634. this.annotationLayer.cancel();
  3635. this.annotationLayer = null;
  3636. }
  3637. if (!currentZoomLayerNode) {
  3638. if (this.canvas) {
  3639. this.paintedViewportMap.delete(this.canvas);
  3640. this.canvas.width = 0;
  3641. this.canvas.height = 0;
  3642. delete this.canvas;
  3643. }
  3644. this._resetZoomLayer();
  3645. }
  3646. if (this.svg) {
  3647. this.paintedViewportMap.delete(this.svg);
  3648. delete this.svg;
  3649. }
  3650. this.loadingIconDiv = document.createElement("div");
  3651. this.loadingIconDiv.className = "loadingIcon";
  3652. div.appendChild(this.loadingIconDiv);
  3653. }
  3654. update(scale, rotation, optionalContentConfigPromise = null) {
  3655. this.scale = scale || this.scale;
  3656. if (typeof rotation !== "undefined") {
  3657. this.rotation = rotation;
  3658. }
  3659. if (optionalContentConfigPromise instanceof Promise) {
  3660. this._optionalContentConfigPromise = optionalContentConfigPromise;
  3661. }
  3662. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  3663. this.viewport = this.viewport.clone({
  3664. scale: this.scale * _ui_utils.CSS_UNITS,
  3665. rotation: totalRotation
  3666. });
  3667. if (this.svg) {
  3668. this.cssTransform(this.svg, true);
  3669. this.eventBus.dispatch("pagerendered", {
  3670. source: this,
  3671. pageNumber: this.id,
  3672. cssTransform: true,
  3673. timestamp: performance.now(),
  3674. error: this._renderError
  3675. });
  3676. return;
  3677. }
  3678. let isScalingRestricted = false;
  3679. if (this.canvas && this.maxCanvasPixels > 0) {
  3680. const outputScale = this.outputScale;
  3681. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  3682. isScalingRestricted = true;
  3683. }
  3684. }
  3685. if (this.canvas) {
  3686. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  3687. this.cssTransform(this.canvas, true);
  3688. this.eventBus.dispatch("pagerendered", {
  3689. source: this,
  3690. pageNumber: this.id,
  3691. cssTransform: true,
  3692. timestamp: performance.now(),
  3693. error: this._renderError
  3694. });
  3695. return;
  3696. }
  3697. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  3698. this.zoomLayer = this.canvas.parentNode;
  3699. this.zoomLayer.style.position = "absolute";
  3700. }
  3701. }
  3702. if (this.zoomLayer) {
  3703. this.cssTransform(this.zoomLayer.firstChild);
  3704. }
  3705. this.reset(true, true);
  3706. }
  3707. cancelRendering(keepAnnotations = false) {
  3708. if (this.paintTask) {
  3709. this.paintTask.cancel();
  3710. this.paintTask = null;
  3711. }
  3712. this.resume = null;
  3713. if (this.textLayer) {
  3714. this.textLayer.cancel();
  3715. this.textLayer = null;
  3716. }
  3717. if (!keepAnnotations && this.annotationLayer) {
  3718. this.annotationLayer.cancel();
  3719. this.annotationLayer = null;
  3720. }
  3721. }
  3722. cssTransform(target, redrawAnnotations = false) {
  3723. const width = this.viewport.width;
  3724. const height = this.viewport.height;
  3725. const div = this.div;
  3726. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  3727. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  3728. const relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  3729. const absRotation = Math.abs(relativeRotation);
  3730. let scaleX = 1,
  3731. scaleY = 1;
  3732. if (absRotation === 90 || absRotation === 270) {
  3733. scaleX = height / width;
  3734. scaleY = width / height;
  3735. }
  3736. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  3737. if (this.textLayer) {
  3738. const textLayerViewport = this.textLayer.viewport;
  3739. const textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  3740. const textAbsRotation = Math.abs(textRelativeRotation);
  3741. let scale = width / textLayerViewport.width;
  3742. if (textAbsRotation === 90 || textAbsRotation === 270) {
  3743. scale = width / textLayerViewport.height;
  3744. }
  3745. const textLayerDiv = this.textLayer.textLayerDiv;
  3746. let transX, transY;
  3747. switch (textAbsRotation) {
  3748. case 0:
  3749. transX = transY = 0;
  3750. break;
  3751. case 90:
  3752. transX = 0;
  3753. transY = "-" + textLayerDiv.style.height;
  3754. break;
  3755. case 180:
  3756. transX = "-" + textLayerDiv.style.width;
  3757. transY = "-" + textLayerDiv.style.height;
  3758. break;
  3759. case 270:
  3760. transX = "-" + textLayerDiv.style.width;
  3761. transY = 0;
  3762. break;
  3763. default:
  3764. console.error("Bad rotation value.");
  3765. break;
  3766. }
  3767. textLayerDiv.style.transform = `rotate(${textAbsRotation}deg) ` + `scale(${scale}) ` + `translate(${transX}, ${transY})`;
  3768. textLayerDiv.style.transformOrigin = "0% 0%";
  3769. }
  3770. if (redrawAnnotations && this.annotationLayer) {
  3771. this._renderAnnotationLayer();
  3772. }
  3773. }
  3774. get width() {
  3775. return this.viewport.width;
  3776. }
  3777. get height() {
  3778. return this.viewport.height;
  3779. }
  3780. getPagePoint(x, y) {
  3781. return this.viewport.convertToPdfPoint(x, y);
  3782. }
  3783. draw() {
  3784. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  3785. console.error("Must be in new state before drawing");
  3786. this.reset();
  3787. }
  3788. const {
  3789. div,
  3790. pdfPage
  3791. } = this;
  3792. if (!pdfPage) {
  3793. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  3794. if (this.loadingIconDiv) {
  3795. div.removeChild(this.loadingIconDiv);
  3796. delete this.loadingIconDiv;
  3797. }
  3798. return Promise.reject(new Error("pdfPage is not loaded"));
  3799. }
  3800. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  3801. const canvasWrapper = document.createElement("div");
  3802. canvasWrapper.style.width = div.style.width;
  3803. canvasWrapper.style.height = div.style.height;
  3804. canvasWrapper.classList.add("canvasWrapper");
  3805. if (this.annotationLayer && this.annotationLayer.div) {
  3806. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  3807. } else {
  3808. div.appendChild(canvasWrapper);
  3809. }
  3810. let textLayer = null;
  3811. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  3812. const textLayerDiv = document.createElement("div");
  3813. textLayerDiv.className = "textLayer";
  3814. textLayerDiv.style.width = canvasWrapper.style.width;
  3815. textLayerDiv.style.height = canvasWrapper.style.height;
  3816. if (this.annotationLayer && this.annotationLayer.div) {
  3817. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  3818. } else {
  3819. div.appendChild(textLayerDiv);
  3820. }
  3821. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  3822. }
  3823. this.textLayer = textLayer;
  3824. let renderContinueCallback = null;
  3825. if (this.renderingQueue) {
  3826. renderContinueCallback = cont => {
  3827. if (!this.renderingQueue.isHighestPriority(this)) {
  3828. this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  3829. this.resume = () => {
  3830. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  3831. cont();
  3832. };
  3833. return;
  3834. }
  3835. cont();
  3836. };
  3837. }
  3838. const finishPaintTask = async (error = null) => {
  3839. if (paintTask === this.paintTask) {
  3840. this.paintTask = null;
  3841. }
  3842. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  3843. this._renderError = null;
  3844. return;
  3845. }
  3846. this._renderError = error;
  3847. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  3848. if (this.loadingIconDiv) {
  3849. div.removeChild(this.loadingIconDiv);
  3850. delete this.loadingIconDiv;
  3851. }
  3852. this._resetZoomLayer(true);
  3853. this.eventBus.dispatch("pagerendered", {
  3854. source: this,
  3855. pageNumber: this.id,
  3856. cssTransform: false,
  3857. timestamp: performance.now(),
  3858. error: this._renderError
  3859. });
  3860. if (error) {
  3861. throw error;
  3862. }
  3863. };
  3864. const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  3865. paintTask.onRenderContinue = renderContinueCallback;
  3866. this.paintTask = paintTask;
  3867. const resultPromise = paintTask.promise.then(function () {
  3868. return finishPaintTask(null).then(function () {
  3869. if (textLayer) {
  3870. const readableStream = pdfPage.streamTextContent({
  3871. normalizeWhitespace: true
  3872. });
  3873. textLayer.setTextContentStream(readableStream);
  3874. textLayer.render();
  3875. }
  3876. });
  3877. }, function (reason) {
  3878. return finishPaintTask(reason);
  3879. });
  3880. if (this.annotationLayerFactory) {
  3881. if (!this.annotationLayer) {
  3882. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
  3883. }
  3884. this._renderAnnotationLayer();
  3885. }
  3886. div.setAttribute("data-loaded", true);
  3887. this.eventBus.dispatch("pagerender", {
  3888. source: this,
  3889. pageNumber: this.id
  3890. });
  3891. return resultPromise;
  3892. }
  3893. paintOnCanvas(canvasWrapper) {
  3894. const renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  3895. const result = {
  3896. promise: renderCapability.promise,
  3897. onRenderContinue(cont) {
  3898. cont();
  3899. },
  3900. cancel() {
  3901. renderTask.cancel();
  3902. }
  3903. };
  3904. const viewport = this.viewport;
  3905. const canvas = document.createElement("canvas");
  3906. this.l10n.get("page_canvas", {
  3907. page: this.id
  3908. }, "Page {{page}}").then(msg => {
  3909. canvas.setAttribute("aria-label", msg);
  3910. });
  3911. canvas.setAttribute("hidden", "hidden");
  3912. let isCanvasHidden = true;
  3913. const showCanvas = function () {
  3914. if (isCanvasHidden) {
  3915. canvas.removeAttribute("hidden");
  3916. isCanvasHidden = false;
  3917. }
  3918. };
  3919. canvasWrapper.appendChild(canvas);
  3920. this.canvas = canvas;
  3921. canvas.mozOpaque = true;
  3922. const ctx = canvas.getContext("2d", {
  3923. alpha: false
  3924. });
  3925. const outputScale = (0, _ui_utils.getOutputScale)(ctx);
  3926. this.outputScale = outputScale;
  3927. if (this.useOnlyCssZoom) {
  3928. const actualSizeViewport = viewport.clone({
  3929. scale: _ui_utils.CSS_UNITS
  3930. });
  3931. outputScale.sx *= actualSizeViewport.width / viewport.width;
  3932. outputScale.sy *= actualSizeViewport.height / viewport.height;
  3933. outputScale.scaled = true;
  3934. }
  3935. if (this.maxCanvasPixels > 0) {
  3936. const pixelsInViewport = viewport.width * viewport.height;
  3937. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  3938. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  3939. outputScale.sx = maxScale;
  3940. outputScale.sy = maxScale;
  3941. outputScale.scaled = true;
  3942. this.hasRestrictedScaling = true;
  3943. } else {
  3944. this.hasRestrictedScaling = false;
  3945. }
  3946. }
  3947. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  3948. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  3949. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  3950. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  3951. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  3952. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  3953. this.paintedViewportMap.set(canvas, viewport);
  3954. const transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  3955. const renderContext = {
  3956. canvasContext: ctx,
  3957. transform,
  3958. viewport: this.viewport,
  3959. enableWebGL: this.enableWebGL,
  3960. renderInteractiveForms: this.renderInteractiveForms,
  3961. optionalContentConfigPromise: this._optionalContentConfigPromise
  3962. };
  3963. const renderTask = this.pdfPage.render(renderContext);
  3964. renderTask.onContinue = function (cont) {
  3965. showCanvas();
  3966. if (result.onRenderContinue) {
  3967. result.onRenderContinue(cont);
  3968. } else {
  3969. cont();
  3970. }
  3971. };
  3972. renderTask.promise.then(function () {
  3973. showCanvas();
  3974. renderCapability.resolve(undefined);
  3975. }, function (error) {
  3976. showCanvas();
  3977. renderCapability.reject(error);
  3978. });
  3979. return result;
  3980. }
  3981. paintOnSvg(wrapper) {
  3982. let cancelled = false;
  3983. const ensureNotCancelled = () => {
  3984. if (cancelled) {
  3985. throw new _pdfjsLib.RenderingCancelledException(`Rendering cancelled, page ${this.id}`, "svg");
  3986. }
  3987. };
  3988. const pdfPage = this.pdfPage;
  3989. const actualSizeViewport = this.viewport.clone({
  3990. scale: _ui_utils.CSS_UNITS
  3991. });
  3992. const promise = pdfPage.getOperatorList().then(opList => {
  3993. ensureNotCancelled();
  3994. const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  3995. return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
  3996. ensureNotCancelled();
  3997. this.svg = svg;
  3998. this.paintedViewportMap.set(svg, actualSizeViewport);
  3999. svg.style.width = wrapper.style.width;
  4000. svg.style.height = wrapper.style.height;
  4001. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4002. wrapper.appendChild(svg);
  4003. });
  4004. });
  4005. return {
  4006. promise,
  4007. onRenderContinue(cont) {
  4008. cont();
  4009. },
  4010. cancel() {
  4011. cancelled = true;
  4012. }
  4013. };
  4014. }
  4015. setPageLabel(label) {
  4016. this.pageLabel = typeof label === "string" ? label : null;
  4017. if (this.pageLabel !== null) {
  4018. this.div.setAttribute("data-page-label", this.pageLabel);
  4019. } else {
  4020. this.div.removeAttribute("data-page-label");
  4021. }
  4022. }
  4023. }
  4024. exports.PDFPageView = PDFPageView;
  4025. /***/ }),
  4026. /* 14 */
  4027. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4028. Object.defineProperty(exports, "__esModule", ({
  4029. value: true
  4030. }));
  4031. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  4032. var _pdfjsLib = __w_pdfjs_require__(2);
  4033. const CLEANUP_TIMEOUT = 30000;
  4034. const RenderingStates = {
  4035. INITIAL: 0,
  4036. RUNNING: 1,
  4037. PAUSED: 2,
  4038. FINISHED: 3
  4039. };
  4040. exports.RenderingStates = RenderingStates;
  4041. class PDFRenderingQueue {
  4042. constructor() {
  4043. this.pdfViewer = null;
  4044. this.pdfThumbnailViewer = null;
  4045. this.onIdle = null;
  4046. this.highestPriorityPage = null;
  4047. this.idleTimeout = null;
  4048. this.printing = false;
  4049. this.isThumbnailViewEnabled = false;
  4050. }
  4051. setViewer(pdfViewer) {
  4052. this.pdfViewer = pdfViewer;
  4053. }
  4054. setThumbnailViewer(pdfThumbnailViewer) {
  4055. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4056. }
  4057. isHighestPriority(view) {
  4058. return this.highestPriorityPage === view.renderingId;
  4059. }
  4060. renderHighestPriority(currentlyVisiblePages) {
  4061. if (this.idleTimeout) {
  4062. clearTimeout(this.idleTimeout);
  4063. this.idleTimeout = null;
  4064. }
  4065. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4066. return;
  4067. }
  4068. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4069. if (this.pdfThumbnailViewer.forceRendering()) {
  4070. return;
  4071. }
  4072. }
  4073. if (this.printing) {
  4074. return;
  4075. }
  4076. if (this.onIdle) {
  4077. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4078. }
  4079. }
  4080. getHighestPriority(visible, views, scrolledDown) {
  4081. const visibleViews = visible.views;
  4082. const numVisible = visibleViews.length;
  4083. if (numVisible === 0) {
  4084. return null;
  4085. }
  4086. for (let i = 0; i < numVisible; ++i) {
  4087. const view = visibleViews[i].view;
  4088. if (!this.isViewFinished(view)) {
  4089. return view;
  4090. }
  4091. }
  4092. if (scrolledDown) {
  4093. const nextPageIndex = visible.last.id;
  4094. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4095. return views[nextPageIndex];
  4096. }
  4097. } else {
  4098. const previousPageIndex = visible.first.id - 2;
  4099. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4100. return views[previousPageIndex];
  4101. }
  4102. }
  4103. return null;
  4104. }
  4105. isViewFinished(view) {
  4106. return view.renderingState === RenderingStates.FINISHED;
  4107. }
  4108. renderView(view) {
  4109. switch (view.renderingState) {
  4110. case RenderingStates.FINISHED:
  4111. return false;
  4112. case RenderingStates.PAUSED:
  4113. this.highestPriorityPage = view.renderingId;
  4114. view.resume();
  4115. break;
  4116. case RenderingStates.RUNNING:
  4117. this.highestPriorityPage = view.renderingId;
  4118. break;
  4119. case RenderingStates.INITIAL:
  4120. this.highestPriorityPage = view.renderingId;
  4121. view.draw().finally(() => {
  4122. this.renderHighestPriority();
  4123. }).catch(reason => {
  4124. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  4125. return;
  4126. }
  4127. console.error(`renderView: "${reason}"`);
  4128. });
  4129. break;
  4130. }
  4131. return true;
  4132. }
  4133. }
  4134. exports.PDFRenderingQueue = PDFRenderingQueue;
  4135. /***/ }),
  4136. /* 15 */
  4137. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4138. Object.defineProperty(exports, "__esModule", ({
  4139. value: true
  4140. }));
  4141. exports.PDFSinglePageViewer = void 0;
  4142. var _base_viewer = __w_pdfjs_require__(16);
  4143. var _pdfjsLib = __w_pdfjs_require__(2);
  4144. class PDFSinglePageViewer extends _base_viewer.BaseViewer {
  4145. constructor(options) {
  4146. super(options);
  4147. this.eventBus._on("pagesinit", evt => {
  4148. this._ensurePageViewVisible();
  4149. });
  4150. }
  4151. get _viewerElement() {
  4152. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  4153. }
  4154. get _pageWidthScaleFactor() {
  4155. return 1;
  4156. }
  4157. _resetView() {
  4158. super._resetView();
  4159. this._previousPageNumber = 1;
  4160. this._shadowViewer = document.createDocumentFragment();
  4161. this._updateScrollDown = null;
  4162. }
  4163. _ensurePageViewVisible() {
  4164. const pageView = this._pages[this._currentPageNumber - 1];
  4165. const previousPageView = this._pages[this._previousPageNumber - 1];
  4166. const viewerNodes = this.viewer.childNodes;
  4167. switch (viewerNodes.length) {
  4168. case 0:
  4169. this.viewer.appendChild(pageView.div);
  4170. break;
  4171. case 1:
  4172. if (viewerNodes[0] !== previousPageView.div) {
  4173. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  4174. }
  4175. if (pageView === previousPageView) {
  4176. break;
  4177. }
  4178. this._shadowViewer.appendChild(previousPageView.div);
  4179. this.viewer.appendChild(pageView.div);
  4180. this.container.scrollTop = 0;
  4181. break;
  4182. default:
  4183. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  4184. }
  4185. this._previousPageNumber = this._currentPageNumber;
  4186. }
  4187. _scrollUpdate() {
  4188. if (this._updateScrollDown) {
  4189. this._updateScrollDown();
  4190. }
  4191. super._scrollUpdate();
  4192. }
  4193. _scrollIntoView({
  4194. pageDiv,
  4195. pageSpot = null,
  4196. pageNumber = null
  4197. }) {
  4198. if (pageNumber) {
  4199. this._setCurrentPageNumber(pageNumber);
  4200. }
  4201. const scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  4202. this._ensurePageViewVisible();
  4203. this.update();
  4204. super._scrollIntoView({
  4205. pageDiv,
  4206. pageSpot,
  4207. pageNumber
  4208. });
  4209. this._updateScrollDown = () => {
  4210. this.scroll.down = scrolledDown;
  4211. this._updateScrollDown = null;
  4212. };
  4213. }
  4214. _getVisiblePages() {
  4215. return this._getCurrentVisiblePage();
  4216. }
  4217. _updateHelper(visiblePages) {}
  4218. get _isScrollModeHorizontal() {
  4219. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  4220. }
  4221. _updateScrollMode() {}
  4222. _updateSpreadMode() {}
  4223. _getPageAdvance() {
  4224. return 1;
  4225. }
  4226. }
  4227. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  4228. /***/ }),
  4229. /* 16 */
  4230. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4231. Object.defineProperty(exports, "__esModule", ({
  4232. value: true
  4233. }));
  4234. exports.BaseViewer = void 0;
  4235. var _pdfjsLib = __w_pdfjs_require__(2);
  4236. var _ui_utils = __w_pdfjs_require__(3);
  4237. var _pdf_rendering_queue = __w_pdfjs_require__(14);
  4238. var _annotation_layer_builder = __w_pdfjs_require__(1);
  4239. var _pdf_page_view = __w_pdfjs_require__(13);
  4240. var _pdf_link_service = __w_pdfjs_require__(4);
  4241. var _text_layer_builder = __w_pdfjs_require__(5);
  4242. const DEFAULT_CACHE_SIZE = 10;
  4243. function PDFPageViewBuffer(size) {
  4244. const data = [];
  4245. this.push = function (view) {
  4246. const i = data.indexOf(view);
  4247. if (i >= 0) {
  4248. data.splice(i, 1);
  4249. }
  4250. data.push(view);
  4251. if (data.length > size) {
  4252. data.shift().destroy();
  4253. }
  4254. };
  4255. this.resize = function (newSize, pagesToKeep) {
  4256. size = newSize;
  4257. if (pagesToKeep) {
  4258. const pageIdsToKeep = new Set();
  4259. for (let i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  4260. pageIdsToKeep.add(pagesToKeep[i].id);
  4261. }
  4262. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  4263. return pageIdsToKeep.has(page.id);
  4264. });
  4265. }
  4266. while (data.length > size) {
  4267. data.shift().destroy();
  4268. }
  4269. };
  4270. this.has = function (view) {
  4271. return data.includes(view);
  4272. };
  4273. }
  4274. function isSameScale(oldScale, newScale) {
  4275. if (newScale === oldScale) {
  4276. return true;
  4277. }
  4278. if (Math.abs(newScale - oldScale) < 1e-15) {
  4279. return true;
  4280. }
  4281. return false;
  4282. }
  4283. class BaseViewer {
  4284. constructor(options) {
  4285. if (this.constructor === BaseViewer) {
  4286. throw new Error("Cannot initialize BaseViewer.");
  4287. }
  4288. const viewerVersion = '2.7.570';
  4289. if (_pdfjsLib.version !== viewerVersion) {
  4290. throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
  4291. }
  4292. this._name = this.constructor.name;
  4293. this.container = options.container;
  4294. this.viewer = options.viewer || options.container.firstElementChild;
  4295. if (!(this.container?.tagName.toUpperCase() === "DIV" && this.viewer?.tagName.toUpperCase() === "DIV")) {
  4296. throw new Error("Invalid `container` and/or `viewer` option.");
  4297. }
  4298. if (getComputedStyle(this.container).position !== "absolute") {
  4299. throw new Error("The `container` must be absolutely positioned.");
  4300. }
  4301. this.eventBus = options.eventBus;
  4302. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  4303. this.downloadManager = options.downloadManager || null;
  4304. this.findController = options.findController || null;
  4305. this.removePageBorders = options.removePageBorders || false;
  4306. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4307. this.imageResourcesPath = options.imageResourcesPath || "";
  4308. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  4309. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  4310. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4311. this.enableWebGL = options.enableWebGL || false;
  4312. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4313. this.maxCanvasPixels = options.maxCanvasPixels;
  4314. this.l10n = options.l10n || _ui_utils.NullL10n;
  4315. this.enableScripting = options.enableScripting || false;
  4316. this._mouseState = options.mouseState || null;
  4317. this.defaultRenderingQueue = !options.renderingQueue;
  4318. if (this.defaultRenderingQueue) {
  4319. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  4320. this.renderingQueue.setViewer(this);
  4321. } else {
  4322. this.renderingQueue = options.renderingQueue;
  4323. }
  4324. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  4325. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  4326. this._onBeforeDraw = this._onAfterDraw = null;
  4327. this._resetView();
  4328. if (this.removePageBorders) {
  4329. this.viewer.classList.add("removePageBorders");
  4330. }
  4331. Promise.resolve().then(() => {
  4332. this.eventBus.dispatch("baseviewerinit", {
  4333. source: this
  4334. });
  4335. });
  4336. }
  4337. get pagesCount() {
  4338. return this._pages.length;
  4339. }
  4340. getPageView(index) {
  4341. return this._pages[index];
  4342. }
  4343. get pageViewsReady() {
  4344. if (!this._pagesCapability.settled) {
  4345. return false;
  4346. }
  4347. return this._pages.every(function (pageView) {
  4348. return pageView && pageView.pdfPage;
  4349. });
  4350. }
  4351. get currentPageNumber() {
  4352. return this._currentPageNumber;
  4353. }
  4354. set currentPageNumber(val) {
  4355. if (!Number.isInteger(val)) {
  4356. throw new Error("Invalid page number.");
  4357. }
  4358. if (!this.pdfDocument) {
  4359. return;
  4360. }
  4361. if (!this._setCurrentPageNumber(val, true)) {
  4362. console.error(`${this._name}.currentPageNumber: "${val}" is not a valid page.`);
  4363. }
  4364. }
  4365. _setCurrentPageNumber(val, resetCurrentPageView = false) {
  4366. if (this._currentPageNumber === val) {
  4367. if (resetCurrentPageView) {
  4368. this._resetCurrentPageView();
  4369. }
  4370. return true;
  4371. }
  4372. if (!(0 < val && val <= this.pagesCount)) {
  4373. return false;
  4374. }
  4375. const previous = this._currentPageNumber;
  4376. this._currentPageNumber = val;
  4377. this.eventBus.dispatch("pagechanging", {
  4378. source: this,
  4379. pageNumber: val,
  4380. pageLabel: this._pageLabels && this._pageLabels[val - 1],
  4381. previous
  4382. });
  4383. if (resetCurrentPageView) {
  4384. this._resetCurrentPageView();
  4385. }
  4386. return true;
  4387. }
  4388. get currentPageLabel() {
  4389. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  4390. }
  4391. set currentPageLabel(val) {
  4392. if (!this.pdfDocument) {
  4393. return;
  4394. }
  4395. let page = val | 0;
  4396. if (this._pageLabels) {
  4397. const i = this._pageLabels.indexOf(val);
  4398. if (i >= 0) {
  4399. page = i + 1;
  4400. }
  4401. }
  4402. if (!this._setCurrentPageNumber(page, true)) {
  4403. console.error(`${this._name}.currentPageLabel: "${val}" is not a valid page.`);
  4404. }
  4405. }
  4406. get currentScale() {
  4407. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  4408. }
  4409. set currentScale(val) {
  4410. if (isNaN(val)) {
  4411. throw new Error("Invalid numeric scale.");
  4412. }
  4413. if (!this.pdfDocument) {
  4414. return;
  4415. }
  4416. this._setScale(val, false);
  4417. }
  4418. get currentScaleValue() {
  4419. return this._currentScaleValue;
  4420. }
  4421. set currentScaleValue(val) {
  4422. if (!this.pdfDocument) {
  4423. return;
  4424. }
  4425. this._setScale(val, false);
  4426. }
  4427. get pagesRotation() {
  4428. return this._pagesRotation;
  4429. }
  4430. set pagesRotation(rotation) {
  4431. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  4432. throw new Error("Invalid pages rotation angle.");
  4433. }
  4434. if (!this.pdfDocument) {
  4435. return;
  4436. }
  4437. if (this._pagesRotation === rotation) {
  4438. return;
  4439. }
  4440. this._pagesRotation = rotation;
  4441. const pageNumber = this._currentPageNumber;
  4442. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4443. const pageView = this._pages[i];
  4444. pageView.update(pageView.scale, rotation);
  4445. }
  4446. if (this._currentScaleValue) {
  4447. this._setScale(this._currentScaleValue, true);
  4448. }
  4449. this.eventBus.dispatch("rotationchanging", {
  4450. source: this,
  4451. pagesRotation: rotation,
  4452. pageNumber
  4453. });
  4454. if (this.defaultRenderingQueue) {
  4455. this.update();
  4456. }
  4457. }
  4458. get firstPagePromise() {
  4459. return this.pdfDocument ? this._firstPageCapability.promise : null;
  4460. }
  4461. get onePageRendered() {
  4462. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  4463. }
  4464. get pagesPromise() {
  4465. return this.pdfDocument ? this._pagesCapability.promise : null;
  4466. }
  4467. get _viewerElement() {
  4468. throw new Error("Not implemented: _viewerElement");
  4469. }
  4470. _onePageRenderedOrForceFetch() {
  4471. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  4472. return Promise.resolve();
  4473. }
  4474. return this._onePageRenderedCapability.promise;
  4475. }
  4476. setDocument(pdfDocument) {
  4477. if (this.pdfDocument) {
  4478. this.eventBus.dispatch("pagesdestroy", {
  4479. source: this
  4480. });
  4481. this._cancelRendering();
  4482. this._resetView();
  4483. if (this.findController) {
  4484. this.findController.setDocument(null);
  4485. }
  4486. }
  4487. this.pdfDocument = pdfDocument;
  4488. if (!pdfDocument) {
  4489. return;
  4490. }
  4491. const pagesCount = pdfDocument.numPages;
  4492. const firstPagePromise = pdfDocument.getPage(1);
  4493. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  4494. this._pagesCapability.promise.then(() => {
  4495. this.eventBus.dispatch("pagesloaded", {
  4496. source: this,
  4497. pagesCount
  4498. });
  4499. });
  4500. this._onBeforeDraw = evt => {
  4501. const pageView = this._pages[evt.pageNumber - 1];
  4502. if (!pageView) {
  4503. return;
  4504. }
  4505. this._buffer.push(pageView);
  4506. };
  4507. this.eventBus._on("pagerender", this._onBeforeDraw);
  4508. this._onAfterDraw = evt => {
  4509. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  4510. return;
  4511. }
  4512. this._onePageRenderedCapability.resolve();
  4513. this.eventBus._off("pagerendered", this._onAfterDraw);
  4514. this._onAfterDraw = null;
  4515. };
  4516. this.eventBus._on("pagerendered", this._onAfterDraw);
  4517. firstPagePromise.then(firstPdfPage => {
  4518. this._firstPageCapability.resolve(firstPdfPage);
  4519. this._optionalContentConfigPromise = optionalContentConfigPromise;
  4520. const scale = this.currentScale;
  4521. const viewport = firstPdfPage.getViewport({
  4522. scale: scale * _ui_utils.CSS_UNITS
  4523. });
  4524. const textLayerFactory = this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? this : null;
  4525. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  4526. const pageView = new _pdf_page_view.PDFPageView({
  4527. container: this._viewerElement,
  4528. eventBus: this.eventBus,
  4529. id: pageNum,
  4530. scale,
  4531. defaultViewport: viewport.clone(),
  4532. optionalContentConfigPromise,
  4533. renderingQueue: this.renderingQueue,
  4534. textLayerFactory,
  4535. textLayerMode: this.textLayerMode,
  4536. annotationLayerFactory: this,
  4537. imageResourcesPath: this.imageResourcesPath,
  4538. renderInteractiveForms: this.renderInteractiveForms,
  4539. renderer: this.renderer,
  4540. enableWebGL: this.enableWebGL,
  4541. useOnlyCssZoom: this.useOnlyCssZoom,
  4542. maxCanvasPixels: this.maxCanvasPixels,
  4543. l10n: this.l10n,
  4544. enableScripting: this.enableScripting
  4545. });
  4546. this._pages.push(pageView);
  4547. }
  4548. const firstPageView = this._pages[0];
  4549. if (firstPageView) {
  4550. firstPageView.setPdfPage(firstPdfPage);
  4551. this.linkService.cachePageRef(1, firstPdfPage.ref);
  4552. }
  4553. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  4554. this._updateSpreadMode();
  4555. }
  4556. this._onePageRenderedOrForceFetch().then(() => {
  4557. if (this.findController) {
  4558. this.findController.setDocument(pdfDocument);
  4559. }
  4560. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  4561. this._pagesCapability.resolve();
  4562. return;
  4563. }
  4564. let getPagesLeft = pagesCount - 1;
  4565. if (getPagesLeft <= 0) {
  4566. this._pagesCapability.resolve();
  4567. return;
  4568. }
  4569. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  4570. pdfDocument.getPage(pageNum).then(pdfPage => {
  4571. const pageView = this._pages[pageNum - 1];
  4572. if (!pageView.pdfPage) {
  4573. pageView.setPdfPage(pdfPage);
  4574. }
  4575. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  4576. if (--getPagesLeft === 0) {
  4577. this._pagesCapability.resolve();
  4578. }
  4579. }, reason => {
  4580. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  4581. if (--getPagesLeft === 0) {
  4582. this._pagesCapability.resolve();
  4583. }
  4584. });
  4585. }
  4586. });
  4587. this.eventBus.dispatch("pagesinit", {
  4588. source: this
  4589. });
  4590. if (this.defaultRenderingQueue) {
  4591. this.update();
  4592. }
  4593. }).catch(reason => {
  4594. console.error("Unable to initialize viewer", reason);
  4595. });
  4596. }
  4597. setPageLabels(labels) {
  4598. if (!this.pdfDocument) {
  4599. return;
  4600. }
  4601. if (!labels) {
  4602. this._pageLabels = null;
  4603. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  4604. this._pageLabels = null;
  4605. console.error(`${this._name}.setPageLabels: Invalid page labels.`);
  4606. } else {
  4607. this._pageLabels = labels;
  4608. }
  4609. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4610. const pageView = this._pages[i];
  4611. const label = this._pageLabels && this._pageLabels[i];
  4612. pageView.setPageLabel(label);
  4613. }
  4614. }
  4615. _resetView() {
  4616. this._pages = [];
  4617. this._currentPageNumber = 1;
  4618. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  4619. this._currentScaleValue = null;
  4620. this._pageLabels = null;
  4621. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  4622. this._location = null;
  4623. this._pagesRotation = 0;
  4624. this._optionalContentConfigPromise = null;
  4625. this._pagesRequests = new WeakMap();
  4626. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  4627. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4628. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  4629. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  4630. this._spreadMode = _ui_utils.SpreadMode.NONE;
  4631. if (this._onBeforeDraw) {
  4632. this.eventBus._off("pagerender", this._onBeforeDraw);
  4633. this._onBeforeDraw = null;
  4634. }
  4635. if (this._onAfterDraw) {
  4636. this.eventBus._off("pagerendered", this._onAfterDraw);
  4637. this._onAfterDraw = null;
  4638. }
  4639. this._resetScriptingEvents();
  4640. this.viewer.textContent = "";
  4641. this._updateScrollMode();
  4642. }
  4643. _scrollUpdate() {
  4644. if (this.pagesCount === 0) {
  4645. return;
  4646. }
  4647. this.update();
  4648. }
  4649. _scrollIntoView({
  4650. pageDiv,
  4651. pageSpot = null,
  4652. pageNumber = null
  4653. }) {
  4654. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4655. }
  4656. _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
  4657. this._currentScaleValue = newValue.toString();
  4658. if (isSameScale(this._currentScale, newScale)) {
  4659. if (preset) {
  4660. this.eventBus.dispatch("scalechanging", {
  4661. source: this,
  4662. scale: newScale,
  4663. presetValue: newValue
  4664. });
  4665. }
  4666. return;
  4667. }
  4668. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4669. this._pages[i].update(newScale);
  4670. }
  4671. this._currentScale = newScale;
  4672. if (!noScroll) {
  4673. let page = this._currentPageNumber,
  4674. dest;
  4675. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  4676. page = this._location.pageNumber;
  4677. dest = [null, {
  4678. name: "XYZ"
  4679. }, this._location.left, this._location.top, null];
  4680. }
  4681. this.scrollPageIntoView({
  4682. pageNumber: page,
  4683. destArray: dest,
  4684. allowNegativeOffset: true
  4685. });
  4686. }
  4687. this.eventBus.dispatch("scalechanging", {
  4688. source: this,
  4689. scale: newScale,
  4690. presetValue: preset ? newValue : undefined
  4691. });
  4692. if (this.defaultRenderingQueue) {
  4693. this.update();
  4694. }
  4695. }
  4696. get _pageWidthScaleFactor() {
  4697. if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  4698. return 2;
  4699. }
  4700. return 1;
  4701. }
  4702. _setScale(value, noScroll = false) {
  4703. let scale = parseFloat(value);
  4704. if (scale > 0) {
  4705. this._setScaleUpdatePages(scale, value, noScroll, false);
  4706. } else {
  4707. const currentPage = this._pages[this._currentPageNumber - 1];
  4708. if (!currentPage) {
  4709. return;
  4710. }
  4711. const noPadding = this.isInPresentationMode || this.removePageBorders;
  4712. let hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  4713. let vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  4714. if (!noPadding && this._isScrollModeHorizontal) {
  4715. [hPadding, vPadding] = [vPadding, hPadding];
  4716. }
  4717. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  4718. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  4719. switch (value) {
  4720. case "page-actual":
  4721. scale = 1;
  4722. break;
  4723. case "page-width":
  4724. scale = pageWidthScale;
  4725. break;
  4726. case "page-height":
  4727. scale = pageHeightScale;
  4728. break;
  4729. case "page-fit":
  4730. scale = Math.min(pageWidthScale, pageHeightScale);
  4731. break;
  4732. case "auto":
  4733. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  4734. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  4735. break;
  4736. default:
  4737. console.error(`${this._name}._setScale: "${value}" is an unknown zoom value.`);
  4738. return;
  4739. }
  4740. this._setScaleUpdatePages(scale, value, noScroll, true);
  4741. }
  4742. }
  4743. _resetCurrentPageView() {
  4744. if (this.isInPresentationMode) {
  4745. this._setScale(this._currentScaleValue, true);
  4746. }
  4747. const pageView = this._pages[this._currentPageNumber - 1];
  4748. this._scrollIntoView({
  4749. pageDiv: pageView.div
  4750. });
  4751. }
  4752. pageLabelToPageNumber(label) {
  4753. if (!this._pageLabels) {
  4754. return null;
  4755. }
  4756. const i = this._pageLabels.indexOf(label);
  4757. if (i < 0) {
  4758. return null;
  4759. }
  4760. return i + 1;
  4761. }
  4762. scrollPageIntoView({
  4763. pageNumber,
  4764. destArray = null,
  4765. allowNegativeOffset = false,
  4766. ignoreDestinationZoom = false
  4767. }) {
  4768. if (!this.pdfDocument) {
  4769. return;
  4770. }
  4771. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  4772. if (!pageView) {
  4773. console.error(`${this._name}.scrollPageIntoView: ` + `"${pageNumber}" is not a valid pageNumber parameter.`);
  4774. return;
  4775. }
  4776. if (this.isInPresentationMode || !destArray) {
  4777. this._setCurrentPageNumber(pageNumber, true);
  4778. return;
  4779. }
  4780. let x = 0,
  4781. y = 0;
  4782. let width = 0,
  4783. height = 0,
  4784. widthScale,
  4785. heightScale;
  4786. const changeOrientation = pageView.rotation % 180 !== 0;
  4787. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  4788. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  4789. let scale = 0;
  4790. switch (destArray[1].name) {
  4791. case "XYZ":
  4792. x = destArray[2];
  4793. y = destArray[3];
  4794. scale = destArray[4];
  4795. x = x !== null ? x : 0;
  4796. y = y !== null ? y : pageHeight;
  4797. break;
  4798. case "Fit":
  4799. case "FitB":
  4800. scale = "page-fit";
  4801. break;
  4802. case "FitH":
  4803. case "FitBH":
  4804. y = destArray[2];
  4805. scale = "page-width";
  4806. if (y === null && this._location) {
  4807. x = this._location.left;
  4808. y = this._location.top;
  4809. } else if (typeof y !== "number") {
  4810. y = pageHeight;
  4811. }
  4812. break;
  4813. case "FitV":
  4814. case "FitBV":
  4815. x = destArray[2];
  4816. width = pageWidth;
  4817. height = pageHeight;
  4818. scale = "page-height";
  4819. break;
  4820. case "FitR":
  4821. x = destArray[2];
  4822. y = destArray[3];
  4823. width = destArray[4] - x;
  4824. height = destArray[5] - y;
  4825. const hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  4826. const vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  4827. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  4828. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  4829. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  4830. break;
  4831. default:
  4832. console.error(`${this._name}.scrollPageIntoView: ` + `"${destArray[1].name}" is not a valid destination type.`);
  4833. return;
  4834. }
  4835. if (!ignoreDestinationZoom) {
  4836. if (scale && scale !== this._currentScale) {
  4837. this.currentScaleValue = scale;
  4838. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  4839. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  4840. }
  4841. }
  4842. if (scale === "page-fit" && !destArray[4]) {
  4843. this._scrollIntoView({
  4844. pageDiv: pageView.div,
  4845. pageNumber
  4846. });
  4847. return;
  4848. }
  4849. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  4850. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  4851. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  4852. if (!allowNegativeOffset) {
  4853. left = Math.max(left, 0);
  4854. top = Math.max(top, 0);
  4855. }
  4856. this._scrollIntoView({
  4857. pageDiv: pageView.div,
  4858. pageSpot: {
  4859. left,
  4860. top
  4861. },
  4862. pageNumber
  4863. });
  4864. }
  4865. _updateLocation(firstPage) {
  4866. const currentScale = this._currentScale;
  4867. const currentScaleValue = this._currentScaleValue;
  4868. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  4869. const pageNumber = firstPage.id;
  4870. let pdfOpenParams = "#page=" + pageNumber;
  4871. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  4872. const currentPageView = this._pages[pageNumber - 1];
  4873. const container = this.container;
  4874. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  4875. const intLeft = Math.round(topLeft[0]);
  4876. const intTop = Math.round(topLeft[1]);
  4877. pdfOpenParams += "," + intLeft + "," + intTop;
  4878. this._location = {
  4879. pageNumber,
  4880. scale: normalizedScaleValue,
  4881. top: intTop,
  4882. left: intLeft,
  4883. rotation: this._pagesRotation,
  4884. pdfOpenParams
  4885. };
  4886. }
  4887. _updateHelper(visiblePages) {
  4888. throw new Error("Not implemented: _updateHelper");
  4889. }
  4890. update() {
  4891. const visible = this._getVisiblePages();
  4892. const visiblePages = visible.views,
  4893. numVisiblePages = visiblePages.length;
  4894. if (numVisiblePages === 0) {
  4895. return;
  4896. }
  4897. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  4898. this._buffer.resize(newCacheSize, visiblePages);
  4899. this.renderingQueue.renderHighestPriority(visible);
  4900. this._updateHelper(visiblePages);
  4901. this._updateLocation(visible.first);
  4902. this.eventBus.dispatch("updateviewarea", {
  4903. source: this,
  4904. location: this._location
  4905. });
  4906. }
  4907. containsElement(element) {
  4908. return this.container.contains(element);
  4909. }
  4910. focus() {
  4911. this.container.focus();
  4912. }
  4913. get _isScrollModeHorizontal() {
  4914. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  4915. }
  4916. get _isContainerRtl() {
  4917. return getComputedStyle(this.container).direction === "rtl";
  4918. }
  4919. get isInPresentationMode() {
  4920. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  4921. }
  4922. get isChangingPresentationMode() {
  4923. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  4924. }
  4925. get isHorizontalScrollbarEnabled() {
  4926. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  4927. }
  4928. get isVerticalScrollbarEnabled() {
  4929. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  4930. }
  4931. _getCurrentVisiblePage() {
  4932. if (!this.pagesCount) {
  4933. return {
  4934. views: []
  4935. };
  4936. }
  4937. const pageView = this._pages[this._currentPageNumber - 1];
  4938. const element = pageView.div;
  4939. const view = {
  4940. id: pageView.id,
  4941. x: element.offsetLeft + element.clientLeft,
  4942. y: element.offsetTop + element.clientTop,
  4943. view: pageView
  4944. };
  4945. return {
  4946. first: view,
  4947. last: view,
  4948. views: [view]
  4949. };
  4950. }
  4951. _getVisiblePages() {
  4952. return (0, _ui_utils.getVisibleElements)({
  4953. scrollEl: this.container,
  4954. views: this._pages,
  4955. sortByVisibility: true,
  4956. horizontal: this._isScrollModeHorizontal,
  4957. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  4958. });
  4959. }
  4960. isPageVisible(pageNumber) {
  4961. if (!this.pdfDocument) {
  4962. return false;
  4963. }
  4964. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  4965. console.error(`${this._name}.isPageVisible: "${pageNumber}" is not a valid page.`);
  4966. return false;
  4967. }
  4968. return this._getVisiblePages().views.some(function (view) {
  4969. return view.id === pageNumber;
  4970. });
  4971. }
  4972. isPageCached(pageNumber) {
  4973. if (!this.pdfDocument || !this._buffer) {
  4974. return false;
  4975. }
  4976. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  4977. console.error(`${this._name}.isPageCached: "${pageNumber}" is not a valid page.`);
  4978. return false;
  4979. }
  4980. const pageView = this._pages[pageNumber - 1];
  4981. if (!pageView) {
  4982. return false;
  4983. }
  4984. return this._buffer.has(pageView);
  4985. }
  4986. cleanup() {
  4987. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4988. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  4989. this._pages[i].reset();
  4990. }
  4991. }
  4992. }
  4993. _cancelRendering() {
  4994. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4995. if (this._pages[i]) {
  4996. this._pages[i].cancelRendering();
  4997. }
  4998. }
  4999. }
  5000. _ensurePdfPageLoaded(pageView) {
  5001. if (pageView.pdfPage) {
  5002. return Promise.resolve(pageView.pdfPage);
  5003. }
  5004. if (this._pagesRequests.has(pageView)) {
  5005. return this._pagesRequests.get(pageView);
  5006. }
  5007. const promise = this.pdfDocument.getPage(pageView.id).then(pdfPage => {
  5008. if (!pageView.pdfPage) {
  5009. pageView.setPdfPage(pdfPage);
  5010. }
  5011. this._pagesRequests.delete(pageView);
  5012. return pdfPage;
  5013. }).catch(reason => {
  5014. console.error("Unable to get page for page view", reason);
  5015. this._pagesRequests.delete(pageView);
  5016. });
  5017. this._pagesRequests.set(pageView, promise);
  5018. return promise;
  5019. }
  5020. forceRendering(currentlyVisiblePages) {
  5021. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  5022. const scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  5023. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  5024. if (pageView) {
  5025. this._ensurePdfPageLoaded(pageView).then(() => {
  5026. this.renderingQueue.renderView(pageView);
  5027. });
  5028. return true;
  5029. }
  5030. return false;
  5031. }
  5032. createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
  5033. return new _text_layer_builder.TextLayerBuilder({
  5034. textLayerDiv,
  5035. eventBus,
  5036. pageIndex,
  5037. viewport,
  5038. findController: this.isInPresentationMode ? null : this.findController,
  5039. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  5040. });
  5041. }
  5042. createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _ui_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
  5043. return new _annotation_layer_builder.AnnotationLayerBuilder({
  5044. pageDiv,
  5045. pdfPage,
  5046. annotationStorage: annotationStorage || this.pdfDocument?.annotationStorage,
  5047. imageResourcesPath,
  5048. renderInteractiveForms,
  5049. linkService: this.linkService,
  5050. downloadManager: this.downloadManager,
  5051. l10n,
  5052. enableScripting,
  5053. hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
  5054. mouseState: mouseState || this._mouseState
  5055. });
  5056. }
  5057. get hasEqualPageSizes() {
  5058. const firstPageView = this._pages[0];
  5059. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  5060. const pageView = this._pages[i];
  5061. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  5062. return false;
  5063. }
  5064. }
  5065. return true;
  5066. }
  5067. getPagesOverview() {
  5068. const pagesOverview = this._pages.map(function (pageView) {
  5069. const viewport = pageView.pdfPage.getViewport({
  5070. scale: 1
  5071. });
  5072. return {
  5073. width: viewport.width,
  5074. height: viewport.height,
  5075. rotation: viewport.rotation
  5076. };
  5077. });
  5078. if (!this.enablePrintAutoRotate) {
  5079. return pagesOverview;
  5080. }
  5081. return pagesOverview.map(function (size) {
  5082. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  5083. return size;
  5084. }
  5085. return {
  5086. width: size.height,
  5087. height: size.width,
  5088. rotation: (size.rotation + 90) % 360
  5089. };
  5090. });
  5091. }
  5092. get optionalContentConfigPromise() {
  5093. if (!this.pdfDocument) {
  5094. return Promise.resolve(null);
  5095. }
  5096. if (!this._optionalContentConfigPromise) {
  5097. return this.pdfDocument.getOptionalContentConfig();
  5098. }
  5099. return this._optionalContentConfigPromise;
  5100. }
  5101. set optionalContentConfigPromise(promise) {
  5102. if (!(promise instanceof Promise)) {
  5103. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  5104. }
  5105. if (!this.pdfDocument) {
  5106. return;
  5107. }
  5108. if (!this._optionalContentConfigPromise) {
  5109. return;
  5110. }
  5111. this._optionalContentConfigPromise = promise;
  5112. for (const pageView of this._pages) {
  5113. pageView.update(pageView.scale, pageView.rotation, promise);
  5114. }
  5115. this.update();
  5116. this.eventBus.dispatch("optionalcontentconfigchanged", {
  5117. source: this,
  5118. promise
  5119. });
  5120. }
  5121. get scrollMode() {
  5122. return this._scrollMode;
  5123. }
  5124. set scrollMode(mode) {
  5125. if (this._scrollMode === mode) {
  5126. return;
  5127. }
  5128. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  5129. throw new Error(`Invalid scroll mode: ${mode}`);
  5130. }
  5131. this._scrollMode = mode;
  5132. this.eventBus.dispatch("scrollmodechanged", {
  5133. source: this,
  5134. mode
  5135. });
  5136. this._updateScrollMode(this._currentPageNumber);
  5137. }
  5138. _updateScrollMode(pageNumber = null) {
  5139. const scrollMode = this._scrollMode,
  5140. viewer = this.viewer;
  5141. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  5142. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  5143. if (!this.pdfDocument || !pageNumber) {
  5144. return;
  5145. }
  5146. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  5147. this._setScale(this._currentScaleValue, true);
  5148. }
  5149. this._setCurrentPageNumber(pageNumber, true);
  5150. this.update();
  5151. }
  5152. get spreadMode() {
  5153. return this._spreadMode;
  5154. }
  5155. set spreadMode(mode) {
  5156. if (this._spreadMode === mode) {
  5157. return;
  5158. }
  5159. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  5160. throw new Error(`Invalid spread mode: ${mode}`);
  5161. }
  5162. this._spreadMode = mode;
  5163. this.eventBus.dispatch("spreadmodechanged", {
  5164. source: this,
  5165. mode
  5166. });
  5167. this._updateSpreadMode(this._currentPageNumber);
  5168. }
  5169. _updateSpreadMode(pageNumber = null) {
  5170. if (!this.pdfDocument) {
  5171. return;
  5172. }
  5173. const viewer = this.viewer,
  5174. pages = this._pages;
  5175. viewer.textContent = "";
  5176. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  5177. for (let i = 0, iMax = pages.length; i < iMax; ++i) {
  5178. viewer.appendChild(pages[i].div);
  5179. }
  5180. } else {
  5181. const parity = this._spreadMode - 1;
  5182. let spread = null;
  5183. for (let i = 0, iMax = pages.length; i < iMax; ++i) {
  5184. if (spread === null) {
  5185. spread = document.createElement("div");
  5186. spread.className = "spread";
  5187. viewer.appendChild(spread);
  5188. } else if (i % 2 === parity) {
  5189. spread = spread.cloneNode(false);
  5190. viewer.appendChild(spread);
  5191. }
  5192. spread.appendChild(pages[i].div);
  5193. }
  5194. }
  5195. if (!pageNumber) {
  5196. return;
  5197. }
  5198. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  5199. this._setScale(this._currentScaleValue, true);
  5200. }
  5201. this._setCurrentPageNumber(pageNumber, true);
  5202. this.update();
  5203. }
  5204. _getPageAdvance(currentPageNumber, previous = false) {
  5205. if (this.isInPresentationMode) {
  5206. return 1;
  5207. }
  5208. switch (this._scrollMode) {
  5209. case _ui_utils.ScrollMode.WRAPPED:
  5210. {
  5211. const {
  5212. views
  5213. } = this._getVisiblePages(),
  5214. pageLayout = new Map();
  5215. for (const {
  5216. id,
  5217. y,
  5218. percent,
  5219. widthPercent
  5220. } of views) {
  5221. if (percent === 0 || widthPercent < 100) {
  5222. continue;
  5223. }
  5224. let yArray = pageLayout.get(y);
  5225. if (!yArray) {
  5226. pageLayout.set(y, yArray || (yArray = []));
  5227. }
  5228. yArray.push(id);
  5229. }
  5230. for (const yArray of pageLayout.values()) {
  5231. const currentIndex = yArray.indexOf(currentPageNumber);
  5232. if (currentIndex === -1) {
  5233. continue;
  5234. }
  5235. const numPages = yArray.length;
  5236. if (numPages === 1) {
  5237. break;
  5238. }
  5239. if (previous) {
  5240. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  5241. const currentId = yArray[i],
  5242. expectedId = yArray[i + 1] - 1;
  5243. if (currentId < expectedId) {
  5244. return currentPageNumber - expectedId;
  5245. }
  5246. }
  5247. } else {
  5248. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  5249. const currentId = yArray[i],
  5250. expectedId = yArray[i - 1] + 1;
  5251. if (currentId > expectedId) {
  5252. return expectedId - currentPageNumber;
  5253. }
  5254. }
  5255. }
  5256. if (previous) {
  5257. const firstId = yArray[0];
  5258. if (firstId < currentPageNumber) {
  5259. return currentPageNumber - firstId + 1;
  5260. }
  5261. } else {
  5262. const lastId = yArray[numPages - 1];
  5263. if (lastId > currentPageNumber) {
  5264. return lastId - currentPageNumber + 1;
  5265. }
  5266. }
  5267. break;
  5268. }
  5269. break;
  5270. }
  5271. case _ui_utils.ScrollMode.HORIZONTAL:
  5272. {
  5273. break;
  5274. }
  5275. case _ui_utils.ScrollMode.VERTICAL:
  5276. {
  5277. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  5278. break;
  5279. }
  5280. const parity = this._spreadMode - 1;
  5281. if (previous && currentPageNumber % 2 !== parity) {
  5282. break;
  5283. } else if (!previous && currentPageNumber % 2 === parity) {
  5284. break;
  5285. }
  5286. const {
  5287. views
  5288. } = this._getVisiblePages(),
  5289. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  5290. for (const {
  5291. id,
  5292. percent,
  5293. widthPercent
  5294. } of views) {
  5295. if (id !== expectedId) {
  5296. continue;
  5297. }
  5298. if (percent > 0 && widthPercent === 100) {
  5299. return 2;
  5300. }
  5301. break;
  5302. }
  5303. break;
  5304. }
  5305. }
  5306. return 1;
  5307. }
  5308. nextPage() {
  5309. const currentPageNumber = this._currentPageNumber,
  5310. pagesCount = this.pagesCount;
  5311. if (currentPageNumber >= pagesCount) {
  5312. return false;
  5313. }
  5314. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  5315. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  5316. return true;
  5317. }
  5318. previousPage() {
  5319. const currentPageNumber = this._currentPageNumber;
  5320. if (currentPageNumber <= 1) {
  5321. return false;
  5322. }
  5323. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  5324. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  5325. return true;
  5326. }
  5327. initializeScriptingEvents() {
  5328. if (!this.enableScripting || this._pageOpenPendingSet) {
  5329. return;
  5330. }
  5331. const eventBus = this.eventBus,
  5332. pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
  5333. scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
  5334. const dispatchPageClose = pageNumber => {
  5335. if (pageOpenPendingSet.has(pageNumber)) {
  5336. return;
  5337. }
  5338. eventBus.dispatch("pageclose", {
  5339. source: this,
  5340. pageNumber
  5341. });
  5342. };
  5343. const dispatchPageOpen = pageNumber => {
  5344. const pageView = this._pages[pageNumber - 1];
  5345. if (pageView?.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  5346. pageOpenPendingSet.delete(pageNumber);
  5347. eventBus.dispatch("pageopen", {
  5348. source: this,
  5349. pageNumber,
  5350. actionsPromise: pageView.pdfPage?.getJSActions()
  5351. });
  5352. } else {
  5353. pageOpenPendingSet.add(pageNumber);
  5354. }
  5355. };
  5356. scriptingEvents.onPageChanging = ({
  5357. pageNumber,
  5358. previous
  5359. }) => {
  5360. if (pageNumber === previous) {
  5361. return;
  5362. }
  5363. dispatchPageClose(previous);
  5364. dispatchPageOpen(pageNumber);
  5365. };
  5366. eventBus._on("pagechanging", scriptingEvents.onPageChanging);
  5367. scriptingEvents.onPageRendered = ({
  5368. pageNumber
  5369. }) => {
  5370. if (!pageOpenPendingSet.has(pageNumber)) {
  5371. return;
  5372. }
  5373. if (pageNumber !== this._currentPageNumber) {
  5374. return;
  5375. }
  5376. dispatchPageOpen(pageNumber);
  5377. };
  5378. eventBus._on("pagerendered", scriptingEvents.onPageRendered);
  5379. scriptingEvents.onPagesDestroy = () => {
  5380. dispatchPageClose(this._currentPageNumber);
  5381. };
  5382. eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
  5383. dispatchPageOpen(this._currentPageNumber);
  5384. }
  5385. _resetScriptingEvents() {
  5386. if (!this.enableScripting || !this._pageOpenPendingSet) {
  5387. return;
  5388. }
  5389. const eventBus = this.eventBus,
  5390. scriptingEvents = this._scriptingEvents;
  5391. eventBus._off("pagechanging", scriptingEvents.onPageChanging);
  5392. scriptingEvents.onPageChanging = null;
  5393. eventBus._off("pagerendered", scriptingEvents.onPageRendered);
  5394. scriptingEvents.onPageRendered = null;
  5395. eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
  5396. scriptingEvents.onPagesDestroy = null;
  5397. this._pageOpenPendingSet = null;
  5398. }
  5399. }
  5400. exports.BaseViewer = BaseViewer;
  5401. /***/ }),
  5402. /* 17 */
  5403. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5404. Object.defineProperty(exports, "__esModule", ({
  5405. value: true
  5406. }));
  5407. exports.PDFViewer = void 0;
  5408. var _ui_utils = __w_pdfjs_require__(3);
  5409. var _base_viewer = __w_pdfjs_require__(16);
  5410. var _pdfjsLib = __w_pdfjs_require__(2);
  5411. class PDFViewer extends _base_viewer.BaseViewer {
  5412. get _viewerElement() {
  5413. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  5414. }
  5415. _scrollIntoView({
  5416. pageDiv,
  5417. pageSpot = null,
  5418. pageNumber = null
  5419. }) {
  5420. if (!pageSpot && !this.isInPresentationMode) {
  5421. const left = pageDiv.offsetLeft + pageDiv.clientLeft;
  5422. const right = left + pageDiv.clientWidth;
  5423. const {
  5424. scrollLeft,
  5425. clientWidth
  5426. } = this.container;
  5427. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  5428. pageSpot = {
  5429. left: 0,
  5430. top: 0
  5431. };
  5432. }
  5433. }
  5434. super._scrollIntoView({
  5435. pageDiv,
  5436. pageSpot,
  5437. pageNumber
  5438. });
  5439. }
  5440. _getVisiblePages() {
  5441. if (this.isInPresentationMode) {
  5442. return this._getCurrentVisiblePage();
  5443. }
  5444. return super._getVisiblePages();
  5445. }
  5446. _updateHelper(visiblePages) {
  5447. if (this.isInPresentationMode) {
  5448. return;
  5449. }
  5450. let currentId = this._currentPageNumber;
  5451. let stillFullyVisible = false;
  5452. for (const page of visiblePages) {
  5453. if (page.percent < 100) {
  5454. break;
  5455. }
  5456. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  5457. stillFullyVisible = true;
  5458. break;
  5459. }
  5460. }
  5461. if (!stillFullyVisible) {
  5462. currentId = visiblePages[0].id;
  5463. }
  5464. this._setCurrentPageNumber(currentId);
  5465. }
  5466. }
  5467. exports.PDFViewer = PDFViewer;
  5468. /***/ })
  5469. /******/ ]);
  5470. /************************************************************************/
  5471. /******/ // The module cache
  5472. /******/ var __webpack_module_cache__ = {};
  5473. /******/
  5474. /******/ // The require function
  5475. /******/ function __w_pdfjs_require__(moduleId) {
  5476. /******/ // Check if module is in cache
  5477. /******/ if(__webpack_module_cache__[moduleId]) {
  5478. /******/ return __webpack_module_cache__[moduleId].exports;
  5479. /******/ }
  5480. /******/ // Create a new module (and put it into the cache)
  5481. /******/ var module = __webpack_module_cache__[moduleId] = {
  5482. /******/ // no module.id needed
  5483. /******/ // no module.loaded needed
  5484. /******/ exports: {}
  5485. /******/ };
  5486. /******/
  5487. /******/ // Execute the module function
  5488. /******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
  5489. /******/
  5490. /******/ // Return the exports of the module
  5491. /******/ return module.exports;
  5492. /******/ }
  5493. /******/
  5494. /************************************************************************/
  5495. /******/ // module exports must be returned from runtime so entry inlining is disabled
  5496. /******/ // startup
  5497. /******/ // Load entry module and return exports
  5498. /******/ return __w_pdfjs_require__(0);
  5499. /******/ })()
  5500. ;
  5501. });
  5502. //# sourceMappingURL=pdf_viewer.js.map