1
0

pdf_viewer.js 228 KB

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