viewer.js 549 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 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. /******/
  23. (() => { // webpackBootstrap
  24. /******/
  25. "use strict";
  26. /******/
  27. var __webpack_modules__ = ([
  28. /* 0 */
  29. ,
  30. /* 1 */
  31. /***/
  32. ((__unused_webpack_module, exports) => {
  33. Object.defineProperty(exports, "__esModule", ({
  34. value: true
  35. }));
  36. exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports
  37. .TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports
  38. .SCROLLBAR_PADDING = exports.RenderingStates = exports.RendererType = exports
  39. .ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE =
  40. exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports
  41. .DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0;
  42. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  43. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  44. exports.approximateFraction = approximateFraction;
  45. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  46. exports.binarySearchFirstItem = binarySearchFirstItem;
  47. exports.docStyle = void 0;
  48. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  49. exports.getPageSizeInches = getPageSizeInches;
  50. exports.getVisibleElements = getVisibleElements;
  51. exports.isPortraitOrientation = isPortraitOrientation;
  52. exports.isValidRotation = isValidRotation;
  53. exports.isValidScrollMode = isValidScrollMode;
  54. exports.isValidSpreadMode = isValidSpreadMode;
  55. exports.noContextMenuHandler = noContextMenuHandler;
  56. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  57. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  58. exports.parseQueryString = parseQueryString;
  59. exports.removeNullCharacters = removeNullCharacters;
  60. exports.roundToDivide = roundToDivide;
  61. exports.scrollIntoView = scrollIntoView;
  62. exports.watchScroll = watchScroll;
  63. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  64. _checkPrivateRedeclaration(obj, privateMap);
  65. privateMap.set(obj, value);
  66. }
  67. function _checkPrivateRedeclaration(obj, privateCollection) {
  68. if (privateCollection.has(obj)) {
  69. throw new TypeError(
  70. "Cannot initialize the same private elements twice on an object");
  71. }
  72. }
  73. function _classPrivateFieldGet(receiver, privateMap) {
  74. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  75. return _classApplyDescriptorGet(receiver, descriptor);
  76. }
  77. function _classApplyDescriptorGet(receiver, descriptor) {
  78. if (descriptor.get) {
  79. return descriptor.get.call(receiver);
  80. }
  81. return descriptor.value;
  82. }
  83. function _classPrivateFieldSet(receiver, privateMap, value) {
  84. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  85. _classApplyDescriptorSet(receiver, descriptor, value);
  86. return value;
  87. }
  88. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  89. if (!privateMap.has(receiver)) {
  90. throw new TypeError("attempted to " + action + " private field on non-instance");
  91. }
  92. return privateMap.get(receiver);
  93. }
  94. function _classApplyDescriptorSet(receiver, descriptor, value) {
  95. if (descriptor.set) {
  96. descriptor.set.call(receiver, value);
  97. } else {
  98. if (!descriptor.writable) {
  99. throw new TypeError("attempted to set read only private field");
  100. }
  101. descriptor.value = value;
  102. }
  103. }
  104. const DEFAULT_SCALE_VALUE = "auto";
  105. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  106. const DEFAULT_SCALE = 1.0;
  107. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  108. const DEFAULT_SCALE_DELTA = 1.1;
  109. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  110. const MIN_SCALE = 0.1;
  111. exports.MIN_SCALE = MIN_SCALE;
  112. const MAX_SCALE = 10.0;
  113. exports.MAX_SCALE = MAX_SCALE;
  114. const UNKNOWN_SCALE = 0;
  115. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  116. const MAX_AUTO_SCALE = 1.25;
  117. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  118. const SCROLLBAR_PADDING = 40;
  119. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  120. const VERTICAL_PADDING = 5;
  121. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  122. const RenderingStates = {
  123. INITIAL: 0,
  124. RUNNING: 1,
  125. PAUSED: 2,
  126. FINISHED: 3
  127. };
  128. exports.RenderingStates = RenderingStates;
  129. const PresentationModeState = {
  130. UNKNOWN: 0,
  131. NORMAL: 1,
  132. CHANGING: 2,
  133. FULLSCREEN: 3
  134. };
  135. exports.PresentationModeState = PresentationModeState;
  136. const SidebarView = {
  137. UNKNOWN: -1,
  138. NONE: 0,
  139. THUMBS: 1,
  140. OUTLINE: 2,
  141. ATTACHMENTS: 3,
  142. LAYERS: 4
  143. };
  144. exports.SidebarView = SidebarView;
  145. const RendererType = {
  146. CANVAS: "canvas",
  147. SVG: "svg"
  148. };
  149. exports.RendererType = RendererType;
  150. const TextLayerMode = {
  151. DISABLE: 0,
  152. ENABLE: 1,
  153. ENABLE_ENHANCE: 2
  154. };
  155. exports.TextLayerMode = TextLayerMode;
  156. const ScrollMode = {
  157. UNKNOWN: -1,
  158. VERTICAL: 0,
  159. HORIZONTAL: 1,
  160. WRAPPED: 2,
  161. PAGE: 3
  162. };
  163. exports.ScrollMode = ScrollMode;
  164. const SpreadMode = {
  165. UNKNOWN: -1,
  166. NONE: 0,
  167. ODD: 1,
  168. EVEN: 2
  169. };
  170. exports.SpreadMode = SpreadMode;
  171. const AutoPrintRegExp = /\bprint\s*\(/;
  172. exports.AutoPrintRegExp = AutoPrintRegExp;
  173. class OutputScale {
  174. constructor() {
  175. const pixelRatio = window.devicePixelRatio || 1;
  176. this.sx = pixelRatio;
  177. this.sy = pixelRatio;
  178. }
  179. get scaled() {
  180. return this.sx !== 1 || this.sy !== 1;
  181. }
  182. }
  183. exports.OutputScale = OutputScale;
  184. function scrollIntoView(element, spot) {
  185. let scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
  186. false;
  187. let parent = element.offsetParent;
  188. if (!parent) {
  189. console.error("offsetParent is not set -- cannot scroll");
  190. return;
  191. }
  192. let offsetY = element.offsetTop + element.clientTop;
  193. let offsetX = element.offsetLeft + element.clientLeft;
  194. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent
  195. .scrollWidth || scrollMatches && (parent.classList.contains("markedContent") ||
  196. getComputedStyle(parent).overflow === "hidden")) {
  197. offsetY += parent.offsetTop;
  198. offsetX += parent.offsetLeft;
  199. parent = parent.offsetParent;
  200. if (!parent) {
  201. return;
  202. }
  203. }
  204. if (spot) {
  205. if (spot.top !== undefined) {
  206. offsetY += spot.top;
  207. }
  208. if (spot.left !== undefined) {
  209. offsetX += spot.left;
  210. parent.scrollLeft = offsetX;
  211. }
  212. }
  213. parent.scrollTop = offsetY;
  214. }
  215. function watchScroll(viewAreaElement, callback) {
  216. const debounceScroll = function(evt) {
  217. if (rAF) {
  218. return;
  219. }
  220. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  221. rAF = null;
  222. const currentX = viewAreaElement.scrollLeft;
  223. const lastX = state.lastX;
  224. if (currentX !== lastX) {
  225. state.right = currentX > lastX;
  226. }
  227. state.lastX = currentX;
  228. const currentY = viewAreaElement.scrollTop;
  229. const lastY = state.lastY;
  230. if (currentY !== lastY) {
  231. state.down = currentY > lastY;
  232. }
  233. state.lastY = currentY;
  234. callback(state);
  235. });
  236. };
  237. const state = {
  238. right: true,
  239. down: true,
  240. lastX: viewAreaElement.scrollLeft,
  241. lastY: viewAreaElement.scrollTop,
  242. _eventHandler: debounceScroll
  243. };
  244. let rAF = null;
  245. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  246. return state;
  247. }
  248. function parseQueryString(query) {
  249. const params = new Map();
  250. for (const [key, value] of new URLSearchParams(query)) {
  251. params.set(key.toLowerCase(), value);
  252. }
  253. return params;
  254. }
  255. const NullCharactersRegExp = /\x00/g;
  256. const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  257. function removeNullCharacters(str) {
  258. let replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  259. 1] : false;
  260. if (typeof str !== "string") {
  261. console.error(`The argument must be a string.`);
  262. return str;
  263. }
  264. if (replaceInvisible) {
  265. str = str.replace(InvisibleCharactersRegExp, " ");
  266. }
  267. return str.replace(NullCharactersRegExp, "");
  268. }
  269. function binarySearchFirstItem(items, condition) {
  270. let start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  271. let minIndex = start;
  272. let maxIndex = items.length - 1;
  273. if (maxIndex < 0 || !condition(items[maxIndex])) {
  274. return items.length;
  275. }
  276. if (condition(items[minIndex])) {
  277. return minIndex;
  278. }
  279. while (minIndex < maxIndex) {
  280. const currentIndex = minIndex + maxIndex >> 1;
  281. const currentItem = items[currentIndex];
  282. if (condition(currentItem)) {
  283. maxIndex = currentIndex;
  284. } else {
  285. minIndex = currentIndex + 1;
  286. }
  287. }
  288. return minIndex;
  289. }
  290. function approximateFraction(x) {
  291. if (Math.floor(x) === x) {
  292. return [x, 1];
  293. }
  294. const xinv = 1 / x;
  295. const limit = 8;
  296. if (xinv > limit) {
  297. return [1, limit];
  298. } else if (Math.floor(xinv) === xinv) {
  299. return [1, xinv];
  300. }
  301. const x_ = x > 1 ? xinv : x;
  302. let a = 0,
  303. b = 1,
  304. c = 1,
  305. d = 1;
  306. while (true) {
  307. const p = a + c,
  308. q = b + d;
  309. if (q > limit) {
  310. break;
  311. }
  312. if (x_ <= p / q) {
  313. c = p;
  314. d = q;
  315. } else {
  316. a = p;
  317. b = q;
  318. }
  319. }
  320. let result;
  321. if (x_ - a / b < c / d - x_) {
  322. result = x_ === x ? [a, b] : [b, a];
  323. } else {
  324. result = x_ === x ? [c, d] : [d, c];
  325. }
  326. return result;
  327. }
  328. function roundToDivide(x, div) {
  329. const r = x % div;
  330. return r === 0 ? x : Math.round(x - r + div);
  331. }
  332. function getPageSizeInches(_ref) {
  333. let {
  334. view,
  335. userUnit,
  336. rotate
  337. } = _ref;
  338. const [x1, y1, x2, y2] = view;
  339. const changeOrientation = rotate % 180 !== 0;
  340. const width = (x2 - x1) / 72 * userUnit;
  341. const height = (y2 - y1) / 72 * userUnit;
  342. return {
  343. width: changeOrientation ? height : width,
  344. height: changeOrientation ? width : height
  345. };
  346. }
  347. function backtrackBeforeAllVisibleElements(index, views, top) {
  348. if (index < 2) {
  349. return index;
  350. }
  351. let elt = views[index].div;
  352. let pageTop = elt.offsetTop + elt.clientTop;
  353. if (pageTop >= top) {
  354. elt = views[index - 1].div;
  355. pageTop = elt.offsetTop + elt.clientTop;
  356. }
  357. for (let i = index - 2; i >= 0; --i) {
  358. elt = views[i].div;
  359. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  360. break;
  361. }
  362. index = i;
  363. }
  364. return index;
  365. }
  366. function getVisibleElements(_ref2) {
  367. let {
  368. scrollEl,
  369. views,
  370. sortByVisibility = false,
  371. horizontal = false,
  372. rtl = false
  373. } = _ref2;
  374. const top = scrollEl.scrollTop,
  375. bottom = top + scrollEl.clientHeight;
  376. const left = scrollEl.scrollLeft,
  377. right = left + scrollEl.clientWidth;
  378. function isElementBottomAfterViewTop(view) {
  379. const element = view.div;
  380. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  381. return elementBottom > top;
  382. }
  383. function isElementNextAfterViewHorizontally(view) {
  384. const element = view.div;
  385. const elementLeft = element.offsetLeft + element.clientLeft;
  386. const elementRight = elementLeft + element.clientWidth;
  387. return rtl ? elementLeft < right : elementRight > left;
  388. }
  389. const visible = [],
  390. ids = new Set(),
  391. numViews = views.length;
  392. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ?
  393. isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  394. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  395. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd,
  396. views, top);
  397. }
  398. let lastEdge = horizontal ? right : -1;
  399. for (let i = firstVisibleElementInd; i < numViews; i++) {
  400. const view = views[i],
  401. element = view.div;
  402. const currentWidth = element.offsetLeft + element.clientLeft;
  403. const currentHeight = element.offsetTop + element.clientTop;
  404. const viewWidth = element.clientWidth,
  405. viewHeight = element.clientHeight;
  406. const viewRight = currentWidth + viewWidth;
  407. const viewBottom = currentHeight + viewHeight;
  408. if (lastEdge === -1) {
  409. if (viewBottom >= bottom) {
  410. lastEdge = viewBottom;
  411. }
  412. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  413. break;
  414. }
  415. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left ||
  416. currentWidth >= right) {
  417. continue;
  418. }
  419. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom -
  420. bottom);
  421. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight -
  422. right);
  423. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  424. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  425. const percent = fractionHeight * fractionWidth * 100 | 0;
  426. visible.push({
  427. id: view.id,
  428. x: currentWidth,
  429. y: currentHeight,
  430. view,
  431. percent,
  432. widthPercent: fractionWidth * 100 | 0
  433. });
  434. ids.add(view.id);
  435. }
  436. const first = visible[0],
  437. last = visible.at(-1);
  438. if (sortByVisibility) {
  439. visible.sort(function(a, b) {
  440. const pc = a.percent - b.percent;
  441. if (Math.abs(pc) > 0.001) {
  442. return -pc;
  443. }
  444. return a.id - b.id;
  445. });
  446. }
  447. return {
  448. first,
  449. last,
  450. views: visible,
  451. ids
  452. };
  453. }
  454. function noContextMenuHandler(evt) {
  455. evt.preventDefault();
  456. }
  457. function normalizeWheelEventDirection(evt) {
  458. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  459. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  460. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  461. delta = -delta;
  462. }
  463. return delta;
  464. }
  465. function normalizeWheelEventDelta(evt) {
  466. let delta = normalizeWheelEventDirection(evt);
  467. const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  468. const MOUSE_DOM_DELTA_LINE_MODE = 1;
  469. const MOUSE_PIXELS_PER_LINE = 30;
  470. const MOUSE_LINES_PER_PAGE = 30;
  471. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  472. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  473. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  474. delta /= MOUSE_LINES_PER_PAGE;
  475. }
  476. return delta;
  477. }
  478. function isValidRotation(angle) {
  479. return Number.isInteger(angle) && angle % 90 === 0;
  480. }
  481. function isValidScrollMode(mode) {
  482. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !==
  483. ScrollMode.UNKNOWN;
  484. }
  485. function isValidSpreadMode(mode) {
  486. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !==
  487. SpreadMode.UNKNOWN;
  488. }
  489. function isPortraitOrientation(size) {
  490. return size.width <= size.height;
  491. }
  492. const animationStarted = new Promise(function(resolve) {
  493. window.requestAnimationFrame(resolve);
  494. });
  495. exports.animationStarted = animationStarted;
  496. const docStyle = document.documentElement.style;
  497. exports.docStyle = docStyle;
  498. function clamp(v, min, max) {
  499. return Math.min(Math.max(v, min), max);
  500. }
  501. var _classList = /*#__PURE__*/ new WeakMap();
  502. var _percent = /*#__PURE__*/ new WeakMap();
  503. var _visible = /*#__PURE__*/ new WeakMap();
  504. class ProgressBar {
  505. constructor(id) {
  506. _classPrivateFieldInitSpec(this, _classList, {
  507. writable: true,
  508. value: null
  509. });
  510. _classPrivateFieldInitSpec(this, _percent, {
  511. writable: true,
  512. value: 0
  513. });
  514. _classPrivateFieldInitSpec(this, _visible, {
  515. writable: true,
  516. value: true
  517. });
  518. if (arguments.length > 1) {
  519. throw new Error("ProgressBar no longer accepts any additional options, " +
  520. "please use CSS rules to modify its appearance instead.");
  521. }
  522. const bar = document.getElementById(id);
  523. _classPrivateFieldSet(this, _classList, bar.classList);
  524. }
  525. get percent() {
  526. return _classPrivateFieldGet(this, _percent);
  527. }
  528. set percent(val) {
  529. _classPrivateFieldSet(this, _percent, clamp(val, 0, 100));
  530. if (isNaN(val)) {
  531. _classPrivateFieldGet(this, _classList).add("indeterminate");
  532. return;
  533. }
  534. _classPrivateFieldGet(this, _classList).remove("indeterminate");
  535. docStyle.setProperty("--progressBar-percent",
  536. `${_classPrivateFieldGet(this, _percent)}%`);
  537. }
  538. setWidth(viewer) {
  539. if (!viewer) {
  540. return;
  541. }
  542. const container = viewer.parentNode;
  543. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  544. if (scrollbarWidth > 0) {
  545. docStyle.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  546. }
  547. }
  548. hide() {
  549. if (!_classPrivateFieldGet(this, _visible)) {
  550. return;
  551. }
  552. _classPrivateFieldSet(this, _visible, false);
  553. _classPrivateFieldGet(this, _classList).add("hidden");
  554. }
  555. show() {
  556. if (_classPrivateFieldGet(this, _visible)) {
  557. return;
  558. }
  559. _classPrivateFieldSet(this, _visible, true);
  560. _classPrivateFieldGet(this, _classList).remove("hidden");
  561. }
  562. }
  563. exports.ProgressBar = ProgressBar;
  564. function getActiveOrFocusedElement() {
  565. let curRoot = document;
  566. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  567. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !==
  568. void 0 && _curActiveOrFocused.shadowRoot) {
  569. var _curActiveOrFocused;
  570. curRoot = curActiveOrFocused.shadowRoot;
  571. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  572. }
  573. return curActiveOrFocused;
  574. }
  575. function apiPageLayoutToViewerModes(layout) {
  576. let scrollMode = ScrollMode.VERTICAL,
  577. spreadMode = SpreadMode.NONE;
  578. switch (layout) {
  579. case "SinglePage":
  580. scrollMode = ScrollMode.PAGE;
  581. break;
  582. case "OneColumn":
  583. break;
  584. case "TwoPageLeft":
  585. scrollMode = ScrollMode.PAGE;
  586. case "TwoColumnLeft":
  587. spreadMode = SpreadMode.ODD;
  588. break;
  589. case "TwoPageRight":
  590. scrollMode = ScrollMode.PAGE;
  591. case "TwoColumnRight":
  592. spreadMode = SpreadMode.EVEN;
  593. break;
  594. }
  595. return {
  596. scrollMode,
  597. spreadMode
  598. };
  599. }
  600. function apiPageModeToSidebarView(mode) {
  601. switch (mode) {
  602. case "UseNone":
  603. return SidebarView.NONE;
  604. case "UseThumbs":
  605. return SidebarView.THUMBS;
  606. case "UseOutlines":
  607. return SidebarView.OUTLINE;
  608. case "UseAttachments":
  609. return SidebarView.ATTACHMENTS;
  610. case "UseOC":
  611. return SidebarView.LAYERS;
  612. }
  613. return SidebarView.NONE;
  614. }
  615. /***/
  616. }),
  617. /* 2 */
  618. /***/
  619. ((__unused_webpack_module, exports) => {
  620. Object.defineProperty(exports, "__esModule", ({
  621. value: true
  622. }));
  623. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  624. const compatibilityParams = Object.create(null);
  625. exports.compatibilityParams = compatibilityParams; {
  626. const userAgent = navigator.userAgent || "";
  627. const platform = navigator.platform || "";
  628. const maxTouchPoints = navigator.maxTouchPoints || 1;
  629. const isAndroid = /Android/.test(userAgent);
  630. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" &&
  631. maxTouchPoints > 1;
  632. (function checkCanvasSizeLimitation() {
  633. if (isIOS || isAndroid) {
  634. compatibilityParams.maxCanvasPixels = 5242880;
  635. }
  636. })();
  637. }
  638. const OptionKind = {
  639. VIEWER: 0x02,
  640. API: 0x04,
  641. WORKER: 0x08,
  642. PREFERENCE: 0x80
  643. };
  644. exports.OptionKind = OptionKind;
  645. const defaultOptions = {
  646. annotationEditorMode: {
  647. value: -1,
  648. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  649. },
  650. annotationMode: {
  651. value: 2,
  652. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  653. },
  654. cursorToolOnLoad: {
  655. value: 0,
  656. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  657. },
  658. defaultZoomValue: {
  659. value: "",
  660. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  661. },
  662. disableHistory: {
  663. value: false,
  664. kind: OptionKind.VIEWER
  665. },
  666. disablePageLabels: {
  667. value: false,
  668. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  669. },
  670. enablePermissions: {
  671. value: false,
  672. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  673. },
  674. enablePrintAutoRotate: {
  675. value: true,
  676. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  677. },
  678. enableScripting: {
  679. value: true,
  680. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  681. },
  682. externalLinkRel: {
  683. value: "noopener noreferrer nofollow",
  684. kind: OptionKind.VIEWER
  685. },
  686. externalLinkTarget: {
  687. value: 0,
  688. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  689. },
  690. historyUpdateUrl: {
  691. value: false,
  692. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  693. },
  694. ignoreDestinationZoom: {
  695. value: false,
  696. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  697. },
  698. imageResourcesPath: {
  699. value: "./images/",
  700. kind: OptionKind.VIEWER
  701. },
  702. maxCanvasPixels: {
  703. value: 16777216,
  704. kind: OptionKind.VIEWER
  705. },
  706. forcePageColors: {
  707. value: false,
  708. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  709. },
  710. pageColorsBackground: {
  711. value: "Canvas",
  712. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  713. },
  714. pageColorsForeground: {
  715. value: "CanvasText",
  716. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  717. },
  718. pdfBugEnabled: {
  719. value: false,
  720. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  721. },
  722. printResolution: {
  723. value: 150,
  724. kind: OptionKind.VIEWER
  725. },
  726. sidebarViewOnLoad: {
  727. value: -1,
  728. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  729. },
  730. scrollModeOnLoad: {
  731. value: -1,
  732. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  733. },
  734. spreadModeOnLoad: {
  735. value: -1,
  736. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  737. },
  738. textLayerMode: {
  739. value: 1,
  740. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  741. },
  742. useOnlyCssZoom: {
  743. value: false,
  744. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  745. },
  746. viewerCssTheme: {
  747. value: 0,
  748. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  749. },
  750. viewOnLoad: {
  751. value: 0,
  752. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  753. },
  754. cMapPacked: {
  755. value: true,
  756. kind: OptionKind.API
  757. },
  758. cMapUrl: {
  759. value: "../web/cmaps/",
  760. kind: OptionKind.API
  761. },
  762. disableAutoFetch: {
  763. value: false,
  764. kind: OptionKind.API + OptionKind.PREFERENCE
  765. },
  766. disableFontFace: {
  767. value: false,
  768. kind: OptionKind.API + OptionKind.PREFERENCE
  769. },
  770. disableRange: {
  771. value: false,
  772. kind: OptionKind.API + OptionKind.PREFERENCE
  773. },
  774. disableStream: {
  775. value: false,
  776. kind: OptionKind.API + OptionKind.PREFERENCE
  777. },
  778. docBaseUrl: {
  779. value: "",
  780. kind: OptionKind.API
  781. },
  782. enableXfa: {
  783. value: true,
  784. kind: OptionKind.API + OptionKind.PREFERENCE
  785. },
  786. fontExtraProperties: {
  787. value: false,
  788. kind: OptionKind.API
  789. },
  790. isEvalSupported: {
  791. value: true,
  792. kind: OptionKind.API
  793. },
  794. maxImageSize: {
  795. value: -1,
  796. kind: OptionKind.API
  797. },
  798. pdfBug: {
  799. value: false,
  800. kind: OptionKind.API
  801. },
  802. standardFontDataUrl: {
  803. value: "../web/standard_fonts/",
  804. kind: OptionKind.API
  805. },
  806. verbosity: {
  807. value: 1,
  808. kind: OptionKind.API
  809. },
  810. workerPort: {
  811. value: null,
  812. kind: OptionKind.WORKER
  813. },
  814. workerSrc: {
  815. value: "../build/pdf.worker.js",
  816. kind: OptionKind.WORKER
  817. }
  818. }; {
  819. defaultOptions.defaultUrl = {
  820. value: "compressed.tracemonkey-pldi-09.pdf",
  821. kind: OptionKind.VIEWER
  822. };
  823. defaultOptions.disablePreferences = {
  824. value: false,
  825. kind: OptionKind.VIEWER
  826. };
  827. defaultOptions.locale = {
  828. value: navigator.language || "en-US",
  829. kind: OptionKind.VIEWER
  830. };
  831. defaultOptions.renderer = {
  832. value: "canvas",
  833. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  834. };
  835. defaultOptions.sandboxBundleSrc = {
  836. value: "../build/pdf.sandbox.js",
  837. kind: OptionKind.VIEWER
  838. };
  839. }
  840. const userOptions = Object.create(null);
  841. class AppOptions {
  842. constructor() {
  843. throw new Error("Cannot initialize AppOptions.");
  844. }
  845. static get(name) {
  846. const userOption = userOptions[name];
  847. if (userOption !== undefined) {
  848. return userOption;
  849. }
  850. const defaultOption = defaultOptions[name];
  851. if (defaultOption !== undefined) {
  852. var _compatibilityParams$;
  853. return (_compatibilityParams$ = compatibilityParams[name]) !== null &&
  854. _compatibilityParams$ !== void 0 ? _compatibilityParams$ : defaultOption
  855. .value;
  856. }
  857. return undefined;
  858. }
  859. static getAll() {
  860. let kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  861. null;
  862. const options = Object.create(null);
  863. for (const name in defaultOptions) {
  864. var _compatibilityParams$2;
  865. const defaultOption = defaultOptions[name];
  866. if (kind) {
  867. if ((kind & defaultOption.kind) === 0) {
  868. continue;
  869. }
  870. if (kind === OptionKind.PREFERENCE) {
  871. const value = defaultOption.value,
  872. valueType = typeof value;
  873. if (valueType === "boolean" || valueType === "string" ||
  874. valueType === "number" && Number.isInteger(value)) {
  875. options[name] = value;
  876. continue;
  877. }
  878. throw new Error(`Invalid type for preference: ${name}`);
  879. }
  880. }
  881. const userOption = userOptions[name];
  882. options[name] = userOption !== undefined ? userOption : (
  883. _compatibilityParams$2 = compatibilityParams[name]) !== null &&
  884. _compatibilityParams$2 !== void 0 ? _compatibilityParams$2 :
  885. defaultOption.value;
  886. }
  887. return options;
  888. }
  889. static set(name, value) {
  890. userOptions[name] = value;
  891. }
  892. static setAll(options) {
  893. for (const name in options) {
  894. userOptions[name] = options[name];
  895. }
  896. }
  897. static remove(name) {
  898. delete userOptions[name];
  899. }
  900. static _hasUserOptions() {
  901. return Object.keys(userOptions).length > 0;
  902. }
  903. }
  904. exports.AppOptions = AppOptions;
  905. /***/
  906. }),
  907. /* 3 */
  908. /***/
  909. ((__unused_webpack_module, exports, __webpack_require__) => {
  910. Object.defineProperty(exports, "__esModule", ({
  911. value: true
  912. }));
  913. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  914. var _ui_utils = __webpack_require__(1);
  915. function _classPrivateMethodInitSpec(obj, privateSet) {
  916. _checkPrivateRedeclaration(obj, privateSet);
  917. privateSet.add(obj);
  918. }
  919. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  920. _checkPrivateRedeclaration(obj, privateMap);
  921. privateMap.set(obj, value);
  922. }
  923. function _checkPrivateRedeclaration(obj, privateCollection) {
  924. if (privateCollection.has(obj)) {
  925. throw new TypeError(
  926. "Cannot initialize the same private elements twice on an object");
  927. }
  928. }
  929. function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
  930. _classCheckPrivateStaticAccess(receiver, classConstructor);
  931. return method;
  932. }
  933. function _classCheckPrivateStaticAccess(receiver, classConstructor) {
  934. if (receiver !== classConstructor) {
  935. throw new TypeError("Private static access of wrong provenance");
  936. }
  937. }
  938. function _classPrivateMethodGet(receiver, privateSet, fn) {
  939. if (!privateSet.has(receiver)) {
  940. throw new TypeError("attempted to get private field on non-instance");
  941. }
  942. return fn;
  943. }
  944. function _classPrivateFieldGet(receiver, privateMap) {
  945. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  946. return _classApplyDescriptorGet(receiver, descriptor);
  947. }
  948. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  949. if (!privateMap.has(receiver)) {
  950. throw new TypeError("attempted to " + action + " private field on non-instance");
  951. }
  952. return privateMap.get(receiver);
  953. }
  954. function _classApplyDescriptorGet(receiver, descriptor) {
  955. if (descriptor.get) {
  956. return descriptor.get.call(receiver);
  957. }
  958. return descriptor.value;
  959. }
  960. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  961. const LinkTarget = {
  962. NONE: 0,
  963. SELF: 1,
  964. BLANK: 2,
  965. PARENT: 3,
  966. TOP: 4
  967. };
  968. exports.LinkTarget = LinkTarget;
  969. function addLinkAttributes(link) {
  970. let {
  971. url,
  972. target,
  973. rel,
  974. enabled = true
  975. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  976. if (!url || typeof url !== "string") {
  977. throw new Error('A valid "url" parameter must provided.');
  978. }
  979. const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  980. if (enabled) {
  981. link.href = link.title = urlNullRemoved;
  982. } else {
  983. link.href = "";
  984. link.title = `Disabled: ${urlNullRemoved}`;
  985. link.onclick = () => {
  986. return false;
  987. };
  988. }
  989. let targetStr = "";
  990. switch (target) {
  991. case LinkTarget.NONE:
  992. break;
  993. case LinkTarget.SELF:
  994. targetStr = "_self";
  995. break;
  996. case LinkTarget.BLANK:
  997. targetStr = "_blank";
  998. break;
  999. case LinkTarget.PARENT:
  1000. targetStr = "_parent";
  1001. break;
  1002. case LinkTarget.TOP:
  1003. targetStr = "_top";
  1004. break;
  1005. }
  1006. link.target = targetStr;
  1007. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  1008. }
  1009. var _pagesRefCache = /*#__PURE__*/ new WeakMap();
  1010. var _goToDestinationHelper = /*#__PURE__*/ new WeakSet();
  1011. class PDFLinkService {
  1012. constructor() {
  1013. let {
  1014. eventBus,
  1015. externalLinkTarget = null,
  1016. externalLinkRel = null,
  1017. ignoreDestinationZoom = false
  1018. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1019. _classPrivateMethodInitSpec(this, _goToDestinationHelper);
  1020. _classPrivateFieldInitSpec(this, _pagesRefCache, {
  1021. writable: true,
  1022. value: new Map()
  1023. });
  1024. this.eventBus = eventBus;
  1025. this.externalLinkTarget = externalLinkTarget;
  1026. this.externalLinkRel = externalLinkRel;
  1027. this.externalLinkEnabled = true;
  1028. this._ignoreDestinationZoom = ignoreDestinationZoom;
  1029. this.baseUrl = null;
  1030. this.pdfDocument = null;
  1031. this.pdfViewer = null;
  1032. this.pdfHistory = null;
  1033. }
  1034. setDocument(pdfDocument) {
  1035. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  1036. 1] : null;
  1037. this.baseUrl = baseUrl;
  1038. this.pdfDocument = pdfDocument;
  1039. _classPrivateFieldGet(this, _pagesRefCache).clear();
  1040. }
  1041. setViewer(pdfViewer) {
  1042. this.pdfViewer = pdfViewer;
  1043. }
  1044. setHistory(pdfHistory) {
  1045. this.pdfHistory = pdfHistory;
  1046. }
  1047. get pagesCount() {
  1048. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1049. }
  1050. get page() {
  1051. return this.pdfViewer.currentPageNumber;
  1052. }
  1053. set page(value) {
  1054. this.pdfViewer.currentPageNumber = value;
  1055. }
  1056. get rotation() {
  1057. return this.pdfViewer.pagesRotation;
  1058. }
  1059. set rotation(value) {
  1060. this.pdfViewer.pagesRotation = value;
  1061. }
  1062. async goToDestination(dest) {
  1063. if (!this.pdfDocument) {
  1064. return;
  1065. }
  1066. let namedDest, explicitDest;
  1067. if (typeof dest === "string") {
  1068. namedDest = dest;
  1069. explicitDest = await this.pdfDocument.getDestination(dest);
  1070. } else {
  1071. namedDest = null;
  1072. explicitDest = await dest;
  1073. }
  1074. if (!Array.isArray(explicitDest)) {
  1075. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` +
  1076. `a valid destination array, for dest="${dest}".`);
  1077. return;
  1078. }
  1079. _classPrivateMethodGet(this, _goToDestinationHelper, _goToDestinationHelper2)
  1080. .call(this, dest, namedDest, explicitDest);
  1081. }
  1082. goToPage(val) {
  1083. if (!this.pdfDocument) {
  1084. return;
  1085. }
  1086. const pageNumber = typeof val === "string" && this.pdfViewer
  1087. .pageLabelToPageNumber(val) || val | 0;
  1088. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this
  1089. .pagesCount)) {
  1090. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  1091. return;
  1092. }
  1093. if (this.pdfHistory) {
  1094. this.pdfHistory.pushCurrentPosition();
  1095. this.pdfHistory.pushPage(pageNumber);
  1096. }
  1097. this.pdfViewer.scrollPageIntoView({
  1098. pageNumber
  1099. });
  1100. }
  1101. addLinkAttributes(link, url) {
  1102. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  1103. 2] : false;
  1104. addLinkAttributes(link, {
  1105. url,
  1106. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  1107. rel: this.externalLinkRel,
  1108. enabled: this.externalLinkEnabled
  1109. });
  1110. }
  1111. getDestinationHash(dest) {
  1112. if (typeof dest === "string") {
  1113. if (dest.length > 0) {
  1114. return this.getAnchorUrl("#" + escape(dest));
  1115. }
  1116. } else if (Array.isArray(dest)) {
  1117. const str = JSON.stringify(dest);
  1118. if (str.length > 0) {
  1119. return this.getAnchorUrl("#" + escape(str));
  1120. }
  1121. }
  1122. return this.getAnchorUrl("");
  1123. }
  1124. getAnchorUrl(anchor) {
  1125. return (this.baseUrl || "") + anchor;
  1126. }
  1127. setHash(hash) {
  1128. if (!this.pdfDocument) {
  1129. return;
  1130. }
  1131. let pageNumber, dest;
  1132. if (hash.includes("=")) {
  1133. const params = (0, _ui_utils.parseQueryString)(hash);
  1134. if (params.has("search")) {
  1135. this.eventBus.dispatch("findfromurlhash", {
  1136. source: this,
  1137. query: params.get("search").replace(/"/g, ""),
  1138. phraseSearch: params.get("phrase") === "true"
  1139. });
  1140. }
  1141. if (params.has("page")) {
  1142. pageNumber = params.get("page") | 0 || 1;
  1143. }
  1144. if (params.has("zoom")) {
  1145. const zoomArgs = params.get("zoom").split(",");
  1146. const zoomArg = zoomArgs[0];
  1147. const zoomArgNumber = parseFloat(zoomArg);
  1148. if (!zoomArg.includes("Fit")) {
  1149. dest = [null, {
  1150. name: "XYZ"
  1151. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs
  1152. .length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ?
  1153. zoomArgNumber / 100 : zoomArg
  1154. ];
  1155. } else {
  1156. if (zoomArg === "Fit" || zoomArg === "FitB") {
  1157. dest = [null, {
  1158. name: zoomArg
  1159. }];
  1160. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg ===
  1161. "FitV" || zoomArg === "FitBV") {
  1162. dest = [null, {
  1163. name: zoomArg
  1164. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1165. } else if (zoomArg === "FitR") {
  1166. if (zoomArgs.length !== 5) {
  1167. console.error(
  1168. 'PDFLinkService.setHash: Not enough parameters for "FitR".'
  1169. );
  1170. } else {
  1171. dest = [null, {
  1172. name: zoomArg
  1173. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] |
  1174. 0, zoomArgs[4] | 0
  1175. ];
  1176. }
  1177. } else {
  1178. console.error(
  1179. `PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`
  1180. );
  1181. }
  1182. }
  1183. }
  1184. if (dest) {
  1185. this.pdfViewer.scrollPageIntoView({
  1186. pageNumber: pageNumber || this.page,
  1187. destArray: dest,
  1188. allowNegativeOffset: true
  1189. });
  1190. } else if (pageNumber) {
  1191. this.page = pageNumber;
  1192. }
  1193. if (params.has("pagemode")) {
  1194. this.eventBus.dispatch("pagemode", {
  1195. source: this,
  1196. mode: params.get("pagemode")
  1197. });
  1198. }
  1199. if (params.has("nameddest")) {
  1200. this.goToDestination(params.get("nameddest"));
  1201. }
  1202. } else {
  1203. dest = unescape(hash);
  1204. try {
  1205. dest = JSON.parse(dest);
  1206. if (!Array.isArray(dest)) {
  1207. dest = dest.toString();
  1208. }
  1209. } catch (ex) {}
  1210. if (typeof dest === "string" || _classStaticPrivateMethodGet(PDFLinkService,
  1211. PDFLinkService, _isValidExplicitDestination).call(PDFLinkService,
  1212. dest)) {
  1213. this.goToDestination(dest);
  1214. return;
  1215. }
  1216. console.error(
  1217. `PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`
  1218. );
  1219. }
  1220. }
  1221. executeNamedAction(action) {
  1222. var _this$pdfHistory, _this$pdfHistory2;
  1223. switch (action) {
  1224. case "GoBack":
  1225. (_this$pdfHistory = this.pdfHistory) === null || _this$pdfHistory ===
  1226. void 0 ? void 0 : _this$pdfHistory.back();
  1227. break;
  1228. case "GoForward":
  1229. (_this$pdfHistory2 = this.pdfHistory) === null || _this$pdfHistory2 ===
  1230. void 0 ? void 0 : _this$pdfHistory2.forward();
  1231. break;
  1232. case "NextPage":
  1233. this.pdfViewer.nextPage();
  1234. break;
  1235. case "PrevPage":
  1236. this.pdfViewer.previousPage();
  1237. break;
  1238. case "LastPage":
  1239. this.page = this.pagesCount;
  1240. break;
  1241. case "FirstPage":
  1242. this.page = 1;
  1243. break;
  1244. default:
  1245. break;
  1246. }
  1247. this.eventBus.dispatch("namedaction", {
  1248. source: this,
  1249. action
  1250. });
  1251. }
  1252. cachePageRef(pageNum, pageRef) {
  1253. if (!pageRef) {
  1254. return;
  1255. }
  1256. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` :
  1257. `${pageRef.num}R${pageRef.gen}`;
  1258. _classPrivateFieldGet(this, _pagesRefCache).set(refStr, pageNum);
  1259. }
  1260. _cachedPageNumber(pageRef) {
  1261. if (!pageRef) {
  1262. return null;
  1263. }
  1264. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` :
  1265. `${pageRef.num}R${pageRef.gen}`;
  1266. return _classPrivateFieldGet(this, _pagesRefCache).get(refStr) || null;
  1267. }
  1268. isPageVisible(pageNumber) {
  1269. return this.pdfViewer.isPageVisible(pageNumber);
  1270. }
  1271. isPageCached(pageNumber) {
  1272. return this.pdfViewer.isPageCached(pageNumber);
  1273. }
  1274. }
  1275. exports.PDFLinkService = PDFLinkService;
  1276. function _goToDestinationHelper2(rawDest) {
  1277. let namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  1278. null;
  1279. let explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  1280. const destRef = explicitDest[0];
  1281. let pageNumber;
  1282. if (typeof destRef === "object" && destRef !== null) {
  1283. pageNumber = this._cachedPageNumber(destRef);
  1284. if (!pageNumber) {
  1285. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  1286. this.cachePageRef(pageIndex + 1, destRef);
  1287. _classPrivateMethodGet(this, _goToDestinationHelper,
  1288. _goToDestinationHelper2).call(this, rawDest, namedDest,
  1289. explicitDest);
  1290. }).catch(() => {
  1291. console.error(
  1292. `PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` +
  1293. `a valid page reference, for dest="${rawDest}".`);
  1294. });
  1295. return;
  1296. }
  1297. } else if (Number.isInteger(destRef)) {
  1298. pageNumber = destRef + 1;
  1299. } else {
  1300. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` +
  1301. `a valid destination reference, for dest="${rawDest}".`);
  1302. return;
  1303. }
  1304. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  1305. console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` +
  1306. `a valid page number, for dest="${rawDest}".`);
  1307. return;
  1308. }
  1309. if (this.pdfHistory) {
  1310. this.pdfHistory.pushCurrentPosition();
  1311. this.pdfHistory.push({
  1312. namedDest,
  1313. explicitDest,
  1314. pageNumber
  1315. });
  1316. }
  1317. this.pdfViewer.scrollPageIntoView({
  1318. pageNumber,
  1319. destArray: explicitDest,
  1320. ignoreDestinationZoom: this._ignoreDestinationZoom
  1321. });
  1322. }
  1323. function _isValidExplicitDestination(dest) {
  1324. if (!Array.isArray(dest)) {
  1325. return false;
  1326. }
  1327. const destLength = dest.length;
  1328. if (destLength < 2) {
  1329. return false;
  1330. }
  1331. const page = dest[0];
  1332. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page
  1333. .gen)) && !(Number.isInteger(page) && page >= 0)) {
  1334. return false;
  1335. }
  1336. const zoom = dest[1];
  1337. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  1338. return false;
  1339. }
  1340. let allowNull = true;
  1341. switch (zoom.name) {
  1342. case "XYZ":
  1343. if (destLength !== 5) {
  1344. return false;
  1345. }
  1346. break;
  1347. case "Fit":
  1348. case "FitB":
  1349. return destLength === 2;
  1350. case "FitH":
  1351. case "FitBH":
  1352. case "FitV":
  1353. case "FitBV":
  1354. if (destLength !== 3) {
  1355. return false;
  1356. }
  1357. break;
  1358. case "FitR":
  1359. if (destLength !== 6) {
  1360. return false;
  1361. }
  1362. allowNull = false;
  1363. break;
  1364. default:
  1365. return false;
  1366. }
  1367. for (let i = 2; i < destLength; i++) {
  1368. const param = dest[i];
  1369. if (!(typeof param === "number" || allowNull && param === null)) {
  1370. return false;
  1371. }
  1372. }
  1373. return true;
  1374. }
  1375. class SimpleLinkService {
  1376. constructor() {
  1377. this.externalLinkEnabled = true;
  1378. }
  1379. get pagesCount() {
  1380. return 0;
  1381. }
  1382. get page() {
  1383. return 0;
  1384. }
  1385. set page(value) {}
  1386. get rotation() {
  1387. return 0;
  1388. }
  1389. set rotation(value) {}
  1390. async goToDestination(dest) {}
  1391. goToPage(val) {}
  1392. addLinkAttributes(link, url) {
  1393. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  1394. 2] : false;
  1395. addLinkAttributes(link, {
  1396. url,
  1397. enabled: this.externalLinkEnabled
  1398. });
  1399. }
  1400. getDestinationHash(dest) {
  1401. return "#";
  1402. }
  1403. getAnchorUrl(hash) {
  1404. return "#";
  1405. }
  1406. setHash(hash) {}
  1407. executeNamedAction(action) {}
  1408. cachePageRef(pageNum, pageRef) {}
  1409. isPageVisible(pageNumber) {
  1410. return true;
  1411. }
  1412. isPageCached(pageNumber) {
  1413. return true;
  1414. }
  1415. }
  1416. exports.SimpleLinkService = SimpleLinkService;
  1417. /***/
  1418. }),
  1419. /* 4 */
  1420. /***/
  1421. ((__unused_webpack_module, exports, __webpack_require__) => {
  1422. Object.defineProperty(exports, "__esModule", ({
  1423. value: true
  1424. }));
  1425. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports
  1426. .DefaultExternalServices = void 0;
  1427. var _ui_utils = __webpack_require__(1);
  1428. var _pdfjsLib = __webpack_require__(5);
  1429. var _app_options = __webpack_require__(2);
  1430. var _event_utils = __webpack_require__(6);
  1431. var _pdf_cursor_tools = __webpack_require__(7);
  1432. var _pdf_link_service = __webpack_require__(3);
  1433. var _annotation_editor_params = __webpack_require__(9);
  1434. var _overlay_manager = __webpack_require__(10);
  1435. var _password_prompt = __webpack_require__(12);
  1436. var _pdf_attachment_viewer = __webpack_require__(13);
  1437. var _pdf_document_properties = __webpack_require__(15);
  1438. var _pdf_find_bar = __webpack_require__(16);
  1439. var _pdf_find_controller = __webpack_require__(17);
  1440. var _pdf_history = __webpack_require__(19);
  1441. var _pdf_layer_viewer = __webpack_require__(20);
  1442. var _pdf_outline_viewer = __webpack_require__(21);
  1443. var _pdf_presentation_mode = __webpack_require__(22);
  1444. var _pdf_rendering_queue = __webpack_require__(23);
  1445. var _pdf_scripting_manager = __webpack_require__(24);
  1446. var _pdf_sidebar = __webpack_require__(25);
  1447. var _pdf_sidebar_resizer = __webpack_require__(26);
  1448. var _pdf_thumbnail_viewer = __webpack_require__(27);
  1449. var _pdf_viewer = __webpack_require__(29);
  1450. var _secondary_toolbar = __webpack_require__(40);
  1451. var _toolbar = __webpack_require__(41);
  1452. var _view_history = __webpack_require__(42);
  1453. const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  1454. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  1455. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  1456. const ViewOnLoad = {
  1457. UNKNOWN: -1,
  1458. PREVIOUS: 0,
  1459. INITIAL: 1
  1460. };
  1461. const ViewerCssTheme = {
  1462. AUTOMATIC: 0,
  1463. LIGHT: 1,
  1464. DARK: 2
  1465. };
  1466. const KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8",
  1467. "1.9", "2.0", "2.1", "2.2", "2.3"
  1468. ];
  1469. const KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle",
  1470. "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm",
  1471. "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x",
  1472. "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house",
  1473. "aspose.cells", "fpdf"
  1474. ];
  1475. class DefaultExternalServices {
  1476. constructor() {
  1477. throw new Error("Cannot initialize DefaultExternalServices.");
  1478. }
  1479. static updateFindControlState(data) {}
  1480. static updateFindMatchesCount(data) {}
  1481. static initPassiveLoading(callbacks) {}
  1482. static reportTelemetry(data) {}
  1483. static createDownloadManager(options) {
  1484. throw new Error("Not implemented: createDownloadManager");
  1485. }
  1486. static createPreferences() {
  1487. throw new Error("Not implemented: createPreferences");
  1488. }
  1489. static createL10n(options) {
  1490. throw new Error("Not implemented: createL10n");
  1491. }
  1492. static createScripting(options) {
  1493. throw new Error("Not implemented: createScripting");
  1494. }
  1495. static get supportsIntegratedFind() {
  1496. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  1497. }
  1498. static get supportsDocumentFonts() {
  1499. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  1500. }
  1501. static get supportedMouseWheelZoomModifierKeys() {
  1502. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  1503. ctrlKey: true,
  1504. metaKey: true
  1505. });
  1506. }
  1507. static get isInAutomation() {
  1508. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  1509. }
  1510. static updateEditorStates(data) {
  1511. throw new Error("Not implemented: updateEditorStates");
  1512. }
  1513. }
  1514. exports.DefaultExternalServices = DefaultExternalServices;
  1515. const PDFViewerApplication = {
  1516. initialBookmark: document.location.hash.substring(1),
  1517. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  1518. appConfig: null,
  1519. pdfDocument: null,
  1520. pdfLoadingTask: null,
  1521. printService: null,
  1522. pdfViewer: null,
  1523. pdfThumbnailViewer: null,
  1524. pdfRenderingQueue: null,
  1525. pdfPresentationMode: null,
  1526. pdfDocumentProperties: null,
  1527. pdfLinkService: null,
  1528. pdfHistory: null,
  1529. pdfSidebar: null,
  1530. pdfSidebarResizer: null,
  1531. pdfOutlineViewer: null,
  1532. pdfAttachmentViewer: null,
  1533. pdfLayerViewer: null,
  1534. pdfCursorTools: null,
  1535. pdfScriptingManager: null,
  1536. store: null,
  1537. downloadManager: null,
  1538. overlayManager: null,
  1539. preferences: null,
  1540. toolbar: null,
  1541. secondaryToolbar: null,
  1542. eventBus: null,
  1543. l10n: null,
  1544. annotationEditorParams: null,
  1545. isInitialViewSet: false,
  1546. downloadComplete: false,
  1547. isViewerEmbedded: window.parent !== window,
  1548. url: "",
  1549. baseUrl: "",
  1550. _downloadUrl: "",
  1551. externalServices: DefaultExternalServices,
  1552. _boundEvents: Object.create(null),
  1553. documentInfo: null,
  1554. metadata: null,
  1555. _contentDispositionFilename: null,
  1556. _contentLength: null,
  1557. _saveInProgress: false,
  1558. _docStats: null,
  1559. _wheelUnusedTicks: 0,
  1560. _idleCallbacks: new Set(),
  1561. _PDFBug: null,
  1562. _hasAnnotationEditors: false,
  1563. _title: document.title,
  1564. _printAnnotationStoragePromise: null,
  1565. async initialize(appConfig) {
  1566. this.preferences = this.externalServices.createPreferences();
  1567. this.appConfig = appConfig;
  1568. await this._readPreferences();
  1569. await this._parseHashParameters();
  1570. this._forceCssTheme();
  1571. await this._initializeL10n();
  1572. if (this.isViewerEmbedded && _app_options.AppOptions.get(
  1573. "externalLinkTarget") === _pdf_link_service.LinkTarget.NONE) {
  1574. _app_options.AppOptions.set("externalLinkTarget", _pdf_link_service
  1575. .LinkTarget.TOP);
  1576. }
  1577. await this._initializeViewerComponents();
  1578. this.bindEvents();
  1579. this.bindWindowEvents();
  1580. const appContainer = appConfig.appContainer || document.documentElement;
  1581. this.l10n.translate(appContainer).then(() => {
  1582. this.eventBus.dispatch("localized", {
  1583. source: this
  1584. });
  1585. });
  1586. this._initializedCapability.resolve();
  1587. },
  1588. async _readPreferences() {
  1589. if (_app_options.AppOptions.get("disablePreferences")) {
  1590. return;
  1591. }
  1592. if (_app_options.AppOptions._hasUserOptions()) {
  1593. console.warn(
  1594. "_readPreferences: The Preferences may override manually set AppOptions; " +
  1595. 'please use the "disablePreferences"-option in order to prevent that.'
  1596. );
  1597. }
  1598. try {
  1599. _app_options.AppOptions.setAll(await this.preferences.getAll());
  1600. } catch (reason) {
  1601. console.error(
  1602. `_readPreferences: "${reason === null || reason === void 0 ? void 0 : reason.message}".`
  1603. );
  1604. }
  1605. },
  1606. async _parseHashParameters() {
  1607. if (!_app_options.AppOptions.get("pdfBugEnabled")) {
  1608. return;
  1609. }
  1610. const hash = document.location.hash.substring(1);
  1611. if (!hash) {
  1612. return;
  1613. }
  1614. const {
  1615. mainContainer,
  1616. viewerContainer
  1617. } = this.appConfig,
  1618. params = (0, _ui_utils.parseQueryString)(hash);
  1619. if (params.get("disableworker") === "true") {
  1620. try {
  1621. await loadFakeWorker();
  1622. } catch (ex) {
  1623. console.error(`_parseHashParameters: "${ex.message}".`);
  1624. }
  1625. }
  1626. if (params.has("disablerange")) {
  1627. _app_options.AppOptions.set("disableRange", params.get(
  1628. "disablerange") === "true");
  1629. }
  1630. if (params.has("disablestream")) {
  1631. _app_options.AppOptions.set("disableStream", params.get(
  1632. "disablestream") === "true");
  1633. }
  1634. if (params.has("disableautofetch")) {
  1635. _app_options.AppOptions.set("disableAutoFetch", params.get(
  1636. "disableautofetch") === "true");
  1637. }
  1638. if (params.has("disablefontface")) {
  1639. _app_options.AppOptions.set("disableFontFace", params.get(
  1640. "disablefontface") === "true");
  1641. }
  1642. if (params.has("disablehistory")) {
  1643. _app_options.AppOptions.set("disableHistory", params.get(
  1644. "disablehistory") === "true");
  1645. }
  1646. if (params.has("verbosity")) {
  1647. _app_options.AppOptions.set("verbosity", params.get("verbosity") | 0);
  1648. }
  1649. if (params.has("textlayer")) {
  1650. switch (params.get("textlayer")) {
  1651. case "off":
  1652. _app_options.AppOptions.set("textLayerMode", _ui_utils
  1653. .TextLayerMode.DISABLE);
  1654. break;
  1655. case "visible":
  1656. case "shadow":
  1657. case "hover":
  1658. viewerContainer.classList.add(
  1659. `textLayer-${params.get("textlayer")}`);
  1660. try {
  1661. await loadPDFBug(this);
  1662. this._PDFBug.loadCSS();
  1663. } catch (ex) {
  1664. console.error(`_parseHashParameters: "${ex.message}".`);
  1665. }
  1666. break;
  1667. }
  1668. }
  1669. if (params.has("pdfbug")) {
  1670. _app_options.AppOptions.set("pdfBug", true);
  1671. _app_options.AppOptions.set("fontExtraProperties", true);
  1672. const enabled = params.get("pdfbug").split(",");
  1673. try {
  1674. await loadPDFBug(this);
  1675. this._PDFBug.init({
  1676. OPS: _pdfjsLib.OPS
  1677. }, mainContainer, enabled);
  1678. } catch (ex) {
  1679. console.error(`_parseHashParameters: "${ex.message}".`);
  1680. }
  1681. }
  1682. if (params.has("locale")) {
  1683. _app_options.AppOptions.set("locale", params.get("locale"));
  1684. }
  1685. },
  1686. async _initializeL10n() {
  1687. this.l10n = this.externalServices.createL10n({
  1688. locale: _app_options.AppOptions.get("locale")
  1689. });
  1690. const dir = await this.l10n.getDirection();
  1691. document.getElementsByTagName("html")[0].dir = dir;
  1692. },
  1693. _forceCssTheme() {
  1694. const cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  1695. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme)
  1696. .includes(cssTheme)) {
  1697. return;
  1698. }
  1699. try {
  1700. const styleSheet = document.styleSheets[0];
  1701. const cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 :
  1702. styleSheet.cssRules) || [];
  1703. for (let i = 0, ii = cssRules.length; i < ii; i++) {
  1704. var _rule$media;
  1705. const rule = cssRules[i];
  1706. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) ===
  1707. null || _rule$media === void 0 ? void 0 : _rule$media[0]) ===
  1708. "(prefers-color-scheme: dark)") {
  1709. if (cssTheme === ViewerCssTheme.LIGHT) {
  1710. styleSheet.deleteRule(i);
  1711. return;
  1712. }
  1713. const darkRules =
  1714. /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/
  1715. .exec(rule.cssText);
  1716. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  1717. styleSheet.deleteRule(i);
  1718. styleSheet.insertRule(darkRules[1], i);
  1719. }
  1720. return;
  1721. }
  1722. }
  1723. } catch (reason) {
  1724. console.error(
  1725. `_forceCssTheme: "${reason === null || reason === void 0 ? void 0 : reason.message}".`
  1726. );
  1727. }
  1728. },
  1729. async _initializeViewerComponents() {
  1730. const {
  1731. appConfig,
  1732. externalServices
  1733. } = this;
  1734. const eventBus = externalServices.isInAutomation ? new _event_utils
  1735. .AutomationEventBus() : new _event_utils.EventBus();
  1736. this.eventBus = eventBus;
  1737. this.overlayManager = new _overlay_manager.OverlayManager();
  1738. const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  1739. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  1740. this.pdfRenderingQueue = pdfRenderingQueue;
  1741. const pdfLinkService = new _pdf_link_service.PDFLinkService({
  1742. eventBus,
  1743. externalLinkTarget: _app_options.AppOptions.get(
  1744. "externalLinkTarget"),
  1745. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  1746. ignoreDestinationZoom: _app_options.AppOptions.get(
  1747. "ignoreDestinationZoom")
  1748. });
  1749. this.pdfLinkService = pdfLinkService;
  1750. const downloadManager = externalServices.createDownloadManager();
  1751. this.downloadManager = downloadManager;
  1752. const findController = new _pdf_find_controller.PDFFindController({
  1753. linkService: pdfLinkService,
  1754. eventBus
  1755. });
  1756. this.findController = findController;
  1757. const pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  1758. eventBus,
  1759. sandboxBundleSrc: _app_options.AppOptions.get(
  1760. "sandboxBundleSrc"),
  1761. scriptingFactory: externalServices,
  1762. docPropertiesLookup: this._scriptingDocProperties.bind(this)
  1763. });
  1764. this.pdfScriptingManager = pdfScriptingManager;
  1765. const container = appConfig.mainContainer,
  1766. viewer = appConfig.viewerContainer;
  1767. const annotationEditorMode = _app_options.AppOptions.get(
  1768. "annotationEditorMode");
  1769. const pageColors = _app_options.AppOptions.get("forcePageColors") || window
  1770. .matchMedia("(forced-colors: active)").matches ? {
  1771. background: _app_options.AppOptions.get("pageColorsBackground"),
  1772. foreground: _app_options.AppOptions.get("pageColorsForeground")
  1773. } : null;
  1774. this.pdfViewer = new _pdf_viewer.PDFViewer({
  1775. container,
  1776. viewer,
  1777. eventBus,
  1778. renderingQueue: pdfRenderingQueue,
  1779. linkService: pdfLinkService,
  1780. downloadManager,
  1781. findController,
  1782. scriptingManager: _app_options.AppOptions.get(
  1783. "enableScripting") && pdfScriptingManager,
  1784. renderer: _app_options.AppOptions.get("renderer"),
  1785. l10n: this.l10n,
  1786. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  1787. annotationMode: _app_options.AppOptions.get("annotationMode"),
  1788. annotationEditorMode,
  1789. imageResourcesPath: _app_options.AppOptions.get(
  1790. "imageResourcesPath"),
  1791. enablePrintAutoRotate: _app_options.AppOptions.get(
  1792. "enablePrintAutoRotate"),
  1793. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  1794. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  1795. enablePermissions: _app_options.AppOptions.get(
  1796. "enablePermissions"),
  1797. pageColors
  1798. });
  1799. pdfRenderingQueue.setViewer(this.pdfViewer);
  1800. pdfLinkService.setViewer(this.pdfViewer);
  1801. pdfScriptingManager.setViewer(this.pdfViewer);
  1802. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  1803. container: appConfig.sidebar.thumbnailView,
  1804. eventBus,
  1805. renderingQueue: pdfRenderingQueue,
  1806. linkService: pdfLinkService,
  1807. l10n: this.l10n,
  1808. pageColors
  1809. });
  1810. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  1811. if (!this.isViewerEmbedded && !_app_options.AppOptions.get(
  1812. "disableHistory")) {
  1813. this.pdfHistory = new _pdf_history.PDFHistory({
  1814. linkService: pdfLinkService,
  1815. eventBus
  1816. });
  1817. pdfLinkService.setHistory(this.pdfHistory);
  1818. }
  1819. if (!this.supportsIntegratedFind) {
  1820. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus,
  1821. this.l10n);
  1822. }
  1823. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  1824. this.annotationEditorParams = new _annotation_editor_params
  1825. .AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  1826. for (const element of [document.getElementById("editorModeButtons"),
  1827. document.getElementById("editorModeSeparator")
  1828. ]) {
  1829. element.classList.remove("hidden");
  1830. }
  1831. }
  1832. this.pdfDocumentProperties = new _pdf_document_properties
  1833. .PDFDocumentProperties(appConfig.documentProperties, this
  1834. .overlayManager, eventBus, this.l10n, () => {
  1835. return this._docFilename;
  1836. });
  1837. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  1838. container,
  1839. eventBus,
  1840. cursorToolOnLoad: _app_options.AppOptions.get(
  1841. "cursorToolOnLoad")
  1842. });
  1843. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  1844. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig
  1845. .secondaryToolbar, eventBus);
  1846. if (this.supportsFullscreen) {
  1847. this.pdfPresentationMode = new _pdf_presentation_mode
  1848. .PDFPresentationMode({
  1849. container,
  1850. pdfViewer: this.pdfViewer,
  1851. eventBus
  1852. });
  1853. }
  1854. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig
  1855. .passwordOverlay, this.overlayManager, this.l10n, this
  1856. .isViewerEmbedded);
  1857. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  1858. container: appConfig.sidebar.outlineView,
  1859. eventBus,
  1860. linkService: pdfLinkService
  1861. });
  1862. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  1863. container: appConfig.sidebar.attachmentsView,
  1864. eventBus,
  1865. downloadManager
  1866. });
  1867. this.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  1868. container: appConfig.sidebar.layersView,
  1869. eventBus,
  1870. l10n: this.l10n
  1871. });
  1872. this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  1873. elements: appConfig.sidebar,
  1874. pdfViewer: this.pdfViewer,
  1875. pdfThumbnailViewer: this.pdfThumbnailViewer,
  1876. eventBus,
  1877. l10n: this.l10n
  1878. });
  1879. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  1880. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(
  1881. appConfig.sidebarResizer, eventBus, this.l10n);
  1882. },
  1883. run(config) {
  1884. this.initialize(config).then(webViewerInitialized);
  1885. },
  1886. get initialized() {
  1887. return this._initializedCapability.settled;
  1888. },
  1889. get initializedPromise() {
  1890. return this._initializedCapability.promise;
  1891. },
  1892. zoomIn(steps) {
  1893. if (this.pdfViewer.isInPresentationMode) {
  1894. return;
  1895. }
  1896. this.pdfViewer.increaseScale(steps);
  1897. },
  1898. zoomOut(steps) {
  1899. if (this.pdfViewer.isInPresentationMode) {
  1900. return;
  1901. }
  1902. this.pdfViewer.decreaseScale(steps);
  1903. },
  1904. zoomReset() {
  1905. if (this.pdfViewer.isInPresentationMode) {
  1906. return;
  1907. }
  1908. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1909. },
  1910. get pagesCount() {
  1911. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1912. },
  1913. get page() {
  1914. return this.pdfViewer.currentPageNumber;
  1915. },
  1916. set page(val) {
  1917. this.pdfViewer.currentPageNumber = val;
  1918. },
  1919. get supportsPrinting() {
  1920. return PDFPrintServiceFactory.instance.supportsPrinting;
  1921. },
  1922. get supportsFullscreen() {
  1923. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document
  1924. .fullscreenEnabled);
  1925. },
  1926. get supportsIntegratedFind() {
  1927. return this.externalServices.supportsIntegratedFind;
  1928. },
  1929. get supportsDocumentFonts() {
  1930. return this.externalServices.supportsDocumentFonts;
  1931. },
  1932. get loadingBar() {
  1933. const bar = new _ui_utils.ProgressBar("loadingBar");
  1934. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1935. },
  1936. get supportedMouseWheelZoomModifierKeys() {
  1937. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  1938. },
  1939. initPassiveLoading() {
  1940. throw new Error("Not implemented: initPassiveLoading");
  1941. },
  1942. setTitleUsingUrl() {
  1943. let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  1944. "";
  1945. let downloadUrl = arguments.length > 1 && arguments[1] !== undefined ?
  1946. arguments[1] : null;
  1947. this.url = url;
  1948. this.baseUrl = url.split("#")[0];
  1949. if (downloadUrl) {
  1950. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split(
  1951. "#")[0];
  1952. }
  1953. let title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  1954. if (!title) {
  1955. try {
  1956. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) ||
  1957. url;
  1958. } catch (ex) {
  1959. title = url;
  1960. }
  1961. }
  1962. this.setTitle(title);
  1963. },
  1964. setTitle() {
  1965. let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  1966. this._title;
  1967. this._title = title;
  1968. if (this.isViewerEmbedded) {
  1969. return;
  1970. }
  1971. document.title = `${this._hasAnnotationEditors ? "* " : ""}${title}`;
  1972. },
  1973. get _docFilename() {
  1974. return this._contentDispositionFilename || (0, _pdfjsLib
  1975. .getPdfFilenameFromUrl)(this.url);
  1976. },
  1977. _hideViewBookmark() {
  1978. const {
  1979. toolbar,
  1980. secondaryToolbar
  1981. } = this.appConfig;
  1982. toolbar.viewBookmark.hidden = true;
  1983. secondaryToolbar.viewBookmarkButton.hidden = true;
  1984. },
  1985. _cancelIdleCallbacks() {
  1986. if (!this._idleCallbacks.size) {
  1987. return;
  1988. }
  1989. for (const callback of this._idleCallbacks) {
  1990. window.cancelIdleCallback(callback);
  1991. }
  1992. this._idleCallbacks.clear();
  1993. },
  1994. async close() {
  1995. var _this$pdfDocument, _this$pdfHistory, _this$findBar, _this$_PDFBug;
  1996. this._unblockDocumentLoadEvent();
  1997. this._hideViewBookmark();
  1998. const {
  1999. container
  2000. } = this.appConfig.errorWrapper;
  2001. container.hidden = true;
  2002. if (!this.pdfLoadingTask) {
  2003. return;
  2004. }
  2005. if (((_this$pdfDocument = this.pdfDocument) === null ||
  2006. _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument
  2007. .annotationStorage.size) > 0 && this._annotationStorageModified) {
  2008. try {
  2009. await this.save();
  2010. } catch (reason) {}
  2011. }
  2012. const promises = [];
  2013. promises.push(this.pdfLoadingTask.destroy());
  2014. this.pdfLoadingTask = null;
  2015. if (this.pdfDocument) {
  2016. this.pdfDocument = null;
  2017. this.pdfThumbnailViewer.setDocument(null);
  2018. this.pdfViewer.setDocument(null);
  2019. this.pdfLinkService.setDocument(null);
  2020. this.pdfDocumentProperties.setDocument(null);
  2021. }
  2022. this.pdfLinkService.externalLinkEnabled = true;
  2023. this.store = null;
  2024. this.isInitialViewSet = false;
  2025. this.downloadComplete = false;
  2026. this.url = "";
  2027. this.baseUrl = "";
  2028. this._downloadUrl = "";
  2029. this.documentInfo = null;
  2030. this.metadata = null;
  2031. this._contentDispositionFilename = null;
  2032. this._contentLength = null;
  2033. this._saveInProgress = false;
  2034. this._docStats = null;
  2035. this._hasAnnotationEditors = false;
  2036. this._cancelIdleCallbacks();
  2037. promises.push(this.pdfScriptingManager.destroyPromise);
  2038. this.setTitle();
  2039. this.pdfSidebar.reset();
  2040. this.pdfOutlineViewer.reset();
  2041. this.pdfAttachmentViewer.reset();
  2042. this.pdfLayerViewer.reset();
  2043. (_this$pdfHistory = this.pdfHistory) === null || _this$pdfHistory ===
  2044. void 0 ? void 0 : _this$pdfHistory.reset();
  2045. (_this$findBar = this.findBar) === null || _this$findBar === void 0 ?
  2046. void 0 : _this$findBar.reset();
  2047. this.toolbar.reset();
  2048. this.secondaryToolbar.reset();
  2049. (_this$_PDFBug = this._PDFBug) === null || _this$_PDFBug === void 0 ?
  2050. void 0 : _this$_PDFBug.cleanup();
  2051. await Promise.all(promises);
  2052. },
  2053. async open(file, args) {
  2054. if (this.pdfLoadingTask) {
  2055. await this.close();
  2056. }
  2057. const workerParameters = _app_options.AppOptions.getAll(_app_options
  2058. .OptionKind.WORKER);
  2059. for (const key in workerParameters) {
  2060. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  2061. }
  2062. const parameters = Object.create(null);
  2063. if (typeof file === "string") {
  2064. this.setTitleUsingUrl(file, file);
  2065. parameters.url = file;
  2066. } else if (file && "byteLength" in file) {
  2067. parameters.data = file;
  2068. } else if (file.url && file.originalUrl) {
  2069. this.setTitleUsingUrl(file.originalUrl, file.url);
  2070. parameters.url = file.url;
  2071. }
  2072. const apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind
  2073. .API);
  2074. for (const key in apiParameters) {
  2075. let value = apiParameters[key];
  2076. if (key === "docBaseUrl" && !value) {}
  2077. parameters[key] = value;
  2078. }
  2079. if (args) {
  2080. for (const key in args) {
  2081. parameters[key] = args[key];
  2082. }
  2083. }
  2084. const loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  2085. this.pdfLoadingTask = loadingTask;
  2086. loadingTask.onPassword = (updateCallback, reason) => {
  2087. this.pdfLinkService.externalLinkEnabled = false;
  2088. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2089. this.passwordPrompt.open();
  2090. };
  2091. loadingTask.onProgress = _ref => {
  2092. let {
  2093. loaded,
  2094. total
  2095. } = _ref;
  2096. this.progress(loaded / total);
  2097. };
  2098. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  2099. return loadingTask.promise.then(pdfDocument => {
  2100. this.load(pdfDocument);
  2101. }, reason => {
  2102. if (loadingTask !== this.pdfLoadingTask) {
  2103. return undefined;
  2104. }
  2105. let key = "loading_error";
  2106. if (reason instanceof _pdfjsLib.InvalidPDFException) {
  2107. key = "invalid_file_error";
  2108. } else if (reason instanceof _pdfjsLib.MissingPDFException) {
  2109. key = "missing_file_error";
  2110. } else if (reason instanceof _pdfjsLib
  2111. .UnexpectedResponseException) {
  2112. key = "unexpected_response_error";
  2113. }
  2114. return this.l10n.get(key).then(msg => {
  2115. this._documentError(msg, {
  2116. message: reason === null || reason ===
  2117. void 0 ? void 0 : reason.message
  2118. });
  2119. throw reason;
  2120. });
  2121. });
  2122. },
  2123. _ensureDownloadComplete() {
  2124. if (this.pdfDocument && this.downloadComplete) {
  2125. return;
  2126. }
  2127. throw new Error("PDF document not downloaded.");
  2128. },
  2129. async download() {
  2130. const url = this._downloadUrl,
  2131. filename = this._docFilename;
  2132. try {
  2133. this._ensureDownloadComplete();
  2134. const data = await this.pdfDocument.getData();
  2135. const blob = new Blob([data], {
  2136. type: "application/pdf"
  2137. });
  2138. await this.downloadManager.download(blob, url, filename);
  2139. } catch (reason) {
  2140. await this.downloadManager.downloadUrl(url, filename);
  2141. }
  2142. },
  2143. async save() {
  2144. if (this._saveInProgress) {
  2145. return;
  2146. }
  2147. this._saveInProgress = true;
  2148. await this.pdfScriptingManager.dispatchWillSave();
  2149. const url = this._downloadUrl,
  2150. filename = this._docFilename;
  2151. try {
  2152. this._ensureDownloadComplete();
  2153. const data = await this.pdfDocument.saveDocument();
  2154. const blob = new Blob([data], {
  2155. type: "application/pdf"
  2156. });
  2157. await this.downloadManager.download(blob, url, filename);
  2158. } catch (reason) {
  2159. console.error(`Error when saving the document: ${reason.message}`);
  2160. await this.download();
  2161. } finally {
  2162. await this.pdfScriptingManager.dispatchDidSave();
  2163. this._saveInProgress = false;
  2164. }
  2165. if (this._hasAnnotationEditors) {
  2166. this.externalServices.reportTelemetry({
  2167. type: "editing",
  2168. data: {
  2169. type: "save"
  2170. }
  2171. });
  2172. }
  2173. },
  2174. downloadOrSave() {
  2175. var _this$pdfDocument2;
  2176. if (((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 ===
  2177. void 0 ? void 0 : _this$pdfDocument2.annotationStorage.size) > 0) {
  2178. this.save();
  2179. } else {
  2180. this.download();
  2181. }
  2182. },
  2183. fallback(featureId) {
  2184. this.externalServices.reportTelemetry({
  2185. type: "unsupportedFeature",
  2186. featureId
  2187. });
  2188. },
  2189. _documentError(message) {
  2190. var _moreInfo$message;
  2191. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  2192. 1] : null;
  2193. this._unblockDocumentLoadEvent();
  2194. this._otherError(message, moreInfo);
  2195. this.eventBus.dispatch("documenterror", {
  2196. source: this,
  2197. message,
  2198. reason: (_moreInfo$message = moreInfo === null || moreInfo ===
  2199. void 0 ? void 0 : moreInfo.message) !== null &&
  2200. _moreInfo$message !== void 0 ? _moreInfo$message : null
  2201. });
  2202. },
  2203. _otherError(message) {
  2204. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  2205. 1] : null;
  2206. const moreInfoText = [this.l10n.get("error_version_info", {
  2207. version: _pdfjsLib.version || "?",
  2208. build: _pdfjsLib.build || "?"
  2209. })];
  2210. if (moreInfo) {
  2211. moreInfoText.push(this.l10n.get("error_message", {
  2212. message: moreInfo.message
  2213. }));
  2214. if (moreInfo.stack) {
  2215. moreInfoText.push(this.l10n.get("error_stack", {
  2216. stack: moreInfo.stack
  2217. }));
  2218. } else {
  2219. if (moreInfo.filename) {
  2220. moreInfoText.push(this.l10n.get("error_file", {
  2221. file: moreInfo.filename
  2222. }));
  2223. }
  2224. if (moreInfo.lineNumber) {
  2225. moreInfoText.push(this.l10n.get("error_line", {
  2226. line: moreInfo.lineNumber
  2227. }));
  2228. }
  2229. }
  2230. }
  2231. const errorWrapperConfig = this.appConfig.errorWrapper;
  2232. const errorWrapper = errorWrapperConfig.container;
  2233. errorWrapper.hidden = false;
  2234. const errorMessage = errorWrapperConfig.errorMessage;
  2235. errorMessage.textContent = message;
  2236. const closeButton = errorWrapperConfig.closeButton;
  2237. closeButton.onclick = function() {
  2238. errorWrapper.hidden = true;
  2239. };
  2240. const errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  2241. const moreInfoButton = errorWrapperConfig.moreInfoButton;
  2242. const lessInfoButton = errorWrapperConfig.lessInfoButton;
  2243. moreInfoButton.onclick = function() {
  2244. errorMoreInfo.hidden = false;
  2245. moreInfoButton.hidden = true;
  2246. lessInfoButton.hidden = false;
  2247. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  2248. };
  2249. lessInfoButton.onclick = function() {
  2250. errorMoreInfo.hidden = true;
  2251. moreInfoButton.hidden = false;
  2252. lessInfoButton.hidden = true;
  2253. };
  2254. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  2255. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  2256. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  2257. moreInfoButton.hidden = false;
  2258. lessInfoButton.hidden = true;
  2259. Promise.all(moreInfoText).then(parts => {
  2260. errorMoreInfo.value = parts.join("\n");
  2261. });
  2262. },
  2263. progress(level) {
  2264. var _this$pdfDocument$loa, _this$pdfDocument3;
  2265. if (this.downloadComplete) {
  2266. return;
  2267. }
  2268. const percent = Math.round(level * 100);
  2269. if (percent <= this.loadingBar.percent) {
  2270. return;
  2271. }
  2272. this.loadingBar.percent = percent;
  2273. const disableAutoFetch = (_this$pdfDocument$loa = (_this$pdfDocument3 = this
  2274. .pdfDocument) === null || _this$pdfDocument3 === void 0 ? void 0 :
  2275. _this$pdfDocument3.loadingParams.disableAutoFetch) !== null &&
  2276. _this$pdfDocument$loa !== void 0 ? _this$pdfDocument$loa : _app_options
  2277. .AppOptions.get("disableAutoFetch");
  2278. if (!disableAutoFetch || isNaN(percent)) {
  2279. return;
  2280. }
  2281. if (this.disableAutoFetchLoadingBarTimeout) {
  2282. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  2283. this.disableAutoFetchLoadingBarTimeout = null;
  2284. }
  2285. this.loadingBar.show();
  2286. this.disableAutoFetchLoadingBarTimeout = setTimeout(() => {
  2287. this.loadingBar.hide();
  2288. this.disableAutoFetchLoadingBarTimeout = null;
  2289. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  2290. },
  2291. load(pdfDocument) {
  2292. this.pdfDocument = pdfDocument;
  2293. pdfDocument.getDownloadInfo().then(_ref2 => {
  2294. let {
  2295. length
  2296. } = _ref2;
  2297. this._contentLength = length;
  2298. this.downloadComplete = true;
  2299. this.loadingBar.hide();
  2300. firstPagePromise.then(() => {
  2301. this.eventBus.dispatch("documentloaded", {
  2302. source: this
  2303. });
  2304. });
  2305. });
  2306. const pageLayoutPromise = pdfDocument.getPageLayout().catch(function() {});
  2307. const pageModePromise = pdfDocument.getPageMode().catch(function() {});
  2308. const openActionPromise = pdfDocument.getOpenAction().catch(function() {});
  2309. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  2310. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  2311. let baseDocumentUrl;
  2312. baseDocumentUrl = null;
  2313. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  2314. this.pdfDocumentProperties.setDocument(pdfDocument);
  2315. const pdfViewer = this.pdfViewer;
  2316. pdfViewer.setDocument(pdfDocument);
  2317. const {
  2318. firstPagePromise,
  2319. onePageRendered,
  2320. pagesPromise
  2321. } = pdfViewer;
  2322. const pdfThumbnailViewer = this.pdfThumbnailViewer;
  2323. pdfThumbnailViewer.setDocument(pdfDocument);
  2324. const storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument
  2325. .fingerprints[0])).getMultiple({
  2326. page: null,
  2327. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  2328. scrollLeft: "0",
  2329. scrollTop: "0",
  2330. rotation: null,
  2331. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  2332. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  2333. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  2334. }).catch(() => {
  2335. return Object.create(null);
  2336. });
  2337. firstPagePromise.then(pdfPage => {
  2338. this.loadingBar.setWidth(this.appConfig.viewerContainer);
  2339. this._initializeAnnotationStorageCallbacks(pdfDocument);
  2340. Promise.all([_ui_utils.animationStarted, storedPromise,
  2341. pageLayoutPromise, pageModePromise, openActionPromise
  2342. ]).then(async _ref3 => {
  2343. let [timeStamp, stored, pageLayout, pageMode,
  2344. openAction
  2345. ] = _ref3;
  2346. const viewOnLoad = _app_options.AppOptions.get(
  2347. "viewOnLoad");
  2348. this._initializePdfHistory({
  2349. fingerprint: pdfDocument.fingerprints[
  2350. 0],
  2351. viewOnLoad,
  2352. initialDest: openAction === null ||
  2353. openAction === void 0 ? void 0 :
  2354. openAction.dest
  2355. });
  2356. const initialBookmark = this.initialBookmark;
  2357. const zoom = _app_options.AppOptions.get(
  2358. "defaultZoomValue");
  2359. let hash = zoom ? `zoom=${zoom}` : null;
  2360. let rotation = null;
  2361. let sidebarView = _app_options.AppOptions.get(
  2362. "sidebarViewOnLoad");
  2363. let scrollMode = _app_options.AppOptions.get(
  2364. "scrollModeOnLoad");
  2365. let spreadMode = _app_options.AppOptions.get(
  2366. "spreadModeOnLoad");
  2367. if (stored.page && viewOnLoad !== ViewOnLoad
  2368. .INITIAL) {
  2369. hash =
  2370. `page=${stored.page}&zoom=${zoom || stored.zoom},` +
  2371. `${stored.scrollLeft},${stored.scrollTop}`;
  2372. rotation = parseInt(stored.rotation, 10);
  2373. if (sidebarView === _ui_utils.SidebarView
  2374. .UNKNOWN) {
  2375. sidebarView = stored.sidebarView | 0;
  2376. }
  2377. if (scrollMode === _ui_utils.ScrollMode
  2378. .UNKNOWN) {
  2379. scrollMode = stored.scrollMode | 0;
  2380. }
  2381. if (spreadMode === _ui_utils.SpreadMode
  2382. .UNKNOWN) {
  2383. spreadMode = stored.spreadMode | 0;
  2384. }
  2385. }
  2386. if (pageMode && sidebarView === _ui_utils
  2387. .SidebarView.UNKNOWN) {
  2388. sidebarView = (0, _ui_utils
  2389. .apiPageModeToSidebarView)(pageMode);
  2390. }
  2391. if (pageLayout && scrollMode === _ui_utils
  2392. .ScrollMode.UNKNOWN && spreadMode === _ui_utils
  2393. .SpreadMode.UNKNOWN) {
  2394. const modes = (0, _ui_utils
  2395. .apiPageLayoutToViewerModes)(pageLayout);
  2396. spreadMode = modes.spreadMode;
  2397. }
  2398. this.setInitialView(hash, {
  2399. rotation,
  2400. sidebarView,
  2401. scrollMode,
  2402. spreadMode
  2403. });
  2404. this.eventBus.dispatch("documentinit", {
  2405. source: this
  2406. });
  2407. if (!this.isViewerEmbedded) {
  2408. pdfViewer.focus();
  2409. }
  2410. await Promise.race([pagesPromise, new Promise(
  2411. resolve => {
  2412. setTimeout(resolve,
  2413. FORCE_PAGES_LOADED_TIMEOUT
  2414. );
  2415. })]);
  2416. if (!initialBookmark && !hash) {
  2417. return;
  2418. }
  2419. if (pdfViewer.hasEqualPageSizes) {
  2420. return;
  2421. }
  2422. this.initialBookmark = initialBookmark;
  2423. pdfViewer.currentScaleValue = pdfViewer
  2424. .currentScaleValue;
  2425. this.setInitialView(hash);
  2426. }).catch(() => {
  2427. this.setInitialView();
  2428. }).then(function() {
  2429. pdfViewer.update();
  2430. });
  2431. });
  2432. pagesPromise.then(() => {
  2433. this._unblockDocumentLoadEvent();
  2434. this._initializeAutoPrint(pdfDocument, openActionPromise);
  2435. }, reason => {
  2436. this.l10n.get("loading_error").then(msg => {
  2437. this._documentError(msg, {
  2438. message: reason === null || reason ===
  2439. void 0 ? void 0 : reason.message
  2440. });
  2441. });
  2442. });
  2443. onePageRendered.then(data => {
  2444. this.externalServices.reportTelemetry({
  2445. type: "pageInfo",
  2446. timestamp: data.timestamp
  2447. });
  2448. pdfDocument.getOutline().then(outline => {
  2449. if (pdfDocument !== this.pdfDocument) {
  2450. return;
  2451. }
  2452. this.pdfOutlineViewer.render({
  2453. outline,
  2454. pdfDocument
  2455. });
  2456. });
  2457. pdfDocument.getAttachments().then(attachments => {
  2458. if (pdfDocument !== this.pdfDocument) {
  2459. return;
  2460. }
  2461. this.pdfAttachmentViewer.render({
  2462. attachments
  2463. });
  2464. });
  2465. pdfViewer.optionalContentConfigPromise.then(
  2466. optionalContentConfig => {
  2467. if (pdfDocument !== this.pdfDocument) {
  2468. return;
  2469. }
  2470. this.pdfLayerViewer.render({
  2471. optionalContentConfig,
  2472. pdfDocument
  2473. });
  2474. });
  2475. if ("requestIdleCallback" in window) {
  2476. const callback = window.requestIdleCallback(() => {
  2477. this._collectTelemetry(pdfDocument);
  2478. this._idleCallbacks.delete(callback);
  2479. }, {
  2480. timeout: 1000
  2481. });
  2482. this._idleCallbacks.add(callback);
  2483. }
  2484. });
  2485. this._initializePageLabels(pdfDocument);
  2486. this._initializeMetadata(pdfDocument);
  2487. },
  2488. async _scriptingDocProperties(pdfDocument) {
  2489. var _this$metadata, _this$metadata2;
  2490. if (!this.documentInfo) {
  2491. await new Promise(resolve => {
  2492. this.eventBus._on("metadataloaded", resolve, {
  2493. once: true
  2494. });
  2495. });
  2496. if (pdfDocument !== this.pdfDocument) {
  2497. return null;
  2498. }
  2499. }
  2500. if (!this._contentLength) {
  2501. await new Promise(resolve => {
  2502. this.eventBus._on("documentloaded", resolve, {
  2503. once: true
  2504. });
  2505. });
  2506. if (pdfDocument !== this.pdfDocument) {
  2507. return null;
  2508. }
  2509. }
  2510. return {
  2511. ...this.documentInfo,
  2512. baseURL: this.baseUrl,
  2513. filesize: this._contentLength,
  2514. filename: this._docFilename,
  2515. metadata: (_this$metadata = this.metadata) === null ||
  2516. _this$metadata === void 0 ? void 0 : _this$metadata.getRaw(),
  2517. authors: (_this$metadata2 = this.metadata) === null ||
  2518. _this$metadata2 === void 0 ? void 0 : _this$metadata2.get(
  2519. "dc:creator"),
  2520. numPages: this.pagesCount,
  2521. URL: this.url
  2522. };
  2523. },
  2524. async _collectTelemetry(pdfDocument) {
  2525. const markInfo = await this.pdfDocument.getMarkInfo();
  2526. if (pdfDocument !== this.pdfDocument) {
  2527. return;
  2528. }
  2529. const tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo
  2530. .Marked) || false;
  2531. this.externalServices.reportTelemetry({
  2532. type: "tagged",
  2533. tagged
  2534. });
  2535. },
  2536. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  2537. const [openAction, javaScript] = await Promise.all([openActionPromise, !this
  2538. .pdfViewer.enableScripting ? pdfDocument.getJavaScript() : null
  2539. ]);
  2540. if (pdfDocument !== this.pdfDocument) {
  2541. return;
  2542. }
  2543. let triggerAutoPrint = false;
  2544. if ((openAction === null || openAction === void 0 ? void 0 : openAction
  2545. .action) === "Print") {
  2546. triggerAutoPrint = true;
  2547. }
  2548. if (javaScript) {
  2549. javaScript.some(js => {
  2550. if (!js) {
  2551. return false;
  2552. }
  2553. console.warn("Warning: JavaScript support is not enabled");
  2554. this.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  2555. return true;
  2556. });
  2557. if (!triggerAutoPrint) {
  2558. for (const js of javaScript) {
  2559. if (js && _ui_utils.AutoPrintRegExp.test(js)) {
  2560. triggerAutoPrint = true;
  2561. break;
  2562. }
  2563. }
  2564. }
  2565. }
  2566. if (triggerAutoPrint) {
  2567. this.triggerPrinting();
  2568. }
  2569. },
  2570. async _initializeMetadata(pdfDocument) {
  2571. var _this$_contentDisposi, _this$_contentLength;
  2572. const {
  2573. info,
  2574. metadata,
  2575. contentDispositionFilename,
  2576. contentLength
  2577. } = await pdfDocument.getMetadata();
  2578. if (pdfDocument !== this.pdfDocument) {
  2579. return;
  2580. }
  2581. this.documentInfo = info;
  2582. this.metadata = metadata;
  2583. (_this$_contentDisposi = this._contentDispositionFilename) !== null &&
  2584. _this$_contentDisposi !== void 0 ? _this$_contentDisposi : this
  2585. ._contentDispositionFilename = contentDispositionFilename;
  2586. (_this$_contentLength = this._contentLength) !== null &&
  2587. _this$_contentLength !== void 0 ? _this$_contentLength : this
  2588. ._contentLength = contentLength;
  2589. console.log(
  2590. `PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` +
  2591. `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` +
  2592. `(PDF.js: ${_pdfjsLib.version || "-"})`);
  2593. let pdfTitle = info.Title;
  2594. const metadataTitle = metadata === null || metadata === void 0 ? void 0 :
  2595. metadata.get("dc:title");
  2596. if (metadataTitle) {
  2597. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(
  2598. metadataTitle)) {
  2599. pdfTitle = metadataTitle;
  2600. }
  2601. }
  2602. if (pdfTitle) {
  2603. this.setTitle(
  2604. `${pdfTitle} - ${this._contentDispositionFilename || this._title}`
  2605. );
  2606. } else if (this._contentDispositionFilename) {
  2607. this.setTitle(this._contentDispositionFilename);
  2608. }
  2609. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument
  2610. .isPureXfa) {
  2611. if (pdfDocument.loadingParams.enableXfa) {
  2612. console.warn("Warning: XFA Foreground documents are not supported");
  2613. } else {
  2614. console.warn("Warning: XFA support is not enabled");
  2615. }
  2616. this.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2617. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer
  2618. .renderForms) {
  2619. console.warn("Warning: Interactive form support is not enabled");
  2620. this.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2621. }
  2622. if (info.IsSignaturesPresent) {
  2623. console.warn("Warning: Digital signatures validation is not supported");
  2624. this.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.signatures);
  2625. }
  2626. let versionId = "other";
  2627. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  2628. versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
  2629. }
  2630. let generatorId = "other";
  2631. if (info.Producer) {
  2632. const producer = info.Producer.toLowerCase();
  2633. KNOWN_GENERATORS.some(function(generator) {
  2634. if (!producer.includes(generator)) {
  2635. return false;
  2636. }
  2637. generatorId = generator.replace(/[ .-]/g, "_");
  2638. return true;
  2639. });
  2640. }
  2641. let formType = null;
  2642. if (info.IsXFAPresent) {
  2643. formType = "xfa";
  2644. } else if (info.IsAcroFormPresent) {
  2645. formType = "acroform";
  2646. }
  2647. this.externalServices.reportTelemetry({
  2648. type: "documentInfo",
  2649. version: versionId,
  2650. generator: generatorId,
  2651. formType
  2652. });
  2653. this.eventBus.dispatch("metadataloaded", {
  2654. source: this
  2655. });
  2656. },
  2657. async _initializePageLabels(pdfDocument) {
  2658. const labels = await pdfDocument.getPageLabels();
  2659. if (pdfDocument !== this.pdfDocument) {
  2660. return;
  2661. }
  2662. if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
  2663. return;
  2664. }
  2665. const numLabels = labels.length;
  2666. let standardLabels = 0,
  2667. emptyLabels = 0;
  2668. for (let i = 0; i < numLabels; i++) {
  2669. const label = labels[i];
  2670. if (label === (i + 1).toString()) {
  2671. standardLabels++;
  2672. } else if (label === "") {
  2673. emptyLabels++;
  2674. } else {
  2675. break;
  2676. }
  2677. }
  2678. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  2679. return;
  2680. }
  2681. const {
  2682. pdfViewer,
  2683. pdfThumbnailViewer,
  2684. toolbar
  2685. } = this;
  2686. pdfViewer.setPageLabels(labels);
  2687. pdfThumbnailViewer.setPageLabels(labels);
  2688. toolbar.setPagesCount(numLabels, true);
  2689. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  2690. .currentPageLabel);
  2691. },
  2692. _initializePdfHistory(_ref4) {
  2693. let {
  2694. fingerprint,
  2695. viewOnLoad,
  2696. initialDest = null
  2697. } = _ref4;
  2698. if (!this.pdfHistory) {
  2699. return;
  2700. }
  2701. this.pdfHistory.initialize({
  2702. fingerprint,
  2703. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2704. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2705. });
  2706. if (this.pdfHistory.initialBookmark) {
  2707. this.initialBookmark = this.pdfHistory.initialBookmark;
  2708. this.initialRotation = this.pdfHistory.initialRotation;
  2709. }
  2710. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2711. this.initialBookmark = JSON.stringify(initialDest);
  2712. this.pdfHistory.push({
  2713. explicitDest: initialDest,
  2714. pageNumber: null
  2715. });
  2716. }
  2717. },
  2718. _initializeAnnotationStorageCallbacks(pdfDocument) {
  2719. if (pdfDocument !== this.pdfDocument) {
  2720. return;
  2721. }
  2722. const {
  2723. annotationStorage
  2724. } = pdfDocument;
  2725. annotationStorage.onSetModified = () => {
  2726. window.addEventListener("beforeunload", beforeUnload);
  2727. this._annotationStorageModified = true;
  2728. };
  2729. annotationStorage.onResetModified = () => {
  2730. window.removeEventListener("beforeunload", beforeUnload);
  2731. delete this._annotationStorageModified;
  2732. };
  2733. annotationStorage.onAnnotationEditor = typeStr => {
  2734. this._hasAnnotationEditors = !!typeStr;
  2735. this.setTitle();
  2736. if (typeStr) {
  2737. this.externalServices.reportTelemetry({
  2738. type: "editing",
  2739. data: {
  2740. type: typeStr
  2741. }
  2742. });
  2743. }
  2744. };
  2745. },
  2746. setInitialView(storedHash) {
  2747. let {
  2748. rotation,
  2749. sidebarView,
  2750. scrollMode,
  2751. spreadMode
  2752. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2753. const setRotation = angle => {
  2754. if ((0, _ui_utils.isValidRotation)(angle)) {
  2755. this.pdfViewer.pagesRotation = angle;
  2756. }
  2757. };
  2758. const setViewerModes = (scroll, spread) => {
  2759. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2760. this.pdfViewer.scrollMode = scroll;
  2761. }
  2762. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2763. this.pdfViewer.spreadMode = spread;
  2764. }
  2765. };
  2766. this.isInitialViewSet = true;
  2767. this.pdfSidebar.setInitialView(sidebarView);
  2768. setViewerModes(scrollMode, spreadMode);
  2769. if (this.initialBookmark) {
  2770. setRotation(this.initialRotation);
  2771. delete this.initialRotation;
  2772. this.pdfLinkService.setHash(this.initialBookmark);
  2773. this.initialBookmark = null;
  2774. } else if (storedHash) {
  2775. setRotation(rotation);
  2776. this.pdfLinkService.setHash(storedHash);
  2777. }
  2778. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer
  2779. .currentPageLabel);
  2780. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  2781. if (!this.pdfViewer.currentScaleValue) {
  2782. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2783. }
  2784. },
  2785. _cleanup() {
  2786. if (!this.pdfDocument) {
  2787. return;
  2788. }
  2789. this.pdfViewer.cleanup();
  2790. this.pdfThumbnailViewer.cleanup();
  2791. this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType
  2792. .SVG);
  2793. },
  2794. forceRendering() {
  2795. this.pdfRenderingQueue.printing = !!this.printService;
  2796. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.visibleView ===
  2797. _ui_utils.SidebarView.THUMBS;
  2798. this.pdfRenderingQueue.renderHighestPriority();
  2799. },
  2800. beforePrint() {
  2801. this._printAnnotationStoragePromise = this.pdfScriptingManager
  2802. .dispatchWillPrint().catch(() => {}).then(() => {
  2803. var _this$pdfDocument4;
  2804. return (_this$pdfDocument4 = this.pdfDocument) === null ||
  2805. _this$pdfDocument4 === void 0 ? void 0 : _this$pdfDocument4
  2806. .annotationStorage.print;
  2807. });
  2808. if (this.printService) {
  2809. return;
  2810. }
  2811. if (!this.supportsPrinting) {
  2812. this.l10n.get("printing_not_supported").then(msg => {
  2813. this._otherError(msg);
  2814. });
  2815. return;
  2816. }
  2817. if (!this.pdfViewer.pageViewsReady) {
  2818. this.l10n.get("printing_not_ready").then(msg => {
  2819. window.alert(msg);
  2820. });
  2821. return;
  2822. }
  2823. const pagesOverview = this.pdfViewer.getPagesOverview();
  2824. const printContainer = this.appConfig.printContainer;
  2825. const printResolution = _app_options.AppOptions.get("printResolution");
  2826. const optionalContentConfigPromise = this.pdfViewer
  2827. .optionalContentConfigPromise;
  2828. const printService = PDFPrintServiceFactory.instance.createPrintService(this
  2829. .pdfDocument, pagesOverview, printContainer, printResolution,
  2830. optionalContentConfigPromise, this._printAnnotationStoragePromise, this
  2831. .l10n);
  2832. this.printService = printService;
  2833. this.forceRendering();
  2834. printService.layout();
  2835. this.externalServices.reportTelemetry({
  2836. type: "print"
  2837. });
  2838. if (this._hasAnnotationEditors) {
  2839. this.externalServices.reportTelemetry({
  2840. type: "editing",
  2841. data: {
  2842. type: "print"
  2843. }
  2844. });
  2845. }
  2846. },
  2847. afterPrint() {
  2848. if (this._printAnnotationStoragePromise) {
  2849. this._printAnnotationStoragePromise.then(() => {
  2850. this.pdfScriptingManager.dispatchDidPrint();
  2851. });
  2852. this._printAnnotationStoragePromise = null;
  2853. }
  2854. if (this.printService) {
  2855. var _this$pdfDocument5;
  2856. this.printService.destroy();
  2857. this.printService = null;
  2858. (_this$pdfDocument5 = this.pdfDocument) === null || _this$pdfDocument5 ===
  2859. void 0 ? void 0 : _this$pdfDocument5.annotationStorage.resetModified();
  2860. }
  2861. this.forceRendering();
  2862. },
  2863. rotatePages(delta) {
  2864. this.pdfViewer.pagesRotation += delta;
  2865. },
  2866. requestPresentationMode() {
  2867. var _this$pdfPresentation;
  2868. (_this$pdfPresentation = this.pdfPresentationMode) === null ||
  2869. _this$pdfPresentation === void 0 ? void 0 : _this$pdfPresentation.request();
  2870. },
  2871. triggerPrinting() {
  2872. if (!this.supportsPrinting) {
  2873. return;
  2874. }
  2875. window.print();
  2876. },
  2877. bindEvents() {
  2878. const {
  2879. eventBus,
  2880. _boundEvents
  2881. } = this;
  2882. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2883. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2884. eventBus._on("resize", webViewerResize);
  2885. eventBus._on("hashchange", webViewerHashchange);
  2886. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2887. eventBus._on("afterprint", _boundEvents.afterPrint);
  2888. eventBus._on("pagerendered", webViewerPageRendered);
  2889. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2890. eventBus._on("pagechanging", webViewerPageChanging);
  2891. eventBus._on("scalechanging", webViewerScaleChanging);
  2892. eventBus._on("rotationchanging", webViewerRotationChanging);
  2893. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2894. eventBus._on("pagemode", webViewerPageMode);
  2895. eventBus._on("namedaction", webViewerNamedAction);
  2896. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2897. eventBus._on("presentationmode", webViewerPresentationMode);
  2898. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode);
  2899. eventBus._on("switchannotationeditorparams",
  2900. webViewerSwitchAnnotationEditorParams);
  2901. eventBus._on("print", webViewerPrint);
  2902. eventBus._on("download", webViewerDownload);
  2903. eventBus._on("firstpage", webViewerFirstPage);
  2904. eventBus._on("lastpage", webViewerLastPage);
  2905. eventBus._on("nextpage", webViewerNextPage);
  2906. eventBus._on("previouspage", webViewerPreviousPage);
  2907. eventBus._on("zoomin", webViewerZoomIn);
  2908. eventBus._on("zoomout", webViewerZoomOut);
  2909. eventBus._on("zoomreset", webViewerZoomReset);
  2910. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2911. eventBus._on("scalechanged", webViewerScaleChanged);
  2912. eventBus._on("rotatecw", webViewerRotateCw);
  2913. eventBus._on("rotateccw", webViewerRotateCcw);
  2914. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2915. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2916. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2917. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2918. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2919. eventBus._on("documentproperties", webViewerDocumentProperties);
  2920. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2921. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2922. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2923. if (_app_options.AppOptions.get("pdfBug")) {
  2924. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2925. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2926. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2927. }
  2928. eventBus._on("fileinputchange", webViewerFileInputChange);
  2929. eventBus._on("openfile", webViewerOpenFile);
  2930. },
  2931. bindWindowEvents() {
  2932. const {
  2933. eventBus,
  2934. _boundEvents
  2935. } = this;
  2936. function addWindowResolutionChange() {
  2937. let evt = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  2938. 0] : null;
  2939. if (evt) {
  2940. webViewerResolutionChange(evt);
  2941. }
  2942. const mediaQueryList = window.matchMedia(
  2943. `(resolution: ${window.devicePixelRatio || 1}dppx)`);
  2944. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  2945. once: true
  2946. });
  2947. _boundEvents.removeWindowResolutionChange || (_boundEvents
  2948. .removeWindowResolutionChange = function() {
  2949. mediaQueryList.removeEventListener("change",
  2950. addWindowResolutionChange);
  2951. _boundEvents.removeWindowResolutionChange = null;
  2952. });
  2953. }
  2954. addWindowResolutionChange();
  2955. _boundEvents.windowResize = () => {
  2956. eventBus.dispatch("resize", {
  2957. source: window
  2958. });
  2959. };
  2960. _boundEvents.windowHashChange = () => {
  2961. eventBus.dispatch("hashchange", {
  2962. source: window,
  2963. hash: document.location.hash.substring(1)
  2964. });
  2965. };
  2966. _boundEvents.windowBeforePrint = () => {
  2967. eventBus.dispatch("beforeprint", {
  2968. source: window
  2969. });
  2970. };
  2971. _boundEvents.windowAfterPrint = () => {
  2972. eventBus.dispatch("afterprint", {
  2973. source: window
  2974. });
  2975. };
  2976. _boundEvents.windowUpdateFromSandbox = event => {
  2977. eventBus.dispatch("updatefromsandbox", {
  2978. source: window,
  2979. detail: event.detail
  2980. });
  2981. };
  2982. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2983. window.addEventListener("wheel", webViewerWheel, {
  2984. passive: false
  2985. });
  2986. window.addEventListener("touchstart", webViewerTouchStart, {
  2987. passive: false
  2988. });
  2989. window.addEventListener("click", webViewerClick);
  2990. window.addEventListener("keydown", webViewerKeyDown);
  2991. window.addEventListener("resize", _boundEvents.windowResize);
  2992. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2993. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2994. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2995. window.addEventListener("updatefromsandbox", _boundEvents
  2996. .windowUpdateFromSandbox);
  2997. },
  2998. unbindEvents() {
  2999. const {
  3000. eventBus,
  3001. _boundEvents
  3002. } = this;
  3003. eventBus._off("resize", webViewerResize);
  3004. eventBus._off("hashchange", webViewerHashchange);
  3005. eventBus._off("beforeprint", _boundEvents.beforePrint);
  3006. eventBus._off("afterprint", _boundEvents.afterPrint);
  3007. eventBus._off("pagerendered", webViewerPageRendered);
  3008. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  3009. eventBus._off("pagechanging", webViewerPageChanging);
  3010. eventBus._off("scalechanging", webViewerScaleChanging);
  3011. eventBus._off("rotationchanging", webViewerRotationChanging);
  3012. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  3013. eventBus._off("pagemode", webViewerPageMode);
  3014. eventBus._off("namedaction", webViewerNamedAction);
  3015. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  3016. eventBus._off("presentationmode", webViewerPresentationMode);
  3017. eventBus._off("print", webViewerPrint);
  3018. eventBus._off("download", webViewerDownload);
  3019. eventBus._off("firstpage", webViewerFirstPage);
  3020. eventBus._off("lastpage", webViewerLastPage);
  3021. eventBus._off("nextpage", webViewerNextPage);
  3022. eventBus._off("previouspage", webViewerPreviousPage);
  3023. eventBus._off("zoomin", webViewerZoomIn);
  3024. eventBus._off("zoomout", webViewerZoomOut);
  3025. eventBus._off("zoomreset", webViewerZoomReset);
  3026. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  3027. eventBus._off("scalechanged", webViewerScaleChanged);
  3028. eventBus._off("rotatecw", webViewerRotateCw);
  3029. eventBus._off("rotateccw", webViewerRotateCcw);
  3030. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  3031. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  3032. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  3033. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  3034. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  3035. eventBus._off("documentproperties", webViewerDocumentProperties);
  3036. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  3037. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  3038. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  3039. if (_boundEvents.reportPageStatsPDFBug) {
  3040. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  3041. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  3042. _boundEvents.reportPageStatsPDFBug = null;
  3043. }
  3044. eventBus._off("fileinputchange", webViewerFileInputChange);
  3045. eventBus._off("openfile", webViewerOpenFile);
  3046. _boundEvents.beforePrint = null;
  3047. _boundEvents.afterPrint = null;
  3048. },
  3049. unbindWindowEvents() {
  3050. var _boundEvents$removeWi;
  3051. const {
  3052. _boundEvents
  3053. } = this;
  3054. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  3055. window.removeEventListener("wheel", webViewerWheel, {
  3056. passive: false
  3057. });
  3058. window.removeEventListener("touchstart", webViewerTouchStart, {
  3059. passive: false
  3060. });
  3061. window.removeEventListener("click", webViewerClick);
  3062. window.removeEventListener("keydown", webViewerKeyDown);
  3063. window.removeEventListener("resize", _boundEvents.windowResize);
  3064. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  3065. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  3066. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  3067. window.removeEventListener("updatefromsandbox", _boundEvents
  3068. .windowUpdateFromSandbox);
  3069. (_boundEvents$removeWi = _boundEvents.removeWindowResolutionChange) === null ||
  3070. _boundEvents$removeWi === void 0 ? void 0 : _boundEvents$removeWi.call(
  3071. _boundEvents);
  3072. _boundEvents.windowResize = null;
  3073. _boundEvents.windowHashChange = null;
  3074. _boundEvents.windowBeforePrint = null;
  3075. _boundEvents.windowAfterPrint = null;
  3076. _boundEvents.windowUpdateFromSandbox = null;
  3077. },
  3078. accumulateWheelTicks(ticks) {
  3079. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 &&
  3080. ticks > 0) {
  3081. this._wheelUnusedTicks = 0;
  3082. }
  3083. this._wheelUnusedTicks += ticks;
  3084. const wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this
  3085. ._wheelUnusedTicks));
  3086. this._wheelUnusedTicks -= wholeTicks;
  3087. return wholeTicks;
  3088. },
  3089. _unblockDocumentLoadEvent() {
  3090. var _document$blockUnbloc, _document;
  3091. (_document$blockUnbloc = (_document = document).blockUnblockOnload) === null ||
  3092. _document$blockUnbloc === void 0 ? void 0 : _document$blockUnbloc.call(
  3093. _document, false);
  3094. this._unblockDocumentLoadEvent = () => {};
  3095. },
  3096. _reportDocumentStatsTelemetry() {
  3097. const {
  3098. stats
  3099. } = this.pdfDocument;
  3100. if (stats !== this._docStats) {
  3101. this._docStats = stats;
  3102. this.externalServices.reportTelemetry({
  3103. type: "documentStats",
  3104. stats
  3105. });
  3106. }
  3107. },
  3108. get scriptingReady() {
  3109. return this.pdfScriptingManager.ready;
  3110. }
  3111. };
  3112. exports.PDFViewerApplication = PDFViewerApplication;
  3113. let validateFileURL; {
  3114. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io",
  3115. "https://mozilla.github.io"
  3116. ];
  3117. validateFileURL = function(file) {
  3118. if (!file) {
  3119. return;
  3120. }
  3121. try {
  3122. const viewerOrigin = new URL(window.location.href).origin || "null";
  3123. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  3124. return;
  3125. }
  3126. const fileOrigin = new URL(file, window.location.href).origin;
  3127. // if (fileOrigin !== viewerOrigin) {
  3128. // throw new Error("file origin does not match viewer's");
  3129. // }
  3130. } catch (ex) {
  3131. PDFViewerApplication.l10n.get("loading_error").then(msg => {
  3132. PDFViewerApplication._documentError(msg, {
  3133. message: ex === null || ex === void 0 ? void 0 : ex
  3134. .message
  3135. });
  3136. });
  3137. throw ex;
  3138. }
  3139. };
  3140. }
  3141. async function loadFakeWorker() {
  3142. _pdfjsLib.GlobalWorkerOptions.workerSrc || (_pdfjsLib.GlobalWorkerOptions
  3143. .workerSrc = _app_options.AppOptions.get("workerSrc"));
  3144. await (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.workerSrc);
  3145. }
  3146. async function loadPDFBug(self) {
  3147. const {
  3148. debuggerScriptPath
  3149. } = self.appConfig;
  3150. const {
  3151. PDFBug
  3152. } = await import(debuggerScriptPath);
  3153. self._PDFBug = PDFBug;
  3154. }
  3155. function reportPageStatsPDFBug(_ref5) {
  3156. var _globalThis$Stats, _pageView$pdfPage;
  3157. let {
  3158. pageNumber
  3159. } = _ref5;
  3160. if (!((_globalThis$Stats = globalThis.Stats) !== null && _globalThis$Stats !== void 0 &&
  3161. _globalThis$Stats.enabled)) {
  3162. return;
  3163. }
  3164. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3165. globalThis.Stats.add(pageNumber, pageView === null || pageView === void 0 ? void 0 : (
  3166. _pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage ===
  3167. void 0 ? void 0 : _pageView$pdfPage.stats);
  3168. }
  3169. function webViewerInitialized() {
  3170. var _params$get;
  3171. const {
  3172. appConfig,
  3173. eventBus
  3174. } = PDFViewerApplication;
  3175. let file;
  3176. const queryString = document.location.search.substring(1);
  3177. const params = (0, _ui_utils.parseQueryString)(queryString);
  3178. file = (_params$get = params.get("file")) !== null && _params$get !== void 0 ?
  3179. _params$get : _app_options.AppOptions.get("defaultUrl");
  3180. validateFileURL(file);
  3181. const fileInput = appConfig.openFileInput;
  3182. fileInput.value = null;
  3183. fileInput.addEventListener("change", function(evt) {
  3184. const {
  3185. files
  3186. } = evt.target;
  3187. if (!files || files.length === 0) {
  3188. return;
  3189. }
  3190. eventBus.dispatch("fileinputchange", {
  3191. source: this,
  3192. fileInput: evt.target
  3193. });
  3194. });
  3195. appConfig.mainContainer.addEventListener("dragover", function(evt) {
  3196. evt.preventDefault();
  3197. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ?
  3198. "copy" : "move";
  3199. });
  3200. appConfig.mainContainer.addEventListener("drop", function(evt) {
  3201. evt.preventDefault();
  3202. const {
  3203. files
  3204. } = evt.dataTransfer;
  3205. if (!files || files.length === 0) {
  3206. return;
  3207. }
  3208. eventBus.dispatch("fileinputchange", {
  3209. source: this,
  3210. fileInput: evt.dataTransfer
  3211. });
  3212. });
  3213. if (!PDFViewerApplication.supportsDocumentFonts) {
  3214. _app_options.AppOptions.set("disableFontFace", true);
  3215. PDFViewerApplication.l10n.get("web_fonts_disabled").then(msg => {
  3216. console.warn(msg);
  3217. });
  3218. }
  3219. if (!PDFViewerApplication.supportsPrinting) {
  3220. appConfig.toolbar.print.classList.add("hidden");
  3221. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  3222. }
  3223. if (!PDFViewerApplication.supportsFullscreen) {
  3224. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  3225. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  3226. }
  3227. if (PDFViewerApplication.supportsIntegratedFind) {
  3228. appConfig.toolbar.viewFind.classList.add("hidden");
  3229. }
  3230. appConfig.mainContainer.addEventListener("transitionend", function(evt) {
  3231. if (evt.target === this) {
  3232. eventBus.dispatch("resize", {
  3233. source: this
  3234. });
  3235. }
  3236. }, true);
  3237. try {
  3238. if (file) {
  3239. PDFViewerApplication.open(file);
  3240. } else {
  3241. PDFViewerApplication._hideViewBookmark();
  3242. }
  3243. } catch (reason) {
  3244. PDFViewerApplication.l10n.get("loading_error").then(msg => {
  3245. PDFViewerApplication._documentError(msg, reason);
  3246. });
  3247. }
  3248. }
  3249. function webViewerPageRendered(_ref6) {
  3250. let {
  3251. pageNumber,
  3252. error
  3253. } = _ref6;
  3254. if (pageNumber === PDFViewerApplication.page) {
  3255. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  3256. }
  3257. if (PDFViewerApplication.pdfSidebar.visibleView === _ui_utils.SidebarView.THUMBS) {
  3258. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3259. const thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(
  3260. pageNumber - 1);
  3261. if (pageView && thumbnailView) {
  3262. thumbnailView.setImage(pageView);
  3263. }
  3264. }
  3265. if (error) {
  3266. PDFViewerApplication.l10n.get("rendering_error").then(msg => {
  3267. PDFViewerApplication._otherError(msg, error);
  3268. });
  3269. }
  3270. PDFViewerApplication._reportDocumentStatsTelemetry();
  3271. }
  3272. function webViewerPageMode(_ref7) {
  3273. let {
  3274. mode
  3275. } = _ref7;
  3276. let view;
  3277. switch (mode) {
  3278. case "thumbs":
  3279. view = _ui_utils.SidebarView.THUMBS;
  3280. break;
  3281. case "bookmarks":
  3282. case "outline":
  3283. view = _ui_utils.SidebarView.OUTLINE;
  3284. break;
  3285. case "attachments":
  3286. view = _ui_utils.SidebarView.ATTACHMENTS;
  3287. break;
  3288. case "layers":
  3289. view = _ui_utils.SidebarView.LAYERS;
  3290. break;
  3291. case "none":
  3292. view = _ui_utils.SidebarView.NONE;
  3293. break;
  3294. default:
  3295. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3296. return;
  3297. }
  3298. PDFViewerApplication.pdfSidebar.switchView(view, true);
  3299. }
  3300. function webViewerNamedAction(evt) {
  3301. switch (evt.action) {
  3302. case "GoToPage":
  3303. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3304. break;
  3305. case "Find":
  3306. if (!PDFViewerApplication.supportsIntegratedFind) {
  3307. PDFViewerApplication.findBar.toggle();
  3308. }
  3309. break;
  3310. case "Print":
  3311. PDFViewerApplication.triggerPrinting();
  3312. break;
  3313. case "SaveAs":
  3314. PDFViewerApplication.downloadOrSave();
  3315. break;
  3316. }
  3317. }
  3318. function webViewerPresentationModeChanged(evt) {
  3319. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3320. }
  3321. function webViewerSidebarViewChanged(_ref8) {
  3322. let {
  3323. view
  3324. } = _ref8;
  3325. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils
  3326. .SidebarView.THUMBS;
  3327. if (PDFViewerApplication.isInitialViewSet) {
  3328. var _PDFViewerApplication;
  3329. (_PDFViewerApplication = PDFViewerApplication.store) === null ||
  3330. _PDFViewerApplication === void 0 ? void 0 : _PDFViewerApplication.set(
  3331. "sidebarView", view).catch(() => {});
  3332. }
  3333. }
  3334. function webViewerUpdateViewarea(_ref9) {
  3335. let {
  3336. location
  3337. } = _ref9;
  3338. if (PDFViewerApplication.isInitialViewSet) {
  3339. var _PDFViewerApplication2;
  3340. (_PDFViewerApplication2 = PDFViewerApplication.store) === null ||
  3341. _PDFViewerApplication2 === void 0 ? void 0 : _PDFViewerApplication2
  3342. .setMultiple({
  3343. page: location.pageNumber,
  3344. zoom: location.scale,
  3345. scrollLeft: location.left,
  3346. scrollTop: location.top,
  3347. rotation: location.rotation
  3348. }).catch(() => {});
  3349. }
  3350. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3351. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  3352. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3353. const currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication
  3354. .page - 1);
  3355. const loading = (currentPage === null || currentPage === void 0 ? void 0 : currentPage
  3356. .renderingState) !== _ui_utils.RenderingStates.FINISHED;
  3357. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  3358. }
  3359. function webViewerScrollModeChanged(evt) {
  3360. if (PDFViewerApplication.isInitialViewSet) {
  3361. var _PDFViewerApplication3;
  3362. (_PDFViewerApplication3 = PDFViewerApplication.store) === null ||
  3363. _PDFViewerApplication3 === void 0 ? void 0 : _PDFViewerApplication3.set(
  3364. "scrollMode", evt.mode).catch(() => {});
  3365. }
  3366. }
  3367. function webViewerSpreadModeChanged(evt) {
  3368. if (PDFViewerApplication.isInitialViewSet) {
  3369. var _PDFViewerApplication4;
  3370. (_PDFViewerApplication4 = PDFViewerApplication.store) === null ||
  3371. _PDFViewerApplication4 === void 0 ? void 0 : _PDFViewerApplication4.set(
  3372. "spreadMode", evt.mode).catch(() => {});
  3373. }
  3374. }
  3375. function webViewerResize() {
  3376. const {
  3377. pdfDocument,
  3378. pdfViewer,
  3379. pdfRenderingQueue
  3380. } = PDFViewerApplication;
  3381. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  3382. return;
  3383. }
  3384. pdfViewer.updateContainerHeightCss();
  3385. if (!pdfDocument) {
  3386. return;
  3387. }
  3388. const currentScaleValue = pdfViewer.currentScaleValue;
  3389. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" ||
  3390. currentScaleValue === "page-width") {
  3391. pdfViewer.currentScaleValue = currentScaleValue;
  3392. }
  3393. pdfViewer.update();
  3394. }
  3395. function webViewerHashchange(evt) {
  3396. var _PDFViewerApplication5;
  3397. const hash = evt.hash;
  3398. if (!hash) {
  3399. return;
  3400. }
  3401. if (!PDFViewerApplication.isInitialViewSet) {
  3402. PDFViewerApplication.initialBookmark = hash;
  3403. } else if (!((_PDFViewerApplication5 = PDFViewerApplication.pdfHistory) !== null &&
  3404. _PDFViewerApplication5 !== void 0 && _PDFViewerApplication5.popStateInProgress
  3405. )) {
  3406. PDFViewerApplication.pdfLinkService.setHash(hash);
  3407. }
  3408. }
  3409. {
  3410. var webViewerFileInputChange = function(evt) {
  3411. var _PDFViewerApplication6;
  3412. if ((_PDFViewerApplication6 = PDFViewerApplication.pdfViewer) !== null &&
  3413. _PDFViewerApplication6 !== void 0 && _PDFViewerApplication6
  3414. .isInPresentationMode) {
  3415. return;
  3416. }
  3417. const file = evt.fileInput.files[0];
  3418. let url = URL.createObjectURL(file);
  3419. if (file.name) {
  3420. url = {
  3421. url,
  3422. originalUrl: file.name
  3423. };
  3424. }
  3425. PDFViewerApplication.open(url);
  3426. };
  3427. var webViewerOpenFile = function(evt) {
  3428. const fileInput = PDFViewerApplication.appConfig.openFileInput;
  3429. fileInput.click();
  3430. };
  3431. }
  3432. function webViewerPresentationMode() {
  3433. PDFViewerApplication.requestPresentationMode();
  3434. }
  3435. function webViewerSwitchAnnotationEditorMode(evt) {
  3436. PDFViewerApplication.pdfViewer.annotationEditorMode = evt.mode;
  3437. }
  3438. function webViewerSwitchAnnotationEditorParams(evt) {
  3439. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  3440. }
  3441. function webViewerPrint() {
  3442. PDFViewerApplication.triggerPrinting();
  3443. }
  3444. function webViewerDownload() {
  3445. PDFViewerApplication.downloadOrSave();
  3446. }
  3447. function webViewerFirstPage() {
  3448. if (PDFViewerApplication.pdfDocument) {
  3449. PDFViewerApplication.page = 1;
  3450. }
  3451. }
  3452. function webViewerLastPage() {
  3453. if (PDFViewerApplication.pdfDocument) {
  3454. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3455. }
  3456. }
  3457. function webViewerNextPage() {
  3458. PDFViewerApplication.pdfViewer.nextPage();
  3459. }
  3460. function webViewerPreviousPage() {
  3461. PDFViewerApplication.pdfViewer.previousPage();
  3462. }
  3463. function webViewerZoomIn() {
  3464. PDFViewerApplication.zoomIn();
  3465. }
  3466. function webViewerZoomOut() {
  3467. PDFViewerApplication.zoomOut();
  3468. }
  3469. function webViewerZoomReset() {
  3470. PDFViewerApplication.zoomReset();
  3471. }
  3472. function webViewerPageNumberChanged(evt) {
  3473. const pdfViewer = PDFViewerApplication.pdfViewer;
  3474. if (evt.value !== "") {
  3475. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3476. }
  3477. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer
  3478. .currentPageLabel) {
  3479. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  3480. .currentPageLabel);
  3481. }
  3482. }
  3483. function webViewerScaleChanged(evt) {
  3484. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3485. }
  3486. function webViewerRotateCw() {
  3487. PDFViewerApplication.rotatePages(90);
  3488. }
  3489. function webViewerRotateCcw() {
  3490. PDFViewerApplication.rotatePages(-90);
  3491. }
  3492. function webViewerOptionalContentConfig(evt) {
  3493. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3494. }
  3495. function webViewerSwitchScrollMode(evt) {
  3496. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3497. }
  3498. function webViewerSwitchSpreadMode(evt) {
  3499. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3500. }
  3501. function webViewerDocumentProperties() {
  3502. PDFViewerApplication.pdfDocumentProperties.open();
  3503. }
  3504. function webViewerFindFromUrlHash(evt) {
  3505. PDFViewerApplication.eventBus.dispatch("find", {
  3506. source: evt.source,
  3507. type: "",
  3508. query: evt.query,
  3509. phraseSearch: evt.phraseSearch,
  3510. caseSensitive: false,
  3511. entireWord: false,
  3512. highlightAll: true,
  3513. findPrevious: false,
  3514. matchDiacritics: true
  3515. });
  3516. }
  3517. function webViewerUpdateFindMatchesCount(_ref10) {
  3518. let {
  3519. matchesCount
  3520. } = _ref10;
  3521. if (PDFViewerApplication.supportsIntegratedFind) {
  3522. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3523. } else {
  3524. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3525. }
  3526. }
  3527. function webViewerUpdateFindControlState(_ref11) {
  3528. let {
  3529. state,
  3530. previous,
  3531. matchesCount,
  3532. rawQuery
  3533. } = _ref11;
  3534. if (PDFViewerApplication.supportsIntegratedFind) {
  3535. PDFViewerApplication.externalServices.updateFindControlState({
  3536. result: state,
  3537. findPrevious: previous,
  3538. matchesCount,
  3539. rawQuery
  3540. });
  3541. } else {
  3542. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  3543. }
  3544. }
  3545. function webViewerScaleChanging(evt) {
  3546. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  3547. PDFViewerApplication.pdfViewer.update();
  3548. }
  3549. function webViewerRotationChanging(evt) {
  3550. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3551. PDFViewerApplication.forceRendering();
  3552. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3553. }
  3554. function webViewerPageChanging(_ref12) {
  3555. let {
  3556. pageNumber,
  3557. pageLabel
  3558. } = _ref12;
  3559. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  3560. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  3561. if (PDFViewerApplication.pdfSidebar.visibleView === _ui_utils.SidebarView.THUMBS) {
  3562. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  3563. }
  3564. }
  3565. function webViewerResolutionChange(evt) {
  3566. PDFViewerApplication.pdfViewer.refresh();
  3567. }
  3568. function webViewerVisibilityChange(evt) {
  3569. if (document.visibilityState === "visible") {
  3570. setZoomDisabledTimeout();
  3571. }
  3572. }
  3573. let zoomDisabledTimeout = null;
  3574. function setZoomDisabledTimeout() {
  3575. if (zoomDisabledTimeout) {
  3576. clearTimeout(zoomDisabledTimeout);
  3577. }
  3578. zoomDisabledTimeout = setTimeout(function() {
  3579. zoomDisabledTimeout = null;
  3580. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3581. }
  3582. function webViewerWheel(evt) {
  3583. const {
  3584. pdfViewer,
  3585. supportedMouseWheelZoomModifierKeys
  3586. } = PDFViewerApplication;
  3587. if (pdfViewer.isInPresentationMode) {
  3588. return;
  3589. }
  3590. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey &&
  3591. supportedMouseWheelZoomModifierKeys.metaKey) {
  3592. evt.preventDefault();
  3593. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3594. return;
  3595. }
  3596. const deltaMode = evt.deltaMode;
  3597. const delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3598. const previousScale = pdfViewer.currentScale;
  3599. let ticks = 0;
  3600. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent
  3601. .DOM_DELTA_PAGE) {
  3602. if (Math.abs(delta) >= 1) {
  3603. ticks = Math.sign(delta);
  3604. } else {
  3605. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  3606. }
  3607. } else {
  3608. const PIXELS_PER_LINE_SCALE = 30;
  3609. ticks = PDFViewerApplication.accumulateWheelTicks(delta /
  3610. PIXELS_PER_LINE_SCALE);
  3611. }
  3612. if (ticks < 0) {
  3613. PDFViewerApplication.zoomOut(-ticks);
  3614. } else if (ticks > 0) {
  3615. PDFViewerApplication.zoomIn(ticks);
  3616. }
  3617. const currentScale = pdfViewer.currentScale;
  3618. if (previousScale !== currentScale) {
  3619. const scaleCorrectionFactor = currentScale / previousScale - 1;
  3620. const rect = pdfViewer.container.getBoundingClientRect();
  3621. const dx = evt.clientX - rect.left;
  3622. const dy = evt.clientY - rect.top;
  3623. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  3624. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  3625. }
  3626. } else {
  3627. setZoomDisabledTimeout();
  3628. }
  3629. }
  3630. function webViewerTouchStart(evt) {
  3631. if (evt.touches.length > 1) {
  3632. evt.preventDefault();
  3633. }
  3634. }
  3635. function webViewerClick(evt) {
  3636. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  3637. return;
  3638. }
  3639. const appConfig = PDFViewerApplication.appConfig;
  3640. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar
  3641. .container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar
  3642. .toggleButton) {
  3643. PDFViewerApplication.secondaryToolbar.close();
  3644. }
  3645. }
  3646. function webViewerKeyDown(evt) {
  3647. if (PDFViewerApplication.overlayManager.active) {
  3648. return;
  3649. }
  3650. const {
  3651. eventBus,
  3652. pdfViewer
  3653. } = PDFViewerApplication;
  3654. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  3655. let handled = false,
  3656. ensureViewerFocused = false;
  3657. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt
  3658. .metaKey ? 8 : 0);
  3659. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3660. switch (evt.keyCode) {
  3661. case 70:
  3662. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3663. PDFViewerApplication.findBar.open();
  3664. handled = true;
  3665. }
  3666. break;
  3667. case 71:
  3668. if (!PDFViewerApplication.supportsIntegratedFind) {
  3669. const {
  3670. state
  3671. } = PDFViewerApplication.findController;
  3672. if (state) {
  3673. const eventState = Object.assign(Object.create(null), state, {
  3674. source: window,
  3675. type: "again",
  3676. findPrevious: cmd === 5 || cmd === 12
  3677. });
  3678. eventBus.dispatch("find", eventState);
  3679. }
  3680. handled = true;
  3681. }
  3682. break;
  3683. case 61:
  3684. case 107:
  3685. case 187:
  3686. case 171:
  3687. if (!isViewerInPresentationMode) {
  3688. PDFViewerApplication.zoomIn();
  3689. }
  3690. handled = true;
  3691. break;
  3692. case 173:
  3693. case 109:
  3694. case 189:
  3695. if (!isViewerInPresentationMode) {
  3696. PDFViewerApplication.zoomOut();
  3697. }
  3698. handled = true;
  3699. break;
  3700. case 48:
  3701. case 96:
  3702. if (!isViewerInPresentationMode) {
  3703. setTimeout(function() {
  3704. PDFViewerApplication.zoomReset();
  3705. });
  3706. handled = false;
  3707. }
  3708. break;
  3709. case 38:
  3710. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3711. PDFViewerApplication.page = 1;
  3712. handled = true;
  3713. ensureViewerFocused = true;
  3714. }
  3715. break;
  3716. case 40:
  3717. if (isViewerInPresentationMode || PDFViewerApplication.page <
  3718. PDFViewerApplication.pagesCount) {
  3719. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3720. handled = true;
  3721. ensureViewerFocused = true;
  3722. }
  3723. break;
  3724. }
  3725. }
  3726. if (cmd === 1 || cmd === 8) {
  3727. switch (evt.keyCode) {
  3728. case 83:
  3729. eventBus.dispatch("download", {
  3730. source: window
  3731. });
  3732. handled = true;
  3733. break;
  3734. case 79: {
  3735. eventBus.dispatch("openfile", {
  3736. source: window
  3737. });
  3738. handled = true;
  3739. }
  3740. break;
  3741. }
  3742. }
  3743. if (cmd === 3 || cmd === 10) {
  3744. switch (evt.keyCode) {
  3745. case 80:
  3746. PDFViewerApplication.requestPresentationMode();
  3747. handled = true;
  3748. break;
  3749. case 71:
  3750. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3751. handled = true;
  3752. break;
  3753. }
  3754. }
  3755. if (handled) {
  3756. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3757. pdfViewer.focus();
  3758. }
  3759. evt.preventDefault();
  3760. return;
  3761. }
  3762. const curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3763. const curElementTagName = curElement === null || curElement === void 0 ? void 0 :
  3764. curElement.tagName.toUpperCase();
  3765. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" ||
  3766. curElementTagName === "SELECT" || curElement !== null && curElement !== void 0 &&
  3767. curElement.isContentEditable) {
  3768. if (evt.keyCode !== 27) {
  3769. return;
  3770. }
  3771. }
  3772. if (cmd === 0) {
  3773. let turnPage = 0,
  3774. turnOnlyIfPageFit = false;
  3775. switch (evt.keyCode) {
  3776. case 38:
  3777. case 33:
  3778. if (pdfViewer.isVerticalScrollbarEnabled) {
  3779. turnOnlyIfPageFit = true;
  3780. }
  3781. turnPage = -1;
  3782. break;
  3783. case 8:
  3784. if (!isViewerInPresentationMode) {
  3785. turnOnlyIfPageFit = true;
  3786. }
  3787. turnPage = -1;
  3788. break;
  3789. case 37:
  3790. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3791. turnOnlyIfPageFit = true;
  3792. }
  3793. case 75:
  3794. case 80:
  3795. turnPage = -1;
  3796. break;
  3797. case 27:
  3798. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  3799. PDFViewerApplication.secondaryToolbar.close();
  3800. handled = true;
  3801. }
  3802. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication
  3803. .findBar.opened) {
  3804. PDFViewerApplication.findBar.close();
  3805. handled = true;
  3806. }
  3807. break;
  3808. case 40:
  3809. case 34:
  3810. if (pdfViewer.isVerticalScrollbarEnabled) {
  3811. turnOnlyIfPageFit = true;
  3812. }
  3813. turnPage = 1;
  3814. break;
  3815. case 13:
  3816. case 32:
  3817. if (!isViewerInPresentationMode) {
  3818. turnOnlyIfPageFit = true;
  3819. }
  3820. turnPage = 1;
  3821. break;
  3822. case 39:
  3823. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3824. turnOnlyIfPageFit = true;
  3825. }
  3826. case 74:
  3827. case 78:
  3828. turnPage = 1;
  3829. break;
  3830. case 36:
  3831. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3832. PDFViewerApplication.page = 1;
  3833. handled = true;
  3834. ensureViewerFocused = true;
  3835. }
  3836. break;
  3837. case 35:
  3838. if (isViewerInPresentationMode || PDFViewerApplication.page <
  3839. PDFViewerApplication.pagesCount) {
  3840. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3841. handled = true;
  3842. ensureViewerFocused = true;
  3843. }
  3844. break;
  3845. case 83:
  3846. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools
  3847. .CursorTool.SELECT);
  3848. break;
  3849. case 72:
  3850. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools
  3851. .CursorTool.HAND);
  3852. break;
  3853. case 82:
  3854. PDFViewerApplication.rotatePages(90);
  3855. break;
  3856. case 115:
  3857. PDFViewerApplication.pdfSidebar.toggle();
  3858. break;
  3859. }
  3860. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue ===
  3861. "page-fit")) {
  3862. if (turnPage > 0) {
  3863. pdfViewer.nextPage();
  3864. } else {
  3865. pdfViewer.previousPage();
  3866. }
  3867. handled = true;
  3868. }
  3869. }
  3870. if (cmd === 4) {
  3871. switch (evt.keyCode) {
  3872. case 13:
  3873. case 32:
  3874. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !==
  3875. "page-fit") {
  3876. break;
  3877. }
  3878. pdfViewer.previousPage();
  3879. handled = true;
  3880. break;
  3881. case 82:
  3882. PDFViewerApplication.rotatePages(-90);
  3883. break;
  3884. }
  3885. }
  3886. if (!handled && !isViewerInPresentationMode) {
  3887. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 &&
  3888. curElementTagName !== "BUTTON") {
  3889. ensureViewerFocused = true;
  3890. }
  3891. }
  3892. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3893. pdfViewer.focus();
  3894. }
  3895. if (handled) {
  3896. evt.preventDefault();
  3897. }
  3898. }
  3899. function beforeUnload(evt) {
  3900. evt.preventDefault();
  3901. evt.returnValue = "";
  3902. return false;
  3903. }
  3904. function webViewerAnnotationEditorStatesChanged(data) {
  3905. PDFViewerApplication.externalServices.updateEditorStates(data);
  3906. }
  3907. const PDFPrintServiceFactory = {
  3908. instance: {
  3909. supportsPrinting: false,
  3910. createPrintService() {
  3911. throw new Error("Not implemented: createPrintService");
  3912. }
  3913. }
  3914. };
  3915. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3916. /***/
  3917. }),
  3918. /* 5 */
  3919. /***/
  3920. ((module) => {
  3921. let pdfjsLib;
  3922. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  3923. pdfjsLib = window["pdfjs-dist/build/pdf"];
  3924. } else {
  3925. pdfjsLib = require("../build/pdf.js");
  3926. }
  3927. module.exports = pdfjsLib;
  3928. /***/
  3929. }),
  3930. /* 6 */
  3931. /***/
  3932. ((__unused_webpack_module, exports) => {
  3933. Object.defineProperty(exports, "__esModule", ({
  3934. value: true
  3935. }));
  3936. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  3937. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3938. const WaitOnType = {
  3939. EVENT: "event",
  3940. TIMEOUT: "timeout"
  3941. };
  3942. exports.WaitOnType = WaitOnType;
  3943. function waitOnEventOrTimeout(_ref) {
  3944. let {
  3945. target,
  3946. name,
  3947. delay = 0
  3948. } = _ref;
  3949. return new Promise(function(resolve, reject) {
  3950. if (typeof target !== "object" || !(name && typeof name === "string") || !(
  3951. Number.isInteger(delay) && delay >= 0)) {
  3952. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3953. }
  3954. function handler(type) {
  3955. if (target instanceof EventBus) {
  3956. target._off(name, eventHandler);
  3957. } else {
  3958. target.removeEventListener(name, eventHandler);
  3959. }
  3960. if (timeout) {
  3961. clearTimeout(timeout);
  3962. }
  3963. resolve(type);
  3964. }
  3965. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  3966. if (target instanceof EventBus) {
  3967. target._on(name, eventHandler);
  3968. } else {
  3969. target.addEventListener(name, eventHandler);
  3970. }
  3971. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3972. const timeout = setTimeout(timeoutHandler, delay);
  3973. });
  3974. }
  3975. class EventBus {
  3976. constructor() {
  3977. this._listeners = Object.create(null);
  3978. }
  3979. on(eventName, listener) {
  3980. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  3981. 2] : null;
  3982. this._on(eventName, listener, {
  3983. external: true,
  3984. once: options === null || options === void 0 ? void 0 : options.once
  3985. });
  3986. }
  3987. off(eventName, listener) {
  3988. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  3989. 2] : null;
  3990. this._off(eventName, listener, {
  3991. external: true,
  3992. once: options === null || options === void 0 ? void 0 : options.once
  3993. });
  3994. }
  3995. dispatch(eventName, data) {
  3996. const eventListeners = this._listeners[eventName];
  3997. if (!eventListeners || eventListeners.length === 0) {
  3998. return;
  3999. }
  4000. let externalListeners;
  4001. for (const {
  4002. listener,
  4003. external,
  4004. once
  4005. } of eventListeners.slice(0)) {
  4006. if (once) {
  4007. this._off(eventName, listener);
  4008. }
  4009. if (external) {
  4010. (externalListeners || (externalListeners = [])).push(listener);
  4011. continue;
  4012. }
  4013. listener(data);
  4014. }
  4015. if (externalListeners) {
  4016. for (const listener of externalListeners) {
  4017. listener(data);
  4018. }
  4019. externalListeners = null;
  4020. }
  4021. }
  4022. _on(eventName, listener) {
  4023. var _this$_listeners;
  4024. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  4025. 2] : null;
  4026. const eventListeners = (_this$_listeners = this._listeners)[eventName] || (
  4027. _this$_listeners[eventName] = []);
  4028. eventListeners.push({
  4029. listener,
  4030. external: (options === null || options === void 0 ? void 0 : options
  4031. .external) === true,
  4032. once: (options === null || options === void 0 ? void 0 : options
  4033. .once) === true
  4034. });
  4035. }
  4036. _off(eventName, listener) {
  4037. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  4038. 2] : null;
  4039. const eventListeners = this._listeners[eventName];
  4040. if (!eventListeners) {
  4041. return;
  4042. }
  4043. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  4044. if (eventListeners[i].listener === listener) {
  4045. eventListeners.splice(i, 1);
  4046. return;
  4047. }
  4048. }
  4049. }
  4050. }
  4051. exports.EventBus = EventBus;
  4052. class AutomationEventBus extends EventBus {
  4053. dispatch(eventName, data) {
  4054. throw new Error("Not implemented: AutomationEventBus.dispatch");
  4055. }
  4056. }
  4057. exports.AutomationEventBus = AutomationEventBus;
  4058. /***/
  4059. }),
  4060. /* 7 */
  4061. /***/
  4062. ((__unused_webpack_module, exports, __webpack_require__) => {
  4063. Object.defineProperty(exports, "__esModule", ({
  4064. value: true
  4065. }));
  4066. exports.PDFCursorTools = exports.CursorTool = void 0;
  4067. var _grab_to_pan = __webpack_require__(8);
  4068. var _ui_utils = __webpack_require__(1);
  4069. function _classPrivateMethodInitSpec(obj, privateSet) {
  4070. _checkPrivateRedeclaration(obj, privateSet);
  4071. privateSet.add(obj);
  4072. }
  4073. function _checkPrivateRedeclaration(obj, privateCollection) {
  4074. if (privateCollection.has(obj)) {
  4075. throw new TypeError(
  4076. "Cannot initialize the same private elements twice on an object");
  4077. }
  4078. }
  4079. function _classPrivateMethodGet(receiver, privateSet, fn) {
  4080. if (!privateSet.has(receiver)) {
  4081. throw new TypeError("attempted to get private field on non-instance");
  4082. }
  4083. return fn;
  4084. }
  4085. const CursorTool = {
  4086. SELECT: 0,
  4087. HAND: 1,
  4088. ZOOM: 2
  4089. };
  4090. exports.CursorTool = CursorTool;
  4091. var _dispatchEvent = /*#__PURE__*/ new WeakSet();
  4092. var _addEventListeners = /*#__PURE__*/ new WeakSet();
  4093. class PDFCursorTools {
  4094. constructor(_ref) {
  4095. let {
  4096. container,
  4097. eventBus,
  4098. cursorToolOnLoad = CursorTool.SELECT
  4099. } = _ref;
  4100. _classPrivateMethodInitSpec(this, _addEventListeners);
  4101. _classPrivateMethodInitSpec(this, _dispatchEvent);
  4102. this.container = container;
  4103. this.eventBus = eventBus;
  4104. this.active = CursorTool.SELECT;
  4105. this.activeBeforePresentationMode = null;
  4106. this.handTool = new _grab_to_pan.GrabToPan({
  4107. element: this.container
  4108. });
  4109. _classPrivateMethodGet(this, _addEventListeners, _addEventListeners2).call(
  4110. this);
  4111. Promise.resolve().then(() => {
  4112. this.switchTool(cursorToolOnLoad);
  4113. });
  4114. }
  4115. get activeTool() {
  4116. return this.active;
  4117. }
  4118. switchTool(tool) {
  4119. if (this.activeBeforePresentationMode !== null) {
  4120. return;
  4121. }
  4122. if (tool === this.active) {
  4123. return;
  4124. }
  4125. const disableActiveTool = () => {
  4126. switch (this.active) {
  4127. case CursorTool.SELECT:
  4128. break;
  4129. case CursorTool.HAND:
  4130. this.handTool.deactivate();
  4131. break;
  4132. case CursorTool.ZOOM:
  4133. }
  4134. };
  4135. switch (tool) {
  4136. case CursorTool.SELECT:
  4137. disableActiveTool();
  4138. break;
  4139. case CursorTool.HAND:
  4140. disableActiveTool();
  4141. this.handTool.activate();
  4142. break;
  4143. case CursorTool.ZOOM:
  4144. default:
  4145. console.error(`switchTool: "${tool}" is an unsupported value.`);
  4146. return;
  4147. }
  4148. this.active = tool;
  4149. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  4150. }
  4151. }
  4152. exports.PDFCursorTools = PDFCursorTools;
  4153. function _dispatchEvent2() {
  4154. this.eventBus.dispatch("cursortoolchanged", {
  4155. source: this,
  4156. tool: this.active
  4157. });
  4158. }
  4159. function _addEventListeners2() {
  4160. this.eventBus._on("switchcursortool", evt => {
  4161. this.switchTool(evt.tool);
  4162. });
  4163. this.eventBus._on("presentationmodechanged", evt => {
  4164. switch (evt.state) {
  4165. case _ui_utils.PresentationModeState.FULLSCREEN: {
  4166. const previouslyActive = this.active;
  4167. this.switchTool(CursorTool.SELECT);
  4168. this.activeBeforePresentationMode = previouslyActive;
  4169. break;
  4170. }
  4171. case _ui_utils.PresentationModeState.NORMAL: {
  4172. const previouslyActive = this.activeBeforePresentationMode;
  4173. this.activeBeforePresentationMode = null;
  4174. this.switchTool(previouslyActive);
  4175. break;
  4176. }
  4177. }
  4178. });
  4179. }
  4180. /***/
  4181. }),
  4182. /* 8 */
  4183. /***/
  4184. ((__unused_webpack_module, exports) => {
  4185. Object.defineProperty(exports, "__esModule", ({
  4186. value: true
  4187. }));
  4188. exports.GrabToPan = void 0;
  4189. function _classPrivateMethodInitSpec(obj, privateSet) {
  4190. _checkPrivateRedeclaration(obj, privateSet);
  4191. privateSet.add(obj);
  4192. }
  4193. function _checkPrivateRedeclaration(obj, privateCollection) {
  4194. if (privateCollection.has(obj)) {
  4195. throw new TypeError(
  4196. "Cannot initialize the same private elements twice on an object");
  4197. }
  4198. }
  4199. function _classPrivateMethodGet(receiver, privateSet, fn) {
  4200. if (!privateSet.has(receiver)) {
  4201. throw new TypeError("attempted to get private field on non-instance");
  4202. }
  4203. return fn;
  4204. }
  4205. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  4206. var _onMouseDown = /*#__PURE__*/ new WeakSet();
  4207. var _onMouseMove = /*#__PURE__*/ new WeakSet();
  4208. var _endPan = /*#__PURE__*/ new WeakSet();
  4209. class GrabToPan {
  4210. constructor(options) {
  4211. _classPrivateMethodInitSpec(this, _endPan);
  4212. _classPrivateMethodInitSpec(this, _onMouseMove);
  4213. _classPrivateMethodInitSpec(this, _onMouseDown);
  4214. this.element = options.element;
  4215. this.document = options.element.ownerDocument;
  4216. if (typeof options.ignoreTarget === "function") {
  4217. this.ignoreTarget = options.ignoreTarget;
  4218. }
  4219. this.onActiveChanged = options.onActiveChanged;
  4220. this.activate = this.activate.bind(this);
  4221. this.deactivate = this.deactivate.bind(this);
  4222. this.toggle = this.toggle.bind(this);
  4223. this._onMouseDown = _classPrivateMethodGet(this, _onMouseDown, _onMouseDown2)
  4224. .bind(this);
  4225. this._onMouseMove = _classPrivateMethodGet(this, _onMouseMove, _onMouseMove2)
  4226. .bind(this);
  4227. this._endPan = _classPrivateMethodGet(this, _endPan, _endPan2).bind(this);
  4228. const overlay = this.overlay = document.createElement("div");
  4229. overlay.className = "grab-to-pan-grabbing";
  4230. }
  4231. activate() {
  4232. if (!this.active) {
  4233. var _this$onActiveChanged;
  4234. this.active = true;
  4235. this.element.addEventListener("mousedown", this._onMouseDown, true);
  4236. this.element.classList.add(CSS_CLASS_GRAB);
  4237. (_this$onActiveChanged = this.onActiveChanged) === null ||
  4238. _this$onActiveChanged === void 0 ? void 0 : _this$onActiveChanged.call(
  4239. this, true);
  4240. }
  4241. }
  4242. deactivate() {
  4243. if (this.active) {
  4244. var _this$onActiveChanged2;
  4245. this.active = false;
  4246. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  4247. this._endPan();
  4248. this.element.classList.remove(CSS_CLASS_GRAB);
  4249. (_this$onActiveChanged2 = this.onActiveChanged) === null ||
  4250. _this$onActiveChanged2 === void 0 ? void 0 : _this$onActiveChanged2
  4251. .call(this, false);
  4252. }
  4253. }
  4254. toggle() {
  4255. if (this.active) {
  4256. this.deactivate();
  4257. } else {
  4258. this.activate();
  4259. }
  4260. }
  4261. ignoreTarget(node) {
  4262. return node.matches(
  4263. "a[href], a[href] *, input, textarea, button, button *, select, option");
  4264. }
  4265. }
  4266. exports.GrabToPan = GrabToPan;
  4267. function _onMouseDown2(event) {
  4268. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4269. return;
  4270. }
  4271. if (event.originalTarget) {
  4272. try {
  4273. event.originalTarget.tagName;
  4274. } catch (e) {
  4275. return;
  4276. }
  4277. }
  4278. this.scrollLeftStart = this.element.scrollLeft;
  4279. this.scrollTopStart = this.element.scrollTop;
  4280. this.clientXStart = event.clientX;
  4281. this.clientYStart = event.clientY;
  4282. this.document.addEventListener("mousemove", this._onMouseMove, true);
  4283. this.document.addEventListener("mouseup", this._endPan, true);
  4284. this.element.addEventListener("scroll", this._endPan, true);
  4285. event.preventDefault();
  4286. event.stopPropagation();
  4287. const focusedElement = document.activeElement;
  4288. if (focusedElement && !focusedElement.contains(event.target)) {
  4289. focusedElement.blur();
  4290. }
  4291. }
  4292. function _onMouseMove2(event) {
  4293. this.element.removeEventListener("scroll", this._endPan, true);
  4294. if (!(event.buttons & 1)) {
  4295. this._endPan();
  4296. return;
  4297. }
  4298. const xDiff = event.clientX - this.clientXStart;
  4299. const yDiff = event.clientY - this.clientYStart;
  4300. const scrollTop = this.scrollTopStart - yDiff;
  4301. const scrollLeft = this.scrollLeftStart - xDiff;
  4302. if (this.element.scrollTo) {
  4303. this.element.scrollTo({
  4304. top: scrollTop,
  4305. left: scrollLeft,
  4306. behavior: "instant"
  4307. });
  4308. } else {
  4309. this.element.scrollTop = scrollTop;
  4310. this.element.scrollLeft = scrollLeft;
  4311. }
  4312. if (!this.overlay.parentNode) {
  4313. document.body.append(this.overlay);
  4314. }
  4315. }
  4316. function _endPan2() {
  4317. this.element.removeEventListener("scroll", this._endPan, true);
  4318. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  4319. this.document.removeEventListener("mouseup", this._endPan, true);
  4320. this.overlay.remove();
  4321. }
  4322. /***/
  4323. }),
  4324. /* 9 */
  4325. /***/
  4326. ((__unused_webpack_module, exports, __webpack_require__) => {
  4327. Object.defineProperty(exports, "__esModule", ({
  4328. value: true
  4329. }));
  4330. exports.AnnotationEditorParams = void 0;
  4331. var _pdfjsLib = __webpack_require__(5);
  4332. function _classPrivateMethodInitSpec(obj, privateSet) {
  4333. _checkPrivateRedeclaration(obj, privateSet);
  4334. privateSet.add(obj);
  4335. }
  4336. function _checkPrivateRedeclaration(obj, privateCollection) {
  4337. if (privateCollection.has(obj)) {
  4338. throw new TypeError(
  4339. "Cannot initialize the same private elements twice on an object");
  4340. }
  4341. }
  4342. function _classPrivateMethodGet(receiver, privateSet, fn) {
  4343. if (!privateSet.has(receiver)) {
  4344. throw new TypeError("attempted to get private field on non-instance");
  4345. }
  4346. return fn;
  4347. }
  4348. var _bindListeners = /*#__PURE__*/ new WeakSet();
  4349. class AnnotationEditorParams {
  4350. constructor(options, eventBus) {
  4351. _classPrivateMethodInitSpec(this, _bindListeners);
  4352. this.eventBus = eventBus;
  4353. _classPrivateMethodGet(this, _bindListeners, _bindListeners2).call(this,
  4354. options);
  4355. }
  4356. }
  4357. exports.AnnotationEditorParams = AnnotationEditorParams;
  4358. function _bindListeners2(_ref) {
  4359. let {
  4360. editorFreeTextFontSize,
  4361. editorFreeTextColor,
  4362. editorInkColor,
  4363. editorInkThickness,
  4364. editorInkOpacity
  4365. } = _ref;
  4366. editorFreeTextFontSize.addEventListener("input", evt => {
  4367. this.eventBus.dispatch("switchannotationeditorparams", {
  4368. source: this,
  4369. type: _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE,
  4370. value: editorFreeTextFontSize.valueAsNumber
  4371. });
  4372. });
  4373. editorFreeTextColor.addEventListener("input", evt => {
  4374. this.eventBus.dispatch("switchannotationeditorparams", {
  4375. source: this,
  4376. type: _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR,
  4377. value: editorFreeTextColor.value
  4378. });
  4379. });
  4380. editorInkColor.addEventListener("input", evt => {
  4381. this.eventBus.dispatch("switchannotationeditorparams", {
  4382. source: this,
  4383. type: _pdfjsLib.AnnotationEditorParamsType.INK_COLOR,
  4384. value: editorInkColor.value
  4385. });
  4386. });
  4387. editorInkThickness.addEventListener("input", evt => {
  4388. this.eventBus.dispatch("switchannotationeditorparams", {
  4389. source: this,
  4390. type: _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS,
  4391. value: editorInkThickness.valueAsNumber
  4392. });
  4393. });
  4394. editorInkOpacity.addEventListener("input", evt => {
  4395. this.eventBus.dispatch("switchannotationeditorparams", {
  4396. source: this,
  4397. type: _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY,
  4398. value: editorInkOpacity.valueAsNumber
  4399. });
  4400. });
  4401. this.eventBus._on("annotationeditorparamschanged", evt => {
  4402. for (const [type, value] of evt.details) {
  4403. switch (type) {
  4404. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE:
  4405. editorFreeTextFontSize.value = value;
  4406. break;
  4407. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR:
  4408. editorFreeTextColor.value = value;
  4409. break;
  4410. case _pdfjsLib.AnnotationEditorParamsType.INK_COLOR:
  4411. editorInkColor.value = value;
  4412. break;
  4413. case _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS:
  4414. editorInkThickness.value = value;
  4415. break;
  4416. case _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY:
  4417. editorInkOpacity.value = value;
  4418. break;
  4419. }
  4420. }
  4421. });
  4422. }
  4423. /***/
  4424. }),
  4425. /* 10 */
  4426. /***/
  4427. ((__unused_webpack_module, exports, __webpack_require__) => {
  4428. Object.defineProperty(exports, "__esModule", ({
  4429. value: true
  4430. }));
  4431. exports.OverlayManager = void 0;
  4432. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  4433. _checkPrivateRedeclaration(obj, privateMap);
  4434. privateMap.set(obj, value);
  4435. }
  4436. function _checkPrivateRedeclaration(obj, privateCollection) {
  4437. if (privateCollection.has(obj)) {
  4438. throw new TypeError(
  4439. "Cannot initialize the same private elements twice on an object");
  4440. }
  4441. }
  4442. function _classPrivateFieldSet(receiver, privateMap, value) {
  4443. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  4444. _classApplyDescriptorSet(receiver, descriptor, value);
  4445. return value;
  4446. }
  4447. function _classApplyDescriptorSet(receiver, descriptor, value) {
  4448. if (descriptor.set) {
  4449. descriptor.set.call(receiver, value);
  4450. } else {
  4451. if (!descriptor.writable) {
  4452. throw new TypeError("attempted to set read only private field");
  4453. }
  4454. descriptor.value = value;
  4455. }
  4456. }
  4457. function _classPrivateFieldGet(receiver, privateMap) {
  4458. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  4459. return _classApplyDescriptorGet(receiver, descriptor);
  4460. }
  4461. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  4462. if (!privateMap.has(receiver)) {
  4463. throw new TypeError("attempted to " + action + " private field on non-instance");
  4464. }
  4465. return privateMap.get(receiver);
  4466. }
  4467. function _classApplyDescriptorGet(receiver, descriptor) {
  4468. if (descriptor.get) {
  4469. return descriptor.get.call(receiver);
  4470. }
  4471. return descriptor.value;
  4472. }
  4473. var _overlays = /*#__PURE__*/ new WeakMap();
  4474. var _active = /*#__PURE__*/ new WeakMap();
  4475. class OverlayManager {
  4476. constructor() {
  4477. _classPrivateFieldInitSpec(this, _overlays, {
  4478. writable: true,
  4479. value: new WeakMap()
  4480. });
  4481. _classPrivateFieldInitSpec(this, _active, {
  4482. writable: true,
  4483. value: null
  4484. });
  4485. }
  4486. get active() {
  4487. return _classPrivateFieldGet(this, _active);
  4488. }
  4489. async register(dialog) {
  4490. let canForceClose = arguments.length > 1 && arguments[1] !== undefined ?
  4491. arguments[1] : false;
  4492. if (typeof dialog !== "object") {
  4493. throw new Error("Not enough parameters.");
  4494. } else if (_classPrivateFieldGet(this, _overlays).has(dialog)) {
  4495. throw new Error("The overlay is already registered.");
  4496. }
  4497. _classPrivateFieldGet(this, _overlays).set(dialog, {
  4498. canForceClose
  4499. });
  4500. if (!dialog.showModal) {
  4501. const dialogPolyfill = __webpack_require__(11);
  4502. dialogPolyfill.registerDialog(dialog);
  4503. if (!this._dialogPolyfillCSS) {
  4504. this._dialogPolyfillCSS = true;
  4505. const style = document.createElement("style");
  4506. style.textContent =
  4507. 'dialog {\n position: absolute;\n left: 0; right: 0;\n width: -moz-fit-content;\n width: -webkit-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: -webkit-fit-content;\n height: fit-content;\n margin: auto;\n border: solid;\n padding: 1em;\n background: white;\n color: black;\n display: block;\n}\n\ndialog:not([open]) {\n display: none;\n}\n\ndialog + .backdrop {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n background: rgba(0,0,0,0.1);\n}\n\n._dialog_overlay {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n}\n\ndialog.fixed {\n position: fixed;\n top: 50%;\n transform: translate(0, -50%);\n}';
  4508. document.head.prepend(style);
  4509. }
  4510. }
  4511. dialog.addEventListener("cancel", evt => {
  4512. _classPrivateFieldSet(this, _active, null);
  4513. });
  4514. }
  4515. async unregister(dialog) {
  4516. if (!_classPrivateFieldGet(this, _overlays).has(dialog)) {
  4517. throw new Error("The overlay does not exist.");
  4518. } else if (_classPrivateFieldGet(this, _active) === dialog) {
  4519. throw new Error("The overlay cannot be removed while it is active.");
  4520. }
  4521. _classPrivateFieldGet(this, _overlays).delete(dialog);
  4522. }
  4523. async open(dialog) {
  4524. if (!_classPrivateFieldGet(this, _overlays).has(dialog)) {
  4525. throw new Error("The overlay does not exist.");
  4526. } else if (_classPrivateFieldGet(this, _active)) {
  4527. if (_classPrivateFieldGet(this, _active) === dialog) {
  4528. throw new Error("The overlay is already active.");
  4529. } else if (_classPrivateFieldGet(this, _overlays).get(dialog)
  4530. .canForceClose) {
  4531. await this.close();
  4532. } else {
  4533. throw new Error("Another overlay is currently active.");
  4534. }
  4535. }
  4536. _classPrivateFieldSet(this, _active, dialog);
  4537. dialog.showModal();
  4538. }
  4539. async close() {
  4540. let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  4541. _classPrivateFieldGet(this, _active);
  4542. if (!_classPrivateFieldGet(this, _overlays).has(dialog)) {
  4543. throw new Error("The overlay does not exist.");
  4544. } else if (!_classPrivateFieldGet(this, _active)) {
  4545. throw new Error("The overlay is currently not active.");
  4546. } else if (_classPrivateFieldGet(this, _active) !== dialog) {
  4547. throw new Error("Another overlay is currently active.");
  4548. }
  4549. dialog.close();
  4550. _classPrivateFieldSet(this, _active, null);
  4551. }
  4552. }
  4553. exports.OverlayManager = OverlayManager;
  4554. /***/
  4555. }),
  4556. /* 11 */
  4557. /***/
  4558. ((module) => {
  4559. (function(global, factory) {
  4560. true ? module.exports = factory() : 0;
  4561. })(void 0, function() {
  4562. 'use strict';
  4563. var supportCustomEvent = window.CustomEvent;
  4564. if (!supportCustomEvent || typeof supportCustomEvent === 'object') {
  4565. supportCustomEvent = function CustomEvent(event, x) {
  4566. x = x || {};
  4567. var ev = document.createEvent('CustomEvent');
  4568. ev.initCustomEvent(event, !!x.bubbles, !!x.cancelable, x.detail ||
  4569. null);
  4570. return ev;
  4571. };
  4572. supportCustomEvent.prototype = window.Event.prototype;
  4573. }
  4574. function safeDispatchEvent(target, event) {
  4575. var check = 'on' + event.type.toLowerCase();
  4576. if (typeof target[check] === 'function') {
  4577. target[check](event);
  4578. }
  4579. return target.dispatchEvent(event);
  4580. }
  4581. function createsStackingContext(el) {
  4582. while (el && el !== document.body) {
  4583. var s = window.getComputedStyle(el);
  4584. var invalid = function(k, ok) {
  4585. return !(s[k] === undefined || s[k] === ok);
  4586. };
  4587. if (s.opacity < 1 || invalid('zIndex', 'auto') || invalid('transform',
  4588. 'none') || invalid('mixBlendMode', 'normal') || invalid('filter',
  4589. 'none') || invalid('perspective', 'none') || s['isolation'] ===
  4590. 'isolate' || s.position === 'fixed' || s.webkitOverflowScrolling ===
  4591. 'touch') {
  4592. return true;
  4593. }
  4594. el = el.parentElement;
  4595. }
  4596. return false;
  4597. }
  4598. function findNearestDialog(el) {
  4599. while (el) {
  4600. if (el.localName === 'dialog') {
  4601. return el;
  4602. }
  4603. if (el.parentElement) {
  4604. el = el.parentElement;
  4605. } else if (el.parentNode) {
  4606. el = el.parentNode.host;
  4607. } else {
  4608. el = null;
  4609. }
  4610. }
  4611. return null;
  4612. }
  4613. function safeBlur(el) {
  4614. while (el && el.shadowRoot && el.shadowRoot.activeElement) {
  4615. el = el.shadowRoot.activeElement;
  4616. }
  4617. if (el && el.blur && el !== document.body) {
  4618. el.blur();
  4619. }
  4620. }
  4621. function inNodeList(nodeList, node) {
  4622. for (var i = 0; i < nodeList.length; ++i) {
  4623. if (nodeList[i] === node) {
  4624. return true;
  4625. }
  4626. }
  4627. return false;
  4628. }
  4629. function isFormMethodDialog(el) {
  4630. if (!el || !el.hasAttribute('method')) {
  4631. return false;
  4632. }
  4633. return el.getAttribute('method').toLowerCase() === 'dialog';
  4634. }
  4635. function findFocusableElementWithin(hostElement) {
  4636. var opts = ['button', 'input', 'keygen', 'select', 'textarea'];
  4637. var query = opts.map(function(el) {
  4638. return el + ':not([disabled])';
  4639. });
  4640. query.push('[tabindex]:not([disabled]):not([tabindex=""])');
  4641. var target = hostElement.querySelector(query.join(', '));
  4642. if (!target && 'attachShadow' in Element.prototype) {
  4643. var elems = hostElement.querySelectorAll('*');
  4644. for (var i = 0; i < elems.length; i++) {
  4645. if (elems[i].tagName && elems[i].shadowRoot) {
  4646. target = findFocusableElementWithin(elems[i].shadowRoot);
  4647. if (target) {
  4648. break;
  4649. }
  4650. }
  4651. }
  4652. }
  4653. return target;
  4654. }
  4655. function isConnected(element) {
  4656. return element.isConnected || document.body.contains(element);
  4657. }
  4658. function findFormSubmitter(event) {
  4659. if (event.submitter) {
  4660. return event.submitter;
  4661. }
  4662. var form = event.target;
  4663. if (!(form instanceof HTMLFormElement)) {
  4664. return null;
  4665. }
  4666. var submitter = dialogPolyfill.formSubmitter;
  4667. if (!submitter) {
  4668. var target = event.target;
  4669. var root = 'getRootNode' in target && target.getRootNode() || document;
  4670. submitter = root.activeElement;
  4671. }
  4672. if (!submitter || submitter.form !== form) {
  4673. return null;
  4674. }
  4675. return submitter;
  4676. }
  4677. function maybeHandleSubmit(event) {
  4678. if (event.defaultPrevented) {
  4679. return;
  4680. }
  4681. var form = event.target;
  4682. var value = dialogPolyfill.imagemapUseValue;
  4683. var submitter = findFormSubmitter(event);
  4684. if (value === null && submitter) {
  4685. value = submitter.value;
  4686. }
  4687. var dialog = findNearestDialog(form);
  4688. if (!dialog) {
  4689. return;
  4690. }
  4691. var formmethod = submitter && submitter.getAttribute('formmethod') || form
  4692. .getAttribute('method');
  4693. if (formmethod !== 'dialog') {
  4694. return;
  4695. }
  4696. event.preventDefault();
  4697. if (value != null) {
  4698. dialog.close(value);
  4699. } else {
  4700. dialog.close();
  4701. }
  4702. }
  4703. function dialogPolyfillInfo(dialog) {
  4704. this.dialog_ = dialog;
  4705. this.replacedStyleTop_ = false;
  4706. this.openAsModal_ = false;
  4707. if (!dialog.hasAttribute('role')) {
  4708. dialog.setAttribute('role', 'dialog');
  4709. }
  4710. dialog.show = this.show.bind(this);
  4711. dialog.showModal = this.showModal.bind(this);
  4712. dialog.close = this.close.bind(this);
  4713. dialog.addEventListener('submit', maybeHandleSubmit, false);
  4714. if (!('returnValue' in dialog)) {
  4715. dialog.returnValue = '';
  4716. }
  4717. if ('MutationObserver' in window) {
  4718. var mo = new MutationObserver(this.maybeHideModal.bind(this));
  4719. mo.observe(dialog, {
  4720. attributes: true,
  4721. attributeFilter: ['open']
  4722. });
  4723. } else {
  4724. var removed = false;
  4725. var cb = function() {
  4726. removed ? this.downgradeModal() : this.maybeHideModal();
  4727. removed = false;
  4728. }.bind(this);
  4729. var timeout;
  4730. var delayModel = function(ev) {
  4731. if (ev.target !== dialog) {
  4732. return;
  4733. }
  4734. var cand = 'DOMNodeRemoved';
  4735. removed |= ev.type.substr(0, cand.length) === cand;
  4736. window.clearTimeout(timeout);
  4737. timeout = window.setTimeout(cb, 0);
  4738. };
  4739. ['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(
  4740. function(name) {
  4741. dialog.addEventListener(name, delayModel);
  4742. });
  4743. }
  4744. Object.defineProperty(dialog, 'open', {
  4745. set: this.setOpen.bind(this),
  4746. get: dialog.hasAttribute.bind(dialog, 'open')
  4747. });
  4748. this.backdrop_ = document.createElement('div');
  4749. this.backdrop_.className = 'backdrop';
  4750. this.backdrop_.addEventListener('mouseup', this.backdropMouseEvent_.bind(this));
  4751. this.backdrop_.addEventListener('mousedown', this.backdropMouseEvent_.bind(
  4752. this));
  4753. this.backdrop_.addEventListener('click', this.backdropMouseEvent_.bind(this));
  4754. }
  4755. dialogPolyfillInfo.prototype = {
  4756. get dialog() {
  4757. return this.dialog_;
  4758. },
  4759. maybeHideModal: function() {
  4760. if (this.dialog_.hasAttribute('open') && isConnected(this
  4761. .dialog_)) {
  4762. return;
  4763. }
  4764. this.downgradeModal();
  4765. },
  4766. downgradeModal: function() {
  4767. if (!this.openAsModal_) {
  4768. return;
  4769. }
  4770. this.openAsModal_ = false;
  4771. this.dialog_.style.zIndex = '';
  4772. if (this.replacedStyleTop_) {
  4773. this.dialog_.style.top = '';
  4774. this.replacedStyleTop_ = false;
  4775. }
  4776. this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(
  4777. this.backdrop_);
  4778. dialogPolyfill.dm.removeDialog(this);
  4779. },
  4780. setOpen: function(value) {
  4781. if (value) {
  4782. this.dialog_.hasAttribute('open') || this.dialog_.setAttribute(
  4783. 'open', '');
  4784. } else {
  4785. this.dialog_.removeAttribute('open');
  4786. this.maybeHideModal();
  4787. }
  4788. },
  4789. backdropMouseEvent_: function(e) {
  4790. if (!this.dialog_.hasAttribute('tabindex')) {
  4791. var fake = document.createElement('div');
  4792. this.dialog_.insertBefore(fake, this.dialog_.firstChild);
  4793. fake.tabIndex = -1;
  4794. fake.focus();
  4795. this.dialog_.removeChild(fake);
  4796. } else {
  4797. this.dialog_.focus();
  4798. }
  4799. var redirectedEvent = document.createEvent('MouseEvents');
  4800. redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable,
  4801. window, e.detail, e.screenX, e.screenY, e.clientX, e
  4802. .clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e
  4803. .button, e.relatedTarget);
  4804. this.dialog_.dispatchEvent(redirectedEvent);
  4805. e.stopPropagation();
  4806. },
  4807. focus_: function() {
  4808. var target = this.dialog_.querySelector(
  4809. '[autofocus]:not([disabled])');
  4810. if (!target && this.dialog_.tabIndex >= 0) {
  4811. target = this.dialog_;
  4812. }
  4813. if (!target) {
  4814. target = findFocusableElementWithin(this.dialog_);
  4815. }
  4816. safeBlur(document.activeElement);
  4817. target && target.focus();
  4818. },
  4819. updateZIndex: function(dialogZ, backdropZ) {
  4820. if (dialogZ < backdropZ) {
  4821. throw new Error('dialogZ should never be < backdropZ');
  4822. }
  4823. this.dialog_.style.zIndex = dialogZ;
  4824. this.backdrop_.style.zIndex = backdropZ;
  4825. },
  4826. show: function() {
  4827. if (!this.dialog_.open) {
  4828. this.setOpen(true);
  4829. this.focus_();
  4830. }
  4831. },
  4832. showModal: function() {
  4833. if (this.dialog_.hasAttribute('open')) {
  4834. throw new Error(
  4835. 'Failed to execute \'showModal\' on dialog: The element is already open, and therefore cannot be opened modally.'
  4836. );
  4837. }
  4838. if (!isConnected(this.dialog_)) {
  4839. throw new Error(
  4840. 'Failed to execute \'showModal\' on dialog: The element is not in a Document.'
  4841. );
  4842. }
  4843. if (!dialogPolyfill.dm.pushDialog(this)) {
  4844. throw new Error(
  4845. 'Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.'
  4846. );
  4847. }
  4848. if (createsStackingContext(this.dialog_.parentElement)) {
  4849. console.warn(
  4850. 'A dialog is being shown inside a stacking context. ' +
  4851. 'This may cause it to be unusable. For more information, see this link: ' +
  4852. 'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context'
  4853. );
  4854. }
  4855. this.setOpen(true);
  4856. this.openAsModal_ = true;
  4857. if (dialogPolyfill.needsCentering(this.dialog_)) {
  4858. dialogPolyfill.reposition(this.dialog_);
  4859. this.replacedStyleTop_ = true;
  4860. } else {
  4861. this.replacedStyleTop_ = false;
  4862. }
  4863. this.dialog_.parentNode.insertBefore(this.backdrop_, this.dialog_
  4864. .nextSibling);
  4865. this.focus_();
  4866. },
  4867. close: function(opt_returnValue) {
  4868. if (!this.dialog_.hasAttribute('open')) {
  4869. throw new Error(
  4870. 'Failed to execute \'close\' on dialog: The element does not have an \'open\' attribute, and therefore cannot be closed.'
  4871. );
  4872. }
  4873. this.setOpen(false);
  4874. if (opt_returnValue !== undefined) {
  4875. this.dialog_.returnValue = opt_returnValue;
  4876. }
  4877. var closeEvent = new supportCustomEvent('close', {
  4878. bubbles: false,
  4879. cancelable: false
  4880. });
  4881. safeDispatchEvent(this.dialog_, closeEvent);
  4882. }
  4883. };
  4884. var dialogPolyfill = {};
  4885. dialogPolyfill.reposition = function(element) {
  4886. var scrollTop = document.body.scrollTop || document.documentElement
  4887. .scrollTop;
  4888. var topValue = scrollTop + (window.innerHeight - element.offsetHeight) / 2;
  4889. element.style.top = Math.max(scrollTop, topValue) + 'px';
  4890. };
  4891. dialogPolyfill.isInlinePositionSetByStylesheet = function(element) {
  4892. for (var i = 0; i < document.styleSheets.length; ++i) {
  4893. var styleSheet = document.styleSheets[i];
  4894. var cssRules = null;
  4895. try {
  4896. cssRules = styleSheet.cssRules;
  4897. } catch (e) {}
  4898. if (!cssRules) {
  4899. continue;
  4900. }
  4901. for (var j = 0; j < cssRules.length; ++j) {
  4902. var rule = cssRules[j];
  4903. var selectedNodes = null;
  4904. try {
  4905. selectedNodes = document.querySelectorAll(rule.selectorText);
  4906. } catch (e) {}
  4907. if (!selectedNodes || !inNodeList(selectedNodes, element)) {
  4908. continue;
  4909. }
  4910. var cssTop = rule.style.getPropertyValue('top');
  4911. var cssBottom = rule.style.getPropertyValue('bottom');
  4912. if (cssTop && cssTop !== 'auto' || cssBottom && cssBottom !==
  4913. 'auto') {
  4914. return true;
  4915. }
  4916. }
  4917. }
  4918. return false;
  4919. };
  4920. dialogPolyfill.needsCentering = function(dialog) {
  4921. var computedStyle = window.getComputedStyle(dialog);
  4922. if (computedStyle.position !== 'absolute') {
  4923. return false;
  4924. }
  4925. if (dialog.style.top !== 'auto' && dialog.style.top !== '' || dialog.style
  4926. .bottom !== 'auto' && dialog.style.bottom !== '') {
  4927. return false;
  4928. }
  4929. return !dialogPolyfill.isInlinePositionSetByStylesheet(dialog);
  4930. };
  4931. dialogPolyfill.forceRegisterDialog = function(element) {
  4932. if (window.HTMLDialogElement || element.showModal) {
  4933. console.warn('This browser already supports <dialog>, the polyfill ' +
  4934. 'may not work correctly', element);
  4935. }
  4936. if (element.localName !== 'dialog') {
  4937. throw new Error(
  4938. 'Failed to register dialog: The element is not a dialog.');
  4939. }
  4940. new dialogPolyfillInfo(element);
  4941. };
  4942. dialogPolyfill.registerDialog = function(element) {
  4943. if (!element.showModal) {
  4944. dialogPolyfill.forceRegisterDialog(element);
  4945. }
  4946. };
  4947. dialogPolyfill.DialogManager = function() {
  4948. this.pendingDialogStack = [];
  4949. var checkDOM = this.checkDOM_.bind(this);
  4950. this.overlay = document.createElement('div');
  4951. this.overlay.className = '_dialog_overlay';
  4952. this.overlay.addEventListener('click', function(e) {
  4953. this.forwardTab_ = undefined;
  4954. e.stopPropagation();
  4955. checkDOM([]);
  4956. }.bind(this));
  4957. this.handleKey_ = this.handleKey_.bind(this);
  4958. this.handleFocus_ = this.handleFocus_.bind(this);
  4959. this.zIndexLow_ = 100000;
  4960. this.zIndexHigh_ = 100000 + 150;
  4961. this.forwardTab_ = undefined;
  4962. if ('MutationObserver' in window) {
  4963. this.mo_ = new MutationObserver(function(records) {
  4964. var removed = [];
  4965. records.forEach(function(rec) {
  4966. for (var i = 0, c; c = rec.removedNodes[i]; ++
  4967. i) {
  4968. if (!(c instanceof Element)) {
  4969. continue;
  4970. } else if (c.localName === 'dialog') {
  4971. removed.push(c);
  4972. }
  4973. removed = removed.concat(c.querySelectorAll(
  4974. 'dialog'));
  4975. }
  4976. });
  4977. removed.length && checkDOM(removed);
  4978. });
  4979. }
  4980. };
  4981. dialogPolyfill.DialogManager.prototype.blockDocument = function() {
  4982. document.documentElement.addEventListener('focus', this.handleFocus_, true);
  4983. document.addEventListener('keydown', this.handleKey_);
  4984. this.mo_ && this.mo_.observe(document, {
  4985. childList: true,
  4986. subtree: true
  4987. });
  4988. };
  4989. dialogPolyfill.DialogManager.prototype.unblockDocument = function() {
  4990. document.documentElement.removeEventListener('focus', this.handleFocus_,
  4991. true);
  4992. document.removeEventListener('keydown', this.handleKey_);
  4993. this.mo_ && this.mo_.disconnect();
  4994. };
  4995. dialogPolyfill.DialogManager.prototype.updateStacking = function() {
  4996. var zIndex = this.zIndexHigh_;
  4997. for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
  4998. dpi.updateZIndex(--zIndex, --zIndex);
  4999. if (i === 0) {
  5000. this.overlay.style.zIndex = --zIndex;
  5001. }
  5002. }
  5003. var last = this.pendingDialogStack[0];
  5004. if (last) {
  5005. var p = last.dialog.parentNode || document.body;
  5006. p.appendChild(this.overlay);
  5007. } else if (this.overlay.parentNode) {
  5008. this.overlay.parentNode.removeChild(this.overlay);
  5009. }
  5010. };
  5011. dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function(candidate) {
  5012. while (candidate = findNearestDialog(candidate)) {
  5013. for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
  5014. if (dpi.dialog === candidate) {
  5015. return i === 0;
  5016. }
  5017. }
  5018. candidate = candidate.parentElement;
  5019. }
  5020. return false;
  5021. };
  5022. dialogPolyfill.DialogManager.prototype.handleFocus_ = function(event) {
  5023. var target = event.composedPath ? event.composedPath()[0] : event.target;
  5024. if (this.containedByTopDialog_(target)) {
  5025. return;
  5026. }
  5027. if (document.activeElement === document.documentElement) {
  5028. return;
  5029. }
  5030. event.preventDefault();
  5031. event.stopPropagation();
  5032. safeBlur(target);
  5033. if (this.forwardTab_ === undefined) {
  5034. return;
  5035. }
  5036. var dpi = this.pendingDialogStack[0];
  5037. var dialog = dpi.dialog;
  5038. var position = dialog.compareDocumentPosition(target);
  5039. if (position & Node.DOCUMENT_POSITION_PRECEDING) {
  5040. if (this.forwardTab_) {
  5041. dpi.focus_();
  5042. } else if (target !== document.documentElement) {
  5043. document.documentElement.focus();
  5044. }
  5045. }
  5046. return false;
  5047. };
  5048. dialogPolyfill.DialogManager.prototype.handleKey_ = function(event) {
  5049. this.forwardTab_ = undefined;
  5050. if (event.keyCode === 27) {
  5051. event.preventDefault();
  5052. event.stopPropagation();
  5053. var cancelEvent = new supportCustomEvent('cancel', {
  5054. bubbles: false,
  5055. cancelable: true
  5056. });
  5057. var dpi = this.pendingDialogStack[0];
  5058. if (dpi && safeDispatchEvent(dpi.dialog, cancelEvent)) {
  5059. dpi.dialog.close();
  5060. }
  5061. } else if (event.keyCode === 9) {
  5062. this.forwardTab_ = !event.shiftKey;
  5063. }
  5064. };
  5065. dialogPolyfill.DialogManager.prototype.checkDOM_ = function(removed) {
  5066. var clone = this.pendingDialogStack.slice();
  5067. clone.forEach(function(dpi) {
  5068. if (removed.indexOf(dpi.dialog) !== -1) {
  5069. dpi.downgradeModal();
  5070. } else {
  5071. dpi.maybeHideModal();
  5072. }
  5073. });
  5074. };
  5075. dialogPolyfill.DialogManager.prototype.pushDialog = function(dpi) {
  5076. var allowed = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1;
  5077. if (this.pendingDialogStack.length >= allowed) {
  5078. return false;
  5079. }
  5080. if (this.pendingDialogStack.unshift(dpi) === 1) {
  5081. this.blockDocument();
  5082. }
  5083. this.updateStacking();
  5084. return true;
  5085. };
  5086. dialogPolyfill.DialogManager.prototype.removeDialog = function(dpi) {
  5087. var index = this.pendingDialogStack.indexOf(dpi);
  5088. if (index === -1) {
  5089. return;
  5090. }
  5091. this.pendingDialogStack.splice(index, 1);
  5092. if (this.pendingDialogStack.length === 0) {
  5093. this.unblockDocument();
  5094. }
  5095. this.updateStacking();
  5096. };
  5097. dialogPolyfill.dm = new dialogPolyfill.DialogManager();
  5098. dialogPolyfill.formSubmitter = null;
  5099. dialogPolyfill.imagemapUseValue = null;
  5100. if (window.HTMLDialogElement === undefined) {
  5101. var testForm = document.createElement('form');
  5102. testForm.setAttribute('method', 'dialog');
  5103. if (testForm.method !== 'dialog') {
  5104. var methodDescriptor = Object.getOwnPropertyDescriptor(HTMLFormElement
  5105. .prototype, 'method');
  5106. if (methodDescriptor) {
  5107. var realGet = methodDescriptor.get;
  5108. methodDescriptor.get = function() {
  5109. if (isFormMethodDialog(this)) {
  5110. return 'dialog';
  5111. }
  5112. return realGet.call(this);
  5113. };
  5114. var realSet = methodDescriptor.set;
  5115. methodDescriptor.set = function(v) {
  5116. if (typeof v === 'string' && v.toLowerCase() === 'dialog') {
  5117. return this.setAttribute('method', v);
  5118. }
  5119. return realSet.call(this, v);
  5120. };
  5121. Object.defineProperty(HTMLFormElement.prototype, 'method',
  5122. methodDescriptor);
  5123. }
  5124. }
  5125. document.addEventListener('click', function(ev) {
  5126. dialogPolyfill.formSubmitter = null;
  5127. dialogPolyfill.imagemapUseValue = null;
  5128. if (ev.defaultPrevented) {
  5129. return;
  5130. }
  5131. var target = ev.target;
  5132. if ('composedPath' in ev) {
  5133. var path = ev.composedPath();
  5134. target = path.shift() || target;
  5135. }
  5136. if (!target || !isFormMethodDialog(target.form)) {
  5137. return;
  5138. }
  5139. var valid = target.type === 'submit' && ['button', 'input'].indexOf(
  5140. target.localName) > -1;
  5141. if (!valid) {
  5142. if (!(target.localName === 'input' && target.type ===
  5143. 'image')) {
  5144. return;
  5145. }
  5146. dialogPolyfill.imagemapUseValue = ev.offsetX + ',' + ev.offsetY;
  5147. }
  5148. var dialog = findNearestDialog(target);
  5149. if (!dialog) {
  5150. return;
  5151. }
  5152. dialogPolyfill.formSubmitter = target;
  5153. }, false);
  5154. document.addEventListener('submit', function(ev) {
  5155. var form = ev.target;
  5156. var dialog = findNearestDialog(form);
  5157. if (dialog) {
  5158. return;
  5159. }
  5160. var submitter = findFormSubmitter(ev);
  5161. var formmethod = submitter && submitter.getAttribute(
  5162. 'formmethod') || form.getAttribute('method');
  5163. if (formmethod === 'dialog') {
  5164. ev.preventDefault();
  5165. }
  5166. });
  5167. var nativeFormSubmit = HTMLFormElement.prototype.submit;
  5168. var replacementFormSubmit = function() {
  5169. if (!isFormMethodDialog(this)) {
  5170. return nativeFormSubmit.call(this);
  5171. }
  5172. var dialog = findNearestDialog(this);
  5173. dialog && dialog.close();
  5174. };
  5175. HTMLFormElement.prototype.submit = replacementFormSubmit;
  5176. }
  5177. return dialogPolyfill;
  5178. });
  5179. /***/
  5180. }),
  5181. /* 12 */
  5182. /***/
  5183. ((__unused_webpack_module, exports, __webpack_require__) => {
  5184. Object.defineProperty(exports, "__esModule", ({
  5185. value: true
  5186. }));
  5187. exports.PasswordPrompt = void 0;
  5188. var _pdfjsLib = __webpack_require__(5);
  5189. function _classPrivateMethodInitSpec(obj, privateSet) {
  5190. _checkPrivateRedeclaration(obj, privateSet);
  5191. privateSet.add(obj);
  5192. }
  5193. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  5194. _checkPrivateRedeclaration(obj, privateMap);
  5195. privateMap.set(obj, value);
  5196. }
  5197. function _checkPrivateRedeclaration(obj, privateCollection) {
  5198. if (privateCollection.has(obj)) {
  5199. throw new TypeError(
  5200. "Cannot initialize the same private elements twice on an object");
  5201. }
  5202. }
  5203. function _classPrivateFieldSet(receiver, privateMap, value) {
  5204. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  5205. _classApplyDescriptorSet(receiver, descriptor, value);
  5206. return value;
  5207. }
  5208. function _classApplyDescriptorSet(receiver, descriptor, value) {
  5209. if (descriptor.set) {
  5210. descriptor.set.call(receiver, value);
  5211. } else {
  5212. if (!descriptor.writable) {
  5213. throw new TypeError("attempted to set read only private field");
  5214. }
  5215. descriptor.value = value;
  5216. }
  5217. }
  5218. function _classPrivateFieldGet(receiver, privateMap) {
  5219. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  5220. return _classApplyDescriptorGet(receiver, descriptor);
  5221. }
  5222. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  5223. if (!privateMap.has(receiver)) {
  5224. throw new TypeError("attempted to " + action + " private field on non-instance");
  5225. }
  5226. return privateMap.get(receiver);
  5227. }
  5228. function _classApplyDescriptorGet(receiver, descriptor) {
  5229. if (descriptor.get) {
  5230. return descriptor.get.call(receiver);
  5231. }
  5232. return descriptor.value;
  5233. }
  5234. function _classPrivateMethodGet(receiver, privateSet, fn) {
  5235. if (!privateSet.has(receiver)) {
  5236. throw new TypeError("attempted to get private field on non-instance");
  5237. }
  5238. return fn;
  5239. }
  5240. var _activeCapability = /*#__PURE__*/ new WeakMap();
  5241. var _updateCallback = /*#__PURE__*/ new WeakMap();
  5242. var _reason = /*#__PURE__*/ new WeakMap();
  5243. var _verify = /*#__PURE__*/ new WeakSet();
  5244. var _cancel = /*#__PURE__*/ new WeakSet();
  5245. var _invokeCallback = /*#__PURE__*/ new WeakSet();
  5246. class PasswordPrompt {
  5247. constructor(options, overlayManager, l10n) {
  5248. let isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ?
  5249. arguments[3] : false;
  5250. _classPrivateMethodInitSpec(this, _invokeCallback);
  5251. _classPrivateMethodInitSpec(this, _cancel);
  5252. _classPrivateMethodInitSpec(this, _verify);
  5253. _classPrivateFieldInitSpec(this, _activeCapability, {
  5254. writable: true,
  5255. value: null
  5256. });
  5257. _classPrivateFieldInitSpec(this, _updateCallback, {
  5258. writable: true,
  5259. value: null
  5260. });
  5261. _classPrivateFieldInitSpec(this, _reason, {
  5262. writable: true,
  5263. value: null
  5264. });
  5265. this.dialog = options.dialog;
  5266. this.label = options.label;
  5267. this.input = options.input;
  5268. this.submitButton = options.submitButton;
  5269. this.cancelButton = options.cancelButton;
  5270. this.overlayManager = overlayManager;
  5271. this.l10n = l10n;
  5272. this._isViewerEmbedded = isViewerEmbedded;
  5273. this.submitButton.addEventListener("click", _classPrivateMethodGet(this,
  5274. _verify, _verify2).bind(this));
  5275. this.cancelButton.addEventListener("click", this.close.bind(this));
  5276. this.input.addEventListener("keydown", e => {
  5277. if (e.keyCode === 13) {
  5278. _classPrivateMethodGet(this, _verify, _verify2).call(this);
  5279. }
  5280. });
  5281. this.overlayManager.register(this.dialog, true);
  5282. this.dialog.addEventListener("close", _classPrivateMethodGet(this, _cancel,
  5283. _cancel2).bind(this));
  5284. }
  5285. async open() {
  5286. if (_classPrivateFieldGet(this, _activeCapability)) {
  5287. await _classPrivateFieldGet(this, _activeCapability).promise;
  5288. }
  5289. _classPrivateFieldSet(this, _activeCapability, (0, _pdfjsLib
  5290. .createPromiseCapability)());
  5291. try {
  5292. await this.overlayManager.open(this.dialog);
  5293. } catch (ex) {
  5294. _classPrivateFieldSet(this, _activeCapability, null);
  5295. throw ex;
  5296. }
  5297. const passwordIncorrect = _classPrivateFieldGet(this, _reason) === _pdfjsLib
  5298. .PasswordResponses.INCORRECT_PASSWORD;
  5299. if (!this._isViewerEmbedded || passwordIncorrect) {
  5300. this.input.focus();
  5301. }
  5302. this.label.textContent = await this.l10n.get(
  5303. `password_${passwordIncorrect ? "invalid" : "label"}`);
  5304. }
  5305. async close() {
  5306. if (this.overlayManager.active === this.dialog) {
  5307. this.overlayManager.close(this.dialog);
  5308. }
  5309. }
  5310. async setUpdateCallback(updateCallback, reason) {
  5311. if (_classPrivateFieldGet(this, _activeCapability)) {
  5312. await _classPrivateFieldGet(this, _activeCapability).promise;
  5313. }
  5314. _classPrivateFieldSet(this, _updateCallback, updateCallback);
  5315. _classPrivateFieldSet(this, _reason, reason);
  5316. }
  5317. }
  5318. exports.PasswordPrompt = PasswordPrompt;
  5319. function _verify2() {
  5320. const password = this.input.value;
  5321. if ((password === null || password === void 0 ? void 0 : password.length) > 0) {
  5322. _classPrivateMethodGet(this, _invokeCallback, _invokeCallback2).call(this,
  5323. password);
  5324. }
  5325. }
  5326. function _cancel2() {
  5327. _classPrivateMethodGet(this, _invokeCallback, _invokeCallback2).call(this, new Error(
  5328. "PasswordPrompt cancelled."));
  5329. _classPrivateFieldGet(this, _activeCapability).resolve();
  5330. }
  5331. function _invokeCallback2(password) {
  5332. if (!_classPrivateFieldGet(this, _updateCallback)) {
  5333. return;
  5334. }
  5335. this.close();
  5336. this.input.value = "";
  5337. _classPrivateFieldGet(this, _updateCallback).call(this, password);
  5338. _classPrivateFieldSet(this, _updateCallback, null);
  5339. }
  5340. /***/
  5341. }),
  5342. /* 13 */
  5343. /***/
  5344. ((__unused_webpack_module, exports, __webpack_require__) => {
  5345. Object.defineProperty(exports, "__esModule", ({
  5346. value: true
  5347. }));
  5348. exports.PDFAttachmentViewer = void 0;
  5349. var _pdfjsLib = __webpack_require__(5);
  5350. var _base_tree_viewer = __webpack_require__(14);
  5351. var _event_utils = __webpack_require__(6);
  5352. function _classPrivateMethodInitSpec(obj, privateSet) {
  5353. _checkPrivateRedeclaration(obj, privateSet);
  5354. privateSet.add(obj);
  5355. }
  5356. function _checkPrivateRedeclaration(obj, privateCollection) {
  5357. if (privateCollection.has(obj)) {
  5358. throw new TypeError(
  5359. "Cannot initialize the same private elements twice on an object");
  5360. }
  5361. }
  5362. function _classPrivateMethodGet(receiver, privateSet, fn) {
  5363. if (!privateSet.has(receiver)) {
  5364. throw new TypeError("attempted to get private field on non-instance");
  5365. }
  5366. return fn;
  5367. }
  5368. var _appendAttachment = /*#__PURE__*/ new WeakSet();
  5369. class PDFAttachmentViewer extends _base_tree_viewer.BaseTreeViewer {
  5370. constructor(options) {
  5371. super(options);
  5372. _classPrivateMethodInitSpec(this, _appendAttachment);
  5373. this.downloadManager = options.downloadManager;
  5374. this.eventBus._on("fileattachmentannotation", _classPrivateMethodGet(this,
  5375. _appendAttachment, _appendAttachment2).bind(this));
  5376. }
  5377. reset() {
  5378. let keepRenderedCapability = arguments.length > 0 && arguments[0] !==
  5379. undefined ? arguments[0] : false;
  5380. super.reset();
  5381. this._attachments = null;
  5382. if (!keepRenderedCapability) {
  5383. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5384. }
  5385. this._pendingDispatchEvent = false;
  5386. }
  5387. async _dispatchEvent(attachmentsCount) {
  5388. this._renderedCapability.resolve();
  5389. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  5390. this._pendingDispatchEvent = true;
  5391. await (0, _event_utils.waitOnEventOrTimeout)({
  5392. target: this.eventBus,
  5393. name: "annotationlayerrendered",
  5394. delay: 1000
  5395. });
  5396. if (!this._pendingDispatchEvent) {
  5397. return;
  5398. }
  5399. }
  5400. this._pendingDispatchEvent = false;
  5401. this.eventBus.dispatch("attachmentsloaded", {
  5402. source: this,
  5403. attachmentsCount
  5404. });
  5405. }
  5406. _bindLink(element, _ref) {
  5407. let {
  5408. content,
  5409. filename
  5410. } = _ref;
  5411. element.onclick = () => {
  5412. this.downloadManager.openOrDownloadData(element, content, filename);
  5413. return false;
  5414. };
  5415. }
  5416. render(_ref2) {
  5417. let {
  5418. attachments,
  5419. keepRenderedCapability = false
  5420. } = _ref2;
  5421. if (this._attachments) {
  5422. this.reset(keepRenderedCapability);
  5423. }
  5424. this._attachments = attachments || null;
  5425. if (!attachments) {
  5426. this._dispatchEvent(0);
  5427. return;
  5428. }
  5429. const names = Object.keys(attachments).sort(function(a, b) {
  5430. return a.toLowerCase().localeCompare(b.toLowerCase());
  5431. });
  5432. const fragment = document.createDocumentFragment();
  5433. let attachmentsCount = 0;
  5434. for (const name of names) {
  5435. const item = attachments[name];
  5436. const content = item.content,
  5437. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  5438. const div = document.createElement("div");
  5439. div.className = "treeItem";
  5440. const element = document.createElement("a");
  5441. this._bindLink(element, {
  5442. content,
  5443. filename
  5444. });
  5445. element.textContent = this._normalizeTextContent(filename);
  5446. div.append(element);
  5447. fragment.append(div);
  5448. attachmentsCount++;
  5449. }
  5450. this._finishRendering(fragment, attachmentsCount);
  5451. }
  5452. }
  5453. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5454. function _appendAttachment2(_ref3) {
  5455. let {
  5456. filename,
  5457. content
  5458. } = _ref3;
  5459. const renderedPromise = this._renderedCapability.promise;
  5460. renderedPromise.then(() => {
  5461. if (renderedPromise !== this._renderedCapability.promise) {
  5462. return;
  5463. }
  5464. const attachments = this._attachments || Object.create(null);
  5465. for (const name in attachments) {
  5466. if (filename === name) {
  5467. return;
  5468. }
  5469. }
  5470. attachments[filename] = {
  5471. filename,
  5472. content
  5473. };
  5474. this.render({
  5475. attachments,
  5476. keepRenderedCapability: true
  5477. });
  5478. });
  5479. }
  5480. /***/
  5481. }),
  5482. /* 14 */
  5483. /***/
  5484. ((__unused_webpack_module, exports, __webpack_require__) => {
  5485. Object.defineProperty(exports, "__esModule", ({
  5486. value: true
  5487. }));
  5488. exports.BaseTreeViewer = void 0;
  5489. var _ui_utils = __webpack_require__(1);
  5490. const TREEITEM_OFFSET_TOP = -100;
  5491. const TREEITEM_SELECTED_CLASS = "selected";
  5492. class BaseTreeViewer {
  5493. constructor(options) {
  5494. if (this.constructor === BaseTreeViewer) {
  5495. throw new Error("Cannot initialize BaseTreeViewer.");
  5496. }
  5497. this.container = options.container;
  5498. this.eventBus = options.eventBus;
  5499. this.reset();
  5500. }
  5501. reset() {
  5502. this._pdfDocument = null;
  5503. this._lastToggleIsShow = true;
  5504. this._currentTreeItem = null;
  5505. this.container.textContent = "";
  5506. this.container.classList.remove("treeWithDeepNesting");
  5507. }
  5508. _dispatchEvent(count) {
  5509. throw new Error("Not implemented: _dispatchEvent");
  5510. }
  5511. _bindLink(element, params) {
  5512. throw new Error("Not implemented: _bindLink");
  5513. }
  5514. _normalizeTextContent(str) {
  5515. return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013";
  5516. }
  5517. _addToggleButton(div) {
  5518. let hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  5519. false;
  5520. const toggler = document.createElement("div");
  5521. toggler.className = "treeItemToggler";
  5522. if (hidden) {
  5523. toggler.classList.add("treeItemsHidden");
  5524. }
  5525. toggler.onclick = evt => {
  5526. evt.stopPropagation();
  5527. toggler.classList.toggle("treeItemsHidden");
  5528. if (evt.shiftKey) {
  5529. const shouldShowAll = !toggler.classList.contains(
  5530. "treeItemsHidden");
  5531. this._toggleTreeItem(div, shouldShowAll);
  5532. }
  5533. };
  5534. div.prepend(toggler);
  5535. }
  5536. _toggleTreeItem(root) {
  5537. let show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  5538. false;
  5539. this._lastToggleIsShow = show;
  5540. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  5541. toggler.classList.toggle("treeItemsHidden", !show);
  5542. }
  5543. }
  5544. _toggleAllTreeItems() {
  5545. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5546. }
  5547. _finishRendering(fragment, count) {
  5548. let hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ?
  5549. arguments[2] : false;
  5550. if (hasAnyNesting) {
  5551. this.container.classList.add("treeWithDeepNesting");
  5552. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  5553. }
  5554. this.container.append(fragment);
  5555. this._dispatchEvent(count);
  5556. }
  5557. render(params) {
  5558. throw new Error("Not implemented: render");
  5559. }
  5560. _updateCurrentTreeItem() {
  5561. let treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  5562. 0] : null;
  5563. if (this._currentTreeItem) {
  5564. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  5565. this._currentTreeItem = null;
  5566. }
  5567. if (treeItem) {
  5568. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  5569. this._currentTreeItem = treeItem;
  5570. }
  5571. }
  5572. _scrollToCurrentTreeItem(treeItem) {
  5573. if (!treeItem) {
  5574. return;
  5575. }
  5576. let currentNode = treeItem.parentNode;
  5577. while (currentNode && currentNode !== this.container) {
  5578. if (currentNode.classList.contains("treeItem")) {
  5579. const toggler = currentNode.firstElementChild;
  5580. toggler === null || toggler === void 0 ? void 0 : toggler.classList
  5581. .remove("treeItemsHidden");
  5582. }
  5583. currentNode = currentNode.parentNode;
  5584. }
  5585. this._updateCurrentTreeItem(treeItem);
  5586. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop +
  5587. TREEITEM_OFFSET_TOP);
  5588. }
  5589. }
  5590. exports.BaseTreeViewer = BaseTreeViewer;
  5591. /***/
  5592. }),
  5593. /* 15 */
  5594. /***/
  5595. ((__unused_webpack_module, exports, __webpack_require__) => {
  5596. Object.defineProperty(exports, "__esModule", ({
  5597. value: true
  5598. }));
  5599. exports.PDFDocumentProperties = void 0;
  5600. var _pdfjsLib = __webpack_require__(5);
  5601. var _ui_utils = __webpack_require__(1);
  5602. function _classPrivateMethodInitSpec(obj, privateSet) {
  5603. _checkPrivateRedeclaration(obj, privateSet);
  5604. privateSet.add(obj);
  5605. }
  5606. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  5607. _checkPrivateRedeclaration(obj, privateMap);
  5608. privateMap.set(obj, value);
  5609. }
  5610. function _checkPrivateRedeclaration(obj, privateCollection) {
  5611. if (privateCollection.has(obj)) {
  5612. throw new TypeError(
  5613. "Cannot initialize the same private elements twice on an object");
  5614. }
  5615. }
  5616. function _classPrivateFieldSet(receiver, privateMap, value) {
  5617. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  5618. _classApplyDescriptorSet(receiver, descriptor, value);
  5619. return value;
  5620. }
  5621. function _classApplyDescriptorSet(receiver, descriptor, value) {
  5622. if (descriptor.set) {
  5623. descriptor.set.call(receiver, value);
  5624. } else {
  5625. if (!descriptor.writable) {
  5626. throw new TypeError("attempted to set read only private field");
  5627. }
  5628. descriptor.value = value;
  5629. }
  5630. }
  5631. function _classPrivateFieldGet(receiver, privateMap) {
  5632. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  5633. return _classApplyDescriptorGet(receiver, descriptor);
  5634. }
  5635. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  5636. if (!privateMap.has(receiver)) {
  5637. throw new TypeError("attempted to " + action + " private field on non-instance");
  5638. }
  5639. return privateMap.get(receiver);
  5640. }
  5641. function _classApplyDescriptorGet(receiver, descriptor) {
  5642. if (descriptor.get) {
  5643. return descriptor.get.call(receiver);
  5644. }
  5645. return descriptor.value;
  5646. }
  5647. function _classPrivateMethodGet(receiver, privateSet, fn) {
  5648. if (!privateSet.has(receiver)) {
  5649. throw new TypeError("attempted to get private field on non-instance");
  5650. }
  5651. return fn;
  5652. }
  5653. const DEFAULT_FIELD_CONTENT = "-";
  5654. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5655. const US_PAGE_NAMES = {
  5656. "8.5x11": "Letter",
  5657. "8.5x14": "Legal"
  5658. };
  5659. const METRIC_PAGE_NAMES = {
  5660. "297x420": "A3",
  5661. "210x297": "A4"
  5662. };
  5663. function getPageName(size, isPortrait, pageNames) {
  5664. const width = isPortrait ? size.width : size.height;
  5665. const height = isPortrait ? size.height : size.width;
  5666. return pageNames[`${width}x${height}`];
  5667. }
  5668. var _fieldData = /*#__PURE__*/ new WeakMap();
  5669. var _reset = /*#__PURE__*/ new WeakSet();
  5670. var _updateUI = /*#__PURE__*/ new WeakSet();
  5671. var _parseFileSize = /*#__PURE__*/ new WeakSet();
  5672. var _parsePageSize = /*#__PURE__*/ new WeakSet();
  5673. var _parseDate = /*#__PURE__*/ new WeakSet();
  5674. var _parseLinearization = /*#__PURE__*/ new WeakSet();
  5675. class PDFDocumentProperties {
  5676. constructor(_ref, overlayManager, eventBus, l10n, fileNameLookup) {
  5677. let {
  5678. dialog,
  5679. fields,
  5680. closeButton
  5681. } = _ref;
  5682. _classPrivateMethodInitSpec(this, _parseLinearization);
  5683. _classPrivateMethodInitSpec(this, _parseDate);
  5684. _classPrivateMethodInitSpec(this, _parsePageSize);
  5685. _classPrivateMethodInitSpec(this, _parseFileSize);
  5686. _classPrivateMethodInitSpec(this, _updateUI);
  5687. _classPrivateMethodInitSpec(this, _reset);
  5688. _classPrivateFieldInitSpec(this, _fieldData, {
  5689. writable: true,
  5690. value: null
  5691. });
  5692. this.dialog = dialog;
  5693. this.fields = fields;
  5694. this.overlayManager = overlayManager;
  5695. this.l10n = l10n;
  5696. this._fileNameLookup = fileNameLookup;
  5697. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  5698. closeButton.addEventListener("click", this.close.bind(this));
  5699. this.overlayManager.register(this.dialog);
  5700. eventBus._on("pagechanging", evt => {
  5701. this._currentPageNumber = evt.pageNumber;
  5702. });
  5703. eventBus._on("rotationchanging", evt => {
  5704. this._pagesRotation = evt.pagesRotation;
  5705. });
  5706. this._isNonMetricLocale = true;
  5707. l10n.getLanguage().then(locale => {
  5708. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5709. });
  5710. }
  5711. async open() {
  5712. await Promise.all([this.overlayManager.open(this.dialog), this
  5713. ._dataAvailableCapability.promise
  5714. ]);
  5715. const currentPageNumber = this._currentPageNumber;
  5716. const pagesRotation = this._pagesRotation;
  5717. if (_classPrivateFieldGet(this, _fieldData) && currentPageNumber ===
  5718. _classPrivateFieldGet(this, _fieldData)._currentPageNumber &&
  5719. pagesRotation === _classPrivateFieldGet(this, _fieldData)._pagesRotation) {
  5720. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  5721. return;
  5722. }
  5723. const {
  5724. info,
  5725. contentLength
  5726. } = await this.pdfDocument.getMetadata();
  5727. const [fileName, fileSize, creationDate, modificationDate, pageSize,
  5728. isLinearized
  5729. ] = await Promise.all([this._fileNameLookup(), _classPrivateMethodGet(this,
  5730. _parseFileSize, _parseFileSize2).call(this, contentLength),
  5731. _classPrivateMethodGet(this, _parseDate, _parseDate2).call(this,
  5732. info.CreationDate), _classPrivateMethodGet(this, _parseDate,
  5733. _parseDate2).call(this, info.ModDate), this.pdfDocument.getPage(
  5734. currentPageNumber).then(pdfPage => {
  5735. return _classPrivateMethodGet(this, _parsePageSize,
  5736. _parsePageSize2).call(this, (0, _ui_utils
  5737. .getPageSizeInches)(pdfPage), pagesRotation);
  5738. }), _classPrivateMethodGet(this, _parseLinearization,
  5739. _parseLinearization2).call(this, info.IsLinearized)
  5740. ]);
  5741. _classPrivateFieldSet(this, _fieldData, Object.freeze({
  5742. fileName,
  5743. fileSize,
  5744. title: info.Title,
  5745. author: info.Author,
  5746. subject: info.Subject,
  5747. keywords: info.Keywords,
  5748. creationDate,
  5749. modificationDate,
  5750. creator: info.Creator,
  5751. producer: info.Producer,
  5752. version: info.PDFFormatVersion,
  5753. pageCount: this.pdfDocument.numPages,
  5754. pageSize,
  5755. linearized: isLinearized,
  5756. _currentPageNumber: currentPageNumber,
  5757. _pagesRotation: pagesRotation
  5758. }));
  5759. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  5760. const {
  5761. length
  5762. } = await this.pdfDocument.getDownloadInfo();
  5763. if (contentLength === length) {
  5764. return;
  5765. }
  5766. const data = Object.assign(Object.create(null), _classPrivateFieldGet(this,
  5767. _fieldData));
  5768. data.fileSize = await _classPrivateMethodGet(this, _parseFileSize,
  5769. _parseFileSize2).call(this, length);
  5770. _classPrivateFieldSet(this, _fieldData, Object.freeze(data));
  5771. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  5772. }
  5773. async close() {
  5774. this.overlayManager.close(this.dialog);
  5775. }
  5776. setDocument(pdfDocument) {
  5777. if (this.pdfDocument) {
  5778. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  5779. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this, true);
  5780. }
  5781. if (!pdfDocument) {
  5782. return;
  5783. }
  5784. this.pdfDocument = pdfDocument;
  5785. this._dataAvailableCapability.resolve();
  5786. }
  5787. }
  5788. exports.PDFDocumentProperties = PDFDocumentProperties;
  5789. function _reset2() {
  5790. this.pdfDocument = null;
  5791. _classPrivateFieldSet(this, _fieldData, null);
  5792. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5793. this._currentPageNumber = 1;
  5794. this._pagesRotation = 0;
  5795. }
  5796. function _updateUI2() {
  5797. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5798. if (reset || !_classPrivateFieldGet(this, _fieldData)) {
  5799. for (const id in this.fields) {
  5800. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5801. }
  5802. return;
  5803. }
  5804. if (this.overlayManager.active !== this.dialog) {
  5805. return;
  5806. }
  5807. for (const id in this.fields) {
  5808. const content = _classPrivateFieldGet(this, _fieldData)[id];
  5809. this.fields[id].textContent = content || content === 0 ? content :
  5810. DEFAULT_FIELD_CONTENT;
  5811. }
  5812. }
  5813. async function _parseFileSize2() {
  5814. let fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  5815. 0;
  5816. const kb = fileSize / 1024,
  5817. mb = kb / 1024;
  5818. if (!kb) {
  5819. return undefined;
  5820. }
  5821. return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
  5822. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  5823. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  5824. size_b: fileSize.toLocaleString()
  5825. });
  5826. }
  5827. async function _parsePageSize2(pageSizeInches, pagesRotation) {
  5828. if (!pageSizeInches) {
  5829. return undefined;
  5830. }
  5831. if (pagesRotation % 180 !== 0) {
  5832. pageSizeInches = {
  5833. width: pageSizeInches.height,
  5834. height: pageSizeInches.width
  5835. };
  5836. }
  5837. const isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5838. let sizeInches = {
  5839. width: Math.round(pageSizeInches.width * 100) / 100,
  5840. height: Math.round(pageSizeInches.height * 100) / 100
  5841. };
  5842. let sizeMillimeters = {
  5843. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5844. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5845. };
  5846. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(
  5847. sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5848. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(
  5849. sizeMillimeters.height))) {
  5850. const exactMillimeters = {
  5851. width: pageSizeInches.width * 25.4,
  5852. height: pageSizeInches.height * 25.4
  5853. };
  5854. const intMillimeters = {
  5855. width: Math.round(sizeMillimeters.width),
  5856. height: Math.round(sizeMillimeters.height)
  5857. };
  5858. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(
  5859. exactMillimeters.height - intMillimeters.height) < 0.1) {
  5860. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5861. if (rawName) {
  5862. sizeInches = {
  5863. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5864. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5865. };
  5866. sizeMillimeters = intMillimeters;
  5867. }
  5868. }
  5869. }
  5870. const [{
  5871. width,
  5872. height
  5873. }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ?
  5874. sizeInches : sizeMillimeters, this.l10n.get(
  5875. `document_properties_page_size_unit_${this._isNonMetricLocale ? "inches" : "millimeters"}`
  5876. ), rawName && this.l10n.get(
  5877. `document_properties_page_size_name_${rawName.toLowerCase()}`), this
  5878. .l10n.get(
  5879. `document_properties_page_size_orientation_${isPortrait ? "portrait" : "landscape"}`
  5880. )
  5881. ]);
  5882. return this.l10n.get(
  5883. `document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
  5884. width: width.toLocaleString(),
  5885. height: height.toLocaleString(),
  5886. unit,
  5887. name,
  5888. orientation
  5889. });
  5890. }
  5891. async function _parseDate2(inputDate) {
  5892. const dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5893. if (!dateObject) {
  5894. return undefined;
  5895. }
  5896. return this.l10n.get("document_properties_date_string", {
  5897. date: dateObject.toLocaleDateString(),
  5898. time: dateObject.toLocaleTimeString()
  5899. });
  5900. }
  5901. function _parseLinearization2(isLinearized) {
  5902. return this.l10n.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
  5903. }
  5904. /***/
  5905. }),
  5906. /* 16 */
  5907. /***/
  5908. ((__unused_webpack_module, exports, __webpack_require__) => {
  5909. Object.defineProperty(exports, "__esModule", ({
  5910. value: true
  5911. }));
  5912. exports.PDFFindBar = void 0;
  5913. var _pdf_find_controller = __webpack_require__(17);
  5914. function _classPrivateMethodInitSpec(obj, privateSet) {
  5915. _checkPrivateRedeclaration(obj, privateSet);
  5916. privateSet.add(obj);
  5917. }
  5918. function _checkPrivateRedeclaration(obj, privateCollection) {
  5919. if (privateCollection.has(obj)) {
  5920. throw new TypeError(
  5921. "Cannot initialize the same private elements twice on an object");
  5922. }
  5923. }
  5924. function _classPrivateMethodGet(receiver, privateSet, fn) {
  5925. if (!privateSet.has(receiver)) {
  5926. throw new TypeError("attempted to get private field on non-instance");
  5927. }
  5928. return fn;
  5929. }
  5930. const MATCHES_COUNT_LIMIT = 1000;
  5931. var _adjustWidth = /*#__PURE__*/ new WeakSet();
  5932. class PDFFindBar {
  5933. constructor(options, eventBus, l10n) {
  5934. _classPrivateMethodInitSpec(this, _adjustWidth);
  5935. this.opened = false;
  5936. this.bar = options.bar;
  5937. this.toggleButton = options.toggleButton;
  5938. this.findField = options.findField;
  5939. this.highlightAll = options.highlightAllCheckbox;
  5940. this.caseSensitive = options.caseSensitiveCheckbox;
  5941. this.matchDiacritics = options.matchDiacriticsCheckbox;
  5942. this.entireWord = options.entireWordCheckbox;
  5943. this.findMsg = options.findMsg;
  5944. this.findResultsCount = options.findResultsCount;
  5945. this.findPreviousButton = options.findPreviousButton;
  5946. this.findNextButton = options.findNextButton;
  5947. this.eventBus = eventBus;
  5948. this.l10n = l10n;
  5949. this.toggleButton.addEventListener("click", () => {
  5950. this.toggle();
  5951. });
  5952. this.findField.addEventListener("input", () => {
  5953. this.dispatchEvent("");
  5954. });
  5955. this.bar.addEventListener("keydown", e => {
  5956. switch (e.keyCode) {
  5957. case 13:
  5958. if (e.target === this.findField) {
  5959. this.dispatchEvent("again", e.shiftKey);
  5960. }
  5961. break;
  5962. case 27:
  5963. this.close();
  5964. break;
  5965. }
  5966. });
  5967. this.findPreviousButton.addEventListener("click", () => {
  5968. this.dispatchEvent("again", true);
  5969. });
  5970. this.findNextButton.addEventListener("click", () => {
  5971. this.dispatchEvent("again", false);
  5972. });
  5973. this.highlightAll.addEventListener("click", () => {
  5974. this.dispatchEvent("highlightallchange");
  5975. });
  5976. this.caseSensitive.addEventListener("click", () => {
  5977. this.dispatchEvent("casesensitivitychange");
  5978. });
  5979. this.entireWord.addEventListener("click", () => {
  5980. this.dispatchEvent("entirewordchange");
  5981. });
  5982. this.matchDiacritics.addEventListener("click", () => {
  5983. this.dispatchEvent("diacriticmatchingchange");
  5984. });
  5985. this.eventBus._on("resize", _classPrivateMethodGet(this, _adjustWidth,
  5986. _adjustWidth2).bind(this));
  5987. }
  5988. reset() {
  5989. this.updateUIState();
  5990. }
  5991. dispatchEvent(type) {
  5992. let findPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  5993. 1] : false;
  5994. this.eventBus.dispatch("find", {
  5995. source: this,
  5996. type,
  5997. query: this.findField.value,
  5998. phraseSearch: true,
  5999. caseSensitive: this.caseSensitive.checked,
  6000. entireWord: this.entireWord.checked,
  6001. highlightAll: this.highlightAll.checked,
  6002. findPrevious: findPrev,
  6003. matchDiacritics: this.matchDiacritics.checked
  6004. });
  6005. }
  6006. updateUIState(state, previous, matchesCount) {
  6007. let findMsg = Promise.resolve("");
  6008. let status = "";
  6009. switch (state) {
  6010. case _pdf_find_controller.FindState.FOUND:
  6011. break;
  6012. case _pdf_find_controller.FindState.PENDING:
  6013. status = "pending";
  6014. break;
  6015. case _pdf_find_controller.FindState.NOT_FOUND:
  6016. findMsg = this.l10n.get("find_not_found");
  6017. status = "notFound";
  6018. break;
  6019. case _pdf_find_controller.FindState.WRAPPED:
  6020. findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
  6021. break;
  6022. }
  6023. this.findField.setAttribute("data-status", status);
  6024. this.findField.setAttribute("aria-invalid", state === _pdf_find_controller
  6025. .FindState.NOT_FOUND);
  6026. findMsg.then(msg => {
  6027. this.findMsg.textContent = msg;
  6028. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(
  6029. this);
  6030. });
  6031. this.updateResultsCount(matchesCount);
  6032. }
  6033. updateResultsCount() {
  6034. let {
  6035. current = 0,
  6036. total = 0
  6037. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6038. const limit = MATCHES_COUNT_LIMIT;
  6039. let matchCountMsg = Promise.resolve("");
  6040. if (total > 0) {
  6041. if (total > limit) {
  6042. let key = "find_match_count_limit";
  6043. matchCountMsg = this.l10n.get(key, {
  6044. limit
  6045. });
  6046. } else {
  6047. let key = "find_match_count";
  6048. matchCountMsg = this.l10n.get(key, {
  6049. current,
  6050. total
  6051. });
  6052. }
  6053. }
  6054. matchCountMsg.then(msg => {
  6055. this.findResultsCount.textContent = msg;
  6056. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(
  6057. this);
  6058. });
  6059. }
  6060. open() {
  6061. if (!this.opened) {
  6062. this.opened = true;
  6063. this.toggleButton.classList.add("toggled");
  6064. this.toggleButton.setAttribute("aria-expanded", "true");
  6065. this.bar.classList.remove("hidden");
  6066. }
  6067. this.findField.select();
  6068. this.findField.focus();
  6069. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(this);
  6070. }
  6071. close() {
  6072. if (!this.opened) {
  6073. return;
  6074. }
  6075. this.opened = false;
  6076. this.toggleButton.classList.remove("toggled");
  6077. this.toggleButton.setAttribute("aria-expanded", "false");
  6078. this.bar.classList.add("hidden");
  6079. this.eventBus.dispatch("findbarclose", {
  6080. source: this
  6081. });
  6082. }
  6083. toggle() {
  6084. if (this.opened) {
  6085. this.close();
  6086. } else {
  6087. this.open();
  6088. }
  6089. }
  6090. }
  6091. exports.PDFFindBar = PDFFindBar;
  6092. function _adjustWidth2() {
  6093. if (!this.opened) {
  6094. return;
  6095. }
  6096. this.bar.classList.remove("wrapContainers");
  6097. const findbarHeight = this.bar.clientHeight;
  6098. const inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6099. if (findbarHeight > inputContainerHeight) {
  6100. this.bar.classList.add("wrapContainers");
  6101. }
  6102. }
  6103. /***/
  6104. }),
  6105. /* 17 */
  6106. /***/
  6107. ((__unused_webpack_module, exports, __webpack_require__) => {
  6108. Object.defineProperty(exports, "__esModule", ({
  6109. value: true
  6110. }));
  6111. exports.PDFFindController = exports.FindState = void 0;
  6112. var _ui_utils = __webpack_require__(1);
  6113. var _pdfjsLib = __webpack_require__(5);
  6114. var _pdf_find_utils = __webpack_require__(18);
  6115. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  6116. _checkPrivateRedeclaration(obj, privateMap);
  6117. privateMap.set(obj, value);
  6118. }
  6119. function _classPrivateMethodInitSpec(obj, privateSet) {
  6120. _checkPrivateRedeclaration(obj, privateSet);
  6121. privateSet.add(obj);
  6122. }
  6123. function _checkPrivateRedeclaration(obj, privateCollection) {
  6124. if (privateCollection.has(obj)) {
  6125. throw new TypeError(
  6126. "Cannot initialize the same private elements twice on an object");
  6127. }
  6128. }
  6129. function _classPrivateFieldGet(receiver, privateMap) {
  6130. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  6131. return _classApplyDescriptorGet(receiver, descriptor);
  6132. }
  6133. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  6134. if (!privateMap.has(receiver)) {
  6135. throw new TypeError("attempted to " + action + " private field on non-instance");
  6136. }
  6137. return privateMap.get(receiver);
  6138. }
  6139. function _classApplyDescriptorGet(receiver, descriptor) {
  6140. if (descriptor.get) {
  6141. return descriptor.get.call(receiver);
  6142. }
  6143. return descriptor.value;
  6144. }
  6145. function _classPrivateMethodGet(receiver, privateSet, fn) {
  6146. if (!privateSet.has(receiver)) {
  6147. throw new TypeError("attempted to get private field on non-instance");
  6148. }
  6149. return fn;
  6150. }
  6151. const FindState = {
  6152. FOUND: 0,
  6153. NOT_FOUND: 1,
  6154. WRAPPED: 2,
  6155. PENDING: 3
  6156. };
  6157. exports.FindState = FindState;
  6158. const FIND_TIMEOUT = 250;
  6159. const MATCH_SCROLL_OFFSET_TOP = -50;
  6160. const MATCH_SCROLL_OFFSET_LEFT = -400;
  6161. const CHARACTERS_TO_NORMALIZE = {
  6162. "\u2010": "-",
  6163. "\u2018": "'",
  6164. "\u2019": "'",
  6165. "\u201A": "'",
  6166. "\u201B": "'",
  6167. "\u201C": '"',
  6168. "\u201D": '"',
  6169. "\u201E": '"',
  6170. "\u201F": '"',
  6171. "\u00BC": "1/4",
  6172. "\u00BD": "1/2",
  6173. "\u00BE": "3/4"
  6174. };
  6175. const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd,
  6176. 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba,
  6177. 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab,
  6178. 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed,
  6179. 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74
  6180. ]);
  6181. const DIACRITICS_EXCEPTION_STR = [...DIACRITICS_EXCEPTION.values()].map(x => String
  6182. .fromCharCode(x)).join("");
  6183. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  6184. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  6185. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  6186. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  6187. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  6188. const SYLLABLES_LENGTHS = new Map();
  6189. const FIRST_CHAR_SYLLABLES_REG_EXP =
  6190. "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  6191. let noSyllablesRegExp = null;
  6192. let withSyllablesRegExp = null;
  6193. function normalize(text) {
  6194. const syllablePositions = [];
  6195. let m;
  6196. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  6197. let {
  6198. index
  6199. } = m;
  6200. for (const char of m[0]) {
  6201. let len = SYLLABLES_LENGTHS.get(char);
  6202. if (!len) {
  6203. len = char.normalize("NFD").length;
  6204. SYLLABLES_LENGTHS.set(char, len);
  6205. }
  6206. syllablePositions.push([len, index++]);
  6207. }
  6208. }
  6209. let normalizationRegex;
  6210. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  6211. normalizationRegex = noSyllablesRegExp;
  6212. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  6213. normalizationRegex = withSyllablesRegExp;
  6214. } else {
  6215. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6216. const regexp = `([${replace}])|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(\\n)`;
  6217. if (syllablePositions.length === 0) {
  6218. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)",
  6219. "gum");
  6220. } else {
  6221. normalizationRegex = withSyllablesRegExp = new RegExp(regexp +
  6222. `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  6223. }
  6224. }
  6225. const rawDiacriticsPositions = [];
  6226. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  6227. rawDiacriticsPositions.push([m[0].length, m.index]);
  6228. }
  6229. let normalized = text.normalize("NFD");
  6230. const positions = [
  6231. [0, 0]
  6232. ];
  6233. let rawDiacriticsIndex = 0;
  6234. let syllableIndex = 0;
  6235. let shift = 0;
  6236. let shiftOrigin = 0;
  6237. let eol = 0;
  6238. let hasDiacritics = false;
  6239. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, i) => {
  6240. var _syllablePositions$sy;
  6241. i -= shiftOrigin;
  6242. if (p1) {
  6243. const replacement = CHARACTERS_TO_NORMALIZE[match];
  6244. const jj = replacement.length;
  6245. for (let j = 1; j < jj; j++) {
  6246. positions.push([i - shift + j, shift - j]);
  6247. }
  6248. shift -= jj - 1;
  6249. return replacement;
  6250. }
  6251. if (p2) {
  6252. var _rawDiacriticsPositio;
  6253. const hasTrailingDashEOL = p2.endsWith("\n");
  6254. const len = hasTrailingDashEOL ? p2.length - 2 : p2.length;
  6255. hasDiacritics = true;
  6256. let jj = len;
  6257. if (i + eol === ((_rawDiacriticsPositio = rawDiacriticsPositions[
  6258. rawDiacriticsIndex]) === null || _rawDiacriticsPositio ===
  6259. void 0 ? void 0 : _rawDiacriticsPositio[1])) {
  6260. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  6261. ++rawDiacriticsIndex;
  6262. }
  6263. for (let j = 1; j <= jj; j++) {
  6264. positions.push([i - 1 - shift + j, shift - j]);
  6265. }
  6266. shift -= jj;
  6267. shiftOrigin += jj;
  6268. if (hasTrailingDashEOL) {
  6269. i += len - 1;
  6270. positions.push([i - shift + 1, 1 + shift]);
  6271. shift += 1;
  6272. shiftOrigin += 1;
  6273. eol += 1;
  6274. return p2.slice(0, len);
  6275. }
  6276. return p2;
  6277. }
  6278. if (p3) {
  6279. positions.push([i - shift + 1, 1 + shift]);
  6280. shift += 1;
  6281. shiftOrigin += 1;
  6282. eol += 1;
  6283. return p3.charAt(0);
  6284. }
  6285. if (p4) {
  6286. positions.push([i - shift + 1, shift - 1]);
  6287. shift -= 1;
  6288. shiftOrigin += 1;
  6289. eol += 1;
  6290. return " ";
  6291. }
  6292. if (i + eol === ((_syllablePositions$sy = syllablePositions[
  6293. syllableIndex]) === null || _syllablePositions$sy === void 0 ?
  6294. void 0 : _syllablePositions$sy[1])) {
  6295. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  6296. ++syllableIndex;
  6297. for (let j = 1; j <= newCharLen; j++) {
  6298. positions.push([i - (shift - j), shift - j]);
  6299. }
  6300. shift -= newCharLen;
  6301. shiftOrigin += newCharLen;
  6302. }
  6303. return p5;
  6304. });
  6305. positions.push([normalized.length, shift]);
  6306. return [normalized, positions, hasDiacritics];
  6307. }
  6308. function getOriginalIndex(diffs, pos, len) {
  6309. if (!diffs) {
  6310. return [pos, len];
  6311. }
  6312. const start = pos;
  6313. const end = pos + len;
  6314. let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
  6315. if (diffs[i][0] > start) {
  6316. --i;
  6317. }
  6318. let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  6319. if (diffs[j][0] > end) {
  6320. --j;
  6321. }
  6322. return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
  6323. }
  6324. var _onFind = /*#__PURE__*/ new WeakSet();
  6325. var _reset = /*#__PURE__*/ new WeakSet();
  6326. var _query = /*#__PURE__*/ new WeakMap();
  6327. var _shouldDirtyMatch = /*#__PURE__*/ new WeakSet();
  6328. var _isEntireWord = /*#__PURE__*/ new WeakSet();
  6329. var _calculateRegExpMatch = /*#__PURE__*/ new WeakSet();
  6330. var _convertToRegExpString = /*#__PURE__*/ new WeakSet();
  6331. var _calculateMatch = /*#__PURE__*/ new WeakSet();
  6332. var _extractText = /*#__PURE__*/ new WeakSet();
  6333. var _updatePage = /*#__PURE__*/ new WeakSet();
  6334. var _updateAllPages = /*#__PURE__*/ new WeakSet();
  6335. var _nextMatch = /*#__PURE__*/ new WeakSet();
  6336. var _matchesReady = /*#__PURE__*/ new WeakSet();
  6337. var _nextPageMatch = /*#__PURE__*/ new WeakSet();
  6338. var _advanceOffsetPage = /*#__PURE__*/ new WeakSet();
  6339. var _updateMatch = /*#__PURE__*/ new WeakSet();
  6340. var _onFindBarClose = /*#__PURE__*/ new WeakSet();
  6341. var _requestMatchesCount = /*#__PURE__*/ new WeakSet();
  6342. var _updateUIResultsCount = /*#__PURE__*/ new WeakSet();
  6343. var _updateUIState = /*#__PURE__*/ new WeakSet();
  6344. class PDFFindController {
  6345. constructor(_ref) {
  6346. let {
  6347. linkService: _linkService,
  6348. eventBus
  6349. } = _ref;
  6350. _classPrivateMethodInitSpec(this, _updateUIState);
  6351. _classPrivateMethodInitSpec(this, _updateUIResultsCount);
  6352. _classPrivateMethodInitSpec(this, _requestMatchesCount);
  6353. _classPrivateMethodInitSpec(this, _onFindBarClose);
  6354. _classPrivateMethodInitSpec(this, _updateMatch);
  6355. _classPrivateMethodInitSpec(this, _advanceOffsetPage);
  6356. _classPrivateMethodInitSpec(this, _nextPageMatch);
  6357. _classPrivateMethodInitSpec(this, _matchesReady);
  6358. _classPrivateMethodInitSpec(this, _nextMatch);
  6359. _classPrivateMethodInitSpec(this, _updateAllPages);
  6360. _classPrivateMethodInitSpec(this, _updatePage);
  6361. _classPrivateMethodInitSpec(this, _extractText);
  6362. _classPrivateMethodInitSpec(this, _calculateMatch);
  6363. _classPrivateMethodInitSpec(this, _convertToRegExpString);
  6364. _classPrivateMethodInitSpec(this, _calculateRegExpMatch);
  6365. _classPrivateMethodInitSpec(this, _isEntireWord);
  6366. _classPrivateMethodInitSpec(this, _shouldDirtyMatch);
  6367. _classPrivateFieldInitSpec(this, _query, {
  6368. get: _get_query,
  6369. set: void 0
  6370. });
  6371. _classPrivateMethodInitSpec(this, _reset);
  6372. _classPrivateMethodInitSpec(this, _onFind);
  6373. this._linkService = _linkService;
  6374. this._eventBus = eventBus;
  6375. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  6376. eventBus._on("find", _classPrivateMethodGet(this, _onFind, _onFind2).bind(
  6377. this));
  6378. eventBus._on("findbarclose", _classPrivateMethodGet(this, _onFindBarClose,
  6379. _onFindBarClose2).bind(this));
  6380. }
  6381. get highlightMatches() {
  6382. return this._highlightMatches;
  6383. }
  6384. get pageMatches() {
  6385. return this._pageMatches;
  6386. }
  6387. get pageMatchesLength() {
  6388. return this._pageMatchesLength;
  6389. }
  6390. get selected() {
  6391. return this._selected;
  6392. }
  6393. get state() {
  6394. return this._state;
  6395. }
  6396. setDocument(pdfDocument) {
  6397. if (this._pdfDocument) {
  6398. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  6399. }
  6400. if (!pdfDocument) {
  6401. return;
  6402. }
  6403. this._pdfDocument = pdfDocument;
  6404. this._firstPageCapability.resolve();
  6405. }
  6406. scrollMatchIntoView(_ref2) {
  6407. let {
  6408. element = null,
  6409. selectedLeft = 0,
  6410. pageIndex = -1,
  6411. matchIndex = -1
  6412. } = _ref2;
  6413. if (!this._scrollMatches || !element) {
  6414. return;
  6415. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6416. return;
  6417. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6418. return;
  6419. }
  6420. this._scrollMatches = false;
  6421. const spot = {
  6422. top: MATCH_SCROLL_OFFSET_TOP,
  6423. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  6424. };
  6425. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6426. }
  6427. }
  6428. exports.PDFFindController = PDFFindController;
  6429. function _onFind2(state) {
  6430. if (!state) {
  6431. return;
  6432. }
  6433. const pdfDocument = this._pdfDocument;
  6434. const {
  6435. type
  6436. } = state;
  6437. if (this._state === null || _classPrivateMethodGet(this, _shouldDirtyMatch,
  6438. _shouldDirtyMatch2).call(this, state)) {
  6439. this._dirtyMatch = true;
  6440. }
  6441. this._state = state;
  6442. if (type !== "highlightallchange") {
  6443. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState
  6444. .PENDING);
  6445. }
  6446. this._firstPageCapability.promise.then(() => {
  6447. if (!this._pdfDocument || pdfDocument && this._pdfDocument !==
  6448. pdfDocument) {
  6449. return;
  6450. }
  6451. _classPrivateMethodGet(this, _extractText, _extractText2).call(this);
  6452. const findbarClosed = !this._highlightMatches;
  6453. const pendingTimeout = !!this._findTimeout;
  6454. if (this._findTimeout) {
  6455. clearTimeout(this._findTimeout);
  6456. this._findTimeout = null;
  6457. }
  6458. if (!type) {
  6459. this._findTimeout = setTimeout(() => {
  6460. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(
  6461. this);
  6462. this._findTimeout = null;
  6463. }, FIND_TIMEOUT);
  6464. } else if (this._dirtyMatch) {
  6465. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6466. } else if (type === "again") {
  6467. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6468. if (findbarClosed && this._state.highlightAll) {
  6469. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2)
  6470. .call(this);
  6471. }
  6472. } else if (type === "highlightallchange") {
  6473. if (pendingTimeout) {
  6474. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6475. } else {
  6476. this._highlightMatches = true;
  6477. }
  6478. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(
  6479. this);
  6480. } else {
  6481. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6482. }
  6483. });
  6484. }
  6485. function _reset2() {
  6486. this._highlightMatches = false;
  6487. this._scrollMatches = false;
  6488. this._pdfDocument = null;
  6489. this._pageMatches = [];
  6490. this._pageMatchesLength = [];
  6491. this._state = null;
  6492. this._selected = {
  6493. pageIdx: -1,
  6494. matchIdx: -1
  6495. };
  6496. this._offset = {
  6497. pageIdx: null,
  6498. matchIdx: null,
  6499. wrapped: false
  6500. };
  6501. this._extractTextPromises = [];
  6502. this._pageContents = [];
  6503. this._pageDiffs = [];
  6504. this._hasDiacritics = [];
  6505. this._matchesCountTotal = 0;
  6506. this._pagesToSearch = null;
  6507. this._pendingFindMatches = new Set();
  6508. this._resumePageIdx = null;
  6509. this._dirtyMatch = false;
  6510. clearTimeout(this._findTimeout);
  6511. this._findTimeout = null;
  6512. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6513. }
  6514. function _get_query() {
  6515. if (this._state.query !== this._rawQuery) {
  6516. this._rawQuery = this._state.query;
  6517. [this._normalizedQuery] = normalize(this._state.query);
  6518. }
  6519. return this._normalizedQuery;
  6520. }
  6521. function _shouldDirtyMatch2(state) {
  6522. if (state.query !== this._state.query) {
  6523. return true;
  6524. }
  6525. switch (state.type) {
  6526. case "again":
  6527. const pageNumber = this._selected.pageIdx + 1;
  6528. const linkService = this._linkService;
  6529. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !==
  6530. linkService.page && !linkService.isPageVisible(pageNumber)) {
  6531. return true;
  6532. }
  6533. return false;
  6534. case "highlightallchange":
  6535. return false;
  6536. }
  6537. return true;
  6538. }
  6539. function _isEntireWord2(content, startIdx, length) {
  6540. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  6541. if (match) {
  6542. const first = content.charCodeAt(startIdx);
  6543. const limit = match[1].charCodeAt(0);
  6544. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils
  6545. .getCharacterType)(limit)) {
  6546. return false;
  6547. }
  6548. }
  6549. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  6550. if (match) {
  6551. const last = content.charCodeAt(startIdx + length - 1);
  6552. const limit = match[1].charCodeAt(0);
  6553. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils
  6554. .getCharacterType)(limit)) {
  6555. return false;
  6556. }
  6557. }
  6558. return true;
  6559. }
  6560. function _calculateRegExpMatch2(query, entireWord, pageIndex, pageContent) {
  6561. const matches = [],
  6562. matchesLength = [];
  6563. const diffs = this._pageDiffs[pageIndex];
  6564. let match;
  6565. while ((match = query.exec(pageContent)) !== null) {
  6566. if (entireWord && !_classPrivateMethodGet(this, _isEntireWord, _isEntireWord2).call(
  6567. this, pageContent, match.index, match[0].length)) {
  6568. continue;
  6569. }
  6570. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  6571. if (matchLen) {
  6572. matches.push(matchPos);
  6573. matchesLength.push(matchLen);
  6574. }
  6575. }
  6576. this._pageMatches[pageIndex] = matches;
  6577. this._pageMatchesLength[pageIndex] = matchesLength;
  6578. }
  6579. function _convertToRegExpString2(query, hasDiacritics) {
  6580. const {
  6581. matchDiacritics
  6582. } = this._state;
  6583. let isUnicode = false;
  6584. query = query.replace(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  6585. if (p1) {
  6586. return `[ ]*\\${p1}[ ]*`;
  6587. }
  6588. if (p2) {
  6589. return `[ ]*${p2}[ ]*`;
  6590. }
  6591. if (p3) {
  6592. return "[ ]+";
  6593. }
  6594. if (matchDiacritics) {
  6595. return p4 || p5;
  6596. }
  6597. if (p4) {
  6598. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  6599. }
  6600. if (hasDiacritics) {
  6601. isUnicode = true;
  6602. return `${p5}\\p{M}*`;
  6603. }
  6604. return p5;
  6605. });
  6606. const trailingSpaces = "[ ]*";
  6607. if (query.endsWith(trailingSpaces)) {
  6608. query = query.slice(0, query.length - trailingSpaces.length);
  6609. }
  6610. if (matchDiacritics) {
  6611. if (hasDiacritics) {
  6612. isUnicode = true;
  6613. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  6614. }
  6615. }
  6616. return [isUnicode, query];
  6617. }
  6618. function _calculateMatch2(pageIndex) {
  6619. let query = _classPrivateFieldGet(this, _query);
  6620. if (query.length === 0) {
  6621. return;
  6622. }
  6623. const {
  6624. caseSensitive,
  6625. entireWord,
  6626. phraseSearch
  6627. } = this._state;
  6628. const pageContent = this._pageContents[pageIndex];
  6629. const hasDiacritics = this._hasDiacritics[pageIndex];
  6630. let isUnicode = false;
  6631. if (phraseSearch) {
  6632. [isUnicode, query] = _classPrivateMethodGet(this, _convertToRegExpString,
  6633. _convertToRegExpString2).call(this, query, hasDiacritics);
  6634. } else {
  6635. const match = query.match(/\S+/g);
  6636. if (match) {
  6637. query = match.sort().reverse().map(q => {
  6638. const [isUnicodePart, queryPart] = _classPrivateMethodGet(this,
  6639. _convertToRegExpString, _convertToRegExpString2).call(this,
  6640. q, hasDiacritics);
  6641. isUnicode || (isUnicode = isUnicodePart);
  6642. return `(${queryPart})`;
  6643. }).join("|");
  6644. }
  6645. }
  6646. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  6647. query = new RegExp(query, flags);
  6648. _classPrivateMethodGet(this, _calculateRegExpMatch, _calculateRegExpMatch2).call(this,
  6649. query, entireWord, pageIndex, pageContent);
  6650. if (this._state.highlightAll) {
  6651. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, pageIndex);
  6652. }
  6653. if (this._resumePageIdx === pageIndex) {
  6654. this._resumePageIdx = null;
  6655. _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this);
  6656. }
  6657. const pageMatchesCount = this._pageMatches[pageIndex].length;
  6658. if (pageMatchesCount > 0) {
  6659. this._matchesCountTotal += pageMatchesCount;
  6660. _classPrivateMethodGet(this, _updateUIResultsCount, _updateUIResultsCount2).call(
  6661. this);
  6662. }
  6663. }
  6664. function _extractText2() {
  6665. if (this._extractTextPromises.length > 0) {
  6666. return;
  6667. }
  6668. let promise = Promise.resolve();
  6669. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6670. const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6671. this._extractTextPromises[i] = extractTextCapability.promise;
  6672. promise = promise.then(() => {
  6673. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  6674. return pdfPage.getTextContent();
  6675. }).then(textContent => {
  6676. const strBuf = [];
  6677. for (const textItem of textContent.items) {
  6678. strBuf.push(textItem.str);
  6679. if (textItem.hasEOL) {
  6680. strBuf.push("\n");
  6681. }
  6682. }
  6683. [this._pageContents[i], this._pageDiffs[i], this
  6684. ._hasDiacritics[i]
  6685. ] = normalize(strBuf.join(""));
  6686. extractTextCapability.resolve();
  6687. }, reason => {
  6688. console.error(
  6689. `Unable to get text content for page ${i + 1}`,
  6690. reason);
  6691. this._pageContents[i] = "";
  6692. this._pageDiffs[i] = null;
  6693. this._hasDiacritics[i] = false;
  6694. extractTextCapability.resolve();
  6695. });
  6696. });
  6697. }
  6698. }
  6699. function _updatePage2(index) {
  6700. if (this._scrollMatches && this._selected.pageIdx === index) {
  6701. this._linkService.page = index + 1;
  6702. }
  6703. this._eventBus.dispatch("updatetextlayermatches", {
  6704. source: this,
  6705. pageIndex: index
  6706. });
  6707. }
  6708. function _updateAllPages2() {
  6709. this._eventBus.dispatch("updatetextlayermatches", {
  6710. source: this,
  6711. pageIndex: -1
  6712. });
  6713. }
  6714. function _nextMatch2() {
  6715. const previous = this._state.findPrevious;
  6716. const currentPageIndex = this._linkService.page - 1;
  6717. const numPages = this._linkService.pagesCount;
  6718. this._highlightMatches = true;
  6719. if (this._dirtyMatch) {
  6720. this._dirtyMatch = false;
  6721. this._selected.pageIdx = this._selected.matchIdx = -1;
  6722. this._offset.pageIdx = currentPageIndex;
  6723. this._offset.matchIdx = null;
  6724. this._offset.wrapped = false;
  6725. this._resumePageIdx = null;
  6726. this._pageMatches.length = 0;
  6727. this._pageMatchesLength.length = 0;
  6728. this._matchesCountTotal = 0;
  6729. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  6730. for (let i = 0; i < numPages; i++) {
  6731. if (this._pendingFindMatches.has(i)) {
  6732. continue;
  6733. }
  6734. this._pendingFindMatches.add(i);
  6735. this._extractTextPromises[i].then(() => {
  6736. this._pendingFindMatches.delete(i);
  6737. _classPrivateMethodGet(this, _calculateMatch, _calculateMatch2)
  6738. .call(this, i);
  6739. });
  6740. }
  6741. }
  6742. if (_classPrivateFieldGet(this, _query) === "") {
  6743. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState
  6744. .FOUND);
  6745. return;
  6746. }
  6747. if (this._resumePageIdx) {
  6748. return;
  6749. }
  6750. const offset = this._offset;
  6751. this._pagesToSearch = numPages;
  6752. if (offset.matchIdx !== null) {
  6753. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  6754. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset
  6755. .matchIdx > 0) {
  6756. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6757. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true);
  6758. return;
  6759. }
  6760. _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this,
  6761. previous);
  6762. }
  6763. _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this);
  6764. }
  6765. function _matchesReady2(matches) {
  6766. const offset = this._offset;
  6767. const numMatches = matches.length;
  6768. const previous = this._state.findPrevious;
  6769. if (numMatches) {
  6770. offset.matchIdx = previous ? numMatches - 1 : 0;
  6771. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true);
  6772. return true;
  6773. }
  6774. _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this,
  6775. previous);
  6776. if (offset.wrapped) {
  6777. offset.matchIdx = null;
  6778. if (this._pagesToSearch < 0) {
  6779. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, false);
  6780. return true;
  6781. }
  6782. }
  6783. return false;
  6784. }
  6785. function _nextPageMatch2() {
  6786. if (this._resumePageIdx !== null) {
  6787. console.error("There can only be one pending page.");
  6788. }
  6789. let matches = null;
  6790. do {
  6791. const pageIdx = this._offset.pageIdx;
  6792. matches = this._pageMatches[pageIdx];
  6793. if (!matches) {
  6794. this._resumePageIdx = pageIdx;
  6795. break;
  6796. }
  6797. } while (!_classPrivateMethodGet(this, _matchesReady, _matchesReady2).call(this,
  6798. matches));
  6799. }
  6800. function _advanceOffsetPage2(previous) {
  6801. const offset = this._offset;
  6802. const numPages = this._linkService.pagesCount;
  6803. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6804. offset.matchIdx = null;
  6805. this._pagesToSearch--;
  6806. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6807. offset.pageIdx = previous ? numPages - 1 : 0;
  6808. offset.wrapped = true;
  6809. }
  6810. }
  6811. function _updateMatch2() {
  6812. let found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6813. let state = FindState.NOT_FOUND;
  6814. const wrapped = this._offset.wrapped;
  6815. this._offset.wrapped = false;
  6816. if (found) {
  6817. const previousPage = this._selected.pageIdx;
  6818. this._selected.pageIdx = this._offset.pageIdx;
  6819. this._selected.matchIdx = this._offset.matchIdx;
  6820. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6821. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6822. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this,
  6823. previousPage);
  6824. }
  6825. }
  6826. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, state, this
  6827. ._state.findPrevious);
  6828. if (this._selected.pageIdx !== -1) {
  6829. this._scrollMatches = true;
  6830. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, this._selected
  6831. .pageIdx);
  6832. }
  6833. }
  6834. function _onFindBarClose2(evt) {
  6835. const pdfDocument = this._pdfDocument;
  6836. this._firstPageCapability.promise.then(() => {
  6837. if (!this._pdfDocument || pdfDocument && this._pdfDocument !==
  6838. pdfDocument) {
  6839. return;
  6840. }
  6841. if (this._findTimeout) {
  6842. clearTimeout(this._findTimeout);
  6843. this._findTimeout = null;
  6844. }
  6845. if (this._resumePageIdx) {
  6846. this._resumePageIdx = null;
  6847. this._dirtyMatch = true;
  6848. }
  6849. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this,
  6850. FindState.FOUND);
  6851. this._highlightMatches = false;
  6852. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  6853. });
  6854. }
  6855. function _requestMatchesCount2() {
  6856. const {
  6857. pageIdx,
  6858. matchIdx
  6859. } = this._selected;
  6860. let current = 0,
  6861. total = this._matchesCountTotal;
  6862. if (matchIdx !== -1) {
  6863. for (let i = 0; i < pageIdx; i++) {
  6864. var _this$_pageMatches$i;
  6865. current += ((_this$_pageMatches$i = this._pageMatches[i]) === null ||
  6866. _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length
  6867. ) || 0;
  6868. }
  6869. current += matchIdx + 1;
  6870. }
  6871. if (current < 1 || current > total) {
  6872. current = total = 0;
  6873. }
  6874. return {
  6875. current,
  6876. total
  6877. };
  6878. }
  6879. function _updateUIResultsCount2() {
  6880. this._eventBus.dispatch("updatefindmatchescount", {
  6881. source: this,
  6882. matchesCount: _classPrivateMethodGet(this, _requestMatchesCount,
  6883. _requestMatchesCount2).call(this)
  6884. });
  6885. }
  6886. function _updateUIState2(state) {
  6887. var _this$_state$query, _this$_state;
  6888. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  6889. false;
  6890. this._eventBus.dispatch("updatefindcontrolstate", {
  6891. source: this,
  6892. state,
  6893. previous,
  6894. matchesCount: _classPrivateMethodGet(this, _requestMatchesCount,
  6895. _requestMatchesCount2).call(this),
  6896. rawQuery: (_this$_state$query = (_this$_state = this._state) === null ||
  6897. _this$_state === void 0 ? void 0 : _this$_state.query) !== null &&
  6898. _this$_state$query !== void 0 ? _this$_state$query : null
  6899. });
  6900. }
  6901. /***/
  6902. }),
  6903. /* 18 */
  6904. /***/
  6905. ((__unused_webpack_module, exports) => {
  6906. Object.defineProperty(exports, "__esModule", ({
  6907. value: true
  6908. }));
  6909. exports.CharacterType = void 0;
  6910. exports.getCharacterType = getCharacterType;
  6911. const CharacterType = {
  6912. SPACE: 0,
  6913. ALPHA_LETTER: 1,
  6914. PUNCT: 2,
  6915. HAN_LETTER: 3,
  6916. KATAKANA_LETTER: 4,
  6917. HIRAGANA_LETTER: 5,
  6918. HALFWIDTH_KATAKANA_LETTER: 6,
  6919. THAI_LETTER: 7
  6920. };
  6921. exports.CharacterType = CharacterType;
  6922. function isAlphabeticalScript(charCode) {
  6923. return charCode < 0x2e80;
  6924. }
  6925. function isAscii(charCode) {
  6926. return (charCode & 0xff80) === 0;
  6927. }
  6928. function isAsciiAlpha(charCode) {
  6929. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6930. }
  6931. function isAsciiDigit(charCode) {
  6932. return charCode >= 0x30 && charCode <= 0x39;
  6933. }
  6934. function isAsciiSpace(charCode) {
  6935. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6936. }
  6937. function isHan(charCode) {
  6938. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <=
  6939. 0xfaff;
  6940. }
  6941. function isKatakana(charCode) {
  6942. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6943. }
  6944. function isHiragana(charCode) {
  6945. return charCode >= 0x3040 && charCode <= 0x309f;
  6946. }
  6947. function isHalfwidthKatakana(charCode) {
  6948. return charCode >= 0xff60 && charCode <= 0xff9f;
  6949. }
  6950. function isThai(charCode) {
  6951. return (charCode & 0xff80) === 0x0e00;
  6952. }
  6953. function getCharacterType(charCode) {
  6954. if (isAlphabeticalScript(charCode)) {
  6955. if (isAscii(charCode)) {
  6956. if (isAsciiSpace(charCode)) {
  6957. return CharacterType.SPACE;
  6958. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode ===
  6959. 0x5f) {
  6960. return CharacterType.ALPHA_LETTER;
  6961. }
  6962. return CharacterType.PUNCT;
  6963. } else if (isThai(charCode)) {
  6964. return CharacterType.THAI_LETTER;
  6965. } else if (charCode === 0xa0) {
  6966. return CharacterType.SPACE;
  6967. }
  6968. return CharacterType.ALPHA_LETTER;
  6969. }
  6970. if (isHan(charCode)) {
  6971. return CharacterType.HAN_LETTER;
  6972. } else if (isKatakana(charCode)) {
  6973. return CharacterType.KATAKANA_LETTER;
  6974. } else if (isHiragana(charCode)) {
  6975. return CharacterType.HIRAGANA_LETTER;
  6976. } else if (isHalfwidthKatakana(charCode)) {
  6977. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6978. }
  6979. return CharacterType.ALPHA_LETTER;
  6980. }
  6981. /***/
  6982. }),
  6983. /* 19 */
  6984. /***/
  6985. ((__unused_webpack_module, exports, __webpack_require__) => {
  6986. Object.defineProperty(exports, "__esModule", ({
  6987. value: true
  6988. }));
  6989. exports.PDFHistory = void 0;
  6990. exports.isDestArraysEqual = isDestArraysEqual;
  6991. exports.isDestHashesEqual = isDestHashesEqual;
  6992. var _ui_utils = __webpack_require__(1);
  6993. var _event_utils = __webpack_require__(6);
  6994. const HASH_CHANGE_TIMEOUT = 1000;
  6995. const POSITION_UPDATED_THRESHOLD = 50;
  6996. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  6997. function getCurrentHash() {
  6998. return document.location.hash;
  6999. }
  7000. class PDFHistory {
  7001. constructor(_ref) {
  7002. let {
  7003. linkService,
  7004. eventBus
  7005. } = _ref;
  7006. this.linkService = linkService;
  7007. this.eventBus = eventBus;
  7008. this._initialized = false;
  7009. this._fingerprint = "";
  7010. this.reset();
  7011. this._boundEvents = null;
  7012. this.eventBus._on("pagesinit", () => {
  7013. this._isPagesLoaded = false;
  7014. this.eventBus._on("pagesloaded", evt => {
  7015. this._isPagesLoaded = !!evt.pagesCount;
  7016. }, {
  7017. once: true
  7018. });
  7019. });
  7020. }
  7021. initialize(_ref2) {
  7022. let {
  7023. fingerprint,
  7024. resetHistory = false,
  7025. updateUrl = false
  7026. } = _ref2;
  7027. if (!fingerprint || typeof fingerprint !== "string") {
  7028. console.error(
  7029. 'PDFHistory.initialize: The "fingerprint" must be a non-empty string.'
  7030. );
  7031. return;
  7032. }
  7033. if (this._initialized) {
  7034. this.reset();
  7035. }
  7036. const reInitialized = this._fingerprint !== "" && this._fingerprint !==
  7037. fingerprint;
  7038. this._fingerprint = fingerprint;
  7039. this._updateUrl = updateUrl === true;
  7040. this._initialized = true;
  7041. this._bindEvents();
  7042. const state = window.history.state;
  7043. this._popStateInProgress = false;
  7044. this._blockHashChange = 0;
  7045. this._currentHash = getCurrentHash();
  7046. this._numPositionUpdates = 0;
  7047. this._uid = this._maxUid = 0;
  7048. this._destination = null;
  7049. this._position = null;
  7050. if (!this._isValidState(state, true) || resetHistory) {
  7051. const {
  7052. hash,
  7053. page,
  7054. rotation
  7055. } = this._parseCurrentHash(true);
  7056. if (!hash || reInitialized || resetHistory) {
  7057. this._pushOrReplaceState(null, true);
  7058. return;
  7059. }
  7060. this._pushOrReplaceState({
  7061. hash,
  7062. page,
  7063. rotation
  7064. }, true);
  7065. return;
  7066. }
  7067. const destination = state.destination;
  7068. this._updateInternalState(destination, state.uid, true);
  7069. if (destination.rotation !== undefined) {
  7070. this._initialRotation = destination.rotation;
  7071. }
  7072. if (destination.dest) {
  7073. this._initialBookmark = JSON.stringify(destination.dest);
  7074. this._destination.page = null;
  7075. } else if (destination.hash) {
  7076. this._initialBookmark = destination.hash;
  7077. } else if (destination.page) {
  7078. this._initialBookmark = `page=${destination.page}`;
  7079. }
  7080. }
  7081. reset() {
  7082. if (this._initialized) {
  7083. this._pageHide();
  7084. this._initialized = false;
  7085. this._unbindEvents();
  7086. }
  7087. if (this._updateViewareaTimeout) {
  7088. clearTimeout(this._updateViewareaTimeout);
  7089. this._updateViewareaTimeout = null;
  7090. }
  7091. this._initialBookmark = null;
  7092. this._initialRotation = null;
  7093. }
  7094. push(_ref3) {
  7095. let {
  7096. namedDest = null,
  7097. explicitDest,
  7098. pageNumber
  7099. } = _ref3;
  7100. if (!this._initialized) {
  7101. return;
  7102. }
  7103. if (namedDest && typeof namedDest !== "string") {
  7104. console.error("PDFHistory.push: " +
  7105. `"${namedDest}" is not a valid namedDest parameter.`);
  7106. return;
  7107. } else if (!Array.isArray(explicitDest)) {
  7108. console.error("PDFHistory.push: " +
  7109. `"${explicitDest}" is not a valid explicitDest parameter.`);
  7110. return;
  7111. } else if (!this._isValidPage(pageNumber)) {
  7112. if (pageNumber !== null || this._destination) {
  7113. console.error("PDFHistory.push: " +
  7114. `"${pageNumber}" is not a valid pageNumber parameter.`);
  7115. return;
  7116. }
  7117. }
  7118. const hash = namedDest || JSON.stringify(explicitDest);
  7119. if (!hash) {
  7120. return;
  7121. }
  7122. let forceReplace = false;
  7123. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) ||
  7124. isDestArraysEqual(this._destination.dest, explicitDest))) {
  7125. if (this._destination.page) {
  7126. return;
  7127. }
  7128. forceReplace = true;
  7129. }
  7130. if (this._popStateInProgress && !forceReplace) {
  7131. return;
  7132. }
  7133. this._pushOrReplaceState({
  7134. dest: explicitDest,
  7135. hash,
  7136. page: pageNumber,
  7137. rotation: this.linkService.rotation
  7138. }, forceReplace);
  7139. if (!this._popStateInProgress) {
  7140. this._popStateInProgress = true;
  7141. Promise.resolve().then(() => {
  7142. this._popStateInProgress = false;
  7143. });
  7144. }
  7145. }
  7146. pushPage(pageNumber) {
  7147. var _this$_destination;
  7148. if (!this._initialized) {
  7149. return;
  7150. }
  7151. if (!this._isValidPage(pageNumber)) {
  7152. console.error(
  7153. `PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  7154. return;
  7155. }
  7156. if (((_this$_destination = this._destination) === null || _this$_destination ===
  7157. void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  7158. return;
  7159. }
  7160. if (this._popStateInProgress) {
  7161. return;
  7162. }
  7163. this._pushOrReplaceState({
  7164. dest: null,
  7165. hash: `page=${pageNumber}`,
  7166. page: pageNumber,
  7167. rotation: this.linkService.rotation
  7168. });
  7169. if (!this._popStateInProgress) {
  7170. this._popStateInProgress = true;
  7171. Promise.resolve().then(() => {
  7172. this._popStateInProgress = false;
  7173. });
  7174. }
  7175. }
  7176. pushCurrentPosition() {
  7177. if (!this._initialized || this._popStateInProgress) {
  7178. return;
  7179. }
  7180. this._tryPushCurrentPosition();
  7181. }
  7182. back() {
  7183. if (!this._initialized || this._popStateInProgress) {
  7184. return;
  7185. }
  7186. const state = window.history.state;
  7187. if (this._isValidState(state) && state.uid > 0) {
  7188. window.history.back();
  7189. }
  7190. }
  7191. forward() {
  7192. if (!this._initialized || this._popStateInProgress) {
  7193. return;
  7194. }
  7195. const state = window.history.state;
  7196. if (this._isValidState(state) && state.uid < this._maxUid) {
  7197. window.history.forward();
  7198. }
  7199. }
  7200. get popStateInProgress() {
  7201. return this._initialized && (this._popStateInProgress || this._blockHashChange >
  7202. 0);
  7203. }
  7204. get initialBookmark() {
  7205. return this._initialized ? this._initialBookmark : null;
  7206. }
  7207. get initialRotation() {
  7208. return this._initialized ? this._initialRotation : null;
  7209. }
  7210. _pushOrReplaceState(destination) {
  7211. let forceReplace = arguments.length > 1 && arguments[1] !== undefined ?
  7212. arguments[1] : false;
  7213. const shouldReplace = forceReplace || !this._destination;
  7214. const newState = {
  7215. fingerprint: this._fingerprint,
  7216. uid: shouldReplace ? this._uid : this._uid + 1,
  7217. destination
  7218. };
  7219. this._updateInternalState(destination, newState.uid);
  7220. let newUrl;
  7221. if (this._updateUrl && destination !== null && destination !== void 0 &&
  7222. destination.hash) {
  7223. const baseUrl = document.location.href.split("#")[0];
  7224. if (!baseUrl.startsWith("file://")) {
  7225. newUrl = `${baseUrl}#${destination.hash}`;
  7226. }
  7227. }
  7228. if (shouldReplace) {
  7229. window.history.replaceState(newState, "", newUrl);
  7230. } else {
  7231. window.history.pushState(newState, "", newUrl);
  7232. }
  7233. }
  7234. _tryPushCurrentPosition() {
  7235. let temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  7236. 0] : false;
  7237. if (!this._position) {
  7238. return;
  7239. }
  7240. let position = this._position;
  7241. if (temporary) {
  7242. position = Object.assign(Object.create(null), this._position);
  7243. position.temporary = true;
  7244. }
  7245. if (!this._destination) {
  7246. this._pushOrReplaceState(position);
  7247. return;
  7248. }
  7249. if (this._destination.temporary) {
  7250. this._pushOrReplaceState(position, true);
  7251. return;
  7252. }
  7253. if (this._destination.hash === position.hash) {
  7254. return;
  7255. }
  7256. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this
  7257. ._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7258. return;
  7259. }
  7260. let forceReplace = false;
  7261. if (this._destination.page >= position.first && this._destination.page <=
  7262. position.page) {
  7263. if (this._destination.dest !== undefined || !this._destination.first) {
  7264. return;
  7265. }
  7266. forceReplace = true;
  7267. }
  7268. this._pushOrReplaceState(position, forceReplace);
  7269. }
  7270. _isValidPage(val) {
  7271. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  7272. }
  7273. _isValidState(state) {
  7274. let checkReload = arguments.length > 1 && arguments[1] !== undefined ?
  7275. arguments[1] : false;
  7276. if (!state) {
  7277. return false;
  7278. }
  7279. if (state.fingerprint !== this._fingerprint) {
  7280. if (checkReload) {
  7281. if (typeof state.fingerprint !== "string" || state.fingerprint
  7282. .length !== this._fingerprint.length) {
  7283. return false;
  7284. }
  7285. const [perfEntry] = performance.getEntriesByType("navigation");
  7286. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry
  7287. .type) !== "reload") {
  7288. return false;
  7289. }
  7290. } else {
  7291. return false;
  7292. }
  7293. }
  7294. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7295. return false;
  7296. }
  7297. if (state.destination === null || typeof state.destination !== "object") {
  7298. return false;
  7299. }
  7300. return true;
  7301. }
  7302. _updateInternalState(destination, uid) {
  7303. let removeTemporary = arguments.length > 2 && arguments[2] !== undefined ?
  7304. arguments[2] : false;
  7305. if (this._updateViewareaTimeout) {
  7306. clearTimeout(this._updateViewareaTimeout);
  7307. this._updateViewareaTimeout = null;
  7308. }
  7309. if (removeTemporary && destination !== null && destination !== void 0 &&
  7310. destination.temporary) {
  7311. delete destination.temporary;
  7312. }
  7313. this._destination = destination;
  7314. this._uid = uid;
  7315. this._maxUid = Math.max(this._maxUid, uid);
  7316. this._numPositionUpdates = 0;
  7317. }
  7318. _parseCurrentHash() {
  7319. let checkNameddest = arguments.length > 0 && arguments[0] !== undefined ?
  7320. arguments[0] : false;
  7321. const hash = unescape(getCurrentHash()).substring(1);
  7322. const params = (0, _ui_utils.parseQueryString)(hash);
  7323. const nameddest = params.get("nameddest") || "";
  7324. let page = params.get("page") | 0;
  7325. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  7326. page = null;
  7327. }
  7328. return {
  7329. hash,
  7330. page,
  7331. rotation: this.linkService.rotation
  7332. };
  7333. }
  7334. _updateViewarea(_ref4) {
  7335. let {
  7336. location
  7337. } = _ref4;
  7338. if (this._updateViewareaTimeout) {
  7339. clearTimeout(this._updateViewareaTimeout);
  7340. this._updateViewareaTimeout = null;
  7341. }
  7342. this._position = {
  7343. hash: location.pdfOpenParams.substring(1),
  7344. page: this.linkService.page,
  7345. first: location.pageNumber,
  7346. rotation: location.rotation
  7347. };
  7348. if (this._popStateInProgress) {
  7349. return;
  7350. }
  7351. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this
  7352. ._destination && !this._destination.page) {
  7353. this._numPositionUpdates++;
  7354. }
  7355. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7356. this._updateViewareaTimeout = setTimeout(() => {
  7357. if (!this._popStateInProgress) {
  7358. this._tryPushCurrentPosition(true);
  7359. }
  7360. this._updateViewareaTimeout = null;
  7361. }, UPDATE_VIEWAREA_TIMEOUT);
  7362. }
  7363. }
  7364. _popState(_ref5) {
  7365. let {
  7366. state
  7367. } = _ref5;
  7368. const newHash = getCurrentHash(),
  7369. hashChanged = this._currentHash !== newHash;
  7370. this._currentHash = newHash;
  7371. if (!state) {
  7372. this._uid++;
  7373. const {
  7374. hash,
  7375. page,
  7376. rotation
  7377. } = this._parseCurrentHash();
  7378. this._pushOrReplaceState({
  7379. hash,
  7380. page,
  7381. rotation
  7382. }, true);
  7383. return;
  7384. }
  7385. if (!this._isValidState(state)) {
  7386. return;
  7387. }
  7388. this._popStateInProgress = true;
  7389. if (hashChanged) {
  7390. this._blockHashChange++;
  7391. (0, _event_utils.waitOnEventOrTimeout)({
  7392. target: window,
  7393. name: "hashchange",
  7394. delay: HASH_CHANGE_TIMEOUT
  7395. }).then(() => {
  7396. this._blockHashChange--;
  7397. });
  7398. }
  7399. const destination = state.destination;
  7400. this._updateInternalState(destination, state.uid, true);
  7401. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7402. this.linkService.rotation = destination.rotation;
  7403. }
  7404. if (destination.dest) {
  7405. this.linkService.goToDestination(destination.dest);
  7406. } else if (destination.hash) {
  7407. this.linkService.setHash(destination.hash);
  7408. } else if (destination.page) {
  7409. this.linkService.page = destination.page;
  7410. }
  7411. Promise.resolve().then(() => {
  7412. this._popStateInProgress = false;
  7413. });
  7414. }
  7415. _pageHide() {
  7416. if (!this._destination || this._destination.temporary) {
  7417. this._tryPushCurrentPosition();
  7418. }
  7419. }
  7420. _bindEvents() {
  7421. if (this._boundEvents) {
  7422. return;
  7423. }
  7424. this._boundEvents = {
  7425. updateViewarea: this._updateViewarea.bind(this),
  7426. popState: this._popState.bind(this),
  7427. pageHide: this._pageHide.bind(this)
  7428. };
  7429. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7430. window.addEventListener("popstate", this._boundEvents.popState);
  7431. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7432. }
  7433. _unbindEvents() {
  7434. if (!this._boundEvents) {
  7435. return;
  7436. }
  7437. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7438. window.removeEventListener("popstate", this._boundEvents.popState);
  7439. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7440. this._boundEvents = null;
  7441. }
  7442. }
  7443. exports.PDFHistory = PDFHistory;
  7444. function isDestHashesEqual(destHash, pushHash) {
  7445. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7446. return false;
  7447. }
  7448. if (destHash === pushHash) {
  7449. return true;
  7450. }
  7451. const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  7452. if (nameddest === pushHash) {
  7453. return true;
  7454. }
  7455. return false;
  7456. }
  7457. function isDestArraysEqual(firstDest, secondDest) {
  7458. function isEntryEqual(first, second) {
  7459. if (typeof first !== typeof second) {
  7460. return false;
  7461. }
  7462. if (Array.isArray(first) || Array.isArray(second)) {
  7463. return false;
  7464. }
  7465. if (first !== null && typeof first === "object" && second !== null) {
  7466. if (Object.keys(first).length !== Object.keys(second).length) {
  7467. return false;
  7468. }
  7469. for (const key in first) {
  7470. if (!isEntryEqual(first[key], second[key])) {
  7471. return false;
  7472. }
  7473. }
  7474. return true;
  7475. }
  7476. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7477. }
  7478. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7479. return false;
  7480. }
  7481. if (firstDest.length !== secondDest.length) {
  7482. return false;
  7483. }
  7484. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  7485. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7486. return false;
  7487. }
  7488. }
  7489. return true;
  7490. }
  7491. /***/
  7492. }),
  7493. /* 20 */
  7494. /***/
  7495. ((__unused_webpack_module, exports, __webpack_require__) => {
  7496. Object.defineProperty(exports, "__esModule", ({
  7497. value: true
  7498. }));
  7499. exports.PDFLayerViewer = void 0;
  7500. var _base_tree_viewer = __webpack_require__(14);
  7501. class PDFLayerViewer extends _base_tree_viewer.BaseTreeViewer {
  7502. constructor(options) {
  7503. super(options);
  7504. this.l10n = options.l10n;
  7505. this.eventBus._on("resetlayers", this._resetLayers.bind(this));
  7506. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  7507. }
  7508. reset() {
  7509. super.reset();
  7510. this._optionalContentConfig = null;
  7511. }
  7512. _dispatchEvent(layersCount) {
  7513. this.eventBus.dispatch("layersloaded", {
  7514. source: this,
  7515. layersCount
  7516. });
  7517. }
  7518. _bindLink(element, _ref) {
  7519. let {
  7520. groupId,
  7521. input
  7522. } = _ref;
  7523. const setVisibility = () => {
  7524. this._optionalContentConfig.setVisibility(groupId, input.checked);
  7525. this.eventBus.dispatch("optionalcontentconfig", {
  7526. source: this,
  7527. promise: Promise.resolve(this._optionalContentConfig)
  7528. });
  7529. };
  7530. element.onclick = evt => {
  7531. if (evt.target === input) {
  7532. setVisibility();
  7533. return true;
  7534. } else if (evt.target !== element) {
  7535. return true;
  7536. }
  7537. input.checked = !input.checked;
  7538. setVisibility();
  7539. return false;
  7540. };
  7541. }
  7542. async _setNestedName(element, _ref2) {
  7543. let {
  7544. name = null
  7545. } = _ref2;
  7546. if (typeof name === "string") {
  7547. element.textContent = this._normalizeTextContent(name);
  7548. return;
  7549. }
  7550. element.textContent = await this.l10n.get("additional_layers");
  7551. element.style.fontStyle = "italic";
  7552. }
  7553. _addToggleButton(div, _ref3) {
  7554. let {
  7555. name = null
  7556. } = _ref3;
  7557. super._addToggleButton(div, name === null);
  7558. }
  7559. _toggleAllTreeItems() {
  7560. if (!this._optionalContentConfig) {
  7561. return;
  7562. }
  7563. super._toggleAllTreeItems();
  7564. }
  7565. render(_ref4) {
  7566. let {
  7567. optionalContentConfig,
  7568. pdfDocument
  7569. } = _ref4;
  7570. if (this._optionalContentConfig) {
  7571. this.reset();
  7572. }
  7573. this._optionalContentConfig = optionalContentConfig || null;
  7574. this._pdfDocument = pdfDocument || null;
  7575. const groups = optionalContentConfig === null || optionalContentConfig ===
  7576. void 0 ? void 0 : optionalContentConfig.getOrder();
  7577. if (!groups) {
  7578. this._dispatchEvent(0);
  7579. return;
  7580. }
  7581. const fragment = document.createDocumentFragment(),
  7582. queue = [{
  7583. parent: fragment,
  7584. groups
  7585. }];
  7586. let layersCount = 0,
  7587. hasAnyNesting = false;
  7588. while (queue.length > 0) {
  7589. const levelData = queue.shift();
  7590. for (const groupId of levelData.groups) {
  7591. const div = document.createElement("div");
  7592. div.className = "treeItem";
  7593. const element = document.createElement("a");
  7594. div.append(element);
  7595. if (typeof groupId === "object") {
  7596. hasAnyNesting = true;
  7597. this._addToggleButton(div, groupId);
  7598. this._setNestedName(element, groupId);
  7599. const itemsDiv = document.createElement("div");
  7600. itemsDiv.className = "treeItems";
  7601. div.append(itemsDiv);
  7602. queue.push({
  7603. parent: itemsDiv,
  7604. groups: groupId.order
  7605. });
  7606. } else {
  7607. const group = optionalContentConfig.getGroup(groupId);
  7608. const input = document.createElement("input");
  7609. this._bindLink(element, {
  7610. groupId,
  7611. input
  7612. });
  7613. input.type = "checkbox";
  7614. input.checked = group.visible;
  7615. const label = document.createElement("label");
  7616. label.textContent = this._normalizeTextContent(group.name);
  7617. label.append(input);
  7618. element.append(label);
  7619. layersCount++;
  7620. }
  7621. levelData.parent.append(div);
  7622. }
  7623. }
  7624. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7625. }
  7626. async _resetLayers() {
  7627. if (!this._optionalContentConfig) {
  7628. return;
  7629. }
  7630. const optionalContentConfig = await this._pdfDocument
  7631. .getOptionalContentConfig();
  7632. this.eventBus.dispatch("optionalcontentconfig", {
  7633. source: this,
  7634. promise: Promise.resolve(optionalContentConfig)
  7635. });
  7636. this.render({
  7637. optionalContentConfig,
  7638. pdfDocument: this._pdfDocument
  7639. });
  7640. }
  7641. }
  7642. exports.PDFLayerViewer = PDFLayerViewer;
  7643. /***/
  7644. }),
  7645. /* 21 */
  7646. /***/
  7647. ((__unused_webpack_module, exports, __webpack_require__) => {
  7648. Object.defineProperty(exports, "__esModule", ({
  7649. value: true
  7650. }));
  7651. exports.PDFOutlineViewer = void 0;
  7652. var _base_tree_viewer = __webpack_require__(14);
  7653. var _pdfjsLib = __webpack_require__(5);
  7654. var _ui_utils = __webpack_require__(1);
  7655. class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
  7656. constructor(options) {
  7657. super(options);
  7658. this.linkService = options.linkService;
  7659. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  7660. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(
  7661. this));
  7662. this.eventBus._on("pagechanging", evt => {
  7663. this._currentPageNumber = evt.pageNumber;
  7664. });
  7665. this.eventBus._on("pagesloaded", evt => {
  7666. this._isPagesLoaded = !!evt.pagesCount;
  7667. if (this._currentOutlineItemCapability && !this
  7668. ._currentOutlineItemCapability.settled) {
  7669. this._currentOutlineItemCapability.resolve(this
  7670. ._isPagesLoaded);
  7671. }
  7672. });
  7673. this.eventBus._on("sidebarviewchanged", evt => {
  7674. this._sidebarView = evt.view;
  7675. });
  7676. }
  7677. reset() {
  7678. super.reset();
  7679. this._outline = null;
  7680. this._pageNumberToDestHashCapability = null;
  7681. this._currentPageNumber = 1;
  7682. this._isPagesLoaded = null;
  7683. if (this._currentOutlineItemCapability && !this
  7684. ._currentOutlineItemCapability.settled) {
  7685. this._currentOutlineItemCapability.resolve(false);
  7686. }
  7687. this._currentOutlineItemCapability = null;
  7688. }
  7689. _dispatchEvent(outlineCount) {
  7690. var _this$_pdfDocument;
  7691. this._currentOutlineItemCapability = (0, _pdfjsLib.createPromiseCapability)
  7692. ();
  7693. if (outlineCount === 0 || (_this$_pdfDocument = this._pdfDocument) !==
  7694. null && _this$_pdfDocument !== void 0 && _this$_pdfDocument
  7695. .loadingParams.disableAutoFetch) {
  7696. this._currentOutlineItemCapability.resolve(false);
  7697. } else if (this._isPagesLoaded !== null) {
  7698. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  7699. }
  7700. this.eventBus.dispatch("outlineloaded", {
  7701. source: this,
  7702. outlineCount,
  7703. currentOutlineItemPromise: this._currentOutlineItemCapability
  7704. .promise
  7705. });
  7706. }
  7707. _bindLink(element, _ref) {
  7708. let {
  7709. url,
  7710. newWindow,
  7711. dest
  7712. } = _ref;
  7713. const {
  7714. linkService
  7715. } = this;
  7716. if (url) {
  7717. linkService.addLinkAttributes(element, url, newWindow);
  7718. return;
  7719. }
  7720. element.href = linkService.getDestinationHash(dest);
  7721. element.onclick = evt => {
  7722. this._updateCurrentTreeItem(evt.target.parentNode);
  7723. if (dest) {
  7724. linkService.goToDestination(dest);
  7725. }
  7726. return false;
  7727. };
  7728. }
  7729. _setStyles(element, _ref2) {
  7730. let {
  7731. bold,
  7732. italic
  7733. } = _ref2;
  7734. if (bold) {
  7735. element.style.fontWeight = "bold";
  7736. }
  7737. if (italic) {
  7738. element.style.fontStyle = "italic";
  7739. }
  7740. }
  7741. _addToggleButton(div, _ref3) {
  7742. let {
  7743. count,
  7744. items
  7745. } = _ref3;
  7746. let hidden = false;
  7747. if (count < 0) {
  7748. let totalCount = items.length;
  7749. if (totalCount > 0) {
  7750. const queue = [...items];
  7751. while (queue.length > 0) {
  7752. const {
  7753. count: nestedCount,
  7754. items: nestedItems
  7755. } = queue.shift();
  7756. if (nestedCount > 0 && nestedItems.length > 0) {
  7757. totalCount += nestedItems.length;
  7758. queue.push(...nestedItems);
  7759. }
  7760. }
  7761. }
  7762. if (Math.abs(count) === totalCount) {
  7763. hidden = true;
  7764. }
  7765. }
  7766. super._addToggleButton(div, hidden);
  7767. }
  7768. _toggleAllTreeItems() {
  7769. if (!this._outline) {
  7770. return;
  7771. }
  7772. super._toggleAllTreeItems();
  7773. }
  7774. render(_ref4) {
  7775. let {
  7776. outline,
  7777. pdfDocument
  7778. } = _ref4;
  7779. if (this._outline) {
  7780. this.reset();
  7781. }
  7782. this._outline = outline || null;
  7783. this._pdfDocument = pdfDocument || null;
  7784. if (!outline) {
  7785. this._dispatchEvent(0);
  7786. return;
  7787. }
  7788. const fragment = document.createDocumentFragment();
  7789. const queue = [{
  7790. parent: fragment,
  7791. items: outline
  7792. }];
  7793. let outlineCount = 0,
  7794. hasAnyNesting = false;
  7795. while (queue.length > 0) {
  7796. const levelData = queue.shift();
  7797. for (const item of levelData.items) {
  7798. const div = document.createElement("div");
  7799. div.className = "treeItem";
  7800. const element = document.createElement("a");
  7801. this._bindLink(element, item);
  7802. this._setStyles(element, item);
  7803. element.textContent = this._normalizeTextContent(item.title);
  7804. div.append(element);
  7805. if (item.items.length > 0) {
  7806. hasAnyNesting = true;
  7807. this._addToggleButton(div, item);
  7808. const itemsDiv = document.createElement("div");
  7809. itemsDiv.className = "treeItems";
  7810. div.append(itemsDiv);
  7811. queue.push({
  7812. parent: itemsDiv,
  7813. items: item.items
  7814. });
  7815. }
  7816. levelData.parent.append(div);
  7817. outlineCount++;
  7818. }
  7819. }
  7820. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  7821. }
  7822. async _currentOutlineItem() {
  7823. if (!this._isPagesLoaded) {
  7824. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  7825. }
  7826. if (!this._outline || !this._pdfDocument) {
  7827. return;
  7828. }
  7829. const pageNumberToDestHash = await this._getPageNumberToDestHash(this
  7830. ._pdfDocument);
  7831. if (!pageNumberToDestHash) {
  7832. return;
  7833. }
  7834. this._updateCurrentTreeItem(null);
  7835. if (this._sidebarView !== _ui_utils.SidebarView.OUTLINE) {
  7836. return;
  7837. }
  7838. for (let i = this._currentPageNumber; i > 0; i--) {
  7839. const destHash = pageNumberToDestHash.get(i);
  7840. if (!destHash) {
  7841. continue;
  7842. }
  7843. const linkElement = this.container.querySelector(
  7844. `a[href="${destHash}"]`);
  7845. if (!linkElement) {
  7846. continue;
  7847. }
  7848. this._scrollToCurrentTreeItem(linkElement.parentNode);
  7849. break;
  7850. }
  7851. }
  7852. async _getPageNumberToDestHash(pdfDocument) {
  7853. if (this._pageNumberToDestHashCapability) {
  7854. return this._pageNumberToDestHashCapability.promise;
  7855. }
  7856. this._pageNumberToDestHashCapability = (0, _pdfjsLib
  7857. .createPromiseCapability)();
  7858. const pageNumberToDestHash = new Map(),
  7859. pageNumberNesting = new Map();
  7860. const queue = [{
  7861. nesting: 0,
  7862. items: this._outline
  7863. }];
  7864. while (queue.length > 0) {
  7865. const levelData = queue.shift(),
  7866. currentNesting = levelData.nesting;
  7867. for (const {
  7868. dest,
  7869. items
  7870. } of levelData.items) {
  7871. let explicitDest, pageNumber;
  7872. if (typeof dest === "string") {
  7873. explicitDest = await pdfDocument.getDestination(dest);
  7874. if (pdfDocument !== this._pdfDocument) {
  7875. return null;
  7876. }
  7877. } else {
  7878. explicitDest = dest;
  7879. }
  7880. if (Array.isArray(explicitDest)) {
  7881. const [destRef] = explicitDest;
  7882. if (typeof destRef === "object" && destRef !== null) {
  7883. pageNumber = this.linkService._cachedPageNumber(destRef);
  7884. if (!pageNumber) {
  7885. try {
  7886. pageNumber = (await pdfDocument.getPageIndex(
  7887. destRef)) + 1;
  7888. if (pdfDocument !== this._pdfDocument) {
  7889. return null;
  7890. }
  7891. this.linkService.cachePageRef(pageNumber, destRef);
  7892. } catch (ex) {}
  7893. }
  7894. } else if (Number.isInteger(destRef)) {
  7895. pageNumber = destRef + 1;
  7896. }
  7897. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(
  7898. pageNumber) || currentNesting > pageNumberNesting
  7899. .get(pageNumber))) {
  7900. const destHash = this.linkService.getDestinationHash(dest);
  7901. pageNumberToDestHash.set(pageNumber, destHash);
  7902. pageNumberNesting.set(pageNumber, currentNesting);
  7903. }
  7904. }
  7905. if (items.length > 0) {
  7906. queue.push({
  7907. nesting: currentNesting + 1,
  7908. items
  7909. });
  7910. }
  7911. }
  7912. }
  7913. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ?
  7914. pageNumberToDestHash : null);
  7915. return this._pageNumberToDestHashCapability.promise;
  7916. }
  7917. }
  7918. exports.PDFOutlineViewer = PDFOutlineViewer;
  7919. /***/
  7920. }),
  7921. /* 22 */
  7922. /***/
  7923. ((__unused_webpack_module, exports, __webpack_require__) => {
  7924. Object.defineProperty(exports, "__esModule", ({
  7925. value: true
  7926. }));
  7927. exports.PDFPresentationMode = void 0;
  7928. var _ui_utils = __webpack_require__(1);
  7929. var _pdfjsLib = __webpack_require__(5);
  7930. function _classPrivateMethodInitSpec(obj, privateSet) {
  7931. _checkPrivateRedeclaration(obj, privateSet);
  7932. privateSet.add(obj);
  7933. }
  7934. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  7935. _checkPrivateRedeclaration(obj, privateMap);
  7936. privateMap.set(obj, value);
  7937. }
  7938. function _checkPrivateRedeclaration(obj, privateCollection) {
  7939. if (privateCollection.has(obj)) {
  7940. throw new TypeError(
  7941. "Cannot initialize the same private elements twice on an object");
  7942. }
  7943. }
  7944. function _classPrivateFieldGet(receiver, privateMap) {
  7945. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  7946. return _classApplyDescriptorGet(receiver, descriptor);
  7947. }
  7948. function _classApplyDescriptorGet(receiver, descriptor) {
  7949. if (descriptor.get) {
  7950. return descriptor.get.call(receiver);
  7951. }
  7952. return descriptor.value;
  7953. }
  7954. function _classPrivateFieldSet(receiver, privateMap, value) {
  7955. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  7956. _classApplyDescriptorSet(receiver, descriptor, value);
  7957. return value;
  7958. }
  7959. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  7960. if (!privateMap.has(receiver)) {
  7961. throw new TypeError("attempted to " + action + " private field on non-instance");
  7962. }
  7963. return privateMap.get(receiver);
  7964. }
  7965. function _classApplyDescriptorSet(receiver, descriptor, value) {
  7966. if (descriptor.set) {
  7967. descriptor.set.call(receiver, value);
  7968. } else {
  7969. if (!descriptor.writable) {
  7970. throw new TypeError("attempted to set read only private field");
  7971. }
  7972. descriptor.value = value;
  7973. }
  7974. }
  7975. function _classPrivateMethodGet(receiver, privateSet, fn) {
  7976. if (!privateSet.has(receiver)) {
  7977. throw new TypeError("attempted to get private field on non-instance");
  7978. }
  7979. return fn;
  7980. }
  7981. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7982. const ACTIVE_SELECTOR = "pdfPresentationMode";
  7983. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  7984. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7985. const PAGE_SWITCH_THRESHOLD = 0.1;
  7986. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7987. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7988. var _state = /*#__PURE__*/ new WeakMap();
  7989. var _args = /*#__PURE__*/ new WeakMap();
  7990. var _mouseWheel = /*#__PURE__*/ new WeakSet();
  7991. var _notifyStateChange = /*#__PURE__*/ new WeakSet();
  7992. var _enter = /*#__PURE__*/ new WeakSet();
  7993. var _exit = /*#__PURE__*/ new WeakSet();
  7994. var _mouseDown = /*#__PURE__*/ new WeakSet();
  7995. var _contextMenu = /*#__PURE__*/ new WeakSet();
  7996. var _showControls = /*#__PURE__*/ new WeakSet();
  7997. var _hideControls = /*#__PURE__*/ new WeakSet();
  7998. var _resetMouseScrollState = /*#__PURE__*/ new WeakSet();
  7999. var _touchSwipe = /*#__PURE__*/ new WeakSet();
  8000. var _addWindowListeners = /*#__PURE__*/ new WeakSet();
  8001. var _removeWindowListeners = /*#__PURE__*/ new WeakSet();
  8002. var _fullscreenChange = /*#__PURE__*/ new WeakSet();
  8003. var _addFullscreenChangeListeners = /*#__PURE__*/ new WeakSet();
  8004. var _removeFullscreenChangeListeners = /*#__PURE__*/ new WeakSet();
  8005. class PDFPresentationMode {
  8006. constructor(_ref) {
  8007. let {
  8008. container,
  8009. pdfViewer,
  8010. eventBus
  8011. } = _ref;
  8012. _classPrivateMethodInitSpec(this, _removeFullscreenChangeListeners);
  8013. _classPrivateMethodInitSpec(this, _addFullscreenChangeListeners);
  8014. _classPrivateMethodInitSpec(this, _fullscreenChange);
  8015. _classPrivateMethodInitSpec(this, _removeWindowListeners);
  8016. _classPrivateMethodInitSpec(this, _addWindowListeners);
  8017. _classPrivateMethodInitSpec(this, _touchSwipe);
  8018. _classPrivateMethodInitSpec(this, _resetMouseScrollState);
  8019. _classPrivateMethodInitSpec(this, _hideControls);
  8020. _classPrivateMethodInitSpec(this, _showControls);
  8021. _classPrivateMethodInitSpec(this, _contextMenu);
  8022. _classPrivateMethodInitSpec(this, _mouseDown);
  8023. _classPrivateMethodInitSpec(this, _exit);
  8024. _classPrivateMethodInitSpec(this, _enter);
  8025. _classPrivateMethodInitSpec(this, _notifyStateChange);
  8026. _classPrivateMethodInitSpec(this, _mouseWheel);
  8027. _classPrivateFieldInitSpec(this, _state, {
  8028. writable: true,
  8029. value: _ui_utils.PresentationModeState.UNKNOWN
  8030. });
  8031. _classPrivateFieldInitSpec(this, _args, {
  8032. writable: true,
  8033. value: null
  8034. });
  8035. this.container = container;
  8036. this.pdfViewer = pdfViewer;
  8037. this.eventBus = eventBus;
  8038. this.contextMenuOpen = false;
  8039. this.mouseScrollTimeStamp = 0;
  8040. this.mouseScrollDelta = 0;
  8041. this.touchSwipeState = null;
  8042. }
  8043. async request() {
  8044. const {
  8045. container,
  8046. pdfViewer
  8047. } = this;
  8048. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  8049. return false;
  8050. }
  8051. _classPrivateMethodGet(this, _addFullscreenChangeListeners,
  8052. _addFullscreenChangeListeners2).call(this);
  8053. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this,
  8054. _ui_utils.PresentationModeState.CHANGING);
  8055. const promise = container.requestFullscreen();
  8056. _classPrivateFieldSet(this, _args, {
  8057. pageNumber: pdfViewer.currentPageNumber,
  8058. scaleValue: pdfViewer.currentScaleValue,
  8059. scrollMode: pdfViewer.scrollMode,
  8060. spreadMode: null,
  8061. annotationEditorMode: null
  8062. });
  8063. if (pdfViewer.spreadMode !== _ui_utils.SpreadMode.NONE && !(pdfViewer
  8064. .pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  8065. console.warn("Ignoring Spread modes when entering PresentationMode, " +
  8066. "since the document may contain varying page sizes.");
  8067. _classPrivateFieldGet(this, _args).spreadMode = pdfViewer.spreadMode;
  8068. }
  8069. if (pdfViewer.annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  8070. _classPrivateFieldGet(this, _args).annotationEditorMode = pdfViewer
  8071. .annotationEditorMode;
  8072. }
  8073. try {
  8074. await promise;
  8075. pdfViewer.focus();
  8076. return true;
  8077. } catch (reason) {
  8078. _classPrivateMethodGet(this, _removeFullscreenChangeListeners,
  8079. _removeFullscreenChangeListeners2).call(this);
  8080. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(
  8081. this, _ui_utils.PresentationModeState.NORMAL);
  8082. }
  8083. return false;
  8084. }
  8085. get active() {
  8086. return _classPrivateFieldGet(this, _state) === _ui_utils.PresentationModeState
  8087. .CHANGING || _classPrivateFieldGet(this, _state) === _ui_utils
  8088. .PresentationModeState.FULLSCREEN;
  8089. }
  8090. }
  8091. exports.PDFPresentationMode = PDFPresentationMode;
  8092. function _mouseWheel2(evt) {
  8093. if (!this.active) {
  8094. return;
  8095. }
  8096. evt.preventDefault();
  8097. const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8098. const currentTime = Date.now();
  8099. const storedTime = this.mouseScrollTimeStamp;
  8100. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8101. return;
  8102. }
  8103. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8104. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(
  8105. this);
  8106. }
  8107. this.mouseScrollDelta += delta;
  8108. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8109. const totalDelta = this.mouseScrollDelta;
  8110. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(
  8111. this);
  8112. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer
  8113. .nextPage();
  8114. if (success) {
  8115. this.mouseScrollTimeStamp = currentTime;
  8116. }
  8117. }
  8118. }
  8119. function _notifyStateChange2(state) {
  8120. _classPrivateFieldSet(this, _state, state);
  8121. this.eventBus.dispatch("presentationmodechanged", {
  8122. source: this,
  8123. state
  8124. });
  8125. }
  8126. function _enter2() {
  8127. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this,
  8128. _ui_utils.PresentationModeState.FULLSCREEN);
  8129. this.container.classList.add(ACTIVE_SELECTOR);
  8130. setTimeout(() => {
  8131. this.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  8132. if (_classPrivateFieldGet(this, _args).spreadMode !== null) {
  8133. this.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  8134. }
  8135. this.pdfViewer.currentPageNumber = _classPrivateFieldGet(this, _args)
  8136. .pageNumber;
  8137. this.pdfViewer.currentScaleValue = "page-fit";
  8138. if (_classPrivateFieldGet(this, _args).annotationEditorMode !== null) {
  8139. this.pdfViewer.annotationEditorMode = _pdfjsLib.AnnotationEditorType
  8140. .NONE;
  8141. }
  8142. }, 0);
  8143. _classPrivateMethodGet(this, _addWindowListeners, _addWindowListeners2).call(this);
  8144. _classPrivateMethodGet(this, _showControls, _showControls2).call(this);
  8145. this.contextMenuOpen = false;
  8146. window.getSelection().removeAllRanges();
  8147. }
  8148. function _exit2() {
  8149. const pageNumber = this.pdfViewer.currentPageNumber;
  8150. this.container.classList.remove(ACTIVE_SELECTOR);
  8151. setTimeout(() => {
  8152. _classPrivateMethodGet(this, _removeFullscreenChangeListeners,
  8153. _removeFullscreenChangeListeners2).call(this);
  8154. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(
  8155. this, _ui_utils.PresentationModeState.NORMAL);
  8156. this.pdfViewer.scrollMode = _classPrivateFieldGet(this, _args).scrollMode;
  8157. if (_classPrivateFieldGet(this, _args).spreadMode !== null) {
  8158. this.pdfViewer.spreadMode = _classPrivateFieldGet(this, _args)
  8159. .spreadMode;
  8160. }
  8161. this.pdfViewer.currentScaleValue = _classPrivateFieldGet(this, _args)
  8162. .scaleValue;
  8163. this.pdfViewer.currentPageNumber = pageNumber;
  8164. if (_classPrivateFieldGet(this, _args).annotationEditorMode !== null) {
  8165. this.pdfViewer.annotationEditorMode = _classPrivateFieldGet(this, _args)
  8166. .annotationEditorMode;
  8167. }
  8168. _classPrivateFieldSet(this, _args, null);
  8169. }, 0);
  8170. _classPrivateMethodGet(this, _removeWindowListeners, _removeWindowListeners2).call(
  8171. this);
  8172. _classPrivateMethodGet(this, _hideControls, _hideControls2).call(this);
  8173. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(
  8174. this);
  8175. this.contextMenuOpen = false;
  8176. }
  8177. function _mouseDown2(evt) {
  8178. if (this.contextMenuOpen) {
  8179. this.contextMenuOpen = false;
  8180. evt.preventDefault();
  8181. return;
  8182. }
  8183. if (evt.button === 0) {
  8184. const isInternalLink = evt.target.href && evt.target.classList.contains(
  8185. "internalLink");
  8186. if (!isInternalLink) {
  8187. evt.preventDefault();
  8188. if (evt.shiftKey) {
  8189. this.pdfViewer.previousPage();
  8190. } else {
  8191. this.pdfViewer.nextPage();
  8192. }
  8193. }
  8194. }
  8195. }
  8196. function _contextMenu2() {
  8197. this.contextMenuOpen = true;
  8198. }
  8199. function _showControls2() {
  8200. if (this.controlsTimeout) {
  8201. clearTimeout(this.controlsTimeout);
  8202. } else {
  8203. this.container.classList.add(CONTROLS_SELECTOR);
  8204. }
  8205. this.controlsTimeout = setTimeout(() => {
  8206. this.container.classList.remove(CONTROLS_SELECTOR);
  8207. delete this.controlsTimeout;
  8208. }, DELAY_BEFORE_HIDING_CONTROLS);
  8209. }
  8210. function _hideControls2() {
  8211. if (!this.controlsTimeout) {
  8212. return;
  8213. }
  8214. clearTimeout(this.controlsTimeout);
  8215. this.container.classList.remove(CONTROLS_SELECTOR);
  8216. delete this.controlsTimeout;
  8217. }
  8218. function _resetMouseScrollState2() {
  8219. this.mouseScrollTimeStamp = 0;
  8220. this.mouseScrollDelta = 0;
  8221. }
  8222. function _touchSwipe2(evt) {
  8223. if (!this.active) {
  8224. return;
  8225. }
  8226. if (evt.touches.length > 1) {
  8227. this.touchSwipeState = null;
  8228. return;
  8229. }
  8230. switch (evt.type) {
  8231. case "touchstart":
  8232. this.touchSwipeState = {
  8233. startX: evt.touches[0].pageX,
  8234. startY: evt.touches[0].pageY,
  8235. endX: evt.touches[0].pageX,
  8236. endY: evt.touches[0].pageY
  8237. };
  8238. break;
  8239. case "touchmove":
  8240. if (this.touchSwipeState === null) {
  8241. return;
  8242. }
  8243. this.touchSwipeState.endX = evt.touches[0].pageX;
  8244. this.touchSwipeState.endY = evt.touches[0].pageY;
  8245. evt.preventDefault();
  8246. break;
  8247. case "touchend":
  8248. if (this.touchSwipeState === null) {
  8249. return;
  8250. }
  8251. let delta = 0;
  8252. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  8253. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  8254. const absAngle = Math.abs(Math.atan2(dy, dx));
  8255. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <=
  8256. SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  8257. delta = dx;
  8258. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle -
  8259. Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  8260. delta = dy;
  8261. }
  8262. if (delta > 0) {
  8263. this.pdfViewer.previousPage();
  8264. } else if (delta < 0) {
  8265. this.pdfViewer.nextPage();
  8266. }
  8267. break;
  8268. }
  8269. }
  8270. function _addWindowListeners2() {
  8271. this.showControlsBind = _classPrivateMethodGet(this, _showControls, _showControls2)
  8272. .bind(this);
  8273. this.mouseDownBind = _classPrivateMethodGet(this, _mouseDown, _mouseDown2).bind(this);
  8274. this.mouseWheelBind = _classPrivateMethodGet(this, _mouseWheel, _mouseWheel2).bind(
  8275. this);
  8276. this.resetMouseScrollStateBind = _classPrivateMethodGet(this, _resetMouseScrollState,
  8277. _resetMouseScrollState2).bind(this);
  8278. this.contextMenuBind = _classPrivateMethodGet(this, _contextMenu, _contextMenu2).bind(
  8279. this);
  8280. this.touchSwipeBind = _classPrivateMethodGet(this, _touchSwipe, _touchSwipe2).bind(
  8281. this);
  8282. window.addEventListener("mousemove", this.showControlsBind);
  8283. window.addEventListener("mousedown", this.mouseDownBind);
  8284. window.addEventListener("wheel", this.mouseWheelBind, {
  8285. passive: false
  8286. });
  8287. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  8288. window.addEventListener("contextmenu", this.contextMenuBind);
  8289. window.addEventListener("touchstart", this.touchSwipeBind);
  8290. window.addEventListener("touchmove", this.touchSwipeBind);
  8291. window.addEventListener("touchend", this.touchSwipeBind);
  8292. }
  8293. function _removeWindowListeners2() {
  8294. window.removeEventListener("mousemove", this.showControlsBind);
  8295. window.removeEventListener("mousedown", this.mouseDownBind);
  8296. window.removeEventListener("wheel", this.mouseWheelBind, {
  8297. passive: false
  8298. });
  8299. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  8300. window.removeEventListener("contextmenu", this.contextMenuBind);
  8301. window.removeEventListener("touchstart", this.touchSwipeBind);
  8302. window.removeEventListener("touchmove", this.touchSwipeBind);
  8303. window.removeEventListener("touchend", this.touchSwipeBind);
  8304. delete this.showControlsBind;
  8305. delete this.mouseDownBind;
  8306. delete this.mouseWheelBind;
  8307. delete this.resetMouseScrollStateBind;
  8308. delete this.contextMenuBind;
  8309. delete this.touchSwipeBind;
  8310. }
  8311. function _fullscreenChange2() {
  8312. if (document.fullscreenElement) {
  8313. _classPrivateMethodGet(this, _enter, _enter2).call(this);
  8314. } else {
  8315. _classPrivateMethodGet(this, _exit, _exit2).call(this);
  8316. }
  8317. }
  8318. function _addFullscreenChangeListeners2() {
  8319. this.fullscreenChangeBind = _classPrivateMethodGet(this, _fullscreenChange,
  8320. _fullscreenChange2).bind(this);
  8321. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  8322. }
  8323. function _removeFullscreenChangeListeners2() {
  8324. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  8325. delete this.fullscreenChangeBind;
  8326. }
  8327. /***/
  8328. }),
  8329. /* 23 */
  8330. /***/
  8331. ((__unused_webpack_module, exports, __webpack_require__) => {
  8332. Object.defineProperty(exports, "__esModule", ({
  8333. value: true
  8334. }));
  8335. exports.PDFRenderingQueue = void 0;
  8336. var _pdfjsLib = __webpack_require__(5);
  8337. var _ui_utils = __webpack_require__(1);
  8338. const CLEANUP_TIMEOUT = 30000;
  8339. class PDFRenderingQueue {
  8340. constructor() {
  8341. this.pdfViewer = null;
  8342. this.pdfThumbnailViewer = null;
  8343. this.onIdle = null;
  8344. this.highestPriorityPage = null;
  8345. this.idleTimeout = null;
  8346. this.printing = false;
  8347. this.isThumbnailViewEnabled = false;
  8348. }
  8349. setViewer(pdfViewer) {
  8350. this.pdfViewer = pdfViewer;
  8351. }
  8352. setThumbnailViewer(pdfThumbnailViewer) {
  8353. this.pdfThumbnailViewer = pdfThumbnailViewer;
  8354. }
  8355. isHighestPriority(view) {
  8356. return this.highestPriorityPage === view.renderingId;
  8357. }
  8358. hasViewer() {
  8359. return !!this.pdfViewer;
  8360. }
  8361. renderHighestPriority(currentlyVisiblePages) {
  8362. var _this$pdfThumbnailVie;
  8363. if (this.idleTimeout) {
  8364. clearTimeout(this.idleTimeout);
  8365. this.idleTimeout = null;
  8366. }
  8367. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  8368. return;
  8369. }
  8370. if (this.isThumbnailViewEnabled && (_this$pdfThumbnailVie = this
  8371. .pdfThumbnailViewer) !== null && _this$pdfThumbnailVie !== void 0 &&
  8372. _this$pdfThumbnailVie.forceRendering()) {
  8373. return;
  8374. }
  8375. if (this.printing) {
  8376. return;
  8377. }
  8378. if (this.onIdle) {
  8379. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  8380. }
  8381. }
  8382. getHighestPriority(visible, views, scrolledDown) {
  8383. let preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ?
  8384. arguments[3] : false;
  8385. const visibleViews = visible.views,
  8386. numVisible = visibleViews.length;
  8387. if (numVisible === 0) {
  8388. return null;
  8389. }
  8390. for (let i = 0; i < numVisible; i++) {
  8391. const view = visibleViews[i].view;
  8392. if (!this.isViewFinished(view)) {
  8393. return view;
  8394. }
  8395. }
  8396. const firstId = visible.first.id,
  8397. lastId = visible.last.id;
  8398. if (lastId - firstId + 1 > numVisible) {
  8399. const visibleIds = visible.ids;
  8400. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  8401. const holeId = scrolledDown ? firstId + i : lastId - i;
  8402. if (visibleIds.has(holeId)) {
  8403. continue;
  8404. }
  8405. const holeView = views[holeId - 1];
  8406. if (!this.isViewFinished(holeView)) {
  8407. return holeView;
  8408. }
  8409. }
  8410. }
  8411. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  8412. let preRenderView = views[preRenderIndex];
  8413. if (preRenderView && !this.isViewFinished(preRenderView)) {
  8414. return preRenderView;
  8415. }
  8416. if (preRenderExtra) {
  8417. preRenderIndex += scrolledDown ? 1 : -1;
  8418. preRenderView = views[preRenderIndex];
  8419. if (preRenderView && !this.isViewFinished(preRenderView)) {
  8420. return preRenderView;
  8421. }
  8422. }
  8423. return null;
  8424. }
  8425. isViewFinished(view) {
  8426. return view.renderingState === _ui_utils.RenderingStates.FINISHED;
  8427. }
  8428. renderView(view) {
  8429. switch (view.renderingState) {
  8430. case _ui_utils.RenderingStates.FINISHED:
  8431. return false;
  8432. case _ui_utils.RenderingStates.PAUSED:
  8433. this.highestPriorityPage = view.renderingId;
  8434. view.resume();
  8435. break;
  8436. case _ui_utils.RenderingStates.RUNNING:
  8437. this.highestPriorityPage = view.renderingId;
  8438. break;
  8439. case _ui_utils.RenderingStates.INITIAL:
  8440. this.highestPriorityPage = view.renderingId;
  8441. view.draw().finally(() => {
  8442. this.renderHighestPriority();
  8443. }).catch(reason => {
  8444. if (reason instanceof _pdfjsLib
  8445. .RenderingCancelledException) {
  8446. return;
  8447. }
  8448. console.error(`renderView: "${reason}"`);
  8449. });
  8450. break;
  8451. }
  8452. return true;
  8453. }
  8454. }
  8455. exports.PDFRenderingQueue = PDFRenderingQueue;
  8456. /***/
  8457. }),
  8458. /* 24 */
  8459. /***/
  8460. ((__unused_webpack_module, exports, __webpack_require__) => {
  8461. Object.defineProperty(exports, "__esModule", ({
  8462. value: true
  8463. }));
  8464. exports.PDFScriptingManager = void 0;
  8465. var _ui_utils = __webpack_require__(1);
  8466. var _pdfjsLib = __webpack_require__(5);
  8467. class PDFScriptingManager {
  8468. constructor(_ref) {
  8469. let {
  8470. eventBus,
  8471. sandboxBundleSrc = null,
  8472. scriptingFactory = null,
  8473. docPropertiesLookup = null
  8474. } = _ref;
  8475. this._pdfDocument = null;
  8476. this._pdfViewer = null;
  8477. this._closeCapability = null;
  8478. this._destroyCapability = null;
  8479. this._scripting = null;
  8480. this._mouseState = Object.create(null);
  8481. this._ready = false;
  8482. this._eventBus = eventBus;
  8483. this._sandboxBundleSrc = sandboxBundleSrc;
  8484. this._scriptingFactory = scriptingFactory;
  8485. this._docPropertiesLookup = docPropertiesLookup;
  8486. }
  8487. setViewer(pdfViewer) {
  8488. this._pdfViewer = pdfViewer;
  8489. }
  8490. async setDocument(pdfDocument) {
  8491. var _this$_scripting3;
  8492. if (this._pdfDocument) {
  8493. await this._destroyScripting();
  8494. }
  8495. this._pdfDocument = pdfDocument;
  8496. if (!pdfDocument) {
  8497. return;
  8498. }
  8499. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument
  8500. .getFieldObjects(), pdfDocument.getCalculationOrderIds(),
  8501. pdfDocument.getJSActions()
  8502. ]);
  8503. if (!objects && !docActions) {
  8504. await this._destroyScripting();
  8505. return;
  8506. }
  8507. if (pdfDocument !== this._pdfDocument) {
  8508. return;
  8509. }
  8510. try {
  8511. this._scripting = this._createScripting();
  8512. } catch (error) {
  8513. console.error(
  8514. `PDFScriptingManager.setDocument: "${error === null || error === void 0 ? void 0 : error.message}".`
  8515. );
  8516. await this._destroyScripting();
  8517. return;
  8518. }
  8519. this._internalEvents.set("updatefromsandbox", event => {
  8520. if ((event === null || event === void 0 ? void 0 : event.source) !==
  8521. window) {
  8522. return;
  8523. }
  8524. this._updateFromSandbox(event.detail);
  8525. });
  8526. this._internalEvents.set("dispatcheventinsandbox", event => {
  8527. var _this$_scripting;
  8528. (_this$_scripting = this._scripting) === null ||
  8529. _this$_scripting === void 0 ? void 0 : _this$_scripting
  8530. .dispatchEventInSandbox(event.detail);
  8531. });
  8532. this._internalEvents.set("pagechanging", _ref2 => {
  8533. let {
  8534. pageNumber,
  8535. previous
  8536. } = _ref2;
  8537. if (pageNumber === previous) {
  8538. return;
  8539. }
  8540. this._dispatchPageClose(previous);
  8541. this._dispatchPageOpen(pageNumber);
  8542. });
  8543. this._internalEvents.set("pagerendered", _ref3 => {
  8544. let {
  8545. pageNumber
  8546. } = _ref3;
  8547. if (!this._pageOpenPending.has(pageNumber)) {
  8548. return;
  8549. }
  8550. if (pageNumber !== this._pdfViewer.currentPageNumber) {
  8551. return;
  8552. }
  8553. this._dispatchPageOpen(pageNumber);
  8554. });
  8555. this._internalEvents.set("pagesdestroy", async event => {
  8556. var _this$_scripting2, _this$_closeCapabilit;
  8557. await this._dispatchPageClose(this._pdfViewer
  8558. .currentPageNumber);
  8559. await ((_this$_scripting2 = this._scripting) === null ||
  8560. _this$_scripting2 === void 0 ? void 0 : _this$_scripting2
  8561. .dispatchEventInSandbox({
  8562. id: "doc",
  8563. name: "WillClose"
  8564. }));
  8565. (_this$_closeCapabilit = this._closeCapability) === null ||
  8566. _this$_closeCapabilit === void 0 ? void 0 :
  8567. _this$_closeCapabilit.resolve();
  8568. });
  8569. this._domEvents.set("mousedown", event => {
  8570. this._mouseState.isDown = true;
  8571. });
  8572. this._domEvents.set("mouseup", event => {
  8573. this._mouseState.isDown = false;
  8574. });
  8575. for (const [name, listener] of this._internalEvents) {
  8576. this._eventBus._on(name, listener);
  8577. }
  8578. for (const [name, listener] of this._domEvents) {
  8579. window.addEventListener(name, listener, true);
  8580. }
  8581. try {
  8582. const docProperties = await this._getDocProperties();
  8583. if (pdfDocument !== this._pdfDocument) {
  8584. return;
  8585. }
  8586. await this._scripting.createSandbox({
  8587. objects,
  8588. calculationOrder,
  8589. appInfo: {
  8590. platform: navigator.platform,
  8591. language: navigator.language
  8592. },
  8593. docInfo: {
  8594. ...docProperties,
  8595. actions: docActions
  8596. }
  8597. });
  8598. this._eventBus.dispatch("sandboxcreated", {
  8599. source: this
  8600. });
  8601. } catch (error) {
  8602. console.error(
  8603. `PDFScriptingManager.setDocument: "${error === null || error === void 0 ? void 0 : error.message}".`
  8604. );
  8605. await this._destroyScripting();
  8606. return;
  8607. }
  8608. await ((_this$_scripting3 = this._scripting) === null || _this$_scripting3 ===
  8609. void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({
  8610. id: "doc",
  8611. name: "Open"
  8612. }));
  8613. await this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
  8614. Promise.resolve().then(() => {
  8615. if (pdfDocument === this._pdfDocument) {
  8616. this._ready = true;
  8617. }
  8618. });
  8619. }
  8620. async dispatchWillSave(detail) {
  8621. var _this$_scripting4;
  8622. return (_this$_scripting4 = this._scripting) === null || _this$_scripting4 ===
  8623. void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({
  8624. id: "doc",
  8625. name: "WillSave"
  8626. });
  8627. }
  8628. async dispatchDidSave(detail) {
  8629. var _this$_scripting5;
  8630. return (_this$_scripting5 = this._scripting) === null || _this$_scripting5 ===
  8631. void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({
  8632. id: "doc",
  8633. name: "DidSave"
  8634. });
  8635. }
  8636. async dispatchWillPrint(detail) {
  8637. var _this$_scripting6;
  8638. return (_this$_scripting6 = this._scripting) === null || _this$_scripting6 ===
  8639. void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({
  8640. id: "doc",
  8641. name: "WillPrint"
  8642. });
  8643. }
  8644. async dispatchDidPrint(detail) {
  8645. var _this$_scripting7;
  8646. return (_this$_scripting7 = this._scripting) === null || _this$_scripting7 ===
  8647. void 0 ? void 0 : _this$_scripting7.dispatchEventInSandbox({
  8648. id: "doc",
  8649. name: "DidPrint"
  8650. });
  8651. }
  8652. get mouseState() {
  8653. return this._mouseState;
  8654. }
  8655. get destroyPromise() {
  8656. var _this$_destroyCapabil;
  8657. return ((_this$_destroyCapabil = this._destroyCapability) === null ||
  8658. _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil
  8659. .promise) || null;
  8660. }
  8661. get ready() {
  8662. return this._ready;
  8663. }
  8664. get _internalEvents() {
  8665. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  8666. }
  8667. get _domEvents() {
  8668. return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
  8669. }
  8670. get _pageOpenPending() {
  8671. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  8672. }
  8673. get _visitedPages() {
  8674. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  8675. }
  8676. async _updateFromSandbox(detail) {
  8677. const isInPresentationMode = this._pdfViewer.isInPresentationMode || this
  8678. ._pdfViewer.isChangingPresentationMode;
  8679. const {
  8680. id,
  8681. siblings,
  8682. command,
  8683. value
  8684. } = detail;
  8685. if (!id) {
  8686. switch (command) {
  8687. case "clear":
  8688. console.clear();
  8689. break;
  8690. case "error":
  8691. console.error(value);
  8692. break;
  8693. case "layout":
  8694. if (isInPresentationMode) {
  8695. return;
  8696. }
  8697. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
  8698. this._pdfViewer.spreadMode = modes.spreadMode;
  8699. break;
  8700. case "page-num":
  8701. this._pdfViewer.currentPageNumber = value + 1;
  8702. break;
  8703. case "print":
  8704. await this._pdfViewer.pagesPromise;
  8705. this._eventBus.dispatch("print", {
  8706. source: this
  8707. });
  8708. break;
  8709. case "println":
  8710. console.log(value);
  8711. break;
  8712. case "zoom":
  8713. if (isInPresentationMode) {
  8714. return;
  8715. }
  8716. this._pdfViewer.currentScaleValue = value;
  8717. break;
  8718. case "SaveAs":
  8719. this._eventBus.dispatch("download", {
  8720. source: this
  8721. });
  8722. break;
  8723. case "FirstPage":
  8724. this._pdfViewer.currentPageNumber = 1;
  8725. break;
  8726. case "LastPage":
  8727. this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount;
  8728. break;
  8729. case "NextPage":
  8730. this._pdfViewer.nextPage();
  8731. break;
  8732. case "PrevPage":
  8733. this._pdfViewer.previousPage();
  8734. break;
  8735. case "ZoomViewIn":
  8736. if (isInPresentationMode) {
  8737. return;
  8738. }
  8739. this._pdfViewer.increaseScale();
  8740. break;
  8741. case "ZoomViewOut":
  8742. if (isInPresentationMode) {
  8743. return;
  8744. }
  8745. this._pdfViewer.decreaseScale();
  8746. break;
  8747. }
  8748. return;
  8749. }
  8750. if (isInPresentationMode) {
  8751. if (detail.focus) {
  8752. return;
  8753. }
  8754. }
  8755. delete detail.id;
  8756. delete detail.siblings;
  8757. const ids = siblings ? [id, ...siblings] : [id];
  8758. for (const elementId of ids) {
  8759. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  8760. if (element) {
  8761. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  8762. detail
  8763. }));
  8764. } else {
  8765. var _this$_pdfDocument;
  8766. (_this$_pdfDocument = this._pdfDocument) === null ||
  8767. _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument
  8768. .annotationStorage.setValue(elementId, detail);
  8769. }
  8770. }
  8771. }
  8772. async _dispatchPageOpen(pageNumber) {
  8773. let initialize = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  8774. 1] : false;
  8775. const pdfDocument = this._pdfDocument,
  8776. visitedPages = this._visitedPages;
  8777. if (initialize) {
  8778. this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
  8779. }
  8780. if (!this._closeCapability) {
  8781. return;
  8782. }
  8783. const pageView = this._pdfViewer.getPageView(pageNumber - 1);
  8784. if ((pageView === null || pageView === void 0 ? void 0 : pageView
  8785. .renderingState) !== _ui_utils.RenderingStates.FINISHED) {
  8786. this._pageOpenPending.add(pageNumber);
  8787. return;
  8788. }
  8789. this._pageOpenPending.delete(pageNumber);
  8790. const actionsPromise = (async () => {
  8791. var _pageView$pdfPage, _this$_scripting8;
  8792. const actions = await (!visitedPages.has(pageNumber) ? (
  8793. _pageView$pdfPage = pageView.pdfPage) === null ||
  8794. _pageView$pdfPage === void 0 ? void 0 :
  8795. _pageView$pdfPage.getJSActions() : null);
  8796. if (pdfDocument !== this._pdfDocument) {
  8797. return;
  8798. }
  8799. await ((_this$_scripting8 = this._scripting) === null ||
  8800. _this$_scripting8 === void 0 ? void 0 : _this$_scripting8
  8801. .dispatchEventInSandbox({
  8802. id: "page",
  8803. name: "PageOpen",
  8804. pageNumber,
  8805. actions
  8806. }));
  8807. })();
  8808. visitedPages.set(pageNumber, actionsPromise);
  8809. }
  8810. async _dispatchPageClose(pageNumber) {
  8811. var _this$_scripting9;
  8812. const pdfDocument = this._pdfDocument,
  8813. visitedPages = this._visitedPages;
  8814. if (!this._closeCapability) {
  8815. return;
  8816. }
  8817. if (this._pageOpenPending.has(pageNumber)) {
  8818. return;
  8819. }
  8820. const actionsPromise = visitedPages.get(pageNumber);
  8821. if (!actionsPromise) {
  8822. return;
  8823. }
  8824. visitedPages.set(pageNumber, null);
  8825. await actionsPromise;
  8826. if (pdfDocument !== this._pdfDocument) {
  8827. return;
  8828. }
  8829. await ((_this$_scripting9 = this._scripting) === null || _this$_scripting9 ===
  8830. void 0 ? void 0 : _this$_scripting9.dispatchEventInSandbox({
  8831. id: "page",
  8832. name: "PageClose",
  8833. pageNumber
  8834. }));
  8835. }
  8836. async _getDocProperties() {
  8837. if (this._docPropertiesLookup) {
  8838. return this._docPropertiesLookup(this._pdfDocument);
  8839. }
  8840. throw new Error("_getDocProperties: Unable to lookup properties.");
  8841. }
  8842. _createScripting() {
  8843. this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
  8844. if (this._scripting) {
  8845. throw new Error("_createScripting: Scripting already exists.");
  8846. }
  8847. if (this._scriptingFactory) {
  8848. return this._scriptingFactory.createScripting({
  8849. sandboxBundleSrc: this._sandboxBundleSrc
  8850. });
  8851. }
  8852. throw new Error("_createScripting: Cannot create scripting.");
  8853. }
  8854. async _destroyScripting() {
  8855. var _this$_destroyCapabil3;
  8856. if (!this._scripting) {
  8857. var _this$_destroyCapabil2;
  8858. this._pdfDocument = null;
  8859. (_this$_destroyCapabil2 = this._destroyCapability) === null ||
  8860. _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2
  8861. .resolve();
  8862. return;
  8863. }
  8864. if (this._closeCapability) {
  8865. await Promise.race([this._closeCapability.promise, new Promise(resolve => {
  8866. setTimeout(resolve, 1000);
  8867. })]).catch(reason => {});
  8868. this._closeCapability = null;
  8869. }
  8870. this._pdfDocument = null;
  8871. try {
  8872. await this._scripting.destroySandbox();
  8873. } catch (ex) {}
  8874. for (const [name, listener] of this._internalEvents) {
  8875. this._eventBus._off(name, listener);
  8876. }
  8877. this._internalEvents.clear();
  8878. for (const [name, listener] of this._domEvents) {
  8879. window.removeEventListener(name, listener, true);
  8880. }
  8881. this._domEvents.clear();
  8882. this._pageOpenPending.clear();
  8883. this._visitedPages.clear();
  8884. this._scripting = null;
  8885. delete this._mouseState.isDown;
  8886. this._ready = false;
  8887. (_this$_destroyCapabil3 = this._destroyCapability) === null ||
  8888. _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3
  8889. .resolve();
  8890. }
  8891. }
  8892. exports.PDFScriptingManager = PDFScriptingManager;
  8893. /***/
  8894. }),
  8895. /* 25 */
  8896. /***/
  8897. ((__unused_webpack_module, exports, __webpack_require__) => {
  8898. Object.defineProperty(exports, "__esModule", ({
  8899. value: true
  8900. }));
  8901. exports.PDFSidebar = void 0;
  8902. var _ui_utils = __webpack_require__(1);
  8903. function _classPrivateMethodInitSpec(obj, privateSet) {
  8904. _checkPrivateRedeclaration(obj, privateSet);
  8905. privateSet.add(obj);
  8906. }
  8907. function _checkPrivateRedeclaration(obj, privateCollection) {
  8908. if (privateCollection.has(obj)) {
  8909. throw new TypeError(
  8910. "Cannot initialize the same private elements twice on an object");
  8911. }
  8912. }
  8913. function _classPrivateMethodGet(receiver, privateSet, fn) {
  8914. if (!privateSet.has(receiver)) {
  8915. throw new TypeError("attempted to get private field on non-instance");
  8916. }
  8917. return fn;
  8918. }
  8919. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  8920. var _dispatchEvent = /*#__PURE__*/ new WeakSet();
  8921. var _forceRendering = /*#__PURE__*/ new WeakSet();
  8922. var _updateThumbnailViewer = /*#__PURE__*/ new WeakSet();
  8923. var _showUINotification = /*#__PURE__*/ new WeakSet();
  8924. var _hideUINotification = /*#__PURE__*/ new WeakSet();
  8925. var _addEventListeners = /*#__PURE__*/ new WeakSet();
  8926. class PDFSidebar {
  8927. constructor(_ref) {
  8928. let {
  8929. elements,
  8930. pdfViewer: _pdfViewer,
  8931. pdfThumbnailViewer: _pdfThumbnailViewer,
  8932. eventBus,
  8933. l10n
  8934. } = _ref;
  8935. _classPrivateMethodInitSpec(this, _addEventListeners);
  8936. _classPrivateMethodInitSpec(this, _hideUINotification);
  8937. _classPrivateMethodInitSpec(this, _showUINotification);
  8938. _classPrivateMethodInitSpec(this, _updateThumbnailViewer);
  8939. _classPrivateMethodInitSpec(this, _forceRendering);
  8940. _classPrivateMethodInitSpec(this, _dispatchEvent);
  8941. this.isOpen = false;
  8942. this.active = _ui_utils.SidebarView.THUMBS;
  8943. this.isInitialViewSet = false;
  8944. this.isInitialEventDispatched = false;
  8945. this.onToggled = null;
  8946. this.pdfViewer = _pdfViewer;
  8947. this.pdfThumbnailViewer = _pdfThumbnailViewer;
  8948. this.outerContainer = elements.outerContainer;
  8949. this.sidebarContainer = elements.sidebarContainer;
  8950. this.toggleButton = elements.toggleButton;
  8951. this.thumbnailButton = elements.thumbnailButton;
  8952. this.outlineButton = elements.outlineButton;
  8953. this.attachmentsButton = elements.attachmentsButton;
  8954. this.layersButton = elements.layersButton;
  8955. this.thumbnailView = elements.thumbnailView;
  8956. this.outlineView = elements.outlineView;
  8957. this.attachmentsView = elements.attachmentsView;
  8958. this.layersView = elements.layersView;
  8959. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  8960. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  8961. this.eventBus = eventBus;
  8962. this.l10n = l10n;
  8963. _classPrivateMethodGet(this, _addEventListeners, _addEventListeners2).call(
  8964. this);
  8965. }
  8966. reset() {
  8967. this.isInitialViewSet = false;
  8968. this.isInitialEventDispatched = false;
  8969. _classPrivateMethodGet(this, _hideUINotification, _hideUINotification2).call(
  8970. this, true);
  8971. this.switchView(_ui_utils.SidebarView.THUMBS);
  8972. this.outlineButton.disabled = false;
  8973. this.attachmentsButton.disabled = false;
  8974. this.layersButton.disabled = false;
  8975. this._currentOutlineItemButton.disabled = true;
  8976. }
  8977. get visibleView() {
  8978. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  8979. }
  8980. setInitialView() {
  8981. let view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  8982. _ui_utils.SidebarView.NONE;
  8983. if (this.isInitialViewSet) {
  8984. return;
  8985. }
  8986. this.isInitialViewSet = true;
  8987. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView
  8988. .UNKNOWN) {
  8989. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8990. return;
  8991. }
  8992. this.switchView(view, true);
  8993. if (!this.isInitialEventDispatched) {
  8994. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8995. }
  8996. }
  8997. switchView(view) {
  8998. let forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  8999. 1] : false;
  9000. const isViewChanged = view !== this.active;
  9001. let shouldForceRendering = false;
  9002. switch (view) {
  9003. case _ui_utils.SidebarView.NONE:
  9004. if (this.isOpen) {
  9005. this.close();
  9006. }
  9007. return;
  9008. case _ui_utils.SidebarView.THUMBS:
  9009. if (this.isOpen && isViewChanged) {
  9010. shouldForceRendering = true;
  9011. }
  9012. break;
  9013. case _ui_utils.SidebarView.OUTLINE:
  9014. if (this.outlineButton.disabled) {
  9015. return;
  9016. }
  9017. break;
  9018. case _ui_utils.SidebarView.ATTACHMENTS:
  9019. if (this.attachmentsButton.disabled) {
  9020. return;
  9021. }
  9022. break;
  9023. case _ui_utils.SidebarView.LAYERS:
  9024. if (this.layersButton.disabled) {
  9025. return;
  9026. }
  9027. break;
  9028. default:
  9029. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  9030. return;
  9031. }
  9032. this.active = view;
  9033. const isThumbs = view === _ui_utils.SidebarView.THUMBS,
  9034. isOutline = view === _ui_utils.SidebarView.OUTLINE,
  9035. isAttachments = view === _ui_utils.SidebarView.ATTACHMENTS,
  9036. isLayers = view === _ui_utils.SidebarView.LAYERS;
  9037. this.thumbnailButton.classList.toggle("toggled", isThumbs);
  9038. this.outlineButton.classList.toggle("toggled", isOutline);
  9039. this.attachmentsButton.classList.toggle("toggled", isAttachments);
  9040. this.layersButton.classList.toggle("toggled", isLayers);
  9041. this.thumbnailButton.setAttribute("aria-checked", isThumbs);
  9042. this.outlineButton.setAttribute("aria-checked", isOutline);
  9043. this.attachmentsButton.setAttribute("aria-checked", isAttachments);
  9044. this.layersButton.setAttribute("aria-checked", isLayers);
  9045. this.thumbnailView.classList.toggle("hidden", !isThumbs);
  9046. this.outlineView.classList.toggle("hidden", !isOutline);
  9047. this.attachmentsView.classList.toggle("hidden", !isAttachments);
  9048. this.layersView.classList.toggle("hidden", !isLayers);
  9049. this._outlineOptionsContainer.classList.toggle("hidden", !isOutline);
  9050. if (forceOpen && !this.isOpen) {
  9051. this.open();
  9052. return;
  9053. }
  9054. if (shouldForceRendering) {
  9055. _classPrivateMethodGet(this, _updateThumbnailViewer,
  9056. _updateThumbnailViewer2).call(this);
  9057. _classPrivateMethodGet(this, _forceRendering, _forceRendering2).call(this);
  9058. }
  9059. if (isViewChanged) {
  9060. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  9061. }
  9062. }
  9063. open() {
  9064. if (this.isOpen) {
  9065. return;
  9066. }
  9067. this.isOpen = true;
  9068. this.toggleButton.classList.add("toggled");
  9069. this.toggleButton.setAttribute("aria-expanded", "true");
  9070. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9071. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9072. _classPrivateMethodGet(this, _updateThumbnailViewer,
  9073. _updateThumbnailViewer2).call(this);
  9074. }
  9075. _classPrivateMethodGet(this, _forceRendering, _forceRendering2).call(this);
  9076. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  9077. _classPrivateMethodGet(this, _hideUINotification, _hideUINotification2).call(
  9078. this);
  9079. }
  9080. close() {
  9081. if (!this.isOpen) {
  9082. return;
  9083. }
  9084. this.isOpen = false;
  9085. this.toggleButton.classList.remove("toggled");
  9086. this.toggleButton.setAttribute("aria-expanded", "false");
  9087. this.outerContainer.classList.add("sidebarMoving");
  9088. this.outerContainer.classList.remove("sidebarOpen");
  9089. _classPrivateMethodGet(this, _forceRendering, _forceRendering2).call(this);
  9090. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  9091. }
  9092. toggle() {
  9093. if (this.isOpen) {
  9094. this.close();
  9095. } else {
  9096. this.open();
  9097. }
  9098. }
  9099. }
  9100. exports.PDFSidebar = PDFSidebar;
  9101. function _dispatchEvent2() {
  9102. if (this.isInitialViewSet && !this.isInitialEventDispatched) {
  9103. this.isInitialEventDispatched = true;
  9104. }
  9105. this.eventBus.dispatch("sidebarviewchanged", {
  9106. source: this,
  9107. view: this.visibleView
  9108. });
  9109. }
  9110. function _forceRendering2() {
  9111. if (this.onToggled) {
  9112. this.onToggled();
  9113. } else {
  9114. this.pdfViewer.forceRendering();
  9115. this.pdfThumbnailViewer.forceRendering();
  9116. }
  9117. }
  9118. function _updateThumbnailViewer2() {
  9119. const {
  9120. pdfViewer,
  9121. pdfThumbnailViewer
  9122. } = this;
  9123. const pagesCount = pdfViewer.pagesCount;
  9124. for (let pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  9125. const pageView = pdfViewer.getPageView(pageIndex);
  9126. if ((pageView === null || pageView === void 0 ? void 0 : pageView
  9127. .renderingState) === _ui_utils.RenderingStates.FINISHED) {
  9128. const thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  9129. thumbnailView.setImage(pageView);
  9130. }
  9131. }
  9132. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  9133. }
  9134. function _showUINotification2() {
  9135. this.l10n.get("toggle_sidebar_notification2.title").then(msg => {
  9136. this.toggleButton.title = msg;
  9137. });
  9138. if (!this.isOpen) {
  9139. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9140. }
  9141. }
  9142. function _hideUINotification2() {
  9143. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9144. if (this.isOpen || reset) {
  9145. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9146. }
  9147. if (reset) {
  9148. this.l10n.get("toggle_sidebar.title").then(msg => {
  9149. this.toggleButton.title = msg;
  9150. });
  9151. }
  9152. }
  9153. function _addEventListeners2() {
  9154. this.sidebarContainer.addEventListener("transitionend", evt => {
  9155. if (evt.target === this.sidebarContainer) {
  9156. this.outerContainer.classList.remove("sidebarMoving");
  9157. }
  9158. });
  9159. this.toggleButton.addEventListener("click", () => {
  9160. this.toggle();
  9161. });
  9162. this.thumbnailButton.addEventListener("click", () => {
  9163. this.switchView(_ui_utils.SidebarView.THUMBS);
  9164. });
  9165. this.outlineButton.addEventListener("click", () => {
  9166. this.switchView(_ui_utils.SidebarView.OUTLINE);
  9167. });
  9168. this.outlineButton.addEventListener("dblclick", () => {
  9169. this.eventBus.dispatch("toggleoutlinetree", {
  9170. source: this
  9171. });
  9172. });
  9173. this.attachmentsButton.addEventListener("click", () => {
  9174. this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9175. });
  9176. this.layersButton.addEventListener("click", () => {
  9177. this.switchView(_ui_utils.SidebarView.LAYERS);
  9178. });
  9179. this.layersButton.addEventListener("dblclick", () => {
  9180. this.eventBus.dispatch("resetlayers", {
  9181. source: this
  9182. });
  9183. });
  9184. this._currentOutlineItemButton.addEventListener("click", () => {
  9185. this.eventBus.dispatch("currentoutlineitem", {
  9186. source: this
  9187. });
  9188. });
  9189. const onTreeLoaded = (count, button, view) => {
  9190. button.disabled = !count;
  9191. if (count) {
  9192. _classPrivateMethodGet(this, _showUINotification, _showUINotification2)
  9193. .call(this);
  9194. } else if (this.active === view) {
  9195. this.switchView(_ui_utils.SidebarView.THUMBS);
  9196. }
  9197. };
  9198. this.eventBus._on("outlineloaded", evt => {
  9199. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView
  9200. .OUTLINE);
  9201. evt.currentOutlineItemPromise.then(enabled => {
  9202. if (!this.isInitialViewSet) {
  9203. return;
  9204. }
  9205. this._currentOutlineItemButton.disabled = !enabled;
  9206. });
  9207. });
  9208. this.eventBus._on("attachmentsloaded", evt => {
  9209. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils
  9210. .SidebarView.ATTACHMENTS);
  9211. });
  9212. this.eventBus._on("layersloaded", evt => {
  9213. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView
  9214. .LAYERS);
  9215. });
  9216. this.eventBus._on("presentationmodechanged", evt => {
  9217. if (evt.state === _ui_utils.PresentationModeState.NORMAL && this
  9218. .visibleView === _ui_utils.SidebarView.THUMBS) {
  9219. _classPrivateMethodGet(this, _updateThumbnailViewer,
  9220. _updateThumbnailViewer2).call(this);
  9221. }
  9222. });
  9223. }
  9224. /***/
  9225. }),
  9226. /* 26 */
  9227. /***/
  9228. ((__unused_webpack_module, exports, __webpack_require__) => {
  9229. Object.defineProperty(exports, "__esModule", ({
  9230. value: true
  9231. }));
  9232. exports.PDFSidebarResizer = void 0;
  9233. var _ui_utils = __webpack_require__(1);
  9234. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9235. const SIDEBAR_MIN_WIDTH = 200;
  9236. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9237. class PDFSidebarResizer {
  9238. constructor(options, eventBus, l10n) {
  9239. this.isRTL = false;
  9240. this.sidebarOpen = false;
  9241. this._width = null;
  9242. this._outerContainerWidth = null;
  9243. this._boundEvents = Object.create(null);
  9244. this.outerContainer = options.outerContainer;
  9245. this.resizer = options.resizer;
  9246. this.eventBus = eventBus;
  9247. l10n.getDirection().then(dir => {
  9248. this.isRTL = dir === "rtl";
  9249. });
  9250. this._addEventListeners();
  9251. }
  9252. get outerContainerWidth() {
  9253. return this._outerContainerWidth || (this._outerContainerWidth = this
  9254. .outerContainer.clientWidth);
  9255. }
  9256. _updateWidth() {
  9257. let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  9258. 0;
  9259. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  9260. if (width > maxWidth) {
  9261. width = maxWidth;
  9262. }
  9263. if (width < SIDEBAR_MIN_WIDTH) {
  9264. width = SIDEBAR_MIN_WIDTH;
  9265. }
  9266. if (width === this._width) {
  9267. return false;
  9268. }
  9269. this._width = width;
  9270. _ui_utils.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  9271. return true;
  9272. }
  9273. _mouseMove(evt) {
  9274. let width = evt.clientX;
  9275. if (this.isRTL) {
  9276. width = this.outerContainerWidth - width;
  9277. }
  9278. this._updateWidth(width);
  9279. }
  9280. _mouseUp(evt) {
  9281. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9282. this.eventBus.dispatch("resize", {
  9283. source: this
  9284. });
  9285. const _boundEvents = this._boundEvents;
  9286. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  9287. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  9288. }
  9289. _addEventListeners() {
  9290. const _boundEvents = this._boundEvents;
  9291. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9292. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9293. this.resizer.addEventListener("mousedown", evt => {
  9294. if (evt.button !== 0) {
  9295. return;
  9296. }
  9297. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9298. window.addEventListener("mousemove", _boundEvents.mouseMove);
  9299. window.addEventListener("mouseup", _boundEvents.mouseUp);
  9300. });
  9301. this.eventBus._on("sidebarviewchanged", evt => {
  9302. this.sidebarOpen = !!(evt !== null && evt !== void 0 && evt.view);
  9303. });
  9304. this.eventBus._on("resize", evt => {
  9305. if ((evt === null || evt === void 0 ? void 0 : evt.source) !==
  9306. window) {
  9307. return;
  9308. }
  9309. this._outerContainerWidth = null;
  9310. if (!this._width) {
  9311. return;
  9312. }
  9313. if (!this.sidebarOpen) {
  9314. this._updateWidth(this._width);
  9315. return;
  9316. }
  9317. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9318. const updated = this._updateWidth(this._width);
  9319. Promise.resolve().then(() => {
  9320. this.outerContainer.classList.remove(
  9321. SIDEBAR_RESIZING_CLASS);
  9322. if (updated) {
  9323. this.eventBus.dispatch("resize", {
  9324. source: this
  9325. });
  9326. }
  9327. });
  9328. });
  9329. }
  9330. }
  9331. exports.PDFSidebarResizer = PDFSidebarResizer;
  9332. /***/
  9333. }),
  9334. /* 27 */
  9335. /***/
  9336. ((__unused_webpack_module, exports, __webpack_require__) => {
  9337. Object.defineProperty(exports, "__esModule", ({
  9338. value: true
  9339. }));
  9340. exports.PDFThumbnailViewer = void 0;
  9341. var _ui_utils = __webpack_require__(1);
  9342. var _pdf_thumbnail_view = __webpack_require__(28);
  9343. function _classPrivateMethodInitSpec(obj, privateSet) {
  9344. _checkPrivateRedeclaration(obj, privateSet);
  9345. privateSet.add(obj);
  9346. }
  9347. function _checkPrivateRedeclaration(obj, privateCollection) {
  9348. if (privateCollection.has(obj)) {
  9349. throw new TypeError(
  9350. "Cannot initialize the same private elements twice on an object");
  9351. }
  9352. }
  9353. function _classPrivateMethodGet(receiver, privateSet, fn) {
  9354. if (!privateSet.has(receiver)) {
  9355. throw new TypeError("attempted to get private field on non-instance");
  9356. }
  9357. return fn;
  9358. }
  9359. const THUMBNAIL_SCROLL_MARGIN = -19;
  9360. const THUMBNAIL_SELECTED_CLASS = "selected";
  9361. var _ensurePdfPageLoaded = /*#__PURE__*/ new WeakSet();
  9362. var _getScrollAhead = /*#__PURE__*/ new WeakSet();
  9363. class PDFThumbnailViewer {
  9364. constructor(_ref) {
  9365. let {
  9366. container,
  9367. eventBus,
  9368. linkService,
  9369. renderingQueue,
  9370. l10n,
  9371. pageColors
  9372. } = _ref;
  9373. _classPrivateMethodInitSpec(this, _getScrollAhead);
  9374. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  9375. this.container = container;
  9376. this.linkService = linkService;
  9377. this.renderingQueue = renderingQueue;
  9378. this.l10n = l10n;
  9379. this.pageColors = pageColors || null;
  9380. if (this.pageColors && !(CSS.supports("color", this.pageColors.background) &&
  9381. CSS.supports("color", this.pageColors.foreground))) {
  9382. if (this.pageColors.background || this.pageColors.foreground) {
  9383. console.warn(
  9384. "PDFThumbnailViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."
  9385. );
  9386. }
  9387. this.pageColors = null;
  9388. }
  9389. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated
  9390. .bind(this));
  9391. this._resetView();
  9392. }
  9393. _scrollUpdated() {
  9394. this.renderingQueue.renderHighestPriority();
  9395. }
  9396. getThumbnail(index) {
  9397. return this._thumbnails[index];
  9398. }
  9399. _getVisibleThumbs() {
  9400. return (0, _ui_utils.getVisibleElements)({
  9401. scrollEl: this.container,
  9402. views: this._thumbnails
  9403. });
  9404. }
  9405. scrollThumbnailIntoView(pageNumber) {
  9406. if (!this.pdfDocument) {
  9407. return;
  9408. }
  9409. const thumbnailView = this._thumbnails[pageNumber - 1];
  9410. if (!thumbnailView) {
  9411. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9412. return;
  9413. }
  9414. if (pageNumber !== this._currentPageNumber) {
  9415. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  9416. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9417. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9418. }
  9419. const {
  9420. first,
  9421. last,
  9422. views
  9423. } = this._getVisibleThumbs();
  9424. if (views.length > 0) {
  9425. let shouldScroll = false;
  9426. if (pageNumber <= first.id || pageNumber >= last.id) {
  9427. shouldScroll = true;
  9428. } else {
  9429. for (const {
  9430. id,
  9431. percent
  9432. } of views) {
  9433. if (id !== pageNumber) {
  9434. continue;
  9435. }
  9436. shouldScroll = percent < 100;
  9437. break;
  9438. }
  9439. }
  9440. if (shouldScroll) {
  9441. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9442. top: THUMBNAIL_SCROLL_MARGIN
  9443. });
  9444. }
  9445. }
  9446. this._currentPageNumber = pageNumber;
  9447. }
  9448. get pagesRotation() {
  9449. return this._pagesRotation;
  9450. }
  9451. set pagesRotation(rotation) {
  9452. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9453. throw new Error("Invalid thumbnails rotation angle.");
  9454. }
  9455. if (!this.pdfDocument) {
  9456. return;
  9457. }
  9458. if (this._pagesRotation === rotation) {
  9459. return;
  9460. }
  9461. this._pagesRotation = rotation;
  9462. const updateArgs = {
  9463. rotation
  9464. };
  9465. for (const thumbnail of this._thumbnails) {
  9466. thumbnail.update(updateArgs);
  9467. }
  9468. }
  9469. cleanup() {
  9470. for (const thumbnail of this._thumbnails) {
  9471. if (thumbnail.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9472. thumbnail.reset();
  9473. }
  9474. }
  9475. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  9476. }
  9477. _resetView() {
  9478. this._thumbnails = [];
  9479. this._currentPageNumber = 1;
  9480. this._pageLabels = null;
  9481. this._pagesRotation = 0;
  9482. this.container.textContent = "";
  9483. }
  9484. setDocument(pdfDocument) {
  9485. if (this.pdfDocument) {
  9486. this._cancelRendering();
  9487. this._resetView();
  9488. }
  9489. this.pdfDocument = pdfDocument;
  9490. if (!pdfDocument) {
  9491. return;
  9492. }
  9493. const firstPagePromise = pdfDocument.getPage(1);
  9494. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9495. firstPagePromise.then(firstPdfPage => {
  9496. const pagesCount = pdfDocument.numPages;
  9497. const viewport = firstPdfPage.getViewport({
  9498. scale: 1
  9499. });
  9500. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9501. const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  9502. container: this.container,
  9503. id: pageNum,
  9504. defaultViewport: viewport.clone(),
  9505. optionalContentConfigPromise,
  9506. linkService: this.linkService,
  9507. renderingQueue: this.renderingQueue,
  9508. l10n: this.l10n,
  9509. pageColors: this.pageColors
  9510. });
  9511. this._thumbnails.push(thumbnail);
  9512. }
  9513. const firstThumbnailView = this._thumbnails[0];
  9514. if (firstThumbnailView) {
  9515. firstThumbnailView.setPdfPage(firstPdfPage);
  9516. }
  9517. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  9518. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9519. }).catch(reason => {
  9520. console.error("Unable to initialize thumbnail viewer", reason);
  9521. });
  9522. }
  9523. _cancelRendering() {
  9524. for (const thumbnail of this._thumbnails) {
  9525. thumbnail.cancelRendering();
  9526. }
  9527. }
  9528. setPageLabels(labels) {
  9529. if (!this.pdfDocument) {
  9530. return;
  9531. }
  9532. if (!labels) {
  9533. this._pageLabels = null;
  9534. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels
  9535. .length)) {
  9536. this._pageLabels = null;
  9537. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  9538. } else {
  9539. this._pageLabels = labels;
  9540. }
  9541. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9542. var _this$_pageLabels$i, _this$_pageLabels;
  9543. this._thumbnails[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels =
  9544. this._pageLabels) === null || _this$_pageLabels === void 0 ?
  9545. void 0 : _this$_pageLabels[i]) !== null &&
  9546. _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null);
  9547. }
  9548. }
  9549. forceRendering() {
  9550. const visibleThumbs = this._getVisibleThumbs();
  9551. const scrollAhead = _classPrivateMethodGet(this, _getScrollAhead,
  9552. _getScrollAhead2).call(this, visibleThumbs);
  9553. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this
  9554. ._thumbnails, scrollAhead);
  9555. if (thumbView) {
  9556. _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2)
  9557. .call(this, thumbView).then(() => {
  9558. this.renderingQueue.renderView(thumbView);
  9559. });
  9560. return true;
  9561. }
  9562. return false;
  9563. }
  9564. }
  9565. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9566. async function _ensurePdfPageLoaded2(thumbView) {
  9567. if (thumbView.pdfPage) {
  9568. return thumbView.pdfPage;
  9569. }
  9570. try {
  9571. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  9572. if (!thumbView.pdfPage) {
  9573. thumbView.setPdfPage(pdfPage);
  9574. }
  9575. return pdfPage;
  9576. } catch (reason) {
  9577. console.error("Unable to get page for thumb view", reason);
  9578. return null;
  9579. }
  9580. }
  9581. function _getScrollAhead2(visible) {
  9582. var _visible$first, _visible$last;
  9583. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 :
  9584. _visible$first.id) === 1) {
  9585. return true;
  9586. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ?
  9587. void 0 : _visible$last.id) === this._thumbnails.length) {
  9588. return false;
  9589. }
  9590. return this.scroll.down;
  9591. }
  9592. /***/
  9593. }),
  9594. /* 28 */
  9595. /***/
  9596. ((__unused_webpack_module, exports, __webpack_require__) => {
  9597. Object.defineProperty(exports, "__esModule", ({
  9598. value: true
  9599. }));
  9600. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  9601. var _ui_utils = __webpack_require__(1);
  9602. var _pdfjsLib = __webpack_require__(5);
  9603. function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
  9604. _classCheckPrivateStaticAccess(receiver, classConstructor);
  9605. _classCheckPrivateStaticFieldDescriptor(descriptor, "set");
  9606. _classApplyDescriptorSet(receiver, descriptor, value);
  9607. return value;
  9608. }
  9609. function _classApplyDescriptorSet(receiver, descriptor, value) {
  9610. if (descriptor.set) {
  9611. descriptor.set.call(receiver, value);
  9612. } else {
  9613. if (!descriptor.writable) {
  9614. throw new TypeError("attempted to set read only private field");
  9615. }
  9616. descriptor.value = value;
  9617. }
  9618. }
  9619. function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
  9620. _classCheckPrivateStaticAccess(receiver, classConstructor);
  9621. _classCheckPrivateStaticFieldDescriptor(descriptor, "get");
  9622. return _classApplyDescriptorGet(receiver, descriptor);
  9623. }
  9624. function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
  9625. if (descriptor === undefined) {
  9626. throw new TypeError("attempted to " + action +
  9627. " private static field before its declaration");
  9628. }
  9629. }
  9630. function _classCheckPrivateStaticAccess(receiver, classConstructor) {
  9631. if (receiver !== classConstructor) {
  9632. throw new TypeError("Private static access of wrong provenance");
  9633. }
  9634. }
  9635. function _classApplyDescriptorGet(receiver, descriptor) {
  9636. if (descriptor.get) {
  9637. return descriptor.get.call(receiver);
  9638. }
  9639. return descriptor.value;
  9640. }
  9641. const DRAW_UPSCALE_FACTOR = 2;
  9642. const MAX_NUM_SCALING_STEPS = 3;
  9643. const THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  9644. const THUMBNAIL_WIDTH = 98;
  9645. class TempImageFactory {
  9646. static getCanvas(width, height) {
  9647. const tempCanvas = _classStaticPrivateFieldSpecGet(this, TempImageFactory,
  9648. _tempCanvas) || _classStaticPrivateFieldSpecSet(this, TempImageFactory,
  9649. _tempCanvas, document.createElement("canvas"));
  9650. tempCanvas.width = width;
  9651. tempCanvas.height = height;
  9652. const ctx = tempCanvas.getContext("2d", {
  9653. alpha: false
  9654. });
  9655. ctx.save();
  9656. ctx.fillStyle = "rgb(255, 255, 255)";
  9657. ctx.fillRect(0, 0, width, height);
  9658. ctx.restore();
  9659. return [tempCanvas, tempCanvas.getContext("2d")];
  9660. }
  9661. static destroyCanvas() {
  9662. const tempCanvas = _classStaticPrivateFieldSpecGet(this, TempImageFactory,
  9663. _tempCanvas);
  9664. if (tempCanvas) {
  9665. tempCanvas.width = 0;
  9666. tempCanvas.height = 0;
  9667. }
  9668. _classStaticPrivateFieldSpecSet(this, TempImageFactory, _tempCanvas, null);
  9669. }
  9670. }
  9671. exports.TempImageFactory = TempImageFactory;
  9672. var _tempCanvas = {
  9673. writable: true,
  9674. value: null
  9675. };
  9676. class PDFThumbnailView {
  9677. constructor(_ref) {
  9678. let {
  9679. container,
  9680. id,
  9681. defaultViewport,
  9682. optionalContentConfigPromise,
  9683. linkService,
  9684. renderingQueue,
  9685. l10n,
  9686. pageColors
  9687. } = _ref;
  9688. this.id = id;
  9689. this.renderingId = "thumbnail" + id;
  9690. this.pageLabel = null;
  9691. this.pdfPage = null;
  9692. this.rotation = 0;
  9693. this.viewport = defaultViewport;
  9694. this.pdfPageRotate = defaultViewport.rotation;
  9695. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  9696. this.pageColors = pageColors || null;
  9697. this.linkService = linkService;
  9698. this.renderingQueue = renderingQueue;
  9699. this.renderTask = null;
  9700. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  9701. this.resume = null;
  9702. const pageWidth = this.viewport.width,
  9703. pageHeight = this.viewport.height,
  9704. pageRatio = pageWidth / pageHeight;
  9705. this.canvasWidth = THUMBNAIL_WIDTH;
  9706. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  9707. this.scale = this.canvasWidth / pageWidth;
  9708. this.l10n = l10n;
  9709. const anchor = document.createElement("a");
  9710. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9711. this._thumbPageTitle.then(msg => {
  9712. anchor.title = msg;
  9713. });
  9714. anchor.onclick = function() {
  9715. linkService.goToPage(id);
  9716. return false;
  9717. };
  9718. this.anchor = anchor;
  9719. const div = document.createElement("div");
  9720. div.className = "thumbnail";
  9721. div.setAttribute("data-page-number", this.id);
  9722. this.div = div;
  9723. const ring = document.createElement("div");
  9724. ring.className = "thumbnailSelectionRing";
  9725. const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9726. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9727. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9728. this.ring = ring;
  9729. div.append(ring);
  9730. anchor.append(div);
  9731. container.append(anchor);
  9732. }
  9733. setPdfPage(pdfPage) {
  9734. this.pdfPage = pdfPage;
  9735. this.pdfPageRotate = pdfPage.rotate;
  9736. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9737. this.viewport = pdfPage.getViewport({
  9738. scale: 1,
  9739. rotation: totalRotation
  9740. });
  9741. this.reset();
  9742. }
  9743. reset() {
  9744. this.cancelRendering();
  9745. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  9746. const pageWidth = this.viewport.width,
  9747. pageHeight = this.viewport.height,
  9748. pageRatio = pageWidth / pageHeight;
  9749. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  9750. this.scale = this.canvasWidth / pageWidth;
  9751. this.div.removeAttribute("data-loaded");
  9752. const ring = this.ring;
  9753. ring.textContent = "";
  9754. const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9755. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9756. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9757. if (this.canvas) {
  9758. this.canvas.width = 0;
  9759. this.canvas.height = 0;
  9760. delete this.canvas;
  9761. }
  9762. if (this.image) {
  9763. this.image.removeAttribute("src");
  9764. delete this.image;
  9765. }
  9766. }
  9767. update(_ref2) {
  9768. let {
  9769. rotation = null
  9770. } = _ref2;
  9771. if (typeof rotation === "number") {
  9772. this.rotation = rotation;
  9773. }
  9774. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9775. this.viewport = this.viewport.clone({
  9776. scale: 1,
  9777. rotation: totalRotation
  9778. });
  9779. this.reset();
  9780. }
  9781. cancelRendering() {
  9782. if (this.renderTask) {
  9783. this.renderTask.cancel();
  9784. this.renderTask = null;
  9785. }
  9786. this.resume = null;
  9787. }
  9788. _getPageDrawContext() {
  9789. let upscaleFactor = arguments.length > 0 && arguments[0] !== undefined ?
  9790. arguments[0] : 1;
  9791. const canvas = document.createElement("canvas");
  9792. const ctx = canvas.getContext("2d", {
  9793. alpha: false
  9794. });
  9795. const outputScale = new _ui_utils.OutputScale();
  9796. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  9797. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  9798. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0,
  9799. 0
  9800. ] : null;
  9801. return {
  9802. ctx,
  9803. canvas,
  9804. transform
  9805. };
  9806. }
  9807. _convertCanvasToImage(canvas) {
  9808. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9809. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  9810. }
  9811. const reducedCanvas = this._reduceImage(canvas);
  9812. const image = document.createElement("img");
  9813. image.className = "thumbnailImage";
  9814. this._thumbPageCanvas.then(msg => {
  9815. image.setAttribute("aria-label", msg);
  9816. });
  9817. image.style.width = this.canvasWidth + "px";
  9818. image.style.height = this.canvasHeight + "px";
  9819. image.src = reducedCanvas.toDataURL();
  9820. this.image = image;
  9821. this.div.setAttribute("data-loaded", true);
  9822. this.ring.append(image);
  9823. reducedCanvas.width = 0;
  9824. reducedCanvas.height = 0;
  9825. }
  9826. draw() {
  9827. var _this = this;
  9828. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  9829. console.error("Must be in new state before drawing");
  9830. return Promise.resolve();
  9831. }
  9832. const {
  9833. pdfPage
  9834. } = this;
  9835. if (!pdfPage) {
  9836. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  9837. return Promise.reject(new Error("pdfPage is not loaded"));
  9838. }
  9839. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  9840. const finishRenderTask = async function() {
  9841. let error = arguments.length > 0 && arguments[0] !== undefined ?
  9842. arguments[0] : null;
  9843. if (renderTask === _this.renderTask) {
  9844. _this.renderTask = null;
  9845. }
  9846. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9847. return;
  9848. }
  9849. _this.renderingState = _ui_utils.RenderingStates.FINISHED;
  9850. _this._convertCanvasToImage(canvas);
  9851. if (error) {
  9852. throw error;
  9853. }
  9854. };
  9855. const {
  9856. ctx,
  9857. canvas,
  9858. transform
  9859. } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
  9860. const drawViewport = this.viewport.clone({
  9861. scale: DRAW_UPSCALE_FACTOR * this.scale
  9862. });
  9863. const renderContinueCallback = cont => {
  9864. if (!this.renderingQueue.isHighestPriority(this)) {
  9865. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  9866. this.resume = () => {
  9867. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  9868. cont();
  9869. };
  9870. return;
  9871. }
  9872. cont();
  9873. };
  9874. const renderContext = {
  9875. canvasContext: ctx,
  9876. transform,
  9877. viewport: drawViewport,
  9878. optionalContentConfigPromise: this._optionalContentConfigPromise,
  9879. pageColors: this.pageColors
  9880. };
  9881. const renderTask = this.renderTask = pdfPage.render(renderContext);
  9882. renderTask.onContinue = renderContinueCallback;
  9883. const resultPromise = renderTask.promise.then(function() {
  9884. return finishRenderTask(null);
  9885. }, function(error) {
  9886. return finishRenderTask(error);
  9887. });
  9888. resultPromise.finally(() => {
  9889. canvas.width = 0;
  9890. canvas.height = 0;
  9891. const pageCached = this.linkService.isPageCached(this.id);
  9892. if (!pageCached) {
  9893. var _this$pdfPage;
  9894. (_this$pdfPage = this.pdfPage) === null || _this$pdfPage ===
  9895. void 0 ? void 0 : _this$pdfPage.cleanup();
  9896. }
  9897. });
  9898. return resultPromise;
  9899. }
  9900. setImage(pageView) {
  9901. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  9902. return;
  9903. }
  9904. const {
  9905. thumbnailCanvas: canvas,
  9906. pdfPage,
  9907. scale
  9908. } = pageView;
  9909. if (!canvas) {
  9910. return;
  9911. }
  9912. if (!this.pdfPage) {
  9913. this.setPdfPage(pdfPage);
  9914. }
  9915. if (scale < this.scale) {
  9916. return;
  9917. }
  9918. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  9919. this._convertCanvasToImage(canvas);
  9920. }
  9921. _reduceImage(img) {
  9922. const {
  9923. ctx,
  9924. canvas
  9925. } = this._getPageDrawContext();
  9926. if (img.width <= 2 * canvas.width) {
  9927. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas
  9928. .height);
  9929. return canvas;
  9930. }
  9931. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  9932. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  9933. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth,
  9934. reducedHeight);
  9935. while (reducedWidth > img.width || reducedHeight > img.height) {
  9936. reducedWidth >>= 1;
  9937. reducedHeight >>= 1;
  9938. }
  9939. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth,
  9940. reducedHeight);
  9941. while (reducedWidth > 2 * canvas.width) {
  9942. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight,
  9943. 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  9944. reducedWidth >>= 1;
  9945. reducedHeight >>= 1;
  9946. }
  9947. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas
  9948. .width, canvas.height);
  9949. return canvas;
  9950. }
  9951. get _thumbPageTitle() {
  9952. var _this$pageLabel;
  9953. return this.l10n.get("thumb_page_title", {
  9954. page: (_this$pageLabel = this.pageLabel) !== null &&
  9955. _this$pageLabel !== void 0 ? _this$pageLabel : this.id
  9956. });
  9957. }
  9958. get _thumbPageCanvas() {
  9959. var _this$pageLabel2;
  9960. return this.l10n.get("thumb_page_canvas", {
  9961. page: (_this$pageLabel2 = this.pageLabel) !== null &&
  9962. _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
  9963. });
  9964. }
  9965. setPageLabel(label) {
  9966. this.pageLabel = typeof label === "string" ? label : null;
  9967. this._thumbPageTitle.then(msg => {
  9968. this.anchor.title = msg;
  9969. });
  9970. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9971. return;
  9972. }
  9973. this._thumbPageCanvas.then(msg => {
  9974. var _this$image;
  9975. (_this$image = this.image) === null || _this$image === void 0 ?
  9976. void 0 : _this$image.setAttribute("aria-label", msg);
  9977. });
  9978. }
  9979. }
  9980. exports.PDFThumbnailView = PDFThumbnailView;
  9981. /***/
  9982. }),
  9983. /* 29 */
  9984. /***/
  9985. ((__unused_webpack_module, exports, __webpack_require__) => {
  9986. Object.defineProperty(exports, "__esModule", ({
  9987. value: true
  9988. }));
  9989. exports.PDFViewer = exports.PDFSinglePageViewer = void 0;
  9990. var _ui_utils = __webpack_require__(1);
  9991. var _base_viewer = __webpack_require__(30);
  9992. class PDFViewer extends _base_viewer.BaseViewer {}
  9993. exports.PDFViewer = PDFViewer;
  9994. class PDFSinglePageViewer extends _base_viewer.BaseViewer {
  9995. _resetView() {
  9996. super._resetView();
  9997. this._scrollMode = _ui_utils.ScrollMode.PAGE;
  9998. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9999. }
  10000. set scrollMode(mode) {}
  10001. _updateScrollMode() {}
  10002. set spreadMode(mode) {}
  10003. _updateSpreadMode() {}
  10004. }
  10005. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10006. /***/
  10007. }),
  10008. /* 30 */
  10009. /***/
  10010. ((__unused_webpack_module, exports, __webpack_require__) => {
  10011. Object.defineProperty(exports, "__esModule", ({
  10012. value: true
  10013. }));
  10014. exports.PagesCountLimit = exports.PDFPageViewBuffer = exports.BaseViewer = void 0;
  10015. var _pdfjsLib = __webpack_require__(5);
  10016. var _ui_utils = __webpack_require__(1);
  10017. var _annotation_editor_layer_builder = __webpack_require__(31);
  10018. var _annotation_layer_builder = __webpack_require__(33);
  10019. var _l10n_utils = __webpack_require__(32);
  10020. var _pdf_page_view = __webpack_require__(34);
  10021. var _pdf_rendering_queue = __webpack_require__(23);
  10022. var _pdf_link_service = __webpack_require__(3);
  10023. var _struct_tree_layer_builder = __webpack_require__(36);
  10024. var _text_highlighter = __webpack_require__(37);
  10025. var _text_layer_builder = __webpack_require__(38);
  10026. var _xfa_layer_builder = __webpack_require__(39);
  10027. let _Symbol$iterator;
  10028. function _classPrivateMethodInitSpec(obj, privateSet) {
  10029. _checkPrivateRedeclaration(obj, privateSet);
  10030. privateSet.add(obj);
  10031. }
  10032. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  10033. _checkPrivateRedeclaration(obj, privateMap);
  10034. privateMap.set(obj, value);
  10035. }
  10036. function _checkPrivateRedeclaration(obj, privateCollection) {
  10037. if (privateCollection.has(obj)) {
  10038. throw new TypeError(
  10039. "Cannot initialize the same private elements twice on an object");
  10040. }
  10041. }
  10042. function _classPrivateMethodGet(receiver, privateSet, fn) {
  10043. if (!privateSet.has(receiver)) {
  10044. throw new TypeError("attempted to get private field on non-instance");
  10045. }
  10046. return fn;
  10047. }
  10048. function _classPrivateFieldGet(receiver, privateMap) {
  10049. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  10050. return _classApplyDescriptorGet(receiver, descriptor);
  10051. }
  10052. function _classApplyDescriptorGet(receiver, descriptor) {
  10053. if (descriptor.get) {
  10054. return descriptor.get.call(receiver);
  10055. }
  10056. return descriptor.value;
  10057. }
  10058. function _classPrivateFieldSet(receiver, privateMap, value) {
  10059. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  10060. _classApplyDescriptorSet(receiver, descriptor, value);
  10061. return value;
  10062. }
  10063. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  10064. if (!privateMap.has(receiver)) {
  10065. throw new TypeError("attempted to " + action + " private field on non-instance");
  10066. }
  10067. return privateMap.get(receiver);
  10068. }
  10069. function _classApplyDescriptorSet(receiver, descriptor, value) {
  10070. if (descriptor.set) {
  10071. descriptor.set.call(receiver, value);
  10072. } else {
  10073. if (!descriptor.writable) {
  10074. throw new TypeError("attempted to set read only private field");
  10075. }
  10076. descriptor.value = value;
  10077. }
  10078. }
  10079. const DEFAULT_CACHE_SIZE = 10;
  10080. const ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  10081. const PagesCountLimit = {
  10082. FORCE_SCROLL_MODE_PAGE: 15000,
  10083. FORCE_LAZY_PAGE_INIT: 7500,
  10084. PAUSE_EAGER_PAGE_INIT: 250
  10085. };
  10086. exports.PagesCountLimit = PagesCountLimit;
  10087. function isValidAnnotationEditorMode(mode) {
  10088. return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !==
  10089. _pdfjsLib.AnnotationEditorType.DISABLE;
  10090. }
  10091. var _buf = /*#__PURE__*/ new WeakMap();
  10092. var _size = /*#__PURE__*/ new WeakMap();
  10093. var _destroyFirstView = /*#__PURE__*/ new WeakSet();
  10094. _Symbol$iterator = Symbol.iterator;
  10095. class PDFPageViewBuffer {
  10096. constructor(size) {
  10097. _classPrivateMethodInitSpec(this, _destroyFirstView);
  10098. _classPrivateFieldInitSpec(this, _buf, {
  10099. writable: true,
  10100. value: new Set()
  10101. });
  10102. _classPrivateFieldInitSpec(this, _size, {
  10103. writable: true,
  10104. value: 0
  10105. });
  10106. _classPrivateFieldSet(this, _size, size);
  10107. }
  10108. push(view) {
  10109. const buf = _classPrivateFieldGet(this, _buf);
  10110. if (buf.has(view)) {
  10111. buf.delete(view);
  10112. }
  10113. buf.add(view);
  10114. if (buf.size > _classPrivateFieldGet(this, _size)) {
  10115. _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(
  10116. this);
  10117. }
  10118. }
  10119. resize(newSize) {
  10120. let idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  10121. 1] : null;
  10122. _classPrivateFieldSet(this, _size, newSize);
  10123. const buf = _classPrivateFieldGet(this, _buf);
  10124. if (idsToKeep) {
  10125. const ii = buf.size;
  10126. let i = 1;
  10127. for (const view of buf) {
  10128. if (idsToKeep.has(view.id)) {
  10129. buf.delete(view);
  10130. buf.add(view);
  10131. }
  10132. if (++i > ii) {
  10133. break;
  10134. }
  10135. }
  10136. }
  10137. while (buf.size > _classPrivateFieldGet(this, _size)) {
  10138. _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(
  10139. this);
  10140. }
  10141. }
  10142. has(view) {
  10143. return _classPrivateFieldGet(this, _buf).has(view);
  10144. }
  10145. [_Symbol$iterator]() {
  10146. return _classPrivateFieldGet(this, _buf).keys();
  10147. }
  10148. }
  10149. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  10150. function _destroyFirstView2() {
  10151. const firstView = _classPrivateFieldGet(this, _buf).keys().next().value;
  10152. firstView === null || firstView === void 0 ? void 0 : firstView.destroy();
  10153. _classPrivateFieldGet(this, _buf).delete(firstView);
  10154. }
  10155. var _buffer = /*#__PURE__*/ new WeakMap();
  10156. var _annotationEditorMode = /*#__PURE__*/ new WeakMap();
  10157. var _annotationEditorUIManager = /*#__PURE__*/ new WeakMap();
  10158. var _annotationMode = /*#__PURE__*/ new WeakMap();
  10159. var _enablePermissions = /*#__PURE__*/ new WeakMap();
  10160. var _previousContainerHeight = /*#__PURE__*/ new WeakMap();
  10161. var _scrollModePageState = /*#__PURE__*/ new WeakMap();
  10162. var _onVisibilityChange = /*#__PURE__*/ new WeakMap();
  10163. var _initializePermissions = /*#__PURE__*/ new WeakSet();
  10164. var _onePageRenderedOrForceFetch = /*#__PURE__*/ new WeakSet();
  10165. var _ensurePageViewVisible = /*#__PURE__*/ new WeakSet();
  10166. var _scrollIntoView = /*#__PURE__*/ new WeakSet();
  10167. var _isSameScale = /*#__PURE__*/ new WeakSet();
  10168. var _resetCurrentPageView = /*#__PURE__*/ new WeakSet();
  10169. var _ensurePdfPageLoaded = /*#__PURE__*/ new WeakSet();
  10170. var _getScrollAhead = /*#__PURE__*/ new WeakSet();
  10171. var _toggleLoadingIconSpinner = /*#__PURE__*/ new WeakSet();
  10172. class BaseViewer {
  10173. constructor(options) {
  10174. var _this$container, _this$viewer, _options$textLayerMod, _options$annotationMo,
  10175. _options$annotationEd;
  10176. _classPrivateMethodInitSpec(this, _toggleLoadingIconSpinner);
  10177. _classPrivateMethodInitSpec(this, _getScrollAhead);
  10178. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  10179. _classPrivateMethodInitSpec(this, _resetCurrentPageView);
  10180. _classPrivateMethodInitSpec(this, _isSameScale);
  10181. _classPrivateMethodInitSpec(this, _scrollIntoView);
  10182. _classPrivateMethodInitSpec(this, _ensurePageViewVisible);
  10183. _classPrivateMethodInitSpec(this, _onePageRenderedOrForceFetch);
  10184. _classPrivateMethodInitSpec(this, _initializePermissions);
  10185. _classPrivateFieldInitSpec(this, _buffer, {
  10186. writable: true,
  10187. value: null
  10188. });
  10189. _classPrivateFieldInitSpec(this, _annotationEditorMode, {
  10190. writable: true,
  10191. value: _pdfjsLib.AnnotationEditorType.DISABLE
  10192. });
  10193. _classPrivateFieldInitSpec(this, _annotationEditorUIManager, {
  10194. writable: true,
  10195. value: null
  10196. });
  10197. _classPrivateFieldInitSpec(this, _annotationMode, {
  10198. writable: true,
  10199. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  10200. });
  10201. _classPrivateFieldInitSpec(this, _enablePermissions, {
  10202. writable: true,
  10203. value: false
  10204. });
  10205. _classPrivateFieldInitSpec(this, _previousContainerHeight, {
  10206. writable: true,
  10207. value: 0
  10208. });
  10209. _classPrivateFieldInitSpec(this, _scrollModePageState, {
  10210. writable: true,
  10211. value: null
  10212. });
  10213. _classPrivateFieldInitSpec(this, _onVisibilityChange, {
  10214. writable: true,
  10215. value: null
  10216. });
  10217. if (this.constructor === BaseViewer) {
  10218. throw new Error("Cannot initialize BaseViewer.");
  10219. }
  10220. const viewerVersion = '2.16.105';
  10221. if (_pdfjsLib.version !== viewerVersion) {
  10222. throw new Error(
  10223. `The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`
  10224. );
  10225. }
  10226. this.container = options.container;
  10227. this.viewer = options.viewer || options.container.firstElementChild;
  10228. if (!(((_this$container = this.container) === null || _this$container ===
  10229. void 0 ? void 0 : _this$container.tagName.toUpperCase()) ===
  10230. "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer ===
  10231. void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  10232. throw new Error("Invalid `container` and/or `viewer` option.");
  10233. }
  10234. if (this.container.offsetParent && getComputedStyle(this.container).position !==
  10235. "absolute") {
  10236. throw new Error("The `container` must be absolutely positioned.");
  10237. }
  10238. this.eventBus = options.eventBus;
  10239. this.linkService = options.linkService || new _pdf_link_service
  10240. .SimpleLinkService();
  10241. this.downloadManager = options.downloadManager || null;
  10242. this.findController = options.findController || null;
  10243. this._scriptingManager = options.scriptingManager || null;
  10244. this.removePageBorders = options.removePageBorders || false;
  10245. this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null &&
  10246. _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils
  10247. .TextLayerMode.ENABLE;
  10248. _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options
  10249. .annotationMode) !== null && _options$annotationMo !== void 0 ?
  10250. _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  10251. _classPrivateFieldSet(this, _annotationEditorMode, (_options$annotationEd =
  10252. options.annotationEditorMode) !== null && _options$annotationEd !==
  10253. void 0 ? _options$annotationEd : _pdfjsLib.AnnotationEditorType.DISABLE);
  10254. this.imageResourcesPath = options.imageResourcesPath || "";
  10255. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10256. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10257. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10258. this.maxCanvasPixels = options.maxCanvasPixels;
  10259. this.l10n = options.l10n || _l10n_utils.NullL10n;
  10260. _classPrivateFieldSet(this, _enablePermissions, options.enablePermissions ||
  10261. false);
  10262. this.pageColors = options.pageColors || null;
  10263. if (this.pageColors && !(CSS.supports("color", this.pageColors.background) &&
  10264. CSS.supports("color", this.pageColors.foreground))) {
  10265. if (this.pageColors.background || this.pageColors.foreground) {
  10266. console.warn(
  10267. "BaseViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."
  10268. );
  10269. }
  10270. this.pageColors = null;
  10271. }
  10272. this.defaultRenderingQueue = !options.renderingQueue;
  10273. if (this.defaultRenderingQueue) {
  10274. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10275. this.renderingQueue.setViewer(this);
  10276. } else {
  10277. this.renderingQueue = options.renderingQueue;
  10278. }
  10279. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate
  10280. .bind(this));
  10281. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10282. this._onBeforeDraw = this._onAfterDraw = null;
  10283. this._resetView();
  10284. if (this.removePageBorders) {
  10285. this.viewer.classList.add("removePageBorders");
  10286. }
  10287. this.updateContainerHeightCss();
  10288. }
  10289. get pagesCount() {
  10290. return this._pages.length;
  10291. }
  10292. getPageView(index) {
  10293. return this._pages[index];
  10294. }
  10295. get pageViewsReady() {
  10296. if (!this._pagesCapability.settled) {
  10297. return false;
  10298. }
  10299. return this._pages.every(function(pageView) {
  10300. return pageView === null || pageView === void 0 ? void 0 : pageView
  10301. .pdfPage;
  10302. });
  10303. }
  10304. get renderForms() {
  10305. return _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode
  10306. .ENABLE_FORMS;
  10307. }
  10308. get enableScripting() {
  10309. return !!this._scriptingManager;
  10310. }
  10311. get currentPageNumber() {
  10312. return this._currentPageNumber;
  10313. }
  10314. set currentPageNumber(val) {
  10315. if (!Number.isInteger(val)) {
  10316. throw new Error("Invalid page number.");
  10317. }
  10318. if (!this.pdfDocument) {
  10319. return;
  10320. }
  10321. if (!this._setCurrentPageNumber(val, true)) {
  10322. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  10323. }
  10324. }
  10325. _setCurrentPageNumber(val) {
  10326. var _this$_pageLabels, _this$_pageLabels2;
  10327. let resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ?
  10328. arguments[1] : false;
  10329. if (this._currentPageNumber === val) {
  10330. if (resetCurrentPageView) {
  10331. _classPrivateMethodGet(this, _resetCurrentPageView,
  10332. _resetCurrentPageView2).call(this);
  10333. }
  10334. return true;
  10335. }
  10336. if (!(0 < val && val <= this.pagesCount)) {
  10337. return false;
  10338. }
  10339. const previous = this._currentPageNumber;
  10340. this._currentPageNumber = val;
  10341. this.eventBus.dispatch("pagechanging", {
  10342. source: this,
  10343. pageNumber: val,
  10344. pageLabel: (_this$_pageLabels = (_this$_pageLabels2 = this
  10345. ._pageLabels) === null || _this$_pageLabels2 ===
  10346. void 0 ? void 0 : _this$_pageLabels2[val - 1]) !== null &&
  10347. _this$_pageLabels !== void 0 ? _this$_pageLabels : null,
  10348. previous
  10349. });
  10350. if (resetCurrentPageView) {
  10351. _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2)
  10352. .call(this);
  10353. }
  10354. return true;
  10355. }
  10356. get currentPageLabel() {
  10357. var _this$_pageLabels3, _this$_pageLabels4;
  10358. return (_this$_pageLabels3 = (_this$_pageLabels4 = this._pageLabels) === null ||
  10359. _this$_pageLabels4 === void 0 ? void 0 : _this$_pageLabels4[this
  10360. ._currentPageNumber - 1]) !== null && _this$_pageLabels3 !==
  10361. void 0 ? _this$_pageLabels3 : null;
  10362. }
  10363. set currentPageLabel(val) {
  10364. if (!this.pdfDocument) {
  10365. return;
  10366. }
  10367. let page = val | 0;
  10368. if (this._pageLabels) {
  10369. const i = this._pageLabels.indexOf(val);
  10370. if (i >= 0) {
  10371. page = i + 1;
  10372. }
  10373. }
  10374. if (!this._setCurrentPageNumber(page, true)) {
  10375. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  10376. }
  10377. }
  10378. get currentScale() {
  10379. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale :
  10380. _ui_utils.DEFAULT_SCALE;
  10381. }
  10382. set currentScale(val) {
  10383. if (isNaN(val)) {
  10384. throw new Error("Invalid numeric scale.");
  10385. }
  10386. if (!this.pdfDocument) {
  10387. return;
  10388. }
  10389. this._setScale(val, false);
  10390. }
  10391. get currentScaleValue() {
  10392. return this._currentScaleValue;
  10393. }
  10394. set currentScaleValue(val) {
  10395. if (!this.pdfDocument) {
  10396. return;
  10397. }
  10398. this._setScale(val, false);
  10399. }
  10400. get pagesRotation() {
  10401. return this._pagesRotation;
  10402. }
  10403. set pagesRotation(rotation) {
  10404. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10405. throw new Error("Invalid pages rotation angle.");
  10406. }
  10407. if (!this.pdfDocument) {
  10408. return;
  10409. }
  10410. rotation %= 360;
  10411. if (rotation < 0) {
  10412. rotation += 360;
  10413. }
  10414. if (this._pagesRotation === rotation) {
  10415. return;
  10416. }
  10417. this._pagesRotation = rotation;
  10418. const pageNumber = this._currentPageNumber;
  10419. const updateArgs = {
  10420. rotation
  10421. };
  10422. for (const pageView of this._pages) {
  10423. pageView.update(updateArgs);
  10424. }
  10425. if (this._currentScaleValue) {
  10426. this._setScale(this._currentScaleValue, true);
  10427. }
  10428. this.eventBus.dispatch("rotationchanging", {
  10429. source: this,
  10430. pagesRotation: rotation,
  10431. pageNumber
  10432. });
  10433. if (this.defaultRenderingQueue) {
  10434. this.update();
  10435. }
  10436. }
  10437. get firstPagePromise() {
  10438. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10439. }
  10440. get onePageRendered() {
  10441. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10442. }
  10443. get pagesPromise() {
  10444. return this.pdfDocument ? this._pagesCapability.promise : null;
  10445. }
  10446. setDocument(pdfDocument) {
  10447. if (this.pdfDocument) {
  10448. this.eventBus.dispatch("pagesdestroy", {
  10449. source: this
  10450. });
  10451. this._cancelRendering();
  10452. this._resetView();
  10453. if (this.findController) {
  10454. this.findController.setDocument(null);
  10455. }
  10456. if (this._scriptingManager) {
  10457. this._scriptingManager.setDocument(null);
  10458. }
  10459. if (_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  10460. _classPrivateFieldGet(this, _annotationEditorUIManager).destroy();
  10461. _classPrivateFieldSet(this, _annotationEditorUIManager, null);
  10462. }
  10463. }
  10464. this.pdfDocument = pdfDocument;
  10465. if (!pdfDocument) {
  10466. return;
  10467. }
  10468. const isPureXfa = pdfDocument.isPureXfa;
  10469. const pagesCount = pdfDocument.numPages;
  10470. const firstPagePromise = pdfDocument.getPage(1);
  10471. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10472. const permissionsPromise = _classPrivateFieldGet(this, _enablePermissions) ?
  10473. pdfDocument.getPermissions() : Promise.resolve();
  10474. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  10475. console.warn(
  10476. "Forcing PAGE-scrolling for performance reasons, given the length of the document."
  10477. );
  10478. const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  10479. this.eventBus.dispatch("scrollmodechanged", {
  10480. source: this,
  10481. mode
  10482. });
  10483. }
  10484. this._pagesCapability.promise.then(() => {
  10485. this.eventBus.dispatch("pagesloaded", {
  10486. source: this,
  10487. pagesCount
  10488. });
  10489. }, () => {});
  10490. this._onBeforeDraw = evt => {
  10491. const pageView = this._pages[evt.pageNumber - 1];
  10492. if (!pageView) {
  10493. return;
  10494. }
  10495. _classPrivateFieldGet(this, _buffer).push(pageView);
  10496. };
  10497. this.eventBus._on("pagerender", this._onBeforeDraw);
  10498. this._onAfterDraw = evt => {
  10499. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  10500. return;
  10501. }
  10502. this._onePageRenderedCapability.resolve({
  10503. timestamp: evt.timestamp
  10504. });
  10505. this.eventBus._off("pagerendered", this._onAfterDraw);
  10506. this._onAfterDraw = null;
  10507. if (_classPrivateFieldGet(this, _onVisibilityChange)) {
  10508. document.removeEventListener("visibilitychange",
  10509. _classPrivateFieldGet(this, _onVisibilityChange));
  10510. _classPrivateFieldSet(this, _onVisibilityChange, null);
  10511. }
  10512. };
  10513. this.eventBus._on("pagerendered", this._onAfterDraw);
  10514. Promise.all([firstPagePromise, permissionsPromise]).then(_ref => {
  10515. let [firstPdfPage, permissions] = _ref;
  10516. if (pdfDocument !== this.pdfDocument) {
  10517. return;
  10518. }
  10519. this._firstPageCapability.resolve(firstPdfPage);
  10520. this._optionalContentConfigPromise = optionalContentConfigPromise;
  10521. const {
  10522. annotationEditorMode,
  10523. annotationMode,
  10524. textLayerMode
  10525. } = _classPrivateMethodGet(this, _initializePermissions,
  10526. _initializePermissions2).call(this, permissions);
  10527. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType
  10528. .DISABLE) {
  10529. const mode = annotationEditorMode;
  10530. if (isPureXfa) {
  10531. console.warn("Warning: XFA-editing is not implemented.");
  10532. } else if (isValidAnnotationEditorMode(mode)) {
  10533. _classPrivateFieldSet(this, _annotationEditorUIManager,
  10534. new _pdfjsLib.AnnotationEditorUIManager(this
  10535. .container, this.eventBus));
  10536. if (mode !== _pdfjsLib.AnnotationEditorType.NONE) {
  10537. _classPrivateFieldGet(this, _annotationEditorUIManager)
  10538. .updateMode(mode);
  10539. }
  10540. } else {
  10541. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  10542. }
  10543. }
  10544. const viewerElement = this._scrollMode === _ui_utils.ScrollMode
  10545. .PAGE ? null : this.viewer;
  10546. const scale = this.currentScale;
  10547. const viewport = firstPdfPage.getViewport({
  10548. scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  10549. });
  10550. const textLayerFactory = textLayerMode !== _ui_utils.TextLayerMode
  10551. .DISABLE && !isPureXfa ? this : null;
  10552. const annotationLayerFactory = annotationMode !== _pdfjsLib
  10553. .AnnotationMode.DISABLE ? this : null;
  10554. const xfaLayerFactory = isPureXfa ? this : null;
  10555. const annotationEditorLayerFactory = _classPrivateFieldGet(this,
  10556. _annotationEditorUIManager) ? this : null;
  10557. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10558. const pageView = new _pdf_page_view.PDFPageView({
  10559. container: viewerElement,
  10560. eventBus: this.eventBus,
  10561. id: pageNum,
  10562. scale,
  10563. defaultViewport: viewport.clone(),
  10564. optionalContentConfigPromise,
  10565. renderingQueue: this.renderingQueue,
  10566. textLayerFactory,
  10567. textLayerMode,
  10568. annotationLayerFactory,
  10569. annotationMode,
  10570. xfaLayerFactory,
  10571. annotationEditorLayerFactory,
  10572. textHighlighterFactory: this,
  10573. structTreeLayerFactory: this,
  10574. imageResourcesPath: this.imageResourcesPath,
  10575. renderer: this.renderer,
  10576. useOnlyCssZoom: this.useOnlyCssZoom,
  10577. maxCanvasPixels: this.maxCanvasPixels,
  10578. pageColors: this.pageColors,
  10579. l10n: this.l10n
  10580. });
  10581. this._pages.push(pageView);
  10582. }
  10583. const firstPageView = this._pages[0];
  10584. if (firstPageView) {
  10585. firstPageView.setPdfPage(firstPdfPage);
  10586. this.linkService.cachePageRef(1, firstPdfPage.ref);
  10587. }
  10588. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  10589. _classPrivateMethodGet(this, _ensurePageViewVisible,
  10590. _ensurePageViewVisible2).call(this);
  10591. } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10592. this._updateSpreadMode();
  10593. }
  10594. _classPrivateMethodGet(this, _onePageRenderedOrForceFetch,
  10595. _onePageRenderedOrForceFetch2).call(this).then(async () => {
  10596. if (this.findController) {
  10597. this.findController.setDocument(pdfDocument);
  10598. }
  10599. if (this._scriptingManager) {
  10600. this._scriptingManager.setDocument(pdfDocument);
  10601. }
  10602. if (_classPrivateFieldGet(this,
  10603. _annotationEditorUIManager)) {
  10604. this.eventBus.dispatch(
  10605. "annotationeditormodechanged", {
  10606. source: this,
  10607. mode: _classPrivateFieldGet(this,
  10608. _annotationEditorMode)
  10609. });
  10610. }
  10611. if (pdfDocument.loadingParams.disableAutoFetch ||
  10612. pagesCount > PagesCountLimit
  10613. .FORCE_LAZY_PAGE_INIT) {
  10614. this._pagesCapability.resolve();
  10615. return;
  10616. }
  10617. let getPagesLeft = pagesCount - 1;
  10618. if (getPagesLeft <= 0) {
  10619. this._pagesCapability.resolve();
  10620. return;
  10621. }
  10622. for (let pageNum = 2; pageNum <= pagesCount; ++
  10623. pageNum) {
  10624. const promise = pdfDocument.getPage(pageNum)
  10625. .then(pdfPage => {
  10626. const pageView = this._pages[
  10627. pageNum - 1];
  10628. if (!pageView.pdfPage) {
  10629. pageView.setPdfPage(pdfPage);
  10630. }
  10631. this.linkService.cachePageRef(
  10632. pageNum, pdfPage.ref);
  10633. if (--getPagesLeft === 0) {
  10634. this._pagesCapability.resolve();
  10635. }
  10636. }, reason => {
  10637. console.error(
  10638. `Unable to get page ${pageNum} to initialize viewer`,
  10639. reason);
  10640. if (--getPagesLeft === 0) {
  10641. this._pagesCapability.resolve();
  10642. }
  10643. });
  10644. if (pageNum % PagesCountLimit
  10645. .PAUSE_EAGER_PAGE_INIT === 0) {
  10646. await promise;
  10647. }
  10648. }
  10649. });
  10650. this.eventBus.dispatch("pagesinit", {
  10651. source: this
  10652. });
  10653. pdfDocument.getMetadata().then(_ref2 => {
  10654. let {
  10655. info
  10656. } = _ref2;
  10657. if (pdfDocument !== this.pdfDocument) {
  10658. return;
  10659. }
  10660. if (info.Language) {
  10661. this.viewer.lang = info.Language;
  10662. }
  10663. });
  10664. if (this.defaultRenderingQueue) {
  10665. this.update();
  10666. }
  10667. }).catch(reason => {
  10668. console.error("Unable to initialize viewer", reason);
  10669. this._pagesCapability.reject(reason);
  10670. });
  10671. }
  10672. setPageLabels(labels) {
  10673. if (!this.pdfDocument) {
  10674. return;
  10675. }
  10676. if (!labels) {
  10677. this._pageLabels = null;
  10678. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels
  10679. .length)) {
  10680. this._pageLabels = null;
  10681. console.error(`setPageLabels: Invalid page labels.`);
  10682. } else {
  10683. this._pageLabels = labels;
  10684. }
  10685. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  10686. var _this$_pageLabels$i, _this$_pageLabels5;
  10687. this._pages[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels5 =
  10688. this._pageLabels) === null || _this$_pageLabels5 ===
  10689. void 0 ? void 0 : _this$_pageLabels5[i]) !== null &&
  10690. _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null);
  10691. }
  10692. }
  10693. _resetView() {
  10694. this._pages = [];
  10695. this._currentPageNumber = 1;
  10696. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10697. this._currentScaleValue = null;
  10698. this._pageLabels = null;
  10699. _classPrivateFieldSet(this, _buffer, new PDFPageViewBuffer(DEFAULT_CACHE_SIZE));
  10700. this._location = null;
  10701. this._pagesRotation = 0;
  10702. this._optionalContentConfigPromise = null;
  10703. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  10704. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  10705. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10706. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10707. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  10708. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10709. _classPrivateFieldSet(this, _scrollModePageState, {
  10710. previousPageNumber: 1,
  10711. scrollDown: true,
  10712. pages: []
  10713. });
  10714. if (this._onBeforeDraw) {
  10715. this.eventBus._off("pagerender", this._onBeforeDraw);
  10716. this._onBeforeDraw = null;
  10717. }
  10718. if (this._onAfterDraw) {
  10719. this.eventBus._off("pagerendered", this._onAfterDraw);
  10720. this._onAfterDraw = null;
  10721. }
  10722. if (_classPrivateFieldGet(this, _onVisibilityChange)) {
  10723. document.removeEventListener("visibilitychange", _classPrivateFieldGet(this,
  10724. _onVisibilityChange));
  10725. _classPrivateFieldSet(this, _onVisibilityChange, null);
  10726. }
  10727. this.viewer.textContent = "";
  10728. this._updateScrollMode();
  10729. this.viewer.removeAttribute("lang");
  10730. this.viewer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  10731. }
  10732. _scrollUpdate() {
  10733. if (this.pagesCount === 0) {
  10734. return;
  10735. }
  10736. this.update();
  10737. }
  10738. _setScaleUpdatePages(newScale, newValue) {
  10739. let noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  10740. 2] : false;
  10741. let preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] :
  10742. false;
  10743. this._currentScaleValue = newValue.toString();
  10744. if (_classPrivateMethodGet(this, _isSameScale, _isSameScale2).call(this,
  10745. newScale)) {
  10746. if (preset) {
  10747. this.eventBus.dispatch("scalechanging", {
  10748. source: this,
  10749. scale: newScale,
  10750. presetValue: newValue
  10751. });
  10752. }
  10753. return;
  10754. }
  10755. _ui_utils.docStyle.setProperty("--scale-factor", newScale * _pdfjsLib
  10756. .PixelsPerInch.PDF_TO_CSS_UNITS);
  10757. const updateArgs = {
  10758. scale: newScale
  10759. };
  10760. for (const pageView of this._pages) {
  10761. pageView.update(updateArgs);
  10762. }
  10763. this._currentScale = newScale;
  10764. if (!noScroll) {
  10765. let page = this._currentPageNumber,
  10766. dest;
  10767. if (this._location && !(this.isInPresentationMode || this
  10768. .isChangingPresentationMode)) {
  10769. page = this._location.pageNumber;
  10770. dest = [null, {
  10771. name: "XYZ"
  10772. }, this._location.left, this._location.top, null];
  10773. }
  10774. this.scrollPageIntoView({
  10775. pageNumber: page,
  10776. destArray: dest,
  10777. allowNegativeOffset: true
  10778. });
  10779. }
  10780. this.eventBus.dispatch("scalechanging", {
  10781. source: this,
  10782. scale: newScale,
  10783. presetValue: preset ? newValue : undefined
  10784. });
  10785. if (this.defaultRenderingQueue) {
  10786. this.update();
  10787. }
  10788. this.updateContainerHeightCss();
  10789. }
  10790. get _pageWidthScaleFactor() {
  10791. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !==
  10792. _ui_utils.ScrollMode.HORIZONTAL) {
  10793. return 2;
  10794. }
  10795. return 1;
  10796. }
  10797. _setScale(value) {
  10798. let noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  10799. 1] : false;
  10800. let scale = parseFloat(value);
  10801. if (scale > 0) {
  10802. this._setScaleUpdatePages(scale, value, noScroll, false);
  10803. } else {
  10804. const currentPage = this._pages[this._currentPageNumber - 1];
  10805. if (!currentPage) {
  10806. return;
  10807. }
  10808. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  10809. vPadding = _ui_utils.VERTICAL_PADDING;
  10810. if (this.isInPresentationMode) {
  10811. hPadding = vPadding = 4;
  10812. } else if (this.removePageBorders) {
  10813. hPadding = vPadding = 0;
  10814. } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
  10815. [hPadding, vPadding] = [vPadding, hPadding];
  10816. }
  10817. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage
  10818. .width * currentPage.scale / this._pageWidthScaleFactor;
  10819. const pageHeightScale = (this.container.clientHeight - vPadding) /
  10820. currentPage.height * currentPage.scale;
  10821. switch (value) {
  10822. case "page-actual":
  10823. scale = 1;
  10824. break;
  10825. case "page-width":
  10826. scale = pageWidthScale;
  10827. break;
  10828. case "page-height":
  10829. scale = pageHeightScale;
  10830. break;
  10831. case "page-fit":
  10832. scale = Math.min(pageWidthScale, pageHeightScale);
  10833. break;
  10834. case "auto":
  10835. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(
  10836. currentPage) ? pageWidthScale : Math.min(pageHeightScale,
  10837. pageWidthScale);
  10838. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10839. break;
  10840. default:
  10841. console.error(`_setScale: "${value}" is an unknown zoom value.`);
  10842. return;
  10843. }
  10844. this._setScaleUpdatePages(scale, value, noScroll, true);
  10845. }
  10846. }
  10847. pageLabelToPageNumber(label) {
  10848. if (!this._pageLabels) {
  10849. return null;
  10850. }
  10851. const i = this._pageLabels.indexOf(label);
  10852. if (i < 0) {
  10853. return null;
  10854. }
  10855. return i + 1;
  10856. }
  10857. scrollPageIntoView(_ref3) {
  10858. let {
  10859. pageNumber,
  10860. destArray = null,
  10861. allowNegativeOffset = false,
  10862. ignoreDestinationZoom = false
  10863. } = _ref3;
  10864. if (!this.pdfDocument) {
  10865. return;
  10866. }
  10867. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  10868. if (!pageView) {
  10869. console.error(
  10870. `scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`
  10871. );
  10872. return;
  10873. }
  10874. if (this.isInPresentationMode || !destArray) {
  10875. this._setCurrentPageNumber(pageNumber, true);
  10876. return;
  10877. }
  10878. let x = 0,
  10879. y = 0;
  10880. let width = 0,
  10881. height = 0,
  10882. widthScale,
  10883. heightScale;
  10884. const changeOrientation = pageView.rotation % 180 !== 0;
  10885. const pageWidth = (changeOrientation ? pageView.height : pageView.width) /
  10886. pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10887. const pageHeight = (changeOrientation ? pageView.width : pageView.height) /
  10888. pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10889. let scale = 0;
  10890. switch (destArray[1].name) {
  10891. case "XYZ":
  10892. x = destArray[2];
  10893. y = destArray[3];
  10894. scale = destArray[4];
  10895. x = x !== null ? x : 0;
  10896. y = y !== null ? y : pageHeight;
  10897. break;
  10898. case "Fit":
  10899. case "FitB":
  10900. scale = "page-fit";
  10901. break;
  10902. case "FitH":
  10903. case "FitBH":
  10904. y = destArray[2];
  10905. scale = "page-width";
  10906. if (y === null && this._location) {
  10907. x = this._location.left;
  10908. y = this._location.top;
  10909. } else if (typeof y !== "number" || y < 0) {
  10910. y = pageHeight;
  10911. }
  10912. break;
  10913. case "FitV":
  10914. case "FitBV":
  10915. x = destArray[2];
  10916. width = pageWidth;
  10917. height = pageHeight;
  10918. scale = "page-height";
  10919. break;
  10920. case "FitR":
  10921. x = destArray[2];
  10922. y = destArray[3];
  10923. width = destArray[4] - x;
  10924. height = destArray[5] - y;
  10925. const hPadding = this.removePageBorders ? 0 : _ui_utils
  10926. .SCROLLBAR_PADDING;
  10927. const vPadding = this.removePageBorders ? 0 : _ui_utils
  10928. .VERTICAL_PADDING;
  10929. widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib
  10930. .PixelsPerInch.PDF_TO_CSS_UNITS;
  10931. heightScale = (this.container.clientHeight - vPadding) / height /
  10932. _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10933. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10934. break;
  10935. default:
  10936. console.error(
  10937. `scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`
  10938. );
  10939. return;
  10940. }
  10941. if (!ignoreDestinationZoom) {
  10942. if (scale && scale !== this._currentScale) {
  10943. this.currentScaleValue = scale;
  10944. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10945. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10946. }
  10947. }
  10948. if (scale === "page-fit" && !destArray[4]) {
  10949. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this,
  10950. pageView);
  10951. return;
  10952. }
  10953. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView
  10954. .viewport.convertToViewportPoint(x + width, y + height)
  10955. ];
  10956. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10957. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10958. if (!allowNegativeOffset) {
  10959. left = Math.max(left, 0);
  10960. top = Math.max(top, 0);
  10961. }
  10962. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this,
  10963. pageView, {
  10964. left,
  10965. top
  10966. });
  10967. }
  10968. _updateLocation(firstPage) {
  10969. const currentScale = this._currentScale;
  10970. const currentScaleValue = this._currentScaleValue;
  10971. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ?
  10972. Math.round(currentScale * 10000) / 100 : currentScaleValue;
  10973. const pageNumber = firstPage.id;
  10974. const currentPageView = this._pages[pageNumber - 1];
  10975. const container = this.container;
  10976. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x,
  10977. container.scrollTop - firstPage.y);
  10978. const intLeft = Math.round(topLeft[0]);
  10979. const intTop = Math.round(topLeft[1]);
  10980. let pdfOpenParams = `#page=${pageNumber}`;
  10981. if (!this.isInPresentationMode) {
  10982. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  10983. }
  10984. this._location = {
  10985. pageNumber,
  10986. scale: normalizedScaleValue,
  10987. top: intTop,
  10988. left: intLeft,
  10989. rotation: this._pagesRotation,
  10990. pdfOpenParams
  10991. };
  10992. }
  10993. update() {
  10994. const visible = this._getVisiblePages();
  10995. const visiblePages = visible.views,
  10996. numVisiblePages = visiblePages.length;
  10997. if (numVisiblePages === 0) {
  10998. return;
  10999. }
  11000. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11001. _classPrivateFieldGet(this, _buffer).resize(newCacheSize, visible.ids);
  11002. this.renderingQueue.renderHighestPriority(visible);
  11003. const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this
  11004. ._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode ===
  11005. _ui_utils.ScrollMode.VERTICAL);
  11006. const currentId = this._currentPageNumber;
  11007. let stillFullyVisible = false;
  11008. for (const page of visiblePages) {
  11009. if (page.percent < 100) {
  11010. break;
  11011. }
  11012. if (page.id === currentId && isSimpleLayout) {
  11013. stillFullyVisible = true;
  11014. break;
  11015. }
  11016. }
  11017. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  11018. this._updateLocation(visible.first);
  11019. this.eventBus.dispatch("updateviewarea", {
  11020. source: this,
  11021. location: this._location
  11022. });
  11023. }
  11024. containsElement(element) {
  11025. return this.container.contains(element);
  11026. }
  11027. focus() {
  11028. this.container.focus();
  11029. }
  11030. get _isContainerRtl() {
  11031. return getComputedStyle(this.container).direction === "rtl";
  11032. }
  11033. get isInPresentationMode() {
  11034. return this.presentationModeState === _ui_utils.PresentationModeState
  11035. .FULLSCREEN;
  11036. }
  11037. get isChangingPresentationMode() {
  11038. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11039. }
  11040. get isHorizontalScrollbarEnabled() {
  11041. return this.isInPresentationMode ? false : this.container.scrollWidth > this
  11042. .container.clientWidth;
  11043. }
  11044. get isVerticalScrollbarEnabled() {
  11045. return this.isInPresentationMode ? false : this.container.scrollHeight > this
  11046. .container.clientHeight;
  11047. }
  11048. _getVisiblePages() {
  11049. const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ?
  11050. _classPrivateFieldGet(this, _scrollModePageState).pages : this._pages,
  11051. horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
  11052. rtl = horizontal && this._isContainerRtl;
  11053. return (0, _ui_utils.getVisibleElements)({
  11054. scrollEl: this.container,
  11055. views,
  11056. sortByVisibility: true,
  11057. horizontal,
  11058. rtl
  11059. });
  11060. }
  11061. isPageVisible(pageNumber) {
  11062. if (!this.pdfDocument) {
  11063. return false;
  11064. }
  11065. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this
  11066. .pagesCount)) {
  11067. console.error(`isPageVisible: "${pageNumber}" is not a valid page.`);
  11068. return false;
  11069. }
  11070. return this._getVisiblePages().ids.has(pageNumber);
  11071. }
  11072. isPageCached(pageNumber) {
  11073. if (!this.pdfDocument) {
  11074. return false;
  11075. }
  11076. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this
  11077. .pagesCount)) {
  11078. console.error(`isPageCached: "${pageNumber}" is not a valid page.`);
  11079. return false;
  11080. }
  11081. const pageView = this._pages[pageNumber - 1];
  11082. return _classPrivateFieldGet(this, _buffer).has(pageView);
  11083. }
  11084. cleanup() {
  11085. for (const pageView of this._pages) {
  11086. if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11087. pageView.reset();
  11088. }
  11089. }
  11090. }
  11091. _cancelRendering() {
  11092. for (const pageView of this._pages) {
  11093. pageView.cancelRendering();
  11094. }
  11095. }
  11096. forceRendering(currentlyVisiblePages) {
  11097. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11098. const scrollAhead = _classPrivateMethodGet(this, _getScrollAhead,
  11099. _getScrollAhead2).call(this, visiblePages);
  11100. const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this
  11101. ._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
  11102. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this
  11103. ._pages, scrollAhead, preRenderExtra);
  11104. _classPrivateMethodGet(this, _toggleLoadingIconSpinner,
  11105. _toggleLoadingIconSpinner2).call(this, visiblePages.ids);
  11106. if (pageView) {
  11107. _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2)
  11108. .call(this, pageView).then(() => {
  11109. this.renderingQueue.renderView(pageView);
  11110. });
  11111. return true;
  11112. }
  11113. return false;
  11114. }
  11115. createTextLayerBuilder(_ref4) {
  11116. let {
  11117. textLayerDiv,
  11118. pageIndex,
  11119. viewport,
  11120. enhanceTextSelection = false,
  11121. eventBus,
  11122. highlighter,
  11123. accessibilityManager = null
  11124. } = _ref4;
  11125. return new _text_layer_builder.TextLayerBuilder({
  11126. textLayerDiv,
  11127. eventBus,
  11128. pageIndex,
  11129. viewport,
  11130. enhanceTextSelection: this.isInPresentationMode ? false :
  11131. enhanceTextSelection,
  11132. highlighter,
  11133. accessibilityManager
  11134. });
  11135. }
  11136. createTextHighlighter(_ref5) {
  11137. let {
  11138. pageIndex,
  11139. eventBus
  11140. } = _ref5;
  11141. return new _text_highlighter.TextHighlighter({
  11142. eventBus,
  11143. pageIndex,
  11144. findController: this.isInPresentationMode ? null : this
  11145. .findController
  11146. });
  11147. }
  11148. createAnnotationLayerBuilder(_ref6) {
  11149. var _this$pdfDocument, _this$pdfDocument2, _this$_scriptingManag,
  11150. _this$pdfDocument3;
  11151. let {
  11152. pageDiv,
  11153. pdfPage,
  11154. annotationStorage = (_this$pdfDocument = this.pdfDocument) === null ||
  11155. _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage,
  11156. imageResourcesPath = "",
  11157. renderForms = true,
  11158. l10n = _l10n_utils.NullL10n,
  11159. enableScripting = this.enableScripting,
  11160. hasJSActionsPromise = (_this$pdfDocument2 = this.pdfDocument) === null ||
  11161. _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions(),
  11162. mouseState = (_this$_scriptingManag = this._scriptingManager) === null ||
  11163. _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag
  11164. .mouseState,
  11165. fieldObjectsPromise = (_this$pdfDocument3 = this.pdfDocument) === null ||
  11166. _this$pdfDocument3 === void 0 ? void 0 : _this$pdfDocument3
  11167. .getFieldObjects(),
  11168. annotationCanvasMap = null,
  11169. accessibilityManager = null
  11170. } = _ref6;
  11171. return new _annotation_layer_builder.AnnotationLayerBuilder({
  11172. pageDiv,
  11173. pdfPage,
  11174. annotationStorage,
  11175. imageResourcesPath,
  11176. renderForms,
  11177. linkService: this.linkService,
  11178. downloadManager: this.downloadManager,
  11179. l10n,
  11180. enableScripting,
  11181. hasJSActionsPromise,
  11182. mouseState,
  11183. fieldObjectsPromise,
  11184. annotationCanvasMap,
  11185. accessibilityManager
  11186. });
  11187. }
  11188. createAnnotationEditorLayerBuilder(_ref7) {
  11189. var _this$pdfDocument4;
  11190. let {
  11191. uiManager = _classPrivateFieldGet(this, _annotationEditorUIManager),
  11192. pageDiv,
  11193. pdfPage,
  11194. accessibilityManager = null,
  11195. l10n,
  11196. annotationStorage = (_this$pdfDocument4 = this.pdfDocument) === null ||
  11197. _this$pdfDocument4 === void 0 ? void 0 : _this$pdfDocument4
  11198. .annotationStorage
  11199. } = _ref7;
  11200. return new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
  11201. uiManager,
  11202. pageDiv,
  11203. pdfPage,
  11204. annotationStorage,
  11205. accessibilityManager,
  11206. l10n
  11207. });
  11208. }
  11209. createXfaLayerBuilder(_ref8) {
  11210. var _this$pdfDocument5;
  11211. let {
  11212. pageDiv,
  11213. pdfPage,
  11214. annotationStorage = (_this$pdfDocument5 = this.pdfDocument) === null ||
  11215. _this$pdfDocument5 === void 0 ? void 0 : _this$pdfDocument5
  11216. .annotationStorage
  11217. } = _ref8;
  11218. return new _xfa_layer_builder.XfaLayerBuilder({
  11219. pageDiv,
  11220. pdfPage,
  11221. annotationStorage,
  11222. linkService: this.linkService
  11223. });
  11224. }
  11225. createStructTreeLayerBuilder(_ref9) {
  11226. let {
  11227. pdfPage
  11228. } = _ref9;
  11229. return new _struct_tree_layer_builder.StructTreeLayerBuilder({
  11230. pdfPage
  11231. });
  11232. }
  11233. get hasEqualPageSizes() {
  11234. const firstPageView = this._pages[0];
  11235. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  11236. const pageView = this._pages[i];
  11237. if (pageView.width !== firstPageView.width || pageView.height !==
  11238. firstPageView.height) {
  11239. return false;
  11240. }
  11241. }
  11242. return true;
  11243. }
  11244. getPagesOverview() {
  11245. return this._pages.map(pageView => {
  11246. const viewport = pageView.pdfPage.getViewport({
  11247. scale: 1
  11248. });
  11249. if (!this.enablePrintAutoRotate || (0, _ui_utils
  11250. .isPortraitOrientation)(viewport)) {
  11251. return {
  11252. width: viewport.width,
  11253. height: viewport.height,
  11254. rotation: viewport.rotation
  11255. };
  11256. }
  11257. return {
  11258. width: viewport.height,
  11259. height: viewport.width,
  11260. rotation: (viewport.rotation - 90) % 360
  11261. };
  11262. });
  11263. }
  11264. get optionalContentConfigPromise() {
  11265. if (!this.pdfDocument) {
  11266. return Promise.resolve(null);
  11267. }
  11268. if (!this._optionalContentConfigPromise) {
  11269. console.error("optionalContentConfigPromise: Not initialized yet.");
  11270. return this.pdfDocument.getOptionalContentConfig();
  11271. }
  11272. return this._optionalContentConfigPromise;
  11273. }
  11274. set optionalContentConfigPromise(promise) {
  11275. if (!(promise instanceof Promise)) {
  11276. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  11277. }
  11278. if (!this.pdfDocument) {
  11279. return;
  11280. }
  11281. if (!this._optionalContentConfigPromise) {
  11282. return;
  11283. }
  11284. this._optionalContentConfigPromise = promise;
  11285. const updateArgs = {
  11286. optionalContentConfigPromise: promise
  11287. };
  11288. for (const pageView of this._pages) {
  11289. pageView.update(updateArgs);
  11290. }
  11291. this.update();
  11292. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11293. source: this,
  11294. promise
  11295. });
  11296. }
  11297. get scrollMode() {
  11298. return this._scrollMode;
  11299. }
  11300. set scrollMode(mode) {
  11301. if (this._scrollMode === mode) {
  11302. return;
  11303. }
  11304. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11305. throw new Error(`Invalid scroll mode: ${mode}`);
  11306. }
  11307. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  11308. return;
  11309. }
  11310. this._previousScrollMode = this._scrollMode;
  11311. this._scrollMode = mode;
  11312. this.eventBus.dispatch("scrollmodechanged", {
  11313. source: this,
  11314. mode
  11315. });
  11316. this._updateScrollMode(this._currentPageNumber);
  11317. }
  11318. _updateScrollMode() {
  11319. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  11320. 0] : null;
  11321. const scrollMode = this._scrollMode,
  11322. viewer = this.viewer;
  11323. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode
  11324. .HORIZONTAL);
  11325. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode
  11326. .WRAPPED);
  11327. if (!this.pdfDocument || !pageNumber) {
  11328. return;
  11329. }
  11330. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  11331. _classPrivateMethodGet(this, _ensurePageViewVisible,
  11332. _ensurePageViewVisible2).call(this);
  11333. } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
  11334. this._updateSpreadMode();
  11335. }
  11336. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11337. this._setScale(this._currentScaleValue, true);
  11338. }
  11339. this._setCurrentPageNumber(pageNumber, true);
  11340. this.update();
  11341. }
  11342. get spreadMode() {
  11343. return this._spreadMode;
  11344. }
  11345. set spreadMode(mode) {
  11346. if (this._spreadMode === mode) {
  11347. return;
  11348. }
  11349. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11350. throw new Error(`Invalid spread mode: ${mode}`);
  11351. }
  11352. this._spreadMode = mode;
  11353. this.eventBus.dispatch("spreadmodechanged", {
  11354. source: this,
  11355. mode
  11356. });
  11357. this._updateSpreadMode(this._currentPageNumber);
  11358. }
  11359. _updateSpreadMode() {
  11360. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  11361. 0] : null;
  11362. if (!this.pdfDocument) {
  11363. return;
  11364. }
  11365. const viewer = this.viewer,
  11366. pages = this._pages;
  11367. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11368. _classPrivateMethodGet(this, _ensurePageViewVisible,
  11369. _ensurePageViewVisible2).call(this);
  11370. } else {
  11371. viewer.textContent = "";
  11372. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11373. for (const pageView of this._pages) {
  11374. viewer.append(pageView.div);
  11375. }
  11376. } else {
  11377. const parity = this._spreadMode - 1;
  11378. let spread = null;
  11379. for (let i = 0, ii = pages.length; i < ii; ++i) {
  11380. if (spread === null) {
  11381. spread = document.createElement("div");
  11382. spread.className = "spread";
  11383. viewer.append(spread);
  11384. } else if (i % 2 === parity) {
  11385. spread = spread.cloneNode(false);
  11386. viewer.append(spread);
  11387. }
  11388. spread.append(pages[i].div);
  11389. }
  11390. }
  11391. }
  11392. if (!pageNumber) {
  11393. return;
  11394. }
  11395. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11396. this._setScale(this._currentScaleValue, true);
  11397. }
  11398. this._setCurrentPageNumber(pageNumber, true);
  11399. this.update();
  11400. }
  11401. _getPageAdvance(currentPageNumber) {
  11402. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  11403. 1] : false;
  11404. switch (this._scrollMode) {
  11405. case _ui_utils.ScrollMode.WRAPPED: {
  11406. const {
  11407. views
  11408. } = this._getVisiblePages(),
  11409. pageLayout = new Map();
  11410. for (const {
  11411. id,
  11412. y,
  11413. percent,
  11414. widthPercent
  11415. } of views) {
  11416. if (percent === 0 || widthPercent < 100) {
  11417. continue;
  11418. }
  11419. let yArray = pageLayout.get(y);
  11420. if (!yArray) {
  11421. pageLayout.set(y, yArray || (yArray = []));
  11422. }
  11423. yArray.push(id);
  11424. }
  11425. for (const yArray of pageLayout.values()) {
  11426. const currentIndex = yArray.indexOf(currentPageNumber);
  11427. if (currentIndex === -1) {
  11428. continue;
  11429. }
  11430. const numPages = yArray.length;
  11431. if (numPages === 1) {
  11432. break;
  11433. }
  11434. if (previous) {
  11435. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11436. const currentId = yArray[i],
  11437. expectedId = yArray[i + 1] - 1;
  11438. if (currentId < expectedId) {
  11439. return currentPageNumber - expectedId;
  11440. }
  11441. }
  11442. } else {
  11443. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  11444. const currentId = yArray[i],
  11445. expectedId = yArray[i - 1] + 1;
  11446. if (currentId > expectedId) {
  11447. return expectedId - currentPageNumber;
  11448. }
  11449. }
  11450. }
  11451. if (previous) {
  11452. const firstId = yArray[0];
  11453. if (firstId < currentPageNumber) {
  11454. return currentPageNumber - firstId + 1;
  11455. }
  11456. } else {
  11457. const lastId = yArray[numPages - 1];
  11458. if (lastId > currentPageNumber) {
  11459. return lastId - currentPageNumber + 1;
  11460. }
  11461. }
  11462. break;
  11463. }
  11464. break;
  11465. }
  11466. case _ui_utils.ScrollMode.HORIZONTAL: {
  11467. break;
  11468. }
  11469. case _ui_utils.ScrollMode.PAGE:
  11470. case _ui_utils.ScrollMode.VERTICAL: {
  11471. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11472. break;
  11473. }
  11474. const parity = this._spreadMode - 1;
  11475. if (previous && currentPageNumber % 2 !== parity) {
  11476. break;
  11477. } else if (!previous && currentPageNumber % 2 === parity) {
  11478. break;
  11479. }
  11480. const {
  11481. views
  11482. } = this._getVisiblePages(),
  11483. expectedId = previous ? currentPageNumber - 1 : currentPageNumber +
  11484. 1;
  11485. for (const {
  11486. id,
  11487. percent,
  11488. widthPercent
  11489. } of views) {
  11490. if (id !== expectedId) {
  11491. continue;
  11492. }
  11493. if (percent > 0 && widthPercent === 100) {
  11494. return 2;
  11495. }
  11496. break;
  11497. }
  11498. break;
  11499. }
  11500. }
  11501. return 1;
  11502. }
  11503. nextPage() {
  11504. const currentPageNumber = this._currentPageNumber,
  11505. pagesCount = this.pagesCount;
  11506. if (currentPageNumber >= pagesCount) {
  11507. return false;
  11508. }
  11509. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11510. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  11511. return true;
  11512. }
  11513. previousPage() {
  11514. const currentPageNumber = this._currentPageNumber;
  11515. if (currentPageNumber <= 1) {
  11516. return false;
  11517. }
  11518. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  11519. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  11520. return true;
  11521. }
  11522. increaseScale() {
  11523. let steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  11524. 1;
  11525. let newScale = this._currentScale;
  11526. do {
  11527. newScale = (newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
  11528. newScale = Math.ceil(newScale * 10) / 10;
  11529. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  11530. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  11531. this.currentScaleValue = newScale;
  11532. }
  11533. decreaseScale() {
  11534. let steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  11535. 1;
  11536. let newScale = this._currentScale;
  11537. do {
  11538. newScale = (newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
  11539. newScale = Math.floor(newScale * 10) / 10;
  11540. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  11541. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  11542. this.currentScaleValue = newScale;
  11543. }
  11544. updateContainerHeightCss() {
  11545. const height = this.container.clientHeight;
  11546. if (height !== _classPrivateFieldGet(this, _previousContainerHeight)) {
  11547. _classPrivateFieldSet(this, _previousContainerHeight, height);
  11548. _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`);
  11549. }
  11550. }
  11551. get annotationEditorMode() {
  11552. return _classPrivateFieldGet(this, _annotationEditorUIManager) ?
  11553. _classPrivateFieldGet(this, _annotationEditorMode) : _pdfjsLib
  11554. .AnnotationEditorType.DISABLE;
  11555. }
  11556. set annotationEditorMode(mode) {
  11557. if (!_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  11558. throw new Error(`The AnnotationEditor is not enabled.`);
  11559. }
  11560. if (_classPrivateFieldGet(this, _annotationEditorMode) === mode) {
  11561. return;
  11562. }
  11563. if (!isValidAnnotationEditorMode(mode)) {
  11564. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  11565. }
  11566. if (!this.pdfDocument) {
  11567. return;
  11568. }
  11569. _classPrivateFieldSet(this, _annotationEditorMode, mode);
  11570. this.eventBus.dispatch("annotationeditormodechanged", {
  11571. source: this,
  11572. mode
  11573. });
  11574. _classPrivateFieldGet(this, _annotationEditorUIManager).updateMode(mode);
  11575. }
  11576. set annotationEditorParams(_ref10) {
  11577. let {
  11578. type,
  11579. value
  11580. } = _ref10;
  11581. if (!_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  11582. throw new Error(`The AnnotationEditor is not enabled.`);
  11583. }
  11584. _classPrivateFieldGet(this, _annotationEditorUIManager).updateParams(type,
  11585. value);
  11586. }
  11587. refresh() {
  11588. if (!this.pdfDocument) {
  11589. return;
  11590. }
  11591. const updateArgs = {};
  11592. for (const pageView of this._pages) {
  11593. pageView.update(updateArgs);
  11594. }
  11595. this.update();
  11596. }
  11597. }
  11598. exports.BaseViewer = BaseViewer;
  11599. function _initializePermissions2(permissions) {
  11600. const params = {
  11601. annotationEditorMode: _classPrivateFieldGet(this, _annotationEditorMode),
  11602. annotationMode: _classPrivateFieldGet(this, _annotationMode),
  11603. textLayerMode: this.textLayerMode
  11604. };
  11605. if (!permissions) {
  11606. return params;
  11607. }
  11608. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  11609. this.viewer.classList.add(ENABLE_PERMISSIONS_CLASS);
  11610. }
  11611. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) {
  11612. params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
  11613. }
  11614. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions
  11615. .includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && _classPrivateFieldGet(
  11616. this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
  11617. params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE;
  11618. }
  11619. return params;
  11620. }
  11621. function _onePageRenderedOrForceFetch2() {
  11622. if (document.visibilityState === "hidden" || !this.container.offsetParent || this
  11623. ._getVisiblePages().views.length === 0) {
  11624. return Promise.resolve();
  11625. }
  11626. const visibilityChangePromise = new Promise(resolve => {
  11627. _classPrivateFieldSet(this, _onVisibilityChange, () => {
  11628. if (document.visibilityState !== "hidden") {
  11629. return;
  11630. }
  11631. resolve();
  11632. document.removeEventListener("visibilitychange",
  11633. _classPrivateFieldGet(this, _onVisibilityChange));
  11634. _classPrivateFieldSet(this, _onVisibilityChange, null);
  11635. });
  11636. document.addEventListener("visibilitychange", _classPrivateFieldGet(this,
  11637. _onVisibilityChange));
  11638. });
  11639. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  11640. }
  11641. function _ensurePageViewVisible2() {
  11642. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  11643. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  11644. }
  11645. const pageNumber = this._currentPageNumber,
  11646. state = _classPrivateFieldGet(this, _scrollModePageState),
  11647. viewer = this.viewer;
  11648. viewer.textContent = "";
  11649. state.pages.length = 0;
  11650. if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
  11651. const pageView = this._pages[pageNumber - 1];
  11652. viewer.append(pageView.div);
  11653. state.pages.push(pageView);
  11654. } else {
  11655. const pageIndexSet = new Set(),
  11656. parity = this._spreadMode - 1;
  11657. if (parity === -1) {
  11658. pageIndexSet.add(pageNumber - 1);
  11659. } else if (pageNumber % 2 !== parity) {
  11660. pageIndexSet.add(pageNumber - 1);
  11661. pageIndexSet.add(pageNumber);
  11662. } else {
  11663. pageIndexSet.add(pageNumber - 2);
  11664. pageIndexSet.add(pageNumber - 1);
  11665. }
  11666. const spread = document.createElement("div");
  11667. spread.className = "spread";
  11668. if (this.isInPresentationMode) {
  11669. const dummyPage = document.createElement("div");
  11670. dummyPage.className = "dummyPage";
  11671. spread.append(dummyPage);
  11672. }
  11673. for (const i of pageIndexSet) {
  11674. const pageView = this._pages[i];
  11675. if (!pageView) {
  11676. continue;
  11677. }
  11678. spread.append(pageView.div);
  11679. state.pages.push(pageView);
  11680. }
  11681. viewer.append(spread);
  11682. }
  11683. state.scrollDown = pageNumber >= state.previousPageNumber;
  11684. state.previousPageNumber = pageNumber;
  11685. }
  11686. function _scrollIntoView2(pageView) {
  11687. let pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11688. const {
  11689. div,
  11690. id
  11691. } = pageView;
  11692. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  11693. this._setCurrentPageNumber(id);
  11694. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(
  11695. this);
  11696. this.update();
  11697. }
  11698. if (!pageSpot && !this.isInPresentationMode) {
  11699. const left = div.offsetLeft + div.clientLeft,
  11700. right = left + div.clientWidth;
  11701. const {
  11702. scrollLeft,
  11703. clientWidth
  11704. } = this.container;
  11705. if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft ||
  11706. right > scrollLeft + clientWidth) {
  11707. pageSpot = {
  11708. left: 0,
  11709. top: 0
  11710. };
  11711. }
  11712. }
  11713. (0, _ui_utils.scrollIntoView)(div, pageSpot);
  11714. }
  11715. function _isSameScale2(newScale) {
  11716. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) <
  11717. 1e-15;
  11718. }
  11719. function _resetCurrentPageView2() {
  11720. const pageView = this._pages[this._currentPageNumber - 1];
  11721. if (this.isInPresentationMode) {
  11722. this._setScale(this._currentScaleValue, true);
  11723. }
  11724. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView);
  11725. }
  11726. async function _ensurePdfPageLoaded2(pageView) {
  11727. if (pageView.pdfPage) {
  11728. return pageView.pdfPage;
  11729. }
  11730. try {
  11731. var _this$linkService$_ca, _this$linkService;
  11732. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  11733. if (!pageView.pdfPage) {
  11734. pageView.setPdfPage(pdfPage);
  11735. }
  11736. if (!((_this$linkService$_ca = (_this$linkService = this.linkService)
  11737. ._cachedPageNumber) !== null && _this$linkService$_ca !== void 0 &&
  11738. _this$linkService$_ca.call(_this$linkService, pdfPage.ref))) {
  11739. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  11740. }
  11741. return pdfPage;
  11742. } catch (reason) {
  11743. console.error("Unable to get page for page view", reason);
  11744. return null;
  11745. }
  11746. }
  11747. function _getScrollAhead2(visible) {
  11748. var _visible$first, _visible$last;
  11749. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 :
  11750. _visible$first.id) === 1) {
  11751. return true;
  11752. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ?
  11753. void 0 : _visible$last.id) === this.pagesCount) {
  11754. return false;
  11755. }
  11756. switch (this._scrollMode) {
  11757. case _ui_utils.ScrollMode.PAGE:
  11758. return _classPrivateFieldGet(this, _scrollModePageState).scrollDown;
  11759. case _ui_utils.ScrollMode.HORIZONTAL:
  11760. return this.scroll.right;
  11761. }
  11762. return this.scroll.down;
  11763. }
  11764. function _toggleLoadingIconSpinner2(visibleIds) {
  11765. for (const id of visibleIds) {
  11766. const pageView = this._pages[id - 1];
  11767. pageView === null || pageView === void 0 ? void 0 : pageView
  11768. .toggleLoadingIconSpinner(true);
  11769. }
  11770. for (const pageView of _classPrivateFieldGet(this, _buffer)) {
  11771. if (visibleIds.has(pageView.id)) {
  11772. continue;
  11773. }
  11774. pageView.toggleLoadingIconSpinner(false);
  11775. }
  11776. }
  11777. /***/
  11778. }),
  11779. /* 31 */
  11780. /***/
  11781. ((__unused_webpack_module, exports, __webpack_require__) => {
  11782. Object.defineProperty(exports, "__esModule", ({
  11783. value: true
  11784. }));
  11785. exports.AnnotationEditorLayerBuilder = void 0;
  11786. var _pdfjsLib = __webpack_require__(5);
  11787. var _l10n_utils = __webpack_require__(32);
  11788. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  11789. _checkPrivateRedeclaration(obj, privateMap);
  11790. privateMap.set(obj, value);
  11791. }
  11792. function _checkPrivateRedeclaration(obj, privateCollection) {
  11793. if (privateCollection.has(obj)) {
  11794. throw new TypeError(
  11795. "Cannot initialize the same private elements twice on an object");
  11796. }
  11797. }
  11798. function _classPrivateFieldGet(receiver, privateMap) {
  11799. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  11800. return _classApplyDescriptorGet(receiver, descriptor);
  11801. }
  11802. function _classApplyDescriptorGet(receiver, descriptor) {
  11803. if (descriptor.get) {
  11804. return descriptor.get.call(receiver);
  11805. }
  11806. return descriptor.value;
  11807. }
  11808. function _classPrivateFieldSet(receiver, privateMap, value) {
  11809. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  11810. _classApplyDescriptorSet(receiver, descriptor, value);
  11811. return value;
  11812. }
  11813. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  11814. if (!privateMap.has(receiver)) {
  11815. throw new TypeError("attempted to " + action + " private field on non-instance");
  11816. }
  11817. return privateMap.get(receiver);
  11818. }
  11819. function _classApplyDescriptorSet(receiver, descriptor, value) {
  11820. if (descriptor.set) {
  11821. descriptor.set.call(receiver, value);
  11822. } else {
  11823. if (!descriptor.writable) {
  11824. throw new TypeError("attempted to set read only private field");
  11825. }
  11826. descriptor.value = value;
  11827. }
  11828. }
  11829. var _uiManager = /*#__PURE__*/ new WeakMap();
  11830. class AnnotationEditorLayerBuilder {
  11831. constructor(options) {
  11832. _classPrivateFieldInitSpec(this, _uiManager, {
  11833. writable: true,
  11834. value: void 0
  11835. });
  11836. this.pageDiv = options.pageDiv;
  11837. this.pdfPage = options.pdfPage;
  11838. this.annotationStorage = options.annotationStorage || null;
  11839. this.accessibilityManager = options.accessibilityManager;
  11840. this.l10n = options.l10n || _l10n_utils.NullL10n;
  11841. this.annotationEditorLayer = null;
  11842. this.div = null;
  11843. this._cancelled = false;
  11844. _classPrivateFieldSet(this, _uiManager, options.uiManager);
  11845. }
  11846. async render(viewport) {
  11847. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  11848. "display";
  11849. if (intent !== "display") {
  11850. return;
  11851. }
  11852. if (this._cancelled) {
  11853. return;
  11854. }
  11855. const clonedViewport = viewport.clone({
  11856. dontFlip: true
  11857. });
  11858. if (this.div) {
  11859. this.annotationEditorLayer.update({
  11860. viewport: clonedViewport
  11861. });
  11862. this.show();
  11863. return;
  11864. }
  11865. this.div = document.createElement("div");
  11866. this.div.className = "annotationEditorLayer";
  11867. this.div.tabIndex = 0;
  11868. this.pageDiv.append(this.div);
  11869. this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({
  11870. uiManager: _classPrivateFieldGet(this, _uiManager),
  11871. div: this.div,
  11872. annotationStorage: this.annotationStorage,
  11873. accessibilityManager: this.accessibilityManager,
  11874. pageIndex: this.pdfPage._pageIndex,
  11875. l10n: this.l10n,
  11876. viewport: clonedViewport
  11877. });
  11878. const parameters = {
  11879. viewport: clonedViewport,
  11880. div: this.div,
  11881. annotations: null,
  11882. intent
  11883. };
  11884. this.annotationEditorLayer.render(parameters);
  11885. }
  11886. cancel() {
  11887. this._cancelled = true;
  11888. this.destroy();
  11889. }
  11890. hide() {
  11891. if (!this.div) {
  11892. return;
  11893. }
  11894. this.div.hidden = true;
  11895. }
  11896. show() {
  11897. if (!this.div) {
  11898. return;
  11899. }
  11900. this.div.hidden = false;
  11901. }
  11902. destroy() {
  11903. if (!this.div) {
  11904. return;
  11905. }
  11906. this.pageDiv = null;
  11907. this.annotationEditorLayer.destroy();
  11908. this.div.remove();
  11909. }
  11910. }
  11911. exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
  11912. /***/
  11913. }),
  11914. /* 32 */
  11915. /***/
  11916. ((__unused_webpack_module, exports) => {
  11917. Object.defineProperty(exports, "__esModule", ({
  11918. value: true
  11919. }));
  11920. exports.NullL10n = void 0;
  11921. exports.fixupLangCode = fixupLangCode;
  11922. exports.getL10nFallback = getL10nFallback;
  11923. const DEFAULT_L10N_STRINGS = {
  11924. of_pages: "of {{pagesCount}}",
  11925. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  11926. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  11927. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  11928. document_properties_date_string: "{{date}}, {{time}}",
  11929. document_properties_page_size_unit_inches: "in",
  11930. document_properties_page_size_unit_millimeters: "mm",
  11931. document_properties_page_size_orientation_portrait: "portrait",
  11932. document_properties_page_size_orientation_landscape: "landscape",
  11933. document_properties_page_size_name_a3: "A3",
  11934. document_properties_page_size_name_a4: "A4",
  11935. document_properties_page_size_name_letter: "Letter",
  11936. document_properties_page_size_name_legal: "Legal",
  11937. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  11938. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  11939. document_properties_linearized_yes: "Yes",
  11940. document_properties_linearized_no: "No",
  11941. print_progress_percent: "{{progress}}%",
  11942. "toggle_sidebar.title": "Toggle Sidebar",
  11943. "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
  11944. additional_layers: "Additional Layers",
  11945. page_landmark: "Page {{page}}",
  11946. thumb_page_title: "Page {{page}}",
  11947. thumb_page_canvas: "Thumbnail of Page {{page}}",
  11948. find_reached_top: "Reached top of document, continued from bottom",
  11949. find_reached_bottom: "Reached end of document, continued from top",
  11950. "find_match_count[one]": "{{current}} of {{total}} match",
  11951. "find_match_count[other]": "{{current}} of {{total}} matches",
  11952. "find_match_count_limit[one]": "More than {{limit}} match",
  11953. "find_match_count_limit[other]": "More than {{limit}} matches",
  11954. find_not_found: "Phrase not found",
  11955. error_version_info: "PDF.js v{{version}} (build: {{build}})",
  11956. error_message: "Message: {{message}}",
  11957. error_stack: "Stack: {{stack}}",
  11958. error_file: "File: {{file}}",
  11959. error_line: "Line: {{line}}",
  11960. rendering_error: "An error occurred while rendering the page.",
  11961. page_scale_width: "Page Width",
  11962. page_scale_fit: "Page Fit",
  11963. page_scale_auto: "Automatic Zoom",
  11964. page_scale_actual: "Actual Size",
  11965. page_scale_percent: "{{scale}}%",
  11966. loading: "Loading…",
  11967. loading_error: "An error occurred while loading the PDF.",
  11968. invalid_file_error: "Invalid or corrupted PDF file.",
  11969. missing_file_error: "Missing PDF file.",
  11970. unexpected_response_error: "Unexpected server response.",
  11971. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  11972. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  11973. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
  11974. free_text_default_content: "Enter text…",
  11975. editor_free_text_aria_label: "FreeText Editor",
  11976. editor_ink_aria_label: "Ink Editor",
  11977. editor_ink_canvas_aria_label: "User-created image"
  11978. };
  11979. function getL10nFallback(key, args) {
  11980. switch (key) {
  11981. case "find_match_count":
  11982. key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
  11983. break;
  11984. case "find_match_count_limit":
  11985. key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
  11986. break;
  11987. }
  11988. return DEFAULT_L10N_STRINGS[key] || "";
  11989. }
  11990. const PARTIAL_LANG_CODES = {
  11991. en: "en-US",
  11992. es: "es-ES",
  11993. fy: "fy-NL",
  11994. ga: "ga-IE",
  11995. gu: "gu-IN",
  11996. hi: "hi-IN",
  11997. hy: "hy-AM",
  11998. nb: "nb-NO",
  11999. ne: "ne-NP",
  12000. nn: "nn-NO",
  12001. pa: "pa-IN",
  12002. pt: "pt-PT",
  12003. sv: "sv-SE",
  12004. zh: "zh-CN"
  12005. };
  12006. function fixupLangCode(langCode) {
  12007. return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode
  12008. .toLowerCase()] || langCode;
  12009. }
  12010. function formatL10nValue(text, args) {
  12011. if (!args) {
  12012. return text;
  12013. }
  12014. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  12015. return name in args ? args[name] : "{{" + name + "}}";
  12016. });
  12017. }
  12018. const NullL10n = {
  12019. async getLanguage() {
  12020. return "en-us";
  12021. },
  12022. async getDirection() {
  12023. return "ltr";
  12024. },
  12025. async get(key) {
  12026. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  12027. 1] : null;
  12028. let fallback = arguments.length > 2 && arguments[2] !== undefined ?
  12029. arguments[2] : getL10nFallback(key, args);
  12030. return formatL10nValue(fallback, args);
  12031. },
  12032. async translate(element) {}
  12033. };
  12034. exports.NullL10n = NullL10n;
  12035. /***/
  12036. }),
  12037. /* 33 */
  12038. /***/
  12039. ((__unused_webpack_module, exports, __webpack_require__) => {
  12040. Object.defineProperty(exports, "__esModule", ({
  12041. value: true
  12042. }));
  12043. exports.AnnotationLayerBuilder = void 0;
  12044. var _pdfjsLib = __webpack_require__(5);
  12045. var _l10n_utils = __webpack_require__(32);
  12046. class AnnotationLayerBuilder {
  12047. constructor(_ref) {
  12048. let {
  12049. pageDiv,
  12050. pdfPage,
  12051. linkService,
  12052. downloadManager,
  12053. annotationStorage = null,
  12054. imageResourcesPath = "",
  12055. renderForms = true,
  12056. l10n = _l10n_utils.NullL10n,
  12057. enableScripting = false,
  12058. hasJSActionsPromise = null,
  12059. fieldObjectsPromise = null,
  12060. mouseState = null,
  12061. annotationCanvasMap = null,
  12062. accessibilityManager = null
  12063. } = _ref;
  12064. this.pageDiv = pageDiv;
  12065. this.pdfPage = pdfPage;
  12066. this.linkService = linkService;
  12067. this.downloadManager = downloadManager;
  12068. this.imageResourcesPath = imageResourcesPath;
  12069. this.renderForms = renderForms;
  12070. this.l10n = l10n;
  12071. this.annotationStorage = annotationStorage;
  12072. this.enableScripting = enableScripting;
  12073. this._hasJSActionsPromise = hasJSActionsPromise;
  12074. this._fieldObjectsPromise = fieldObjectsPromise;
  12075. this._mouseState = mouseState;
  12076. this._annotationCanvasMap = annotationCanvasMap;
  12077. this._accessibilityManager = accessibilityManager;
  12078. this.div = null;
  12079. this._cancelled = false;
  12080. }
  12081. async render(viewport) {
  12082. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  12083. "display";
  12084. const [annotations, hasJSActions = false, fieldObjects = null] = await Promise
  12085. .all([this.pdfPage.getAnnotations({
  12086. intent
  12087. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  12088. if (this._cancelled || annotations.length === 0) {
  12089. return;
  12090. }
  12091. const parameters = {
  12092. viewport: viewport.clone({
  12093. dontFlip: true
  12094. }),
  12095. div: this.div,
  12096. annotations,
  12097. page: this.pdfPage,
  12098. imageResourcesPath: this.imageResourcesPath,
  12099. renderForms: this.renderForms,
  12100. linkService: this.linkService,
  12101. downloadManager: this.downloadManager,
  12102. annotationStorage: this.annotationStorage,
  12103. enableScripting: this.enableScripting,
  12104. hasJSActions,
  12105. fieldObjects,
  12106. mouseState: this._mouseState,
  12107. annotationCanvasMap: this._annotationCanvasMap,
  12108. accessibilityManager: this._accessibilityManager
  12109. };
  12110. if (this.div) {
  12111. _pdfjsLib.AnnotationLayer.update(parameters);
  12112. } else {
  12113. this.div = document.createElement("div");
  12114. this.div.className = "annotationLayer";
  12115. this.pageDiv.append(this.div);
  12116. parameters.div = this.div;
  12117. _pdfjsLib.AnnotationLayer.render(parameters);
  12118. this.l10n.translate(this.div);
  12119. }
  12120. }
  12121. cancel() {
  12122. this._cancelled = true;
  12123. }
  12124. hide() {
  12125. if (!this.div) {
  12126. return;
  12127. }
  12128. this.div.hidden = true;
  12129. }
  12130. }
  12131. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  12132. /***/
  12133. }),
  12134. /* 34 */
  12135. /***/
  12136. ((__unused_webpack_module, exports, __webpack_require__) => {
  12137. Object.defineProperty(exports, "__esModule", ({
  12138. value: true
  12139. }));
  12140. exports.PDFPageView = void 0;
  12141. var _pdfjsLib = __webpack_require__(5);
  12142. var _ui_utils = __webpack_require__(1);
  12143. var _app_options = __webpack_require__(2);
  12144. var _l10n_utils = __webpack_require__(32);
  12145. var _text_accessibility = __webpack_require__(35);
  12146. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  12147. _checkPrivateRedeclaration(obj, privateMap);
  12148. privateMap.set(obj, value);
  12149. }
  12150. function _checkPrivateRedeclaration(obj, privateCollection) {
  12151. if (privateCollection.has(obj)) {
  12152. throw new TypeError(
  12153. "Cannot initialize the same private elements twice on an object");
  12154. }
  12155. }
  12156. function _classPrivateFieldGet(receiver, privateMap) {
  12157. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  12158. return _classApplyDescriptorGet(receiver, descriptor);
  12159. }
  12160. function _classApplyDescriptorGet(receiver, descriptor) {
  12161. if (descriptor.get) {
  12162. return descriptor.get.call(receiver);
  12163. }
  12164. return descriptor.value;
  12165. }
  12166. function _classPrivateFieldSet(receiver, privateMap, value) {
  12167. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  12168. _classApplyDescriptorSet(receiver, descriptor, value);
  12169. return value;
  12170. }
  12171. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  12172. if (!privateMap.has(receiver)) {
  12173. throw new TypeError("attempted to " + action + " private field on non-instance");
  12174. }
  12175. return privateMap.get(receiver);
  12176. }
  12177. function _classApplyDescriptorSet(receiver, descriptor, value) {
  12178. if (descriptor.set) {
  12179. descriptor.set.call(receiver, value);
  12180. } else {
  12181. if (!descriptor.writable) {
  12182. throw new TypeError("attempted to set read only private field");
  12183. }
  12184. descriptor.value = value;
  12185. }
  12186. }
  12187. const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  12188. var _annotationMode = /*#__PURE__*/ new WeakMap();
  12189. var _useThumbnailCanvas = /*#__PURE__*/ new WeakMap();
  12190. class PDFPageView {
  12191. constructor(options) {
  12192. var _options$textLayerMod, _options$annotationMo, _options$textHighligh,
  12193. _this$renderingQueue;
  12194. _classPrivateFieldInitSpec(this, _annotationMode, {
  12195. writable: true,
  12196. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  12197. });
  12198. _classPrivateFieldInitSpec(this, _useThumbnailCanvas, {
  12199. writable: true,
  12200. value: {
  12201. initialOptionalContent: true,
  12202. regularAnnotations: true
  12203. }
  12204. });
  12205. const container = options.container;
  12206. const defaultViewport = options.defaultViewport;
  12207. this.id = options.id;
  12208. this.renderingId = "page" + this.id;
  12209. this.pdfPage = null;
  12210. this.pageLabel = null;
  12211. this.rotation = 0;
  12212. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  12213. this.viewport = defaultViewport;
  12214. this.pdfPageRotate = defaultViewport.rotation;
  12215. this._optionalContentConfigPromise = options.optionalContentConfigPromise ||
  12216. null;
  12217. this.hasRestrictedScaling = false;
  12218. this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null &&
  12219. _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils
  12220. .TextLayerMode.ENABLE;
  12221. _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options
  12222. .annotationMode) !== null && _options$annotationMo !== void 0 ?
  12223. _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  12224. this.imageResourcesPath = options.imageResourcesPath || "";
  12225. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  12226. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  12227. this.pageColors = options.pageColors || null;
  12228. this.eventBus = options.eventBus;
  12229. this.renderingQueue = options.renderingQueue;
  12230. this.textLayerFactory = options.textLayerFactory;
  12231. this.annotationLayerFactory = options.annotationLayerFactory;
  12232. this.annotationEditorLayerFactory = options.annotationEditorLayerFactory;
  12233. this.xfaLayerFactory = options.xfaLayerFactory;
  12234. this.textHighlighter = (_options$textHighligh = options
  12235. .textHighlighterFactory) === null || _options$textHighligh === void 0 ?
  12236. void 0 : _options$textHighligh.createTextHighlighter({
  12237. pageIndex: this.id - 1,
  12238. eventBus: this.eventBus
  12239. });
  12240. this.structTreeLayerFactory = options.structTreeLayerFactory;
  12241. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  12242. this.l10n = options.l10n || _l10n_utils.NullL10n;
  12243. this.paintTask = null;
  12244. this.paintedViewportMap = new WeakMap();
  12245. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  12246. this.resume = null;
  12247. this._renderError = null;
  12248. this._isStandalone = !((_this$renderingQueue = this.renderingQueue) !== null &&
  12249. _this$renderingQueue !== void 0 && _this$renderingQueue.hasViewer());
  12250. this._annotationCanvasMap = null;
  12251. this.annotationLayer = null;
  12252. this.annotationEditorLayer = null;
  12253. this.textLayer = null;
  12254. this.zoomLayer = null;
  12255. this.xfaLayer = null;
  12256. this.structTreeLayer = null;
  12257. const div = document.createElement("div");
  12258. div.className = "page";
  12259. div.style.width = Math.floor(this.viewport.width) + "px";
  12260. div.style.height = Math.floor(this.viewport.height) + "px";
  12261. div.setAttribute("data-page-number", this.id);
  12262. div.setAttribute("role", "region");
  12263. this.l10n.get("page_landmark", {
  12264. page: this.id
  12265. }).then(msg => {
  12266. div.setAttribute("aria-label", msg);
  12267. });
  12268. this.div = div;
  12269. container === null || container === void 0 ? void 0 : container.append(div);
  12270. if (this._isStandalone) {
  12271. const {
  12272. optionalContentConfigPromise
  12273. } = options;
  12274. if (optionalContentConfigPromise) {
  12275. optionalContentConfigPromise.then(optionalContentConfig => {
  12276. if (optionalContentConfigPromise !== this
  12277. ._optionalContentConfigPromise) {
  12278. return;
  12279. }
  12280. _classPrivateFieldGet(this, _useThumbnailCanvas)
  12281. .initialOptionalContent = optionalContentConfig
  12282. .hasInitialVisibility;
  12283. });
  12284. }
  12285. }
  12286. }
  12287. setPdfPage(pdfPage) {
  12288. this.pdfPage = pdfPage;
  12289. this.pdfPageRotate = pdfPage.rotate;
  12290. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12291. this.viewport = pdfPage.getViewport({
  12292. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12293. rotation: totalRotation
  12294. });
  12295. this.reset();
  12296. }
  12297. destroy() {
  12298. this.reset();
  12299. if (this.pdfPage) {
  12300. this.pdfPage.cleanup();
  12301. }
  12302. }
  12303. async _renderAnnotationLayer() {
  12304. let error = null;
  12305. try {
  12306. await this.annotationLayer.render(this.viewport, "display");
  12307. } catch (ex) {
  12308. console.error(`_renderAnnotationLayer: "${ex}".`);
  12309. error = ex;
  12310. } finally {
  12311. this.eventBus.dispatch("annotationlayerrendered", {
  12312. source: this,
  12313. pageNumber: this.id,
  12314. error
  12315. });
  12316. }
  12317. }
  12318. async _renderAnnotationEditorLayer() {
  12319. let error = null;
  12320. try {
  12321. await this.annotationEditorLayer.render(this.viewport, "display");
  12322. } catch (ex) {
  12323. console.error(`_renderAnnotationEditorLayer: "${ex}".`);
  12324. error = ex;
  12325. } finally {
  12326. this.eventBus.dispatch("annotationeditorlayerrendered", {
  12327. source: this,
  12328. pageNumber: this.id,
  12329. error
  12330. });
  12331. }
  12332. }
  12333. async _renderXfaLayer() {
  12334. let error = null;
  12335. try {
  12336. const result = await this.xfaLayer.render(this.viewport, "display");
  12337. if (this.textHighlighter) {
  12338. this._buildXfaTextContentItems(result.textDivs);
  12339. }
  12340. } catch (ex) {
  12341. console.error(`_renderXfaLayer: "${ex}".`);
  12342. error = ex;
  12343. } finally {
  12344. this.eventBus.dispatch("xfalayerrendered", {
  12345. source: this,
  12346. pageNumber: this.id,
  12347. error
  12348. });
  12349. }
  12350. }
  12351. async _buildXfaTextContentItems(textDivs) {
  12352. const text = await this.pdfPage.getTextContent();
  12353. const items = [];
  12354. for (const item of text.items) {
  12355. items.push(item.str);
  12356. }
  12357. this.textHighlighter.setTextMapping(textDivs, items);
  12358. this.textHighlighter.enable();
  12359. }
  12360. _resetZoomLayer() {
  12361. let removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ?
  12362. arguments[0] : false;
  12363. if (!this.zoomLayer) {
  12364. return;
  12365. }
  12366. const zoomLayerCanvas = this.zoomLayer.firstChild;
  12367. this.paintedViewportMap.delete(zoomLayerCanvas);
  12368. zoomLayerCanvas.width = 0;
  12369. zoomLayerCanvas.height = 0;
  12370. if (removeFromDOM) {
  12371. this.zoomLayer.remove();
  12372. }
  12373. this.zoomLayer = null;
  12374. }
  12375. reset() {
  12376. var _this$annotationLayer, _this$annotationEdito, _this$xfaLayer;
  12377. let {
  12378. keepZoomLayer = false,
  12379. keepAnnotationLayer = false,
  12380. keepAnnotationEditorLayer = false,
  12381. keepXfaLayer = false
  12382. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12383. this.cancelRendering({
  12384. keepAnnotationLayer,
  12385. keepAnnotationEditorLayer,
  12386. keepXfaLayer
  12387. });
  12388. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  12389. const div = this.div;
  12390. div.style.width = Math.floor(this.viewport.width) + "px";
  12391. div.style.height = Math.floor(this.viewport.height) + "px";
  12392. const childNodes = div.childNodes,
  12393. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  12394. annotationLayerNode = keepAnnotationLayer && ((_this$annotationLayer = this
  12395. .annotationLayer) === null || _this$annotationLayer === void 0 ?
  12396. void 0 : _this$annotationLayer.div) || null,
  12397. annotationEditorLayerNode = keepAnnotationEditorLayer && ((
  12398. _this$annotationEdito = this.annotationEditorLayer) === null ||
  12399. _this$annotationEdito === void 0 ? void 0 : _this$annotationEdito.div
  12400. ) || null,
  12401. xfaLayerNode = keepXfaLayer && ((_this$xfaLayer = this.xfaLayer) === null ||
  12402. _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null;
  12403. for (let i = childNodes.length - 1; i >= 0; i--) {
  12404. const node = childNodes[i];
  12405. switch (node) {
  12406. case zoomLayerNode:
  12407. case annotationLayerNode:
  12408. case annotationEditorLayerNode:
  12409. case xfaLayerNode:
  12410. continue;
  12411. }
  12412. node.remove();
  12413. }
  12414. div.removeAttribute("data-loaded");
  12415. if (annotationLayerNode) {
  12416. this.annotationLayer.hide();
  12417. }
  12418. if (annotationEditorLayerNode) {
  12419. this.annotationEditorLayer.hide();
  12420. } else {
  12421. var _this$annotationEdito2;
  12422. (_this$annotationEdito2 = this.annotationEditorLayer) === null ||
  12423. _this$annotationEdito2 === void 0 ? void 0 : _this$annotationEdito2
  12424. .destroy();
  12425. }
  12426. if (xfaLayerNode) {
  12427. this.xfaLayer.hide();
  12428. }
  12429. if (!zoomLayerNode) {
  12430. if (this.canvas) {
  12431. this.paintedViewportMap.delete(this.canvas);
  12432. this.canvas.width = 0;
  12433. this.canvas.height = 0;
  12434. delete this.canvas;
  12435. }
  12436. this._resetZoomLayer();
  12437. }
  12438. if (this.svg) {
  12439. this.paintedViewportMap.delete(this.svg);
  12440. delete this.svg;
  12441. }
  12442. this.loadingIconDiv = document.createElement("div");
  12443. this.loadingIconDiv.className = "loadingIcon notVisible";
  12444. if (this._isStandalone) {
  12445. this.toggleLoadingIconSpinner(true);
  12446. }
  12447. this.loadingIconDiv.setAttribute("role", "img");
  12448. this.l10n.get("loading").then(msg => {
  12449. var _this$loadingIconDiv;
  12450. (_this$loadingIconDiv = this.loadingIconDiv) === null ||
  12451. _this$loadingIconDiv === void 0 ? void 0 : _this$loadingIconDiv
  12452. .setAttribute("aria-label", msg);
  12453. });
  12454. div.append(this.loadingIconDiv);
  12455. }
  12456. update(_ref) {
  12457. let {
  12458. scale = 0,
  12459. rotation = null,
  12460. optionalContentConfigPromise = null
  12461. } = _ref;
  12462. this.scale = scale || this.scale;
  12463. if (typeof rotation === "number") {
  12464. this.rotation = rotation;
  12465. }
  12466. if (optionalContentConfigPromise instanceof Promise) {
  12467. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12468. optionalContentConfigPromise.then(optionalContentConfig => {
  12469. if (optionalContentConfigPromise !== this
  12470. ._optionalContentConfigPromise) {
  12471. return;
  12472. }
  12473. _classPrivateFieldGet(this, _useThumbnailCanvas)
  12474. .initialOptionalContent = optionalContentConfig
  12475. .hasInitialVisibility;
  12476. });
  12477. }
  12478. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12479. this.viewport = this.viewport.clone({
  12480. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  12481. rotation: totalRotation
  12482. });
  12483. if (this._isStandalone) {
  12484. _ui_utils.docStyle.setProperty("--scale-factor", this.viewport.scale);
  12485. }
  12486. if (this.svg) {
  12487. this.cssTransform({
  12488. target: this.svg,
  12489. redrawAnnotationLayer: true,
  12490. redrawAnnotationEditorLayer: true,
  12491. redrawXfaLayer: true
  12492. });
  12493. this.eventBus.dispatch("pagerendered", {
  12494. source: this,
  12495. pageNumber: this.id,
  12496. cssTransform: true,
  12497. timestamp: performance.now(),
  12498. error: this._renderError
  12499. });
  12500. return;
  12501. }
  12502. let isScalingRestricted = false;
  12503. if (this.canvas && this.maxCanvasPixels > 0) {
  12504. const outputScale = this.outputScale;
  12505. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(
  12506. this.viewport.height) * outputScale.sy | 0) > this
  12507. .maxCanvasPixels) {
  12508. isScalingRestricted = true;
  12509. }
  12510. }
  12511. if (this.canvas) {
  12512. if (this.useOnlyCssZoom || this.hasRestrictedScaling &&
  12513. isScalingRestricted) {
  12514. this.cssTransform({
  12515. target: this.canvas,
  12516. redrawAnnotationLayer: true,
  12517. redrawAnnotationEditorLayer: true,
  12518. redrawXfaLayer: true
  12519. });
  12520. this.eventBus.dispatch("pagerendered", {
  12521. source: this,
  12522. pageNumber: this.id,
  12523. cssTransform: true,
  12524. timestamp: performance.now(),
  12525. error: this._renderError
  12526. });
  12527. return;
  12528. }
  12529. if (!this.zoomLayer && !this.canvas.hidden) {
  12530. this.zoomLayer = this.canvas.parentNode;
  12531. this.zoomLayer.style.position = "absolute";
  12532. }
  12533. }
  12534. if (this.zoomLayer) {
  12535. this.cssTransform({
  12536. target: this.zoomLayer.firstChild
  12537. });
  12538. }
  12539. this.reset({
  12540. keepZoomLayer: true,
  12541. keepAnnotationLayer: true,
  12542. keepAnnotationEditorLayer: true,
  12543. keepXfaLayer: true
  12544. });
  12545. }
  12546. cancelRendering() {
  12547. let {
  12548. keepAnnotationLayer = false,
  12549. keepAnnotationEditorLayer = false,
  12550. keepXfaLayer = false
  12551. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12552. if (this.paintTask) {
  12553. this.paintTask.cancel();
  12554. this.paintTask = null;
  12555. }
  12556. this.resume = null;
  12557. if (this.textLayer) {
  12558. this.textLayer.cancel();
  12559. this.textLayer = null;
  12560. }
  12561. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer
  12562. .div)) {
  12563. this.annotationLayer.cancel();
  12564. this.annotationLayer = null;
  12565. this._annotationCanvasMap = null;
  12566. }
  12567. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this
  12568. .annotationEditorLayer.div)) {
  12569. this.annotationEditorLayer.cancel();
  12570. this.annotationEditorLayer = null;
  12571. }
  12572. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  12573. var _this$textHighlighter;
  12574. this.xfaLayer.cancel();
  12575. this.xfaLayer = null;
  12576. (_this$textHighlighter = this.textHighlighter) === null ||
  12577. _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter
  12578. .disable();
  12579. }
  12580. if (this._onTextLayerRendered) {
  12581. this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
  12582. this._onTextLayerRendered = null;
  12583. }
  12584. }
  12585. cssTransform(_ref2) {
  12586. let {
  12587. target,
  12588. redrawAnnotationLayer = false,
  12589. redrawAnnotationEditorLayer = false,
  12590. redrawXfaLayer = false
  12591. } = _ref2;
  12592. const width = this.viewport.width;
  12593. const height = this.viewport.height;
  12594. const div = this.div;
  12595. target.style.width = target.parentNode.style.width = div.style.width = Math
  12596. .floor(width) + "px";
  12597. target.style.height = target.parentNode.style.height = div.style.height = Math
  12598. .floor(height) + "px";
  12599. const relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(
  12600. target).rotation;
  12601. const absRotation = Math.abs(relativeRotation);
  12602. let scaleX = 1,
  12603. scaleY = 1;
  12604. if (absRotation === 90 || absRotation === 270) {
  12605. scaleX = height / width;
  12606. scaleY = width / height;
  12607. }
  12608. target.style.transform =
  12609. `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  12610. if (this.textLayer) {
  12611. const textLayerViewport = this.textLayer.viewport;
  12612. const textRelativeRotation = this.viewport.rotation - textLayerViewport
  12613. .rotation;
  12614. const textAbsRotation = Math.abs(textRelativeRotation);
  12615. let scale = width / textLayerViewport.width;
  12616. if (textAbsRotation === 90 || textAbsRotation === 270) {
  12617. scale = width / textLayerViewport.height;
  12618. }
  12619. const textLayerDiv = this.textLayer.textLayerDiv;
  12620. let transX, transY;
  12621. switch (textAbsRotation) {
  12622. case 0:
  12623. transX = transY = 0;
  12624. break;
  12625. case 90:
  12626. transX = 0;
  12627. transY = "-" + textLayerDiv.style.height;
  12628. break;
  12629. case 180:
  12630. transX = "-" + textLayerDiv.style.width;
  12631. transY = "-" + textLayerDiv.style.height;
  12632. break;
  12633. case 270:
  12634. transX = "-" + textLayerDiv.style.width;
  12635. transY = 0;
  12636. break;
  12637. default:
  12638. console.error("Bad rotation value.");
  12639. break;
  12640. }
  12641. textLayerDiv.style.transform = `rotate(${textAbsRotation}deg) ` +
  12642. `scale(${scale}) ` + `translate(${transX}, ${transY})`;
  12643. textLayerDiv.style.transformOrigin = "0% 0%";
  12644. }
  12645. if (redrawAnnotationLayer && this.annotationLayer) {
  12646. this._renderAnnotationLayer();
  12647. }
  12648. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  12649. this._renderAnnotationEditorLayer();
  12650. }
  12651. if (redrawXfaLayer && this.xfaLayer) {
  12652. this._renderXfaLayer();
  12653. }
  12654. }
  12655. get width() {
  12656. return this.viewport.width;
  12657. }
  12658. get height() {
  12659. return this.viewport.height;
  12660. }
  12661. getPagePoint(x, y) {
  12662. return this.viewport.convertToPdfPoint(x, y);
  12663. }
  12664. toggleLoadingIconSpinner() {
  12665. var _this$loadingIconDiv2;
  12666. let viewVisible = arguments.length > 0 && arguments[0] !== undefined ?
  12667. arguments[0] : false;
  12668. (_this$loadingIconDiv2 = this.loadingIconDiv) === null ||
  12669. _this$loadingIconDiv2 === void 0 ? void 0 : _this$loadingIconDiv2.classList
  12670. .toggle("notVisible", !viewVisible);
  12671. }
  12672. draw() {
  12673. var _this$annotationLayer2,
  12674. _this$annotationEdito3,
  12675. _this$xfaLayer2,
  12676. _this = this;
  12677. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  12678. console.error("Must be in new state before drawing");
  12679. this.reset();
  12680. }
  12681. const {
  12682. div,
  12683. pdfPage
  12684. } = this;
  12685. if (!pdfPage) {
  12686. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12687. if (this.loadingIconDiv) {
  12688. this.loadingIconDiv.remove();
  12689. delete this.loadingIconDiv;
  12690. }
  12691. return Promise.reject(new Error("pdfPage is not loaded"));
  12692. }
  12693. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12694. const canvasWrapper = document.createElement("div");
  12695. canvasWrapper.style.width = div.style.width;
  12696. canvasWrapper.style.height = div.style.height;
  12697. canvasWrapper.classList.add("canvasWrapper");
  12698. const lastDivBeforeTextDiv = ((_this$annotationLayer2 = this
  12699. .annotationLayer) === null || _this$annotationLayer2 === void 0 ?
  12700. void 0 : _this$annotationLayer2.div) || ((_this$annotationEdito3 = this
  12701. .annotationEditorLayer) === null || _this$annotationEdito3 ===
  12702. void 0 ? void 0 : _this$annotationEdito3.div);
  12703. if (lastDivBeforeTextDiv) {
  12704. lastDivBeforeTextDiv.before(canvasWrapper);
  12705. } else {
  12706. div.append(canvasWrapper);
  12707. }
  12708. let textLayer = null;
  12709. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this
  12710. .textLayerFactory) {
  12711. this._accessibilityManager || (this._accessibilityManager =
  12712. new _text_accessibility.TextAccessibilityManager());
  12713. const textLayerDiv = document.createElement("div");
  12714. textLayerDiv.className = "textLayer";
  12715. textLayerDiv.style.width = canvasWrapper.style.width;
  12716. textLayerDiv.style.height = canvasWrapper.style.height;
  12717. if (lastDivBeforeTextDiv) {
  12718. lastDivBeforeTextDiv.before(textLayerDiv);
  12719. } else {
  12720. div.append(textLayerDiv);
  12721. }
  12722. textLayer = this.textLayerFactory.createTextLayerBuilder({
  12723. textLayerDiv,
  12724. pageIndex: this.id - 1,
  12725. viewport: this.viewport,
  12726. enhanceTextSelection: this.textLayerMode === _ui_utils
  12727. .TextLayerMode.ENABLE_ENHANCE,
  12728. eventBus: this.eventBus,
  12729. highlighter: this.textHighlighter,
  12730. accessibilityManager: this._accessibilityManager
  12731. });
  12732. }
  12733. this.textLayer = textLayer;
  12734. if (_classPrivateFieldGet(this, _annotationMode) !== _pdfjsLib.AnnotationMode
  12735. .DISABLE && this.annotationLayerFactory) {
  12736. this._annotationCanvasMap || (this._annotationCanvasMap = new Map());
  12737. this.annotationLayer || (this.annotationLayer = this.annotationLayerFactory
  12738. .createAnnotationLayerBuilder({
  12739. pageDiv: div,
  12740. pdfPage,
  12741. imageResourcesPath: this.imageResourcesPath,
  12742. renderForms: _classPrivateFieldGet(this,
  12743. _annotationMode) === _pdfjsLib.AnnotationMode
  12744. .ENABLE_FORMS,
  12745. l10n: this.l10n,
  12746. annotationCanvasMap: this._annotationCanvasMap,
  12747. accessibilityManager: this._accessibilityManager
  12748. }));
  12749. }
  12750. if ((_this$xfaLayer2 = this.xfaLayer) !== null && _this$xfaLayer2 !== void 0 &&
  12751. _this$xfaLayer2.div) {
  12752. div.append(this.xfaLayer.div);
  12753. }
  12754. let renderContinueCallback = null;
  12755. if (this.renderingQueue) {
  12756. renderContinueCallback = cont => {
  12757. if (!this.renderingQueue.isHighestPriority(this)) {
  12758. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  12759. this.resume = () => {
  12760. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  12761. cont();
  12762. };
  12763. return;
  12764. }
  12765. cont();
  12766. };
  12767. }
  12768. const finishPaintTask = async function() {
  12769. let error = arguments.length > 0 && arguments[0] !== undefined ?
  12770. arguments[0] : null;
  12771. if (paintTask === _this.paintTask) {
  12772. _this.paintTask = null;
  12773. }
  12774. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  12775. _this._renderError = null;
  12776. return;
  12777. }
  12778. _this._renderError = error;
  12779. _this.renderingState = _ui_utils.RenderingStates.FINISHED;
  12780. if (_this.loadingIconDiv) {
  12781. _this.loadingIconDiv.remove();
  12782. delete _this.loadingIconDiv;
  12783. }
  12784. _this._resetZoomLayer(true);
  12785. _classPrivateFieldGet(_this, _useThumbnailCanvas)
  12786. .regularAnnotations = !paintTask.separateAnnots;
  12787. _this.eventBus.dispatch("pagerendered", {
  12788. source: _this,
  12789. pageNumber: _this.id,
  12790. cssTransform: false,
  12791. timestamp: performance.now(),
  12792. error: _this._renderError
  12793. });
  12794. if (error) {
  12795. throw error;
  12796. }
  12797. };
  12798. const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this
  12799. .paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  12800. paintTask.onRenderContinue = renderContinueCallback;
  12801. this.paintTask = paintTask;
  12802. const resultPromise = paintTask.promise.then(() => {
  12803. return finishPaintTask(null).then(() => {
  12804. if (textLayer) {
  12805. const readableStream = pdfPage.streamTextContent({
  12806. includeMarkedContent: true
  12807. });
  12808. textLayer.setTextContentStream(readableStream);
  12809. textLayer.render();
  12810. }
  12811. if (this.annotationLayer) {
  12812. this._renderAnnotationLayer().then(() => {
  12813. if (this.annotationEditorLayerFactory) {
  12814. this.annotationEditorLayer || (this
  12815. .annotationEditorLayer =
  12816. this
  12817. .annotationEditorLayerFactory
  12818. .createAnnotationEditorLayerBuilder({
  12819. pageDiv: div,
  12820. pdfPage,
  12821. l10n: this.l10n,
  12822. accessibilityManager: this
  12823. ._accessibilityManager
  12824. }));
  12825. this._renderAnnotationEditorLayer();
  12826. }
  12827. });
  12828. }
  12829. });
  12830. }, function(reason) {
  12831. return finishPaintTask(reason);
  12832. });
  12833. if (this.xfaLayerFactory) {
  12834. this.xfaLayer || (this.xfaLayer = this.xfaLayerFactory
  12835. .createXfaLayerBuilder({
  12836. pageDiv: div,
  12837. pdfPage
  12838. }));
  12839. this._renderXfaLayer();
  12840. }
  12841. if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
  12842. this._onTextLayerRendered = event => {
  12843. if (event.pageNumber !== this.id) {
  12844. return;
  12845. }
  12846. this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
  12847. this._onTextLayerRendered = null;
  12848. if (!this.canvas) {
  12849. return;
  12850. }
  12851. this.pdfPage.getStructTree().then(tree => {
  12852. if (!tree) {
  12853. return;
  12854. }
  12855. if (!this.canvas) {
  12856. return;
  12857. }
  12858. const treeDom = this.structTreeLayer.render(tree);
  12859. treeDom.classList.add("structTree");
  12860. this.canvas.append(treeDom);
  12861. });
  12862. };
  12863. this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
  12864. this.structTreeLayer = this.structTreeLayerFactory
  12865. .createStructTreeLayerBuilder({
  12866. pdfPage
  12867. });
  12868. }
  12869. div.setAttribute("data-loaded", true);
  12870. this.eventBus.dispatch("pagerender", {
  12871. source: this,
  12872. pageNumber: this.id
  12873. });
  12874. return resultPromise;
  12875. }
  12876. paintOnCanvas(canvasWrapper) {
  12877. const renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  12878. const result = {
  12879. promise: renderCapability.promise,
  12880. onRenderContinue(cont) {
  12881. cont();
  12882. },
  12883. cancel() {
  12884. renderTask.cancel();
  12885. },
  12886. get separateAnnots() {
  12887. return renderTask.separateAnnots;
  12888. }
  12889. };
  12890. const viewport = this.viewport;
  12891. const canvas = document.createElement("canvas");
  12892. canvas.setAttribute("role", "presentation");
  12893. canvas.hidden = true;
  12894. let isCanvasHidden = true;
  12895. const showCanvas = function() {
  12896. if (isCanvasHidden) {
  12897. canvas.hidden = false;
  12898. isCanvasHidden = false;
  12899. }
  12900. };
  12901. canvasWrapper.append(canvas);
  12902. this.canvas = canvas;
  12903. const ctx = canvas.getContext("2d", {
  12904. alpha: false
  12905. });
  12906. const outputScale = this.outputScale = new _ui_utils.OutputScale();
  12907. if (this.useOnlyCssZoom) {
  12908. const actualSizeViewport = viewport.clone({
  12909. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  12910. });
  12911. outputScale.sx *= actualSizeViewport.width / viewport.width;
  12912. outputScale.sy *= actualSizeViewport.height / viewport.height;
  12913. }
  12914. if (this.maxCanvasPixels > 0) {
  12915. const pixelsInViewport = viewport.width * viewport.height;
  12916. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12917. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12918. outputScale.sx = maxScale;
  12919. outputScale.sy = maxScale;
  12920. this.hasRestrictedScaling = true;
  12921. } else {
  12922. this.hasRestrictedScaling = false;
  12923. }
  12924. }
  12925. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12926. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12927. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx,
  12928. sfx[0]);
  12929. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy,
  12930. sfy[0]);
  12931. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) +
  12932. "px";
  12933. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) +
  12934. "px";
  12935. this.paintedViewportMap.set(canvas, viewport);
  12936. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0,
  12937. 0
  12938. ] : null;
  12939. const renderContext = {
  12940. canvasContext: ctx,
  12941. transform,
  12942. viewport: this.viewport,
  12943. annotationMode: _classPrivateFieldGet(this, _annotationMode),
  12944. optionalContentConfigPromise: this._optionalContentConfigPromise,
  12945. annotationCanvasMap: this._annotationCanvasMap,
  12946. pageColors: this.pageColors
  12947. };
  12948. const renderTask = this.pdfPage.render(renderContext);
  12949. renderTask.onContinue = function(cont) {
  12950. showCanvas();
  12951. if (result.onRenderContinue) {
  12952. result.onRenderContinue(cont);
  12953. } else {
  12954. cont();
  12955. }
  12956. };
  12957. renderTask.promise.then(function() {
  12958. showCanvas();
  12959. renderCapability.resolve();
  12960. }, function(error) {
  12961. showCanvas();
  12962. renderCapability.reject(error);
  12963. });
  12964. return result;
  12965. }
  12966. paintOnSvg(wrapper) {
  12967. let cancelled = false;
  12968. const ensureNotCancelled = () => {
  12969. if (cancelled) {
  12970. throw new _pdfjsLib.RenderingCancelledException(
  12971. `Rendering cancelled, page ${this.id}`, "svg");
  12972. }
  12973. };
  12974. const pdfPage = this.pdfPage;
  12975. const actualSizeViewport = this.viewport.clone({
  12976. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  12977. });
  12978. const promise = pdfPage.getOperatorList({
  12979. annotationMode: _classPrivateFieldGet(this, _annotationMode)
  12980. }).then(opList => {
  12981. ensureNotCancelled();
  12982. const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage
  12983. .objs);
  12984. return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
  12985. ensureNotCancelled();
  12986. this.svg = svg;
  12987. this.paintedViewportMap.set(svg, actualSizeViewport);
  12988. svg.style.width = wrapper.style.width;
  12989. svg.style.height = wrapper.style.height;
  12990. this.renderingState = _ui_utils.RenderingStates
  12991. .FINISHED;
  12992. wrapper.append(svg);
  12993. });
  12994. });
  12995. return {
  12996. promise,
  12997. onRenderContinue(cont) {
  12998. cont();
  12999. },
  13000. cancel() {
  13001. cancelled = true;
  13002. },
  13003. get separateAnnots() {
  13004. return false;
  13005. }
  13006. };
  13007. }
  13008. setPageLabel(label) {
  13009. this.pageLabel = typeof label === "string" ? label : null;
  13010. if (this.pageLabel !== null) {
  13011. this.div.setAttribute("data-page-label", this.pageLabel);
  13012. } else {
  13013. this.div.removeAttribute("data-page-label");
  13014. }
  13015. }
  13016. get thumbnailCanvas() {
  13017. const {
  13018. initialOptionalContent,
  13019. regularAnnotations
  13020. } = _classPrivateFieldGet(this, _useThumbnailCanvas);
  13021. return initialOptionalContent && regularAnnotations ? this.canvas : null;
  13022. }
  13023. }
  13024. exports.PDFPageView = PDFPageView;
  13025. /***/
  13026. }),
  13027. /* 35 */
  13028. /***/
  13029. ((__unused_webpack_module, exports, __webpack_require__) => {
  13030. Object.defineProperty(exports, "__esModule", ({
  13031. value: true
  13032. }));
  13033. exports.TextAccessibilityManager = void 0;
  13034. var _ui_utils = __webpack_require__(1);
  13035. function _classPrivateMethodInitSpec(obj, privateSet) {
  13036. _checkPrivateRedeclaration(obj, privateSet);
  13037. privateSet.add(obj);
  13038. }
  13039. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  13040. _checkPrivateRedeclaration(obj, privateMap);
  13041. privateMap.set(obj, value);
  13042. }
  13043. function _checkPrivateRedeclaration(obj, privateCollection) {
  13044. if (privateCollection.has(obj)) {
  13045. throw new TypeError(
  13046. "Cannot initialize the same private elements twice on an object");
  13047. }
  13048. }
  13049. function _classPrivateMethodGet(receiver, privateSet, fn) {
  13050. if (!privateSet.has(receiver)) {
  13051. throw new TypeError("attempted to get private field on non-instance");
  13052. }
  13053. return fn;
  13054. }
  13055. function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
  13056. _classCheckPrivateStaticAccess(receiver, classConstructor);
  13057. return method;
  13058. }
  13059. function _classCheckPrivateStaticAccess(receiver, classConstructor) {
  13060. if (receiver !== classConstructor) {
  13061. throw new TypeError("Private static access of wrong provenance");
  13062. }
  13063. }
  13064. function _classPrivateFieldGet(receiver, privateMap) {
  13065. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  13066. return _classApplyDescriptorGet(receiver, descriptor);
  13067. }
  13068. function _classApplyDescriptorGet(receiver, descriptor) {
  13069. if (descriptor.get) {
  13070. return descriptor.get.call(receiver);
  13071. }
  13072. return descriptor.value;
  13073. }
  13074. function _classPrivateFieldSet(receiver, privateMap, value) {
  13075. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  13076. _classApplyDescriptorSet(receiver, descriptor, value);
  13077. return value;
  13078. }
  13079. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  13080. if (!privateMap.has(receiver)) {
  13081. throw new TypeError("attempted to " + action + " private field on non-instance");
  13082. }
  13083. return privateMap.get(receiver);
  13084. }
  13085. function _classApplyDescriptorSet(receiver, descriptor, value) {
  13086. if (descriptor.set) {
  13087. descriptor.set.call(receiver, value);
  13088. } else {
  13089. if (!descriptor.writable) {
  13090. throw new TypeError("attempted to set read only private field");
  13091. }
  13092. descriptor.value = value;
  13093. }
  13094. }
  13095. var _enabled = /*#__PURE__*/ new WeakMap();
  13096. var _textChildren = /*#__PURE__*/ new WeakMap();
  13097. var _textNodes = /*#__PURE__*/ new WeakMap();
  13098. var _waitingElements = /*#__PURE__*/ new WeakMap();
  13099. var _addIdToAriaOwns = /*#__PURE__*/ new WeakSet();
  13100. class TextAccessibilityManager {
  13101. constructor() {
  13102. _classPrivateMethodInitSpec(this, _addIdToAriaOwns);
  13103. _classPrivateFieldInitSpec(this, _enabled, {
  13104. writable: true,
  13105. value: false
  13106. });
  13107. _classPrivateFieldInitSpec(this, _textChildren, {
  13108. writable: true,
  13109. value: null
  13110. });
  13111. _classPrivateFieldInitSpec(this, _textNodes, {
  13112. writable: true,
  13113. value: new Map()
  13114. });
  13115. _classPrivateFieldInitSpec(this, _waitingElements, {
  13116. writable: true,
  13117. value: new Map()
  13118. });
  13119. }
  13120. setTextMapping(textDivs) {
  13121. _classPrivateFieldSet(this, _textChildren, textDivs);
  13122. }
  13123. enable() {
  13124. if (_classPrivateFieldGet(this, _enabled)) {
  13125. throw new Error("TextAccessibilityManager is already enabled.");
  13126. }
  13127. if (!_classPrivateFieldGet(this, _textChildren)) {
  13128. throw new Error("Text divs and strings have not been set.");
  13129. }
  13130. _classPrivateFieldSet(this, _enabled, true);
  13131. _classPrivateFieldSet(this, _textChildren, _classPrivateFieldGet(this,
  13132. _textChildren).slice());
  13133. _classPrivateFieldGet(this, _textChildren).sort(_classStaticPrivateMethodGet(
  13134. TextAccessibilityManager, TextAccessibilityManager,
  13135. _compareElementPositions));
  13136. if (_classPrivateFieldGet(this, _textNodes).size > 0) {
  13137. const textChildren = _classPrivateFieldGet(this, _textChildren);
  13138. for (const [id, nodeIndex] of _classPrivateFieldGet(this, _textNodes)) {
  13139. const element = document.getElementById(id);
  13140. if (!element) {
  13141. _classPrivateFieldGet(this, _textNodes).delete(id);
  13142. continue;
  13143. }
  13144. _classPrivateMethodGet(this, _addIdToAriaOwns, _addIdToAriaOwns2).call(
  13145. this, id, textChildren[nodeIndex]);
  13146. }
  13147. }
  13148. for (const [element, isRemovable] of _classPrivateFieldGet(this,
  13149. _waitingElements)) {
  13150. this.addPointerInTextLayer(element, isRemovable);
  13151. }
  13152. _classPrivateFieldGet(this, _waitingElements).clear();
  13153. }
  13154. disable() {
  13155. if (!_classPrivateFieldGet(this, _enabled)) {
  13156. return;
  13157. }
  13158. _classPrivateFieldGet(this, _waitingElements).clear();
  13159. _classPrivateFieldSet(this, _textChildren, null);
  13160. _classPrivateFieldSet(this, _enabled, false);
  13161. }
  13162. removePointerInTextLayer(element) {
  13163. var _owns;
  13164. if (!_classPrivateFieldGet(this, _enabled)) {
  13165. _classPrivateFieldGet(this, _waitingElements).delete(element);
  13166. return;
  13167. }
  13168. const children = _classPrivateFieldGet(this, _textChildren);
  13169. if (!children || children.length === 0) {
  13170. return;
  13171. }
  13172. const {
  13173. id
  13174. } = element;
  13175. const nodeIndex = _classPrivateFieldGet(this, _textNodes).get(id);
  13176. if (nodeIndex === undefined) {
  13177. return;
  13178. }
  13179. const node = children[nodeIndex];
  13180. _classPrivateFieldGet(this, _textNodes).delete(id);
  13181. let owns = node.getAttribute("aria-owns");
  13182. if ((_owns = owns) !== null && _owns !== void 0 && _owns.includes(id)) {
  13183. owns = owns.split(" ").filter(x => x !== id).join(" ");
  13184. if (owns) {
  13185. node.setAttribute("aria-owns", owns);
  13186. } else {
  13187. node.removeAttribute("aria-owns");
  13188. node.setAttribute("role", "presentation");
  13189. }
  13190. }
  13191. }
  13192. addPointerInTextLayer(element, isRemovable) {
  13193. const {
  13194. id
  13195. } = element;
  13196. if (!id) {
  13197. return;
  13198. }
  13199. if (!_classPrivateFieldGet(this, _enabled)) {
  13200. _classPrivateFieldGet(this, _waitingElements).set(element, isRemovable);
  13201. return;
  13202. }
  13203. if (isRemovable) {
  13204. this.removePointerInTextLayer(element);
  13205. }
  13206. const children = _classPrivateFieldGet(this, _textChildren);
  13207. if (!children || children.length === 0) {
  13208. return;
  13209. }
  13210. const index = (0, _ui_utils.binarySearchFirstItem)(children, node =>
  13211. _classStaticPrivateMethodGet(TextAccessibilityManager,
  13212. TextAccessibilityManager, _compareElementPositions).call(
  13213. TextAccessibilityManager, element, node) < 0);
  13214. const nodeIndex = Math.max(0, index - 1);
  13215. _classPrivateMethodGet(this, _addIdToAriaOwns, _addIdToAriaOwns2).call(this, id,
  13216. children[nodeIndex]);
  13217. _classPrivateFieldGet(this, _textNodes).set(id, nodeIndex);
  13218. }
  13219. moveElementInDOM(container, element, contentElement, isRemovable) {
  13220. this.addPointerInTextLayer(contentElement, isRemovable);
  13221. if (!container.hasChildNodes()) {
  13222. container.append(element);
  13223. return;
  13224. }
  13225. const children = Array.from(container.childNodes).filter(node => node !==
  13226. element);
  13227. if (children.length === 0) {
  13228. return;
  13229. }
  13230. const elementToCompare = contentElement || element;
  13231. const index = (0, _ui_utils.binarySearchFirstItem)(children, node =>
  13232. _classStaticPrivateMethodGet(TextAccessibilityManager,
  13233. TextAccessibilityManager, _compareElementPositions).call(
  13234. TextAccessibilityManager, elementToCompare, node) < 0);
  13235. if (index === 0) {
  13236. children[0].before(element);
  13237. } else {
  13238. children[index - 1].after(element);
  13239. }
  13240. }
  13241. }
  13242. exports.TextAccessibilityManager = TextAccessibilityManager;
  13243. function _compareElementPositions(e1, e2) {
  13244. const rect1 = e1.getBoundingClientRect();
  13245. const rect2 = e2.getBoundingClientRect();
  13246. if (rect1.width === 0 && rect1.height === 0) {
  13247. return +1;
  13248. }
  13249. if (rect2.width === 0 && rect2.height === 0) {
  13250. return -1;
  13251. }
  13252. const top1 = rect1.y;
  13253. const bot1 = rect1.y + rect1.height;
  13254. const mid1 = rect1.y + rect1.height / 2;
  13255. const top2 = rect2.y;
  13256. const bot2 = rect2.y + rect2.height;
  13257. const mid2 = rect2.y + rect2.height / 2;
  13258. if (mid1 <= top2 && mid2 >= bot1) {
  13259. return -1;
  13260. }
  13261. if (mid2 <= top1 && mid1 >= bot2) {
  13262. return +1;
  13263. }
  13264. const centerX1 = rect1.x + rect1.width / 2;
  13265. const centerX2 = rect2.x + rect2.width / 2;
  13266. return centerX1 - centerX2;
  13267. }
  13268. function _addIdToAriaOwns2(id, node) {
  13269. const owns = node.getAttribute("aria-owns");
  13270. if (!(owns !== null && owns !== void 0 && owns.includes(id))) {
  13271. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  13272. }
  13273. node.removeAttribute("role");
  13274. }
  13275. /***/
  13276. }),
  13277. /* 36 */
  13278. /***/
  13279. ((__unused_webpack_module, exports) => {
  13280. Object.defineProperty(exports, "__esModule", ({
  13281. value: true
  13282. }));
  13283. exports.StructTreeLayerBuilder = void 0;
  13284. const PDF_ROLE_TO_HTML_ROLE = {
  13285. Document: null,
  13286. DocumentFragment: null,
  13287. Part: "group",
  13288. Sect: "group",
  13289. Div: "group",
  13290. Aside: "note",
  13291. NonStruct: "none",
  13292. P: null,
  13293. H: "heading",
  13294. Title: null,
  13295. FENote: "note",
  13296. Sub: "group",
  13297. Lbl: null,
  13298. Span: null,
  13299. Em: null,
  13300. Strong: null,
  13301. Link: "link",
  13302. Annot: "note",
  13303. Form: "form",
  13304. Ruby: null,
  13305. RB: null,
  13306. RT: null,
  13307. RP: null,
  13308. Warichu: null,
  13309. WT: null,
  13310. WP: null,
  13311. L: "list",
  13312. LI: "listitem",
  13313. LBody: null,
  13314. Table: "table",
  13315. TR: "row",
  13316. TH: "columnheader",
  13317. TD: "cell",
  13318. THead: "columnheader",
  13319. TBody: null,
  13320. TFoot: null,
  13321. Caption: null,
  13322. Figure: "figure",
  13323. Formula: null,
  13324. Artifact: null
  13325. };
  13326. const HEADING_PATTERN = /^H(\d+)$/;
  13327. class StructTreeLayerBuilder {
  13328. constructor(_ref) {
  13329. let {
  13330. pdfPage
  13331. } = _ref;
  13332. this.pdfPage = pdfPage;
  13333. }
  13334. render(structTree) {
  13335. return this._walk(structTree);
  13336. }
  13337. _setAttributes(structElement, htmlElement) {
  13338. if (structElement.alt !== undefined) {
  13339. htmlElement.setAttribute("aria-label", structElement.alt);
  13340. }
  13341. if (structElement.id !== undefined) {
  13342. htmlElement.setAttribute("aria-owns", structElement.id);
  13343. }
  13344. if (structElement.lang !== undefined) {
  13345. htmlElement.setAttribute("lang", structElement.lang);
  13346. }
  13347. }
  13348. _walk(node) {
  13349. if (!node) {
  13350. return null;
  13351. }
  13352. const element = document.createElement("span");
  13353. if ("role" in node) {
  13354. const {
  13355. role
  13356. } = node;
  13357. const match = role.match(HEADING_PATTERN);
  13358. if (match) {
  13359. element.setAttribute("role", "heading");
  13360. element.setAttribute("aria-level", match[1]);
  13361. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  13362. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  13363. }
  13364. }
  13365. this._setAttributes(node, element);
  13366. if (node.children) {
  13367. if (node.children.length === 1 && "id" in node.children[0]) {
  13368. this._setAttributes(node.children[0], element);
  13369. } else {
  13370. for (const kid of node.children) {
  13371. element.append(this._walk(kid));
  13372. }
  13373. }
  13374. }
  13375. return element;
  13376. }
  13377. }
  13378. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  13379. /***/
  13380. }),
  13381. /* 37 */
  13382. /***/
  13383. ((__unused_webpack_module, exports) => {
  13384. Object.defineProperty(exports, "__esModule", ({
  13385. value: true
  13386. }));
  13387. exports.TextHighlighter = void 0;
  13388. class TextHighlighter {
  13389. constructor(_ref) {
  13390. let {
  13391. findController,
  13392. eventBus,
  13393. pageIndex
  13394. } = _ref;
  13395. this.findController = findController;
  13396. this.matches = [];
  13397. this.eventBus = eventBus;
  13398. this.pageIdx = pageIndex;
  13399. this._onUpdateTextLayerMatches = null;
  13400. this.textDivs = null;
  13401. this.textContentItemsStr = null;
  13402. this.enabled = false;
  13403. }
  13404. setTextMapping(divs, texts) {
  13405. this.textDivs = divs;
  13406. this.textContentItemsStr = texts;
  13407. }
  13408. enable() {
  13409. if (!this.textDivs || !this.textContentItemsStr) {
  13410. throw new Error("Text divs and strings have not been set.");
  13411. }
  13412. if (this.enabled) {
  13413. throw new Error("TextHighlighter is already enabled.");
  13414. }
  13415. this.enabled = true;
  13416. if (!this._onUpdateTextLayerMatches) {
  13417. this._onUpdateTextLayerMatches = evt => {
  13418. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  13419. this._updateMatches();
  13420. }
  13421. };
  13422. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  13423. }
  13424. this._updateMatches();
  13425. }
  13426. disable() {
  13427. if (!this.enabled) {
  13428. return;
  13429. }
  13430. this.enabled = false;
  13431. if (this._onUpdateTextLayerMatches) {
  13432. this.eventBus._off("updatetextlayermatches", this
  13433. ._onUpdateTextLayerMatches);
  13434. this._onUpdateTextLayerMatches = null;
  13435. }
  13436. }
  13437. _convertMatches(matches, matchesLength) {
  13438. if (!matches) {
  13439. return [];
  13440. }
  13441. const {
  13442. textContentItemsStr
  13443. } = this;
  13444. let i = 0,
  13445. iIndex = 0;
  13446. const end = textContentItemsStr.length - 1;
  13447. const result = [];
  13448. for (let m = 0, mm = matches.length; m < mm; m++) {
  13449. let matchIdx = matches[m];
  13450. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  13451. iIndex += textContentItemsStr[i].length;
  13452. i++;
  13453. }
  13454. if (i === textContentItemsStr.length) {
  13455. console.error("Could not find a matching mapping");
  13456. }
  13457. const match = {
  13458. begin: {
  13459. divIdx: i,
  13460. offset: matchIdx - iIndex
  13461. }
  13462. };
  13463. matchIdx += matchesLength[m];
  13464. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  13465. iIndex += textContentItemsStr[i].length;
  13466. i++;
  13467. }
  13468. match.end = {
  13469. divIdx: i,
  13470. offset: matchIdx - iIndex
  13471. };
  13472. result.push(match);
  13473. }
  13474. return result;
  13475. }
  13476. _renderMatches(matches) {
  13477. if (matches.length === 0) {
  13478. return;
  13479. }
  13480. const {
  13481. findController,
  13482. pageIdx
  13483. } = this;
  13484. const {
  13485. textContentItemsStr,
  13486. textDivs
  13487. } = this;
  13488. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  13489. const selectedMatchIdx = findController.selected.matchIdx;
  13490. const highlightAll = findController.state.highlightAll;
  13491. let prevEnd = null;
  13492. const infinity = {
  13493. divIdx: -1,
  13494. offset: undefined
  13495. };
  13496. function beginText(begin, className) {
  13497. const divIdx = begin.divIdx;
  13498. textDivs[divIdx].textContent = "";
  13499. return appendTextToDiv(divIdx, 0, begin.offset, className);
  13500. }
  13501. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  13502. let div = textDivs[divIdx];
  13503. if (div.nodeType === Node.TEXT_NODE) {
  13504. const span = document.createElement("span");
  13505. div.before(span);
  13506. span.append(div);
  13507. textDivs[divIdx] = span;
  13508. div = span;
  13509. }
  13510. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  13511. const node = document.createTextNode(content);
  13512. if (className) {
  13513. const span = document.createElement("span");
  13514. span.className = `${className} appended`;
  13515. span.append(node);
  13516. div.append(span);
  13517. return className.includes("selected") ? span.offsetLeft : 0;
  13518. }
  13519. div.append(node);
  13520. return 0;
  13521. }
  13522. let i0 = selectedMatchIdx,
  13523. i1 = i0 + 1;
  13524. if (highlightAll) {
  13525. i0 = 0;
  13526. i1 = matches.length;
  13527. } else if (!isSelectedPage) {
  13528. return;
  13529. }
  13530. for (let i = i0; i < i1; i++) {
  13531. const match = matches[i];
  13532. const begin = match.begin;
  13533. const end = match.end;
  13534. const isSelected = isSelectedPage && i === selectedMatchIdx;
  13535. const highlightSuffix = isSelected ? " selected" : "";
  13536. let selectedLeft = 0;
  13537. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  13538. if (prevEnd !== null) {
  13539. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13540. }
  13541. beginText(begin);
  13542. } else {
  13543. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  13544. }
  13545. if (begin.divIdx === end.divIdx) {
  13546. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset,
  13547. "highlight" + highlightSuffix);
  13548. } else {
  13549. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity
  13550. .offset, "highlight begin" + highlightSuffix);
  13551. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  13552. textDivs[n0].className = "highlight middle" + highlightSuffix;
  13553. }
  13554. beginText(end, "highlight end" + highlightSuffix);
  13555. }
  13556. prevEnd = end;
  13557. if (isSelected) {
  13558. findController.scrollMatchIntoView({
  13559. element: textDivs[begin.divIdx],
  13560. selectedLeft,
  13561. pageIndex: pageIdx,
  13562. matchIndex: selectedMatchIdx
  13563. });
  13564. }
  13565. }
  13566. if (prevEnd) {
  13567. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  13568. }
  13569. }
  13570. _updateMatches() {
  13571. if (!this.enabled) {
  13572. return;
  13573. }
  13574. const {
  13575. findController,
  13576. matches,
  13577. pageIdx
  13578. } = this;
  13579. const {
  13580. textContentItemsStr,
  13581. textDivs
  13582. } = this;
  13583. let clearedUntilDivIdx = -1;
  13584. for (let i = 0, ii = matches.length; i < ii; i++) {
  13585. const match = matches[i];
  13586. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  13587. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  13588. const div = textDivs[n];
  13589. div.textContent = textContentItemsStr[n];
  13590. div.className = "";
  13591. }
  13592. clearedUntilDivIdx = match.end.divIdx + 1;
  13593. }
  13594. if (!(findController !== null && findController !== void 0 && findController
  13595. .highlightMatches)) {
  13596. return;
  13597. }
  13598. const pageMatches = findController.pageMatches[pageIdx] || null;
  13599. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  13600. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  13601. this._renderMatches(this.matches);
  13602. }
  13603. }
  13604. exports.TextHighlighter = TextHighlighter;
  13605. /***/
  13606. }),
  13607. /* 38 */
  13608. /***/
  13609. ((__unused_webpack_module, exports, __webpack_require__) => {
  13610. Object.defineProperty(exports, "__esModule", ({
  13611. value: true
  13612. }));
  13613. exports.TextLayerBuilder = void 0;
  13614. var _pdfjsLib = __webpack_require__(5);
  13615. const EXPAND_DIVS_TIMEOUT = 300;
  13616. class TextLayerBuilder {
  13617. constructor(_ref) {
  13618. let {
  13619. textLayerDiv,
  13620. eventBus,
  13621. pageIndex,
  13622. viewport,
  13623. highlighter = null,
  13624. enhanceTextSelection = false,
  13625. accessibilityManager = null
  13626. } = _ref;
  13627. this.textLayerDiv = textLayerDiv;
  13628. this.eventBus = eventBus;
  13629. this.textContent = null;
  13630. this.textContentItemsStr = [];
  13631. this.textContentStream = null;
  13632. this.renderingDone = false;
  13633. this.pageNumber = pageIndex + 1;
  13634. this.viewport = viewport;
  13635. this.textDivs = [];
  13636. this.textLayerRenderTask = null;
  13637. this.highlighter = highlighter;
  13638. this.enhanceTextSelection = enhanceTextSelection;
  13639. this.accessibilityManager = accessibilityManager;
  13640. this._bindMouse();
  13641. }
  13642. _finishRendering() {
  13643. this.renderingDone = true;
  13644. if (!this.enhanceTextSelection) {
  13645. const endOfContent = document.createElement("div");
  13646. endOfContent.className = "endOfContent";
  13647. this.textLayerDiv.append(endOfContent);
  13648. }
  13649. this.eventBus.dispatch("textlayerrendered", {
  13650. source: this,
  13651. pageNumber: this.pageNumber,
  13652. numTextDivs: this.textDivs.length
  13653. });
  13654. }
  13655. render() {
  13656. var _this$highlighter, _this$accessibilityMa;
  13657. let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  13658. 0] : 0;
  13659. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  13660. return;
  13661. }
  13662. this.cancel();
  13663. this.textDivs.length = 0;
  13664. (_this$highlighter = this.highlighter) === null || _this$highlighter ===
  13665. void 0 ? void 0 : _this$highlighter.setTextMapping(this.textDivs, this
  13666. .textContentItemsStr);
  13667. (_this$accessibilityMa = this.accessibilityManager) === null ||
  13668. _this$accessibilityMa === void 0 ? void 0 : _this$accessibilityMa
  13669. .setTextMapping(this.textDivs);
  13670. const textLayerFrag = document.createDocumentFragment();
  13671. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  13672. textContent: this.textContent,
  13673. textContentStream: this.textContentStream,
  13674. container: textLayerFrag,
  13675. viewport: this.viewport,
  13676. textDivs: this.textDivs,
  13677. textContentItemsStr: this.textContentItemsStr,
  13678. timeout,
  13679. enhanceTextSelection: this.enhanceTextSelection
  13680. });
  13681. this.textLayerRenderTask.promise.then(() => {
  13682. var _this$highlighter2, _this$accessibilityMa2;
  13683. this.textLayerDiv.append(textLayerFrag);
  13684. this._finishRendering();
  13685. (_this$highlighter2 = this.highlighter) === null ||
  13686. _this$highlighter2 === void 0 ? void 0 : _this$highlighter2
  13687. .enable();
  13688. (_this$accessibilityMa2 = this.accessibilityManager) === null ||
  13689. _this$accessibilityMa2 === void 0 ? void 0 :
  13690. _this$accessibilityMa2.enable();
  13691. }, function(reason) {});
  13692. }
  13693. cancel() {
  13694. var _this$highlighter3, _this$accessibilityMa3;
  13695. if (this.textLayerRenderTask) {
  13696. this.textLayerRenderTask.cancel();
  13697. this.textLayerRenderTask = null;
  13698. }
  13699. (_this$highlighter3 = this.highlighter) === null || _this$highlighter3 ===
  13700. void 0 ? void 0 : _this$highlighter3.disable();
  13701. (_this$accessibilityMa3 = this.accessibilityManager) === null ||
  13702. _this$accessibilityMa3 === void 0 ? void 0 : _this$accessibilityMa3
  13703. .disable();
  13704. }
  13705. setTextContentStream(readableStream) {
  13706. this.cancel();
  13707. this.textContentStream = readableStream;
  13708. }
  13709. setTextContent(textContent) {
  13710. this.cancel();
  13711. this.textContent = textContent;
  13712. }
  13713. _bindMouse() {
  13714. const div = this.textLayerDiv;
  13715. let expandDivsTimer = null;
  13716. div.addEventListener("mousedown", evt => {
  13717. if (this.enhanceTextSelection && this.textLayerRenderTask) {
  13718. this.textLayerRenderTask.expandTextDivs(true);
  13719. if (expandDivsTimer) {
  13720. clearTimeout(expandDivsTimer);
  13721. expandDivsTimer = null;
  13722. }
  13723. return;
  13724. }
  13725. const end = div.querySelector(".endOfContent");
  13726. if (!end) {
  13727. return;
  13728. }
  13729. let adjustTop = evt.target !== div;
  13730. adjustTop = adjustTop && window.getComputedStyle(end)
  13731. .getPropertyValue("-moz-user-select") !== "none";
  13732. if (adjustTop) {
  13733. const divBounds = div.getBoundingClientRect();
  13734. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds
  13735. .height);
  13736. end.style.top = (r * 100).toFixed(2) + "%";
  13737. }
  13738. end.classList.add("active");
  13739. });
  13740. div.addEventListener("mouseup", () => {
  13741. if (this.enhanceTextSelection && this.textLayerRenderTask) {
  13742. expandDivsTimer = setTimeout(() => {
  13743. if (this.textLayerRenderTask) {
  13744. this.textLayerRenderTask.expandTextDivs(false);
  13745. }
  13746. expandDivsTimer = null;
  13747. }, EXPAND_DIVS_TIMEOUT);
  13748. return;
  13749. }
  13750. const end = div.querySelector(".endOfContent");
  13751. if (!end) {
  13752. return;
  13753. }
  13754. end.style.top = "";
  13755. end.classList.remove("active");
  13756. });
  13757. }
  13758. }
  13759. exports.TextLayerBuilder = TextLayerBuilder;
  13760. /***/
  13761. }),
  13762. /* 39 */
  13763. /***/
  13764. ((__unused_webpack_module, exports, __webpack_require__) => {
  13765. Object.defineProperty(exports, "__esModule", ({
  13766. value: true
  13767. }));
  13768. exports.XfaLayerBuilder = void 0;
  13769. var _pdfjsLib = __webpack_require__(5);
  13770. class XfaLayerBuilder {
  13771. constructor(_ref) {
  13772. let {
  13773. pageDiv,
  13774. pdfPage,
  13775. annotationStorage = null,
  13776. linkService,
  13777. xfaHtml = null
  13778. } = _ref;
  13779. this.pageDiv = pageDiv;
  13780. this.pdfPage = pdfPage;
  13781. this.annotationStorage = annotationStorage;
  13782. this.linkService = linkService;
  13783. this.xfaHtml = xfaHtml;
  13784. this.div = null;
  13785. this._cancelled = false;
  13786. }
  13787. render(viewport) {
  13788. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  13789. "display";
  13790. if (intent === "print") {
  13791. const parameters = {
  13792. viewport: viewport.clone({
  13793. dontFlip: true
  13794. }),
  13795. div: this.div,
  13796. xfaHtml: this.xfaHtml,
  13797. annotationStorage: this.annotationStorage,
  13798. linkService: this.linkService,
  13799. intent
  13800. };
  13801. const div = document.createElement("div");
  13802. this.pageDiv.append(div);
  13803. parameters.div = div;
  13804. const result = _pdfjsLib.XfaLayer.render(parameters);
  13805. return Promise.resolve(result);
  13806. }
  13807. return this.pdfPage.getXfa().then(xfaHtml => {
  13808. if (this._cancelled || !xfaHtml) {
  13809. return {
  13810. textDivs: []
  13811. };
  13812. }
  13813. const parameters = {
  13814. viewport: viewport.clone({
  13815. dontFlip: true
  13816. }),
  13817. div: this.div,
  13818. xfaHtml,
  13819. annotationStorage: this.annotationStorage,
  13820. linkService: this.linkService,
  13821. intent
  13822. };
  13823. if (this.div) {
  13824. return _pdfjsLib.XfaLayer.update(parameters);
  13825. }
  13826. this.div = document.createElement("div");
  13827. this.pageDiv.append(this.div);
  13828. parameters.div = this.div;
  13829. return _pdfjsLib.XfaLayer.render(parameters);
  13830. }).catch(error => {
  13831. console.error(error);
  13832. });
  13833. }
  13834. cancel() {
  13835. this._cancelled = true;
  13836. }
  13837. hide() {
  13838. if (!this.div) {
  13839. return;
  13840. }
  13841. this.div.hidden = true;
  13842. }
  13843. }
  13844. exports.XfaLayerBuilder = XfaLayerBuilder;
  13845. /***/
  13846. }),
  13847. /* 40 */
  13848. /***/
  13849. ((__unused_webpack_module, exports, __webpack_require__) => {
  13850. Object.defineProperty(exports, "__esModule", ({
  13851. value: true
  13852. }));
  13853. exports.SecondaryToolbar = void 0;
  13854. var _ui_utils = __webpack_require__(1);
  13855. var _pdf_cursor_tools = __webpack_require__(7);
  13856. var _base_viewer = __webpack_require__(30);
  13857. function _classPrivateMethodInitSpec(obj, privateSet) {
  13858. _checkPrivateRedeclaration(obj, privateSet);
  13859. privateSet.add(obj);
  13860. }
  13861. function _checkPrivateRedeclaration(obj, privateCollection) {
  13862. if (privateCollection.has(obj)) {
  13863. throw new TypeError(
  13864. "Cannot initialize the same private elements twice on an object");
  13865. }
  13866. }
  13867. function _classPrivateMethodGet(receiver, privateSet, fn) {
  13868. if (!privateSet.has(receiver)) {
  13869. throw new TypeError("attempted to get private field on non-instance");
  13870. }
  13871. return fn;
  13872. }
  13873. var _updateUIState = /*#__PURE__*/ new WeakSet();
  13874. var _bindClickListeners = /*#__PURE__*/ new WeakSet();
  13875. var _bindCursorToolsListener = /*#__PURE__*/ new WeakSet();
  13876. var _bindScrollModeListener = /*#__PURE__*/ new WeakSet();
  13877. var _bindSpreadModeListener = /*#__PURE__*/ new WeakSet();
  13878. class SecondaryToolbar {
  13879. constructor(options, eventBus) {
  13880. _classPrivateMethodInitSpec(this, _bindSpreadModeListener);
  13881. _classPrivateMethodInitSpec(this, _bindScrollModeListener);
  13882. _classPrivateMethodInitSpec(this, _bindCursorToolsListener);
  13883. _classPrivateMethodInitSpec(this, _bindClickListeners);
  13884. _classPrivateMethodInitSpec(this, _updateUIState);
  13885. this.toolbar = options.toolbar;
  13886. this.toggleButton = options.toggleButton;
  13887. this.buttons = [{
  13888. element: options.presentationModeButton,
  13889. eventName: "presentationmode",
  13890. close: true
  13891. }, {
  13892. element: options.printButton,
  13893. eventName: "print",
  13894. close: true
  13895. }, {
  13896. element: options.downloadButton,
  13897. eventName: "download",
  13898. close: true
  13899. }, {
  13900. element: options.viewBookmarkButton,
  13901. eventName: null,
  13902. close: true
  13903. }, {
  13904. element: options.firstPageButton,
  13905. eventName: "firstpage",
  13906. close: true
  13907. }, {
  13908. element: options.lastPageButton,
  13909. eventName: "lastpage",
  13910. close: true
  13911. }, {
  13912. element: options.pageRotateCwButton,
  13913. eventName: "rotatecw",
  13914. close: false
  13915. }, {
  13916. element: options.pageRotateCcwButton,
  13917. eventName: "rotateccw",
  13918. close: false
  13919. }, {
  13920. element: options.cursorSelectToolButton,
  13921. eventName: "switchcursortool",
  13922. eventDetails: {
  13923. tool: _pdf_cursor_tools.CursorTool.SELECT
  13924. },
  13925. close: true
  13926. }, {
  13927. element: options.cursorHandToolButton,
  13928. eventName: "switchcursortool",
  13929. eventDetails: {
  13930. tool: _pdf_cursor_tools.CursorTool.HAND
  13931. },
  13932. close: true
  13933. }, {
  13934. element: options.scrollPageButton,
  13935. eventName: "switchscrollmode",
  13936. eventDetails: {
  13937. mode: _ui_utils.ScrollMode.PAGE
  13938. },
  13939. close: true
  13940. }, {
  13941. element: options.scrollVerticalButton,
  13942. eventName: "switchscrollmode",
  13943. eventDetails: {
  13944. mode: _ui_utils.ScrollMode.VERTICAL
  13945. },
  13946. close: true
  13947. }, {
  13948. element: options.scrollHorizontalButton,
  13949. eventName: "switchscrollmode",
  13950. eventDetails: {
  13951. mode: _ui_utils.ScrollMode.HORIZONTAL
  13952. },
  13953. close: true
  13954. }, {
  13955. element: options.scrollWrappedButton,
  13956. eventName: "switchscrollmode",
  13957. eventDetails: {
  13958. mode: _ui_utils.ScrollMode.WRAPPED
  13959. },
  13960. close: true
  13961. }, {
  13962. element: options.spreadNoneButton,
  13963. eventName: "switchspreadmode",
  13964. eventDetails: {
  13965. mode: _ui_utils.SpreadMode.NONE
  13966. },
  13967. close: true
  13968. }, {
  13969. element: options.spreadOddButton,
  13970. eventName: "switchspreadmode",
  13971. eventDetails: {
  13972. mode: _ui_utils.SpreadMode.ODD
  13973. },
  13974. close: true
  13975. }, {
  13976. element: options.spreadEvenButton,
  13977. eventName: "switchspreadmode",
  13978. eventDetails: {
  13979. mode: _ui_utils.SpreadMode.EVEN
  13980. },
  13981. close: true
  13982. }, {
  13983. element: options.documentPropertiesButton,
  13984. eventName: "documentproperties",
  13985. close: true
  13986. }];
  13987. this.buttons.push({
  13988. element: options.openFileButton,
  13989. eventName: "openfile",
  13990. close: true
  13991. });
  13992. this.items = {
  13993. firstPage: options.firstPageButton,
  13994. lastPage: options.lastPageButton,
  13995. pageRotateCw: options.pageRotateCwButton,
  13996. pageRotateCcw: options.pageRotateCcwButton
  13997. };
  13998. this.eventBus = eventBus;
  13999. this.opened = false;
  14000. _classPrivateMethodGet(this, _bindClickListeners, _bindClickListeners2).call(
  14001. this);
  14002. _classPrivateMethodGet(this, _bindCursorToolsListener,
  14003. _bindCursorToolsListener2).call(this, options);
  14004. _classPrivateMethodGet(this, _bindScrollModeListener, _bindScrollModeListener2)
  14005. .call(this, options);
  14006. _classPrivateMethodGet(this, _bindSpreadModeListener, _bindSpreadModeListener2)
  14007. .call(this, options);
  14008. this.reset();
  14009. }
  14010. get isOpen() {
  14011. return this.opened;
  14012. }
  14013. setPageNumber(pageNumber) {
  14014. this.pageNumber = pageNumber;
  14015. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  14016. }
  14017. setPagesCount(pagesCount) {
  14018. this.pagesCount = pagesCount;
  14019. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  14020. }
  14021. reset() {
  14022. this.pageNumber = 0;
  14023. this.pagesCount = 0;
  14024. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  14025. this.eventBus.dispatch("secondarytoolbarreset", {
  14026. source: this
  14027. });
  14028. }
  14029. open() {
  14030. if (this.opened) {
  14031. return;
  14032. }
  14033. this.opened = true;
  14034. this.toggleButton.classList.add("toggled");
  14035. this.toggleButton.setAttribute("aria-expanded", "true");
  14036. this.toolbar.classList.remove("hidden");
  14037. }
  14038. close() {
  14039. if (!this.opened) {
  14040. return;
  14041. }
  14042. this.opened = false;
  14043. this.toolbar.classList.add("hidden");
  14044. this.toggleButton.classList.remove("toggled");
  14045. this.toggleButton.setAttribute("aria-expanded", "false");
  14046. }
  14047. toggle() {
  14048. if (this.opened) {
  14049. this.close();
  14050. } else {
  14051. this.open();
  14052. }
  14053. }
  14054. }
  14055. exports.SecondaryToolbar = SecondaryToolbar;
  14056. function _updateUIState2() {
  14057. this.items.firstPage.disabled = this.pageNumber <= 1;
  14058. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  14059. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  14060. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  14061. }
  14062. function _bindClickListeners2() {
  14063. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  14064. for (const {
  14065. element,
  14066. eventName,
  14067. close,
  14068. eventDetails
  14069. } of this.buttons) {
  14070. element.addEventListener("click", evt => {
  14071. if (eventName !== null) {
  14072. const details = {
  14073. source: this
  14074. };
  14075. for (const property in eventDetails) {
  14076. details[property] = eventDetails[property];
  14077. }
  14078. this.eventBus.dispatch(eventName, details);
  14079. }
  14080. if (close) {
  14081. this.close();
  14082. }
  14083. });
  14084. }
  14085. }
  14086. function _bindCursorToolsListener2(_ref) {
  14087. let {
  14088. cursorSelectToolButton,
  14089. cursorHandToolButton
  14090. } = _ref;
  14091. this.eventBus._on("cursortoolchanged", function(_ref2) {
  14092. let {
  14093. tool
  14094. } = _ref2;
  14095. const isSelect = tool === _pdf_cursor_tools.CursorTool.SELECT,
  14096. isHand = tool === _pdf_cursor_tools.CursorTool.HAND;
  14097. cursorSelectToolButton.classList.toggle("toggled", isSelect);
  14098. cursorHandToolButton.classList.toggle("toggled", isHand);
  14099. cursorSelectToolButton.setAttribute("aria-checked", isSelect);
  14100. cursorHandToolButton.setAttribute("aria-checked", isHand);
  14101. });
  14102. }
  14103. function _bindScrollModeListener2(_ref3) {
  14104. let {
  14105. scrollPageButton,
  14106. scrollVerticalButton,
  14107. scrollHorizontalButton,
  14108. scrollWrappedButton,
  14109. spreadNoneButton,
  14110. spreadOddButton,
  14111. spreadEvenButton
  14112. } = _ref3;
  14113. const scrollModeChanged = _ref4 => {
  14114. let {
  14115. mode
  14116. } = _ref4;
  14117. const isPage = mode === _ui_utils.ScrollMode.PAGE,
  14118. isVertical = mode === _ui_utils.ScrollMode.VERTICAL,
  14119. isHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL,
  14120. isWrapped = mode === _ui_utils.ScrollMode.WRAPPED;
  14121. scrollPageButton.classList.toggle("toggled", isPage);
  14122. scrollVerticalButton.classList.toggle("toggled", isVertical);
  14123. scrollHorizontalButton.classList.toggle("toggled", isHorizontal);
  14124. scrollWrappedButton.classList.toggle("toggled", isWrapped);
  14125. scrollPageButton.setAttribute("aria-checked", isPage);
  14126. scrollVerticalButton.setAttribute("aria-checked", isVertical);
  14127. scrollHorizontalButton.setAttribute("aria-checked", isHorizontal);
  14128. scrollWrappedButton.setAttribute("aria-checked", isWrapped);
  14129. const forceScrollModePage = this.pagesCount > _base_viewer.PagesCountLimit
  14130. .FORCE_SCROLL_MODE_PAGE;
  14131. scrollPageButton.disabled = forceScrollModePage;
  14132. scrollVerticalButton.disabled = forceScrollModePage;
  14133. scrollHorizontalButton.disabled = forceScrollModePage;
  14134. scrollWrappedButton.disabled = forceScrollModePage;
  14135. spreadNoneButton.disabled = isHorizontal;
  14136. spreadOddButton.disabled = isHorizontal;
  14137. spreadEvenButton.disabled = isHorizontal;
  14138. };
  14139. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  14140. this.eventBus._on("secondarytoolbarreset", evt => {
  14141. if (evt.source === this) {
  14142. scrollModeChanged({
  14143. mode: _ui_utils.ScrollMode.VERTICAL
  14144. });
  14145. }
  14146. });
  14147. }
  14148. function _bindSpreadModeListener2(_ref5) {
  14149. let {
  14150. spreadNoneButton,
  14151. spreadOddButton,
  14152. spreadEvenButton
  14153. } = _ref5;
  14154. function spreadModeChanged(_ref6) {
  14155. let {
  14156. mode
  14157. } = _ref6;
  14158. const isNone = mode === _ui_utils.SpreadMode.NONE,
  14159. isOdd = mode === _ui_utils.SpreadMode.ODD,
  14160. isEven = mode === _ui_utils.SpreadMode.EVEN;
  14161. spreadNoneButton.classList.toggle("toggled", isNone);
  14162. spreadOddButton.classList.toggle("toggled", isOdd);
  14163. spreadEvenButton.classList.toggle("toggled", isEven);
  14164. spreadNoneButton.setAttribute("aria-checked", isNone);
  14165. spreadOddButton.setAttribute("aria-checked", isOdd);
  14166. spreadEvenButton.setAttribute("aria-checked", isEven);
  14167. }
  14168. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  14169. this.eventBus._on("secondarytoolbarreset", evt => {
  14170. if (evt.source === this) {
  14171. spreadModeChanged({
  14172. mode: _ui_utils.SpreadMode.NONE
  14173. });
  14174. }
  14175. });
  14176. }
  14177. /***/
  14178. }),
  14179. /* 41 */
  14180. /***/
  14181. ((__unused_webpack_module, exports, __webpack_require__) => {
  14182. Object.defineProperty(exports, "__esModule", ({
  14183. value: true
  14184. }));
  14185. exports.Toolbar = void 0;
  14186. var _ui_utils = __webpack_require__(1);
  14187. var _pdfjsLib = __webpack_require__(5);
  14188. function _classPrivateMethodInitSpec(obj, privateSet) {
  14189. _checkPrivateRedeclaration(obj, privateSet);
  14190. privateSet.add(obj);
  14191. }
  14192. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  14193. _checkPrivateRedeclaration(obj, privateMap);
  14194. privateMap.set(obj, value);
  14195. }
  14196. function _checkPrivateRedeclaration(obj, privateCollection) {
  14197. if (privateCollection.has(obj)) {
  14198. throw new TypeError(
  14199. "Cannot initialize the same private elements twice on an object");
  14200. }
  14201. }
  14202. function _classPrivateFieldGet(receiver, privateMap) {
  14203. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  14204. return _classApplyDescriptorGet(receiver, descriptor);
  14205. }
  14206. function _classApplyDescriptorGet(receiver, descriptor) {
  14207. if (descriptor.get) {
  14208. return descriptor.get.call(receiver);
  14209. }
  14210. return descriptor.value;
  14211. }
  14212. function _classPrivateFieldSet(receiver, privateMap, value) {
  14213. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  14214. _classApplyDescriptorSet(receiver, descriptor, value);
  14215. return value;
  14216. }
  14217. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  14218. if (!privateMap.has(receiver)) {
  14219. throw new TypeError("attempted to " + action + " private field on non-instance");
  14220. }
  14221. return privateMap.get(receiver);
  14222. }
  14223. function _classApplyDescriptorSet(receiver, descriptor, value) {
  14224. if (descriptor.set) {
  14225. descriptor.set.call(receiver, value);
  14226. } else {
  14227. if (!descriptor.writable) {
  14228. throw new TypeError("attempted to set read only private field");
  14229. }
  14230. descriptor.value = value;
  14231. }
  14232. }
  14233. function _classPrivateMethodGet(receiver, privateSet, fn) {
  14234. if (!privateSet.has(receiver)) {
  14235. throw new TypeError("attempted to get private field on non-instance");
  14236. }
  14237. return fn;
  14238. }
  14239. const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  14240. var _wasLocalized = /*#__PURE__*/ new WeakMap();
  14241. var _bindListeners = /*#__PURE__*/ new WeakSet();
  14242. var _bindEditorToolsListener = /*#__PURE__*/ new WeakSet();
  14243. var _updateUIState = /*#__PURE__*/ new WeakSet();
  14244. var _adjustScaleWidth = /*#__PURE__*/ new WeakSet();
  14245. class Toolbar {
  14246. constructor(_options, eventBus, _l10n) {
  14247. _classPrivateMethodInitSpec(this, _adjustScaleWidth);
  14248. _classPrivateMethodInitSpec(this, _updateUIState);
  14249. _classPrivateMethodInitSpec(this, _bindEditorToolsListener);
  14250. _classPrivateMethodInitSpec(this, _bindListeners);
  14251. _classPrivateFieldInitSpec(this, _wasLocalized, {
  14252. writable: true,
  14253. value: false
  14254. });
  14255. this.toolbar = _options.container;
  14256. this.eventBus = eventBus;
  14257. this.l10n = _l10n;
  14258. this.buttons = [{
  14259. element: _options.previous,
  14260. eventName: "previouspage"
  14261. }, {
  14262. element: _options.next,
  14263. eventName: "nextpage"
  14264. }, {
  14265. element: _options.zoomIn,
  14266. eventName: "zoomin"
  14267. }, {
  14268. element: _options.zoomOut,
  14269. eventName: "zoomout"
  14270. }, {
  14271. element: _options.print,
  14272. eventName: "print"
  14273. }, {
  14274. element: _options.presentationModeButton,
  14275. eventName: "presentationmode"
  14276. }, {
  14277. element: _options.download,
  14278. eventName: "download"
  14279. }, {
  14280. element: _options.viewBookmark,
  14281. eventName: null
  14282. }, {
  14283. element: _options.editorFreeTextButton,
  14284. eventName: "switchannotationeditormode",
  14285. eventDetails: {
  14286. get mode() {
  14287. const {
  14288. classList
  14289. } = _options.editorFreeTextButton;
  14290. return classList.contains("toggled") ? _pdfjsLib
  14291. .AnnotationEditorType.NONE : _pdfjsLib
  14292. .AnnotationEditorType.FREETEXT;
  14293. }
  14294. }
  14295. }, {
  14296. element: _options.editorInkButton,
  14297. eventName: "switchannotationeditormode",
  14298. eventDetails: {
  14299. get mode() {
  14300. const {
  14301. classList
  14302. } = _options.editorInkButton;
  14303. return classList.contains("toggled") ? _pdfjsLib
  14304. .AnnotationEditorType.NONE : _pdfjsLib
  14305. .AnnotationEditorType.INK;
  14306. }
  14307. }
  14308. }];
  14309. this.buttons.push({
  14310. element: _options.openFile,
  14311. eventName: "openfile"
  14312. });
  14313. this.items = {
  14314. numPages: _options.numPages,
  14315. pageNumber: _options.pageNumber,
  14316. scaleSelect: _options.scaleSelect,
  14317. customScaleOption: _options.customScaleOption,
  14318. previous: _options.previous,
  14319. next: _options.next,
  14320. zoomIn: _options.zoomIn,
  14321. zoomOut: _options.zoomOut
  14322. };
  14323. _classPrivateMethodGet(this, _bindListeners, _bindListeners2).call(this,
  14324. _options);
  14325. this.reset();
  14326. }
  14327. setPageNumber(pageNumber, pageLabel) {
  14328. this.pageNumber = pageNumber;
  14329. this.pageLabel = pageLabel;
  14330. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, false);
  14331. }
  14332. setPagesCount(pagesCount, hasPageLabels) {
  14333. this.pagesCount = pagesCount;
  14334. this.hasPageLabels = hasPageLabels;
  14335. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, true);
  14336. }
  14337. setPageScale(pageScaleValue, pageScale) {
  14338. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  14339. this.pageScale = pageScale;
  14340. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, false);
  14341. }
  14342. reset() {
  14343. this.pageNumber = 0;
  14344. this.pageLabel = null;
  14345. this.hasPageLabels = false;
  14346. this.pagesCount = 0;
  14347. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  14348. this.pageScale = _ui_utils.DEFAULT_SCALE;
  14349. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, true);
  14350. this.updateLoadingIndicatorState();
  14351. this.eventBus.dispatch("toolbarreset", {
  14352. source: this
  14353. });
  14354. }
  14355. updateLoadingIndicatorState() {
  14356. let loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  14357. 0] : false;
  14358. const {
  14359. pageNumber
  14360. } = this.items;
  14361. pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  14362. }
  14363. }
  14364. exports.Toolbar = Toolbar;
  14365. function _bindListeners2(options) {
  14366. const {
  14367. pageNumber,
  14368. scaleSelect
  14369. } = this.items;
  14370. const self = this;
  14371. for (const {
  14372. element,
  14373. eventName,
  14374. eventDetails
  14375. } of this.buttons) {
  14376. element.addEventListener("click", evt => {
  14377. if (eventName !== null) {
  14378. const details = {
  14379. source: this
  14380. };
  14381. if (eventDetails) {
  14382. for (const property in eventDetails) {
  14383. details[property] = eventDetails[property];
  14384. }
  14385. }
  14386. this.eventBus.dispatch(eventName, details);
  14387. }
  14388. });
  14389. }
  14390. pageNumber.addEventListener("click", function() {
  14391. this.select();
  14392. });
  14393. pageNumber.addEventListener("change", function() {
  14394. self.eventBus.dispatch("pagenumberchanged", {
  14395. source: self,
  14396. value: this.value
  14397. });
  14398. });
  14399. scaleSelect.addEventListener("change", function() {
  14400. if (this.value === "custom") {
  14401. return;
  14402. }
  14403. self.eventBus.dispatch("scalechanged", {
  14404. source: self,
  14405. value: this.value
  14406. });
  14407. });
  14408. scaleSelect.addEventListener("click", function(evt) {
  14409. const target = evt.target;
  14410. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() ===
  14411. "OPTION") {
  14412. this.blur();
  14413. }
  14414. });
  14415. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  14416. this.eventBus._on("localized", () => {
  14417. _classPrivateFieldSet(this, _wasLocalized, true);
  14418. _classPrivateMethodGet(this, _adjustScaleWidth, _adjustScaleWidth2).call(
  14419. this);
  14420. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this,
  14421. true);
  14422. });
  14423. _classPrivateMethodGet(this, _bindEditorToolsListener, _bindEditorToolsListener2).call(
  14424. this, options);
  14425. }
  14426. function _bindEditorToolsListener2(_ref) {
  14427. let {
  14428. editorFreeTextButton,
  14429. editorFreeTextParamsToolbar,
  14430. editorInkButton,
  14431. editorInkParamsToolbar
  14432. } = _ref;
  14433. const editorModeChanged = function(evt) {
  14434. let disableButtons = arguments.length > 1 && arguments[1] !== undefined ?
  14435. arguments[1] : false;
  14436. const editorButtons = [{
  14437. mode: _pdfjsLib.AnnotationEditorType.FREETEXT,
  14438. button: editorFreeTextButton,
  14439. toolbar: editorFreeTextParamsToolbar
  14440. }, {
  14441. mode: _pdfjsLib.AnnotationEditorType.INK,
  14442. button: editorInkButton,
  14443. toolbar: editorInkParamsToolbar
  14444. }];
  14445. for (const {
  14446. mode,
  14447. button,
  14448. toolbar
  14449. } of editorButtons) {
  14450. const checked = mode === evt.mode;
  14451. button.classList.toggle("toggled", checked);
  14452. button.setAttribute("aria-checked", checked);
  14453. button.disabled = disableButtons;
  14454. toolbar === null || toolbar === void 0 ? void 0 : toolbar.classList.toggle(
  14455. "hidden", !checked);
  14456. }
  14457. };
  14458. this.eventBus._on("annotationeditormodechanged", editorModeChanged);
  14459. this.eventBus._on("toolbarreset", evt => {
  14460. if (evt.source === this) {
  14461. editorModeChanged({
  14462. mode: _pdfjsLib.AnnotationEditorType.NONE
  14463. }, true);
  14464. }
  14465. });
  14466. }
  14467. function _updateUIState2() {
  14468. let resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  14469. false;
  14470. if (!_classPrivateFieldGet(this, _wasLocalized)) {
  14471. return;
  14472. }
  14473. const {
  14474. pageNumber,
  14475. pagesCount,
  14476. pageScaleValue,
  14477. pageScale,
  14478. items
  14479. } = this;
  14480. if (resetNumPages) {
  14481. if (this.hasPageLabels) {
  14482. items.pageNumber.type = "text";
  14483. } else {
  14484. items.pageNumber.type = "number";
  14485. this.l10n.get("of_pages", {
  14486. pagesCount
  14487. }).then(msg => {
  14488. items.numPages.textContent = msg;
  14489. });
  14490. }
  14491. items.pageNumber.max = pagesCount;
  14492. }
  14493. if (this.hasPageLabels) {
  14494. items.pageNumber.value = this.pageLabel;
  14495. this.l10n.get("page_of_pages", {
  14496. pageNumber,
  14497. pagesCount
  14498. }).then(msg => {
  14499. items.numPages.textContent = msg;
  14500. });
  14501. } else {
  14502. items.pageNumber.value = pageNumber;
  14503. }
  14504. items.previous.disabled = pageNumber <= 1;
  14505. items.next.disabled = pageNumber >= pagesCount;
  14506. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  14507. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  14508. this.l10n.get("page_scale_percent", {
  14509. scale: Math.round(pageScale * 10000) / 100
  14510. }).then(msg => {
  14511. let predefinedValueFound = false;
  14512. for (const option of items.scaleSelect.options) {
  14513. if (option.value !== pageScaleValue) {
  14514. option.selected = false;
  14515. continue;
  14516. }
  14517. option.selected = true;
  14518. predefinedValueFound = true;
  14519. }
  14520. if (!predefinedValueFound) {
  14521. items.customScaleOption.textContent = msg;
  14522. items.customScaleOption.selected = true;
  14523. }
  14524. });
  14525. }
  14526. async function _adjustScaleWidth2() {
  14527. const {
  14528. items,
  14529. l10n
  14530. } = this;
  14531. const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get(
  14532. "page_scale_actual"), l10n.get("page_scale_fit"), l10n.get(
  14533. "page_scale_width")]);
  14534. await _ui_utils.animationStarted;
  14535. const style = getComputedStyle(items.scaleSelect),
  14536. scaleSelectContainerWidth = parseInt(style.getPropertyValue(
  14537. "--scale-select-container-width"), 10),
  14538. scaleSelectOverflow = parseInt(style.getPropertyValue(
  14539. "--scale-select-overflow"), 10);
  14540. const canvas = document.createElement("canvas");
  14541. const ctx = canvas.getContext("2d", {
  14542. alpha: false
  14543. });
  14544. ctx.font = `${style.fontSize} ${style.fontFamily}`;
  14545. let maxWidth = 0;
  14546. for (const predefinedValue of await predefinedValuesPromise) {
  14547. const {
  14548. width
  14549. } = ctx.measureText(predefinedValue);
  14550. if (width > maxWidth) {
  14551. maxWidth = width;
  14552. }
  14553. }
  14554. maxWidth += 2 * scaleSelectOverflow;
  14555. if (maxWidth > scaleSelectContainerWidth) {
  14556. _ui_utils.docStyle.setProperty("--scale-select-container-width",
  14557. `${maxWidth}px`);
  14558. }
  14559. canvas.width = 0;
  14560. canvas.height = 0;
  14561. }
  14562. /***/
  14563. }),
  14564. /* 42 */
  14565. /***/
  14566. ((__unused_webpack_module, exports) => {
  14567. Object.defineProperty(exports, "__esModule", ({
  14568. value: true
  14569. }));
  14570. exports.ViewHistory = void 0;
  14571. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  14572. class ViewHistory {
  14573. constructor(fingerprint) {
  14574. let cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  14575. 1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  14576. this.fingerprint = fingerprint;
  14577. this.cacheSize = cacheSize;
  14578. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  14579. const database = JSON.parse(databaseStr || "{}");
  14580. let index = -1;
  14581. if (!Array.isArray(database.files)) {
  14582. database.files = [];
  14583. } else {
  14584. while (database.files.length >= this.cacheSize) {
  14585. database.files.shift();
  14586. }
  14587. for (let i = 0, ii = database.files.length; i < ii; i++) {
  14588. const branch = database.files[i];
  14589. if (branch.fingerprint === this.fingerprint) {
  14590. index = i;
  14591. break;
  14592. }
  14593. }
  14594. }
  14595. if (index === -1) {
  14596. index = database.files.push({
  14597. fingerprint: this.fingerprint
  14598. }) - 1;
  14599. }
  14600. this.file = database.files[index];
  14601. this.database = database;
  14602. });
  14603. }
  14604. async _writeToStorage() {
  14605. const databaseStr = JSON.stringify(this.database);
  14606. localStorage.setItem("pdfjs.history", databaseStr);
  14607. }
  14608. async _readFromStorage() {
  14609. return localStorage.getItem("pdfjs.history");
  14610. }
  14611. async set(name, val) {
  14612. await this._initializedPromise;
  14613. this.file[name] = val;
  14614. return this._writeToStorage();
  14615. }
  14616. async setMultiple(properties) {
  14617. await this._initializedPromise;
  14618. for (const name in properties) {
  14619. this.file[name] = properties[name];
  14620. }
  14621. return this._writeToStorage();
  14622. }
  14623. async get(name, defaultValue) {
  14624. await this._initializedPromise;
  14625. const val = this.file[name];
  14626. return val !== undefined ? val : defaultValue;
  14627. }
  14628. async getMultiple(properties) {
  14629. await this._initializedPromise;
  14630. const values = Object.create(null);
  14631. for (const name in properties) {
  14632. const val = this.file[name];
  14633. values[name] = val !== undefined ? val : properties[name];
  14634. }
  14635. return values;
  14636. }
  14637. }
  14638. exports.ViewHistory = ViewHistory;
  14639. /***/
  14640. }),
  14641. /* 43 */
  14642. /***/
  14643. ((__unused_webpack_module, exports, __webpack_require__) => {
  14644. Object.defineProperty(exports, "__esModule", ({
  14645. value: true
  14646. }));
  14647. exports.GenericCom = void 0;
  14648. var _app = __webpack_require__(4);
  14649. var _preferences = __webpack_require__(44);
  14650. var _download_manager = __webpack_require__(45);
  14651. var _genericl10n = __webpack_require__(46);
  14652. var _generic_scripting = __webpack_require__(48);
  14653. ;
  14654. const GenericCom = {};
  14655. exports.GenericCom = GenericCom;
  14656. class GenericPreferences extends _preferences.BasePreferences {
  14657. async _writeToStorage(prefObj) {
  14658. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  14659. }
  14660. async _readFromStorage(prefObj) {
  14661. return JSON.parse(localStorage.getItem("pdfjs.preferences"));
  14662. }
  14663. }
  14664. class GenericExternalServices extends _app.DefaultExternalServices {
  14665. static createDownloadManager(options) {
  14666. return new _download_manager.DownloadManager();
  14667. }
  14668. static createPreferences() {
  14669. return new GenericPreferences();
  14670. }
  14671. static createL10n(_ref) {
  14672. let {
  14673. locale = "en-US"
  14674. } = _ref;
  14675. return new _genericl10n.GenericL10n(locale);
  14676. }
  14677. static createScripting(_ref2) {
  14678. let {
  14679. sandboxBundleSrc
  14680. } = _ref2;
  14681. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  14682. }
  14683. }
  14684. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  14685. /***/
  14686. }),
  14687. /* 44 */
  14688. /***/
  14689. ((__unused_webpack_module, exports, __webpack_require__) => {
  14690. Object.defineProperty(exports, "__esModule", ({
  14691. value: true
  14692. }));
  14693. exports.BasePreferences = void 0;
  14694. var _app_options = __webpack_require__(2);
  14695. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  14696. _checkPrivateRedeclaration(obj, privateMap);
  14697. privateMap.set(obj, value);
  14698. }
  14699. function _checkPrivateRedeclaration(obj, privateCollection) {
  14700. if (privateCollection.has(obj)) {
  14701. throw new TypeError(
  14702. "Cannot initialize the same private elements twice on an object");
  14703. }
  14704. }
  14705. function _classPrivateFieldGet(receiver, privateMap) {
  14706. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  14707. return _classApplyDescriptorGet(receiver, descriptor);
  14708. }
  14709. function _classApplyDescriptorGet(receiver, descriptor) {
  14710. if (descriptor.get) {
  14711. return descriptor.get.call(receiver);
  14712. }
  14713. return descriptor.value;
  14714. }
  14715. function _classPrivateFieldSet(receiver, privateMap, value) {
  14716. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  14717. _classApplyDescriptorSet(receiver, descriptor, value);
  14718. return value;
  14719. }
  14720. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  14721. if (!privateMap.has(receiver)) {
  14722. throw new TypeError("attempted to " + action + " private field on non-instance");
  14723. }
  14724. return privateMap.get(receiver);
  14725. }
  14726. function _classApplyDescriptorSet(receiver, descriptor, value) {
  14727. if (descriptor.set) {
  14728. descriptor.set.call(receiver, value);
  14729. } else {
  14730. if (!descriptor.writable) {
  14731. throw new TypeError("attempted to set read only private field");
  14732. }
  14733. descriptor.value = value;
  14734. }
  14735. }
  14736. var _defaults = /*#__PURE__*/ new WeakMap();
  14737. var _prefs = /*#__PURE__*/ new WeakMap();
  14738. var _initializedPromise = /*#__PURE__*/ new WeakMap();
  14739. class BasePreferences {
  14740. constructor() {
  14741. _classPrivateFieldInitSpec(this, _defaults, {
  14742. writable: true,
  14743. value: Object.freeze({
  14744. "annotationEditorMode": -1,
  14745. "annotationMode": 2,
  14746. "cursorToolOnLoad": 0,
  14747. "defaultZoomValue": "",
  14748. "disablePageLabels": false,
  14749. "enablePermissions": false,
  14750. "enablePrintAutoRotate": true,
  14751. "enableScripting": true,
  14752. "externalLinkTarget": 0,
  14753. "historyUpdateUrl": false,
  14754. "ignoreDestinationZoom": false,
  14755. "forcePageColors": false,
  14756. "pageColorsBackground": "Canvas",
  14757. "pageColorsForeground": "CanvasText",
  14758. "pdfBugEnabled": false,
  14759. "sidebarViewOnLoad": -1,
  14760. "scrollModeOnLoad": -1,
  14761. "spreadModeOnLoad": -1,
  14762. "textLayerMode": 1,
  14763. "useOnlyCssZoom": false,
  14764. "viewerCssTheme": 0,
  14765. "viewOnLoad": 0,
  14766. "disableAutoFetch": false,
  14767. "disableFontFace": false,
  14768. "disableRange": false,
  14769. "disableStream": false,
  14770. "enableXfa": true,
  14771. "renderer": "canvas"
  14772. })
  14773. });
  14774. _classPrivateFieldInitSpec(this, _prefs, {
  14775. writable: true,
  14776. value: Object.create(null)
  14777. });
  14778. _classPrivateFieldInitSpec(this, _initializedPromise, {
  14779. writable: true,
  14780. value: null
  14781. });
  14782. if (this.constructor === BasePreferences) {
  14783. throw new Error("Cannot initialize BasePreferences.");
  14784. }
  14785. _classPrivateFieldSet(this, _initializedPromise, this._readFromStorage(
  14786. _classPrivateFieldGet(this, _defaults)).then(prefs => {
  14787. for (const name in _classPrivateFieldGet(this, _defaults)) {
  14788. const prefValue = prefs === null || prefs === void 0 ?
  14789. void 0 : prefs[name];
  14790. if (typeof prefValue === typeof _classPrivateFieldGet(this,
  14791. _defaults)[name]) {
  14792. _classPrivateFieldGet(this, _prefs)[name] = prefValue;
  14793. }
  14794. }
  14795. }));
  14796. }
  14797. async _writeToStorage(prefObj) {
  14798. throw new Error("Not implemented: _writeToStorage");
  14799. }
  14800. async _readFromStorage(prefObj) {
  14801. throw new Error("Not implemented: _readFromStorage");
  14802. }
  14803. async reset() {
  14804. await _classPrivateFieldGet(this, _initializedPromise);
  14805. const prefs = _classPrivateFieldGet(this, _prefs);
  14806. _classPrivateFieldSet(this, _prefs, Object.create(null));
  14807. return this._writeToStorage(_classPrivateFieldGet(this, _defaults)).catch(
  14808. reason => {
  14809. _classPrivateFieldSet(this, _prefs, prefs);
  14810. throw reason;
  14811. });
  14812. }
  14813. async set(name, value) {
  14814. await _classPrivateFieldGet(this, _initializedPromise);
  14815. const defaultValue = _classPrivateFieldGet(this, _defaults)[name],
  14816. prefs = _classPrivateFieldGet(this, _prefs);
  14817. if (defaultValue === undefined) {
  14818. throw new Error(`Set preference: "${name}" is undefined.`);
  14819. } else if (value === undefined) {
  14820. throw new Error("Set preference: no value is specified.");
  14821. }
  14822. const valueType = typeof value,
  14823. defaultType = typeof defaultValue;
  14824. if (valueType !== defaultType) {
  14825. if (valueType === "number" && defaultType === "string") {
  14826. value = value.toString();
  14827. } else {
  14828. throw new Error(
  14829. `Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`
  14830. );
  14831. }
  14832. } else {
  14833. if (valueType === "number" && !Number.isInteger(value)) {
  14834. throw new Error(`Set preference: "${value}" must be an integer.`);
  14835. }
  14836. }
  14837. _classPrivateFieldGet(this, _prefs)[name] = value;
  14838. return this._writeToStorage(_classPrivateFieldGet(this, _prefs)).catch(
  14839. reason => {
  14840. _classPrivateFieldSet(this, _prefs, prefs);
  14841. throw reason;
  14842. });
  14843. }
  14844. async get(name) {
  14845. var _classPrivateFieldGet2;
  14846. await _classPrivateFieldGet(this, _initializedPromise);
  14847. const defaultValue = _classPrivateFieldGet(this, _defaults)[name];
  14848. if (defaultValue === undefined) {
  14849. throw new Error(`Get preference: "${name}" is undefined.`);
  14850. }
  14851. return (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _prefs)[name]) !==
  14852. null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 :
  14853. defaultValue;
  14854. }
  14855. async getAll() {
  14856. await _classPrivateFieldGet(this, _initializedPromise);
  14857. const obj = Object.create(null);
  14858. for (const name in _classPrivateFieldGet(this, _defaults)) {
  14859. var _classPrivateFieldGet3;
  14860. obj[name] = (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _prefs)[
  14861. name]) !== null && _classPrivateFieldGet3 !== void 0 ?
  14862. _classPrivateFieldGet3 : _classPrivateFieldGet(this, _defaults)[name];
  14863. }
  14864. return obj;
  14865. }
  14866. }
  14867. exports.BasePreferences = BasePreferences;
  14868. /***/
  14869. }),
  14870. /* 45 */
  14871. /***/
  14872. ((__unused_webpack_module, exports, __webpack_require__) => {
  14873. Object.defineProperty(exports, "__esModule", ({
  14874. value: true
  14875. }));
  14876. exports.DownloadManager = void 0;
  14877. var _pdfjsLib = __webpack_require__(5);
  14878. ;
  14879. function download(blobUrl, filename) {
  14880. const a = document.createElement("a");
  14881. if (!a.click) {
  14882. throw new Error('DownloadManager: "a.click()" is not supported.');
  14883. }
  14884. a.href = blobUrl;
  14885. a.target = "_parent";
  14886. if ("download" in a) {
  14887. a.download = filename;
  14888. }
  14889. (document.body || document.documentElement).append(a);
  14890. a.click();
  14891. a.remove();
  14892. }
  14893. class DownloadManager {
  14894. constructor() {
  14895. this._openBlobUrls = new WeakMap();
  14896. }
  14897. downloadUrl(url, filename) {
  14898. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14899. console.error(`downloadUrl - not a valid URL: ${url}`);
  14900. return;
  14901. }
  14902. download(url + "#pdfjs.action=download", filename);
  14903. }
  14904. downloadData(data, filename, contentType) {
  14905. const blobUrl = URL.createObjectURL(new Blob([data], {
  14906. type: contentType
  14907. }));
  14908. download(blobUrl, filename);
  14909. }
  14910. openOrDownloadData(element, data, filename) {
  14911. const isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  14912. const contentType = isPdfData ? "application/pdf" : "";
  14913. if (isPdfData) {
  14914. let blobUrl = this._openBlobUrls.get(element);
  14915. if (!blobUrl) {
  14916. blobUrl = URL.createObjectURL(new Blob([data], {
  14917. type: contentType
  14918. }));
  14919. this._openBlobUrls.set(element, blobUrl);
  14920. }
  14921. let viewerUrl;
  14922. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  14923. try {
  14924. window.open(viewerUrl);
  14925. return true;
  14926. } catch (ex) {
  14927. console.error(`openOrDownloadData: ${ex}`);
  14928. URL.revokeObjectURL(blobUrl);
  14929. this._openBlobUrls.delete(element);
  14930. }
  14931. }
  14932. this.downloadData(data, filename, contentType);
  14933. return false;
  14934. }
  14935. download(blob, url, filename) {
  14936. const blobUrl = URL.createObjectURL(blob);
  14937. download(blobUrl, filename);
  14938. }
  14939. }
  14940. exports.DownloadManager = DownloadManager;
  14941. /***/
  14942. }),
  14943. /* 46 */
  14944. /***/
  14945. ((__unused_webpack_module, exports, __webpack_require__) => {
  14946. Object.defineProperty(exports, "__esModule", ({
  14947. value: true
  14948. }));
  14949. exports.GenericL10n = void 0;
  14950. __webpack_require__(47);
  14951. var _l10n_utils = __webpack_require__(32);
  14952. const webL10n = document.webL10n;
  14953. class GenericL10n {
  14954. constructor(lang) {
  14955. this._lang = lang;
  14956. this._ready = new Promise((resolve, reject) => {
  14957. webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), () => {
  14958. resolve(webL10n);
  14959. });
  14960. });
  14961. }
  14962. async getLanguage() {
  14963. const l10n = await this._ready;
  14964. return l10n.getLanguage();
  14965. }
  14966. async getDirection() {
  14967. const l10n = await this._ready;
  14968. return l10n.getDirection();
  14969. }
  14970. async get(key) {
  14971. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  14972. null;
  14973. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[
  14974. 2] : (0, _l10n_utils.getL10nFallback)(key, args);
  14975. const l10n = await this._ready;
  14976. return l10n.get(key, args, fallback);
  14977. }
  14978. async translate(element) {
  14979. const l10n = await this._ready;
  14980. return l10n.translate(element);
  14981. }
  14982. }
  14983. exports.GenericL10n = GenericL10n;
  14984. /***/
  14985. }),
  14986. /* 47 */
  14987. /***/
  14988. (() => {
  14989. document.webL10n = function(window, document, undefined) {
  14990. var gL10nData = {};
  14991. var gTextData = '';
  14992. var gTextProp = 'textContent';
  14993. var gLanguage = '';
  14994. var gMacros = {};
  14995. var gReadyState = 'loading';
  14996. var gAsyncResourceLoading = true;
  14997. function getL10nResourceLinks() {
  14998. return document.querySelectorAll('link[type="application/l10n"]');
  14999. }
  15000. function getL10nDictionary() {
  15001. var script = document.querySelector('script[type="application/l10n"]');
  15002. return script ? JSON.parse(script.innerHTML) : null;
  15003. }
  15004. function getTranslatableChildren(element) {
  15005. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  15006. }
  15007. function getL10nAttributes(element) {
  15008. if (!element) return {};
  15009. var l10nId = element.getAttribute('data-l10n-id');
  15010. var l10nArgs = element.getAttribute('data-l10n-args');
  15011. var args = {};
  15012. if (l10nArgs) {
  15013. try {
  15014. args = JSON.parse(l10nArgs);
  15015. } catch (e) {
  15016. console.warn('could not parse arguments for #' + l10nId);
  15017. }
  15018. }
  15019. return {
  15020. id: l10nId,
  15021. args: args
  15022. };
  15023. }
  15024. function xhrLoadText(url, onSuccess, onFailure) {
  15025. onSuccess = onSuccess || function _onSuccess(data) {};
  15026. onFailure = onFailure || function _onFailure() {};
  15027. var xhr = new XMLHttpRequest();
  15028. xhr.open('GET', url, gAsyncResourceLoading);
  15029. if (xhr.overrideMimeType) {
  15030. xhr.overrideMimeType('text/plain; charset=utf-8');
  15031. }
  15032. xhr.onreadystatechange = function() {
  15033. if (xhr.readyState == 4) {
  15034. if (xhr.status == 200 || xhr.status === 0) {
  15035. onSuccess(xhr.responseText);
  15036. } else {
  15037. onFailure();
  15038. }
  15039. }
  15040. };
  15041. xhr.onerror = onFailure;
  15042. xhr.ontimeout = onFailure;
  15043. try {
  15044. xhr.send(null);
  15045. } catch (e) {
  15046. onFailure();
  15047. }
  15048. }
  15049. function parseResource(href, lang, successCallback, failureCallback) {
  15050. var baseURL = href.replace(/[^\/]*$/, '') || './';
  15051. function evalString(text) {
  15052. if (text.lastIndexOf('\\') < 0) return text;
  15053. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g,
  15054. '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g,
  15055. '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"')
  15056. .replace(/\\'/g, "'");
  15057. }
  15058. function parseProperties(text, parsedPropertiesCallback) {
  15059. var dictionary = {};
  15060. var reBlank = /^\s*|\s*$/;
  15061. var reComment = /^\s*#|^\s*$/;
  15062. var reSection = /^\s*\[(.*)\]\s*$/;
  15063. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  15064. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  15065. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  15066. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  15067. var currentLang = '*';
  15068. var genericLang = lang.split('-', 1)[0];
  15069. var skipLang = false;
  15070. var match = '';
  15071. function nextEntry() {
  15072. while (true) {
  15073. if (!entries.length) {
  15074. parsedRawLinesCallback();
  15075. return;
  15076. }
  15077. var line = entries.shift();
  15078. if (reComment.test(line)) continue;
  15079. if (extendedSyntax) {
  15080. match = reSection.exec(line);
  15081. if (match) {
  15082. currentLang = match[1].toLowerCase();
  15083. skipLang = currentLang !== '*' && currentLang !==
  15084. lang && currentLang !== genericLang;
  15085. continue;
  15086. } else if (skipLang) {
  15087. continue;
  15088. }
  15089. match = reImport.exec(line);
  15090. if (match) {
  15091. loadImport(baseURL + match[1], nextEntry);
  15092. return;
  15093. }
  15094. }
  15095. var tmp = line.match(reSplit);
  15096. if (tmp && tmp.length == 3) {
  15097. dictionary[tmp[1]] = evalString(tmp[2]);
  15098. }
  15099. }
  15100. }
  15101. nextEntry();
  15102. }
  15103. function loadImport(url, callback) {
  15104. xhrLoadText(url, function(content) {
  15105. parseRawLines(content, false, callback);
  15106. }, function() {
  15107. console.warn(url + ' not found.');
  15108. callback();
  15109. });
  15110. }
  15111. parseRawLines(text, true, function() {
  15112. parsedPropertiesCallback(dictionary);
  15113. });
  15114. }
  15115. xhrLoadText(href, function(response) {
  15116. gTextData += response;
  15117. parseProperties(response, function(data) {
  15118. for (var key in data) {
  15119. var id,
  15120. prop,
  15121. index = key.lastIndexOf('.');
  15122. if (index > 0) {
  15123. id = key.substring(0, index);
  15124. prop = key.substring(index + 1);
  15125. } else {
  15126. id = key;
  15127. prop = gTextProp;
  15128. }
  15129. if (!gL10nData[id]) {
  15130. gL10nData[id] = {};
  15131. }
  15132. gL10nData[id][prop] = data[key];
  15133. }
  15134. if (successCallback) {
  15135. successCallback();
  15136. }
  15137. });
  15138. }, failureCallback);
  15139. }
  15140. function loadLocale(lang, callback) {
  15141. if (lang) {
  15142. lang = lang.toLowerCase();
  15143. }
  15144. callback = callback || function _callback() {};
  15145. clear();
  15146. gLanguage = lang;
  15147. var langLinks = getL10nResourceLinks();
  15148. var langCount = langLinks.length;
  15149. if (langCount === 0) {
  15150. var dict = getL10nDictionary();
  15151. if (dict && dict.locales && dict.default_locale) {
  15152. console.log('using the embedded JSON directory, early way out');
  15153. gL10nData = dict.locales[lang];
  15154. if (!gL10nData) {
  15155. var defaultLocale = dict.default_locale.toLowerCase();
  15156. for (var anyCaseLang in dict.locales) {
  15157. anyCaseLang = anyCaseLang.toLowerCase();
  15158. if (anyCaseLang === lang) {
  15159. gL10nData = dict.locales[lang];
  15160. break;
  15161. } else if (anyCaseLang === defaultLocale) {
  15162. gL10nData = dict.locales[defaultLocale];
  15163. }
  15164. }
  15165. }
  15166. callback();
  15167. } else {
  15168. console.log('no resource to load, early way out');
  15169. }
  15170. gReadyState = 'complete';
  15171. return;
  15172. }
  15173. var onResourceLoaded = null;
  15174. var gResourceCount = 0;
  15175. onResourceLoaded = function() {
  15176. gResourceCount++;
  15177. if (gResourceCount >= langCount) {
  15178. callback();
  15179. gReadyState = 'complete';
  15180. }
  15181. };
  15182. function L10nResourceLink(link) {
  15183. var href = link.href;
  15184. this.load = function(lang, callback) {
  15185. parseResource(href, lang, callback, function() {
  15186. console.warn(href + ' not found.');
  15187. console.warn('"' + lang + '" resource not found');
  15188. gLanguage = '';
  15189. callback();
  15190. });
  15191. };
  15192. }
  15193. for (var i = 0; i < langCount; i++) {
  15194. var resource = new L10nResourceLink(langLinks[i]);
  15195. resource.load(lang, onResourceLoaded);
  15196. }
  15197. }
  15198. function clear() {
  15199. gL10nData = {};
  15200. gTextData = '';
  15201. gLanguage = '';
  15202. }
  15203. function getPluralRules(lang) {
  15204. var locales2rules = {
  15205. 'af': 3,
  15206. 'ak': 4,
  15207. 'am': 4,
  15208. 'ar': 1,
  15209. 'asa': 3,
  15210. 'az': 0,
  15211. 'be': 11,
  15212. 'bem': 3,
  15213. 'bez': 3,
  15214. 'bg': 3,
  15215. 'bh': 4,
  15216. 'bm': 0,
  15217. 'bn': 3,
  15218. 'bo': 0,
  15219. 'br': 20,
  15220. 'brx': 3,
  15221. 'bs': 11,
  15222. 'ca': 3,
  15223. 'cgg': 3,
  15224. 'chr': 3,
  15225. 'cs': 12,
  15226. 'cy': 17,
  15227. 'da': 3,
  15228. 'de': 3,
  15229. 'dv': 3,
  15230. 'dz': 0,
  15231. 'ee': 3,
  15232. 'el': 3,
  15233. 'en': 3,
  15234. 'eo': 3,
  15235. 'es': 3,
  15236. 'et': 3,
  15237. 'eu': 3,
  15238. 'fa': 0,
  15239. 'ff': 5,
  15240. 'fi': 3,
  15241. 'fil': 4,
  15242. 'fo': 3,
  15243. 'fr': 5,
  15244. 'fur': 3,
  15245. 'fy': 3,
  15246. 'ga': 8,
  15247. 'gd': 24,
  15248. 'gl': 3,
  15249. 'gsw': 3,
  15250. 'gu': 3,
  15251. 'guw': 4,
  15252. 'gv': 23,
  15253. 'ha': 3,
  15254. 'haw': 3,
  15255. 'he': 2,
  15256. 'hi': 4,
  15257. 'hr': 11,
  15258. 'hu': 0,
  15259. 'id': 0,
  15260. 'ig': 0,
  15261. 'ii': 0,
  15262. 'is': 3,
  15263. 'it': 3,
  15264. 'iu': 7,
  15265. 'ja': 0,
  15266. 'jmc': 3,
  15267. 'jv': 0,
  15268. 'ka': 0,
  15269. 'kab': 5,
  15270. 'kaj': 3,
  15271. 'kcg': 3,
  15272. 'kde': 0,
  15273. 'kea': 0,
  15274. 'kk': 3,
  15275. 'kl': 3,
  15276. 'km': 0,
  15277. 'kn': 0,
  15278. 'ko': 0,
  15279. 'ksb': 3,
  15280. 'ksh': 21,
  15281. 'ku': 3,
  15282. 'kw': 7,
  15283. 'lag': 18,
  15284. 'lb': 3,
  15285. 'lg': 3,
  15286. 'ln': 4,
  15287. 'lo': 0,
  15288. 'lt': 10,
  15289. 'lv': 6,
  15290. 'mas': 3,
  15291. 'mg': 4,
  15292. 'mk': 16,
  15293. 'ml': 3,
  15294. 'mn': 3,
  15295. 'mo': 9,
  15296. 'mr': 3,
  15297. 'ms': 0,
  15298. 'mt': 15,
  15299. 'my': 0,
  15300. 'nah': 3,
  15301. 'naq': 7,
  15302. 'nb': 3,
  15303. 'nd': 3,
  15304. 'ne': 3,
  15305. 'nl': 3,
  15306. 'nn': 3,
  15307. 'no': 3,
  15308. 'nr': 3,
  15309. 'nso': 4,
  15310. 'ny': 3,
  15311. 'nyn': 3,
  15312. 'om': 3,
  15313. 'or': 3,
  15314. 'pa': 3,
  15315. 'pap': 3,
  15316. 'pl': 13,
  15317. 'ps': 3,
  15318. 'pt': 3,
  15319. 'rm': 3,
  15320. 'ro': 9,
  15321. 'rof': 3,
  15322. 'ru': 11,
  15323. 'rwk': 3,
  15324. 'sah': 0,
  15325. 'saq': 3,
  15326. 'se': 7,
  15327. 'seh': 3,
  15328. 'ses': 0,
  15329. 'sg': 0,
  15330. 'sh': 11,
  15331. 'shi': 19,
  15332. 'sk': 12,
  15333. 'sl': 14,
  15334. 'sma': 7,
  15335. 'smi': 7,
  15336. 'smj': 7,
  15337. 'smn': 7,
  15338. 'sms': 7,
  15339. 'sn': 3,
  15340. 'so': 3,
  15341. 'sq': 3,
  15342. 'sr': 11,
  15343. 'ss': 3,
  15344. 'ssy': 3,
  15345. 'st': 3,
  15346. 'sv': 3,
  15347. 'sw': 3,
  15348. 'syr': 3,
  15349. 'ta': 3,
  15350. 'te': 3,
  15351. 'teo': 3,
  15352. 'th': 0,
  15353. 'ti': 4,
  15354. 'tig': 3,
  15355. 'tk': 3,
  15356. 'tl': 4,
  15357. 'tn': 3,
  15358. 'to': 0,
  15359. 'tr': 0,
  15360. 'ts': 3,
  15361. 'tzm': 22,
  15362. 'uk': 11,
  15363. 'ur': 3,
  15364. 've': 3,
  15365. 'vi': 0,
  15366. 'vun': 3,
  15367. 'wa': 4,
  15368. 'wae': 3,
  15369. 'wo': 0,
  15370. 'xh': 3,
  15371. 'xog': 3,
  15372. 'yo': 0,
  15373. 'zh': 0,
  15374. 'zu': 3
  15375. };
  15376. function isIn(n, list) {
  15377. return list.indexOf(n) !== -1;
  15378. }
  15379. function isBetween(n, start, end) {
  15380. return start <= n && n <= end;
  15381. }
  15382. var pluralRules = {
  15383. '0': function(n) {
  15384. return 'other';
  15385. },
  15386. '1': function(n) {
  15387. if (isBetween(n % 100, 3, 10)) return 'few';
  15388. if (n === 0) return 'zero';
  15389. if (isBetween(n % 100, 11, 99)) return 'many';
  15390. if (n == 2) return 'two';
  15391. if (n == 1) return 'one';
  15392. return 'other';
  15393. },
  15394. '2': function(n) {
  15395. if (n !== 0 && n % 10 === 0) return 'many';
  15396. if (n == 2) return 'two';
  15397. if (n == 1) return 'one';
  15398. return 'other';
  15399. },
  15400. '3': function(n) {
  15401. if (n == 1) return 'one';
  15402. return 'other';
  15403. },
  15404. '4': function(n) {
  15405. if (isBetween(n, 0, 1)) return 'one';
  15406. return 'other';
  15407. },
  15408. '5': function(n) {
  15409. if (isBetween(n, 0, 2) && n != 2) return 'one';
  15410. return 'other';
  15411. },
  15412. '6': function(n) {
  15413. if (n === 0) return 'zero';
  15414. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15415. return 'other';
  15416. },
  15417. '7': function(n) {
  15418. if (n == 2) return 'two';
  15419. if (n == 1) return 'one';
  15420. return 'other';
  15421. },
  15422. '8': function(n) {
  15423. if (isBetween(n, 3, 6)) return 'few';
  15424. if (isBetween(n, 7, 10)) return 'many';
  15425. if (n == 2) return 'two';
  15426. if (n == 1) return 'one';
  15427. return 'other';
  15428. },
  15429. '9': function(n) {
  15430. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19))
  15431. return 'few';
  15432. if (n == 1) return 'one';
  15433. return 'other';
  15434. },
  15435. '10': function(n) {
  15436. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19))
  15437. return 'few';
  15438. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  15439. return 'other';
  15440. },
  15441. '11': function(n) {
  15442. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14))
  15443. return 'few';
  15444. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n %
  15445. 100, 11, 14)) return 'many';
  15446. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15447. return 'other';
  15448. },
  15449. '12': function(n) {
  15450. if (isBetween(n, 2, 4)) return 'few';
  15451. if (n == 1) return 'one';
  15452. return 'other';
  15453. },
  15454. '13': function(n) {
  15455. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14))
  15456. return 'few';
  15457. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5,
  15458. 9) || isBetween(n % 100, 12, 14)) return 'many';
  15459. if (n == 1) return 'one';
  15460. return 'other';
  15461. },
  15462. '14': function(n) {
  15463. if (isBetween(n % 100, 3, 4)) return 'few';
  15464. if (n % 100 == 2) return 'two';
  15465. if (n % 100 == 1) return 'one';
  15466. return 'other';
  15467. },
  15468. '15': function(n) {
  15469. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  15470. if (isBetween(n % 100, 11, 19)) return 'many';
  15471. if (n == 1) return 'one';
  15472. return 'other';
  15473. },
  15474. '16': function(n) {
  15475. if (n % 10 == 1 && n != 11) return 'one';
  15476. return 'other';
  15477. },
  15478. '17': function(n) {
  15479. if (n == 3) return 'few';
  15480. if (n === 0) return 'zero';
  15481. if (n == 6) return 'many';
  15482. if (n == 2) return 'two';
  15483. if (n == 1) return 'one';
  15484. return 'other';
  15485. },
  15486. '18': function(n) {
  15487. if (n === 0) return 'zero';
  15488. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  15489. return 'other';
  15490. },
  15491. '19': function(n) {
  15492. if (isBetween(n, 2, 10)) return 'few';
  15493. if (isBetween(n, 0, 1)) return 'one';
  15494. return 'other';
  15495. },
  15496. '20': function(n) {
  15497. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n %
  15498. 100, 10, 19) || isBetween(n % 100, 70, 79) ||
  15499. isBetween(n % 100, 90, 99))) return 'few';
  15500. if (n % 1000000 === 0 && n !== 0) return 'many';
  15501. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  15502. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  15503. return 'other';
  15504. },
  15505. '21': function(n) {
  15506. if (n === 0) return 'zero';
  15507. if (n == 1) return 'one';
  15508. return 'other';
  15509. },
  15510. '22': function(n) {
  15511. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  15512. return 'other';
  15513. },
  15514. '23': function(n) {
  15515. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  15516. return 'other';
  15517. },
  15518. '24': function(n) {
  15519. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  15520. if (isIn(n, [2, 12])) return 'two';
  15521. if (isIn(n, [1, 11])) return 'one';
  15522. return 'other';
  15523. }
  15524. };
  15525. var index = locales2rules[lang.replace(/-.*$/, '')];
  15526. if (!(index in pluralRules)) {
  15527. console.warn('plural form unknown for [' + lang + ']');
  15528. return function() {
  15529. return 'other';
  15530. };
  15531. }
  15532. return pluralRules[index];
  15533. }
  15534. gMacros.plural = function(str, param, key, prop) {
  15535. var n = parseFloat(param);
  15536. if (isNaN(n)) return str;
  15537. if (prop != gTextProp) return str;
  15538. if (!gMacros._pluralRules) {
  15539. gMacros._pluralRules = getPluralRules(gLanguage);
  15540. }
  15541. var index = '[' + gMacros._pluralRules(n) + ']';
  15542. if (n === 0 && key + '[zero]' in gL10nData) {
  15543. str = gL10nData[key + '[zero]'][prop];
  15544. } else if (n == 1 && key + '[one]' in gL10nData) {
  15545. str = gL10nData[key + '[one]'][prop];
  15546. } else if (n == 2 && key + '[two]' in gL10nData) {
  15547. str = gL10nData[key + '[two]'][prop];
  15548. } else if (key + index in gL10nData) {
  15549. str = gL10nData[key + index][prop];
  15550. } else if (key + '[other]' in gL10nData) {
  15551. str = gL10nData[key + '[other]'][prop];
  15552. }
  15553. return str;
  15554. };
  15555. function getL10nData(key, args, fallback) {
  15556. var data = gL10nData[key];
  15557. if (!data) {
  15558. console.warn('#' + key + ' is undefined.');
  15559. if (!fallback) {
  15560. return null;
  15561. }
  15562. data = fallback;
  15563. }
  15564. var rv = {};
  15565. for (var prop in data) {
  15566. var str = data[prop];
  15567. str = substIndexes(str, args, key, prop);
  15568. str = substArguments(str, args, key);
  15569. rv[prop] = str;
  15570. }
  15571. return rv;
  15572. }
  15573. function substIndexes(str, args, key, prop) {
  15574. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15575. var reMatch = reIndex.exec(str);
  15576. if (!reMatch || !reMatch.length) return str;
  15577. var macroName = reMatch[1];
  15578. var paramName = reMatch[2];
  15579. var param;
  15580. if (args && paramName in args) {
  15581. param = args[paramName];
  15582. } else if (paramName in gL10nData) {
  15583. param = gL10nData[paramName];
  15584. }
  15585. if (macroName in gMacros) {
  15586. var macro = gMacros[macroName];
  15587. str = macro(str, param, key, prop);
  15588. }
  15589. return str;
  15590. }
  15591. function substArguments(str, args, key) {
  15592. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15593. return str.replace(reArgs, function(matched_text, arg) {
  15594. if (args && arg in args) {
  15595. return args[arg];
  15596. }
  15597. if (arg in gL10nData) {
  15598. return gL10nData[arg];
  15599. }
  15600. console.log('argument {{' + arg + '}} for #' + key +
  15601. ' is undefined.');
  15602. return matched_text;
  15603. });
  15604. }
  15605. function translateElement(element) {
  15606. var l10n = getL10nAttributes(element);
  15607. if (!l10n.id) return;
  15608. var data = getL10nData(l10n.id, l10n.args);
  15609. if (!data) {
  15610. console.warn('#' + l10n.id + ' is undefined.');
  15611. return;
  15612. }
  15613. if (data[gTextProp]) {
  15614. if (getChildElementCount(element) === 0) {
  15615. element[gTextProp] = data[gTextProp];
  15616. } else {
  15617. var children = element.childNodes;
  15618. var found = false;
  15619. for (var i = 0, l = children.length; i < l; i++) {
  15620. if (children[i].nodeType === 3 && /\S/.test(children[i]
  15621. .nodeValue)) {
  15622. if (found) {
  15623. children[i].nodeValue = '';
  15624. } else {
  15625. children[i].nodeValue = data[gTextProp];
  15626. found = true;
  15627. }
  15628. }
  15629. }
  15630. if (!found) {
  15631. var textNode = document.createTextNode(data[gTextProp]);
  15632. element.prepend(textNode);
  15633. }
  15634. }
  15635. delete data[gTextProp];
  15636. }
  15637. for (var k in data) {
  15638. element[k] = data[k];
  15639. }
  15640. }
  15641. function getChildElementCount(element) {
  15642. if (element.children) {
  15643. return element.children.length;
  15644. }
  15645. if (typeof element.childElementCount !== 'undefined') {
  15646. return element.childElementCount;
  15647. }
  15648. var count = 0;
  15649. for (var i = 0; i < element.childNodes.length; i++) {
  15650. count += element.nodeType === 1 ? 1 : 0;
  15651. }
  15652. return count;
  15653. }
  15654. function translateFragment(element) {
  15655. element = element || document.documentElement;
  15656. var children = getTranslatableChildren(element);
  15657. var elementCount = children.length;
  15658. for (var i = 0; i < elementCount; i++) {
  15659. translateElement(children[i]);
  15660. }
  15661. translateElement(element);
  15662. }
  15663. return {
  15664. get: function(key, args, fallbackString) {
  15665. var index = key.lastIndexOf('.');
  15666. var prop = gTextProp;
  15667. if (index > 0) {
  15668. prop = key.substring(index + 1);
  15669. key = key.substring(0, index);
  15670. }
  15671. var fallback;
  15672. if (fallbackString) {
  15673. fallback = {};
  15674. fallback[prop] = fallbackString;
  15675. }
  15676. var data = getL10nData(key, args, fallback);
  15677. if (data && prop in data) {
  15678. return data[prop];
  15679. }
  15680. return '{{' + key + '}}';
  15681. },
  15682. getData: function() {
  15683. return gL10nData;
  15684. },
  15685. getText: function() {
  15686. return gTextData;
  15687. },
  15688. getLanguage: function() {
  15689. return gLanguage;
  15690. },
  15691. setLanguage: function(lang, callback) {
  15692. loadLocale(lang, function() {
  15693. if (callback) callback();
  15694. });
  15695. },
  15696. getDirection: function() {
  15697. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15698. var shortCode = gLanguage.split('-', 1)[0];
  15699. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15700. },
  15701. translate: translateFragment,
  15702. getReadyState: function() {
  15703. return gReadyState;
  15704. },
  15705. ready: function(callback) {
  15706. if (!callback) {
  15707. return;
  15708. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15709. window.setTimeout(function() {
  15710. callback();
  15711. });
  15712. } else if (document.addEventListener) {
  15713. document.addEventListener('localized', function once() {
  15714. document.removeEventListener('localized', once);
  15715. callback();
  15716. });
  15717. }
  15718. }
  15719. };
  15720. }(window, document);
  15721. /***/
  15722. }),
  15723. /* 48 */
  15724. /***/
  15725. ((__unused_webpack_module, exports, __webpack_require__) => {
  15726. Object.defineProperty(exports, "__esModule", ({
  15727. value: true
  15728. }));
  15729. exports.GenericScripting = void 0;
  15730. exports.docPropertiesLookup = docPropertiesLookup;
  15731. var _pdfjsLib = __webpack_require__(5);
  15732. async function docPropertiesLookup(pdfDocument) {
  15733. const url = "",
  15734. baseUrl = url.split("#")[0];
  15735. let {
  15736. info,
  15737. metadata,
  15738. contentDispositionFilename,
  15739. contentLength
  15740. } = await pdfDocument.getMetadata();
  15741. if (!contentLength) {
  15742. const {
  15743. length
  15744. } = await pdfDocument.getDownloadInfo();
  15745. contentLength = length;
  15746. }
  15747. return {
  15748. ...info,
  15749. baseURL: baseUrl,
  15750. filesize: contentLength,
  15751. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(
  15752. url),
  15753. metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(),
  15754. authors: metadata === null || metadata === void 0 ? void 0 : metadata.get(
  15755. "dc:creator"),
  15756. numPages: pdfDocument.numPages,
  15757. URL: url
  15758. };
  15759. }
  15760. class GenericScripting {
  15761. constructor(sandboxBundleSrc) {
  15762. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
  15763. return window.pdfjsSandbox.QuickJSSandbox();
  15764. });
  15765. }
  15766. async createSandbox(data) {
  15767. const sandbox = await this._ready;
  15768. sandbox.create(data);
  15769. }
  15770. async dispatchEventInSandbox(event) {
  15771. const sandbox = await this._ready;
  15772. setTimeout(() => sandbox.dispatchEvent(event), 0);
  15773. }
  15774. async destroySandbox() {
  15775. const sandbox = await this._ready;
  15776. sandbox.nukeSandbox();
  15777. }
  15778. }
  15779. exports.GenericScripting = GenericScripting;
  15780. /***/
  15781. }),
  15782. /* 49 */
  15783. /***/
  15784. ((__unused_webpack_module, exports, __webpack_require__) => {
  15785. Object.defineProperty(exports, "__esModule", ({
  15786. value: true
  15787. }));
  15788. exports.PDFPrintService = PDFPrintService;
  15789. var _pdfjsLib = __webpack_require__(5);
  15790. var _app = __webpack_require__(4);
  15791. var _print_utils = __webpack_require__(50);
  15792. let activeService = null;
  15793. let dialog = null;
  15794. let overlayManager = null;
  15795. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution,
  15796. optionalContentConfigPromise, printAnnotationStoragePromise) {
  15797. const scratchCanvas = activeService.scratchCanvas;
  15798. const PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  15799. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15800. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15801. const ctx = scratchCanvas.getContext("2d");
  15802. ctx.save();
  15803. ctx.fillStyle = "rgb(255, 255, 255)";
  15804. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15805. ctx.restore();
  15806. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise])
  15807. .then(function(_ref) {
  15808. let [pdfPage, printAnnotationStorage] = _ref;
  15809. const renderContext = {
  15810. canvasContext: ctx,
  15811. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15812. viewport: pdfPage.getViewport({
  15813. scale: 1,
  15814. rotation: size.rotation
  15815. }),
  15816. intent: "print",
  15817. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  15818. optionalContentConfigPromise,
  15819. printAnnotationStorage
  15820. };
  15821. return pdfPage.render(renderContext).promise;
  15822. });
  15823. }
  15824. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  15825. let optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ?
  15826. arguments[4] : null;
  15827. let printAnnotationStoragePromise = arguments.length > 5 && arguments[5] !== undefined ?
  15828. arguments[5] : null;
  15829. let l10n = arguments.length > 6 ? arguments[6] : undefined;
  15830. this.pdfDocument = pdfDocument;
  15831. this.pagesOverview = pagesOverview;
  15832. this.printContainer = printContainer;
  15833. this._printResolution = printResolution || 150;
  15834. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument
  15835. .getOptionalContentConfig();
  15836. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise
  15837. .resolve();
  15838. this.l10n = l10n;
  15839. this.currentPage = -1;
  15840. this.scratchCanvas = document.createElement("canvas");
  15841. }
  15842. PDFPrintService.prototype = {
  15843. layout() {
  15844. this.throwIfInactive();
  15845. const body = document.querySelector("body");
  15846. body.setAttribute("data-pdfjsprinting", true);
  15847. const hasEqualPageSizes = this.pagesOverview.every(function(size) {
  15848. return size.width === this.pagesOverview[0].width && size.height ===
  15849. this.pagesOverview[0].height;
  15850. }, this);
  15851. if (!hasEqualPageSizes) {
  15852. console.warn("Not all pages have the same size. The printed " +
  15853. "result may be incorrect!");
  15854. }
  15855. this.pageStyleSheet = document.createElement("style");
  15856. const pageSize = this.pagesOverview[0];
  15857. this.pageStyleSheet.textContent = "@page { size: " + pageSize.width + "pt " +
  15858. pageSize.height + "pt;}";
  15859. body.append(this.pageStyleSheet);
  15860. },
  15861. destroy() {
  15862. if (activeService !== this) {
  15863. return;
  15864. }
  15865. this.printContainer.textContent = "";
  15866. const body = document.querySelector("body");
  15867. body.removeAttribute("data-pdfjsprinting");
  15868. if (this.pageStyleSheet) {
  15869. this.pageStyleSheet.remove();
  15870. this.pageStyleSheet = null;
  15871. }
  15872. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15873. this.scratchCanvas = null;
  15874. activeService = null;
  15875. ensureOverlay().then(function() {
  15876. if (overlayManager.active === dialog) {
  15877. overlayManager.close(dialog);
  15878. }
  15879. });
  15880. },
  15881. renderPages() {
  15882. if (this.pdfDocument.isPureXfa) {
  15883. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this
  15884. .pdfDocument);
  15885. return Promise.resolve();
  15886. }
  15887. const pageCount = this.pagesOverview.length;
  15888. const renderNextPage = (resolve, reject) => {
  15889. this.throwIfInactive();
  15890. if (++this.currentPage >= pageCount) {
  15891. renderProgress(pageCount, pageCount, this.l10n);
  15892. resolve();
  15893. return;
  15894. }
  15895. const index = this.currentPage;
  15896. renderProgress(index, pageCount, this.l10n);
  15897. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index],
  15898. this._printResolution, this._optionalContentConfigPromise, this
  15899. ._printAnnotationStoragePromise).then(this.useRenderedPage.bind(
  15900. this)).then(function() {
  15901. renderNextPage(resolve, reject);
  15902. }, reject);
  15903. };
  15904. return new Promise(renderNextPage);
  15905. },
  15906. useRenderedPage() {
  15907. this.throwIfInactive();
  15908. const img = document.createElement("img");
  15909. const scratchCanvas = this.scratchCanvas;
  15910. if ("toBlob" in scratchCanvas) {
  15911. scratchCanvas.toBlob(function(blob) {
  15912. img.src = URL.createObjectURL(blob);
  15913. });
  15914. } else {
  15915. img.src = scratchCanvas.toDataURL();
  15916. }
  15917. const wrapper = document.createElement("div");
  15918. wrapper.className = "printedPage";
  15919. wrapper.append(img);
  15920. this.printContainer.append(wrapper);
  15921. return new Promise(function(resolve, reject) {
  15922. img.onload = resolve;
  15923. img.onerror = reject;
  15924. });
  15925. },
  15926. performPrint() {
  15927. this.throwIfInactive();
  15928. return new Promise(resolve => {
  15929. setTimeout(() => {
  15930. if (!this.active) {
  15931. resolve();
  15932. return;
  15933. }
  15934. print.call(window);
  15935. setTimeout(resolve, 20);
  15936. }, 0);
  15937. });
  15938. },
  15939. get active() {
  15940. return this === activeService;
  15941. },
  15942. throwIfInactive() {
  15943. if (!this.active) {
  15944. throw new Error("This print request was cancelled or completed.");
  15945. }
  15946. }
  15947. };
  15948. const print = window.print;
  15949. window.print = function() {
  15950. if (activeService) {
  15951. console.warn("Ignored window.print() because of a pending print job.");
  15952. return;
  15953. }
  15954. ensureOverlay().then(function() {
  15955. if (activeService) {
  15956. overlayManager.open(dialog);
  15957. }
  15958. });
  15959. try {
  15960. dispatchEvent("beforeprint");
  15961. } finally {
  15962. if (!activeService) {
  15963. console.error("Expected print service to be initialized.");
  15964. ensureOverlay().then(function() {
  15965. if (overlayManager.active === dialog) {
  15966. overlayManager.close(dialog);
  15967. }
  15968. });
  15969. return;
  15970. }
  15971. const activeServiceOnEntry = activeService;
  15972. activeService.renderPages().then(function() {
  15973. return activeServiceOnEntry.performPrint();
  15974. }).catch(function() {}).then(function() {
  15975. if (activeServiceOnEntry.active) {
  15976. abort();
  15977. }
  15978. });
  15979. }
  15980. };
  15981. function dispatchEvent(eventType) {
  15982. const event = document.createEvent("CustomEvent");
  15983. event.initCustomEvent(eventType, false, false, "custom");
  15984. window.dispatchEvent(event);
  15985. }
  15986. function abort() {
  15987. if (activeService) {
  15988. activeService.destroy();
  15989. dispatchEvent("afterprint");
  15990. }
  15991. }
  15992. function renderProgress(index, total, l10n) {
  15993. dialog || (dialog = document.getElementById("printServiceDialog"));
  15994. const progress = Math.round(100 * index / total);
  15995. const progressBar = dialog.querySelector("progress");
  15996. const progressPerc = dialog.querySelector(".relative-progress");
  15997. progressBar.value = progress;
  15998. l10n.get("print_progress_percent", {
  15999. progress
  16000. }).then(msg => {
  16001. progressPerc.textContent = msg;
  16002. });
  16003. }
  16004. window.addEventListener("keydown", function(event) {
  16005. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey &&
  16006. (!event.shiftKey || window.chrome || window.opera)) {
  16007. window.print();
  16008. event.preventDefault();
  16009. if (event.stopImmediatePropagation) {
  16010. event.stopImmediatePropagation();
  16011. } else {
  16012. event.stopPropagation();
  16013. }
  16014. }
  16015. }, true);
  16016. if ("onbeforeprint" in window) {
  16017. const stopPropagationIfNeeded = function(event) {
  16018. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  16019. event.stopImmediatePropagation();
  16020. }
  16021. };
  16022. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  16023. window.addEventListener("afterprint", stopPropagationIfNeeded);
  16024. }
  16025. let overlayPromise;
  16026. function ensureOverlay() {
  16027. if (!overlayPromise) {
  16028. overlayManager = _app.PDFViewerApplication.overlayManager;
  16029. if (!overlayManager) {
  16030. throw new Error("The overlay manager has not yet been initialized.");
  16031. }
  16032. dialog || (dialog = document.getElementById("printServiceDialog"));
  16033. overlayPromise = overlayManager.register(dialog, true);
  16034. document.getElementById("printCancel").onclick = abort;
  16035. dialog.addEventListener("close", abort);
  16036. }
  16037. return overlayPromise;
  16038. }
  16039. _app.PDFPrintServiceFactory.instance = {
  16040. supportsPrinting: true,
  16041. createPrintService(pdfDocument, pagesOverview, printContainer, printResolution,
  16042. optionalContentConfigPromise, printAnnotationStoragePromise, l10n) {
  16043. if (activeService) {
  16044. throw new Error("The print service is created and active.");
  16045. }
  16046. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer,
  16047. printResolution, optionalContentConfigPromise,
  16048. printAnnotationStoragePromise, l10n);
  16049. return activeService;
  16050. }
  16051. };
  16052. /***/
  16053. }),
  16054. /* 50 */
  16055. /***/
  16056. ((__unused_webpack_module, exports, __webpack_require__) => {
  16057. Object.defineProperty(exports, "__esModule", ({
  16058. value: true
  16059. }));
  16060. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  16061. var _pdfjsLib = __webpack_require__(5);
  16062. var _pdf_link_service = __webpack_require__(3);
  16063. var _xfa_layer_builder = __webpack_require__(39);
  16064. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  16065. const xfaHtml = pdfDocument.allXfaHtml;
  16066. const linkService = new _pdf_link_service.SimpleLinkService();
  16067. const scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  16068. for (const xfaPage of xfaHtml.children) {
  16069. const page = document.createElement("div");
  16070. page.className = "xfaPrintedPage";
  16071. printContainer.append(page);
  16072. const builder = new _xfa_layer_builder.XfaLayerBuilder({
  16073. pageDiv: page,
  16074. pdfPage: null,
  16075. annotationStorage: pdfDocument.annotationStorage,
  16076. linkService,
  16077. xfaHtml: xfaPage
  16078. });
  16079. const viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  16080. scale
  16081. });
  16082. builder.render(viewport, "print");
  16083. }
  16084. }
  16085. /***/
  16086. })
  16087. /******/
  16088. ]);
  16089. /************************************************************************/
  16090. /******/ // The module cache
  16091. /******/
  16092. var __webpack_module_cache__ = {};
  16093. /******/
  16094. /******/ // The require function
  16095. /******/
  16096. function __webpack_require__(moduleId) {
  16097. /******/ // Check if module is in cache
  16098. /******/
  16099. var cachedModule = __webpack_module_cache__[moduleId];
  16100. /******/
  16101. if (cachedModule !== undefined) {
  16102. /******/
  16103. return cachedModule.exports;
  16104. /******/
  16105. }
  16106. /******/ // Create a new module (and put it into the cache)
  16107. /******/
  16108. var module = __webpack_module_cache__[moduleId] = {
  16109. /******/ // no module.id needed
  16110. /******/ // no module.loaded needed
  16111. /******/
  16112. exports: {}
  16113. /******/
  16114. };
  16115. /******/
  16116. /******/ // Execute the module function
  16117. /******/
  16118. __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  16119. /******/
  16120. /******/ // Return the exports of the module
  16121. /******/
  16122. return module.exports;
  16123. /******/
  16124. }
  16125. /******/
  16126. /************************************************************************/
  16127. var __webpack_exports__ = {};
  16128. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  16129. (() => {
  16130. var exports = __webpack_exports__;
  16131. Object.defineProperty(exports, "__esModule", ({
  16132. value: true
  16133. }));
  16134. Object.defineProperty(exports, "PDFViewerApplication", ({
  16135. enumerable: true,
  16136. get: function() {
  16137. return _app.PDFViewerApplication;
  16138. }
  16139. }));
  16140. exports.PDFViewerApplicationConstants = void 0;
  16141. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  16142. enumerable: true,
  16143. get: function() {
  16144. return _app_options.AppOptions;
  16145. }
  16146. }));
  16147. var _ui_utils = __webpack_require__(1);
  16148. var _app_options = __webpack_require__(2);
  16149. var _pdf_link_service = __webpack_require__(3);
  16150. var _app = __webpack_require__(4);
  16151. var _document$blockUnbloc, _document;
  16152. const pdfjsVersion = '2.16.105';
  16153. const pdfjsBuild = '172ccdbe5';
  16154. const AppConstants = {
  16155. LinkTarget: _pdf_link_service.LinkTarget,
  16156. RenderingStates: _ui_utils.RenderingStates,
  16157. ScrollMode: _ui_utils.ScrollMode,
  16158. SpreadMode: _ui_utils.SpreadMode
  16159. };
  16160. exports.PDFViewerApplicationConstants = AppConstants;
  16161. window.PDFViewerApplication = _app.PDFViewerApplication;
  16162. window.PDFViewerApplicationConstants = AppConstants;
  16163. window.PDFViewerApplicationOptions = _app_options.AppOptions;;; {
  16164. __webpack_require__(43);
  16165. }; {
  16166. __webpack_require__(49);
  16167. }
  16168. function getViewerConfiguration() {
  16169. let errorWrapper = null;
  16170. errorWrapper = {
  16171. container: document.getElementById("errorWrapper"),
  16172. errorMessage: document.getElementById("errorMessage"),
  16173. closeButton: document.getElementById("errorClose"),
  16174. errorMoreInfo: document.getElementById("errorMoreInfo"),
  16175. moreInfoButton: document.getElementById("errorShowMore"),
  16176. lessInfoButton: document.getElementById("errorShowLess")
  16177. };
  16178. return {
  16179. appContainer: document.body,
  16180. mainContainer: document.getElementById("viewerContainer"),
  16181. viewerContainer: document.getElementById("viewer"),
  16182. toolbar: {
  16183. container: document.getElementById("toolbarViewer"),
  16184. numPages: document.getElementById("numPages"),
  16185. pageNumber: document.getElementById("pageNumber"),
  16186. scaleSelect: document.getElementById("scaleSelect"),
  16187. customScaleOption: document.getElementById("customScaleOption"),
  16188. previous: document.getElementById("previous"),
  16189. next: document.getElementById("next"),
  16190. zoomIn: document.getElementById("zoomIn"),
  16191. zoomOut: document.getElementById("zoomOut"),
  16192. viewFind: document.getElementById("viewFind"),
  16193. openFile: document.getElementById("openFile"),
  16194. print: document.getElementById("print"),
  16195. editorFreeTextButton: document.getElementById("editorFreeText"),
  16196. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  16197. editorInkButton: document.getElementById("editorInk"),
  16198. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  16199. presentationModeButton: document.getElementById("presentationMode"),
  16200. download: document.getElementById("download"),
  16201. viewBookmark: document.getElementById("viewBookmark")
  16202. },
  16203. secondaryToolbar: {
  16204. toolbar: document.getElementById("secondaryToolbar"),
  16205. toggleButton: document.getElementById("secondaryToolbarToggle"),
  16206. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  16207. openFileButton: document.getElementById("secondaryOpenFile"),
  16208. printButton: document.getElementById("secondaryPrint"),
  16209. downloadButton: document.getElementById("secondaryDownload"),
  16210. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  16211. firstPageButton: document.getElementById("firstPage"),
  16212. lastPageButton: document.getElementById("lastPage"),
  16213. pageRotateCwButton: document.getElementById("pageRotateCw"),
  16214. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  16215. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  16216. cursorHandToolButton: document.getElementById("cursorHandTool"),
  16217. scrollPageButton: document.getElementById("scrollPage"),
  16218. scrollVerticalButton: document.getElementById("scrollVertical"),
  16219. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  16220. scrollWrappedButton: document.getElementById("scrollWrapped"),
  16221. spreadNoneButton: document.getElementById("spreadNone"),
  16222. spreadOddButton: document.getElementById("spreadOdd"),
  16223. spreadEvenButton: document.getElementById("spreadEven"),
  16224. documentPropertiesButton: document.getElementById("documentProperties")
  16225. },
  16226. sidebar: {
  16227. outerContainer: document.getElementById("outerContainer"),
  16228. sidebarContainer: document.getElementById("sidebarContainer"),
  16229. toggleButton: document.getElementById("sidebarToggle"),
  16230. thumbnailButton: document.getElementById("viewThumbnail"),
  16231. outlineButton: document.getElementById("viewOutline"),
  16232. attachmentsButton: document.getElementById("viewAttachments"),
  16233. layersButton: document.getElementById("viewLayers"),
  16234. thumbnailView: document.getElementById("thumbnailView"),
  16235. outlineView: document.getElementById("outlineView"),
  16236. attachmentsView: document.getElementById("attachmentsView"),
  16237. layersView: document.getElementById("layersView"),
  16238. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  16239. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  16240. },
  16241. sidebarResizer: {
  16242. outerContainer: document.getElementById("outerContainer"),
  16243. resizer: document.getElementById("sidebarResizer")
  16244. },
  16245. findBar: {
  16246. bar: document.getElementById("findbar"),
  16247. toggleButton: document.getElementById("viewFind"),
  16248. findField: document.getElementById("findInput"),
  16249. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  16250. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  16251. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  16252. entireWordCheckbox: document.getElementById("findEntireWord"),
  16253. findMsg: document.getElementById("findMsg"),
  16254. findResultsCount: document.getElementById("findResultsCount"),
  16255. findPreviousButton: document.getElementById("findPrevious"),
  16256. findNextButton: document.getElementById("findNext")
  16257. },
  16258. passwordOverlay: {
  16259. dialog: document.getElementById("passwordDialog"),
  16260. label: document.getElementById("passwordText"),
  16261. input: document.getElementById("password"),
  16262. submitButton: document.getElementById("passwordSubmit"),
  16263. cancelButton: document.getElementById("passwordCancel")
  16264. },
  16265. documentProperties: {
  16266. dialog: document.getElementById("documentPropertiesDialog"),
  16267. closeButton: document.getElementById("documentPropertiesClose"),
  16268. fields: {
  16269. fileName: document.getElementById("fileNameField"),
  16270. fileSize: document.getElementById("fileSizeField"),
  16271. title: document.getElementById("titleField"),
  16272. author: document.getElementById("authorField"),
  16273. subject: document.getElementById("subjectField"),
  16274. keywords: document.getElementById("keywordsField"),
  16275. creationDate: document.getElementById("creationDateField"),
  16276. modificationDate: document.getElementById("modificationDateField"),
  16277. creator: document.getElementById("creatorField"),
  16278. producer: document.getElementById("producerField"),
  16279. version: document.getElementById("versionField"),
  16280. pageCount: document.getElementById("pageCountField"),
  16281. pageSize: document.getElementById("pageSizeField"),
  16282. linearized: document.getElementById("linearizedField")
  16283. }
  16284. },
  16285. annotationEditorParams: {
  16286. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  16287. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  16288. editorInkColor: document.getElementById("editorInkColor"),
  16289. editorInkThickness: document.getElementById("editorInkThickness"),
  16290. editorInkOpacity: document.getElementById("editorInkOpacity")
  16291. },
  16292. errorWrapper,
  16293. printContainer: document.getElementById("printContainer"),
  16294. openFileInput: document.getElementById("fileInput"),
  16295. debuggerScriptPath: "./debugger.js"
  16296. };
  16297. }
  16298. function webViewerLoad() {
  16299. const config = getViewerConfiguration();
  16300. const event = document.createEvent("CustomEvent");
  16301. event.initCustomEvent("webviewerloaded", true, true, {
  16302. source: window
  16303. });
  16304. try {
  16305. parent.document.dispatchEvent(event);
  16306. } catch (ex) {
  16307. console.error(`webviewerloaded: ${ex}`);
  16308. document.dispatchEvent(event);
  16309. }
  16310. _app.PDFViewerApplication.run(config);
  16311. }
  16312. (_document$blockUnbloc = (_document = document).blockUnblockOnload) === null ||
  16313. _document$blockUnbloc === void 0 ? void 0 : _document$blockUnbloc.call(_document, true);
  16314. if (document.readyState === "interactive" || document.readyState === "complete") {
  16315. webViewerLoad();
  16316. } else {
  16317. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  16318. }
  16319. })();
  16320. /******/
  16321. })();
  16322. //# sourceMappingURL=viewer.js.map